OSDN Git Service

1757cb524fcb8382a9d3133c96eb1effa3c1f426
[linuxjm/LDP_man-pages.git] / original / man3 / adjtime.3
1 .\" Copyright (c) 2006 by Michael Kerrisk <mtk.manpages@gmail.com>
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .TH ADJTIME 3 2013-10-07 "Linux" "Linux Programmer's Manual"
26 .SH NAME
27 adjtime \- correct the time to synchronize the system clock
28 .SH SYNOPSIS
29 .nf
30 .BI "int adjtime(const struct timeval *" delta ", struct timeval *" olddelta );
31 .fi
32 .sp
33 .in -4n
34 Feature Test Macro Requirements for glibc (see
35 .BR feature_test_macros (7)):
36 .in
37 .sp
38 .BR adjtime ():
39 _BSD_SOURCE
40 .SH DESCRIPTION
41 The
42 .BR adjtime ()
43 function gradually adjusts the system clock (as returned by
44 .BR gettimeofday (2)).
45 The amount of time by which the clock is to be adjusted is specified
46 in the structure pointed to by
47 .IR delta .
48 This structure has the following form:
49 .in +4n
50 .nf
51
52 struct timeval {
53     time_t      tv_sec;     /* seconds */
54     suseconds_t tv_usec;    /* microseconds */
55 };
56 .fi
57 .in
58 .PP
59 If the adjustment in
60 .I delta
61 is positive, then the system clock is speeded up by some
62 small percentage (i.e., by adding a small
63 amount of time to the clock value in each second) until the adjustment
64 has been completed.
65 If the adjustment in
66 .I delta
67 is negative, then the clock is slowed down in a similar fashion.
68
69 If a clock adjustment from an earlier
70 .BR adjtime ()
71 call is already in progress
72 at the time of a later
73 .BR adjtime ()
74 call, and
75 .I delta
76 is not NULL for the later call, then the earlier adjustment is stopped,
77 but any already completed part of that adjustment is not undone.
78
79 If
80 .I olddelta
81 is not NULL, then the buffer that it points to is used to return
82 the amount of time remaining from any previous adjustment that
83 has not yet been completed.
84 .SH RETURN VALUE
85 On success,
86 .BR adjtime ()
87 returns 0.
88 On failure, \-1 is returned, and
89 .I errno
90 is set to indicate the error.
91 .SH ERRORS
92 .TP
93 .B EINVAL
94 The adjustment in
95 .I delta
96 is outside the permitted range.
97 .TP
98 .B EPERM
99 The caller does not have sufficient privilege to adjust the time.
100 Under Linux the
101 .B CAP_SYS_TIME
102 capability is required.
103 .SH ATTRIBUTES
104 .SS Multithreading (see pthreads(7))
105 The
106 .BR adjtime ()
107 function is thread-safe.
108 .SH CONFORMING TO
109 4.3BSD, System V.
110 .SH NOTES
111 The adjustment that
112 .BR adjtime ()
113 makes to the clock is carried out in such a manner that the clock
114 is always monotonically increasing.
115 Using
116 .BR adjtime ()
117 to adjust the time prevents the problems that can be caused for certain
118 applications (e.g.,
119 .BR make (1))
120 by abrupt positive or negative jumps in the system time.
121
122 .BR adjtime ()
123 is intended to be used to make small adjustments to the system time.
124 Most systems impose a limit on the adjustment that can be specified in
125 .IR delta .
126 In the glibc implementation,
127 .I delta
128 must be less than or equal to (INT_MAX / 1000000 \- 2)
129 and greater than or equal to (INT_MIN / 1000000 + 2)
130 (respectively 2145 and \-2145 seconds on i386).
131 .SH BUGS
132 A longstanding bug
133 .\" http://sourceware.org/bugzilla/show_bug?id=2449
134 .\" http://bugzilla.kernel.org/show_bug.cgi?id=6761
135 meant that if
136 .I delta
137 was specified as NULL,
138 no valid information about the outstanding clock adjustment was returned in
139 .IR olddelta .
140 (In this circumstance,
141 .BR adjtime ()
142 should return the outstanding clock adjustment, without changing it.)
143 This bug is fixed
144 .\" Thanks to the new adjtimex() ADJ_OFFSET_SS_READ flag
145 on systems with glibc 2.8 or later and
146 Linux kernel 2.6.26 or later.
147 .SH SEE ALSO
148 .BR adjtimex (2),
149 .BR gettimeofday (2),
150 .BR time (7)
151 .SH COLOPHON
152 This page is part of release 3.67 of the Linux
153 .I man-pages
154 project.
155 A description of the project,
156 information about reporting bugs,
157 and the latest version of this page,
158 can be found at
159 \%http://www.kernel.org/doc/man\-pages/.