From e9c2d22da9c04ed96cc75f613e5ea16bff5deee9 Mon Sep 17 00:00:00 2001 From: Anton Kochkov Date: Wed, 25 Jan 2017 13:30:16 +0300 Subject: [PATCH] Fix windows detection in headers (#6557) --- libr/include/r_types.h | 6 +++--- libr/include/r_userconf.h.acr | 2 +- libr/include/sdb/types.h | 2 +- libr/util/thread.c | 2 +- libr/util/thread_lock.c | 10 +++++----- shlr/sdb/src/types.h | 2 +- shlr/spp/r_api.h | 4 ++-- shlr/udis86/udint.h | 2 +- shlr/wind/iob_pipe.c | 2 +- shlr/wind/transport.c | 2 +- 10 files changed, 17 insertions(+), 17 deletions(-) diff --git a/libr/include/r_types.h b/libr/include/r_types.h index 1e0122d6c0..7ee60219f9 100644 --- a/libr/include/r_types.h +++ b/libr/include/r_types.h @@ -81,11 +81,11 @@ #define __BSD__ 1 #define __UNIX__ 1 #endif -#if __WIN32__ || __CYGWIN__ || MINGW32 +#if _WIN32 || __CYGWIN__ || MINGW32 #define __addr_t_defined #include #endif -#if __WIN32__ || MINGW32 && !__CYGWIN__ +#if _WIN32 || MINGW32 && !__CYGWIN__ #include typedef int socklen_t; #undef USE_SOCKETS @@ -423,7 +423,7 @@ enum { #define R_SYS_OS "darwin" #elif defined (__linux__) #define R_SYS_OS "linux" -#elif defined (__WIN32__) || defined (__CYGWIN__) || defined (MINGW32) +#elif defined (_WIN32) || defined (__CYGWIN__) || defined (MINGW32) #define R_SYS_OS "windows" #elif defined (__NetBSD__ ) #define R_SYS_OS "netbsd" diff --git a/libr/include/r_userconf.h.acr b/libr/include/r_userconf.h.acr index 511c71159a..4351f24bdd 100644 --- a/libr/include/r_userconf.h.acr +++ b/libr/include/r_userconf.h.acr @@ -5,7 +5,7 @@ #define DEBUGGER @DEBUGGER@ -#if __WIN32__ || __CYGWIN__ || MINGW32 +#if _WIN32 || __CYGWIN__ || MINGW32 #define R2_PREFIX "." #define R2_LIBDIR "./lib" #define R2_INCDIR "./include/libr" diff --git a/libr/include/sdb/types.h b/libr/include/sdb/types.h index b99da48848..d2314ad77e 100644 --- a/libr/include/sdb/types.h +++ b/libr/include/sdb/types.h @@ -30,7 +30,7 @@ #define __MINGW__ 1 #endif -#if __WIN32__ || __MINGW__ || __WINDOWS__ +#if _WIN32 || __MINGW__ || __WINDOWS__ #define __SDB_WINDOWS__ 1 #include #define DIRSEP '\\' diff --git a/libr/util/thread.c b/libr/util/thread.c index 582829536c..53b3dc58c9 100644 --- a/libr/util/thread.c +++ b/libr/util/thread.c @@ -49,7 +49,7 @@ R_API RThread *r_th_new(R_TH_FUNCTION(fun), void *user, int delay) { th->ready = false; #if HAVE_PTHREAD pthread_create (&th->tid, NULL, _r_th_launcher, th); -#elif __WIN32__ || __WINDOWS__ && !defined(__CYGWIN__) +#elif _WIN32 || __WINDOWS__ && !defined(__CYGWIN__) th->tid = CreateThread (NULL, 0, _r_th_launcher, th, 0, &th->tid); #endif } diff --git a/libr/util/thread_lock.c b/libr/util/thread_lock.c index cbe727e346..3672f86789 100644 --- a/libr/util/thread_lock.c +++ b/libr/util/thread_lock.c @@ -10,7 +10,7 @@ R_API RThreadLock *r_th_lock_new() { thl->refs = 0; #if HAVE_PTHREAD pthread_mutex_init (&thl->lock, NULL); -#elif __WIN32__ || __WINDOWS__ && !defined(__CYGWIN__) +#elif _WIN32 || __WINDOWS__ && !defined(__CYGWIN__) //thl->lock = CreateSemaphore(NULL, 0, 1, NULL); InitializeCriticalSection(&thl->lock); #endif @@ -22,7 +22,7 @@ R_API int r_th_lock_wait(RThreadLock *thl) { #if HAVE_PTHREAD r_th_lock_enter (thl); // locks here r_th_lock_leave (thl); // releases previous mutex -#elif __WIN32__ || __WINDOWS__ && !defined(__CYGWIN__) +#elif _WIN32 || __WINDOWS__ && !defined(__CYGWIN__) WaitForSingleObject (thl->lock, INFINITE); #else while (r_th_lock_check (thl)); @@ -33,7 +33,7 @@ R_API int r_th_lock_wait(RThreadLock *thl) { R_API int r_th_lock_enter(RThreadLock *thl) { #if HAVE_PTHREAD pthread_mutex_lock(&thl->lock); -#elif __WIN32__ || __WINDOWS__ && !defined(__CYGWIN__) +#elif _WIN32 || __WINDOWS__ && !defined(__CYGWIN__) EnterCriticalSection (&thl->lock); #endif return ++thl->refs; @@ -42,7 +42,7 @@ R_API int r_th_lock_enter(RThreadLock *thl) { R_API int r_th_lock_leave(RThreadLock *thl) { #if HAVE_PTHREAD pthread_mutex_unlock (&thl->lock); -#elif __WIN32__ || __WINDOWS__ && !defined(__CYGWIN__) +#elif _WIN32 || __WINDOWS__ && !defined(__CYGWIN__) LeaveCriticalSection (&thl->lock); //ReleaseSemaphore (thl->lock, 1, NULL); #endif @@ -60,7 +60,7 @@ R_API void *r_th_lock_free(RThreadLock *thl) { if (thl) { #if HAVE_PTHREAD pthread_mutex_destroy (&thl->lock); -#elif __WIN32__ || __WINDOWS__ && !defined(__CYGWIN__) +#elif _WIN32 || __WINDOWS__ && !defined(__CYGWIN__) DeleteCriticalSection (&thl->lock); CloseHandle (thl->lock); #endif diff --git a/shlr/sdb/src/types.h b/shlr/sdb/src/types.h index b99da48848..d2314ad77e 100644 --- a/shlr/sdb/src/types.h +++ b/shlr/sdb/src/types.h @@ -30,7 +30,7 @@ #define __MINGW__ 1 #endif -#if __WIN32__ || __MINGW__ || __WINDOWS__ +#if _WIN32 || __MINGW__ || __WINDOWS__ #define __SDB_WINDOWS__ 1 #include #define DIRSEP '\\' diff --git a/shlr/spp/r_api.h b/shlr/spp/r_api.h index 4414bfeadf..dd773e804c 100644 --- a/shlr/spp/r_api.h +++ b/shlr/spp/r_api.h @@ -17,11 +17,11 @@ #define __BSD__ 1 #define __UNIX__ 1 #endif -#if __WIN32__ || __CYGWIN__ || MINGW32 +#if _WIN32 || __CYGWIN__ || MINGW32 #define __addr_t_defined #include #endif -#if __WIN32__ || MINGW32 && !__CYGWIN__ +#if _WIN32 || MINGW32 && !__CYGWIN__ #include typedef int socklen_t; #undef USE_SOCKETS diff --git a/shlr/udis86/udint.h b/shlr/udis86/udint.h index befa8ea1d5..93c63cd4c6 100644 --- a/shlr/udis86/udint.h +++ b/shlr/udis86/udint.h @@ -74,7 +74,7 @@ #ifdef FMT64 # undef FMT64 #endif -#if defined(_MSC_VER) || defined(__BORLANDC__) || __WIN32__ || __MINGW32__ && !defined(__CYGWIN__) +#if defined(_MSC_VER) || defined(__BORLANDC__) || _WIN32 || __MINGW32__ && !defined(__CYGWIN__) # define FMT64 "I64" #else # if defined(__APPLE__) diff --git a/shlr/wind/iob_pipe.c b/shlr/wind/iob_pipe.c index c67f53a8b7..ee1287853e 100644 --- a/shlr/wind/iob_pipe.c +++ b/shlr/wind/iob_pipe.c @@ -4,7 +4,7 @@ #include #include -#if __WIN32__ || __CYGWIN__ || MINGW32 +#if _WIN32 || __CYGWIN__ || MINGW32 #include #include #include "transport.h" diff --git a/shlr/wind/transport.c b/shlr/wind/transport.c index fa2d9c56e2..cc4c0b8f1b 100644 --- a/shlr/wind/transport.c +++ b/shlr/wind/transport.c @@ -6,7 +6,7 @@ extern io_backend_t iob_pipe; static io_backend_t *io_backends[] = { -//#if __WIN32__ || __CYGWIN__ || MINGW32 +//#if _WIN32 || __CYGWIN__ || MINGW32 //#warning TODO: add proper IO backend for windows here //#else &iob_pipe,