RTEMS
clock.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 
11 /*
12  * Copyright (C) 2014, 2020 embedded brains GmbH (http://www.embedded-brains.de)
13  * Copyright (C) 1988, 2008 On-Line Applications Research Corporation (OAR)
14  *
15  * Redistribution and use in source and binary forms, with or without
16  * modification, are permitted provided that the following conditions
17  * are met:
18  * 1. Redistributions of source code must retain the above copyright
19  * notice, this list of conditions and the following disclaimer.
20  * 2. Redistributions in binary form must reproduce the above copyright
21  * notice, this list of conditions and the following disclaimer in the
22  * documentation and/or other materials provided with the distribution.
23  *
24  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
28  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  */
36 
37 /*
38  * Do not manually edit this file. It is part of the RTEMS quality process
39  * and was automatically generated.
40  *
41  * If you find something that needs to be fixed or worded better please
42  * post a report to an RTEMS mailing list or raise a bug report:
43  *
44  * https://docs.rtems.org/branches/master/user/support/bugs.html
45  *
46  * For information on updating and regenerating please refer to:
47  *
48  * https://docs.rtems.org/branches/master/eng/req/howto.html
49  */
50 
51 /* Generated from spec:/rtems/clock/if/header */
52 
53 #ifndef _RTEMS_RTEMS_CLOCK_H
54 #define _RTEMS_RTEMS_CLOCK_H
55 
56 #include <stdbool.h>
57 #include <stdint.h>
58 #include <time.h>
59 #include <rtems/config.h>
60 #include <sys/_timespec.h>
61 #include <sys/_timeval.h>
62 #include <rtems/rtems/status.h>
63 #include <rtems/rtems/types.h>
65 
66 #ifdef __cplusplus
67 extern "C" {
68 #endif
69 
70 /* Generated from spec:/rtems/clock/if/group */
71 
81 /* Generated from spec:/rtems/clock/if/get-seconds-since-epoch */
82 
91  rtems_interval *the_interval
92 );
93 
94 /* Generated from spec:/rtems/clock/if/get-ticks-per-second */
95 
101 #define rtems_clock_get_ticks_per_second() _Watchdog_Ticks_per_second
102 
103 /* Generated from spec:/rtems/clock/if/get-ticks-since-boot */
104 
110 #define rtems_clock_get_ticks_since_boot() _Watchdog_Ticks_since_boot
111 
112 /* Generated from spec:/rtems/clock/if/get-tod */
113 
122 
123 /* Generated from spec:/rtems/clock/if/get-tod-timeval */
124 
132 rtems_status_code rtems_clock_get_tod_timeval( struct timeval *time );
133 
134 /* Generated from spec:/rtems/clock/if/get-uptime */
135 
143 rtems_status_code rtems_clock_get_uptime( struct timespec *uptime );
144 
145 /* Generated from spec:/rtems/clock/if/get-uptime-nanoseconds */
146 
152 uint64_t rtems_clock_get_uptime_nanoseconds( void );
153 
154 /* Generated from spec:/rtems/clock/if/get-uptime-seconds */
155 
161 time_t rtems_clock_get_uptime_seconds( void );
162 
163 /* Generated from spec:/rtems/clock/if/get-uptime-timeval */
164 
172 void rtems_clock_get_uptime_timeval( struct timeval *uptime );
173 
174 /* Generated from spec:/rtems/clock/if/set */
175 
184 
185 /* Generated from spec:/rtems/clock/if/tick */
186 
193 
194 /* Generated from spec:/rtems/clock/if/tick-before */
195 
211 static inline bool rtems_clock_tick_before( rtems_interval tick )
212 {
213  return (int32_t) ( tick - _Watchdog_Ticks_since_boot ) > 0;
214 }
215 
216 /* Generated from spec:/rtems/clock/if/tick-later */
217 
228 {
229  return _Watchdog_Ticks_since_boot + delta;
230 }
231 
232 /* Generated from spec:/rtems/clock/if/tick-later-usec */
233 
245  rtems_interval delta_in_usec
246 )
247 {
248  rtems_interval us_per_tick;
249 
251 
252  /*
253  * Add one additional tick, since we do not know the time to the clock
254  * next tick.
255  */
256  return _Watchdog_Ticks_since_boot + 1
257  + ( delta_in_usec + us_per_tick - 1 ) / us_per_tick;
258 }
259 
260 /* Generated from spec:/score/if/tod-to-seconds */
261 
268 
269 /* Generated from spec:/score/if/tod-validate */
270 
276 bool _TOD_Validate( const rtems_time_of_day *the_tod );
277 
278 #ifdef __cplusplus
279 }
280 #endif
281 
282 #endif /* _RTEMS_RTEMS_CLOCK_H */
rtems_status_code rtems_clock_get_tod(rtems_time_of_day *time_buffer)
%
This header file defines types provided by the Classic API.
uint32_t Watchdog_Interval
Type is used to specify the length of intervals.
Definition: watchdogticks.h:38
static rtems_interval rtems_clock_tick_later_usec(rtems_interval delta_in_usec)
Returns the ticks counter value at least delta microseconds in the future.
Definition: clock.h:244
time_t rtems_clock_get_uptime_seconds(void)
%
This header file defines the status codes and support functions of the Classic API.
Watchdog_Interval _TOD_To_seconds(const rtems_time_of_day *the_tod)
%
This type is used to represent the calendar time in the Classic API.
Definition: types.h:258
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:82
void rtems_clock_get_uptime_timeval(struct timeval *uptime)
%
uint64_t rtems_clock_get_uptime_nanoseconds(void)
%
rtems_status_code rtems_clock_get_seconds_since_epoch(rtems_interval *the_interval)
%
rtems_status_code rtems_clock_get_uptime(struct timespec *uptime)
%
#define rtems_configuration_get_microseconds_per_tick()
Returns the number of microseconds per clock tick configured for this application.
Definition: config.h:205
Watchdog_Interval rtems_interval
This type is used to represent clock tick intervals.
Definition: types.h:90
rtems_status_code rtems_clock_get_tod_timeval(struct timeval *time)
%
Constants for the watchdog ticks.
static rtems_interval rtems_clock_tick_later(rtems_interval delta)
Returns the ticks counter value delta ticks in the future.
Definition: clock.h:227
rtems_status_code rtems_clock_set(const rtems_time_of_day *time_buffer)
%
static bool rtems_clock_tick_before(rtems_interval tick)
Returns true if the current ticks counter value indicates a time before the time specified by the tic...
Definition: clock.h:211
volatile Watchdog_Interval _Watchdog_Ticks_since_boot
The watchdog ticks counter.
bool _TOD_Validate(const rtems_time_of_day *the_tod)
%
rtems_status_code rtems_clock_tick(void)
%