[kaffe] CVS kaffe (dalibor): Changed MIPS to use compare_and_swap from glibc 2.3.2

Kaffe CVS cvs-commits at kaffe.org
Wed Jul 7 15:19:21 PDT 2004


PatchSet 4906 
Date: 2004/07/07 22:15:02
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Changed MIPS to use compare_and_swap from glibc 2.3.2

2004-07-08  Dalibor Topic  <robilad at kaffe.org>

        * config/mips/atomicity.h:
        New file, taken from glibc 2.3.2.

        * THIRDPARTY: Documented MIPS atomicity.h merge.

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

        * config/Makefile.in:
        Regenerated.

        * config/mips/common.h:
        Use config/mips/atomicity.h for compare_and_swap for MIPS
        platofrms with MIPS2 instructions.

Members: 
	ChangeLog:1.2472->1.2473 
	THIRDPARTY:1.19->1.20 
	config/Makefile.am:1.43->1.44 
	config/Makefile.in:1.138->1.139 
	config/mips/atomicity.h:INITIAL->1.1 
	config/mips/common.h:1.9->1.10 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2472 kaffe/ChangeLog:1.2473
--- kaffe/ChangeLog:1.2472	Wed Jul  7 19:34:11 2004
+++ kaffe/ChangeLog	Wed Jul  7 22:15:02 2004
@@ -1,3 +1,20 @@
+2004-07-08  Dalibor Topic  <robilad at kaffe.org>
+
+        * config/mips/atomicity.h:
+	New file, taken from glibc 2.3.2.
+
+	* THIRDPARTY: Documented MIPS atomicity.h merge.
+
+        * config/Makefile.am:
+	(EXTRA_DIST) Added config/mips/atomicity.h.
+
+        * config/Makefile.in:
+	Regenerated.
+
+        * config/mips/common.h:
+	Use config/mips/atomicity.h for compare_and_swap for MIPS
+	platofrms with MIPS2 instructions.
+
 2004-07-07  Dalibor Topic  <robilad at kaffe.org>
 
         * configure.ac:
Index: kaffe/THIRDPARTY
diff -u kaffe/THIRDPARTY:1.19 kaffe/THIRDPARTY:1.20
--- kaffe/THIRDPARTY:1.19	Sat Jul  3 23:57:16 2004
+++ kaffe/THIRDPARTY	Wed Jul  7 22:15:04 2004
@@ -179,8 +179,8 @@
 
 At the time of writing, Kaffe uses getaddrinfo 1.6.1.
 
-* Alpha, ARM, ia64, M68k, S390 and SPARC atomic compare_and_swap, Linux
-  sigcontextinfo
+* Alpha, ARM, ia64, M68k, MIPS, S390 and SPARC atomic compare_and_swap, 
+  Linux sigcontextinfo
 
 Taken from GNU libc 2.3.2, which is licensed under the GNU Lesser General 
 Public License. See file license-lesser.terms for details.
Index: kaffe/config/Makefile.am
diff -u kaffe/config/Makefile.am:1.43 kaffe/config/Makefile.am:1.44
--- kaffe/config/Makefile.am:1.43	Sat Jul  3 23:57:17 2004
+++ kaffe/config/Makefile.am	Wed Jul  7 22:15:05 2004
@@ -244,6 +244,7 @@
 	m68k/sysdepCallMethod.h \
 	m68k/threads.h \
 	m68k/trampolines.c \
+	mips/atomicity.h \
 	mips/callKaffeException.h \
 	mips/common.h \
 	mips/irix5/config.frag \
Index: kaffe/config/Makefile.in
diff -u kaffe/config/Makefile.in:1.138 kaffe/config/Makefile.in:1.139
--- kaffe/config/Makefile.in:1.138	Wed Jul  7 19:34:24 2004
+++ kaffe/config/Makefile.in	Wed Jul  7 22:15:05 2004
@@ -552,6 +552,7 @@
 	m68k/sysdepCallMethod.h \
 	m68k/threads.h \
 	m68k/trampolines.c \
+	mips/atomicity.h \
 	mips/callKaffeException.h \
 	mips/common.h \
 	mips/irix5/config.frag \
===================================================================
Checking out kaffe/config/mips/atomicity.h
RCS:  /home/cvs/kaffe/kaffe/config/mips/atomicity.h,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/config/mips/atomicity.h	Wed Jul  7 22:19:20 2004
@@ -0,0 +1,52 @@
+/* Low-level functions for atomic operations. Mips version.
+   Copyright (C) 2001, 2002 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 _MIPS_ATOMICITY_H
+#define _MIPS_ATOMICITY_H    1
+
+#include <inttypes.h>
+
+static inline int
+__attribute__ ((unused))
+compare_and_swap (volatile long int *p, long int oldval, long int newval)
+{
+  long int ret, temp;
+
+  __asm__ __volatile__
+    ("/* Inline compare & swap */\n"
+     "1:\n\t"
+     ".set	push\n\t"
+     ".set	mips2\n\t"
+     "ll	%1,%5\n\t"
+     "move	%0,$0\n\t"
+     "bne	%1,%3,2f\n\t"
+     "move	%0,%4\n\t"
+     "sc	%0,%2\n\t"
+     ".set	pop\n\t"
+     "beqz	%0,1b\n"
+     "2:\n\t"
+     "/* End compare & swap */"
+     : "=&r" (ret), "=&r" (temp), "=m" (*p)
+     : "r" (oldval), "r" (newval), "m" (*p)
+     : "memory");
+
+  return ret;
+}
+
+#endif /* atomicity.h */
Index: kaffe/config/mips/common.h
diff -u kaffe/config/mips/common.h:1.9 kaffe/config/mips/common.h:1.10
--- kaffe/config/mips/common.h:1.9	Sat Dec 13 19:31:28 2003
+++ kaffe/config/mips/common.h	Wed Jul  7 22:15:08 2004
@@ -31,33 +31,17 @@
 #endif 
 
 #if defined(HAVE_MIPSII_INSTRUCTIONS)
+#include "atomicity.h"
+#endif /* defined(HAVE_MIPSII_INSTRUCTIONS) */
+
+#if defined(HAVE_MIPSII_INSTRUCTIONS)
+
 /*
  * Do an atomic compare and exchange.  The address 'A' is checked against
  * 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 int tmp, ret;			\
- 						\
-	asm volatile(				\
-	"	.set	noreorder\n"		\
-	"	.set	mips2\n"		\
-	"1:	ll	%0, %2\n"		\
-	"	bne	%0, %3,2f\n"		\
-	"	move	%0, $0\n"		\
-	"	move	%0, %4\n"		\
-	"	sc	%0, %1\n"		\
-	"	beqz	%0, 1b\n"		\
-	"	nop\n"				\
-	"2:\n"					\
-	"	.set	mips0\n"		\
-	"	.set	reorder\n"		\
-	: "=&r" (ret), "=m" (*(A))		\
-	: "m" (*(A)), "r" (O), "r" (N)		\
-	: "memory");				\
-	ret;					\
-})
+#define COMPARE_AND_EXCHANGE(A,O,N)	(compare_and_swap((long int*) A, (long int) O, (long int) N))
 
 #else
 



More information about the kaffe mailing list