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
This commit is contained in:
@@ -23,7 +23,7 @@
|
|||||||
# include <endian.h> /* attempt to define endianness */
|
# include <endian.h> /* attempt to define endianness */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||||
# define WIN32_LEAN_AND_MEAN
|
# define WIN32_LEAN_AND_MEAN
|
||||||
# include <windows.h> /* Get InterlockedCompareExchange */
|
# include <windows.h> /* Get InterlockedCompareExchange */
|
||||||
#endif
|
#endif
|
||||||
@@ -452,7 +452,7 @@ static unsigned long lh_perllike_str_hash(const void *k)
|
|||||||
|
|
||||||
static unsigned long lh_char_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
|
#define RANDOM_SEED_TYPE LONG
|
||||||
#else
|
#else
|
||||||
#define RANDOM_SEED_TYPE int
|
#define RANDOM_SEED_TYPE int
|
||||||
@@ -474,7 +474,7 @@ static unsigned long lh_char_hash(const void *k)
|
|||||||
#endif
|
#endif
|
||||||
#if defined USE_SYNC_COMPARE_AND_SWAP
|
#if defined USE_SYNC_COMPARE_AND_SWAP
|
||||||
(void)__sync_val_compare_and_swap(&random_seed, -1, seed);
|
(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);
|
InterlockedCompareExchange(&random_seed, seed, -1);
|
||||||
#else
|
#else
|
||||||
#warning "racy random seed initializtion if used by multiple threads"
|
#warning "racy random seed initializtion if used by multiple threads"
|
||||||
|
|||||||
Reference in New Issue
Block a user