blob: c2c3ee8762121f6746c88e6e67e30da73ccc49a1 [file] [log] [blame]
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08001/*
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 */
Elliott Hughes3503ce22013-11-05 13:28:36 -080028
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080029#ifndef _TIME_H_
30#define _TIME_H_
31
32#include <sys/cdefs.h>
33#include <sys/time.h>
David 'Digit' Turnerc1b44ec2012-10-17 19:10:11 +020034
Elliott Hughes3503ce22013-11-05 13:28:36 -080035/* For struct sigevent. */
David 'Digit' Turnerc1b44ec2012-10-17 19:10:11 +020036#define __ARCH_SI_UID_T __kernel_uid32_t
37#include <asm/siginfo.h>
38#undef __ARCH_SI_UID_T
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080039
40__BEGIN_DECLS
41
Elliott Hughes3503ce22013-11-05 13:28:36 -080042#define CLOCKS_PER_SEC 1000000
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080043
Elliott Hughes3503ce22013-11-05 13:28:36 -080044extern char* tzname[];
45extern int daylight;
46extern long int timezone;
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080047
48struct tm {
Elliott Hughes3503ce22013-11-05 13:28:36 -080049 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;
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080060};
61
Elliott Hughes3503ce22013-11-05 13:28:36 -080062#define TM_ZONE tm_zone
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080063
Elliott Hughes3503ce22013-11-05 13:28:36 -080064extern time_t time(time_t*);
65extern int nanosleep(const struct timespec*, struct timespec*);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080066
Elliott Hughes3503ce22013-11-05 13:28:36 -080067extern char* strtotimeval(const char*, struct timeval*);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080068
Elliott Hughes3503ce22013-11-05 13:28:36 -080069extern char* asctime(const struct tm*);
70extern char* asctime_r(const struct tm*, char*);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080071
Elliott Hughes3503ce22013-11-05 13:28:36 -080072extern double difftime(time_t, time_t);
73extern time_t mktime(struct tm*);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080074
Elliott Hughes3503ce22013-11-05 13:28:36 -080075extern struct tm* localtime(const time_t*);
76extern struct tm* localtime_r(const time_t*, struct tm*);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080077
Elliott Hughes3503ce22013-11-05 13:28:36 -080078extern struct tm* gmtime(const time_t*);
79extern struct tm* gmtime_r(const time_t*, struct tm*);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080080
Elliott Hughes3503ce22013-11-05 13:28:36 -080081extern char* strptime(const char*, const char*, struct tm*);
82extern size_t strftime(char*, size_t, const char*, const struct tm*);
The Android Open Source Projectedbe7fc2009-03-18 22:20:24 -070083
Elliott Hughes3503ce22013-11-05 13:28:36 -080084extern char* ctime(const time_t*);
85extern char* ctime_r(const time_t*, char*);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080086
Elliott Hughes3503ce22013-11-05 13:28:36 -080087extern void tzset(void);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080088
Elliott Hughes3503ce22013-11-05 13:28:36 -080089extern clock_t clock(void);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080090
Elliott Hughes3503ce22013-11-05 13:28:36 -080091extern int clock_getres(int, struct timespec*);
92extern int clock_gettime(int, struct timespec*);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080093
Elliott Hughes3503ce22013-11-05 13:28:36 -080094extern 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);
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080099
Elliott Hughes3503ce22013-11-05 13:28:36 -0800100extern time_t timelocal(struct tm*);
101extern time_t timegm(struct tm*);
102extern time_t time2posix(time_t);
103extern time_t posix2time(time_t);
David 'Digit' Turner6481b912010-12-06 12:23:16 +0100104
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800105__END_DECLS
106
107#endif /* _TIME_H_ */