12 #ifndef SST_CORE_INTERPROCESS_TUNNEL_MMAP_CHILD_PIN3_H
13 #define SST_CORE_INTERPROCESS_TUNNEL_MMAP_CHILD_PIN3_H 1
17 #include "sst/core/interprocess/tunneldef.h"
21 namespace Interprocess {
29 template<
typename TunnelType>
42 OS_RETURN_CODE retval = OS_OpenFD(filename.c_str(), OS_FILE_OPEN_TYPE_READ | OS_FILE_OPEN_TYPE_WRITE, 0, &fd);
44 if (!OS_RETURN_CODE_IS_SUCCESS(retval)) {
46 fprintf(stderr,
"Failed to open file for IPC '%s' (%d): %s\n",
47 filename.c_str(), retval.os_specific_err, strerror(retval.os_specific_err));
52 retval = OS_MapFileToMemory(NATIVE_PID_CURRENT, OS_PAGE_PROTECTION_TYPE_READ | OS_PAGE_PROTECTION_TYPE_WRITE,
55 if (!OS_RETURN_CODE_IS_SUCCESS(retval)) {
57 fprintf(stderr,
"mmap failed (%d): %s\n", retval.os_specific_err, strerror(retval.os_specific_err));
62 tunnel =
new TunnelType(shmPtr);
63 shmSize = tunnel->getTunnelSize();
68 retval = OS_MapFileToMemory(NATIVE_PID_CURRENT, OS_PAGE_PROTECTION_TYPE_READ | OS_PAGE_PROTECTION_TYPE_WRITE,
69 shmSize, OS_MEMORY_FLAGS_SHARED, fd, 0, &shmPtr);
71 if (!OS_RETURN_CODE_IS_SUCCESS(retval)) {
73 fprintf(stderr,
"mmap failed (%d): %s\n", retval.os_specific_err, strerror(retval.os_specific_err));
80 tunnel->initialize(shmPtr);
86 OS_FreeMemory(NATIVE_PID_CURRENT, shmPtr, shmSize);
const std::string & getRegionName(void) const
Return the name of the mmap'd file.
Definition: mmapchild_pin3.h:93
Class supports an IPC tunnel between two or more processes, via an mmap'd file This class attaches to...
Definition: mmapchild_pin3.h:30
virtual ~MMAPChild_Pin3()
Close file and shutdown tunnel.
Definition: mmapchild_pin3.h:84
MMAPChild_Pin3(const std::string &file_name)
Child-side tunnel manager for an IPC tunnel Opens an existing file and mmaps it using PinCRT...
Definition: mmapchild_pin3.h:38
Definition: tunneldef.h:37
TunnelType * getTunnel()
return a pointer to the tunnel
Definition: mmapchild_pin3.h:90