2023-05-20 10:05:22 +00:00
|
|
|
/* bits/timespec.h: The timespec and timeval structures. */
|
2023-01-07 10:21:53 +00:00
|
|
|
|
2023-01-06 23:21:08 +00:00
|
|
|
#ifndef _BITS_TIMESPEC_H
|
|
|
|
#define _BITS_TIMESPEC_H
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
struct timespec
|
|
|
|
{
|
|
|
|
time_t tv_sec;
|
|
|
|
long tv_nsec;
|
|
|
|
};
|
|
|
|
|
2023-05-20 10:05:22 +00:00
|
|
|
struct timeval
|
|
|
|
{
|
|
|
|
time_t tv_sec;
|
|
|
|
suseconds_t tv_usec;
|
|
|
|
};
|
|
|
|
|
2023-01-06 23:21:08 +00:00
|
|
|
#endif
|
2023-06-03 11:15:10 +00:00
|
|
|
|
|
|
|
#if defined(IN_MOON) || defined(_INCLUDE_TIMESPEC_MACROS)
|
|
|
|
#ifndef _TIMESPEC_MACROS_INCLUDED
|
|
|
|
#define _TIMESPEC_MACROS_INCLUDED
|
|
|
|
#define timespecadd(a, b, res) \
|
|
|
|
do { \
|
|
|
|
(res)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
|
|
|
|
(res)->tv_nsec = (a)->tv_nsec + (b)->tv_nsec; \
|
|
|
|
while ((res)->tv_nsec >= 1'000'000'000) \
|
|
|
|
{ \
|
|
|
|
(res)->tv_sec++; \
|
|
|
|
(res)->tv_nsec -= 1'000'000'000; \
|
|
|
|
} \
|
|
|
|
} while (0);
|
|
|
|
#endif
|
2023-11-16 20:48:18 +00:00
|
|
|
|
2024-12-23 21:56:56 +00:00
|
|
|
#define TIMEVAL_TO_TIMESPEC(x) { .tv_sec = (x).tv_sec, .tv_nsec = (x).tv_usec * 1000 }
|
|
|
|
#define TIMESPEC_TO_TIMEVAL(x) { .tv_sec = (x).tv_sec, .tv_usec = (x).tv_nsec / 1000 }
|
2023-06-03 11:15:10 +00:00
|
|
|
#endif
|