commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r826207 - in /commons/sandbox/runtime/trunk/src/main/native: ./ os/darwin/ os/hpux/ os/linux/
Date Sat, 17 Oct 2009 09:38:15 GMT
Author: mturk
Date: Sat Oct 17 09:38:14 2009
New Revision: 826207

URL: http://svn.apache.org/viewvc?rev=826207&view=rev
Log:
Use only atomic add32 in asembler

Added:
    commons/sandbox/runtime/trunk/src/main/native/os/darwin/arch_ppc.S
    commons/sandbox/runtime/trunk/src/main/native/os/darwin/arch_ppc64.S
    commons/sandbox/runtime/trunk/src/main/native/os/darwin/atomics.c   (with props)
    commons/sandbox/runtime/trunk/src/main/native/os/hpux/arch_ia32.S
    commons/sandbox/runtime/trunk/src/main/native/os/hpux/arch_ia64.S
    commons/sandbox/runtime/trunk/src/main/native/os/hpux/arch_parisc.S
    commons/sandbox/runtime/trunk/src/main/native/os/hpux/arch_parisc64.S
    commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_ia32.S
    commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_ia64.S
    commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_ppc.S
    commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_ppc64.S
    commons/sandbox/runtime/trunk/src/main/native/os/linux/atomics.c   (with props)
Modified:
    commons/sandbox/runtime/trunk/src/main/native/Makefile.in
    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/hpux/atomics.c
    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

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=826207&r1=826206&r2=826207&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.in Sat Oct 17 09:38:14 2009
@@ -141,6 +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) \
@@ -210,6 +211,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) \
@@ -244,6 +246,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) \

