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