Fix pointer display

This commit is contained in:
Glenn Y. Rolland 2020-03-04 00:00:08 +01:00
parent 3dc81d8cf8
commit e2692e8547
6 changed files with 25 additions and 17 deletions

View file

@ -204,8 +204,9 @@ if (mSPoolDataTabAddr==NULL){
msgPoolDataTabClose(space,mSPoolDataTabAddr); msgPoolDataTabClose(space,mSPoolDataTabAddr);
msgPoolDataTabUnlock(space); msgPoolDataTabUnlock(space);
printf( "alloc de 0x%08x\n", (int)resultAddr); printf( "alloc de %p\n", (void *)resultAddr);
return resultAddr; return resultAddr;
ERROR: ERROR:
NZG_ERROR("msgAllocate","error processing"); NZG_ERROR("msgAllocate","error processing");
msgPoolDataTabUnlock(space); msgPoolDataTabUnlock(space);

View file

@ -11,6 +11,9 @@ void * msgBufferMap(msgPoolData * poolDataTab, int poolIndex, int bufferIndex) {
strcpy(poolBufferTabId, poolDataTab[poolIndex].poolId); strcpy(poolBufferTabId, poolDataTab[poolIndex].poolId);
bufferSize = poolDataTab[poolIndex].bufferSize; bufferSize = poolDataTab[poolIndex].bufferSize;
bufferNb = poolDataTab[poolIndex].bufferNb; bufferNb = poolDataTab[poolIndex].bufferNb;
if (bufferNb < 0) {
// do something with bufferNb
}
poolBufferTabFd=shm_open(poolBufferTabId,O_RDWR,SHM_DEFAULT_MODE); poolBufferTabFd=shm_open(poolBufferTabId,O_RDWR,SHM_DEFAULT_MODE);
if (poolBufferTabFd<0){ if (poolBufferTabFd<0){
@ -30,13 +33,13 @@ void * msgBufferMap(msgPoolData * poolDataTab, int poolIndex, int bufferIndex) {
NZG_ERROR("mmap", poolBufferTabId); NZG_ERROR("mmap", poolBufferTabId);
goto ERROR; goto ERROR;
} }
printf( "Mapped from 0x%08x to 0x%08x\n", printf( "Mapped from %p to %p\n",
(int)resultAddr, (void *)resultAddr,
(int)resultAddr+ bufferSize*(bufferIndex+1) (void *)(resultAddr+ bufferSize*(bufferIndex+1))
); );
resultAddr=resultAddr +( bufferSize*bufferIndex); resultAddr=resultAddr +( bufferSize*bufferIndex);
printf( "Moved to 0x%08x\n",(int)resultAddr ); printf( "Moved to %p\n",(void *)resultAddr );
/* mprotect( /* mprotect(
resultAddr, resultAddr,

View file

@ -11,7 +11,7 @@ int msgFree(msgSpace * space, void * addr){
int bufferNb; int bufferNb;
int bufferSize; int bufferSize;
void * realAddr; void * realAddr;
printf("[ FREE 0x%08x ]\n",(int)addr); printf("[ FREE %p ]\n",(void *)addr);
/* on acquiert le droit de modifier les infos sur la ressource */ /* on acquiert le droit de modifier les infos sur la ressource */
/* on protege le tableau des associations */ /* on protege le tableau des associations */
if (msgPoolDataTabLock(space) <0){ if (msgPoolDataTabLock(space) <0){

View file

@ -24,6 +24,9 @@ int msgPut(msgSpace * space,int queueIndex, void * addr){
&bufferIndex, &bufferIndex,
addr addr
); );
if (err) {
//FIXME
}
// ouvrir la queue avec le bon index // ouvrir la queue avec le bon index
msgQueueIdIntern(queueId,space->externId,queueIndex); msgQueueIdIntern(queueId,space->externId,queueIndex);
@ -63,6 +66,7 @@ int msgPut(msgSpace * space,int queueIndex, void * addr){
// on laisse une nouvelle ressource de la liste au get // on laisse une nouvelle ressource de la liste au get
msgQueueReadUnlock(space->externId,queueIndex); msgQueueReadUnlock(space->externId,queueIndex);
return 0; return 0;
ERROR: ERROR:
return -1; return -1;
} }

View file

@ -97,7 +97,7 @@ msgSpace * msgSpaceCreate(
goto ERROR; goto ERROR;
} }
printf( "CREAT: msgSpace mapped to 0x%08x in %d\n", (int)space,(int)getpid()); printf( "CREAT: msgSpace mapped to 0x%08lx in %d\n", (long)space,(int)getpid());
/* on ferme le descripteur du fichier */ /* on ferme le descripteur du fichier */
close(mSFd); close(mSFd);

View file

@ -19,7 +19,7 @@ msgSpace * msgSpaceOpen(msgSpaceId externId){
} }
mSAddr=mmap(NULL,sizeof(msgSpace),PROT_READ|PROT_WRITE,MAP_SHARED,shmFd,(off_t)0); mSAddr=mmap(NULL,sizeof(msgSpace),PROT_READ|PROT_WRITE,MAP_SHARED,shmFd,(off_t)0);
printf( "OPEN: msgSpace mapped to 0x%08x in %d\n", (int)mSAddr,(int)getpid()); printf( "OPEN: msgSpace mapped to %p in %d\n", (void *)mSAddr,(int)getpid());
return mSAddr; return mSAddr;
} }