summaryrefslogtreecommitdiffstats
path: root/Utilities/cmlibrhash/librhash/util.h
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2016-11-03 17:45:29 (GMT)
committerBrad King <brad.king@kitware.com>2016-11-03 17:45:29 (GMT)
commit5cb1b345d932d3e0dc34a2d423894a59a6c8db35 (patch)
treee65b51405aeffee8b4ca00523fe450c76cf3aec0 /Utilities/cmlibrhash/librhash/util.h
parent798b0adc628ab16dbb4d04ef444b8e7db4f5cffa (diff)
parent1367fccc330b0ff314845aeb3547bbc38486913a (diff)
downloadCMake-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.h31
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 */