Subversion Repositories SvarDOS

Rev

Rev 616 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
207 mateuszvis 1
/*!\file sys/wtime.h
2
 *
3
 * Watt-32 time functions.
4
 */
5
 
6
#ifndef __SYS_WTIME_H
7
#define __SYS_WTIME_H
8
 
9
/*
10
 * The naming <sys/wtime.h> is required for those compilers that
11
 * have <sys/time.h> in the usual place but doesn't define
12
 * the following.
13
 */
14
 
15
#include <time.h>
16
 
17
#ifdef __BORLANDC__
18
#undef timezone   /* a macro in bcc 5+ */
19
#endif
20
 
21
#ifndef __SYS_W32API_H
22
#include <sys/w32api.h>
23
#endif
24
 
25
#ifndef __SYS_CDEFS_H
26
#include <sys/cdefs.h>
27
#endif
28
 
29
#if defined(__DJGPP__)
30
  #include <sys/time.h>
31
  #include <sys/times.h>
32
 
33
#elif defined(__MINGW32__)
34
  #include <sys/time.h>
35
 
36
#else
37
  struct timeval {
38
         time_t tv_sec;
39
         long   tv_usec;
40
       };
41
  #define STRUCT_TIMEVAL_DEFINED
42
#endif
43
 
44
#if !defined(__DJGPP__)
45
  struct timezone {
46
         int tz_minuteswest;
47
         int tz_dsttime;
48
       };
49
 
50
  struct tms {
51
         unsigned long tms_utime;
52
         unsigned long tms_cstime;
53
         unsigned long tms_cutime;
54
         unsigned long tms_stime;
55
       };
56
  #define STRUCT_TIMEZONE_DEFINED
57
  #define STRUCT_TMS_DEFINED
58
 
59
  __BEGIN_DECLS
60
 
61
  #define ITIMER_REAL  0
62
  #define ITIMER_PROF  1
63
 
64
  struct itimerval {
65
         struct timeval it_interval;  /* timer interval */
66
         struct timeval it_value;     /* current value */
67
       };
68
 
69
  W32_FUNC int getitimer (int, struct itimerval *);
70
  W32_FUNC int setitimer (int, struct itimerval *, struct itimerval *);
71
 
72
  W32_FUNC int gettimeofday (struct timeval *tp, struct timezone *tz);
73
 
74
  __END_DECLS
75
 
76
#endif      /* !__DJGPP__ */
77
 
78
#if !defined(_STRUCT_TIMESPEC) && !defined(_pthread_signal_h)
79
  #define _STRUCT_TIMESPEC
80
  struct timespec {
81
         time_t tv_sec;
82
         long   tv_nsec;
83
       };
84
#endif
85
 
86
#ifndef HZ
87
#define HZ 18.2F
88
#endif
89
 
90
__BEGIN_DECLS
91
 
92
W32_FUNC unsigned long net_times (struct tms *buffer);
93
W32_FUNC int           gettimeofday2 (struct timeval *tv, struct timezone *tz);
94
 
95
__END_DECLS
96
 
97
/*
98
 * Operations on timevals.
99
 *
100
 * NB: timercmp does not work for >= or <=.
101
 */
102
#ifndef timerisset
103
  #define timerisset(tvp)         ((tvp)->tv_sec || (tvp)->tv_usec)
104
 
105
  #define timercmp(tvp, uvp, cmp) ((tvp)->tv_sec cmp (uvp)->tv_sec || \
106
                                   ((tvp)->tv_sec == (uvp)->tv_sec &&  \
107
                                    (tvp)->tv_usec cmp (uvp)->tv_usec))
108
 
109
  #define timerclear(tvp)         (tvp)->tv_sec = (tvp)->tv_usec = 0
110
#endif
111
 
112
#endif  /* !__SYS_WTIME_H */