stdio: Work around compilation error due to renameat() on Solaris 10.
authorBruno Haible <bruno@clisp.org>
Wed, 27 Oct 2010 00:53:42 +0000 (02:53 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 27 Oct 2010 00:53:42 +0000 (02:53 +0200)
* lib/stdio.in.h: Include <unistd.h> on Solaris.
* lib/renameat.c: Don't include <unistd.h> here.
* doc/posix-functions/renameat.texi: Mention the Solaris problem.
Reported by Paul Eggert and Eric Blake.

ChangeLog
doc/posix-functions/renameat.texi
lib/renameat.c
lib/stdio.in.h

index 38888bf..d02876d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-10-26  Bruno Haible  <bruno@clisp.org>
+
+       stdio: Work around compilation error due to renameat() on Solaris 10.
+       * lib/stdio.in.h: Include <unistd.h> on Solaris.
+       * lib/renameat.c: Don't include <unistd.h> here.
+       * doc/posix-functions/renameat.texi: Mention the Solaris problem.
+       Reported by Paul Eggert and Eric Blake.
+
 2010-10-26  Paul Eggert  <eggert@cs.ucla.edu>
 
        renameat: port to Solaris 10, which declares renameat in unistd.h
index e8eef36..6100fb1 100644 (file)
@@ -17,6 +17,10 @@ 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:
+Solaris 10.
+@item
 This function is missing on some platforms:
 glibc 2.3.6, MacOS X 10.3, FreeBSD 6.0, NetBSD 3.0, OpenBSD 3.8, AIX
 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 8, Cygwin 1.5.x, mingw,
index 692fd52..f294765 100644 (file)
 
 #include <config.h>
 
-/* Solaris 10, which predates POSIX-2008, declares its renameat in
-   unistd.h.  Include unistd.h before including stdio.h, so that
-   gnulib's stdio.h doesn't #define renameat to rpl_renameat before
-   Solaris 10's unistd.h declares the system renameat.  */
-#include <unistd.h>
-
 #include <stdio.h>
 
 #if HAVE_RENAMEAT
index efd2609..4da4b77 100644 (file)
 # endif
 #endif
 
+/* Solaris 10 declares renameat in <unistd.h>, not in <stdio.h>.  */
+/* But in any case avoid namespace pollution on glibc systems.  */
+#if (@GNULIB_RENAMEAT@ || defined GNULIB_POSIXCHECK) && defined __sun \
+    && ! defined __GLIBC__
+# include <unistd.h>
+#endif
+
 
 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */