1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* 28*7c478bd9Sstevel@tonic-gate * Implementation-private. This header should not be included 29*7c478bd9Sstevel@tonic-gate * directly by an application. The application should instead 30*7c478bd9Sstevel@tonic-gate * include <time.h> which includes this header conditionally 31*7c478bd9Sstevel@tonic-gate * depending on which feature test macros are defined. By default, 32*7c478bd9Sstevel@tonic-gate * this header is included by <time.h>. X/Open and POSIX 33*7c478bd9Sstevel@tonic-gate * standards requirements result in this header being included 34*7c478bd9Sstevel@tonic-gate * by <time.h> only under a restricted set of conditions. 35*7c478bd9Sstevel@tonic-gate */ 36*7c478bd9Sstevel@tonic-gate 37*7c478bd9Sstevel@tonic-gate #ifndef _SYS_TIME_IMPL_H 38*7c478bd9Sstevel@tonic-gate #define _SYS_TIME_IMPL_H 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h> 41*7c478bd9Sstevel@tonic-gate 42*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 43*7c478bd9Sstevel@tonic-gate extern "C" { 44*7c478bd9Sstevel@tonic-gate #endif 45*7c478bd9Sstevel@tonic-gate 46*7c478bd9Sstevel@tonic-gate #ifndef _ASM 47*7c478bd9Sstevel@tonic-gate 48*7c478bd9Sstevel@tonic-gate #if !defined(_TIME_T) || __cplusplus >= 199711L 49*7c478bd9Sstevel@tonic-gate #define _TIME_T 50*7c478bd9Sstevel@tonic-gate typedef long time_t; /* time of day in seconds */ 51*7c478bd9Sstevel@tonic-gate #endif /* _TIME_T */ 52*7c478bd9Sstevel@tonic-gate 53*7c478bd9Sstevel@tonic-gate /* 54*7c478bd9Sstevel@tonic-gate * Time expressed in seconds and nanoseconds 55*7c478bd9Sstevel@tonic-gate */ 56*7c478bd9Sstevel@tonic-gate 57*7c478bd9Sstevel@tonic-gate typedef struct timespec { /* definition per POSIX.4 */ 58*7c478bd9Sstevel@tonic-gate time_t tv_sec; /* seconds */ 59*7c478bd9Sstevel@tonic-gate long tv_nsec; /* and nanoseconds */ 60*7c478bd9Sstevel@tonic-gate } timespec_t; 61*7c478bd9Sstevel@tonic-gate 62*7c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 63*7c478bd9Sstevel@tonic-gate 64*7c478bd9Sstevel@tonic-gate #include <sys/types32.h> 65*7c478bd9Sstevel@tonic-gate 66*7c478bd9Sstevel@tonic-gate #define TIMESPEC32_TO_TIMESPEC(ts, ts32) { \ 67*7c478bd9Sstevel@tonic-gate (ts)->tv_sec = (time_t)(ts32)->tv_sec; \ 68*7c478bd9Sstevel@tonic-gate (ts)->tv_nsec = (ts32)->tv_nsec; \ 69*7c478bd9Sstevel@tonic-gate } 70*7c478bd9Sstevel@tonic-gate 71*7c478bd9Sstevel@tonic-gate #define TIMESPEC_TO_TIMESPEC32(ts32, ts) { \ 72*7c478bd9Sstevel@tonic-gate (ts32)->tv_sec = (time32_t)(ts)->tv_sec; \ 73*7c478bd9Sstevel@tonic-gate (ts32)->tv_nsec = (ts)->tv_nsec; \ 74*7c478bd9Sstevel@tonic-gate } 75*7c478bd9Sstevel@tonic-gate 76*7c478bd9Sstevel@tonic-gate #define TIMESPEC_OVERFLOW(ts) \ 77*7c478bd9Sstevel@tonic-gate ((ts)->tv_sec < TIME32_MIN || (ts)->tv_sec > TIME32_MAX) 78*7c478bd9Sstevel@tonic-gate 79*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 80*7c478bd9Sstevel@tonic-gate 81*7c478bd9Sstevel@tonic-gate typedef struct timespec timestruc_t; /* definition per SVr4 */ 82*7c478bd9Sstevel@tonic-gate 83*7c478bd9Sstevel@tonic-gate /* 84*7c478bd9Sstevel@tonic-gate * The following has been left in for backward compatibility. Portable 85*7c478bd9Sstevel@tonic-gate * applications should not use the structure name timestruc. 86*7c478bd9Sstevel@tonic-gate */ 87*7c478bd9Sstevel@tonic-gate 88*7c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 89*7c478bd9Sstevel@tonic-gate #define timestruc timespec /* structure name per SVr4 */ 90*7c478bd9Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 91*7c478bd9Sstevel@tonic-gate 92*7c478bd9Sstevel@tonic-gate /* 93*7c478bd9Sstevel@tonic-gate * Timer specification 94*7c478bd9Sstevel@tonic-gate */ 95*7c478bd9Sstevel@tonic-gate typedef struct itimerspec { /* definition per POSIX.4 */ 96*7c478bd9Sstevel@tonic-gate struct timespec it_interval; /* timer period */ 97*7c478bd9Sstevel@tonic-gate struct timespec it_value; /* timer expiration */ 98*7c478bd9Sstevel@tonic-gate } itimerspec_t; 99*7c478bd9Sstevel@tonic-gate 100*7c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 101*7c478bd9Sstevel@tonic-gate 102*7c478bd9Sstevel@tonic-gate #define ITIMERSPEC32_TO_ITIMERSPEC(it, it32) { \ 103*7c478bd9Sstevel@tonic-gate TIMESPEC32_TO_TIMESPEC(&(it)->it_interval, &(it32)->it_interval); \ 104*7c478bd9Sstevel@tonic-gate TIMESPEC32_TO_TIMESPEC(&(it)->it_value, &(it32)->it_value); \ 105*7c478bd9Sstevel@tonic-gate } 106*7c478bd9Sstevel@tonic-gate 107*7c478bd9Sstevel@tonic-gate #define ITIMERSPEC_TO_ITIMERSPEC32(it32, it) { \ 108*7c478bd9Sstevel@tonic-gate TIMESPEC_TO_TIMESPEC32(&(it32)->it_interval, &(it)->it_interval); \ 109*7c478bd9Sstevel@tonic-gate TIMESPEC_TO_TIMESPEC32(&(it32)->it_value, &(it)->it_value); \ 110*7c478bd9Sstevel@tonic-gate } 111*7c478bd9Sstevel@tonic-gate 112*7c478bd9Sstevel@tonic-gate #define ITIMERSPEC_OVERFLOW(it) \ 113*7c478bd9Sstevel@tonic-gate (TIMESPEC_OVERFLOW(&(it)->it_interval) && \ 114*7c478bd9Sstevel@tonic-gate TIMESPEC_OVERFLOW(&(it)->it_value)) 115*7c478bd9Sstevel@tonic-gate 116*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 117*7c478bd9Sstevel@tonic-gate 118*7c478bd9Sstevel@tonic-gate #endif /* _ASM */ 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate #define __CLOCK_REALTIME0 0 /* obsolete; same as CLOCK_REALTIME */ 121*7c478bd9Sstevel@tonic-gate #define CLOCK_VIRTUAL 1 /* thread's user-level CPU clock */ 122*7c478bd9Sstevel@tonic-gate #define CLOCK_THREAD_CPUTIME_ID 2 /* thread's user+system CPU clock */ 123*7c478bd9Sstevel@tonic-gate #define CLOCK_REALTIME 3 /* wall clock */ 124*7c478bd9Sstevel@tonic-gate #define CLOCK_MONOTONIC 4 /* high resolution monotonic clock */ 125*7c478bd9Sstevel@tonic-gate #define CLOCK_PROCESS_CPUTIME_ID 5 /* process's user+system CPU clock */ 126*7c478bd9Sstevel@tonic-gate #define CLOCK_HIGHRES CLOCK_MONOTONIC /* alternate name */ 127*7c478bd9Sstevel@tonic-gate #define CLOCK_PROF CLOCK_THREAD_CPUTIME_ID /* alternate name */ 128*7c478bd9Sstevel@tonic-gate 129*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 130*7c478bd9Sstevel@tonic-gate #define CLOCK_MAX 6 131*7c478bd9Sstevel@tonic-gate #endif 132*7c478bd9Sstevel@tonic-gate 133*7c478bd9Sstevel@tonic-gate #define TIMER_RELTIME 0x0 /* set timer relative */ 134*7c478bd9Sstevel@tonic-gate #define TIMER_ABSTIME 0x1 /* set timer absolute */ 135*7c478bd9Sstevel@tonic-gate 136*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 137*7c478bd9Sstevel@tonic-gate } 138*7c478bd9Sstevel@tonic-gate #endif 139*7c478bd9Sstevel@tonic-gate 140*7c478bd9Sstevel@tonic-gate #endif /* _SYS_TIME_IMPL_H */ 141