5 #include <linux/types.h>
7 #ifndef _STRUCT_TIMESPEC
8 #define _STRUCT_TIMESPEC
10 time_t tv_sec
; /* seconds */
11 long tv_nsec
; /* nanoseconds */
13 #endif /* _STRUCT_TIMESPEC */
16 * Change timeval to jiffies, trying to avoid the
17 * most obvious overflows..
19 * And some not so obvious.
21 * Note that we don't want to return MAX_LONG, because
22 * for various timeout reasons we often end up having
23 * to wait "jiffies+1" in order to guarantee that we wait
24 * at _least_ "jiffies" - so "jiffies+1" had better still
27 #define MAX_JIFFY_OFFSET ((~0UL >> 1)-1)
29 static __inline__
unsigned long
30 timespec_to_jiffies(struct timespec
*value
)
32 unsigned long sec
= value
->tv_sec
;
33 long nsec
= value
->tv_nsec
;
35 if (sec
>= (MAX_JIFFY_OFFSET
/ HZ
))
36 return MAX_JIFFY_OFFSET
;
37 nsec
+= 1000000000L / HZ
- 1;
38 nsec
/= 1000000000L / HZ
;
39 return HZ
* sec
+ nsec
;
42 static __inline__
void
43 jiffies_to_timespec(unsigned long jiffies
, struct timespec
*value
)
45 value
->tv_nsec
= (jiffies
% HZ
) * (1000000000L / HZ
);
46 value
->tv_sec
= jiffies
/ HZ
;
50 time_t tv_sec
; /* seconds */
51 suseconds_t tv_usec
; /* microseconds */
55 int tz_minuteswest
; /* minutes west of Greenwich */
56 int tz_dsttime
; /* type of dst correction */
59 #define NFDBITS __NFDBITS
62 extern void do_gettimeofday(struct timeval
*tv
);
63 extern void do_settimeofday(struct timeval
*tv
);
64 extern void get_fast_time(struct timeval
*tv
);
65 extern void (*do_get_fast_time
)(struct timeval
*);
68 #define FD_SETSIZE __FD_SETSIZE
69 #define FD_SET(fd,fdsetp) __FD_SET(fd,fdsetp)
70 #define FD_CLR(fd,fdsetp) __FD_CLR(fd,fdsetp)
71 #define FD_ISSET(fd,fdsetp) __FD_ISSET(fd,fdsetp)
72 #define FD_ZERO(fdsetp) __FD_ZERO(fdsetp)
75 * Names of the interval timers, and structure
76 * defining a timer setting.
79 #define ITIMER_VIRTUAL 1
83 struct timespec it_interval
; /* timer period */
84 struct timespec it_value
; /* timer expiration */
88 struct timeval it_interval
; /* timer interval */
89 struct timeval it_value
; /* current value */