10a041f3bSBjoern A. Zeeb /*- 20a041f3bSBjoern A. Zeeb * Copyright (c) 2014 Bjoern A. Zeeb 30a041f3bSBjoern A. Zeeb * All rights reserved. 40a041f3bSBjoern A. Zeeb * 50a041f3bSBjoern A. Zeeb * This software was developed by SRI International and the University of 60a041f3bSBjoern A. Zeeb * Cambridge Computer Laboratory under DARPA/AFRL contract FA8750-11-C-0249 70a041f3bSBjoern A. Zeeb * ("MRC2"), as part of the DARPA MRC research programme. 80a041f3bSBjoern A. Zeeb * 90a041f3bSBjoern A. Zeeb * Redistribution and use in source and binary forms, with or without 100a041f3bSBjoern A. Zeeb * modification, are permitted provided that the following conditions 110a041f3bSBjoern A. Zeeb * are met: 120a041f3bSBjoern A. Zeeb * 1. Redistributions of source code must retain the above copyright 130a041f3bSBjoern A. Zeeb * notice, this list of conditions and the following disclaimer. 140a041f3bSBjoern A. Zeeb * 2. Redistributions in binary form must reproduce the above copyright 150a041f3bSBjoern A. Zeeb * notice, this list of conditions and the following disclaimer in the 160a041f3bSBjoern A. Zeeb * documentation and/or other materials provided with the distribution. 170a041f3bSBjoern A. Zeeb * 180a041f3bSBjoern A. Zeeb * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 190a041f3bSBjoern A. Zeeb * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 200a041f3bSBjoern A. Zeeb * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 210a041f3bSBjoern A. Zeeb * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 220a041f3bSBjoern A. Zeeb * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 230a041f3bSBjoern A. Zeeb * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 240a041f3bSBjoern A. Zeeb * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 250a041f3bSBjoern A. Zeeb * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 260a041f3bSBjoern A. Zeeb * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 270a041f3bSBjoern A. Zeeb * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 280a041f3bSBjoern A. Zeeb * SUCH DAMAGE. 290a041f3bSBjoern A. Zeeb * 300a041f3bSBjoern A. Zeeb * $FreeBSD$ 310a041f3bSBjoern A. Zeeb */ 320a041f3bSBjoern A. Zeeb 330a041f3bSBjoern A. Zeeb #ifndef _LINUX_TIMER_H 340a041f3bSBjoern A. Zeeb #define _LINUX_TIMER_H 350a041f3bSBjoern A. Zeeb 36*562894f0SBrooks Davis #include <sys/abi_compat.h> 37*562894f0SBrooks Davis 380a041f3bSBjoern A. Zeeb #ifndef __LINUX_ARCH_SIGEV_PREAMBLE_SIZE 390a041f3bSBjoern A. Zeeb #define __LINUX_ARCH_SIGEV_PREAMBLE_SIZE \ 400a041f3bSBjoern A. Zeeb (sizeof(l_int) * 2 + sizeof(l_sigval_t)) 410a041f3bSBjoern A. Zeeb #endif 420a041f3bSBjoern A. Zeeb 430a041f3bSBjoern A. Zeeb #define LINUX_SIGEV_MAX_SIZE 64 440a041f3bSBjoern A. Zeeb #define LINUX_SIGEV_PAD_SIZE \ 450a041f3bSBjoern A. Zeeb ((LINUX_SIGEV_MAX_SIZE - __LINUX_ARCH_SIGEV_PREAMBLE_SIZE) / \ 460a041f3bSBjoern A. Zeeb sizeof(l_int)) 470a041f3bSBjoern A. Zeeb 480a041f3bSBjoern A. Zeeb #define LINUX_CLOCK_REALTIME 0 490a041f3bSBjoern A. Zeeb #define LINUX_CLOCK_MONOTONIC 1 500a041f3bSBjoern A. Zeeb #define LINUX_CLOCK_PROCESS_CPUTIME_ID 2 510a041f3bSBjoern A. Zeeb #define LINUX_CLOCK_THREAD_CPUTIME_ID 3 520a041f3bSBjoern A. Zeeb #define LINUX_CLOCK_MONOTONIC_RAW 4 530a041f3bSBjoern A. Zeeb #define LINUX_CLOCK_REALTIME_COARSE 5 540a041f3bSBjoern A. Zeeb #define LINUX_CLOCK_MONOTONIC_COARSE 6 550a041f3bSBjoern A. Zeeb #define LINUX_CLOCK_BOOTTIME 7 560a041f3bSBjoern A. Zeeb #define LINUX_CLOCK_REALTIME_ALARM 8 570a041f3bSBjoern A. Zeeb #define LINUX_CLOCK_BOOTTIME_ALARM 9 580a041f3bSBjoern A. Zeeb #define LINUX_CLOCK_SGI_CYCLE 10 590a041f3bSBjoern A. Zeeb #define LINUX_CLOCK_TAI 11 600a041f3bSBjoern A. Zeeb 612711aba9SDmitry Chagin #define LINUX_CPUCLOCK_PERTHREAD_MASK 4 622711aba9SDmitry Chagin #define LINUX_CPUCLOCK_MASK 3 632711aba9SDmitry Chagin #define LINUX_CPUCLOCK_WHICH(clock) \ 642711aba9SDmitry Chagin ((clock) & (clockid_t) LINUX_CPUCLOCK_MASK) 652711aba9SDmitry Chagin #define LINUX_CPUCLOCK_PROF 0 662711aba9SDmitry Chagin #define LINUX_CPUCLOCK_VIRT 1 672711aba9SDmitry Chagin #define LINUX_CPUCLOCK_SCHED 2 682711aba9SDmitry Chagin #define LINUX_CPUCLOCK_MAX 3 692711aba9SDmitry Chagin #define LINUX_CLOCKFD LINUX_CPUCLOCK_MAX 702711aba9SDmitry Chagin #define LINUX_CLOCKFD_MASK \ 712711aba9SDmitry Chagin (LINUX_CPUCLOCK_PERTHREAD_MASK|LINUX_CPUCLOCK_MASK) 722711aba9SDmitry Chagin 732711aba9SDmitry Chagin #define LINUX_CPUCLOCK_ID(clock) ((pid_t) ~((clock) >> 3)) 742711aba9SDmitry Chagin #define LINUX_CPUCLOCK_PERTHREAD(clock) \ 752711aba9SDmitry Chagin (((clock) & (clockid_t) LINUX_CPUCLOCK_PERTHREAD_MASK) != 0) 762711aba9SDmitry Chagin 77f0f58384SDmitry Chagin #define LINUX_TIMER_ABSTIME 0x01 782711aba9SDmitry Chagin 790a041f3bSBjoern A. Zeeb #define L_SIGEV_SIGNAL 0 800a041f3bSBjoern A. Zeeb #define L_SIGEV_NONE 1 810a041f3bSBjoern A. Zeeb #define L_SIGEV_THREAD 2 820a041f3bSBjoern A. Zeeb #define L_SIGEV_THREAD_ID 4 830a041f3bSBjoern A. Zeeb 840a041f3bSBjoern A. Zeeb struct l_sigevent { 850a041f3bSBjoern A. Zeeb l_sigval_t sigev_value; 860a041f3bSBjoern A. Zeeb l_int sigev_signo; 870a041f3bSBjoern A. Zeeb l_int sigev_notify; 880a041f3bSBjoern A. Zeeb union { 890a041f3bSBjoern A. Zeeb l_int _pad[LINUX_SIGEV_PAD_SIZE]; 900a041f3bSBjoern A. Zeeb l_int _tid; 910a041f3bSBjoern A. Zeeb struct { 920a041f3bSBjoern A. Zeeb l_uintptr_t _function; 930a041f3bSBjoern A. Zeeb l_uintptr_t _attribute; 940a041f3bSBjoern A. Zeeb } _l_sigev_thread; 950a041f3bSBjoern A. Zeeb } _l_sigev_un; 960a041f3bSBjoern A. Zeeb } 970a041f3bSBjoern A. Zeeb #if defined(__amd64__) && defined(COMPAT_LINUX32) 980a041f3bSBjoern A. Zeeb __packed 990a041f3bSBjoern A. Zeeb #endif 1000a041f3bSBjoern A. Zeeb ; 1010a041f3bSBjoern A. Zeeb 1020a041f3bSBjoern A. Zeeb struct l_itimerspec { 1030a041f3bSBjoern A. Zeeb struct l_timespec it_interval; 1040a041f3bSBjoern A. Zeeb struct l_timespec it_value; 1050a041f3bSBjoern A. Zeeb }; 1060a041f3bSBjoern A. Zeeb 1070670e972SDmitry Chagin int native_to_linux_timespec(struct l_timespec *, 10868098228SDmitry Chagin struct timespec *); 10968098228SDmitry Chagin int linux_to_native_timespec(struct timespec *, 11068098228SDmitry Chagin struct l_timespec *); 11116ac71bcSDmitry Chagin int linux_to_native_clockid(clockid_t *, clockid_t); 112dd93b628SDmitry Chagin int native_to_linux_itimerspec(struct l_itimerspec *, 113dd93b628SDmitry Chagin struct itimerspec *); 114dd93b628SDmitry Chagin int linux_to_native_itimerspec(struct itimerspec *, 115dd93b628SDmitry Chagin struct l_itimerspec *); 116f0f58384SDmitry Chagin int linux_to_native_timerflags(int *, int); 11768098228SDmitry Chagin 1180a041f3bSBjoern A. Zeeb #endif /* _LINUX_TIMER_H */ 119