/* 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