OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [newlib/] [newlib/] [libc/] [stdlib/] [rand.c] - Diff between revs 39 and 56

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 39 Rev 56
Line 62... Line 62...
on two different systems.
on two different systems.
 
 
<<rand>> requires no supporting OS subroutines.
<<rand>> requires no supporting OS subroutines.
*/
*/
 
 
#include <stdlib.h>
#ifndef _REENT_ONLY
 
 
static unsigned int next = 1;
#include <stdlib.h>
 
#include <reent.h>
 
 
void
void
_DEFUN (srand, (seed), unsigned int seed)
_DEFUN (srand, (seed), unsigned int seed)
{
{
        next = seed;
        _REENT->_new._reent._rand_next = seed;
}
}
 
 
int
int
_DEFUN_VOID (rand)
_DEFUN_VOID (rand)
{
{
        return ((next = next * 1103515245 + 12345) & RAND_MAX);
        return ((_REENT->_new._reent._rand_next =
 
                 _REENT->_new._reent._rand_next * 1103515245 + 12345 )
 
                & RAND_MAX );
}
}
 
 
 No newline at end of file
 No newline at end of file
 
#endif /* _REENT_ONLY */
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.