From a26916573e4d78592989c6eecbbe4081d0398d43 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 22 Jan 2023 12:25:06 +0100 Subject: [PATCH 22/47] Resolve conflicts for functions introduced in Android API level 21. * m4/random.m4 (gl_FUNC_RANDOM): Conditionally set REPLACE_INITSTATE, REPLACE_SETSTATE. * lib/stdlib.in.h (initstate, setstate): Disable _GL_CXXALIASWARN invocation on non-glibc systems. --- ChangeLog | 5 +++++ lib/stdlib.in.h | 4 ++++ m4/random.m4 | 36 +++++++++++++++++++++++------------- 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index ea0077fcbb..3de67682f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,11 @@ Resolve conflicts for functions introduced in Android API level 21. + * m4/random.m4 (gl_FUNC_RANDOM): Conditionally set REPLACE_INITSTATE, + REPLACE_SETSTATE. + * lib/stdlib.in.h (initstate, setstate): Disable _GL_CXXALIASWARN + invocation on non-glibc systems. + * m4/dprintf.m4 (gl_REPLACE_DPRINTF): Conditionally set REPLACE_DPRINTF. * lib/stdio.in.h (dprintf): Disable _GL_CXXALIASWARN invocation on non-glibc systems. diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index 88a8e034a1..c9e2475477 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -1013,7 +1013,9 @@ _GL_FUNCDECL_SYS (initstate, char *, _GL_CXXALIAS_SYS_CAST (initstate, char *, (unsigned int seed, char *buf, size_t buf_size)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (initstate); +# endif #elif defined GNULIB_POSIXCHECK # undef initstate # if HAVE_RAW_DECL_INITSTATE @@ -1038,7 +1040,9 @@ _GL_FUNCDECL_SYS (setstate, char *, (char *arg_state) _GL_ARG_NONNULL ((1))); is const char *arg_state. */ _GL_CXXALIAS_SYS_CAST (setstate, char *, (char *arg_state)); # endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (setstate); +# endif #elif defined GNULIB_POSIXCHECK # undef setstate # if HAVE_RAW_DECL_SETSTATE diff --git a/m4/random.m4 b/m4/random.m4 index b99603cf9a..b0d1cb86ee 100644 --- a/m4/random.m4 +++ b/m4/random.m4 @@ -1,4 +1,4 @@ -# random.m4 serial 5 +# random.m4 serial 6 dnl Copyright (C) 2012-2023 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -19,29 +19,39 @@ AC_DEFUN([gl_FUNC_RANDOM], [gl_cv_func_random=yes], [gl_cv_func_random=no]) ]) + gl_CHECK_FUNCS_ANDROID([initstate], [[#include ]]) + gl_CHECK_FUNCS_ANDROID([setstate], [[#include ]]) if test $gl_cv_func_random = no; then HAVE_RANDOM=0 HAVE_INITSTATE=0 HAVE_SETSTATE=0 else - gl_CHECK_FUNCS_ANDROID([initstate], [[#include ]]) - gl_CHECK_FUNCS_ANDROID([setstate], [[#include ]]) if test $ac_cv_func_initstate = no; then HAVE_INITSTATE=0 fi if test $ac_cv_func_setstate = no; then HAVE_SETSTATE=0 fi - if test $ac_cv_func_initstate = no || test $ac_cv_func_setstate = no; then - dnl In order to define initstate or setstate, we need to define all the - dnl functions at once. - REPLACE_RANDOM=1 - if test $ac_cv_func_initstate = yes; then - REPLACE_INITSTATE=1 - fi - if test $ac_cv_func_setstate = yes; then - REPLACE_SETSTATE=1 - fi + fi + if test $HAVE_INITSTATE = 0; then + case "$gl_cv_onwards_func_initstate" in + future*) REPLACE_INITSTATE=1 ;; + esac + fi + if test $HAVE_SETSTATE = 0; then + case "$gl_cv_onwards_func_setstate" in + future*) REPLACE_SETSTATE=1 ;; + esac + fi + if test $ac_cv_func_initstate = no || test $ac_cv_func_setstate = no; then + dnl In order to define initstate or setstate, we need to define all the + dnl functions at once. + REPLACE_RANDOM=1 + if test $ac_cv_func_initstate = yes; then + REPLACE_INITSTATE=1 + fi + if test $ac_cv_func_setstate = yes; then + REPLACE_SETSTATE=1 fi fi -- 2.34.1