time.h revision 1dc9e472e19acfe6dc7f41e429236e7eef7ceda1
11dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/*
21dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Copyright (C) 2008 The Android Open Source Project
31dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * All rights reserved.
41dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *
51dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * Redistribution and use in source and binary forms, with or without
61dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * modification, are permitted provided that the following conditions
71dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * are met:
81dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *  * Redistributions of source code must retain the above copyright
91dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *    notice, this list of conditions and the following disclaimer.
101dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *  * Redistributions in binary form must reproduce the above copyright
111dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *    notice, this list of conditions and the following disclaimer in
121dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *    the documentation and/or other materials provided with the
131dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *    distribution.
141dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project *
151dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
161dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
171dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
181dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
191dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
201dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
211dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
221dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
231dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
241dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
251dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
261dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * SUCH DAMAGE.
271dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project */
281dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#ifndef _TIME_H_
291dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define _TIME_H_
301dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
311dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#include <sys/cdefs.h>
321dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#include <sys/time.h>
331dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
341dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define __ARCH_SI_UID_T __kernel_uid32_t
351dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#include <asm/siginfo.h>
361dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#undef __ARCH_SI_UID_T
371dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
381dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project__BEGIN_DECLS
391dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
401dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern time_t   time(time_t *);
411dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int      nanosleep(const struct timespec *, struct timespec *);
421dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
431dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern char *strtotimeval(const char *str, struct timeval *tv);
441dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
451dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectstruct tm {
461dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project   int     tm_sec;         /* seconds */
471dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project   int     tm_min;         /* minutes */
481dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project   int     tm_hour;        /* hours */
491dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project   int     tm_mday;        /* day of the month */
501dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project   int     tm_mon;         /* month */
511dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project   int     tm_year;        /* year */
521dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project   int     tm_wday;        /* day of the week */
531dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project   int     tm_yday;        /* day in the year */
541dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project   int     tm_isdst;       /* daylight saving time */
551dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
561dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project   long int tm_gmtoff;     /* Seconds east of UTC.  */
571dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project   const char *tm_zone;    /* Timezone abbreviation.  */
581dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
591dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project};
601dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
611dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* defining TM_ZONE indicates that we have a "timezone abbreviation" field in
621dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project * struct tm, the value should be the field name
631dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project */
641dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define   TM_ZONE   tm_zone
651dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
661dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern char* asctime(const struct tm* a);
671dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern char* asctime_r(const struct tm* a, char* buf);
681dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
691dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* Return the difference between TIME1 and TIME0.  */
701dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern double difftime (time_t __time1, time_t __time0);
711dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern time_t mktime (struct tm *a);
721dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
731dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern struct tm*  localtime(const time_t *t);
741dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern struct tm*  localtime_r(const time_t *timep, struct tm *result);
751dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
761dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern struct tm*  gmtime(const time_t *timep);
771dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern struct tm*  gmtime_r(const time_t *timep, struct tm *result);
781dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
791dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern char*       strptime(const char *buf, const char *fmt, struct tm *tm);
801dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern size_t      strftime(char *s, size_t max, const char *format, const struct tm *tm);
811dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
821dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern char *ctime(const time_t *timep);
831dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern char *ctime_r(const time_t *timep, char *buf);
841dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
851dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* global includes */
861dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern char*     tzname[];
871dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int       daylight;
881dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern long int  timezone;
891dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
901dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define CLOCKS_PER_SEC     1000000
911dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
921dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern clock_t   clock();
931dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
941dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project/* BIONIC: extra linux clock goodies */
951dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int clock_getres(int, struct timespec *);
961dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int clock_gettime(int, struct timespec *);
971dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
981dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define CLOCK_REALTIME             0
991dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define CLOCK_MONOTONIC            1
1001dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define CLOCK_PROCESS_CPUTIME_ID   2
1011dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define CLOCK_THREAD_CPUTIME_ID    3
1021dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define CLOCK_REALTIME_HR          4
1031dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#define CLOCK_MONOTONIC_HR         5
1041dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
1051dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int  timer_create(int, struct sigevent*, timer_t*);
1061dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int  timer_delete(timer_t);
1071dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int  timer_settime(timer_t timerid, int flags, const struct itimerspec *value, struct itimerspec *ovalue);
1081dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int  timer_gettime(timer_t timerid, struct itimerspec *value);
1091dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Projectextern int  timer_getoverrun(timer_t  timerid);
1101dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
1111dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project__END_DECLS
1121dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project
1131dc9e472e19acfe6dc7f41e429236e7eef7ceda1The Android Open Source Project#endif /* _TIME_H_ */
114