With this revamped 'limits-h' module, a number of other modules can
be simplified. Done as in the attached patches.


2018-09-06  Bruno Haible  <[email protected]>

        count-trailing-zeros tests: Rely on limits-h module.
        * tests/test-count-trailing-zeros.c (ULLONG_MAX): Remove fallback
        definition.
        * modules/count-trailing-zeros-tests (Depends-on): Add 'limits-h'.

2018-09-06  Bruno Haible  <[email protected]>

        count-leading-zeros tests: Rely on limits-h module.
        * tests/test-count-leading-zeros.c (ULLONG_MAX): Remove fallback
        definition.
        * modules/count-leading-zeros-tests (Depends-on): Add 'limits-h'.

2018-09-06  Bruno Haible  <[email protected]>

        count-one-bits tests: Rely on limits-h module.
        * tests/test-count-one-bits.c (ULLONG_MAX): Remove fallback definition.
        * modules/count-one-bits-tests (Depends-on): Add 'limits-h'.

2018-09-06  Bruno Haible  <[email protected]>

        xstrtoll: Rely on limits-h module.
        * lib/xstrtol.c: Don't include intprops.h.
        (ULLONG_MAX, LLONG_MAX, LLONG_MIN): Remove fallback definitions.
        * modules/xstrtol (Depends-on): Remove 'intprops'.
        * modules/xstrtoll (Depends-on): Add 'limits-h'.

2018-09-06  Bruno Haible  <[email protected]>

        strtoll, strtoull: Rely on limits-h module.
        * lib/strtol.c (TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM): Remove macros.
        (ULLONG_MAX, LLONG_MAX, LLONG_MIN): Remove fallback definitions.
        * modules/strtoll (Depends-on): Add limits-h.
        * modules/strtoull (Depends-on): Likewise.

>From 05e49b15838f5bce440ffc87693f6fc670614ba0 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Thu, 6 Sep 2018 14:41:00 +0200
Subject: [PATCH 1/5] strtoll, strtoull: Rely on limits-h module.

* lib/strtol.c (TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM): Remove macros.
(ULLONG_MAX, LLONG_MAX, LLONG_MIN): Remove fallback definitions.
* modules/strtoll (Depends-on): Add limits-h.
* modules/strtoull (Depends-on): Likewise.
---
 ChangeLog        |  8 ++++++++
 lib/strtol.c     | 29 -----------------------------
 modules/strtoll  |  1 +
 modules/strtoull |  1 +
 4 files changed, 10 insertions(+), 29 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3166c7c..4116600 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2018-09-06  Bruno Haible  <[email protected]>
 
+	strtoll, strtoull: Rely on limits-h module.
+	* lib/strtol.c (TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM): Remove macros.
+	(ULLONG_MAX, LLONG_MAX, LLONG_MIN): Remove fallback definitions.
+	* modules/strtoll (Depends-on): Add limits-h.
+	* modules/strtoull (Depends-on): Likewise.
+
+2018-09-06  Bruno Haible  <[email protected]>
+
 	intprops tests: Fix compilation error with pre-C99 compiler.
 	* tests/test-intprops.c (verify_stmt): New macro.
 	(VERIFY, main): Use it.
diff --git a/lib/strtol.c b/lib/strtol.c
index 55871b4..f6f5c32 100644
--- a/lib/strtol.c
+++ b/lib/strtol.c
@@ -117,35 +117,6 @@
 # define STRTOL_LONG_MIN LLONG_MIN
 # define STRTOL_LONG_MAX LLONG_MAX
 # define STRTOL_ULONG_MAX ULLONG_MAX
