Ticket #9379: user_sys_time.h

File user_sys_time.h, 24.1 KB (added by gengyonghui@…, 9 years ago)
Line 
1/*
2 * BEGIN_DESC
3 *
4 * File:
5 * @(#)B11.23_LR common/sys/time.h $Revision: $
6 *
7 * Purpose:
8 * Definitions for time handling functions
9 *
10 * Classification: Release to Release Consistency Req:
11 * public binary & source
12 *
13 * BE header: yes
14 *
15 * Shipped: yes
16 * /usr/include/sys/time.h
17 * /usr/conf/sys/time.h
18 *
19 * END_DESC
20*/
21
22
23#ifndef _SYS_TIME_INCLUDED
24#define _SYS_TIME_INCLUDED
25
26#include <sys/stdsyms.h>
27#include <sys/types.h>
28#include <sys/sigevent.h>
29
30#ifdef __cplusplus
31# ifndef CLOCKS_PER_SEC
32# define CLOCKS_PER_SEC 1000000
33# endif
34
35# ifndef NULL
36# if __cplusplus < 199707L
37# define NULL 0 /* old compiler requires 0 not 0L */
38# else /* __cplusplus < 199707L */
39# define NULL 0L /* new compiler allows preferred 0L */
40# endif /* __cplusplus < 199707L */
41# endif /* NULL */
42#endif /* __cplusplus */
43
44/* XOPEN defs */
45
46#ifdef _XOPEN_SOURCE
47#if !defined(_XOPEN_SOURCE_EXTENDED) || (_XOPEN_SOURCE_EXTENDED +0 == -1)
48# ifndef _STRUCT_TM
49# define _STRUCT_TM
50_NAMESPACE_STD_START
51 struct tm {
52 int tm_sec; /* second (0-61, allows for leap seconds) */
53 int tm_min; /* minute (0-59) */
54 int tm_hour; /* hour (0-23) */
55 int tm_mday; /* day of the month (1-31) */
56 int tm_mon; /* month (0-11) */
57 int tm_year; /* years since 1900 */
58 int tm_wday; /* day of the week (0-6) */
59 int tm_yday; /* day of the year (0-365) */
60 int tm_isdst; /* non-0 if daylight savings time is in effect */
61 };
62_NAMESPACE_STD_END
63# endif /* _STRUCT_TM */
64
65# ifndef _GETDATE
66# define _GETDATE
67# ifndef _NO_USER_PROTOS
68# if defined(__ia64) && !defined(_LIBC)
69 /* pragmas needed to support -B protected */
70# pragma extern getdate
71# endif /* __ia64 && ! _LIBC */
72# ifdef _PROTOTYPES
73 extern __struct_tm *getdate(const char *);
74# else
75 extern struct tm *getdate();
76# endif /* _PROTOTYPES */
77# endif /* ! _NO_USER_PROTOS */
78# endif /* _GETDATE */
79#endif /* !defined(_XOPEN_SOURCE_EXTENDED) || (_XOPEN_SOURCE_EXTENDED +0 == -1) */
80#endif /* _XOPEN_SOURCE */
81
82/* ANSI C time constants, types, and structures */
83
84#ifdef _INCLUDE__STDC__
85
86# if defined(_XPG4_EXTENDED) && !defined(_INCLUDE_HPUX_SOURCE)
87 /*
88 * For CASPEC, look in <time.h> for the _XPG4_EXTENDED definition
89 * only if _XPG4_EXTENDED is turned on EXPLICITLY.
90 * But for all other cases, maintain definition(s) here
91 * EXCEPT: time_t is defined in both <time.h> and <sys/time.h>
92 */
93# else /* !_XPG4_EXTENDED || _INCLUDE_HPUX_SOURCE */
94
95# ifndef CLOCKS_PER_SEC
96# define CLOCKS_PER_SEC 1000000
97# endif
98
99#ifndef NULL
100# define NULL 0L
101#endif /* NULL */
102
103 /* Structure used with gmtime(), localtime(), mktime(), strftime(). */
104#ifndef _STRUCT_TM
105# define _STRUCT_TM
106_NAMESPACE_STD_START
107 struct tm {
108 int tm_sec; /* second (0-61, allows for leap seconds) */
109 int tm_min; /* minute (0-59) */
110 int tm_hour; /* hour (0-23) */
111 int tm_mday; /* day of the month (1-31) */
112 int tm_mon; /* month (0-11) */
113 int tm_year; /* years since 1900 */
114 int tm_wday; /* day of the week (0-6) */
115 int tm_yday; /* day of the year (0-365) */
116 int tm_isdst; /* non-0 if daylight savings time is in effect */
117 };
118_NAMESPACE_STD_END
119#endif /* _STRUCT_TM */
120# endif /* _XPG4_EXTENDED && _INCLUDE_HPUX_SOURCE */
121#endif /* _INCLUDE__STDC__ */
122
123#ifdef _INCLUDE_POSIX4_SOURCE
124#ifndef _STRUCT_TIMESPEC
125#define _STRUCT_TIMESPEC
126 /* Structure returned by clock_gettime(2) system call and others */
127 struct timespec {
128 __time_t tv_sec; /* seconds */
129 long tv_nsec; /* and nanoseconds */
130};
131typedef struct timespec timestruc_t;
132#endif /* _STRUCT_TIMESPEC */
133
134#ifndef _STRUCT_ITIMERSPEC
135#define _STRUCT_ITIMERSPEC
136/* Structure returned by timer_gettime(2) system call and others */
137struct itimerspec {
138 struct timespec it_interval; /* timer period */
139 struct timespec it_value; /* timer expiration */
140};
141#endif /* _STRUCT_ITIMERSPEC */
142
143typedef enum __clockid_t {
144 CLOCK_INVALID = 0,
145 CLOCK_REALTIME = 1, /* the system-wide "wall clock" */
146 CLOCK_VIRTUAL = 2, /* the per-process user execution clock */
147 CLOCK_PROFILE = 4, /* the per-process execution clock */
148 RTTIMER0 = 8,
149 RTTIMER1 = 16
150} clockid_t;
151
152#ifndef _TIMER_T
153#define _TIMER_T
154 typedef unsigned long timer_t;
155#if defined(_KERNEL) && defined(__LP64__)
156 typedef unsigned int timer_32t;
157#endif /* defined(_KERNEL) && defined(__LP64__) */
158#endif /* _TIMER_T_ */
159
160#define TIMER_ABSTIME 0x1
161#endif /* _INCLUDE_POSIX4_SOURCE */
162
163/* Additional types needed for HP-UX */
164
165#ifdef _INCLUDE_XOPEN_SOURCE_EXTENDED
166# ifndef _STRUCT_TIMEVAL
167# define _STRUCT_TIMEVAL
168 /* Structure returned by gettimeofday(2) system call and others */
169 struct timeval {
170# if defined(_XPG4_EXTENDED) && !defined(_KERNEL)
171 __time_t tv_sec; /* seconds */
172# else /* !__XPG4_EXTENDED || _KERNEL*/
173 uint32_t tv_sec; /* seconds */
174# endif /* __XPG4_EXTENDED && !_KERNEL*/
175 long tv_usec; /* and microseconds */
176 };
177# endif /* !__STRUCT_TIMEVAL */
178
179 /* Structure defining a timer setting. */
180 struct itimerval {
181 struct timeval it_interval; /* timer interval */
182 struct timeval it_value; /* current value */
183 };
184# define _STRUCT_ITIMERVAL
185
186#endif /* _INCLUDE_XOPEN_SOURCE_EXTENDED */
187
188#ifdef _INCLUDE_HPUX_SOURCE
189 /* Structure used to represent timezones for gettimeofday(2) and others */
190 struct timezone {
191 int tz_minuteswest; /* minutes west of Greenwich */
192 int tz_dsttime; /* type of dst correction */
193 };
194# define _STRUCT_TIMEZONE
195
196 /* Structure used to represent times as a 64-bit cycle count */
197 typedef struct __cycles { /* for counting machine cycles ... */
198 uint32_t hi; /* most significant bits */
199 uint32_t lo; /* least significant bits */
200 } cycles_t;
201#define _CYCLES_T
202
203#endif /* _INCLUDE_HPUX_SOURCE */
204
205
206/* Function prototypes and external variable declarations */
207
208#ifndef _NO_USER_PROTOS
209#ifdef __cplusplus
210 extern "C" {
211#endif /* __cplusplus */
212
213
214#if defined(_XPG4_EXTENDED) && !defined(_INCLUDE_HPUX_SOURCE)
215 /*
216 * For CASPEC, look in <time.h> for the _XPG4_EXTENDED definition
217 * But for all other cases, maintain definition(s) here
218 */
219#else /* !_XPG4_EXTENDED || _INCLUDE_HPUX_SOURCE */
220# ifdef _INCLUDE__STDC__
221# ifdef _PROTOTYPES
222
223_NAMESPACE_STD_START /* { */
224# ifndef _DIFFTIME
225# define _DIFFTIME
226# if defined(__ia64) && !defined(_LIBC)
227 /* pragmas needed to support -B protected */
228# pragma extern difftime
229# endif /* __ia64 && ! _LIBC */
230 extern double difftime(time_t, time_t);
231# endif
232
233# ifndef _MKTIME
234# define _MKTIME
235# if defined(__ia64) && !defined(_LIBC)
236 /* pragmas needed to support -B protected */
237# pragma extern mktime
238# endif /* __ia64 && ! _LIBC */
239 extern time_t mktime(struct tm *);
240# endif
241
242# ifndef _TIME
243# define _TIME
244# if defined(__ia64) && !defined(_LIBC)
245 /* pragmas needed to support -B protected */
246# pragma extern time
247# endif /* __ia64 && ! _LIBC */
248 extern time_t time(time_t *);
249# endif
250
251# ifndef _ASCTIME
252# if defined(__ia64) && !defined(_LIBC)
253 /* pragmas needed to support -B protected */
254# pragma extern asctime
255# endif /* __ia64 && ! _LIBC */
256 extern char *asctime(const struct tm *);
257# endif
258
259# ifndef _CTIME
260# define _CTIME
261# if defined(__ia64) && !defined(_LIBC)
262 /* pragmas needed to support -B protected */
263# pragma extern ctime
264# endif /* __ia64 && ! _LIBC */
265 extern char *ctime(const time_t *);
266# endif
267
268# ifndef _GMTIME
269# define _GMTIME
270# if defined(__ia64) && !defined(_LIBC)
271 /* pragmas needed to support -B protected */
272# pragma extern gmtime
273# endif /* __ia64 && ! _LIBC */
274 extern struct tm *gmtime(const time_t *);
275# endif
276
277# ifndef _LOCALTIME
278# define _LOCALTIME
279# if defined(__ia64) && !defined(_LIBC)
280 /* pragmas needed to support -B protected */
281# pragma extern localtime
282# endif /* __ia64 && ! _LIBC */
283 extern struct tm *localtime(const time_t *);
284# endif
285
286# ifndef _STRFTIME
287# define _STRFTIME
288# if defined(__ia64) && !defined(_LIBC)
289 /* pragmas needed to support -B protected */
290# pragma extern strftime
291# endif /* __ia64 && ! _LIBC */
292 extern size_t strftime(char *, size_t, const char *, const struct tm *);
293# endif
294_NAMESPACE_STD_END /* } */
295
296# ifdef _REENTRANT
297
298# ifndef _ASCTIME_R
299# define _ASCTIME_R
300# if defined(__ia64) && !defined(_LIBC)
301 /* pragmas needed to support -B protected */
302# pragma extern asctime_r
303# endif /* __ia64 && ! _LIBC */
304# ifndef _PTHREADS_DRAFT4
305 extern char *asctime_r(const __struct_tm *, char *);
306# else /* _PTHREADS_DRAFT4 */
307 extern int asctime_r(const __struct_tm *, char *, int);
308# endif /* _PTHREADS_DRAFT4 */
309# endif
310
311# ifndef _CTIME_R
312# define _CTIME_R
313# if defined(__ia64) && !defined(_LIBC)
314 /* pragmas needed to support -B protected */
315# pragma extern ctime_r
316# endif /* __ia64 && ! _LIBC */
317# ifndef _PTHREADS_DRAFT4
318 extern char *ctime_r(const __time_t *, char *);
319# else /* _PTHREADS_DRAFT4 */
320 extern int ctime_r(const __time_t *, char *, int);
321# endif /* _PTHREADS_DRAFT4 */
322# endif
323
324#ifndef _GMTIME_R
325# define _GMTIME_R
326# if defined(__ia64) && !defined(_LIBC)
327 /* pragmas needed to support -B protected */
328# pragma extern gmtime_r
329# endif /* __ia64 && ! _LIBC */
330# ifndef _PTHREADS_DRAFT4
331 extern __struct_tm *gmtime_r(const __time_t *, __struct_tm *);
332# else /* _PTHREADS_DRAFT4 */
333 extern int gmtime_r(const __time_t *, __struct_tm *);
334# endif /* _PTHREADS_DRAFT4 */
335# endif
336
337# ifndef _LOCALTIME_R
338# define _LOCALTIME_R
339# if defined(__ia64) && !defined(_LIBC)
340 /* pragmas needed to support -B protected */
341# pragma extern localtime_r
342# endif /* __ia64 && ! _LIBC */
343# ifndef _PTHREADS_DRAFT4
344 extern __struct_tm *localtime_r(const __time_t *, __struct_tm *);
345# else /* _PTHREADS_DRAFT4 */
346 extern int localtime_r(const __time_t *, __struct_tm *);
347# endif /* _PTHREADS_DRAFT4 */
348# endif
349
350# endif
351# else /* not _PROTOTYPES */
352
353# ifndef _DIFFTIME
354# define _DIFFTIME
355# if defined(__ia64) && !defined(_LIBC)
356 /* pragmas needed to support -B protected */
357# pragma extern difftime
358# endif /* __ia64 && ! _LIBC */
359 extern double difftime();
360# endif
361
362# ifndef _MKTIME
363# define _MKTIME
364# if defined(__ia64) && !defined(_LIBC)
365 /* pragmas needed to support -B protected */
366# pragma extern mktime
367# endif /* __ia64 && ! _LIBC */
368 extern time_t mktime();
369# endif
370
371# ifndef _TIME
372# define _TIME
373# if defined(__ia64) && !defined(_LIBC)
374 /* pragmas needed to support -B protected */
375# pragma extern time
376# endif /* __ia64 && ! _LIBC */
377 extern time_t time();
378# endif
379
380# ifndef _ASCTIME
381# define _ASCTIME
382# if defined(__ia64) && !defined(_LIBC)
383 /* pragmas needed to support -B protected */
384# pragma extern asctime
385# endif /* __ia64 && ! _LIBC */
386 extern char *asctime();
387# endif
388
389# ifndef _CTIME
390# define _CTIME
391# if defined(__ia64) && !defined(_LIBC)
392 /* pragmas needed to support -B protected */
393# pragma extern ctime
394# endif /* __ia64 && ! _LIBC */
395 extern char *ctime();
396# endif
397
398# ifndef _GMTIME
399# define _GMTIME
400# if defined(__ia64) && !defined(_LIBC)
401 /* pragmas needed to support -B protected */
402# pragma extern gmtime
403# endif /* __ia64 && ! _LIBC */
404 extern struct tm *gmtime();
405# endif
406
407# ifndef _LOCALTIME
408# define _LOCALTIME
409# if defined(__ia64) && !defined(_LIBC)
410 /* pragmas needed to support -B protected */
411# pragma extern localtime
412# endif /* __ia64 && ! _LIBC */
413 extern struct tm *localtime();
414# endif
415
416# ifndef _STRFTIME
417# define _STRFTIME
418# if defined(__ia64) && !defined(_LIBC)
419 /* pragmas needed to support -B protected */
420# pragma extern strftime
421# endif /* __ia64 && ! _LIBC */
422 extern size_t strftime();
423# endif
424
425
426# ifdef _REENTRANT
427
428# ifndef _ASCTIME_R
429# define _ASCTIME_R
430# if defined(__ia64) && !defined(_LIBC)
431 /* pragmas needed to support -B protected */
432# pragma extern asctime_r
433# endif /* __ia64 && ! _LIBC */
434# ifndef _PTHREADS_DRAFT4
435 extern char * asctime_r();
436# else /*_PTHREADS_DRAFT4 */
437 extern int asctime_r();
438# endif /*_PTHREADS_DRAFT4 */
439# endif
440
441# ifndef _CTIME_R
442# define _CTIME_R
443# if defined(__ia64) && !defined(_LIBC)
444 /* pragmas needed to support -B protected */
445# pragma extern ctime_r
446# endif /* __ia64 && ! _LIBC */
447# ifndef _PTHREADS_DRAFT4
448 extern char *ctime_r();
449# else /*_PTHREADS_DRAFT4 */
450 extern int ctime_r();
451# endif /*_PTHREADS_DRAFT4 */
452# endif
453
454# ifndef _GMTIME_R
455# define _GMTIME_R
456# if defined(__ia64) && !defined(_LIBC)
457 /* pragmas needed to support -B protected */
458# pragma extern gmtime_r
459# endif /* __ia64 && ! _LIBC */
460# ifndef _PTHREADS_DRAFT4
461 extern struct tm *gmtime_r();
462# else /*_PTHREADS_DRAFT4 */
463 extern int gmtime_r();
464# endif /*_PTHREADS_DRAFT4 */
465# endif
466
467#ifndef _LOCALTIME_R
468# define _LOCALTIME_R
469# if defined(__ia64) && !defined(_LIBC)
470 /* pragmas needed to support -B protected */
471# pragma extern localtime_r
472# endif /* __ia64 && ! _LIBC */
473# ifndef _PTHREADS_DRAFT4
474 extern struct tm *localtime_r();
475# else /*_PTHREADS_DRAFT4 */
476 extern int localtime_r();
477# endif /*_PTHREADS_DRAFT4 */
478# endif
479
480# endif
481# endif /* not _PROTOTYPES */
482
483# if defined(__ia64) && !defined(_LIBC)
484 /* pragmas needed to support -B protected */
485# ifndef _CLOCK
486# pragma extern clock
487# endif /* _CLOCK */
488# endif /* __ia64 && ! _LIBC */
489
490# ifdef _CLASSIC_ANSI_TYPES
491
492
493# ifndef _CLOCK
494# define _CLOCK
495 extern long clock(); /* REVISIT FOR 64BIT CLEAN */
496# endif
497# else /* not _CLASSIC_ANSI_TYPES */
498# ifdef _PROTOTYPES
499
500# ifndef _CLOCK
501# define _CLOCK
502_NAMESPACE_STD_START
503 extern clock_t clock(void);
504_NAMESPACE_STD_END
505# endif
506
507# else /* not _PROTOTYPES */
508
509# ifndef _CLOCK
510# define _CLOCK
511 extern clock_t clock();
512# endif
513# endif /* not _PROTOTYPES */
514# endif /* not _CLASSIC_ANSI_TYPES */
515#endif /* _INCLUDE__STDC__ */
516
517#ifdef _INCLUDE_POSIX_SOURCE
518
519# if defined(__ia64) && !defined(_LIBC)
520 /* pragmas needed to support -B protected */
521# ifndef _TZSET
522# pragma extern tzset
523# endif /* _TZSET */
524# endif /* __ia64 && ! _LIBC */
525
526# ifdef _PROTOTYPES
527# ifndef _TZSET
528# define _TZSET
529 extern void tzset(void);
530# endif
531# else /* not _PROTOTYPES */
532# ifndef _TZSET
533# define _TZSET
534 extern void tzset();
535# endif
536# endif /* not _PROTOTYPES */
537
538# if defined(__ia64) && !defined(_LIBC)
539 /* pragmas needed to support -B protected */
540# pragma extern tzname
541# endif /* __ia64 && ! _LIBC */
542
543 extern char *tzname[2];
544# endif /* _INCLUDE_POSIX_SOURCE */
545#endif /* _XPG4_EXTENDED || !_INCLUDE_HPUX_SOURCE */
546
547
548#ifdef _INCLUDE_POSIX4_SOURCE
549# if defined(__ia64) && !defined(_LIBC)
550 /* pragmas needed to support -B protected */
551# pragma extern clock_settime, clock_gettime, clock_getres
552# pragma extern timer_create, timer_delete, timer_settime
553# pragma extern timer_gettime, timer_getoverrun, nanosleep
554# endif /* __ia64 && ! _LIBC */
555# ifdef _PROTOTYPES
556 extern int clock_settime(clockid_t, const struct timespec *);
557 extern int clock_gettime(clockid_t, struct timespec *);
558 extern int clock_getres(clockid_t, struct timespec *);
559 extern int timer_create(clockid_t, struct sigevent *, timer_t *);
560 extern int timer_delete(timer_t);
561 extern int timer_settime(timer_t, int, const struct itimerspec *,
562 struct itimerspec *);
563 extern int timer_gettime(timer_t, struct itimerspec *);
564 extern int timer_getoverrun(timer_t);
565 extern int nanosleep(const struct timespec *, struct timespec *);
566# else /* not _PROTOTYPES */
567 extern int clock_settime();
568 extern int clock_gettime();
569 extern int clock_getres();
570 extern int timer_create();
571 extern int timer_delete();
572 extern int timer_settime();
573 extern int timer_gettime();
574 extern int timer_getoverrun();
575 extern int nanosleep();
576# endif /* not _PROTOTYPES */
577#endif /* _INCLUDE_POSIX4_SOURCE */
578
579
580#if defined(_XPG4_EXTENDED) && !defined(_INCLUDE_HPUX_SOURCE)
581 /*
582 * For CASPEC, look in <time.h> for the _XPG4_EXTENDED definition
583 * But for all other cases, maintain definition(s) here
584 */
585#else /* !_XPG4_EXTENDED || _INCLUDE_HPUX_SOURCE */
586# ifdef _INCLUDE_XOPEN_SOURCE
587# if defined(__ia64) && !defined(_LIBC)
588 /* pragmas needed to support -B protected */
589# ifndef _STRPTIME
590# pragma extern strptime
591# endif /* _STRPTIME */
592# ifndef _TIMEZONE
593# pragma extern timezone
594# endif /* _TIMEZONE */
595# ifndef _DAYLIGHT
596# pragma extern daylight
597# endif /* _DAYLIGHT */
598# endif /* __ia64 && ! _LIBC */
599# ifdef _PROTOTYPES
600# ifndef _STRPTIME
601# define _STRPTIME
602 extern char *strptime(const char *, const char *, __struct_tm *);
603# endif
604# else /* not _PROTOTYPES */
605# ifndef _STRPTIME
606# define _STRPTIME
607 extern char *strptime();
608# endif
609# endif /* not _PROTOTYPES */
610
611# ifndef _TIMEZONE
612# define _TIMEZONE
613 extern long timezone;
614# endif
615
616# ifndef _DAYLIGHT
617# define _DAYLIGHT
618 extern int daylight;
619# endif
620
621# endif /* _INCLUDE_XOPEN_SOURCE */
622#endif /* _XPG4_EXTENDED && !_INCLUDE_HPUX_SOURCE */
623
624#ifdef __cplusplus
625 }
626#endif /* __cplusplus */
627
628
629#ifdef _INCLUDE_XOPEN_SOURCE_EXTENDED
630
631/* For FD_* macros and struct fd_set. Here we get the x/Open version. */
632# ifndef _MAXFUPLIM
633# include <sys/_fd_macros.h>
634# endif /* not _MAXFUPLIM */
635
636# ifdef __cplusplus
637 extern "C" {
638# endif /* __cplusplus */
639
640# if defined(__ia64) && !defined(_LIBC)
641 /* pragmas needed to support -B protected */
642# pragma extern getitimer, setitimer, utimes, gettimeofday, select
643# endif /* __ia64 && ! _LIBC */
644
645# ifdef _PROTOTYPES
646 extern int getitimer(int, struct itimerval *);
647 extern int setitimer(int, const struct itimerval *, struct itimerval *);
648 extern int utimes(const char *, const struct timeval[2]);
649 extern int gettimeofday(struct timeval *, void *);
650# if defined(__INCLUDE_FROM_TIME_H) && !defined(_XOPEN_SOURCE_EXTENDED)
651 extern int select(__size_t, int *, int *, int *, const struct timeval *);
652# else /* __INCLUDE_FROM_TIME_H && !_XOPEN_SOURCE_EXTENDED */
653 extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
654# endif /* __INCLUDE_FROM_TIME_H && !_XOPEN_SOURCE_EXTENDED */
655# else /* !_PROTOTYPES */
656 extern int getitimer();
657 extern int setitimer();
658 extern int utimes();
659 extern int select();
660 extern int gettimeofday();
661# endif /* _PROTOTYPES */
662
663# ifdef __cplusplus
664 }
665# endif /* __cplusplus */
666
667#endif /* _INCLUDE_XOPEN_SOURCE_EXTENDED */
668
669
670#ifdef __cplusplus
671 extern "C" {
672#endif /* __cplusplus */
673
674#ifdef _INCLUDE_HPUX_SOURCE
675# if defined(__ia64) && !defined(_LIBC)
676 /* pragmas needed to support -B protected */
677# pragma extern adjtime
678# ifndef _GETDATE
679# pragma extern getdate
680# endif /* _GETDATE */
681# ifndef _GETDATE_R
682# ifdef _PTHREADS_DRAFT4
683# pragma extern getdate_r
684# endif /* _PTHREADS_DRAFT4 */
685# endif /* _GETDATE_R */
686# pragma extern settimeofday, stime, profil
687# endif /* __ia64 && ! _LIBC */
688# ifdef _PROTOTYPES
689 extern int adjtime(const struct timeval *, struct timeval *);
690
691# ifndef _GETDATE
692# define _GETDATE
693 extern __struct_tm *getdate(const char *);
694# endif
695
696# ifndef _GETDATE_R
697# define _GETDATE_R
698# ifdef _PTHREADS_DRAFT4
699 extern int getdate_r(const char *, __struct_tm *, int *);
700# endif /* _PTHREADS_DRAFT4 */
701# endif
702
703 extern int settimeofday(const struct timeval *, const struct timezone *);
704 extern int stime(const __time_t *);
705 extern void profil(void *, __size_t, __size_t, int);
706# else /* not _PROTOTYPES */
707 extern int adjtime();
708
709# ifndef _GETDATE
710# define _GETDATE
711 extern struct tm *getdate();
712# endif
713
714# ifndef _GETDATE_R
715# define _GETDATE_R
716# ifdef _PTHREADS_DRAFT4
717 extern int getdate_r();
718# endif /* _PTHREADS_DRAFT4 */
719# endif
720
721 extern int settimeofday();
722 extern int stime();
723 extern void profil();
724# endif /* not _PROTOTYPES */
725
726# ifndef _GETDATE_ERR
727# define _GETDATE_ERR
728
729#if defined(_REENTRANT) && !defined(_PTHREADS_DRAFT4)
730# if defined(__ia64) && !defined(_LIBC)
731 /* pragmas needed to support -B protected */
732# pragma extern __getdate_error
733# endif /* __ia64 && ! _LIBC */
734 int * __getdate_error __((void)) ;
735# define getdate_err (*__getdate_error())
736# else
737# if defined(__ia64) && !defined(_LIBC)
738 /* pragmas needed to support -B protected */
739# pragma extern getdate_err
740# endif /* __ia64 && ! _LIBC */
741 extern int getdate_err;
742# endif /* defined(_REENTRANT) && !defined(_PTHREADS_DRAFT4) */
743
744# endif
745#endif /* _INCLUDE_HPUX_SOURCE */
746
747#ifdef __cplusplus
748 }
749#endif /* __cplusplus */
750#endif /* not _NO_USER_PROTOS */
751
752#if defined(_XPG4_EXTENDED) && !defined(_INCLUDE_HPUX_SOURCE)
753/*
754 * For CASPEC, look in <time.h> for the _XPG4_EXTENDED definition
755 * But for all other cases, maintain definition(s) here
756 */
757#else /* not _XPG4_EXTENDED */
758 /*
759 * CLK_TCK is needed by the kernel, and also in the POSIX namespace.
760 */
761
762# ifdef _INCLUDE_POSIX_SOURCE
763# ifndef CLK_TCK
764# define CLK_TCK 100
765# endif /* CLK_TCK */
766# endif
767#endif /* _XPG4_EXTENDED */
768
769#ifdef _INCLUDE_XOPEN_SOURCE_EXTENDED
770
771/* Additional structures, macros, and constants */
772
773 /* Names of the interval timers */
774# define ITIMER_REAL 0
775# define ITIMER_VIRTUAL 1
776# define ITIMER_PROF 2
777
778/*
779 * Thread specific timers.
780 */
781# define ITIMER_THREAD_REAL 3
782# define ITIMER_THREAD_VIRTUAL 4
783# define ITIMER_THREAD_PROF 5
784
785#endif /* _INCLUDE_XOPEN_SOURCE_EXTENDED */
786
787/* Additional HP-UX structures, macros, and constants */
788
789#ifdef _INCLUDE_HPUX_SOURCE
790
791 /* Kernel instrumentation time value */
792 struct ki_timeval {
793 uint32_t pad1;
794 uint32_t pad2;
795 };
796
797/*
798 * The definition of kt_t assumes 2 things :
799 * First, 32bit data types are alligned 32bit (i.e. and int is
800 * not padded to 8 bytes).
801 * Second, any consumer that truely uses KI (and thus kt_t) will
802 * be compiled in extended mode.
803 *
804 * If the size of kt_t changes or compiler alignment rules change, this
805 * will have to be adjusted.
806 */
807
808/* 11.0 and later representation of ki time*/
809#if !defined(_KT_T)
810#define _KT_T
811#if !defined(__STDC_32_MODE__)
812typedef uint64_t kt_t;
813#else
814typedef struct ki_timeval kt_t;
815#endif /*narrow mode space reservation*/
816#endif /* _KT_T */
817
818
819 /* Kinds of daylight savings time */
820# define DST_NONE 0 /* not on dst */
821# define DST_USA 1 /* USA style dst */
822# define DST_AUST 2 /* Australian style dst */
823# define DST_WET 3 /* Western European dst */
824# define DST_MET 4 /* Middle European dst */
825# define DST_EET 5 /* Eastern European dst */
826
827 /*
828 * Operations on timevals.
829 *
830 * NB: timercmp does not work for >= or <= or ==.
831 */
832# define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
833# define timercmp(tvp, uvp, cmp) \
834 ((tvp)->tv_sec cmp (uvp)->tv_sec || \
835 (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
836# define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0L)
837# define is_valid_timeval(tvp) \
838 ((tvp)->tv_usec >= 0L && (tvp)->tv_usec < 1000000L)
839
840
841
842 /*
843 * Operations on timespecs.
844 *
845 * NB: timespeccmp works for < and >, not >=, == or <=.
846 */
847#define timespeccmp(tsp1, tsp2, op) \
848 ((tsp1)->tv_sec op (tsp2)->tv_sec || \
849 ((tsp1)->tv_sec == (tsp2)->tv_sec && (tsp1)->tv_nsec op (tsp2)->tv_nsec))
850
851#define timespeceq(tsp1, tsp2) \
852 ((tsp1)->tv_sec == (tsp2)->tv_sec && \
853 (tsp1)->tv_nsec == (tsp2)->tv_nsec)
854
855#define timespecclear(tsp) ((tsp)->tv_sec = (tsp)->tv_nsec = 0L)
856
857#define timespecisset(tsp) ((tsp)->tv_nsec || (tsp)->tv_sec)
858
859#endif /* _INCLUDE_HPUX_SOURCE */
860
861#endif /* _SYS_TIME_INCLUDED */
862