rand()

Lorenzo Beretta <[email protected]> Sat, 01 Jun 2013 16:19:39 +0200
Newsgroups gmane.linux.lib.dietlibc
Message-ID <[email protected]>
Hello,

there's a couple(*) of problems with rand()/rand_r():


1. srand(0) is ok, while
	seed = 0;
	rand_r(&seed);
    always returns 0 -- ie the srand(0) fix doesn't fix rand_r()

2. I've never used an embedded system, so this may be just me being 
paranoid, but anyway: does the diet libc support embedded systems where 
integers are 16 bits wide? That would screw up rand_r(unsigned *).
Once again: I have absolutely no idea if the dietlibc is meant to run on 
a 16 bit system; looking at stddef.h, limits.h, inttypes.h I couldn't 
find any explicit mention of it, and it seems you assume that __WORDSIZE 
is either 64 or 32 - is it correct?

3. For the standard obsessed: "The implementation shall behave as if no 
library function calls the rand function" -- qsort() does anyway ;)


Sorry if question #2 is a bit too long.



(*) http://xkcd.com/1070/