[libcxx-commits] [PATCH] D94909: [libc++][VE] Support futex system call on VE
Kazushi Marukawa via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Dec 8 08:42:30 PST 2021
kaz7 updated this revision to Diff 392799.
kaz7 added a comment.
Update implementation as suggested.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D94909/new/
https://reviews.llvm.org/D94909
Files:
libcxx/src/atomic.cpp
Index: libcxx/src/atomic.cpp
===================================================================
--- libcxx/src/atomic.cpp
+++ libcxx/src/atomic.cpp
@@ -16,7 +16,9 @@
#ifdef __linux__
#include <unistd.h>
-#include <linux/futex.h>
+#if __has_include(<linux/futex.h>)
+# include <linux/futex.h>
+#endif
#include <sys/syscall.h>
// libc++ uses SYS_futex as a universal syscall name. However, on 32 bit architectures
@@ -35,6 +37,27 @@
#ifdef __linux__
+# ifdef __ve__ && !defined(FUTEX_WAIT)
+// VE doesn't distribute linux/futex.h. Hoever, SYS_futex is implemented
+// partially as described in "Difference points for system calls",
+// https://www.hpc.nec/documents/veos/en/Difference_Point_System_Calls.pdf.
+// It describes following futex operations are supported.
+// FUTEX_WAIT
+// FUTEX_WAKT
+// FUTEX_PRIVATE_FLAG
+//
+// The values of those operations are available in glibc-ve at
+// https://github.com/veos-sxarr-NEC/glibc-ve/blob/master/sysdeps/unix/sysv/linux/ve/lowlevellock.h#L30-L43.
+//
+// So, we copy defined values here as a remedy until linux/futex.h is
+// distributed.
+# define FUTEX_WAIT 0
+# define FUTEX_WAKE 1
+# define FUTEX_PRIVATE_FLAG 128
+# define FUTEX_WAIT_PRIVATE (FUTEX_WAIT | FUTEX_PRIVATE_FLAG)
+# define FUTEX_WAKE_PRIVATE (FUTEX_WAKE | FUTEX_PRIVATE_FLAG)
+# endif // __ve__ && !defined(FUTEX_WAIT)
+
static void __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr,
__cxx_contention_t __val)
{
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D94909.392799.patch
Type: text/x-patch
Size: 1566 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20211208/76eb0cb4/attachment.bin>
More information about the libcxx-commits
mailing list