diff options
author | fluffypony <ric@spagni.net> | 2014-09-10 13:55:39 +0200 |
---|---|---|
committer | fluffypony <ric@spagni.net> | 2014-09-10 13:55:39 +0200 |
commit | a8d043b6dd58a15bb21448db8e141a76e5c8276e (patch) | |
tree | 1d8155c81a110d4b2f1b8c07e1da199ff6675f52 /src/crypto | |
parent | make FreeBSD use -lcompat till we can fix ftime() (diff) | |
download | monero-a8d043b6dd58a15bb21448db8e141a76e5c8276e.tar.xz |
replace ftime with gettimeofday on FreeBSD because lcompat is stupid
Diffstat (limited to 'src/crypto')
-rw-r--r-- | src/crypto/oaes_lib.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/crypto/oaes_lib.c b/src/crypto/oaes_lib.c index 8e45309b5..ff2665381 100644 --- a/src/crypto/oaes_lib.c +++ b/src/crypto/oaes_lib.c @@ -468,6 +468,7 @@ OAES_RET oaes_sprintf( #ifdef OAES_HAVE_ISAAC static void oaes_get_seed( char buf[RANDSIZ + 1] ) { + #ifndef __FreeBSD__ struct timeb timer; struct tm *gmTimer; char * _test = NULL; @@ -479,13 +480,27 @@ static void oaes_get_seed( char buf[RANDSIZ + 1] ) gmTimer->tm_year + 1900, gmTimer->tm_mon + 1, gmTimer->tm_mday, gmTimer->tm_hour, gmTimer->tm_min, gmTimer->tm_sec, timer.millitm, _test + timer.millitm, getpid() ); + #else + struct timeval timer; + struct tm *gmTimer; + char * _test = NULL; + gettimeofday(&timer, NULL); + gmTimer = gmtime( &timer.tv_sec ); + _test = (char *) calloc( sizeof( char ), timer.tv_usec/1000 ); + sprintf( buf, "%04d%02d%02d%02d%02d%02d%03d%p%d", + gmTimer->tm_year + 1900, gmTimer->tm_mon + 1, gmTimer->tm_mday, + gmTimer->tm_hour, gmTimer->tm_min, gmTimer->tm_sec, timer.tv_usec/1000, + _test + timer.tv_usec/1000, getpid() ); + #endif + if( _test ) free( _test ); } #else static uint32_t oaes_get_seed(void) { + #ifndef __FreeBSD__ struct timeb timer; struct tm *gmTimer; char * _test = NULL; @@ -497,6 +512,19 @@ static uint32_t oaes_get_seed(void) _ret = gmTimer->tm_year + 1900 + gmTimer->tm_mon + 1 + gmTimer->tm_mday + gmTimer->tm_hour + gmTimer->tm_min + gmTimer->tm_sec + timer.millitm + (uintptr_t) ( _test + timer.millitm ) + getpid(); + #else + struct timeval timer; + struct tm *gmTimer; + char * _test = NULL; + uint32_t _ret = 0; + + gettimeofday(&timer, NULL); + gmTimer = gmtime( &timer.tv_sec ); + _test = (char *) calloc( sizeof( char ), timer.tv_usec/1000 ); + _ret = gmTimer->tm_year + 1900 + gmTimer->tm_mon + 1 + gmTimer->tm_mday + + gmTimer->tm_hour + gmTimer->tm_min + gmTimer->tm_sec + timer.tv_usec/1000 + + (uintptr_t) ( _test + timer.tv_usec/1000 ) + getpid(); + #endif if( _test ) free( _test ); |