Luna/libc/include/bits/timespec.h

37 lines
1.5 KiB
C
Raw Normal View History

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
#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
#endif