aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlrich Drepper1998-02-16 02:42:49 +0000
committerUlrich Drepper1998-02-16 02:42:49 +0000
commit067cc4dc8050b88ee0bef47e3a4ef0f707c8dea3 (patch)
tree9cf1cd754395a7f83e6f8eaa30a22faee1e5a739
parent8e7df2e62bfdb00ce85055dbcb17ad0744c1ee73 (diff)
downloademacs-067cc4dc8050b88ee0bef47e3a4ef0f707c8dea3.tar.gz
emacs-067cc4dc8050b88ee0bef47e3a4ef0f707c8dea3.zip
automatically generated from GPLed version
-rw-r--r--src/mktime.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/src/mktime.c b/src/mktime.c
index a6e2756aebe..b852951458e 100644
--- a/src/mktime.c
+++ b/src/mktime.c
@@ -1,4 +1,4 @@
1/* Copyright (C) 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc. 1/* Copyright (C) 1993, 94, 95, 96, 97, 98 Free Software Foundation, Inc.
2 Contributed by Paul Eggert (eggert@twinsun.com). 2 Contributed by Paul Eggert (eggert@twinsun.com).
3 3
4 NOTE: The canonical source of this file is maintained with the GNU C Library. 4 NOTE: The canonical source of this file is maintained with the GNU C Library.
@@ -27,7 +27,7 @@
27# include <config.h> 27# include <config.h>
28#endif 28#endif
29 29
30/* Some hosts need this in order to declare localtime_r properly. */ 30/* Some systems need this in order to declare localtime_r properly. */
31#ifndef _REENTRANT 31#ifndef _REENTRANT
32# define _REENTRANT 1 32# define _REENTRANT 1
33#endif 33#endif
@@ -73,21 +73,26 @@
73# define CHAR_BIT 8 73# define CHAR_BIT 8
74#endif 74#endif
75 75
76/* The extra casts work around common compiler bugs. */
77#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
78/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
79 It is necessary at least when t == time_t. */
80#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
81 ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
82#define TYPE_MAXIMUM(t) (~ (t) 0 - TYPE_MINIMUM (t))
83
76#ifndef INT_MIN 84#ifndef INT_MIN
77# define INT_MIN (~0 << (sizeof (int) * CHAR_BIT - 1)) 85# define INT_MIN TYPE_MINIMUM (int)
78#endif 86#endif
79#ifndef INT_MAX 87#ifndef INT_MAX
80# define INT_MAX (~0 - INT_MIN) 88# define INT_MAX TYPE_MAXIMUM (int)
81#endif 89#endif
82 90
83#ifndef TIME_T_MIN 91#ifndef TIME_T_MIN
84/* The outer cast to time_t works around a bug in Cray C 5.0.3.0. */ 92# define TIME_T_MIN TYPE_MINIMUM (time_t)
85# define TIME_T_MIN ((time_t) \
86 (0 < (time_t) -1 ? (time_t) 0 \
87 : ~ (time_t) 0 << (sizeof (time_t) * CHAR_BIT - 1)))
88#endif 93#endif
89#ifndef TIME_T_MAX 94#ifndef TIME_T_MAX
90# define TIME_T_MAX (~ (time_t) 0 - TIME_T_MIN) 95# define TIME_T_MAX TYPE_MAXIMUM (time_t)
91#endif 96#endif
92 97
93#define TM_YEAR_BASE 1900 98#define TM_YEAR_BASE 1900
@@ -365,7 +370,15 @@ __mktime_internal (tp, convert, offset)
365 double dday = 366 * dyear + mday; 370 double dday = 366 * dyear + mday;
366 double dsec = 60 * (60 * (24 * dday + hour) + min) + sec_requested; 371 double dsec = 60 * (60 * (24 * dday + hour) + min) + sec_requested;
367 372
368 if (TIME_T_MAX / 3 - TIME_T_MIN / 3 < (dsec < 0 ? - dsec : dsec)) 373 /* On Irix4.0.5 cc, dividing TIME_T_MIN by 3 does not produce
374 correct results, ie., it erroneously gives a positive value
375 of 715827882. Setting a variable first then doing math on it
376 seems to work. (ghazi@caip.rutgers.edu) */
377
378 const time_t time_t_max = TIME_T_MAX;
379 const time_t time_t_min = TIME_T_MIN;
380
381 if (time_t_max / 3 - time_t_min / 3 < (dsec < 0 ? - dsec : dsec))
369 return -1; 382 return -1;
370 } 383 }
371 384