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 38888bf12d3e0cc4737aa2577a74c001fa4c1c55..d02876da13a3dd3a4396bd37a63781d80a6e4ddb 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 e8eef3668157d2e006b645367f4a8ba17dade2cd..6100fb1c1f503f2c081aa92bdcfb172f19cab76c 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 692fd52ae5cc1d2a7692b7401c4cb2fab6bb5c6f..f29476504377dca032c30be501a37ae0cd40bb13 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 efd2609d3efbd25bdd8b75673d6c3a9526186c06..4da4b777de4182e6c63e8a7e852b2907491a0d61 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.  */