pike.git / src / stuff.c

version» Context lines:

pike.git/src/stuff.c:160:      #define RNDBUF 250   #define RNDSTEP 7   #define RNDJUMP 103      static unsigned INT32 rndbuf[ RNDBUF ];   static unsigned int rnd_index;      #if HAS___BUILTIN_IA32_RDRAND32_STEP   static int use_rdrnd; + static unsigned long long rnd_index64;   #endif   #define bit_RDRND_2 (1<<30)      #if SIZEOF_CHAR_P == 4   #define __cpuid(level, a, b, c, d) \    __asm__ ("pushl %%ebx \n\t" \    "cpuid \n\t" \    "movl %%ebx, %1 \n\t" \    "popl %%ebx \n\t" \    : "=a" (a), "=r" (b), "=c" (c), "=d" (d) \
pike.git/src/stuff.c:253:   #endif    if(++rnd_index == RNDBUF) rnd_index=0;    return rndbuf[rnd_index] += rndbuf[rnd_index+RNDJUMP-(rnd_index<RNDBUF-RNDJUMP?0:RNDBUF)];   }      PMOD_EXPORT unsigned INT64 my_rand64(void)   {   #if HAS___BUILTIN_IA32_RDRAND32_STEP    if( use_rdrnd )    { -  unsigned long long rnd; +     unsigned int cnt = 0;    do{    /* We blindly trust that _builtin_ia32_rdrand64_step exists when    the 32 bit version does. */ -  if( __builtin_ia32_rdrand64_step( &rnd ) ) -  return rnd; +  if( __builtin_ia32_rdrand64_step( &rnd_index64 ) ) +  return rnd_index64;    } while(cnt++ < 100);       /* hardware random unit most likely not healthy.    Switch to software random. */    rnd_index = 0;    use_rdrnd = 0;    }   #endif    return ((INT64)my_rand()<<32) | my_rand();   }