imaxdiv: Fix compilation error on Android.
authorBruno Haible <bruno@clisp.org>
Sun, 13 May 2018 21:23:47 +0000 (23:23 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 13 May 2018 21:23:47 +0000 (23:23 +0200)
* m4/imaxdiv.m4 (gl_FUNC_IMAXDIV): Set HAVE_IMAXDIV_T to 0 if imaxdiv_t
is not defined.
* lib/inttypes.in.h (imaxdiv_t): Define if HAVE_IMAXDIV_T, not
HAVE_DECL_IMAXDIV, is 0.
* m4/inttypes.m4 (gl_INTTYPES_H_DEFAULTS): Initialize HAVE_IMAXDIV_T.
* modules/inttypes-incomplete (Makefile.am): Substitute HAVE_IMAXDIV_T.

ChangeLog
lib/inttypes.in.h
m4/imaxdiv.m4
m4/inttypes.m4
modules/inttypes-incomplete

index bd75aedca514d60eb209ee4bad1ea57b14a4af3e..9dc6edb5e641110279c118dd9fbeb3b894d0c618 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2018-05-13  Bruno Haible  <bruno@clisp.org>
+
+       imaxdiv: Fix compilation error on Android.
+       * m4/imaxdiv.m4 (gl_FUNC_IMAXDIV): Set HAVE_IMAXDIV_T to 0 if imaxdiv_t
+       is not defined.
+       * lib/inttypes.in.h (imaxdiv_t): Define if HAVE_IMAXDIV_T, not
+       HAVE_DECL_IMAXDIV, is 0.
+       * m4/inttypes.m4 (gl_INTTYPES_H_DEFAULTS): Initialize HAVE_IMAXDIV_T.
+       * modules/inttypes-incomplete (Makefile.am): Substitute HAVE_IMAXDIV_T.
+
 2018-05-13  Bruno Haible  <bruno@clisp.org>
 
        Support selective inclusion mechanism of recent mingw.org header files.
index 1e303cb79b080d4a82c5365229a72b4f8d4b5e5b..c7d7968e6e9e74c76bb6cfe3c50a54e427faf97e 100644 (file)
@@ -1067,11 +1067,13 @@ _GL_WARN_ON_USE (imaxabs, "imaxabs is unportable - "
 #endif
 
 #if @GNULIB_IMAXDIV@
-# if !@HAVE_DECL_IMAXDIV@
+# if !@HAVE_IMAXDIV_T@
 #  if !GNULIB_defined_imaxdiv_t
 typedef struct { intmax_t quot; intmax_t rem; } imaxdiv_t;
 #   define GNULIB_defined_imaxdiv_t 1
 #  endif
+# endif
+# if !@HAVE_DECL_IMAXDIV@
 extern imaxdiv_t imaxdiv (intmax_t, intmax_t);
 # endif
 #elif defined GNULIB_POSIXCHECK
index 45394937157ed1f8bed37fc90f255e47e2e6118e..33931faf64f5f436ce3d6a99713d92e47a94542d 100644 (file)
@@ -1,4 +1,4 @@
-# imaxdiv.m4 serial 4
+# imaxdiv.m4 serial 5
 dnl Copyright (C) 2006, 2009-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -14,6 +14,26 @@ AC_DEFUN([gl_FUNC_IMAXDIV],
   if test "$ac_cv_have_decl_imaxdiv" != yes; then
     HAVE_DECL_IMAXDIV=0
   fi
+
+  AC_CACHE_CHECK([whether <inttypes.h> defines imaxdiv_t],
+    [gl_cv_type_imaxdiv_t],
+    [dnl Assume that if imaxdiv is declared, imaxdiv_t is defined.
+     if test $ac_cv_have_decl_imaxdiv = yes; then
+       gl_cv_type_imaxdiv_t=yes
+     else
+       AC_COMPILE_IFELSE(
+         [AC_LANG_PROGRAM(
+            [[#include <inttypes.h>
+              imaxdiv_t x;
+            ]])
+         ],
+         [gl_cv_type_imaxdiv_t=yes],
+         [gl_cv_type_imaxdiv_t=no])
+     fi
+    ])
+  if test $gl_cv_type_imaxdiv_t = no; then
+    HAVE_IMAXDIV_T=0
+  fi
 ])
 
 # Prerequisites of lib/imaxdiv.c.
index 8069493cab5c3eeae909bb98316e7177f2e192d4..d756f012f6a26915fcb16a6845c53403e719294a 100644 (file)
@@ -1,4 +1,4 @@
-# inttypes.m4 serial 26
+# inttypes.m4 serial 27
 dnl Copyright (C) 2006-2018 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -147,6 +147,7 @@ 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])
+  HAVE_IMAXDIV_T=1;      AC_SUBST([HAVE_IMAXDIV_T])
   REPLACE_STRTOIMAX=0;   AC_SUBST([REPLACE_STRTOIMAX])
   REPLACE_STRTOUMAX=0;   AC_SUBST([REPLACE_STRTOUMAX])
   INT32_MAX_LT_INTMAX_MAX=1;  AC_SUBST([INT32_MAX_LT_INTMAX_MAX])
index 8c29a29a18cb3d6f7cf229e1f41f425d6bd34d8d..394d48fc14502d22e089146dce432062fd9f3dd4 100644 (file)
@@ -42,6 +42,7 @@ inttypes.h: inttypes.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(WARN_ON_U
              -e 's/@''HAVE_DECL_IMAXDIV''@/$(HAVE_DECL_IMAXDIV)/g' \
              -e 's/@''HAVE_DECL_STRTOIMAX''@/$(HAVE_DECL_STRTOIMAX)/g' \
              -e 's/@''HAVE_DECL_STRTOUMAX''@/$(HAVE_DECL_STRTOUMAX)/g' \
+             -e 's/@''HAVE_IMAXDIV_T''@/$(HAVE_IMAXDIV_T)/g' \
              -e 's/@''REPLACE_STRTOIMAX''@/$(REPLACE_STRTOIMAX)/g' \
              -e 's/@''REPLACE_STRTOUMAX''@/$(REPLACE_STRTOUMAX)/g' \
              -e 's/@''INT32_MAX_LT_INTMAX_MAX''@/$(INT32_MAX_LT_INTMAX_MAX)/g' \