mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/timex: Fix integer width issue
The macros US_PER_MS and friends are assumed to be 32 bit unsigned integers by users. However, e.g. on AVR a `1000U` is only 16 bit long. Thus, e.g. `xtimer_usleep(100 * US_PER_MS)` will wrap around and only sleep for ~34ms. This commit declares them as unsigned long, which is on all currently supported platforms 32 bit wide.
This commit is contained in:
parent
60aabbec25
commit
654b558343
@ -31,27 +31,27 @@ extern "C" {
|
||||
/**
|
||||
* @brief The number of microseconds per second
|
||||
*/
|
||||
#define US_PER_SEC (1000000U)
|
||||
#define US_PER_SEC (1000000LU)
|
||||
|
||||
/**
|
||||
* @brief The number of seconds per minute
|
||||
*/
|
||||
#define SEC_PER_MIN (60U)
|
||||
#define SEC_PER_MIN (60LU)
|
||||
|
||||
/**
|
||||
* @brief The number of centiseconds per second
|
||||
*/
|
||||
#define CS_PER_SEC (100U)
|
||||
#define CS_PER_SEC (100LU)
|
||||
|
||||
/**
|
||||
* @brief The number of milliseconds per second
|
||||
*/
|
||||
#define MS_PER_SEC (1000U)
|
||||
#define MS_PER_SEC (1000LU)
|
||||
|
||||
/**
|
||||
* @brief The number of microseconds per millisecond
|
||||
*/
|
||||
#define US_PER_MS (1000U)
|
||||
#define US_PER_MS (1000LU)
|
||||
|
||||
/**
|
||||
* @brief The number of microseconds per centisecond
|
||||
@ -61,7 +61,7 @@ extern "C" {
|
||||
/**
|
||||
* @brief The number of nanoseconds per microsecond
|
||||
*/
|
||||
#define NS_PER_US (1000U)
|
||||
#define NS_PER_US (1000LU)
|
||||
|
||||
/**
|
||||
* @brief The number of nanoseconds per second
|
||||
|
Loading…
Reference in New Issue
Block a user