[kaffe] CVS kaffe (dalibor): Merged in compare and swap from glibc for s390

Kaffe CVS cvs-commits at kaffe.org
Tue Jun 22 03:35:23 PDT 2004


PatchSet 4855 
Date: 2004/06/22 10:28:37
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Merged in compare and swap from glibc for s390

2004-06-21  Dalibor Topic  <robilad at kaffe.org>

        * config/s390/atomicity32.h,
        config/s390/atomicity64.h:
        New files, taken from glibc 2.3.2.

        * config/s390/common.h:
        Include atomicity file for the architecture.

        Reported by: Bastian Blank <waldi at debian.org>

Members: 
	ChangeLog:1.2422->1.2423 
	config/s390/atomicity32.h:INITIAL->1.1 
	config/s390/atomicity64.h:INITIAL->1.1 
	config/s390/common.h:1.3->1.4 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2422 kaffe/ChangeLog:1.2423
--- kaffe/ChangeLog:1.2422	Mon Jun 21 22:01:28 2004
+++ kaffe/ChangeLog	Tue Jun 22 10:28:37 2004
@@ -7,6 +7,17 @@
 
 2004-06-21  Dalibor Topic  <robilad at kaffe.org>
 
+        * config/s390/atomicity32.h,
+        config/s390/atomicity64.h:
+	New files, taken from glibc 2.3.2.
+
+        * config/s390/common.h:
+	Include atomicity file for the architecture.
+
+        Reported by: Bastian Blank <waldi at debian.org>
+
+2004-06-21  Dalibor Topic  <robilad at kaffe.org>
+
         * configure.ac:
 	Removed checks for winbase.h, winnt.h and
 	winsock.h.
===================================================================
Checking out kaffe/config/s390/atomicity32.h
RCS:  /home/cvs/kaffe/kaffe/config/s390/atomicity32.h,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/config/s390/atomicity32.h	Tue Jun 22 10:35:22 2004
@@ -0,0 +1,45 @@
+/* Low-level functions for atomic operations.  S390 version.
+   Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+   Contributed by Martin Schwidefsky (schwidefsky at de.ibm.com).
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _ATOMICITY_H
+#define _ATOMICITY_H	1
+
+#include <inttypes.h>
+
+static inline int
+__attribute__ ((unused))
+compare_and_swap (volatile long int *p, long int oldval, long int newval)
+{
+  int retval;
+
+  __asm__ __volatile__(
+        "  la   1,%1\n"
+        "  lr   0,%2\n"
+        "  cs   0,%3,0(1)\n"
+        "  ipm  %0\n"
+        "  srl  %0,28\n"
+        "0:"
+        : "=&r" (retval), "+m" (*p)
+        : "d" (oldval) , "d" (newval)
+        : "memory", "0", "1", "cc");
+  return !retval;
+}
+
+#endif /* atomicity.h */
===================================================================
Checking out kaffe/config/s390/atomicity64.h
RCS:  /home/cvs/kaffe/kaffe/config/s390/atomicity64.h,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/config/s390/atomicity64.h	Tue Jun 22 10:35:22 2004
@@ -0,0 +1,45 @@
+/* Low-level functions for atomic operations.  64 bit S/390 version.
+   Copyright (C) 2001 Free Software Foundation, Inc.
+   Contributed by Martin Schwidefsky (schwidefsky at de.ibm.com).
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _ATOMICITY_H
+#define _ATOMICITY_H	1
+
+#include <inttypes.h>
+
+static inline int
+__attribute__ ((unused))
+compare_and_swap (volatile long int *p, long int oldval, long int newval)
+{
+  int retval;
+
+  __asm__ __volatile__(
+        "  la   1,%1\n"
+        "  lgr  0,%2\n"
+        "  csg  0,%3,0(1)\n"
+        "  ipm  %0\n"
+        "  srl  %0,28\n"
+        "0:"
+        : "=&r" (retval), "+m" (*p)
+        : "d" (oldval) , "d" (newval)
+        : "memory", "0", "1", "cc");
+  return !retval;
+}
+
+#endif /* atomicity.h */
Index: kaffe/config/s390/common.h
diff -u kaffe/config/s390/common.h:1.3 kaffe/config/s390/common.h:1.4
--- kaffe/config/s390/common.h:1.3	Sat Dec 13 20:01:55 2003
+++ kaffe/config/s390/common.h	Tue Jun 22 10:28:40 2004
@@ -15,6 +15,12 @@
 #ifndef __s390_h
 #define __s390_h
 
+#if defined(__s390x__)
+#include "atomicity64.h"
+#else
+#include "atomicity32.h"
+#endif /* defined(__s390x__) */
+
 /* The s390 gcc port aligns to the appropriate boundary: 1->1, 2->2, 4->4,
    and 8->8.  So alignment is pretty simple: */
 #define  ALIGNMENT_OF_SIZE(S) (S)
@@ -46,25 +52,6 @@
  * value 'O' and if they match it's exchanged with value 'N'.
  * We return '1' if the exchange is sucessful, otherwise 0.
  */
-#define COMPARE_AND_EXCHANGE(A,O,N)                                     \
-   ({                                                                   \
-      char ret;                                                         \
-      asm volatile(" \n"						\
-"         # gcc will invoke us with *A in %1, O in %3 and N in %2 \n"	\
-"         cs %3,%2,0(%1) # compare O to A and exchange A and N if \n"	\
-"                        # equal, else load O from A \n"		\
-"         je 1f          # branch if equal \n"				\
-"         la %0,0        # compare did not match \n"			\
-"         j  2f          # skip  \n"					\
-"      1: la %0,1        # compare matched \n"				\
-"      2: \n"								\
-"         "                                                             \
-        : "=r&" (ret),                                 /* sets these */ \
-          "+r" (A)                                                      \
-        : "r" (N),                                     /* uses these */ \
-          "r" (O)                                                       \
-        : "cc" );                                  /* clobbers these */ \
-      (ret);                                                            \
-   })
+#define COMPARE_AND_EXCHANGE(A, O, N)  (compare_and_swap((long int*) A, (long int) O, (long int) N))
 
-#endif
+#endif /* __s390_h */




More information about the kaffe mailing list