Make source compile under Linux X32 ABI
authorErik Lindahl <erik@kth.se>
Mon, 23 Jun 2014 19:30:51 +0000 (21:30 +0200)
committerGerrit Code Review <gerrit@gerrit.gromacs.org>
Wed, 25 Jun 2014 17:26:17 +0000 (19:26 +0200)
The X32 ABI uses 32-bit pointers in combination with all
other features of x86-64 to save memory. This requires two
minor changes to x86 inline assembly macro checks, where we
need check for __LP64__ (64-bit pointers) rather than
__x86_64__ (which is set for X32). The resulting binaries
run approximately 2% faster, but since it requires all
dependent libraries to be available in X32 format it is
not something we will enable with a simple setting for now.
To use it manually, set CFLAGS and CXXFLAGS to "-O3 -mx32".

Fixes #1263.

Change-Id: I2555b2c68d4bba24f4e581268c472a47fe7d1531

cmake/TestInlineASM_gcc_x86.c
src/external/thread_mpi/include/thread_mpi/atomic/gcc_x86.h

index 152cddfafd63ca46fde188ab9c92ae356b715313..27f7a07d56984760e5fe3b9de1029630dffa7e01 100644 (file)
@@ -5,7 +5,7 @@ main()
   unsigned int level = 0;
 
   /* Test gcc inline asm for x86 */
-#if defined (__x86_64__) || defined (_M_X64)
+#if defined (__LP64__) || defined (_M_X64)
     __asm__("push %%rbx       \n\t"
             "cpuid            \n\t"
             "movl %%ebx, %1   \n\t"
index 122dff53278d78ecc2636c9f93893b50001393fa..559258e8d889a59eb95aa0d366ad14de13e0bd58 100644 (file)
@@ -194,7 +194,7 @@ static inline int tMPI_Atomic_swap(tMPI_Atomic_t *a, int b)
 static inline void *tMPI_Atomic_ptr_swap(tMPI_Atomic_ptr_t *a, void *b)
 {
     void *volatile *ret = (void* volatile*)b;
-#ifndef __x86_64__
+#ifndef __LP64__
     __asm__ __volatile__("\txchgl %0, %1;"
                          : "+r" (ret), "+m" (a->value)
                          :