source: rtems/cpukit/include/rtems/rtems/modesimpl.h @ a660e9dc

Last change on this file since a660e9dc was a660e9dc, checked in by Sebastian Huber <sebastian.huber@…>, on 09/08/22 at 08:37:05

Do not use RTEMS_INLINE_ROUTINE

Directly use "static inline" which is available in C99 and later. This brings
the RTEMS implementation closer to standard C.

Close #3935.

  • Property mode set to 100644
File size: 5.1 KB
Line 
1/* SPDX-License-Identifier: BSD-2-Clause */
2
3/**
4 * @file
5 *
6 * @ingroup RTEMSImplClassicModes
7 *
8 * @brief This header file provides the implementation interfaces of
9 *   the @ref RTEMSImplClassicModes support.
10 */
11
12/*  COPYRIGHT (c) 1989-2008.
13 *  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#ifndef _RTEMS_RTEMS_MODESIMPL_H
38#define _RTEMS_RTEMS_MODESIMPL_H
39
40#include <rtems/rtems/modes.h>
41#include <rtems/score/schedulerimpl.h>
42#include <rtems/score/smpimpl.h>
43#include <rtems/score/threadimpl.h>
44#include <rtems/score/threadcpubudget.h>
45#include <rtems/config.h>
46
47#ifdef __cplusplus
48extern "C" {
49#endif
50
51/**
52 * @defgroup RTEMSImplClassicModes Task Modes
53 *
54 * @ingroup RTEMSImplClassic
55 *
56 * @brief This group contains the implementation to support task modes.
57 *
58 * @{
59 */
60
61/**
62 *  @brief Checks if mode_set says that Asynchronous Signal Processing is disabled.
63 *
64 *  This function returns TRUE if mode_set indicates that Asynchronous
65 *  Signal Processing is disabled, and FALSE otherwise.
66 */
67static inline bool _Modes_Is_asr_disabled (
68  rtems_mode mode_set
69)
70{
71   return (mode_set & RTEMS_ASR_MASK) == RTEMS_NO_ASR;
72}
73
74/**
75 *  @brief Checks if mode_set indicates that preemption is enabled.
76 *
77 *  This function returns TRUE if mode_set indicates that preemption
78 *  is enabled, and FALSE otherwise.
79 */
80static inline bool _Modes_Is_preempt (
81  rtems_mode mode_set
82)
83{
84   return (mode_set & RTEMS_PREEMPT_MASK) == RTEMS_PREEMPT;
85}
86
87/**
88 *  @brief Checks if mode_set indicates that timeslicing is enabled.
89 *
90 *  This function returns TRUE if mode_set indicates that timeslicing
91 *  is enabled, and FALSE otherwise.
92 */
93static inline bool _Modes_Is_timeslice (
94  rtems_mode mode_set
95)
96{
97  return (mode_set & RTEMS_TIMESLICE_MASK) == RTEMS_TIMESLICE;
98}
99
100/**
101 *  @brief Gets the interrupt level portion of the mode_set.
102 *
103 *  This function returns the interrupt level portion of the mode_set.
104 */
105static inline ISR_Level _Modes_Get_interrupt_level (
106  rtems_mode mode_set
107)
108{
109  return ( mode_set & RTEMS_INTERRUPT_MASK );
110}
111
112#if defined(RTEMS_SMP) || CPU_ENABLE_ROBUST_THREAD_DISPATCH == TRUE
113/**
114 * @brief Checks if support for the interrupt level is implemented.
115 *
116 * @param mode_set is the mode set which specifies the interrupt level to
117 *   check.
118 *
119 * @return Returns true, if support for the interrupt level is implemented,
120 *   otherwise returns false.
121 */
122static inline bool _Modes_Is_interrupt_level_supported(
123  rtems_mode mode_set
124)
125{
126  return _Modes_Get_interrupt_level( mode_set ) == 0
127#if CPU_ENABLE_ROBUST_THREAD_DISPATCH == FALSE
128    || !_SMP_Need_inter_processor_interrupts()
129#endif
130    ;
131}
132#endif
133
134#if defined(RTEMS_SMP)
135/**
136 * @brief Checks if support for the preempt mode is implemented.
137 *
138 * @param mode_set is the mode set which specifies the preempt mode to check.
139 *
140 * @param the_thread is the thread to check.
141 *
142 * @return Returns true, if support for the preempt mode is implemented,
143 *   otherwise returns false.
144 */
145static inline bool _Modes_Is_preempt_mode_supported(
146  rtems_mode            mode_set,
147  const Thread_Control *the_thread
148)
149{
150  return _Modes_Is_preempt( mode_set ) ||
151    _Scheduler_Is_non_preempt_mode_supported(
152      _Thread_Scheduler_get_home( the_thread )
153    );
154}
155#endif
156
157/**
158 * @brief Applies the timeslice mode to the thread.
159 *
160 * @param mode_set is the mode set which specifies the timeslice mode for the
161 *   thread.
162 *
163 * @param[out] the_thread is the thread to apply the timeslice mode.
164 */
165static inline void _Modes_Apply_timeslice_to_thread(
166  rtems_mode      mode_set,
167  Thread_Control *the_thread
168)
169{
170  if ( _Modes_Is_timeslice( mode_set ) ) {
171    the_thread->CPU_budget.operations = &_Thread_CPU_budget_reset_timeslice;
172    the_thread->CPU_budget.available =
173      rtems_configuration_get_ticks_per_timeslice();
174  } else {
175    the_thread->CPU_budget.operations = NULL;
176  }
177}
178
179#ifdef __cplusplus
180}
181#endif
182
183/**@}*/
184
185#endif
186/* end of include file */
Note: See TracBrowser for help on using the repository browser.