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 //==============================================================================
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
34 #if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC)
35 #include <windows.h>
36 #include <process.h>
|
37 mday 1.3 #include <stdio.h>
|
38 mday 1.1 #elif defined (PEGASUS_PLATFORM_LINUX_IX86_GNU)
39 #include <pthread.h>
40 #include <semaphore.h>
41 #include <unistd.h>
42
43 #elif defined (PEGASUS_PLATFORM_AIX_RS_IBMCXX)
44 #include <sched.h>
45 #include <pthread.h>
46 #include <semaphore.h>
47 #include <unistd.h>
48
49 #elif defined (PEGASUS_PLATFORM_HPUX_PARISC_ACC)
50 #include <sched.h>
51 #include <semaphore.h>
52 #include <pthread.h>
53 #include <unistd.h>
54
55 #elif defined (PEGASUS_PLATFORM_TRU64_ALPHA_DECCXX)
56 #include <sched.h>
57 #include <semaphore.h>
58 #include <pthread.h>
59 mday 1.1 #include <unistd.h>
60
61 #elif defined (PEGASUS_PLATFORM_SOLARIS_SPARC_GNU)
62 #include <sched.h>
63 #include <semaphore.h>
64 #include <pthread.h>
65 #include <unistd.h>
66
67 #elif defined (PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
68 #include <sched.h>
69 #include <semaphore.h>
70 #include <pthread.h>
71 #include <unistd.h>
72
73 #elif defined (PEGASUS_PLATFORM_LINUX_IA64_GNU)
74 #include <sched.h>
75 #include <semaphore.h>
76 #include <pthread.h>
77 #include <unistd.h>
|
78 mday 1.2
|
79 mday 1.1 #else
80 # error "<Pegasus/Common/Config.h>: Unsupported Platform"
81 #endif
82
83 #include <time.h>
84 #include <assert.h>
85 #include <stdio.h>
86 #include <string.h>
87 #include <memory.h>
88 #include <malloc.h>
89 #include <errno.h>
90 #include <signal.h>
91
|
92 mday 1.8 namespace
93 {
94 static const int GUARD_SIZE = 0x10;
95 static const int MAX_PATH_LEN = 0xff;
96 static const int MAX_LINE_LEN = 0x14;
97 static const int PRE_ALLOCATE = 0x00;
98 static const int STEP_ALLOCATE = 0x01;
99 static const int AVAILABLE = 0x00;
100 static const int NORMAL = 0x01;
101 static const int ARRAY = 0x02;
102 }
103
|
104 mday 1.1 PEGASUS_NAMESPACE_BEGIN
105
|
106 mday 1.10 void * PEGASUS_SUBALLOC_LINKAGE pegasus_alloc(size_t );
107 void PEGASUS_SUBALLOC_LINKAGE pegasus_free(void *);
|
108 mday 1.7
|
109 mday 1.2 #if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC)
110
111 #define ENOTSOCK WSAENOTSOCK
112 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
113 #define EAFNOSUPPORT WSAEAFNOSUPPORT
114 #define EISCONN WSAEISCONN
115 #define ETIMEDOUT WSAETIMEDOUT
116 #define ECONNREFUSED WSAECONNREFUSED
117 #define ENETUNREACH WSAENETUNREACH
118 #define EADDRINUSE WSAEADDRINUSE
119 #define EINPROGRESS WSAEINPROGRESS
120 #define EALREADY WSAEALREADY
121 #define EWOULDBLOCK WSAEWOULDBLOCK
122 #ifndef EINVAL
123 #define EINVAL WSAEINVAL
124 #endif
|
125 mday 1.3 #define snprintf _snprintf
|
126 mday 1.2 typedef HANDLE PEGASUS_MUTEX_T;
127
128 #elif defined (PEGASUS_PLATFORM_LINUX_IX86_GNU)
129
130 typedef pthread_mutex_t PEGASUS_MUTEX_T;
131
132 #elif defined (PEGASUS_PLATFORM_AIX_RS_IBMCXX)
133
134 typedef pthread_mutex_t PEGASUS_MUTEX_T;
135
136 #elif defined (PEGASUS_PLATFORM_HPUX_PARISC_ACC)
|
137 mday 1.1
|
138 mday 1.2 typedef pthread_mutex_t PEGASUS_MUTEX_T;
|
139 mday 1.1
|
140 mday 1.2 #elif defined (PEGASUS_PLATFORM_TRU64_ALPHA_DECCXX)
|
141 mday 1.1
|
142 mday 1.2 typedef pthread_mutex_t PEGASUS_MUTEX_T;
|
143 mday 1.1
|
144 mday 1.2 #elif defined (PEGASUS_PLATFORM_SOLARIS_SPARC_GNU)
145
146 typedef pthread_mutex_t PEGASUS_MUTEX_T;
147
148 #elif defined (PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
149
150 typedef pthread_mutex_t PEGASUS_MUTEX_T;
151
152 #elif defined (PEGASUS_PLATFORM_NSK_NONSTOP_NMCPLUS)
153
154 typedef Uint32 PEGASUS_MUTEX_T;
155
156 #elif defined (PEGASUS_PLATFORM_LINUX_IA64_GNU)
|
157 mday 1.1
|
158 mday 1.2 typedef pthread_mutex_t PEGASUS_MUTEX_T;
|
159 mday 1.1
160 #endif
161
|
162 mday 1.3
|
163 mday 1.5 // to reduce the number of wasted bytes:
164 // reduce GUARD_SIZE
165 // eliminate guard checking from SUBALLOC_NODEs
166 //
167
|
168 mday 1.3 class PEGASUS_SUBALLOC_LINKAGE peg_suballocator
|
169 mday 1.2 {
170 private:
171 peg_suballocator(const peg_suballocator &);
172 peg_suballocator & operator = (const peg_suballocator &);
173 Boolean _debug;
174
175 typedef struct _subAllocTemplate {
176 struct _subAllocNode *next;
177 struct _subAllocNode *prev;
178 Boolean isHead;
179 Boolean avail;
180 Uint32 allocSize;
181 Uint8 guardPre[GUARD_SIZE];
182 } SUB_TEMPLATE;
183
184 typedef struct _subAllocNode {
185 struct _subAllocNode *next;
186 struct _subAllocNode *prev;
187 Boolean isHead;
|
188 mday 1.5 int avail;
|
189 mday 1.2 Uint32 allocSize;
190 Uint8 guardPre[GUARD_SIZE];
191 void *allocPtr;
192 Uint8 guardPost[GUARD_SIZE];
193 Sint8 file[MAX_PATH_LEN + 1];
194 Sint8 line[MAX_LINE_LEN + 1];
195 void *concurrencyHandle;
196 } SUBALLOC_NODE;
197
198
199 SUBALLOC_NODE *nodeListHeads[3][16];
200
201 PEGASUS_MUTEX_T globalSemHandle;
202 PEGASUS_MUTEX_T semHandles[3][16];
|
203 mday 1.3 static const Sint32 nodeSizes[3][16];
204 Uint32 allocs[3][16];
205 Uint32 wastedBytes[3][16];
206 Uint32 inUse[3][16];
207 Uint32 avail[3][16] ;
|
208 mday 1.2 Uint32 totalAllocs;
209 Uint32 totalMemoryInUse;
210
|
211 mday 1.5 static const Uint32 preAlloc[3][16];
212 static const Uint32 step[3][16];
|
213 mday 1.2
214 Sint32 initialized;
215 Sint32 init_count;
216 PEGASUS_MUTEX_T init_mutex;
|
217 mday 1.5 Boolean debug_mode;
|
218 mday 1.6
219
|
220 mday 1.2
221 int CREATE_MUTEX(PEGASUS_MUTEX_T *mut);
222 void WAIT_MUTEX(PEGASUS_MUTEX_T *mut, Uint32 msec, int *result);
223 void WAIT_MUTEX(PEGASUS_MUTEX_T *mut);
224 void RELEASE_MUTEX(PEGASUS_MUTEX_T *mut);
225 void CLOSE_MUTEX(PEGASUS_MUTEX_T *mut);
226
227 Boolean IS_HEAD(SUBALLOC_NODE *x);
228 void INSERT(SUBALLOC_NODE *new_node, SUBALLOC_NODE *after);
229 void INSERT_AFTER(SUBALLOC_NODE *new_node, SUBALLOC_NODE *after);
230 void INSERT_BEFORE(SUBALLOC_NODE *new_node, SUBALLOC_NODE *before);
231 void _DELETE(SUBALLOC_NODE *x);
232 Boolean IS_LAST(SUBALLOC_NODE *head, SUBALLOC_NODE *node);
233 Boolean IS_FIRST(SUBALLOC_NODE *head, SUBALLOC_NODE *node);
234 Boolean IS_ONLY(SUBALLOC_NODE *head, SUBALLOC_NODE *node);
235 inline Boolean IS_EMPTY(SUBALLOC_NODE *h) ;
236
237 Boolean _Allocate(Sint32, Sint32, Sint32);
238 void _DeAllocate(Sint32 vector, Sint32 index);
239 SUBALLOC_NODE *GetNode(Sint32 vector, Sint32 index);
240 SUBALLOC_NODE *GetHugeNode(Sint32 size);
241 mday 1.2 void PutNode(Sint32 vector, Sint32 index, SUBALLOC_NODE *node);
242 void PutHugeNode(SUBALLOC_NODE *node);
243
244 static const Sint8 dumpFileName[];
245 Sint8 global_log_filename[MAX_PATH_LEN + 1];
246 FILE *dumpFile ;
247 static const Uint8 guard[];
|
248 mday 1.5 static const Uint8 alloc_pattern;
249 static const Uint8 delete_pattern;
250
|
251 mday 1.2 static Boolean _CheckGuard(SUBALLOC_NODE *);
252
253
254 public:
255
|
256 mday 1.7 peg_suballocator(void);
|
257 mday 1.5 peg_suballocator(Sint8 *log_filename, Boolean mode = true);
|
258 mday 1.2 virtual ~peg_suballocator(void);
259
260 inline Boolean PEGASUS_DEBUG_ALLOC(void) { return _debug; }
261
262 typedef class _suballocHandle
263 {
264 public:
265 Sint8 logpath[MAX_PATH_LEN + 1];
266 _suballocHandle(Sint8 *log_path = 0)
267 {
268 if(log_path)
269 snprintf(logpath, MAX_PATH_LEN, "%s", log_path);
270 else
271 snprintf(logpath, MAX_PATH_LEN, "%p_suballoc_log", this);
272 }
273 virtual ~_suballocHandle(void)
274 {
275 }
276
277 }SUBALLOC_HANDLE;
278
279 mday 1.2 Boolean InitializeSubAllocator(Sint8 *f = NULL);
280 SUBALLOC_HANDLE *InitializeProcessHeap(Sint8 *f = NULL);
|
281 mday 1.5 void *vs_malloc(size_t size, void *handle, int type = NORMAL, Sint8 *f = 0, Sint32 l = 0);
282 void *vs_calloc(size_t num, size_t size, void *handle, int type = NORMAL, Sint8 *f = 0, Sint32 l = 0);
283 void *vs_realloc(void *pblock, size_t newsize, void *handle, int type = NORMAL, Sint8 *f = 0, Sint32 l = 0);
284 Sint8 * vs_strdup(const Sint8 *string, void *handle, int type = NORMAL, Sint8 *f = 0, Sint32 l = 0);
285 void vs_free(void *m, int type = NORMAL);
|
286 mday 1.2 Boolean _UnfreedNodes(void *handle);
287 void DeInitSubAllocator(void *handle);
288 static void _CheckNode(void *m);
|
289 mday 1.6
290 Boolean get_mode(void)
291 {
292 return debug_mode;
293 }
294
295 SUBALLOC_HANDLE & get_handle(void)
296 {
297 return internal_handle;
298 }
299
300
|
301 mday 1.2 private:
302 _suballocHandle internal_handle;
303 };
304
305
306
307 inline Boolean peg_suballocator::IS_HEAD(SUBALLOC_NODE *x) { return x->isHead; }
308
309 inline Boolean peg_suballocator::IS_EMPTY(SUBALLOC_NODE *h)
310 {
311 return (( (h)->next == (h) && (h)->prev == (h) ) ? true : false);
312 }
313
314 inline void peg_suballocator::INSERT(SUBALLOC_NODE *new_node, SUBALLOC_NODE *after)
315 {
316 new_node->prev = after;
317 new_node->next = after->next;
318 after->next->prev = new_node;
319 after->next = new_node;
320 }
321
322 mday 1.2 inline void peg_suballocator::INSERT_AFTER(SUBALLOC_NODE *new_node, SUBALLOC_NODE *after)
323 {
324 INSERT(new_node, after);
325 return;
326 }
327
328 inline void peg_suballocator::INSERT_BEFORE(SUBALLOC_NODE *new_node, SUBALLOC_NODE *before)
329 {
330 new_node->next = before;
331 new_node->prev = before->prev;
332 before->prev->next = new_node;
333 before->prev = new_node;
334 }
335
336 inline void peg_suballocator::_DELETE(SUBALLOC_NODE *x)
337 {
338 x->prev->next = x->next;
339 x->next->prev = x->prev;
340 }
341
342 inline Boolean peg_suballocator::IS_LAST(SUBALLOC_NODE *head, SUBALLOC_NODE *node)
343 mday 1.2 {
344 return ((node->prev == head && head->prev == node) ? true : false);
345 }
346
347 inline Boolean peg_suballocator::IS_FIRST(SUBALLOC_NODE *head, SUBALLOC_NODE *node)
348 {
349 return ((node->prev == head && head->next == node) ? true : false);
350 }
351
352 inline Boolean peg_suballocator::IS_ONLY(SUBALLOC_NODE *head, SUBALLOC_NODE *node)
353 {
354 return ((node->next == head && node->prev == head) ? true : false);
355 }
356
357
358
359
360 #if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC)
361
362 inline int peg_suballocator::CREATE_MUTEX(PEGASUS_MUTEX_T *mut)
363 {
|
364 mday 1.4 if((*mut = ::CreateMutex(NULL, false, NULL))) return 0;
|
365 mday 1.2 return -1;
366 }
367
368 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut, Uint32 msec, int *result)
369 {
370 assert(mut && *mut && result);
371 *result = WaitForSingleObject(*mut, INFINITE);
372 return;
373 }
374
375 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut)
376 {
377 WaitForSingleObject(*mut, INFINITE);
378 return;
379 }
380
381 inline void peg_suballocator::RELEASE_MUTEX(PEGASUS_MUTEX_T *mut)
382 {
|
383 mday 1.4 ::ReleaseMutex(*mut);
|
384 mday 1.2 return;
385 }
386
387 inline void peg_suballocator::CLOSE_MUTEX(PEGASUS_MUTEX_T *mut)
388 {
389 CloseHandle(*mut);
390 *mut = 0;
391 return;
392 }
393
394
395 #elif defined (PEGASUS_PLATFORM_LINUX_IX86_GNU)
396
397 inline int peg_suballocator::CREATE_MUTEX(PEGASUS_MUTEX_T *mut)
398 {
399 return(pthread_mutex_init(mut, NULL));
400 }
401
402 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut, Uint32 msec, int *result)
403 {
404 *result = pthread_mutex_lock(mut);
405 mday 1.2 return;
406 }
407
408 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut)
409 {
410 pthread_mutex_lock(mut);
411 }
412
413 inline void peg_suballocator::RELEASE_MUTEX(PEGASUS_MUTEX_T *mut)
414 {
415 pthread_mutex_unlock(mut);
416 return;
417 }
418
419 inline void peg_suballocator::CLOSE_MUTEX(PEGASUS_MUTEX_T *mut)
420 {
421 pthread_mutex_destroy(mut);
422 return;
423 }
424
425 #elif defined (PEGASUS_PLATFORM_AIX_RS_IBMCXX)
426 mday 1.2
427
428 inline int peg_suballocator::CREATE_MUTEX(PEGASUS_MUTEX_T *mut)
429 {
430 return(pthread_mutex_init(mut, NULL));
431 }
432
433 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut, Uint32 msec, int *result)
434 {
435 *result = pthread_mutex_lock(mut);
436 return;
437 }
438
439 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut)
440 {
441 pthread_mutex_lock(mut);
442 }
443
444 inline void peg_suballocator::RELEASE_MUTEX(PEGASUS_MUTEX_T *mut)
445 {
446 pthread_mutex_unlock(mut);
447 mday 1.2 return;
448 }
449
450 inline void peg_suballocator::CLOSE_MUTEX(PEGASUS_MUTEX_T *mut)
451 {
452 pthread_mutex_destroy(mut);
453 return;
454 }
455
456 #elif defined (PEGASUS_PLATFORM_HPUX_PARISC_ACC)
457
458 inline int peg_suballocator::CREATE_MUTEX(PEGASUS_MUTEX_T *mut)
459 {
460 return(pthread_mutex_init(mut, NULL));
461 }
462
463 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut, Uint32 msec, int *result)
464 {
465 *result = pthread_mutex_lock(mut);
466 return;
467 }
468 mday 1.2
469 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut)
470 {
471 pthread_mutex_lock(mut);
472 }
473
474 inline void peg_suballocator::RELEASE_MUTEX(PEGASUS_MUTEX_T *mut)
475 {
476 pthread_mutex_unlock(mut);
477 return;
478 }
479
480 inline void peg_suballocator::CLOSE_MUTEX(PEGASUS_MUTEX_T *mut)
481 {
482 pthread_mutex_destroy(mut);
483 return;
484 }
485
486 #elif defined (PEGASUS_PLATFORM_TRU64_ALPHA_DECCXX)
487
488 inline int peg_suballocator::CREATE_MUTEX(PEGASUS_MUTEX_T *mut)
489 mday 1.2 {
490 return(pthread_mutex_init(mut, NULL));
491 }
492
493 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut, Uint32 msec, int *result)
494 {
495 *result = pthread_mutex_lock(mut);
496 return;
497 }
498
499 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut)
500 {
501 pthread_mutex_lock(mut);
502 }
503
504 inline void peg_suballocator::RELEASE_MUTEX(PEGASUS_MUTEX_T *mut)
505 {
506 pthread_mutex_unlock(mut);
507 return;
508 }
509
510 mday 1.2 inline void peg_suballocator::CLOSE_MUTEX(PEGASUS_MUTEX_T *mut)
511 {
512 pthread_mutex_destroy(mut);
513 return;
514 }
515
516 #elif defined (PEGASUS_PLATFORM_SOLARIS_SPARC_GNU)
517
518 inline int peg_suballocator::CREATE_MUTEX(PEGASUS_MUTEX_T *mut)
519 {
520 return(pthread_mutex_init(mut, NULL));
521 }
522
523 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut, Uint32 msec, int *result)
524 {
525 *result = pthread_mutex_lock(mut);
526 return;
527 }
528
529 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut)
530 {
531 mday 1.2 pthread_mutex_lock(mut);
532 }
533
534 inline void peg_suballocator::RELEASE_MUTEX(PEGASUS_MUTEX_T *mut)
535 {
536 pthread_mutex_unlock(mut);
537 return;
538 }
539
540 inline void peg_suballocator::CLOSE_MUTEX(PEGASUS_MUTEX_T *mut)
541 {
542 pthread_mutex_destroy(mut);
543 return;
544 }
545
546 #elif defined (PEGASUS_PLATFORM_ZOS_ZSERIES_IBM)
547
548 inline int peg_suballocator::CREATE_MUTEX(PEGASUS_MUTEX_T *mut)
549 {
550 return(pthread_mutex_init(mut, NULL));
551 }
552 mday 1.2
553 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut, Uint32 msec, int *result)
554 {
555 *result = pthread_mutex_lock(mut);
556 return;
557 }
558
559 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut)
560 {
561 pthread_mutex_lock(mut);
562 }
563
564 inline void peg_suballocator::RELEASE_MUTEX(PEGASUS_MUTEX_T *mut)
565 {
566 pthread_mutex_unlock(mut);
567 return;
568 }
569
570 inline void peg_suballocator::CLOSE_MUTEX(PEGASUS_MUTEX_T *mut)
571 {
572 pthread_mutex_destroy(mut);
573 mday 1.2 return;
574 }
575
576 #elif defined (PEGASUS_PLATFORM_NSK_NONSTOP_NMCPLUS)
577
578 inline int peg_suballocator::CREATE_MUTEX(PEGASUS_MUTEX_T *mut)
579 {
580 return(0);
581 }
582
583 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut, Uint32 msec, int *result)
584 {
585 }
586
587 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut)
588 {
589
590 }
591
592 inline void peg_suballocator::RELEASE_MUTEX(PEGASUS_MUTEX_T *mut)
593 {
594 mday 1.2
595 }
596
597 inline void peg_suballocator::CLOSE_MUTEX(PEGASUS_MUTEX_T *mut)
598 {
599
600 }
601
602 #elif defined (PEGASUS_PLATFORM_LINUX_IA64_GNU)
603
604 inline int peg_suballocator::CREATE_MUTEX(PEGASUS_MUTEX_T *mut)
605 {
606 return(pthread_mutex_init(mut, NULL));
607 }
608
609 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut, Uint32 msec, int *result)
610 {
611 *result = pthread_mutex_lock(mut);
612 return;
613 }
614
615 mday 1.2 inline void peg_suballocator::WAIT_MUTEX(PEGASUS_MUTEX_T *mut)
616 {
617 pthread_mutex_lock(mut);
618 }
619
620 inline void peg_suballocator::RELEASE_MUTEX(PEGASUS_MUTEX_T *mut)
621 {
622 pthread_mutex_unlock(mut);
623 return;
624 }
625
626 inline void peg_suballocator::CLOSE_MUTEX(PEGASUS_MUTEX_T *mut)
627 {
628 pthread_mutex_destroy(mut);
629 return;
630 }
|
631 mday 1.1
632 #endif
633
|
634 mday 1.2 PEGASUS_NAMESPACE_END
|
635 mday 1.1
|
636 mday 1.2 #endif /* SUBALLOC_INCLUDE */
|
637 mday 1.1
638
|
639 mday 1.2 // how to debug a specific object:
640 // add an operator new to the object such that
641 // void * operator new(size_t size, peg_suballocator::_sub_handle = 0);
642 // void operator delete(void *dead, size_t size);
643 // have operator delete check for unfreed nodes by calling sub->unfreed_nodes
|
644 mday 1.1
|