2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
13 * Copyright (c) 2015 Joyent, Inc. All rights reserved.
17 * Header file to support for the timerfd facility.
20 #ifndef _SYS_TIMERFD_H
21 #define _SYS_TIMERFD_H
23 #include <sys/types.h>
24 #include <sys/time_impl.h>
31 * To assure binary compatibility with Linux, these values are fixed at their
32 * Linux equivalents, not their native ones.
34 #define TFD_CLOEXEC 02000000 /* LX_O_CLOEXEC */
35 #define TFD_NONBLOCK 04000 /* LX_O_NONBLOCK */
36 #define TFD_TIMER_ABSTIME (1 << 0)
37 #define TFD_TIMER_CANCEL_ON_SET (1 << 1)
40 * These ioctl values are specific to the native implementation; applications
41 * shouldn't be using them directly, and they should therefore be safe to
42 * change without breaking apps.
44 #define TIMERFDIOC (('t' << 24) | ('f' << 16) | ('d' << 8))
45 #define TIMERFDIOC_CREATE (TIMERFDIOC | 1) /* create timer */
46 #define TIMERFDIOC_SETTIME (TIMERFDIOC | 2) /* timerfd_settime() */
47 #define TIMERFDIOC_GETTIME (TIMERFDIOC | 3) /* timerfd_gettime() */
49 typedef struct timerfd_settime
{
50 uint64_t tfd_settime_flags
; /* flags (e.g., TFD_TIMER_ABSTIME) */
51 uint64_t tfd_settime_value
; /* pointer to value */
52 uint64_t tfd_settime_ovalue
; /* pointer to old value, if any */
57 extern int timerfd_create(int, int);
58 extern int timerfd_settime(int, int,
59 const struct itimerspec
*, struct itimerspec
*);
60 extern int timerfd_gettime(int, struct itimerspec
*);
64 #define TIMERFDMNRN_TIMERFD 0
65 #define TIMERFDMNRN_CLONE 1
66 #define TIMERFD_VALMAX (ULLONG_MAX - 1ULL)
69 * Fortunately, the values for the Linux clocks that are valid for timerfd
70 * (namely, CLOCK_REALTIME and CLOCK_MONOTONIC) don't overlap with our values
73 #define TIMERFD_MONOTONIC 1 /* Linux value for CLOCK_MONOTONIC */
81 #endif /* _SYS_TIMERFD_H */