diff options
| -rw-r--r-- | libartbase/Android.bp | 5 | ||||
| -rw-r--r-- | libartbase/base/memfd.cc | 6 | ||||
| -rw-r--r-- | libartbase/base/memfd.h | 3 |
3 files changed, 11 insertions, 3 deletions
diff --git a/libartbase/Android.bp b/libartbase/Android.bp index 8bd3bd12aa..fc53aaa28a 100644 --- a/libartbase/Android.bp +++ b/libartbase/Android.bp @@ -25,7 +25,10 @@ package { cc_defaults { name: "libartbase_defaults", - defaults: ["art_defaults"], + defaults: [ + "art_defaults", + "has_memfd_backport_defaults", + ], host_supported: true, srcs: [ "arch/instruction_set.cc", diff --git a/libartbase/base/memfd.cc b/libartbase/base/memfd.cc index 8512a3ae13..84cc66d5f2 100644 --- a/libartbase/base/memfd.cc +++ b/libartbase/base/memfd.cc @@ -17,11 +17,15 @@ #include "memfd.h" #include <errno.h> +#if !defined(HAS_MEMFD_BACKPORT) #include <stdio.h> +#endif #if !defined(_WIN32) #include <fcntl.h> #include <sys/syscall.h> +#if !defined(HAS_MEMFD_BACKPORT) #include <sys/utsname.h> +#endif #include <unistd.h> #endif #if defined(__BIONIC__) @@ -49,6 +53,7 @@ namespace art { #if defined(__NR_memfd_create) int memfd_create(const char* name, unsigned int flags) { +#if !defined(HAS_MEMFD_BACKPORT) // Check kernel version supports memfd_create(). Some older kernels segfault executing // memfd_create() rather than returning ENOSYS (b/116769556). static constexpr int kRequiredMajor = 3; @@ -62,6 +67,7 @@ int memfd_create(const char* name, unsigned int flags) { errno = ENOSYS; return -1; } +#endif return syscall(__NR_memfd_create, name, flags); } diff --git a/libartbase/base/memfd.h b/libartbase/base/memfd.h index 3c27dcb9e3..d26101824b 100644 --- a/libartbase/base/memfd.h +++ b/libartbase/base/memfd.h @@ -65,8 +65,7 @@ namespace art { -// Call memfd(2) if available on platform and return result. This call also makes a kernel version -// check for safety on older kernels (b/116769556).. + // Call memfd(2) if available on platform and return result. int memfd_create(const char* name, unsigned int flags); // Call memfd(2) if available on platform and return result. Try to give us an unlinked FD in some |
