home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue4 / SDL / gcc346 / !gcc / include / unixlib / h / time < prev    next >
Encoding:
Text File  |  2006-09-17  |  8.2 KB  |  270 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /usr/local/cvsroot/gccsdk/unixlib/source/clib/time.h,v $
  4.  * $Date: 2005/03/31 11:42:02 $
  5.  * $Revision: 1.15 $
  6.  * $State: Exp $
  7.  * $Author: nick $
  8.  *
  9.  ***************************************************************************/
  10.  
  11. /* ISO C99 Standard: 7.23 Date and Time <time.h>.  */
  12.  
  13. #ifndef __TIME_H
  14.  
  15. #if (! defined __need_time_t && ! defined __need_clock_t \
  16.     && ! defined __need_timespec && ! defined __need_clockid_t \
  17.     && ! defined __need_timer_t)
  18. #define __TIME_H
  19.  
  20. #define __need_time_t
  21. #define __need_clock_t
  22. #define __need_timespec
  23. #define __need_clockid_t
  24. #define __need_timer_t
  25.  
  26. #define __need_size_t
  27. #define __need_NULL
  28. #include <stddef.h>
  29. #endif
  30.  
  31.  
  32. #if !defined __clock_t_defined && defined __need_clock_t
  33. #define __clock_t_defined 1
  34. #include <unixlib/types.h>
  35. __BEGIN_NAMESPACE_STD
  36. typedef __clock_t clock_t;  /* Data type used to represent clock ticks.  */
  37. __END_NAMESPACE_STD
  38. #endif
  39. #undef __need_clock_t
  40.  
  41. #if !defined __clockid_t_defined && defined __need_clockid_t
  42. #define __clockid_t_defined 1
  43. #include <unixlib/types.h>
  44. typedef __clockid_t clockid_t;  /* Data type used to represent clock ticks.  */
  45. #endif
  46. #undef __need_clockid_t
  47.  
  48. #if !defined __time_t_defined && defined __need_time_t
  49. #define __time_t_defined 1
  50. #include <unixlib/types.h>
  51. /* The data type used to represent calendar time. It represents
  52.    the number of seconds elapsed since 00:00:00 on 1 January, 1970
  53.    Universal Time Coordinated.  */
  54. __BEGIN_NAMESPACE_STD
  55. typedef __time_t time_t;
  56. __END_NAMESPACE_STD
  57. #endif
  58. #undef __need_time_t
  59.  
  60. #if !defined __timer_t_defined && defined __need_timer_t
  61. #define __timer_t_defined 1
  62. #include <unixlib/types.h>
  63. /* The data type used to represent calendar time. It represents
  64.    the number of seconds elapsed since 00:00:00 on 1 January, 1970
  65.    Universal Time Coordinated.  */
  66. typedef __timer_t timer_t;
  67. #endif
  68. #undef __need_timer_t
  69.  
  70. #if !defined __timespec_defined && defined __need_timespec
  71. #define __timespec_defined 1
  72.  
  73. /* POSIX.1b structure for a time value.  This is like a `struct timeval' but
  74.    has nanoseconds instead of microseconds.  */
  75. struct timespec
  76. {
  77.   long int tv_sec;  /* Seconds.  */
  78.   long int tv_nsec; /* Nanoseconds.  */
  79. };
  80. #endif
  81. #undef __need_timespec
  82.  
  83.  
  84. #ifdef __TIME_H
  85.  
  86. #ifndef __UNIXLIB_FEATURES_H
  87. #include <features.h>
  88. #endif
  89.  
  90. __BEGIN_DECLS
  91.  
  92. /* The number of clock ticks per second measured by the clock function.  */
  93. #define CLOCKS_PER_SEC 100
  94.  
  95. /* Obsolete name for CLOCKS_PER_SEC.  */
  96. #define CLK_TCK CLOCKS_PER_SEC
  97.  
  98. __BEGIN_NAMESPACE_STD
  99.  
  100. /* Return the elapsed processor time.  */
  101. extern clock_t clock (void) __THROW;
  102.  
  103. /* Return the current time as a value of type 'time_t'.
  104.    If result is not NULL, the time will also be return in it. */
  105. extern time_t time (time_t *__result) __THROW;
  106.  
  107. struct tm
  108. {
  109.   int tm_sec;     /* seconds (0 - 59) */
  110.   int tm_min;     /* minutes (0 - 59) */
  111.   int tm_hour;    /* hours (0 - 23) */
  112.   int tm_mday;    /* day of month (1 - 31) */
  113.   int tm_mon;     /* month of year (0 - 11) */
  114.   int tm_year;    /* year - 1900 */
  115.   int tm_wday;    /* day of week (Sunday = 0) */
  116.   int tm_yday;    /* day of year (0 - 365) */
  117.   int tm_isdst;    /* 1 - DST in effect,0 - not,-1 - not known */
  118.   int tm_gmtoff;    /* offset east of UTC (GMT) in seconds */
  119.   const char *tm_zone;    /* abbreviation of timezone name */
  120. };
  121.  
  122. /* Convert the broken-down time value into a string in a standard
  123.    format:  "Sat Jul 12 14:47:12 1997\n"  */
  124. extern char *asctime (const struct tm *__brokentime) __THROW;
  125.  
  126. /* Similar to asctime except that the time value is specified
  127.    as a time_t calendar time value.  */
  128. extern char *ctime (const time_t *__timer) __THROW;
  129.  
  130. /* Return the number of seconds elapsed between time1 and time 0
  131.    as a value of type double.  */
  132. extern double difftime (time_t __time1, time_t __time0)
  133.      __THROW __attribute__ ((__const__));
  134.  
  135. /* Convert a broken-down time structure to a calendar time
  136.    representation.  */
  137. extern time_t mktime (struct tm *__brokentime) __THROW;
  138.  
  139. /* Place characters into the 's' as controlled by the 'format'.
  140.    'format' is specialised for printing components of 'brokentime'
  141.    according to the locale currently specified for time conversion.  */
  142. extern size_t strftime (char *__restrict __s, size_t __size,
  143.             const char *__restrict __format,
  144.                              const struct tm *__restrict __brokentime) __THROW;
  145. /* Convert the calendar time 'time' to broken-down time,
  146.    expressed relative to the user's specified time zone. */
  147. extern struct tm *localtime (const time_t *__timer) __THROW;
  148.  
  149. /* Similar to localtime() but the broken-down time is expressed
  150.    as UTC (GMT) rather than the local time zone.  */
  151. extern struct tm *gmtime (const time_t *__timer) __THROW;
  152.  
  153. __END_NAMESPACE_STD
  154.  
  155. # if defined __USE_POSIX || defined __USE_MISC
  156. /* Convert the calendar time 'time' to broken-down time,
  157.    expressed relative to the user's specified time zone (re-entrant). */
  158. extern struct tm *localtime_r (const time_t *__restrict __timer,
  159.                    struct tm *__restrict resultp) __THROW;
  160.  
  161. /* Similar to localtime() but the broken-down time is expressed
  162.    as UTC (GMT) rather than the local time zone (re-entrant).  */
  163. extern struct tm *gmtime_r (const time_t *__restrict __timer,
  164.                 struct tm *__restrict resultp) __THROW;
  165.  
  166. #endif
  167.  
  168. /* C99 Additions.  */
  169.  
  170. #ifdef __USE_POSIX199309
  171.  
  172. /* Identifier for system-wide realtime clock.  */
  173. #define CLOCK_REALTIME 0
  174.  
  175. /* Monotonic system-wide clock.  */
  176. #define CLOCK_MONOTONIC 1
  177.  
  178. /* High-resolution timer from the CPU.  */
  179. #define CLOCK_PROCESS_CPUTIME_ID 2
  180.  
  181. /* Thread-specific CPU-time clock.  */
  182. #define CLOCK_THREAD_CPUTIME_ID 3
  183.  
  184. /* Find the resolution of a specified clockid.  If 'res' is non NULL,
  185.    then store the result into the structure pointed to by it.  */
  186. extern int clock_getres (clockid_t __clk_id, struct timespec *__res) __THROW;
  187.  
  188. /* Retrieve the time of the specified clk_id.  */
  189. extern int clock_gettime (clockid_t __clk_id, struct timespec *__tp) __THROW;
  190.  
  191. /* Set the time of the specified clk_id.  */
  192. extern int clock_settime (clockid_t __clk_id, const struct timespec *__tp) __THROW;
  193.  
  194. /* Pause for a number of nanoseconds.
  195.    This function is a cancellation point.  */
  196. extern int nanosleep (const struct timespec *__req,
  197.               struct timespec *__rem);
  198. #endif
  199.  
  200. /* System V compatibility.  */
  201.  
  202. # if defined __USE_SVID || defined __USE_XOPEN
  203. /* The difference between UTC and the latest local standard time,
  204.    in seconds west of UTC. The time is not adjusted for daylight
  205.    saving and the sign is the reverse of tm_gmtoff.  */
  206. extern int timezone;
  207.  
  208. /* Nonzero if daylight savings time rules apply.  */
  209. extern int daylight;
  210. #endif
  211.  
  212. /* Nonzero if YEAR is a leap year (every 4 years,
  213.    except every 100th isn't, and every 400th is).  */
  214. # define __isleap(year) \
  215.   ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 400 == 0))
  216.  
  217. # ifdef __USE_MISC
  218. /* Miscellaneous functions many Unices inherited from the public domain
  219.    localtime package.  These are included only for compatibility.  */
  220.  
  221. /* Like `mktime', but for TP represents Universal Time, not local time.  */
  222. extern time_t timegm (struct tm *__tp) __THROW;
  223.  
  224. /* Another name for `mktime'.  */
  225. extern time_t timelocal (struct tm *__tp) __THROW;
  226.  
  227. /* Return the number of days in YEAR.  */
  228. extern int dysize (int __year) __THROW  __attribute__ ((__const__));
  229. # endif
  230.  
  231.  
  232. /* POSIX extensions.  */
  233.  
  234. #ifdef __USE_POSIX
  235. /* Initialise the tzname variable with the TimeZone information from
  236.    CMOS.  */
  237. extern void tzset (void) __THROW;
  238.  
  239. /* tzname[0] is the name of the standard time zone.
  240.    tzname[1] is the name for the time zone when daylight saving time
  241.    is in use.  */
  242. extern char *tzname[];
  243. #endif
  244.  
  245. #ifdef __UNIXLIB_INTERNALS
  246. extern struct tm __tz[1];
  247.  
  248. /* Convert broken time to 5-byte RISC OS time.  */
  249. extern void __cvt_broken_time (const struct tm *__brokentime,
  250.                    char *__riscos_time);
  251.  
  252. /* Common function for localtime() and gmtime().  */
  253. extern struct tm *__calendar_convert (int __swinum, const time_t *__tp,
  254.                       struct tm *resultp);
  255.  
  256. /* Common function for ctime() and asctime().  */
  257. extern char *__standard_time (const char *__riscos_time);
  258. #endif /* __UNIXLIB_INTERNALS */
  259.  
  260. __END_DECLS
  261.  
  262. #endif /* __TIME_H */
  263. #else
  264. #undef __need_time_t
  265. #undef __need_clock_t
  266. #undef __need_timespec
  267. #undef __need_clockid_t
  268. #undef __need_timer_t
  269. #endif /* ! __TIME_H */
  270.