Rephrase error message in infcall.c:call_function_by_hand
[deliverable/binutils-gdb.git] / gdb / osf-share / cma_mutex.h
CommitLineData
c906108c
SS
1/*
2 * (c) Copyright 1990-1996 OPEN SOFTWARE FOUNDATION, INC.
3 * (c) Copyright 1990-1996 HEWLETT-PACKARD COMPANY
4 * (c) Copyright 1990-1996 DIGITAL EQUIPMENT CORPORATION
5 * (c) Copyright 1991, 1992 Siemens-Nixdorf Information Systems
6 * To anyone who acknowledges that this file is provided "AS IS" without
7 * any express or implied warranty: permission to use, copy, modify, and
8 * distribute this file for any purpose is hereby granted without fee,
9 * provided that the above copyright notices and this notice appears in
10 * all source code copies, and that none of the names listed above be used
11 * in advertising or publicity pertaining to distribution of the software
12 * without specific, written prior permission. None of these organizations
13 * makes any representations about the suitability of this software for
14 * any purpose.
15 */
16/*
17 * Header file for mutex operations
18 */
19
20#ifndef CMA_MUTEX
21#define CMA_MUTEX
22
23/*
24 * INCLUDE FILES
25 */
26
27#include <cma.h>
28#include <cma_attr.h>
29#include <cma_defs.h>
30#include <cma_semaphore_defs.h>
31#include <cma_sequence.h>
32#include <cma_tcb_defs.h>
33#include <cma_stack.h>
34
35/*
36 * CONSTANTS AND MACROS
37 */
38
39/*
40 * TYPEDEFS
41 */
42
43typedef struct CMA__T_INT_MUTEX {
44 cma__t_object header; /* Common header (sequence, type) */
45 cma__t_int_attr *attributes; /* Back link */
46 cma__t_int_tcb *owner; /* Current owner (if any) */
47 cma_t_integer nest_count; /* Nesting level for recursive mutex */
48 cma__t_atomic_bit *unlock; /* Pointer used for unlock operation */
49 cma__t_atomic_bit lock; /* Set if currently locked */
50 struct CMA__T_INT_MUTEX *int_lock; /* Internal protection for mutex */
51 cma__t_atomic_bit event; /* Clear when unlock requires action */
52 cma__t_atomic_bit waiters; /* Clear when threads are waiting */
9a2b4c1b
MS
53 cma__t_atomic_bit bitbucket; /* Fake bit to keep friendlies
54 locked */
c906108c
SS
55 cma_t_mutex_kind mutex_kind; /* Kind of mutex */
56 cma__t_semaphore semaphore; /* Semaphore for low-level wait */
57 } cma__t_int_mutex;
58
59\f
60/*
61 * FUNCTIONAL DESCRIPTION:
62 *
63 * Lock a mutex (internal)
64 *
65 * FORMAL PARAMETERS:
66 *
67 * mutex Pointer to mutex object to lock
68 *
69 * IMPLICIT INPUTS:
70 *
71 * none
72 *
73 * IMPLICIT OUTPUTS:
74 *
75 * none
76 *
77 * FUNCTION VALUE:
78 *
79 * none
80 *
81 * SIDE EFFECTS:
82 *
83 * none
84 */
85#ifdef NDEBUG
86# define cma__int_lock(mutex) { \
87 if (cma__test_and_set (&((cma__t_int_mutex *)mutex)->lock)) { \
88 cma_t_status res;\
89 res = cma__int_mutex_block ((cma__t_int_mutex *)mutex); \
90 if (res != cma_s_normal) cma__error (res); \
91 } \
92 }
93#else
94# define cma__int_lock(mutex) { \
95 cma__t_int_tcb *__ltcb__; \
96 __ltcb__ = cma__get_self_tcb (); \
97 if (cma__test_and_set (&((cma__t_int_mutex *)mutex)->lock)) { \
98 cma_t_status res;\
99 res = cma__int_mutex_block ((cma__t_int_mutex *)mutex); \
100 if (res != cma_s_normal) cma__error (res); \
101 } \
102 ((cma__t_int_mutex *)mutex)->owner = __ltcb__; \
103 }
104#endif
105\f
106/*
107 * FUNCTIONAL DESCRIPTION:
108 *
109 * Unlock a mutex (internal)
110 *
111 * FORMAL PARAMETERS:
112 *
113 * mutex Pointer to mutex object to unlock
114 *
115 * IMPLICIT INPUTS:
116 *
117 * none
118 *
119 * IMPLICIT OUTPUTS:
120 *
121 * none
122 *
123 * FUNCTION VALUE:
124 *
125 * none
126 *
127 * SIDE EFFECTS:
128 *
129 * none
130 */
131#ifdef NDEBUG
132# define cma__int_unlock(mutex) { \
133 cma__unset (((cma__t_int_mutex *)mutex)->unlock); \
134 if (!cma__test_and_set (&((cma__t_int_mutex *)mutex)->event)) { \
135 cma_t_status res;\
136 res = cma__int_mutex_unblock ((cma__t_int_mutex *)mutex); \
137 if (res != cma_s_normal) cma__error (res); \
138 } \
139 }
140#else
141# define cma__int_unlock(mutex) { \
142 cma__t_int_tcb *__utcb__; \
143 __utcb__ = cma__get_self_tcb (); \
144 if (((cma__t_int_mutex *)mutex)->mutex_kind == cma_c_mutex_fast) { \
145 cma__assert_warn ( \
146 (__utcb__ == ((cma__t_int_mutex *)mutex)->owner), \
147 "attempt to release mutx owned by another thread"); \
9a2b4c1b
MS
148 ((cma__t_int_mutex *) mutex)->owner \
149 = (cma__t_int_tcb *)cma_c_null_ptr; \
c906108c
SS
150 } \
151 cma__unset (((cma__t_int_mutex *)mutex)->unlock); \
152 if (!cma__test_and_set (&((cma__t_int_mutex *)mutex)->event)) { \
153 cma_t_status res;\
154 res = cma__int_mutex_unblock ((cma__t_int_mutex *)mutex); \
155 if (res != cma_s_normal) cma__error (res); \
156 } \
157 }
158#endif
159\f
160/*
161 * FUNCTIONAL DESCRIPTION:
162 *
163 * cma__int_mutex_delete - Performs work for cma_mutex_delete
164 *
165 * FORMAL PARAMETERS:
166 *
167 * cma__t_mutex _mutex_ - Mutex to be deleted
168 *
169 * IMPLICIT INPUTS:
170 *
171 * none
172 *
173 * IMPLICIT OUTPUTS:
174 *
175 * none
176 *
177 * FUNCTION VALUE:
178 *
179 * none
180 *
181 * SIDE EFFECTS:
182 *
183 * none
184 */
185#define cma__int_mutex_delete(_mutex_) { \
186 cma__t_int_mutex *_int_mutex_; \
187 _int_mutex_ = cma__validate_null_mutex (_mutex_); \
188 if (_int_mutex_ == (cma__t_int_mutex *)cma_c_null_ptr) \
189 return; \
190 if (cma__int_mutex_locked (_int_mutex_)) \
191 cma__error (cma_s_in_use); \
192 cma__free_mutex (_int_mutex_); \
193 cma__clear_handle (_mutex_); \
194 }
195
196
197/*
198 * GLOBAL DATA
199 */
200
201extern cma__t_sequence cma__g_mutex_seq;
202extern cma__t_int_mutex *cma__g_global_lock;
203
204/*
205 * INTERNAL INTERFACES
206 */
207
208extern void cma__destroy_mutex (cma__t_int_mutex *);
209
210extern void cma__free_mutex (cma__t_int_mutex *);
211
212extern void cma__free_mutex_nolock (cma__t_int_mutex *);
213
214extern cma__t_int_mutex * cma__get_first_mutex (cma__t_int_attr *);
215
216extern cma__t_int_mutex * cma__get_mutex (cma__t_int_attr *);
217
218extern void cma__init_mutex (void);
219
220extern cma_t_status cma__int_mutex_block (cma__t_int_mutex *);
221
222extern cma_t_boolean cma__int_mutex_locked (cma__t_int_mutex *);
223
224extern cma_t_boolean cma__int_try_lock (cma__t_int_mutex *);
225
226extern cma_t_status cma__int_mutex_unblock (cma__t_int_mutex *);
227
228extern cma_t_boolean cma__mutex_locked (cma_t_mutex);
229
230extern void cma__reinit_mutex (cma_t_integer);
231
232#endif
This page took 1.03845 seconds and 4 git commands to generate.