1#include <stdlib.h> 2#include <stdio.h> 3#include <sys/stat.h> 4#include <sys/mman.h> 5#include <string.h> 6 7#ifndef MAP_NORESERVE 8#define MAP_NORESERVE 0 9#endif 10 11volatile char ch; 12 13main(){ 14 struct stat statbuf; 15 uchar *buf; 16 fstat(0, &statbuf); 17 buf = mmap(NULL, statbuf.st_size, PROT_READ, MAP_SHARED|MAP_NORESERVE, 18 0, 0); 19 if(buf != (uchar*)(-1)){ 20 uchar *cur, *lim = &buf[statbuf.st_size]; 21 for(cur = buf; buf != lim; ++cur){ 22 ch = *cur; 23 } 24 munmap(buf, statbuf.st_size); 25 } 26} 27