This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
[patch] srand broken when _REENT_SMALL
- From: Paul Brook <paul at codesourcery dot com>
- To: newlib at sourceware dot org
- Date: Tue, 12 Sep 2006 17:52:23 +0100
- Subject: [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