From 6afbdd975496535567e2c24777721660ba1b4280 Mon Sep 17 00:00:00 2001 From: fluffypony Date: Tue, 9 Sep 2014 12:37:19 +0200 Subject: FreeBSD alloca.h reference fixed --- src/crypto/crypto.cpp | 7 ++++++- src/crypto/tree-hash.c | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'src/crypto') diff --git a/src/crypto/crypto.cpp b/src/crypto/crypto.cpp index bce3b1131..fa0199f20 100644 --- a/src/crypto/crypto.cpp +++ b/src/crypto/crypto.cpp @@ -28,7 +28,6 @@ // // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers -#include #include #include #include @@ -42,6 +41,12 @@ #include "crypto.h" #include "hash.h" +#ifndef __FreeBSD__ + #include +#else + #include +#endif + namespace crypto { using std::abort; diff --git a/src/crypto/tree-hash.c b/src/crypto/tree-hash.c index 573f44643..5a84c8688 100644 --- a/src/crypto/tree-hash.c +++ b/src/crypto/tree-hash.c @@ -28,13 +28,18 @@ // // Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers -#include #include #include #include #include "hash-ops.h" +#ifndef __FreeBSD__ + #include +#else + #include +#endif + /// Quick check if this is power of two (use on unsigned types; in this case for size_t only) bool ispowerof2_size_t(size_t x) { return x && !(x & (x - 1)); -- cgit v1.2.3 From e1d31e0a8b59fd74829f790e97c75e7a530b86df Mon Sep 17 00:00:00 2001 From: fluffypony Date: Tue, 9 Sep 2014 14:07:57 +0200 Subject: malloc.h reference fixed for FreeBSD --- src/crypto/oaes_lib.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/crypto') diff --git a/src/crypto/oaes_lib.c b/src/crypto/oaes_lib.c index 81c8aeff2..1dce99edd 100644 --- a/src/crypto/oaes_lib.c +++ b/src/crypto/oaes_lib.c @@ -38,8 +38,8 @@ static const char _NR[] = { #include #include -#ifndef __APPLE__ -#include +#ifndef __APPLE__ || __FREEBSD__ + #include #endif #ifdef WIN32 -- cgit v1.2.3 From 266c639f4fbadee324007d5fabf6089b7a6d9753 Mon Sep 17 00:00:00 2001 From: fluffypony Date: Tue, 9 Sep 2014 14:49:13 +0200 Subject: more FreeBSD fixes --- src/crypto/oaes_lib.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/crypto') diff --git a/src/crypto/oaes_lib.c b/src/crypto/oaes_lib.c index 1dce99edd..8e45309b5 100644 --- a/src/crypto/oaes_lib.c +++ b/src/crypto/oaes_lib.c @@ -33,15 +33,20 @@ static const char _NR[] = { #include #include -#include #include #include #include -#ifndef __APPLE__ || __FREEBSD__ +// Both OS X and FreeBSD don't need malloc.h +#if !defined(__APPLE__) && !defined(__FreeBSD__) #include #endif +// FreeBSD also doesn't need timeb.h +#ifndef __FreeBSD__ + #include +#endif + #ifdef WIN32 #include #else -- cgit v1.2.3 From a8d043b6dd58a15bb21448db8e141a76e5c8276e Mon Sep 17 00:00:00 2001 From: fluffypony Date: Wed, 10 Sep 2014 13:55:39 +0200 Subject: replace ftime with gettimeofday on FreeBSD because lcompat is stupid --- CMakeLists.txt | 4 ---- src/CMakeLists.txt | 8 ++++---- src/crypto/oaes_lib.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 8 deletions(-) (limited to 'src/crypto') diff --git a/CMakeLists.txt b/CMakeLists.txt index ea5a094f7..9614d7028 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -130,10 +130,6 @@ elseif(NOT MSVC) set(Boost_LIBRARIES "${Boost_LIBRARIES};rt;pthread") endif() -if(FREEBSD) - set(BSD_COMPAT "compat") -endif() - set(COMMIT_ID_IN_VERSION ON CACHE BOOL "Include commit ID in version") file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/version") if (NOT COMMIT_ID_IN_VERSION) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0bb3b87ea..e4e682b99 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -30,13 +30,13 @@ add_library(cryptonote_core ${CRYPTONOTE_CORE}) add_executable(daemon ${DAEMON} ${P2P} ${CRYPTONOTE_PROTOCOL}) add_executable(connectivity_tool ${CONN_TOOL}) 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(connectivity_tool 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} ${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}) +target_link_libraries(simpleminer cryptonote_core crypto common ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES}) add_library(rpc ${RPC}) add_library(wallet ${WALLET}) 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(rpc version) add_dependencies(simplewallet version) 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 ); -- cgit v1.2.3 From 110f110181aa614d7ff2a3a4485a42d74af0f738 Mon Sep 17 00:00:00 2001 From: fluffypony Date: Wed, 10 Sep 2014 13:58:43 +0200 Subject: Include sys/time.h on BSD --- src/crypto/oaes_lib.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/crypto') diff --git a/src/crypto/oaes_lib.c b/src/crypto/oaes_lib.c index ff2665381..c86b8caa0 100644 --- a/src/crypto/oaes_lib.c +++ b/src/crypto/oaes_lib.c @@ -45,6 +45,8 @@ static const char _NR[] = { // FreeBSD also doesn't need timeb.h #ifndef __FreeBSD__ #include +#else + #include #endif #ifdef WIN32 -- cgit v1.2.3 From ccb2ab2b7b982afa3f495779f852f25c7dd8b274 Mon Sep 17 00:00:00 2001 From: fluffypony Date: Wed, 10 Sep 2014 14:01:39 +0200 Subject: mmap on FreeBSD doesn't have MAP_HUGETLB --- src/crypto/slow-hash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/crypto') diff --git a/src/crypto/slow-hash.c b/src/crypto/slow-hash.c index 4d1594723..3aff7bd5d 100644 --- a/src/crypto/slow-hash.c +++ b/src/crypto/slow-hash.c @@ -330,7 +330,7 @@ void slow_hash_allocate_state(void) hp_state = (uint8_t *) VirtualAlloc(hp_state, MEMORY, MEM_LARGE_PAGES | MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE); #else -#if defined(__APPLE__) +#if defined(__APPLE__) || defined(__FreeBSD__) hp_state = mmap(0, MEMORY, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, 0, 0); #else -- cgit v1.2.3