use SYS_openat when available

some architecture like AArch64 may not have the open syscall, but have
openat syscall. so check and use SYS_openat if SYS_openat available if
SYS_open is not supported at init_thp_state.
This commit is contained in:
RingsC 2019-10-13 23:11:23 +08:00 committed by Qi Wang
parent de81a4eada
commit 6924f83cb2

View File

@ -563,6 +563,9 @@ init_thp_state(void) {
#if defined(JEMALLOC_USE_SYSCALL) && defined(SYS_open) #if defined(JEMALLOC_USE_SYSCALL) && defined(SYS_open)
int fd = (int)syscall(SYS_open, int fd = (int)syscall(SYS_open,
"/sys/kernel/mm/transparent_hugepage/enabled", O_RDONLY); "/sys/kernel/mm/transparent_hugepage/enabled", O_RDONLY);
#elif defined(JEMALLOC_USE_SYSCALL) && defined(SYS_openat)
int fd = (int)syscall(SYS_openat,
AT_FDCWD, "/sys/kernel/mm/transparent_hugepage/enabled", O_RDONLY);
#else #else
int fd = open("/sys/kernel/mm/transparent_hugepage/enabled", O_RDONLY); int fd = open("/sys/kernel/mm/transparent_hugepage/enabled", O_RDONLY);
#endif #endif