Luna/libc/include/bits/timespec.h
apio 8bcec00a9d
All checks were successful
continuous-integration/drone/push Build is passing
kernel: Change the timer subsystem to use timespecs natively
2023-06-03 13:15:10 +02:00

37 lines
1.5 KiB
C

/* bits/timespec.h: The timespec and timeval structures. */
#ifndef _BITS_TIMESPEC_H
#define _BITS_TIMESPEC_H
#include <sys/types.h>
struct timespec
{
time_t tv_sec;
long tv_nsec;
};
struct timeval
{
time_t tv_sec;
suseconds_t tv_usec;
};
#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