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:
Maksim Masalski 2019-02-27 22:26:39 +03:00 committed by Anas Nashif
parent b1944bc669
commit b324f35e61
8 changed files with 33 additions and 45 deletions

View file

@ -213,17 +213,6 @@ struct _timeout {
_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
}
#endif

View file

@ -104,6 +104,6 @@ void main(void)
toggle = 1;
}
k_sleep(SECONDS(2));
k_sleep(K_SECONDS(2));
}
}

View file

@ -14,7 +14,7 @@ LOG_MODULE_DECLARE(net_gptp, CONFIG_NET_GPTP_LOG_LEVEL);
#include "gptp_md.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 pdelay_response_timestamp_cb;

View file

@ -158,7 +158,7 @@ void test_kobject_revoke_access(void *p1, void *p2, void *p3)
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_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);
k_sem_take(&sync_sem, MSEC(100));
k_sem_take(&sync_sem, K_MSEC(100));
k_thread_create(&kobject_test_reuse_2_tid,
kobject_stack_2,
@ -346,7 +346,7 @@ void test_kobject_access_all_grant(void *p1, void *p2, void *p3)
NULL, NULL, NULL,
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,
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);
k_sem_take(&sync_sem, MSEC(100));
k_sem_take(&sync_sem, K_MSEC(100));
k_thread_create(&kobject_test_9_tid,
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);
}

View file

@ -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);
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,
&mem_domain_tc3_part2_struct);

View file

@ -40,8 +40,8 @@ ZTEST_BMEM u8_t rx_buffer[PIPE_SIZE];
#define ALL_BYTES (sizeof(tx_buffer))
#define RETURN_SUCCESS (0)
#define TIMEOUT_VAL (MSEC(10))
#define TIMEOUT_200MSEC (MSEC(200))
#define TIMEOUT_VAL (K_MSEC(10))
#define TIMEOUT_200MSEC (K_MSEC(200))
/* encompasing structs */
struct pipe_sequence {

View file

@ -14,7 +14,7 @@
#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_TIMEOUT (MSEC(100))
#define SEM_TIMEOUT (K_MSEC(100))
#define STACK_SIZE (1024 + CONFIG_TEST_EXTRA_STACKSIZE)
#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)
{
k_sleep(MSEC(100));
k_sleep(K_MSEC(100));
k_sem_give(&simple_sem);
}
@ -363,17 +363,17 @@ void test_sem_take_multiple(void)
/* 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 */
k_sem_give(&high_prio_sem);
k_sem_give(&mid_prio_sem);
k_sem_give(&low_prio_sem);
k_sleep(MSEC(200));
k_sleep(K_MSEC(200));
/* enable the higher priority thread to run. */
k_sem_give(&multiple_thread_sem);
k_sleep(MSEC(200));
k_sleep(K_MSEC(200));
/* check which threads completed. */
signal_count = k_sem_count_get(&high_prio_sem);
zassert_true(signal_count == 1,
@ -389,7 +389,7 @@ void test_sem_take_multiple(void)
/* enable the Medium priority thread to run. */
k_sem_give(&multiple_thread_sem);
k_sleep(MSEC(200));
k_sleep(K_MSEC(200));
/* check which threads completed. */
signal_count = k_sem_count_get(&high_prio_sem);
zassert_true(signal_count == 1,
@ -405,7 +405,7 @@ void test_sem_take_multiple(void)
/* enable the low priority thread to run. */
k_sem_give(&multiple_thread_sem);
k_sleep(MSEC(200));
k_sleep(K_MSEC(200));
/* check which threads completed. */
signal_count = k_sem_count_get(&high_prio_sem);
zassert_true(signal_count == 1,
@ -492,7 +492,7 @@ void test_sem_multiple_threads_wait(void)
}
/* giving time for the other threads to execute */
k_sleep(MSEC(500));
k_sleep(K_MSEC(500));
/* Give the semaphores */
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 */
k_sleep(MSEC(500));
k_sleep(K_MSEC(500));
/* check if all the threads are done. */
for (int i = 0; i < TOTAL_THREADS_WAITING; i++) {
@ -542,16 +542,16 @@ void test_sem_measure_timeouts(void)
/* With timeout of 1 sec */
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();
zassert_true(ret_value == -EAGAIN,
"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",
SECONDS(1), end_ticks - start_ticks);
K_SECONDS(1), end_ticks - start_ticks);
/* With 0 as the timeout */
start_ticks = k_uptime_get();
@ -606,16 +606,16 @@ void test_sem_measure_timeout_from_thread(void)
/* With timeout of 1 sec */
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();
zassert_true(ret_value == 0,
"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",
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],
multiple_stack[i], STACK_SIZE,
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);
}
for (int i = 0; i < TOTAL_THREADS_WAITING; i++) {
k_pipe_get(&timeout_info_pipe, &timeout, sizeof(int),
&bytes_read, sizeof(int), K_FOREVER);
zassert_true(timeout == SECONDS(i + 1),
zassert_true(timeout == K_SECONDS(i + 1),
"timeout didn't occur properly");
}
@ -716,11 +716,11 @@ void test_sem_multi_take_timeout_diff_sem(void)
{
size_t bytes_read;
struct timeout_info seq_info[] = {
{ SECONDS(2), &simple_sem },
{ SECONDS(1), &multiple_thread_sem },
{ SECONDS(3), &simple_sem },
{ SECONDS(5), &multiple_thread_sem },
{ SECONDS(4), &simple_sem },
{ K_SECONDS(2), &simple_sem },
{ K_SECONDS(1), &multiple_thread_sem },
{ K_SECONDS(3), &simple_sem },
{ K_SECONDS(5), &multiple_thread_sem },
{ K_SECONDS(4), &simple_sem },
};
struct timeout_info retrieved_info;
@ -751,7 +751,7 @@ void test_sem_multi_take_timeout_diff_sem(void)
K_FOREVER);
zassert_true(retrieved_info.timeout == SECONDS(i + 1),
zassert_true(retrieved_info.timeout == K_SECONDS(i + 1),
"timeout didn't occur properly");
}

View file

@ -15,7 +15,7 @@
#include <ztest.h>
#define TEST_TIMEOUT SECONDS(1)
#define TEST_TIMEOUT K_SECONDS(1)
struct bt_data {
void *hci_sync;