You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2015/02/24 16:41:30 UTC

lucy-clownfish git commit: Make atomic utils private

Repository: lucy-clownfish
Updated Branches:
  refs/heads/private_atomic_utils [created] 38d547a57


Make atomic utils private


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

Branch: refs/heads/private_atomic_utils
Commit: 38d547a57b322ed39c44400bd660c53c1adbc092
Parents: 5646bf0
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Tue Feb 24 16:39:09 2015 +0100
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Tue Feb 24 16:41:03 2015 +0100

----------------------------------------------------------------------
 compiler/common/charmonizer.c            |   6 --
 compiler/common/charmonizer.main         |   6 --
 compiler/src/CFCBindCore.c               |  24 ++---
 runtime/common/charmonizer.c             |   5 ++
 runtime/common/charmonizer.main          |   5 ++
 runtime/core/Clownfish/Util/Atomic.cfh   | 117 ------------------------
 runtime/core/Clownfish/Util/Atomic.h     | 122 ++++++++++++++++++++++++++
 runtime/perl/buildlib/Clownfish/Build.pm |   2 +-
 8 files changed, 139 insertions(+), 148 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/38d547a5/compiler/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/compiler/common/charmonizer.c b/compiler/common/charmonizer.c
index 47563a6..5aeec1a 100644
--- a/compiler/common/charmonizer.c
+++ b/compiler/common/charmonizer.c
@@ -7806,7 +7806,6 @@ int main(int argc, const char **argv) {
     chaz_BuildEnv_run();
     chaz_DirManip_run();
     chaz_Headers_run();
-    chaz_AtomicOps_run();
     chaz_FuncMacro_run();
     chaz_Booleans_run();
     chaz_Integers_run();
@@ -7820,11 +7819,6 @@ 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/38d547a5/compiler/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/compiler/common/charmonizer.main b/compiler/common/charmonizer.main
index 74ff7b6..7ce7b14 100644
--- a/compiler/common/charmonizer.main
+++ b/compiler/common/charmonizer.main
@@ -63,7 +63,6 @@ int main(int argc, const char **argv) {
     chaz_BuildEnv_run();
     chaz_DirManip_run();
     chaz_Headers_run();
-    chaz_AtomicOps_run();
     chaz_FuncMacro_run();
     chaz_Booleans_run();
     chaz_Integers_run();
@@ -77,11 +76,6 @@ 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/38d547a5/compiler/src/CFCBindCore.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCBindCore.c b/compiler/src/CFCBindCore.c
index 5ad2ca2..0baf4f2 100644
--- a/compiler/src/CFCBindCore.c
+++ b/compiler/src/CFCBindCore.c
@@ -627,45 +627,33 @@ static char*
 S_charmony_feature_defines() {
     char *defines = CFCUtil_strdup("");
 
-#ifdef CHY_HAS_WINDOWS_H
-    defines = CFCUtil_cat(defines, "#define CFISH_HAS_WINDOWS_H\n", NULL);
-#endif
-#ifdef CHY_HAS_SYS_ATOMIC_H
-    defines = CFCUtil_cat(defines, "#define CFISH_HAS_SYS_ATOMIC_H\n", NULL);
-#endif
-#ifdef CHY_HAS_PTHREAD_H
-    defines = CFCUtil_cat(defines, "#define CFISH_HAS_PTHREAD_H\n", NULL);
-#endif
 #ifdef CHY_LITTLE_END
+    // Needed by NumberUtils.cfh.
     defines = CFCUtil_cat(defines, "#define CFISH_LITTLE_END\n", NULL);
 #endif
 #ifdef CHY_BIG_END
+    // Needed by NumberUtils.cfh.
     defines = CFCUtil_cat(defines, "#define CFISH_BIG_END\n", NULL);
 #endif
 #ifdef CHY_HAS_FUNC_MACRO
+    // Needed by Err.cfh.
     defines = CFCUtil_cat(defines, "#define CFISH_HAS_FUNC_MACRO\n", NULL);
 #endif
 #ifdef CHY_HAS_VARIADIC_MACROS
+    // Needed by Err.cfh.
     defines = CFCUtil_cat(defines, "#define CFISH_HAS_VARIADIC_MACROS\n",
                           NULL);
 #endif
 #ifdef CHY_HAS_ISO_VARIADIC_MACROS
+    // Needed by Err.cfh.
     defines = CFCUtil_cat(defines, "#define CFISH_HAS_ISO_VARIADIC_MACROS\n",
                           NULL);
 #endif
 #ifdef CHY_HAS_GNUC_VARIADIC_MACROS
+    // Needed by Err.cfh.
     defines = CFCUtil_cat(defines, "#define CFISH_HAS_GNUC_VARIADIC_MACROS\n",
                           NULL);
 #endif
-#ifdef CHY_HAS_OSATOMIC_CAS_PTR
-    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/38d547a5/runtime/common/charmonizer.c
----------------------------------------------------------------------
diff --git a/runtime/common/charmonizer.c b/runtime/common/charmonizer.c
index 08e5ed3..a4bcb4d 100644
--- a/runtime/common/charmonizer.c
+++ b/runtime/common/charmonizer.c
@@ -7877,6 +7877,10 @@ int main(int argc, const char **argv) {
     chaz_VariadicMacros_run();
 
     /* Write custom postamble. */
+    if (chaz_HeadCheck_defines_symbol("__sync_bool_compare_and_swap", "")) {
+        chaz_ConfWriter_append_conf(
+            "#define CHY_HAS___SYNC_BOOL_COMPARE_AND_SWAP\n\n");
+    }
     chaz_ConfWriter_append_conf(
         "#ifdef CHY_HAS_SYS_TYPES_H\n"
         "  #include <sys/types.h>\n"
@@ -8074,6 +8078,7 @@ cfish_MakeFile_write(cfish_MakeFile *self) {
     }
 
     chaz_CFlags_add_include_dir(makefile_cflags, ".");
+    chaz_CFlags_add_include_dir(makefile_cflags, self->core_dir);
     chaz_CFlags_add_include_dir(makefile_cflags, self->host_src_dir);
     chaz_CFlags_add_include_dir(makefile_cflags, self->autogen_inc_dir);
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/38d547a5/runtime/common/charmonizer.main
----------------------------------------------------------------------
diff --git a/runtime/common/charmonizer.main b/runtime/common/charmonizer.main
index 9ef16dc..4ae07ff 100644
--- a/runtime/common/charmonizer.main
+++ b/runtime/common/charmonizer.main
@@ -134,6 +134,10 @@ int main(int argc, const char **argv) {
     chaz_VariadicMacros_run();
 
     /* Write custom postamble. */
+    if (chaz_HeadCheck_defines_symbol("__sync_bool_compare_and_swap", "")) {
+        chaz_ConfWriter_append_conf(
+            "#define CHY_HAS___SYNC_BOOL_COMPARE_AND_SWAP\n\n");
+    }
     chaz_ConfWriter_append_conf(
         "#ifdef CHY_HAS_SYS_TYPES_H\n"
         "  #include <sys/types.h>\n"
@@ -331,6 +335,7 @@ cfish_MakeFile_write(cfish_MakeFile *self) {
     }
 
     chaz_CFlags_add_include_dir(makefile_cflags, ".");
+    chaz_CFlags_add_include_dir(makefile_cflags, self->core_dir);
     chaz_CFlags_add_include_dir(makefile_cflags, self->host_src_dir);
     chaz_CFlags_add_include_dir(makefile_cflags, self->autogen_inc_dir);
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/38d547a5/runtime/core/Clownfish/Util/Atomic.cfh
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Util/Atomic.cfh b/runtime/core/Clownfish/Util/Atomic.cfh
deleted file mode 100644
index 8708438..0000000
--- a/runtime/core/Clownfish/Util/Atomic.cfh
+++ /dev/null
@@ -1,117 +0,0 @@
-/* Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-parcel Clownfish;
-
-/** Provide atomic memory operations.
- */
-inert class Clownfish::Util::Atomic { }
-
-__C__
-
-/** Compare and swap a pointer.  Test whether the value at `target`
- * matches `old_value`.  If it does, set `target` to
- * `new_value` and return true.  Otherwise, return false.
- */
-static CFISH_INLINE bool
-cfish_Atomic_cas_ptr(void *volatile *target, void *old_value, void *new_value);
-
-/************************** Single threaded *******************************/
-#ifdef CFISH_NOTHREADS
-
-static CFISH_INLINE bool
-cfish_Atomic_cas_ptr(void *volatile *target, void *old_value, void *new_value) {
-    if (*target == old_value) {
-        *target = new_value;
-        return true;
-    }
-    else {
-        return false;
-    }
-}
-
-/************************** Mac OS X 10.4 and later ***********************/
-#elif defined(CFISH_HAS_OSATOMIC_CAS_PTR)
-#include <libkern/OSAtomic.h>
-
-static CFISH_INLINE bool
-cfish_Atomic_cas_ptr(void *volatile *target, void *old_value, void *new_value) {
-    return OSAtomicCompareAndSwapPtr(old_value, new_value, target);
-}
-
-/********************************** Windows *******************************/
-#elif defined(CFISH_HAS_WINDOWS_H)
-
-bool
-cfish_Atomic_wrapped_cas_ptr(void *volatile *target, void *old_value,
-                            void *new_value);
-
-static CFISH_INLINE bool
-cfish_Atomic_cas_ptr(void *volatile *target, void *old_value, void *new_value) {
-    return cfish_Atomic_wrapped_cas_ptr(target, old_value, new_value);
-}
-
-/**************************** Solaris 10 and later ************************/
-#elif defined(CFISH_HAS_SYS_ATOMIC_H)
-#include <sys/atomic.h>
-
-static CFISH_INLINE bool
-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>
-
-extern pthread_mutex_t cfish_Atomic_mutex;
-
-static CFISH_INLINE bool
-cfish_Atomic_cas_ptr(void *volatile *target, void *old_value, void *new_value) {
-    pthread_mutex_lock(&cfish_Atomic_mutex);
-    if (*target == old_value) {
-        *target = new_value;
-        pthread_mutex_unlock(&cfish_Atomic_mutex);
-        return true;
-    }
-    else {
-        pthread_mutex_unlock(&cfish_Atomic_mutex);
-        return false;
-    }
-}
-
-/******************** No support for atomics at all. ***********************/
-#else
-
-#error "No support for atomic operations."
-
-#endif /* Big platform if-else chain. */
-
-#ifdef CFISH_USE_SHORT_NAMES
-  #define Atomic_cas_ptr cfish_Atomic_cas_ptr
-#endif
-
-__END_C__
-
-

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/38d547a5/runtime/core/Clownfish/Util/Atomic.h
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Util/Atomic.h b/runtime/core/Clownfish/Util/Atomic.h
new file mode 100644
index 0000000..8b2f8e6
--- /dev/null
+++ b/runtime/core/Clownfish/Util/Atomic.h
@@ -0,0 +1,122 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef H_CLOWNFISH_UTIL_ATOMIC
+#define H_CLOWNFISH_UTIL_ATOMIC 1
+
+#include "charmony.h"
+#include "cfish_parcel.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Compare and swap a pointer.  Test whether the value at `target`
+ * matches `old_value`.  If it does, set `target` to
+ * `new_value` and return true.  Otherwise, return false.
+ */
+static CFISH_INLINE bool
+cfish_Atomic_cas_ptr(void *volatile *target, void *old_value, void *new_value);
+
+/************************** Single threaded *******************************/
+#ifdef CFISH_NOTHREADS
+
+static CFISH_INLINE bool
+cfish_Atomic_cas_ptr(void *volatile *target, void *old_value, void *new_value) {
+    if (*target == old_value) {
+        *target = new_value;
+        return true;
+    }
+    else {
+        return false;
+    }
+}
+
+/************************** Mac OS X 10.4 and later ***********************/
+#elif defined(CHY_HAS_OSATOMIC_CAS_PTR)
+#include <libkern/OSAtomic.h>
+
+static CFISH_INLINE bool
+cfish_Atomic_cas_ptr(void *volatile *target, void *old_value, void *new_value) {
+    return OSAtomicCompareAndSwapPtr(old_value, new_value, target);
+}
+
+/********************************** Windows *******************************/
+#elif defined(CHY_HAS_WINDOWS_H)
+
+bool
+cfish_Atomic_wrapped_cas_ptr(void *volatile *target, void *old_value,
+                            void *new_value);
+
+static CFISH_INLINE bool
+cfish_Atomic_cas_ptr(void *volatile *target, void *old_value, void *new_value) {
+    return cfish_Atomic_wrapped_cas_ptr(target, old_value, new_value);
+}
+
+/**************************** Solaris 10 and later ************************/
+#elif defined(CHY_HAS_SYS_ATOMIC_H)
+#include <sys/atomic.h>
+
+static CFISH_INLINE bool
+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(CHY_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(CHY_HAS_PTHREAD_H)
+#include <pthread.h>
+
+extern pthread_mutex_t cfish_Atomic_mutex;
+
+static CFISH_INLINE bool
+cfish_Atomic_cas_ptr(void *volatile *target, void *old_value, void *new_value) {
+    pthread_mutex_lock(&cfish_Atomic_mutex);
+    if (*target == old_value) {
+        *target = new_value;
+        pthread_mutex_unlock(&cfish_Atomic_mutex);
+        return true;
+    }
+    else {
+        pthread_mutex_unlock(&cfish_Atomic_mutex);
+        return false;
+    }
+}
+
+/******************** No support for atomics at all. ***********************/
+#else
+
+#error "No support for atomic operations."
+
+#endif /* Big platform if-else chain. */
+
+#ifdef CFISH_USE_SHORT_NAMES
+  #define Atomic_cas_ptr cfish_Atomic_cas_ptr
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* H_CLOWNFISH_UTIL_ATOMIC */
+

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/38d547a5/runtime/perl/buildlib/Clownfish/Build.pm
----------------------------------------------------------------------
diff --git a/runtime/perl/buildlib/Clownfish/Build.pm b/runtime/perl/buildlib/Clownfish/Build.pm
index b0743e2..a4d52c5 100644
--- a/runtime/perl/buildlib/Clownfish/Build.pm
+++ b/runtime/perl/buildlib/Clownfish/Build.pm
@@ -61,7 +61,7 @@ else {
 
 sub new {
     my ( $class, %args ) = @_;
-    $args{include_dirs}     = $XS_SOURCE_DIR;
+    $args{include_dirs}     = [ $CORE_SOURCE_DIR, $XS_SOURCE_DIR ];
     $args{clownfish_params} = {
         autogen_header => _autogen_header(),
         include        => [],                  # Don't use default includes.