time.h revision 0689f76c08c5e553ff25ac43a852b56c430bb61e
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright (c) 1982, 1986, 1993 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_TIME_H
#define _SYS_TIME_H
#include <sys/feature_tests.h>
/*
* Structure returned by gettimeofday(2) system call,
* and used in other calls.
*/
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || \
defined(__EXTENSIONS__)
#ifndef _ASM
#define _TIME_T
typedef long time_t; /* time of day in seconds */
#endif /* _TIME_T */
#ifndef _SUSECONDS_T
#define _SUSECONDS_T
typedef long suseconds_t; /* signed # of microseconds */
#endif /* _SUSECONDS_T */
struct timeval {
};
#if defined(_SYSCALL32)
}
}
#define TIME32_MAX INT32_MAX
#define TIME32_MIN INT32_MIN
#define TIMEVAL_OVERFLOW(tv) \
#endif /* _SYSCALL32 || _KERNEL */
#endif /* _ASM */
#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) ... */
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
#ifndef _ASM
struct timezone {
int tz_minuteswest; /* minutes west of Greenwich */
int tz_dsttime; /* type of dst correction */
};
#endif /* _ASM */
#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
#ifdef __cplusplus
}
#endif
/*
* structure.
*/
#ifndef _ASM
#endif /* _ASM */
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
#define DST_NONE 0 /* not on dst */
/*
* Operations on timevals.
*/
/* CSTYLED */ \
/* CSTYLED */ \
#ifdef __lint
/*
* Make innocuous, lint-happy versions until do {} while (0) is acknowleged as
* lint-safe. If the compiler could know that we always make tv_usec < 1000000
* we wouldn't need a special linted version.
*/
do \
{ \
{ \
} \
do \
{ \
{ \
} \
#else
do \
{ \
{ \
} \
} while (0)
do \
{ \
{ \
} \
} while (0)
#endif /* __lint */
#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
/*
* Names of the interval timers, and structure
* defining a timer setting.
*/
#define ITIMER_REAL 0 /* Decrements in real time */
/* time and when system is running on */
/* behalf of the process. */
/* time profiling of multithreaded */
/* programs. */
#ifndef _ASM
struct itimerval {
};
#if defined(_SYSCALL32)
struct itimerval32 {
struct timeval32 it_interval;
};
}
}
#define ITIMERVAL_OVERFLOW(itv) \
#endif /* _SYSCALL32 */
#endif /* _ASM */
#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) ... */
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
/*
* Definitions for commonly used resolutions.
*/
#define SEC 1
#define MILLISEC 1000
#define MICROSEC 1000000
#define NANOSEC 1000000000
#endif /* !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__) */
#ifndef _ASM
/*
* Time expressed as a 64-bit nanosecond counter.
*/
typedef longlong_t hrtime_t;
#ifdef _KERNEL
#include <sys/time_impl.h>
extern int tick_per_msec; /* clock ticks per millisecond (may be zero) */
extern int msec_per_tick; /* milliseconds per clock tick (may be zero) */
extern int usec_per_tick; /* microseconds per clock tick */
extern int nsec_per_tick; /* nanoseconds per clock tick */
/*
* Macros to convert from common units of time (sec, msec, usec, nsec,
* timeval, timestruc) to clock ticks and vice versa.
*/
#define TICK_TO_MSEC(tick) \
#define MSEC_TO_TICK(msec) \
#define MSEC_TO_TICK_ROUNDUP(msec) \
(msec_per_tick ? \
(msec) * tick_per_msec)
#define USEC_TO_TICK_ROUNDUP(usec) \
#define NSEC_TO_TICK_ROUNDUP(nsec) \
}
}
}
}
#define TIMEVAL_TO_TICK(tvp) \
#define TIMESTRUC_TO_TICK(tsp) \
typedef struct todinfo {
int tod_sec; /* seconds 0-59 */
int tod_min; /* minutes 0-59 */
int tod_hour; /* hours 0-23 */
int tod_dow; /* day of week 1-7 */
int tod_day; /* day of month 1-31 */
int tod_month; /* month 1-12 */
int tod_year; /* year 70+ */
} todinfo_t;
extern int timechanged;
extern int tod_needsync;
extern volatile timestruc_t hrestime;
extern hrtime_t hres_last_tick;
extern int64_t hrestime_adj;
extern timestruc_t tod_get(void);
extern void tod_set(timestruc_t);
extern void set_hrestime(timestruc_t *);
extern int hr_clock_lock(void);
extern void hr_clock_unlock(int);
extern hrtime_t gethrtime_unscaled(void);
extern hrtime_t gethrtime_max(void);
extern hrtime_t gethrtime_waitfree(void);
extern void scalehrtime(hrtime_t *);
extern void gethrestime(timespec_t *);
extern time_t gethrestime_sec(void);
extern void gethrestime_lasttick(timespec_t *);
extern int itimerdecr(struct itimerval *, int);
extern void timevalfix(struct timeval *);
extern void dtrace_hres_tick(void);
extern clock_t ddi_get_lbolt(void);
extern int64_t ddi_get_lbolt64(void);
#if defined(_SYSCALL32)
#endif
#endif /* _KERNEL */
#if defined(__STDC__)
#else
int adjtime();
#endif
#endif /* !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) ... */
#if !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) || \
defined(_ATFILE_SOURCE) || defined(__EXTENSIONS__)
#if defined(__STDC__)
#else
int futimesat();
#endif /* defined(__STDC__) */
#endif /* defined(__ATFILE_SOURCE) */
defined(__EXTENSIONS__)
#if defined(__STDC__)
#if defined(_XPG4_2)
struct itimerval *_RESTRICT_KYWD);
#else
struct itimerval *_RESTRICT_KYWD);
#endif /* defined(_XPG2_2) */
#else /* __STDC__ */
int gettimer();
int settimer();
int utimes();
#endif /* __STDC__ */
#endif /* !defined(_KERNEL) ... defined(_XPG4_2) */
/*
* gettimeofday() and settimeofday() were included in SVr4 due to their
* common use in BSD based applications. They were to be included exactly
* parameter was unused and deleted it, thereby making a routine included
* for compatibility, incompatible.
*
* XSH4.2 (spec 1170) defines gettimeofday and settimeofday to have two
* parameters.
*
* This has caused general disagreement in the application community as to
* the syntax of these routines. Solaris defaults to the XSH4.2 definition.
* The flag _SVID_GETTOD may be used to force the SVID version.
*/
#if defined(__STDC__)
#if defined(_SVID_GETTOD)
int settimeofday(struct timeval *);
#else
int settimeofday(struct timeval *, void *);
#endif
hrtime_t gethrvtime(void);
#else /* __STDC__ */
int settimeofday();
#endif /* __STDC__ */
#endif /* !(defined _KERNEL) && !defined(__XOPEN_OR_POSIX) ... */
defined(__EXTENSIONS__)
#if defined(__STDC__)
#if defined(_SVID_GETTOD)
int gettimeofday(struct timeval *);
#else
#endif
#else /* __STDC__ */
int gettimeofday();
#endif /* __STDC__ */
#endif /* !defined(_KERNEL) && !defined(__XOPEN_OR_POSIX) ... */
/*
* The inclusion of <time.h> is historical and was added for
* backward compatibility in delta 1.2 when a number of definitions
* itimerspec structure definitions, along with the _CLOCK_*, CLOCK_*,
* _TIMER_*, and TIMER_* symbols were moved to <sys/time_impl.h>,
* which is now included by <time.h>. This change was due to POSIX
* visible these definitions.
*/
!defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
#include <time.h>
#endif
/*
* FD_ISSET, FD_SET, and FD_SETSIZE macros as well as the
* select() prototype defined in the XOpen specifications
* beginning with XSH4v2. Placement required after definition
* for itimerval.
*/
defined(__EXTENSIONS__)
#endif
#endif /* _ASM */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_TIME_H */