make SHM header fixed-size

develop
Petr Mrázek 2010-01-01 23:21:55 +00:00
parent 84c68fb31c
commit a597c69915
4 changed files with 10 additions and 7 deletions

@ -452,7 +452,7 @@ void SHMProcess::read (const uint32_t offset, const uint32_t size, uint8_t *targ
gcc_barrier gcc_barrier
((shm_read *)d->my_shm)->pingpong = DFPP_READ; ((shm_read *)d->my_shm)->pingpong = DFPP_READ;
d->waitWhile(DFPP_READ); d->waitWhile(DFPP_READ);
memcpy (target, d->my_shm + sizeof(shm_ret_data),size); memcpy (target, d->my_shm + SHM_HEADER,size);
} }
uint8_t SHMProcess::readByte (const uint32_t offset) uint8_t SHMProcess::readByte (const uint32_t offset)
@ -544,7 +544,7 @@ void SHMProcess::write (uint32_t offset, uint32_t size, const uint8_t *source)
{ {
((shm_write *)d->my_shm)->address = offset; ((shm_write *)d->my_shm)->address = offset;
((shm_write *)d->my_shm)->length = size; ((shm_write *)d->my_shm)->length = size;
memcpy(d->my_shm+sizeof(shm_write),source, size); memcpy(d->my_shm+SHM_HEADER,source, size);
gcc_barrier gcc_barrier
((shm_write *)d->my_shm)->pingpong = DFPP_WRITE; ((shm_write *)d->my_shm)->pingpong = DFPP_WRITE;
d->waitWhile(DFPP_WRITE); d->waitWhile(DFPP_WRITE);

@ -39,6 +39,7 @@ distribution.
#include <time.h> #include <time.h>
#include <linux/futex.h> #include <linux/futex.h>
#include <sys/syscall.h> #include <sys/syscall.h>
#include <signal.h>
// a full memory barrier! better be safe than sorry. // a full memory barrier! better be safe than sorry.
#define gcc_barrier asm volatile("" ::: "memory"); __sync_synchronize(); #define gcc_barrier asm volatile("" ::: "memory"); __sync_synchronize();
@ -181,8 +182,8 @@ void SHM_Act (void)
/* /*
case DFPP_BOUNCE: case DFPP_BOUNCE:
length = ((shm_bounce *)shm)->length; length = ((shm_bounce *)shm)->length;
memcpy(BigFat,shm + sizeof(shm_bounce),length); memcpy(BigFat,shm + SHM_HEADER,length);
memcpy(shm + sizeof(shm_ret_data),BigFat,length); memcpy(shm + SHM_HEADER,BigFat,length);
((shm_cmd *)shm)->pingpong = DFPP_RET_DATA; ((shm_cmd *)shm)->pingpong = DFPP_RET_DATA;
goto check_again; goto check_again;
*/ */
@ -201,7 +202,7 @@ void SHM_Act (void)
case DFPP_READ: case DFPP_READ:
length = ((shm_read *)shm)->length; length = ((shm_read *)shm)->length;
address = ((shm_read *)shm)->address; address = ((shm_read *)shm)->address;
memcpy(shm + sizeof(shm_ret_data), (void *) address,length); memcpy(shm + SHM_HEADER, (void *) address,length);
gcc_barrier gcc_barrier
((shm_cmd *)shm)->pingpong = DFPP_RET_DATA; ((shm_cmd *)shm)->pingpong = DFPP_RET_DATA;
goto check_again; goto check_again;
@ -230,7 +231,7 @@ void SHM_Act (void)
case DFPP_WRITE: case DFPP_WRITE:
address = ((shm_write *)shm)->address; address = ((shm_write *)shm)->address;
length = ((shm_write *)shm)->length; length = ((shm_write *)shm)->length;
memcpy((void *)address, shm + sizeof(shm_write),length); memcpy((void *)address, shm + SHM_HEADER,length);
gcc_barrier gcc_barrier
((shm_cmd *)shm)->pingpong = DFPP_SUSPENDED; ((shm_cmd *)shm)->pingpong = DFPP_SUSPENDED;
goto check_again; goto check_again;

@ -3,7 +3,9 @@
#define PINGPONG_VERSION 1 #define PINGPONG_VERSION 1
#define SHM_KEY 123466 #define SHM_KEY 123466
#define SHM_SIZE 1024*1024 #define SHM_HEADER 1024
#define SHM_BODY 1024*1024
#define SHM_SIZE SHM_HEADER+SHM_BODY
/* /*
* read - parameters are address and length * read - parameters are address and length

Binary file not shown.