From 39eda5d0b1b3d1df691102b311868ef4ce69d221 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 22 Jan 2023 14:22:28 +0100 Subject: [PATCH 40/47] Resolve conflicts for functions introduced in Android API level 28. * lib/unistd.in.h (getentropy): Consider REPLACE_GETENTROPY. Disable _GL_CXXALIASWARN invocation on non-glibc systems. * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_GETENTROPY. * modules/unistd (Makefile.am): Substitute REPLACE_GETENTROPY. * m4/getentropy.m4 (gl_FUNC_GETENTROPY): Conditionally set REPLACE_GETENTROPY. * modules/getentropy (Depends-on, configure.ac): Consider REPLACE_GETENTROPY. --- ChangeLog | 13 +++++++++++++ lib/unistd.in.h | 15 +++++++++++++-- m4/getentropy.m4 | 5 ++++- m4/unistd_h.m4 | 3 ++- modules/getentropy | 5 +++-- modules/unistd | 1 + 6 files changed, 36 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 513a009fce..fa9d220e0c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2023-01-22 Bruno Haible + + Resolve conflicts for functions introduced in Android API level 28. + + * lib/unistd.in.h (getentropy): Consider REPLACE_GETENTROPY. Disable + _GL_CXXALIASWARN invocation on non-glibc systems. + * m4/unistd_h.m4 (gl_UNISTD_H_DEFAULTS): Initialize REPLACE_GETENTROPY. + * modules/unistd (Makefile.am): Substitute REPLACE_GETENTROPY. + * m4/getentropy.m4 (gl_FUNC_GETENTROPY): Conditionally set + REPLACE_GETENTROPY. + * modules/getentropy (Depends-on, configure.ac): Consider + REPLACE_GETENTROPY. + 2023-01-22 Bruno Haible Resolve conflicts for functions introduced in Android API level 26. diff --git a/lib/unistd.in.h b/lib/unistd.in.h index 9930a11c19..8016f7345e 100644 --- a/lib/unistd.in.h +++ b/lib/unistd.in.h @@ -1207,11 +1207,22 @@ _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - " #if @GNULIB_GETENTROPY@ /* Fill a buffer with random bytes. */ -# if !@HAVE_GETENTROPY@ +# if @REPLACE_GETENTROPY@ +# if !(defined __cplusplus && defined GNULIB_NAMESPACE) +# undef getentropy +# define getentropy rpl_getentropy +# endif +_GL_FUNCDECL_RPL (getentropy, int, (void *buffer, size_t length)); +_GL_CXXALIAS_RPL (getentropy, int, (void *buffer, size_t length)); +# else +# if !@HAVE_GETENTROPY@ _GL_FUNCDECL_SYS (getentropy, int, (void *buffer, size_t length)); -# endif +# endif _GL_CXXALIAS_SYS (getentropy, int, (void *buffer, size_t length)); +# endif +# if __GLIBC__ >= 2 _GL_CXXALIASWARN (getentropy); +# endif #elif defined GNULIB_POSIXCHECK # undef getentropy # if HAVE_RAW_DECL_GETENTROPY diff --git a/m4/getentropy.m4 b/m4/getentropy.m4 index 352b04ee4f..0e7ef26940 100644 --- a/m4/getentropy.m4 +++ b/m4/getentropy.m4 @@ -1,4 +1,4 @@ -# getentropy.m4 serial 2 +# getentropy.m4 serial 3 dnl Copyright 2020-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,5 +19,8 @@ AC_DEFUN([gl_FUNC_GETENTROPY], ]]) if test $ac_cv_func_getentropy = no; then HAVE_GETENTROPY=0 + case "$gl_cv_onwards_func_getentropy" in + future*) REPLACE_GETENTROPY=1 ;; + esac fi ]) diff --git a/m4/unistd_h.m4 b/m4/unistd_h.m4 index fc8e2a58f3..1c96158155 100644 --- a/m4/unistd_h.m4 +++ b/m4/unistd_h.m4 @@ -1,4 +1,4 @@ -# unistd_h.m4 serial 93 +# unistd_h.m4 serial 94 dnl Copyright (C) 2006-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, @@ -240,6 +240,7 @@ AC_DEFUN([gl_UNISTD_H_DEFAULTS], REPLACE_GETCWD=0; AC_SUBST([REPLACE_GETCWD]) REPLACE_GETDOMAINNAME=0; AC_SUBST([REPLACE_GETDOMAINNAME]) REPLACE_GETDTABLESIZE=0; AC_SUBST([REPLACE_GETDTABLESIZE]) + REPLACE_GETENTROPY=0; AC_SUBST([REPLACE_GETENTROPY]) REPLACE_GETLOGIN_R=0; AC_SUBST([REPLACE_GETLOGIN_R]) REPLACE_GETGROUPS=0; AC_SUBST([REPLACE_GETGROUPS]) REPLACE_GETPAGESIZE=0; AC_SUBST([REPLACE_GETPAGESIZE]) diff --git a/modules/getentropy b/modules/getentropy index 2f4bcf054c..3b0c434547 100644 --- a/modules/getentropy +++ b/modules/getentropy @@ -6,13 +6,14 @@ lib/getentropy.c m4/getentropy.m4 Depends-on: -getrandom [test $HAVE_GETENTROPY = 0] +getrandom [test $HAVE_GETENTROPY = 0 || test $REPLACE_GETENTROPY = 1] extensions unistd configure.ac: gl_FUNC_GETENTROPY -gl_CONDITIONAL([GL_COND_OBJ_GETENTROPY], [test $HAVE_GETENTROPY = 0]) +gl_CONDITIONAL([GL_COND_OBJ_GETENTROPY], + [test $HAVE_GETENTROPY = 0 || test $REPLACE_GETENTROPY = 1]) gl_UNISTD_MODULE_INDICATOR([getentropy]) Makefile.am: diff --git a/modules/unistd b/modules/unistd index ddb0991f85..1e9bc9ca6b 100644 --- a/modules/unistd +++ b/modules/unistd @@ -194,6 +194,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H -e 's|@''REPLACE_GETCWD''@|$(REPLACE_GETCWD)|g' \ -e 's|@''REPLACE_GETDOMAINNAME''@|$(REPLACE_GETDOMAINNAME)|g' \ -e 's|@''REPLACE_GETDTABLESIZE''@|$(REPLACE_GETDTABLESIZE)|g' \ + -e 's|@''REPLACE_GETENTROPY''@|$(REPLACE_GETENTROPY)|g' \ -e 's|@''REPLACE_GETLOGIN_R''@|$(REPLACE_GETLOGIN_R)|g' \ -e 's|@''REPLACE_GETGROUPS''@|$(REPLACE_GETGROUPS)|g' \ -e 's|@''REPLACE_GETPAGESIZE''@|$(REPLACE_GETPAGESIZE)|g' \ -- 2.34.1