[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
synced mktime.c and strtol.c from intprops.h
From: |
Paul Eggert |
Subject: |
synced mktime.c and strtol.c from intprops.h |
Date: |
Mon, 14 Mar 2005 16:46:10 -0800 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux) |
When I updated intprops.h I forgot to make similar modifications to
mktime.c and strtol.c. I installed this patch to fix that.
2005-03-14 Paul Eggert <address@hidden>
* mktime.c (TYPE_TWOS_COMPLEMENT, TYPE_ONES_COMPLEMENT,
TYPE_SIGNED_MAGNITUDE, TYPE_MINIMUM, TYPE_MAXIMUM): Sync from
intprops.h.
* strtol.c: Likewise.
Index: lib/mktime.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/mktime.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -p -u -r1.48 -r1.49
--- lib/mktime.c 9 Mar 2005 19:11:23 -0000 1.48
+++ lib/mktime.c 15 Mar 2005 00:39:17 -0000 1.49
@@ -68,21 +68,31 @@
an integer. */
#define TYPE_IS_INTEGER(t) ((t) 1.5 == 1)
-/* True if negative values of the integer type T use twos complement
- representation. */
-#define TYPE_TWOS_COMPLEMENT(t) ((t) - (t) 1 == (t) ((t) ~ (t) 1 + (t) 1))
+/* True if negative values of the signed integer type T use twos
+ complement, ones complement, or signed magnitude representation,
+ respectively. Much GNU code assumes twos 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_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. */
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
/* The maximum and minimum values for the integer type T. These
- macros have undefined behavior if T is signed and has padding bits
- (i.e., bits that do not contribute to the value), or if T uses
- signed-magnitude representation. If this is a problem for you,
- please let us know how to fix it for your host. */
-#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
- ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) : (t) 0))
-#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
+ macros have undefined behavior if T is signed and has padding bits.
+ If this is a problem for you, please let us know how to fix it for
+ your host. */
+#define TYPE_MINIMUM(t) \
+ ((t) (! TYPE_SIGNED (t) \
+ ? (t) 0 \
+ : TYPE_SIGNED_MAGNITUDE (t) \
+ ? ~ (t) 0 \
+ : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))
+#define TYPE_MAXIMUM(t) \
+ ((t) (! TYPE_SIGNED (t) \
+ ? (t) -1 \
+ : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
#ifndef TIME_T_MIN
# define TIME_T_MIN TYPE_MINIMUM (time_t)
Index: lib/strtol.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/strtol.c,v
retrieving revision 1.19
retrieving revision 1.21
diff -p -u -r1.19 -r1.21
--- lib/strtol.c 9 Mar 2005 19:11:23 -0000 1.19
+++ lib/strtol.c 15 Mar 2005 00:43:37 -0000 1.21
@@ -127,24 +127,31 @@ extern int errno;
/* The extra casts in the following macros work around compiler bugs,
e.g., in Cray C 5.0.3.0. */
+/* True if negative values of the signed integer type T use twos
+ complement, ones complement, or signed magnitude representation,
+ respectively. Much GNU code assumes twos 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_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. */
-# ifndef TYPE_SIGNED
-# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
-# endif
+# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
/* The maximum and minimum values for the integer type T. These
- macros have undefined behavior if T is signed and has padding bits
- (i.e., bits that do not contribute to the value), or if T uses
- signed-magnitude representation. If this is a problem for you,
- please let us know how to fix it for your host. */
-# ifndef TYPE_MINIMUM
-# define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \
- ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) \
- : (t) 0))
-# endif
-# ifndef TYPE_MAXIMUM
-# define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t)))
-# endif
+ macros have undefined behavior if T is signed and has padding bits.
+ If this is a problem for you, please let us know how to fix it for
+ your host. */
+# define TYPE_MINIMUM(t) \
+ ((t) (! TYPE_SIGNED (t) \
+ ? (t) 0 \
+ : TYPE_SIGNED_MAGNITUDE (t) \
+ ? ~ (t) 0 \
+ : ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1)))
+# define TYPE_MAXIMUM(t) \
+ ((t) (! TYPE_SIGNED (t) \
+ ? (t) -1 \
+ : ~ (~ (t) 0 << (sizeof (t) * CHAR_BIT - 1))))
# ifndef ULONG_LONG_MAX
# define ULONG_LONG_MAX TYPE_MAXIMUM (unsigned long long)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- synced mktime.c and strtol.c from intprops.h,
Paul Eggert <=