changeset 39378:a24cbc969ed9

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.
author Bruno Haible <bruno@clisp.org>
date Sun, 13 May 2018 23:23:47 +0200
parents d4f5e651f17c
children 5530508745d3
files ChangeLog lib/inttypes.in.h m4/imaxdiv.m4 m4/inttypes.m4 modules/inttypes-incomplete
diffstat 5 files changed, 37 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun May 13 22:20:13 2018 +0200
+++ b/ChangeLog	Sun May 13 23:23:47 2018 +0200
@@ -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.
--- a/lib/inttypes.in.h	Sun May 13 22:20:13 2018 +0200
+++ b/lib/inttypes.in.h	Sun May 13 23:23:47 2018 +0200
@@ -1067,11 +1067,13 @@
 #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
--- a/m4/imaxdiv.m4	Sun May 13 22:20:13 2018 +0200
+++ b/m4/imaxdiv.m4	Sun May 13 23:23:47 2018 +0200
@@ -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 @@
   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.
--- a/m4/inttypes.m4	Sun May 13 22:20:13 2018 +0200
+++ b/m4/inttypes.m4	Sun May 13 23:23:47 2018 +0200
@@ -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 @@
   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])
--- a/modules/inttypes-incomplete	Sun May 13 22:20:13 2018 +0200
+++ b/modules/inttypes-incomplete	Sun May 13 23:23:47 2018 +0200
@@ -42,6 +42,7 @@
 	      -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' \