1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00

Support abseil on i686-pc-winnt-gnu

This commit is contained in:
Rick V 2019-03-05 22:44:43 -06:00
parent 53f7360094
commit 8443c5ab8c
No known key found for this signature in database
GPG key ID: C0EDC8723FDC3465
17 changed files with 37 additions and 18 deletions

View file

@ -30,6 +30,7 @@ endif()
if(WIN32)
set(CMAKE_CXX_STANDARD 17)
ENABLE_LANGUAGE(RC)
set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES} -lshlwapi")
else()
set(CMAKE_CXX_STANDARD 14)
endif(WIN32)
@ -139,6 +140,7 @@ if(STATIC_LINK_RUNTIME)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++ -static-libgcc -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive" )
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
endif(USING_CLANG)
endif(STATIC_LINK_RUNTIME)

View file

@ -40,7 +40,6 @@ target_link_libraries(${UTIL_LIB} PUBLIC nlohmann_json::nlohmann_json)
# cut back on fluff
if (NOT WIN32)
target_link_libraries(${UTIL_LIB} PUBLIC absl::optional absl::variant absl::strings absl::hash cppbackport)
# TODO #371: link against absl::synchronization on windows
endif(NOT WIN32)
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")

View file

@ -2,6 +2,10 @@
#include <util/threading.hpp>
#include <condition_variable>
#include <thread>
#include <mutex>
#include <condition_variable>
#include <gtest/gtest.h>
using namespace llarp;

View file

@ -107,11 +107,16 @@
// Note: As the GCC manual states, "[s]ince non-static C++ methods
// have an implicit 'this' argument, the arguments of such methods
// should be counted from two, not one."
#if ABSL_HAVE_ATTRIBUTE(format) || (defined(__GNUC__) && !defined(__clang__))
#if ABSL_HAVE_ATTRIBUTE(format) && !defined(_WIN32)
#define ABSL_PRINTF_ATTRIBUTE(string_index, first_to_check) \
__attribute__((__format__(__printf__, string_index, first_to_check)))
#define ABSL_SCANF_ATTRIBUTE(string_index, first_to_check) \
__attribute__((__format__(__scanf__, string_index, first_to_check)))
#elif ABSL_HAVE_ATTRIBUTE(format) && defined(__MINGW32__)
#define ABSL_PRINTF_ATTRIBUTE(string_index, first_to_check) \
__attribute__((__format__ (__MINGW_PRINTF_FORMAT, string_index, first_to_check)))
#define ABSL_SCANF_ATTRIBUTE(string_index, first_to_check) \
__attribute__((__format__ (__MINGW_PRINTF_FORMAT, string_index, first_to_check)))
#else
#define ABSL_PRINTF_ATTRIBUTE(string_index, first_to_check)
#define ABSL_SCANF_ATTRIBUTE(string_index, first_to_check)
@ -164,6 +169,12 @@
#undef ABSL_ATTRIBUTE_WEAK
#define ABSL_ATTRIBUTE_WEAK __attribute__((weak))
#define ABSL_HAVE_ATTRIBUTE_WEAK 1
#ifdef __MINGW32__
#undef ABSL_ATTRIBUTE_WEAK
#define ABSL_ATTRIBUTE_WEAK
#undef ABSL_HAVE_ATTRIBUTE_WEAK
#define ABSL_HAVE_ATTRIBUTE_WEAK 0
#endif
#else
#define ABSL_ATTRIBUTE_WEAK
#define ABSL_HAVE_ATTRIBUTE_WEAK 0

View file

@ -328,7 +328,7 @@
#elif defined(__GLIBC__)
// feature test for glibc
#define ABSL_HAVE_ALARM 1
#elif defined(_MSC_VER)
#elif defined(_MSC_VER) || defined(__MINGW32__)
// feature tests for Microsoft's library
#elif defined(__EMSCRIPTEN__)
// emscripten doesn't support signals

View file

@ -21,7 +21,7 @@
#include "absl/base/internal/spinlock_wait.h"
#if defined(_WIN32)
#if defined(_WIN32) && defined(_MSC_VER)
#include "absl/base/internal/spinlock_win32.inc"
#elif defined(__linux__)
#include "absl/base/internal/spinlock_linux.inc"

View file

