source: rtems/cpukit/include/rtems/score/timestamp.h @ 2afb22b

5
Last change on this file since 2afb22b was 2afb22b, checked in by Chris Johns <chrisj@…>, on 12/23/17 at 07:18:56

Remove make preinstall

A speciality of the RTEMS build system was the make preinstall step. It
copied header files from arbitrary locations into the build tree. The
header files were included via the -Bsome/build/tree/path GCC command
line option.

This has at least seven problems:

  • The make preinstall step itself needs time and disk space.
  • Errors in header files show up in the build tree copy. This makes it hard for editors to open the right file to fix the error.
  • There is no clear relationship between source and build tree header files. This makes an audit of the build process difficult.
  • The visibility of all header files in the build tree makes it difficult to enforce API barriers. For example it is discouraged to use BSP-specifics in the cpukit.
  • An introduction of a new build system is difficult.
  • Include paths specified by the -B option are system headers. This may suppress warnings.
  • The parallel build had sporadic failures on some hosts.

This patch removes the make preinstall step. All installed header
files are moved to dedicated include directories in the source tree.
Let @RTEMS_CPU@ be the target architecture, e.g. arm, powerpc, sparc,
etc. Let @RTEMS_BSP_FAMILIY@ be a BSP family base directory, e.g.
erc32, imx, qoriq, etc.

The new cpukit include directories are:

  • cpukit/include
  • cpukit/score/cpu/@RTEMS_CPU@/include
  • cpukit/libnetworking

The new BSP include directories are:

  • bsps/include
  • bsps/@RTEMS_CPU@/include
  • bsps/@RTEMS_CPU@/@RTEMS_BSP_FAMILIY@/include

There are build tree include directories for generated files.

The include directory order favours the most general header file, e.g.
it is not possible to override general header files via the include path
order.

The "bootstrap -p" option was removed. The new "bootstrap -H" option
should be used to regenerate the "headers.am" files.

Update #3254.

  • Property mode set to 100644
