diff options
-rw-r--r-- | libartbase/base/memfd.cc | 26 |
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 |