summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog23
-rw-r--r--ace/OS_NS_time.h37
-rw-r--r--ace/README2
-rw-r--r--ace/config-linux-common.h3
-rw-r--r--ace/config-netbsd.h1
-rw-r--r--configure.ac2
-rw-r--r--m4/platform.m420
7 files changed, 63 insertions, 25 deletions
diff --git a/ChangeLog b/ChangeLog
index 9a8138fa5ea..92677bb1971 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+Thu Sep 2 16:39:29 2004 J.T. Conklin <jtc@acorntoolworks.com>
+
+ * ace/config-linux-common.h:
+ * ace/config-netbsd.h:
+
+ Changed to define ACE_HAS_TIMEZONE.
+
+ * ace/OS_NS_time.h:
+
+ Changed ace_timezone() to use ACE_HAS_TIMEZONE feature test
+ macro instead of OS-specific macros to determine whether to
+ use global timezone variable or the gettimeofday() function
+ to obtain the current timezone.
+
+ * configure.ac:
+
+ Changed to call ACE_VAR_TIMEZONE.
+
+ * m4/platform.m4:
+
+ Added new macro, ACE_VAR_TIMEZONE. Sets new feature test macro
+ ACE_HAS_TIMEZONE if platform supports global timezone variable.
+
Thu Sep 2 16:43:29 2004 Steve Huston <shuston@riverace.com>
* m4/ace.m4: Added AM_CONDITIONAL for BUILD_EXCEPTIONS, BUILD_THREADS,
diff --git a/ace/OS_NS_time.h b/ace/OS_NS_time.h
index 0c2e50b3d5e..dd4e58a289f 100644
--- a/ace/OS_NS_time.h
+++ b/ace/OS_NS_time.h
@@ -133,48 +133,35 @@ struct tm {
*/
inline long ace_timezone()
{
-#if !defined (VXWORKS) && !defined (ACE_PSOS) && !defined (CHORUS)
-# if defined (ACE_HAS_WINCE)
+#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_GETTIMEOFDAY) \
- && !defined (__linux__) \
- && !defined (__FreeBSD__) \
- && !defined (__NetBSD__)
+#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)
// The XPG/POSIX specification does not require gettimeofday to
// set the timezone struct (it leaves the behavior of passing a
- // 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.
+ // non-null struct undefined).
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 /* 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
+#else
ACE_NOTSUP_RETURN (0);
-#endif /* !ACE_HAS_WINCE && !VXWORKS && !ACE_PSOS */
+#endif
}
diff --git a/ace/README b/ace/README
index 17000f57204..21535753a85 100644
--- a/ace/README
+++ b/ace/README
@@ -632,6 +632,8 @@ ACE_HAS_THR_C_DEST The pthread_keycreate()
ACE_HAS_THR_C_FUNC The pthread_create() routine
*must* take extern C
functions.
+ACE_HAS_TIMEZONE Platform/compiler supports
+ global "timezone" variable.
ACE_HAS_TIMEZONE_GETTIMEOFDAY Platform/compiler supports
timezone * as second parameter
to gettimeofday()
diff --git a/ace/config-linux-common.h b/ace/config-linux-common.h
index e00e7fcecd7..3be0898f3a5 100644
--- a/ace/config-linux-common.h
+++ b/ace/config-linux-common.h
@@ -295,6 +295,9 @@
// Compiler/platform contains the <sys/syscall.h> file.
#define ACE_HAS_SYS_SYSCALL_H
+// Platform/compiler supports global timezone variable.
+#define ACE_HAS_TIMEZONE
+
// Platform/compiler supports void * as second parameter to gettimeofday().
#define ACE_HAS_VOIDPTR_GETTIMEOFDAY
diff --git a/ace/config-netbsd.h b/ace/config-netbsd.h
index 9a7664b42ad..30366dfc4ab 100644
--- a/ace/config-netbsd.h
+++ b/ace/config-netbsd.h
@@ -73,6 +73,7 @@
#define ACE_HAS_TEMPLATE_TYPEDEFS 1
#define ACE_HAS_THREADS 1
#define ACE_HAS_THREAD_SPECIFIC_STORAGE 1
+#define ACE_HAS_TIMEZONE 1
#define ACE_HAS_TIMEZONE_GETTIMEOFDAY 1
#define ACE_HAS_TYPENAME_KEYWORD 1
#define ACE_HAS_UALARM 1
diff --git a/configure.ac b/configure.ac
index 167c29b8856..282c69cb625 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1778,6 +1778,8 @@ fi dnl test "$cross_compiling" != yes
dnl Other checks
+ACE_VAR_TIMEZONE
+
dnl Check for istream operator>> for char, unsigned char and signed char
ACE_CACHE_CHECK([for istream operator>> for char types],
diff --git a/m4/platform.m4 b/m4/platform.m4
index 9a5ee9daffb..c3cdf1cc9ef 100644
--- a/m4/platform.m4
+++ b/m4/platform.m4
@@ -419,3 +419,23 @@ the first joined multicast group to the socket, and all future joins on that
socket will fail with an error.])
fi
])
+
+
+# ACE_VAR_TIMEZONE
+#
+# Checks whether platform has global "timezone" variable.
+#
+#---------------------------------------------------------------------------
+AC_DEFUN([ACE_VAR_TIMEZONE],
+[AC_CACHE_CHECK([for timezone variable],
+ [ace_cv_var_timezone],
+ [AC_TRY_LINK([#include <time.h>],
+ [return (int)timezone;],
+ [ace_cv_var_timezone=yes],
+ [ace_cv_var_timezone=no])
+ ])
+if test "$ace_cv_var_timezone" = yes; then
+ AC_DEFINE([ACE_HAS_TIMEZONE], 1,
+ [Define to 1 if platform has global timezone variable])
+fi
+])