/[pkg-firebird]/upstream/current/src/jrd/isc.h
ViewVC logotype

Contents of /upstream/current/src/jrd/isc.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1141 - (show annotations) (download)
Sun Apr 1 15:48:28 2007 UTC (6 years, 1 month ago) by dmn
File MIME type: text/plain
File size: 7419 byte(s)
Import current upstream CVS
1 /*
2 * PROGRAM: JRD access method
3 * MODULE: isc.h
4 * DESCRIPTION: Common descriptions for general-purpose but non-user routines
5 *
6 * The contents of this file are subject to the Interbase Public
7 * License Version 1.0 (the "License"); you may not use this file
8 * except in compliance with the License. You may obtain a copy
9 * of the License at http://www.Inprise.com/IPL.html
10 *
11 * Software distributed under the License is distributed on an
12 * "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express
13 * or implied. See the License for the specific language governing
14 * rights and limitations under the License.
15 *
16 * The Original Code was created by Inprise Corporation
17 * and its predecessors. Portions created by Inprise Corporation are
18 * Copyright (C) Inprise Corporation.
19 *
20 * All Rights Reserved.
21 * Contributor(s): ______________________________________.
22 *
23 * 26-Sept-2001 Paul Beach - External File Directory Config. Parameter
24 * 17-Oct-2001 Mike Nordell - CPU affinity
25 * 2002.10.29 Sean Leyne - Removed obsolete "Netware" port
26 *
27 * 2002.10.30 Sean Leyne - Removed support for obsolete "PC_PLATFORM" define
28 *
29 */
30
31 #ifndef JRD_ISC_H
32 #define JRD_ISC_H
33
34 // For AST_THREAD
35 #include "../jrd/common.h"
36 #include "../jrd/sch_proto.h"
37
38 // For AstInhibit
39 #include "../jrd/os/isc_i_proto.h"
40
41 /* Defines for semaphore and shared memory removal */
42
43 const USHORT ISC_SEM_REMOVE = 1;
44 const USHORT ISC_MEM_REMOVE = 2; // tested but never set
45
46 // Firebird platform-specific synchronization data structures
47
48 #ifdef VMS
49 struct itm {
50 SSHORT itm_length;
51 SSHORT itm_code;
52 SCHAR *itm_buffer;
53 SSHORT *itm_return_length;
54 };
55
56 typedef itm ITM;
57
58 struct event_t {
59 SLONG event_pid;
60 SLONG event_count;
61 };
62
63 struct wait {
64 USHORT wait_count;
65 event_t* wait_events;
66 SLONG *wait_values;
67 };
68
69 typedef wait WAIT;
70
71 /* Lock status block */
72
73 struct lock_status {
74 SSHORT lksb_status;
75 SSHORT lksb_reserved;
76 SLONG lksb_lock_id;
77 SLONG lksb_value[4];
78 };
79
80 /* Poke block (for asynchronous poking) */
81
82 struct poke {
83 struct poke *poke_next;
84 lock_status poke_lksb;
85 SLONG poke_parent_id;
86 USHORT poke_value;
87 USHORT poke_use_count;
88 };
89
90 typedef poke* POKE;
91
92 #define SH_MEM_STRUCTURE_DEFINED
93 struct sh_mem {
94 int sh_mem_system_flag;
95 UCHAR *sh_mem_address;
96 SLONG sh_mem_length_mapped;
97 SLONG sh_mem_mutex_arg;
98 SLONG sh_mem_handle;
99 SLONG sh_mem_retadr[2];
100 SLONG sh_mem_channel;
101 TEXT sh_mem_filename[MAXPATHLEN];
102 };
103 typedef struct sh_mem SH_MEM_T;
104 typedef struct sh_mem* SH_MEM;
105 #endif // VMS
106
107
108 #ifdef UNIX
109 #define MTX_STRUCTURE_DEFINED
110
111 // This is the only place where COND_STRUCT and MUTEX_STRUCT are used.
112 // Therefore it's definitions were moved here from thd.h in order
113 // to avoid circular dependencies in h-files.
114 // Alex Peshkov. Tue 08 Jun 2004 02:22:08 PM MSD.
115
116 #if defined(SOLARIS_MT)
117 #include <thread.h>
118 #define COND_STRUCT cond_t
119 #define MUTEX_STRUCT mutex_t
120 #endif
121
122 #ifdef USE_POSIX_THREADS
123 #include <pthread.h>
124 #define COND_STRUCT pthread_cond_t
125 #define MUTEX_STRUCT pthread_mutex_t
126 #endif
127
128 #ifndef COND_STRUCT
129 #define COND_STRUCT SCHAR
130 #endif
131 #ifndef MUTEX_STRUCT
132 #define MUTEX_STRUCT SCHAR
133 #endif
134
135 #ifdef MULTI_THREAD
136 struct mtx {
137 MUTEX_STRUCT mtx_mutex[1];
138 };
139 typedef mtx MTX_T;
140 typedef mtx* MTX;
141 #else
142 struct mtx {
143 SLONG mtx_semid;
144 SSHORT mtx_semnum;
145 SCHAR mtx_use_count;
146 SCHAR mtx_wait;
147 };
148 typedef mtx MTX_T;
149 typedef mtx* MTX;
150 #endif // MULTI_THREAD
151
152 #ifdef MULTI_THREAD
153 struct event_t
154 {
155 SLONG event_semid;
156 SLONG event_count;
157 MUTEX_STRUCT event_mutex[1];
158 COND_STRUCT event_semnum[1];
159 };
160 #else
161 struct event_t
162 {
163 SLONG event_semid;
164 SLONG event_count;
165 SSHORT event_semnum;
166 };
167 #endif // MULTI_THREAD
168
169
170 #define SH_MEM_STRUCTURE_DEFINED
171 struct sh_mem
172 {
173 int sh_mem_semaphores;
174 UCHAR *sh_mem_address;
175 SLONG sh_mem_length_mapped;
176 SLONG sh_mem_mutex_arg;
177 SLONG sh_mem_handle;
178 };
179 typedef sh_mem SH_MEM_T;
180 typedef sh_mem *SH_MEM;
181 #endif // UNIX
182
183
184 #ifdef WIN_NT
185 #define MTX_STRUCTURE_DEFINED
186
187 #include <windows.h>
188
189 typedef struct _FAST_MUTEX_SHARED_SECTION
190 {
191 SLONG fInitialized;
192 SLONG lSpinLock;
193 SLONG lThreadsWaiting;
194 SLONG lAvailable;
195 #ifdef _DEBUG
196 DWORD dwThreadId;
197 #endif
198 } FAST_MUTEX_SHARED_SECTION;
199
200 typedef struct _FAST_MUTEX
201 {
202 HANDLE hEvent;
203 HANDLE hFileMap;
204 ULONG lSpinCount;
205 volatile FAST_MUTEX_SHARED_SECTION* lpSharedInfo;
206 } FAST_MUTEX;
207
208 struct mtx
209 {
210 FAST_MUTEX mtx_fast;
211 };
212
213 typedef mtx MTX_T;
214 typedef mtx *MTX;
215
216 struct event_t
217 {
218 SLONG event_pid;
219 SLONG event_count;
220 SLONG event_type;
221 void* event_handle;
222 event_t* event_shared;
223 };
224
225 #define SH_MEM_STRUCTURE_DEFINED
226 struct sh_mem
227 {
228 UCHAR* sh_mem_address;
229 SLONG sh_mem_length_mapped;
230 SLONG sh_mem_mutex_arg;
231 void* sh_mem_handle;
232 void* sh_mem_object;
233 void* sh_mem_interest;
234 void* sh_mem_hdr_object;
235 SLONG* sh_mem_hdr_address;
236 TEXT sh_mem_name[MAXPATHLEN];
237 };
238 typedef sh_mem SH_MEM_T;
239 typedef sh_mem *SH_MEM;
240 #define THREAD_HANDLE_DEFINED
241 typedef void *THD_T;
242 #endif // WIN_NT
243
244
245 #ifndef MTX_STRUCTURE_DEFINED
246 #define MTX_STRUCTURE_DEFINED
247 struct mtx
248 {
249 SSHORT mtx_event_count[3];
250 SCHAR mtx_use_count;
251 SCHAR mtx_wait;
252 };
253 typedef mtx MTX_T;
254 typedef mtx *MTX;
255 #endif
256 #undef MTX_STRUCTURE_DEFINED
257
258 #ifndef SH_MEM_STRUCTURE_DEFINED
259 #define SH_MEM_STRUCTURE_DEFINED
260 struct sh_mem
261 {
262 UCHAR* sh_mem_address;
263 SLONG sh_mem_length_mapped;
264 SLONG sh_mem_mutex_arg;
265 SLONG sh_mem_handle;
266 };
267 typedef sh_mem SH_MEM_T;
268 typedef sh_mem *SH_MEM;
269 #endif
270 #undef SH_MEM_STRUCTURE_DEFINED
271
272 #ifndef THREAD_HANDLE_DEFINED
273 #define THREAD_HANDLE_DEFINED
274 typedef ULONG THD_T;
275 #endif
276 #undef THREAD_HANDLE_DEFINED
277
278
279 // Interprocess communication configuration structure
280 // This was used to read to and write from the Config dialog when the server
281 // or the guardian is showing an icon in the tray.
282
283 /*
284 struct ipccfg
285 {
286 const char* ipccfg_keyword;
287 SCHAR ipccfg_key;
288 SLONG* ipccfg_variable;
289 SSHORT ipccfg_parent_offset; // Relative offset of parent keyword
290 USHORT ipccfg_found; // TRUE when keyword has been set
291 };
292
293 typedef ipccfg *IPCCFG;
294 */
295
296 /* AST thread scheduling macros */
297
298 #ifdef AST_THREAD
299 inline void AST_ALLOC() {
300 SCH_ast(AST_alloc);
301 }
302 inline void AST_INIT() {
303 SCH_ast(AST_init);
304 }
305 inline void AST_FINI() {
306 SCH_ast(AST_fini);
307 }
308 inline void AST_CHECK() {
309 SCH_ast(AST_check);
310 }
311 inline void AST_DISABLE() {
312 SCH_ast(AST_disable);
313 }
314 inline void AST_ENABLE() {
315 SCH_ast(AST_enable);
316 }
317 inline void AST_ENTER() {
318 SCH_ast(AST_enter);
319 }
320 inline void AST_EXIT() {
321 SCH_ast(AST_exit);
322 }
323 #else
324 inline void AST_ALLOC() {
325 }
326 inline void AST_INIT() {
327 }
328 inline void AST_FINI() {
329 }
330 inline void AST_CHECK() {
331 }
332 inline void AST_DISABLE() {
333 }
334 inline void AST_ENABLE() {
335 }
336 inline void AST_ENTER() {
337 }
338 inline void AST_EXIT() {
339 }
340 #endif
341
342
343 namespace Jrd {
344 #ifdef MULTI_THREAD
345
346 // This class inhibits AST processing.
347
348 class AstInhibit
349 {
350 public:
351 // Constructor inhibits processing.
352 AstInhibit() : enabled(false)
353 {
354 AST_DISABLE();
355 }
356
357 // Destructor re-enables processing.
358 ~AstInhibit()
359 {
360 enable();
361 }
362
363 // Let one re-enable processing in advance.
364 void enable()
365 {
366 if (enabled)
367 return;
368
369 enabled = true;
370
371 AST_ENABLE();
372 }
373
374 private:
375 // Forbid copy constructor
376 AstInhibit(const AstInhibit&);
377 bool enabled;
378 };
379 #else // MULTI_THREAD
380 class AstInhibit : public SignalInhibit
381 //
382 // This class inhibits signals' processing.
383 //
384 {
385 public:
386 AstInhibit() { }
387
388 private:
389 // Forbid copy constructor
390 AstInhibit(const AstInhibit&);
391 };
392 #endif // MULTI_THREAD
393 } // namespace Jrd
394
395
396 #endif // JRD_ISC_H

  ViewVC Help
Powered by ViewVC 1.1.5