[Openmp-commits] [openmp] Fix build for X32 ABI (PR #90395)

Andrii Batyiev via Openmp-commits openmp-commits at lists.llvm.org
Sun Apr 28 04:02:30 PDT 2024


https://github.com/abatyiev created https://github.com/llvm/llvm-project/pull/90395

X32 ABI is special 32bit ABI for long mode (64bit) of X86_64 with 32bit pointers and integer types.

Syscall numbering scheme uses second highest bit to tell difference between regular 64bit calls and X32 ABI calls.

Fixes #90346

>From 7d230d1974aae201441dbb81f033b36323b59ed7 Mon Sep 17 00:00:00 2001
From: Andrii Batyiev <batyiev at gmail.com>
Date: Sun, 28 Apr 2024 13:56:55 +0300
Subject: [PATCH] Fix build for X32 ABI

X32 ABI is special 32bit ABI for long mode (64bit) of X86_64 with 32bit
pointers and integer types.

Fixes #90346
---
 openmp/runtime/src/kmp_affinity.h | 13 +++++++++----
 openmp/runtime/src/kmp_os.h       |  2 +-
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/openmp/runtime/src/kmp_affinity.h b/openmp/runtime/src/kmp_affinity.h
index 3dc2c84d53f773..2f0f4f29d6a8af 100644
--- a/openmp/runtime/src/kmp_affinity.h
+++ b/openmp/runtime/src/kmp_affinity.h
@@ -222,14 +222,19 @@ class KMPHwlocAffinity : public KMPAffinity {
 #error Wrong code for getaffinity system call.
 #endif /* __NR_sched_getaffinity */
 #elif KMP_ARCH_X86_64
+#ifndef __ILP32__
+#define X32_BIT 0
+#else
+#define X32_BIT 0x40000000
+#endif /* __ILP32__ */
 #ifndef __NR_sched_setaffinity
-#define __NR_sched_setaffinity 203
-#elif __NR_sched_setaffinity != 203
+#define __NR_sched_setaffinity (203 + X32_BIT)
+#elif __NR_sched_setaffinity != (203 + X32_BIT)
 #error Wrong code for setaffinity system call.
 #endif /* __NR_sched_setaffinity */
 #ifndef __NR_sched_getaffinity
-#define __NR_sched_getaffinity 204
-#elif __NR_sched_getaffinity != 204
+#define __NR_sched_getaffinity (204 + X32_BIT)
+#elif __NR_sched_getaffinity != (204 + X32_BIT)
 #error Wrong code for getaffinity system call.
 #endif /* __NR_sched_getaffinity */
 #elif KMP_ARCH_PPC64
diff --git a/openmp/runtime/src/kmp_os.h b/openmp/runtime/src/kmp_os.h
index 24b40ed32d988a..59a81557e0d2ac 100644
--- a/openmp/runtime/src/kmp_os.h
+++ b/openmp/runtime/src/kmp_os.h
@@ -189,7 +189,7 @@ typedef unsigned long long kmp_uint64;
 #error "Can't determine size_t printf format specifier."
 #endif
 
-#if KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_WASM || KMP_ARCH_PPC
+#if KMP_ARCH_X86 || KMP_ARCH_ARM || KMP_ARCH_WASM || KMP_ARCH_PPC || defined(__ILP32__)
 #define KMP_SIZE_T_MAX (0xFFFFFFFF)
 #else
 #define KMP_SIZE_T_MAX (0xFFFFFFFFFFFFFFFF)



More information about the Openmp-commits mailing list