AMF-Placer
2.0
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
ProcessFuncInterface.h
Go to the documentation of this file.
1
25
#ifndef _PROCESSFUNCINTERFACE
26
#define _PROCESSFUNCINTERFACE
27
28
#include "
strPrint.h
"
29
#include <assert.h>
30
#include <fcntl.h>
31
#include <functional>
32
#include <iomanip>
33
#include <iostream>
34
#include <limits.h>
35
#include <stdio.h>
36
#include <stdlib.h>
37
#include <string.h>
38
#include <string>
39
#include <sys/shm.h>
40
#include <sys/stat.h>
41
#include <sys/types.h>
42
#include <sys/wait.h>
43
#include <unistd.h>
44
#include <unordered_set>
45
46
class
ProcessFuncInterface
47
{
48
public
:
49
ProcessFuncInterface
(
unsigned
int
shmSize
, key_t
sharedid
) :
shmSize
(
shmSize
),
sharedid
(
sharedid
)
50
{
51
createShareMemory
();
52
}
53
54
~ProcessFuncInterface
()
55
{
56
deleteShareMemory
();
57
}
58
59
void
createShareMemory
()
60
{
61
shmid
= shmget((key_t)
sharedid
,
shmSize
, 0666 | IPC_CREAT);
62
if
(
shmid
== -1)
63
{
64
fprintf(stderr,
"shmget failed\n"
);
65
exit(EXIT_FAILURE);
66
}
67
shm
= shmat(
shmid
, 0, 0);
68
if
(
shm
== (
void
*)-1)
69
{
70
fprintf(stderr,
"shmat failed\n"
);
71
exit(EXIT_FAILURE);
72
}
73
// printf("Memory attached at %llX\n", (unsigned long long)shm);
74
}
75
76
void
deleteShareMemory
()
77
{
78
if
(shmdt(
shm
) == -1)
79
{
80
fprintf(stderr,
"shmdt failed\n"
);
81
exit(EXIT_FAILURE);
82
}
83
}
84
85
inline
void
*
getSharedMemory
()
86
{
87
return
shm
;
88
}
89
90
private
:
91
int
shmid
;
92
void
*
shm
= NULL;
93
unsigned
int
shmSize
;
94
key_t
sharedid
;
95
};
96
97
#endif
ProcessFuncInterface::shm
void * shm
Definition:
ProcessFuncInterface.h:92
ProcessFuncInterface::createShareMemory
void createShareMemory()
Definition:
ProcessFuncInterface.h:59
ProcessFuncInterface::shmid
int shmid
Definition:
ProcessFuncInterface.h:91
ProcessFuncInterface::deleteShareMemory
void deleteShareMemory()
Definition:
ProcessFuncInterface.h:76
ProcessFuncInterface::sharedid
key_t sharedid
Definition:
ProcessFuncInterface.h:94
ProcessFuncInterface::ProcessFuncInterface
ProcessFuncInterface(unsigned int shmSize, key_t sharedid)
Definition:
ProcessFuncInterface.h:49
ProcessFuncInterface
Definition:
ProcessFuncInterface.h:47
strPrint.h
ProcessFuncInterface::getSharedMemory
void * getSharedMemory()
Definition:
ProcessFuncInterface.h:85
ProcessFuncInterface::~ProcessFuncInterface
~ProcessFuncInterface()
Definition:
ProcessFuncInterface.h:54
ProcessFuncInterface::shmSize
unsigned int shmSize
Definition:
ProcessFuncInterface.h:93
src
lib
utils
ProcessFuncInterface.h
Generated by
1.8.18