読出しサンプル

#include < stdio.h >
#include < math.h >
#include < fcnt1.h >
#include < math.h >
#include < sys/types.h >
#include < unistd.h >
#include < sys/mman.h >
typedef struct {
    char str[512];
    long lval;
    double dval;
}SSS;
#define NUMBER (10000)
void main()
{
    int fd;
    long psize,size;
    SSS *ptr;
    long i;
    if((fd=open("MapFile",O_RDWR))== -1){
        perror("open");
        exit(-1);
    }
#ifdef BSD
    psize=getpagesize();
#else
    psize=sysconf(_SC_PAGE_SIZE);
#endif
    size=(NUMBER*sizeof(SSS)/psize+1)*psize;
    /* map */
    ptr=(SSS *)mmap(0,size,PROT_READ|PROT_WRITE,MAP_SHARED,fd,0);
    /* test */
    while(1){
        for(i=0;i