This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: unlinkat, symlinkat in wrong headers
- From: Eric Blake <ebb9 at byu dot net>
- To: newlib at sources dot redhat dot com
- Date: Tue, 08 Dec 2009 06:50:25 -0700
- Subject: Re: unlinkat, symlinkat in wrong headers
- References: <loom.20091208T005847-339@post.gmane.org> <20091208104235.GB12303@calimero.vinschen.de>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Corinna Vinschen on 12/8/2009 3:42 AM:
> On Dec 8 00:05, Eric Blake wrote:
>> Per POSIX, unlinkat should be declared in <unistd.h>; but cygwin only declares
>> it in <fcntl.h>:
>>
>> $ echo '#include <unistd.h>' | gcc -E - | grep unlink
>> int __attribute__((__cdecl__)) unlink (const char *__path );
>> $ echo '#include <fcntl.h>' | gcc -E - | grep unlink
>> extern int unlinkat (int, const char *, int);
>>
>> Likewise, symlinkat should be in <unistd.h>; but cygwin only declares it in
>> <stdio.h>:
>
> That's how it's defined in the Linux man pages. Apparently I took that
> for granted since the declarations are actually in unistd.h, contrary to
> the man pages. Dunno if we should really fix that for 1.7.1, but if you
> can come up with a patch for newlib ASAP...
I took the liberty of applying this, since it is cygwin-specific. I also
fired off an email to the Linux man page maintainer.
2009-12-08 Eric Blake <ebb9@byu.net>
Fix some *at declarations.
* libc/include/stdio.h (symlinkat): Move this...
* libc/include/sys/_default_fcntl.h (unlinkat): ...and this...
* libc/include/sys/unistd.h (symlinkat, unlinkat): ...here, to
match POSIX.
- --
Don't work too hard, make some time for fun as well!
Eric Blake ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkseWaEACgkQ84KuGfSFAYBDpQCffS/VmwdXh/1FGJ5W846iac6H
zSYAn0VHpIAnZZp6brFMv0YTmnsCMy3O
=GUox
-----END PGP SIGNATURE-----
diff --git a/newlib/libc/include/stdio.h b/newlib/libc/include/stdio.h
index b9c8745..8389449 100644
--- a/newlib/libc/include/stdio.h
+++ b/newlib/libc/include/stdio.h
@@ -348,7 +348,6 @@ FILE * _EXFUN(fmemopen, (void *, size_t, const char *));
FILE * _EXFUN(open_memstream, (char **, size_t *));
#if defined (__CYGWIN__)
int _EXFUN(renameat, (int, const char *, int, const char *));
-int _EXFUN(symlinkat, (const char *, int, const char *));
#endif
int _EXFUN(vdprintf, (int, const char *, __VALIST)
_ATTRIBUTE ((__format__ (__printf__, 2, 0))));
diff --git a/newlib/libc/include/sys/_default_fcntl.h b/newlib/libc/include/sys/_default_fcntl.h
index ccef613..eb30e5c 100644
--- a/newlib/libc/include/sys/_default_fcntl.h
+++ b/newlib/libc/include/sys/_default_fcntl.h
@@ -181,7 +181,6 @@ extern int fcntl _PARAMS ((int, int, ...));
#include <sys/time.h>
extern int futimesat _PARAMS ((int, const char *, const struct timeval *));
extern int openat _PARAMS ((int, const char *, int, ...));
-extern int unlinkat _PARAMS ((int, const char *, int));
#endif
/* Provide _<systemcall> prototypes for functions provided by some versions
diff --git a/newlib/libc/include/sys/unistd.h b/newlib/libc/include/sys/unistd.h
index cc507a9..5abe5f7 100644
--- a/newlib/libc/include/sys/unistd.h
+++ b/newlib/libc/include/sys/unistd.h
@@ -242,6 +242,10 @@ ssize_t _EXFUN(readlink, (const char *__path, char *__buf, size_t __buflen));
ssize_t _EXFUN(readlinkat, (int __dirfd1, const char *__path, char *__buf, size_t __buflen));
#endif
int _EXFUN(symlink, (const char *__name1, const char *__name2));
+#if defined(__CYGWIN__)
+int _EXFUN(symlinkat, (const char *, int, const char *));
+int _EXFUN(unlinkat, (int, const char *, int));
+#endif
#define F_OK 0
#define R_OK 4