-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patches: Use unikraft syscall in cxa_guard
This patch replaces calls to libc syscall() with short-circuited unikraft-specific static implementations of these syscalls. Co-authored-by: Marco Schlumpp <marco@unikraft.io> Signed-off-by: Marco Schlumpp <marco@unikraft.io> Signed-off-by: Andrei Tatar <andrei@unikraft.io> Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com> Reviewed-by: Maria Sfiraiala <maria.sfiraiala@gmail.com> Reviewed-by: Razvan Deaconescu <razvand@unikraft.io> Approved-by: Eduard Vintilă <eduard.vintila47@gmail.com> Tested-by: Unikraft CI <monkey@unikraft.io> GitHub-Closes: #4
- Loading branch information
1 parent
6546a39
commit 17ce85c
Showing
2 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
diff --git a/libcxxabi/src/cxa_guard_impl.h b/libcxxabi/src/cxa_guard_impl.h | ||
index 72940cc7e..822765d89 100644 | ||
--- a/src/cxa_guard_impl.h | ||
+++ b/src/cxa_guard_impl.h | ||
@@ -56,6 +56,7 @@ | ||
|
||
#include <limits.h> | ||
#include <stdlib.h> | ||
+#include <uk/syscall.h> | ||
#include <__threading_support> | ||
#ifndef _LIBCXXABI_HAS_NO_THREADS | ||
# if defined(__ELF__) && defined(_LIBCXXABI_LINK_PTHREAD_LIB) | ||
@@ -157,7 +158,7 @@ uint32_t PlatformThreadID() { | ||
#elif defined(SYS_gettid) && defined(_LIBCPP_HAS_THREAD_API_PTHREAD) | ||
uint32_t PlatformThreadID() { | ||
static_assert(sizeof(pid_t) == sizeof(uint32_t), ""); | ||
- return static_cast<uint32_t>(syscall(SYS_gettid)); | ||
+ return static_cast<uint32_t>(uk_syscall_static(SYS_gettid)); | ||
} | ||
#else | ||
constexpr uint32_t (*PlatformThreadID)() = nullptr; | ||
@@ -410,13 +411,13 @@ private: | ||
#if defined(SYS_futex) | ||
void PlatformFutexWait(int* addr, int expect) { | ||
constexpr int WAIT = 0; | ||
- syscall(SYS_futex, addr, WAIT, expect, 0); | ||
+ uk_syscall_static(SYS_futex, addr, WAIT, expect, 0); | ||
__tsan_acquire(addr); | ||
} | ||
void PlatformFutexWake(int* addr) { | ||
constexpr int WAKE = 1; | ||
__tsan_release(addr); | ||
- syscall(SYS_futex, addr, WAKE, INT_MAX); | ||
+ uk_syscall_static(SYS_futex, addr, WAKE, INT_MAX); | ||
} | ||
#else | ||
constexpr void (*PlatformFutexWait)(int*, int) = nullptr; |