RTEMS  5.0.0
timestampimpl.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_TIMESTAMPIMPL_H
19 #define _RTEMS_SCORE_TIMESTAMPIMPL_H
20 
27 #include <rtems/score/timestamp.h>
28 #include <rtems/score/basedefs.h>
29 
30 #include <sys/time.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
47  Timestamp_Control *_time,
48  time_t _seconds,
49  long _nanoseconds
50 )
51 {
52  struct timespec _ts;
53 
54  _ts.tv_sec = _seconds;
55  _ts.tv_nsec = _nanoseconds;
56 
57  *_time = tstosbt(_ts);
58 }
59 
70  Timestamp_Control *_time
71 )
72 {
73  *_time = 0;
74 }
75 
89  const Timestamp_Control *_lhs,
90  const Timestamp_Control *_rhs
91 )
92 {
93  return *_lhs < *_rhs;
94 }
95 
109  const Timestamp_Control *_lhs,
110  const Timestamp_Control *_rhs
111 )
112 {
113  return *_lhs > *_rhs;
114 }
115 
129  const Timestamp_Control *_lhs,
130  const Timestamp_Control *_rhs
131 )
132 {
133  return *_lhs == *_rhs;
134 }
135 
146  Timestamp_Control *_time,
147  const Timestamp_Control *_add
148 )
149 {
150  *_time += *_add;
151 }
152 
167  const Timestamp_Control *_start,
168  const Timestamp_Control *_end,
169  Timestamp_Control *_result
170 )
171 {
172  *_result = *_end - *_start;
173 }
174 
189  const Timestamp_Control *_lhs,
190  const Timestamp_Control *_rhs,
191  uint32_t *_ival_percentage,
192  uint32_t *_fval_percentage
193 )
194 {
195  struct timespec _ts_left;
196  struct timespec _ts_right;
197 
198  _ts_left = sbttots( *_lhs );
199  _ts_right = sbttots( *_rhs );
200 
202  &_ts_left,
203  &_ts_right,
204  _ival_percentage,
205  _fval_percentage
206  );
207 }
208 
219  const Timestamp_Control *_time
220 )
221 {
222  return (*_time >> 32);
223 }
224 
235  const Timestamp_Control *_time
236 )
237 {
238  struct timespec _ts;
239 
240  _ts = sbttots( *_time );
241 
242  return (uint32_t) _ts.tv_nsec;
243 }
244 
255  const Timestamp_Control *_time
256 )
257 {
258  struct timespec _ts;
259 
260  _ts = sbttots( *_time );
261 
262  return _Timespec_Get_as_nanoseconds( &_ts );
263 }
264 
274  const Timestamp_Control *_timestamp,
275  struct timespec *_timespec
276 )
277 {
278  *_timespec = sbttots( *_timestamp );
279 }
280 
288  const Timestamp_Control *_timestamp,
289  struct timeval *_timeval
290 )
291 {
292  *_timeval = sbttotv( *_timestamp );
293 }
294 
295 #ifdef __cplusplus
296 }
297 #endif
298 
301 #endif
302 /* end of include file */
int64_t Timestamp_Control
Definition: timestamp.h:52
void _start(void)
System start entry.
RTEMS_INLINE_ROUTINE void _Timestamp_To_timeval(const Timestamp_Control *_timestamp, struct timeval *_timeval)
Convert timestamp to struct timeval.
Definition: timestampimpl.h:287
#define RTEMS_INLINE_ROUTINE
Definition: basedefs.h:65
RTEMS_INLINE_ROUTINE bool _Timestamp_Equal_to(const Timestamp_Control *_lhs, const Timestamp_Control *_rhs)
Equal to than operator for timestamps.
Definition: timestampimpl.h:128
Helpers for Manipulating Timestamps.
RTEMS_INLINE_ROUTINE uint32_t _Timestamp_Get_nanoseconds(const Timestamp_Control *_time)
Get nanoseconds portion of timestamp.
Definition: timestampimpl.h:234
RTEMS_INLINE_ROUTINE void _Timestamp_Add_to(Timestamp_Control *_time, const Timestamp_Control *_add)
Adds two timestamps.
Definition: timestampimpl.h:145
RTEMS_INLINE_ROUTINE bool _Timestamp_Greater_than(const Timestamp_Control *_lhs, const Timestamp_Control *_rhs)
Greater than operator for timestamps.
Definition: timestampimpl.h:108
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 _Timestamp_Subtract(const Timestamp_Control *_start, const Timestamp_Control *_end, Timestamp_Control *_result)
Subtracts two timestamps.
Definition: timestampimpl.h:166
RTEMS_INLINE_ROUTINE time_t _Timestamp_Get_seconds(const Timestamp_Control *_time)
Get seconds portion of timestamp.
Definition: timestampimpl.h:218
RTEMS_INLINE_ROUTINE uint64_t _Timestamp_Get_as_nanoseconds(const Timestamp_Control *_time)
Get the timestamp as nanoseconds.
Definition: timestampimpl.h:254
RTEMS_INLINE_ROUTINE void _Timestamp_Set(Timestamp_Control *_time, time_t _seconds, long _nanoseconds)
Set timestamp to specified seconds and nanoseconds.
Definition: timestampimpl.h:46
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:188
Basic Definitions.
RTEMS_INLINE_ROUTINE void _Timestamp_Set_to_zero(Timestamp_Control *_time)
Sets the timestamp to zero.
Definition: timestampimpl.h:69
RTEMS_INLINE_ROUTINE bool _Timestamp_Less_than(const Timestamp_Control *_lhs, const Timestamp_Control *_rhs)
Less than operator for timestamps.
Definition: timestampimpl.h:88
uint64_t _Timespec_Get_as_nanoseconds(const struct timespec *time)
Get the timestamp as nanoseconds.
Definition: timespecgetasnanoseconds.c:23
RTEMS_INLINE_ROUTINE void _Timestamp_To_timespec(const Timestamp_Control *_timestamp, struct timespec *_timespec)
Convert timestamp to struct timespec.
Definition: timestampimpl.h:273