1 /* SPDX-License-Identifier: LGPL-2.1 OR MIT */ 2 /* 3 * timerfd definitions for NOLIBC 4 * Copyright (C) 2025 Thomas Weißschuh <thomas.weissschuh@linutronix.de> 5 */ 6 7 /* make sure to include all global symbols */ 8 #include "../nolibc.h" 9 10 #ifndef _NOLIBC_SYS_TIMERFD_H 11 #define _NOLIBC_SYS_TIMERFD_H 12 13 #include "../sys.h" 14 #include "../time.h" 15 16 #include <linux/timerfd.h> 17 18 19 static __attribute__((unused)) 20 int sys_timerfd_create(int clockid, int flags) 21 { 22 return my_syscall2(__NR_timerfd_create, clockid, flags); 23 } 24 25 static __attribute__((unused)) 26 int timerfd_create(int clockid, int flags) 27 { 28 return __sysret(sys_timerfd_create(clockid, flags)); 29 } 30 31 32 static __attribute__((unused)) 33 int sys_timerfd_gettime(int fd, struct itimerspec *curr_value) 34 { 35 #if defined(__NR_timerfd_gettime64) 36 return my_syscall2(__NR_timerfd_gettime64, fd, curr_value); 37 #else 38 return my_syscall2(__NR_timerfd_gettime, fd, curr_value); 39 #endif 40 } 41 42 static __attribute__((unused)) 43 int timerfd_gettime(int fd, struct itimerspec *curr_value) 44 { 45 return __sysret(sys_timerfd_gettime(fd, curr_value)); 46 } 47 48 49 static __attribute__((unused)) 50 int sys_timerfd_settime(int fd, int flags, 51 const struct itimerspec *new_value, struct itimerspec *old_value) 52 { 53 #if defined(__NR_timerfd_settime64) 54 return my_syscall4(__NR_timerfd_settime64, fd, flags, new_value, old_value); 55 #else 56 return my_syscall4(__NR_timerfd_settime, fd, flags, new_value, old_value); 57 #endif 58 } 59 60 static __attribute__((unused)) 61 int timerfd_settime(int fd, int flags, 62 const struct itimerspec *new_value, struct itimerspec *old_value) 63 { 64 return __sysret(sys_timerfd_settime(fd, flags, new_value, old_value)); 65 } 66 67 #endif /* _NOLIBC_SYS_TIMERFD_H */ 68