time.h
001:
002:
003:
004:
005:
006:
007:
008:
009:
010:
011:
012:
013:
014:
015:
016:
017:
018:
019:
020: #ifndef _SYS_TIME_H
021: #define _SYS_TIME_H 1
022:
023: #include <features.h>
024:
025: #include <bits/types.h>
026: #define __need_time_t
027: #include <time.h>
028: #define __need_timeval
029: #include <bits/time.h>
030:
031: #include <sys/select.h>
032:
033: #ifndef __suseconds_t_defined
034: typedef __suseconds_t suseconds_t;
035: # define __suseconds_t_defined
036: #endif
037:
038:
039: __BEGIN_DECLS
040:
041: #ifdef __USE_GNU
042:
043: # define TIMEVAL_TO_TIMESPEC(tv, ts) { \
044: (ts)->tv_sec = (tv)->tv_sec; \
045: (ts)->tv_nsec = (tv)->tv_usec * 1000; \
046: }
047: # define TIMESPEC_TO_TIMEVAL(tv, ts) { \
048: (tv)->tv_sec = (ts)->tv_sec; \
049: (tv)->tv_usec = (ts)->tv_nsec / 1000; \
050: }
051: #endif
052:
053:
054: #ifdef __USE_BSD
055:
056:
057: struct timezone
058: {
059: int tz_minuteswest;
060: int tz_dsttime;
061: };
062:
063: typedef struct timezone *__restrict __timezone_ptr_t;
064: #else
065: typedef void *__restrict __timezone_ptr_t;
066: #endif
067:
068:
069:
070:
071:
072:
073: extern int gettimeofday (struct timeval *__restrict __tv,
074: __timezone_ptr_t __tz) __THROW __nonnull ((1));
075:
076: #ifdef __USE_BSD
077:
078:
079: extern int settimeofday (__const struct timeval *__tv,
080: __const struct timezone *__tz)
081: __THROW __nonnull ((1));
082:
083:
084:
085:
086:
087: extern int adjtime (__const struct timeval *__delta,
088: struct timeval *__olddelta) __THROW;
089: #endif
090:
091:
092:
093: enum __itimer_which
094: {
095:
096: ITIMER_REAL = 0,
097: #define ITIMER_REAL ITIMER_REAL
098:
099: ITIMER_VIRTUAL = 1,
100: #define ITIMER_VIRTUAL ITIMER_VIRTUAL
101:
102:
103: ITIMER_PROF = 2
104: #define ITIMER_PROF ITIMER_PROF
105: };
106:
107:
108:
109: struct itimerval
110: {
111:
112: struct timeval it_interval;
113:
114: struct timeval it_value;
115: };
116:
117: #if defined __USE_GNU && !defined __cplusplus
118:
119:
120: typedef enum __itimer_which __itimer_which_t;
121: #else
122: typedef int __itimer_which_t;
123: #endif
124:
125:
126:
127: extern int getitimer (__itimer_which_t __which,
128: struct itimerval *__value) __THROW;
129:
130:
131:
132:
133: extern int setitimer (__itimer_which_t __which,
134: __const struct itimerval *__restrict __new,
135: struct itimerval *__restrict __old) __THROW;
136:
137:
138:
139:
140: extern int utimes (__const char *__file, __const struct timeval __tvp[2])
141: __THROW __nonnull ((1));
142:
143: #ifdef __USE_BSD
144:
145: extern int lutimes (__const char *__file, __const struct timeval __tvp[2])
146: __THROW __nonnull ((1));
147:
148:
149: extern int futimes (int __fd, __const struct timeval __tvp[2]) __THROW;
150: #endif
151:
152: #ifdef __USE_GNU
153:
154:
155:
156: extern int futimesat (int __fd, __const char *__file,
157: __const struct timeval __tvp[2]) __THROW;
158: #endif
159:
160:
161: #ifdef __USE_BSD
162:
163:
164: # define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
165: # define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
166: # define timercmp(a, b, CMP) \
167: (((a)->tv_sec == (b)->tv_sec) ? \
168: ((a)->tv_usec CMP (b)->tv_usec) : \
169: ((a)->tv_sec CMP (b)->tv_sec))
170: # define timeradd(a, b, result) \
171: do { \
172: (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
173: (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
174: if ((result)->tv_usec >= 1000000) \
175: { \
176: ++(result)->tv_sec; \
177: (result)->tv_usec -= 1000000; \
178: } \
179: } while (0)
180: # define timersub(a, b, result) \
181: do { \
182: (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
183: (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
184: if ((result)->tv_usec < 0) { \
185: --(result)->tv_sec; \
186: (result)->tv_usec += 1000000; \
187: } \
188: } while (0)
189: #endif
190:
191: __END_DECLS
192:
193: #endif
194:
© Andrew Scott 2006 -
2024,
All Rights Reserved