## Coverage Report

#### Created: 2025-03-01 02:43

next uncovered line (L), next uncovered region (R), next uncovered branch (B)

    /libfido2/openbsd-compat/time.h

    Line
    Count
    Source
    1
    /*
    2
     * Public domain
    3
     * sys/time.h compatibility shim
    4
     */
    5
    6
    #if defined(_MSC_VER) && (_MSC_VER >= 1900)
    7
    #include <../ucrt/time.h>
    8
    #elif defined(_MSC_VER) && (_MSC_VER < 1900)
    9
    #include <../include/time.h>
    10
    #else
    11
    #include <time.h>
    12
    #endif
    13
    14
    #ifndef _COMPAT_TIME_H
    15
    #define _COMPAT_TIME_H
    16
    17
    #ifndef CLOCK_MONOTONIC
    18
    #define CLOCK_MONOTONIC CLOCK_REALTIME
    19
    #endif
    20
    21
    #ifndef CLOCK_REALTIME
    22
    #define CLOCK_REALTIME 0
    23
    #endif
    24
    25
    #ifndef HAVE_CLOCK_GETTIME
    26
    typedef int clockid_t;
    27
    int clock_gettime(clockid_t, struct timespec *);
    28
    #endif
    29
    30
    #ifdef HAVE_TIMESPECSUB
    31
    #include <sys/time.h>
    32
    #endif
    33
    34
    #ifndef HAVE_TIMESPECSUB
    35
    #define timespecadd(tsp, usp, vsp)                                      \
    36
            do {                                                            \
    37
                    (vsp)->tv_sec = (tsp)->tv_sec + (usp)->tv_sec;          \
    38
                    (vsp)->tv_nsec = (tsp)->tv_nsec + (usp)->tv_nsec;       \
    39
                    if ((vsp)->tv_nsec >= 1000000000L) {                    \
    40
                            (vsp)->tv_sec++;                                \
    41
                            (vsp)->tv_nsec -= 1000000000L;                  \
    42
                    }                                                       \
    43
            } while (0)
    44
    45
    #define timespecsub(tsp, usp, vsp)                                      \
    46
    3.50M
            do {                                                               \
    47
    3.50M
                    (vsp)->tv_sec = (tsp)->tv_sec - (usp)->tv_sec;          \
    48
    3.50M
                    (vsp)->tv_nsec = (tsp)->tv_nsec - (usp)->tv_nsec;       \
    49
    3.50M
                    if ((vsp)->tv_nsec < 0) {                               \
    50
    0
                            (vsp)->tv_sec--;                                \
    51
    0
                            (vsp)->tv_nsec += 1000000000L;                  \
    52
    0
                    }                                                        \
    53
    3.50M
            } while (0)
    54
    55
    #define timespeccmp(tsp, usp, cmp)                                      \
    56
    3.50M
            (((tsp)->tv_sec == (usp)->tv_sec) ?                              \
    57
    3.50M
                ((tsp)->tv_nsec cmp (usp)->tv_nsec) :                      \
    58
    3.50M
                ((tsp)->tv_sec cmp (usp)->tv_sec))
    59
    #endif
    60
    61
    #endif /* _COMPAT_TIME_H */