From 88d119b2a44243255dbcd720e296393986d16551 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 13 May 2018 23:23:47 +0200 Subject: [PATCH] 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. --- ChangeLog | 10 ++++++++++ lib/inttypes.in.h | 4 +++- m4/imaxdiv.m4 | 22 +++++++++++++++++++++- m4/inttypes.m4 | 3 ++- modules/inttypes-incomplete | 1 + 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index bd75aedca5..9dc6edb5e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2018-05-13 Bruno Haible + + 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 Support selective inclusion mechanism of recent mingw.org header files. diff --git a/lib/inttypes.in.h b/lib/inttypes.in.h index 1e303cb79b..c7d7968e6e 100644 --- a/lib/inttypes.in.h +++ b/lib/inttypes.in.h @@ -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 diff --git a/m4/imaxdiv.m4 b/m4/imaxdiv.m4 index 4539493715..33931faf64 100644 --- a/m4/imaxdiv.m4 +++ b/m4/imaxdiv.m4 @@ -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 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 + 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. diff --git a/m4/inttypes.m4 b/m4/inttypes.m4 index 8069493cab..d756f012f6 100644 --- a/m4/inttypes.m4 +++ b/m4/inttypes.m4 @@ -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]) diff --git a/modules/inttypes-incomplete b/modules/inttypes-incomplete index 8c29a29a18..394d48fc14 100644 --- a/modules/inttypes-incomplete +++ b/modules/inttypes-incomplete @@ -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' \ -- 2.39.5