From: Bruno Haible Date: Sun, 13 Aug 2023 13:39:09 +0000 (+0200) Subject: readutmp, boot-time: Fix compilation error on old Android. X-Git-Tag: v1.0~916 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=9cf0d830f0afc16392ef859fa66a9c5b08d7fcbe;p=gnulib.git readutmp, boot-time: Fix compilation error on old Android. Reported by Po Lu in . * lib/readutmp.c (endutent): New fallback declaration, for Android. (getutent): Remove Ultrix workaround from 2000-04-05. * lib/boot-time.c: Likewise. * m4/readutmp.m4 (gl_PREREQ_READUTMP_H): Test whether endutent is declared, not getutent. * doc/glibc-functions/endutent.texi: Mention the Android bug. --- diff --git a/ChangeLog b/ChangeLog index 252f302a59..9b4f07a2b1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2023-08-13 Bruno Haible + + readutmp, boot-time: Fix compilation error on old Android. + Reported by Po Lu in + . + * lib/readutmp.c (endutent): New fallback declaration, for Android. + (getutent): Remove Ultrix workaround from 2000-04-05. + * lib/boot-time.c: Likewise. + * m4/readutmp.m4 (gl_PREREQ_READUTMP_H): Test whether endutent is + declared, not getutent. + * doc/glibc-functions/endutent.texi: Mention the Android bug. + 2023-08-12 Paul Eggert boot-time,readutmp: do not depend on c-strtod diff --git a/doc/glibc-functions/endutent.texi b/doc/glibc-functions/endutent.texi index 5e12e23c44..b4f3dd397a 100644 --- a/doc/glibc-functions/endutent.texi +++ b/doc/glibc-functions/endutent.texi @@ -28,4 +28,7 @@ Portability problems not fixed by Gnulib: @item This function is missing on some platforms: macOS 11.1, FreeBSD 13.0, OpenBSD 6.7, Minix 3.1.8, mingw, MSVC 14. +@item +This function is not declared on some platforms: +Android before ca.@: 2015. @end itemize diff --git a/lib/boot-time.c b/lib/boot-time.c index d813bfa582..c359954f19 100644 --- a/lib/boot-time.c +++ b/lib/boot-time.c @@ -65,8 +65,10 @@ # define UT_USER(UT) ((UT)->ut_user) #endif -#if !HAVE_UTMPX_H && HAVE_UTMP_H && defined UTMP_NAME_FUNCTION && !HAVE_DECL_GETUTENT -struct utmp *getutent (void); +#if !HAVE_UTMPX_H && HAVE_UTMP_H && defined UTMP_NAME_FUNCTION +# if !HAVE_DECL_ENDUTENT /* Android */ +void endutent (void); +# endif #endif #if defined __linux__ || HAVE_UTMPX_H || HAVE_UTMP_H || defined __CYGWIN__ || defined _WIN32 diff --git a/lib/readutmp.c b/lib/readutmp.c index ef9f0aff43..0b7732b165 100644 --- a/lib/readutmp.c +++ b/lib/readutmp.c @@ -314,9 +314,11 @@ have_boot_time (struct utmp_alloc a) return false; } -# if !HAVE_UTMPX_H && HAVE_UTMP_H && defined UTMP_NAME_FUNCTION && !HAVE_DECL_GETUTENT -struct utmp *getutent (void); +#if !HAVE_UTMPX_H && HAVE_UTMP_H && defined UTMP_NAME_FUNCTION +# if !HAVE_DECL_ENDUTENT /* Android */ +void endutent (void); # endif +#endif static int read_utmp_from_file (char const *file, idx_t *n_entries, STRUCT_UTMP **utmp_buf, diff --git a/m4/readutmp.m4 b/m4/readutmp.m4 index fff8d4eb7b..9dffe981b8 100644 --- a/m4/readutmp.m4 +++ b/m4/readutmp.m4 @@ -1,4 +1,4 @@ -# readutmp.m4 serial 28 +# readutmp.m4 serial 29 dnl Copyright (C) 2002-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, @@ -55,7 +55,7 @@ AC_DEFUN_ONCE([gl_PREREQ_READUTMP_H], if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then dnl Prerequisites of lib/readutmp.h and lib/readutmp.c. AC_CHECK_FUNCS_ONCE([utmpname utmpxname]) - AC_CHECK_DECLS([getutent],,,[[ + AC_CHECK_DECLS([endutent],,,[[ /* is a prerequisite of on FreeBSD 8.0, OpenBSD 4.6. */ #include #ifdef HAVE_UTMP_H