00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef ACE_OS_NS_TIME_H
00018 # define ACE_OS_NS_TIME_H
00019
00020 # include "ace/pre.h"
00021
00022 # include "ace/config-all.h"
00023
00024 # if !defined (ACE_LACKS_PRAGMA_ONCE)
00025 # pragma once
00026 # endif
00027
00028 #include "ace/OS_NS_errno.h"
00029 #include "ace/Basic_Types.h"
00030 #include "ace/os_include/os_time.h"
00031 #include "ace/ACE_export.h"
00032
00033 #if defined (ACE_EXPORT_MACRO)
00034 # undef ACE_EXPORT_MACRO
00035 #endif
00036 #define ACE_EXPORT_MACRO ACE_Export
00037
00038 # if defined (ACE_HAS_BROKEN_R_ROUTINES)
00039 # undef ctime_r
00040 # undef asctime_r
00041 # endif
00042
00043 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00044
00045
00046 static const ACE_UINT32 ACE_U_ONE_SECOND_IN_MSECS = 1000U;
00047 static const ACE_UINT32 ACE_U_ONE_SECOND_IN_USECS = 1000000U;
00048 static const ACE_UINT32 ACE_U_ONE_SECOND_IN_NSECS = 1000000000U;
00049
00050 #if defined (ACE_HAS_WINCE) && (defined (_MSC_VER) && (_MSC_VER < 1400))
00051
00052
00053
00054
00055
00056 struct tm {
00057 int tm_sec;
00058 int tm_min;
00059 int tm_hour;
00060 int tm_mday;
00061 int tm_mon;
00062 int tm_year;
00063 int tm_wday;
00064 int tm_yday;
00065 int tm_isdst;
00066 };
00067 #endif
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 inline long ace_timezone()
00079 {
00080 #if defined (ACE_WIN32)
00081 TIME_ZONE_INFORMATION tz;
00082 GetTimeZoneInformation (&tz);
00083 return tz.Bias * 60;
00084 #elif defined (ACE_HAS_TIMEZONE)
00085
00086
00087 ::tzset();
00088 return timezone;
00089 #elif defined (ACE_HAS_TIMEZONE_GETTIMEOFDAY)
00090
00091
00092
00093 long result = 0;
00094 struct timeval time;
00095 struct timezone zone;
00096 ACE_UNUSED_ARG (result);
00097 ACE_OSCALL (::gettimeofday (&time, &zone), int, -1, result);
00098 return zone.tz_minuteswest * 60;
00099 #else
00100 ACE_NOTSUP_RETURN (0);
00101 #endif
00102 }
00103
00104
00105 #if !defined (ACE_LACKS_DIFFTIME)
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115 inline double ace_difftime(time_t t1, time_t t0)
00116 {
00117 return difftime (t1, t0);
00118 }
00119 #endif
00120
00121 # if defined (ACE_WIN32)
00122 # if !defined (ACE_LACKS_LONGLONG_T)
00123
00124 typedef unsigned __int64 ACE_QWORD;
00125 typedef unsigned __int64 ACE_hrtime_t;
00126 inline ACE_QWORD ACE_MAKE_QWORD (DWORD lo, DWORD hi) { return ACE_QWORD (lo) | (ACE_QWORD (hi) << 32); }
00127 inline DWORD ACE_LOW_DWORD (ACE_QWORD q) { return (DWORD) q; }
00128 inline DWORD ACE_HIGH_DWORD (ACE_QWORD q) { return (DWORD) (q >> 32); }
00129 # else
00130
00131 typedef ACE_UINT64 ACE_hrtime_t;
00132 # endif // ACE_LACKS_LONGLONG_T
00133 # elif defined (_TNS_R_TARGET)
00134 typedef long long ACE_hrtime_t;
00135 # else
00136 # if defined (ACE_HAS_HI_RES_TIMER) && !defined (ACE_LACKS_LONGLONG_T)
00137
00138 typedef hrtime_t ACE_hrtime_t;
00139 # else
00140 typedef ACE_UINT64 ACE_hrtime_t;
00141 # endif
00142 # endif
00143
00144 # if defined (ACE_LACKS_UNSIGNEDLONGLONG_T)
00145 # define ACE_HRTIME_CONVERSION(VAL) ACE_U64_TO_U32(VAL)
00146 # define ACE_HRTIME_TO_U64(VAL) ACE_U_LongLong(VAL)
00147 # else
00148 # define ACE_HRTIME_CONVERSION(VAL) (VAL)
00149 # define ACE_HRTIME_TO_U64(VAL) (VAL)
00150 # endif
00151
00152 namespace ACE_OS
00153 {
00154 enum ACE_HRTimer_Op
00155 {
00156 ACE_HRTIMER_START = 0x0,
00157 ACE_HRTIMER_INCR = 0x1,
00158 ACE_HRTIMER_STOP = 0x2,
00159 ACE_HRTIMER_GETTIME = 0xFFFF
00160 };
00161
00162
00163
00164 ACE_NAMESPACE_INLINE_FUNCTION
00165 char *asctime (const struct tm *tm);
00166
00167 ACE_NAMESPACE_INLINE_FUNCTION
00168 char *asctime_r (const struct tm *tm,
00169 char *buf, int buflen);
00170
00171 ACE_NAMESPACE_INLINE_FUNCTION
00172 int clock_gettime (clockid_t,
00173 struct timespec *);
00174
00175 ACE_NAMESPACE_INLINE_FUNCTION
00176 int clock_settime (clockid_t,
00177 const struct timespec *);
00178
00179 ACE_NAMESPACE_INLINE_FUNCTION
00180 ACE_TCHAR *ctime (const time_t *t);
00181
00182 #if defined (ACE_HAS_WINCE) && !defined (_DEBUG)
00183 extern ACE_EXPORT_MACRO
00184 #else
00185 ACE_NAMESPACE_INLINE_FUNCTION
00186 #endif
00187 ACE_TCHAR *ctime_r (const time_t *clock, ACE_TCHAR *buf, int buflen);
00188
00189 # if defined (difftime)
00190 # undef difftime
00191 # endif
00192
00193 #if !defined (ACE_LACKS_DIFFTIME)
00194 ACE_NAMESPACE_INLINE_FUNCTION
00195 #else
00196 extern ACE_Export
00197 #endif
00198 double difftime (time_t t1,
00199 time_t t0);
00200
00201 ACE_NAMESPACE_INLINE_FUNCTION
00202 ACE_hrtime_t gethrtime (const ACE_HRTimer_Op = ACE_HRTIMER_GETTIME);
00203
00204 ACE_NAMESPACE_INLINE_FUNCTION
00205 struct tm *gmtime (const time_t *clock);
00206
00207 ACE_NAMESPACE_INLINE_FUNCTION
00208 struct tm *gmtime_r (const time_t *clock,
00209 struct tm *res);
00210
00211 ACE_NAMESPACE_INLINE_FUNCTION
00212 struct tm *localtime (const time_t *clock);
00213
00214 extern ACE_Export
00215 struct tm *localtime_r (const time_t *clock,
00216 struct tm *res);
00217
00218
00219 extern ACE_Export
00220 time_t mktime (struct tm *timeptr);
00221
00222 ACE_NAMESPACE_INLINE_FUNCTION
00223 int nanosleep (const struct timespec *requested,
00224 struct timespec *remaining = 0);
00225
00226 # if defined (ACE_HAS_POWERPC_TIMER) && defined (ghs)
00227 extern ACE_Export
00228 void readPPCTimeBase (u_long &most,
00229 u_long &least);
00230 # endif
00231
00232 ACE_NAMESPACE_INLINE_FUNCTION
00233 size_t strftime (char *s,
00234 size_t maxsize,
00235 const char *format,
00236 const struct tm *timeptr);
00237
00238 ACE_NAMESPACE_INLINE_FUNCTION
00239 char *strptime (const char *buf,
00240 const char *format,
00241 struct tm *tm);
00242
00243 # if defined (ACE_LACKS_STRPTIME) && !defined (ACE_REFUSE_STRPTIME_EMULATION)
00244 extern ACE_Export
00245 char *strptime_emulation (const char *buf,
00246 const char *format,
00247 struct tm *tm);
00248
00249 extern ACE_Export
00250 int strptime_getnum (const char *buf, int *num, int *bi,
00251 int *fi, int min, int max);
00252 # endif
00253
00254 ACE_NAMESPACE_INLINE_FUNCTION
00255 time_t time (time_t *tloc = 0);
00256
00257 # if defined (timezone)
00258 # undef timezone
00259 # endif
00260
00261 ACE_NAMESPACE_INLINE_FUNCTION
00262 long timezone (void);
00263
00264
00265 ACE_NAMESPACE_INLINE_FUNCTION
00266 void tzset (void);
00267
00268
00269 }
00270
00271 ACE_END_VERSIONED_NAMESPACE_DECL
00272
00273 #if (defined (ACE_HAS_VERSIONED_NAMESPACE) \
00274 && ACE_HAS_VERSIONED_NAMESPACE == 1) \
00275 && defined (ghs) \
00276 && defined (ACE_HAS_PENTIUM) \
00277 && !defined (ACE_WIN32)
00278 #define ACE_GETHRTIME_NAME ACE_PREPROC_CONCATENATE(ACE_,ACE_PREPROC_CONCATENATE(ACE_VERSIONED_NAMESPACE_NAME, _gethrtime))
00279 #else
00280 # define ACE_GETHRTIME_NAME ACE_gethrtime
00281 #endif
00282
00283
00284 # if defined (ACE_HAS_INLINED_OSCALLS)
00285 # if defined (ACE_INLINE)
00286 # undef ACE_INLINE
00287 # endif
00288 # define ACE_INLINE inline
00289 # include "ace/OS_NS_time.inl"
00290 # endif
00291
00292 # include "ace/post.h"
00293 #endif