1 /* SPDX-License-Identifier: MIT */ 2 3 #ifndef LIBURING_ARCH_AARCH64_LIB_H 4 #define LIBURING_ARCH_AARCH64_LIB_H 5 6 #include <elf.h> 7 #include "../../syscall.h" 8 __get_page_size(void)9static inline long __get_page_size(void) 10 { 11 Elf64_Off buf[2]; 12 long ret = 4096; 13 int fd; 14 15 fd = __sys_open("/proc/self/auxv", O_RDONLY, 0); 16 if (fd < 0) 17 return ret; 18 19 while (1) { 20 ssize_t x; 21 22 x = __sys_read(fd, buf, sizeof(buf)); 23 if (x < (long) sizeof(buf)) 24 break; 25 26 if (buf[0] == AT_PAGESZ) { 27 ret = buf[1]; 28 break; 29 } 30 } 31 32 __sys_close(fd); 33 return ret; 34 } 35 get_page_size(void)36static inline long get_page_size(void) 37 { 38 static long cache_val; 39 40 if (cache_val) 41 return cache_val; 42 43 cache_val = __get_page_size(); 44 return cache_val; 45 } 46 47 #endif /* #ifndef LIBURING_ARCH_AARCH64_LIB_H */ 48