| 1 |
|
| 2 | |
| 3 | * timerfd definitions for NOLIBC
|
| 4 | * Copyright (C) 2025 Thomas Weißschuh <[email protected]>
|
| 5 |
|
| 6 |
|
| 7 |
|
| 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 __nolibc_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 | __nolibc_assert_time64_type(curr_value->it_value.tv_sec);
|
| 37 | return __nolibc_syscall2(__NR_timerfd_gettime64, fd, curr_value);
|
| 38 | #else
|
| 39 | __nolibc_assert_native_time64();
|
| 40 | return __nolibc_syscall2(__NR_timerfd_gettime, fd, curr_value);
|
| 41 | #endif
|
| 42 | }
|
| 43 |
|
| 44 | static __attribute__((unused))
|
| 45 | int timerfd_gettime(int fd, struct itimerspec *curr_value)
|
| 46 | {
|
| 47 | return __sysret(_sys_timerfd_gettime(fd, curr_value));
|
| 48 | }
|
| 49 |
|
| 50 |
|
| 51 | static __attribute__((unused))
|
| 52 | int _sys_timerfd_settime(int fd, int flags,
|
| 53 | const struct itimerspec *new_value, struct itimerspec *old_value)
|
| 54 | {
|
| 55 | #if defined(__NR_timerfd_settime64)
|
| 56 | __nolibc_assert_time64_type(new_value->it_value.tv_sec);
|
| 57 | return __nolibc_syscall4(__NR_timerfd_settime64, fd, flags, new_value, old_value);
|
| 58 | #else
|
| 59 | __nolibc_assert_native_time64();
|
| 60 | return __nolibc_syscall4(__NR_timerfd_settime, fd, flags, new_value, old_value);
|
| 61 | #endif
|
| 62 | }
|
| 63 |
|
| 64 | static __attribute__((unused))
|
| 65 | int timerfd_settime(int fd, int flags,
|
| 66 | const struct itimerspec *new_value, struct itimerspec *old_value)
|
| 67 | {
|
| 68 | return __sysret(_sys_timerfd_settime(fd, flags, new_value, old_value));
|
| 69 | }
|
| 70 |
|
| 71 | #endif
|