28 lines
701 B
C
28 lines
701 B
C
#include "libnazgul.h"
|
|
#include "ids.h"
|
|
|
|
/* prototypes des fonctions annexes à ne pas exporter */
|
|
int msgSpaceIdIntern(msgSpaceId dest, const msgSpaceId src);
|
|
int msgPoolDataIdIntern(msgSpaceId dest, const msgSpaceId src);
|
|
|
|
msgSpace *msgSpaceOpen(msgSpaceId externId)
|
|
{
|
|
int shmFd;
|
|
msgSpaceId nzgId;
|
|
msgSpace *mSAddr;
|
|
if (msgSpaceIdIntern(nzgId, externId) < 0) {
|
|
return NULL;
|
|
}
|
|
if ((shmFd = shm_open(nzgId, O_RDWR, MSGSPACE_DEFAULT_MODE)) < 0) {
|
|
perror("shm_open");
|
|
return NULL;
|
|
}
|
|
mSAddr =
|
|
mmap(NULL, sizeof(msgSpace), PROT_READ | PROT_WRITE, MAP_SHARED,
|
|
shmFd, (off_t) 0);
|
|
|
|
printf("OPEN: msgSpace mapped to %p in %d\n", (void *)mSAddr,
|
|
(int)getpid());
|
|
return mSAddr;
|
|
}
|