12 #ifndef SST_CORE_INTERPROCESS_TUNNEL_MMAP_CHILD_PIN3_H
13 #define SST_CORE_INTERPROCESS_TUNNEL_MMAP_CHILD_PIN3_H
15 #include "sst/core/interprocess/tunneldef.h"
21 namespace Interprocess {
28 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) ) {
47 stderr,
"Failed to open file for IPC '%s' (%d): %s\n", filename.c_str(), retval.os_specific_err,
48 strerror(retval.os_specific_err));
53 retval = OS_MapFileToMemory(
54 NATIVE_PID_CURRENT, OS_PAGE_PROTECTION_TYPE_READ | OS_PAGE_PROTECTION_TYPE_WRITE,
57 if ( !OS_RETURN_CODE_IS_SUCCESS(retval) ) {
59 fprintf(stderr,
"mmap failed (%d): %s\n", retval.os_specific_err, strerror(retval.os_specific_err));
64 tunnel =
new TunnelType(shmPtr);
65 shmSize = tunnel->getTunnelSize();
70 retval = OS_MapFileToMemory(
71 NATIVE_PID_CURRENT, OS_PAGE_PROTECTION_TYPE_READ | OS_PAGE_PROTECTION_TYPE_WRITE, shmSize,
72 OS_MEMORY_FLAGS_SHARED, fd, 0, &shmPtr);
74 if ( !OS_RETURN_CODE_IS_SUCCESS(retval) ) {
76 fprintf(stderr,
"mmap failed (%d): %s\n", retval.os_specific_err, strerror(retval.os_specific_err));
83 tunnel->initialize(shmPtr);
90 OS_FreeMemory(NATIVE_PID_CURRENT, shmPtr, shmSize);
101 std::string filename;
111 #endif // SST_CORE_INTERPROCESS_TUNNEL_MMAP_CHILD_PIN3_H
const std::string & getRegionName(void) const
Return the name of the mmap'd file.
Definition: mmapchild_pin3.h:97
Class supports an IPC tunnel between two or more processes, via an mmap'd file This class attaches to...
Definition: mmapchild_pin3.h:29
virtual ~MMAPChild_Pin3()
Close file and shutdown tunnel.
Definition: mmapchild_pin3.h:87
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:36
TunnelType * getTunnel()
return a pointer to the tunnel
Definition: mmapchild_pin3.h:94