2 #include "ace/OS_NS_sys_shm.h"
3 #include "ace/Global_Macros.h"
4 #include "ace/OS_NS_errno.h"
6 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
9 ACE_SV_Shared_Memory::round_up (size_t len)
11 ACE_TRACE ("ACE_SV_Shared_Memory::round_up");
12 return (len + ACE_SV_Shared_Memory::ALIGN_WORDB - 1) & ~(ACE_SV_Shared_Memory::ALIGN_WORDB - 1);
15 // Creates a shared memory segment of SIZE bytes. Does *not* attach
16 // this memory segment...
19 ACE_SV_Shared_Memory::open (key_t external_id, size_t sz, int create, int perms)
21 ACE_TRACE ("ACE_SV_Shared_Memory::open");
22 #if defined (ACE_WIN32)
23 ACE_UNUSED_ARG(perms);
24 ACE_UNUSED_ARG(create);
26 ACE_UNUSED_ARG(external_id);
27 ACE_NOTSUP_RETURN (-1);
29 this->segment_ptr_ = 0;
32 this->internal_id_ = ACE_OS::shmget (external_id, sz, create | perms);
34 return this->internal_id_ == -1 ? -1 : 0;
35 #endif /* ACE_WIN32 */
38 // Attachs to the shared memory segment.
41 ACE_SV_Shared_Memory::attach (void *virtual_addr, int flags)
43 ACE_TRACE ("ACE_SV_Shared_Memory::attach");
44 #if defined (ACE_WIN32)
45 ACE_UNUSED_ARG(flags);
46 ACE_UNUSED_ARG(virtual_addr);
47 ACE_NOTSUP_RETURN (-1);
49 this->segment_ptr_ = ACE_OS::shmat (this->internal_id_, virtual_addr, flags);
50 return this->segment_ptr_ == (void *) -1 ? -1 : 0;
51 #endif /* ACE_WIN32 */
54 // Interface to the underlying shared memory control function.
57 ACE_SV_Shared_Memory::control (int cmd, void *buf)
59 ACE_TRACE ("ACE_SV_Shared_Memory::control");
60 #if defined (ACE_WIN32)
63 ACE_NOTSUP_RETURN (-1);
65 return ACE_OS::shmctl (this->internal_id_, cmd, (struct shmid_ds *) buf);
66 #endif /* ACE_WIN32 */
69 // The overall size of the segment.
72 ACE_SV_Shared_Memory::get_segment_size (void) const
74 ACE_TRACE ("ACE_SV_Shared_Memory::get_segment_size");
78 // Removes the shared memory segment.
81 ACE_SV_Shared_Memory::remove (void)
83 ACE_TRACE ("ACE_SV_Shared_Memory::remove");
84 #if defined (ACE_WIN32)
85 ACE_NOTSUP_RETURN (-1);
87 return ACE_OS::shmctl (this->internal_id_, IPC_RMID, 0);
88 #endif /* ACE_WIN32 */
91 // Detach the current binding between this->segment_ptr and the shared
95 ACE_SV_Shared_Memory::detach (void)
97 ACE_TRACE ("ACE_SV_Shared_Memory::detach");
98 return ACE_OS::shmdt (this->segment_ptr_);
102 ACE_SV_Shared_Memory::get_segment_ptr (void) const
104 ACE_TRACE ("ACE_SV_Shared_Memory::get_segment_ptr");
105 return this->segment_ptr_;
108 ACE_INLINE ACE_HANDLE
109 ACE_SV_Shared_Memory::get_id (void) const
111 ACE_TRACE ("ACE_SV_Shared_Memory::get_id");
112 return this->internal_id_;
115 ACE_END_VERSIONED_NAMESPACE_DECL