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 #pragma ident "%Z%%M% %I% %E% SMI" 41*7c478bd9Sstevel@tonic-gate 42*7c478bd9Sstevel@tonic-gate #include <sys/feature_tests.h> 43*7c478bd9Sstevel@tonic-gate 44*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 45*7c478bd9Sstevel@tonic-gate extern "C" { 46*7c478bd9Sstevel@tonic-gate #endif 47*7c478bd9Sstevel@tonic-gate 48*7c478bd9Sstevel@tonic-gate #ifndef _ASM 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gate #if !defined(_TIME_T) || __cplusplus >= 199711L 51*7c478bd9Sstevel@tonic-gate #define _TIME_T 52*7c478bd9Sstevel@tonic-gate typedef long time_t; /* time of day in seconds */ 53*7c478bd9Sstevel@tonic-gate #endif /* _TIME_T */ 54*7c478bd9Sstevel@tonic-gate 55*7c478bd9Sstevel@tonic-gate /* 56*7c478bd9Sstevel@tonic-gate * Time expressed in seconds and nanoseconds 57*7c478bd9Sstevel@tonic-gate */ 58*7c478bd9Sstevel@tonic-gate 59*7c478bd9Sstevel@tonic-gate typedef struct timespec { /* definition per POSIX.4 */ 60*7c478bd9Sstevel@tonic-gate time_t tv_sec; /* seconds */ 61*7c478bd9Sstevel@tonic-gate long tv_nsec; /* and nanoseconds */ 62*7c478bd9Sstevel@tonic-gate } timespec_t; 63*7c478bd9Sstevel@tonic-gate 64*7c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 65*7c478bd9Sstevel@tonic-gate 66*7c478bd9Sstevel@tonic-gate #include <sys/types32.h> 67*7c478bd9Sstevel@tonic-gate 68*7c478bd9Sstevel@tonic-gate #define TIMESPEC32_TO_TIMESPEC(ts, ts32) { \ 69*7c478bd9Sstevel@tonic-gate (ts)->tv_sec = (time_t)(ts32)->tv_sec; \ 70*7c478bd9Sstevel@tonic-gate (ts)->tv_nsec = (ts32)->tv_nsec; \ 71*7c478bd9Sstevel@tonic-gate } 72*7c478bd9Sstevel@tonic-gate 73*7c478bd9Sstevel@tonic-gate #define TIMESPEC_TO_TIMESPEC32(ts32, ts) { \ 74*7c478bd9Sstevel@tonic-gate (ts32)->tv_sec = (time32_t)(ts)->tv_sec; \ 75*7c478bd9Sstevel@tonic-gate (ts32)->tv_nsec = (ts)->tv_nsec; \ 76*7c478bd9Sstevel@tonic-gate } 77*7c478bd9Sstevel@tonic-gate 78*7c478bd9Sstevel@tonic-gate #define TIMESPEC_OVERFLOW(ts) \ 79*7c478bd9Sstevel@tonic-gate ((ts)->tv_sec < TIME32_MIN || (ts)->tv_sec > TIME32_MAX) 80*7c478bd9Sstevel@tonic-gate 81*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 82*7c478bd9Sstevel@tonic-gate 83*7c478bd9Sstevel@tonic-gate typedef struct timespec timestruc_t; /* definition per SVr4 */ 84*7c478bd9Sstevel@tonic-gate 85*7c478bd9Sstevel@tonic-gate /* 86*7c478bd9Sstevel@tonic-gate * The following has been left in for backward compatibility. Portable 87*7c478bd9Sstevel@tonic-gate * applications should not use the structure name timestruc. 88*7c478bd9Sstevel@tonic-gate */ 89*7c478bd9Sstevel@tonic-gate 90*7c478bd9Sstevel@tonic-gate #if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) 91*7c478bd9Sstevel@tonic-gate #define timestruc timespec /* structure name per SVr4 */ 92*7c478bd9Sstevel@tonic-gate #endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */ 93*7c478bd9Sstevel@tonic-gate 94*7c478bd9Sstevel@tonic-gate /* 95*7c478bd9Sstevel@tonic-gate * Timer specification 96*7c478bd9Sstevel@tonic-gate */ 97*7c478bd9Sstevel@tonic-gate typedef struct itimerspec { /* definition per POSIX.4 */ 98*7c478bd9Sstevel@tonic-gate struct timespec it_interval; /* timer period */ 99*7c478bd9Sstevel@tonic-gate struct timespec it_value; /* timer expiration */ 100*7c478bd9Sstevel@tonic-gate } itimerspec_t; 101*7c478bd9Sstevel@tonic-gate 102*7c478bd9Sstevel@tonic-gate #if defined(_SYSCALL32) 103*7c478bd9Sstevel@tonic-gate 104*7c478bd9Sstevel@tonic-gate #define ITIMERSPEC32_TO_ITIMERSPEC(it, it32) { \ 105*7c478bd9Sstevel@tonic-gate TIMESPEC32_TO_TIMESPEC(&(it)->it_interval, &(it32)->it_interval); \ 106*7c478bd9Sstevel@tonic-gate TIMESPEC32_TO_TIMESPEC(&(it)->it_value, &(it32)->it_value); \ 107*7c478bd9Sstevel@tonic-gate } 108*7c478bd9Sstevel@tonic-gate 109*7c478bd9Sstevel@tonic-gate #define ITIMERSPEC_TO_ITIMERSPEC32(it32, it) { \ 110*7c478bd9Sstevel@tonic-gate TIMESPEC_TO_TIMESPEC32(&(it32)->it_interval, &(it)->it_interval); \ 111*7c478bd9Sstevel@tonic-gate TIMESPEC_TO_TIMESPEC32(&(it32)->it_value, &(it)->it_value); \ 112*7c478bd9Sstevel@tonic-gate } 113*7c478bd9Sstevel@tonic-gate 114*7c478bd9Sstevel@tonic-gate #define ITIMERSPEC_OVERFLOW(it) \ 115*7c478bd9Sstevel@tonic-gate (TIMESPEC_OVERFLOW(&(it)->it_interval) && \ 116*7c478bd9Sstevel@tonic-gate TIMESPEC_OVERFLOW(&(it)->it_value)) 117*7c478bd9Sstevel@tonic-gate 118*7c478bd9Sstevel@tonic-gate #endif /* _SYSCALL32 */ 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate #endif /* _ASM */ 121*7c478bd9Sstevel@tonic-gate 122*7c478bd9Sstevel@tonic-gate #define __CLOCK_REALTIME0 0 /* obsolete; same as CLOCK_REALTIME */ 123*7c478bd9Sstevel@tonic-gate #define CLOCK_VIRTUAL 1 /* thread's user-level CPU clock */ 124*7c478bd9Sstevel@tonic-gate #define CLOCK_THREAD_CPUTIME_ID 2 /* thread's user+system CPU clock */ 125*7c478bd9Sstevel@tonic-gate #define CLOCK_REALTIME 3 /* wall clock */ 126*7c478bd9Sstevel@tonic-gate #define CLOCK_MONOTONIC 4 /* high resolution monotonic clock */ 127*7c478bd9Sstevel@tonic-gate #define CLOCK_PROCESS_CPUTIME_ID 5 /* process's user+system CPU clock */ 128*7c478bd9Sstevel@tonic-gate #define CLOCK_HIGHRES CLOCK_MONOTONIC /* alternate name */ 129*7c478bd9Sstevel@tonic-gate #define CLOCK_PROF CLOCK_THREAD_CPUTIME_ID /* alternate name */ 130*7c478bd9Sstevel@tonic-gate 131*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 132*7c478bd9Sstevel@tonic-gate #define CLOCK_MAX 6 133*7c478bd9Sstevel@tonic-gate #endif 134*7c478bd9Sstevel@tonic-gate 135*7c478bd9Sstevel@tonic-gate #define TIMER_RELTIME 0x0 /* set timer relative */ 136*7c478bd9Sstevel@tonic-gate #define TIMER_ABSTIME 0x1 /* set timer absolute */ 137*7c478bd9Sstevel@tonic-gate 138*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 139*7c478bd9Sstevel@tonic-gate } 140*7c478bd9Sstevel@tonic-gate #endif 141*7c478bd9Sstevel@tonic-gate 142*7c478bd9Sstevel@tonic-gate #endif /* _SYS_TIME_IMPL_H */ 143