File: compat_time.h

package info (click to toggle)
rtl-433 25.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,192 kB
  • sloc: ansic: 55,982; cpp: 3,263; python: 2,544; php: 55; javascript: 43; sh: 18; makefile: 16
file content (34 lines) | stat: -rw-r--r-- 844 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/** @file
    compat_time addresses compatibility time functions.

    topic: high-resolution timestamps
    issue: <sys/time.h> is not available on Windows systems
    solution: provide a compatible version for Windows systems
*/

#ifndef INCLUDE_COMPAT_TIME_H_
#define INCLUDE_COMPAT_TIME_H_

// ensure struct timeval is known
#ifdef _WIN32
#include <winsock2.h>
#else
#include <sys/time.h>
#endif

/** Subtract `struct timeval` values.

    @param[out] result time difference result
    @param x first time value
    @param y second time value
    @return 1 if the difference is negative, otherwise 0.
*/
int timeval_subtract(struct timeval *result, struct timeval const *x, struct timeval const *y);

// platform-specific functions

#ifdef _WIN32
int gettimeofday(struct timeval *tv, void *tz);
#endif

#endif  /* INCLUDE_COMPAT_TIME_H_ */