3 //==========================================================================
5 * @file SV_Shared_Memory.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
9 //==========================================================================
11 #ifndef ACE_SV_SHARED_MEMORY_H
12 #define ACE_SV_SHARED_MEMORY_H
14 #include /**/ "ace/pre.h"
16 #include /**/ "ace/ACE_export.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #include "ace/os_include/sys/os_stat.h"
23 #include "ace/os_include/sys/os_ipc.h"
24 #include "ace/Default_Constants.h"
26 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
29 * @class ACE_SV_Shared_Memory
31 * @brief This is a wrapper for System V shared memory.
33 class ACE_Export ACE_SV_Shared_Memory
38 ACE_CREATE
= IPC_CREAT
,
42 ACE_SV_Shared_Memory ();
43 ACE_SV_Shared_Memory (key_t external_id
,
46 int perms
= ACE_DEFAULT_FILE_PERMS
,
47 void *virtual_addr
= 0,
50 ACE_SV_Shared_Memory (ACE_HANDLE internal_id
,
53 int open (key_t external_id
,
55 int create
= ACE_SV_Shared_Memory::ACE_OPEN
,
56 int perms
= ACE_DEFAULT_FILE_PERMS
);
58 int open_and_attach (key_t external_id
,
60 int create
= ACE_SV_Shared_Memory::ACE_OPEN
,
61 int perms
= ACE_DEFAULT_FILE_PERMS
,
62 void *virtual_addr
= 0,
65 /// Attach this shared memory segment.
66 int attach (void *virtual_addr
= 0, int flags
= 0);
68 /// Detach this shared memory segment.
71 /// Remove this shared memory segment.
74 /// Forward to underlying System V <shmctl>.
75 int control (int cmd
, void *buf
);
77 // = Segment-related info.
78 void *get_segment_ptr () const;
79 size_t get_segment_size () const;
81 /// Return the ID of the shared memory segment (i.e., an ACE_HANDLE).
82 ACE_HANDLE
get_id () const;
84 /// Dump the state of an object.
87 /// Declare the dynamic allocation hooks.
88 ACE_ALLOC_HOOK_DECLARE
;
93 /// Most restrictive alignment.
97 /// Internal identifier.
98 ACE_HANDLE internal_id_
;
100 /// Size of the mapped segment.
103 /// Pointer to the beginning of the segment.
106 /// Round up to an appropriate page size.
107 size_t round_up (size_t len
);
110 ACE_END_VERSIONED_NAMESPACE_DECL
112 #if defined (__ACE_INLINE__)
113 #include "ace/SV_Shared_Memory.inl"
114 #endif /* __ACE_INLINE__ */
116 #include /**/ "ace/post.h"
118 #endif /* ACE_SV_SHARED_MEMORY_H */