1adjtime(3) Library Functions Manual adjtime(3)
2
3
4
6 adjtime - correct the time to synchronize the system clock
7
9 Standard C library (libc, -lc)
10
12 #include <sys/time.h>
13
14 int adjtime(const struct timeval *delta, struct timeval *olddelta);
15
16 Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
17
18 adjtime():
19 Since glibc 2.19:
20 _DEFAULT_SOURCE
21 glibc 2.19 and earlier:
22 _BSD_SOURCE
23
25 The adjtime() function gradually adjusts the system clock (as returned
26 by gettimeofday(2)). The amount of time by which the clock is to be
27 adjusted is specified in the structure pointed to by delta. This
28 structure has the following form:
29
30 struct timeval {
31 time_t tv_sec; /* seconds */
32 suseconds_t tv_usec; /* microseconds */
33 };
34
35 If the adjustment in delta is positive, then the system clock is
36 speeded up by some small percentage (i.e., by adding a small amount of
37 time to the clock value in each second) until the adjustment has been
38 completed. If the adjustment in delta is negative, then the clock is
39 slowed down in a similar fashion.
40
41 If a clock adjustment from an earlier adjtime() call is already in
42 progress at the time of a later adjtime() call, and delta is not NULL
43 for the later call, then the earlier adjustment is stopped, but any al‐
44 ready completed part of that adjustment is not undone.
45
46 If olddelta is not NULL, then the buffer that it points to is used to
47 return the amount of time remaining from any previous adjustment that
48 has not yet been completed.
49
51 On success, adjtime() returns 0. On failure, -1 is returned, and errno
52 is set to indicate the error.
53
55 EINVAL The adjustment in delta is outside the permitted range.
56
57 EPERM The caller does not have sufficient privilege to adjust the
58 time. Under Linux, the CAP_SYS_TIME capability is required.
59
61 For an explanation of the terms used in this section, see at‐
62 tributes(7).
63
64 ┌────────────────────────────────────────────┬───────────────┬─────────┐
65 │Interface │ Attribute │ Value │
66 ├────────────────────────────────────────────┼───────────────┼─────────┤
67 │adjtime() │ Thread safety │ MT-Safe │
68 └────────────────────────────────────────────┴───────────────┴─────────┘
69
71 None.
72
74 4.3BSD, System V.
75
77 The adjustment that adjtime() makes to the clock is carried out in such
78 a manner that the clock is always monotonically increasing. Using
79 adjtime() to adjust the time prevents the problems that can be caused
80 for certain applications (e.g., make(1)) by abrupt positive or negative
81 jumps in the system time.
82
83 adjtime() is intended to be used to make small adjustments to the
84 system time. Most systems impose a limit on the adjustment that can be
85 specified in delta. In the glibc implementation, delta must be less
86 than or equal to (INT_MAX / 1000000 - 2) and greater than or equal to
87 (INT_MIN / 1000000 + 2) (respectively 2145 and -2145 seconds on i386).
88
90 A longstanding bug meant that if delta was specified as NULL, no valid
91 information about the outstanding clock adjustment was returned in
92 olddelta. (In this circumstance, adjtime() should return the
93 outstanding clock adjustment, without changing it.) This bug is fixed
94 on systems with glibc 2.8 or later and Linux kernel 2.6.26 or later.
95
97 adjtimex(2), gettimeofday(2), time(7)
98
99
100
101Linux man-pages 6.05 2023-07-20 adjtime(3)