source: rtems/cpukit/include/rtems/score/todimpl.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: 6.8 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup ScoreTOD
5 *
6 * @brief Time of Day Handler API
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_TODIMPL_H
19#define _RTEMS_SCORE_TODIMPL_H
20
21#include <rtems/score/tod.h>
22#include <rtems/score/timestamp.h>
23#include <rtems/score/timecounterimpl.h>
24#include <rtems/score/watchdog.h>
25
26#include <sys/time.h>
27#include <time.h>
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33/**
34 *  @defgroup ScoreTOD Time of Day Handler
35 *
36 *  @ingroup Score
37 *
38 *  The following constants are related to the time of day and are
39 *  independent of RTEMS.
40 */
41/**@{*/
42
43/**
44 *  This constant represents the number of seconds in a minute.
45 */
46#define TOD_SECONDS_PER_MINUTE (uint32_t)60
47
48/**
49 *  This constant represents the number of minutes per hour.
50 */
51#define TOD_MINUTES_PER_HOUR   (uint32_t)60
52
53/**
54 *  This constant represents the number of months in a year.
55 */
56#define TOD_MONTHS_PER_YEAR    (uint32_t)12
57
58/**
59 *  This constant represents the number of days in a non-leap year.
60 */
61#define TOD_DAYS_PER_YEAR      (uint32_t)365
62
63/**
64 *  This constant represents the number of hours per day.
65 */
66#define TOD_HOURS_PER_DAY      (uint32_t)24
67
68/**
69 *  This constant represents the number of seconds in a day which does
70 *  not include a leap second.
71 */
72#define TOD_SECONDS_PER_DAY    (uint32_t) (TOD_SECONDS_PER_MINUTE * \
73                                TOD_MINUTES_PER_HOUR   * \
74                                TOD_HOURS_PER_DAY)
75
76/**
77 *  This constant represents the number of seconds in a non-leap year.
78 */
79#define TOD_SECONDS_PER_NON_LEAP_YEAR (365 * TOD_SECONDS_PER_DAY)
80
81/**
82 *  This constant represents the number of millisecond in a second.
83 */
84#define TOD_MILLISECONDS_PER_SECOND     (uint32_t)1000
85
86/**
87 *  This constant represents the number of microseconds in a second.
88 */
89#define TOD_MICROSECONDS_PER_SECOND     (uint32_t)1000000
90
91/**
92 *  This constant represents the number of nanoseconds in a second.
93 */
94#define TOD_NANOSECONDS_PER_SECOND      (uint32_t)1000000000
95
96/**
97 *  This constant represents the number of nanoseconds in a mircosecond.
98 */
99#define TOD_NANOSECONDS_PER_MICROSECOND (uint32_t)1000
100
101/**@}*/
102
103/**
104 *  Seconds from January 1, 1970 to January 1, 1988.  Used to account for
105 *  differences between POSIX API and RTEMS core. The timespec format time
106 *  is kept in POSIX compliant form.
107 */
108#define TOD_SECONDS_1970_THROUGH_1988 \
109  (((1987 - 1970 + 1)  * TOD_SECONDS_PER_NON_LEAP_YEAR) + \
110  (4 * TOD_SECONDS_PER_DAY))
111
112/**
113 *  @brief Earliest year to which an time of day can be initialized.
114 *
115 *  The following constant define the earliest year to which an
116 *  time of day can be initialized.  This is considered the
117 *  epoch.
118 */
119#define TOD_BASE_YEAR 1988
120
121/**
122 *  @defgroup ScoreTOD Time Of Day (TOD) Handler
123 *
124 *  @ingroup Score
125 *
126 *  This handler encapsulates functionality used to manage time of day.
127 */
128/**@{*/
129
130/**
131 *  @brief TOD control.
132 */
133typedef struct {
134  /**
135   *  @brief Indicates if the time of day is set.
136   *
137   *  This is true if the application has set the current
138   *  time of day, and false otherwise.
139   */
140  bool is_set;
141} TOD_Control;
142
143extern TOD_Control _TOD;
144
145void _TOD_Lock( void );
146
147void _TOD_Unlock( void );
148
149#if defined(RTEMS_DEBUG)
150bool _TOD_Is_owner( void );
151#endif
152
153static inline void _TOD_Acquire( ISR_lock_Context *lock_context )
154{
155  _Timecounter_Acquire( lock_context );
156}
157
158/**
159 * @brief Sets the time of day.
160 *
161 * The caller must be the owner of the TOD lock.
162 *
163 * @param tod The new time of day in timespec format representing
164 *   the time since UNIX Epoch.
165 * @param lock_context The ISR lock context used for the corresponding
166 *   _TOD_Acquire().  The caller must be the owner of the TOD lock.  This
167 *   function will release the TOD lock.
168 */
169void _TOD_Set(
170  const struct timespec *tod,
171  ISR_lock_Context      *lock_context
172);
173
174/**
175 *  @brief Gets the current time in the timespec format.
176 *
177 *  @param[out] time is the value gathered by the request
178 */
179static inline void _TOD_Get(
180  struct timespec *tod
181)
182{
183  _Timecounter_Nanotime( tod );
184}
185
186/**
187 *  @brief Gets the system uptime with potential accuracy to the nanosecond.
188 *
189 *  This routine returns the system uptime with potential accuracy
190 *  to the nanosecond.
191 *
192 *  The initial uptime value is undefined.
193 *
194 *  @param[in] time is a pointer to the uptime to be returned
195 */
196static inline void _TOD_Get_uptime(
197  Timestamp_Control *time
198)
199{
200  *time = _Timecounter_Sbinuptime();
201}
202
203/**
204 *  @brief Gets the system uptime with potential accuracy to the nanosecond.
205 *  to the nanosecond.
206 *
207 *  The initial uptime value is zero.
208 *
209 *  @param[in] time is a pointer to the uptime to be returned
210 */
211static inline void _TOD_Get_zero_based_uptime(
212  Timestamp_Control *time
213)
214{
215  *time = _Timecounter_Sbinuptime() - SBT_1S;
216}
217
218/**
219 *  @brief Gets the system uptime with potential accuracy to the nanosecond.
220 *
221 *  The initial uptime value is zero.
222 *
223 *  @param[in] time is a pointer to the uptime to be returned
224 */
225static inline void _TOD_Get_zero_based_uptime_as_timespec(
226  struct timespec *time
227)
228{
229  _Timecounter_Nanouptime( time );
230  --time->tv_sec;
231}
232
233/**
234 *  @brief Number of seconds Since RTEMS epoch.
235 *
236 *  The following contains the number of seconds from 00:00:00
237 *  January 1, TOD_BASE_YEAR until the current time of day.
238 */
239static inline uint32_t _TOD_Seconds_since_epoch( void )
240{
241  return (uint32_t) _Timecounter_Time_second;
242}
243
244/**
245 *  @brief Gets number of ticks in a second.
246 *
247 *  This method returns the number of ticks in a second.
248 *
249 *  @note If the clock tick value does not multiply evenly into a second
250 *        then this number of ticks will be slightly shorter than a second.
251 */
252uint32_t TOD_TICKS_PER_SECOND_method(void);
253
254/**
255 *  @brief Gets number of ticks in a second.
256 *
257 *  This method exists to hide the fact that TOD_TICKS_PER_SECOND can not
258 *  be implemented as a macro in a .h file due to visibility issues.
259 *  The Configuration Table is not available to SuperCore .h files but
260 *  is available to their .c files.
261 */
262#define TOD_TICKS_PER_SECOND TOD_TICKS_PER_SECOND_method()
263
264/**
265 * This routine returns a timeval based upon the internal timespec format TOD.
266 */
267
268RTEMS_INLINE_ROUTINE void _TOD_Get_timeval(
269  struct timeval *time
270)
271{
272  _Timecounter_Microtime( time );
273}
274
275/**
276 * @brief Adjust the Time of Time
277 *
278 * This method is used to adjust the current time of day by the
279 * specified amount.
280 *
281 * @param[in] delta is the amount to adjust
282 */
283void _TOD_Adjust(
284  const struct timespec *delta
285);
286
287/**
288 * @brief Check if the TOD is Set
289 *
290 * @return TRUE is the time is set. FALSE otherwise.
291 */
292RTEMS_INLINE_ROUTINE bool _TOD_Is_set( void )
293{
294  return _TOD.is_set;
295}
296
297/**@}*/
298
299#ifdef __cplusplus
300}
301#endif
302
303#endif
304/* end of include file */
Note: See TracBrowser for help on using the repository browser.