replace ftime with gettimeofday on FreeBSD because lcompat is stupid

This commit is contained in:
fluffypony 2014-09-10 13:55:39 +02:00
parent 0e343ecfdf
commit a8d043b6dd
3 changed files with 32 additions and 8 deletions

View file

@ -130,10 +130,6 @@ elseif(NOT MSVC)
set(Boost_LIBRARIES "${Boost_LIBRARIES};rt;pthread") set(Boost_LIBRARIES "${Boost_LIBRARIES};rt;pthread")
endif() endif()
if(FREEBSD)
set(BSD_COMPAT "compat")
endif()
set(COMMIT_ID_IN_VERSION ON CACHE BOOL "Include commit ID in version") set(COMMIT_ID_IN_VERSION ON CACHE BOOL "Include commit ID in version")
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/version") file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/version")
if (NOT COMMIT_ID_IN_VERSION) if (NOT COMMIT_ID_IN_VERSION)

View file

@ -30,13 +30,13 @@ add_library(cryptonote_core ${CRYPTONOTE_CORE})
add_executable(daemon ${DAEMON} ${P2P} ${CRYPTONOTE_PROTOCOL}) add_executable(daemon ${DAEMON} ${P2P} ${CRYPTONOTE_PROTOCOL})
add_executable(connectivity_tool ${CONN_TOOL}) add_executable(connectivity_tool ${CONN_TOOL})
add_executable(simpleminer ${MINER}) add_executable(simpleminer ${MINER})
target_link_libraries(daemon rpc cryptonote_core crypto common upnpc-static ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${BSD_COMPAT}) target_link_libraries(daemon rpc cryptonote_core crypto common upnpc-static ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
target_link_libraries(connectivity_tool cryptonote_core crypto common ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${BSD_COMPAT}) target_link_libraries(connectivity_tool cryptonote_core crypto common ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
target_link_libraries(simpleminer cryptonote_core crypto common ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${BSD_COMPAT}) target_link_libraries(simpleminer cryptonote_core crypto common ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
add_library(rpc ${RPC}) add_library(rpc ${RPC})
add_library(wallet ${WALLET}) add_library(wallet ${WALLET})
add_executable(simplewallet ${SIMPLEWALLET} ) add_executable(simplewallet ${SIMPLEWALLET} )
target_link_libraries(simplewallet wallet rpc cryptonote_core crypto common upnpc-static ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} ${BSD_COMPAT}) target_link_libraries(simplewallet wallet rpc cryptonote_core crypto common upnpc-static ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
add_dependencies(daemon version) add_dependencies(daemon version)
add_dependencies(rpc version) add_dependencies(rpc version)
add_dependencies(simplewallet version) add_dependencies(simplewallet version)

View file

@ -468,6 +468,7 @@ OAES_RET oaes_sprintf(
#ifdef OAES_HAVE_ISAAC #ifdef OAES_HAVE_ISAAC
static void oaes_get_seed( char buf[RANDSIZ + 1] ) static void oaes_get_seed( char buf[RANDSIZ + 1] )
{ {
#ifndef __FreeBSD__
struct timeb timer; struct timeb timer;
struct tm *gmTimer; struct tm *gmTimer;
char * _test = NULL; 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_year + 1900, gmTimer->tm_mon + 1, gmTimer->tm_mday,
gmTimer->tm_hour, gmTimer->tm_min, gmTimer->tm_sec, timer.millitm, gmTimer->tm_hour, gmTimer->tm_min, gmTimer->tm_sec, timer.millitm,
_test + timer.millitm, getpid() ); _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 ) if( _test )
free( _test ); free( _test );
} }
#else #else
static uint32_t oaes_get_seed(void) static uint32_t oaes_get_seed(void)
{ {
#ifndef __FreeBSD__
struct timeb timer; struct timeb timer;
struct tm *gmTimer; struct tm *gmTimer;
char * _test = NULL; 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 + _ret = gmTimer->tm_year + 1900 + gmTimer->tm_mon + 1 + gmTimer->tm_mday +
gmTimer->tm_hour + gmTimer->tm_min + gmTimer->tm_sec + timer.millitm + gmTimer->tm_hour + gmTimer->tm_min + gmTimer->tm_sec + timer.millitm +
(uintptr_t) ( _test + timer.millitm ) + getpid(); (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 ) if( _test )
free( _test ); free( _test );