Merge pull request #297 from t-b/upgrade_msys_openssl_101m
[msysgit.git] / include / sys / time.h
blob8dae4dbb8d9995b530e0c09b7b3ec36bd8306ae8
1 /* time.h -- An implementation of the standard Unix <sys/time.h> file.
2 Written by Geoffrey Noer <noer@cygnus.com>
3 Public domain; no rights reserved. */
5 #ifndef _SYS_TIME_H_
6 #define _SYS_TIME_H_
8 #include <_ansi.h>
9 #include <sys/types.h>
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
15 #ifndef _WINSOCK_H
16 struct timeval {
17 long tv_sec;
18 long tv_usec;
21 struct timezone {
22 int tz_minuteswest;
23 int tz_dsttime;
26 #if defined(__CYGWIN__) || defined(__MSYS__)
27 #include <sys/select.h>
28 #endif /* __CYGWIN__ or __MSYS__ */
30 #endif /* _WINSOCK_H */
32 #define ITIMER_REAL 0
33 #define ITIMER_VIRTUAL 1
34 #define ITIMER_PROF 2
36 struct itimerval {
37 struct timeval it_interval;
38 struct timeval it_value;
41 /* BSD time macros used by RTEMS code */
42 #if defined (__rtems__) || defined (__CYGWIN__) || defined (__MSYS__)
44 /* Convenience macros for operations on timevals.
45 NOTE: `timercmp' does not work for >= or <=. */
46 #define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
47 #define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0)
48 #define timercmp(a, b, CMP) \
49 (((a)->tv_sec == (b)->tv_sec) ? \
50 ((a)->tv_usec CMP (b)->tv_usec) : \
51 ((a)->tv_sec CMP (b)->tv_sec))
52 #define timeradd(a, b, result) \
53 do { \
54 (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \
55 (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \
56 if ((result)->tv_usec >= 1000000) \
57 { \
58 ++(result)->tv_sec; \
59 (result)->tv_usec -= 1000000; \
60 } \
61 } while (0)
62 #define timersub(a, b, result) \
63 do { \
64 (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
65 (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
66 if ((result)->tv_usec < 0) { \
67 --(result)->tv_sec; \
68 (result)->tv_usec += 1000000; \
69 } \
70 } while (0)
71 #endif /* defined (__rtems__) || defined (__CYGWIN__) || defined (__MSYS__) */
73 int _EXFUN(gettimeofday, (struct timeval *__p, struct timezone *__z));
74 int _EXFUN(settimeofday, (const struct timeval *, const struct timezone *));
75 int _EXFUN(utimes, (const char *__path, struct timeval *__tvp));
76 int _EXFUN(getitimer, (int __which, struct itimerval *__value));
77 int _EXFUN(setitimer, (int __which, const struct itimerval *__value,
78 struct itimerval *__ovalue));
80 #ifdef __cplusplus
82 #endif
83 #endif /* _SYS_TIME_H_ */