-
-/* 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.  */
-# define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
-
-/* Minimum and maximum values for integer types.
-   These macros have undefined behavior for signed types that either
-   have padding bits or do not use two's complement.  If this is a
-   problem for you, please let us know how to fix it for your host.  */
-
-/* The maximum and minimum values for the integer type T.  */
-# define TYPE_MINIMUM(t) ((t) ~ TYPE_MAXIMUM (t))
-# define TYPE_MAXIMUM(t)                                                 \
-   ((t) (! TYPE_SIGNED (t)                                               \
-         ? (t) -1                                                        \
-         : ((((t) 1 << (sizeof (t) * CHAR_BIT - 2)) - 1) * 2 + 1)))
-
-# ifndef ULLONG_MAX
-#  define ULLONG_MAX TYPE_MAXIMUM (unsigned long long)
-# endif
-# ifndef LLONG_MAX
-#  define LLONG_MAX TYPE_MAXIMUM (long long int)
-# endif
-# ifndef LLONG_MIN
-#  define LLONG_MIN TYPE_MINIMUM (long long int)
-# endif
-
 # if __GNUC__ == 2 && __GNUC_MINOR__ < 7
    /* Work around gcc bug with using this constant.  */
    static const unsigned long long int maxquad = ULLONG_MAX;
diff --git a/modules/strtoll b/modules/strtoll
index 5501fda..082d7f4 100644
--- a/modules/strtoll
+++ b/modules/strtoll
@@ -8,6 +8,7 @@ m4/longlong.m4
 m4/strtoll.m4
 
 Depends-on:
+limits-h
 stdlib
 
 configure.ac:
diff --git a/modules/strtoull b/modules/strtoull
index 6bb66fe..7f94bca 100644
--- a/modules/strtoull
+++ b/modules/strtoull
@@ -9,6 +9,7 @@ m4/longlong.m4
 m4/strtoull.m4
 
 Depends-on:
+limits-h
 stdlib
 
 configure.ac:
-- 
2.7.4

>From c4b2df3e3a859ac2eebc3f1685bdc6ff3d4c3ba3 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Thu, 6 Sep 2018 14:46:06 +0200
Subject: [PATCH 2/5] xstrtoll: Rely on limits-h module.

* lib/xstrtol.c: Don't include intprops.h.
(ULLONG_MAX, LLONG_MAX, LLONG_MIN): Remove fallback definitions.
* modules/xstrtol (Depends-on): Remove 'intprops'.
* modules/xstrtoll (Depends-on): Add 'limits-h'.
---
 ChangeLog        |  8 ++++++++
 lib/xstrtol.c    | 14 --------------
 modules/xstrtol  |  1 -
 modules/xstrtoll |  1 +
 4 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4116600..6eb3027 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2018-09-06  Bruno Haible  <[email protected]>
 
+	xstrtoll: Rely on limits-h module.
+	* lib/xstrtol.c: Don't include intprops.h.
+	(ULLONG_MAX, LLONG_MAX, LLONG_MIN): Remove fallback definitions.
+	* modules/xstrtol (Depends-on): Remove 'intprops'.
+	* modules/xstrtoll (Depends-on): Add 'limits-h'.
+
+2018-09-06  Bruno Haible  <[email protected]>
+
 	strtoll, strtoull: Rely on limits-h module.
 	* lib/strtol.c (TYPE_SIGNED, TYPE_MINIMUM, TYPE_MAXIMUM): Remove macros.
 	(ULLONG_MAX, LLONG_MAX, LLONG_MIN): Remove fallback definitions.
diff --git a/lib/xstrtol.c b/lib/xstrtol.c
index d8b4edb..1332e3f 100644
--- a/lib/xstrtol.c
+++ b/lib/xstrtol.c
@@ -41,20 +41,6 @@
 #include <string.h>
 
 #include "assure.h"
-#include "intprops.h"
-
-/* xstrtoll.c and xstrtoull.c, which include this file, require that
-   ULLONG_MAX, LLONG_MAX, LLONG_MIN are defined, but <limits.h> does not
-   define them on all platforms.  */
-#ifndef ULLONG_MAX
-# define ULLONG_MAX TYPE_MAXIMUM (unsigned long long)
-#endif
-#ifndef LLONG_MAX
-# define LLONG_MAX TYPE_MAXIMUM (long long int)
-#endif
-#ifndef LLONG_MIN
-# define LLONG_MIN TYPE_MINIMUM (long long int)
-#endif
 
 static strtol_error
 bkm_scale (__strtol_t *x, int scale_factor)
