summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Elliott Hughes <enh@google.com> 2025-03-14 10:19:04 -0700
committer Elliott Hughes <enh@google.com> 2025-03-14 16:13:18 -0700
commit38a1949da3b69443cf1d88b3dedaccc7c5fe2c90 (patch)
tree892fb1e4065cf87474b85743cba75110d181cf30
parente5d43edd02f7a16e3de1c3aca7bbc6bdd52b318b (diff)
IsSealFutureWriteSupported isn't bionic-specific.
This was a workaround for "our ancient glibc headers are out of date", but I've modernized the relevant ones so this should just work on the host now too. Change-Id: Ie32c22a2e4707c0ba91e082b6743dd3c2d338859
-rw-r--r--libartbase/base/memfd.cc26
1 files changed, 9 insertions, 17 deletions
diff --git a/libartbase/base/memfd.cc b/libartbase/base/memfd.cc
index 4530f8199b..f965a08780 100644
--- a/libartbase/base/memfd.cc
+++ b/libartbase/base/memfd.cc
@@ -20,13 +20,11 @@
#include <stdio.h>
#if !defined(_WIN32)
#include <fcntl.h>
+#include <sys/mman.h>
#include <sys/syscall.h>
#include <sys/utsname.h>
#include <unistd.h>
#endif
-#if defined(__BIONIC__)
-#include <linux/memfd.h> // To access memfd flags.
-#endif
#include <android-base/logging.h>
#include <android-base/unique_fd.h>
@@ -35,7 +33,7 @@
namespace art {
-#if defined(__NR_memfd_create)
+#if defined(__linux__)
int memfd_create(const char* name, unsigned int flags) {
// Check kernel version supports memfd_create(). Some older kernels segfault executing
@@ -55,17 +53,6 @@ int memfd_create(const char* name, unsigned int flags) {
return syscall(__NR_memfd_create, name, flags);
}
-#else // __NR_memfd_create
-
-int memfd_create([[maybe_unused]] const char* name, [[maybe_unused]] unsigned int flags) {
- errno = ENOSYS;
- return -1;
-}
-
-#endif // __NR_memfd_create
-
-#if defined(__BIONIC__)
-
static bool IsSealFutureWriteSupportedInternal() {
android::base::unique_fd fd(art::memfd_create("test_android_memfd", MFD_ALLOW_SEALING));
if (fd == -1) {
@@ -87,12 +74,17 @@ bool IsSealFutureWriteSupported() {
return is_seal_future_write_supported;
}
-#else
+#else // __linux__
+
+int memfd_create([[maybe_unused]] const char* name, [[maybe_unused]] unsigned int flags) {
+ errno = ENOSYS;
+ return -1;
+}
bool IsSealFutureWriteSupported() {
return false;
}
-#endif
+#endif // __linux__
} // namespace art