3 //==========================================================================
5 * @file SV_Shared_Memory.h
7 * $Id: SV_Shared_Memory.h 80826 2008-03-04 14:51:23Z wotte $
9 * @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
11 //==========================================================================
13 #ifndef ACE_SV_SHARED_MEMORY_H
14 #define ACE_SV_SHARED_MEMORY_H
16 #include /**/ "ace/pre.h"
18 #include /**/ "ace/ACE_export.h"
20 #if !defined (ACE_LACKS_PRAGMA_ONCE)
22 #endif /* ACE_LACKS_PRAGMA_ONCE */
24 #include "ace/os_include/sys/os_stat.h"
25 #include "ace/os_include/sys/os_ipc.h"
26 #include "ace/Default_Constants.h"
28 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
31 * @class ACE_SV_Shared_Memory
33 * @brief This is a wrapper for System V shared memory.
35 class ACE_Export ACE_SV_Shared_Memory
40 ACE_CREATE
= IPC_CREAT
,
44 // = Initialization and termination methods.
45 ACE_SV_Shared_Memory (void);
46 ACE_SV_Shared_Memory (key_t external_id
,
49 int perms
= ACE_DEFAULT_FILE_PERMS
,
50 void *virtual_addr
= 0,
53 ACE_SV_Shared_Memory (ACE_HANDLE internal_id
,
56 int open (key_t external_id
,
58 int create
= ACE_SV_Shared_Memory::ACE_OPEN
,
59 int perms
= ACE_DEFAULT_FILE_PERMS
);
61 int open_and_attach (key_t external_id
,
63 int create
= ACE_SV_Shared_Memory::ACE_OPEN
,
64 int perms
= ACE_DEFAULT_FILE_PERMS
,
65 void *virtual_addr
= 0,
68 /// Attach this shared memory segment.
69 int attach (void *virtual_addr
= 0, int flags
= 0);
71 /// Detach this shared memory segment.
74 /// Remove this shared memory segment.
77 /// Forward to underlying System V <shmctl>.
78 int control (int cmd
, void *buf
);
80 // = Segment-related info.
81 void *get_segment_ptr (void) const;
82 size_t get_segment_size (void) const;
84 /// Return the ID of the shared memory segment (i.e., an ACE_HANDLE).
85 ACE_HANDLE
get_id (void) const;
87 /// Dump the state of an object.
88 void dump (void) const;
90 /// Declare the dynamic allocation hooks.
91 ACE_ALLOC_HOOK_DECLARE
;
96 /// Most restrictive alignment.
100 /// Internal identifier.
101 ACE_HANDLE internal_id_
;
103 /// Size of the mapped segment.
106 /// Pointer to the beginning of the segment.
109 /// Round up to an appropriate page size.
110 size_t round_up (size_t len
);
113 ACE_END_VERSIONED_NAMESPACE_DECL
115 #if defined (__ACE_INLINE__)
116 #include "ace/SV_Shared_Memory.inl"
117 #endif /* __ACE_INLINE__ */
119 #include /**/ "ace/post.h"
121 #endif /* ACE_SV_SHARED_MEMORY_H */