* 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
# @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

View file

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

View file

@ -1,10 +1,10 @@
#include <stdlib.h>
#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;
}
*/

View file

@ -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;

View file

@ -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);

View file

@ -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;
}