Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc/time Backout previous, it breaks the build big time...



details:   https://anonhg.NetBSD.org/src/rev/5779e1c355cf
branches:  trunk
changeset: 760878:5779e1c355cf
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Jan 15 12:31:56 2011 +0000

description:
Backout previous, it breaks the build big time and causes e.g. date(1)
and top(1) to dump core.

diffstat:

 lib/libc/time/Makefile    |   7 +------
 lib/libc/time/localtime.c |  12 ++++--------
 lib/libc/time/zdump.c     |  35 +++++++++++++++--------------------
 lib/libc/time/zic.c       |  18 ++++++++++++------
 4 files changed, 32 insertions(+), 40 deletions(-)

diffs (194 lines):

diff -r 3866a44680ce -r 5779e1c355cf lib/libc/time/Makefile
--- a/lib/libc/time/Makefile    Sat Jan 15 11:59:42 2011 +0000
+++ b/lib/libc/time/Makefile    Sat Jan 15 12:31:56 2011 +0000
@@ -110,10 +110,6 @@
 #  -TTZ_DOMAINDIR=\"/path\" to use "/path" for gettext directory;
 #      the default is system-supplied, typically "/usr/lib/locale"
 #  $(GCC_DEBUG_FLAGS) if you are using GCC and want lots of checking
-#  $(GCC_OVERFLOW_FLAGS) if you are using GCC 3.4 or later.
-#      If you are using a compiler other than GCC, and if it defaults to
-#      undefined behavior on integer overflow, then you need to specify a flag
-#      saying that integer arithmetic is supposed to wrap around on overflow.
 #  -DNO_RUN_TIME_WARNINGS_ABOUT_YEAR_2000_PROBLEMS_THANK_YOU=1
 #      if you do not want run time warnings about formats that may cause
 #      year 2000 grief
@@ -124,7 +120,6 @@
        -Wall -Wcast-qual -Wconversion -Wmissing-prototypes \
        -Wnested-externs -Wpointer-arith -Wshadow \
        -Wtraditional # -Wstrict-prototypes -Wwrite-strings
-GCC_OVERFLOW_FLAGS = -fwrapv
 #
 # If you want to use System V compatibility code, add
 #      -DUSG_COMPAT
@@ -391,7 +386,7 @@
 
 public:                $(ENCHILADA)
                make maintainer-clean
-               make "CFLAGS=$(GCC_DEBUG_FLAGS) $(GCC_OVERFLOW_FLAGS)"
+               make "CFLAGS=$(GCC_DEBUG_FLAGS)"
                -mkdir /tmp/,tzpublic
                -for i in $(TDATA) ; do zic -v -d /tmp/,tzpublic $$i 2>&1 | grep -v "starting year" ; done
                for i in $(TDATA) ; do zic -d /tmp/,tzpublic $$i || exit; done
diff -r 3866a44680ce -r 5779e1c355cf lib/libc/time/localtime.c
--- a/lib/libc/time/localtime.c Sat Jan 15 11:59:42 2011 +0000
+++ b/lib/libc/time/localtime.c Sat Jan 15 12:31:56 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: localtime.c,v 1.52 2011/01/14 23:35:07 christos Exp $  */
+/*     $NetBSD: localtime.c,v 1.53 2011/01/15 12:31:57 martin Exp $    */
 
 /*
 ** This file is in the public domain, so clarified as of
@@ -10,7 +10,7 @@
 #if 0
 static char    elsieid[] = "@(#)localtime.c    8.9";
 #else
-__RCSID("$NetBSD: localtime.c,v 1.52 2011/01/14 23:35:07 christos Exp $");
+__RCSID("$NetBSD: localtime.c,v 1.53 2011/01/15 12:31:57 martin Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -1704,10 +1704,8 @@
        int     number0;
 
        number0 = *number;
-       if (delta < 0 ? number0 < delta - INT_MIN : INT_MAX - delta < number0)
-                 return 1;
        *number += delta;
-       return 0;
+       return (*number < number0) != (delta < 0);
 }
 
 static int
@@ -1716,10 +1714,8 @@
        long    number0;
 
        number0 = *number;
-       if (delta < 0 ? number0 < delta - LONG_MIN : LONG_MAX - delta < number0)
-                 return 1;
        *number += delta;
-       return 0;
+       return (*number < number0) != (delta < 0);
 }
 
 static int
diff -r 3866a44680ce -r 5779e1c355cf lib/libc/time/zdump.c
--- a/lib/libc/time/zdump.c     Sat Jan 15 11:59:42 2011 +0000
+++ b/lib/libc/time/zdump.c     Sat Jan 15 12:31:56 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: zdump.c,v 1.18 2011/01/14 23:35:07 christos Exp $      */
+/*     $NetBSD: zdump.c,v 1.19 2011/01/15 12:31:57 martin Exp $        */
 /*
 ** This file is in the public domain, so clarified as of
 ** 2009-05-17 by Arthur David Olson.
@@ -7,7 +7,7 @@
 #include <sys/cdefs.h>
 #ifndef lint
 #ifndef NOID
-__RCSID("$NetBSD: zdump.c,v 1.18 2011/01/14 23:35:07 christos Exp $");
+__RCSID("$NetBSD: zdump.c,v 1.19 2011/01/15 12:31:57 martin Exp $");
 #endif /* !defined NOID */
 #endif /* !defined lint */
 
