From fd1f257ee818194140493c8ef327e79a2a82e7bd Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Wed, 15 Dec 2021 14:33:20 +0100 Subject: [PATCH] sys: factor out US_PER_SEC etc from timex.h into time_units.h --- sys/include/time_units.h | 77 ++++++++++++++++++++++++++++++++++++++++ sys/include/timex.h | 46 +----------------------- 2 files changed, 78 insertions(+), 45 deletions(-) create mode 100644 sys/include/time_units.h diff --git a/sys/include/time_units.h b/sys/include/time_units.h new file mode 100644 index 0000000000..fbd55a298b --- /dev/null +++ b/sys/include/time_units.h @@ -0,0 +1,77 @@ +/* + * Copyright (C) 2021 Kaspar Schleiser + * Copyright (C) 2014 Oliver Hahm + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @defgroup sys_time_units Time unit representations + * @brief Timestamp representation, computation, and conversion + * @ingroup sys + * + * @{ + * @file + * @brief Utility header providing time unit defines + */ + +#ifndef TIME_UNITS_H +#define TIME_UNITS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief The number of microseconds per second + */ +#define US_PER_SEC (1000000LU) + +/** + * @brief The number of seconds per minute + */ +#define SEC_PER_MIN (60LU) + +/** + * @brief The number of centiseconds per second + */ +#define CS_PER_SEC (100LU) + +/** + * @brief The number of milliseconds per second + */ +#define MS_PER_SEC (1000LU) + +/** + * @brief The number of microseconds per millisecond + */ +#define US_PER_MS (1000LU) + +/** + * @brief The number of microseconds per centisecond + */ +#define US_PER_CS (10000U) + +/** + * @brief The number of milliseconds per centisecond + */ +#define MS_PER_CS (10U) + +/** + * @brief The number of nanoseconds per microsecond + */ +#define NS_PER_US (1000LU) + +/** + * @brief The number of nanoseconds per second + */ +#define NS_PER_SEC (1000000000LLU) + +#ifdef __cplusplus +} +#endif + +/** @} */ +#endif /* TIME_UNITS_H */ diff --git a/sys/include/timex.h b/sys/include/timex.h index c88fe486b8..3396e21689 100644 --- a/sys/include/timex.h +++ b/sys/include/timex.h @@ -22,56 +22,12 @@ #include #include +#include "time_units.h" #ifdef __cplusplus extern "C" { #endif -/** - * @brief The number of microseconds per second - */ -#define US_PER_SEC (1000000LU) - -/** - * @brief The number of seconds per minute - */ -#define SEC_PER_MIN (60LU) - -/** - * @brief The number of centiseconds per second - */ -#define CS_PER_SEC (100LU) - -/** - * @brief The number of milliseconds per second - */ -#define MS_PER_SEC (1000LU) - -/** - * @brief The number of microseconds per millisecond - */ -#define US_PER_MS (1000LU) - -/** - * @brief The number of microseconds per centisecond - */ -#define US_PER_CS (10000U) - -/** - * @brief The number of milliseconds per centisecond - */ -#define MS_PER_CS (10U) - -/** - * @brief The number of nanoseconds per microsecond - */ -#define NS_PER_US (1000LU) - -/** - * @brief The number of nanoseconds per second - */ -#define NS_PER_SEC (1000000000LLU) - /** * @brief The maximum length of the string representation of a timex timestamp */