mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-30 22:43:12 +03:00
mktime: remove incorrect attempt at unusual arithmetics
* time/mktime.c (TYPE_ONES_COMPLEMENT, TYPE_SIGNED_MAGNITUDE): Remove. The code didn't really work on such machines anyway. (TYPE_MINIMUM): Assume two's complement. (twos_complement_arithmetic): Verify that long_int and time_t are two's complement (or unsigned, in the latter case).
This commit is contained in:
@ -1,5 +1,12 @@
|
|||||||
2012-05-23 Paul Eggert <eggert@cs.ucla.edu>
|
2012-05-23 Paul Eggert <eggert@cs.ucla.edu>
|
||||||
|
|
||||||
|
mktime: remove incorrect attempt at unusual arithmetics
|
||||||
|
* time/mktime.c (TYPE_ONES_COMPLEMENT, TYPE_SIGNED_MAGNITUDE): Remove.
|
||||||
|
The code didn't really work on such machines anyway.
|
||||||
|
(TYPE_MINIMUM): Assume two's complement.
|
||||||
|
(twos_complement_arithmetic): Verify that long_int and time_t
|
||||||
|
are two's complement (or unsigned, in the latter case).
|
||||||
|
|
||||||
mktime: check signed shifts on long_int and time_t, too
|
mktime: check signed shifts on long_int and time_t, too
|
||||||
* time/mktime.c (SHR): Check that shifts work as desired
|
* time/mktime.c (SHR): Check that shifts work as desired
|
||||||
on the types long_int and time_t too, as SHR is used on
|
on the types long_int and time_t too, as SHR is used on
|
||||||
|
@ -104,12 +104,8 @@ verify (long_int_is_wide_enough, INT_MAX == INT_MAX * (long_int) 2 / 2);
|
|||||||
#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
|
#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
|
||||||
|
|
||||||
/* True if negative values of the signed integer type T use two's
|
/* True if negative values of the signed integer type T use two's
|
||||||
complement, ones' complement, or signed magnitude representation,
|
complement, or if T is an unsigned integer type. */
|
||||||
respectively. Much GNU code assumes two's complement, but some
|
|
||||||
people like to be portable to all possible C hosts. */
|
|
||||||
#define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
|
#define TYPE_TWOS_COMPLEMENT(t) ((t) ~ (t) 0 == (t) -1)
|
||||||
#define TYPE_ONES_COMPLEMENT(t) ((t) ~ (t) 0 == 0)
|
|
||||||
#define TYPE_SIGNED_MAGNITUDE(t) ((t) ~ (t) 0 < (t) -1)
|
|
||||||
|
|
||||||
/* True if the arithmetic type T is signed. */
|
/* True if the arithmetic type T is signed. */
|
||||||
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
|
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
|
||||||
@ -121,9 +117,7 @@ verify (long_int_is_wide_enough, INT_MAX == INT_MAX * (long_int) 2 / 2);
|
|||||||
#define TYPE_MINIMUM(t) \
|
#define TYPE_MINIMUM(t) \
|
||||||
((t) (! TYPE_SIGNED (t) \
|
((t) (! TYPE_SIGNED (t) \
|
||||||
? (t) 0 \
|
? (t) 0 \
|
||||||
: TYPE_SIGNED_MAGNITUDE (t) \
|
: ~ TYPE_MAXIMUM (t)))
|
||||||
? ~ (t) 0 \
|
|
||||||
: ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))
|
|
||||||
#define TYPE_MAXIMUM(t) \
|
#define TYPE_MAXIMUM(t) \
|
||||||
((t) (! TYPE_SIGNED (t) \
|
((t) (! TYPE_SIGNED (t) \
|
||||||
? (t) -1 \
|
? (t) -1 \
|
||||||
@ -138,7 +132,10 @@ verify (long_int_is_wide_enough, INT_MAX == INT_MAX * (long_int) 2 / 2);
|
|||||||
#define TIME_T_MIDPOINT (SHR (TIME_T_MIN + TIME_T_MAX, 1) + 1)
|
#define TIME_T_MIDPOINT (SHR (TIME_T_MIN + TIME_T_MAX, 1) + 1)
|
||||||
|
|
||||||
verify (time_t_is_integer, TYPE_IS_INTEGER (time_t));
|
verify (time_t_is_integer, TYPE_IS_INTEGER (time_t));
|
||||||
verify (twos_complement_arithmetic, TYPE_TWOS_COMPLEMENT (int));
|
verify (twos_complement_arithmetic,
|
||||||
|
(TYPE_TWOS_COMPLEMENT (int)
|
||||||
|
&& TYPE_TWOS_COMPLEMENT (long_int)
|
||||||
|
&& TYPE_TWOS_COMPLEMENT (time_t)));
|
||||||
|
|
||||||
#define EPOCH_YEAR 1970
|
#define EPOCH_YEAR 1970
|
||||||
#define TM_YEAR_BASE 1900
|
#define TM_YEAR_BASE 1900
|
||||||
|
Reference in New Issue
Block a user