diff mbox

PATCH: Add x32 support to libgomp

Message ID 20110728193226.GA7809@intel.com
State New
Headers show

Commit Message

H.J. Lu July 28, 2011, 7:32 p.m. UTC
Hi,

This patch fixes 2 issues in libgomp for x32:

1. x32 should use the same futex functions as x86-64.
2. IA32 tests should check ia32 instead of ilp32.

OK for trunk?

Thanks.


H.J.
---
2011-07-28  H.J. Lu  <hongjiu.lu@intel.com>

	* config/linux/x86/futex.h: Check __x86_64__ instead of
	__LP64__.

	* testsuite/lib/libgomp.exp (libgomp_init): Add -march=i486
	for ia32 instead of ilp32.

	* testsuite/libgomp.c/atomic-1.c: Require ia32 instead of ilp32.
	* testsuite/libgomp.c/atomic-6.c: Likewise.

Comments

Jakub Jelinek July 28, 2011, 7:45 p.m. UTC | #1
On Thu, Jul 28, 2011 at 12:32:26PM -0700, H.J. Lu wrote:
> This patch fixes 2 issues in libgomp for x32:
> 
> 1. x32 should use the same futex functions as x86-64.

What kind of syscalls is -mx32 using on Linux?  I thought it was using the
-m32 compat layer, isn't that the case?  If it works properly this way using
a 64-bit syscall, including any needed sign/zero extensions of the arguments,
fine.

> 2. IA32 tests should check ia32 instead of ilp32.

This is certainly fine.

	Jakub
H.J. Lu July 28, 2011, 7:51 p.m. UTC | #2
On Thu, Jul 28, 2011 at 12:45 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Thu, Jul 28, 2011 at 12:32:26PM -0700, H.J. Lu wrote:
>> This patch fixes 2 issues in libgomp for x32:
>>
>> 1. x32 should use the same futex functions as x86-64.
>
> What kind of syscalls is -mx32 using on Linux?  I thought it was using the
> -m32 compat layer, isn't that the case?  If it works properly this way using
> a 64-bit syscall, including any needed sign/zero extensions of the arguments,
> fine.

x32 uses syscall instruction for system call with long == 32bit. For futex.
it calls the compat_sys_futex kernel function.  As far as kernel
is concerned,  x32 is the same as ia32 with x86-64 kernel calling convention.

>> 2. IA32 tests should check ia32 instead of ilp32.
>
> This is certainly fine.
>
>        Jakub
>

Thanks.
diff mbox

Patch

diff --git a/libgomp/config/linux/x86/futex.h b/libgomp/config/linux/x86/futex.h
index cb7461d..419f4d9 100644
--- a/libgomp/config/linux/x86/futex.h
+++ b/libgomp/config/linux/x86/futex.h
@@ -24,7 +24,7 @@ 
 
 /* Provide target-specific access to the futex system call.  */
 
-#ifdef __LP64__
+#ifdef __x86_64__
 # ifndef SYS_futex
 #  define SYS_futex	202
 # endif
@@ -138,7 +138,7 @@  futex_wake (int *addr, int count)
     }
 }
 
-#endif /* __LP64__ */
+#endif /* __x86_64__ */
 
 static inline void
 cpu_relax (void)
diff --git a/libgomp/testsuite/lib/libgomp.exp b/libgomp/testsuite/lib/libgomp.exp
index 976543d..a75e22f 100644
--- a/libgomp/testsuite/lib/libgomp.exp
+++ b/libgomp/testsuite/lib/libgomp.exp
@@ -140,7 +140,7 @@  proc libgomp_init { args } {
 
     # We use atomic operations in the testcases to validate results.
     if { ([istarget i?86-*-*] || [istarget x86_64-*-*])
-	 && [check_effective_target_ilp32] } {
+	 && [check_effective_target_ia32] } {
 	lappend ALWAYS_CFLAGS "additional_flags=-march=i486"
     }
 
diff --git a/libgomp/testsuite/libgomp.c/atomic-1.c b/libgomp/testsuite/libgomp.c/atomic-1.c
index b2be8f0..4725b7d 100644
--- a/libgomp/testsuite/libgomp.c/atomic-1.c
+++ b/libgomp/testsuite/libgomp.c/atomic-1.c
@@ -1,5 +1,5 @@ 
 /* { dg-do run } */
-/* { dg-options "-O2 -march=pentium" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+/* { dg-options "-O2 -march=pentium" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */
 
 #ifdef __i386__
 #include "cpuid.h"
diff --git a/libgomp/testsuite/libgomp.c/atomic-6.c b/libgomp/testsuite/libgomp.c/atomic-6.c
index 59baf7d..f8ab75e 100644
--- a/libgomp/testsuite/libgomp.c/atomic-6.c
+++ b/libgomp/testsuite/libgomp.c/atomic-6.c
@@ -1,7 +1,7 @@ 
 /* PR middle-end/36106 */
 /* { dg-options "-O2" } */
 /* { dg-options "-O2 -mieee" { target alpha*-*-* } } */
-/* { dg-options "-O2 -march=i586" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */
+/* { dg-options "-O2 -march=i586" { target { { i?86-*-* x86_64-*-* } && ia32 } } } */
 
 #ifdef __i386__
 # include "cpuid.h"