You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2011/06/25 17:23:51 UTC

svn commit: r1139553 - in /commons/sandbox/runtime/trunk/src/main/native: Makefile.unx.in configure include/acr/atomic.h os/linux/epoll.c os/solaris/atomic.c os/unix/arch_sync.h os/unix/atomic.c os/unix/pollset.c

Author: mturk
Date: Sat Jun 25 15:23:50 2011
New Revision: 1139553

URL: http://svn.apache.org/viewvc?rev=1139553&view=rev
Log:
Require gcc 4.1.0 and make all atomics inlines

Removed:
    commons/sandbox/runtime/trunk/src/main/native/include/acr/atomic.h
    commons/sandbox/runtime/trunk/src/main/native/os/solaris/atomic.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/atomic.c
Modified:
    commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in
    commons/sandbox/runtime/trunk/src/main/native/configure
    commons/sandbox/runtime/trunk/src/main/native/os/linux/epoll.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/arch_sync.h
    commons/sandbox/runtime/trunk/src/main/native/os/unix/pollset.c

Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in?rev=1139553&r1=1139552&r2=1139553&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.unx.in Sat Jun 25 15:23:50 2011
@@ -78,20 +78,16 @@ UNIX_SOURCES=\
 	$(TOPDIR)/os/unix/util.c
 
 BSDX_SOURCES=\
-	$(TOPDIR)/os/bsdx/os.c \
-	$(TOPDIR)/os/unix/atomic.c
+	$(TOPDIR)/os/bsdx/os.c
 DARWIN_SOURCES=\
-	$(TOPDIR)/os/darwin/os.c \
-	$(TOPDIR)/os/unix/atomic.c
+	$(TOPDIR)/os/darwin/os.c
 HPUX_SOURCES=\
 	$(TOPDIR)/os/hpux/os.c
 LINUX_SOURCES=\
 	$(TOPDIR)/os/linux/epoll.c \
 	$(TOPDIR)/os/linux/misc.c \
-	$(TOPDIR)/os/linux/os.c \
-	$(TOPDIR)/os/unix/atomic.c
+	$(TOPDIR)/os/linux/os.c
 SOLARIS_SOURCES=\
-	$(TOPDIR)/os/solaris/atomic.c \
 	$(TOPDIR)/os/solaris/os.c
 
 LIBSOURCES=\

Modified: commons/sandbox/runtime/trunk/src/main/native/configure
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/configure?rev=1139553&r1=1139552&r2=1139553&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/configure (original)
+++ commons/sandbox/runtime/trunk/src/main/native/configure Sat Jun 25 15:23:50 2011
@@ -675,11 +675,12 @@ case "$host-$cctype" in
             varadds ccflags -g
             varadds asflags -g
         fi
-        if [ ${cc_ver_major}${cc_ver_minor}0 -gt 400 ]; then
-            varadds cppopts -DUSE_GCC_ATOMIC_BUILTINS
-            varadds ccflags -fvisibility=hidden
+        if [ ${cc_ver_major}${cc_ver_minor}0 -lt 410 ]; then
+            echo "Error: Detected $cc version"
+            echo "       gcc >= 4.1.0 required"
+            exit 1
         fi
-        varadds ccflags -fstrict-aliasing
+        varadds ccflags -fvisibility=hidden -fstrict-aliasing
         if [ ".$has_zlib_asm" = .yes ]; then
             if [ ".$mach" = .i386 ]; then
                 varadds cppopts -DASMV

Modified: commons/sandbox/runtime/trunk/src/main/native/os/linux/epoll.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/linux/epoll.c?rev=1139553&r1=1139552&r2=1139553&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/linux/epoll.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/linux/epoll.c Sat Jun 25 15:23:50 2011
@@ -15,7 +15,6 @@
  */
 
 #include "acr/clazz.h"
-#include "acr/atomic.h"
 #include "acr/memory.h"
 #include "acr/jniapi.h"
 #include "acr/port.h"
@@ -24,6 +23,7 @@
 #include "acr/netapi.h"
 #include "acr/ring.h"
 #include "arch_opts.h"
+#include "arch_sync.h"
 #include <poll.h>
 #include <sys/epoll.h>
 

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/arch_sync.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/arch_sync.h?rev=1139553&r1=1139552&r2=1139553&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/arch_sync.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/arch_sync.h Sat Jun 25 15:23:50 2011
@@ -23,38 +23,23 @@
 #include <atomic.h>
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #if defined(__GNUC__)
 # if (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 1)
