PSP2SDK  dirty-f9e4f2d
The free SDK for PSP2
include/time.h
00001 /*
00002  * Copyright (C) 2015 PSP2SDK Project
00003  *
00004  * This Source Code Form is subject to the terms of the Mozilla Public
00005  * License, v. 2.0. If a copy of the MPL was not distributed with this
00006  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
00007  *
00008  * Modified for PSP2 by PSP2SDK Team
00009  *
00010  * time.h
00011  * 
00012  * Struct and function declarations for dealing with time.
00013  */
00014 
00015 #ifndef _TIME_H_
00016 #define _TIME_H_
00017 
00018 #include "_ansi.h"
00019 
00020 #define __need_size_t
00021 #define __need_NULL
00022 #include <stddef.h>
00023 
00024 /* Get _CLOCKS_PER_SEC_ */
00025 #include <machine/time.h>
00026 
00027 #ifndef _CLOCKS_PER_SEC_
00028 #define _CLOCKS_PER_SEC_ 1000
00029 #endif
00030 
00031 #define CLOCKS_PER_SEC _CLOCKS_PER_SEC_
00032 #define CLK_TCK CLOCKS_PER_SEC
00033 
00034 #include <sys/types.h>
00035 
00036 _BEGIN_STD_C
00037 
00038 struct tm
00039 {
00040   int   tm_sec;
00041   int   tm_min;
00042   int   tm_hour;
00043   int   tm_mday;
00044   int   tm_mon;
00045   int   tm_year;
00046   int   tm_wday;
00047   int   tm_yday;
00048   int   tm_isdst;
00049 #ifdef __TM_GMTOFF
00050   long  __TM_GMTOFF;
00051 #endif
00052 #ifdef __TM_ZONE
00053   const char *__TM_ZONE;
00054 #endif
00055 };
00056 
00057 clock_t    _EXFUN(clock,    (void));
00058 double     _EXFUN(difftime, (time_t _time2, time_t _time1));
00059 time_t     _EXFUN(mktime,   (struct tm *_timeptr));
00060 time_t     _EXFUN(time,     (time_t *_timer));
00061 #ifndef _REENT_ONLY
00062 char      *_EXFUN(asctime,  (const struct tm *_tblock));
00063 char      *_EXFUN(ctime,    (const time_t *_time));
00064 struct tm *_EXFUN(gmtime,   (const time_t *_timer));
00065 struct tm *_EXFUN(localtime,(const time_t *_timer));
00066 #endif
00067 size_t     _EXFUN(strftime, (char *__restrict _s,
00068                  size_t _maxsize, const char *__restrict _fmt,
00069                  const struct tm *__restrict _t));
00070 
00071 char      *_EXFUN(asctime_r,    (const struct tm *__restrict,
00072                  char *__restrict));
00073 char      *_EXFUN(ctime_r,  (const time_t *, char *));
00074 struct tm *_EXFUN(gmtime_r, (const time_t *__restrict,
00075                  struct tm *__restrict));
00076 struct tm *_EXFUN(localtime_r,  (const time_t *__restrict,
00077                  struct tm *__restrict));
00078 
00079 _END_STD_C
00080 
00081 #ifdef __cplusplus
00082 extern "C" {
00083 #endif
00084 
00085 #ifndef __STRICT_ANSI__
00086 char      *_EXFUN(strptime,     (const char *__restrict,
00087                  const char *__restrict,
00088                  struct tm *__restrict));
00089 _VOID      _EXFUN(tzset,    (_VOID));
00090 
00091 typedef struct __tzrule_struct
00092 {
00093   char ch;
00094   int m;
00095   int n;
00096   int d;
00097   int s;
00098   time_t change;
00099   long offset; /* Match type of _timezone. */
00100 } __tzrule_type;
00101 
00102 typedef struct __tzinfo_struct
00103 {
00104   int __tznorth;
00105   int __tzyear;
00106   __tzrule_type __tzrule[2];
00107 } __tzinfo_type;
00108 
00109 __tzinfo_type *_EXFUN (__gettzinfo, (_VOID));
00110 
00111 /* getdate functions */
00112 
00113 #ifdef HAVE_GETDATE
00114 #ifndef _REENT_ONLY
00115 #define getdate_err (*__getdate_err())
00116 int *_EXFUN(__getdate_err,(_VOID));
00117 
00118 struct tm * _EXFUN(getdate, (const char *));
00119 /* getdate_err is set to one of the following values to indicate the error.
00120      1  the DATEMSK environment variable is null or undefined,
00121      2  the template file cannot be opened for reading,
00122      3  failed to get file status information,
00123      4  the template file is not a regular file,
00124      5  an error is encountered while reading the template file,
00125      6  memory allication failed (not enough memory available),
00126      7  there is no line in the template that matches the input,
00127      8  invalid input specification  */
00128 #endif /* !_REENT_ONLY */
00129 
00130 /* getdate_r returns the error code as above */
00131 int     _EXFUN(getdate_r, (const char *, struct tm *));
00132 #endif /* HAVE_GETDATE */
00133 
00134 /* defines for the opengroup specifications Derived from Issue 1 of the SVID.  */
00135 extern __IMPORT long _timezone;
00136 extern __IMPORT int _daylight;
00137 extern __IMPORT char *_tzname[2];
00138 
00139 /* POSIX defines the external tzname being defined in time.h */
00140 #ifndef tzname
00141 #define tzname _tzname
00142 #endif
00143 #endif /* !__STRICT_ANSI__ */
00144 
00145 #ifdef __cplusplus
00146 }
00147 #endif
00148 
00149 #include <sys/features.h>
00150 
00151 #ifdef __CYGWIN__
00152 #include <cygwin/time.h>
00153 #endif /*__CYGWIN__*/
00154 
00155 #if defined(_POSIX_TIMERS)
00156 
00157 #include <signal.h>
00158 
00159 #ifdef __cplusplus
00160 extern "C" {
00161 #endif
00162 
00163 /* Clocks, P1003.1b-1993, p. 263 */
00164 
00165 int _EXFUN(clock_settime, (clockid_t clock_id, const struct timespec *tp));
00166 int _EXFUN(clock_gettime, (clockid_t clock_id, struct timespec *tp));
00167 int _EXFUN(clock_getres,  (clockid_t clock_id, struct timespec *res));
00168 
00169 /* Create a Per-Process Timer, P1003.1b-1993, p. 264 */
00170 
00171 int _EXFUN(timer_create,
00172     (clockid_t clock_id,
00173     struct sigevent *__restrict evp,
00174     timer_t *__restrict timerid));
00175 
00176 /* Delete a Per_process Timer, P1003.1b-1993, p. 266 */
00177 
00178 int _EXFUN(timer_delete, (timer_t timerid));
00179 
00180 /* Per-Process Timers, P1003.1b-1993, p. 267 */
00181 
00182 int _EXFUN(timer_settime,
00183     (timer_t timerid, int flags,
00184     const struct itimerspec *__restrict value,
00185     struct itimerspec *__restrict ovalue));
00186 int _EXFUN(timer_gettime, (timer_t timerid, struct itimerspec *value));
00187 int _EXFUN(timer_getoverrun, (timer_t timerid));
00188 
00189 /* High Resolution Sleep, P1003.1b-1993, p. 269 */
00190 
00191 int _EXFUN(nanosleep, (const struct timespec  *rqtp, struct timespec *rmtp));
00192 
00193 #ifdef __cplusplus
00194 }
00195 #endif
00196 #endif /* _POSIX_TIMERS */
00197 
00198 #if defined(_POSIX_CLOCK_SELECTION)
00199 
00200 #ifdef __cplusplus
00201 extern "C" {
00202 #endif
00203 
00204 int _EXFUN(clock_nanosleep,
00205   (clockid_t clock_id, int flags, const struct timespec *rqtp,
00206    struct timespec *rmtp));
00207 
00208 #ifdef __cplusplus
00209 }
00210 #endif
00211 
00212 #endif /* _POSIX_CLOCK_SELECTION */
00213 
00214 #ifdef __cplusplus
00215 extern "C" {
00216 #endif
00217 
00218 /* CPU-time Clock Attributes, P1003.4b/D8, p. 54 */
00219 
00220 /* values for the clock enable attribute */
00221 
00222 #define CLOCK_ENABLED  1  /* clock is enabled, i.e. counting execution time */
00223 #define CLOCK_DISABLED 0  /* clock is disabled */
00224 
00225 /* values for the pthread cputime_clock_allowed attribute */
00226 
00227 #define CLOCK_ALLOWED    1 /* If a thread is created with this value a */
00228                            /*   CPU-time clock attached to that thread */
00229                            /*   shall be accessible. */
00230 #define CLOCK_DISALLOWED 0 /* If a thread is created with this value, the */
00231                            /*   thread shall not have a CPU-time clock */
00232                            /*   accessible. */
00233 
00234 /* Manifest Constants, P1003.1b-1993, p. 262 */
00235 
00236 #define CLOCK_REALTIME (clockid_t)1
00237 
00238 /* Flag indicating time is "absolute" with respect to the clock
00239    associated with a time.  */
00240 
00241 #define TIMER_ABSTIME   4
00242 
00243 /* Manifest Constants, P1003.4b/D8, p. 55 */
00244 
00245 #if defined(_POSIX_CPUTIME)
00246 
00247 /* When used in a clock or timer function call, this is interpreted as
00248    the identifier of the CPU_time clock associated with the PROCESS
00249    making the function call.  */
00250 
00251 #define CLOCK_PROCESS_CPUTIME_ID (clockid_t)2
00252 
00253 #endif
00254 
00255 #if defined(_POSIX_THREAD_CPUTIME)
00256 
00257 /*  When used in a clock or timer function call, this is interpreted as
00258     the identifier of the CPU_time clock associated with the THREAD
00259     making the function call.  */
00260 
00261 #define CLOCK_THREAD_CPUTIME_ID (clockid_t)3
00262 
00263 #endif
00264 
00265 #if defined(_POSIX_MONOTONIC_CLOCK)
00266 
00267 /*  The identifier for the system-wide monotonic clock, which is defined
00268  *      as a clock whose value cannot be set via clock_settime() and which 
00269  *          cannot have backward clock jumps. */
00270 
00271 #define CLOCK_MONOTONIC (clockid_t)4
00272 
00273 #endif
00274 
00275 #if defined(_POSIX_CPUTIME)
00276 
00277 /* Accessing a Process CPU-time CLock, P1003.4b/D8, p. 55 */
00278 
00279 int _EXFUN(clock_getcpuclockid, (pid_t pid, clockid_t *clock_id));
00280 
00281 #endif /* _POSIX_CPUTIME */
00282 
00283 #if defined(_POSIX_CPUTIME) || defined(_POSIX_THREAD_CPUTIME)
00284 
00285 /* CPU-time Clock Attribute Access, P1003.4b/D8, p. 56 */
00286 
00287 int _EXFUN(clock_setenable_attr, (clockid_t clock_id, int attr));
00288 int _EXFUN(clock_getenable_attr, (clockid_t clock_id, int *attr));
00289 
00290 #endif /* _POSIX_CPUTIME or _POSIX_THREAD_CPUTIME */
00291 
00292 #ifdef __cplusplus
00293 }
00294 #endif
00295 
00296 #endif /* _TIME_H_ */
00297 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines