this should get things going on UNIX :D

pull/7/head
despair86 6 years ago
parent 6c5873c441
commit bbe0634edc

3
.gitignore vendored

@ -33,4 +33,5 @@ shadow.config.xml
testnet_tmp
*.pid
*.pid
vsproject/

@ -13,10 +13,13 @@ endmacro(add_cxxflags)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
if(COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++17" COMPILER_SUPPORTS_CXX17)
if(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
add_cxxflags("-std=c++11")
elseif(COMPILER_SUPPORTS_CXX17)
add_cxxflags("-std=c++17")
else()
message(ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
message(ERROR "The compiler ${CMAKE_CXX_COMPILER} has no C++11 or C++17 support. Please use a different C++ compiler.")
endif()
set(THREAD_LIB "-pthread")
@ -97,9 +100,9 @@ if(SODIUM_LIBRARIES)
set(SODIUM_LIB ${SODIUM_LIBRARIES})
else()
find_library (
SODIUM_LIB
NAMES sodium libsodium
HINTS "/usr/local/lib"
SODIUM_LIB
NAMES sodium libsodium
HINTS "/usr/local/lib"
)
endif()
@ -222,6 +225,7 @@ set(LIB_SRC
llarp/service.cpp
llarp/transit_hop.cpp
llarp/testnet.c
llarp/win32_inet.c
llarp/dht/context.cpp
llarp/dht/decode.cpp
llarp/dht/dht_immediate.cpp
@ -310,29 +314,85 @@ else()
if(WITH_STATIC)
add_library(${STATIC_LIB} STATIC ${LIB_SRC})
add_library(libbackport-static STATIC ${CPP_BACKPORT_SRC})
add_library(libllarpplatform-static STATIC ${LIB_PLATFORM_SRC})
target_link_libraries(libllarpplatform-static ${THREAD_LIB})
target_link_libraries(${STATIC_LIB} ${LIBS} libbackport-static libllarpplatform-static)
if(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
add_library(backport-static STATIC ${CPP_BACKPORT_SRC})
endif(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
add_library(llarpplatform-static STATIC ${LIB_PLATFORM_SRC})
target_link_libraries(llarpplatform-static ${THREAD_LIB})
if(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
target_link_libraries(${STATIC_LIB} ${LIBS} backport-static llarpplatform-static)
else()
target_link_libraries(${STATIC_LIB} ${LIBS} llarpplatform-static)
endif(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
if(NOT WITH_SHARED)
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} libbackport-static libllarpplatform-static)
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} libbackport-static libllarpplatform-static)
target_link_libraries(rcutil ${STATIC_LINK_LIBS} ${STATIC_LIB} libbackport-static libllarpplatform-static)
target_link_libraries(dns libllarpplatform-static pthread)
endif()
endif()
if(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static)
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static)
target_link_libraries(rcutil ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static)
if (MINGW)
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static ws2_32 stdc++fs)
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static ws2_32 stdc++fs)
target_link_libraries(rcutil ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static ws2_32 stdc++fs)
elseif(WIN32)
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static ws2_32)
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static ws2_32)
target_link_libraries(rcutil ${STATIC_LINK_LIBS} ${STATIC_LIB} backport-static llarpplatform-static ws2_32)
endif(MINGW)
else()
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static)
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static)
target_link_libraries(rcutil ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static)
if (MINGW)
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static ws2_32 stdc++fs)
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static ws2_32 stdc++fs)
target_link_libraries(rcutil ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static ws2_32 stdc++fs)
elseif(WIN32)
target_link_libraries(${EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static ws2_32)
target_link_libraries(${CLIENT_EXE} ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static ws2_32)
target_link_libraries(rcutil ${STATIC_LINK_LIBS} ${STATIC_LIB} llarpplatform-static ws2_32)
endif(MINGW)
endif(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
if (MINGW)
target_link_libraries(dns ${STATIC_LIB} llarpplatform-static pthread ws2_32 stdc++fs)
elseif(WIN32)
target_link_libraries(dns ${STATIC_LIB} llarpplatform-static pthread ws2_32)
endif(MINGW)
target_link_libraries(dns ${STATIC_LIB} llarpplatform-static pthread)
endif(NOT WITH_SHARED)
endif(WITH_STATIC)
if(WITH_SHARED)
add_library(${SHARED_LIB} SHARED ${LIB_SRC})
add_library(libbackport SHARED ${CPP_BACKPORT_SRC})
add_library(libllarpplatform SHARED ${LIB_PLATFORM_SRC})
target_link_libraries(${SHARED_LIB} ${LIBS} libbackport libllarpplatform)
if(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
add_library(backport SHARED ${CPP_BACKPORT_SRC})
endif(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
add_library(llarpplatform SHARED ${LIB_PLATFORM_SRC})
if(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
target_link_libraries(${SHARED_LIB} ${LIBS} backport llarpplatform)
if (MINGW)
target_link_libraries(${SHARED_LIB} ${LIBS} backport llarpplatform ws2_32 stdc++fs)
elseif(WIN32)
target_link_libraries(${SHARED_LIB} ${LIBS} backport llarpplatform ws2_32)
endif(MINGW)
else()
target_link_libraries(${SHARED_LIB} ${LIBS} llarpplatform)
if (MINGW)
target_link_libraries(${SHARED_LIB} ${LIBS} llarpplatform ws2_32 stdc++fs)
elseif(WIN32)
target_link_libraries(${SHARED_LIB} ${LIBS} llarpplatform ws2_32)
endif(MINGW)
endif(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
if(NOT WITH_STATIC)
target_link_libraries(${EXE} ${SHARED_LIB} libbackport libllarpplatform)
target_link_libraries(${CLIENT_EXE} ${SHARED_LIB} libbackport libllarpplatform)
target_link_libraries(rcutil ${SHARED_LIB} libbackport libllarpplatform)
target_link_libraries(dns libllarpplatform pthread)
endif()
endif()
endif()
if(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
target_link_libraries(${EXE} ${SHARED_LIB} backport llarpplatform)
target_link_libraries(${CLIENT_EXE} ${SHARED_LIB} backport llarpplatform)
target_link_libraries(rcutil ${SHARED_LIB} backport llarpplatform)
else()
target_link_libraries(${EXE} ${SHARED_LIB} llarpplatform)
target_link_libraries(${CLIENT_EXE} ${SHARED_LIB} llarpplatform)
target_link_libraries(rcutil ${SHARED_LIB} llarpplatform)
endif(COMPILER_SUPPORTS_CXX11 AND NOT COMPILER_SUPPORTS_CXX17 OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
target_link_libraries(dns ${SHARED_LIB} llarpplatform pthread)
endif(NOT WITH_STATIC)
endif(WITH_SHARED)
endif(SHADOW)

@ -12,6 +12,10 @@
#include <thread> // for multithreaded version
#include <vector>
#if(__FreeBSD__) || (__OpenBSD__) || (__NetBSD__)
#include <pthread_np.h>
#endif
bool done = false;
void
@ -29,7 +33,7 @@ hookChecker(std::string name)
}
// FIXME: make configurable
#define SERVER "8.8.8.8"
#define SERVER "1.1.1.1"
#define PORT 53
int
@ -85,7 +89,7 @@ main(int argc, char *argv[])
netio_threads.emplace_back([netio]() { llarp_ev_loop_run(netio); });
#if(__APPLE__ && __MACH__)
#elif(__FreeBSD__)
#elif(__FreeBSD__) || (__OpenBSD__) || (__NetBSD__)
pthread_set_name_np(netio_threads.back().native_handle(),
"llarp-netio");
#else

@ -6,7 +6,7 @@
#include "math.h"
#include "router.hpp"
#if(__FreeBSD__)
#if(__FreeBSD__) || (__OpenBSD__) || (__NetBSD__)
#include <pthread_np.h>
#endif
@ -191,7 +191,7 @@ namespace llarp
netio_threads.emplace_back([netio]() { llarp_ev_loop_run(netio); });
#if(__APPLE__ && __MACH__)
#elif(__FreeBSD__)
#elif(__FreeBSD__) || (__OpenBSD__) || (__NetBSD__)
pthread_set_name_np(netio_threads.back().native_handle(),
"llarp-"
"netio");

@ -8,7 +8,7 @@
#if(__APPLE__ && __MACH__)
#include "ev_kqueue.hpp"
#endif
#ifdef __FreeBSD__
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
#include "ev_kqueue.hpp"
#endif
@ -21,7 +21,7 @@ llarp_ev_loop_alloc(struct llarp_ev_loop **ev)
#if(__APPLE__ && __MACH__)
*ev = new llarp_kqueue_loop;
#endif
#ifdef __FreeBSD__
#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
*ev = new llarp_kqueue_loop;
#endif
(*ev)->init();

@ -3,7 +3,7 @@
#include <llarp/buffer.h>
#include <llarp/net.h>
#if __FreeBSD__
#if __FreeBSD__ || __OpenBSD__ || __NetBSD__
// kqueue / kevent
#include <sys/event.h>
#include <sys/time.h>

@ -8,6 +8,14 @@
#endif
#include "filesystem.h"
#if !defined(CPP17) || defined(__OpenBSD__)
namespace fs = cpp17::filesystem;
#else
#ifndef __MINGW32__
namespace fs = std::filesystem;
#else
namespace fs = std::experimental::filesystem;
#endif
#endif
#endif

@ -182,8 +182,13 @@ struct llarp_nodedb
{
ssize_t sz = 0;
fs::directory_iterator i(dir);
#if defined(CPP17) && !defined(__OpenBSD__)
auto itr = fs::begin(i);
while(itr != fs::end(i))
#else
auto itr = i.begin();
while(itr != itr.end())
#endif
{
if(fs::is_regular_file(itr->symlink_status()) && loadfile(*itr))
sz++;

@ -7,7 +7,7 @@
#include "logger.hpp"
#if(__FreeBSD__)
#if(__FreeBSD__) || (__OpenBSD__) || (__NetBSD__)
#include <pthread_np.h>
#endif
@ -25,7 +25,7 @@ namespace llarp
{
#if(__APPLE__ && __MACH__)
pthread_setname_np(name);
#elif(__FreeBSD__)
#elif(__FreeBSD__) || (__OpenBSD__) || (__NetBSD__)
pthread_set_name_np(pthread_self(), name);
#else
pthread_setname_np(pthread_self(), name);

@ -32,8 +32,12 @@
#include "version.h"
#if defined(CPP17)
#if defined(CPP17) && !defined(__OpenBSD__)
#if defined(__MINGW32__)
#include <experimental/filesystem>
#else
#include <filesystem>
#endif
#else
#include "fs/absolute.h"
#include "fs/basename.h"

Loading…
Cancel
Save