diff options
author | Brad King <brad.king@kitware.com> | 2016-11-03 17:45:29 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-11-03 17:45:29 (GMT) |
commit | 5cb1b345d932d3e0dc34a2d423894a59a6c8db35 (patch) | |
tree | e65b51405aeffee8b4ca00523fe450c76cf3aec0 /Utilities/cmlibrhash/librhash/util.h | |
parent | 798b0adc628ab16dbb4d04ef444b8e7db4f5cffa (diff) | |
parent | 1367fccc330b0ff314845aeb3547bbc38486913a (diff) | |
download | CMake-5cb1b345d932d3e0dc34a2d423894a59a6c8db35.zip CMake-5cb1b345d932d3e0dc34a2d423894a59a6c8db35.tar.gz CMake-5cb1b345d932d3e0dc34a2d423894a59a6c8db35.tar.bz2 |
Merge branch 'upstream-librhash' into import-librhash
* upstream-librhash:
librhash 2016-11-01 (d839a1a8)
Diffstat (limited to 'Utilities/cmlibrhash/librhash/util.h')
-rw-r--r-- | Utilities/cmlibrhash/librhash/util.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Utilities/cmlibrhash/librhash/util.h b/Utilities/cmlibrhash/librhash/util.h new file mode 100644 index 0000000..9f37157 --- /dev/null +++ b/Utilities/cmlibrhash/librhash/util.h @@ -0,0 +1,31 @@ +/* util.h */ +#ifndef UTIL_H +#define UTIL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if (defined(__GNUC__) && __GNUC__ >= 4 && (__GNUC__ > 4 || __GNUC_MINOR__ >= 1) \ + && defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4)) \ + || (defined(__INTEL_COMPILER) && !defined(_WIN32)) +/* atomic operations are defined by ICC and GCC >= 4.1, but by the later one supposedly not for ARM */ +/* note: ICC on ia64 platform possibly require ia64intrin.h, need testing */ +# define atomic_compare_and_swap(ptr, oldval, newval) __sync_val_compare_and_swap(ptr, oldval, newval) +#elif defined(_MSC_VER) +# include <windows.h> +# define atomic_compare_and_swap(ptr, oldval, newval) InterlockedCompareExchange(ptr, newval, oldval) +#elif defined(__sun) +# include <atomic.h> +# define atomic_compare_and_swap(ptr, oldval, newval) atomic_cas_32(ptr, oldval, newval) +#else +/* pray that it will work */ +# define atomic_compare_and_swap(ptr, oldval, newval) { if(*(ptr) == (oldval)) *(ptr) = (newval); } +# define NO_ATOMIC_BUILTINS +#endif + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* UTIL_H */ |