This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gomp] s390{,x} libgomp using futex
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>, Diego Novillo <dnovillo at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 9 Nov 2005 16:05:39 -0500
- Subject: [gomp] s390{,x} libgomp using futex
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
s390{,x} will still need QI/HImode __sync_* builtins (doable similarly to
what I did on SPARC) to fix
testsuite/gcc.log:FAIL: gcc.dg/gomp/atomic-3.c scan-tree-dump-times xyzzy, 4 1
testsuite/gcc.log:FAIL: gcc.dg/gomp/atomic-9.c scan-tree-dump-times __sync_fetch_and_add 1
testsuite/g++.log:FAIL: g++.dg/gomp/atomic-3.C scan-tree-dump-times xyzzy, 4 1
testsuite/g++.log:FAIL: g++.dg/gomp/atomic-9.C scan-tree-dump-times __sync_fetch_and_add 1
but the libgomp side of things seems to work.
Ok for gomp?
2005-11-09 Jakub Jelinek <jakub@redhat.com>
* config/linux/s390/futex.h: New file.
* configure.tgt: Use it.
--- libgomp/configure.tgt.jj 2005-11-01 12:39:50.000000000 +0100
+++ libgomp/configure.tgt 2005-11-09 21:28:58.000000000 +0100
@@ -37,6 +37,10 @@ if test $enable_linux_futex = yes; then
config_path="linux/powerpc linux posix"
;;
+ s390*-*-linux*)
+ config_path="linux/s390 linux posix"
+ ;;
+
# Note that bare i386 is not included here. We need cmpxchg.
i[456]86-*-linux*)
config_path="linux/x86 linux posix"
--- libgomp/config/linux/s390/futex.h.jj 2005-11-09 21:29:34.000000000 +0100
+++ libgomp/config/linux/s390/futex.h 2005-11-09 21:40:25.000000000 +0100
@@ -0,0 +1,64 @@
+/* Copyright (C) 2005 Free Software Foundation, Inc.
+ Contributed by Jakub Jelinek <jakub@redhat.com>.
+
+ This file is part of the GNU OpenMP Library (libgomp).
+
+ Libgomp 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.
+
+ Libgomp 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 libgomp; see the file COPYING.LIB. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ MA 02111-1307, USA. */
+
+/* As a special exception, if you link this library with other files, some
+ of which are compiled with GCC, to produce an executable, this library
+ does not by itself cause the resulting executable to be covered by the
+ GNU General Public License. This exception does not however invalidate
+ any other reasons why the executable file might be covered by the GNU
+ General Public License. */
+
+/* Provide target-specific access to the futex system call. */
+
+#include <sys/syscall.h>
+#define FUTEX_WAIT 0
+#define FUTEX_WAKE 1
+
+static inline void
+sys_futex0 (int *addr, int op, int val)
+{
+ register long int gpr2 __asm__ ("2");
+ register long int gpr3 __asm__ ("3");
+ register long int gpr4 __asm__ ("4");
+ register long int gpr5 __asm__ ("5");
+
+ gpr2 = (long) addr;
+ gpr3 = op;
+ gpr4 = val;
+ gpr5 = 0;
+
+ __asm volatile ("svc %b1"
+ : "=d" (gpr2)
+ : "i" (SYS_futex),
+ "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5)
+ : "memory");
+}
+
+static inline void
+futex_wait (int *addr, int val)
+{
+ sys_futex0 (addr, FUTEX_WAIT, val);
+}
+
+static inline void
+futex_wake (int *addr, int count)
+{
+ sys_futex0 (addr, FUTEX_WAKE, count);
+}
Jakub