From 87b252bfa4a94407b98dfa91631786f986178b88 Mon Sep 17 00:00:00 2001 From: glenux Date: Thu, 19 Feb 2004 18:27:41 +0000 Subject: [PATCH] =?UTF-8?q?*=20ajout=C3=A9=20du=20preprocessing=20pour=20l?= =?UTF-8?q?es=20ID=20en=20fonction=20du=20systeme?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Makefile | 26 +++++++++++++++++++------- src/nzg_global.h | 1 + src/nzg_list.c | 10 +++++----- src/nzg_pool.c | 2 +- src/nzg_proto.h | 2 +- src/nzg_spaces.c | 9 +++++++-- 6 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/Makefile b/src/Makefile index 7da086b..045eca0 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,11 +1,6 @@ ### HEADER HERE -# @CLASSPATH=$(CLASSPATH) $(JAVAC) $(JFLAGS) $< - -#INCLUDES=-I/ -#LIBINC=-L -#LIBS= - +OS=$(shell uname -s) CC=gcc CFLAGS=-ggdb -Wall -O2 #-O2 @@ -20,6 +15,21 @@ CFILES := $(shell ls *.c) OFILES := $(patsubst %.c,%.o,$(CFILES)) 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 build : $(OFILES) @@ -32,5 +42,7 @@ clean: @rm -f *.o %.o : %.c - $(CC) $(CFLAGS) -c $< $(INCLUDES) $(LIBINC) $(LIBS) -o $*.o + $(CC) $(CFLAGS) -c $< $(INCLUDES) $(LIBINC) $(LIBS) $(DEFINES) -o $*.o +edit: + gvim *.c *.h diff --git a/src/nzg_global.h b/src/nzg_global.h index 34a84fa..57f26ab 100644 --- a/src/nzg_global.h +++ b/src/nzg_global.h @@ -11,4 +11,5 @@ #include #define PAGESIZE sysconf(_SC_PAGESIZE) + #endif diff --git a/src/nzg_list.c b/src/nzg_list.c index b270c71..005c0bb 100644 --- a/src/nzg_list.c +++ b/src/nzg_list.c @@ -1,10 +1,10 @@ -#include #include "libnazgul.h" -char ** msgSpaceIdList(){ +/* +void msgSpaceIdList(msgSpaceListId){ // i = le nombre d'id publics disponnibles int i=0; - char ** idList; - idList=(char **)malloc(i*sizeof(char *)); - return idList; + msgSpaceListId idList; + return; } +*/ diff --git a/src/nzg_pool.c b/src/nzg_pool.c index c807c3f..e1e9907 100644 --- a/src/nzg_pool.c +++ b/src/nzg_pool.c @@ -28,7 +28,7 @@ int msgPoolCreate( // on met le pool a la taille voulue pour qu'il // puisse contenir les buffs - if (ftruncate(poolFd, sizeof((buffSize)*buffNb)) == -1){ + if (ftruncate(poolFd, (buffSize*buffNb)) == -1){ fprintf( stderr, "msgPool resizing failed: %s\n", strerror( errno ) ); return -1; diff --git a/src/nzg_proto.h b/src/nzg_proto.h index 3ab05eb..ee3a9dd 100644 --- a/src/nzg_proto.h +++ b/src/nzg_proto.h @@ -2,7 +2,7 @@ #define _NZG_PROTO 1 /* nzg_list.c */ -char **msgSpaceIdList(void); +/* msgSpaceListId msgSpaceIdList(void); */ /* nzg_pool.c */ int msgPoolCreate(msgSpacePoolId poolId, int buffNb, int buffSize); int msgSpacePoolId2nzgPoolId(msgSpacePoolId dest, msgSpacePoolId src, int num); diff --git a/src/nzg_spaces.c b/src/nzg_spaces.c index 7aa57c9..1d42190 100644 --- a/src/nzg_spaces.c +++ b/src/nzg_spaces.c @@ -27,7 +27,8 @@ msgSpace * msgSpaceCreate( /** on créee le nouvel element **/ printf("PAGESIZE : %d\n",(int)PAGESIZE); - msgSp2nzgId(spaceId,nzgId); + msgSp2nzgId(nzgId,spaceId); + printf("Id interne : %s\n",nzgId); mSFd=shm_open( nzgId, O_RDWR|O_CREAT|O_EXCL|O_TRUNC, @@ -51,7 +52,7 @@ msgSpace * msgSpaceCreate( mSAddr = mmap( 0, sizeof( *mSAddr ), PROT_READ | PROT_WRITE, MAP_SHARED, mSFd, 0 ); - if( mSAddr == MAP_FAILED ) { + if( mSAddr == NULL ) { fprintf( stderr, "mmap failed: %s\n", strerror( errno ) ); return NULL; @@ -116,6 +117,10 @@ int msgSp2nzgId(msgSpaceId dest,const msgSpaceId src ){ return -1; } /* sprintf(resNzgId,"/tmp/.nzg-%s",(char *)spaceId); */ +#ifdef _NZG_REALFILEID + sprintf(dest,"/tmp/nzgSpace%s",(char *)src); +#else sprintf(dest,"/nzgSpace%s",(char *)src); +#endif return 0; }