1
0
Fork 0
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:
Jonas 'Sortie' Termansen 2013-03-19 13:48:59 +01:00
parent 6d86af8d60
commit 1a3aa45c2c
2 changed files with 12 additions and 1 deletions

View file

@ -88,6 +88,7 @@ void qsort(void*, size_t, size_t, int (*)(const void*, const void*));
int rand(void); int rand(void);
void* realloc(void*, size_t); void* realloc(void*, size_t);
int setenv(const char*, const char*, int); int setenv(const char*, const char*, int);
void srand(unsigned);
long strtol(const char* restrict, char** restrict, int); long strtol(const char* restrict, char** restrict, int);
unsigned long strtoul(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); 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]); unsigned short *seed48(unsigned short [3]);
void setkey(const char*); void setkey(const char*);
char* setstate(char*); char* setstate(char*);
void srand(unsigned);
void srand48(long); void srand48(long);
void srandom(unsigned); void srandom(unsigned);
double strtod(const char* restrict, char** restrict); double strtod(const char* restrict, char** restrict);

View file

@ -41,6 +41,12 @@ extern "C" int rand()
return RandomUnsignedInt() % 32768; return RandomUnsignedInt() % 32768;
} }
extern "C" void srand(unsigned int seed)
{
m_w = seed >> 16 & 0xFFFF;
m_z = seed >> 0 & 0xFFFF;
}
#else #else
static unsigned random_seed = 1337; static unsigned random_seed = 1337;
@ -51,4 +57,9 @@ extern "C" int rand()
return random_seed >> 16; return random_seed >> 16;
} }
extern "C" void srand(unsigned int seed)
{
random_seed = seed;
}
#endif #endif