From: Pablo Sanabria Date: Sat, 25 Mar 2017 22:18:29 +0000 (-0300) Subject: Fixed linkhash.c for MinGW X-Git-Tag: json-c-0.13-20171207~84^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F312%2Fhead;p=thirdparty%2Fjson-c.git Fixed linkhash.c for MinGW Added #ifdef conditions for MinGW because this compiler doesn't define gcc atomic builtins, so __sync_val_compare_and_swap was not found neither any of any __GCC_HAVE_SYNC_COMPARE_AND_SWAP_* definition --- diff --git a/linkhash.c b/linkhash.c index fd52fe34..830caa83 100644 --- a/linkhash.c +++ b/linkhash.c @@ -23,7 +23,7 @@ # include /* attempt to define endianness */ #endif -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__MINGW32__) # define WIN32_LEAN_AND_MEAN # include /* Get InterlockedCompareExchange */ #endif @@ -452,7 +452,7 @@ static unsigned long lh_perllike_str_hash(const void *k) static unsigned long lh_char_hash(const void *k) { -#if defined _MSC_VER +#if defined _MSC_VER || defined __MINGW32__ #define RANDOM_SEED_TYPE LONG #else #define RANDOM_SEED_TYPE int @@ -474,7 +474,7 @@ static unsigned long lh_char_hash(const void *k) #endif #if defined USE_SYNC_COMPARE_AND_SWAP (void)__sync_val_compare_and_swap(&random_seed, -1, seed); -#elif defined _MSC_VER +#elif defined _MSC_VER || defined __MINGW32__ InterlockedCompareExchange(&random_seed, seed, -1); #else #warning "racy random seed initializtion if used by multiple threads"