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);
msgPoolDataTabUnlock(space);
printf( "alloc de 0x%08x\n", (int)resultAddr);
printf( "alloc de %p\n", (void *)resultAddr);
return resultAddr;
ERROR:
NZG_ERROR("msgAllocate","error processing");
msgPoolDataTabUnlock(space);

View file

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

View file

@ -11,7 +11,7 @@ int msgFree(msgSpace * space, void * addr){
int bufferNb;
int bufferSize;
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 protege le tableau des associations */
if (msgPoolDataTabLock(space) <0){

View file

@ -24,6 +24,9 @@ int msgPut(msgSpace * space,int queueIndex, void * addr){
&bufferIndex,
addr
);
if (err) {
//FIXME
}
// ouvrir la queue avec le bon index
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
msgQueueReadUnlock(space->externId,queueIndex);
return 0;
ERROR:
return -1;
}

View file

@ -97,7 +97,7 @@ msgSpace * msgSpaceCreate(
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 */
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);
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;
}