*** 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 <sys/types.h>
#include <sys/mman.h> /* shm_open */
#include <errno.h>
#define PAGESIZE sysconf(_SC_PAGESIZE)
#endif

View file

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