macros: deleted macros SECONDS(), MSEC(), USEC()
Changed everywhere these macros to the K_MSEC(), K_SECONDS() Signed-off-by: Maksim Masalski <maxxliferobot@gmail.com>
This commit is contained in:
parent
b1944bc669
commit
b324f35e61
8 changed files with 33 additions and 45 deletions
|
@ -213,17 +213,6 @@ struct _timeout {
|
||||||
_timeout_func_t fn;
|
_timeout_func_t fn;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
|
||||||
* Number of ticks for x seconds. NOTE: With MSEC() or USEC(),
|
|
||||||
* since it does an integer division, x must be greater or equal to
|
|
||||||
* 1000/CONFIG_SYS_CLOCK_TICKS_PER_SEC to get a non-zero value.
|
|
||||||
* You may want to raise CONFIG_SYS_CLOCK_TICKS_PER_SEC depending on
|
|
||||||
* your requirements.
|
|
||||||
*/
|
|
||||||
#define SECONDS(x) ((x) * CONFIG_SYS_CLOCK_TICKS_PER_SEC)
|
|
||||||
#define MSEC(x) (SECONDS(x) / MSEC_PER_SEC)
|
|
||||||
#define USEC(x) (MSEC(x) / USEC_PER_MSEC)
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -104,6 +104,6 @@ void main(void)
|
||||||
toggle = 1;
|
toggle = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
k_sleep(SECONDS(2));
|
k_sleep(K_SECONDS(2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ LOG_MODULE_DECLARE(net_gptp, CONFIG_NET_GPTP_LOG_LEVEL);
|
||||||
#include "gptp_md.h"
|
#include "gptp_md.h"
|
||||||
#include "gptp_private.h"
|
#include "gptp_private.h"
|
||||||
|
|
||||||
#define NET_BUF_TIMEOUT MSEC(100)
|
#define NET_BUF_TIMEOUT K_MSEC(100)
|
||||||
|
|
||||||
static struct net_if_timestamp_cb sync_timestamp_cb;
|
static struct net_if_timestamp_cb sync_timestamp_cb;
|
||||||
static struct net_if_timestamp_cb pdelay_response_timestamp_cb;
|
static struct net_if_timestamp_cb pdelay_response_timestamp_cb;
|
||||||
|
|
|
@ -158,7 +158,7 @@ void test_kobject_revoke_access(void *p1, void *p2, void *p3)
|
||||||
0, K_INHERIT_PERMS | K_USER, K_NO_WAIT);
|
0, K_INHERIT_PERMS | K_USER, K_NO_WAIT);
|
||||||
|
|
||||||
|
|
||||||
k_sem_take(&sync_sem, MSEC(100));
|
k_sem_take(&sync_sem, K_MSEC(100));
|
||||||
k_object_access_revoke(&kobject_sem, k_current_get());
|
k_object_access_revoke(&kobject_sem, k_current_get());
|
||||||
|
|
||||||
k_thread_create(&kobject_test_4_tid,
|
k_thread_create(&kobject_test_4_tid,
|
||||||
|
@ -215,7 +215,7 @@ void test_kobject_grant_access_kobj(void *p1, void *p2, void *p3)
|
||||||
0, K_INHERIT_PERMS | K_USER, K_NO_WAIT);
|
0, K_INHERIT_PERMS | K_USER, K_NO_WAIT);
|
||||||
|
|
||||||
|
|
||||||
k_sem_take(&sync_sem, MSEC(100));
|
k_sem_take(&sync_sem, K_MSEC(100));
|
||||||
|
|
||||||
k_thread_create(&kobject_test_reuse_2_tid,
|
k_thread_create(&kobject_test_reuse_2_tid,
|
||||||
kobject_stack_2,
|
kobject_stack_2,
|
||||||
|
@ -346,7 +346,7 @@ void test_kobject_access_all_grant(void *p1, void *p2, void *p3)
|
||||||
NULL, NULL, NULL,
|
NULL, NULL, NULL,
|
||||||
0, K_USER, K_NO_WAIT);
|
0, K_USER, K_NO_WAIT);
|
||||||
|
|
||||||
k_sem_take(&sync_sem, MSEC(100));
|
k_sem_take(&sync_sem, K_MSEC(100));
|
||||||
|
|
||||||
k_thread_create(&kobject_test_reuse_2_tid,
|
k_thread_create(&kobject_test_reuse_2_tid,
|
||||||
kobject_stack_4,
|
kobject_stack_4,
|
||||||
|
@ -405,7 +405,7 @@ void test_thread_has_residual_permissions(void *p1, void *p2, void *p3)
|
||||||
0, K_INHERIT_PERMS | K_USER, K_NO_WAIT);
|
0, K_INHERIT_PERMS | K_USER, K_NO_WAIT);
|
||||||
|
|
||||||
|
|
||||||
k_sem_take(&sync_sem, MSEC(100));
|
k_sem_take(&sync_sem, K_MSEC(100));
|
||||||
|
|
||||||
k_thread_create(&kobject_test_9_tid,
|
k_thread_create(&kobject_test_9_tid,
|
||||||
kobject_stack_1,
|
kobject_stack_1,
|
||||||
|
@ -956,4 +956,3 @@ void test_create_new_invalid_prio_thread_from_user(void *p1, void *p2, void *p3)
|
||||||
k_sem_take(&sync_sem, SYNC_SEM_TIMEOUT);
|
k_sem_take(&sync_sem, SYNC_SEM_TIMEOUT);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -524,7 +524,7 @@ void test_mem_domain_remove_partitions(void *p1, void *p2, void *p3)
|
||||||
10, K_USER | K_INHERIT_PERMS, K_NO_WAIT);
|
10, K_USER | K_INHERIT_PERMS, K_NO_WAIT);
|
||||||
|
|
||||||
|
|
||||||
k_sem_take(&sync_sem, MSEC(100));
|
k_sem_take(&sync_sem, K_MSEC(100));
|
||||||
|
|
||||||
k_mem_domain_remove_partition(&mem_domain_tc3_mem_domain,
|
k_mem_domain_remove_partition(&mem_domain_tc3_mem_domain,
|
||||||
&mem_domain_tc3_part2_struct);
|
&mem_domain_tc3_part2_struct);
|
||||||
|
|
|
@ -40,8 +40,8 @@ ZTEST_BMEM u8_t rx_buffer[PIPE_SIZE];
|
||||||
#define ALL_BYTES (sizeof(tx_buffer))
|
#define ALL_BYTES (sizeof(tx_buffer))
|
||||||
|
|
||||||
#define RETURN_SUCCESS (0)
|
#define RETURN_SUCCESS (0)
|
||||||
#define TIMEOUT_VAL (MSEC(10))
|
#define TIMEOUT_VAL (K_MSEC(10))
|
||||||
#define TIMEOUT_200MSEC (MSEC(200))
|
#define TIMEOUT_200MSEC (K_MSEC(200))
|
||||||
|
|
||||||
/* encompasing structs */
|
/* encompasing structs */
|
||||||
struct pipe_sequence {
|
struct pipe_sequence {
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#define sem_give_from_isr(sema) irq_offload(isr_sem_give, sema)
|
#define sem_give_from_isr(sema) irq_offload(isr_sem_give, sema)
|
||||||
#define sem_take_from_isr(sema) irq_offload(isr_sem_take, sema)
|
#define sem_take_from_isr(sema) irq_offload(isr_sem_take, sema)
|
||||||
|
|
||||||
#define SEM_TIMEOUT (MSEC(100))
|
#define SEM_TIMEOUT (K_MSEC(100))
|
||||||
#define STACK_SIZE (1024 + CONFIG_TEST_EXTRA_STACKSIZE)
|
#define STACK_SIZE (1024 + CONFIG_TEST_EXTRA_STACKSIZE)
|
||||||
#define TOTAL_THREADS_WAITING (5)
|
#define TOTAL_THREADS_WAITING (5)
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ void sem_give_task(void *p1, void *p2, void *p3)
|
||||||
|
|
||||||
void sem_take_timeout_forever_helper(void *p1, void *p2, void *p3)
|
void sem_take_timeout_forever_helper(void *p1, void *p2, void *p3)
|
||||||
{
|
{
|
||||||
k_sleep(MSEC(100));
|
k_sleep(K_MSEC(100));
|
||||||
k_sem_give(&simple_sem);
|
k_sem_give(&simple_sem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,17 +363,17 @@ void test_sem_take_multiple(void)
|
||||||
|
|
||||||
|
|
||||||
/* time for those 3 threads to complete */
|
/* time for those 3 threads to complete */
|
||||||
k_sleep(MSEC(20));
|
k_sleep(K_MSEC(20));
|
||||||
|
|
||||||
/* Let these threads proceed to take the multiple_sem */
|
/* Let these threads proceed to take the multiple_sem */
|
||||||
k_sem_give(&high_prio_sem);
|
k_sem_give(&high_prio_sem);
|
||||||
k_sem_give(&mid_prio_sem);
|
k_sem_give(&mid_prio_sem);
|
||||||
k_sem_give(&low_prio_sem);
|
k_sem_give(&low_prio_sem);
|
||||||
k_sleep(MSEC(200));
|
k_sleep(K_MSEC(200));
|
||||||
|
|
||||||
/* enable the higher priority thread to run. */
|
/* enable the higher priority thread to run. */
|
||||||
k_sem_give(&multiple_thread_sem);
|
k_sem_give(&multiple_thread_sem);
|
||||||
k_sleep(MSEC(200));
|
k_sleep(K_MSEC(200));
|
||||||
/* check which threads completed. */
|
/* check which threads completed. */
|
||||||
signal_count = k_sem_count_get(&high_prio_sem);
|
signal_count = k_sem_count_get(&high_prio_sem);
|
||||||
zassert_true(signal_count == 1,
|
zassert_true(signal_count == 1,
|
||||||
|
@ -389,7 +389,7 @@ void test_sem_take_multiple(void)
|
||||||
|
|
||||||
/* enable the Medium priority thread to run. */
|
/* enable the Medium priority thread to run. */
|
||||||
k_sem_give(&multiple_thread_sem);
|
k_sem_give(&multiple_thread_sem);
|
||||||
k_sleep(MSEC(200));
|
k_sleep(K_MSEC(200));
|
||||||
/* check which threads completed. */
|
/* check which threads completed. */
|
||||||
signal_count = k_sem_count_get(&high_prio_sem);
|
signal_count = k_sem_count_get(&high_prio_sem);
|
||||||
zassert_true(signal_count == 1,
|
zassert_true(signal_count == 1,
|
||||||
|
@ -405,7 +405,7 @@ void test_sem_take_multiple(void)
|
||||||
|
|
||||||
/* enable the low priority thread to run. */
|
/* enable the low priority thread to run. */
|
||||||
k_sem_give(&multiple_thread_sem);
|
k_sem_give(&multiple_thread_sem);
|
||||||
k_sleep(MSEC(200));
|
k_sleep(K_MSEC(200));
|
||||||
/* check which threads completed. */
|
/* check which threads completed. */
|
||||||
signal_count = k_sem_count_get(&high_prio_sem);
|
signal_count = k_sem_count_get(&high_prio_sem);
|
||||||
zassert_true(signal_count == 1,
|
zassert_true(signal_count == 1,
|
||||||
|
@ -492,7 +492,7 @@ void test_sem_multiple_threads_wait(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* giving time for the other threads to execute */
|
/* giving time for the other threads to execute */
|
||||||
k_sleep(MSEC(500));
|
k_sleep(K_MSEC(500));
|
||||||
|
|
||||||
/* Give the semaphores */
|
/* Give the semaphores */
|
||||||
for (int i = 0; i < TOTAL_THREADS_WAITING; i++) {
|
for (int i = 0; i < TOTAL_THREADS_WAITING; i++) {
|
||||||
|
@ -500,7 +500,7 @@ void test_sem_multiple_threads_wait(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* giving time for the other threads to execute */
|
/* giving time for the other threads to execute */
|
||||||
k_sleep(MSEC(500));
|
k_sleep(K_MSEC(500));
|
||||||
|
|
||||||
/* check if all the threads are done. */
|
/* check if all the threads are done. */
|
||||||
for (int i = 0; i < TOTAL_THREADS_WAITING; i++) {
|
for (int i = 0; i < TOTAL_THREADS_WAITING; i++) {
|
||||||
|
@ -542,16 +542,16 @@ void test_sem_measure_timeouts(void)
|
||||||
/* With timeout of 1 sec */
|
/* With timeout of 1 sec */
|
||||||
start_ticks = k_uptime_get();
|
start_ticks = k_uptime_get();
|
||||||
|
|
||||||
ret_value = k_sem_take(&simple_sem, SECONDS(1));
|
ret_value = k_sem_take(&simple_sem, K_SECONDS(1));
|
||||||
|
|
||||||
end_ticks = k_uptime_get();
|
end_ticks = k_uptime_get();
|
||||||
|
|
||||||
zassert_true(ret_value == -EAGAIN,
|
zassert_true(ret_value == -EAGAIN,
|
||||||
"k_sem_take failed when its shouldn't have");
|
"k_sem_take failed when its shouldn't have");
|
||||||
|
|
||||||
zassert_true((end_ticks - start_ticks >= SECONDS(1)),
|
zassert_true((end_ticks - start_ticks >= K_SECONDS(1)),
|
||||||
"time missmatch expected %d ,got %d\n",
|
"time missmatch expected %d ,got %d\n",
|
||||||
SECONDS(1), end_ticks - start_ticks);
|
K_SECONDS(1), end_ticks - start_ticks);
|
||||||
|
|
||||||
/* With 0 as the timeout */
|
/* With 0 as the timeout */
|
||||||
start_ticks = k_uptime_get();
|
start_ticks = k_uptime_get();
|
||||||
|
@ -606,16 +606,16 @@ void test_sem_measure_timeout_from_thread(void)
|
||||||
/* With timeout of 1 sec */
|
/* With timeout of 1 sec */
|
||||||
start_ticks = k_uptime_get();
|
start_ticks = k_uptime_get();
|
||||||
|
|
||||||
ret_value = k_sem_take(&multiple_thread_sem, SECONDS(1));
|
ret_value = k_sem_take(&multiple_thread_sem, K_SECONDS(1));
|
||||||
|
|
||||||
end_ticks = k_uptime_get();
|
end_ticks = k_uptime_get();
|
||||||
|
|
||||||
zassert_true(ret_value == 0,
|
zassert_true(ret_value == 0,
|
||||||
"k_sem_take failed when its shouldn't have");
|
"k_sem_take failed when its shouldn't have");
|
||||||
|
|
||||||
zassert_true((end_ticks - start_ticks <= SECONDS(1)),
|
zassert_true((end_ticks - start_ticks <= K_SECONDS(1)),
|
||||||
"time missmatch. expected less than%d ,got %d\n",
|
"time missmatch. expected less than%d ,got %d\n",
|
||||||
SECONDS(1), end_ticks - start_ticks);
|
K_SECONDS(1), end_ticks - start_ticks);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -661,14 +661,14 @@ void test_sem_multiple_take_and_timeouts(void)
|
||||||
k_thread_create(&multiple_tid[i],
|
k_thread_create(&multiple_tid[i],
|
||||||
multiple_stack[i], STACK_SIZE,
|
multiple_stack[i], STACK_SIZE,
|
||||||
test_sem_multiple_take_and_timeouts_helper,
|
test_sem_multiple_take_and_timeouts_helper,
|
||||||
(void *)SECONDS(i + 1), NULL, NULL,
|
(void *)K_SECONDS(i + 1), NULL, NULL,
|
||||||
K_PRIO_PREEMPT(1), 0, K_NO_WAIT);
|
K_PRIO_PREEMPT(1), 0, K_NO_WAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < TOTAL_THREADS_WAITING; i++) {
|
for (int i = 0; i < TOTAL_THREADS_WAITING; i++) {
|
||||||
k_pipe_get(&timeout_info_pipe, &timeout, sizeof(int),
|
k_pipe_get(&timeout_info_pipe, &timeout, sizeof(int),
|
||||||
&bytes_read, sizeof(int), K_FOREVER);
|
&bytes_read, sizeof(int), K_FOREVER);
|
||||||
zassert_true(timeout == SECONDS(i + 1),
|
zassert_true(timeout == K_SECONDS(i + 1),
|
||||||
"timeout didn't occur properly");
|
"timeout didn't occur properly");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -716,11 +716,11 @@ void test_sem_multi_take_timeout_diff_sem(void)
|
||||||
{
|
{
|
||||||
size_t bytes_read;
|
size_t bytes_read;
|
||||||
struct timeout_info seq_info[] = {
|
struct timeout_info seq_info[] = {
|
||||||
{ SECONDS(2), &simple_sem },
|
{ K_SECONDS(2), &simple_sem },
|
||||||
{ SECONDS(1), &multiple_thread_sem },
|
{ K_SECONDS(1), &multiple_thread_sem },
|
||||||
{ SECONDS(3), &simple_sem },
|
{ K_SECONDS(3), &simple_sem },
|
||||||
{ SECONDS(5), &multiple_thread_sem },
|
{ K_SECONDS(5), &multiple_thread_sem },
|
||||||
{ SECONDS(4), &simple_sem },
|
{ K_SECONDS(4), &simple_sem },
|
||||||
};
|
};
|
||||||
|
|
||||||
struct timeout_info retrieved_info;
|
struct timeout_info retrieved_info;
|
||||||
|
@ -751,7 +751,7 @@ void test_sem_multi_take_timeout_diff_sem(void)
|
||||||
K_FOREVER);
|
K_FOREVER);
|
||||||
|
|
||||||
|
|
||||||
zassert_true(retrieved_info.timeout == SECONDS(i + 1),
|
zassert_true(retrieved_info.timeout == K_SECONDS(i + 1),
|
||||||
"timeout didn't occur properly");
|
"timeout didn't occur properly");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
#include <ztest.h>
|
#include <ztest.h>
|
||||||
|
|
||||||
#define TEST_TIMEOUT SECONDS(1)
|
#define TEST_TIMEOUT K_SECONDS(1)
|
||||||
|
|
||||||
struct bt_data {
|
struct bt_data {
|
||||||
void *hci_sync;
|
void *hci_sync;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue