mirror of
https://github.com/ntop/n2n.git
synced 2024-09-20 00:51:10 +02:00
CentOS compilation fixes
This commit is contained in:
parent
9d9695ebdb
commit
62097dee26
|
@ -1,7 +1,7 @@
|
||||||
/* The following code offers an alterate pseudo random number generator
|
/* The following code offers an alterate pseudo random number generator
|
||||||
namely XORSHIFT128+ to use instead of C's rand(). Its performance is
|
namely XORSHIFT128+ to use instead of C's rand(). Its performance is
|
||||||
on par with C's rand().
|
on par with C's rand().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "random_numbers.h"
|
#include "random_numbers.h"
|
||||||
|
@ -29,7 +29,7 @@ static uint64_t splitmix64 (struct splitmix64_state_t *state) {
|
||||||
|
|
||||||
|
|
||||||
int n2n_srand (uint64_t seed) {
|
int n2n_srand (uint64_t seed) {
|
||||||
|
uint8_t i;
|
||||||
struct splitmix64_state_t smstate = {seed};
|
struct splitmix64_state_t smstate = {seed};
|
||||||
|
|
||||||
rn_current_state.a = 0;
|
rn_current_state.a = 0;
|
||||||
|
@ -46,7 +46,7 @@ int n2n_srand (uint64_t seed) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* stabilize in unlikely case of weak state with only a few bits set */
|
/* stabilize in unlikely case of weak state with only a few bits set */
|
||||||
for (uint8_t i = 0; i < 32; i++)
|
for(i = 0; i < 32; i++)
|
||||||
n2n_rand();
|
n2n_rand();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -84,27 +84,27 @@ uint64_t n2n_seed (void) {
|
||||||
ret += seed;
|
ret += seed;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// __RDRND__ is set only if architecturual feature is set, e.g. compile with -march=native
|
// __RDRND__ is set only if architecturual feature is set, e.g. compile with -march=native
|
||||||
#ifdef __RDRND__
|
#ifdef __RDRND__
|
||||||
_rdrand64_step ((unsigned long long*)&seed);
|
_rdrand64_step ((unsigned long long*)&seed);
|
||||||
ret += seed;
|
ret += seed;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// __RDSEED__ ist set only if architecturual feature is set, e.g. compile with -march=native
|
// __RDSEED__ ist set only if architecturual feature is set, e.g. compile with -march=native
|
||||||
#ifdef __RDSEED__
|
#ifdef __RDSEED__
|
||||||
_rdseed64_step((unsigned long long*)&seed);
|
_rdseed64_step((unsigned long long*)&seed);
|
||||||
ret += seed;
|
ret += seed;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The WIN32 code is still untested and thus commented
|
/* The WIN32 code is still untested and thus commented
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
HCRYPTPROV crypto_provider;
|
HCRYPTPROV crypto_provider;
|
||||||
CryptAcquireContext (&crypto_provider, NULL, (LPCWSTR)L"Microsoft Base Cryptographic Provider v1.0",
|
CryptAcquireContext (&crypto_provider, NULL, (LPCWSTR)L"Microsoft Base Cryptographic Provider v1.0",
|
||||||
PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
|
PROV_RSA_FULL, CRYPT_VERIFYCONTEXT);
|
||||||
CryptGenRandom (crypto_provider, 8, &seed);
|
CryptGenRandom (crypto_provider, 8, &seed);
|
||||||
CryptReleaseContext (crypto_provider, 0);
|
CryptReleaseContext (crypto_provider, 0);
|
||||||
ret += seed;
|
ret += seed;
|
||||||
#endif */
|
#endif */
|
||||||
|
|
||||||
seed = time(NULL); /* UTC in seconds */
|
seed = time(NULL); /* UTC in seconds */
|
||||||
ret += seed;
|
ret += seed;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user