source: mainline/uspace/lib/posix/include/posix/time.h

Last change on this file was bc56f30, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 6 years ago

Make some libc and libposix headers usable in C++

These headers either get included from standard C++ headers,
or are standard themselves, which means any unnamespaced nonstandard
identifiers are a problem. This commit attempts to fix those
issues, and removes hacks previously used in libcpp to work around it.

  • Property mode set to 100644
File size: 3.2 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#include <stddef.h>
40#include <sys/types.h>
41#include <libc/time.h>
42
43#define CLOCK_REALTIME ((clockid_t) 0)
44
45#define ASCTIME_BUF_LEN 26
46
47__C_DECLS_BEGIN;
48
49#ifndef __locale_t_defined
50#define __locale_t_defined
51typedef struct __posix_locale *locale_t;
52#endif
53
54struct sigevent;
55
56struct itimerspec {
57 struct timespec it_interval; /* Timer period. */
58 struct timespec it_value; /* Timer expiration. */
59};
60
61typedef struct __posix_timer *timer_t;
62
63/* Timezones */
64extern int daylight;
65extern long timezone;
66extern char *tzname[2];
67extern void tzset(void);
68
69/* Time */
70extern time_t time(time_t *t);
71
72/* Broken-down Time */
73extern struct tm *gmtime_r(const time_t *__restrict__ timer,
74 struct tm *__restrict__ result);
75extern struct tm *gmtime(const time_t *__restrict__ timep);
76extern struct tm *localtime_r(const time_t *__restrict__ timer,
77 struct tm *__restrict__ result);
78extern struct tm *localtime(const time_t *__restrict__ timep);
79
80/* Formatting Calendar Time */
81extern char *asctime_r(const struct tm *__restrict__ timeptr,
82 char *__restrict__ buf);
83extern char *asctime(const struct tm *__restrict__ timeptr);
84extern char *ctime_r(const time_t *timer, char *buf);
85extern char *ctime(const time_t *timer);
86extern time_t time(time_t *t);
87
88/* Clocks */
89extern int clock_getres(clockid_t clock_id,
90 struct timespec *res);
91extern int clock_gettime(clockid_t clock_id,
92 struct timespec *tp);
93extern int clock_settime(clockid_t clock_id,
94 const struct timespec *tp);
95extern int clock_nanosleep(clockid_t clock_id, int flags,
96 const struct timespec *rqtp, struct timespec *rmtp);
97
98__C_DECLS_END;
99
100#endif // POSIX_TIME_H_
101
102/** @}
103 */
Note: See TracBrowser for help on using the repository browser.