changeset 40130:1408a8db4054

renameat: Fix compilation error on Android 4.3. * lib/stdio.in.h: Include <sys/stat.h> when module 'renameat' is in use. * doc/posix-functions/renameat.texi: Mention the issue.
author Bruno Haible <bruno@clisp.org>
date Fri, 25 Jan 2019 00:03:12 +0100
parents fc1768dc2fc5
children 9c7eed94d112
files ChangeLog doc/posix-functions/renameat.texi lib/stdio.in.h
diffstat 3 files changed, 28 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Jan 24 23:51:11 2019 +0100
+++ b/ChangeLog	Fri Jan 25 00:03:12 2019 +0100
@@ -1,3 +1,9 @@
+2019-01-24  Bruno Haible  <bruno@clisp.org>
+
+	renameat: Fix compilation error on Android 4.3.
+	* lib/stdio.in.h: Include <sys/stat.h> when module 'renameat' is in use.
+	* doc/posix-functions/renameat.texi: Mention the issue.
+
 2019-01-24  Bruno Haible  <bruno@clisp.org>
 
 	fchownat: Fix compilation error on Android 4.3.
--- a/doc/posix-functions/renameat.texi	Thu Jan 24 23:51:11 2019 +0100
+++ b/doc/posix-functions/renameat.texi	Fri Jan 25 00:03:12 2019 +0100
@@ -9,6 +9,21 @@
 Portability problems fixed by Gnulib:
 @itemize
 @item
+This function is missing on some platforms:
+glibc 2.3.6, Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8,
+AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 8, Cygwin 1.5.x, mingw, MSVC 14,
+Interix 3.5, BeOS.
+But the replacement function is not safe to be used in libraries and is not
+multithread-safe.
+@item
+This function is declared in @code{<unistd.h>}, not in @code{<stdio.h>},
+on some platforms:
+NetBSD 7.0, Solaris 11.4.
+@item
+This function is declared in @code{<sys/stat.h>}, not in @code{<stdio.h>},
+on some platforms:
+Android 4.3.
+@item
 This function does not reject trailing slashes on non-directories on
 some platforms, as in @code{renameat(fd,"file",fd,"new/")}:
 Solaris 11.4.
@@ -16,16 +31,6 @@
 This function ignores trailing slashes on symlinks on some platforms,
 such that @code{renameat(fd,"link/",fd,"new")} corrupts @file{link}:
 Solaris 9.
-@item
-This function is declared in @code{<unistd.h>} instead of @code{<stdio.h>}
-on some platforms:
-NetBSD 7.0, Solaris 11.4.
-@item
-This function is missing on some platforms:
-glibc 2.3.6, Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8,
-AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 8, Cygwin 1.5.x, mingw, MSVC 14,
-Interix 3.5, BeOS.
-But the replacement function is not safe to be used in libraries and is not multithread-safe.
 @end itemize
 
 Portability problems not fixed by Gnulib:
--- a/lib/stdio.in.h	Thu Jan 24 23:51:11 2019 +0100
+++ b/lib/stdio.in.h	Fri Jan 25 00:03:12 2019 +0100
@@ -118,6 +118,13 @@
 # include <unistd.h>
 #endif
 
+/* Android 4.3 declares renameat in <sys/stat.h>, not in <stdio.h>.  */
+/* But in any case avoid namespace pollution on glibc systems.  */
+#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
+    && ! defined __GLIBC__
+# include <sys/stat.h>
+#endif
+
 /* MSVC declares 'perror' in <stdlib.h>, not in <stdio.h>.  We must include
    it before we  #define perror rpl_perror.  */
 /* But in any case avoid namespace pollution on glibc systems.  */