RTEMS: cpukit/include/rtems/score/timespec.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
timespec.h
Go to the documentation of this file.
1
9/*
10 * COPYRIGHT (c) 1989-2009.
11 * On-Line Applications Research Corporation (OAR).
12 *
13 * The license and distribution terms for this file may be
14 * found in the file LICENSE in this distribution or at
15 * http://www.rtems.org/license/LICENSE.
16 */
17
18#ifndef _RTEMS_SCORE_TIMESPEC_H
19#define _RTEMS_SCORE_TIMESPEC_H
20
34#include <stdbool.h> /* bool */
35#include <stdint.h> /* uint32_t */
36#include <time.h> /* struct timespec */
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
52#define _Timespec_Set( _time, _seconds, _nanoseconds ) \
53 do { \
54 (_time)->tv_sec = (_seconds); \
55 (_time)->tv_nsec = (_nanoseconds); \
56 } while (0)
57
66#define _Timespec_Set_to_zero( _time ) \
67 do { \
68 (_time)->tv_sec = 0; \
69 (_time)->tv_nsec = 0; \
70 } while (0)
71
81#define _Timespec_Get_seconds( _time ) \
82 ((_time)->tv_sec)
83
93#define _Timespec_Get_nanoseconds( _time ) \
94 ((_time)->tv_nsec)
95
105uint64_t _Timespec_Get_as_nanoseconds(
106 const struct timespec *time
107);
108
119bool _Timespec_Is_valid(
120 const struct timespec *time
121);
122
134bool _Timespec_Less_than(
135 const struct timespec *lhs,
136 const struct timespec *rhs
137);
138
150#define _Timespec_Greater_than( _lhs, _rhs ) \
151 _Timespec_Less_than( _rhs, _lhs )
152
164#define _Timespec_Equal_to( lhs, rhs ) \
165 ( ((lhs)->tv_sec == (rhs)->tv_sec) && \
166 ((lhs)->tv_nsec == (rhs)->tv_nsec) \
167 )
168
180uint32_t _Timespec_Add_to(
181 struct timespec *time,
182 const struct timespec *add
183);
184
195uint32_t _Timespec_To_ticks(
196 const struct timespec *time
197);
198
208void _Timespec_From_ticks(
209 uint32_t ticks,
210 struct timespec *time
211);
212
223void _Timespec_Subtract(
224 const struct timespec *start,
225 const struct timespec *end,
226 struct timespec *result
227);
228
240void _Timespec_Divide_by_integer(
241 const struct timespec *time,
242 uint32_t iterations,
243 struct timespec *result
244);
245
257void _Timespec_Divide(
258 const struct timespec *lhs,
259 const struct timespec *rhs,
260 uint32_t *ival_percentage,
261 uint32_t *fval_percentage
262);
263
264#ifdef __cplusplus
265}
266#endif
267
270#endif
271/* end of include file */
_Timespec_Divide
void _Timespec_Divide(const struct timespec *lhs, const struct timespec *rhs, uint32_t *ival_percentage, uint32_t *fval_percentage)
Divides a timespec by another timespec.
Definition: timespecdivide.c:25
_Timespec_Less_than
bool _Timespec_Less_than(const struct timespec *lhs, const struct timespec *rhs)
Checks if the left hand side timespec is less than the right one.
Definition: timespeclessthan.c:25
_Timespec_To_ticks
uint32_t _Timespec_To_ticks(const struct timespec *time)
Converts timespec to number of ticks.
Definition: timespectoticks.c:27
_Timespec_Get_as_nanoseconds
uint64_t _Timespec_Get_as_nanoseconds(const struct timespec *time)
Gets the timestamp as nanoseconds.
Definition: timespecgetasnanoseconds.c:23
_Timespec_From_ticks
void _Timespec_From_ticks(uint32_t ticks, struct timespec *time)
Converts ticks to timespec.
Definition: timespecfromticks.c:25
_Timespec_Add_to
uint32_t _Timespec_Add_to(struct timespec *time, const struct timespec *add)
Adds two timespecs.
Definition: timespecaddto.c:25
_Timespec_Is_valid
bool _Timespec_Is_valid(const struct timespec *time)
Checks if timespec is valid.
Definition: timespecisvalid.c:24
_Timespec_Subtract
void _Timespec_Subtract(const struct timespec *start, const struct timespec *end, struct timespec *result)
Subtracts two timespec.
Definition: timespecsubtract.c:24
_Timespec_Divide_by_integer
void _Timespec_Divide_by_integer(const struct timespec *time, uint32_t iterations, struct timespec *result)
Divides timespec by an integer.
Definition: timespecdividebyinteger.c:25