mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-03-07 18:27:40 +08:00
Fix get_random_seed on Native Client
Newlib in Native Client SDK does not provide ::random function. Implement get_random_seed for NaCl using ::rand, similarly to Windows version.
This commit is contained in:
parent
2fb24384c9
commit
8b5ab0e4dd
@ -45,6 +45,14 @@ EIGEN_DEVICE_FUNC uint64_t get_random_seed() {
|
|||||||
uint64_t rnd = ::random() ^ mach_absolute_time();
|
uint64_t rnd = ::random() ^ mach_absolute_time();
|
||||||
return rnd;
|
return rnd;
|
||||||
|
|
||||||
|
#elif defined __native_client__
|
||||||
|
// Same approach as for win32, except using clock_gettime
|
||||||
|
timespec ts;
|
||||||
|
clock_gettime(CLOCK_REALTIME, &ts);
|
||||||
|
int rnd1 = ::rand();
|
||||||
|
int rnd2 = ::rand();
|
||||||
|
uint64_t rnd = (rnd1 | rnd2 << 16) ^ ts.tv_nsec;
|
||||||
|
return rnd;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// Augment the current time with pseudo random number generation
|
// Augment the current time with pseudo random number generation
|
||||||
|
Loading…
Reference in New Issue
Block a user