source: mainline/uspace/lib/posix/include/posix/time.h@ 0dd4779

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 0dd4779 was 0dd4779, checked in by jzr <zarevucky.jiri@…>, 8 years ago

Use __restrict__ instead of restrict in header files.

  • Property mode set to 100644
File size: 4.1 KB
Line 
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 */
33/** @file Time measurement support.
34 */
35
36#ifndef POSIX_TIME_H_
37#define POSIX_TIME_H_
38
39#ifndef __POSIX_DEF__
40#define __POSIX_DEF__(x) x
41#endif
42
43#include "sys/types.h"
44
45#include <_bits/NULL.h>
46
47#ifndef CLOCKS_PER_SEC
48 #define CLOCKS_PER_SEC (1000000L)
49#endif
50
51#ifndef __locale_t_defined
52 #define __locale_t_defined
53 typedef struct __posix_locale *__POSIX_DEF__(locale_t);
54 #ifndef LIBPOSIX_INTERNAL
55 #define locale_t __POSIX_DEF__(locale_t)
56 #endif
57#endif
58
59#ifndef POSIX_SIGNAL_H_
60 struct __POSIX_DEF__(sigevent);
61 #ifndef LIBPOSIX_INTERNAL
62 #define sigevent __POSIX_DEF__(sigevent)
63 #endif
64#endif
65
66#undef CLOCK_REALTIME
67#define CLOCK_REALTIME ((__POSIX_DEF__(clockid_t)) 0)
68
69struct __POSIX_DEF__(timespec) {
70 time_t tv_sec; /* Seconds. */
71 long tv_nsec; /* Nanoseconds. */
72};
73
74struct __POSIX_DEF__(itimerspec) {
75 struct __POSIX_DEF__(timespec) it_interval; /* Timer period. */
76 struct __POSIX_DEF__(timespec) it_value; /* Timer expiration. */
77};
78
79typedef struct __posix_timer *__POSIX_DEF__(timer_t);
80
81/* Timezones */
82extern int __POSIX_DEF__(daylight);
83extern long __POSIX_DEF__(timezone);
84extern char *__POSIX_DEF__(tzname)[2];
85extern void __POSIX_DEF__(tzset)(void);
86
87/* Time */
88extern time_t __POSIX_DEF__(time)(time_t *t);
89
90/* Broken-down Time */
91extern struct tm *__POSIX_DEF__(gmtime_r)(const time_t *__restrict__ timer,
92 struct tm *__restrict__ result);
93extern struct tm *__POSIX_DEF__(gmtime)(const time_t *__restrict__ timep);
94extern struct tm *__POSIX_DEF__(localtime_r)(const time_t *__restrict__ timer,
95 struct tm *__restrict__ result);
96extern struct tm *__POSIX_DEF__(localtime)(const time_t *__restrict__ timep);
97
98/* Formatting Calendar Time */
99extern char *__POSIX_DEF__(asctime_r)(const struct tm *__restrict__ timeptr,
100 char *__restrict__ buf);
101extern char *__POSIX_DEF__(asctime)(const struct tm *__restrict__ timeptr);
102extern char *__POSIX_DEF__(ctime_r)(const time_t *timer, char *buf);
103extern char *__POSIX_DEF__(ctime)(const time_t *timer);
104extern time_t time(time_t *t);
105
106/* Clocks */
107extern int __POSIX_DEF__(clock_getres)(__POSIX_DEF__(clockid_t) clock_id,
108 struct __POSIX_DEF__(timespec) *res);
109extern int __POSIX_DEF__(clock_gettime)(__POSIX_DEF__(clockid_t) clock_id,
110 struct __POSIX_DEF__(timespec) *tp);
111extern int __POSIX_DEF__(clock_settime)(__POSIX_DEF__(clockid_t) clock_id,
112 const struct __POSIX_DEF__(timespec) *tp);
113extern int __POSIX_DEF__(clock_nanosleep)(__POSIX_DEF__(clockid_t) clock_id, int flags,
114 const struct __POSIX_DEF__(timespec) *rqtp, struct __POSIX_DEF__(timespec) *rmtp);
115
116/* CPU Time */
117extern __POSIX_DEF__(clock_t) __POSIX_DEF__(clock)(void);
118
119
120#endif // POSIX_TIME_H_
121
122/** @}
123 */
Note: See TracBrowser for help on using the repository browser.