2 * Copyright (c) 2014 Bjoern A. Zeeb
5 * This software was developed by SRI International and the University of
6 * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-11-C-0249
7 * ("MRC2"), as part of the DARPA MRC research programme.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 #ifndef _LINUX_TIMER_H
34 #define _LINUX_TIMER_H
36 #ifndef __LINUX_ARCH_SIGEV_PREAMBLE_SIZE
37 #define __LINUX_ARCH_SIGEV_PREAMBLE_SIZE \
38 (sizeof(l_int) * 2 + sizeof(l_sigval_t))
41 #define LINUX_SIGEV_MAX_SIZE 64
42 #define LINUX_SIGEV_PAD_SIZE \
43 ((LINUX_SIGEV_MAX_SIZE - __LINUX_ARCH_SIGEV_PREAMBLE_SIZE) / \
46 #define LINUX_CLOCK_REALTIME 0
47 #define LINUX_CLOCK_MONOTONIC 1
48 #define LINUX_CLOCK_PROCESS_CPUTIME_ID 2
49 #define LINUX_CLOCK_THREAD_CPUTIME_ID 3
50 #define LINUX_CLOCK_MONOTONIC_RAW 4
51 #define LINUX_CLOCK_REALTIME_COARSE 5
52 #define LINUX_CLOCK_MONOTONIC_COARSE 6
53 #define LINUX_CLOCK_BOOTTIME 7
54 #define LINUX_CLOCK_REALTIME_ALARM 8
55 #define LINUX_CLOCK_BOOTTIME_ALARM 9
56 #define LINUX_CLOCK_SGI_CYCLE 10
57 #define LINUX_CLOCK_TAI 11
59 #define LINUX_CPUCLOCK_PERTHREAD_MASK 4
60 #define LINUX_CPUCLOCK_MASK 3
61 #define LINUX_CPUCLOCK_WHICH(clock) \
62 ((clock) & (clockid_t) LINUX_CPUCLOCK_MASK)
63 #define LINUX_CPUCLOCK_PROF 0
64 #define LINUX_CPUCLOCK_VIRT 1
65 #define LINUX_CPUCLOCK_SCHED 2
66 #define LINUX_CPUCLOCK_MAX 3
67 #define LINUX_CLOCKFD LINUX_CPUCLOCK_MAX
68 #define LINUX_CLOCKFD_MASK \
69 (LINUX_CPUCLOCK_PERTHREAD_MASK|LINUX_CPUCLOCK_MASK)
71 #define LINUX_CPUCLOCK_ID(clock) ((pid_t) ~((clock) >> 3))
72 #define LINUX_CPUCLOCK_PERTHREAD(clock) \
73 (((clock) & (clockid_t) LINUX_CPUCLOCK_PERTHREAD_MASK) != 0)
76 #define L_SIGEV_SIGNAL 0
77 #define L_SIGEV_NONE 1
78 #define L_SIGEV_THREAD 2
79 #define L_SIGEV_THREAD_ID 4
81 #define TS_CP(src,dst,fld) do { \
82 CP((src).fld,(dst).fld,tv_sec); \
83 CP((src).fld,(dst).fld,tv_nsec); \
86 #define ITS_CP(src, dst) do { \
87 TS_CP((src), (dst), it_interval); \
88 TS_CP((src), (dst), it_value); \
92 l_sigval_t sigev_value;
96 l_int _pad[LINUX_SIGEV_PAD_SIZE];
99 l_uintptr_t _function;
100 l_uintptr_t _attribute;
104 #if defined(__amd64__) && defined(COMPAT_LINUX32)
109 struct l_itimerspec {
110 struct l_timespec it_interval;
111 struct l_timespec it_value;
114 void native_to_linux_timespec(struct l_timespec *,
116 int linux_to_native_timespec(struct timespec *,
117 struct l_timespec *);
118 int linux_to_native_clockid(clockid_t *, clockid_t);
120 #endif /* _LINUX_TIMER_H */