RTEMS 6.1-rc7
Loading...
Searching...
No Matches
clock.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
11/*
12 * Copyright (C) 2014, 2021 embedded brains GmbH & Co. KG
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 * This file is part of the RTEMS quality process and was automatically
39 * generated. If you find something that needs to be fixed or
40 * worded better please post a report or patch to an RTEMS mailing list
41 * or raise a bug report:
42 *
43 * https://www.rtems.org/bugs.html
44 *
45 * For information on updating and regenerating please refer to the How-To
46 * section in the Software Requirements Engineering chapter of the
47 * RTEMS Software Engineering manual. The manual is provided as a part of
48 * a release. For development sources please refer to the online
49 * documentation at:
50 *
51 * https://docs.rtems.org
52 */
53
54/* Generated from spec:/rtems/clock/if/header */
55
56#ifndef _RTEMS_RTEMS_CLOCK_H
57#define _RTEMS_RTEMS_CLOCK_H
58
59#include <stdbool.h>
60#include <stdint.h>
61#include <time.h>
62#include <rtems/config.h>
63#include <sys/_timespec.h>
64#include <sys/_timeval.h>
65#include <rtems/rtems/status.h>
66#include <rtems/rtems/types.h>
68
69#ifdef __cplusplus
70extern "C" {
71#endif
72
73/* Generated from spec:/rtems/clock/if/group */
74
84/* Generated from spec:/rtems/clock/if/bintime */
85
86/* Forward declaration */
87struct bintime;
88
89/* Generated from spec:/rtems/clock/if/set */
90
155
156/* Generated from spec:/rtems/clock/if/get-tod */
157
187
188/* Generated from spec:/rtems/clock/if/get-tod-timeval */
189
219rtems_status_code rtems_clock_get_tod_timeval( struct timeval *time_of_day );
220
221/* Generated from spec:/rtems/clock/if/get-realtime */
222
256void rtems_clock_get_realtime( struct timespec *time_snapshot );
257
258/* Generated from spec:/rtems/clock/if/get-realtime-bintime */
259
293void rtems_clock_get_realtime_bintime( struct bintime *time_snapshot );
294
295/* Generated from spec:/rtems/clock/if/get-realtime-timeval */
296
330void rtems_clock_get_realtime_timeval( struct timeval *time_snapshot );
331
332/* Generated from spec:/rtems/clock/if/get-realtime-coarse */
333
368void rtems_clock_get_realtime_coarse( struct timespec *time_snapshot );
369
370/* Generated from spec:/rtems/clock/if/get-realtime-coarse-bintime */
371
406void rtems_clock_get_realtime_coarse_bintime( struct bintime *time_snapshot );
407
408/* Generated from spec:/rtems/clock/if/get-realtime-coarse-timeval */
409
444void rtems_clock_get_realtime_coarse_timeval( struct timeval *time_snapshot );
445
446/* Generated from spec:/rtems/clock/if/get-monotonic */
447
483void rtems_clock_get_monotonic( struct timespec *time_snapshot );
484
485/* Generated from spec:/rtems/clock/if/get-monotonic-bintime */
486
521void rtems_clock_get_monotonic_bintime( struct bintime *time_snapshot );
522
523/* Generated from spec:/rtems/clock/if/get-monotonic-sbintime */
524
556
557/* Generated from spec:/rtems/clock/if/get-monotonic-timeval */
558
593void rtems_clock_get_monotonic_timeval( struct timeval *time_snapshot );
594
595/* Generated from spec:/rtems/clock/if/get-monotonic-coarse */
596
633void rtems_clock_get_monotonic_coarse( struct timespec *time_snapshot );
634
635/* Generated from spec:/rtems/clock/if/get-monotonic-coarse-bintime */
636
673void rtems_clock_get_monotonic_coarse_bintime( struct bintime *time_snapshot );
674
675/* Generated from spec:/rtems/clock/if/get-monotonic-coarse-timeval */
676
713void rtems_clock_get_monotonic_coarse_timeval( struct timeval *time_snapshot );
714
715/* Generated from spec:/rtems/clock/if/get-boot-time */
716
744void rtems_clock_get_boot_time( struct timespec *boot_time );
745
746/* Generated from spec:/rtems/clock/if/get-boot-time-bintime */
747
775void rtems_clock_get_boot_time_bintime( struct bintime *boot_time );
776
777/* Generated from spec:/rtems/clock/if/get-boot-time-timeval */
778
806void rtems_clock_get_boot_time_timeval( struct timeval *boot_time );
807
808/* Generated from spec:/rtems/clock/if/get-seconds-since-epoch */
809
841 rtems_interval *seconds_since_rtems_epoch
842);
843
844/* Generated from spec:/rtems/clock/if/get-ticks-per-second */
845
869
870/* Generated from spec:/rtems/clock/if/get-ticks-per-second-macro */
871#define rtems_clock_get_ticks_per_second() _Watchdog_Ticks_per_second
872
873/* Generated from spec:/rtems/clock/if/get-ticks-since-boot */
874
900
901/* Generated from spec:/rtems/clock/if/get-ticks-since-boot-macro */
902#define rtems_clock_get_ticks_since_boot() _Watchdog_Ticks_since_boot
903
904/* Generated from spec:/rtems/clock/if/get-uptime */
905
932rtems_status_code rtems_clock_get_uptime( struct timespec *uptime );
933
934/* Generated from spec:/rtems/clock/if/get-uptime-timeval */
935
959void rtems_clock_get_uptime_timeval( struct timeval *uptime );
960
961/* Generated from spec:/rtems/clock/if/get-uptime-seconds */
962
984time_t rtems_clock_get_uptime_seconds( void );
985
986/* Generated from spec:/rtems/clock/if/get-uptime-nanoseconds */
987
1009uint64_t rtems_clock_get_uptime_nanoseconds( void );
1010
1011/* Generated from spec:/rtems/clock/if/tick-later */
1012
1035static inline rtems_interval rtems_clock_tick_later( rtems_interval delta )
1036{
1037 return _Watchdog_Ticks_since_boot + delta;
1038}
1039
1040/* Generated from spec:/rtems/clock/if/tick-later-usec */
1041
1064static inline rtems_interval rtems_clock_tick_later_usec(
1065 rtems_interval delta_in_usec
1066)
1067{
1068 rtems_interval us_per_tick;
1069
1071
1072 /*
1073 * Add one additional tick, since we do not know the time to the clock
1074 * next tick.
1075 */
1077 + ( delta_in_usec + us_per_tick - 1 ) / us_per_tick;
1078}
1079
1080/* Generated from spec:/rtems/clock/if/tick-before */
1081
1125static inline bool rtems_clock_tick_before( rtems_interval ticks )
1126{
1127 return (int32_t) ( ticks - _Watchdog_Ticks_since_boot ) > 0;
1128}
1129
1130/* Generated from spec:/rtems/clock/if/tick */
1131
1152
1153#ifdef __cplusplus
1154}
1155#endif
1156
1157#endif /* _RTEMS_RTEMS_CLOCK_H */
rtems_status_code rtems_clock_tick(void)
Announces a clock tick.
Definition: clocktick.c:46
This header file provides types used by the Classic API.
void rtems_clock_get_realtime_coarse_timeval(struct timeval *time_snapshot)
Gets the time elapsed since the Unix epoch measured using CLOCK_REALTIME in coarse resolution in seco...
uint64_t rtems_clock_get_uptime_nanoseconds(void)
Gets the nanoseconds elapsed since some time point during the system initialization using CLOCK_MONOT...
Definition: clockgetuptimenanoseconds.c:45
void rtems_clock_get_boot_time_timeval(struct timeval *boot_time)
Gets the time elapsed since the Unix epoch at some time point during system initialization in seconds...
void rtems_clock_get_realtime_timeval(struct timeval *time_snapshot)
Gets the time elapsed since the Unix epoch measured using CLOCK_REALTIME in seconds and microseconds ...
rtems_status_code rtems_clock_get_tod_timeval(struct timeval *time_of_day)
Gets the seconds and microseconds elapsed since the Unix epoch and the current CLOCK_REALTIME.
Definition: clockgettodtimeval.c:45
#define rtems_clock_get_ticks_per_second()
Gets the number of clock ticks per second configured for the application.
Definition: clock.h:871
rtems_status_code rtems_clock_get_seconds_since_epoch(rtems_interval *seconds_since_rtems_epoch)
Gets the seconds elapsed since the RTEMS epoch and the current CLOCK_REALTIME.
Definition: clockgetsecondssinceepoch.c:45
time_t rtems_clock_get_uptime_seconds(void)
Gets the seconds elapsed since some time point during the system initialization using CLOCK_MONOTONIC...
Definition: clockgetuptimeseconds.c:25
void rtems_clock_get_uptime_timeval(struct timeval *uptime)
Gets the seconds and microseconds elapsed since some time point during the system initialization usin...
Definition: clockgetuptimetimeval.c:45
void rtems_clock_get_boot_time_bintime(struct bintime *boot_time)
Gets the time elapsed since the Unix epoch at some time point during system initialization in binary ...
void rtems_clock_get_boot_time(struct timespec *boot_time)
Gets the time elapsed since the Unix epoch at some time point during system initialization in seconds...
rtems_status_code rtems_clock_get_uptime(struct timespec *uptime)
Gets the seconds and nanoseconds elapsed since some time point during the system initialization using...
Definition: clockgetuptime.c:59
int64_t rtems_clock_get_monotonic_sbintime(void)
Gets the time elapsed since some fixed time point in the past measured using the CLOCK_MONOTONIC in s...
void rtems_clock_get_monotonic_timeval(struct timeval *time_snapshot)
Gets the time elapsed since some fixed time point in the past measured using the CLOCK_MONOTONIC in s...
void rtems_clock_get_monotonic_bintime(struct bintime *time_snapshot)
Gets the time elapsed since some fixed time point in the past measured using the CLOCK_MONOTONIC in b...
void rtems_clock_get_realtime_bintime(struct bintime *time_snapshot)
Gets the time elapsed since the Unix epoch measured using CLOCK_REALTIME in binary time format.
void rtems_clock_get_realtime_coarse(struct timespec *time_snapshot)
Gets the time elapsed since the Unix epoch measured using CLOCK_REALTIME in coarse resolution in seco...
void rtems_clock_get_realtime(struct timespec *time_snapshot)
Gets the time elapsed since the Unix epoch measured using CLOCK_REALTIME in seconds and nanoseconds f...
void rtems_clock_get_monotonic_coarse_bintime(struct bintime *time_snapshot)
Gets the time elapsed since some fixed time point in the past measured using the CLOCK_MONOTONIC in c...
rtems_status_code rtems_clock_get_tod(rtems_time_of_day *time_of_day)
Gets the time of day associated with the current CLOCK_REALTIME.
Definition: clockgettod.c:102
void rtems_clock_get_monotonic_coarse_timeval(struct timeval *time_snapshot)
Gets the time elapsed since some fixed time point in the past measured using the CLOCK_MONOTONIC in c...
void rtems_clock_get_monotonic(struct timespec *time_snapshot)
Gets the time elapsed since some fixed time point in the past measured using the CLOCK_MONOTONIC in s...
#define rtems_clock_get_ticks_since_boot()
Gets the number of clock ticks since some time point during the system initialization or the last ove...
Definition: clock.h:902
rtems_status_code rtems_clock_set(const rtems_time_of_day *time_of_day)
Sets the CLOCK_REALTIME to the time of day.
Definition: clockset.c:47
void rtems_clock_get_monotonic_coarse(struct timespec *time_snapshot)
Gets the time elapsed since some fixed time point in the past measured using the CLOCK_MONOTONIC in c...
void rtems_clock_get_realtime_coarse_bintime(struct bintime *time_snapshot)
Gets the time elapsed since the Unix epoch measured using CLOCK_REALTIME in coarse resolution in bina...
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:85
Watchdog_Interval rtems_interval
This type represents clock tick intervals.
Definition: types.h:114
#define rtems_configuration_get_microseconds_per_tick()
Gets the number of microseconds per clock tick configured for this application.
Definition: config.h:527
volatile Watchdog_Interval _Watchdog_Ticks_since_boot
The watchdog ticks counter.
Definition: watchdogtickssinceboot.c:50
This header file provides the status codes of Classic API directives and support functions.
This type represents Classic API calendar times.
Definition: types.h:266
This header file provides the interfaces of the Watchdog Handler related to watchdog ticks which are ...