00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 #ifndef _SYS_TIME_H_
00035 #define _SYS_TIME_H_
00036
00037 #include <sys/_timeval.h>
00038 #include <sys/types.h>
00039 #include <sys/timespec.h>
00040
00041 struct timezone {
00042 int tz_minuteswest;
00043 int tz_dsttime;
00044 };
00045 #define DST_NONE 0
00046 #define DST_USA 1
00047 #define DST_AUST 2
00048 #define DST_WET 3
00049 #define DST_MET 4
00050 #define DST_EET 5
00051 #define DST_CAN 6
00052
00053 #if __BSD_VISIBLE
00054 struct bintime {
00055 time_t sec;
00056 uint64_t frac;
00057 };
00058
00059 static __inline void
00060 bintime_addx(struct bintime *bt, uint64_t x)
00061 {
00062 uint64_t u;
00063
00064 u = bt->frac;
00065 bt->frac += x;
00066 if (u > bt->frac)
00067 bt->sec++;
00068 }
00069
00070 static __inline void
00071 bintime_add(struct bintime *bt, const struct bintime *bt2)
00072 {
00073 uint64_t u;
00074
00075 u = bt->frac;
00076 bt->frac += bt2->frac;
00077 if (u > bt->frac)
00078 bt->sec++;
00079 bt->sec += bt2->sec;
00080 }
00081
00082 static __inline void
00083 bintime_sub(struct bintime *bt, const struct bintime *bt2)
00084 {
00085 uint64_t u;
00086
00087 u = bt->frac;
00088 bt->frac -= bt2->frac;
00089 if (u < bt->frac)
00090 bt->sec--;
00091 bt->sec -= bt2->sec;
00092 }
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 static __inline void
00109 bintime2timespec(const struct bintime *bt, struct timespec *ts)
00110 {
00111
00112 ts->tv_sec = bt->sec;
00113 ts->tv_nsec = ((uint64_t)1000000000 * (uint32_t)(bt->frac >> 32)) >> 32;
00114 }
00115
00116 static __inline void
00117 timespec2bintime(const struct timespec *ts, struct bintime *bt)
00118 {
00119
00120 bt->sec = ts->tv_sec;
00121
00122 bt->frac = ts->tv_nsec * (uint64_t)18446744073LL;
00123 }
00124
00125 static __inline void
00126 bintime2timeval(const struct bintime *bt, struct timeval *tv)
00127 {
00128
00129 tv->tv_sec = bt->sec;
00130 tv->tv_usec = ((uint64_t)1000000 * (uint32_t)(bt->frac >> 32)) >> 32;
00131 }
00132
00133 static __inline void
00134 timeval2bintime(const struct timeval *tv, struct bintime *bt)
00135 {
00136
00137 bt->sec = tv->tv_sec;
00138
00139 bt->frac = tv->tv_usec * (uint64_t)18446744073709LL;
00140 }
00141 #endif
00142
00143
00144
00145
00146
00147 #define ITIMER_REAL 0
00148 #define ITIMER_VIRTUAL 1
00149 #define ITIMER_PROF 2
00150
00151 struct itimerval {
00152 struct timeval it_interval;
00153 struct timeval it_value;
00154 };
00155
00156
00157
00158
00159 struct clockinfo {
00160 int hz;
00161 int tick;
00162 int spare;
00163 int stathz;
00164 int profhz;
00165 };
00166
00167 #include <time.h>
00168
00169 #include <sys/cdefs.h>
00170
00171 __BEGIN_DECLS
00172 IMPORT_C int adjtime(const struct timeval *, struct timeval *);
00173 IMPORT_C int gettimeofday(struct timeval *, struct timezone *);
00174 int settimeofday(const struct timeval *, const struct timezone *);
00175 IMPORT_C int utimes(const char *, const struct timeval *);
00176 __END_DECLS
00177
00178
00179 #endif