bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [1/7] Proposed patches to remove several inttypes-related dependenci


From: Paul Eggert
Subject: Re: [1/7] Proposed patches to remove several inttypes-related dependencies
Date: Fri, 22 Apr 2011 10:14:08 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.14) Gecko/20110223 Thunderbird/3.1.8

On 04/22/11 03:07, Eric Blake wrote:

> How can the egrep check ever succeed if the declaration check (which
> detects macros) failed?  You can further trim this .m4 file.

On hosts that do this:

#define strtoimax(a,b,c) __strtoll(a,b,c)

the declaration check will fail, because it uses strtoimax
without calling it; but the egrep check will succeed.

But now that you mention it, such hosts will have trouble anyway,
on applications that want to use strtoimax without calling it
right away.  Also, HP-UX 11.00 64-bit has the problem that
it has a macro like the above, but there is no __strtoll; see
<http://lists.gnu.org/archive/html/bug-textutils/2002-09/msg00022.html>.
So that's another reason for removing the macro check -- though
inttypes.h should insulate itself from such applications, by
#undeffing strtoimax before declaring it.

The following further patch should do all that.  Thanks for
bringing this up: it's simpler now!

>From 042fed6602188f2afad444113dcd14dce2ab915e Mon Sep 17 00:00:00 2001
From: Paul Eggert <address@hidden>
Date: Fri, 22 Apr 2011 10:06:33 -0700
Subject: [PATCH] strtoimax, strtoumax: simplify, port to HP-UX 11.00 64-bit

This supports apps that need pointers to strtoimax and strtoumax,
and ports to HP-UX 11.00 64.bit, which has macros that expand to
nonexistent functions.  See
<http://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00241.html>
et seq.
* lib/inttypes.in.h (strtoimax, strtoumax): #undef before declaring.
* m4/strtoimax.m4 (gl_FUNC_STRTOIMAX): Don't check whether it's
a macro.
* m4/strtoumax.m4 (gl_FUNC_STRTOUMAX): Likewise.
---
 ChangeLog         |   11 +++++++++++
 lib/inttypes.in.h |    2 ++
 m4/strtoimax.m4   |   17 +++--------------
 m4/strtoumax.m4   |   17 +++--------------
 4 files changed, 19 insertions(+), 28 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 675c895..fa00429 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2011-04-22  Paul Eggert  <address@hidden>
 
+       strtoimax, strtoumax: simplify, port to HP-UX 11.00 64-bit
+       This supports apps that need pointers to strtoimax and strtoumax,
+       and ports to HP-UX 11.00 64.bit, which has macros that expand to
+       nonexistent functions.  See
+       <http://lists.gnu.org/archive/html/bug-gnulib/2011-04/msg00241.html>
+       et seq.
+       * lib/inttypes.in.h (strtoimax, strtoumax): #undef before declaring.
+       * m4/strtoimax.m4 (gl_FUNC_STRTOIMAX): Don't check whether it's
+       a macro.
+       * m4/strtoumax.m4 (gl_FUNC_STRTOUMAX): Likewise.
+
        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
diff --git a/lib/inttypes.in.h b/lib/inttypes.in.h
index 6a8f46d..7abf394 100644
--- a/lib/inttypes.in.h
+++ b/lib/inttypes.in.h
@@ -1076,6 +1076,7 @@ _GL_WARN_ON_USE (imaxdiv, "imaxdiv is unportable - "
 
 #if @GNULIB_STRTOIMAX@
 # if address@hidden@
+#  undef strtoimax
 extern intmax_t strtoimax (const char *, char **, int) _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
@@ -1088,6 +1089,7 @@ _GL_WARN_ON_USE (strtoimax, "strtoimax is unportable - "
 
 #if @GNULIB_STRTOUMAX@
 # if address@hidden@
+#  undef strtoumax
 extern uintmax_t strtoumax (const char *, char **, int) _GL_ARG_NONNULL ((1));
 # endif
 #elif defined GNULIB_POSIXCHECK
diff --git a/m4/strtoimax.m4 b/m4/strtoimax.m4
index bc94dbb..187b80d 100644
--- a/m4/strtoimax.m4
+++ b/m4/strtoimax.m4
@@ -12,20 +12,9 @@ AC_DEFUN([gl_FUNC_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
+    AC_REPLACE_FUNCS([strtoimax])
+    if test $ac_cv_func_strtoimax = no; then
+      gl_PREREQ_STRTOIMAX
     fi
   fi
 ])
diff --git a/m4/strtoumax.m4 b/m4/strtoumax.m4
index f807594..3ca38cd 100644
--- a/m4/strtoumax.m4
+++ b/m4/strtoumax.m4
@@ -12,20 +12,9 @@ AC_DEFUN([gl_FUNC_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
+    AC_REPLACE_FUNCS([strtoumax])
+    if test $ac_cv_func_strtoumax = no; then
+      gl_PREREQ_STRTOUMAX
     fi
   fi
 ])
-- 
1.7.4.4





reply via email to

[Prev in Thread] Current Thread [Next in Thread]