@ -79,7 +79,6 @@ static int GetNumCPUs() {
static double GetNominalCPUFrequency() {
DWORD data;
DWORD data_size = sizeof(data);
#pragma comment(lib, "shlwapi.lib") // For SHGetValue().
if (SUCCEEDED(
SHGetValueA(HKEY_LOCAL_MACHINE,
"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0",
@ -275,7 +274,7 @@ double NominalCPUFrequency() {
return nominal_cpu_frequency;
}
#if defined(_WIN32)
#if defined(_WIN32) && defined(_MSC_VER)
pid_t GetTID() {
return GetCurrentThreadId();
@ -326,6 +325,7 @@ pid_t GetTID() {
#else
// Fallback implementation of GetTID using pthread_getspecific.
// this might work on mingw32
static once_flag tid_once;
static pthread_key_t tid_key;
static absl::base_internal::SpinLock tid_lock(

View file

@ -70,10 +70,11 @@ void SetCurrentThreadIdentity(
absl::call_once(init_thread_identity_key_once, AllocateThreadIdentityKey,
reclaimer);
#ifdef __EMSCRIPTEN__
#if __EMSCRIPTEN__ || __MINGW32__
// Emscripten PThread implementation does not support signals.
// See https://kripken.github.io/emscripten-site/docs/porting/pthreads.html
// for more information.
// Nor does Windows
pthread_setspecific(thread_identity_pthread_key,
reinterpret_cast<void*>(identity));
#else

View file

@ -209,7 +209,7 @@ void ClearCurrentThreadIdentity();
#error ABSL_THREAD_IDENTITY_MODE cannot be direcly set
#elif defined(ABSL_FORCE_THREAD_IDENTITY_MODE)
#define ABSL_THREAD_IDENTITY_MODE ABSL_FORCE_THREAD_IDENTITY_MODE
#elif defined(_WIN32)
#elif defined(_MSC_VER)
#define ABSL_THREAD_IDENTITY_MODE ABSL_THREAD_IDENTITY_MODE_USE_CPP11
#elif ABSL_PER_THREAD_TLS && defined(__GOOGLE_GRTE_VERSION__) && \
(__GOOGLE_GRTE_VERSION__ >= 20140228L)

View file

@ -272,7 +272,7 @@ static void WriteFailureInfo(int signo, void* ucontext,
// may be overridden to do something that isn't async-signal-safe on
// some platforms.
static void PortableSleepForSeconds(int seconds) {
#ifdef _WIN32
#ifdef _MSC_VER
Sleep(seconds * 1000);
#else
struct timespec sleep_time;

View file

@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#define __USE_MINGW_ANSI_STDIO 1
#include "absl/strings/escaping.h"
#include <algorithm>

View file

@ -52,7 +52,7 @@ absl::Time LimitedDeadline(absl::Time deadline) {
} // namespace
#if defined(_WIN32)
#if defined(_WIN32) && defined(_MSC_VER)
MutexImpl::MutexImpl() {}

View file

@ -9,7 +9,7 @@
#include <type_traits>
#if defined(_WIN32)
#if defined(_WIN32) && defined(_MSC_VER)
#include <condition_variable>
#include <mutex>
#else
@ -61,7 +61,7 @@ class CondVarImpl {
bool WaitWithDeadline(MutexImpl* mutex, absl::Time deadline);
private:
#if defined(_WIN32)
#if defined(_WIN32) && defined(_MSC_VER)
std::condition_variable_any std_cv_;
#else
pthread_cond_t pthread_cv_;
@ -89,7 +89,7 @@ class MutexImpl {
private:
friend class CondVarImpl;
#if defined(_WIN32)
#if defined(_WIN32) && defined(_MSC_VER)
std::mutex std_mutex_;
#else
pthread_mutex_t pthread_mutex_;

View file

@ -42,7 +42,8 @@
#if defined(ABSL_FORCE_WAITER_MODE)
#define ABSL_WAITER_MODE ABSL_FORCE_WAITER_MODE
#elif defined(_WIN32)
// Use pthreads with mingw-w64
#elif defined(_WIN32) && defined(_MSC_VER)
#define ABSL_WAITER_MODE ABSL_WAITER_MODE_WIN32
#elif defined(__linux__)
#define ABSL_WAITER_MODE ABSL_WAITER_MODE_FUTEX

View file

@ -542,7 +542,7 @@ constexpr absl::Duration MaxSleep() {
// Sleeps for the given duration.
// REQUIRES: to_sleep <= MaxSleep().
void SleepOnce(absl::Duration to_sleep) {
#ifdef _WIN32
#ifdef _MSC_VER
Sleep(to_sleep / absl::Milliseconds(1));
#else
struct timespec sleep_time = absl::ToTimespec(to_sleep);

View file

@ -13,7 +13,7 @@
// limitations under the License.
#if !defined(HAS_STRPTIME)
# if !defined(_MSC_VER)
# if !defined(_MSC_VER) && !defined(__MINGW32__)
# define HAS_STRPTIME 1 // assume everyone has strptime() except windows
# endif
#endif

View file

@ -68,7 +68,8 @@ ZoneInfoSourceFactory default_factory = DefaultFactory;
#if !defined(__has_attribute)
#define __has_attribute(x) 0
#endif
#if __has_attribute(weak) || defined(__GNUC__)
// gcc on windows doesn't support ELF-style weak symbols
#if (__has_attribute(weak) || defined(__GNUC__)) && !__MINGW32__
ZoneInfoSourceFactory zone_info_source_factory
__attribute__((weak)) = DefaultFactory;
#else