*** empty log message ***

This commit is contained in:
glenux 2004-02-19 10:39:55 +00:00
parent 609eaf5df5
commit a238c8bcdc
2 changed files with 28 additions and 10 deletions

View file

@ -8,6 +8,7 @@
#include <fcntl.h> /* pour O_RDWR */ #include <fcntl.h> /* pour O_RDWR */
#include <sys/types.h> #include <sys/types.h>
#include <sys/mman.h> /* shm_open */ #include <sys/mman.h> /* shm_open */
#include <errno.h>
#define PAGESIZE sysconf(_SC_PAGESIZE) #define PAGESIZE sysconf(_SC_PAGESIZE)
#endif #endif

View file

@ -1,6 +1,5 @@
#include "libnazgul.h" #include "libnazgul.h"
#include <sys/types.h>
#include <sys/mman.h>
/* /*
* spaceId : identifiant externe de l'espace de msg * spaceId : identifiant externe de l'espace de msg
@ -14,30 +13,49 @@ msgSpace * msgSpaceCreate(
int queueNb, int queueNb,
int poolNb, int poolNb,
msgPool * queueNbCar ){ msgPool * queueNbCar ){
msgSpace * result;
int shmId;
msgSpaceId nzgId; msgSpaceId nzgId;
msgSpaceList mSList; msgSpaceList mSList;
int mSFd; // shm file descriptor
static int mSIdNum=-1; static int mSIdNum=-1;
msgSpace * mSAddr;
mSIdNum++; mSIdNum++;
mSAddr=NULL;
/** recuperation de la liste des msgSpace **/ /** recuperation de la liste des msgSpace **/
/* (creation si elle n'existe pas */ /* (creation si elle n'existe pas */
/** on créee le nouvel element **/ /** on créee le nouvel element **/
printf("PAGESIZE : %d\n",(int)PAGESIZE); printf("PAGESIZE : %d\n",(int)PAGESIZE);
nzgId=msgSp2nzgId(spaceId); nzgId=msgSp2nzgId(spaceId);
shmId=shm_open( mSFd=shm_open(
nzgId, nzgId,
O_RDWR|O_CREAT|O_EXCL, O_RDWR|O_CREAT|O_EXCL|O_TRUNC,
MSGSPACE_DEFAULT_MODE MSGSPACE_DEFAULT_MODE
); );
if (shmId < 0 ) { if (mSFd == -1 ) {
perror("shm_open"); fprintf( stderr, "msgSpace creation failed: %s\n",
strerror( errno ) );
return NULL; return NULL;
} }
//on redimentionne l'element
if (ftruncate(mSFd, sizeof(PAGESIZE)) == -1){
fprintf( stderr, "msgSpace resizing failed: %s\n",
strerror( errno ) );
return NULL;
}
/* Map the memory object */
mSAddr = mmap( 0, sizeof( *mSAddr ),
PROT_READ | PROT_WRITE,
MAP_SHARED, mSFd, 0 );
if( mSAddr == MAP_FAILED ) {
fprintf( stderr, "mmap failed: %s\n",
strerror( errno ) );
return NULL;
}
printf( "Map addr is 0x%08x\n", mSAddr );
/* on ajoute spaceId a la liste des msgSpace connus */ /* on ajoute spaceId a la liste des msgSpace connus */
/* on crée queueNb files de messages */ /* on crée queueNb files de messages */
@ -47,8 +65,7 @@ msgSpace * msgSpaceCreate(
/* on attache tout ce beau monde au spaceId */ /* on attache tout ce beau monde au spaceId */
/* on renvoie un pointeur sur le bon spaceId */ /* on renvoie un pointeur sur le bon spaceId */
result=NULL; return mSAddr;
return result;
} }