1 #include "ace/SV_Shared_Memory.h"
2 #include "ace/Log_Category.h"
3 #if defined (ACE_HAS_ALLOC_HOOKS)
4 # include "ace/Malloc_Base.h"
5 #endif /* ACE_HAS_ALLOC_HOOKS */
7 #if !defined (__ACE_INLINE__)
8 #include "ace/SV_Shared_Memory.inl"
9 #endif /* __ACE_INLINE__ */
13 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
15 ACE_ALLOC_HOOK_DEFINE(ACE_SV_Shared_Memory
)
18 ACE_SV_Shared_Memory::dump (void) const
20 #if defined (ACE_HAS_DUMP)
21 ACE_TRACE ("ACE_SV_Shared_Memory::dump");
22 #endif /* ACE_HAS_DUMP */
25 // Creates a shared memory segment of SIZE bytes and *does* attach to
29 ACE_SV_Shared_Memory::open_and_attach (key_t external_id
,
36 ACE_TRACE ("ACE_SV_Shared_Memory::open_and_attach");
37 if (this->open (external_id
, sz
, create
, perms
) == -1)
39 else if (this->attach (virtual_addr
, flags
) == -1)
45 // Constructor interface to this->open_and_attach () member function.
47 ACE_SV_Shared_Memory::ACE_SV_Shared_Memory (key_t external_id
,
54 ACE_TRACE ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory");
55 if (this->open_and_attach (external_id
, sz
, create
,
56 perms
, virtual_addr
, flags
) == -1)
57 ACELIB_ERROR ((LM_ERROR
, ACE_TEXT ("%p\n"),
58 ACE_TEXT ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory")));
61 // The "do nothing" constructor.
63 ACE_SV_Shared_Memory::ACE_SV_Shared_Memory (void)
68 ACE_TRACE ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory");
71 // Added this constructor to accept an internal id, the one generated
72 // when a server constructs with the key IPC_PRIVATE. The client can
73 // be passed ACE_SV_Shared_Memory::internal_id via a socket and call
74 // this construtor to attach the existing segment. This prevents
75 // having to hard-code a key in advance. Courtesy of Marvin Wolfthal
78 ACE_SV_Shared_Memory::ACE_SV_Shared_Memory (ACE_HANDLE int_id
,
80 : internal_id_ (int_id
),
83 ACE_TRACE ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory");
84 if (this->attach (0, flags
) == -1)
85 ACELIB_ERROR ((LM_ERROR
, ACE_TEXT ("%p\n"),
86 ACE_TEXT ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory")));
89 ACE_END_VERSIONED_NAMESPACE_DECL