00001 #include "ace_pch.h"
00002
00003
00004 #include "ace/MEM_SAP.h"
00005
00006 #if (ACE_HAS_POSITION_INDEPENDENT_POINTERS == 1)
00007
00008 #if defined (ACE_LACKS_INLINE_FUNCTIONS)
00009 #include "ace/MEM_SAP.i"
00010 #endif
00011
00012 ACE_RCSID(ace, MEM_SAP, "$Id: MEM_SAP.cpp,v 1.1.1.4.2.1 2003/03/13 19:44:21 chad Exp $")
00013
00014 ACE_ALLOC_HOOK_DEFINE(ACE_IPC_SAP)
00015
00016 void
00017 ACE_MEM_SAP::dump (void) const
00018 {
00019 ACE_TRACE ("ACE_MEM_SAP::dump");
00020
00021 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00022 if (this->shm_malloc_ != 0)
00023 this->shm_malloc_->dump ();
00024 else
00025 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("ACE_MEM_SAP uninitialized.\n")));
00026 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00027 }
00028
00029 ACE_MEM_SAP::ACE_MEM_SAP (void)
00030 : handle_ (ACE_INVALID_HANDLE),
00031 shm_malloc_ (0)
00032 {
00033
00034 }
00035
00036 int
00037 ACE_MEM_SAP::fini ()
00038 {
00039 ACE_TRACE ("ACE_MEM_SAP::fini");
00040
00041 return this->close_shm_malloc ();
00042 }
00043
00044 int
00045 ACE_MEM_SAP::create_shm_malloc (const ACE_TCHAR *name,
00046 MALLOC_OPTIONS *options)
00047 {
00048 ACE_TRACE ("ACE_MEM_SAP::create_shm_malloc");
00049
00050 if (this->shm_malloc_ != 0)
00051 return -1;
00052
00053 ACE_NEW_RETURN (this->shm_malloc_,
00054 MALLOC_TYPE (name,
00055 0,
00056 options),
00057 -1);
00058
00059 if (this->shm_malloc_->bad () != 0)
00060 {
00061 this->shm_malloc_->remove ();
00062 delete this->shm_malloc_;
00063 this->shm_malloc_ = 0;
00064 return -1;
00065 }
00066
00067 return 0;
00068 }
00069
00070 int
00071 ACE_MEM_SAP::close_shm_malloc (void)
00072 {
00073 ACE_TRACE ("ACE_MEM_SAP::close_shm_malloc");
00074
00075 int retv = -1;
00076
00077 if (this->shm_malloc_ != 0)
00078 this->shm_malloc_->release (1);
00079
00080 delete this->shm_malloc_;
00081 this->shm_malloc_ = 0;
00082
00083 return retv;
00084 }
00085
00086 #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
00087 template class ACE_Write_Guard<ACE_Process_Mutex>;
00088 template class ACE_Read_Guard<ACE_Process_Mutex>;
00089 template class ACE_Malloc_T<ACE_MMAP_MEMORY_POOL, ACE_Process_Mutex, ACE_PI_Control_Block>;
00090 template class ACE_Based_Pointer<ACE_MEM_SAP_Node>;
00091 template class ACE_Based_Pointer_Basic<ACE_MEM_SAP_Node>;
00092 #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
00093 #pragma instantiate ACE_Write_Guard<ACE_Process_Mutex>
00094 #pragma instantiate ACE_Read_Guard<ACE_Process_Mutex>
00095 #pragma instantiate ACE_Malloc_T<ACE_MMAP_MEMORY_POOL, ACE_Process_Mutex, ACE_PI_Control_Block>
00096 #pragma instantiate ACE_Based_Pointer<ACE_MEM_SAP_Node>
00097 #pragma instantiate ACE_Based_Pointer_Basic<ACE_MEM_SAP_Node>
00098 #endif
00099
00100 #endif