summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2005-03-09 19:11:23 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2005-03-09 19:11:23 +0000
commiteef56b544e01755a52fdfbf204e6f2d5800efd21 (patch)
tree510e6ad2669f46e75d1b0bc7af8c09f8a2c2456c
parent4f5d6947d90a65c2b577ef2ca7adf4e413cfe6b6 (diff)
downloadgnulib-eef56b544e01755a52fdfbf204e6f2d5800efd21.tar.gz
Factor int-properties macros into a single file, except for
glibc-related files. * lib/intprops.h: New file. * lib/getloadavg.c: Include it instead of limits.h. (INT_STRLEN_BOUND): Remove. * lib/human.c: Include intprops.h. (group_number): Use INT_STRLEN_BOUND instead of rolling it ourself. * lib/human.h (LONGEST_HUMAN_READABLE): Use 146/485 rather than 302/1000. * lib/inttostr.h: Include intprops.h instead of limits.h. (INT_STRLEN_BOUND, INT_BUFSIZE_BOUND): Remove. * lib/mktime.c (TYPE_IS_INTEGER, TYPE_TWOS_COMPLEMENT): New macros, for consistency with intprops.h. (time_t_is_integer, twos_complement_arithmetic): Use them. * lib/sig2str.h: Include <signal.h>, intprops.h. (INT_STRLEN_BOUND): Remove. * lib/strftime.c (TYPE_SIGNED): Remove. (INT_STRLEN_BOUND): Switch to same implementation as intprops.h. * lib/strtol.c: Adjust comments to match intprops.h. * lib/userspec.c: Include intprops.h. (TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM): Remove. * lib/utimecmp.c, lib/xnanosleep.c, lib/xstrtol.c: Likewise. * lib/utimecmp.c (utimecmp): Use TYPE_IS_INTEGER, TYPE_TWOS_COMPLEMENT instead of rolling our own expressions. * lib/xstrtol.c: Include xstrtol.h first, to test interface. * modules/getloadavg (Files): Add lib/intprops.h. * modules/human (Files): Likewise. * modules/inttostr (Files): Likewise. * modules/sig2str (Files): Likewise. * modules/userspec (Files): Likewise. * modules/utimecmp (Files): Likewise. * modules/xnanosleep (Files): Likewise. * modules/xstrtol (Files): Likewise.
-rw-r--r--lib/ChangeLog37
-rw-r--r--lib/getloadavg.c10
-rw-r--r--lib/human.c7
-rw-r--r--lib/human.h6
-rw-r--r--lib/intprops.h55
-rw-r--r--lib/inttostr.h11
-rw-r--r--lib/mktime.c31
-rw-r--r--lib/sig2str.h9
-rw-r--r--lib/strftime.c13
-rw-r--r--lib/strtol.c14
-rw-r--r--lib/userspec.c11
-rw-r--r--lib/utimecmp.c15
-rw-r--r--lib/xnanosleep.c10
-rw-r--r--lib/xstrtol.c15
-rw-r--r--modules/getloadavg1
-rw-r--r--modules/human2
-rw-r--r--modules/inttostr1
-rw-r--r--modules/sig2str2
-rw-r--r--modules/userspec1
-rw-r--r--modules/utimecmp2
-rw-r--r--modules/xnanosleep1
-rw-r--r--modules/xstrtol1
22 files changed, 164 insertions, 91 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 0a9a5e2b5b..ee53ff7280 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,40 @@
+2005-03-09 Paul Eggert <eggert@cs.ucla.edu>
+
+ Factor int-properties macros into a single file, except for
+ glibc-related files.
+ * intprops.h: New file.
+ * getloadavg.c: Include it instead of limits.h.
+ (INT_STRLEN_BOUND): Remove.
+ * human.c: Include intprops.h.
+ (group_number): Use INT_STRLEN_BOUND instead of rolling it ourself.
+ * human.h (LONGEST_HUMAN_READABLE): Use 146/485 rather than 302/1000.
+ * inttostr.h: Include intprops.h instead of limits.h.
+ (INT_STRLEN_BOUND, INT_BUFSIZE_BOUND): Remove.
+ * mktime.c (TYPE_IS_INTEGER, TYPE_TWOS_COMPLEMENT): New macros,
+ for consistency with intprops.h.
+ (time_t_is_integer, twos_complement_arithmetic): Use them.
+ * sig2str.h: Include <signal.h>, intprops.h.
+ (INT_STRLEN_BOUND): Remove.
+ * strftime.c (TYPE_SIGNED): Remove.
+ (INT_STRLEN_BOUND): Switch to same implementation as intprops.h.
+ * strtol.c: Adjust comments to match intprops.h.
+ * userspec.c: Include intprops.h.
+ (TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM): Remove.
+ * utimecmp.c, xnanosleep.c, xstrtol.c: Likewise.
+ * utimecmp.c (utimecmp): Use TYPE_IS_INTEGER, TYPE_TWOS_COMPLEMENT
+ instead of rolling our own expressions.
+ * xstrtol.c: Include xstrtol.h first, to test interface.
+
+ * strftime.c: Include <stdbool.h>. Use bool where appropriate,
+ instead of int.
+ (my_strftime): Do not mishandle years close to INT_MAX, by doing
+ the right thing even if adding 1900 would overflow. Similarly
+ for tm_mon + 1 and tm_yday + 1.
+ Make %Y always equivalent to %C%y, and similarly for %G and %g.
+ (DO_NUMBER, DO_NUMBER_SPACEPAD): Set digits to d, not a conditional.
+ (DO_SIGNED_NUMBER): New macro.
+ (my_strftime) [HAVE_TZNAME]: Don't dump core if tp->tm_dst > 1.
+
2005-03-07 Bruno Haible <bruno@clisp.org>
* pagealign_alloc.c (MAP_FILE, MAP_FAILED): Define fallbacks.
diff --git a/lib/getloadavg.c b/lib/getloadavg.c
index 8b6067b8c6..7732ddd0db 100644
--- a/lib/getloadavg.c
+++ b/lib/getloadavg.c
@@ -1,7 +1,7 @@
/* Get the system load averages.
Copyright (C) 1985, 1986, 1987, 1988, 1989, 1991, 1992, 1993, 1994,
- 1995, 1997, 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
+ 1995, 1997, 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with gnulib.
Bugs can be reported to bug-gnulib@gnu.org.
@@ -104,6 +104,7 @@
# include "c-strtod.h"
# include "cloexec.h"
+# include "intprops.h"
# include "xalloc.h"
/* The existing Emacs configuration files define a macro called
@@ -349,8 +350,6 @@
# include <unistd.h>
# endif
-# include <limits.h>
-
/* LOAD_AVE_TYPE should only get defined if we're going to use the
nlist method. */
# if !defined (LOAD_AVE_TYPE) && (defined (BSD) || defined (LDAV_CVT) || defined (KERNEL_FILE) || defined (LDAV_SYMBOL))
@@ -578,11 +577,6 @@ getloadavg (double loadavg[], int nelem)
# define LINUX_LDAV_FILE "/proc/loadavg"
# endif
-/* Upper bound on the string length of an integer converted to string.
- 302 / 1000 is ceil (log10 (2.0)). Subtract 1 for the sign bit;
- add 1 for integer division truncation; add 1 more for a minus sign. */
-# define INT_STRLEN_BOUND(t) ((sizeof (t) * CHAR_BIT - 1) * 302 / 1000 + 2)
-
char ldavgbuf[3 * (INT_STRLEN_BOUND (long int) + sizeof ".00")];
char const *ptr = ldavgbuf;
int fd, count;
diff --git a/lib/human.c b/lib/human.c
index 6acc03243c..79336624a9 100644
--- a/lib/human.c
+++ b/lib/human.c
@@ -35,6 +35,7 @@
#include <argmatch.h>
#include <error.h>
+#include <intprops.h>
#include <xstrtol.h>
#ifndef SIZE_MAX
@@ -99,10 +100,8 @@ group_number (char *number, size_t numberlen,
size_t i = numberlen;
/* The maximum possible value for NUMBERLEN is the number of digits
- in the square of the largest uintmax_t, so double the size of
- uintmax_t before converting to a bound. 302 / 1000 is ceil
- (log10 (2.0)). Add 1 for integer division truncation. */
- char buf[2 * sizeof (uintmax_t) * CHAR_BIT * 302 / 1000 + 1];
+ in the square of the largest uintmax_t, so double the size needed. */
+ char buf[2 * INT_STRLEN_BOUND (uintmax_t) + 1];
memcpy (buf, number, numberlen);
d = number + numberlen;
diff --git a/lib/human.h b/lib/human.h
index 553d7ad1bc..7282634067 100644
--- a/lib/human.h
+++ b/lib/human.h
@@ -1,6 +1,6 @@
/* human.h -- print human readable file size
- Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+ Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -39,13 +39,13 @@
/* A conservative bound on the maximum length of a human-readable string.
The output can be the square of the largest uintmax_t, so double
its size before converting to a bound.
- 302 / 1000 is ceil (log10 (2.0)). Add 1 for integer division truncation.
+ log10 (2.0) < 146/485. Add 1 for integer division truncation.
Also, the output can have a thousands separator between every digit,
so multiply by MB_LEN_MAX + 1 and then subtract MB_LEN_MAX.
Append 1 for a space before the suffix.
Finally, append 3, the maximum length of a suffix. */
# define LONGEST_HUMAN_READABLE \
- ((2 * sizeof (uintmax_t) * CHAR_BIT * 302 / 1000 + 1) * (MB_LEN_MAX + 1) \
+ ((2 * sizeof (uintmax_t) * CHAR_BIT * 146 / 485 + 1) * (MB_LEN_MAX + 1) \
- MB_LEN_MAX + 1 + 3)
/* Options for human_readable. */
diff --git a/lib/intprops.h b/lib/intprops.h
new file mode 100644
index 0000000000..cd1c172121
--- /dev/null
+++ b/lib/intprops.h
@@ -0,0 +1,55 @@
+/* intprops.h -- properties of integer types
+
+ Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* Written by Paul Eggert. */
+
+#include <limits.h>
+
+/* The extra casts in the following macros work around compiler bugs,
+ e.g., in Cray C 5.0.3.0. */
+
+/* True if the arithmetic type T is an integer type. bool counts as
+ 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 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)))
+
+/* Bound on length of the string representing an integer value or type T.
+ Subtract 1 for the sign bit if t is signed; log10 (2.0) < 146/485;
+ add 1 for integer division truncation; add 1 more for a minus sign
+ if needed. */
+#define INT_STRLEN_BOUND(t) \
+ ((sizeof (t) * CHAR_BIT - 1) * 146 / 485 + 2)
+
+/* Bound on buffer size needed to represent an integer value or type T,
+ including the terminating null. */
+#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
diff --git a/lib/inttostr.h b/lib/inttostr.h
index 6f2416b53f..5f53681b50 100644
--- a/lib/inttostr.h
+++ b/lib/inttostr.h
@@ -1,6 +1,6 @@
/* inttostr.h -- convert integers to printable strings
- Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+ Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -29,18 +29,11 @@
# include <stdint.h>
#endif
-#include <limits.h>
-
#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
-/* Upper bound on the string length of an integer converted to string.
- 302 / 1000 is ceil (log10 (2.0)). Subtract 1 for the sign bit;
- add 1 for integer division truncation; add 1 more for a minus sign. */
-#define INT_STRLEN_BOUND(t) ((sizeof (t) * CHAR_BIT - 1) * 302 / 1000 + 2)
-
-#define INT_BUFSIZE_BOUND(t) (INT_STRLEN_BOUND (t) + 1)
+#include "intprops.h"
char *offtostr (off_t, char *);
char *imaxtostr (intmax_t, char *);
diff --git a/lib/mktime.c b/lib/mktime.c
index a928c8c345..9a92cb0085 100644
--- a/lib/mktime.c
+++ b/lib/mktime.c
@@ -1,5 +1,6 @@
/* Convert a `struct tm' to a time_t value.
- Copyright (C) 1993-1999, 2002-2004, 2005 Free Software Foundation, Inc.
+ Copyright (C) 1993-1999, 2002, 2003, 2004, 2005 Free Software Foundation,
+ Inc.
This file is part of the GNU C Library.
Contributed by Paul Eggert (eggert@twinsun.com).
@@ -60,10 +61,25 @@
? (a) >> (b) \
: (a) / (1 << (b)) - ((a) % (1 << (b)) < 0))
-/* The extra casts work around common compiler bugs. */
+/* The extra casts in the following macros work around compiler bugs,
+ e.g., in Cray C 5.0.3.0. */
+
+/* True if the arithmetic type T is an integer type. bool counts as
+ 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 the arithmetic type T is signed. */
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
-/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
- It is necessary at least when t == time_t. */
+
+/* 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)))
@@ -79,8 +95,8 @@
/* Verify a requirement at compile-time (unlike assert, which is runtime). */
#define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; }
-verify (time_t_is_integer, (time_t) 0.5 == 0);
-verify (twos_complement_arithmetic, -1 == ~1 + 1);
+verify (time_t_is_integer, TYPE_IS_INTEGER (time_t));
+verify (twos_complement_arithmetic, TYPE_TWOS_COMPLEMENT (int));
/* The code also assumes that signed integer overflow silently wraps
around, but this assumption can't be stated without causing a
diagnostic on some hosts. */
@@ -208,8 +224,7 @@ ranged_convert (struct tm *(*convert) (const time_t *, struct tm *),
{
time_t bad = *t;
time_t ok = 0;
- /* Initialize to make the compiler happy. */
- struct tm tm = { 0, };
+ struct tm tm;
/* BAD is a known unconvertible time_t, and OK is a known good one.
Use binary search to narrow the range between BAD and OK until
diff --git a/lib/sig2str.h b/lib/sig2str.h
index 4fbd21ce25..bdc40f170e 100644
--- a/lib/sig2str.h
+++ b/lib/sig2str.h
@@ -1,6 +1,6 @@
/* sig2str.h -- convert between signal names and numbers
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,15 +18,12 @@
/* Written by Paul Eggert. */
-/* Include <signal.h> before including this file. */
+#include <signal.h>
/* Don't override system declarations of SIG2STR_MAX, sig2str, str2sig. */
#ifndef SIG2STR_MAX
-/* Upper bound on the string length of an integer converted to string.
- 302 / 1000 is ceil (log10 (2.0)). Subtract 1 for the sign bit;
- add 1 for integer division truncation; add 1 more for a minus sign. */
-# define INT_STRLEN_BOUND(t) ((sizeof (t) * CHAR_BIT - 1) * 302 / 1000 + 2)
+# include "intprops.h"
/* Size of a buffer needed to hold a signal name like "HUP". */
# define SIG2STR_MAX (sizeof "SIGRTMAX" + INT_STRLEN_BOUND (int) - 1)
diff --git a/lib/strftime.c b/lib/strftime.c
index 6d742f2655..8085a59925 100644
--- a/lib/strftime.c
+++ b/lib/strftime.c
@@ -120,15 +120,12 @@ extern char *tzname[];
? (a) >> (b) \
: (a) / (1 << (b)) - ((a) % (1 << (b)) < 0))
-#define TYPE_SIGNED(t) ((t) -1 < 0)
-
-/* Bound on length of the string representing an integer value of type t.
- Subtract one for the sign bit if t is signed;
- 302 / 1000 is log10 (2) rounded up;
- add one for integer division truncation;
- add one more for a minus sign if t is signed. */
+/* Bound on length of the string representing an integer value or type T.
+ Subtract 1 for the sign bit if t is signed; log10 (2.0) < 146/485;
+ add 1 for integer division truncation; add 1 more for a minus sign
+ if needed. */
#define INT_STRLEN_BOUND(t) \
- ((sizeof (t) * CHAR_BIT - TYPE_SIGNED (t)) * 302 / 1000 + 1 + TYPE_SIGNED (t))
+ ((sizeof (t) * CHAR_BIT - 1) * 146 / 485 + 2)
#define TM_YEAR_BASE 1900
diff --git a/lib/strtol.c b/lib/strtol.c
index e2b1589a7d..a95a765088 100644
--- a/lib/strtol.c
+++ b/lib/strtol.c
@@ -1,6 +1,6 @@
/* Convert string representation of a number into an integer value.
- Copyright (C) 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2003
+ Copyright (C) 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2003, 2005
Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C
@@ -124,11 +124,19 @@ extern int errno;
# define STRTOL_LONG_MAX LONG_LONG_MAX
# define STRTOL_ULONG_MAX ULONG_LONG_MAX
-/* The extra casts work around common compiler bugs,
- e.g. Cray C 5.0.3.0 when t == time_t. */
+/* The extra casts in the following macros work around compiler bugs,
+ e.g., in Cray C 5.0.3.0. */
+
+/* True if the arithmetic type T is signed. */
# ifndef TYPE_SIGNED
# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
# endif
+
+/* 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) \
diff --git a/lib/userspec.c b/lib/userspec.c
index 037961d474..33a9cfd1a2 100644
--- a/lib/userspec.c
+++ b/lib/userspec.c
@@ -1,5 +1,5 @@
/* userspec.c -- Parse a user and group string.
- Copyright (C) 1989-1992, 1997-1998, 2000, 2002-2004 Free Software
+ Copyright (C) 1989-1992, 1997-1998, 2000, 2002-2005 Free Software
Foundation, Inc.
This program is free software; you can redistribute it and/or modify
@@ -43,6 +43,7 @@
# include <unistd.h>
#endif
+#include "intprops.h"
#include "inttostr.h"
#include "strdup.h"
#include "xalloc.h"
@@ -66,14 +67,6 @@ struct group *getgrgid ();
# define endpwent() ((void) 0)
#endif
-/* The extra casts work around common compiler bugs. */
-#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
-/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
- It is necessary at least when t == time_t. */
-#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)))
-
#ifndef UID_T_MAX
# define UID_T_MAX TYPE_MAXIMUM (uid_t)
#endif
diff --git a/lib/utimecmp.c b/lib/utimecmp.c
index 1ff61f39ae..edce9ef121 100644
--- a/lib/utimecmp.c
+++ b/lib/utimecmp.c
@@ -1,6 +1,6 @@
/* utimecmp.c -- compare file time stamps
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -35,6 +35,7 @@
#include <stdbool.h>
#include <stdlib.h>
#include "hash.h"
+#include "intprops.h"
#include "timespec.h"
#include "utimens.h"
#include "xalloc.h"
@@ -50,14 +51,6 @@
# define SIZE_MAX ((size_t) -1)
#endif
-/* The extra casts work around common compiler bugs. */
-#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
-/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
- It is necessary at least when t == time_t. */
-#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)))
-
enum { BILLION = 1000 * 1000 * 1000 };
/* Best possible resolution that utimens can set and stat can return,
@@ -140,8 +133,8 @@ utimecmp (char const *dst_name,
time_t might be unsigned. */
- verify (time_t_is_integer, (time_t) 0.5 == 0);
- verify (twos_complement_arithmetic, -1 == ~1 + 1);
+ verify (time_t_is_integer, TYPE_IS_INTEGER (time_t));
+ verify (twos_complement_arithmetic, TYPE_TWOS_COMPLEMENT (int));
/* Destination and source time stamps. */
time_t dst_s = dst_stat->st_mtime;
diff --git a/lib/xnanosleep.c b/lib/xnanosleep.c
index fcfe3d551d..fe98165a5c 100644
--- a/lib/xnanosleep.c
+++ b/lib/xnanosleep.c
@@ -32,15 +32,7 @@
#include <sys/types.h>
#include <time.h>
-#include "timespec.h"
-
-/* The extra casts work around common compiler bugs. */
-#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
-/* The outer cast is needed to work around a bug in Cray C 5.0.3.0.
- It is necessary at least when t == time_t. */
-#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)))
+#include "intprops.h"
#ifndef TIME_T_MAX
# define TIME_T_MAX TYPE_MAXIMUM (time_t)
diff --git a/lib/xstrtol.c b/lib/xstrtol.c
index 906e4a1cc1..af81eae9e6 100644
--- a/lib/xstrtol.c
+++ b/lib/xstrtol.c
@@ -1,7 +1,7 @@
/* A more useful interface to strtol.
- Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2003, 2004 Free
- Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2003, 2004, 2005
+ Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -23,6 +23,8 @@
# include <config.h>
#endif
+#include "xstrtol.h"
+
#ifndef __strtol
# define __strtol strtol
# define __strtol_t long int
@@ -42,12 +44,7 @@
#include <stdlib.h>
#include <string.h>
-/* The extra casts work around common compiler bugs. */
-#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
-#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)))
+#include "intprops.h"
#ifndef STRTOL_T_MINIMUM
# define STRTOL_T_MINIMUM TYPE_MINIMUM (__strtol_t)
@@ -62,8 +59,6 @@
#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c))
-#include "xstrtol.h"
-
#if !HAVE_DECL_STRTOIMAX && !defined strtoimax
intmax_t strtoimax ();
#endif
diff --git a/modules/getloadavg b/modules/getloadavg
index e2ede2bdc2..8d02810a1b 100644
--- a/modules/getloadavg
+++ b/modules/getloadavg
@@ -3,6 +3,7 @@ Return the current system load averages.
Files:
lib/getloadavg.c
+lib/intprops.h
Depends-on:
cloexec
diff --git a/modules/human b/modules/human
index 78ab324963..5b7ff6a13f 100644
--- a/modules/human
+++ b/modules/human
@@ -5,6 +5,7 @@ with K/M/G suffix.
Files:
lib/human.h
lib/human.c
+lib/intprops.h
m4/ulonglong.m4
m4/stdint_h.m4
m4/inttypes_h.m4
@@ -32,4 +33,3 @@ GPL
Maintainer:
Paul Eggert
-
diff --git a/modules/inttostr b/modules/inttostr
index f070d3f390..b17445194f 100644
--- a/modules/inttostr
+++ b/modules/inttostr
@@ -3,6 +3,7 @@ Convert integers to printable strings.
Files:
lib/imaxtostr.c
+lib/intprops.h
lib/inttostr.c
lib/inttostr.h
lib/offtostr.c
diff --git a/modules/sig2str b/modules/sig2str
index 42c8073030..5f6fce5a38 100644
--- a/modules/sig2str
+++ b/modules/sig2str
@@ -2,6 +2,7 @@ Description:
Convert between signal names and signal numbers.
Files:
+lib/intprops.h
lib/sig2str.h
lib/sig2str.c
m4/sig2str.m4
@@ -22,4 +23,3 @@ GPL
Maintainer:
Paul Eggert, Jim Meyering
-
diff --git a/modules/userspec b/modules/userspec
index a0b1ec29fd..98521fc329 100644
--- a/modules/userspec
+++ b/modules/userspec
@@ -2,6 +2,7 @@ Description:
Parse a `user:group' specifier (e.g. the first argument of chown utility).
Files:
+lib/intprops.h
lib/userspec.c
lib/userspec.h
m4/userspec.m4
diff --git a/modules/utimecmp b/modules/utimecmp
index d65ef3e336..64a4fa3207 100644
--- a/modules/utimecmp
+++ b/modules/utimecmp
@@ -2,6 +2,7 @@ Description:
compare file time stamps
Files:
+lib/intprops.h
lib/utimecmp.h
lib/utimecmp.c
m4/utimecmp.m4
@@ -26,4 +27,3 @@ GPL
Maintainer:
Paul Eggert, Jim Meyering
-
diff --git a/modules/xnanosleep b/modules/xnanosleep
index 18abf00981..546daf4091 100644
--- a/modules/xnanosleep
+++ b/modules/xnanosleep
@@ -2,6 +2,7 @@ Description:
a more convenient interface to nanosleep
Files:
+lib/intprops.h
lib/xnanosleep.h
lib/xnanosleep.c
m4/xnanosleep.m4
diff --git a/modules/xstrtol b/modules/xstrtol
index f453cf2e00..04c825b03b 100644
--- a/modules/xstrtol
+++ b/modules/xstrtol
@@ -2,6 +2,7 @@ Description:
Convert string to 'long` or 'unsigned long', with error checking.
Files:
+lib/intprops.h
lib/xstrtol.h
lib/xstrtol.c
lib/xstrtoul.c