OSDN Git Service

(split) LDP: Change Makefile to stamp-based compilation
[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 2008-06-22 "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.  On failure, \-1 is returned, and
88 .I errno
89 is set to indicate the error.
90 .SH ERRORS
91 .TP
92 .B EINVAL
93 The adjustment in
94 .I delta
95 is outside the permitted range.
96 .TP
97 .B EPERM
98 The caller does not have sufficient privilege to adjust the time.
99 Under Linux the
100 .B CAP_SYS_TIME
101 capability is required.
102 .SH CONFORMING TO
103 4.3BSD, System V.
104 .SH NOTES
105 The adjustment that
106 .BR adjtime ()
107 makes to the clock is carried out in such a manner that the clock
108 is always monotonically increasing.
109 Using
110 .BR adjtime ()
111 to adjust the time prevents the problems that can be caused for certain
112 applications (e.g.,
113 .BR make (1))
114 by abrupt positive or negative jumps in the system time.
115
116 .BR adjtime ()
117 is intended to be used to make small adjustments to the system time.
118 Most systems impose a limit on the adjustment that can be specified in
119 .IR delta .
120 In the glibc implementation,
121 .I delta
122 must be less than or equal to (INT_MAX / 1000000 \- 2)
123 and greater than or equal to (INT_MIN / 1000000 + 2)
124 (respectively 2145 and \-2145 seconds on i386).
125 .SH BUGS
126 A longstanding bug
127 .\" http://sourceware.org/bugzilla/show_bug?id=2449
128 .\" http://bugzilla.kernel.org/show_bug.cgi?id=6761
129 meant that if
130 .I delta
131 was specified as NULL,
132 no valid information about the outstanding clock adjustment was returned in
133 .IR olddelta .
134 (In this circumstance,
135 .BR adjtime ()
136 should return the outstanding clock adjustment, without changing it.)
137 This bug is fixed
138 .\" Thanks to the new adjtimex() ADJ_OFFSET_SS_READ flag
139 on systems with glibc 2.8 or later and
140 Linux kernel 2.6.26 or later.
141 .SH SEE ALSO
142 .BR adjtimex (2),
143 .BR gettimeofday (2),
144 .BR time (7)