Here's a series of proposed patches designed to remove unnecessary dependencies from gnulib's implementation of inttypes.h and related functions. This patch (and the previous strtol patch) effectively removed 11 files from a test version of Emacs that uses strtoumax (in lib: inttypes.h, strtoll,c wchar.h, wchar.in.h; in m4: inttypes-pri.m4, strtoimax.m4, strtol.m4, strtoll,m4, strtoul.m4, wchar_h.m4, wint_t.m4), and removed several unnecessary checks from 'configure'.
This is an incompatible change, and includes a patch to NEWS to describe the incompatibility. Responsibility for declaring imaxabs in <inttypes.h> has been moved to the imaxabs module, and similarly for imaxdiv, strtoimax, strtoumax. Also, <inttypes.h> no longer defines the PRI* and SCN* macros correctly unless the new module inttypes-pri-scn is used. I expect that many programs are like Emacs and don't need these these macros or imaxabs etc., so this should be a win. I haven't tested inttypes-pri-scn but plan to test it before pushing this patch. Sorry about the long "Subject:" in the first patch: I don't know what went wrong. >From 402d05161d2fcfdd2308790969d4b44dae0f9c50 Mon Sep 17 00:00:00 2001 From: Paul Eggert <[email protected]> Date: Fri, 22 Apr 2011 01:11:48 -0700 Subject: [PATCH 1/7] strtoimax: remove dependency on strtoll This is so that if the program needs strtoimax but not strtoll, 'configure' does not check for strtoll unless strtoimax does not exist. * modules/strtoimax (Files): Add lib/strtol.c, lib/strtoll.c, m4/strtoll.m4. (Depends-on): Remove strtoll. * m4/strtoimax.m4 (gl_FUNC_STRTOIMAX): Require gl_INTTYPES_H_DEFAULTS. Check whether strtoimax is declared (this check will be removed from gl_INTTYPES_H). Check for the macro only if strtoimax is not declared. (gl_PREREQ_STRTOIMAX): Call gl_FUNC_STRTOLL, since the strtoimax module no longer depends on the strtoll module. --- ChangeLog | 13 +++++++++++++ m4/strtoimax.m4 | 34 +++++++++++++++++++++------------- modules/strtoimax | 4 +++- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6df0d4e..1355a98 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 2011-04-22 Paul Eggert <[email protected]> + strtoimax: remove dependency on strtoll + This is so that if the program needs strtoimax but not strtoll, + 'configure' does not check for strtoll unless strtoimax does not exist. + * modules/strtoimax (Files): Add lib/strtol.c, lib/strtoll.c, + m4/strtoll.m4. + (Depends-on): Remove strtoll. + * m4/strtoimax.m4 (gl_FUNC_STRTOIMAX): Require gl_INTTYPES_H_DEFAULTS. + Check whether strtoimax is declared (this check will be removed + from gl_INTTYPES_H). Check for the macro only if strtoimax is not + declared. + (gl_PREREQ_STRTOIMAX): Call gl_FUNC_STRTOLL, since the strtoimax + module no longer depends on the strtoll module. + strtol: remove dependency on wchar * lib/strtol.c: Include <wchar.h> only if USE_WIDE_CHAR is defined. * modules/strtol (Depends-on): Remove wchar. diff --git a/m4/strtoimax.m4 b/m4/strtoimax.m4 index e82e7cd..bc94dbb 100644 --- a/m4/strtoimax.m4 +++ b/m4/strtoimax.m4 @@ -1,4 +1,4 @@ -# strtoimax.m4 serial 8 +# strtoimax.m4 serial 9 dnl Copyright (C) 2002-2004, 2006, 2009-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,19 +6,26 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_STRTOIMAX], [ - AC_CACHE_CHECK([whether <inttypes.h> defines strtoimax as a macro], - gl_cv_func_strtoimax_macro, - [AC_EGREP_CPP([inttypes_h_defines_strtoimax], [#include <inttypes.h> -#ifdef strtoimax - inttypes_h_defines_strtoimax -#endif], - gl_cv_func_strtoimax_macro=yes, - gl_cv_func_strtoimax_macro=no)]) + AC_REQUIRE([gl_INTTYPES_H_DEFAULTS]) - if test "$gl_cv_func_strtoimax_macro" != yes; then - AC_REPLACE_FUNCS([strtoimax]) - if test $ac_cv_func_strtoimax = no; then - gl_PREREQ_STRTOIMAX + AC_CHECK_DECLS_ONCE([strtoimax]) + if test "$ac_cv_have_decl_strtoimax" != yes; then + HAVE_DECL_STRTOIMAX=0 + + AC_CACHE_CHECK([whether <inttypes.h> defines strtoimax as a macro], + gl_cv_func_strtoimax_macro, + [AC_EGREP_CPP([inttypes_h_defines_strtoimax], [#include <inttypes.h> + #ifdef strtoimax + inttypes_h_defines_strtoimax + #endif], + gl_cv_func_strtoimax_macro=yes, + gl_cv_func_strtoimax_macro=no)]) + + if test "$gl_cv_func_strtoimax_macro" != yes; then + AC_REPLACE_FUNCS([strtoimax]) + if test $ac_cv_func_strtoimax = no; then + gl_PREREQ_STRTOIMAX + fi fi fi ]) @@ -27,4 +34,5 @@ AC_DEFUN([gl_FUNC_STRTOIMAX], AC_DEFUN([gl_PREREQ_STRTOIMAX], [ AC_CHECK_DECLS([strtoll]) AC_REQUIRE([AC_TYPE_LONG_LONG_INT]) + gl_FUNC_STRTOLL ]) diff --git a/modules/strtoimax b/modules/strtoimax index 9f82af4..df6c88a 100644 --- a/modules/strtoimax +++ b/modules/strtoimax @@ -3,11 +3,13 @@ strtoimax() function: convert string to 'intmax_t'. Files: lib/strtoimax.c +lib/strtol.c +lib/strtoll.c m4/longlong.m4 m4/strtoimax.m4 +m4/strtoll.m4 Depends-on: -strtoll verify inttypes stdint -- 1.7.4.4 >From 68e282b3734aa32b2eeba4f90c18f7ac61304365 Mon Sep 17 00:00:00 2001 From: Paul Eggert <[email protected]> Date: Fri, 22 Apr 2011 01:26:34 -0700 Subject: [PATCH 2/7] strtoumax: remove dependency on strtoimax, strtoull This is like the strtoimax change. * modules/strtoumax (Files): Add lib/strtoimax.c, lib/strtol.c, lib/strtoull.c, m4/strtoull.m4. (Depends-on): Remove strtoimax, strtoull. Add verify. * m4/strtoumax.m4 (gl_FUNC_STRTOUMAX): Remove dependencies, similarly to how it was done for the strtoimax module. (gl_PREREQ_STRTOUMAX): Call gl_FUNC_STRTOULL. --- ChangeLog | 9 +++++++++ m4/strtoumax.m4 | 34 +++++++++++++++++++++------------- modules/strtoumax | 7 +++++-- 3 files changed, 35 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1355a98..13adbd5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2011-04-22 Paul Eggert <[email protected]> + strtoumax: remove dependency on strtoimax, strtoull + This is like the strtoimax change. + * modules/strtoumax (Files): Add lib/strtoimax.c, lib/strtol.c, + lib/strtoull.c, m4/strtoull.m4. + (Depends-on): Remove strtoimax, strtoull. Add verify. + * m4/strtoumax.m4 (gl_FUNC_STRTOUMAX): Remove dependencies, similarly + to how it was done for the strtoimax module. + (gl_PREREQ_STRTOUMAX): Call gl_FUNC_STRTOULL. + strtoimax: remove dependency on strtoll This is so that if the program needs strtoimax but not strtoll, 'configure' does not check for strtoll unless strtoimax does not exist. diff --git a/m4/strtoumax.m4 b/m4/strtoumax.m4 index 448c4d9..f807594 100644 --- a/m4/strtoumax.m4 +++ b/m4/strtoumax.m4 @@ -1,4 +1,4 @@ -# strtoumax.m4 serial 8 +# strtoumax.m4 serial 9 dnl Copyright (C) 2002-2004, 2006, 2009-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,19 +6,26 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_STRTOUMAX], [ - AC_CACHE_CHECK([whether <inttypes.h> defines strtoumax as a macro], - gl_cv_func_strtoumax_macro, - [AC_EGREP_CPP([inttypes_h_defines_strtoumax], [#include <inttypes.h> -#ifdef strtoumax - inttypes_h_defines_strtoumax -#endif], - gl_cv_func_strtoumax_macro=yes, - gl_cv_func_strtoumax_macro=no)]) + AC_REQUIRE([gl_INTTYPES_H_DEFAULTS]) - if test "$gl_cv_func_strtoumax_macro" != yes; then - AC_REPLACE_FUNCS([strtoumax]) - if test $ac_cv_func_strtoumax = no; then - gl_PREREQ_STRTOUMAX + AC_CHECK_DECLS_ONCE([strtoumax]) + if test "$ac_cv_have_decl_strtoumax" != yes; then + HAVE_DECL_STRTOUMAX=0 + + AC_CACHE_CHECK([whether <inttypes.h> defines strtoumax as a macro], + gl_cv_func_strtoumax_macro, + [AC_EGREP_CPP([inttypes_h_defines_strtoumax], [#include <inttypes.h> + #ifdef strtoumax + inttypes_h_defines_strtoumax + #endif], + gl_cv_func_strtoumax_macro=yes, + gl_cv_func_strtoumax_macro=no)]) + + if test "$gl_cv_func_strtoumax_macro" != yes; then + AC_REPLACE_FUNCS([strtoumax]) + if test $ac_cv_func_strtoumax = no; then + gl_PREREQ_STRTOUMAX + fi fi fi ]) @@ -27,4 +34,5 @@ AC_DEFUN([gl_FUNC_STRTOUMAX], AC_DEFUN([gl_PREREQ_STRTOUMAX], [ AC_CHECK_DECLS([strtoull]) AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT]) + gl_FUNC_STRTOULL ]) diff --git a/modules/strtoumax b/modules/strtoumax index e886285..fcbf454 100644 --- a/modules/strtoumax +++ b/modules/strtoumax @@ -2,15 +2,18 @@ Description: strtoumax() function: convert string to 'uintmax_t'. Files: +lib/strtoimax.c +lib/strtol.c +lib/strtoull.c lib/strtoumax.c m4/longlong.m4 +m4/strtoull.m4 m4/strtoumax.m4 Depends-on: -strtoimax -strtoull inttypes stdint +verify configure.ac: gl_FUNC_STRTOUMAX -- 1.7.4.4 >From 0d6f56bb1721e0a6baaac4bf5275ff50c6ea9f70 Mon Sep 17 00:00:00 2001 From: Paul Eggert <[email protected]> Date: Fri, 22 Apr 2011 01:29:51 -0700 Subject: [PATCH 3/7] strtoll: remove dependency on strtol This is so that 'configure' need not check for strtol merely because the application needs strtoll. * modules/strtoll (Files): Add lib/strtol.c. (Depends-on): Remove strtol. --- ChangeLog | 6 ++++++ modules/strtoll | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 13adbd5..49f9049 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2011-04-22 Paul Eggert <[email protected]> + strtoll: remove dependency on strtol + This is so that 'configure' need not check for strtol merely because + the application needs strtoll. + * modules/strtoll (Files): Add lib/strtol.c. + (Depends-on): Remove strtol. + strtoumax: remove dependency on strtoimax, strtoull This is like the strtoimax change. * modules/strtoumax (Files): Add lib/strtoimax.c, lib/strtol.c, diff --git a/modules/strtoll b/modules/strtoll index 738c9ef..8295e83 100644 --- a/modules/strtoll +++ b/modules/strtoll @@ -2,13 +2,13 @@ Description: strtoll() function: convert string to 'long long'. Files: +lib/strtol.c lib/strtoll.c m4/longlong.m4 m4/strtoll.m4 Depends-on: stdlib -strtol configure.ac: gl_FUNC_STRTOLL @@ -24,4 +24,3 @@ LGPL Maintainer: glibc - -- 1.7.4.4 >From 0c752c774a351a0a6eb59626d85b02fba882068f Mon Sep 17 00:00:00 2001 From: Paul Eggert <[email protected]> Date: Fri, 22 Apr 2011 01:31:33 -0700 Subject: [PATCH 4/7] strtoull: remove dependency on strtoul This is like the strtoll change. * modules/strtoull (Files): Add lib/strtol.c, lib/strtoul.c. (Depends-on): Remove strtoul. --- ChangeLog | 5 +++++ modules/strtoull | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 49f9049..5568786 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2011-04-22 Paul Eggert <[email protected]> + strtoull: remove dependency on strtoul + This is like the strtoll change. + * modules/strtoull (Files): Add lib/strtol.c, lib/strtoul.c. + (Depends-on): Remove strtoul. + strtoll: remove dependency on strtol This is so that 'configure' need not check for strtol merely because the application needs strtoll. diff --git a/modules/strtoull b/modules/strtoull index f02e9b0..97ce1fd 100644 --- a/modules/strtoull +++ b/modules/strtoull @@ -2,13 +2,14 @@ Description: strtoull() function: convert string to 'unsigned long long'. Files: +lib/strtol.c +lib/strtoul.c lib/strtoull.c m4/longlong.m4 m4/strtoull.m4 Depends-on: stdlib -strtoul configure.ac: gl_FUNC_STRTOULL @@ -24,4 +25,3 @@ LGPL Maintainer: glibc - -- 1.7.4.4 >From 66f7845fea9f9a50a94e9214dd23225d6644fca8 Mon Sep 17 00:00:00 2001 From: Paul Eggert <[email protected]> Date: Fri, 22 Apr 2011 01:34:06 -0700 Subject: [PATCH 5/7] strtoul: remove dependency on strtol This is so that 'configure' need not check for strtol merely because the application needs strtoul. * modules/strtoul (Files): Add lib/strtol.c. (Depends-on): Remove strtol. --- ChangeLog | 6 ++++++ modules/strtoul | 3 +-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5568786..1ed5995 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2011-04-22 Paul Eggert <[email protected]> + strtoul: remove dependency on strtol + This is so that 'configure' need not check for strtol merely because + the application needs strtoul. + * modules/strtoul (Files): Add lib/strtol.c. + (Depends-on): Remove strtol. + strtoull: remove dependency on strtoul This is like the strtoll change. * modules/strtoull (Files): Add lib/strtol.c, lib/strtoul.c. diff --git a/modules/strtoul b/modules/strtoul index 8cb6d66..9c6ca99 100644 --- a/modules/strtoul +++ b/modules/strtoul @@ -2,11 +2,11 @@ Description: strtoul() function: convert string to 'unsigned long'. Files: +lib/strtol.c lib/strtoul.c m4/strtoul.m4 Depends-on: -strtol configure.ac: gl_FUNC_STRTOUL @@ -21,4 +21,3 @@ LGPL Maintainer: glibc - -- 1.7.4.4 >From b69fedbc0f23ee2961bc4bf41dbb8d68358e94f0 Mon Sep 17 00:00:00 2001 From: Paul Eggert <[email protected]> Date: Fri, 22 Apr 2011 01:59:49 -0700 Subject: [PATCH 6/7] inttypes: migrate 'configure' checks to modules that need it This module was quite heavyweight, and contained 'configure'-time checks that often were not needed. Migrate the checks for PRI* and SCN* macros, which are often not needed, into a new inttypes-pri-scn module. * m4/imaxabs.m4 (gl_FUNC_IMAXABS): Require gl_INTTYPES_H_DEFAULTS instead of gl_INTTYPES_H. Check for imaxabs decl here, not in gl_INTTYPES_H. * m4/imaxdiv.m4 (gl_FUNC_IMAXDIV): Similarly for imaxdiv. * m4/inttypes.m4 (gl_INTTYPES_H): Do not check for the PRI* or SCN* macros; that has been moved to the inttypes-pri-scn module. Do not check for decls of imaxabs etc; that has been moved to their respective modules. Omit check "whether inttypes.h conforms to C99", as the result of the check is never used. (gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION): Move to inttypes-pri-scn module. (gl_INTTYPES_H_DEFAULTS): Provide default values for INT64_MAX_EQ_LONG_MAX, PRI_MACROS_BROKEN, PRIPTR_PREFIX, UINT64_MAX_EQ_ULONG_MAX, in case the inttypes-pri-scn module is not also used. * modules/inttypes (Files): Remove m4/inttypes-pri.m4. * modules/inttypes-pri-scn, m4/inttypes-pri-scn.m4: New files. * NEWS: Document the incompatible change. --- ChangeLog | 24 +++++ NEWS | 8 ++ m4/imaxabs.m4 | 7 +- m4/imaxdiv.m4 | 7 +- m4/inttypes-pri-scn.m4 | 108 ++++++++++++++++++++ m4/inttypes.m4 | 247 +--------------------------------------------- modules/inttypes | 1 - modules/inttypes-pri-scn | 24 +++++ 8 files changed, 179 insertions(+), 247 deletions(-) create mode 100644 m4/inttypes-pri-scn.m4 create mode 100644 modules/inttypes-pri-scn diff --git a/ChangeLog b/ChangeLog index 1ed5995..babb259 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,29 @@ 2011-04-22 Paul Eggert <[email protected]> + inttypes: migrate 'configure' checks to modules that need it + This module was quite heavyweight, and contained 'configure'-time + checks that often were not needed. Migrate the checks for + PRI* and SCN* macros, which are often not needed, into a new + inttypes-pri-scn module. + * m4/imaxabs.m4 (gl_FUNC_IMAXABS): Require gl_INTTYPES_H_DEFAULTS + instead of gl_INTTYPES_H. Check for imaxabs decl here, not in + gl_INTTYPES_H. + * m4/imaxdiv.m4 (gl_FUNC_IMAXDIV): Similarly for imaxdiv. + * m4/inttypes.m4 (gl_INTTYPES_H): Do not check for the PRI* or SCN* + macros; that has been moved to the inttypes-pri-scn module. + Do not check for decls of imaxabs etc; that has been moved to + their respective modules. Omit check "whether inttypes.h conforms + to C99", as the result of the check is never used. + (gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION): Move to inttypes-pri-scn + module. + (gl_INTTYPES_H_DEFAULTS): Provide default values for + INT64_MAX_EQ_LONG_MAX, PRI_MACROS_BROKEN, PRIPTR_PREFIX, + UINT64_MAX_EQ_ULONG_MAX, in case the inttypes-pri-scn module + is not also used. + * modules/inttypes (Files): Remove m4/inttypes-pri.m4. + * modules/inttypes-pri-scn, m4/inttypes-pri-scn.m4: New files. + * NEWS: Document the incompatible change. + strtoul: remove dependency on strtol This is so that 'configure' need not check for strtol merely because the application needs strtoul. diff --git a/NEWS b/NEWS index 7dd126d..79146b5 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,14 @@ User visible incompatible changes Date Modules Changes +2011-04-22 inttypes This module no longer arranges for <inttypes.h> + to declare imaxabs; that has been moved to the + imaxabs module. Similarly for imaxdiv, strtoimax, + and strtoumax. Also, this module no longer + arranges for <inttypes.h> to define the PRI* and + SCN* macros correctly; that has been moved to the + new module inttypes-pri-scn. + 2011-04-19 close-hook This module has been renamed to 'fd-hook' and generalized. diff --git a/m4/imaxabs.m4 b/m4/imaxabs.m4 index 535a26f..11528cb 100644 --- a/m4/imaxabs.m4 +++ b/m4/imaxabs.m4 @@ -1,4 +1,4 @@ -# imaxabs.m4 serial 1 +# imaxabs.m4 serial 2 dnl Copyright (C) 2006, 2009-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,8 +6,11 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_IMAXABS], [ - AC_REQUIRE([gl_INTTYPES_H]) + AC_REQUIRE([gl_INTTYPES_H_DEFAULTS]) + AC_CHECK_DECLS_ONCE([imaxabs]) + if test "$ac_cv_have_decl_imaxabs" != yes; then + HAVE_DECL_IMAXABS=0 AC_LIBOBJ([imaxabs]) gl_PREREQ_IMAXABS fi diff --git a/m4/imaxdiv.m4 b/m4/imaxdiv.m4 index b23f636..712456f 100644 --- a/m4/imaxdiv.m4 +++ b/m4/imaxdiv.m4 @@ -1,4 +1,4 @@ -# imaxdiv.m4 serial 1 +# imaxdiv.m4 serial 2 dnl Copyright (C) 2006, 2009-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,8 +6,11 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_IMAXDIV], [ - AC_REQUIRE([gl_INTTYPES_H]) + AC_REQUIRE([gl_INTTYPES_H_DEFAULTS]) + AC_CHECK_DECLS_ONCE([imaxdiv]) + if test "$ac_cv_have_decl_imaxdiv" != yes; then + HAVE_DECL_IMAXDIV=0 AC_LIBOBJ([imaxdiv]) gl_PREREQ_IMAXDIV fi diff --git a/m4/inttypes-pri-scn.m4 b/m4/inttypes-pri-scn.m4 new file mode 100644 index 0000000..1451297 --- /dev/null +++ b/m4/inttypes-pri-scn.m4 @@ -0,0 +1,108 @@ +# inttypes-pri-scn.m4 serial 1 +dnl Copyright (C) 2006-2011 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Derek Price, Bruno Haible. + +# Ensure that the PRI* and SCN* macros are defined appropriately. +AC_DEFUN([gl_INTTYPES_PRI_SCN], +[ + AC_REQUIRE([gt_INTTYPES_PRI]) + AC_REQUIRE([gl_INTTYPES_H]) + AC_REQUIRE([gl_MULTIARCH]) + + PRIPTR_PREFIX= + if test -n "$STDINT_H"; then + dnl Using the gnulib <stdint.h>. It always defines intptr_t to 'long'. + PRIPTR_PREFIX='"l"' + else + dnl Using the system's <stdint.h>. + for glpfx in '' l ll I64; do + case $glpfx in + '') gltype1='int';; + l) gltype1='long int';; + ll) gltype1='long long int';; + I64) gltype1='__int64';; + esac + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[#include <stdint.h> + extern intptr_t foo; + extern $gltype1 foo;]])], + [PRIPTR_PREFIX='"'$glpfx'"']) + test -n "$PRIPTR_PREFIX" && break + done + fi + AC_SUBST([PRIPTR_PREFIX]) + + gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION( + [INT32_MAX_LT_INTMAX_MAX], + [defined INT32_MAX && defined INTMAX_MAX], + [INT32_MAX < INTMAX_MAX], + [sizeof (int) < sizeof (long long int)]) + if test $APPLE_UNIVERSAL_BUILD = 0; then + gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION( + [INT64_MAX_EQ_LONG_MAX], + [defined INT64_MAX], + [INT64_MAX == LONG_MAX], + [sizeof (long long int) == sizeof (long int)]) + else + INT64_MAX_EQ_LONG_MAX=-1 + fi + gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION( + [UINT32_MAX_LT_UINTMAX_MAX], + [defined UINT32_MAX && defined UINTMAX_MAX], + [UINT32_MAX < UINTMAX_MAX], + [sizeof (unsigned int) < sizeof (unsigned long long int)]) + if test $APPLE_UNIVERSAL_BUILD = 0; then + gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION( + [UINT64_MAX_EQ_ULONG_MAX], + [defined UINT64_MAX], + [UINT64_MAX == ULONG_MAX], + [sizeof (unsigned long long int) == sizeof (unsigned long int)]) + else + UINT64_MAX_EQ_ULONG_MAX=-1 + fi +]) + +# Define the symbol $1 to be 1 if the condition is true, 0 otherwise. +# If $2 is true, the condition is $3; otherwise if long long int is supported +# approximate the condition with $4; otherwise, assume the condition is false. +# The condition should work on all C99 platforms; the approximations should be +# good enough to work on all practical pre-C99 platforms. +# $2 is evaluated by the C preprocessor, $3 and $4 as compile-time constants. +AC_DEFUN([gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION], +[ + AC_CACHE_CHECK([whether $3], + [gl_cv_test_$1], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM( + [[/* Work also in C++ mode. */ + #define __STDC_LIMIT_MACROS 1 + + /* Work if build is not clean. */ + #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H + + #include <limits.h> + #if HAVE_STDINT_H + #include <stdint.h> + #endif + + #if $2 + #define CONDITION ($3) + #elif HAVE_LONG_LONG_INT + #define CONDITION ($4) + #else + #define CONDITION 0 + #endif + int test[CONDITION ? 1 : -1];]])], + [gl_cv_test_$1=yes], + [gl_cv_test_$1=no])]) + if test $gl_cv_test_$1 = yes; then + $1=1; + else + $1=0; + fi + AC_SUBST([$1]) +]) diff --git a/m4/inttypes.m4 b/m4/inttypes.m4 index 92a4ac0..920f72d 100644 --- a/m4/inttypes.m4 +++ b/m4/inttypes.m4 @@ -1,4 +1,4 @@ -# inttypes.m4 serial 18 +# inttypes.m4 serial 19 dnl Copyright (C) 2006-2011 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -10,131 +10,7 @@ dnl Test whether <inttypes.h> is supported or must be substituted. AC_DEFUN([gl_INTTYPES_H], [ AC_REQUIRE([gl_STDINT_H]) - AC_REQUIRE([gt_INTTYPES_PRI]) AC_CHECK_HEADERS_ONCE([inttypes.h]) - AC_CHECK_DECLS_ONCE([imaxabs]) - AC_CHECK_DECLS_ONCE([imaxdiv]) - AC_CHECK_DECLS_ONCE([strtoimax]) - AC_CHECK_DECLS_ONCE([strtoumax]) - - dnl Now see if we need a substitute <inttypes.h>. - dnl A complete <inttypes.h> requires - dnl - a complete <stdint.h>, - dnl - the existence of an <inttypes.h>, - dnl - that imaxabs, imaxdiv, strtoimax, strtoumax are declared, - dnl - some additional tests. - AC_CACHE_CHECK([whether inttypes.h conforms to C99], - [gl_cv_header_working_inttypes_h], - [gl_cv_header_working_inttypes_h=no - if test "$gl_cv_header_working_stdint_h" = yes \ - && test $ac_cv_header_inttypes_h = yes \ - && test "$ac_cv_have_decl_imaxabs" = yes \ - && test "$ac_cv_have_decl_imaxdiv" = yes \ - && test "$ac_cv_have_decl_strtoimax" = yes \ - && test "$ac_cv_have_decl_strtoumax" = yes; then - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[ -#include <stddef.h> -#define __STDC_LIMIT_MACROS 1 /* to make it work also in C++ mode */ -#define __STDC_CONSTANT_MACROS 1 /* to make it work also in C++ mode */ -#define __STDC_FORMAT_MACROS 1 /* to make it work also in C++ mode */ -#define _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H /* work if build isn't clean */ -#include <inttypes.h> - -/* No need to duplicate the tests of stdint.m4; they are subsumed by - $gl_cv_header_working_stdint_h = yes. */ - -/* Tests for macros supposed to be defined in inttypes.h. */ - -const char *k = /* implicit string concatenation */ -#ifdef INT8_MAX - PRId8 PRIi8 -#endif -#ifdef UINT8_MAX - PRIo8 PRIu8 PRIx8 PRIX8 -#endif -#ifdef INT16_MAX - PRId16 PRIi16 -#endif -#ifdef UINT16_MAX - PRIo16 PRIu16 PRIx16 PRIX16 -#endif -#ifdef INT32_MAX - PRId32 PRIi32 -#endif -#ifdef UINT32_MAX - PRIo32 PRIu32 PRIx32 PRIX32 -#endif -#ifdef INT64_MAX - PRId64 PRIi64 -#endif -#ifdef UINT64_MAX - PRIo64 PRIu64 PRIx64 PRIX64 -#endif - PRIdLEAST8 PRIiLEAST8 PRIoLEAST8 PRIuLEAST8 PRIxLEAST8 PRIXLEAST8 - PRIdLEAST16 PRIiLEAST16 PRIoLEAST16 PRIuLEAST16 PRIxLEAST16 PRIXLEAST16 - PRIdLEAST32 PRIiLEAST32 PRIoLEAST32 PRIuLEAST32 PRIxLEAST32 PRIXLEAST32 - PRIdLEAST64 PRIiLEAST64 - PRIoLEAST64 PRIuLEAST64 PRIxLEAST64 PRIXLEAST64 - PRIdFAST8 PRIiFAST8 PRIoFAST8 PRIuFAST8 PRIxFAST8 PRIXFAST8 - PRIdFAST16 PRIiFAST16 PRIoFAST16 PRIuFAST16 PRIxFAST16 PRIXFAST16 - PRIdFAST32 PRIiFAST32 PRIoFAST32 PRIuFAST32 PRIxFAST32 PRIXFAST32 - PRIdFAST64 PRIiFAST64 - PRIoFAST64 PRIuFAST64 PRIxFAST64 PRIXFAST64 - PRIdMAX PRIiMAX PRIoMAX PRIuMAX PRIxMAX PRIXMAX -#ifdef INTPTR_MAX - PRIdPTR PRIiPTR -#endif -#ifdef UINTPTR_MAX - PRIoPTR PRIuPTR PRIxPTR PRIXPTR -#endif - ; -const char *l = /* implicit string concatenation */ -#ifdef INT8_MAX - SCNd8 SCNi8 -#endif -#ifdef UINT8_MAX - SCNo8 SCNu8 SCNx8 -#endif -#ifdef INT16_MAX - SCNd16 SCNi16 -#endif -#ifdef UINT16_MAX - SCNo16 SCNu16 SCNx16 -#endif -#ifdef INT32_MAX - SCNd32 SCNi32 -#endif -#ifdef UINT32_MAX - SCNo32 SCNu32 SCNx32 -#endif -#ifdef INT64_MAX - SCNd64 SCNi64 -#endif -#ifdef UINT64_MAX - SCNo64 SCNu64 SCNx64 -#endif - SCNdLEAST8 SCNiLEAST8 SCNoLEAST8 SCNuLEAST8 SCNxLEAST8 - SCNdLEAST16 SCNiLEAST16 SCNoLEAST16 SCNuLEAST16 SCNxLEAST16 - SCNdLEAST32 SCNiLEAST32 SCNoLEAST32 SCNuLEAST32 SCNxLEAST32 - SCNdLEAST64 SCNiLEAST64 - SCNoLEAST64 SCNuLEAST64 SCNxLEAST64 - SCNdFAST8 SCNiFAST8 SCNoFAST8 SCNuFAST8 SCNxFAST8 - SCNdFAST16 SCNiFAST16 SCNoFAST16 SCNuFAST16 SCNxFAST16 - SCNdFAST32 SCNiFAST32 SCNoFAST32 SCNuFAST32 SCNxFAST32 - SCNdFAST64 SCNiFAST64 - SCNoFAST64 SCNuFAST64 SCNxFAST64 - SCNdMAX SCNiMAX SCNoMAX SCNuMAX SCNxMAX -#ifdef INTPTR_MAX - SCNdPTR SCNiPTR -#endif -#ifdef UINTPTR_MAX - SCNoPTR SCNuPTR SCNxPTR -#endif - ; - ]])], - [gl_cv_header_working_inttypes_h=yes]) - fi]) dnl Override <inttypes.h> always, so that the portability warnings work. AC_REQUIRE([gl_INTTYPES_H_DEFAULTS]) @@ -158,129 +34,12 @@ const char *l = /* implicit string concatenation */ #endif ]) - PRIPTR_PREFIX= - if test -n "$STDINT_H"; then - dnl Using the gnulib <stdint.h>. It always defines intptr_t to 'long'. - PRIPTR_PREFIX='"l"' - else - dnl Using the system's <stdint.h>. - for glpfx in '' l ll I64; do - case $glpfx in - '') gltype1='int';; - l) gltype1='long int';; - ll) gltype1='long long int';; - I64) gltype1='__int64';; - esac - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[#include <stdint.h> - extern intptr_t foo; - extern $gltype1 foo;]])], - [PRIPTR_PREFIX='"'$glpfx'"']) - test -n "$PRIPTR_PREFIX" && break - done - fi - AC_SUBST([PRIPTR_PREFIX]) - - if test "$ac_cv_have_decl_imaxabs" = yes; then - HAVE_DECL_IMAXABS=1 - else - HAVE_DECL_IMAXABS=0 - fi - - if test "$ac_cv_have_decl_imaxdiv" = yes; then - HAVE_DECL_IMAXDIV=1 - else - HAVE_DECL_IMAXDIV=0 - fi - - if test "$ac_cv_have_decl_strtoimax" = yes; then - HAVE_DECL_STRTOIMAX=1 - else - HAVE_DECL_STRTOIMAX=0 - fi - - if test "$ac_cv_have_decl_strtoumax" = yes; then - HAVE_DECL_STRTOUMAX=1 - else - HAVE_DECL_STRTOUMAX=0 - fi - - gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION( - [INT32_MAX_LT_INTMAX_MAX], - [defined INT32_MAX && defined INTMAX_MAX], - [INT32_MAX < INTMAX_MAX], - [sizeof (int) < sizeof (long long int)]) - if test $APPLE_UNIVERSAL_BUILD = 0; then - gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION( - [INT64_MAX_EQ_LONG_MAX], - [defined INT64_MAX], - [INT64_MAX == LONG_MAX], - [sizeof (long long int) == sizeof (long int)]) - else - INT64_MAX_EQ_LONG_MAX=-1 - fi - gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION( - [UINT32_MAX_LT_UINTMAX_MAX], - [defined UINT32_MAX && defined UINTMAX_MAX], - [UINT32_MAX < UINTMAX_MAX], - [sizeof (unsigned int) < sizeof (unsigned long long int)]) - if test $APPLE_UNIVERSAL_BUILD = 0; then - gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION( - [UINT64_MAX_EQ_ULONG_MAX], - [defined UINT64_MAX], - [UINT64_MAX == ULONG_MAX], - [sizeof (unsigned long long int) == sizeof (unsigned long int)]) - else - UINT64_MAX_EQ_ULONG_MAX=-1 - fi - dnl Check for declarations of anything we want to poison if the dnl corresponding gnulib module is not in use. gl_WARN_ON_USE_PREPARE([[#include <inttypes.h> ]], [imaxabs imaxdiv strtoimax strtoumax]) ]) -# Define the symbol $1 to be 1 if the condition is true, 0 otherwise. -# If $2 is true, the condition is $3; otherwise if long long int is supported -# approximate the condition with $4; otherwise, assume the condition is false. -# The condition should work on all C99 platforms; the approximations should be -# good enough to work on all practical pre-C99 platforms. -# $2 is evaluated by the C preprocessor, $3 and $4 as compile-time constants. -AC_DEFUN([gl_INTTYPES_CHECK_LONG_LONG_INT_CONDITION], -[ - AC_CACHE_CHECK([whether $3], - [gl_cv_test_$1], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM( - [[/* Work also in C++ mode. */ - #define __STDC_LIMIT_MACROS 1 - - /* Work if build is not clean. */ - #define _GL_JUST_INCLUDE_SYSTEM_STDINT_H - - #include <limits.h> - #if HAVE_STDINT_H - #include <stdint.h> - #endif - - #if $2 - #define CONDITION ($3) - #elif HAVE_LONG_LONG_INT - #define CONDITION ($4) - #else - #define CONDITION 0 - #endif - int test[CONDITION ? 1 : -1];]])], - [gl_cv_test_$1=yes], - [gl_cv_test_$1=no])]) - if test $gl_cv_test_$1 = yes; then - $1=1; - else - $1=0; - fi - AC_SUBST([$1]) -]) - AC_DEFUN([gl_INTTYPES_MODULE_INDICATOR], [ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. @@ -299,4 +58,8 @@ AC_DEFUN([gl_INTTYPES_H_DEFAULTS], HAVE_DECL_IMAXDIV=1; AC_SUBST([HAVE_DECL_IMAXDIV]) HAVE_DECL_STRTOIMAX=1; AC_SUBST([HAVE_DECL_STRTOIMAX]) HAVE_DECL_STRTOUMAX=1; AC_SUBST([HAVE_DECL_STRTOUMAX]) + INT64_MAX_EQ_LONG_MAX='defined _LP64'; AC_SUBST([INT64_MAX_EQ_LONG_MAX]) + PRI_MACROS_BROKEN=0; AC_SUBST([PRI_MACROS_BROKEN]) + PRIPTR_PREFIX=__PRIPTR_PREFIX; AC_SUBST([PRIPTR_PREFIX]) + UINT64_MAX_EQ_ULONG_MAX='defined _LP64'; AC_SUBST([UINT64_MAX_EQ_ULONG_MAX]) ]) diff --git a/modules/inttypes b/modules/inttypes index f85939c..09442d8 100644 --- a/modules/inttypes +++ b/modules/inttypes @@ -3,7 +3,6 @@ An <inttypes.h> that nearly conforms to C99. Files: lib/inttypes.in.h -m4/inttypes-pri.m4 m4/inttypes.m4 Depends-on: diff --git a/modules/inttypes-pri-scn b/modules/inttypes-pri-scn new file mode 100644 index 0000000..76026c5 --- /dev/null +++ b/modules/inttypes-pri-scn @@ -0,0 +1,24 @@ +Description: +Ensure that the PRI* and SCN* macros work in inttypes.h. + +Files: +m4/inttypes-pri.m4 +m4/inttypes-pri-scn.m4 + +Depends-on: +inttypes +multiarch + +configure.ac: +gl_INTTYPES_PRI_SCN + +Makefile.am: + +Include: +<inttypes.h> + +License: +LGPLv2+ + +Maintainer: +all -- 1.7.4.4 >From c47638570cb16396500392f88ab3f95556a3cc4f Mon Sep 17 00:00:00 2001 From: Paul Eggert <[email protected]> Date: Fri, 22 Apr 2011 02:25:17 -0700 Subject: [PATCH 7/7] Fix typo in modules/strtoumax: it needs strtoul.c too. --- ChangeLog | 2 +- modules/strtoumax | 1 + 2 files changed, 2 insertions(+), 1 deletions(-) diff --git a/ChangeLog b/ChangeLog index babb259..675c895 100644 --- a/ChangeLog +++ b/ChangeLog @@ -44,7 +44,7 @@ strtoumax: remove dependency on strtoimax, strtoull This is like the strtoimax change. * modules/strtoumax (Files): Add lib/strtoimax.c, lib/strtol.c, - lib/strtoull.c, m4/strtoull.m4. + lib/strtoul.c, lib/strtoull.c, m4/strtoull.m4. (Depends-on): Remove strtoimax, strtoull. Add verify. * m4/strtoumax.m4 (gl_FUNC_STRTOUMAX): Remove dependencies, similarly to how it was done for the strtoimax module. diff --git a/modules/strtoumax b/modules/strtoumax index fcbf454..4ff989d 100644 --- a/modules/strtoumax +++ b/modules/strtoumax @@ -4,6 +4,7 @@ strtoumax() function: convert string to 'uintmax_t'. Files: lib/strtoimax.c lib/strtol.c +lib/strtoul.c lib/strtoull.c lib/strtoumax.c m4/longlong.m4 -- 1.7.4.4
