docs/how-to-build.md: use proper markup for directory names
[unleashed/tickless.git] / include / sys / timerfd.h
blob66cb50ac88de8b74d37af7b7c6891fd49b97a2e5
1 /*
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
5 * 1.0 of the CDDL.
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>
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
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 */
53 } timerfd_settime_t;
55 #ifndef _KERNEL
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 *);
62 #else
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
71 * the same.
73 #define TIMERFD_MONOTONIC 1 /* Linux value for CLOCK_MONOTONIC */
75 #endif /* _KERNEL */
77 #ifdef __cplusplus
79 #endif
81 #endif /* _SYS_TIMERFD_H */