* ajouté du preprocessing pour les ID en fonction du systeme

This commit is contained in:
glenux 2004-02-19 18:27:41 +00:00
parent 79381b310f
commit 87b252bfa4
6 changed files with 34 additions and 16 deletions

View file

@ -1,11 +1,6 @@
### HEADER HERE ### HEADER HERE
# @CLASSPATH=$(CLASSPATH) $(JAVAC) $(JFLAGS) $< OS=$(shell uname -s)
#INCLUDES=-I/
#LIBINC=-L
#LIBS=
CC=gcc CC=gcc
CFLAGS=-ggdb -Wall -O2 CFLAGS=-ggdb -Wall -O2
#-O2 #-O2
@ -20,6 +15,21 @@ CFILES := $(shell ls *.c)
OFILES := $(patsubst %.c,%.o,$(CFILES)) OFILES := $(patsubst %.c,%.o,$(CFILES))
DESTFILE=libnazgul.a DESTFILE=libnazgul.a
DEFINES:=
ifeq "SunOS" "${OS}"
DEFINES:=-D_NZG_REALFILEID
endif
ifeq "HP-UX" "${OS}"
DEFINES:=-D_NZG_REALFILEID
endif
ifeq "Linux" "${OS}"
#DEFINES:=-D_NZG_REALFILEID
endif
all: build all: build
build : $(OFILES) build : $(OFILES)
@ -32,5 +42,7 @@ clean:
@rm -f *.o @rm -f *.o
%.o : %.c %.o : %.c
$(CC) $(CFLAGS) -c $< $(INCLUDES) $(LIBINC) $(LIBS) -o $*.o $(CC) $(CFLAGS) -c $< $(INCLUDES) $(LIBINC) $(LIBS) $(DEFINES) -o $*.o
edit:
gvim *.c *.h

View file

@ -11,4 +11,5 @@
#include <errno.h> #include <errno.h>
#define PAGESIZE sysconf(_SC_PAGESIZE) #define PAGESIZE sysconf(_SC_PAGESIZE)
#endif #endif

View file

@ -1,10 +1,10 @@
#include <stdlib.h>
#include "libnazgul.h" #include "libnazgul.h"
char ** msgSpaceIdList(){ /*
void msgSpaceIdList(msgSpaceListId){
// i = le nombre d'id publics disponnibles // i = le nombre d'id publics disponnibles
int i=0; int i=0;
char ** idList; msgSpaceListId idList;
idList=(char **)malloc(i*sizeof(char *)); return;
return idList;
} }
*/

View file

@ -28,7 +28,7 @@ int msgPoolCreate(
// on met le pool a la taille voulue pour qu'il // on met le pool a la taille voulue pour qu'il
// puisse contenir les buffs // puisse contenir les buffs
if (ftruncate(poolFd, sizeof((buffSize)*buffNb)) == -1){ if (ftruncate(poolFd, (buffSize*buffNb)) == -1){
fprintf( stderr, "msgPool resizing failed: %s\n", fprintf( stderr, "msgPool resizing failed: %s\n",
strerror( errno ) ); strerror( errno ) );
return -1; return -1;

View file

@ -2,7 +2,7 @@
#define _NZG_PROTO 1 #define _NZG_PROTO 1
/* nzg_list.c */ /* nzg_list.c */
char **msgSpaceIdList(void); /* msgSpaceListId msgSpaceIdList(void); */
/* nzg_pool.c */ /* nzg_pool.c */
int msgPoolCreate(msgSpacePoolId poolId, int buffNb, int buffSize); int msgPoolCreate(msgSpacePoolId poolId, int buffNb, int buffSize);
int msgSpacePoolId2nzgPoolId(msgSpacePoolId dest, msgSpacePoolId src, int num); int msgSpacePoolId2nzgPoolId(msgSpacePoolId dest, msgSpacePoolId src, int num);

View file

@ -27,7 +27,8 @@ msgSpace * msgSpaceCreate(
/** on créee le nouvel element **/ /** on créee le nouvel element **/
printf("PAGESIZE : %d\n",(int)PAGESIZE); printf("PAGESIZE : %d\n",(int)PAGESIZE);
msgSp2nzgId(spaceId,nzgId); msgSp2nzgId(nzgId,spaceId);
printf("Id interne : %s\n",nzgId);
mSFd=shm_open( mSFd=shm_open(
nzgId, nzgId,
O_RDWR|O_CREAT|O_EXCL|O_TRUNC, O_RDWR|O_CREAT|O_EXCL|O_TRUNC,
@ -51,7 +52,7 @@ msgSpace * msgSpaceCreate(
mSAddr = mmap( 0, sizeof( *mSAddr ), mSAddr = mmap( 0, sizeof( *mSAddr ),
PROT_READ | PROT_WRITE, PROT_READ | PROT_WRITE,
MAP_SHARED, mSFd, 0 ); MAP_SHARED, mSFd, 0 );
if( mSAddr == MAP_FAILED ) { if( mSAddr == NULL ) {
fprintf( stderr, "mmap failed: %s\n", fprintf( stderr, "mmap failed: %s\n",
strerror( errno ) ); strerror( errno ) );
return NULL; return NULL;
@ -116,6 +117,10 @@ int msgSp2nzgId(msgSpaceId dest,const msgSpaceId src ){
return -1; return -1;
} }
/* sprintf(resNzgId,"/tmp/.nzg-%s",(char *)spaceId); */ /* sprintf(resNzgId,"/tmp/.nzg-%s",(char *)spaceId); */
#ifdef _NZG_REALFILEID
sprintf(dest,"/tmp/nzgSpace%s",(char *)src);
#else
sprintf(dest,"/nzgSpace%s",(char *)src); sprintf(dest,"/nzgSpace%s",(char *)src);
#endif
return 0; return 0;
} }