]> sourceware.org Git - newlib-cygwin.git/blob - newlib/libc/include/sys/time.h
* include/sys/time.h: Move more cygwin stuff to cygwin-specific header.
[newlib-cygwin.git] / newlib / libc / include / sys / time.h
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. */
4
5 #ifndef _SYS_TIME_H_
6 #define _SYS_TIME_H_
7
8 #include <_ansi.h>
9 #include <sys/types.h>
10
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14
15 #ifndef _WINSOCK_H
16 struct timeval {
17 long tv_sec;
18 long tv_usec;
19 };
20
21 struct timezone {
22 int tz_minuteswest;
23 int tz_dsttime;
24 };
25
26 #ifdef __CYGWIN__
27 #include <cygwin/sys_time.h>
28 #endif /* __CYGWIN__ */
29
30 #endif /* _WINSOCK_H */
31
32 #define ITIMER_REAL 0
33 #define ITIMER_VIRTUAL 1
34 #define ITIMER_PROF 2
35
36 struct itimerval {
37 struct timeval it_interval;
38 struct timeval it_value;
39 };
40
41 /* BSD time macros used by RTEMS code */
42 #if defined (__rtems__) || defined (__CYGWIN__)
43
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__) */
72
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, const 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));
79
80 #ifdef __cplusplus
81 }
82 #endif
83 #endif /* _SYS_TIME_H_ */
This page took 0.041696 seconds and 6 git commands to generate.