public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* Fix __getcwd rewinddir namespace (bug 17584)
@ 2014-11-12  0:14 Joseph Myers
  2014-11-12  0:21 ` Paul Eggert
  0 siblings, 1 reply; 2+ messages in thread
From: Joseph Myers @ 2014-11-12  0:14 UTC (permalink / raw)
  To: libc-alpha

__getcwd is called from dcigettext.o (brought in by various ISO C
functionality), but calls rewinddir, which is not an ISO C function.
This patch makes __getcwd call __rewinddir instead and makes rewinddir
a weak alias for __rewinddir.

Since getcwd.c is shared with gnulib (albeit not merged in either
direction for a long time, and omitted from gnulib's
config/srclist.txt list of shared files) I put in a #ifndef _LIBC
define of __rewinddir to rewinddir, although a future merged version
of getcwd could end up looking significantly different.

Tested for x86_64 (testsuite, and that disassembly of installed shared
libraries is unchanged by this patch).

2014-11-12  Joseph Myers  <joseph@codesourcery.com>

	[BZ #17584]
	* dirent/rewinddir.c (rewinddir): Rename to __rewinddir and define
	as weak alias of __rewinddir.  Don't use libc_hidden_def.
	(__rewinddir): Use libc_hidden_def.
	* sysdeps/mach/hurd/rewinddir.c: Rename to __rewinddir and define
	as weak alias of __rewinddir.  Don't use libc_hidden_def.
	(__rewinddir): Use libc_hidden_def.
	* sysdeps/posix/rewinddir.c: Rename to __rewinddir and define as
	weak alias of __rewinddir.  Don't use libc_hidden_def.
	(__rewinddir): Use libc_hidden_def.
	* include/dirent.h (rewinddir): Don't use libc_hidden_proto.
	(__rewinddir): Use libc_hidden_proto.
	* sysdeps/posix/getcwd.c [!_LIBC] (__rewinddir): Define to
	rewinddir.
	(__getcwd): Use __rewinddir instead of rewinddir.

diff --git a/dirent/rewinddir.c b/dirent/rewinddir.c
index 86d9fbd..ba5b002 100644
--- a/dirent/rewinddir.c
+++ b/dirent/rewinddir.c
@@ -22,13 +22,14 @@
 
 /* Rewind DIRP to the beginning of the directory.  */
 void
-rewinddir (dirp)
+__rewinddir (dirp)
      DIR *dirp;
 {
   __set_errno (ENOSYS);
   /* No way to indicate failure.	*/
 }
-libc_hidden_def (rewinddir)
+libc_hidden_def (__rewinddir)
+weak_alias (__rewinddir, rewinddir)
 
 
 stub_warning (rewinddir)
diff --git a/include/dirent.h b/include/dirent.h
index 096a977..e8e9e42 100644
--- a/include/dirent.h
+++ b/include/dirent.h
@@ -47,8 +47,9 @@ extern DIR *__alloc_dir (int fd, bool close_fd, int flags,
 			 const struct stat64 *statp)
      internal_function;
 extern void __scandir_cancel_handler (void *arg);
+extern __typeof (rewinddir) __rewinddir;
 
-libc_hidden_proto (rewinddir)
+libc_hidden_proto (__rewinddir)
 libc_hidden_proto (scandirat)
 libc_hidden_proto (scandirat64)
 # endif
diff --git a/sysdeps/mach/hurd/rewinddir.c b/sysdeps/mach/hurd/rewinddir.c
index bccd549..284a48b 100644
--- a/sysdeps/mach/hurd/rewinddir.c
+++ b/sysdeps/mach/hurd/rewinddir.c
@@ -22,9 +22,10 @@
 
 /* Rewind DIRP to the beginning of the directory.  */
 void
-rewinddir (dirp)
+__rewinddir (dirp)
      DIR *dirp;
 {
   seekdir (dirp, (off_t) 0L);
 }
-libc_hidden_def (rewinddir)
+libc_hidden_def (__rewinddir)
+weak_alias (__rewinddir, rewinddir)
diff --git a/sysdeps/posix/getcwd.c b/sysdeps/posix/getcwd.c
index 6201916..92cb22e 100644
--- a/sysdeps/posix/getcwd.c
+++ b/sysdeps/posix/getcwd.c
@@ -195,6 +195,10 @@ extern char *alloca ();
 #ifndef __GNU_LIBRARY__
 # define __lstat64	stat64
 #endif
+
+#ifndef _LIBC
+# define __rewinddir	rewinddir
+#endif
 \f
 #ifndef _LIBC
 # define __getcwd getcwd
@@ -390,7 +394,7 @@ __getcwd (buf, size)
 		  if (use_d_ino)
 		    {
 		      use_d_ino = false;
-		      rewinddir (dirstream);
+		      __rewinddir (dirstream);
 		      continue;
 		    }
 
diff --git a/sysdeps/posix/rewinddir.c b/sysdeps/posix/rewinddir.c
index 5a4a715..e9bc78d 100644
--- a/sysdeps/posix/rewinddir.c
+++ b/sysdeps/posix/rewinddir.c
@@ -23,7 +23,7 @@
 
 /* Rewind DIRP to the beginning of the directory.  */
 void
-rewinddir (dirp)
+__rewinddir (dirp)
      DIR *dirp;
 {
 #ifndef NOT_IN_libc
@@ -38,4 +38,5 @@ rewinddir (dirp)
   __libc_lock_unlock (dirp->lock);
 #endif
 }
-libc_hidden_def (rewinddir)
+libc_hidden_def (__rewinddir)
+weak_alias (__rewinddir, rewinddir)

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Fix __getcwd rewinddir namespace (bug 17584)
  2014-11-12  0:14 Fix __getcwd rewinddir namespace (bug 17584) Joseph Myers
@ 2014-11-12  0:21 ` Paul Eggert
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Eggert @ 2014-11-12  0:21 UTC (permalink / raw)
  To: Joseph Myers, libc-alpha

This one also looks good.  I wouldn't worry too much about the gnulib divergence 
here, as the patch doesn't make it much harder to converge later.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-11-12  0:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-12  0:14 Fix __getcwd rewinddir namespace (bug 17584) Joseph Myers
2014-11-12  0:21 ` Paul Eggert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).