RTEMS  5.0.0
timespec.h
Go to the documentation of this file.
1 
9 /*
10  * Copyright (c) 2012.
11  * Krzysztof Miesowicz <krzysztof.miesowicz@gmail.com>
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_TIMESPEC_H
19 #define _RTEMS_TIMESPEC_H
20 
21 #include <rtems/score/timespec.h>
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
49  const struct timespec *time
50 )
51 {
52  return _Timespec_Is_valid(time);
53 }
54 
68  const struct timespec *lhs,
69  const struct timespec *rhs
70 )
71 {
72  return _Timespec_Less_than(lhs,rhs);
73 }
74 
87  struct timespec *time,
88  const struct timespec *add
89 )
90 {
91  return _Timespec_Add_to(time,add);
92 }
93 
105  const struct timespec *time
106 )
107 {
108  return _Timespec_To_ticks(time);
109 }
110 
122  uint32_t ticks,
123  struct timespec *time
124 )
125 {
126  _Timespec_From_ticks(ticks,time);
127 }
128 
142  const struct timespec *start,
143  const struct timespec *end,
144  struct timespec *result
145 )
146 {
147  _Timespec_Subtract(start,end,result);
148 }
149 
164  const struct timespec *time,
165  uint32_t iterations,
166  struct timespec *result
167 )
168 {
169  _Timespec_Divide_by_integer(time,iterations,result);
170 }
171 
186  const struct timespec *lhs,
187  const struct timespec *rhs,
188  uint32_t *ival_percentage,
189  uint32_t *fval_percentage
190 )
191 {
192  _Timespec_Divide(lhs,rhs,ival_percentage,fval_percentage);
193 }
194 
206  struct timespec *_time,
207  time_t _seconds,
208  uint32_t _nanoseconds
209 )
210 {
211  _Timespec_Set( _time, _seconds, _nanoseconds );
212 }
213 
223  struct timespec *_time
224 )
225 {
226  _Timespec_Set_to_zero( _time );
227 }
228 
239  struct timespec *_time
240 )
241 {
242  return _Timespec_Get_seconds( _time );
243 }
244 
255  struct timespec *_time
256 )
257 {
258  return _Timespec_Get_nanoseconds( _time );
259 }
260 
273  const struct timespec *_lhs,
274  const struct timespec *_rhs
275 )
276 {
277  return _Timespec_Greater_than( _lhs, _rhs );
278 }
291  const struct timespec *lhs,
292  const struct timespec *rhs
293 )
294 {
295  return _Timespec_Equal_to( lhs, rhs);
296 }
297 
300 #ifdef __cplusplus
301 }
302 #endif
303 
304 #endif
305 /* end of include file */
#define _Timespec_Equal_to(lhs, rhs)
The Timespec "equal to" operator.
Definition: timespec.h:159
uint32_t _Timespec_To_ticks(const struct timespec *time)
Convert timespec to number of ticks.
Definition: timespectoticks.c:27
RTEMS_INLINE_ROUTINE time_t rtems_timespec_get_seconds(struct timespec *_time)
Get seconds portion of timespec.
Definition: timespec.h:238
RTEMS_INLINE_ROUTINE void rtems_timespec_divide(const struct timespec *lhs, const struct timespec *rhs, uint32_t *ival_percentage, uint32_t *fval_percentage)
Divide timespec.
Definition: timespec.h:185
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:65
RTEMS_INLINE_ROUTINE bool rtems_timespec_greater_than(const struct timespec *_lhs, const struct timespec *_rhs)
Timespec greater than operator.
Definition: timespec.h:272
#define _Timespec_Set(_time, _seconds, _nanoseconds)
Set timespec to seconds nanosecond.
Definition: timespec.h:47
bool _Timespec_Is_valid(const struct timespec *time)
Check if timespec is valid.
Definition: timespecisvalid.c:24
void _Timespec_Divide_by_integer(const struct timespec *time, uint32_t iterations, struct timespec *result)
Divide timespec by an integer.
Definition: timespecdividebyinteger.c:25
#define _Timespec_Greater_than(_lhs, _rhs)
The Timespec "greater than" operator.
Definition: timespec.h:145
void _Timespec_Subtract(const struct timespec *start, const struct timespec *end, struct timespec *result)
Subtract two timespec.
Definition: timespecsubtract.c:24
RTEMS_INLINE_ROUTINE uint32_t rtems_timespec_to_ticks(const struct timespec *time)
Convert timespec to number of ticks.
Definition: timespec.h:104
#define _Timespec_Set_to_zero(_time)
Sets the Timespec to Zero.
Definition: timespec.h:61
void _Timespec_Divide(const struct timespec *lhs, const struct timespec *rhs, uint32_t *ival_percentage, uint32_t *fval_percentage)
Divide a timespec by anonther timespec.
Definition: timespecdivide.c:24
RTEMS_INLINE_ROUTINE void rtems_timespec_divide_by_integer(const struct timespec *time, uint32_t iterations, struct timespec *result)
Divide timespec by integer.
Definition: timespec.h:163
RTEMS_INLINE_ROUTINE bool rtems_timespec_is_valid(const struct timespec *time)
Is timespec valid.
Definition: timespec.h:48
RTEMS_INLINE_ROUTINE void rtems_timespec_subtract(const struct timespec *start, const struct timespec *end, struct timespec *result)
Subtract two timespec.
Definition: timespec.h:141
#define _Timespec_Get_seconds(_time)
Get seconds portion of timespec.
Definition: timespec.h:76
bool _Timespec_Less_than(const struct timespec *lhs, const struct timespec *rhs)
The Timespec "less than" operator.
Definition: timespeclessthan.c:25
RTEMS_INLINE_ROUTINE uint32_t rtems_timespec_get_nanoseconds(struct timespec *_time)
Get nanoseconds portion of timespec.
Definition: timespec.h:254
void _Timespec_From_ticks(uint32_t ticks, struct timespec *time)
Convert ticks to timespec.
Definition: timespecfromticks.c:25
RTEMS_INLINE_ROUTINE void rtems_timespec_zero(struct timespec *_time)
Zero timespec.
Definition: timespec.h:222
RTEMS_INLINE_ROUTINE void rtems_timespec_set(struct timespec *_time, time_t _seconds, uint32_t _nanoseconds)
Set timespec to seconds nanosecond.
Definition: timespec.h:205
#define _Timespec_Get_nanoseconds(_time)
Get nanoseconds portion of timespec.
Definition: timespec.h:88
RTEMS_INLINE_ROUTINE bool rtems_timespec_equal_to(const struct timespec *lhs, const struct timespec *rhs)
Timespec equal to Operator.
Definition: timespec.h:290
uint32_t _Timespec_Add_to(struct timespec *time, const struct timespec *add)
Add two timespecs.
Definition: timespecaddto.c:25
RTEMS_INLINE_ROUTINE uint32_t rtems_timespec_add_to(struct timespec *time, const struct timespec *add)
Add to a timespec.
Definition: timespec.h:86
RTEMS_INLINE_ROUTINE bool rtems_timespec_less_than(const struct timespec *lhs, const struct timespec *rhs)
Timespec less than operator.
Definition: timespec.h:67
RTEMS_INLINE_ROUTINE void rtems_timespec_from_ticks(uint32_t ticks, struct timespec *time)
Convert ticks to timespec.
Definition: timespec.h:121