(file) Return to suballoc.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / suballoc

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2