1 mday 1.1 //%///////////-*-c++-*-//////////////////////////////////////////////////////
2 //
3 // Copyright (c) 2000 - 2002 The Open group, BMC Software, Tivoli Systems, IBM
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to
7 // deal in the Software without restriction, including without limitation the
8 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 // sell copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
13 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
14 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
15 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
16 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
18 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 //
|
21 mday 1.14 //============================================================================
|
22 mday 1.1 //
23 // Author: Mike Day (mdday@us.ibm.com)
24 //
25 // Modified By:
26 //
27 //%/////////////////////////////////////////////////////////////////////////////
28
29 #ifndef PEGASUS_SUBALLOC_INCLUDE
30 #define PEGASUS_SUBALLOC_INCLUDE 1
|
31 mday 1.2
|
32 mday 1.1 #include <Pegasus/Common/Config.h>
|
33 kumpf 1.15 #include <Pegasus/suballoc/Linkage.h>
|
34 mday 1.1
35 #if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC)
36 #include <windows.h>
37 #include <process.h>
|
38 mday 1.3 #include <stdio.h>
|
39 mday 1.24 #include <malloc.h>
40 #include <stdlib.h>
41
|
42 mday 1.1 #elif defined (PEGASUS_PLATFORM_LINUX_IX86_GNU)
43 #include <pthread.h>
44 #include <semaphore.h>
45 #include <unistd.h>
46
47 #elif defined (PEGASUS_PLATFORM_AIX_RS_IBMCXX)
48 #include <sched.h>
49 #include <pthread.h>
50 #include <semaphore.h>
51 #include <unistd.h>
52
53 #elif defined (PEGASUS_PLATFORM_HPUX_PARISC_ACC)
54 #include <sched.h>
55 #include <semaphore.h>
56 #include <pthread.h>
57 #include <unistd.h>
58
59 #elif defined (PEGASUS_PLATFORM_TRU64_ALPHA_DECCXX)
60 #include <sched.h>
61 #include <semaphore.h>
62 #include <pthread.h>
63 mday 1.1 #include <unistd.h>
64
65 #elif defined (PEGASUS_PLATFORM_SOLARIS_SPARC_GNU)
66 #include <sched.h>
67 #include <semaphore.h>
68 #include <pthread.h>
69 #include <unistd.h>
70
71 #elif defined (PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
72 #include <sched.h>
73 #include <semaphore.h>
74 #include <pthread.h>
75 #include <unistd.h>
76
77 #elif defined (PEGASUS_PLATFORM_LINUX_IA64_GNU)
78 #include <sched.h>
79 #include <semaphore.h>
80 #include <pthread.h>
81 #include <unistd.h>
|
82 mday 1.2
|
83 mday 1.1 #else
84 # error "<Pegasus/Common/Config.h>: Unsupported Platform"
85 #endif
86
87 #include <time.h>
88 #include <assert.h>
89 #include <stdio.h>
90 #include <string.h>
91 #include <memory.h>
92 #include <malloc.h>
93 #include <errno.h>
94 #include <signal.h>
|
95 mday 1.24 #include <new.h>
|
96 mday 1.8 namespace
97 {
98 static const int GUARD_SIZE = 0x10;
99 static const int MAX_PATH_LEN = 0xff;
100 static const int MAX_LINE_LEN = 0x14;
|
101 mday 1.13 static const int MAX_CLASS_LEN = 0x40;
|
102 mday 1.8 static const int PRE_ALLOCATE = 0x00;
103 static const int STEP_ALLOCATE = 0x01;
104 static const int AVAILABLE = 0x00;
|
105 mday 1.18 static const int NORMAL = 0x00;
106 static const int ARRAY = 0x01;
|
107 mday 1.21 static const unsigned int IS_HEAD_NODE = 0x00000001;
108 static const unsigned int AVAIL = 0x00000002;
109 static const unsigned int ARRAY_NODE = 0x00000004;
110 static const unsigned int CHECK_FAILED = 0x00000008;
111 static const unsigned int ALREADY_DELETED = 0x00000010;
112 static const unsigned int OVERWRITE = 0x00000020;
113 static const unsigned int CHECK_LEAK = 0x00000040;
|
114 mday 1.23 static const unsigned int HUGE_NODE = 0x00000080;
|
115 mday 1.8 }
116
|
117 mday 1.1 PEGASUS_NAMESPACE_BEGIN
118
|
119 mday 1.19 struct SUBALLOC_HANDLE;
|
120 mday 1.14
|
121 mday 1.23 #if defined(PEGASUS_DEBUG_MEMORY)
|
122 mday 1.19 PEGASUS_SUBALLOC_LINKAGE void * pegasus_alloc(size_t,
123 void *,
124 int type,
|
125 mday 1.18 const Sint8 *classname,
126 Sint8 *file,
|
127 mday 1.19 Uint32 line );
|
128 mday 1.23
|
129 mday 1.18 PEGASUS_SUBALLOC_LINKAGE void pegasus_free(void *dead,
|
130 mday 1.19 void *,
|
131 mday 1.18 int type,
132 Sint8 *classname,
133 Sint8 *file,
|
134 mday 1.19 Uint32 line);
|
135 mday 1.23 #else
136 PEGASUS_SUBALLOC_LINKAGE void * pegasus_alloc(size_t);
137 PEGASUS_SUBALLOC_LINKAGE void pegasus_free(void *);
138 #endif
139
140
|
141 mday 1.17
|
142 mday 1.21
|
143 mday 1.7
|
144 mday 1.2 #if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC)
145
146 #define ENOTSOCK WSAENOTSOCK
147 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
148 #define EAFNOSUPPORT WSAEAFNOSUPPORT
149 #define EISCONN WSAEISCONN
150 #define ETIMEDOUT WSAETIMEDOUT
151 #define ECONNREFUSED WSAECONNREFUSED
152 #define ENETUNREACH WSAENETUNREACH
153 #define EADDRINUSE WSAEADDRINUSE
154 #define EINPROGRESS WSAEINPROGRESS
155 #define EALREADY WSAEALREADY
156 #define EWOULDBLOCK WSAEWOULDBLOCK
157 #ifndef EINVAL
158 #define EINVAL WSAEINVAL
159 #endif
|
160 mday 1.3 #define snprintf _snprintf
|
161 mday 1.2 typedef HANDLE PEGASUS_MUTEX_T;
162
163 #elif defined (PEGASUS_PLATFORM_LINUX_IX86_GNU)
164
165 typedef pthread_mutex_t PEGASUS_MUTEX_T;
166
167 #elif defined (PEGASUS_PLATFORM_AIX_RS_IBMCXX)
168
169 typedef pthread_mutex_t PEGASUS_MUTEX_T;
170
171 #elif defined (PEGASUS_PLATFORM_HPUX_PARISC_ACC)
|
172 mday 1.1
|
173 mday 1.2 typedef pthread_mutex_t PEGASUS_MUTEX_T;
|
174 mday 1.1
|
175 mday 1.2 #elif defined (PEGASUS_PLATFORM_TRU64_ALPHA_DECCXX)
|
176 mday 1.1
|
177 mday 1.2 typedef pthread_mutex_t PEGASUS_MUTEX_T;
|
178 mday 1.1
|
179 mday 1.2 #elif defined (PEGASUS_PLATFORM_SOLARIS_SPARC_GNU)
180
181 typedef pthread_mutex_t PEGASUS_MUTEX_T;
182
183 #elif defined (PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
184
185 typedef pthread_mutex_t PEGASUS_MUTEX_T;
186
187 #elif defined (PEGASUS_PLATFORM_NSK_NONSTOP_NMCPLUS)
188
189 typedef Uint32 PEGASUS_MUTEX_T;
190
191 #elif defined (PEGASUS_PLATFORM_LINUX_IA64_GNU)
|
192 mday 1.1
|
193 mday 1.2 typedef pthread_mutex_t PEGASUS_MUTEX_T;
|
194 mday 1.1
195 #endif
196
|
197 mday 1.5 // to reduce the number of wasted bytes:
198 // reduce GUARD_SIZE
199 // eliminate guard checking from SUBALLOC_NODEs
200 //
201
|
202 mday 1.14 class peg_suballoc;
203
|
204 mday 1.17 #if defined(PEGASUS_DEBUG_MEMORY)
|
205 mday 1.21 #define PEGASUS_NEW(a, h) new((pegasus_alloc(sizeof(a), ((void *)h), NORMAL, (#a), __FILE__, __LINE__)))
206 #define PEGASUS_ARRAY_NEW(a, i, h) new(pegasus_alloc(sizeof(a) * (i), ((void *)(h)), ARRAY, (#a), __FILE__, __LINE__)) (a)
|
207 mday 1.19 #define PEGASUS_DELETE(a) pegasus_free((a), NULL, NORMAL, (#a), __FILE__, __LINE__)
208 #define PEGASUS_ARRAY_DELETE(a) pegasus_free(a, NULL, ARRAY, (#a), __FILE__, __LINE__)
|
209 mday 1.21 #define PEGASUS_CHECK_FOR_LEAKS(h) peg_suballocator::get_instance()->_UnfreedNodes((h))
210 #define PEGASUS_START_LEAK_CHECK() peg_suballocator::get_instance()->set_leak_mode(true)
211 #define PEGASUS_STOP_LEAK_CHECK() peg_suballocator::get_instance()->set_leak_mode(false)
|
212 mday 1.18 #else
|
213 mday 1.21 #define PEGASUS_NEW(a, h) new
214 #define PEGASUS_ARRAY_NEW(a, i, h) new (a)[(i)]
215 #define PEGASUS_DELETE(a) delete((a))
216 #define PEGASUS_ARRAY_DELETE(a) delete [] ((a))
217 #define PEGASUS_CHECK_FOR_LEAKS(h)
218 #define PEGASUS_START_LEAK_CHECK()
219 #define PEGASUS_STOP_LEAK_CHECK()
|
220 mday 1.17 #endif
221
|
222 mday 1.14
|
223 mday 1.3 class PEGASUS_SUBALLOC_LINKAGE peg_suballocator
|
224 mday 1.2 {
225 private:
226 peg_suballocator(const peg_suballocator &);
227 peg_suballocator & operator = (const peg_suballocator &);
228 Boolean _debug;
229 typedef struct _subAllocNode {
230 struct _subAllocNode *next;
231 struct _subAllocNode *prev;
|
232 mday 1.18 Uint32 flags;
|
233 mday 1.2 Uint32 allocSize;
|
234 mday 1.23 Uint32 nodeSize;
235 void *concurrencyHandle;
236 #if defined(PEGASUS_DEBUG_MEMORY)
|
237 mday 1.2 Sint8 file[MAX_PATH_LEN + 1];
238 Sint8 line[MAX_LINE_LEN + 1];
|
239 mday 1.13 Sint8 classname[MAX_CLASS_LEN + 1];
|
240 mday 1.19 Sint8 d_file[MAX_PATH_LEN + 1];
241 Sint8 d_line[MAX_LINE_LEN + 1];
242 Sint8 d_classname[MAX_CLASS_LEN + 1];
243 Uint8 guardPre[GUARD_SIZE];
|
244 mday 1.23 #endif
|
245 mday 1.2 } SUBALLOC_NODE;
246
247 SUBALLOC_NODE *nodeListHeads[3][16];
248
249 PEGASUS_MUTEX_T globalSemHandle;
250 PEGASUS_MUTEX_T semHandles[3][16];
|
251 mday 1.3 static const Sint32 nodeSizes[3][16];
252 Uint32 allocs[3][16];
253 Uint32 wastedBytes[3][16];
254 Uint32 inUse[3][16];
255 Uint32 avail[3][16] ;
|
256 mday 1.2 Uint32 totalAllocs;
257 Uint32 totalMemoryInUse;
258
|
259 mday 1.5 static const Uint32 preAlloc[3][16];
260 static const Uint32 step[3][16];
|
261 mday 1.2
262 Sint32 initialized;
263 Sint32 init_count;
264 PEGASUS_MUTEX_T init_mutex;
|
265 mday 1.5 Boolean debug_mode;
|
266 mday 1.19 Boolean abort_on_error;
|
267 mday 1.21 Boolean check_for_leaks;
|
268 mday 1.19
|
269 mday 1.14 public:
270 static int CREATE_MUTEX(PEGASUS_MUTEX_T *mut);
271 static void WAIT_MUTEX(PEGASUS_MUTEX_T *mut, Uint32 msec, int *result);
272 static void WAIT_MUTEX(PEGASUS_MUTEX_T *mut);
273 static void RELEASE_MUTEX(PEGASUS_MUTEX_T *mut);
274 static void CLOSE_MUTEX(PEGASUS_MUTEX_T *mut);
275 private:
|
276 mday 1.18 static Boolean IS_ARRAY(SUBALLOC_NODE *x);
277 static Boolean IS_HEAD(SUBALLOC_NODE *x);
278 static void INSERT(SUBALLOC_NODE *new_node, SUBALLOC_NODE *after);
279 static void INSERT_AFTER(SUBALLOC_NODE *new_node, SUBALLOC_NODE *after);
280 static void INSERT_BEFORE(SUBALLOC_NODE *new_node, SUBALLOC_NODE *before);
281 static void _DELETE(SUBALLOC_NODE *x);
282 static Boolean IS_LAST(SUBALLOC_NODE *head, SUBALLOC_NODE *node);
283 static Boolean IS_FIRST(SUBALLOC_NODE *head, SUBALLOC_NODE *node);
284 static Boolean IS_ONLY(SUBALLOC_NODE *head, SUBALLOC_NODE *node);
285 static Boolean IS_EMPTY(SUBALLOC_NODE *h) ;
|
286 mday 1.2
287 Boolean _Allocate(Sint32, Sint32, Sint32);
288 void _DeAllocate(Sint32 vector, Sint32 index);
289 SUBALLOC_NODE *GetNode(Sint32 vector, Sint32 index);
290 SUBALLOC_NODE *GetHugeNode(Sint32 size);
291 void PutNode(Sint32 vector, Sint32 index, SUBALLOC_NODE *node);
292 void PutHugeNode(SUBALLOC_NODE *node);
|
293 mday 1.23 #if defined(PEGASUS_DEBUG_MEMORY)
|
294 mday 1.2 static const Uint8 guard[];
|
295 mday 1.5 static const Uint8 alloc_pattern;
296 static const Uint8 delete_pattern;
297
|
298 mday 1.2 static Boolean _CheckGuard(SUBALLOC_NODE *);
|
299 mday 1.24
|
300 mday 1.21
301 static Uint32 _CheckNode(void *m);
302 SUBALLOC_NODE *_CheckNode(void *m, int type, Sint8 *file, Uint32 line);
|
303 mday 1.24 public:
304 static Uint32 CheckMemory(void *);
|
305 mday 1.23 #endif
|
306 mday 1.2 public:
307
|
308 mday 1.7 peg_suballocator(void);
|
309 mday 1.20 peg_suballocator(Boolean mode );
|
310 mday 1.2 virtual ~peg_suballocator(void);
311
312 inline Boolean PEGASUS_DEBUG_ALLOC(void) { return _debug; }
313
|
314 mday 1.14 typedef class PEGASUS_SUBALLOC_LINKAGE _suballocHandle
|
315 mday 1.2 {
316 public:
317 Sint8 logpath[MAX_PATH_LEN + 1];
|
318 mday 1.19 Sint8 classname[MAX_CLASS_LEN + 1];
|
319 kumpf 1.16 _suballocHandle(const Sint8 *log_path = 0)
|
320 mday 1.2 {
321 if(log_path)
322 snprintf(logpath, MAX_PATH_LEN, "%s", log_path);
323 else
324 snprintf(logpath, MAX_PATH_LEN, "%p_suballoc_log", this);
325 }
326 virtual ~_suballocHandle(void)
327 {
328 }
329
330 }SUBALLOC_HANDLE;
331
|
332 mday 1.19 Boolean InitializeSubAllocator(void);
|
333 mday 1.14 static SUBALLOC_HANDLE *InitializeProcessHeap(Sint8 *f = NULL);
|
334 mday 1.23 #if defined(PEGASUS_DEBUG_MEMORY)
|
335 mday 1.19 void *vs_malloc(size_t size, void *handle, int type = NORMAL, const Sint8 *classname = 0, const Sint8 *f = 0, Uint32 l = 0);
336 void *vs_calloc(size_t num, size_t size, void *handle, int type = NORMAL, Sint8 *f = 0, Uint32 l = 0);
337 void *vs_realloc(void *pblock, size_t newsize, void *handle, int type = NORMAL, Sint8 *f = 0, Uint32 l = 0);
338 Sint8 * vs_strdup(const Sint8 *string, void *handle, int type = NORMAL, Sint8 *f = 0, Uint32 l = 0);
339 void vs_free(void *m, void *handle, int type, Sint8 *classname, Sint8 *f, Uint32 l);
|
340 mday 1.2 Boolean _UnfreedNodes(void *handle);
|
341 mday 1.23 Boolean get_mode(void) { return debug_mode; }
342 void set_leak_mode(Boolean mode) { check_for_leaks = mode; }
343 #else
344 void *vs_malloc(size_t size);
345 void *vs_calloc(size_t num, size_t size);
346 void *vs_realloc(void *pblock, size_t newsize);
347 Sint8 *vs_strdup(const Sint8 *str);
348 void vs_free(void *m);
349 Boolean get_mode(void) { return false; }
350 void set_leak_mode(Boolean mode) { }
351 #endif
|
352 mday 1.2 void DeInitSubAllocator(void *handle);
|
353 mday 1.21 static peg_suballocator *get_instance(void);
|
354 mday 1.23 SUBALLOC_HANDLE & get_handle(void) { return internal_handle; }
|
355 mday 1.2 private:
356 _suballocHandle internal_handle;
|
357 mday 1.21 static peg_suballocator *_suballoc_instance;
358
|
359 mday 1.2 };
360
|
361 mday 1.18 inline Boolean peg_suballocator::IS_ARRAY(SUBALLOC_NODE *x)
362 {
|
363 mday 1.19 return (x->flags & ARRAY_NODE) ? true : false ;
|
364 mday 1.18 }
|
365 mday 1.2
|
366 mday 1.18 inline Boolean peg_suballocator::IS_HEAD(SUBALLOC_NODE *x)
367 {
368 return (x->flags & IS_HEAD_NODE) ? true : false ;
369 }
|
370 mday 1.2
371 inline Boolean peg_suballocator::IS_EMPTY(SUBALLOC_NODE *h)
372 {
373 return (( (h)->next == (h) && (h)->prev == (h) ) ? true : false);
374 }
375
376 inline void peg_suballocator::INSERT(SUBALLOC_NODE *new_node, SUBALLOC_NODE *after)
377 {
378 new_node->prev = after;
379 new_node->next = after->next;
380 after->next->prev = new_node;
381 after->next = new_node;
382 }
383
384 inline void peg_suballocator::INSERT_AFTER(SUBALLOC_NODE *new_node, SUBALLOC_NODE *after)
385 {
386 INSERT(new_node, after);
387 return;
388 }
389
390 inline void peg_suballocator::INSERT_BEFORE(SUBALLOC_NODE *new_node, SUBALLOC_NODE *before)
391 mday 1.2 {
392 new_node->next = before;
393 new_node->prev = before->prev;
394 before->prev->next = new_node;
395 before->prev = new_node;
396 }
397
398 inline void peg_suballocator::_DELETE(SUBALLOC_NODE *x)
399 {
400 x->prev->next = x->next;
401 x->next->prev = x->prev;
402 }
403
404 inline Boolean peg_suballocator::IS_LAST(SUBALLOC_NODE *head, SUBALLOC_NODE *node)
405 {
406 return ((node->prev == head && head->prev == node) ? true : false);
407 }
408
409 inline Boolean peg_suballocator::IS_FIRST(SUBALLOC_NODE *head, SUBALLOC_NODE *node)
410 {
411 return ((node->prev == head && head->next == node) ? true : false);
412 mday 1.2 }
413
414 inline Boolean peg_suballocator::IS_ONLY(SUBALLOC_NODE *head, SUBALLOC_NODE *node)
415 {
416 return ((node->next == head && node->prev == head) ? true : false);
417 }
418
419
420
421
422 #if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC)
423
424 inline int peg_suballocator::CREATE_MUTEX(PEGASUS_MUTEX_T *mut)
425 {
|
426 mday 1.4 if((*mut = ::CreateMutex(NULL, false, NULL))) return 0;
|
427 mday 1.2 return -1;
428 }
429
430 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut, Uint32 msec, int *result)
431 {
432 assert(mut && *mut && result);
433 *result = WaitForSingleObject(*mut, INFINITE);
434 return;
435 }
436
437 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut)
438 {
439 WaitForSingleObject(*mut, INFINITE);
440 return;
441 }
442
443 inline void peg_suballocator::RELEASE_MUTEX(PEGASUS_MUTEX_T *mut)
444 {
|
445 mday 1.4 ::ReleaseMutex(*mut);
|
446 mday 1.2 return;
447 }
448
449 inline void peg_suballocator::CLOSE_MUTEX(PEGASUS_MUTEX_T *mut)
450 {
451 CloseHandle(*mut);
452 *mut = 0;
453 return;
454 }
455
456
457 #elif defined (PEGASUS_PLATFORM_LINUX_IX86_GNU)
458
459 inline int peg_suballocator::CREATE_MUTEX(PEGASUS_MUTEX_T *mut)
460 {
461 return(pthread_mutex_init(mut, NULL));
462 }
463
464 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut, Uint32 msec, int *result)
465 {
466 *result = pthread_mutex_lock(mut);
467 mday 1.2 return;
468 }
469
470 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut)
471 {
472 pthread_mutex_lock(mut);
473 }
474
475 inline void peg_suballocator::RELEASE_MUTEX(PEGASUS_MUTEX_T *mut)
476 {
477 pthread_mutex_unlock(mut);
478 return;
479 }
480
481 inline void peg_suballocator::CLOSE_MUTEX(PEGASUS_MUTEX_T *mut)
482 {
483 pthread_mutex_destroy(mut);
484 return;
485 }
486
487 #elif defined (PEGASUS_PLATFORM_AIX_RS_IBMCXX)
488 mday 1.2
489
490 inline int peg_suballocator::CREATE_MUTEX(PEGASUS_MUTEX_T *mut)
491 {
492 return(pthread_mutex_init(mut, NULL));
493 }
494
495 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut, Uint32 msec, int *result)
496 {
497 *result = pthread_mutex_lock(mut);
498 return;
499 }
500
501 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut)
502 {
503 pthread_mutex_lock(mut);
504 }
505
506 inline void peg_suballocator::RELEASE_MUTEX(PEGASUS_MUTEX_T *mut)
507 {
508 pthread_mutex_unlock(mut);
509 mday 1.2 return;
510 }
511
512 inline void peg_suballocator::CLOSE_MUTEX(PEGASUS_MUTEX_T *mut)
513 {
514 pthread_mutex_destroy(mut);
515 return;
516 }
517
518 #elif defined (PEGASUS_PLATFORM_HPUX_PARISC_ACC)
519
520 inline int peg_suballocator::CREATE_MUTEX(PEGASUS_MUTEX_T *mut)
521 {
522 return(pthread_mutex_init(mut, NULL));
523 }
524
525 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut, Uint32 msec, int *result)
526 {
527 *result = pthread_mutex_lock(mut);
528 return;
529 }
530 mday 1.2
531 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut)
532 {
533 pthread_mutex_lock(mut);
534 }
535
536 inline void peg_suballocator::RELEASE_MUTEX(PEGASUS_MUTEX_T *mut)
537 {
538 pthread_mutex_unlock(mut);
539 return;
540 }
541
542 inline void peg_suballocator::CLOSE_MUTEX(PEGASUS_MUTEX_T *mut)
543 {
544 pthread_mutex_destroy(mut);
545 return;
546 }
547
548 #elif defined (PEGASUS_PLATFORM_TRU64_ALPHA_DECCXX)
549
550 inline int peg_suballocator::CREATE_MUTEX(PEGASUS_MUTEX_T *mut)
551 mday 1.2 {
552 return(pthread_mutex_init(mut, NULL));
553 }
554
555 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut, Uint32 msec, int *result)
556 {
557 *result = pthread_mutex_lock(mut);
558 return;
559 }
560
561 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut)
562 {
563 pthread_mutex_lock(mut);
564 }
565
566 inline void peg_suballocator::RELEASE_MUTEX(PEGASUS_MUTEX_T *mut)
567 {
568 pthread_mutex_unlock(mut);
569 return;
570 }
571
572 mday 1.2 inline void peg_suballocator::CLOSE_MUTEX(PEGASUS_MUTEX_T *mut)
573 {
574 pthread_mutex_destroy(mut);
575 return;
576 }
577
578 #elif defined (PEGASUS_PLATFORM_SOLARIS_SPARC_GNU)
579
580 inline int peg_suballocator::CREATE_MUTEX(PEGASUS_MUTEX_T *mut)
581 {
582 return(pthread_mutex_init(mut, NULL));
583 }
584
585 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut, Uint32 msec, int *result)
586 {
587 *result = pthread_mutex_lock(mut);
588 return;
589 }
590
591 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut)
592 {
593 mday 1.2 pthread_mutex_lock(mut);
594 }
595
596 inline void peg_suballocator::RELEASE_MUTEX(PEGASUS_MUTEX_T *mut)
597 {
598 pthread_mutex_unlock(mut);
599 return;
600 }
601
602 inline void peg_suballocator::CLOSE_MUTEX(PEGASUS_MUTEX_T *mut)
603 {
604 pthread_mutex_destroy(mut);
605 return;
606 }
607
608 #elif defined (PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
609
610 inline int peg_suballocator::CREATE_MUTEX(PEGASUS_MUTEX_T *mut)
611 {
612 return(pthread_mutex_init(mut, NULL));
613 }
614 mday 1.2
615 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut, Uint32 msec, int *result)
616 {
617 *result = pthread_mutex_lock(mut);
618 return;
619 }
620
621 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut)
622 {
623 pthread_mutex_lock(mut);
624 }
625
626 inline void peg_suballocator::RELEASE_MUTEX(PEGASUS_MUTEX_T *mut)
627 {
628 pthread_mutex_unlock(mut);
629 return;
630 }
631
632 inline void peg_suballocator::CLOSE_MUTEX(PEGASUS_MUTEX_T *mut)
633 {
634 pthread_mutex_destroy(mut);
635 mday 1.2 return;
636 }
637
638 #elif defined (PEGASUS_PLATFORM_NSK_NONSTOP_NMCPLUS)
639
640 inline int peg_suballocator::CREATE_MUTEX(PEGASUS_MUTEX_T *mut)
641 {
642 return(0);
643 }
644
645 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut, Uint32 msec, int *result)
646 {
647 }
648
649 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut)
650 {
651
652 }
653
654 inline void peg_suballocator::RELEASE_MUTEX(PEGASUS_MUTEX_T *mut)
655 {
656 mday 1.2
657 }
658
659 inline void peg_suballocator::CLOSE_MUTEX(PEGASUS_MUTEX_T *mut)
660 {
661
662 }
663
664 #elif defined (PEGASUS_PLATFORM_LINUX_IA64_GNU)
665
666 inline int peg_suballocator::CREATE_MUTEX(PEGASUS_MUTEX_T *mut)
667 {
668 return(pthread_mutex_init(mut, NULL));
669 }
670
671 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut, Uint32 msec, int *result)
672 {
673 *result = pthread_mutex_lock(mut);
674 return;
675 }
676
677 mday 1.2 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut)
678 {
679 pthread_mutex_lock(mut);
680 }
681
682 inline void peg_suballocator::RELEASE_MUTEX(PEGASUS_MUTEX_T *mut)
683 {
684 pthread_mutex_unlock(mut);
685 return;
686 }
687
688 inline void peg_suballocator::CLOSE_MUTEX(PEGASUS_MUTEX_T *mut)
689 {
690 pthread_mutex_destroy(mut);
691 return;
692 }
|
693 mday 1.1
694 #endif
695
|
696 mday 1.2 PEGASUS_NAMESPACE_END
|
697 mday 1.1
|
698 mday 1.2 #endif /* SUBALLOC_INCLUDE */
|
699 mday 1.1
700
|