[patch] srand broken when _REENT_SMALL

Jeff Johnston jjohnstn@redhat.com
Tue Sep 12 20:22:00 GMT 2006


Paul Brook wrote:
> The srand() function segfaults on _REENT_SMALL targets. The patchbelow fixes 
> it by adding a call to _REENT_CHECK_RAND48.
> 
> Ok?
> 

Better than ok, it's great :)  Patch checked in.  Thanks.

-- Jeff J.

> 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



More information about the Newlib mailing list