time_impl.h


    1 /*
    2  * Copyright (c) 1998-1999 by Sun Microsystems, Inc.
    3  * All rights reserved.
    4  */
    5 
    6 /*
    7  * Implementation-private.  This header should not be included
    8  * directly by an application.  The application should instead
    9  * include  which includes this header.
    10  */
    11 
    12 #ifndef _SYS_TIME_IMPL_H
    13 #define	_SYS_TIME_IMPL_H
    14 
    15 #pragma ident	"@(#)time_impl.h	1.5	99/10/05 SMI"
    16 
    17 #include 
    18 
    19 #ifdef	__cplusplus
    20 extern "C" {
    21 #endif
    22 
    23 #ifndef	_ASM
    24 
    25 #ifndef _TIME_T
    26 #define	_TIME_T
    27 typedef	long	time_t;		/* time of day in seconds */
    28 #endif	/* _TIME_T */
    29 
    30 /*
    31  * Time expressed in seconds and nanoseconds
    32  */
    33 
    34 #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
    35 	(_POSIX_C_SOURCE > 2) || defined(__EXTENSIONS__)
    36 typedef struct  timespec {		/* definition per POSIX.4 */  <timespec>
    37 	time_t		tv_sec;		/* seconds */
    38 	long		tv_nsec;	/* and nanoseconds */
    39 } timespec_t;  <typedef:timespec_t>
    40 
    41 #if defined(_SYSCALL32)
    42 
    43 #include 
    44 
    45 #define	TIMESPEC32_TO_TIMESPEC(ts, ts32)	{	\
    46 	(ts)->tv_sec = (time_t)(ts32)->tv_sec;		\
    47 	(ts)->tv_nsec = (ts32)->tv_nsec;		\
    48 }
    49 
    50 #define	TIMESPEC_TO_TIMESPEC32(ts32, ts)	{	\
    51 	(ts32)->tv_sec = (time32_t)(ts)->tv_sec;	\
    52 	(ts32)->tv_nsec = (ts)->tv_nsec;		\
    53 }
    54 
    55 #define	TIMESPEC_OVERFLOW(ts)		\
    56 	((ts)->tv_sec < TIME32_MIN || (ts)->tv_sec > TIME32_MAX)
    57 
    58 #endif	/* _SYSCALL32 */
    59 
    60 typedef struct timespec timestruc_t;	/* definition per SVr4 */  <typedef:timestruc_t>
    61 
    62 #endif /* (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE_))... */
    63 
    64 /*
    65  * The following has been left in for backward compatibility. Portable
    66  * applications should not use the structure name timestruc.
    67  */
    68 
    69 #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
    70 	defined(__EXTENSIONS__)
    71 #define	timestruc	timespec	/* structure name per SVr4 */
    72 #endif /* (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE))... */
    73 
    74 /*
    75  * Timer specification
    76  */
    77 #if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
    78 	(_POSIX_C_SOURCE > 2) || defined(__EXTENSIONS__)
    79 typedef struct itimerspec {		/* definition per POSIX.4 */  <itimerspec>
    80 	struct timespec	it_interval;	/* timer period */
    81 	struct timespec	it_value;	/* timer expiration */
    82 } itimerspec_t;  <typedef:itimerspec_t>
    83 
    84 #if defined(_SYSCALL32)
    85 
    86 #define	ITIMERSPEC32_TO_ITIMERSPEC(it, it32)	{	\
    87 	TIMESPEC32_TO_TIMESPEC(&(it)->it_interval, &(it32)->it_interval); \
    88 	TIMESPEC32_TO_TIMESPEC(&(it)->it_value, &(it32)->it_value);	\
    89 }
    90 
    91 #define	ITIMERSPEC_TO_ITIMERSPEC32(it32, it)	{	\
    92 	TIMESPEC_TO_TIMESPEC32(&(it32)->it_interval, &(it)->it_interval); \
    93 	TIMESPEC_TO_TIMESPEC32(&(it32)->it_value, &(it)->it_value);	\
    94 }
    95 
    96 #define	ITIMERSPEC_OVERFLOW(it)				\
    97 	(TIMESPEC_OVERFLOW(&(it)->it_interval) &&	\
    98 	TIMESPEC_OVERFLOW(&(it)->it_value))
    99 
    100 #endif	/* _SYSCALL32 */
    101 
    102 #endif /* (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) ... */
    103 
    104 #endif	/* _ASM */
    105 
    106 #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE) || \
    107 	(_POSIX_C_SOURCE > 2) || defined(__EXTENSIONS__)
    108 
    109 #define	__CLOCK_REALTIME0	0	/* wall clock, bound to LWP */
    110 #define	CLOCK_VIRTUAL		1	/* user CPU usage clock */
    111 #define	CLOCK_PROF		2	/* user and system CPU usage clock */
    112 #define	__CLOCK_REALTIME3	3	/* wall clock, not bound */
    113 #define	CLOCK_HIGHRES		4	/* high resolution clock */
    114 
    115 #ifdef _KERNEL
    116 #define	CLOCK_MAX		5
    117 #endif
    118 
    119 /*
    120  * Define CLOCK_REALTIME as per-process if PTHREADS or explicitly requested
    121  *   NOTE: In the future, per-LWP semantics will be removed and
    122  *   __CLOCK_REALTIME0 will have per-process semantics (see timer_create(3R))
    123  */
    124 #if (_POSIX_C_SOURCE >= 199506L) || defined(_POSIX_PER_PROCESS_TIMER_SOURCE)
    125 #define	CLOCK_REALTIME	__CLOCK_REALTIME3
    126 #else
    127 #define	CLOCK_REALTIME	__CLOCK_REALTIME0
    128 #endif
    129 
    130 #define	TIMER_RELTIME	0x0		/* set timer relative */
    131 #define	TIMER_ABSTIME	0x1		/* set timer absolute */
    132 
    133 #endif	/* (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE))... */
    134 
    135 #ifdef	__cplusplus
    136 }
    137 #endif
    138 
    139 #endif	/* _SYS_TIME_IMPL_H */