diff options
author | Roland McGrath <roland@gnu.org> | 2000-02-04 03:21:18 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2000-02-04 03:21:18 +0000 |
commit | 8880a73970b23f10c720011cb910c0e0e1e02975 (patch) | |
tree | d1ce76577a1ace5312fc0576a93d4d8db1e89323 /pfinet/linux-src/include/linux/time.h | |
parent | 8399aa4ab7b849da57f4c59039f091526c9e2f98 (diff) | |
parent | 9fd51e9b0ad33a89a83fdbbb66bd20d85f7893fb (diff) | |
download | hurd-8880a73970b23f10c720011cb910c0e0e1e02975.tar.gz hurd-8880a73970b23f10c720011cb910c0e0e1e02975.tar.bz2 hurd-8880a73970b23f10c720011cb910c0e0e1e02975.zip |
Merge from vendor branch Linux:
Import of Linux 2.2.12 subset (ipv4 stack and related)
Diffstat (limited to 'pfinet/linux-src/include/linux/time.h')
-rw-r--r-- | pfinet/linux-src/include/linux/time.h | 92 |
1 files changed, 92 insertions, 0 deletions
diff --git a/pfinet/linux-src/include/linux/time.h b/pfinet/linux-src/include/linux/time.h new file mode 100644 index 00000000..53a125a0 --- /dev/null +++ b/pfinet/linux-src/include/linux/time.h @@ -0,0 +1,92 @@ +#ifndef _LINUX_TIME_H +#define _LINUX_TIME_H + +#include <asm/param.h> +#include <linux/types.h> + +#ifndef _STRUCT_TIMESPEC +#define _STRUCT_TIMESPEC +struct timespec { + time_t tv_sec; /* seconds */ + long tv_nsec; /* nanoseconds */ +}; +#endif /* _STRUCT_TIMESPEC */ + +/* + * Change timeval to jiffies, trying to avoid the + * most obvious overflows.. + * + * And some not so obvious. + * + * Note that we don't want to return MAX_LONG, because + * for various timeout reasons we often end up having + * to wait "jiffies+1" in order to guarantee that we wait + * at _least_ "jiffies" - so "jiffies+1" had better still + * be positive. + */ +#define MAX_JIFFY_OFFSET ((~0UL >> 1)-1) + +static __inline__ unsigned long +timespec_to_jiffies(struct timespec *value) +{ + unsigned long sec = value->tv_sec; + long nsec = value->tv_nsec; + + if (sec >= (MAX_JIFFY_OFFSET / HZ)) + return MAX_JIFFY_OFFSET; + nsec += 1000000000L / HZ - 1; + nsec /= 1000000000L / HZ; + return HZ * sec + nsec; +} + +static __inline__ void +jiffies_to_timespec(unsigned long jiffies, struct timespec *value) +{ + value->tv_nsec = (jiffies % HZ) * (1000000000L / HZ); + value->tv_sec = jiffies / HZ; +} + +struct timeval { + time_t tv_sec; /* seconds */ + suseconds_t tv_usec; /* microseconds */ +}; + +struct timezone { + int tz_minuteswest; /* minutes west of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; + +#define NFDBITS __NFDBITS + +#ifdef __KERNEL__ +extern void do_gettimeofday(struct timeval *tv); +extern void do_settimeofday(struct timeval *tv); +extern void get_fast_time(struct timeval *tv); +extern void (*do_get_fast_time)(struct timeval *); +#endif + +#define FD_SETSIZE __FD_SETSIZE +#define FD_SET(fd,fdsetp) __FD_SET(fd,fdsetp) +#define FD_CLR(fd,fdsetp) __FD_CLR(fd,fdsetp) +#define FD_ISSET(fd,fdsetp) __FD_ISSET(fd,fdsetp) +#define FD_ZERO(fdsetp) __FD_ZERO(fdsetp) + +/* + * Names of the interval timers, and structure + * defining a timer setting. + */ +#define ITIMER_REAL 0 +#define ITIMER_VIRTUAL 1 +#define ITIMER_PROF 2 + +struct itimerspec { + struct timespec it_interval; /* timer period */ + struct timespec it_value; /* timer expiration */ +}; + +struct itimerval { + struct timeval it_interval; /* timer interval */ + struct timeval it_value; /* current value */ +}; + +#endif |