001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019 #include <crt.h>
020 #include <libc.h>
021 #include <stdarg.h>
022 #include <debug.h>
023
024
025
026
027
028
029
030
031
032
033 int main()
034 {
035 char *zoup;
036
037 zoup = fakemmap((void*)4096, 8*1024*1024,
038 PROT_READ | PROT_WRITE,
039 MAP_SHARED,
040 "/dev/zero", 34);
041 bochs_printf("mapped @%x\n", (unsigned)zoup);
042
043
044 fork();
045 fork();
046
047 _sos_syscall1(4004, (unsigned)"Initial");
048 munmap(zoup, 10*4096);
049 zoup += 10*4096;
050 _sos_syscall1(4004, (unsigned)"After munmap Low");
051
052 munmap(zoup-4096, 2*4096);
053 zoup += 4096;
054 _sos_syscall1(4004, (unsigned)"After munmap Before Low");
055
056 munmap(zoup-4096, 4096);
057 _sos_syscall1(4004, (unsigned)"After munmap Before Low (bis)");
058
059 munmap(zoup + 1024*1024, 4096);
060 _sos_syscall1(4004, (unsigned)"After munmap middle");
061
062 munmap(zoup + 1024*1024, 4096);
063 _sos_syscall1(4004, (unsigned)"After munmap middle (bis)");
064
065 munmap(zoup + 8*1024*1024 - 11*4096 - 4096, 4096);
066 _sos_syscall1(4004, (unsigned)"After munmap High");
067
068 munmap(zoup + 8*1024*1024 - 11*4096 - 2*4096, 3*4096);
069 _sos_syscall1(4004, (unsigned)"After munmap Past High");
070
071 munmap((void*)0x40000000, 0x10000000);
072 _sos_syscall1(4004, (unsigned)"After munmap Over everything");
073
074 munmap((void*)0x40000000, 0x10000000);
075 _sos_syscall1(4004, (unsigned)"After munmap Over everything (bis)");
076
077 return 0;
078 }