RTEMS
6.3
Toggle main menu visibility
Loading...
Searching...
No Matches
cpukit
include
rtems
posix
barrierimpl.h
Go to the documentation of this file.
1
/* SPDX-License-Identifier: BSD-2-Clause */
2
11
12
/*
13
* COPYRIGHT (c) 1989-2011.
14
* On-Line Applications Research Corporation (OAR).
15
*
16
* Copyright (c) 2017 embedded brains GmbH & Co. KG
17
*
18
* Redistribution and use in source and binary forms, with or without
19
* modification, are permitted provided that the following conditions
20
* are met:
21
* 1. Redistributions of source code must retain the above copyright
22
* notice, this list of conditions and the following disclaimer.
23
* 2. Redistributions in binary form must reproduce the above copyright
24
* notice, this list of conditions and the following disclaimer in the
25
* documentation and/or other materials provided with the distribution.
26
*
27
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37
* POSSIBILITY OF SUCH DAMAGE.
38
*/
39
40
#ifndef _RTEMS_POSIX_BARRIERIMPL_H
41
#define _RTEMS_POSIX_BARRIERIMPL_H
42
43
#include <errno.h>
44
#include <
pthread.h
>
45
46
#include <
rtems/score/percpu.h
>
47
#include <
rtems/score/threadqimpl.h
>
48
49
#ifdef __cplusplus
50
extern
"C"
{
51
#endif
52
53
#define POSIX_BARRIER_MAGIC 0x1cf03773UL
54
55
#define POSIX_BARRIER_TQ_OPERATIONS &_Thread_queue_Operations_FIFO
56
57
typedef
struct
{
58
unsigned
long
flags;
59
Thread_queue_Syslock_queue
Queue;
60
unsigned
int
count;
61
unsigned
int
waiting_threads;
62
}
POSIX_Barrier_Control
;
63
64
static
inline
POSIX_Barrier_Control
*_POSIX_Barrier_Get(
65
pthread_barrier_t *_barrier
66
)
67
{
68
return
(
POSIX_Barrier_Control
*) _barrier;
69
}
70
71
static
inline
Thread_Control *_POSIX_Barrier_Queue_acquire(
72
POSIX_Barrier_Control
*barrier,
73
Thread_queue_Context
*queue_context
74
)
75
{
76
ISR_Level
level;
77
Thread_Control *executing;
78
79
_Thread_queue_Context_initialize( queue_context );
80
_Thread_queue_Context_ISR_disable( queue_context, level );
81
_Thread_queue_Context_set_ISR_level( queue_context, level );
82
executing = _Thread_Executing;
83
_Thread_queue_Queue_acquire_critical(
84
&barrier->Queue.Queue,
85
&executing->Potpourri_stats,
86
&queue_context->
Lock_context
.
Lock_context
87
);
88
89
return
executing;
90
}
91
92
static
inline
void
_POSIX_Barrier_Queue_release(
93
POSIX_Barrier_Control
*barrier,
94
Thread_queue_Context
*queue_context
95
)
96
{
97
_Thread_queue_Queue_release(
98
&barrier->Queue.Queue,
99
&queue_context->
Lock_context
.
Lock_context
100
);
101
}
102
103
#define POSIX_BARRIER_VALIDATE_OBJECT( bar ) \
104
do { \
105
if ( \
106
( bar ) == NULL \
107
|| ( (uintptr_t) ( bar ) ^ POSIX_BARRIER_MAGIC ) != ( bar )->_flags \
108
) { \
109
return EINVAL; \
110
} \
111
} while ( 0 )
112
113
#ifdef __cplusplus
114
}
115
#endif
116
117
#endif
118
/* end of include file */
ISR_Level
uint32_t ISR_Level
Definition
isrlevel.h:60
pthread.h
POSIX Threads Private Support.
percpu.h
This header file provides the interfaces of the Per-CPU Information.
POSIX_Barrier_Control
Definition
barrierimpl.h:57
Thread_queue_Context
Thread queue context for the thread queue methods.
Definition
threadq.h:216
Thread_queue_Context::Lock_context
Thread_queue_Lock_context Lock_context
The lock context for the thread queue acquire and release operations.
Definition
threadq.h:221
Thread_queue_Lock_context::Lock_context
ISR_lock_Context Lock_context
The lock context for the thread queue acquire and release operations.
Definition
threadq.h:148
Thread_queue_Syslock_queue
Thread queue with a layout compatible to struct _Thread_queue_Queue defined in Newlib <sys/lock....
Definition
threadqimpl.h:71
threadqimpl.h
This header file provides interfaces of the Thread Queue Handler which are only used by the implement...
Generated by
1.18.0