1 /* Copyright (C) 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If
16 not, write to the, 1992 Free Software Foundation, Inc., 675 Mass Ave,
17 Cambridge, MA 02139, USA. */
28 /* A time value that is accurate to the nearest
29 microsecond but also has a range of years. */
32 int tv_sec
; /* Seconds. */
33 int tv_usec
; /* Microseconds. */
36 /* POSIX.4 structure for a time value. This is like a `struct timeval' but
37 has nanoseconds instead of microseconds. */
40 long int ts_sec
; /* Seconds. */
41 long int ts_nsec
; /* Nanoseconds. */
44 /* Macros for converting between `struct timeval' and `struct timespec'. */
45 #define TIMEVAL_TO_TIMESPEC(tv, ts) { \
46 (ts)->ts_sec = (tv)->tv_sec; \
47 (ts)->ts_nsec = (tv)->tv_usec * 1000; \
49 #define TIMESPEC_TO_TIMEVAL(tv, ts) { \
50 (tv)->tv_sec = (ts)->ts_sec; \
51 (tv)->tv_usec = (ts)->ts_nsec / 1000; \
55 /* Structure crudely representing a timezone.
56 This is obsolete and should never be used. */
59 int tz_minuteswest
; /* Minutes west of GMT. */
60 int tz_dsttime
; /* Nonzero if DST is ever in effect. */
63 /* Get the current time of day and timezone information,
64 putting it into *TV and *TZ. If TZ is NULL, *TZ is not filled.
65 Returns 0 on success, -1 on errors.
66 NOTE: This form of timezone information is obsolete.
67 Use the functions and variables declared in <time.h> instead. */
68 extern int __gettimeofday
__P ((struct timeval
*__tv
,
69 struct timezone
*__tz
));
70 extern int gettimeofday
__P ((struct timeval
*__tv
,
71 struct timezone
*__tz
));
73 /* Set the current time of day and timezone information.
74 This call is restricted to the super-user. */
75 extern int __settimeofday
__P ((__const
struct timeval
*__tv
,
76 __const
struct timezone
*__tz
));
77 extern int settimeofday
__P ((__const
struct timeval
*__tv
,
78 __const
struct timezone
*__tz
));
80 /* Adjust the current time of day by the amount in DELTA.
81 If OLDDELTA is not NULL, it is filled in with the amount
82 of time adjustment remaining to be done from the last `adjtime' call.
83 This call is restricted to the super-user. */
84 extern int __adjtime
__P ((__const
struct timeval
*__delta
,
85 struct timeval
*__olddelta
));
86 extern int adjtime
__P ((__const
struct timeval
*__delta
,
87 struct timeval
*__olddelta
));
90 /* Values for the first argument to `getitimer' and `setitimer'. */
93 /* Timers run in real time. */
95 /* Timers run only when the process is executing. */
97 /* Timers run when the process is executing and when
98 the system is executing on behalf of the process. */
102 /* Type of the second argument to `getitimer' and
103 the second and third arguments `setitimer'. */
106 /* Value to put into `it_value' when the timer expires. */
107 struct timeval it_interval
;
108 /* Time to the next timer expiration. */
109 struct timeval it_value
;
112 /* Set *VALUE to the current setting of timer WHICH.
113 Return 0 on success, -1 on errors. */
114 extern int __getitimer
__P ((enum __itimer_which __which
,
115 struct itimerval
*__value
));
116 extern int getitimer
__P ((enum __itimer_which __which
,
117 struct itimerval
*__value
));
119 /* Set the timer WHICH to *NEW. If OLD is not NULL,
120 set *OLD to the old value of timer WHICH.
121 Returns 0 on success, -1 on errors. */
122 extern int __setitimer
__P ((enum __itimer_which __which
,
123 struct itimerval
*__new
,
124 struct itimerval
*__old
));
125 extern int setitimer
__P ((enum __itimer_which __which
,
126 struct itimerval
*__new
,
127 struct itimerval
*__old
));
129 /* Change the access time of FILE to TVP[0] and
130 the modification time of FILE to TVP[1]. */
131 extern int __utimes
__P ((__const
char *__file
, struct timeval __tvp
[2]));
132 extern int utimes
__P ((__const
char *__file
, struct timeval __tvp
[2]));
135 /* Convenience macros for operations on timevals.
136 NOTE: `timercmp' does not work for >= or <=. */
137 #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
138 #define timercmp(tvp, uvp, CMP) \
139 ((tvp)->tv_sec CMP (uvp)->tv_sec || \
140 (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec CMP (uvp)->tv_usec)
141 #define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
147 #endif /* sys/time.h */