[Openmp-commits] [PATCH] D96798: GNU/Linux X32 ABI patch for OpenMP

alsoijw via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Tue Feb 16 09:38:46 PST 2021


alsoijw created this revision.
Herald added subscribers: guansong, yaxunl.
alsoijw requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: openmp-commits, sstefan1.
Herald added a project: OpenMP.

In x32 abi defined both x32 and x64 macro flags, so on x32 system uses x64 flags that defines syscall numbers specific on x64. But x32 syscalls are different from x64, so building openmp on x32 platform fails on "#error Wrong code for setaffinity system call." and "#error Wrong code for getaffinity system call." This patch define also x32 flags that allow build both x32 and x64 on same system.

https://lwn.net/Articles/456739/


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96798

Files:
  openmp/runtime/src/kmp_affinity.h
  openmp/runtime/src/kmp_os.h


Index: openmp/runtime/src/kmp_os.h
===================================================================
--- openmp/runtime/src/kmp_os.h
+++ openmp/runtime/src/kmp_os.h
@@ -173,7 +173,7 @@
 #error "Can't determine size_t printf format specifier."
 #endif
 
-#if KMP_ARCH_X86
+#if KMP_ARCH_X86 || __ILP32__
 #define KMP_SIZE_T_MAX (0xFFFFFFFF)
 #else
 #define KMP_SIZE_T_MAX (0xFFFFFFFFFFFFFFFF)
Index: openmp/runtime/src/kmp_affinity.h
===================================================================
--- openmp/runtime/src/kmp_affinity.h
+++ openmp/runtime/src/kmp_affinity.h
@@ -210,6 +210,18 @@
 #error Wrong code for getaffinity system call.
 #endif /* __NR_sched_getaffinity */
 #elif KMP_ARCH_X86_64
+#if __ILP32__
+#ifndef __NR_sched_setaffinity
+#define __NR_sched_setaffinity (0x40000000UL + 203)
+#elif __NR_sched_setaffinity != (0x40000000UL + 203)
+#error Wrong code for setaffinity system call.
+#endif /* __NR_sched_setaffinity */
+#ifndef __NR_sched_getaffinity
+#define __NR_sched_getaffinity (0x40000000UL + 204)
+#elif __NR_sched_getaffinity != (0x40000000UL + 204)
+#error Wrong code for getaffinity system call.
+#endif /* __NR_sched_getaffinity */
+#else
 #ifndef __NR_sched_setaffinity
 #define __NR_sched_setaffinity 203
 #elif __NR_sched_setaffinity != 203
@@ -220,6 +232,7 @@
 #elif __NR_sched_getaffinity != 204
 #error Wrong code for getaffinity system call.
 #endif /* __NR_sched_getaffinity */
+#endif
 #elif KMP_ARCH_PPC64
 #ifndef __NR_sched_setaffinity
 #define __NR_sched_setaffinity 222


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D96798.324037.patch
Type: text/x-patch
Size: 1522 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210216/3c08411e/attachment.bin>


More information about the Openmp-commits mailing list