RTEMS
tc-attr.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 
9 /*
10  * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  * notice, this list of conditions and the following disclaimer.
17  * 2. Redistributions in binary form must reproduce the above copyright
18  * notice, this list of conditions and the following disclaimer in the
19  * documentation and/or other materials provided with the distribution.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 /*
35  * Do not manually edit this file. It is part of the RTEMS quality process
36  * and was automatically generated.
37  *
38  * If you find something that needs to be fixed or worded better please
39  * post a report to an RTEMS mailing list or raise a bug report:
40  *
41  * https://docs.rtems.org/branches/master/user/support/bugs.html
42  *
43  * For information on updating and regenerating please refer to:
44  *
45  * https://docs.rtems.org/branches/master/eng/req/howto.html
46  */
47 
48 #ifdef HAVE_CONFIG_H
49 #include "config.h"
50 #endif
51 
52 #include <rtems.h>
53 
54 #include <rtems/test.h>
55 
125 static bool IsPowerOfTwo( rtems_attribute attribute )
126 {
127  return attribute != 0 && ( attribute & ( attribute - 1 ) ) == 0;
128 }
129 
130 static int PopCount( rtems_attribute attributes )
131 {
132  int count;
133 
134  count = 0;
135 
136  while ( attributes != 0 ) {
137  ++count;
138  attributes &= attributes - 1;
139  }
140 
141  return count;
142 }
143 
147 T_TEST_CASE( RtemsAttrValAttr )
148 {
149  rtems_attribute attributes;
150 
151  T_plan(22);
152 
153  /* No action */
154  T_step_true( 0, IsPowerOfTwo( RTEMS_BARRIER_AUTOMATIC_RELEASE ) );
155  T_step_true( 1, IsPowerOfTwo( RTEMS_BINARY_SEMAPHORE ) );
156  T_step_true( 2, IsPowerOfTwo( RTEMS_FLOATING_POINT ) );
157  T_step_true( 3, IsPowerOfTwo( RTEMS_GLOBAL ) );
158  T_step_true( 4, IsPowerOfTwo( RTEMS_INHERIT_PRIORITY ) );
159  T_step_true(
160  5,
162  );
163  T_step_true( 6, IsPowerOfTwo( RTEMS_PRIORITY ) );
164  T_step_true( 7, IsPowerOfTwo( RTEMS_PRIORITY_CEILING ) );
165  T_step_true( 8, IsPowerOfTwo( RTEMS_SIMPLE_BINARY_SEMAPHORE ) );
166  T_step_true( 9, IsPowerOfTwo( RTEMS_SYSTEM_TASK ) );
167 
168  /* No action */
169  T_step_eq_u32( 10, RTEMS_APPLICATION_TASK, 0 );
170  T_step_eq_u32( 11, RTEMS_BARRIER_MANUAL_RELEASE, 0 );
171  T_step_eq_u32( 12, RTEMS_COUNTING_SEMAPHORE, 0 );
172  T_step_eq_u32( 13, RTEMS_DEFAULT_ATTRIBUTES, 0 );
173  T_step_eq_u32( 14, RTEMS_FIFO, 0 );
174  T_step_eq_u32( 15, RTEMS_LOCAL, 0 );
175  T_step_eq_u32( 16, RTEMS_NO_FLOATING_POINT, 0 );
176  T_step_eq_u32( 17, RTEMS_NO_INHERIT_PRIORITY, 0 );
177  T_step_eq_u32( 18, RTEMS_NO_MULTIPROCESSOR_RESOURCE_SHARING, 0 );
178  T_step_eq_u32( 19, RTEMS_NO_PRIORITY_CEILING, 0 );
179 
180  attributes = 0;
181  attributes |= RTEMS_BARRIER_AUTOMATIC_RELEASE;
182  attributes |= RTEMS_BINARY_SEMAPHORE;
183  attributes |= RTEMS_FLOATING_POINT;
184  attributes |= RTEMS_GLOBAL;
185  attributes |= RTEMS_INHERIT_PRIORITY;
187  attributes |= RTEMS_PRIORITY;
188  attributes |= RTEMS_PRIORITY_CEILING;
189  attributes |= RTEMS_SEMAPHORE_CLASS;
190  attributes |= RTEMS_SIMPLE_BINARY_SEMAPHORE;
191  attributes |= RTEMS_SYSTEM_TASK;
192  T_step_eq_int( 20, PopCount( attributes ), 10 );
193 
194  attributes = 0;
195  attributes |= RTEMS_BINARY_SEMAPHORE;
196  attributes |= RTEMS_COUNTING_SEMAPHORE;
197  attributes |= RTEMS_SIMPLE_BINARY_SEMAPHORE;
198  T_step_eq_u32( 21, RTEMS_SEMAPHORE_CLASS, attributes );
199 }
200 
#define RTEMS_BARRIER_MANUAL_RELEASE
This attribute constant indicates that the Classic API Barrier object shall use the manual release pr...
Definition: attr.h:111
#define RTEMS_INHERIT_PRIORITY
This attribute constant indicates that the Classic API Semaphore object shall use the Priority Inheri...
Definition: attr.h:185
#define RTEMS_LOCAL
This attribute constant indicates that the Classic API object shall be a local resource in a multipro...
Definition: attr.h:195
#define RTEMS_DEFAULT_ATTRIBUTES
This is the default value for an attribute set.
Definition: attr.h:140
#define RTEMS_SYSTEM_TASK
This attribute constant is used to indicate that the Classic API Task object shall be a system task...
Definition: attr.h:302
#define RTEMS_MULTIPROCESSOR_RESOURCE_SHARING
This attribute constant indicates that the Classic API Semaphore object shall use the Multiprocessor ...
Definition: attr.h:207
#define RTEMS_COUNTING_SEMAPHORE
This attribute constant indicates that the Classic API Semaphore object shall be a counting semaphore...
Definition: attr.h:131
#define RTEMS_PRIORITY
This attribute constant indicates that the Classic API object shall manage blocking tasks using the t...
Definition: attr.h:260
#define RTEMS_SIMPLE_BINARY_SEMAPHORE
This attribute constant indicates that the Classic API Semaphore object shall be a simple binary sema...
Definition: attr.h:292
#define RTEMS_NO_PRIORITY_CEILING
This attribute constant indicates that the Classic API Semaphore object will not use the Priority Cei...
Definition: attr.h:250
#define RTEMS_BINARY_SEMAPHORE
This attribute constant indicates that the Classic API Semaphore object shall be a proper binary sema...
Definition: attr.h:121
#define RTEMS_NO_INHERIT_PRIORITY
This attribute constant indicates that the Classic API Semaphore object will not use the Priority Inh...
Definition: attr.h:230
#define RTEMS_FLOATING_POINT
This attribute constant indicates that the task shall be able to use the floating point hardware...
Definition: attr.h:163
#define RTEMS_SEMAPHORE_CLASS
This is the mask for the attribute bits associated with the Classic API Semaphore Manager...
Definition: attr.h:282
This header file defines the RTEMS Classic API.
uint32_t rtems_attribute
This type is used to represent Classic API attributes.
Definition: attr.h:91
#define RTEMS_PRIORITY_CEILING
This attribute constant indicates that the Classic API Semaphore object shall use the Priority Ceilin...
Definition: attr.h:272
#define RTEMS_NO_FLOATING_POINT
This attribute constant indicates that the task will not use the floating point hardware.
Definition: attr.h:220
#define RTEMS_BARRIER_AUTOMATIC_RELEASE
This attribute constant indicates that a Classic API Barrier object shall use the automatic release p...
Definition: attr.h:101
#define RTEMS_APPLICATION_TASK
This attribute constant is used to indicate that the Classic API Task object shall be an application ...
Definition: attr.h:80
#define RTEMS_GLOBAL
This attribute constant indicates that the Classic API object shall be a global resource in a multipr...
Definition: attr.h:173
#define RTEMS_NO_MULTIPROCESSOR_RESOURCE_SHARING
This attribute constant indicates that the Classic API Semaphore object will not use the Multiprocess...
Definition: attr.h:240
#define RTEMS_FIFO
This attribute constant indicates that the Classic API object shall manage blocking tasks using the F...
Definition: attr.h:150