This is the mail archive of the newlib@sourceware.org mailing list for the newlib 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]

[patch] srand broken when _REENT_SMALL


The srand() function segfaults on _REENT_SMALL targets. The patchbelow fixes 
it by adding a call to _REENT_CHECK_RAND48.

Ok?

Paul

2006-09-12  Paul Brook  <paul@codesourcery.com>

	newlib/
	* libc/stdlib/rand.c (srand): Add _REENT_CHECK_RAND48.

Index: newlib/libc/stdlib/rand.c
===================================================================
RCS file: /var/cvsroot/src-cvs/src/newlib/libc/stdlib/rand.c,v
retrieving revision 1.5
diff -u -p -r1.5 rand.c
--- newlib/libc/stdlib/rand.c	28 Oct 2005 21:21:07 -0000	1.5
+++ newlib/libc/stdlib/rand.c	12 Sep 2006 16:43:07 -0000
@@ -72,7 +72,8 @@ on two different systems.
 void
 _DEFUN (srand, (seed), unsigned int seed)
 {
-        _REENT_RAND_NEXT(_REENT) = seed;
+  _REENT_CHECK_RAND48(_REENT);
+  _REENT_RAND_NEXT(_REENT) = seed;
 }
 
 int


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