home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue2 / SDL.ARC / !unixlib / source / clib / h / time < prev    next >
Encoding:
Text File  |  2004-09-05  |  6.3 KB  |  205 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: /usr/local/cvsroot/gccsdk/unixlib/source/clib/time.h,v $
  4.  * $Date: 2004/04/15 22:21:02 $
  5.  * $Revision: 1.11 $
  6.  * $State: Exp $
  7.  * $Author: alex $
  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. typedef __clock_t clock_t;  /* Data type used to represent clock ticks.  */
  36. #endif
  37. #undef __need_clock_t
  38.  
  39. #if !defined __clockid_t_defined && defined __need_clockid_t
  40. #define __clockid_t_defined 1
  41. #include <unixlib/types.h>
  42. typedef __clockid_t clockid_t;  /* Data type used to represent clock ticks.  */
  43. #endif
  44. #undef __need_clockid_t
  45.  
  46. #if !defined __time_t_defined && defined __need_time_t
  47. #define __time_t_defined 1
  48. #include <unixlib/types.h>
  49. /* The data type used to represent calendar time. It represents
  50.    the number of seconds elapsed since 00:00:00 on 1 January, 1970
  51.    Universal Time Coordinated.  */
  52. typedef __time_t time_t;
  53. #endif
  54. #undef __need_time_t
  55.  
  56. #if !defined __timer_t_defined && defined __need_timer_t
  57. #define __timer_t_defined 1
  58. #include <unixlib/types.h>
  59. /* The data type used to represent calendar time. It represents
  60.    the number of seconds elapsed since 00:00:00 on 1 January, 1970
  61.    Universal Time Coordinated.  */
  62. typedef __timer_t timer_t;
  63. #endif
  64. #undef __need_timer_t
  65.  
  66. #if !defined __timespec_defined && defined __need_timespec
  67. #define __timespec_defined 1
  68.  
  69. /* POSIX.1b structure for a time value.  This is like a `struct timeval' but
  70.    has nanoseconds instead of microseconds.  */
  71. struct timespec
  72. {
  73.   long int tv_sec;  /* Seconds.  */
  74.   long int tv_nsec; /* Nanoseconds.  */
  75. };
  76. #endif
  77. #undef __need_timespec
  78.  
  79.  
  80. #ifdef __TIME_H
  81.  
  82. #ifndef __UNIXLIB_FEATURES_H
  83. #include <unixlib/features.h>
  84. #endif
  85.  
  86. __BEGIN_DECLS
  87.  
  88. /* The number of clock ticks per second measured by the clock function.  */
  89. #define CLOCKS_PER_SEC 100
  90.  
  91. /* Obsolete name for CLOCKS_PER_SEC.  */
  92. #define CLK_TCK CLOCKS_PER_SEC
  93.  
  94. /* Return the elapsed processor time.  */
  95. extern clock_t clock (void);
  96.  
  97. /* Return the current time as a value of type 'time_t'.
  98.    If result is not NULL, the time will also be return in it. */
  99. extern time_t time (time_t *__result);
  100.  
  101. struct tm
  102. {
  103.   int tm_sec;     /* seconds (0 - 59) */
  104.   int tm_min;     /* minutes (0 - 59) */
  105.   int tm_hour;    /* hours (0 - 23) */
  106.   int tm_mday;    /* day of month (1 - 31) */
  107.   int tm_mon;     /* month of year (0 - 11) */
  108.   int tm_year;    /* year - 1900 */
  109.   int tm_wday;    /* day of week (Sunday = 0) */
  110.   int tm_yday;    /* day of year (0 - 365) */
  111.   int tm_isdst;    /* 1 - DST in effect,0 - not,-1 - not known */
  112.   int tm_gmtoff;    /* offset east of UTC (GMT) in seconds */
  113.   const char *tm_zone;    /* abbreviation of timezone name */
  114. };
  115.  
  116. /* Convert the broken-down time value into a string in a standard
  117.    format:  "Sat Jul 12 14:47:12 1997\n"  */
  118. extern char *asctime (const struct tm *__brokentime) __THROW;
  119.  
  120. /* Similar to asctime except that the time value is specified
  121.    as a time_t calendar time value.  */
  122. extern char *ctime (const time_t *__timer) __THROW;
  123.  
  124. /* Return the number of seconds elapsed between time1 and time 0
  125.    as a value of type double.  */
  126. extern double difftime (time_t __time1, time_t __time0)
  127.      __THROW __attribute__ ((__const__));
  128.  
  129. /* Convert the calendar time 'time' to broken-down time,
  130.    expressed relative to the user's specified time zone. */
  131. extern struct tm *localtime (const time_t *__timer) __THROW;
  132.  
  133. /* Convert the calendar time 'time' to broken-down time,
  134.    expressed relative to the user's specified time zone (re-entrant). */
  135. extern struct tm *localtime_r (const time_t *__restrict __timer,
  136.                    struct tm *__restrict resultp) __THROW;
  137.  
  138. /* Similar to localtime() but the broken-down time is expressed
  139.    as UTC (GMT) rather than the local time zone.  */
  140. extern struct tm *gmtime (const time_t *__timer) __THROW;
  141.  
  142. /* Similar to localtime() but the broken-down time is expressed
  143.    as UTC (GMT) rather than the local time zone (re-entrant).  */
  144. extern struct tm *gmtime_r (const time_t *__restrict __timer,
  145.                 struct tm *__restrict resultp) __THROW;
  146.  
  147. /* Convert a broken-down time structure to a calendar time
  148.    representation.  */
  149. extern time_t mktime (struct tm *__brokentime) __THROW;
  150.  
  151. /* Place characters into the 's' as controlled by the 'format'.
  152.    'format' is specialised for printing components of 'brokentime'
  153.    according to the locale currently specified for time conversion.  */
  154. extern size_t strftime (char *__restrict __s, size_t __size,
  155.             const char *__restrict __format,
  156.                              const struct tm *__restrict __brokentime) __THROW;
  157.  
  158.  
  159. /* System V compatibility.  */
  160.  
  161. /* The difference between UTC and the latest local standard time,
  162.    in seconds west of UTC. The time is not adjusted for daylight
  163.    saving and the sign is the reverse of tm_gmtoff.  */
  164. extern int timezone;
  165.  
  166. /* Nonzero if daylight savings time rules apply.  */
  167. extern int daylight;
  168.  
  169. /* POSIX extensions.  */
  170.  
  171. /* Initialise the tzname variable with the TimeZone information from
  172.    CMOS.  */
  173. extern void tzset (void) __THROW;
  174.  
  175. /* tzname[0] is the name of the standard time zone.
  176.    tzname[1] is the name for the time zone when daylight saving time
  177.    is in use.  */
  178. extern char *tzname[];
  179.  
  180. #ifdef __UNIXLIB_INTERNALS
  181. extern struct tm __tz[1];
  182.  
  183. /* Convert broken time to 5-byte RISC OS time.  */
  184. extern void __cvt_broken_time (const struct tm *__brokentime,
  185.                    char *__riscos_time);
  186.  
  187. /* Common function for localtime() and gmtime().  */
  188. extern struct tm *__calendar_convert (int __swinum, const time_t *__tp,
  189.                       struct tm *resultp);
  190.  
  191. /* Common function for ctime() and asctime().  */
  192. extern char *__standard_time (const char *__riscos_time);
  193. #endif /* __UNIXLIB_INTERNALS */
  194.  
  195. __END_DECLS
  196.  
  197. #endif /* __TIME_H */
  198. #else
  199. #undef __need_time_t
  200. #undef __need_clock_t
  201. #undef __need_timespec
  202. #undef __need_clockid_t
  203. #undef __need_timer_t
  204. #endif /* ! __TIME_H */
  205.