source: trunk/sys/dietlibc/include/sys/time.h @ 1

Last change on this file since 1 was 1, checked in by alain, 7 years ago

First import

File size: 2.5 KB
Line 
1#ifndef _SYS_TIME_H
2#define _SYS_TIME_H     1
3
4#include <sys/cdefs.h>
5#include <sys/types.h>
6
7__BEGIN_DECLS
8
9struct timespec {
10  time_t tv_sec;        /* seconds */
11  long tv_nsec;         /* nanoseconds */
12};
13
14#if 0
15struct timeval {
16  time_t tv_sec;        /* seconds */
17  suseconds_t tv_usec;  /* microseconds */
18};
19#endif
20struct timeval {
21  clock_t tv_sec;    /* secondes */
22  clock_t tv_usec;   /* microsecondes */
23};
24
25struct timezone {
26  int tz_minuteswest;   /* minutes west of Greenwich */
27  int tz_dsttime;       /* type of dst correction */
28};
29
30//#include <sys/select.h>
31
32#define ITIMER_REAL     0
33#define ITIMER_VIRTUAL  1
34#define ITIMER_PROF     2
35
36struct itimerspec {
37  struct timespec it_interval;  /* timer period */
38  struct timespec it_value;     /* timer expiration */
39};
40
41struct itimerval {
42  struct timeval it_interval;   /* timer interval */
43  struct timeval it_value;      /* current value */
44};
45
46#if defined _GNU_SOURCE || defined _BSD_SOURCE
47typedef struct timezone *__timezone_ptr_t;
48#else
49typedef void *__timezone_ptr_t;
50#endif
51
52int getitimer(int which, struct itimerval *value) __THROW;
53int setitimer(int which, const struct itimerval *value, struct itimerval *ovalue) __THROW;
54
55int gettimeofday(struct timeval *tv, struct timezone *tz) __THROW;
56int settimeofday(const struct timeval *tv , const struct timezone *tz) __THROW;
57
58extern int adjtime (const struct timeval *delta, struct timeval *olddelta) __THROW;
59
60struct tm {
61  int tm_sec;                   /* Seconds.     [0-60] (1 leap second) */
62  int tm_min;                   /* Minutes.     [0-59] */
63  int tm_hour;                  /* Hours.       [0-23] */
64  int tm_mday;                  /* Day.         [1-31] */
65  int tm_mon;                   /* Month.       [0-11] */
66  int tm_year;                  /* Year - 1900. */
67  int tm_wday;                  /* Day of week. [0-6] */
68  int tm_yday;                  /* Days in year.[0-365] */
69  int tm_isdst;                 /* DST.         [-1/0/1]*/
70
71  long int tm_gmtoff;           /* Seconds east of UTC.  */
72  const char *tm_zone;          /* Timezone abbreviation.  */
73};
74
75#ifdef _BSD_SOURCE
76/* another wonderful BSD invention... :( */
77#define timercmp(a,b,CMP) (((a)->tv_sec == (b)->tv_sec) ? ((a)->tv_usec CMP (b)->tv_usec) : ((a)->tv_sec CMP (b)->tv_sec))
78#define timerclear(x) ((x)->tv_sec=(x)->tv_usec=0)
79#define timeradd(a,b,x) do { (x)->tv_sec=(a)->tv_sec+(b)->tv_sec; if (((x)->tv_usec=(a)->tv_usec+(b)->tv_usec)>=1000000) { ++(x)->tv_sec; (x)->tv_usec-=1000000; } } while (0)
80#define timersub(a,b,x) do { (x)->tv_sec=(a)->tv_sec-(b)->tv_sec; if (((x)->tv_usec=(a)->tv_usec-(b)->tv_usec)<0) { --(x)->tv_sec; (x)->tv_usec+=1000000; } } while (0)
81#define timerisset(x) ((x)->tv_sec || (x)->tv_usec)
82
83int utimes(const char * filename, struct timeval * tvp);
84#endif
85
86__END_DECLS
87
88#endif
Note: See TracBrowser for help on using the repository browser.