Warning: That file was not part of the compilation database. It may have many parsing errors.
| 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_gettime) |
| 36 | return my_syscall2(__NR_timerfd_gettime, fd, curr_value); |
| 37 | #else |
| 38 | struct __kernel_itimerspec kcurr_value; |
| 39 | int ret; |
| 40 | |
| 41 | ret = my_syscall2(__NR_timerfd_gettime64, fd, &kcurr_value); |
| 42 | __nolibc_timespec_kernel_to_user(&kcurr_value.it_interval, &curr_value->it_interval); |
| 43 | __nolibc_timespec_kernel_to_user(&kcurr_value.it_value, &curr_value->it_value); |
| 44 | return ret; |
| 45 | #endif |
| 46 | } |
| 47 | |
| 48 | static __attribute__((unused)) |
| 49 | int timerfd_gettime(int fd, struct itimerspec *curr_value) |
| 50 | { |
| 51 | return __sysret(sys_timerfd_gettime(fd, curr_value)); |
| 52 | } |
| 53 | |
| 54 | |
| 55 | static __attribute__((unused)) |
| 56 | int sys_timerfd_settime(int fd, int flags, |
| 57 | const struct itimerspec *new_value, struct itimerspec *old_value) |
| 58 | { |
| 59 | #if defined(__NR_timerfd_settime) |
| 60 | return my_syscall4(__NR_timerfd_settime, fd, flags, new_value, old_value); |
| 61 | #else |
| 62 | struct __kernel_itimerspec knew_value, kold_value; |
| 63 | int ret; |
| 64 | |
| 65 | __nolibc_timespec_user_to_kernel(&new_value->it_value, &knew_value.it_value); |
| 66 | __nolibc_timespec_user_to_kernel(&new_value->it_interval, &knew_value.it_interval); |
| 67 | ret = my_syscall4(__NR_timerfd_settime64, fd, flags, &knew_value, &kold_value); |
| 68 | if (old_value) { |
| 69 | __nolibc_timespec_kernel_to_user(&kold_value.it_interval, &old_value->it_interval); |
| 70 | __nolibc_timespec_kernel_to_user(&kold_value.it_value, &old_value->it_value); |
| 71 | } |
| 72 | return ret; |
| 73 | #endif |
| 74 | } |
| 75 | |
| 76 | static __attribute__((unused)) |
| 77 | int timerfd_settime(int fd, int flags, |
| 78 | const struct itimerspec *new_value, struct itimerspec *old_value) |
| 79 | { |
| 80 | return __sysret(sys_timerfd_settime(fd, flags, new_value, old_value)); |
| 81 | } |
| 82 | |
| 83 | #endif /* _NOLIBC_SYS_TIMERFD_H */ |
| 84 |
Warning: That file was not part of the compilation database. It may have many parsing errors.
