time.h revision 3503ce2177a56a8807887ee540abc68377483393
1/*
2 * Copyright (C) 2008 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *  * Redistributions of source code must retain the above copyright
9 *    notice, this list of conditions and the following disclaimer.
10 *  * Redistributions in binary form must reproduce the above copyright
11 *    notice, this list of conditions and the following disclaimer in
12 *    the documentation and/or other materials provided with the
13 *    distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#ifndef _TIME_H_
30#define _TIME_H_
31
32#include <sys/cdefs.h>
33#include <sys/time.h>
34
35/* For struct sigevent. */
36#define __ARCH_SI_UID_T __kernel_uid32_t
37#include <asm/siginfo.h>
38#undef __ARCH_SI_UID_T
39
40__BEGIN_DECLS
41
42#define CLOCKS_PER_SEC 1000000
43
44extern char* tzname[];
45extern int daylight;
46extern long int timezone;
47
48struct tm {
49  int tm_sec;
50  int tm_min;
51  int tm_hour;
52  int tm_mday;
53  int tm_mon;
54  int tm_year;
55  int tm_wday;
56  int tm_yday;
57  int tm_isdst;
58  long int tm_gmtoff;
59  const char* tm_zone;
60};
61
62#define TM_ZONE tm_zone
63
64extern time_t time(time_t*);
65extern int nanosleep(const struct timespec*, struct timespec*);
66
67extern char* strtotimeval(const char*, struct timeval*);
68
69extern char* asctime(const struct tm*);
70extern char* asctime_r(const struct tm*, char*);
71
72extern double difftime(time_t, time_t);
73extern time_t mktime(struct tm*);
74
75extern struct tm* localtime(const time_t*);
76extern struct tm* localtime_r(const time_t*, struct tm*);
77
78extern struct tm* gmtime(const time_t*);
79extern struct tm* gmtime_r(const time_t*, struct tm*);
80
81extern char* strptime(const char*, const char*, struct tm*);
82extern size_t strftime(char*, size_t, const char*, const struct tm*);
83
84extern char* ctime(const time_t*);
85extern char* ctime_r(const time_t*, char*);
86
87extern void tzset(void);
88
89extern clock_t clock(void);
90
91extern int clock_getres(int, struct timespec*);
92extern int clock_gettime(int, struct timespec*);
93
94extern int timer_create(int, struct sigevent*, timer_t*);
95extern int timer_delete(timer_t);
96extern int timer_settime(timer_t, int, const struct itimerspec*, struct itimerspec*);
97extern int timer_gettime(timer_t, struct itimerspec*);
98extern int timer_getoverrun(timer_t);
99
100extern time_t timelocal(struct tm*);
101extern time_t timegm(struct tm*);
102extern time_t time2posix(time_t);
103extern time_t posix2time(time_t);
104
105__END_DECLS
106
107#endif /* _TIME_H_ */
108