File: basemmap.c

package info (click to toggle)
yasm 1.3.0-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,880 kB
  • sloc: asm: 74,423; ansic: 53,055; python: 9,927; sh: 5,276; xml: 1,617; makefile: 214; pascal: 95; sed: 16
file content (26 lines) | stat: -rw-r--r-- 499 bytes parent folder | download | duplicates (21)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <stdlib.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <string.h>

#ifndef	MAP_NORESERVE
#define	MAP_NORESERVE	0
#endif

volatile char ch;

main(){
    struct stat statbuf;
    uchar *buf;
    fstat(0, &statbuf);
    buf = mmap(NULL, statbuf.st_size, PROT_READ, MAP_SHARED|MAP_NORESERVE,
	0, 0);
    if(buf != (uchar*)(-1)){
	uchar *cur, *lim = &buf[statbuf.st_size];
	for(cur = buf; buf != lim; ++cur){
	    ch = *cur;
	}
	munmap(buf, statbuf.st_size);
    }
}