From 3e32be77060b08c09b8240941a594320495b94f3 Mon Sep 17 00:00:00 2001 From: stormrider1982 Date: Tue, 24 Feb 2004 21:48:30 +0000 Subject: [PATCH] =?UTF-8?q?bufferMap=20pas=20encore=20fini...=20:(=C2=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/bufferMap.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/bufferMap.c diff --git a/src/bufferMap.c b/src/bufferMap.c new file mode 100644 index 0000000..94aecc0 --- /dev/null +++ b/src/bufferMap.c @@ -0,0 +1,39 @@ +#include "libnazgul.h" + + +void * msgBufferMap(msgSpace * space, int poolIndex, int bufferIndex) { + void * resultAddr; + + msgBufferInfoTabId bufferInfoTabId; + int bufferInfoTabFd; + + // TODO: récuperer l'ID du BufferInfoTab; + strcpy(bufferInfoTabId, poolDataTabAddr[poolIndex].bufferInfoTabId); + + + bufferInfoTabFd=shm_open(bufferInfoTabId,O_RDWR,SHM_DEFAULT_MODE); + if (bufferInfoTabFd<0){ + NZG_ERROR("sem_open",bufferInfoTabId); + return -1; + } + + + if(msPoolFd == -1) { + NZG_ERROR("shm_open", space->poolDataTabId); + goto ERROR; + } + + // mapper le buffer dans l'espace mémoire du processus + resultAddr=mmap(NULL, buffersize, PROT_WRITE|PROT_READ, MAP_SHARED, msPoolFd, (off_t)0); + + if(resultAddr == MAP_FAILED) { + NZG_ERROR("mmap", poolDataTabId); + goto ERROR; + } + + close(msPoolFd); + + return resultAddr; +ERROR: + return NULL; +}