lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject lucy-clownfish git commit: Use GCC built-in for atomic compare-and-swap
Date Thu, 12 Feb 2015 16:22:23 GMT
Repository: lucy-clownfish
Updated Branches:
  refs/heads/master cf940884a -> 5055c1ae2


Use GCC built-in for atomic compare-and-swap


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/5055c1ae
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/5055c1ae
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/5055c1ae

Branch: refs/heads/master
Commit: 5055c1ae297a12d1430e2f1afcaa98794f0e93a1
Parents: cf94088
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Mon Feb 9 12:52:28 2015 +0100
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Mon Feb 9 12:52:28 2015 +0100

----------------------------------------------------------------------
 compiler/common/charmonizer.c          | 5 +++++
 compiler/common/charmonizer.main       | 5 +++++
 compiler/src/CFCBindCore.c             | 5 +++++
 runtime/core/Clownfish/Util/Atomic.cfh | 8 ++++++++
 4 files changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5055c1ae/compiler/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/compiler/common/charmonizer.c b/compiler/common/charmonizer.c
index 188c6db..47563a6 100644
--- a/compiler/common/charmonizer.c
+++ b/compiler/common/charmonizer.c
@@ -7820,6 +7820,11 @@ int main(int argc, const char **argv) {
         S_write_makefile(cli);
     }
 
+    if (chaz_HeadCheck_defines_symbol("__sync_bool_compare_and_swap", "")) {
+        chaz_ConfWriter_append_conf(
+            "#define CHY_HAS___SYNC_BOOL_COMPARE_AND_SWAP\n\n");
+    }
+
     /* Needed by cmark. */
     if (chaz_HeadCheck_defines_symbol("va_copy", "#include <stdarg.h>")) {
         chaz_ConfWriter_append_conf("#define CHY_HAS_VA_COPY\n\n");

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5055c1ae/compiler/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/compiler/common/charmonizer.main b/compiler/common/charmonizer.main
index 48774cd..74ff7b6 100644
--- a/compiler/common/charmonizer.main
+++ b/compiler/common/charmonizer.main
@@ -77,6 +77,11 @@ int main(int argc, const char **argv) {
         S_write_makefile(cli);
     }
 
+    if (chaz_HeadCheck_defines_symbol("__sync_bool_compare_and_swap", "")) {
+        chaz_ConfWriter_append_conf(
+            "#define CHY_HAS___SYNC_BOOL_COMPARE_AND_SWAP\n\n");
+    }
+
     /* Needed by cmark. */
     if (chaz_HeadCheck_defines_symbol("va_copy", "#include <stdarg.h>")) {
         chaz_ConfWriter_append_conf("#define CHY_HAS_VA_COPY\n\n");

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5055c1ae/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCBindCore.c b/compiler/src/CFCBindCore.c
index 2bf6119..490fb31 100644
--- a/compiler/src/CFCBindCore.c
+++ b/compiler/src/CFCBindCore.c
@@ -589,6 +589,11 @@ S_charmony_feature_defines() {
     defines = CFCUtil_cat(defines, "#define CFISH_HAS_OSATOMIC_CAS_PTR\n",
                           NULL);
 #endif
+#ifdef CHY_HAS___SYNC_BOOL_COMPARE_AND_SWAP
+    defines = CFCUtil_cat(defines,
+                          "#define CFISH_HAS___SYNC_BOOL_COMPARE_AND_SWAP\n",
+                          NULL);
+#endif
 
     return defines;
 }

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5055c1ae/runtime/core/Clownfish/Util/Atomic.cfh
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Util/Atomic.cfh b/runtime/core/Clownfish/Util/Atomic.cfh
index 7a950a7..8708438 100644
--- a/runtime/core/Clownfish/Util/Atomic.cfh
+++ b/runtime/core/Clownfish/Util/Atomic.cfh
@@ -73,6 +73,14 @@ cfish_Atomic_cas_ptr(void *volatile *target, void *old_value, void *new_value)
{
     return atomic_cas_ptr(target, old_value, new_value) == old_value;
 }
 
+/****************************** GCC 4.1 and later *************************/
+#elif defined(CFISH_HAS___SYNC_BOOL_COMPARE_AND_SWAP)
+
+static CFISH_INLINE bool
+cfish_Atomic_cas_ptr(void *volatile *target, void *old_value, void *new_value) {
+    return __sync_bool_compare_and_swap(target, old_value, new_value);
+}
+
 /************************ Fall back to pthread.h. **************************/
 #elif defined(CFISH_HAS_PTHREAD_H)
 #include <pthread.h>


Mime
View raw message