145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#include <stdlib.h> 245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#include <stdio.h> 345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#include <sys/stat.h> 445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#include <sys/mman.h> 545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#include <string.h> 645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#ifndef MAP_NORESERVE 845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#define MAP_NORESERVE 0 945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org#endif 1045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 1145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgvolatile char ch; 1245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 1345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.orgmain(){ 1445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org struct stat statbuf; 1545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org uchar *buf; 1645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org fstat(0, &statbuf); 1745afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org buf = mmap(NULL, statbuf.st_size, PROT_READ, MAP_SHARED|MAP_NORESERVE, 1845afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org 0, 0); 1945afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org if(buf != (uchar*)(-1)){ 2045afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org uchar *cur, *lim = &buf[statbuf.st_size]; 2145afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org for(cur = buf; buf != lim; ++cur){ 2245afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org ch = *cur; 2345afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org } 2445afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org munmap(buf, statbuf.st_size); 2545afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org } 2645afe016bed87b9c6946184709058b39ede3f77ajwong@chromium.org} 27