source: rtems/cpukit/include/rtems/timespec.h @ 963c6c2

5
Last change on this file since 963c6c2 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.9 KB
Line 
1/**
2 * @file
3 *
4 * @brief Timespec API
5 *
6 * This include file contains API for manipulating timespecs.
7 */
8
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
24extern "C" {
25#endif
26
27/**
28 *  @defgroup TimespecAPI Timespec
29 *
30 *  @ingroup ClassicRTEMS
31 *
32 *  @brief Timespec API
33 *
34 * @{
35 *
36 */
37
38/**
39 * @brief Is timespec valid
40 *
41 * This method determines the validity of a timespec.
42 *
43 * @param[in] time is the timespec instance to validate.
44 *
45 * @retval true The timespec is valid.
46 * @retval false The timespec is not valid.
47 */
48RTEMS_INLINE_ROUTINE bool rtems_timespec_is_valid(
49  const struct timespec *time
50)
51{
52  return _Timespec_Is_valid(time);
53}
54
55/**
56 * @brief Timespec less than operator.
57 *
58 * This method is the less than operator for timespecs.
59 *
60 * @param[in] lhs is the left hand side timespec
61 * @param[in] rhs is the right hand side timespec
62 *
63 * @retval true @a lhs is less than @a rhs.
64 * @retval false @a lhs is not less than @a rhs.
65 *
66 */
67RTEMS_INLINE_ROUTINE bool rtems_timespec_less_than(
68  const struct timespec *lhs,
69  const struct timespec *rhs
70)
71{
72  return _Timespec_Less_than(lhs,rhs);
73}
74
75/**
76 * @brief Add to a timespec.
77 *
78 * This routine adds two timespecs.  The second argument is added
79 * to the first.
80 *
81 * @param[in] time is the base time to be added to
82 * @param[in] add is the timespec to add to the first argument
83 *
84 * @return This method returns the number of seconds @a time increased by.
85 */
86RTEMS_INLINE_ROUTINE uint32_t rtems_timespec_add_to(
87  struct timespec       *time,
88  const struct timespec *add
89)
90{
91  return _Timespec_Add_to(time,add);
92}
93
94/**
95 * @brief Convert timespec to number of ticks.
96 *
97 * This routine convert the @a time timespec to the corresponding number
98 * of clock ticks.
99 *
100 * @param[in] time is the time to be converted
101 *
102 * @return This method returns the number of ticks computed.
103 */
104RTEMS_INLINE_ROUTINE uint32_t rtems_timespec_to_ticks(
105  const struct timespec *time
106)
107{
108  return _Timespec_To_ticks(time);
109}
110
111/**
112 * @brief Convert ticks to timespec.
113 *
114 * This routine converts the @a ticks value to the corresponding
115 * timespec format @a time.
116 *
117 * @param[in] time is the timespec format time result
118 * @param[in] ticks is the number of ticks to convert
119 */
120
121RTEMS_INLINE_ROUTINE void rtems_timespec_from_ticks(
122  uint32_t         ticks,
123  struct timespec *time
124)
125{
126  _Timespec_From_ticks(ticks,time);
127}
128
129/**
130 * @brief Subtract two timespec.
131 *
132 * This routine subtracts two timespecs.  @a result is set to
133 * @a end - @a start.
134 *
135 * @param[in] start is the starting time
136 * @param[in] end is the ending time
137 * @param[in] result is the difference between starting and ending time.
138 *
139 * @return This method fills in @a result.
140 */
141RTEMS_INLINE_ROUTINE void rtems_timespec_subtract(
142  const struct timespec *start,
143  const struct timespec *end,
144  struct timespec       *result
145)
146{
147  _Timespec_Subtract(start,end,result);
148}
149
150/**
151 * @brief Divide timespec by integer.
152 *
153 * This routine divides a timespec by an integer value.  The expected
154 * use is to assist in benchmark calculations where you typically
155 * divide a duration by a number of iterations.
156 *
157 * @param[in] time is the total
158 * @param[in] iterations is the number of iterations
159 * @param[in] result is the average time.
160 *
161 * @return This method fills in @a result.
162 */
163RTEMS_INLINE_ROUTINE void rtems_timespec_divide_by_integer(
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
172/**
173 * @brief Divide timespec.
174 *
175 * This routine divides a timespec by another timespec.  The
176 * intended use is for calculating percentages to three decimal points.
177 *
178 * @param[in] lhs is the left hand number
179 * @param[in] rhs is the right hand number
180 * @param[in] ival_percentage is the integer portion of the average
181 * @param[in] fval_percentage is the thousandths of percentage
182 *
183 * @return This method fills in @a result.
184 */
185RTEMS_INLINE_ROUTINE void rtems_timespec_divide(
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
195/**
196 * @brief Set timespec to seconds nanosecond.
197 *
198 * This method sets the timespec to the specified seconds and nanoseconds
199 * value.
200 *
201 * @param[in] _time points to the timespec instance to validate.
202 * @param[in] _seconds is the seconds portion of the timespec
203 * @param[in] _nanoseconds is the nanoseconds portion of the timespec
204 */
205RTEMS_INLINE_ROUTINE void rtems_timespec_set(
206  struct timespec *_time,
207  time_t _seconds,
208  uint32_t _nanoseconds
209)
210{
211  _Timespec_Set( _time, _seconds, _nanoseconds );
212}
213
214/**
215 * @brief Zero timespec.
216 *
217 * This method sets the timespec to zero.
218 * value.
219 *
220 * @param[in] _time points to the timespec instance to zero.
221 */
222RTEMS_INLINE_ROUTINE void rtems_timespec_zero(
223  struct timespec *_time
224)
225{
226  _Timespec_Set_to_zero( _time );
227}
228
229/**
230 * @brief Get seconds portion of timespec.
231 *
232 * This method returns the seconds portion of the specified timespec
233 *
234 * @param[in] _time points to the timespec
235 *
236 * @return The seconds portion of @a _time.
237 */
238RTEMS_INLINE_ROUTINE time_t rtems_timespec_get_seconds(
239  struct timespec *_time
240)
241{
242  return _Timespec_Get_seconds( _time );
243}
244
245/**
246 * @brief Get nanoseconds portion of timespec.
247 *
248 * This method returns the nanoseconds portion of the specified timespec
249 *
250 * @param[in] _time points to the timespec
251 *
252 * @return The nanoseconds portion of @a _time.
253 */
254RTEMS_INLINE_ROUTINE uint32_t rtems_timespec_get_nanoseconds(
255  struct timespec *_time
256)
257{
258  return _Timespec_Get_nanoseconds( _time );
259}
260
261/**
262 * @brief Timespec greater than operator.
263 *
264 * This method is the greater than operator for timespecs.
265 *
266 * @param[in] _lhs is the left hand side timespec
267 * @param[in] _rhs is the right hand side timespec
268 *
269 * @retval true @a _lhs is greater than @a _rhs.
270 * @retval false @a _lhs is not greater than @a _rhs.
271 */
272RTEMS_INLINE_ROUTINE bool rtems_timespec_greater_than(
273  const struct timespec *_lhs,
274  const struct timespec *_rhs
275)
276{
277  return _Timespec_Greater_than( _lhs, _rhs );
278}
279/**
280 * @brief Timespec equal to Operator
281 *
282 * This method is the is equal to than operator for timespecs.
283 *
284 * @param[in] lhs is the left hand side timespec
285 * @param[in] rhs is the right hand side timespec
286 *
287 * @retval true @a lhs is equal to @a rhs.
288 * @retval false @a lhs is not equal to @a rhs.
289 */
290RTEMS_INLINE_ROUTINE bool rtems_timespec_equal_to(
291  const struct timespec *lhs,
292  const struct timespec *rhs
293)
294{
295  return _Timespec_Equal_to( lhs, rhs);
296}
297
298/** @} */
299
300#ifdef __cplusplus
301}
302#endif
303
304#endif
305/* end of include file */
Note: See TracBrowser for help on using the repository browser.