time.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:5k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* time.h - POSIX time header */
  2. /* Copyright 1992-1999 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01j,00oct00,sn   Removed defns of size_t etc.
  7. 01i,17feb99,mrs  Add C++ support for NULL, (SPR #25079).
  8. 01h,13aug96,dbt  modifed comment for tm_sec (SPR #4436).
  9.  Updated copyright.
  10. 01g,02jul96,dbt  added #include "vxWorks.h" (SPR #4370).
  11. 01f,14jul94,dvs  changed def of CLOCKS_PER_SEC to sysClkRateGet() (SPR# 2486).
  12. 01f,29nov93,dvs  folded in timers.h, made draft 14 POSIX compliant
  13. 01e,15oct92,rrr  silenced warnings.
  14. 01d,22sep92,rrr  added support for c++
  15. 01c,31jul92,gae  added undef of _TYPE_timer_t.
  16. 01b,27jul92,gae  added _TYPE_timer_t, CLOCK_REALTIME, TIMER_ABSTIME.
  17. 01a,22jul92,smb  written
  18.            +rrr
  19. */
  20. #ifndef __INCtimeh
  21. #define __INCtimeh
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. #include "vxWorks.h"
  26. #include "types/vxANSI.h"
  27. #include "sigevent.h"
  28. #define CLOCKS_PER_SEC sysClkRateGet()
  29. #ifndef NULL
  30. #if defined __GNUG__
  31. #define NULL (__null)
  32. #else
  33. #if !defined(__cplusplus) && 0
  34. #define NULL ((void*)0)
  35. #else
  36. #define NULL (0)
  37. #endif
  38. #endif
  39. #endif
  40. #ifdef  _TYPE_timer_t
  41. _TYPE_timer_t;
  42. #undef  _TYPE_timer_t
  43. #endif
  44. #ifdef _TYPE_clock_t
  45. _TYPE_clock_t;
  46. #undef _TYPE_clock_t
  47. #endif
  48. #ifdef _TYPE_time_t
  49. _TYPE_time_t;
  50. #undef _TYPE_time_t
  51. #endif
  52. typedef int clockid_t;
  53. #define CLOCK_REALTIME 0x0 /* system wide realtime clock */
  54. #define TIMER_ABSTIME 0x1 /* absolute time */
  55. struct tm
  56. {
  57. int tm_sec; /* seconds after the minute - [0, 59] */
  58. int tm_min; /* minutes after the hour - [0, 59] */
  59. int tm_hour; /* hours after midnight - [0, 23] */
  60. int tm_mday; /* day of the month - [1, 31] */
  61. int tm_mon; /* months since January - [0, 11] */
  62. int tm_year; /* years since 1900 */
  63. int tm_wday; /* days since Sunday - [0, 6] */
  64. int tm_yday; /* days since January 1 - [0, 365] */
  65. int tm_isdst; /* Daylight Saving Time flag */
  66. };
  67. struct timespec
  68.     {
  69.      /* interval = tv_sec*10**9 + tv_nsec */
  70.     time_t tv_sec; /* seconds */
  71.     long tv_nsec; /* nanoseconds (0 - 1,000,000,000) */
  72.     };
  73. struct itimerspec
  74.     {
  75.     struct timespec it_interval; /* timer period (reload value) */
  76.     struct timespec it_value; /* timer expiration */
  77.     };
  78. #define _POSIX_CLOCKRES_MIN 20 /* milliseconds (1/50th second) */
  79. #define _POSIX_INTERVAL_MAX 1092 /* max. seconds */
  80. #define _POSIX_TIMER_MAX 32 /* max. per task */
  81. #define _POSIX_DELAYTIMER_MAX 32 /* max. expired timers */
  82. /* function declarations */
  83. #if defined(__STDC__) || defined(__cplusplus)
  84. extern uint_t      _clocks_per_sec(void);
  85. extern char *    asctime (const struct tm *_tptr);
  86. extern clock_t    clock (void);
  87. extern char *    ctime (const time_t *_cal);
  88. extern double    difftime (time_t _t1, time_t _t0);
  89. extern struct tm * gmtime (const time_t *_tod);
  90. extern struct tm * localtime (const time_t *_tod);
  91. extern time_t    mktime (struct tm *_tptr);
  92. extern size_t    strftime (char *_s, size_t _n, const char *_format,
  93.           const struct tm *_tptr);
  94. extern time_t    time (time_t *_tod);
  95. extern int  clock_gettime (clockid_t clock_id, struct timespec *tp);
  96. extern int  clock_settime (clockid_t clock_id, const struct timespec *tp);
  97. extern int  clock_getres (clockid_t clock_id, struct timespec *res);
  98. extern int  timer_create (clockid_t clock_id, struct sigevent *evp,
  99.       timer_t *ptimer);
  100. extern int  timer_delete (timer_t timerid);
  101. extern int  timer_gettime (timer_t timerid, struct itimerspec *value);
  102. extern int  timer_settime (timer_t timerid, int flags,
  103.                const struct itimerspec *value,
  104.        struct itimerspec *ovalue);
  105. extern int  timer_getoverrun (timer_t timerid);
  106. extern int      timer_connect (timer_t timerid, VOIDFUNCPTR routine, int arg);
  107. extern int      timer_cancel (timer_t timerid);
  108. extern int      timer_show (timer_t timerid);
  109. extern int  nanosleep (const struct timespec *rqtp, struct timespec *rmtp);
  110. #if _EXTENSION_POSIX_REENTRANT /* undef this for ANSI */
  111. extern int    asctime_r(const struct tm *_tm, char *_buffer,
  112.      size_t *_buflen);
  113. extern char *    ctime_r (const time_t *_cal, char *_buffer, size_t *_buflen);
  114. extern int    gmtime_r (const time_t *_tod, struct tm *_result);
  115. extern int    localtime_r (const time_t *_tod, struct tm *_result);
  116. #endif /*  _EXTENSION_POSIX_REENTRANT */
  117. #else /* __STDC__ */
  118. extern uint_t      _clocks_per_sec();
  119. extern char *    asctime ();
  120. extern clock_t    clock ();
  121. extern char *    ctime ();
  122. extern double    difftime ();
  123. extern struct tm * gmtime ();
  124. extern struct tm * localtime ();
  125. extern time_t    mktime ();
  126. extern size_t    strftime ();
  127. extern time_t    time ();
  128. extern int  clock_settime ();
  129. extern int  clock_gettime ();
  130. extern int  clock_getres ();
  131. extern int  timer_create ();
  132. extern int  timer_delete ();
  133. extern int  timer_gettime ();
  134. extern int  timer_settime ();
  135. extern int  timer_getoverrun ();
  136. extern int  timer_connect ();
  137. extern int  timer_cancel ();
  138. extern int  timer_show ();
  139. extern int  nanosleep ();
  140. #if _EXTENSION_POSIX_REENTRANT /* undef this for ANSI */
  141. extern int    asctime_r();
  142. extern char *    ctime_r ();
  143. extern int    gmtime_r ();
  144. extern int    localtime_r ();
  145. #endif /*  _EXTENSION_POSIX_REENTRANT */
  146. #endif /* __STDC__ */
  147. #ifdef __cplusplus
  148. }
  149. #endif
  150. #endif /* __INCtimeh */