mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Add srand(3).
This commit is contained in:
parent
6d86af8d60
commit
1a3aa45c2c
2 changed files with 12 additions and 1 deletions
|
@ -88,6 +88,7 @@ void qsort(void*, size_t, size_t, int (*)(const void*, const void*));
|
|||
int rand(void);
|
||||
void* realloc(void*, size_t);
|
||||
int setenv(const char*, const char*, int);
|
||||
void srand(unsigned);
|
||||
long strtol(const char* restrict, char** restrict, int);
|
||||
unsigned long strtoul(const char* restrict, char** restrict, int);
|
||||
unsigned long long strtoull(const char* restrict, char** restrict, int);
|
||||
|
@ -140,7 +141,6 @@ char* realpath(const char* restrict, char* restrict);
|
|||
unsigned short *seed48(unsigned short [3]);
|
||||
void setkey(const char*);
|
||||
char* setstate(char*);
|
||||
void srand(unsigned);
|
||||
void srand48(long);
|
||||
void srandom(unsigned);
|
||||
double strtod(const char* restrict, char** restrict);
|
||||
|
|
|
@ -41,6 +41,12 @@ extern "C" int rand()
|
|||
return RandomUnsignedInt() % 32768;
|
||||
}
|
||||
|
||||
extern "C" void srand(unsigned int seed)
|
||||
{
|
||||
m_w = seed >> 16 & 0xFFFF;
|
||||
m_z = seed >> 0 & 0xFFFF;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static unsigned random_seed = 1337;
|
||||
|
@ -51,4 +57,9 @@ extern "C" int rand()
|
|||
return random_seed >> 16;
|
||||
}
|
||||
|
||||
extern "C" void srand(unsigned int seed)
|
||||
{
|
||||
random_seed = seed;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue