source: rtems/cpukit/include/rtems/posix/condimpl.h @ 21275b58

Last change on this file since 21275b58 was 2afb22b, checked in by Chris Johns <chrisj@…>, on Dec 23, 2017 at 7:18:56 AM

Remove make preinstall

A speciality of the RTEMS build system was the make preinstall step. It
copied header files from arbitrary locations into the build tree. The
header files were included via the -Bsome/build/tree/path GCC command
line option.

This has at least seven problems:

  • The make preinstall step itself needs time and disk space.
  • Errors in header files show up in the build tree copy. This makes it hard for editors to open the right file to fix the error.
  • There is no clear relationship between source and build tree header files. This makes an audit of the build process difficult.
  • The visibility of all header files in the build tree makes it difficult to enforce API barriers. For example it is discouraged to use BSP-specifics in the cpukit.
  • An introduction of a new build system is difficult.
  • Include paths specified by the -B option are system headers. This may suppress warnings.
  • The parallel build had sporadic failures on some hosts.

This patch removes the make preinstall step. All installed header
files are moved to dedicated include directories in the source tree.
Let @RTEMS_CPU@ be the target architecture, e.g. arm, powerpc, sparc,
etc. Let @RTEMS_BSP_FAMILIY@ be a BSP family base directory, e.g.
erc32, imx, qoriq, etc.

The new cpukit include directories are:

  • cpukit/include
  • cpukit/score/cpu/@RTEMS_CPU@/include
  • cpukit/libnetworking

The new BSP include directories are:

  • bsps/include
  • bsps/@RTEMS_CPU@/include
  • bsps/@RTEMS_CPU@/@RTEMS_BSP_FAMILIY@/include

There are build tree include directories for generated files.

The include directory order favours the most general header file, e.g.
it is not possible to override general header files via the include path
order.

The "bootstrap -p" option was removed. The new "bootstrap -H" option
should be used to regenerate the "headers.am" files.

Update #3254.

  • Property mode set to 100644
File size: 4.7 KB
Line 
1/**
2 * @file
3 *
4 * This include file contains the static inline implementation of the private
5 * inlined routines for POSIX condition variables.
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2013.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#ifndef _RTEMS_POSIX_CONDIMPL_H
18#define _RTEMS_POSIX_CONDIMPL_H
19
20#include <errno.h>
21#include <pthread.h>
22
23#include <rtems/score/percpu.h>
24#include <rtems/score/threadqimpl.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30typedef struct {
31  unsigned long flags;
32  Thread_queue_Syslock_queue Queue;
33  pthread_mutex_t *mutex;
34} POSIX_Condition_variables_Control;
35
36#define POSIX_CONDITION_VARIABLES_CLOCK_MONOTONIC 0x1UL
37
38#define POSIX_CONDITION_VARIABLES_FLAGS_MASK 0x1UL
39
40#define POSIX_CONDITION_VARIABLES_MAGIC 0x18dfb1feUL
41
42/**
43 *  Constant to indicate condition variable does not currently have
44 *  a mutex assigned to it.
45 */
46#define POSIX_CONDITION_VARIABLES_NO_MUTEX NULL
47
48#define POSIX_CONDITION_VARIABLES_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
49
50#define POSIX_CONDITION_VARIABLE_OF_THREAD_QUEUE_QUEUE( queue ) \
51  RTEMS_CONTAINER_OF( \
52    queue, POSIX_Condition_variables_Control, Queue.Queue )
53
54/**
55 *  The default condition variable attributes structure.
56 */
57extern const pthread_condattr_t _POSIX_Condition_variables_Default_attributes;
58
59static inline POSIX_Condition_variables_Control *_POSIX_Condition_variables_Get(
60  pthread_cond_t *cond
61)
62{
63  return (POSIX_Condition_variables_Control *) cond;
64}
65
66RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Initialize(
67  POSIX_Condition_variables_Control *the_cond,
68  const pthread_condattr_t          *the_attr
69)
70{
71  unsigned long flags;
72
73  _Thread_queue_Queue_initialize( &the_cond->Queue.Queue, NULL );
74  the_cond->mutex = POSIX_CONDITION_VARIABLES_NO_MUTEX;
75
76  flags = (uintptr_t) the_cond ^ POSIX_CONDITION_VARIABLES_MAGIC;
77  flags &= ~POSIX_CONDITION_VARIABLES_FLAGS_MASK;
78
79  if ( the_attr->clock == CLOCK_MONOTONIC ) {
80    flags |= POSIX_CONDITION_VARIABLES_CLOCK_MONOTONIC;
81  }
82
83  the_cond->flags = flags;
84}
85
86RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Destroy(
87  POSIX_Condition_variables_Control *the_cond
88)
89{
90  the_cond->flags = ~the_cond->flags;
91}
92
93RTEMS_INLINE_ROUTINE clockid_t _POSIX_Condition_variables_Get_clock(
94  unsigned long flags
95)
96{
97  if ( ( flags & POSIX_CONDITION_VARIABLES_CLOCK_MONOTONIC ) != 0 ) {
98    return CLOCK_MONOTONIC;
99  }
100
101  return CLOCK_REALTIME;
102}
103
104RTEMS_INLINE_ROUTINE Thread_Control *_POSIX_Condition_variables_Acquire(
105  POSIX_Condition_variables_Control *the_cond,
106  Thread_queue_Context              *queue_context
107)
108{
109  ISR_Level       level;
110  Thread_Control *executing;
111
112  _Thread_queue_Context_ISR_disable( queue_context, level );
113  _Thread_queue_Context_set_ISR_level( queue_context, level );
114  executing = _Thread_Executing;
115  _Thread_queue_Queue_acquire_critical(
116    &the_cond->Queue.Queue,
117    &executing->Potpourri_stats,
118    &queue_context->Lock_context.Lock_context
119  );
120
121  return executing;
122}
123
124RTEMS_INLINE_ROUTINE void _POSIX_Condition_variables_Release(
125  POSIX_Condition_variables_Control *the_cond,
126  Thread_queue_Context              *queue_context
127)
128{
129  _Thread_queue_Queue_release(
130    &the_cond->Queue.Queue,
131    &queue_context->Lock_context.Lock_context
132  );
133}
134
135/**
136 * @brief Implements wake up version of the "signal" operation.
137 *
138 * A support routine which implements guts of the broadcast and single task
139 * wake up version of the "signal" operation.
140 */
141int _POSIX_Condition_variables_Signal_support(
142  pthread_cond_t            *cond,
143  bool                       is_broadcast
144);
145
146/**
147 * @brief POSIX condition variables wait support.
148 *
149 * A support routine which implements guts of the blocking, non-blocking, and
150 * timed wait version of condition variable wait routines.
151 */
152int _POSIX_Condition_variables_Wait_support(
153  pthread_cond_t            *cond,
154  pthread_mutex_t           *mutex,
155  const struct timespec     *abstime
156);
157
158bool _POSIX_Condition_variables_Auto_initialization(
159  POSIX_Condition_variables_Control *the_cond
160);
161
162#define POSIX_CONDITION_VARIABLES_VALIDATE_OBJECT( the_cond, flags ) \
163  do { \
164    if ( ( the_cond ) == NULL ) { \
165      return EINVAL; \
166    } \
167    flags = ( the_cond )->flags; \
168    if ( \
169      ( ( (uintptr_t) ( the_cond ) ^ POSIX_CONDITION_VARIABLES_MAGIC ) \
170          & ~POSIX_CONDITION_VARIABLES_FLAGS_MASK ) \
171        != ( flags & ~POSIX_CONDITION_VARIABLES_FLAGS_MASK ) \
172    ) { \
173      if ( !_POSIX_Condition_variables_Auto_initialization( the_cond ) ) { \
174        return EINVAL; \
175      } \
176    } \
177  } while ( 0 )
178
179#ifdef __cplusplus
180}
181#endif
182
183#endif
184/*  end of include file */
Note: See TracBrowser for help on using the repository browser.