@@ -26,7 +26,6 @@
 #include "stdlib.h"    /* for exit, malloc, atoi */
 #include <err.h>
 #include "float.h"     /* for FLT_MAX and DBL_MAX */
-#include "limits.h"    /* for INT_MAX, LONG_MAX, etc. */
 #include "ctype.h"     /* for isalpha et al. */
 #ifndef isascii
 #define isascii(x) 1
@@ -432,25 +431,21 @@
                }
        } else if (0 > (time_t) -1) {
                /*
-               ** time_t is signed.
+               ** time_t is signed.  Assume overflow wraps around.
                */
-               if (sizeof (time_t) == sizeof (int)) {
-                       absolute_min_time = INT_MIN;
-                       absolute_max_time = INT_MAX;
-               } else if (sizeof (time_t) == sizeof (long)) {
-                       absolute_min_time = LONG_MIN;
-                       absolute_max_time = LONG_MAX;
-#if defined LLONG_MIN && defined LLONG_MAX
-               } else if (sizeof (time_t) == sizeof (long long)) {
-                       absolute_min_time = LLONG_MIN;
-                       absolute_max_time = LLONG_MAX;
-#endif
-               } else {
-                       (void) fprintf(stderr,
-_("%s: use of -v on system with signed time_t whose extrema are unknown\n"),
-                               progname);
-                       exit(EXIT_FAILURE);
+               time_t t = 0;
+               time_t t1 = 1;
+
+               while (t < t1) {
+                       t = t1;
+                       t1 = 2 * t1 + 1;
                }
+
+               absolute_max_time = t;
+               t = -t;
+               absolute_min_time = t - 1;
+               if (t < absolute_min_time)
+                       absolute_min_time = t;
        } else {
                /*
                ** time_t is unsigned.
diff -r 3866a44680ce -r 5779e1c355cf lib/libc/time/zic.c
--- a/lib/libc/time/zic.c       Sat Jan 15 11:59:42 2011 +0000
+++ b/lib/libc/time/zic.c       Sat Jan 15 12:31:56 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: zic.c,v 1.27 2011/01/14 23:35:07 christos Exp $        */
+/*     $NetBSD: zic.c,v 1.28 2011/01/15 12:31:57 martin Exp $  */
 /*
 ** This file is in the public domain, so clarified as of
 ** 2006-07-17 by Arthur David Olson.
@@ -10,7 +10,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: zic.c,v 1.27 2011/01/14 23:35:07 christos Exp $");
+__RCSID("$NetBSD: zic.c,v 1.28 2011/01/15 12:31:57 martin Exp $");
 #endif /* !defined lint */
 
 static char    elsieid[] = "@(#)zic.c  8.20";
@@ -2496,11 +2496,14 @@
 const long     t1;
 const long     t2;
 {
-       if (t2 < 0 ? t1 < t2 - LONG_MIN : LONG_MAX - t2 < t1) {
+       register long   t;
+
+       t = t1 + t2;
+       if ((t2 > 0 && t <= t1) || (t2 < 0 && t >= t1)) {
                error(_("time overflow"));
                exit(EXIT_FAILURE);
        }
-       return t1 + t2;
+       return t;
 }
 
 static zic_t
@@ -2508,15 +2511,18 @@
 const zic_t    t1;
 const long     t2;
 {
+       register zic_t  t;
+
        if (t1 == max_time && t2 > 0)
                return max_time;
        if (t1 == min_time && t2 < 0)
                return min_time;
-       if (t2 < 0 ? t1 < t2 - LONG_MIN : LONG_MAX - t2 < t1) {
+       t = t1 + t2;
+       if ((t2 > 0 && t <= t1) || (t2 < 0 && t >= t1)) {
                error(_("time overflow"));
                exit(EXIT_FAILURE);
        }
-       return t1 + t2;
+       return t;
 }
 
 /*



Home | Main Index | Thread Index | Old Index