Debian Codegraph @

upstream/debian-trixie/man3/adjtime.3

raw
1 '\" t
2 .\" Copyright (c) 2006 by Michael Kerrisk <[email protected]>
3 .\"
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
5 .\"
6 .TH adjtime 3 2024-05-02 "Linux man-pages 6.9.1"
7 .SH NAME
8 adjtime \- correct the time to synchronize the system clock
9 .SH LIBRARY
10 Standard C library
11 .RI ( libc ", " \-lc )
12 .SH SYNOPSIS
13 .nf
14 .B #include <sys/time.h>
15 .P
16 .BI "int adjtime(const struct timeval *" delta ", struct timeval *" olddelta );
17 .fi
18 .P
19 .RS -4
20 Feature Test Macro Requirements for glibc (see
21 .BR feature_test_macros (7)):
22 .RE
23 .P
24 .BR adjtime ():
25 .nf
26 Since glibc 2.19:
27 _DEFAULT_SOURCE
28 glibc 2.19 and earlier:
29 _BSD_SOURCE
30 .fi
31 .SH DESCRIPTION
32 The
33 .BR adjtime ()
34 function gradually adjusts the system clock (as returned by
35 .BR gettimeofday (2)).
36 The amount of time by which the clock is to be adjusted is specified
37 in the structure pointed to by
38 .IR delta .
39 This structure has the following form:
40 .P
41 .in +4n
42 .EX
43 struct timeval {
44 time_t tv_sec; /* seconds */
45 suseconds_t tv_usec; /* microseconds */
46 };
47 .EE
48 .in
49 .P
50 If the adjustment in
51 .I delta
52 is positive, then the system clock is speeded up by some
53 small percentage (i.e., by adding a small
54 amount of time to the clock value in each second) until the adjustment
55 has been completed.
56 If the adjustment in
57 .I delta
58 is negative, then the clock is slowed down in a similar fashion.
59 .P
60 If a clock adjustment from an earlier
61 .BR adjtime ()
62 call is already in progress
63 at the time of a later
64 .BR adjtime ()
65 call, and
66 .I delta
67 is not NULL for the later call, then the earlier adjustment is stopped,
68 but any already completed part of that adjustment is not undone.
69 .P
70 If
71 .I olddelta
72 is not NULL, then the buffer that it points to is used to return
73 the amount of time remaining from any previous adjustment that
74 has not yet been completed.
75 .SH RETURN VALUE
76 On success,
77 .BR adjtime ()
78 returns 0.
79 On failure, \-1 is returned, and
80 .I errno
81 is set to indicate the error.
82 .SH ERRORS
83 .TP
84 .B EINVAL
85 The adjustment in
86 .I delta
87 is outside the permitted range.
88 .TP
89 .B EPERM
90 The caller does not have sufficient privilege to adjust the time.
91 Under Linux, the
92 .B CAP_SYS_TIME
93 capability is required.
94 .SH ATTRIBUTES
95 For an explanation of the terms used in this section, see
96 .BR attributes (7).
97 .TS
98 allbox;
99 lbx lb lb
100 l l l.
101 Interface Attribute Value
102 T{
103 .na
104 .nh
105 .BR adjtime ()
106 T} Thread safety MT-Safe
107 .TE
108 .SH STANDARDS
109 None.
110 .SH HISTORY
111 4.3BSD, System V.
112 .SH NOTES
113 The adjustment that
114 .BR adjtime ()
115 makes to the clock is carried out in such a manner that the clock
116 is always monotonically increasing.
117 Using
118 .BR adjtime ()
119 to adjust the time prevents the problems that could be caused for certain
120 applications (e.g.,
121 .BR make (1))
122 by abrupt positive or negative jumps in the system time.
123 .P
124 .BR adjtime ()
125 is intended to be used to make small adjustments to the system time.
126 Most systems impose a limit on the adjustment that can be specified in
127 .IR delta .
128 In the glibc implementation,
129 .I delta
130 must be less than or equal to (INT_MAX / 1000000 \- 2)
131 and greater than or equal to (INT_MIN / 1000000 + 2)
132 (respectively 2145 and \-2145 seconds on i386).
133 .SH BUGS
134 A longstanding bug
135 .\" http://sourceware.org/bugzilla/show_bug?id=2449
136 .\" http://bugzilla.kernel.org/show_bug.cgi?id=6761
137 meant that if
138 .I delta
139 was specified as NULL,
140 no valid information about the outstanding clock adjustment was returned in
141 .IR olddelta .
142 (In this circumstance,
143 .BR adjtime ()
144 should return the outstanding clock adjustment, without changing it.)
145 This bug is fixed
146 .\" Thanks to the new adjtimex() ADJ_OFFSET_SS_READ flag
147 on systems with glibc 2.8 or later and
148 Linux kernel 2.6.26 or later.
149 .SH SEE ALSO
150 .BR adjtimex (2),
151 .BR gettimeofday (2),
152 .BR time (7)