-#  define USE_ATOMICS_WRAPPER     0
-#  define USE_BUILTIN_ATOMICS     1
-# else
-#  define USE_ATOMICS_WRAPPER     0
-#  define USE_BUILTIN_ATOMICS     0
-# endif
-# define  _PR_COMPILER_FENCE()    __asm__ __volatile__("" : : : "memory")
-# if (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 1)
-#  define _PR_RWMEMORY_FENCE()   __sync_synchronize()
 # else
-#  if defined(_I386_) || defined(_X86_64_)
-#   define __mfence  "mfence"
-#  elif defined(_PPC_) || defined(_PPC_64_)
-#   define __mfence  "sync"
-#  else
-#   define __mfence  ""
-#  endif
-#  define _PR_RWMEMORY_FENCE()    __asm__ __volatile__(__mfence : : : "memory")
+#  error "gcc >= 4.1.0 required!" 
 # endif
-# if USE_BUILTIN_ATOMICS
 ACR_INLINE(void)  AcrCpuFence()
 {
-    _PR_COMPILER_FENCE();
+    __asm__ __volatile__("" : : : "memory");
 }
-
 ACR_INLINE(void)  AcrMemoryFence()
 {
-    _PR_RWMEMORY_FENCE();
+    __sync_synchronize();
 }
-
 ACR_INLINE(int) AcrAtomic32Inc(volatile acr_atomic32_t *val)
 {
     return (int)__sync_add_and_fetch(val, 1);
@@ -92,16 +77,60 @@ ACR_INLINE(int) AcrAtomic32Equ(volatile 
     return __sync_bool_compare_and_swap(val, num, num);
 }
 
-# endif
-#else
+#else /* !__GNUC__ */
 # if defined(_SOLARIS)
-#  define USE_BUILTIN_ATOMICS     1
-#  define USE_ATOMICS_WRAPPER     0
-#  define _PR_COMPILER_FENCE()    membar_consumer()
-#  define _PR_RWMEMORY_FENCE()    do { membar_producer(); membar_consumer(); } while (0)
+ACR_INLINE(void)  AcrCpuFence()
+{
+     membar_consumer();
+}
+
+ACR_INLINE(void)  AcrmemoryFence()
+{
+    membar_producer();
+    membar_consumer();
+}
+
+ACR_INLINE(int) AcrAtomic32Inc(volatile acr_atomic32_t *val)
+{
+    return (int)atomic_inc_32_nv(val);
+}
+
+ACR_INLINE(int) AcrAtomic32Dec(volatile acr_atomic32_t *val)
+{
+    return (int)atomic_dec_32_nv(val);
+}
+
+ACR_INLINE(int) AcrAtomic32Cas(volatile acr_atomic32_t *val, int cmp, int set)
+{
+    return (int)atomic_cas_32(val, (uint32_t)cmp, (uint32_t)set);
+}
+
+ACR_INLINE(void *) AcrAtomic32CasPtr(void * volatile *val, const void *cmp, void *set)
+{
+    return atomic_cas_ptr(val, (void *)cmp, set);
+}
+
+ACR_INLINE(int) AcrAtomic32Set(volatile acr_atomic32_t *val, int num)
+{
+    return (int)atomic_swap_32(val, (uint32_t)num);
+}
+
+ACR_INLINE(void *) AcrAtomic32SetPtr(void * volatile *val, void *set)
+{
+    return atomic_swap_ptr(val,  set);
+}
+
+ACR_INLINE(int) AcrAtomic32Equ(volatile acr_atomic32_t *val, int num)
+{
+    uint32_t cmp = num;
+    return atomic_cas_32(val, cmp, cmp) == cmp;
+}
 # else
 #  error "Atomic operations not implemented for this platform!"
 # endif
 #endif
 
+#ifdef __cplusplus
+}
+#endif
 #endif /* _ACR_ARCH_SYNC_H_ */

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/pollset.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/pollset.c?rev=1139553&r1=1139552&r2=1139553&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/pollset.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/pollset.c Sat Jun 25 15:23:50 2011
@@ -15,7 +15,6 @@
  */
 
 #include "acr/clazz.h"
-#include "acr/atomic.h"
 #include "acr/memory.h"
 #include "acr/jniapi.h"
 #include "acr/port.h"
@@ -23,6 +22,7 @@
 #include "acr/iodefs.h"
 #include "acr/netapi.h"
 #include "arch_opts.h"
+#include "arch_sync.h"
 #include <poll.h>
 
 /* pollset operation states */