/* $Id: xs_test.c,v 1.2 2002/10/29 06:23:56 hio Exp $ */ #include "mediate.h" #include /* memmap */ #include /* memmap */ #include /* stat */ #include /* open */ #ifndef MAP_FAILED #define MAP_FAILED ((void*)-1) #endif void* do_memmap(char* filepath) { int fd; struct stat st; int res; void* ptr; fd = open(filepath,O_RDONLY|O_NONBLOCK); res = fstat(fd,&st); if( res==-1 ) { st.st_size = 0; } ptr = mmap(NULL,st.st_size,PROT_READ,MAP_PRIVATE,fd,0); close(fd); return ptr; } void do_unmemmap(void* ptr) { munmap(ptr,0); }