Browse Source

timex: unambiguous time conversion macros

pr/spi.typo
Oleg Hahm 6 years ago
parent
commit
4f4214235b
  1. 6
      cpu/cc2538/periph/i2c.c
  2. 2
      cpu/lpc2387/mci/lpc2387-mci.c
  3. 4
      drivers/dht/dht.c
  4. 4
      drivers/servo/servo.c
  5. 2
      drivers/si70xx/si70xx.c
  6. 2
      drivers/xbee/xbee.c
  7. 2
      examples/timer_periodic_wakeup/main.c
  8. 4
      pkg/emb6/contrib/target.c
  9. 2
      pkg/lwip/contrib/sock/lwip_sock.c
  10. 8
      pkg/lwip/contrib/sys_arch.c
  11. 6
      sys/include/net/gnrc/ndp.h
  12. 2
      sys/include/net/gnrc/sixlowpan/nd.h
  13. 2
      sys/include/net/gnrc/tftp.h
  14. 4
      sys/include/net/sock/ip.h
  15. 4
      sys/include/net/sock/udp.h
  16. 22
      sys/include/timex.h
  17. 4
      sys/include/xtimer/implementation.h
  18. 2
      sys/net/application_layer/sntp/sntp.c
  19. 2
      sys/net/application_layer/uhcp/uhcpc.c
  20. 8
      sys/net/gnrc/application_layer/tftp/gnrc_tftp.c
  21. 4
      sys/net/gnrc/network_layer/ndp/gnrc_ndp.c
  22. 4
      sys/net/gnrc/network_layer/ndp/host/gnrc_ndp_host.c
  23. 16
      sys/net/gnrc/network_layer/ndp/internal/gnrc_ndp_internal.c
  24. 2
      sys/net/gnrc/network_layer/ndp/router/gnrc_ndp_router.c
  25. 2
      sys/net/gnrc/network_layer/sixlowpan/ctx/gnrc_sixlowpan_ctx.c
  26. 2
      sys/net/gnrc/network_layer/sixlowpan/frag/rbuf.h
  27. 8
      sys/net/gnrc/network_layer/sixlowpan/nd/gnrc_sixlowpan_nd.c
  28. 2
      sys/net/gnrc/network_layer/sixlowpan/nd/router/gnrc_sixlowpan_nd_router.c
  29. 4
      sys/net/gnrc/routing/rpl/gnrc_rpl.c
  30. 4
      sys/net/gnrc/routing/rpl/gnrc_rpl_control_messages.c
  31. 10
      sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c
  32. 2
      sys/net/gnrc/routing/rpl/p2p/gnrc_rpl_p2p.c
  33. 2
      sys/net/network_layer/fib/fib.c
  34. 12
      sys/net/routing/nhdp/iib_table.c
  35. 6
      sys/net/routing/nhdp/nhdp.c
  36. 4
      sys/net/routing/nhdp/nhdp_writer.c
  37. 2
      sys/net/routing/nhdp/nib_table.c
  38. 2
      sys/newlib/syscalls.c
  39. 4
      sys/posix/semaphore/posix_semaphore.c
  40. 2
      sys/shell/commands/sc_gnrc_6ctx.c
  41. 8
      sys/shell/commands/sc_gnrc_rpl.c
  42. 16
      sys/shell/commands/sc_icmpv6_echo.c
  43. 6
      sys/timex/timex.c
  44. 4
      sys/trickle/trickle.c
  45. 2
      sys/xtimer/xtimer.c
  46. 2
      sys/xtimer/xtimer_posix.c
  47. 2
      tests/bitarithm_timings/main.c
  48. 2
      tests/board_calliope-mini/main.c
  49. 2
      tests/board_microbit/main.c
  50. 2
      tests/driver_bh1750/main.c
  51. 2
      tests/driver_dht/main.c
  52. 2
      tests/driver_jc42/main.c
  53. 2
      tests/driver_si70xx/main.c
  54. 2
      tests/driver_srf02/main.c
  55. 2
      tests/periph_adc/main.c
  56. 2
      tests/periph_pwm/main.c
  57. 4
      tests/posix_semaphore/main.c
  58. 2
      tests/saul/main.c
  59. 6
      tests/unittests/tests-fib_sr/tests-fib_sr.c
  60. 4
      tests/xtimer_drift/main.c
  61. 2
      tests/xtimer_hang/main.c
  62. 4
      tests/xtimer_longterm/main.c
  63. 6
      tests/xtimer_usleep/main.c

6
cpu/cc2538/periph/i2c.c

