Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / SV_Shared_Memory.cpp
blobeea8680e145868a8823b1183e63dd4c6bebef2b4
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)
15 void
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
24 // this segment.
26 int
27 ACE_SV_Shared_Memory::open_and_attach (key_t external_id,
28 size_t sz,
29 int create,
30 int perms,
31 void *virtual_addr,
32 int flags)
34 ACE_TRACE ("ACE_SV_Shared_Memory::open_and_attach");
35 if (this->open (external_id, sz, create, perms) == -1)
36 return -1;
37 else if (this->attach (virtual_addr, flags) == -1)
38 return -1;
39 else
40 return 0;
43 // Constructor interface to this->open_and_attach () member function.
45 ACE_SV_Shared_Memory::ACE_SV_Shared_Memory (key_t external_id,
46 size_t sz,
47 int create,
48 int perms,
49 void *virtual_addr,
50 int flags)
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 ()
62 : internal_id_ (0),
63 size_ (0),
64 segment_ptr_ (0)
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
74 // (maw@fsg.com).
76 ACE_SV_Shared_Memory::ACE_SV_Shared_Memory (ACE_HANDLE int_id,
77 int flags)
78 : internal_id_ (int_id),
79 size_ (0)
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