2000-02-18 03:39:52 +08:00
|
|
|
/*
|
|
|
|
* time.h
|
|
|
|
*
|
|
|
|
* Struct and function declarations for dealing with time.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _TIME_H_
|
|
|
|
#define _TIME_H_
|
|
|
|
|
|
|
|
#include "_ansi.h"
|
2002-04-18 05:23:31 +08:00
|
|
|
#include <sys/reent.h>
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef NULL
|
|
|
|
#define NULL 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Get _CLOCKS_PER_SEC_ */
|
|
|
|
#include <machine/time.h>
|
|
|
|
|
|
|
|
#ifndef _CLOCKS_PER_SEC_
|
|
|
|
#define _CLOCKS_PER_SEC_ 1000
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define CLOCKS_PER_SEC _CLOCKS_PER_SEC_
|
|
|
|
#define CLK_TCK CLOCKS_PER_SEC
|
|
|
|
#define __need_size_t
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2000-12-11 Joel Sherrill <joel@OARcorp.com>
* Merge RTEMS specific .h files into main libc/include.
* libc/sys/rtems/include/signal.h: Removed.
* libc/sys/rtems/include/time.h: Removed.
* libc/sys/rtems/sys/features.h: Removed.
* libc/sys/rtems/sys/sched.h: Removed.
* libc/sys/rtems/sys/siginfo.h: Removed.
* libc/sys/rtems/sys/signal.h: Removed.
* libc/sys/rtems/sys/time.h: Removed.
* libc/sys/rtems/sys/times.h: Removed.
definitions for time_t and clock_t since these are
no longer in time.h.
* libc/include/pthread.h: New file.
* libc/include/sys/sched.h: New file.
* libc/include/sys/features.h: New file.
* libc/include/time.h: Removed duplicate definition of clock_t
and time_t, get them from <sys/types.h> instead. Add prototypes for POSIX clock and timer functionality.
* libc/sys/linux/sys/types.h: Changed to include
* libc/include/machine/types.h: Add _CLOCKID_T_ and _TIMER_T_.
* libc/include/sys/signal.h: Add more complete set of POSIX
signal functionality including real-time and threaded signals.
* libc/include/sys/types.h: Add clock_t, time_t, struct
timespec, and struct itimerspec. Centralizing these makes
things cleaner. RTEMS uses 64-bit dev_t.
Added numerous primitive definitions
for pthreads including macros, pthread_attr_t,
pthread_mutexattr_t, pthread_condattr_t, pthread_key_t,
pthread_once_t, and pthread_t.
* libc/include/sys/unistd.h: Added getlogin_r() prototype.
If RTEMS follow POSIX on read(), write() and sbrk() prototype.
Feature flags removed and moved to new file <sys/features.h>.
Full set of POSIX sysconf() constants
2000-12-12 09:24:09 +08:00
|
|
|
#include <sys/types.h>
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
struct tm
|
|
|
|
{
|
|
|
|
int tm_sec;
|
|
|
|
int tm_min;
|
|
|
|
int tm_hour;
|
|
|
|
int tm_mday;
|
|
|
|
int tm_mon;
|
|
|
|
int tm_year;
|
|
|
|
int tm_wday;
|
|
|
|
int tm_yday;
|
|
|
|
int tm_isdst;
|
|
|
|
};
|
|
|
|
|
|
|
|
clock_t _EXFUN(clock, (void));
|
|
|
|
double _EXFUN(difftime, (time_t _time2, time_t _time1));
|
|
|
|
time_t _EXFUN(mktime, (struct tm *_timeptr));
|
|
|
|
time_t _EXFUN(time, (time_t *_timer));
|
|
|
|
#ifndef _REENT_ONLY
|
|
|
|
char *_EXFUN(asctime, (const struct tm *_tblock));
|
|
|
|
char *_EXFUN(ctime, (const time_t *_time));
|
|
|
|
struct tm *_EXFUN(gmtime, (const time_t *_timer));
|
|
|
|
struct tm *_EXFUN(localtime,(const time_t *_timer));
|
|
|
|
#endif
|
|
|
|
size_t _EXFUN(strftime, (char *_s, size_t _maxsize, const char *_fmt, const struct tm *_t));
|
|
|
|
|
|
|
|
char *_EXFUN(asctime_r, (const struct tm *, char *));
|
|
|
|
char *_EXFUN(ctime_r, (const time_t *, char *));
|
|
|
|
struct tm *_EXFUN(gmtime_r, (const time_t *, struct tm *));
|
|
|
|
struct tm *_EXFUN(localtime_r, (const time_t *, struct tm *));
|
|
|
|
|
|
|
|
#ifndef __STRICT_ANSI__
|
2002-04-18 05:23:31 +08:00
|
|
|
char *_EXFUN(strptime, (const char *, const char *, struct tm *));
|
|
|
|
_VOID _EXFUN(tzset, (_VOID));
|
|
|
|
_VOID _EXFUN(_tzset_r, (struct _reent *));
|
|
|
|
|
|
|
|
/* defines for the opengroup specifications Derived from Issue 1 of the SVID. */
|
2000-08-02 04:51:51 +08:00
|
|
|
extern __IMPORT time_t _timezone;
|
|
|
|
extern __IMPORT int _daylight;
|
|
|
|
extern __IMPORT char *_tzname[2];
|
2002-04-18 05:23:31 +08:00
|
|
|
|
|
|
|
/* POSIX defines the external tzname being defined in time.h */
|
2001-04-19 23:54:47 +08:00
|
|
|
#ifndef tzname
|
|
|
|
#define tzname _tzname
|
|
|
|
#endif
|
2002-04-18 05:23:31 +08:00
|
|
|
|
|
|
|
/* CYGWIN also exposes daylight and timezone in the name space */
|
|
|
|
#ifdef __CYGWIN__
|
2001-04-19 23:54:47 +08:00
|
|
|
#ifndef daylight
|
|
|
|
#define daylight _daylight
|
|
|
|
#endif
|
|
|
|
#if timezonevar
|
|
|
|
#ifndef timezone
|
|
|
|
#define timezone ((long int) _timezone)
|
|
|
|
#endif
|
|
|
|
#else
|
2000-02-18 03:39:52 +08:00
|
|
|
char *_EXFUN(timezone, (void));
|
2001-04-19 23:54:47 +08:00
|
|
|
#endif
|
2000-05-31 01:18:05 +08:00
|
|
|
#endif /* __CYGWIN__ */
|
2002-04-18 05:23:31 +08:00
|
|
|
#endif /* !__STRICT_ANSI__ */
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2000-12-11 Joel Sherrill <joel@OARcorp.com>
* Merge RTEMS specific .h files into main libc/include.
* libc/sys/rtems/include/signal.h: Removed.
* libc/sys/rtems/include/time.h: Removed.
* libc/sys/rtems/sys/features.h: Removed.
* libc/sys/rtems/sys/sched.h: Removed.
* libc/sys/rtems/sys/siginfo.h: Removed.
* libc/sys/rtems/sys/signal.h: Removed.
* libc/sys/rtems/sys/time.h: Removed.
* libc/sys/rtems/sys/times.h: Removed.
definitions for time_t and clock_t since these are
no longer in time.h.
* libc/include/pthread.h: New file.
* libc/include/sys/sched.h: New file.
* libc/include/sys/features.h: New file.
* libc/include/time.h: Removed duplicate definition of clock_t
and time_t, get them from <sys/types.h> instead. Add prototypes for POSIX clock and timer functionality.
* libc/sys/linux/sys/types.h: Changed to include
* libc/include/machine/types.h: Add _CLOCKID_T_ and _TIMER_T_.
* libc/include/sys/signal.h: Add more complete set of POSIX
signal functionality including real-time and threaded signals.
* libc/include/sys/types.h: Add clock_t, time_t, struct
timespec, and struct itimerspec. Centralizing these makes
things cleaner. RTEMS uses 64-bit dev_t.
Added numerous primitive definitions
for pthreads including macros, pthread_attr_t,
pthread_mutexattr_t, pthread_condattr_t, pthread_key_t,
pthread_once_t, and pthread_t.
* libc/include/sys/unistd.h: Added getlogin_r() prototype.
If RTEMS follow POSIX on read(), write() and sbrk() prototype.
Feature flags removed and moved to new file <sys/features.h>.
Full set of POSIX sysconf() constants
2000-12-12 09:24:09 +08:00
|
|
|
#include <sys/features.h>
|
|
|
|
|
|
|
|
#if defined(_POSIX_TIMERS)
|
|
|
|
|
|
|
|
#include <signal.h>
|
|
|
|
|
|
|
|
/* Clocks, P1003.1b-1993, p. 263 */
|
|
|
|
|
|
|
|
int _EXFUN(clock_settime, (clockid_t clock_id, const struct timespec *tp));
|
|
|
|
int _EXFUN(clock_gettime, (clockid_t clock_id, struct timespec *tp));
|
|
|
|
int _EXFUN(clock_getres, (clockid_t clock_id, struct timespec *res));
|
|
|
|
|
|
|
|
/* Create a Per-Process Timer, P1003.1b-1993, p. 264 */
|
|
|
|
|
|
|
|
int _EXFUN(timer_create,
|
|
|
|
(clockid_t clock_id, struct sigevent *evp, timer_t *timerid));
|
|
|
|
|
|
|
|
/* Delete a Per_process Timer, P1003.1b-1993, p. 266 */
|
|
|
|
|
|
|
|
int _EXFUN(timer_delete, (timer_t timerid));
|
|
|
|
|
|
|
|
/* Per-Process Timers, P1003.1b-1993, p. 267 */
|
|
|
|
|
|
|
|
int _EXFUN(timer_settime,
|
|
|
|
(timer_t timerid, int flags, const struct itimerspec *value,
|
|
|
|
struct itimerspec *ovalue));
|
|
|
|
int _EXFUN(timer_gettime, (timer_t timerid, struct itimerspec *value));
|
|
|
|
int _EXFUN(timer_getoverrun, (timer_t timerid));
|
|
|
|
|
|
|
|
/* High Resolution Sleep, P1003.1b-1993, p. 269 */
|
|
|
|
|
|
|
|
int _EXFUN(nanosleep, (const struct timespec *rqtp, struct timespec *rmtp));
|
|
|
|
|
|
|
|
#endif /* _POSIX_TIMERS */
|
|
|
|
|
|
|
|
/* CPU-time Clock Attributes, P1003.4b/D8, p. 54 */
|
|
|
|
|
|
|
|
/* values for the clock enable attribute */
|
|
|
|
|
|
|
|
#define CLOCK_ENABLED 1 /* clock is enabled, i.e. counting execution time */
|
|
|
|
#define CLOCK_DISABLED 0 /* clock is disabled */
|
|
|
|
|
|
|
|
/* values for the pthread cputime_clock_allowed attribute */
|
|
|
|
|
|
|
|
#define CLOCK_ALLOWED 1 /* If a thread is created with this value a */
|
|
|
|
/* CPU-time clock attached to that thread */
|
|
|
|
/* shall be accessible. */
|
|
|
|
#define CLOCK_DISALLOWED 0 /* If a thread is created with this value, the */
|
|
|
|
/* thread shall not have a CPU-time clock */
|
|
|
|
/* accessible. */
|
|
|
|
|
|
|
|
/* Manifest Constants, P1003.1b-1993, p. 262 */
|
|
|
|
|
|
|
|
#define CLOCK_REALTIME (clockid_t)1
|
|
|
|
|
|
|
|
/* Flag indicating time is "absolute" with respect to the clock
|
|
|
|
associated with a time. */
|
|
|
|
|
|
|
|
#define TIMER_ABSTIME 4
|
|
|
|
|
|
|
|
/* Manifest Constants, P1003.4b/D8, p. 55 */
|
|
|
|
|
|
|
|
#if defined(_POSIX_CPUTIME)
|
|
|
|
|
|
|
|
/* When used in a clock or timer function call, this is interpreted as
|
|
|
|
the identifier of the CPU_time clock associated with the PROCESS
|
|
|
|
making the function call. */
|
|
|
|
|
|
|
|
#define CLOCK_PROCESS_CPUTIME (clockid_t)2
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(_POSIX_THREAD_CPUTIME)
|
|
|
|
|
|
|
|
/* When used in a clock or timer function call, this is interpreted as
|
|
|
|
the identifier of the CPU_time clock associated with the THREAD
|
|
|
|
making the function call. */
|
|
|
|
|
|
|
|
#define CLOCK_THREAD_CPUTIME (clockid_t)3
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(_POSIX_CPUTIME)
|
|
|
|
|
|
|
|
/* Accessing a Process CPU-time CLock, P1003.4b/D8, p. 55 */
|
|
|
|
|
|
|
|
int _EXFUN(clock_getcpuclockid, (pid_t pid, clockid_t *clock_id));
|
|
|
|
|
|
|
|
#endif /* _POSIX_CPUTIME */
|
|
|
|
|
|
|
|
#if defined(_POSIX_CPUTIME) || defined(_POSIX_THREAD_CPUTIME)
|
|
|
|
|
|
|
|
/* CPU-time Clock Attribute Access, P1003.4b/D8, p. 56 */
|
|
|
|
|
|
|
|
int _EXFUN(clock_setenable_attr, (clockid_t clock_id, int attr));
|
|
|
|
int _EXFUN(clock_getenable_attr, (clockid_t clock_id, int *attr));
|
|
|
|
|
|
|
|
#endif /* _POSIX_CPUTIME or _POSIX_THREAD_CPUTIME */
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif /* _TIME_H_ */
|
|
|
|
|