commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r826025 - in /commons/sandbox/runtime/trunk/src/main/native: Makefile.in configure os/darwin/arch_i386.S os/darwin/arch_x86_64.S os/darwin/atomics.c os/linux/arch_i386.S os/linux/arch_x86_64.S os/linux/atomics.c test/testcase.c
Date Fri, 16 Oct 2009 18:21:16 GMT
Author: mturk
Date: Fri Oct 16 18:21:16 2009
New Revision: 826025

URL: http://svn.apache.org/viewvc?rev=826025&view=rev
Log:
use assembly atomics

Added:
    commons/sandbox/runtime/trunk/src/main/native/os/darwin/arch_i386.S
    commons/sandbox/runtime/trunk/src/main/native/os/darwin/arch_x86_64.S
    commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_i386.S
    commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_x86_64.S
Removed:
    commons/sandbox/runtime/trunk/src/main/native/os/darwin/atomics.c
    commons/sandbox/runtime/trunk/src/main/native/os/linux/atomics.c
Modified:
    commons/sandbox/runtime/trunk/src/main/native/Makefile.in
    commons/sandbox/runtime/trunk/src/main/native/configure
    commons/sandbox/runtime/trunk/src/main/native/test/testcase.c

Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.in
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.in?rev=826025&r1=826024&r2=826025&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.in Fri Oct 16 18:21:16 2009
@@ -35,6 +35,7 @@
 AS=@as@
 AR=@ar@
 ARFLAGS=@arflags@
+ASFLAGS=@asflags@
 RANLIB=@ranlib@
 PREFIX=@prefix@
 LIBDIR=@libdir@
@@ -140,7 +141,7 @@
 	$(SRCDIR)/os/unix/time.$(OBJ) \
 	$(SRCDIR)/os/unix/uuid.$(OBJ) \
 	$(SRCDIR)/os/unix/uutils.$(OBJ) \
-	$(SRCDIR)/os/linux/atomics.$(OBJ) \
+	$(SRCDIR)/os/linux/arch_$(MACH).$(OBJ) \
 	$(SRCDIR)/os/linux/cpu.$(OBJ) \
 	$(SRCDIR)/os/linux/env.$(OBJ) \
 	$(SRCDIR)/os/linux/execmem.$(OBJ) \
@@ -209,7 +210,7 @@
 	$(SRCDIR)/os/unix/time.$(OBJ) \
 	$(SRCDIR)/os/unix/uuid.$(OBJ) \
 	$(SRCDIR)/os/unix/uutils.$(OBJ) \
-	$(SRCDIR)/os/darwin/atomics.$(OBJ) \
+	$(SRCDIR)/os/darwin/arch_$(MACH).$(OBJ) \
 	$(SRCDIR)/os/darwin/cpu.$(OBJ) \
 	$(SRCDIR)/os/darwin/env.$(OBJ) \
 	$(SRCDIR)/os/darwin/platform.$(OBJ) \
@@ -243,7 +244,7 @@
 	$(SRCDIR)/os/unix/time.$(OBJ) \
 	$(SRCDIR)/os/unix/uuid.$(OBJ) \
 	$(SRCDIR)/os/unix/uutils.$(OBJ) \
-	$(SRCDIR)/os/hpux/atomics.$(OBJ) \
+	$(SRCDIR)/os/hpux/arch_$(MACH).$(OBJ) \
 	$(SRCDIR)/os/hpux/cpu.$(OBJ) \
 	$(SRCDIR)/os/hpux/env.$(OBJ) \
 	$(SRCDIR)/os/hpux/group.$(OBJ) \
@@ -310,6 +311,9 @@
 .c.$(OBJ):
 	$(CC) $(CFLAGS) $(CPPFLAGS) $(INCLUDES) -c -o $@ $<
 
+.S.$(OBJ):
+	$(AS) $(ASFLAGS) -o $@ $<
+
 .cpp.$(OBJ):
 	$(CXX) $(CFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDES) -c -o $@ $<
 

Modified: commons/sandbox/runtime/trunk/src/main/native/configure
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/configure?rev=826025&r1=826024&r2=826025&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/configure (original)
+++ commons/sandbox/runtime/trunk/src/main/native/configure Fri Oct 16 18:21:16 2009
@@ -62,7 +62,7 @@
 cxx="${CXX:=g++}"
 ar="${AR:=ar}"
 link=""
