RTEMS
tc-options.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 
89 static bool IsPowerOfTwo( rtems_option option )
90 {
91  return option != 0 && ( option & ( option - 1 ) ) == 0;
92 }
93 
94 static int PopCount( rtems_option options )
95 {
96  int count;
97 
98  count = 0;
99 
100  while ( options != 0 ) {
101  ++count;
102  options &= options - 1;
103  }
104 
105  return count;
106 }
107 
111 T_TEST_CASE( RtemsOptionValOptions )
112 {
113  rtems_option options;
114 
115  T_plan(6);
116 
117  /* No action */
118  T_step_true( 0, IsPowerOfTwo( RTEMS_EVENT_ANY ) );
119  T_step_true( 1, IsPowerOfTwo( RTEMS_NO_WAIT ) );
120 
121  /* No action */
122  T_step_eq_u32( 2, RTEMS_DEFAULT_OPTIONS, 0 );
123  T_step_eq_u32( 3, RTEMS_EVENT_ALL, 0 );
124  T_step_eq_u32( 4, RTEMS_WAIT, 0 );
125 
126  options = 0;
127  options |= RTEMS_EVENT_ANY;
128  options |= RTEMS_NO_WAIT;
129  T_step_eq_int( 5, PopCount( options ), 2 );
130 }
131 
#define RTEMS_NO_WAIT
This option constant indicates that the task does not want to wait on the resource.
Definition: options.h:112
#define RTEMS_DEFAULT_OPTIONS
This option constant is the default option set.
Definition: options.h:79
uint32_t rtems_option
This type is used to represent an option set.
Definition: options.h:121
#define RTEMS_EVENT_ANY
This option constant indicates that the task wishes to wait until at least one of the events of inter...
Definition: options.h:99
This header file defines the RTEMS Classic API.
#define RTEMS_WAIT
This option constant indicates that the task wants to wait on the resource.
Definition: options.h:134
#define RTEMS_EVENT_ALL
This option constant indicates that the task wishes to wait until all events of interest are availabl...
Definition: options.h:89