This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Fix stdlib.h rand_r namespace (bug 20074)

stdlib.h declares rand_r if __USE_POSIX; i.e., POSIX.1:1990.  But
rand_r was added along with threads, so the condition should be
__USE_POSIX199506.  This patch corrects the condition.

Tested for x86_64 and x86 (testsuite, and that installed stripped
shared libraries are unchanged by the patch).

[The XFAIL removal depends on
<> (pending
review) to eliminate the other cause of failure for the test in

2016-05-10  Joseph Myers  <>

	[BZ #20074]
	* stdlib/stdlib.h (rand_r): Declare if [__USE_POSIX199506], not if
	* conform/Makefile (test-xfail-XPG4/stdlib.h/conform): Remove

diff --git a/conform/Makefile b/conform/Makefile
index 8d381fb..47f2eb4 100644
--- a/conform/Makefile
+++ b/conform/Makefile
@@ -180,7 +180,6 @@ test-xfail-XPG4/fcntl.h/conform = yes
 test-xfail-XPG4/netdb.h/conform = yes
 test-xfail-XPG4/netinet/in.h/conform = yes
 test-xfail-XPG4/signal.h/conform = yes
-test-xfail-XPG4/stdlib.h/conform = yes
 test-xfail-XPG4/sys/stat.h/conform = yes
 test-xfail-XPG4/sys/wait.h/conform = yes
 test-xfail-XPG4/termios.h/conform = yes
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h
index 5c0c982..ad9c6c8 100644
--- a/stdlib/stdlib.h
+++ b/stdlib/stdlib.h
@@ -337,7 +337,7 @@ extern int rand (void) __THROW;
 extern void srand (unsigned int __seed) __THROW;
-#ifdef __USE_POSIX
+#ifdef __USE_POSIX199506
 /* Reentrant interface according to POSIX.1.  */
 extern int rand_r (unsigned int *__seed) __THROW;

Joseph S. Myers

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]