changeset 16253:b32a684edf4d

mktime: Avoid compilation error on Solaris 11. * lib/mktime.c (WRAPV): Define to 0 on all non-glibc systems.
author Bruno Haible <bruno@clisp.org>
date Sun, 08 Jan 2012 19:07:23 +0100
parents 89ecf881c52e
children da62858ef2f6
files ChangeLog lib/mktime.c
diffstat 2 files changed, 25 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2012-01-08  Bruno Haible  <bruno@clisp.org>
+
+	mktime: Avoid compilation error on Solaris 11.
+	* lib/mktime.c (WRAPV): Define to 0 on all non-glibc systems.
+
 2012-01-08  Bruno Haible  <bruno@clisp.org>
 
 	doc: Small fix.
--- a/lib/mktime.c
+++ b/lib/mktime.c
@@ -25,24 +25,6 @@
 # include <config.h>
 #endif
 
-/* Some of the code in this file assumes that signed integer overflow
-   silently wraps around.  This assumption can't easily be programmed
-   around, nor can it be checked for portably at compile-time or
-   easily eliminated at run-time.
-
-   Define WRAPV to 1 if the assumption is valid.  Otherwise, define it
-   to 0; this forces the use of slower code that, while not guaranteed
-   by the C Standard, works on all production platforms that we know
-   about.  */
-#ifndef WRAPV
-# if (__GNUC__ == 4 && 4 <= __GNUC_MINOR__) || 4 < __GNUC__
-#  pragma GCC optimize ("wrapv")
-#  define WRAPV 1
-# else
-#  define WRAPV 0
-# endif
-#endif
-
 /* Assume that leap seconds are possible, unless told otherwise.
    If the host has a 'zic' command with a '-L leapsecondfilename' option,
    then it supports leap seconds; otherwise it probably doesn't.  */
@@ -64,6 +46,26 @@
 # define mktime my_mktime
 #endif /* DEBUG */
 
+/* Some of the code in this file assumes that signed integer overflow
+   silently wraps around.  This assumption can't easily be programmed
+   around, nor can it be checked for portably at compile-time or
+   easily eliminated at run-time.
+
+   Define WRAPV to 1 if the assumption is valid and if
+     #pragma GCC optimize ("wrapv")
+   does not trigger GCC bug <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51793>.
+   Otherwise, define it to 0; this forces the use of slower code that,
+   while not guaranteed by the C Standard, works on all production
+   platforms that we know about.  */
+#ifndef WRAPV
+# if ((__GNUC__ == 4 && 4 <= __GNUC_MINOR__) || 4 < __GNUC__) && defined __GLIBC__
+#  pragma GCC optimize ("wrapv")
+#  define WRAPV 1
+# else
+#  define WRAPV 0
+# endif
+#endif
+
 /* Verify a requirement at compile-time (unlike assert, which is runtime).  */
 #define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; }