mirror of https://github.com/aria2/aria2
Fixed segmentation fault in open solaris in unit test.
This is due to the fact that the maximum value of random() in open solaris is not RAND_MAX, but (2**31)-1.pull/14/head
parent
4d8c17d104
commit
ae393329f7
|
@ -98,14 +98,15 @@ long int SimpleRandomizer::getMaxRandomNumber()
|
||||||
#ifdef __MINGW32__
|
#ifdef __MINGW32__
|
||||||
return INT32_MAX;
|
return INT32_MAX;
|
||||||
#else // !__MINGW32__
|
#else // !__MINGW32__
|
||||||
|
// TODO Warning: The maximum value of random() in some sytems (e.g.,
|
||||||
|
// Solaris and openbsd) is (2**31)-1.
|
||||||
return RAND_MAX;
|
return RAND_MAX;
|
||||||
#endif // !__MINGW32__
|
#endif // !__MINGW32__
|
||||||
}
|
}
|
||||||
|
|
||||||
long int SimpleRandomizer::getRandomNumber(long int to)
|
long int SimpleRandomizer::getRandomNumber(long int to)
|
||||||
{
|
{
|
||||||
|
return getRandomNumber() % to;
|
||||||
return(long int)(((double)to)*getRandomNumber()/(getMaxRandomNumber()+1.0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long int SimpleRandomizer::operator()(long int to)
|
long int SimpleRandomizer::operator()(long int to)
|
||||||
|
|
Loading…
Reference in New Issue