111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/*
211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Copyright (C) 2008 The Android Open Source Project
311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * All rights reserved.
411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *
511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * Redistribution and use in source and binary forms, with or without
611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * modification, are permitted provided that the following conditions
711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * are met:
811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *  * Redistributions of source code must retain the above copyright
911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *    notice, this list of conditions and the following disclaimer.
1011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *  * Redistributions in binary form must reproduce the above copyright
1111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *    notice, this list of conditions and the following disclaimer in
1211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *    the documentation and/or other materials provided with the
1311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *    distribution.
1411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert *
1511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
1811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
1911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
2011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
2111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
2211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
2311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
2411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
2511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * SUCH DAMAGE.
2711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
2811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#ifndef _TIME_H_
2911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define _TIME_H_
3011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
3111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#include <sys/cdefs.h>
3211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#include <sys/time.h>
3311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
3411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define __ARCH_SI_UID_T __kernel_uid32_t
3511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#include <asm/siginfo.h>
3611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#undef __ARCH_SI_UID_T
3711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
3811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert__BEGIN_DECLS
3911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
4011cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern time_t   time(time_t *);
4111cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern int      nanosleep(const struct timespec *, struct timespec *);
4211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
4311cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern char *strtotimeval(const char *str, struct timeval *tv);
4411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
4511cd02dfb91661c65134cac258cf5924270e9d2Dan Albertstruct tm {
4611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert   int     tm_sec;         /* seconds */
4711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert   int     tm_min;         /* minutes */
4811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert   int     tm_hour;        /* hours */
4911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert   int     tm_mday;        /* day of the month */
5011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert   int     tm_mon;         /* month */
5111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert   int     tm_year;        /* year */
5211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert   int     tm_wday;        /* day of the week */
5311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert   int     tm_yday;        /* day in the year */
5411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert   int     tm_isdst;       /* daylight saving time */
5511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
5611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert   long int tm_gmtoff;     /* Seconds east of UTC.  */
5711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert   const char *tm_zone;    /* Timezone abbreviation.  */
5811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
5911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert};
6011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
6111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* defining TM_ZONE indicates that we have a "timezone abbreviation" field in
6211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert * struct tm, the value should be the field name
6311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert */
6411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define   TM_ZONE   tm_zone
6511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
6611cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern char* asctime(const struct tm* a);
6711cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern char* asctime_r(const struct tm* a, char* buf);
6811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
6911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* Return the difference between TIME1 and TIME0.  */
7011cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern double difftime (time_t __time1, time_t __time0) __NDK_FPABI__;
7111cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern time_t mktime (struct tm *a);
7211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
7311cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern struct tm*  localtime(const time_t *t);
7411cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern struct tm*  localtime_r(const time_t *timep, struct tm *result);
7511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
7611cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern struct tm*  gmtime(const time_t *timep);
7711cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern struct tm*  gmtime_r(const time_t *timep, struct tm *result);
7811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
7911cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern char*       strptime(const char *buf, const char *fmt, struct tm *tm);
8011cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern size_t      strftime(char *s, size_t max, const char *format, const struct tm *tm);
8111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
8211cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern char *ctime(const time_t *timep);
8311cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern char *ctime_r(const time_t *timep, char *buf);
8411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
8511cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern void  tzset(void);
8611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
8711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* global includes */
8811cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern char*     tzname[];
8911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#if 0 /* MISSING FROM BIONIC */
9011cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern int       daylight;
9111cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern long int  timezone;
9211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#endif /* MISSING */
9311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
9411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define CLOCKS_PER_SEC     1000000
9511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
9611cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern clock_t   clock(void);
9711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
9811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert/* BIONIC: extra linux clock goodies */
9911cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern int clock_getres(clockid_t, struct timespec *);
10011cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern int clock_gettime(clockid_t, struct timespec *);
10111cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern int clock_settime(clockid_t, const struct timespec *);
10211cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern int clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *);
10311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
10411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define CLOCK_REALTIME             0
10511cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define CLOCK_MONOTONIC            1
10611cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define CLOCK_PROCESS_CPUTIME_ID   2
10711cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define CLOCK_THREAD_CPUTIME_ID    3
10811cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define CLOCK_MONOTONIC_RAW        4
10911cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define CLOCK_REALTIME_COARSE      5
11011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define CLOCK_MONOTONIC_COARSE     6
11111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define CLOCK_BOOTTIME             7
11211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define CLOCK_REALTIME_ALARM       8
11311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#define CLOCK_BOOTTIME_ALARM       9
11411cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
11511cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern int  timer_create(int, struct sigevent*, timer_t*);
11611cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern int  timer_delete(timer_t);
11711cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern int  timer_settime(timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue);
11811cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern int  timer_gettime(timer_t timerid, struct itimerspec *value);
11911cd02dfb91661c65134cac258cf5924270e9d2Dan Albertextern int  timer_getoverrun(timer_t  timerid);
12011cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
12111cd02dfb91661c65134cac258cf5924270e9d2Dan Albert__END_DECLS
12211cd02dfb91661c65134cac258cf5924270e9d2Dan Albert
12311cd02dfb91661c65134cac258cf5924270e9d2Dan Albert#endif /* _TIME_H_ */
124