source: trunk/libs/newlib/src/newlib/libc/sys/linux/sys/linux_time.h @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 1.7 KB
Line 
1#ifndef _LINUX_TIME_H
2#define _LINUX_TIME_H
3
4#include <asm/param.h>
5#include <sys/types.h>
6
7#ifndef _STRUCT_TIMESPEC
8#define _STRUCT_TIMESPEC
9struct timespec {
10        time_t  tv_sec;         /* seconds */
11        long    tv_nsec;        /* nanoseconds */
12};
13#endif /* _STRUCT_TIMESPEC */
14
15/*
16 * Change timeval to jiffies, trying to avoid the
17 * most obvious overflows..
18 *
19 * And some not so obvious.
20 *
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
25 * be positive.
26 */
27#define MAX_JIFFY_OFFSET ((~0UL >> 1)-1)
28
29static __inline__ unsigned long
30timespec_to_jiffies(struct timespec *value)
31{
32        unsigned long sec = value->tv_sec;
33        long nsec = value->tv_nsec;
34
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;
40}
41
42static __inline__ void
43jiffies_to_timespec(unsigned long jiffies, struct timespec *value)
44{
45        value->tv_nsec = (jiffies % HZ) * (1000000000L / HZ);
46        value->tv_sec = jiffies / HZ;
47}
48 
49#ifndef _STRUCT_TIMEVAL
50#define _STRUCT_TIMEVAL
51struct timeval {
52        time_t          tv_sec;         /* seconds */
53        suseconds_t     tv_usec;        /* microseconds */
54};
55#endif
56
57struct timezone {
58        int     tz_minuteswest; /* minutes west of Greenwich */
59        int     tz_dsttime;     /* type of dst correction */
60};
61
62#define ITIMER_REAL     0
63#define ITIMER_VIRTUAL  1
64#define ITIMER_PROF     2
65
66struct  itimerspec {
67        struct  timespec it_interval;    /* timer period */
68        struct  timespec it_value;       /* timer expiration */
69};
70
71struct  itimerval {
72        struct  timeval it_interval;    /* timer interval */
73        struct  timeval it_value;       /* current value */
74};
75
76#endif
Note: See TracBrowser for help on using the repository browser.