-as="${AS:=gcc}"
+as="${AS:=as}"
 arflags="${ARFLAGS:=ru}"
 ranlib="${RANLIB:=ranlib}"
 topdir="${TOPDIR:=`dirname $0`}"
@@ -382,8 +382,12 @@
 esac
 
 case "$mach" in
-    amd64    )
-        mach=x86_64
+    amd64|x86_64 )
+        test ".$has_64_bit" = .yes && mach=x86_64
+        test ".$has_32_bit" = .yes && mach=i386
+    ;;
+    ia64         )
+        test ".$has_32_bit" = .yes && mach=i386
     ;;
     i[3-7]86 )
         mach=i386
@@ -462,8 +466,10 @@
         r="`uname -r | sed 's/5.//'`"
         if [ ".$mach" = .sparc ]; then
             varadds ccflags -xarch=sparc
+            varadds asflags -xarch=sparc
         else
             varadds ccflags -fast -xbuiltin=none -U__MATHERR_ERRNO_DONTCARE -xnolibmopt -xnolibmil
+            test ".$bits" = .64 && varadds asflags -xarch=amd64
         fi
         varadds cppopts -DSOLARIS2=$r
         if [ ".$has_native_threads" = .yes ]; then
@@ -487,6 +493,7 @@
         varadds ccflags -Ae +O2 -z +Z
         varadds ldflags -lrt -lpthread -ldld -lm
         varadds shflags +Z -b
+        varadds asflags +Z
         test ".$mach" = .parisc && so=.sl
         test ".$java_pinc" = . && java_pinc=hp-ux
         ;;
@@ -560,6 +567,7 @@
         if [ ".$mach" = .parisc64 ]; then
             varadds ccflags +DA2.0W
             varadds exflags +DA2.0W
+            varadds asflags +DA2.0W
         fi
         ;;
     hpux32-cc    )
@@ -599,6 +607,14 @@
         ;;
 esac
 
+case "$host$bits-$cc" in
+    *64-gcc )
+        varadds asflags --64
+    ;;
+    *32-gcc )
+        varadds asflags --32
+    ;;
+esac
 $EECHO "Configuring \033[1mApache Commons Runtime $vmajor.$vminor.$vpatch\033[0m. for $host$bits-$cc"
 echo ""
 