diff --git a/modules/xstrtol b/modules/xstrtol
index 9c89aef..26240ec 100644
--- a/modules/xstrtol
+++ b/modules/xstrtol
@@ -14,7 +14,6 @@ exitfail
 error
 getopt-gnu
 gettext-h
-intprops
 inttypes-incomplete
 
 configure.ac:
diff --git a/modules/xstrtoll b/modules/xstrtoll
index a5da211..ee5fa8e 100644
--- a/modules/xstrtoll
+++ b/modules/xstrtoll
@@ -6,6 +6,7 @@ lib/xstrtoll.c
 lib/xstrtoull.c
 
 Depends-on:
+limits-h
 strtoll
 strtoull
 xstrtol
-- 
2.7.4

>From 2bbce4309739a9b396f6839922f0e34ae757daf6 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Thu, 6 Sep 2018 14:48:00 +0200
Subject: [PATCH 3/5] count-one-bits tests: Rely on limits-h module.

* tests/test-count-one-bits.c (ULLONG_MAX): Remove fallback definition.
* modules/count-one-bits-tests (Depends-on): Add 'limits-h'.
---
 modules/count-one-bits-tests | 1 +
 tests/test-count-one-bits.c  | 5 -----
 2 files changed, 1 insertion(+), 5 deletions(-)

diff --git a/modules/count-one-bits-tests b/modules/count-one-bits-tests
index bf0a543..c0432d0 100644
--- a/modules/count-one-bits-tests
+++ b/modules/count-one-bits-tests
@@ -3,6 +3,7 @@ tests/test-count-one-bits.c
 tests/macros.h
 
 Depends-on:
+limits-h
 
 configure.ac:
 
diff --git a/tests/test-count-one-bits.c b/tests/test-count-one-bits.c
index fef087e..0215e77 100644
--- a/tests/test-count-one-bits.c
+++ b/tests/test-count-one-bits.c
@@ -29,11 +29,6 @@
 #define ULONG_BIT (sizeof (unsigned long int) * CHAR_BIT)
 #define ULLONG_BIT (sizeof (unsigned long long int) * CHAR_BIT)
 
