OSDN Git Service

LDP: Update original to LDP v3.68
[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 2014-05-28 "Linux" "Linux Programmer's Manual"
26 .SH NAME
27 adjtime \- correct the time to synchronize the system clock
28 .SH SYNOPSIS
29 .nf
30 .B #include <sys/time.h>
31 .sp
32 .BI "int adjtime(const struct timeval *" delta ", struct timeval *" olddelta );
33 .fi
34 .sp
35 .in -4n
36 Feature Test Macro Requirements for glibc (see
37 .BR feature_test_macros (7)):
38 .in
39 .sp
40 .BR adjtime ():
41 _BSD_SOURCE
42 .SH DESCRIPTION
43 The
44 .BR adjtime ()
45 function gradually adjusts the system clock (as returned by
46 .BR gettimeofday (2)).
47 The amount of time by which the clock is to be adjusted is specified
48 in the structure pointed to by
49 .IR delta .
50 This structure has the following form:
51 .in +4n
52 .nf
53
54 struct timeval {
55     time_t      tv_sec;     /* seconds */
56     suseconds_t tv_usec;    /* microseconds */
57 };
58 .fi
59 .in
60 .PP
61 If the adjustment in
62 .I delta
63 is positive, then the system clock is speeded up by some
64 small percentage (i.e., by adding a small
65 amount of time to the clock value in each second) until the adjustment
66 has been completed.
67 If the adjustment in
68 .I delta
69 is negative, then the clock is slowed down in a similar fashion.
70
71 If a clock adjustment from an earlier
72 .BR adjtime ()
73 call is already in progress
74 at the time of a later
75 .BR adjtime ()
76 call, and
77 .I delta
78 is not NULL for the later call, then the earlier adjustment is stopped,
79 but any already completed part of that adjustment is not undone.
80
81 If
82 .I olddelta
83 is not NULL, then the buffer that it points to is used to return
84 the amount of time remaining from any previous adjustment that
85 has not yet been completed.
86 .SH RETURN VALUE
87 On success,
88 .BR adjtime ()
89 returns 0.
90 On failure, \-1 is returned, and
91 .I errno
92 is set to indicate the error.
93 .SH ERRORS
94 .TP
95 .B EINVAL
96 The adjustment in
97 .I delta
98 is outside the permitted range.
99 .TP
100 .B EPERM
101 The caller does not have sufficient privilege to adjust the time.
102 Under Linux the
103 .B CAP_SYS_TIME
104 capability is required.
105 .SH ATTRIBUTES
106 .SS Multithreading (see pthreads(7))
107 The
108 .BR adjtime ()
109 function is thread-safe.
110 .SH CONFORMING TO
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 can be caused for certain
120 applications (e.g.,
121 .BR make (1))
122 by abrupt positive or negative jumps in the system time.
123
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)
153 .SH COLOPHON
154 This page is part of release 3.68 of the Linux
155 .I man-pages
156 project.
157 A description of the project,
158 information about reporting bugs,
159 and the latest version of this page,
160 can be found at
161 \%http://www.kernel.org/doc/man\-pages/.