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__ */
11 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
13 ACE_ALLOC_HOOK_DEFINE(ACE_SV_Shared_Memory
)
16 ACE_SV_Shared_Memory::dump () const
18 #if defined (ACE_HAS_DUMP)
19 ACE_TRACE ("ACE_SV_Shared_Memory::dump");
20 #endif /* ACE_HAS_DUMP */
23 // Creates a shared memory segment of SIZE bytes and *does* attach to
27 ACE_SV_Shared_Memory::open_and_attach (key_t external_id
,
34 ACE_TRACE ("ACE_SV_Shared_Memory::open_and_attach");
35 if (this->open (external_id
, sz
, create
, perms
) == -1)
37 else if (this->attach (virtual_addr
, flags
) == -1)
43 // Constructor interface to this->open_and_attach () member function.
45 ACE_SV_Shared_Memory::ACE_SV_Shared_Memory (key_t external_id
,
52 ACE_TRACE ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory");
53 if (this->open_and_attach (external_id
, sz
, create
,
54 perms
, virtual_addr
, flags
) == -1)
55 ACELIB_ERROR ((LM_ERROR
, ACE_TEXT ("%p\n"),
56 ACE_TEXT ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory")));
59 // The "do nothing" constructor.
61 ACE_SV_Shared_Memory::ACE_SV_Shared_Memory ()
66 ACE_TRACE ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory");
69 // Added this constructor to accept an internal id, the one generated
70 // when a server constructs with the key IPC_PRIVATE. The client can
71 // be passed ACE_SV_Shared_Memory::internal_id via a socket and call
72 // this constructor to attach the existing segment. This prevents
73 // having to hard-code a key in advance. Courtesy of Marvin Wolfthal
76 ACE_SV_Shared_Memory::ACE_SV_Shared_Memory (ACE_HANDLE int_id
,
78 : internal_id_ (int_id
),
81 ACE_TRACE ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory");
82 if (this->attach (0, flags
) == -1)
83 ACELIB_ERROR ((LM_ERROR
, ACE_TEXT ("%p\n"),
84 ACE_TEXT ("ACE_SV_Shared_Memory::ACE_SV_Shared_Memory")));
87 ACE_END_VERSIONED_NAMESPACE_DECL