1af93fea7SJake Freeland /*- 2af93fea7SJake Freeland * SPDX-License-Identifier: BSD-2-Clause 3af93fea7SJake Freeland * 4af93fea7SJake Freeland * Copyright (c) 2023 Jake Freeland <jfree@FreeBSD.org> 5af93fea7SJake Freeland * 6af93fea7SJake Freeland * Redistribution and use in source and binary forms, with or without 7af93fea7SJake Freeland * modification, are permitted provided that the following conditions 8af93fea7SJake Freeland * are met: 9af93fea7SJake Freeland * 1. Redistributions of source code must retain the above copyright 10af93fea7SJake Freeland * notice, this list of conditions and the following disclaimer. 11af93fea7SJake Freeland * 2. Redistributions in binary form must reproduce the above copyright 12af93fea7SJake Freeland * notice, this list of conditions and the following disclaimer in the 13af93fea7SJake Freeland * documentation and/or other materials provided with the distribution. 14af93fea7SJake Freeland * 15af93fea7SJake Freeland * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16af93fea7SJake Freeland * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17af93fea7SJake Freeland * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18af93fea7SJake Freeland * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19af93fea7SJake Freeland * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20af93fea7SJake Freeland * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21af93fea7SJake Freeland * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22af93fea7SJake Freeland * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23af93fea7SJake Freeland * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24af93fea7SJake Freeland * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25af93fea7SJake Freeland * SUCH DAMAGE. 26af93fea7SJake Freeland */ 27af93fea7SJake Freeland 28af93fea7SJake Freeland #ifndef _SYS_TIMERFD_H_ 29af93fea7SJake Freeland #define _SYS_TIMERFD_H_ 30af93fea7SJake Freeland 31af93fea7SJake Freeland #include <sys/types.h> 32af93fea7SJake Freeland #include <sys/fcntl.h> 33fb5daae9SJake Freeland /* 34fb5daae9SJake Freeland * We only need <sys/timespec.h>, but glibc pollutes the namespace 35fb5daae9SJake Freeland * with <time.h>. This pollution is expected by most programs, so 36fb5daae9SJake Freeland * reproduce it by including <sys/time.h> here. 37fb5daae9SJake Freeland */ 38fb5daae9SJake Freeland #include <sys/time.h> 39af93fea7SJake Freeland 40af93fea7SJake Freeland typedef uint64_t timerfd_t; 41af93fea7SJake Freeland 42af93fea7SJake Freeland /* Creation flags. */ 43af93fea7SJake Freeland #define TFD_NONBLOCK O_NONBLOCK 44af93fea7SJake Freeland #define TFD_CLOEXEC O_CLOEXEC 45af93fea7SJake Freeland 46af93fea7SJake Freeland /* Timer flags. */ 47af93fea7SJake Freeland #define TFD_TIMER_ABSTIME 0x01 48af93fea7SJake Freeland #define TFD_TIMER_CANCEL_ON_SET 0x02 49af93fea7SJake Freeland 50af93fea7SJake Freeland #ifndef _KERNEL 51af93fea7SJake Freeland 52af93fea7SJake Freeland __BEGIN_DECLS 53af93fea7SJake Freeland int timerfd_create(int clockid, int flags); 54af93fea7SJake Freeland int timerfd_gettime(int fd, struct itimerspec *curr_value); 55af93fea7SJake Freeland int timerfd_settime(int fd, int flags, const struct itimerspec *new_value, 56af93fea7SJake Freeland struct itimerspec *old_value); 57af93fea7SJake Freeland __END_DECLS 58af93fea7SJake Freeland 59af93fea7SJake Freeland #else /* _KERNEL */ 60af93fea7SJake Freeland 61af93fea7SJake Freeland void timerfd_jumped(void); 62af93fea7SJake Freeland 63af93fea7SJake Freeland #endif /* !_KERNEL */ 64af93fea7SJake Freeland 65af93fea7SJake Freeland #endif /* !_SYS_TIMERFD_H_ */ 66