File: time.h

package info (click to toggle)
openntpd 1%3A6.2p3-4.2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 2,472 kB
  • sloc: ansic: 9,413; sh: 4,425; yacc: 692; makefile: 310
file content (43 lines) | stat: -rw-r--r-- 888 bytes parent folder | download | duplicates (4)
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
35
36
37
38
39
40
41
42
43
/*
 * Public domain
 * sys/time.h compatibility shim
 */

#ifndef LIBCOMPAT_SYS_TIME_H
#define LIBCOMPAT_SYS_TIME_H

#include_next <sys/time.h>

#include <stdint.h>

int adjfreq(const int64_t *freq, int64_t *oldfreq);

#ifdef __sun
static inline int sun_adjtime(struct timeval *delta, struct timeval *olddelta)
{
	struct timeval zero = {0};
	int rc;

	/*
	 * adjtime on Solaris appears to handle a NULL delta differently than
	 * other OSes. Fill in a dummy value as necessary.
	 */
	if (delta)
		rc = adjtime(delta, olddelta);
	else
		rc = adjtime(&zero, olddelta);

	/*
	 * Old delta on Solaris frequently gets stuck with 1 ms left.
	 * Round down to 0 in this case so we do not get flapping clock sync.
	 */
	if (rc == 0 && olddelta &&
	    olddelta->tv_sec == 0 && olddelta->tv_usec == 1)
		olddelta->tv_usec = 0;

	return rc;
}
#define adjtime(d, o) sun_adjtime(d, o)
#endif

#endif