RTEMS 5.2
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
timestampimpl.h
Go to the documentation of this file.
1
11/*
12 * COPYRIGHT (c) 1989-2009.
13 * On-Line Applications Research Corporation (OAR).
14 *
15 * The license and distribution terms for this file may be
16 * found in the file LICENSE in this distribution or at
17 * http://www.rtems.org/license/LICENSE.
18 */
19
20#ifndef _RTEMS_SCORE_TIMESTAMPIMPL_H
21#define _RTEMS_SCORE_TIMESTAMPIMPL_H
22
31
32#include <sys/time.h>
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
49 Timestamp_Control *_time,
50 time_t _seconds,
51 long _nanoseconds
52)
53{
54 struct timespec _ts;
55
56 _ts.tv_sec = _seconds;
57 _ts.tv_nsec = _nanoseconds;
58
59 *_time = tstosbt(_ts);
60}
61
73)
74{
75 *_time = 0;
76}
77
91 const Timestamp_Control *_lhs,
92 const Timestamp_Control *_rhs
93)
94{
95 return *_lhs < *_rhs;
96}
97
111 const Timestamp_Control *_lhs,
112 const Timestamp_Control *_rhs
113)
114{
115 return *_lhs > *_rhs;
116}
117
131 const Timestamp_Control *_lhs,
132 const Timestamp_Control *_rhs
133)
134{
135 return *_lhs == *_rhs;
136}
137
148 Timestamp_Control *_time,
149 const Timestamp_Control *_add
150)
151{
152 *_time += *_add;
153}
154
168 const Timestamp_Control *_end,
169 Timestamp_Control *_result
170)
171{
172 *_result = *_end - *_start;
173}
174
187 const Timestamp_Control *_lhs,
188 const Timestamp_Control *_rhs,
189 uint32_t *_ival_percentage,
190 uint32_t *_fval_percentage
191)
192{
193 struct timespec _ts_left;
194 struct timespec _ts_right;
195
196 _ts_left = sbttots( *_lhs );
197 _ts_right = sbttots( *_rhs );
198
200 &_ts_left,
201 &_ts_right,
202 _ival_percentage,
203 _fval_percentage
204 );
205}
206
217 const Timestamp_Control *_time
218)
219{
220 return (*_time >> 32);
221}
222
233 const Timestamp_Control *_time
234)
235{
236 struct timespec _ts;
237
238 _ts = sbttots( *_time );
239
240 return (uint32_t) _ts.tv_nsec;
241}
242
253 const Timestamp_Control *_time
254)
255{
256 struct timespec _ts;
257
258 _ts = sbttots( *_time );
259
260 return _Timespec_Get_as_nanoseconds( &_ts );
261}
262
270 const Timestamp_Control *_timestamp,
271 struct timespec *_timespec
272)
273{
274 *_timespec = sbttots( *_timestamp );
275}
276
284 const Timestamp_Control *_timestamp,
285 struct timeval *_timeval
286)
287{
288 *_timeval = sbttotv( *_timestamp );
289}
290
291#ifdef __cplusplus
292}
293#endif
294
297#endif
298/* end of include file */
Basic Definitions.
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:66
RTEMS_INLINE_ROUTINE void _Timestamp_Divide(const Timestamp_Control *_lhs, const Timestamp_Control *_rhs, uint32_t *_ival_percentage, uint32_t *_fval_percentage)
Divides a timestamp by another timestamp.
Definition: timestampimpl.h:186
RTEMS_INLINE_ROUTINE uint32_t _Timestamp_Get_nanoseconds(const Timestamp_Control *_time)
Gets nanoseconds portion of timestamp.
Definition: timestampimpl.h:232
RTEMS_INLINE_ROUTINE bool _Timestamp_Equal_to(const Timestamp_Control *_lhs, const Timestamp_Control *_rhs)
Checks if the timestamps are equal.
Definition: timestampimpl.h:130
RTEMS_INLINE_ROUTINE void _Timestamp_Set(Timestamp_Control *_time, time_t _seconds, long _nanoseconds)
Sets timestamp to specified seconds and nanoseconds.
Definition: timestampimpl.h:48
RTEMS_INLINE_ROUTINE uint64_t _Timestamp_Get_as_nanoseconds(const Timestamp_Control *_time)
Gets the timestamp as nanoseconds.
Definition: timestampimpl.h:252
RTEMS_INLINE_ROUTINE bool _Timestamp_Greater_than(const Timestamp_Control *_lhs, const Timestamp_Control *_rhs)
Checks if the left hand side timestamp is greater than the right one.
Definition: timestampimpl.h:110
RTEMS_INLINE_ROUTINE void _Timestamp_Set_to_zero(Timestamp_Control *_time)
Sets the timestamp to zero.
Definition: timestampimpl.h:71
RTEMS_INLINE_ROUTINE void _Timestamp_To_timespec(const Timestamp_Control *_timestamp, struct timespec *_timespec)
Converts timestamp to struct timespec.
Definition: timestampimpl.h:269
int64_t Timestamp_Control
Definition: timestamp.h:57
RTEMS_INLINE_ROUTINE void _Timestamp_Add_to(Timestamp_Control *_time, const Timestamp_Control *_add)
Adds two timestamps.
Definition: timestampimpl.h:147
RTEMS_INLINE_ROUTINE bool _Timestamp_Less_than(const Timestamp_Control *_lhs, const Timestamp_Control *_rhs)
Checks if the left hand side timestamp is less than the right one.
Definition: timestampimpl.h:90
RTEMS_INLINE_ROUTINE time_t _Timestamp_Get_seconds(const Timestamp_Control *_time)
Gets seconds portion of timestamp.
Definition: timestampimpl.h:216
RTEMS_INLINE_ROUTINE void _Timestamp_To_timeval(const Timestamp_Control *_timestamp, struct timeval *_timeval)
Converts timestamp to struct timeval.
Definition: timestampimpl.h:283
RTEMS_INLINE_ROUTINE void _Timestamp_Subtract(const Timestamp_Control *_start, const Timestamp_Control *_end, Timestamp_Control *_result)
Subtracts two timestamps.
Definition: timestampimpl.h:166
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
uint64_t _Timespec_Get_as_nanoseconds(const struct timespec *time)
Gets the timestamp as nanoseconds.
Definition: timespecgetasnanoseconds.c:23
void _start(void)
System start entry.
Helpers for Manipulating Timestamps.