forked from phoenix-rtos/libphoenix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtime.h
115 lines (59 loc) · 1.79 KB
/
time.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
* Phoenix-RTOS
*
* libphoenix
*
* time.h
*
* Copyright 2017, 2018 Phoenix Systems
* Author: Pawel Pisarczyk, Aleksander Kaminski
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/
#ifndef _LIBPHOENIX_TIME_H_
#define _LIBPHOENIX_TIME_H_
#define SECS_TO_USECS_T(secs) (1000000ULL * (secs))
#define MSECS_TO_USECS_T(msecs) (1000ULL * (msecs))
#include <sys/types.h>
#define CLOCKS_PER_SEC 1000000
typedef enum { CLOCK_MONOTONIC = 0, CLOCK_REALTIME } clockid_t;
struct tm {
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
};
struct timespec {
time_t tv_sec;
long tv_nsec;
};
extern char *tzname[2];
extern long timezone;
extern int daylight;
extern void tzset(void);
extern char *asctime(const struct tm *tp);
extern char *asctime_r(const struct tm *tp, char *buf);
extern char *ctime(const time_t *timep);
extern char *ctime_r(const time_t *timep, char *buf);
extern double difftime(time_t t1, time_t t2);
extern struct tm *gmtime(const time_t *timep);
extern struct tm *gmtime_r(const time_t *timep, struct tm *res);
extern struct tm *localtime(const time_t *timep);
extern struct tm *localtime_r(const time_t *timep, struct tm *res);
extern time_t mktime(struct tm *tp);
extern time_t timelocal(struct tm *tm);
extern time_t timegm(struct tm *tm);
extern int clock_gettime(clockid_t clk_id, struct timespec *tp);
extern time_t time(time_t *tp);
extern size_t strftime(char *restrict s, size_t maxsize, const char *restrict format, const struct tm *restrict timeptr);
extern clock_t clock(void);
extern char *strptime(const char *restrict buf, const char *restrict format, struct tm *restrict tm);
extern int nanosleep(const struct timespec *req, struct timespec *rem);
#endif