blob: fa1da4812ee7c4b2fe903deeb5a87274b87c832d [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 */
28#ifndef _TIME_H_
29#define _TIME_H_
30
31#include <sys/cdefs.h>
32#include <sys/time.h>
33
34#define __ARCH_SI_UID_T __kernel_uid32_t
35#include <asm/siginfo.h>
36#undef __ARCH_SI_UID_T
37
38__BEGIN_DECLS
39
40extern time_t time(time_t *);
41extern int nanosleep(const struct timespec *, struct timespec *);
42
43extern char *strtotimeval(const char *str, struct timeval *tv);
44
45struct tm {
46 int tm_sec; /* seconds */
47 int tm_min; /* minutes */
48 int tm_hour; /* hours */
49 int tm_mday; /* day of the month */
50 int tm_mon; /* month */
51 int tm_year; /* year */
52 int tm_wday; /* day of the week */
53 int tm_yday; /* day in the year */
54 int tm_isdst; /* daylight saving time */
55
56 long int tm_gmtoff; /* Seconds east of UTC. */
57 const char *tm_zone; /* Timezone abbreviation. */
58
59};
60
61/* defining TM_ZONE indicates that we have a "timezone abbreviation" field in
62 * struct tm, the value should be the field name
63 */
64#define TM_ZONE tm_zone
65
66extern char* asctime(const struct tm* a);
67extern char* asctime_r(const struct tm* a, char* buf);
68
69/* Return the difference between TIME1 and TIME0. */
70extern double difftime (time_t __time1, time_t __time0);
71extern time_t mktime (struct tm *a);
72
73extern struct tm* localtime(const time_t *t);
74extern struct tm* localtime_r(const time_t *timep, struct tm *result);
75
76extern struct tm* gmtime(const time_t *timep);
77extern struct tm* gmtime_r(const time_t *timep, struct tm *result);
78
79extern char* strptime(const char *buf, const char *fmt, struct tm *tm);
80extern size_t strftime(char *s, size_t max, const char *format, const struct tm *tm);
81
The Android Open Source Projectedbe7fc2009-03-18 22:20:24 -070082/* ANDROID-BEGIN */
83struct strftime_locale {
84 const char * mon[12];
85 const char * month[12];
86 const char * wday[7];
87 const char * weekday[7];
88 const char * X_fmt;
89 const char * x_fmt;
90 const char * c_fmt;
91 const char * am;
92 const char * pm;
93 const char * date_fmt;
94};
95
96extern size_t strftime_tz(char *s, size_t max, const char *format, const struct tm *tm, const struct strftime_locale* lc);
97/* ANDROID-END */
98
The Android Open Source Project1dc9e472009-03-03 19:28:35 -080099extern char *ctime(const time_t *timep);
100extern char *ctime_r(const time_t *timep, char *buf);
101
The Android Open Source Projectedbe7fc2009-03-18 22:20:24 -0700102extern void tzset(void);
103
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800104/* global includes */
105extern char* tzname[];
106extern int daylight;
107extern long int timezone;
108
109#define CLOCKS_PER_SEC 1000000
110
111extern clock_t clock();
112
113/* BIONIC: extra linux clock goodies */
114extern int clock_getres(int, struct timespec *);
115extern int clock_gettime(int, struct timespec *);
116
117#define CLOCK_REALTIME 0
118#define CLOCK_MONOTONIC 1
119#define CLOCK_PROCESS_CPUTIME_ID 2
120#define CLOCK_THREAD_CPUTIME_ID 3
121#define CLOCK_REALTIME_HR 4
122#define CLOCK_MONOTONIC_HR 5
123
124extern int timer_create(int, struct sigevent*, timer_t*);
125extern int timer_delete(timer_t);
126extern int timer_settime(timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue);
127extern int timer_gettime(timer_t timerid, struct itimerspec *value);
128extern int timer_getoverrun(timer_t timerid);
129
130__END_DECLS
131
132#endif /* _TIME_H_ */