File size: 7.6 KB
Line 
1/**
2 *  @file  rtems/score/timestamp.h
3 *
4 *  @brief Helpers for Manipulating Timestamps
5 *
6 *  This include file contains helpers for manipulating timestamps.
7 */
8
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_TIMESTAMP_H
19#define _RTEMS_SCORE_TIMESTAMP_H
20
21/**
22 *  @defgroup SuperCoreTimeStamp Score Timestamp
23 *
24 *  @ingroup Score
25 *
26 *  This handler encapsulates functionality related to manipulating
27 *  SuperCore Timestamps.  SuperCore Timestamps may be used to
28 *  represent time of day, uptime, or intervals.
29 *
30 *  The key attribute of the SuperCore Timestamp handler is that it
31 *  is a completely opaque handler.  There can be multiple implementations
32 *  of the required functionality and with a recompile, RTEMS can use
33 *  any implementation.  It is intended to be a simple wrapper.
34 *
35 *  This handler can be implemented as either struct timespec or
36 *  unsigned64 bit numbers.  The use of a wrapper class allows the
37 *  the implementation of timestamps to change on a per architecture
38 *  basis.  This is an important option as the performance of this
39 *  handler is critical.
40 */
41/**@{*/
42
43#include <sys/time.h>
44
45#include <rtems/score/basedefs.h>
46#include <rtems/score/timespec.h>
47
48#ifdef __cplusplus
49extern "C" {
50#endif
51
52/**
53 *   Define the Timestamp control type.
54 */
55typedef sbintime_t Timestamp_Control;
56
57/**
58 *  @brief Set timestamp to specified seconds and nanoseconds.
59 *
60 *  This method sets the timestamp to the specified @a _seconds and @a _nanoseconds
61 *  value.
62 *
63 *  @param[in] _time points to the timestamp instance to validate.
64 *  @param[in] _seconds is the seconds portion of the timestamp
65 *  @param[in] _nanoseconds is the nanoseconds portion of the timestamp
66 */
67RTEMS_INLINE_ROUTINE void _Timestamp_Set(
68  Timestamp_Control *_time,
69  time_t             _seconds,
70  long               _nanoseconds
71)
72{
73  struct timespec _ts;
74
75  _ts.tv_sec = _seconds;
76  _ts.tv_nsec = _nanoseconds;
77
78  *_time = tstosbt(_ts);
79}
80
81/**
82 *  @brief Sets the timestamp to zero.
83 *
84 *  This method sets the timestamp to zero.
85 *  value.
86 *
87 *  @param[in] _time points to the timestamp instance to zero.
88 */
89
90RTEMS_INLINE_ROUTINE void _Timestamp_Set_to_zero(
91  Timestamp_Control *_time
92)
93{
94  *_time = 0;
95}
96
97/**
98 *  @brief Less than operator for timestamps.
99 *
100 *  This method is the less than operator for timestamps.
101 *
102 *  @param[in] _lhs points to the left hand side timestamp
103 *  @param[in] _rhs points to the right hand side timestamp
104 *
105 *  @retval This method returns true if @a _lhs is less than the @a _rhs and
106 *          false otherwise.
107 */
108
109RTEMS_INLINE_ROUTINE bool _Timestamp_Less_than(
110  const Timestamp_Control *_lhs,
111  const Timestamp_Control *_rhs
112)
113{
114  return *_lhs < *_rhs;
115}
116
117/**
118 *  @brief Greater than operator for timestamps.
119 *
120 *  This method is the greater than operator for timestamps.
121 *
122 *  @param[in] _lhs points to the left hand side timestamp
123 *  @param[in] _rhs points to the right hand side timestamp
124 *
125 *  @retval This method returns true if @a _lhs is greater than the @a _rhs and
126 *          false otherwise.
127 */
128
129RTEMS_INLINE_ROUTINE bool _Timestamp_Greater_than(
130  const Timestamp_Control *_lhs,
131  const Timestamp_Control *_rhs
132)
133{
134  return *_lhs > *_rhs;
135}
136
137/**
138 *  @brief Equal to than operator for timestamps.
139 *
140 *  This method is the is equal to than operator for timestamps.
141 *
142 *  @param[in] _lhs points to the left hand side timestamp
143 *  @param[in] _rhs points to the right hand side timestamp
144 *
145 *  @retval This method returns true if @a _lhs is equal to  @a _rhs and
146 *          false otherwise.
147 */
148
149RTEMS_INLINE_ROUTINE bool _Timestamp_Equal_to(
150  const Timestamp_Control *_lhs,
151  const Timestamp_Control *_rhs
152)
153{
154  return *_lhs == *_rhs;
155}
156
157/**
158 *  @brief Adds two timestamps.
159 *
160 *  This routine adds two timestamps.  The second argument is added
161 *  to the first.
162 *
163 *  @param[in] _time points to the base time to be added to
164 *  @param[in] _add points to the timestamp to add to the first argument
165 */
166RTEMS_INLINE_ROUTINE void _Timestamp_Add_to(
167  Timestamp_Control *_time,
168  const Timestamp_Control *_add
169)
170{
171  *_time += *_add;
172}
173
174/**
175 *  @brief Subtracts two timestamps.
176 *
177 *  This routine subtracts two timestamps.  @a result is set to
178 *  @a end - @a start.
179 *
180 *  @param[in] _start points to the starting time
181 *  @param[in] _end points to the ending time
182 *  @param[in] _result points to the difference between
183 *             starting and ending time.
184 *
185 *  @retval This method fills in @a _result.
186 */
187RTEMS_INLINE_ROUTINE void _Timestamp_Subtract(
188  const Timestamp_Control *_start,
189  const Timestamp_Control *_end,
190  Timestamp_Control       *_result
191)
192{
193  *_result = *_end - *_start;
194}
195
196/**
197 *  @brief Divides a timestamp by another timestamp.
198 *
199 *  This routine divides a timestamp by another timestamp.  The
200 *  intended use is for calculating percentages to three decimal points.
201 *
202 *  @param[in] _lhs points to the left hand number
203 *  @param[in] _rhs points to the right hand number
204 *  @param[in] _ival_percentage points to the integer portion of the average
205 *  @param[in] _fval_percentage points to the thousandths of percentage
206 *
207 *  @retval This method fills in @a result.
208 */
209RTEMS_INLINE_ROUTINE void _Timestamp_Divide(
210  const Timestamp_Control *_lhs,
211  const Timestamp_Control *_rhs,
212  uint32_t                *_ival_percentage,
213  uint32_t                *_fval_percentage
214)
215{
216  struct timespec _ts_left;
217  struct timespec _ts_right;
218
219  _ts_left = sbttots( *_lhs );
220  _ts_right = sbttots( *_rhs );
221
222  _Timespec_Divide(
223    &_ts_left,
224    &_ts_right,
225    _ival_percentage,
226    _fval_percentage
227  );
228}
229
230/**
231 *  @brief Get seconds portion of timestamp.
232 *
233 *  This method returns the seconds portion of the specified timestamp
234 *
235 *  @param[in] _time points to the timestamp
236 *
237 *  @retval The seconds portion of @a _time.
238 */
239RTEMS_INLINE_ROUTINE time_t _Timestamp_Get_seconds(
240  const Timestamp_Control *_time
241)
242{
243  return (*_time >> 32);
244}
245
246/**
247 *  @brief Get nanoseconds portion of timestamp.
248 *
249 *  This method returns the nanoseconds portion of the specified timestamp
250 *
251 *  @param[in] _time points to the timestamp
252 *
253 *  @retval The nanoseconds portion of @a _time.
254 */
255RTEMS_INLINE_ROUTINE uint32_t _Timestamp_Get_nanoseconds(
256  const Timestamp_Control *_time
257)
258{
259  struct timespec _ts;
260
261  _ts = sbttots( *_time );
262
263  return (uint32_t) _ts.tv_nsec;
264}
265
266/**
267 *  @brief Get the timestamp as nanoseconds.
268 *
269 *  This method returns the timestamp as nanoseconds.
270 *
271 *  @param[in] _time points to the timestamp
272 *
273 *  @retval The time in nanoseconds.
274 */
275RTEMS_INLINE_ROUTINE uint64_t _Timestamp_Get_as_nanoseconds(
276  const Timestamp_Control *_time
277)
278{
279  struct timespec _ts;
280
281  _ts = sbttots( *_time );
282
283  return _Timespec_Get_as_nanoseconds( &_ts );
284}
285
286/**
287 *  @brief Convert timestamp to struct timespec.
288 *
289 *  This method returns the seconds portion of the specified @a _timestamp.
290 *
291 *  @param[in] _timestamp points to the timestamp
292 *  @param[in] _timespec points to the timespec
293 */
294RTEMS_INLINE_ROUTINE void _Timestamp_To_timespec(
295  const Timestamp_Control *_timestamp,
296  struct timespec         *_timespec
297)
298{
299  *_timespec = sbttots( *_timestamp );
300}
301
302/**
303 *  @brief Convert timestamp to struct timeval.
304 *
305 *  @param[in] _timestamp points to the timestamp
306 *  @param[in] _timeval points to the timeval
307 */
308RTEMS_INLINE_ROUTINE void _Timestamp_To_timeval(
309  const Timestamp_Control *_timestamp,
310  struct timeval          *_timeval
311)
312{
313  *_timeval = sbttotv( *_timestamp );
314}
315
316#ifdef __cplusplus
317}
318#endif
319
320/**@}*/
321
322#endif
323/* end of include file */
Note: See TracBrowser for help on using the repository browser.