source: trunk/src/emx/include/time.h@ 1788

Last change on this file since 1788 was 1788, checked in by bird, 21 years ago

Added time64_t and a few 64-bit time functions for dealing better with over/underflows.

  • Property cvs2svn:cvs-rev set to 1.7
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 7.4 KB
Line 
1/** @file
2 * FreeBSD 5.1
3 *
4 * @changed EMX isms.
5 * @changed Removed timezone() function as it clashes with the timezone
6 * variable defined in EMX and OGBSI6.
7 * @changed Changed CLK_TCK and CLOCKS_PER_SEC to 100.
8 * @changed Commented out tm_gmtoff and tm_zone in struct tm as LIBC doesn't
9 * implement these yet.
10 *
11 * @todo Implement tm_gmtoff and tm_zone members in struct tm.
12 * @todo Implement clock_getres(), clock_gettime(), clock_settime(), nanosleep().
13 * asctime_r(), ctime_r(), gmtime_r() and localtime_r() which are defined in
14 * various POSIX standard revisions.
15 * @todo Implement tzsetwall(), timelocal(), timegm() which are BSD specific.
16 */
17/*
18 * Copyright (c) 1989, 1993
19 * The Regents of the University of California. All rights reserved.
20 * (c) UNIX System Laboratories, Inc.
21 * All or some portions of this file are derived from material licensed
22 * to the University of California by American Telephone and Telegraph
23 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
24 * the permission of UNIX System Laboratories, Inc.
25 *
26 * Redistribution and use in source and binary forms, with or without
27 * modification, are permitted provided that the following conditions
28 * are met:
29 * 1. Redistributions of source code must retain the above copyright
30 * notice, this list of conditions and the following disclaimer.
31 * 2. Redistributions in binary form must reproduce the above copyright
32 * notice, this list of conditions and the following disclaimer in the
33 * documentation and/or other materials provided with the distribution.
34 * 3. All advertising materials mentioning features or use of this software
35 * must display the following acknowledgement:
36 * This product includes software developed by the University of
37 * California, Berkeley and its contributors.
38 * 4. Neither the name of the University nor the names of its contributors
39 * may be used to endorse or promote products derived from this software
40 * without specific prior written permission.
41 *
42 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
43 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
46 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
48 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
50 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
51 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
52 * SUCH DAMAGE.
53 *
54 * @(#)time.h 8.3 (Berkeley) 1/21/94
55 */
56
57/*
58 * $FreeBSD: src/include/time.h,v 1.30 2002/09/06 11:23:32 tjr Exp $
59 */
60
61#ifndef _TIME_H_
62#define _TIME_H_
63#define _TIME_H /* bird: EMX */
64
65#include <sys/cdefs.h>
66#include <sys/_types.h>
67
68#if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE
69/*
70 * Frequency of the clock ticks reported by times(). Deprecated - use
71 * sysconf(_SC_CLK_TCK) instead. (Removed in 1003.1-2001.)
72 */
73#define CLK_TCK 100 /* bird: EMX uses 100, FreeBSD 128. */
74#endif
75
76/* Frequency of the clock ticks reported by clock(). */
77#define CLOCKS_PER_SEC 100 /* bird: EMX uses 100, FreeBSD 128. */
78
79#ifndef NULL
80#define NULL 0
81#endif
82
83#if !defined(_CLOCK_T_DECLARED) && !defined(_CLOCK_T) /* bird: EMX */
84typedef __clock_t clock_t;
85#define _CLOCK_T_DECLARED
86#define _CLOCK_T /* bird: EMX */
87#endif
88
89#if !defined(_TIME_T_DECLARED) && !defined(_TIME_T) /* bird: EMX */
90typedef __time_t time_t;
91#define _TIME_T_DECLARED
92#define _TIME_T /* bird: EMX */
93#endif
94
95#ifndef _TIME64_T_DECLARED /* bird: LIBC */
96typedef __int64_t time64_t; /* bird: LIBC */
97#define _TIME64_T_DECLARED /* bird: LIBC */
98#endif /* bird: LIBC */
99
100#if !defined(_SIZE_T_DECLARED) && !defined(_SIZE_T) /* bird: EMX */
101typedef __size_t size_t;
102#define _SIZE_T_DECLARED
103#define _SIZE_T /* bird: EMX */
104#endif
105
106#if __POSIX_VISIBLE >= 199309
107/*
108 * New in POSIX 1003.1b-1993.
109 */
110#if !defined(_CLOCKID_T_DECLARED) && !defined(_CLOCKID_T) /* bird: EMX */
111typedef __clockid_t clockid_t;
112#define _CLOCKID_T_DECLARED
113#define _CLOCKID_T /* bird: EMX */
114#endif
115
116#if !defined(_TIMER_T_DECLARED) && !defined(_TIMER_T) /* bird: EMX */
117typedef __timer_t timer_t;
118#define _TIMER_T_DECLARED
119#define _TIMER_T /* bird: EMX */
120#endif
121
122#include <sys/timespec.h>
123#endif /* __POSIX_VISIBLE >= 199309 */
124
125struct tm {
126 int tm_sec; /* seconds after the minute [0-60] */
127 int tm_min; /* minutes after the hour [0-59] */
128 int tm_hour; /* hours since midnight [0-23] */
129 int tm_mday; /* day of the month [1-31] */
130 int tm_mon; /* months since January [0-11] */
131 int tm_year; /* years since 1900 */
132 int tm_wday; /* days since Sunday [0-6] */
133 int tm_yday; /* days since January 1 [0-365] */
134 int tm_isdst; /* Daylight Savings Time flag */
135#if 0 /* bird: LIBC isn't implementing tm_gmtoff and tm_zone. */
136 long tm_gmtoff; /* offset from UTC in seconds */
137 char *tm_zone; /* timezone abbreviation */
138#endif
139};
140
141#if __POSIX_VISIBLE
142extern char *tzname[];
143#endif
144
145__BEGIN_DECLS
146char *asctime(const struct tm *);
147clock_t clock(void);
148char *ctime(const time_t *);
149double difftime(time_t, time_t);
150struct tm *gmtime(const time_t *);
151struct tm *localtime(const time_t *);
152struct tm *_localtime64_r(const time64_t *, struct tm *); /* bird: LIBC */
153time_t mktime(struct tm *);
154time64_t _mktime64(struct tm *); /* bird: LIBC */
155size_t strftime(char * __restrict, size_t, const char * __restrict,
156 const struct tm * __restrict);
157time_t time(time_t *);
158
159#if __POSIX_VISIBLE
160void tzset(void);
161#endif
162
163#if __POSIX_VISIBLE >= 199309
164int clock_getres(clockid_t, struct timespec *);
165int clock_gettime(clockid_t, struct timespec *);
166int clock_settime(clockid_t, const struct timespec *);
167int nanosleep(const struct timespec *, struct timespec *);
168#endif /* __POSIX_VISIBLE >= 199309 */
169
170#if __POSIX_VISIBLE >= 199506
171char *asctime_r(const struct tm *, char *);
172char *ctime_r(const time_t *, char *);
173struct tm *gmtime_r(const time_t *, struct tm *);
174struct tm *_gmtime64_r(const time64_t *, struct tm *); /* bird: LIBC */
175struct tm *localtime_r(const time_t *, struct tm *);
176#endif
177
178#if __XSI_VISIBLE
179char *strptime(const char * __restrict, const char * __restrict,
180 struct tm * __restrict);
181#endif
182
183#if __BSD_VISIBLE
184/* bird: clash with EMX (and OGBSI6) timezone is a variable. man page say this
185 * is for Unix version 7 compatability though...
186char *timezone(int, int); */
187void tzsetwall(void);
188time_t timelocal(struct tm * const);
189time_t timegm(struct tm * const);
190#endif /* __BSD_VISIBLE */
191
192/* bird: LIBC OGBSI6 compliance extras. */
193#if __POSIX_VISIBLE
194extern int daylight;
195extern long timezone;
196#endif
197
198/* bird: EMX/VAC/MSC legacy start. */
199#if (!defined (__STRICT_ANSI__) && !defined (_POSIX_SOURCE)) || defined (_WITH_UNDERSCORE) || defined(__USE_EMX)
200extern int _daylight;
201extern long _timezone;
202extern char *_tzname[2];
203char *_strptime (__const__ char *, __const__ char *, struct tm *);
204void _tzset (void);
205#endif
206/* bird: EMX stuff end. */
207
208__END_DECLS
209
210#endif /* !_TIME_H_ */
211
Note: See TracBrowser for help on using the repository browser.