-#ifndef ULLONG_MAX
-# define HALF (1ULL << (sizeof (unsigned long long int) * CHAR_BIT - 1))
-# define ULLONG_MAX (HALF - 1 + HALF)
-#endif
-
 int
 main (int argc, char *argv[])
 {
-- 
2.7.4

>From 57bac80c66611ad64e50acaaa2a86a7f27cf2600 Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Thu, 6 Sep 2018 14:49:14 +0200
Subject: [PATCH 4/5] count-leading-zeros tests: Rely on limits-h module.

* tests/test-count-leading-zeros.c (ULLONG_MAX): Remove fallback
definition.
* modules/count-leading-zeros-tests (Depends-on): Add 'limits-h'.
---
 ChangeLog                         | 13 +++++++++++++
 modules/count-leading-zeros-tests |  1 +
 tests/test-count-leading-zeros.c  |  5 -----
 3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6eb3027..460fa9f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2018-09-06  Bruno Haible  <[email protected]>
 
+	count-leading-zeros tests: Rely on limits-h module.
+	* tests/test-count-leading-zeros.c (ULLONG_MAX): Remove fallback
+	definition.
+	* modules/count-leading-zeros-tests (Depends-on): Add 'limits-h'.
+
+2018-09-06  Bruno Haible  <[email protected]>
+
+	count-one-bits tests: Rely on limits-h module.
+	* tests/test-count-one-bits.c (ULLONG_MAX): Remove fallback definition.
+	* modules/count-one-bits-tests (Depends-on): Add 'limits-h'.
+
+2018-09-06  Bruno Haible  <[email protected]>
+
 	xstrtoll: Rely on limits-h module.
 	* lib/xstrtol.c: Don't include intprops.h.
 	(ULLONG_MAX, LLONG_MAX, LLONG_MIN): Remove fallback definitions.
diff --git a/modules/count-leading-zeros-tests b/modules/count-leading-zeros-tests
index 1aff87b..6f3ab40 100644
--- a/modules/count-leading-zeros-tests
+++ b/modules/count-leading-zeros-tests
@@ -3,6 +3,7 @@ tests/test-count-leading-zeros.c
 tests/macros.h
 
 Depends-on:
+limits-h
 
 configure.ac:
 
diff --git a/tests/test-count-leading-zeros.c b/tests/test-count-leading-zeros.c
index 0db9af6..4b3fc55 100644
--- a/tests/test-count-leading-zeros.c
+++ b/tests/test-count-leading-zeros.c
@@ -29,11 +29,6 @@
 #define ULONG_BIT (sizeof (unsigned long int) * CHAR_BIT)
 #define ULLONG_BIT (sizeof (unsigned long long int) * CHAR_BIT)
 
-#ifndef ULLONG_MAX
-# define HALF (1ULL << (sizeof (unsigned long long int) * CHAR_BIT - 1))
-# define ULLONG_MAX (HALF - 1 + HALF)
-#endif
-
 int
 main (int argc, char *argv[])
 {
-- 
2.7.4

>From a340c8f8ea0c52dc6196346b6b12a3a96baa387f Mon Sep 17 00:00:00 2001
From: Bruno Haible <[email protected]>
Date: Thu, 6 Sep 2018 14:50:04 +0200
Subject: [PATCH 5/5] count-trailing-zeros tests: Rely on limits-h module.

* tests/test-count-trailing-zeros.c (ULLONG_MAX): Remove fallback
definition.
* modules/count-trailing-zeros-tests (Depends-on): Add 'limits-h'.
---
 ChangeLog                          | 7 +++++++
 modules/count-trailing-zeros-tests | 1 +
 tests/test-count-trailing-zeros.c  | 5 -----
 3 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 460fa9f..a66610f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2018-09-06  Bruno Haible  <[email protected]>
 
+	count-trailing-zeros tests: Rely on limits-h module.
+	* tests/test-count-trailing-zeros.c (ULLONG_MAX): Remove fallback
+	definition.
+	* modules/count-trailing-zeros-tests (Depends-on): Add 'limits-h'.
+
+2018-09-06  Bruno Haible  <[email protected]>
+
 	count-leading-zeros tests: Rely on limits-h module.
 	* tests/test-count-leading-zeros.c (ULLONG_MAX): Remove fallback
 	definition.
diff --git a/modules/count-trailing-zeros-tests b/modules/count-trailing-zeros-tests
index 88b2d0a..1b7e638 100644
--- a/modules/count-trailing-zeros-tests
+++ b/modules/count-trailing-zeros-tests
@@ -3,6 +3,7 @@ tests/test-count-trailing-zeros.c
 tests/macros.h
 
 Depends-on:
+limits-h
 
 configure.ac:
 
diff --git a/tests/test-count-trailing-zeros.c b/tests/test-count-trailing-zeros.c
index 6edd550..862e57d 100644
--- a/tests/test-count-trailing-zeros.c
+++ b/tests/test-count-trailing-zeros.c
@@ -29,11 +29,6 @@
 #define ULONG_BIT (sizeof (unsigned long int) * CHAR_BIT)
 #define ULLONG_BIT (sizeof (unsigned long long int) * CHAR_BIT)
 
-#ifndef ULLONG_MAX
-# define HALF (1ULL << (sizeof (unsigned long long int) * CHAR_BIT - 1))
-# define ULLONG_MAX (HALF - 1 + HALF)
-#endif
-
 int
 main (int argc, char *argv[])
 {
-- 
2.7.4

Reply via email to