@ -30,7 +30,7 @@
#ifdef MODULE_XTIMER
#include "xtimer.h"
#endif
#include "timex.h" /* for SEC_IN_USEC */
#include "timex.h" /* for US_PER_SEC */
#define ENABLE_DEBUG (0)
#include "debug.h"
@ -169,7 +169,7 @@ static void callback(void *arg)
static uint_fast8_t i2c_ctrl_blocking(uint_fast8_t flags)
{
#ifdef MODULE_XTIMER
const unsigned int xtimer_timeout = 3 * (DATA_BITS + ACK_BITS) * SEC_IN_USEC / speed_hz;
const unsigned int xtimer_timeout = 3 * (DATA_BITS + ACK_BITS) * US_PER_SEC / speed_hz;
#endif
mutex_trylock(&i2c_wait_mutex);
@ -302,7 +302,7 @@ int i2c_init_master(i2c_t dev, i2c_speed_t speed)
cc2538_i2c_init_master(speed_hz);
/* Pre-compute an SCL delay in microseconds */
scl_delay = SEC_IN_USEC;
scl_delay = US_PER_SEC;
scl_delay += speed_hz;
scl_delay /= 2 * speed_hz;

2
cpu/lpc2387/mci/lpc2387-mci.c

@ -475,7 +475,7 @@ static int wait_ready(unsigned short tmr)
{
unsigned long rc;
uint32_t stoppoll = xtimer_now_usec() + tmr * MS_IN_USEC;
uint32_t stoppoll = xtimer_now_usec() + tmr * US_PER_MS;
bool bBreak = false;
while (xtimer_now_usec() < stoppoll/*Timer[0]*/) {

4
drivers/dht/dht.c

@ -91,7 +91,7 @@ int dht_init(dht_t *dev, const dht_params_t *params)
}
gpio_set(dev->pin);
xtimer_usleep(2000 * MS_IN_USEC);
xtimer_usleep(2000 * US_PER_MS);
DEBUG("dht_init: success\n");
return 0;
@ -104,7 +104,7 @@ int dht_read(dht_t *dev, int16_t *temp, int16_t *hum)
/* send init signal to device */
gpio_clear(dev->pin);
xtimer_usleep(20 * MS_IN_USEC);
xtimer_usleep(20 * US_PER_MS);
gpio_set(dev->pin);
xtimer_usleep(40);

4
drivers/servo/servo.c

@ -22,7 +22,7 @@
#include "servo.h"
#include "periph/pwm.h"
#include "timex.h" /* for SEC_IN_USEC */
#include "timex.h" /* for US_PER_SEC */
#define ENABLE_DEBUG (0)
#include "debug.h"
@ -32,7 +32,7 @@
#endif
#ifndef SERVO_RESOLUTION
#define SERVO_RESOLUTION (SEC_IN_USEC / SERVO_FREQUENCY)
#define SERVO_RESOLUTION (US_PER_SEC / SERVO_FREQUENCY)
#endif
int servo_init(servo_t *dev, pwm_t pwm, int pwm_channel, unsigned int min, unsigned int max)

2
drivers/si70xx/si70xx.c

@ -82,7 +82,7 @@ int si70xx_init(si70xx_t *dev, i2c_t i2c_dev, uint8_t address)
i2c_release(dev->i2c_dev);
/* sensor is ready after at most 25 ms */
xtimer_usleep(25 * MS_IN_USEC);
xtimer_usleep(25 * US_PER_MS);
return 0;
}

2
drivers/xbee/xbee.c

@ -50,7 +50,7 @@
/**
* @brief Timeout for receiving AT command response
*/
#define RESP_TIMEOUT_USEC (SEC_IN_USEC)
#define RESP_TIMEOUT_USEC (US_PER_SEC)
/**
* @brief Start delimiter in API frame mode

2
examples/timer_periodic_wakeup/main.c

@ -23,7 +23,7 @@
#include "timex.h"
/* set interval to 1 second */
#define INTERVAL (1U * SEC_IN_USEC)
#define INTERVAL (1U * US_PER_SEC)
int main(void)
{

4
pkg/emb6/contrib/target.c

@ -201,13 +201,13 @@ clock_time_t hal_getTick(void)
clock_time_t hal_getSec(void)
{
return (clock_time_t)xtimer_now_usec() / SEC_IN_USEC;
return (clock_time_t)xtimer_now_usec() / US_PER_SEC;
}
clock_time_t hal_getTRes(void)
{
return SEC_IN_USEC;
return US_PER_SEC;
}
/** @} */

2
pkg/lwip/contrib/sock/lwip_sock.c

@ -412,7 +412,7 @@ int lwip_sock_recv(struct netconn *conn, uint32_t timeout, struct netbuf **buf)
}
#if LWIP_SO_RCVTIMEO
if ((timeout != 0) && (timeout != SOCK_NO_TIMEOUT)) {
netconn_set_recvtimeout(conn, timeout / MS_IN_USEC);
netconn_set_recvtimeout(conn, timeout / US_PER_MS);
}
else
#endif

8
pkg/lwip/contrib/sys_arch.c

@ -80,12 +80,12 @@ u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t count)
if (count != 0) {
uint64_t stop, start;
start = xtimer_now_usec64();
int res = sema_wait_timed((sema_t *)sem, count * MS_IN_USEC);
int res = sema_wait_timed((sema_t *)sem, count * US_PER_MS);
stop = xtimer_now_usec64() - start;
if (res == -ETIMEDOUT) {
return SYS_ARCH_TIMEOUT;
}
return (u32_t)(stop / MS_IN_USEC);
return (u32_t)(stop / US_PER_MS);
}
else {
sema_wait_timed((sema_t *)sem, 0);
@ -140,7 +140,7 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
start = xtimer_now_usec64();
if (timeout > 0) {
uint64_t u_timeout = (timeout * MS_IN_USEC);
uint64_t u_timeout = (timeout * US_PER_MS);
_xtimer_set64(&timer, (uint32_t)u_timeout, (uint32_t)(u_timeout >> 32));
}
mbox_get(&mbox->mbox, &m);
@ -149,7 +149,7 @@ u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
switch (m.type) {
case _MSG_SUCCESS:
*msg = m.content.ptr;
return (u32_t)((stop - start) / MS_IN_USEC);
return (u32_t)((stop - start) / US_PER_MS);
case _MSG_TIMEOUT:
break;
default: /* should not happen */

6
sys/include/net/gnrc/ndp.h

@ -120,13 +120,13 @@ extern "C" {
* @brief Base value in mircoseconds for computing randomised
* reachable time.
*/
#define GNRC_NDP_REACH_TIME (30U * SEC_IN_USEC)
#define GNRC_NDP_REACH_TIME (30U * US_PER_SEC)
/**
* @brief Time in mircoseconds between retransmissions of neighbor
* solicitations to a neighbor.
*/
#define GNRC_NDP_RETRANS_TIMER (1U * SEC_IN_USEC)
#define GNRC_NDP_RETRANS_TIMER (1U * US_PER_SEC)
/**
* @brief Delay in seconds for neighbor cache entry between entering
@ -179,7 +179,7 @@ extern "C" {
* solicitation reception and responding router advertisement
* transmission.
*/
#define GNRC_NDP_MAX_RTR_ADV_DELAY (500U * MS_IN_USEC)
#define GNRC_NDP_MAX_RTR_ADV_DELAY (500U * US_PER_MS)
/** @} */
/**

2
sys/include/net/gnrc/sixlowpan/nd.h

@ -113,7 +113,7 @@ extern "C" {
/**
* @brief replacement value (in microseconds) for @ref GNRC_NDP_MAX_RTR_ADV_DELAY
*/
#define GNRC_SIXLOWPAN_ND_MAX_RTR_ADV_DELAY (2U * SEC_IN_USEC)
#define GNRC_SIXLOWPAN_ND_MAX_RTR_ADV_DELAY (2U * US_PER_SEC)
/**
* @brief Lifetime of a tentative address entry in seconds
*/

2
sys/include/net/gnrc/tftp.h

@ -85,7 +85,7 @@ extern "C" {
* @brief The default timeout of a data packet
*/
#ifndef GNRC_TFTP_DEFAULT_TIMEOUT
#define GNRC_TFTP_DEFAULT_TIMEOUT (1 * SEC_IN_USEC)
#define GNRC_TFTP_DEFAULT_TIMEOUT (1 * US_PER_SEC)
#endif
/**

4
sys/include/net/sock/ip.h

@ -170,7 +170,7 @@
* sock_ip_close(&sock);
* return 1;
* }
* if ((res = sock_ip_recv(&sock, buf, sizeof(buf), 1 * SEC_IN_USEC,
* if ((res = sock_ip_recv(&sock, buf, sizeof(buf), 1 * US_PER_SEC,
* NULL)) < 0) {
* if (res == -ETIMEDOUT) {
* puts("Timed out");
@ -232,7 +232,7 @@
* We then wait a second for a reply and print it when it is received.
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.c}
* if ((res = sock_ip_recv(&sock, buf, sizeof(buf), 1 * SEC_IN_USEC,
* if ((res = sock_ip_recv(&sock, buf, sizeof(buf), 1 * US_PER_SEC,
* NULL)) < 0) {
* if (res == -ETIMEDOUT) {
* puts("Timed out");

4
sys/include/net/sock/udp.h

@ -168,7 +168,7 @@
* sock_udp_close(&sock);
* return 1;
* }
* if ((res = sock_udp_recv(&sock, buf, sizeof(buf), 1 * SEC_IN_USEC,
* if ((res = sock_udp_recv(&sock, buf, sizeof(buf), 1 * US_PER_SEC,
* NULL)) < 0) {
* if (res == -ETIMEDOUT) {
* puts("Timed out");
@ -232,7 +232,7 @@
* We then wait a second for a reply and print it when it is received.
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ {.c}
* if ((res = sock_udp_recv(&sock, buf, sizeof(buf), 1 * SEC_IN_USEC,
* if ((res = sock_udp_recv(&sock, buf, sizeof(buf), 1 * US_PER_SEC,
* NULL)) < 0) {
* if (res == -ETIMEDOUT) {
* puts("Timed out");

22
sys/include/timex.h

@ -31,32 +31,32 @@ extern "C" {
/**
* @brief The number of microseconds per second
*/
#define SEC_IN_USEC (1000000U)
#define US_PER_SEC (1000000U)
/**
* @brief The number of seconds per minute
*/
#define MIN_IN_SEC (60U)
#define SEC_PER_MIN (60U)
/**
* @brief The number of centiseconds per second
*/
#define SEC_IN_CS (100U)
#define CS_PER_SEC (100U)
/**
* @brief The number of milliseconds per second
*/
#define SEC_IN_MS (1000U)
#define MS_PER_SEC (1000U)
/**
* @brief The number of microseconds per millisecond
*/
#define MS_IN_USEC (1000U)
#define US_PER_MS (1000U)
/**
* @brief The number of nanoseconds per microsecond
*/
#define USEC_IN_NS (1000)
#define NS_PER_US (1000)
/**
* @brief The maximum length of the string representation of a timex timestamp
@ -133,8 +133,8 @@ int timex_cmp(const timex_t a, const timex_t b);
*/
static inline void timex_normalize(timex_t *time)
{
time->seconds += (time->microseconds / SEC_IN_USEC);
time->microseconds %= SEC_IN_USEC;
time->seconds += (time->microseconds / US_PER_SEC);
time->microseconds %= US_PER_SEC;
}
/**
@ -147,7 +147,7 @@ static inline void timex_normalize(timex_t *time)
*/
static inline int timex_isnormalized(const timex_t *time)
{
return (time->microseconds < SEC_IN_USEC);
return (time->microseconds < US_PER_SEC);
}
/**
@ -160,7 +160,7 @@ static inline int timex_isnormalized(const timex_t *time)
/* cppcheck-suppress passedByValue */
static inline uint64_t timex_uint64(const timex_t a)
{
return (uint64_t) a.seconds * SEC_IN_USEC + a.microseconds;
return (uint64_t) a.seconds * US_PER_SEC + a.microseconds;
}
/**
@ -172,7 +172,7 @@ static inline uint64_t timex_uint64(const timex_t a)
*/
static inline timex_t timex_from_uint64(const uint64_t timestamp)
{
return timex_set(timestamp / SEC_IN_USEC, timestamp % SEC_IN_USEC);
return timex_set(timestamp / US_PER_SEC, timestamp % US_PER_SEC);
}
/**

4
sys/include/xtimer/implementation.h

@ -168,12 +168,12 @@ static inline void xtimer_usleep64(uint64_t microseconds)
static inline void xtimer_sleep(uint32_t seconds)
{
_xtimer_tsleep64(_xtimer_ticks_from_usec64((uint64_t)seconds * SEC_IN_USEC));
_xtimer_tsleep64(_xtimer_ticks_from_usec64((uint64_t)seconds * US_PER_SEC));
}
static inline void xtimer_nanosleep(uint32_t nanoseconds)
{
_xtimer_tsleep32(_xtimer_ticks_from_usec(nanoseconds / USEC_IN_NS));
_xtimer_tsleep32(_xtimer_ticks_from_usec(nanoseconds / NS_PER_US));
}
static inline void xtimer_tsleep32(xtimer_ticks32_t ticks)

2
sys/net/application_layer/sntp/sntp.c

@ -71,7 +71,7 @@ int sntp_sync(sock_udp_ep_t *server, uint32_t timeout)
return result;
}
sock_udp_close(&_sntp_sock);
_sntp_offset = (byteorder_ntohl(_sntp_packet.transmit.seconds) * SEC_IN_USEC) +
_sntp_offset = (byteorder_ntohl(_sntp_packet.transmit.seconds) * US_PER_SEC) +
((byteorder_ntohl(_sntp_packet.transmit.fraction) * 232)
/ 1000000) - xtimer_now64();
mutex_unlock(&_sntp_mutex);

2
sys/net/application_layer/uhcp/uhcpc.c

@ -43,7 +43,7 @@ void uhcp_client(uhcp_iface_t iface)
while(1) {
puts("uhcp_client(): sending REQ...");
sock_udp_send(&sock, &req, sizeof(uhcp_req_t), &req_target);
res = sock_udp_recv(&sock, buf, sizeof(buf), 10U*SEC_IN_USEC, &remote);
res = sock_udp_recv(&sock, buf, sizeof(buf), 10U*US_PER_SEC, &remote);
if (res > 0) {
uhcp_handle_udp(buf, res, remote.addr.ipv6, remote.port, iface);
xtimer_sleep(60);

8
sys/net/gnrc/application_layer/tftp/gnrc_tftp.c

@ -824,7 +824,7 @@ size_t _tftp_add_option(uint8_t *dst, tftp_opt_t *opt, uint32_t value)
uint32_t _tftp_append_options(tftp_context_t *ctxt, tftp_header_t *hdr, uint32_t offset)
{
offset += _tftp_add_option(hdr->data + offset, _tftp_options + TOPT_BLKSIZE, ctxt->block_size);
offset += _tftp_add_option(hdr->data + offset, _tftp_options + TOPT_TIMEOUT, (ctxt->timeout / SEC_IN_USEC));
offset += _tftp_add_option(hdr->data + offset, _tftp_options + TOPT_TIMEOUT, (ctxt->timeout / US_PER_SEC));
/**
* Only set the transfer option if we are sending.
@ -1001,7 +1001,7 @@ tftp_state _tftp_send(gnrc_pktsnip_t *buf, tftp_context_t *ctxt, size_t len)
if (ctxt->block_timeout) {
ctxt->timer_msg.type = TFTP_TIMEOUT_MSG;
xtimer_set_msg(&(ctxt->timer), ctxt->block_timeout, &(ctxt->timer_msg), thread_getpid());
DEBUG("tftp: set timeout %" PRIu32 " ms\n", ctxt->block_timeout / MS_IN_USEC);
DEBUG("tftp: set timeout %" PRIu32 " ms\n", ctxt->block_timeout / US_PER_MS);
}
return TS_BUSY;
@ -1084,8 +1084,8 @@ int _tftp_decode_options(tftp_context_t *ctxt, gnrc_pktsnip_t *buf, uint32_t sta
break;
case TOPT_TIMEOUT:
ctxt->timeout = atoi(value) * SEC_IN_USEC;
DEBUG("tftp: option TOPT_TIMEOUT = %" PRIu32 " ms\n", ctxt->timeout / MS_IN_USEC);
ctxt->timeout = atoi(value) * US_PER_SEC;
DEBUG("tftp: option TOPT_TIMEOUT = %" PRIu32 " ms\n", ctxt->timeout / US_PER_MS);
break;
}

4
sys/net/gnrc/network_layer/ndp/gnrc_ndp.c

@ -64,7 +64,7 @@ static void _stale_nc(kernel_pid_t iface, ipv6_addr_t *ipaddr, uint8_t *l2addr,
GNRC_IPV6_NC_STATE_STALE |
GNRC_IPV6_NC_TYPE_TENTATIVE)) != NULL) {
xtimer_set_msg(&nc_entry->type_timeout,
(GNRC_SIXLOWPAN_ND_TENTATIVE_NCE_LIFETIME * SEC_IN_USEC),
(GNRC_SIXLOWPAN_ND_TENTATIVE_NCE_LIFETIME * US_PER_SEC),
&nc_entry->type_timeout_msg,
gnrc_ipv6_pid);
}
@ -533,7 +533,7 @@ void gnrc_ndp_rtr_adv_handle(kernel_pid_t iface, gnrc_pktsnip_t *pkt, ipv6_hdr_t
#ifdef MODULE_GNRC_SIXLOWPAN_ND
next_rtr_sol = ltime;
#endif
xtimer_set_msg(&nc_entry->rtr_timeout, (ltime * SEC_IN_USEC),
xtimer_set_msg(&nc_entry->rtr_timeout, (ltime * US_PER_SEC),
&nc_entry->rtr_timeout_msg, thread_getpid());
}
/* set current hop limit from message if available */

4
sys/net/gnrc/network_layer/ndp/host/gnrc_ndp_host.c

@ -34,7 +34,7 @@ static inline void _reschedule_rtr_sol(gnrc_ipv6_netif_t *iface, uint32_t delay)
void gnrc_ndp_host_init(gnrc_ipv6_netif_t *iface)
{
uint32_t interval = random_uint32_range(0, GNRC_NDP_MAX_RTR_SOL_DELAY * SEC_IN_USEC);
uint32_t interval = random_uint32_range(0, GNRC_NDP_MAX_RTR_SOL_DELAY * US_PER_SEC);
mutex_lock(&iface->mutex);
iface->rtr_sol_count = GNRC_NDP_MAX_RTR_SOL_NUMOF;
DEBUG("ndp host: delayed initial router solicitation by %" PRIu32 " usec.\n", interval);
@ -48,7 +48,7 @@ void gnrc_ndp_host_retrans_rtr_sol(gnrc_ipv6_netif_t *iface)
if (iface->rtr_sol_count > 1) { /* regard off-by-one error */
DEBUG("ndp hst: retransmit rtr sol in %d sec\n", GNRC_NDP_MAX_RTR_SOL_INT);
iface->rtr_sol_count--;
_reschedule_rtr_sol(iface, GNRC_NDP_MAX_RTR_SOL_INT * SEC_IN_USEC);
_reschedule_rtr_sol(iface, GNRC_NDP_MAX_RTR_SOL_INT * US_PER_SEC);
}
mutex_unlock(&iface->mutex);
gnrc_ndp_internal_send_rtr_sol(iface->pid, NULL);

16
sys/net/gnrc/network_layer/ndp/internal/gnrc_ndp_internal.c

@ -91,7 +91,7 @@ ipv6_addr_t *gnrc_ndp_internal_default_router(void)
void gnrc_ndp_internal_set_state(gnrc_ipv6_nc_t *nc_entry, uint8_t state)
{
gnrc_ipv6_netif_t *ipv6_iface;
uint32_t t = GNRC_NDP_FIRST_PROBE_DELAY * SEC_IN_USEC;
uint32_t t = GNRC_NDP_FIRST_PROBE_DELAY * US_PER_SEC;
nc_entry->flags &= ~GNRC_IPV6_NC_STATE_MASK;
nc_entry->flags |= state;
@ -209,10 +209,10 @@ void gnrc_ndp_internal_send_nbr_adv(kernel_pid_t iface, ipv6_addr_t *tgt, ipv6_a
if (gnrc_ipv6_netif_addr_is_non_unicast(tgt)) {
/* avoid collision for anycast addresses
* (see https://tools.ietf.org/html/rfc4861#section-7.2.7) */
uint32_t delay = random_uint32_range(0, GNRC_NDP_MAX_AC_TGT_DELAY * SEC_IN_USEC);
uint32_t delay = random_uint32_range(0, GNRC_NDP_MAX_AC_TGT_DELAY * US_PER_SEC);
gnrc_ipv6_nc_t *nc_entry = gnrc_ipv6_nc_get(iface, dst);
DEBUG("ndp internal: delay neighbor advertisement for %" PRIu32 " sec.",
(delay / SEC_IN_USEC));
(delay / US_PER_SEC));
/* nc_entry must be set so no need to check it */
assert(nc_entry);
@ -554,15 +554,15 @@ void gnrc_ndp_internal_send_rtr_adv(kernel_pid_t iface, ipv6_addr_t *src, ipv6_a
}
if (ipv6_iface->flags & GNRC_IPV6_NETIF_FLAGS_ADV_REACH_TIME) {
if (ipv6_iface->reach_time > (3600 * SEC_IN_USEC)) { /* reach_time > 1 hour */
reach_time = (3600 * SEC_IN_MS);
if (ipv6_iface->reach_time > (3600 * US_PER_SEC)) { /* reach_time > 1 hour */
reach_time = (3600 * MS_PER_SEC);
}
else {
reach_time = ipv6_iface->reach_time / MS_IN_USEC;
reach_time = ipv6_iface->reach_time / US_PER_MS;
}
}
if (ipv6_iface->flags & GNRC_IPV6_NETIF_FLAGS_ADV_RETRANS_TIMER) {
retrans_timer = ipv6_iface->retrans_timer / MS_IN_USEC;
retrans_timer = ipv6_iface->retrans_timer / US_PER_MS;
}
if (!fin) {
adv_ltime = ipv6_iface->adv_ltime;
@ -792,7 +792,7 @@ bool gnrc_ndp_internal_pi_opt_handle(kernel_pid_t iface, uint8_t icmpv6_type,
netif_addr->preferred = byteorder_ntohl(pi_opt->pref_ltime);
if (netif_addr->valid != UINT32_MAX) {
xtimer_set_msg(&netif_addr->valid_timeout,
(byteorder_ntohl(pi_opt->valid_ltime) * SEC_IN_USEC),
(byteorder_ntohl(pi_opt->valid_ltime) * US_PER_SEC),
&netif_addr->valid_timeout_msg, thread_getpid());
}
/* TODO: preferred lifetime for address auto configuration */

2
sys/net/gnrc/network_layer/ndp/router/gnrc_ndp_router.c

@ -107,7 +107,7 @@ static void _send_rtr_adv(gnrc_ipv6_netif_t *iface, ipv6_addr_t *dst)
xtimer_remove(&iface->rtr_adv_timer);
iface->rtr_adv_msg.type = GNRC_NDP_MSG_RTR_ADV_RETRANS;
iface->rtr_adv_msg.content.ptr = iface;
xtimer_set_msg(&iface->rtr_adv_timer, interval * SEC_IN_USEC, &iface->rtr_adv_msg,
xtimer_set_msg(&iface->rtr_adv_timer, interval * US_PER_SEC, &iface->rtr_adv_msg,
gnrc_ipv6_pid);
}
mutex_unlock(&iface->mutex);

2
sys/net/gnrc/network_layer/sixlowpan/ctx/gnrc_sixlowpan_ctx.c

@ -133,7 +133,7 @@ gnrc_sixlowpan_ctx_t *gnrc_sixlowpan_ctx_update(uint8_t id, const ipv6_addr_t *p
static uint32_t _current_minute(void)
{
return xtimer_now_usec() / (SEC_IN_USEC * 60);
return xtimer_now_usec() / (US_PER_SEC * 60);
}
static void _update_lifetime(uint8_t id)

2
sys/net/gnrc/network_layer/sixlowpan/frag/rbuf.h

@ -32,7 +32,7 @@ extern "C" {
#define RBUF_L2ADDR_MAX_LEN (8U) /**< maximum length for link-layer addresses */
#define RBUF_SIZE (4U) /**< size of the reassembly buffer */
#define RBUF_TIMEOUT (3U * SEC_IN_USEC) /**< timeout for reassembly in microseconds */
#define RBUF_TIMEOUT (3U * US_PER_SEC) /**< timeout for reassembly in microseconds */
/**
* @brief Fragment intervals to identify limits of fragments.

8
sys/net/gnrc/network_layer/sixlowpan/nd/gnrc_sixlowpan_nd.c

@ -31,7 +31,7 @@ static inline void _rtr_sol_reschedule(gnrc_ipv6_netif_t *iface, uint32_t sec_de
xtimer_remove(&iface->rtr_sol_timer);
iface->rtr_sol_msg.type = GNRC_SIXLOWPAN_ND_MSG_MC_RTR_SOL;
iface->rtr_sol_msg.content.ptr = iface;
xtimer_set_msg(&iface->rtr_sol_timer, sec_delay * SEC_IN_USEC, &iface->rtr_sol_msg,
xtimer_set_msg(&iface->rtr_sol_timer, sec_delay * US_PER_SEC, &iface->rtr_sol_msg,
gnrc_ipv6_pid);
}
@ -229,7 +229,7 @@ void gnrc_sixlowpan_nd_rtr_sol_reschedule(gnrc_ipv6_nc_t *nce, uint32_t sec_dela
xtimer_remove(&iface->rtr_sol_timer);
iface->rtr_sol_msg.type = GNRC_SIXLOWPAN_ND_MSG_MC_RTR_SOL;
iface->rtr_sol_msg.content.ptr = iface;
xtimer_set_msg(&iface->rtr_sol_timer, sec_delay * SEC_IN_USEC, &iface->rtr_sol_msg,
xtimer_set_msg(&iface->rtr_sol_timer, sec_delay * US_PER_SEC, &iface->rtr_sol_msg,
gnrc_ipv6_pid);
}
@ -292,7 +292,7 @@ uint8_t gnrc_sixlowpan_nd_opt_ar_handle(kernel_pid_t iface, ipv6_hdr_t *ipv6,
DEBUG("6lo nd: address registration successful\n");
mutex_lock(&ipv6_iface->mutex);
/* reschedule 1 minute before lifetime expires */
gnrc_ndp_internal_reset_nbr_sol_timer(nc_entry, SEC_IN_USEC * 60 *
gnrc_ndp_internal_reset_nbr_sol_timer(nc_entry, US_PER_SEC * 60 *
(uint32_t)(byteorder_ntohs(ar_opt->ltime)
-1),
GNRC_NDP_MSG_NBR_SOL_RETRANS,
@ -357,7 +357,7 @@ uint8_t gnrc_sixlowpan_nd_opt_ar_handle(kernel_pid_t iface, ipv6_hdr_t *ipv6,
nc_entry->flags |= GNRC_IPV6_NC_TYPE_REGISTERED;
reg_ltime = byteorder_ntohs(ar_opt->ltime);
/* TODO: notify routing protocol */
xtimer_set_msg(&nc_entry->type_timeout, (reg_ltime * 60 * SEC_IN_USEC),
xtimer_set_msg(&nc_entry->type_timeout, (reg_ltime * 60 * US_PER_SEC),
&nc_entry->type_timeout_msg, gnrc_ipv6_pid);
}
break;

2
sys/net/gnrc/network_layer/sixlowpan/nd/router/gnrc_sixlowpan_nd_router.c

@ -239,7 +239,7 @@ void gnrc_sixlowpan_nd_opt_abr_handle(kernel_pid_t iface, ndp_rtr_adv_t *rtr_adv
memset(abr->ctxs, 0, sizeof(abr->ctxs));
abr->prfs = NULL;
t = abr->ltime * 60 * SEC_IN_USEC;
t = abr->ltime * 60 * US_PER_SEC;
xtimer_remove(&abr->ltimer);
abr->ltimer_msg.type = GNRC_SIXLOWPAN_ND_MSG_ABR_TIMEOUT;

4
sys/net/gnrc/routing/rpl/gnrc_rpl.c

@ -32,7 +32,7 @@
static char _stack[GNRC_RPL_STACK_SIZE];
kernel_pid_t gnrc_rpl_pid = KERNEL_PID_UNDEF;
const ipv6_addr_t ipv6_addr_all_rpl_nodes = GNRC_RPL_ALL_NODES_ADDR;
static uint32_t _lt_time = GNRC_RPL_LIFETIME_UPDATE_STEP * SEC_IN_USEC;
static uint32_t _lt_time = GNRC_RPL_LIFETIME_UPDATE_STEP * US_PER_SEC;
static xtimer_t _lt_timer;
static msg_t _lt_msg = { .type = GNRC_RPL_MSG_TYPE_LIFETIME_UPDATE };
static msg_t _msg_q[GNRC_RPL_MSG_QUEUE_SIZE];
@ -253,7 +253,7 @@ static void *_event_loop(void *args)
void _update_lifetime(void)
{
uint32_t now = xtimer_now_usec();
uint16_t now_sec = now / SEC_IN_USEC;
uint16_t now_sec = now / US_PER_SEC;
gnrc_rpl_parent_t *parent;
gnrc_rpl_instance_t *inst;

4
sys/net/gnrc/routing/rpl/gnrc_rpl_control_messages.c

@ -408,7 +408,7 @@ bool _parse_options(int msg_type, gnrc_rpl_instance_t *inst, gnrc_rpl_opt_t *opt
sizeof(ipv6_addr_t), fib_dst_flags, src->u8,
sizeof(ipv6_addr_t), FIB_FLAG_RPL_ROUTE,
(dodag->default_lifetime * dodag->lifetime_unit) *
SEC_IN_MS);
MS_PER_SEC);
break;
case (GNRC_RPL_OPT_TRANSIT):
@ -433,7 +433,7 @@ bool _parse_options(int msg_type, gnrc_rpl_instance_t *inst, gnrc_rpl_opt_t *opt
((transit->e_flags & GNRC_RPL_OPT_TRANSIT_E_FLAG) ?
0x0 : FIB_FLAG_RPL_ROUTE),
(transit->path_lifetime *
dodag->lifetime_unit * SEC_IN_MS));
dodag->lifetime_unit * MS_PER_SEC));
first_target = (gnrc_rpl_opt_target_t *) (((uint8_t *) (first_target)) +
sizeof(gnrc_rpl_opt_t) + first_target->length);
}

10
sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c

@ -225,7 +225,7 @@ bool gnrc_rpl_parent_remove(gnrc_rpl_parent_t *parent)
/* set the default route to the next parent for now */
if (parent->next) {
uint32_t now = xtimer_now_usec() / SEC_IN_USEC;
uint32_t now = xtimer_now_usec() / US_PER_SEC;
fib_add_entry(&gnrc_ipv6_fib_table,
dodag->iface,
(uint8_t *) ipv6_addr_unspecified.u8,
@ -234,7 +234,7 @@ bool gnrc_rpl_parent_remove(gnrc_rpl_parent_t *parent)
parent->next->addr.u8,
sizeof(ipv6_addr_t),
FIB_FLAG_RPL_ROUTE,
(parent->next->lifetime - now) * SEC_IN_MS);
(parent->next->lifetime - now) * MS_PER_SEC);
}
}
LL_DELETE(dodag->parents, parent);
@ -267,7 +267,7 @@ void gnrc_rpl_parent_update(gnrc_rpl_dodag_t *dodag, gnrc_rpl_parent_t *parent)
/* update Parent lifetime */
if (parent != NULL) {
uint32_t now = xtimer_now_usec();
parent->lifetime = (now / SEC_IN_USEC) + (dodag->default_lifetime * dodag->lifetime_unit);
parent->lifetime = (now / US_PER_SEC) + (dodag->default_lifetime * dodag->lifetime_unit);
#ifdef MODULE_GNRC_RPL_P2P
if (dodag->instance->mop != GNRC_RPL_P2P_MOP) {
#endif
@ -280,7 +280,7 @@ void gnrc_rpl_parent_update(gnrc_rpl_dodag_t *dodag, gnrc_rpl_parent_t *parent)
parent->addr.u8,
sizeof(ipv6_addr_t),
FIB_FLAG_RPL_ROUTE,
(dodag->default_lifetime * dodag->lifetime_unit) * SEC_IN_MS);
(dodag->default_lifetime * dodag->lifetime_unit) * MS_PER_SEC);
}
#ifdef MODULE_GNRC_RPL_P2P
}
@ -340,7 +340,7 @@ static gnrc_rpl_parent_t *_gnrc_rpl_find_preferred_parent(gnrc_rpl_dodag_t *doda
dodag->parents->addr.u8,
sizeof(ipv6_addr_t),
FIB_FLAG_RPL_ROUTE,
(dodag->default_lifetime * dodag->lifetime_unit) * SEC_IN_MS);
(dodag->default_lifetime * dodag->lifetime_unit) * MS_PER_SEC);
#ifdef MODULE_GNRC_RPL_P2P
}
#endif

2
sys/net/gnrc/routing/rpl/p2p/gnrc_rpl_p2p.c

@ -351,7 +351,7 @@ void gnrc_rpl_p2p_recv_DRO(gnrc_pktsnip_t *pkt, ipv6_addr_t *src)
sizeof(ipv6_addr_t), 0x0, src->u8,
sizeof(ipv6_addr_t), FIB_FLAG_RPL_ROUTE,
p2p_ext->dodag->default_lifetime *
p2p_ext->dodag->lifetime_unit * SEC_IN_MS);
p2p_ext->dodag->lifetime_unit * MS_PER_SEC);
if (p2p_ext->dodag->node_status != GNRC_RPL_ROOT_NODE) {
if ((rdo_snip = gnrc_pktbuf_start_write(rdo_snip)) == NULL) {

2
sys/net/network_layer/fib/fib.c

@ -62,7 +62,7 @@ static char addr_str[IPV6_ADDR_MAX_STR_LEN];
*/
static void fib_lifetime_to_absolute(uint32_t ms, uint64_t *target)
{
*target = xtimer_now_usec64() + (ms * MS_IN_USEC);
*target = xtimer_now_usec64() + (ms * US_PER_MS);
}
/**

12
sys/net/routing/nhdp/iib_table.c

@ -252,7 +252,7 @@ void iib_process_metric_msg(iib_link_set_entry_t *ls_entry, uint64_t int_time)
if (ls_entry->last_seq_no == 0) {
timex_t now, i_time;
xtimer_now_timex(&now);
i_time = timex_from_uint64(int_time * MS_IN_USEC * DAT_HELLO_TIMEOUT_FACTOR);
i_time = timex_from_uint64(int_time * US_PER_MS * DAT_HELLO_TIMEOUT_FACTOR);
ls_entry->dat_received[0]++;
ls_entry->dat_total[0]++;
ls_entry->dat_time = timex_add(now, i_time);
@ -299,7 +299,7 @@ void iib_process_metric_pckt(iib_link_set_entry_t *ls_entry, uint32_t metric_out
timex_t now, i_time;
xtimer_now_timex(&now);
i_time = timex_from_uint64(rfc5444_timetlv_decode(ls_entry->hello_interval)
* MS_IN_USEC * DAT_HELLO_TIMEOUT_FACTOR);
* US_PER_MS * DAT_HELLO_TIMEOUT_FACTOR);
ls_entry->dat_time = timex_add(now, i_time);
}
@ -455,8 +455,8 @@ static iib_link_set_entry_t *update_link_set(iib_base_entry_t *base_entry, nib_e
}
}
v_time = timex_from_uint64(val_time * MS_IN_USEC);
l_hold = timex_from_uint64(((uint64_t)NHDP_L_HOLD_TIME_MS) * MS_IN_USEC);
v_time = timex_from_uint64(val_time * US_PER_MS);
l_hold = timex_from_uint64(((uint64_t)NHDP_L_HOLD_TIME_MS) * US_PER_MS);
/* Set Sending Address List as this tuples address list */
matching_lt->address_list_head = nhdp_generate_addr_list_from_tmp(NHDP_ADDR_TMP_SEND_LIST);
@ -583,7 +583,7 @@ static iib_link_set_entry_t *add_default_link_set_entry(iib_base_entry_t *base_e
*/
static void reset_link_set_entry(iib_link_set_entry_t *ls_entry, timex_t *now, uint64_t val_time)
{
timex_t v_time = timex_from_uint64(val_time * MS_IN_USEC);
timex_t v_time = timex_from_uint64(val_time * US_PER_MS);
release_link_tuple_addresses(ls_entry);
ls_entry->sym_time.microseconds = 0;
@ -679,7 +679,7 @@ static int add_two_hop_entry(iib_base_entry_t *base_entry, iib_link_set_entry_t
nhdp_addr_t *th_addr, timex_t *now, uint64_t val_time)
{
iib_two_hop_set_entry_t *new_entry;
timex_t v_time = timex_from_uint64(val_time * MS_IN_USEC);
timex_t v_time = timex_from_uint64(val_time * US_PER_MS);
new_entry = (iib_two_hop_set_entry_t *) malloc(sizeof(iib_two_hop_set_entry_t));

6
sys/net/routing/nhdp/nhdp.c

@ -102,7 +102,7 @@ kernel_pid_t nhdp_start(void)
#if (NHDP_METRIC_NEEDS_TIMER)
/* Configure periodic timer message to refresh metric values */
if (nhdp_pid != KERNEL_PID_UNDEF) {
metric_interval = timex_from_uint64(DAT_REFRESH_INTERVAL * SEC_IN_USEC);
metric_interval = timex_from_uint64(DAT_REFRESH_INTERVAL * US_PER_SEC);
metric_msg.type = NHDP_METRIC_TIMER;
metric_msg.content.ptr = NULL;
xtimer_set_msg64(&metric_timer, timex_uint64(metric_interval),
@ -184,9 +184,9 @@ int nhdp_register_if(kernel_pid_t if_pid, uint8_t *addr, size_t addr_size, uint8
if_entry->if_pid = if_pid;
/* Set HELLO_INTERVAL and H_HOLD_TIME (validity time) */
if_entry->hello_interval.seconds = 0;
if_entry->hello_interval.microseconds = MS_IN_USEC * hello_int_ms;
if_entry->hello_interval.microseconds = US_PER_MS * hello_int_ms;
if_entry->validity_time.seconds = 0;
if_entry->validity_time.microseconds = MS_IN_USEC * val_time_ms;
if_entry->validity_time.microseconds = US_PER_MS * val_time_ms;
timex_normalize(&if_entry->hello_interval);
timex_normalize(&if_entry->validity_time);
/* Reset sequence number */

4
sys/net/routing/nhdp/nhdp_writer.c

@ -211,9 +211,9 @@ static void _nhdp_add_message_tlvs_cb(struct rfc5444_writer *wr)
{
uint8_t validity_time, interval_time;
/* Convert validity time and interval time to milliseconds */
uint64_t val_tmp = (uint64_t) nhdp_wr_curr_if_entry->validity_time.seconds * SEC_IN_MS
uint64_t val_tmp = (uint64_t) nhdp_wr_curr_if_entry->validity_time.seconds * MS_PER_SEC
+ (nhdp_wr_curr_if_entry->validity_time.microseconds / 1000ULL);
uint64_t int_tmp = (uint64_t) nhdp_wr_curr_if_entry->hello_interval.seconds * SEC_IN_MS
uint64_t int_tmp = (uint64_t) nhdp_wr_curr_if_entry->hello_interval.seconds * MS_PER_SEC
+ (nhdp_wr_curr_if_entry->hello_interval.microseconds / 1000ULL);
/* Add validity time (mandatory) and interval time to msg */

2
sys/net/routing/nhdp/nib_table.c

@ -270,7 +270,7 @@ static void clear_nb_addresses(nib_entry_t *nib_entry, timex_t *now)
static int add_lost_neighbor_address(nhdp_addr_t *lost_addr, timex_t *now)
{
nib_lost_address_entry_t *elt;
timex_t n_hold = timex_from_uint64(((uint64_t)NHDP_N_HOLD_TIME_MS) * MS_IN_USEC);
timex_t n_hold = timex_from_uint64(((uint64_t)NHDP_N_HOLD_TIME_MS) * US_PER_MS);
LL_FOREACH(nib_lost_address_entry_head, elt) {
if (elt->address == lost_addr) {

2
sys/newlib/syscalls.c

@ -342,7 +342,7 @@ int _gettimeofday_r(struct _reent *r, struct timeval *restrict tp, void *restric
(void) r;
uint64_t now = xtimer_now_usec64();
tp->tv_sec = div_u64_by_1000000(now);
tp->tv_usec = now - (tp->tv_sec * SEC_IN_USEC);
tp->tv_usec = now - (tp->tv_sec * US_PER_SEC);
return 0;
}
#endif

4
sys/posix/semaphore/posix_semaphore.c

@ -35,8 +35,8 @@
int sem_timedwait(sem_t *sem, const struct timespec *abstime)
{
uint64_t timeout = (((uint64_t)abstime->tv_sec) * SEC_IN_USEC) +
(abstime->tv_nsec / USEC_IN_NS);
uint64_t timeout = (((uint64_t)abstime->tv_sec) * US_PER_SEC) +
(abstime->tv_nsec / NS_PER_US);
uint64_t now = xtimer_now_usec64();
if (now > timeout) {

2
sys/shell/commands/sc_gnrc_6ctx.c

@ -138,7 +138,7 @@ int _gnrc_6ctx_del(char *cmd_str, char *ctx_str)
ctx->ltime = 0;
del_timer[cid].callback = _del_cb;
del_timer[cid].arg = ctx;
xtimer_set(&del_timer[cid], GNRC_SIXLOWPAN_ND_RTR_MIN_CTX_DELAY * SEC_IN_USEC);
xtimer_set(&del_timer[cid], GNRC_SIXLOWPAN_ND_RTR_MIN_CTX_DELAY * US_PER_SEC);
}
}
else {

8
sys/shell/commands/sc_gnrc_rpl.c

@ -276,11 +276,11 @@ int _gnrc_rpl_dodag_show(void)
tc = (((uint64_t) dodag->trickle.msg_callback_timer.long_target << 32)
| dodag->trickle.msg_callback_timer.target) - xnow;
tc = (int64_t) tc < 0 ? 0 : tc / SEC_IN_USEC;
tc = (int64_t) tc < 0 ? 0 : tc / US_PER_SEC;
ti = (((uint64_t) dodag->trickle.msg_interval_timer.long_target << 32)
| dodag->trickle.msg_interval_timer.target) - xnow;
ti = (int64_t) ti < 0 ? 0 : ti / SEC_IN_USEC;
ti = (int64_t) ti < 0 ? 0 : ti / US_PER_SEC;
cleanup = dodag->instance->cleanup < 0 ? 0 : dodag->instance->cleanup;
@ -306,8 +306,8 @@ int _gnrc_rpl_dodag_show(void)
LL_FOREACH(gnrc_rpl_instances[i].dodag.parents, parent) {
printf("\t\tparent [addr: %s | rank: %d | lifetime: %" PRIu32 "s]\n",
ipv6_addr_to_str(addr_str, &parent->addr, sizeof(addr_str)),
parent->rank, ((int32_t) (parent->lifetime - (((uint32_t) xnow / SEC_IN_USEC))))
< 0 ? 0 : (parent->lifetime - ((uint32_t) xnow / SEC_IN_USEC)));
parent->rank, ((int32_t) (parent->lifetime - (((uint32_t) xnow / US_PER_SEC))))
< 0 ? 0 : (parent->lifetime - ((uint32_t) xnow / US_PER_SEC)));
}
}
return 0;

16
sys/shell/commands/sc_icmpv6_echo.c

@ -107,7 +107,7 @@ int _handle_reply(gnrc_pktsnip_t *pkt, uint32_t time)
PRIu32 ".%03" PRIu32 " ms\n", (unsigned) icmpv6->size,
ipv6_addr_to_str(ipv6_str, &(ipv6_hdr->src), sizeof(ipv6_str)),
byteorder_ntohs(icmpv6_hdr->id), seq, (unsigned)ipv6_hdr->hl,
time / MS_IN_USEC, time % MS_IN_USEC);
time / US_PER_MS, time % US_PER_MS);
#ifdef MODULE_GNRC_IPV6_NC
gnrc_ipv6_nc_still_reachable(&ipv6_hdr->src);
#endif
@ -130,14 +130,14 @@ static void _print_stats(char *addr_str, int success, int count, uint64_t total_
printf("%d packets transmitted, %d received, %d%% packet loss, time %"
PRIu32 ".06%" PRIu32 " s\n", count, success,
(100 - ((success * 100) / count)),
(uint32_t)total_time / SEC_IN_USEC, (uint32_t)total_time % SEC_IN_USEC);
(uint32_t)total_time / US_PER_SEC, (uint32_t)total_time % US_PER_SEC);
printf("rtt min/avg/max = "
"%" PRIu32 ".%03" PRIu32 "/"
"%" PRIu32 ".%03" PRIu32 "/"
"%" PRIu32 ".%03" PRIu32 " ms\n",
min_rtt / MS_IN_USEC, min_rtt % MS_IN_USEC,
avg_rtt / MS_IN_USEC, avg_rtt % MS_IN_USEC,
max_rtt / MS_IN_USEC, max_rtt % MS_IN_USEC);
min_rtt / US_PER_MS, min_rtt % US_PER_MS,
avg_rtt / US_PER_MS, avg_rtt % US_PER_MS,
max_rtt / US_PER_MS, max_rtt % US_PER_MS);
}
else {
printf("%d packets transmitted, 0 received, 100%% packet loss\n", count);
@ -148,7 +148,7 @@ int _icmpv6_ping(int argc, char **argv)
{
int count = 3, success = 0, remaining, stat_interval = 0, stat_counter = 0;
size_t payload_len = 4;
uint32_t delay = 1 * SEC_IN_MS;
uint32_t delay = 1 * MS_PER_SEC;
char *addr_str;
ipv6_addr_t addr;
kernel_pid_t src_iface;
@ -237,7 +237,7 @@ int _icmpv6_ping(int argc, char **argv)
while ((remaining--) > 0) {
gnrc_pktsnip_t *pkt;
uint32_t start, timeout = 1 * SEC_IN_USEC;
uint32_t start, timeout = 1 * US_PER_SEC;
pkt = gnrc_icmpv6_echo_build(ICMPV6_ECHO_REQ, id, ++max_seq_expected,
NULL, payload_len);
@ -318,7 +318,7 @@ int _icmpv6_ping(int argc, char **argv)
}
if (remaining > 0) {
xtimer_usleep64(delay * MS_IN_USEC);
xtimer_usleep64(delay * US_PER_MS);
}
if ((++stat_counter == stat_interval) || (remaining == 0)) {
uint64_t total_time = xtimer_now_usec64() - ping_start;

6
sys/timex/timex.c

@ -38,8 +38,8 @@ timex_t timex_add(const timex_t a, const timex_t b)
result.seconds = a.seconds + b.seconds;
result.microseconds = a.microseconds + b.microseconds;
if (result.microseconds > SEC_IN_USEC) {
result.microseconds -= SEC_IN_USEC;
if (result.microseconds > US_PER_SEC) {
result.microseconds -= US_PER_SEC;
result.seconds++;
}
@ -77,7 +77,7 @@ timex_t timex_sub(const timex_t a, const timex_t b)
}
else {
result.seconds = a.seconds - b.seconds - 1;
result.microseconds = a.microseconds + SEC_IN_USEC - b.microseconds;
result.microseconds = a.microseconds + US_PER_SEC - b.microseconds;
}
return result;

4
sys/trickle/trickle.c

@ -48,11 +48,11 @@ void trickle_interval(trickle_t *trickle)
trickle->c = 0;
trickle->t = (trickle->I / 2) + random_uint32_range(0, (trickle->I / 2) + 1);
trickle->msg_callback_time = trickle->t * SEC_IN_MS;
trickle->msg_callback_time = trickle->t * MS_PER_SEC;
xtimer_set_msg64(&trickle->msg_callback_timer, trickle->msg_callback_time,
&trickle->msg_callback, trickle->pid);
trickle->msg_interval_time = trickle->I * SEC_IN_MS;
trickle->msg_interval_time = trickle->I * MS_PER_SEC;
xtimer_set_msg64(&trickle->msg_interval_timer, trickle->msg_interval_time,
&trickle->msg_interval, trickle->pid);
}

2
sys/xtimer/xtimer.c

@ -183,7 +183,7 @@ void xtimer_now_timex(timex_t *out)
uint64_t now = xtimer_usec_from_ticks64(xtimer_now64());
out->seconds = div_u64_by_1000000(now);
out->microseconds = now - (out->seconds * SEC_IN_USEC);
out->microseconds = now - (out->seconds * US_PER_SEC);
}
/* Prepares the message to trigger the timeout.

2
sys/xtimer/xtimer_posix.c

@ -19,7 +19,7 @@
unsigned int sleep(unsigned int seconds)
{
xtimer_usleep64(seconds * SEC_IN_USEC);
xtimer_usleep64(seconds * US_PER_SEC);
return 0;
}

2
tests/bitarithm_timings/main.c

@ -35,7 +35,7 @@
#include "xtimer.h"
#define TIMEOUT_S (5ul)
#define TIMEOUT (TIMEOUT_S * SEC_IN_USEC)
#define TIMEOUT (TIMEOUT_S * US_PER_SEC)
#define PER_ITERATION (4)
static void callback(void *done_)

2
tests/board_calliope-mini/main.c

@ -23,7 +23,7 @@
#include "timex.h"
#include "mini.h"
#define DELAY (120 * MS_IN_USEC)
#define DELAY (120 * US_PER_MS)
int main(void)
{

2
tests/board_microbit/main.c

@ -23,7 +23,7 @@
#include "timex.h"
#include "microbit.h"
#define DELAY (120 * MS_IN_USEC)
#define DELAY (120 * US_PER_MS)
int main(void)
{

2
tests/driver_bh1750/main.c

@ -24,7 +24,7 @@
#include "bh1750fvi.h"
#include "bh1750fvi_params.h"
#define RATE (200LU * MS_IN_USEC) /* 200ms */
#define RATE (200LU * US_PER_MS) /* 200ms */
int main(void)
{

2
tests/driver_dht/main.c

@ -57,7 +57,7 @@ int main(void)
printf("temp: %i.%i°C, ", int_temp, dec_temp);
printf("relative humidity: %i.%i%%\n", int_hum, dec_hum);
xtimer_usleep(2000 * MS_IN_USEC);
xtimer_usleep(2000 * US_PER_MS);
}
}

2
tests/driver_jc42/main.c

@ -75,7 +75,7 @@ int main(void)
printf("temperature: %d.%02d C\n", temperature / 100, temperature % 100);
/* sleep between measurements */
xtimer_usleep(1000 * MS_IN_USEC);