[kaffe] CVS kaffe (dalibor): Switched alpha over to use glibc atomicity functions

Kaffe CVS Kaffe Mailing List <kaffe@kaffe.org>
Wed Mar 24 03:36:04 2004


PatchSet 4564 
Date: 2004/03/24 11:06:09
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Switched alpha over to use glibc atomicity functions

2004-03-24  Dalibor Topic <robilad@kaffe.org>

        * config/alpha/atomicity.h:
        New file, taken from GNU libc 2.3.2.

        * config/alpha/common.h:
        Include config/alpha/atomicity.h.

        * config/Makefile.am:
        (EXTRA_DIST) Added config/alpha/atomicity.h.

        * config/Makefile.in:
        Regenerated.

Members: 
	ChangeLog:1.2142->1.2143 
	config/Makefile.am:1.38->1.39 
	config/Makefile.in:1.119->1.120 
	config/alpha/atomicity.h:INITIAL->1.1 
	config/alpha/common.h:1.9->1.10 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2142 kaffe/ChangeLog:1.2143
--- kaffe/ChangeLog:1.2142	Tue Mar 23 21:22:47 2004
+++ kaffe/ChangeLog	Wed Mar 24 11:06:09 2004
@@ -1,3 +1,17 @@
+2004-03-24  Dalibor Topic <robilad@kaffe.org>
+
+	* config/alpha/atomicity.h:
+	New file, taken from GNU libc 2.3.2.
+
+	* config/alpha/common.h:
+	Include config/alpha/atomicity.h.
+
+	* config/Makefile.am:
+	(EXTRA_DIST) Added config/alpha/atomicity.h.
+
+	* config/Makefile.in:
+	Regenerated.
+
 2004-03-23  Dalibor Topic <robilad@kaffe.org>
 
 	* kaffe/kaffevm/support.h:
Index: kaffe/config/Makefile.am
diff -u kaffe/config/Makefile.am:1.38 kaffe/config/Makefile.am:1.39
--- kaffe/config/Makefile.am:1.38	Fri Mar 12 11:45:20 2004
+++ kaffe/config/Makefile.am	Wed Mar 24 11:06:11 2004
@@ -52,6 +52,7 @@
 	regen-forward \
 	stamp-h1.in \
 	alpha/alpha.c \
+	alpha/atomicity.h \
 	alpha/callKaffeException.h \
 	alpha/common.h \
 	alpha/jit-alpha.def \
Index: kaffe/config/Makefile.in
diff -u kaffe/config/Makefile.in:1.119 kaffe/config/Makefile.in:1.120
--- kaffe/config/Makefile.in:1.119	Tue Mar 16 14:10:48 2004
+++ kaffe/config/Makefile.in	Wed Mar 24 11:06:11 2004
@@ -337,6 +337,7 @@
 	regen-forward \
 	stamp-h1.in \
 	alpha/alpha.c \
+	alpha/atomicity.h \
 	alpha/callKaffeException.h \
 	alpha/common.h \
 	alpha/jit-alpha.def \
===================================================================
Checking out kaffe/config/alpha/atomicity.h
RCS:  /home/cvs/kaffe/kaffe/config/alpha/atomicity.h,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/config/alpha/atomicity.h	Wed Mar 24 11:10:43 2004
@@ -0,0 +1,51 @@
+/* Low-level functions for atomic operations.  Alpha version.
+   Copyright (C) 1999 Free Software Foundation, Inc.
+   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
+
+static inline long
+__attribute__ ((unused))
+compare_and_swap (volatile long int *p, long int oldval, long int newval)
+{
+  long int ret;
+
+  __asm__ __volatile__ (
+	"/* Inline compare & swap */\n"
+	"1:\t"
+	"ldq_l	%0,%4\n\t"
+	"cmpeq	%0,%2,%0\n\t"
+	"beq	%0,3f\n\t"
+	"mov	%3,%0\n\t"
+	"stq_c	%0,%1\n\t"
+	"beq	%0,2f\n\t"
+	".subsection 1\n"
+	"2:\t"
+	"br	1b\n"
+	".previous\n\t"
+	"3:\t"
+	"mb\n\t"
+	"/* End compare & swap */"
+	: "=&r"(ret), "=m"(*p)
+	: "r"(oldval), "r"(newval), "m"(*p));
+
+  return ret;
+}
+
+#endif /* atomicity.h */
Index: kaffe/config/alpha/common.h
diff -u kaffe/config/alpha/common.h:1.9 kaffe/config/alpha/common.h:1.10
--- kaffe/config/alpha/common.h:1.9	Wed Mar  7 10:38:17 2001
+++ kaffe/config/alpha/common.h	Wed Mar 24 11:06:11 2004
@@ -29,25 +29,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)			\
-({							\
-	unsigned long tmp;				\
-	int ret;					\
-							\
-	asm volatile(					\
-	"1:	ldq_l %0,%5\n"				\
-	"	cmpeq %0,%3,%1\n"			\
-	"	cmovne %1,%4,%0\n"			\
-	"	stq_c %0,%2\n"				\
-	"	beq %0,2f\n"				\
-	"	mb\n"					\
-	"	br 3f\n"				\
-	"2:	br 1b\n"				\
-	"3:\n"						\
-	: "=&r"(tmp), "=&r"(ret), "=m"(*(A))		\
-	: "r"(O), "r"(N), "m"(*(A)) : "memory");	\
-							\
-	ret;						\
-})
+#define COMPARE_AND_EXCHANGE(A,O,N) (compare_and_swap((long int*) A, (long int) O, (long int) N))
 
 #endif