Modified: 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=826207&r1=826206&r2=826207&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/darwin/arch_i386.S (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/arch_i386.S Sat Oct 17 09:38:14
2009
@@ -17,10 +17,11 @@
     .text
     .align 4
 
-/* Atomic Add32
+/*
+ * extern acr_uint32_t acr_AtomicAdd32(acr_atomic32_t *, acr_uint32_t)
  */
-    .globl _ACR_AtomicAdd32
-_ACR_AtomicAdd32:
+    .globl _acr_AtomicAdd32
+_acr_AtomicAdd32:
     movl        4(%esp), %ecx
     movl        8(%esp), %eax
     movl           %eax, %edx
@@ -32,35 +33,3 @@
 
     addl           %edx, %eax      /* ; return %eax + inc                   */
     ret
-
-/* Atomic Inc32
- */
-    .globl _ACR_AtomicInc32
-_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
-_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_ppc.S
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/arch_ppc.S?rev=826207&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/darwin/arch_ppc.S (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/arch_ppc.S Sat Oct 17 09:38:14
2009
@@ -0,0 +1,30 @@
+/* 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 4
+
+/*
+ * extern acr_uint32_t acr_AtomicAdd32(acr_atomic32_t *, acr_uint32_t);
+ */
+
+/*
+ * extern acr_uint32_t acr_AtomicInc32(acr_atomic32_t *);
+ */
+
+/*
+ * extern acr_uint32_t acr_AtomicDec32(acr_atomic32_t *);
+ */

Added: commons/sandbox/runtime/trunk/src/main/native/os/darwin/arch_ppc64.S
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/arch_ppc64.S?rev=826207&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/darwin/arch_ppc64.S (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/arch_ppc64.S Sat Oct 17 09:38:14
2009
@@ -0,0 +1,22 @@
+/* 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 4
+
+/*
+ * extern acr_uint32_t acr_AtomicAdd32(acr_atomic32_t *, acr_uint32_t);
+ */

Modified: 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=826207&r1=826206&r2=826207&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/darwin/arch_x86_64.S (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/arch_x86_64.S Sat Oct 17 09:38:14
2009
@@ -17,10 +17,11 @@
     .text
     .align 4
 
-/* Atomic Add32
+/*
+ * extern acr_uint32_t acr_AtomicAdd32(acr_atomic32_t *, acr_uint32_t)
  */
-    .globl _ACR_AtomicAdd32
-_ACR_AtomicAdd32:
+    .globl _acr_AtomicAdd32
+_acr_AtomicAdd32:
     movq           %rdi, %rcx      /* ; %rcx = dst                          */
     movl           %esi, %edx      /* ; %edx = inc                          */
     movl           %edx, %eax      /* ;                                     */
@@ -32,35 +33,3 @@
 
     addl           %edx, %eax      /* ; return %eax + inc                   */
     ret
-
-/* Atomic Inc32
- */
-    .globl _ACR_AtomicInc32
-_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
-_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/darwin/atomics.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/atomics.c?rev=826207&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/darwin/atomics.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/atomics.c Sat Oct 17 09:38:14
2009
@@ -0,0 +1,65 @@
+/* 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.
+ */
+
+#include "acr.h"
+#include "acr_private.h"
+#include "acr_arch.h"
+#include "acr_atomics.h"
+
+#if defined(USE_ATOMICS_BUILTINS)
+/* Use GCC builtin atomics
+ */
+
+ACR_DECLARE(acr_uint32_t) ACR_AtomicAdd32(acr_atomic32_t *mem,
+                                          acr_uint32_t val)
+{
+    return __sync_fetch_and_add(mem, val);
+}
+
+ACR_DECLARE(acr_uint32_t) ACR_AtomicInc32(acr_atomic32_t *mem)
+{
+    return __sync_fetch_and_add(mem, 1);
+}
+
+ACR_DECLARE(int) ACR_AtomicDec32(acr_atomic32_t *mem)
+{
+    return __sync_sub_and_fetch(mem, 1);
+}
+
+#else
+
+extern acr_uint32_t acr_AtomicAdd32(acr_atomic32_t *, acr_uint32_t);
+
+extern acr_uint32_t acr_AtomicAdd32(acr_atomic32_t *, acr_uint32_t);
+
+ACR_DECLARE(acr_uint32_t) ACR_AtomicAdd32(acr_atomic32_t *mem,
+                                          acr_uint32_t val)
+{
+    return acr_AtomicAdd32(mem, val);
+}
+
+ACR_DECLARE(acr_uint32_t) ACR_AtomicInc32(acr_atomic32_t *mem)
+{
+    return acr_AtomicAdd32(mem,  1);
+}
+
+ACR_DECLARE(int) ACR_AtomicDec32(acr_atomic32_t *mem)
+{
+    return acr_AtomicAdd32(mem, -1);
+}
+
+#endif
+

Propchange: commons/sandbox/runtime/trunk/src/main/native/os/darwin/atomics.c
------------------------------------------------------------------------------
    svn:eol-style = native

Added: commons/sandbox/runtime/trunk/src/main/native/os/hpux/arch_ia32.S
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/hpux/arch_ia32.S?rev=826207&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/hpux/arch_ia32.S (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/hpux/arch_ia32.S Sat Oct 17 09:38:14
2009
@@ -0,0 +1,51 @@
+/* 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
+    .psr abi32
+    .psr msb
+
+
+/*
+ * extern acr_uint32_t acr_AtomicAdd32(acr_atomic32_t *, acr_uint32_t);
+ */
+    .global acr_AtomicAdd32
+    .proc   acr_AtomicAdd32
+acr_AtomicAdd32:
+
+    .prologue
+    .body
+    mf
+    addp4 r9 = 0, r32 // Needed to be able to dereference a 32 bit pointer
+    ;;
+    ld4.acq r15 = [r9]
+    nop 0
+    ;;
+.add32_busywait:
+    mov ar.ccv = r15
+    add r8 = r15, r33
+    mov r2 = r15
+    ;;
+    nop 0
+    cmpxchg4.acq r15 = [r9], r8, ar.ccv
+    nop 0
+    ;;
+    cmp4.ne p8, p9 = r2, r15
+    (p9) br.ret.dpnt.many rp
+    br .add32_busywait
+
+    .endp acr_AtomicAdd32
+

Added: commons/sandbox/runtime/trunk/src/main/native/os/hpux/arch_ia64.S
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/hpux/arch_ia64.S?rev=826207&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/hpux/arch_ia64.S (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/hpux/arch_ia64.S Sat Oct 17 09:38:14
2009
@@ -0,0 +1,48 @@
+/* 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
+
+/*
+ * extern acr_uint32_t acr_AtomicAdd32(acr_atomic32_t *, acr_uint32_t);
+ */
+
+    .global _acr_AtomicAdd32
+    .proc   acr_AtomicAdd32
+acr_AtomicAdd32:
+
+    .prologue
+    .body
+    mf
+    ld4.acq r15 = [r32]
+    nop 0
+    ;;
+.add32_busywait:
+    mov ar.ccv = r15
+    add r8 = r15, r33
+    mov r2 = r15
+    ;;
+    nop 0
+    cmpxchg4.acq r15 = [r32], r8, ar.ccv
+    nop 0
+    ;;
+    cmp4.ne p8, p9 = r2, r15
+    (p9) br.ret.dpnt.many rp
+    br .add32_busywait
+
+    .endp acr_AtomicAdd32
+

Added: commons/sandbox/runtime/trunk/src/main/native/os/hpux/arch_parisc.S
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/hpux/arch_parisc.S?rev=826207&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/hpux/arch_parisc.S (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/hpux/arch_parisc.S Sat Oct 17 09:38:14
2009
@@ -0,0 +1,27 @@
+/* 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.
+ */
+
+/*
+ * extern acr_uint32_t acr_AtomicAdd32(acr_atomic32_t *, acr_uint32_t);
+ */
+
+/*
+ * extern acr_uint32_t acr_AtomicInc32(acr_atomic32_t *);
+ */
+
+/*
+ * extern acr_uint32_t acr_AtomicDec32(acr_atomic32_t *);
+ */

Added: commons/sandbox/runtime/trunk/src/main/native/os/hpux/arch_parisc64.S
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/hpux/arch_parisc64.S?rev=826207&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/hpux/arch_parisc64.S (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/hpux/arch_parisc64.S Sat Oct 17 09:38:14
2009
@@ -0,0 +1,27 @@
+/* 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.
+ */
+
+/*
+ * extern acr_uint32_t acr_AtomicAdd32(acr_atomic32_t *, acr_uint32_t);
+ */
+
+/*
+ * extern acr_uint32_t acr_AtomicInc32(acr_atomic32_t *);
+ */
+
+/*
+ * extern acr_uint32_t acr_AtomicDec32(acr_atomic32_t *);
+ */

Modified: commons/sandbox/runtime/trunk/src/main/native/os/hpux/atomics.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/hpux/atomics.c?rev=826207&r1=826206&r2=826207&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/hpux/atomics.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/hpux/atomics.c Sat Oct 17 09:38:14 2009
@@ -18,21 +18,20 @@
 #include "acr_private.h"
 #include "acr_arch.h"
 
-/* TODO: Implementation
- */
+extern acr_uint32_t acr_AtomicAdd32(acr_atomic32_t *, acr_uint32_t);
+
 ACR_DECLARE(acr_uint32_t) ACR_AtomicAdd32(acr_atomic32_t *mem,
                                           acr_uint32_t val)
 {
-    *mem += val;
-    return *mem;
+    return acr_AtomicAdd32(mem, val);
 }
 
 ACR_DECLARE(acr_uint32_t) ACR_AtomicInc32(acr_atomic32_t *mem)
 {
-    return *mem++;
+    return acr_AtomicAdd32(mem,  1);
 }
 
 ACR_DECLARE(int) ACR_AtomicDec32(acr_atomic32_t *mem)
 {
-    return *mem--;
+    return acr_AtomicAdd32(mem, -1);
 }

Modified: 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=826207&r1=826206&r2=826207&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_i386.S (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_i386.S Sat Oct 17 09:38:14
2009
@@ -17,11 +17,12 @@
     .text
     .align 8
 
-/* Atomic Add32
+/*
+ * extern acr_uint32_t acr_AtomicAdd32(acr_atomic32_t *, acr_uint32_t)
  */
-    .globl ACR_AtomicAdd32
-    .type  ACR_AtomicAdd32, @function
-ACR_AtomicAdd32:
+    .globl acr_AtomicAdd32
+    .type  acr_AtomicAdd32, @function
+acr_AtomicAdd32:
     movl        4(%esp), %ecx
     movl        8(%esp), %eax
     movl           %eax, %edx
@@ -33,37 +34,3 @@
 
     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_ia32.S
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_ia32.S?rev=826207&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_ia32.S (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_ia32.S Sat Oct 17 09:38:14
2009
@@ -0,0 +1,51 @@
+/* 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
+    .psr abi32
+    .psr msb
+
+
+/*
+ * extern acr_uint32_t acr_AtomicAdd32(acr_atomic32_t *, acr_uint32_t);
+ */
+    .global acr_AtomicAdd32
+    .proc   acr_AtomicAdd32
+acr_AtomicAdd32:
+
+    .prologue
+    .body
+    mf
+    addp4 r9 = 0, r32 // Needed to be able to dereference a 32 bit pointer
+    ;;
+    ld4.acq r15 = [r9]
+    nop 0
+    ;;
+.add32_busywait:
+    mov ar.ccv = r15
+    add r8 = r15, r33
+    mov r2 = r15
+    ;;
+    nop 0
+    cmpxchg4.acq r15 = [r9], r8, ar.ccv
+    nop 0
+    ;;
+    cmp4.ne p8, p9 = r2, r15
+    (p9) br.ret.dpnt.many rp
+    br .add32_busywait
+
+    .endp acr_AtomicAdd32
+

Added: commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_ia64.S
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_ia64.S?rev=826207&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_ia64.S (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_ia64.S Sat Oct 17 09:38:14
2009
@@ -0,0 +1,48 @@
+/* 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
+
+/*
+ * extern acr_uint32_t acr_AtomicAdd32(acr_atomic32_t *, acr_uint32_t);
+ */
+
+    .global _acr_AtomicAdd32
+    .proc   acr_AtomicAdd32
+acr_AtomicAdd32:
+
+    .prologue
+    .body
+    mf
+    ld4.acq r15 = [r32]
+    nop 0
+    ;;
+.add32_busywait:
+    mov ar.ccv = r15
+    add r8 = r15, r33
+    mov r2 = r15
+    ;;
+    nop 0
+    cmpxchg4.acq r15 = [r32], r8, ar.ccv
+    nop 0
+    ;;
+    cmp4.ne p8, p9 = r2, r15
+    (p9) br.ret.dpnt.many rp
+    br .add32_busywait
+
+    .endp acr_AtomicAdd32
+

Added: commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_ppc.S
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_ppc.S?rev=826207&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_ppc.S (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_ppc.S Sat Oct 17 09:38:14
2009
@@ -0,0 +1,22 @@
+/* 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
+
+/*
+ * extern acr_uint32_t acr_AtomicAdd32(acr_atomic32_t *, acr_uint32_t);
+ */

Added: commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_ppc64.S
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_ppc64.S?rev=826207&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_ppc64.S (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_ppc64.S Sat Oct 17 09:38:14
2009
@@ -0,0 +1,22 @@
+/* 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
+
+/*
+ * extern acr_uint32_t acr_AtomicAdd32(acr_atomic32_t *, acr_uint32_t);
+ */

Modified: 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=826207&r1=826206&r2=826207&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_x86_64.S (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/linux/arch_x86_64.S Sat Oct 17 09:38:14
2009
@@ -17,11 +17,12 @@
     .text
     .align 16
 
-/* Atomic Add32
+/*
+ * extern acr_uint32_t acr_AtomicAdd32(acr_atomic32_t *, acr_uint32_t)
  */
-    .globl ACR_AtomicAdd32
-    .type  ACR_AtomicAdd32, @function
-ACR_AtomicAdd32:
+    .globl acr_AtomicAdd32
+    .type  acr_AtomicAdd32, @function
+acr_AtomicAdd32:
     movq           %rdi, %rcx      /* ; %rcx = dst                          */
     movl           %esi, %edx      /* ; %edx = inc                          */
     movl           %edx, %eax      /* ;                                     */
@@ -33,37 +34,3 @@
 
     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/atomics.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/linux/atomics.c?rev=826207&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/linux/atomics.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/os/linux/atomics.c Sat Oct 17 09:38:14 2009
@@ -0,0 +1,65 @@
+/* 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.
+ */
+
+#include "acr.h"
+#include "acr_private.h"
+#include "acr_arch.h"
+#include "acr_atomics.h"
+
+#if defined(USE_ATOMICS_BUILTINS)
+/* Use GCC builtin atomics
+ */
+
+ACR_DECLARE(acr_uint32_t) ACR_AtomicAdd32(acr_atomic32_t *mem,
+                                          acr_uint32_t val)
+{
+    return __sync_fetch_and_add(mem, val);
+}
+
+ACR_DECLARE(acr_uint32_t) ACR_AtomicInc32(acr_atomic32_t *mem)
+{
+    return __sync_fetch_and_add(mem, 1);
+}
+
+ACR_DECLARE(int) ACR_AtomicDec32(acr_atomic32_t *mem)
+{
+    return __sync_sub_and_fetch(mem, 1);
+}
+
+#else
+
+extern acr_uint32_t acr_AtomicAdd32(acr_atomic32_t *, acr_uint32_t);
+
+extern acr_uint32_t acr_AtomicAdd32(acr_atomic32_t *, acr_uint32_t);
+
+ACR_DECLARE(acr_uint32_t) ACR_AtomicAdd32(acr_atomic32_t *mem,
+                                          acr_uint32_t val)
+{
+    return acr_AtomicAdd32(mem, val);
+}
+
+ACR_DECLARE(acr_uint32_t) ACR_AtomicInc32(acr_atomic32_t *mem)
+{
+    return acr_AtomicAdd32(mem,  1);
+}
+
+ACR_DECLARE(int) ACR_AtomicDec32(acr_atomic32_t *mem)
+{
+    return acr_AtomicAdd32(mem, -1);
+}
+
+#endif
+

Propchange: commons/sandbox/runtime/trunk/src/main/native/os/linux/atomics.c
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message