14 #ifndef ECL_IPC_SHARED_MEMORY_RT_HPP_    15 #define ECL_IPC_SHARED_MEMORY_RT_HPP_    22 #if defined(ECL_IS_POSIX)    24 #if !defined(ECL_IS_APPLE)    25 #include <bits/posix_opt.h>    27 #ifdef _POSIX_SHARED_MEMORY_OBJECTS    28 #if _POSIX_SHARED_MEMORY_OBJECTS > 0    34 #ifndef ECL_HAS_POSIX_SHARED_MEMORY    35   #define ECL_HAS_POSIX_SHARED_MEMORY    37 #ifndef ECL_HAS_SHARED_MEMORY    38   #define ECL_HAS_SHARED_MEMORY    65 #ifndef ECL_DISABLE_EXCEPTIONS   104         SharedMemoryBase(
const std::string &name_id) :
   106                 shared_memory_manager(false)
   118         bool shared_memory_manager;
   137 template <
typename Storage>
   138 class ECL_PUBLIC SharedMemory : 
public ipc::SharedMemoryBase
   144         SharedMemory(
const std::string& string_id) 
ecl_throw_decl(StandardException);
   145         virtual ~SharedMemory();
   147         Storage* data() { 
return storage; }         
   151         const int shared_memory_size;
   170 template <
typename Storage>
   171 SharedMemory<Storage>::SharedMemory(
const std::string& string_id ) 
ecl_throw_decl(StandardException)  :
   172         ipc::SharedMemoryBase(std::string(
"/")+string_id),
   173         shared_memory_size(sizeof(Storage)),
   176         int shm_descriptor = open();
   177     if ( shm_descriptor == -1) {
   178         ecl_throw( ipc::openSharedSectionException(LOC) );
   196     if ( (shm_address = mmap(0,shared_memory_size,PROT_READ|PROT_WRITE,MAP_SHARED,shm_descriptor,(
long) 0)) == MAP_FAILED )
   198         shared_memory_manager = 
false;
   199         close(shm_descriptor);
   201         ecl_throw( ipc::memoryMapException(LOC) );
   207     if ( ftruncate(shm_descriptor,shared_memory_size) < 0 )
   209         shared_memory_manager = 
false;
   210         close(shm_descriptor);
   212         ecl_throw(StandardException(LOC,
OpenError,
"Shared memory created, but inflation to the desired size failed."));
   222     close(shm_descriptor);
   224     storage = (Storage*) shm_address;
   227     if ( shared_memory_manager ) {
   228         *storage = Storage();
   236 template <
typename Storage>
   237 SharedMemory<Storage>::~SharedMemory()
   240     munmap( (
void*) storage,shared_memory_size);
   243     if ( shared_memory_manager ) {
 Embedded control libraries. 
#define ecl_throw(exception)
#define ecl_throw_decl(exception)