From: Bruno Haible Date: Thu, 5 Jan 2023 15:36:52 +0000 (+0100) Subject: Recognize functions added in future versions of Android. X-Git-Tag: v1.0~1902 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=cf2937d427fd4fc5841b12f2da7ca38297738bf6;p=gnulib.git Recognize functions added in future versions of Android. * m4/gnulib-common.m4 (gl_CHECK_FUNCS_ANDROID): New macro. * m4/aligned_alloc.m4 (gl_FUNC_ALIGNED_ALLOC): Use gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE. * m4/freading.m4 (gl_FUNC_FREADING): Likewise. * m4/fseterr.m4 (gl_FUNC_FSETERR): Likewise. * m4/fwriting.m4 (gl_FUNC_FWRITING): Likewise. * m4/getentropy.m4 (gl_FUNC_GETENTROPY): Likewise. * m4/getlogin_r.m4 (gl_CHECK_FUNCS_ANDROID): Likewise. * m4/getrandom.m4 (gl_FUNC_GETRANDOM): Likewise. * m4/glob.m4 (gl_PREREQ_GLOB): Likewise. * m4/spawn_h.m4 (gl_HAVE_POSIX_SPAWN): Likewise. * doc/glibc-functions/getentropy.texi: Mark function as existing in Android 9.0. * doc/glibc-functions/getrandom.texi: Likewise. * doc/posix-functions/pthread_attr_getinheritsched.texi: Likewise. * doc/posix-functions/pthread_attr_setinheritsched.texi: Likewise. --- diff --git a/ChangeLog b/ChangeLog index b0a6cf4d5e..7327d57a4c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2023-01-05 Bruno Haible + + Recognize functions added in future versions of Android. + * m4/gnulib-common.m4 (gl_CHECK_FUNCS_ANDROID): New macro. + * m4/aligned_alloc.m4 (gl_FUNC_ALIGNED_ALLOC): Use + gl_CHECK_FUNCS_ANDROID instead of AC_CHECK_FUNCS_ONCE. + * m4/freading.m4 (gl_FUNC_FREADING): Likewise. + * m4/fseterr.m4 (gl_FUNC_FSETERR): Likewise. + * m4/fwriting.m4 (gl_FUNC_FWRITING): Likewise. + * m4/getentropy.m4 (gl_FUNC_GETENTROPY): Likewise. + * m4/getlogin_r.m4 (gl_CHECK_FUNCS_ANDROID): Likewise. + * m4/getrandom.m4 (gl_FUNC_GETRANDOM): Likewise. + * m4/glob.m4 (gl_PREREQ_GLOB): Likewise. + * m4/spawn_h.m4 (gl_HAVE_POSIX_SPAWN): Likewise. + * doc/glibc-functions/getentropy.texi: Mark function as existing in + Android 9.0. + * doc/glibc-functions/getrandom.texi: Likewise. + * doc/posix-functions/pthread_attr_getinheritsched.texi: Likewise. + * doc/posix-functions/pthread_attr_setinheritsched.texi: Likewise. + 2023-01-05 Bruno Haible copy-file, supersede: Fix link-time requirements. diff --git a/doc/glibc-functions/getentropy.texi b/doc/glibc-functions/getentropy.texi index 4cee078402..4b2551c465 100644 --- a/doc/glibc-functions/getentropy.texi +++ b/doc/glibc-functions/getentropy.texi @@ -21,7 +21,7 @@ Portability problems fixed by Gnulib: @itemize @item This function is missing on some platforms: -glibc 2.24, Mac OS X 10.11, FreeBSD 11.0, NetBSD 9.0, OpenBSD 5.5, Minix 3.3, AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.0, Cygwin 1.7.x, mingw, MSVC 14, Android 9.0. +glibc 2.24, Mac OS X 10.11, FreeBSD 11.0, NetBSD 9.0, OpenBSD 5.5, Minix 3.3, AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.0, Cygwin 1.7.x, mingw, MSVC 14, Android 8.1. @item This function is declared in @code{}, not in @code{}, on some platforms: diff --git a/doc/glibc-functions/getrandom.texi b/doc/glibc-functions/getrandom.texi index db817363cd..66e8588b32 100644 --- a/doc/glibc-functions/getrandom.texi +++ b/doc/glibc-functions/getrandom.texi @@ -21,7 +21,7 @@ Portability problems fixed by Gnulib: @itemize @item This function is missing on some platforms: -glibc 2.24, macOS 11.1, FreeBSD 11.0, NetBSD 9.0, OpenBSD 6.7, Minix 3.3, AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.0, Cygwin 1.7.x, mingw, MSVC 14, Android 9.0. +glibc 2.24, macOS 11.1, FreeBSD 11.0, NetBSD 9.0, OpenBSD 6.7, Minix 3.3, AIX 7.1, HP-UX 11.31, IRIX 6.5, Solaris 11.0, Cygwin 1.7.x, mingw, MSVC 14, Android 8.1. @item This function has a different return type on some platforms: Solaris 11.4. diff --git a/doc/posix-functions/pthread_attr_getinheritsched.texi b/doc/posix-functions/pthread_attr_getinheritsched.texi index 12a5f955db..2d135a545a 100644 --- a/doc/posix-functions/pthread_attr_getinheritsched.texi +++ b/doc/posix-functions/pthread_attr_getinheritsched.texi @@ -14,5 +14,5 @@ Portability problems not fixed by Gnulib: @itemize @item This function is missing on some platforms: -Minix 3.1.8, mingw, MSVC 14, Android 9.0. +Minix 3.1.8, mingw, MSVC 14, Android 8.1. @end itemize diff --git a/doc/posix-functions/pthread_attr_setinheritsched.texi b/doc/posix-functions/pthread_attr_setinheritsched.texi index 652e41e616..6fad04c670 100644 --- a/doc/posix-functions/pthread_attr_setinheritsched.texi +++ b/doc/posix-functions/pthread_attr_setinheritsched.texi @@ -14,5 +14,5 @@ Portability problems not fixed by Gnulib: @itemize @item This function is missing on some platforms: -Minix 3.1.8, mingw, MSVC 14, Android 9.0. +Minix 3.1.8, mingw, MSVC 14, Android 8.1. @end itemize diff --git a/m4/aligned_alloc.m4 b/m4/aligned_alloc.m4 index 31681ac52a..d088701dbc 100644 --- a/m4/aligned_alloc.m4 +++ b/m4/aligned_alloc.m4 @@ -1,4 +1,4 @@ -# aligned_alloc.m4 serial 3 +# aligned_alloc.m4 serial 4 dnl Copyright (C) 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, @@ -12,7 +12,7 @@ AC_DEFUN([gl_FUNC_ALIGNED_ALLOC], dnl Persuade glibc and OpenBSD to declare aligned_alloc(). AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) - AC_CHECK_FUNCS_ONCE([aligned_alloc]) + gl_CHECK_FUNCS_ANDROID([aligned_alloc], [[#include ]]) if test $ac_cv_func_aligned_alloc = yes; then dnl On macOS 11.1 and AIX 7.2, aligned_alloc returns NULL when the alignment dnl argument is smaller than sizeof (void *). diff --git a/m4/freading.m4 b/m4/freading.m4 index 35333369df..f0f4893335 100644 --- a/m4/freading.m4 +++ b/m4/freading.m4 @@ -1,4 +1,4 @@ -# freading.m4 serial 2 +# freading.m4 serial 3 dnl Copyright (C) 2007, 2009-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, @@ -7,5 +7,8 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_FREADING], [ AC_CHECK_HEADERS_ONCE([stdio_ext.h]) - AC_CHECK_FUNCS_ONCE([__freading]) + gl_CHECK_FUNCS_ANDROID([__freading], + [[#include + #include + ]]) ]) diff --git a/m4/fseterr.m4 b/m4/fseterr.m4 index ecdc81e769..61ac03d49d 100644 --- a/m4/fseterr.m4 +++ b/m4/fseterr.m4 @@ -1,4 +1,4 @@ -# fseterr.m4 serial 1 +# fseterr.m4 serial 2 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, @@ -6,5 +6,8 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_FSETERR], [ - AC_CHECK_FUNCS_ONCE([__fseterr]) + gl_CHECK_FUNCS_ANDROID([__fseterr], + [[#include + #include + ]]) ]) diff --git a/m4/fwriting.m4 b/m4/fwriting.m4 index eee7d50678..8631fdf323 100644 --- a/m4/fwriting.m4 +++ b/m4/fwriting.m4 @@ -1,4 +1,4 @@ -# fwriting.m4 serial 3 +# fwriting.m4 serial 4 dnl Copyright (C) 2007, 2009-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, @@ -7,5 +7,8 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_FWRITING], [ AC_CHECK_HEADERS_ONCE([stdio_ext.h]) - AC_CHECK_FUNCS_ONCE([__fwriting]) + gl_CHECK_FUNCS_ANDROID([__fwriting], + [[#include + #include + ]]) ]) diff --git a/m4/getentropy.m4 b/m4/getentropy.m4 index 0c6cda88f5..352b04ee4f 100644 --- a/m4/getentropy.m4 +++ b/m4/getentropy.m4 @@ -1,4 +1,4 @@ -# getentropy.m4 +# getentropy.m4 serial 2 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, @@ -9,7 +9,14 @@ dnl Written by Paul Eggert. AC_DEFUN([gl_FUNC_GETENTROPY], [ AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) - AC_CHECK_FUNCS_ONCE([getentropy]) + gl_CHECK_FUNCS_ANDROID([getentropy], + [[#include + /* Additional includes are needed before on uClibc + and Mac OS X. */ + #include + #include + #include + ]]) if test $ac_cv_func_getentropy = no; then HAVE_GETENTROPY=0 fi diff --git a/m4/getlogin_r.m4 b/m4/getlogin_r.m4 index db9e37af45..cbfe255ee1 100644 --- a/m4/getlogin_r.m4 +++ b/m4/getlogin_r.m4 @@ -1,4 +1,4 @@ -#serial 13 +#serial 14 # Copyright (C) 2005-2007, 2009-2023 Free Software Foundation, Inc. # @@ -25,7 +25,7 @@ AC_DEFUN([gl_FUNC_GETLOGIN_R], HAVE_DECL_GETLOGIN_R=0 fi - AC_CHECK_FUNCS_ONCE([getlogin_r]) + gl_CHECK_FUNCS_ANDROID([getlogin_r], [[#include ]]) if test $ac_cv_func_getlogin_r = no; then HAVE_GETLOGIN_R=0 else diff --git a/m4/getrandom.m4 b/m4/getrandom.m4 index 95111567d7..f2010c0213 100644 --- a/m4/getrandom.m4 +++ b/m4/getrandom.m4 @@ -1,4 +1,4 @@ -# getrandom.m4 serial 8 +# getrandom.m4 serial 9 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, @@ -9,7 +9,13 @@ dnl Written by Paul Eggert. AC_DEFUN([gl_FUNC_GETRANDOM], [ AC_REQUIRE([gl_SYS_RANDOM_H_DEFAULTS]) - AC_CHECK_FUNCS_ONCE([getrandom]) + gl_CHECK_FUNCS_ANDROID([getrandom], + [[/* Additional includes are needed before on uClibc + and Mac OS X. */ + #include + #include + #include + ]]) if test "$ac_cv_func_getrandom" != yes; then HAVE_GETRANDOM=0 else diff --git a/m4/glob.m4 b/m4/glob.m4 index 4254b6e572..354581b3be 100644 --- a/m4/glob.m4 +++ b/m4/glob.m4 @@ -1,4 +1,4 @@ -# glob.m4 serial 26 +# glob.m4 serial 27 dnl Copyright (C) 2005-2007, 2009-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, @@ -125,5 +125,6 @@ AC_DEFUN([gl_PREREQ_GLOB], [ AC_REQUIRE([gl_CHECK_TYPE_STRUCT_DIRENT_D_TYPE]) AC_CHECK_HEADERS_ONCE([unistd.h]) - AC_CHECK_FUNCS_ONCE([getlogin_r getpwnam_r]) + gl_CHECK_FUNCS_ANDROID([getlogin_r], [[#include ]]) + AC_CHECK_FUNCS_ONCE([getpwnam_r]) ]) diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index fb7fed41f8..26239caa2b 100644 --- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -1,4 +1,4 @@ -# gnulib-common.m4 serial 75 +# gnulib-common.m4 serial 76 dnl Copyright (C) 2007-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, @@ -1023,6 +1023,30 @@ AC_DEFUN([gl_CONDITIONAL_HEADER], m4_popdef([gl_header_name]) ]) +dnl gl_CHECK_FUNCS_ANDROID([func], [[#include ]]) +dnl is like AC_CHECK_FUNCS([func]), taking into account a portability problem +dnl on Android. +dnl Namely, if func was added to Android API level, say, 28, then the libc.so +dnl has the symbol func always, whereas the header file declares func +dnl conditionally: +dnl #if __ANDROID_API__ >= 28 +dnl ... func (...) __INTRODUCED_IN(28); +dnl #endif +dnl Thus, when compiling with "clang -target armv7a-unknown-linux-android28", +dnl the function func is declared and exists in libc. +dnl Whereas when compiling with "clang -target armv7a-unknown-linux-android27", +dnl the function func is not declared but exists in libc. We need to treat this +dnl case like the case where func does not exist. +AC_DEFUN([gl_CHECK_FUNCS_ANDROID], +[ + AC_CHECK_DECL([$1], , , [$2]) + if test $ac_cv_have_decl_[$1] = yes; then + AC_CHECK_FUNCS([$1]) + else + ac_cv_func_[$1]=no + fi +]) + dnl Expands to some code for use in .c programs that, on native Windows, defines dnl the Microsoft deprecated alias function names to the underscore-prefixed dnl actual function names. With this macro, these function names are available diff --git a/m4/spawn_h.m4 b/m4/spawn_h.m4 index d2c5242326..118490adb7 100644 --- a/m4/spawn_h.m4 +++ b/m4/spawn_h.m4 @@ -1,4 +1,4 @@ -# spawn_h.m4 serial 21 +# spawn_h.m4 serial 22 dnl Copyright (C) 2008-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, @@ -71,7 +71,7 @@ AC_DEFUN([gl_HAVE_POSIX_SPAWN], AC_SEARCH_LIBS([posix_spawn], [rt], [test "$ac_cv_search_posix_spawn" = "none required" || LIB_POSIX_SPAWN=$ac_cv_search_posix_spawn]) - AC_CHECK_FUNCS([posix_spawn]) + gl_CHECK_FUNCS_ANDROID([posix_spawn], [[#include ]]) LIBS=$gl_saved_libs if test $ac_cv_func_posix_spawn != yes; then