From e7b7d5dd1236fb4dc26c61f1d27bf2a9cc1c2060 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 8 Jan 2012 19:07:23 +0100 Subject: [PATCH] mktime: Avoid compilation error on Solaris 11. * lib/mktime.c (WRAPV): Define to 0 on all non-glibc systems. --- ChangeLog | 5 +++++ lib/mktime.c | 38 ++++++++++++++++++++------------------ 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9ed54bb38..d27975166 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2012-01-08 Bruno Haible + mktime: Avoid compilation error on Solaris 11. + * lib/mktime.c (WRAPV): Define to 0 on all non-glibc systems. + +2012-01-08 Bruno Haible + doc: Small fix. * doc/posix-headers/nl_types.texi: Correct platforms list. diff --git a/lib/mktime.c b/lib/mktime.c index 17884cde2..c644eb6a5 100644 --- a/lib/mktime.c +++ b/lib/mktime.c @@ -25,24 +25,6 @@ # include #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 . + 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]; } -- 2.11.0