diff options
Diffstat (limited to 'ace/OS_NS_time.h')
-rw-r--r-- | ace/OS_NS_time.h | 48 |
1 files changed, 29 insertions, 19 deletions
diff --git a/ace/OS_NS_time.h b/ace/OS_NS_time.h index 8cb05fa4cda..10efa75c8d5 100644 --- a/ace/OS_NS_time.h +++ b/ace/OS_NS_time.h @@ -25,7 +25,6 @@ # pragma once # endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "ace/OS_NS_errno.h" #include "ace/Basic_Types.h" #include "ace/os_include/os_time.h" #include "ace/ACE_export.h" @@ -106,6 +105,10 @@ private: #endif /* ACE_PSOS_HAS_TIME */ #if defined (ACE_HAS_WINCE) + /// Supporting data for ctime and ctime_r functions on WinCE. + const wchar_t *day_of_week_name[7]; + const wchar_t *month_name[12]; + // WinCE doesn't have most of the standard C library time functions. It // also doesn't define struct tm. SYSTEMTIME has pretty much the same // info though, so we can map it when needed. Define struct tm here and @@ -134,35 +137,48 @@ struct tm { */ inline long ace_timezone() { -#if defined (ACE_HAS_WINCE) +#if !defined (VXWORKS) && !defined (ACE_PSOS) && !defined (CHORUS) +# if defined (ACE_HAS_WINCE) TIME_ZONE_INFORMATION tz; GetTimeZoneInformation (&tz); return tz.Bias * 60; -#elif defined (ACE_WIN32) && !defined (ACE_HAS_DINKUM_STL) +# elif defined (ACE_WIN32) && !defined (ACE_HAS_DINKUM_STL) return _timezone; // For Win32. -#elif defined (ACE_WIN32) && defined (ACE_HAS_DINKUM_STL) +# elif defined (ACE_WIN32) && defined (ACE_HAS_DINKUM_STL) time_t tod = time(0); // get current time time_t t1 = mktime(gmtime(&tod)); // convert without timezone time_t t2 = mktime(localtime(&tod)); // convert with timezone return difftime(t1, t2); // compute difference in seconds -#elif defined (ACE_HAS_TIMEZONE) - // The XPG/POSIX specification requires that tzset() be called to - // set the global variable <timezone>. - ::tzset(); - return timezone; -#elif defined (ACE_HAS_TIMEZONE_GETTIMEOFDAY) +# elif defined (ACE_HAS_TIMEZONE_GETTIMEOFDAY) \ + && !defined (__linux__) \ + && !defined (__FreeBSD__) \ + && !defined (__NetBSD__) // The XPG/POSIX specification does not require gettimeofday to // set the timezone struct (it leaves the behavior of passing a - // non-null struct undefined). + // non-null struct undefined). We know gettimeofday() on Linux + // *BSD systems does not set the timezone, so we avoid using it + // and use the global variable <timezone> instead. + // + // @note As of this writing, OpenBSD does not provide the global + // variable timezone. + // + // @todo It would be better if we had a feature test macro that + // could be used instead of a list of operating systems. long result = 0; struct timeval time; struct timezone zone; ACE_UNUSED_ARG (result); ACE_OSCALL (::gettimeofday (&time, &zone), int, -1, result); return zone.tz_minuteswest * 60; -#else +# else /* ACE_HAS_TIMEZONE_GETTIMEOFDAY */ + // The XPG/POSIX specification requires that tzset() be called to + // set the global variable <timezone>. + ::tzset(); + return timezone; +# endif /* ACE_HAS_TIMEZONE_GETTIMEOFDAY */ +#else ACE_NOTSUP_RETURN (0); -#endif +#endif /* !ACE_HAS_WINCE && !VXWORKS && !ACE_PSOS */ } @@ -214,12 +230,6 @@ typedef ACE_UINT64 ACE_hrtime_t; namespace ACE_OS { -# if defined (ACE_HAS_WINCE) - /// Supporting data for ctime and ctime_r functions on WinCE. - const wchar_t *day_of_week_name[]; - const wchar_t *month_name[]; -# endif /* ACE_HAS_WINCE */ - # if defined (CHORUS) && !defined (CHORUS_4) // We must format this code as follows to avoid confusing OSE. enum ACE_HRTimer_Op |