[2fc5072] | 1 | /*
|
---|
| 2 | * Copyright (c) 2011 Petr Koupy
|
---|
| 3 | * Copyright (c) 2011 Jiri Zarevucky
|
---|
| 4 | * All rights reserved.
|
---|
| 5 | *
|
---|
| 6 | * Redistribution and use in source and binary forms, with or without
|
---|
| 7 | * modification, are permitted provided that the following conditions
|
---|
| 8 | * are met:
|
---|
| 9 | *
|
---|
| 10 | * - Redistributions of source code must retain the above copyright
|
---|
| 11 | * notice, this list of conditions and the following disclaimer.
|
---|
| 12 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 13 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 14 | * documentation and/or other materials provided with the distribution.
|
---|
| 15 | * - The name of the author may not be used to endorse or promote products
|
---|
| 16 | * derived from this software without specific prior written permission.
|
---|
| 17 | *
|
---|
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 28 | */
|
---|
| 29 |
|
---|
| 30 | /** @addtogroup libposix
|
---|
| 31 | * @{
|
---|
| 32 | */
|
---|
[4cf8ca6] | 33 | /** @file Time measurement support.
|
---|
[2fc5072] | 34 | */
|
---|
| 35 |
|
---|
| 36 | #ifndef POSIX_TIME_H_
|
---|
| 37 | #define POSIX_TIME_H_
|
---|
| 38 |
|
---|
[324d46b] | 39 | #include "sys/types.h"
|
---|
[2fc5072] | 40 |
|
---|
[c9f3e7e9] | 41 | #include <_bits/NULL.h>
|
---|
[2fc5072] | 42 |
|
---|
[bd41ac52] | 43 | #include "libc/time.h"
|
---|
[324d46b] | 44 |
|
---|
| 45 | #ifndef __locale_t_defined
|
---|
[1433ecda] | 46 | #define __locale_t_defined
|
---|
| 47 | typedef struct __posix_locale *locale_t;
|
---|
[324d46b] | 48 | #endif
|
---|
| 49 |
|
---|
[3f466c33] | 50 | #ifndef POSIX_SIGNAL_H_
|
---|
[1433ecda] | 51 | struct sigevent;
|
---|
[3f466c33] | 52 | #endif
|
---|
| 53 |
|
---|
[324d46b] | 54 | #undef CLOCK_REALTIME
|
---|
[7f9df7b9] | 55 | #define CLOCK_REALTIME ((clockid_t) 0)
|
---|
[06cb827] | 56 |
|
---|
[bd41ac52] | 57 | #define ASCTIME_BUF_LEN 26
|
---|
[324d46b] | 58 |
|
---|
[7f9df7b9] | 59 | struct itimerspec {
|
---|
| 60 | struct timespec it_interval; /* Timer period. */
|
---|
| 61 | struct timespec it_value; /* Timer expiration. */
|
---|
[324d46b] | 62 | };
|
---|
| 63 |
|
---|
[7f9df7b9] | 64 | typedef struct __posix_timer *timer_t;
|
---|
[3f466c33] | 65 |
|
---|
[324d46b] | 66 | /* Timezones */
|
---|
[7f9df7b9] | 67 | extern int daylight;
|
---|
| 68 | extern long timezone;
|
---|
| 69 | extern char *tzname[2];
|
---|
| 70 | extern void tzset(void);
|
---|
[324d46b] | 71 |
|
---|
[ed29fe4] | 72 | /* Time */
|
---|
[7f9df7b9] | 73 | extern time_t time(time_t *t);
|
---|
[ed29fe4] | 74 |
|
---|
[2fc5072] | 75 | /* Broken-down Time */
|
---|
[7f9df7b9] | 76 | extern struct tm *gmtime_r(const time_t *__restrict__ timer,
|
---|
[0dd4779] | 77 | struct tm *__restrict__ result);
|
---|
[7f9df7b9] | 78 | extern struct tm *gmtime(const time_t *__restrict__ timep);
|
---|
| 79 | extern struct tm *localtime_r(const time_t *__restrict__ timer,
|
---|
[0dd4779] | 80 | struct tm *__restrict__ result);
|
---|
[7f9df7b9] | 81 | extern struct tm *localtime(const time_t *__restrict__ timep);
|
---|
[3f466c33] | 82 |
|
---|
[2fc5072] | 83 | /* Formatting Calendar Time */
|
---|
[7f9df7b9] | 84 | extern char *asctime_r(const struct tm *__restrict__ timeptr,
|
---|
[0dd4779] | 85 | char *__restrict__ buf);
|
---|
[7f9df7b9] | 86 | extern char *asctime(const struct tm *__restrict__ timeptr);
|
---|
| 87 | extern char *ctime_r(const time_t *timer, char *buf);
|
---|
| 88 | extern char *ctime(const time_t *timer);
|
---|
[b08879c2] | 89 | extern time_t time(time_t *t);
|
---|
[3f466c33] | 90 |
|
---|
[4cf8ca6] | 91 | /* Clocks */
|
---|
[7f9df7b9] | 92 | extern int clock_getres(clockid_t clock_id,
|
---|
| 93 | struct timespec *res);
|
---|
| 94 | extern int clock_gettime(clockid_t clock_id,
|
---|
| 95 | struct timespec *tp);
|
---|
| 96 | extern int clock_settime(clockid_t clock_id,
|
---|
| 97 | const struct timespec *tp);
|
---|
| 98 | extern int clock_nanosleep(clockid_t clock_id, int flags,
|
---|
| 99 | const struct timespec *rqtp, struct timespec *rmtp);
|
---|
[3f466c33] | 100 |
|
---|
[2fc5072] | 101 | #endif // POSIX_TIME_H_
|
---|
| 102 |
|
---|
| 103 | /** @}
|
---|
| 104 | */
|
---|