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

Last change on this file since b43f393 was 378d349, checked in by Jakub Jermar <jakub@…>, 7 years ago

Provide a dummy implementation of clock()

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