source: rtems/cpukit/include/rtems/score/timespec.h @ 878487b0

5
Last change on this file since 878487b0 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: 6.6 KB
Line 
1/**
2 *  @file  rtems/score/timespec.h
3 *
4 *  This include file contains helpers for manipulating timespecs.
5 */
6
7/*
8 *  COPYRIGHT (c) 1989-2009.
9 *  On-Line Applications Research Corporation (OAR).
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.rtems.org/license/LICENSE.
14 */
15
16#ifndef _RTEMS_SCORE_TIMESPEC_H
17#define _RTEMS_SCORE_TIMESPEC_H
18
19/**
20 *  @defgroup Timespec Helpers
21 *
22 *  @ingroup Score
23 *
24 *  This handler encapsulates functionality related to manipulating
25 *  POSIX struct timespecs.
26 */
27/**@{*/
28
29#include <stdbool.h> /* bool */
30#include <stdint.h> /* uint32_t */
31#include <time.h> /* struct timespec */
32
33#ifdef __cplusplus
34extern "C" {
35#endif
36
37/**
38 * @brief Set timespec to seconds nanosecond.
39 *
40 *  This method sets the timespec to the specified seconds and nanoseconds
41 *  value.
42 *
43 *  @param[in] _time points to the timespec instance to validate.
44 *  @param[in] _seconds is the seconds portion of the timespec
45 *  @param[in] _nanoseconds is the nanoseconds portion of the timespec
46 */
47#define _Timespec_Set( _time, _seconds, _nanoseconds ) \
48        do { \
49           (_time)->tv_sec = (_seconds); \
50           (_time)->tv_nsec = (_nanoseconds); \
51        } while (0)
52
53/**
54 * @brief Sets the Timespec to Zero
55 *
56 *  This method sets the timespec to zero.
57 *  value.
58 *
59 *  @param[in] _time points to the timespec instance to zero.
60 */
61#define _Timespec_Set_to_zero( _time ) \
62        do { \
63           (_time)->tv_sec = 0; \
64           (_time)->tv_nsec = 0; \
65        } while (0)
66
67/**
68 * @brief Get seconds portion of timespec.
69 *
70 *  This method returns the seconds portion of the specified timespec
71 *
72 *  @param[in] _time points to the timespec
73 *
74 *  @retval The seconds portion of @a _time.
75 */
76#define _Timespec_Get_seconds( _time ) \
77        ((_time)->tv_sec)
78
79/**
80 * @brief Get nanoseconds portion of timespec.
81 *
82 *  This method returns the nanoseconds portion of the specified timespec
83 *
84 *  @param[in] _time points to the timespec
85 *
86 *  @retval The nanoseconds portion of @a _time.
87 */
88#define _Timespec_Get_nanoseconds( _time ) \
89        ((_time)->tv_nsec)
90
91/**
92 *  @brief Get the timestamp as nanoseconds.
93 *
94 *  This method returns the timestamp as nanoseconds.
95 *
96 *  @param[in] time points to the timestamp.
97 *
98 *  @retval The time in nanoseconds.
99 */
100uint64_t _Timespec_Get_as_nanoseconds(
101  const struct timespec *time
102);
103
104/**
105 * @brief Check if timespec is valid.
106 *
107 *  This method determines the validity of a timespec.
108 *
109 *  @param[in] time is the timespec instance to validate.
110 *
111 *  @retval This method returns true if @a time is valid and
112 *          false otherwise.
113 */
114bool _Timespec_Is_valid(
115  const struct timespec *time
116);
117
118/**
119 *  @brief The Timespec "less than" operator.
120 *
121 *  This method is the less than operator for timespecs.
122 *
123 *  @param[in] lhs is the left hand side timespec
124 *  @param[in] rhs is the right hand side timespec
125 *
126 *  @retval This method returns true if @a lhs is less than the @a rhs and
127 *          false otherwise.
128 */
129bool _Timespec_Less_than(
130  const struct timespec *lhs,
131  const struct timespec *rhs
132);
133
134/**
135 * @brief The Timespec "greater than" operator.
136 *
137 *  This method is the greater than operator for timespecs.
138 *
139 *  @param[in] _lhs is the left hand side timespec
140 *  @param[in] _rhs is the right hand side timespec
141 *
142 *  @retval This method returns true if @a lhs is greater than the @a rhs and
143 *          false otherwise.
144 */
145#define _Timespec_Greater_than( _lhs, _rhs ) \
146  _Timespec_Less_than( _rhs, _lhs )
147
148/**
149 * @brief The Timespec "equal to" operator.
150 *
151 *  This method is the is equal to than operator for timespecs.
152 *
153 *  @param[in] lhs is the left hand side timespec
154 *  @param[in] rhs is the right hand side timespec
155 *
156 *  @retval This method returns true if @a lhs is equal to  @a rhs and
157 *          false otherwise.
158 */
159#define _Timespec_Equal_to( lhs, rhs ) \
160  ( ((lhs)->tv_sec  == (rhs)->tv_sec) &&   \
161    ((lhs)->tv_nsec == (rhs)->tv_nsec)     \
162  )
163
164/**
165 *  @brief Add two timespecs.
166 *
167 *  This routine adds two timespecs.  The second argument is added
168 *  to the first.
169 *
170 *  @param[in] time is the base time to be added to
171 *  @param[in] add is the timespec to add to the first argument
172 *
173 *  @retval This method returns the number of seconds @a time increased by.
174 */
175uint32_t _Timespec_Add_to(
176  struct timespec       *time,
177  const struct timespec *add
178);
179
180/**
181 * @brief Convert timespec to number of ticks.
182 *
183 *  This routine convert the @a time timespec to the corresponding number
184 *  of clock ticks.
185 *
186 *  @param[in] time is the time to be converted
187 *
188 *  @retval This method returns the number of ticks computed.
189 */
190uint32_t _Timespec_To_ticks(
191  const struct timespec *time
192);
193
194/**
195 * @brief Convert ticks to timespec.
196 *
197 *  This routine converts the @a ticks value to the corresponding
198 *  timespec format @a time.
199 *
200 *  @param[in] time is the timespec format time result
201 *  @param[in] ticks is the number of ticks to convert
202 */
203void _Timespec_From_ticks(
204  uint32_t         ticks,
205  struct timespec *time
206);
207
208/**
209 * @brief Subtract two timespec.
210 *
211 *  This routine subtracts two timespecs.  @a result is set to
212 *  @a end - @a start.
213 *
214 *  @param[in] start is the starting time
215 *  @param[in] end is the ending time
216 *  @param[in] result is the difference between starting and ending time.
217 *
218 *  @retval This method fills in @a result.
219 */
220void _Timespec_Subtract(
221  const struct timespec *start,
222  const struct timespec *end,
223  struct timespec       *result
224);
225
226/**
227 * @brief Divide timespec by an integer.
228 *
229 *  This routine divides a timespec by an integer value.  The expected
230 *  use is to assist in benchmark calculations where you typically
231 *  divide a duration by a number of iterations.
232 *
233 *  @param[in] time is the total
234 *  @param[in] iterations is the number of iterations
235 *  @param[in] result is the average time.
236 *
237 *  @retval This method fills in @a result.
238 */
239void _Timespec_Divide_by_integer(
240  const struct timespec *time,
241  uint32_t               iterations,
242  struct timespec       *result
243);
244
245/**
246 * @brief Divide a timespec by anonther timespec.
247 *
248 *  This routine divides a timespec by another timespec.  The
249 *  intended use is for calculating percentages to three decimal points.
250 *
251 *  @param[in] lhs is the left hand number
252 *  @param[in] rhs is the right hand number
253 *  @param[in] ival_percentage is the integer portion of the average
254 *  @param[in] fval_percentage is the thousandths of percentage
255 *
256 *  @retval This method fills in @a result.
257 */
258void _Timespec_Divide(
259  const struct timespec *lhs,
260  const struct timespec *rhs,
261  uint32_t              *ival_percentage,
262  uint32_t              *fval_percentage
263);
264
265#ifdef __cplusplus
266}
267#endif
268
269/**@}*/
270
271#endif
272/* end of include file */
Note: See TracBrowser for help on using the repository browser.