RTEMS 6.1-rc4
Loading...
Searching...
No Matches
timespec.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
11/*
12 * Copyright (c) 2012.
13 * Krzysztof Miesowicz <krzysztof.miesowicz@gmail.com>
14 *
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
17 * are met:
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#ifndef _RTEMS_TIMESPEC_H
38#define _RTEMS_TIMESPEC_H
39
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
67static inline bool rtems_timespec_is_valid(
68 const struct timespec *time
69)
70{
71 return _Timespec_Is_valid(time);
72}
73
86static inline bool rtems_timespec_less_than(
87 const struct timespec *lhs,
88 const struct timespec *rhs
89)
90{
91 return _Timespec_Less_than(lhs,rhs);
92}
93
105static inline time_t rtems_timespec_add_to(
106 struct timespec *time,
107 const struct timespec *add
108)
109{
110 return _Timespec_Add_to(time,add);
111}
112
123static inline uint32_t rtems_timespec_to_ticks(
124 const struct timespec *time
125)
126{
127 return _Timespec_To_ticks(time);
128}
129
140static inline void rtems_timespec_from_ticks(
141 uint32_t ticks,
142 struct timespec *time
143)
144{
145 _Timespec_From_ticks(ticks,time);
146}
147
160static inline void rtems_timespec_subtract(
161 const struct timespec *start,
162 const struct timespec *end,
163 struct timespec *result
164)
165{
166 _Timespec_Subtract(start,end,result);
167}
168
182static inline void rtems_timespec_divide_by_integer(
183 const struct timespec *time,
184 uint32_t iterations,
185 struct timespec *result
186)
187{
188 _Timespec_Divide_by_integer(time,iterations,result);
189}
190
204static inline void rtems_timespec_divide(
205 const struct timespec *lhs,
206 const struct timespec *rhs,
207 uint32_t *ival_percentage,
208 uint32_t *fval_percentage
209)
210{
211 _Timespec_Divide(lhs,rhs,ival_percentage,fval_percentage);
212}
213
224static inline void rtems_timespec_set(
225 struct timespec *_time,
226 time_t _seconds,
227 uint32_t _nanoseconds
228)
229{
230 _Timespec_Set( _time, _seconds, _nanoseconds );
231}
232
241static inline void rtems_timespec_zero(
242 struct timespec *_time
243)
244{
245 _Timespec_Set_to_zero( _time );
246}
247
257static inline time_t rtems_timespec_get_seconds(
258 struct timespec *_time
259)
260{
261 return _Timespec_Get_seconds( _time );
262}
263
273static inline uint32_t rtems_timespec_get_nanoseconds(
274 struct timespec *_time
275)
276{
277 return _Timespec_Get_nanoseconds( _time );
278}
279
291static inline bool rtems_timespec_greater_than(
292 const struct timespec *_lhs,
293 const struct timespec *_rhs
294)
295{
296 return _Timespec_Greater_than( _lhs, _rhs );
297}
309static inline bool rtems_timespec_equal_to(
310 const struct timespec *lhs,
311 const struct timespec *rhs
312)
313{
314 return _Timespec_Equal_to( lhs, rhs);
315}
316
319#ifdef __cplusplus
320}
321#endif
322
323#endif
324/* end of include file */
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:45
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:46
uint32_t _Timespec_To_ticks(const struct timespec *time)
Converts timespec to number of ticks.
Definition: timespectoticks.c:51
void _Timespec_From_ticks(uint32_t ticks, struct timespec *time)
Converts ticks to timespec.
Definition: timespecfromticks.c:46
#define _Timespec_Get_nanoseconds(_time)
Get nanoseconds portion of timespec.
Definition: timespec.h:110
#define _Timespec_Greater_than(_lhs, _rhs)
The Timespec "greater than" operator.
Definition: timespec.h:179
#define _Timespec_Set(_time, _seconds, _nanoseconds)
Set timespec to seconds nanosecond.
Definition: timespec.h:69
bool _Timespec_Is_valid(const struct timespec *time)
Checks if timespec is valid.
Definition: timespecisvalid.c:45
void _Timespec_Subtract(const struct timespec *start, const struct timespec *end, struct timespec *result)
Subtracts two timespec.
Definition: timespecsubtract.c:45
time_t _Timespec_Add_to(struct timespec *time, const struct timespec *add)
Adds two timespecs.
Definition: timespecaddto.c:46
#define _Timespec_Equal_to(lhs, rhs)
The Timespec "equal to" operator.
Definition: timespec.h:193
#define _Timespec_Get_seconds(_time)
Get seconds portion of timespec.
Definition: timespec.h:98
#define _Timespec_Set_to_zero(_time)
Sets the Timespec to Zero.
Definition: timespec.h:83
void _Timespec_Divide_by_integer(const struct timespec *time, uint32_t iterations, struct timespec *result)
Divides timespec by an integer.
Definition: timespecdividebyinteger.c:45
This header file provides the interfaces of the Timespec Helpers.