Annotation of src/include/time.h, Revision 1.20
1.20 ! jsg 1: /* $OpenBSD: time.h,v 1.19 2011/04/06 11:39:42 miod Exp $ */
1.1 deraadt 2: /* $NetBSD: time.h,v 1.9 1994/10/26 00:56:35 cgd Exp $ */
3:
4: /*
5: * Copyright (c) 1989 The Regents of the University of California.
6: * All rights reserved.
7: *
8: * (c) UNIX System Laboratories, Inc.
9: * All or some portions of this file are derived from material licensed
10: * to the University of California by American Telephone and Telegraph
11: * Co. or Unix System Laboratories, Inc. and are reproduced herein with
12: * the permission of UNIX System Laboratories, Inc.
13: *
14: * Redistribution and use in source and binary forms, with or without
15: * modification, are permitted provided that the following conditions
16: * are met:
17: * 1. Redistributions of source code must retain the above copyright
18: * notice, this list of conditions and the following disclaimer.
19: * 2. Redistributions in binary form must reproduce the above copyright
20: * notice, this list of conditions and the following disclaimer in the
21: * documentation and/or other materials provided with the distribution.
1.13 millert 22: * 3. Neither the name of the University nor the names of its contributors
1.1 deraadt 23: * may be used to endorse or promote products derived from this software
24: * without specific prior written permission.
25: *
26: * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27: * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29: * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30: * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31: * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32: * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33: * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34: * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35: * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36: * SUCH DAMAGE.
37: *
38: * @(#)time.h 5.12 (Berkeley) 3/9/91
39: */
40:
41: #ifndef _TIME_H_
42: #define _TIME_H_
43:
1.17 millert 44: #include <sys/cdefs.h>
1.18 millert 45: #include <machine/_types.h>
1.1 deraadt 46:
47: #ifndef NULL
1.7 espie 48: #ifdef __GNUG__
1.8 espie 49: #define NULL __null
1.20 ! jsg 50: #elif defined(__cplusplus)
! 51: #define NULL 0L
1.7 espie 52: #else
1.19 miod 53: #define NULL ((void *)0)
1.7 espie 54: #endif
1.1 deraadt 55: #endif
56:
1.18 millert 57: #ifndef _CLOCK_T_DEFINED_
58: #define _CLOCK_T_DEFINED_
59: typedef __clock_t clock_t;
1.1 deraadt 60: #endif
61:
1.18 millert 62: #ifndef _TIME_T_DEFINED_
63: #define _TIME_T_DEFINED_
64: typedef __time_t time_t;
1.1 deraadt 65: #endif
66:
1.18 millert 67: #ifndef _SIZE_T_DEFINED_
68: #define _SIZE_T_DEFINED_
69: typedef __size_t size_t;
1.1 deraadt 70: #endif
71:
1.17 millert 72: #if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE
73: /*
74: * Frequency of the clock ticks reported by times(). Deprecated - use
75: * sysconf(_SC_CLK_TCK) instead. (Removed in 1003.1-2001.)
76: */
77: #define CLK_TCK 100
78: #endif
79:
80: #define CLOCKS_PER_SEC 100 /* frequency of ticks reported by clock(). */
81:
82: #ifndef _TIMESPEC_DECLARED
83: #define _TIMESPEC_DECLARED
84: struct timespec {
85: time_t tv_sec; /* seconds */
86: long tv_nsec; /* and nanoseconds */
87: };
88: #endif
1.1 deraadt 89:
90: struct tm {
91: int tm_sec; /* seconds after the minute [0-60] */
92: int tm_min; /* minutes after the hour [0-59] */
93: int tm_hour; /* hours since midnight [0-23] */
94: int tm_mday; /* day of the month [1-31] */
95: int tm_mon; /* months since January [0-11] */
96: int tm_year; /* years since 1900 */
97: int tm_wday; /* days since Sunday [0-6] */
98: int tm_yday; /* days since January 1 [0-365] */
1.5 pjanzen 99: int tm_isdst; /* Daylight Saving Time flag */
1.6 aaron 100: long tm_gmtoff; /* offset from UTC in seconds */
1.1 deraadt 101: char *tm_zone; /* timezone abbreviation */
102: };
103:
104: __BEGIN_DECLS
1.10 millert 105: struct timespec;
1.11 millert 106: char *asctime(const struct tm *);
107: clock_t clock(void);
108: char *ctime(const time_t *);
109: double difftime(time_t, time_t);
110: struct tm *gmtime(const time_t *);
111: struct tm *localtime(const time_t *);
112: time_t mktime(struct tm *);
1.16 avsm 113: size_t strftime(char *, size_t, const char *, const struct tm *)
114: __attribute__ ((__bounded__(__string__,1,2)));
1.11 millert 115: char *strptime(const char *, const char *, struct tm *);
116: time_t time(time_t *);
1.16 avsm 117: char *asctime_r(const struct tm *, char *)
118: __attribute__ ((__bounded__(__minbytes__,2,26)));
119: char *ctime_r(const time_t *, char *)
120: __attribute__ ((__bounded__(__minbytes__,2,26)));
1.11 millert 121: struct tm *gmtime_r(const time_t *, struct tm *);
122: struct tm *localtime_r(const time_t *, struct tm *);
123: int nanosleep(const struct timespec *, struct timespec *);
1.1 deraadt 124:
1.17 millert 125: #if __POSIX_VISIBLE
1.1 deraadt 126: extern char *tzname[2];
1.11 millert 127: void tzset(void);
1.17 millert 128: #endif
1.1 deraadt 129:
1.17 millert 130: #if __BSD_VISIBLE
1.11 millert 131: char *timezone(int, int);
132: void tzsetwall(void);
133: time_t timelocal(struct tm *);
134: time_t timegm(struct tm *);
135: time_t timeoff(struct tm *, const long);
1.17 millert 136: #endif
1.1 deraadt 137: __END_DECLS
138:
139: #endif /* !_TIME_H_ */