Added: commons/sandbox/runtime/trunk/src/main/native/os/darwin/arch_i386.S
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/arch_i386.S?rev=826025&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/darwin/arch_i386.S (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/arch_i386.S Fri Oct 16 18:21:16
2009
@@ -0,0 +1,69 @@
+/* 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.
+ */
+
+    .text
+    .align 8
+
+/* Atomic Add32
+ */
+    .globl ACR_AtomicAdd32
+    .type  ACR_AtomicAdd32, @function
+ACR_AtomicAdd32:
+    movl        4(%esp), %ecx
+    movl        8(%esp), %eax
+    movl           %eax, %edx
+
+    lock                           /* ; lock the bus                        */
+    xaddl          %eax, (%ecx)    /* ; tmp = *dst                          */
+                                   /* ; dst += inc                          */
+                                   /* ; %eax = tmp                          */
+
+    addl           %edx, %eax      /* ; return %eax + inc                   */
+    ret
+
+/* Atomic Inc32
+ */
+    .globl ACR_AtomicInc32
+    .type  ACR_AtomicInc32, @function
+ACR_AtomicInc32:
+    movl        4(%esp), %ecx
+    movl           $1,   %eax      /* ; %edx = 1                            */
+    movl           %eax, %edx      /* ;                                     */
+
+    lock
+    xaddl          %eax, (%ecx)    /* ; tmp = *dst                          */
+                                   /* ; dst += 1                            */
+                                   /* ; %eax = tmp                          */
+
+    incl            %eax
+    ret
+
+/* Atomic Dec32
+ */
+    .globl acr_AtomicDec32
+    .type  acr_AtomicDec32, @function
+ACR_AtomicDec32:
+    movl        4(%esp), %ecx
+    movl           $-1,  %eax      /* ; %edx = -1                           */
+    movl           %eax, %edx      /* ;                                     */
+
+    lock
+    xaddl          %eax, (%ecx)    /* ; tmp = *dst                          */
+                                   /* ; dst -= 1                            */
+                                   /* ; %eax = tmp                          */
+
+    decl            %eax
+    ret

Added: commons/sandbox/runtime/trunk/src/main/native/os/darwin/arch_x86_64.S
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/arch_x86_64.S?rev=826025&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/darwin/arch_x86_64.S (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/arch_x86_64.S Fri Oct 16 18:21:16
2009
@@ -0,0 +1,69 @@
+/* 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.
+ */
+
+    .text
+    .align 16
+
+/* Atomic Add32
+ */
+    .globl ACR_AtomicAdd32
+    .type  ACR_AtomicAdd32, @function
+ACR_AtomicAdd32:
+    movq           %rdi, %rcx      /* ; %rcx = dst                          */
+    movl           %esi, %edx      /* ; %edx = inc                          */
+    movl           %edx, %eax      /* ;                                     */
+
+    lock                           /* ; lock the bus                        */
+    xaddl          %eax, (%rcx)    /* ; tmp = *dst                          */
+                                   /* ; dst += inc                          */
+                                   /* ; %eax = tmp                          */
+
+    addl           %edx, %eax      /* ; return %eax + inc                   */
+    ret
+
+/* Atomic Inc32
+ */
+    .globl ACR_AtomicInc32
+    .type  ACR_AtomicInc32, @function
+ACR_AtomicInc32:
+    movq           %rdi, %rcx      /* ; %rcx = dst                          */
+    movl           $1,   %edx      /* ; %edx = 1                            */
+    movl           %edx, %eax      /* ;                                     */
+
+    lock
+    xaddl          %eax, (%rcx)    /* ; tmp = *dst                          */
+                                   /* ; dst += 1                            */
+                                   /* ; %eax = tmp                          */
+
+    incl            %eax
+    ret
+
+/* Atomic Dec32
+ */
+    .globl acr_AtomicDec32
+    .type  acr_AtomicDec32, @function
+ACR_AtomicDec32:
+    movq           %rdi, %rcx      /* ; %rcx = dst                          */
+    movl           $-1,   %edx     /* ; %edx = -1                           */
+    movl           %edx, %eax      /* ;                                     */
+
+    lock
+    xaddl          %eax, (%rcx)    /* ; tmp = *dst                          */
+                                   /* ; dst -= 1                            */
+                                   /* ; %eax = tmp                          */
+
+    decl            %eax
+    ret

Added: commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_i386.S
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_i386.S?rev=826025&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_i386.S (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_i386.S Fri Oct 16 18:21:16
2009
@@ -0,0 +1,69 @@
+/* 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.
+ */
+
+    .text
+    .align 8
+
+/* Atomic Add32
+ */
+    .globl ACR_AtomicAdd32
+    .type  ACR_AtomicAdd32, @function
+ACR_AtomicAdd32:
+    movl        4(%esp), %ecx
+    movl        8(%esp), %eax
+    movl           %eax, %edx
+
+    lock                           /* ; lock the bus                        */
+    xaddl          %eax, (%ecx)    /* ; tmp = *dst                          */
+                                   /* ; dst += inc                          */
+                                   /* ; %eax = tmp                          */
+
+    addl           %edx, %eax      /* ; return %eax + inc                   */
+    ret
+
+/* Atomic Inc32
+ */
+    .globl ACR_AtomicInc32
+    .type  ACR_AtomicInc32, @function
+ACR_AtomicInc32:
+    movl        4(%esp), %ecx
+    movl           $1,   %eax      /* ; %edx = 1                            */
+    movl           %eax, %edx      /* ;                                     */
+
+    lock
+    xaddl          %eax, (%ecx)    /* ; tmp = *dst                          */
+                                   /* ; dst += 1                            */
+                                   /* ; %eax = tmp                          */
+
+    incl            %eax
+    ret
+
+/* Atomic Dec32
+ */
+    .globl acr_AtomicDec32
+    .type  acr_AtomicDec32, @function
+ACR_AtomicDec32:
+    movl        4(%esp), %ecx
+    movl           $-1,  %eax      /* ; %edx = -1                           */
+    movl           %eax, %edx      /* ;                                     */
+
+    lock
+    xaddl          %eax, (%ecx)    /* ; tmp = *dst                          */
+                                   /* ; dst -= 1                            */
+                                   /* ; %eax = tmp                          */
+
+    decl            %eax
+    ret

Added: commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_x86_64.S
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_x86_64.S?rev=826025&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_x86_64.S (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_x86_64.S Fri Oct 16 18:21:16
2009
@@ -0,0 +1,69 @@
+/* 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.
+ */
+
+    .text
+    .align 16
+
+/* Atomic Add32
+ */
+    .globl ACR_AtomicAdd32
+    .type  ACR_AtomicAdd32, @function
+ACR_AtomicAdd32:
+    movq           %rdi, %rcx      /* ; %rcx = dst                          */
+    movl           %esi, %edx      /* ; %edx = inc                          */
+    movl           %edx, %eax      /* ;                                     */
+
+    lock                           /* ; lock the bus                        */
+    xaddl          %eax, (%rcx)    /* ; tmp = *dst                          */
+                                   /* ; dst += inc                          */
+                                   /* ; %eax = tmp                          */
+
+    addl           %edx, %eax      /* ; return %eax + inc                   */
+    ret
+
+/* Atomic Inc32
+ */
+    .globl ACR_AtomicInc32
+    .type  ACR_AtomicInc32, @function
+ACR_AtomicInc32:
+    movq           %rdi, %rcx      /* ; %rcx = dst                          */
+    movl           $1,   %edx      /* ; %edx = 1                            */
+    movl           %edx, %eax      /* ;                                     */
+
+    lock
+    xaddl          %eax, (%rcx)    /* ; tmp = *dst                          */
+                                   /* ; dst += 1                            */
+                                   /* ; %eax = tmp                          */
+
+    incl            %eax
+    ret
+
+/* Atomic Dec32
+ */
+    .globl acr_AtomicDec32
+    .type  acr_AtomicDec32, @function
+ACR_AtomicDec32:
+    movq           %rdi, %rcx      /* ; %rcx = dst                          */
+    movl           $-1,   %edx     /* ; %edx = -1                           */
+    movl           %edx, %eax      /* ;                                     */
+
+    lock
+    xaddl          %eax, (%rcx)    /* ; tmp = *dst                          */
+                                   /* ; dst -= 1                            */
+                                   /* ; %eax = tmp                          */
+
+    decl            %eax
+    ret

Modified: commons/sandbox/runtime/trunk/src/main/native/test/testcase.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/test/testcase.c?rev=826025&r1=826024&r2=826025&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/test/testcase.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/test/testcase.c Fri Oct 16 18:21:16 2009
@@ -34,6 +34,7 @@
 #include "acr_callback.h"
 #include "acr_observer.h"
 #include "acr_system.h"
+#include "acr_atomics.h"
 
 #if defined (WIN32)
 #include <io.h>
@@ -691,26 +692,15 @@
     return r;
 }
 
-#if defined(SOLARIS2)
-#include <atomic.h>
-#endif
 
-static volatile unsigned int  dtf_counter = 0;
-static volatile unsigned int *dtf_called  = &dtf_counter;
+static acr_atomic32_t  dtf_counter = 0;
+static acr_atomic32_t *dtf_called  = &dtf_counter;
 static int dtf_cleanup(void *d, int type, unsigned int flags)
 {
     x_free(d);
     /* This should be atomic counter
      */
-#if defined(__GNUC__)
-    __sync_fetch_and_add(dtf_called, 1);
-#elif defined(_MSC_VER)
-    InterlockedIncrement(dtf_called);
-#elif defined(SOLARIS2)
-    atomic_inc_32(dtf_called);
-#else
-    *dtf_called += 1;
-#endif
+    ACR_AtomicInc32(&dtf_counter);
     return 0;
 }
 
@@ -729,6 +719,8 @@
 ACR_JNI_EXPORT_DECLARE(int, TestPrivate, test054)(ACR_JNISTDARGS, jint d)
 {
     acr_ioh_dump_stats();
+    fprintf(stdout, "DTF counter %d\n", dtf_counter);
+    fflush(stdout);
     return dtf_counter;
 }
 



Mime
View raw message