Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

SV_Shared_Memory.i

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 // $Id: SV_Shared_Memory.i,v 1.1.1.3 2003/02/21 18:36:32 chad Exp $
00003 
00004 // SV_Shared_Memory.i
00005 
00006 #include "ace/SV_Shared_Memory.h"
00007 
00008 ACE_INLINE size_t
00009 ACE_SV_Shared_Memory::round_up (size_t len)
00010 {
00011   ACE_TRACE ("ACE_SV_Shared_Memory::round_up");
00012   return (len + ACE_SV_Shared_Memory::ALIGN_WORDB - 1) & ~(ACE_SV_Shared_Memory::ALIGN_WORDB - 1);
00013 }
00014 
00015 // Creates a shared memory segment of SIZE bytes. Does *not* attach
00016 // this memory segment...
00017 
00018 ACE_INLINE int 
00019 ACE_SV_Shared_Memory::open (key_t external_id, size_t sz, int create, int perms)
00020 {
00021   ACE_TRACE ("ACE_SV_Shared_Memory::open");
00022 #if defined (ACE_WIN32)
00023         ACE_UNUSED_ARG(perms);
00024         ACE_UNUSED_ARG(create);
00025         ACE_UNUSED_ARG(sz);
00026         ACE_UNUSED_ARG(external_id);
00027   ACE_NOTSUP_RETURN (-1);
00028 #else
00029   this->segment_ptr_ = 0;
00030   this->size_ = sz;
00031 
00032   this->internal_id_ = ACE_OS::shmget (external_id, sz, create | perms);
00033 
00034   return this->internal_id_ == -1 ? -1 : 0;
00035 #endif /* ACE_WIN32 */
00036 }
00037 
00038 // Attachs to the shared memory segment. 
00039 
00040 ACE_INLINE int
00041 ACE_SV_Shared_Memory::attach (void *virtual_addr, int flags)
00042 {
00043   ACE_TRACE ("ACE_SV_Shared_Memory::attach");
00044 #if defined (ACE_WIN32)
00045         ACE_UNUSED_ARG(flags);
00046         ACE_UNUSED_ARG(virtual_addr);
00047   ACE_NOTSUP_RETURN (-1);
00048 #else
00049   this->segment_ptr_ = ACE_OS::shmat (this->internal_id_, virtual_addr, flags);
00050   return this->segment_ptr_ == (void *) -1 ? -1 : 0;
00051 #endif /* ACE_WIN32 */
00052 }
00053 
00054 // Interface to the underlying shared memory control function. 
00055 
00056 ACE_INLINE int
00057 ACE_SV_Shared_Memory::control (int cmd, void *buf)
00058 {
00059   ACE_TRACE ("ACE_SV_Shared_Memory::control");
00060 #if defined (ACE_WIN32)
00061         ACE_UNUSED_ARG(cmd);
00062         ACE_UNUSED_ARG(buf);
00063         
00064         ACE_NOTSUP_RETURN (-1);
00065 #else
00066   return ACE_OS::shmctl (this->internal_id_, cmd, (struct shmid_ds *) buf);
00067 #endif /* ACE_WIN32 */
00068 }
00069 
00070 // The overall size of the segment. 
00071 
00072 ACE_INLINE size_t
00073 ACE_SV_Shared_Memory::get_segment_size (void) const
00074 {
00075   ACE_TRACE ("ACE_SV_Shared_Memory::get_segment_size");
00076   return this->size_;
00077 }
00078 
00079 // Removes the shared memory segment. 
00080 
00081 ACE_INLINE int
00082 ACE_SV_Shared_Memory::remove (void)
00083 {
00084   ACE_TRACE ("ACE_SV_Shared_Memory::remove");
00085 #if defined (ACE_WIN32)
00086   ACE_NOTSUP_RETURN (-1);
00087 #else
00088   return ACE_OS::shmctl (this->internal_id_, IPC_RMID, 0);
00089 #endif /* ACE_WIN32 */
00090 }
00091 
00092 // Detach the current binding between this->segment_ptr and the shared
00093 // memory segment.
00094 
00095 ACE_INLINE int
00096 ACE_SV_Shared_Memory::detach (void)
00097 {
00098   ACE_TRACE ("ACE_SV_Shared_Memory::detach");
00099   return ACE_OS::shmdt (this->segment_ptr_);
00100 }
00101 
00102 ACE_INLINE void *
00103 ACE_SV_Shared_Memory::get_segment_ptr (void) const
00104 {
00105   ACE_TRACE ("ACE_SV_Shared_Memory::get_segment_ptr");
00106   return this->segment_ptr_;
00107 }
00108 
00109 ACE_INLINE ACE_HANDLE
00110 ACE_SV_Shared_Memory::get_id (void) const
00111 {
00112   ACE_TRACE ("ACE_SV_Shared_Memory::get_id");
00113   return this->internal_id_;
00114 }

Generated on Mon Jun 16 11:21:33 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002