[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 |
|
---|
[fdf97f6] | 39 | #ifndef __POSIX_DEF__
|
---|
| 40 | #define __POSIX_DEF__(x) x
|
---|
| 41 | #endif
|
---|
| 42 |
|
---|
[324d46b] | 43 | #include "sys/types.h"
|
---|
[2fc5072] | 44 |
|
---|
| 45 | #ifndef NULL
|
---|
| 46 | #define NULL ((void *) 0)
|
---|
| 47 | #endif
|
---|
| 48 |
|
---|
[324d46b] | 49 | #ifndef CLOCKS_PER_SEC
|
---|
| 50 | #define CLOCKS_PER_SEC (1000000L)
|
---|
| 51 | #endif
|
---|
| 52 |
|
---|
| 53 | #ifndef __locale_t_defined
|
---|
| 54 | #define __locale_t_defined
|
---|
[fdf97f6] | 55 | typedef struct __posix_locale *__POSIX_DEF__(locale_t);
|
---|
[324d46b] | 56 | #ifndef LIBPOSIX_INTERNAL
|
---|
[fdf97f6] | 57 | #define locale_t __POSIX_DEF__(locale_t)
|
---|
[324d46b] | 58 | #endif
|
---|
| 59 | #endif
|
---|
| 60 |
|
---|
[3f466c33] | 61 | #ifndef POSIX_SIGNAL_H_
|
---|
[fdf97f6] | 62 | struct __POSIX_DEF__(sigevent);
|
---|
[3f466c33] | 63 | #ifndef LIBPOSIX_INTERNAL
|
---|
[fdf97f6] | 64 | #define sigevent __POSIX_DEF__(sigevent)
|
---|
[3f466c33] | 65 | #endif
|
---|
| 66 | #endif
|
---|
| 67 |
|
---|
[324d46b] | 68 | #undef CLOCK_REALTIME
|
---|
[fdf97f6] | 69 | #define CLOCK_REALTIME ((__POSIX_DEF__(clockid_t)) 0)
|
---|
[06cb827] | 70 |
|
---|
[fdf97f6] | 71 | struct __POSIX_DEF__(timespec) {
|
---|
[324d46b] | 72 | time_t tv_sec; /* Seconds. */
|
---|
| 73 | long tv_nsec; /* Nanoseconds. */
|
---|
| 74 | };
|
---|
| 75 |
|
---|
[fdf97f6] | 76 | struct __POSIX_DEF__(itimerspec) {
|
---|
| 77 | struct __POSIX_DEF__(timespec) it_interval; /* Timer period. */
|
---|
| 78 | struct __POSIX_DEF__(timespec) it_value; /* Timer expiration. */
|
---|
[324d46b] | 79 | };
|
---|
| 80 |
|
---|
[fdf97f6] | 81 | typedef struct __posix_timer *__POSIX_DEF__(timer_t);
|
---|
[3f466c33] | 82 |
|
---|
[324d46b] | 83 | /* Timezones */
|
---|
[fdf97f6] | 84 | extern int __POSIX_DEF__(daylight);
|
---|
| 85 | extern long __POSIX_DEF__(timezone);
|
---|
| 86 | extern char *__POSIX_DEF__(tzname)[2];
|
---|
| 87 | extern void __POSIX_DEF__(tzset)(void);
|
---|
[324d46b] | 88 |
|
---|
[ed29fe4] | 89 | /* Time */
|
---|
| 90 | extern time_t __POSIX_DEF__(time)(time_t *t);
|
---|
| 91 |
|
---|
[2fc5072] | 92 | /* Broken-down Time */
|
---|
[fdf97f6] | 93 | extern struct tm *__POSIX_DEF__(gmtime_r)(const time_t *restrict timer,
|
---|
[f8b6d34c] | 94 | struct tm *restrict result);
|
---|
[fdf97f6] | 95 | extern struct tm *__POSIX_DEF__(gmtime)(const time_t *restrict timep);
|
---|
| 96 | extern struct tm *__POSIX_DEF__(localtime_r)(const time_t *restrict timer,
|
---|
[f8b6d34c] | 97 | struct tm *restrict result);
|
---|
[fdf97f6] | 98 | extern struct tm *__POSIX_DEF__(localtime)(const time_t *restrict timep);
|
---|
[3f466c33] | 99 |
|
---|
[2fc5072] | 100 | /* Formatting Calendar Time */
|
---|
[fdf97f6] | 101 | extern char *__POSIX_DEF__(asctime_r)(const struct tm *restrict timeptr,
|
---|
[324d46b] | 102 | char *restrict buf);
|
---|
[fdf97f6] | 103 | extern char *__POSIX_DEF__(asctime)(const struct tm *restrict timeptr);
|
---|
| 104 | extern char *__POSIX_DEF__(ctime_r)(const time_t *timer, char *buf);
|
---|
| 105 | extern char *__POSIX_DEF__(ctime)(const time_t *timer);
|
---|
[b08879c2] | 106 | extern time_t time(time_t *t);
|
---|
[3f466c33] | 107 |
|
---|
[4cf8ca6] | 108 | /* Clocks */
|
---|
[fdf97f6] | 109 | extern int __POSIX_DEF__(clock_getres)(__POSIX_DEF__(clockid_t) clock_id,
|
---|
| 110 | struct __POSIX_DEF__(timespec) *res);
|
---|
| 111 | extern int __POSIX_DEF__(clock_gettime)(__POSIX_DEF__(clockid_t) clock_id,
|
---|
| 112 | struct __POSIX_DEF__(timespec) *tp);
|
---|
| 113 | extern int __POSIX_DEF__(clock_settime)(__POSIX_DEF__(clockid_t) clock_id,
|
---|
| 114 | const struct __POSIX_DEF__(timespec) *tp);
|
---|
| 115 | extern int __POSIX_DEF__(clock_nanosleep)(__POSIX_DEF__(clockid_t) clock_id, int flags,
|
---|
| 116 | const struct __POSIX_DEF__(timespec) *rqtp, struct __POSIX_DEF__(timespec) *rmtp);
|
---|
[3f466c33] | 117 |
|
---|
[823a929] | 118 | /* CPU Time */
|
---|
[fdf97f6] | 119 | extern __POSIX_DEF__(clock_t) __POSIX_DEF__(clock)(void);
|
---|
| 120 |
|
---|
[2fc5072] | 121 |
|
---|
| 122 | #endif // POSIX_TIME_H_
|
---|
| 123 |
|
---|
| 124 | /** @}
|
---|
| 125 | */
|
---|