SimpleOS

LXR

Navigation



Site hébergé par : enix

The LXR Cross Referencer for SOS

source navigation ]
diff markup ]
identifier search ]
general search ]
 
 
Article:1 ] [ 2 ] [ 3 ] [ 4 ] [ 5 ] [ 6 ] [ 6.5 ] [ 7 ] [ 7.5 ] [ 8 ] [ 9 ] [ 9.5 ]

001 /* Copyright (C) 2005 David Decotigny
002 
003    This program is free software; you can redistribute it and/or
004    modify it under the terms of the GNU General Public License
005    as published by the Free Software Foundation; either version 2
006    of the License, or (at your option) any later version.
007    
008    This program is distributed in the hope that it will be useful,
009    but WITHOUT ANY WARRANTY; without even the implied warranty of
010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
011    GNU General Public License for more details.
012    
013    You should have received a copy of the GNU General Public License
014    along with this program; if not, write to the Free Software
015    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
016    USA. 
017 */
018 
019 #include <crt.h>
020 #include <libc.h>
021 #include <stdarg.h>
022 #include <debug.h>
023 
024 
025 /**
026  * @file myprog13.c
027  * Test brk (and, hence: mremap)
028  */
029 
030 int main()
031 {
032   char * zoup;
033 
034   bochs_printf("myprog13: Hello world !\n");
035 
036   /* Do some forks to complicate things */
037   fork();
038   fork();
039 
040   zoup = _sos_brk(0);
041   bochs_printf("_sos_brk(0)=%x\n", (unsigned)_sos_brk(0));
042   bochs_printf("_sos_brk(+0)=%x\n", (unsigned)_sos_brk(zoup));
043   bochs_printf("_sos_brk(+1)=%x\n", (unsigned)_sos_brk(zoup + 1));
044   zoup[3] = 42;
045   bochs_printf("z[] = %d\n", zoup[3]);
046   bochs_printf("_sos_brk(0)=%x\n", (unsigned)_sos_brk(0));
047   bochs_printf("_sos_brk(orig)=%x\n", (unsigned)_sos_brk(zoup));
048   bochs_printf("_sos_brk(0)=%x\n", (unsigned)_sos_brk(0));
049   //  zoup[3] = 42;
050   
051   bochs_printf("brk(0)=%x\n", (unsigned)brk(0));
052   bochs_printf("sbrk(0)=%x\n", (unsigned)sbrk(0));
053   bochs_printf("brk(0)=%x\n", (unsigned)brk(0));
054   bochs_printf("sbrk(0)=%x\n", (unsigned)sbrk(0));
055   bochs_printf("sbrk(1)=%x\n", (unsigned)sbrk(1));
056   bochs_printf("brk(0)=%x\n", (unsigned)brk(0));
057   bochs_printf("sbrk(0)=%x\n", (unsigned)sbrk(0));
058   zoup = sbrk(0);
059   bochs_printf("brk(+1)=%x\n", (unsigned)brk(zoup + 1));
060   bochs_printf("sbrk(0)=%x\n", (unsigned)sbrk(0));
061   bochs_printf("brk(0)=%x\n", (unsigned)brk(0));
062   bochs_printf("sbrk(0)=%x\n", (unsigned)sbrk(0));
063 
064   bochs_printf("sbrk(-4k)=%x\n", (unsigned)sbrk(-4096));
065   bochs_printf("brk(0)=%x\n", (unsigned)brk(0));
066   bochs_printf("sbrk(0)=%x\n", (unsigned)sbrk(0));
067   zoup = sbrk(0);
068   bochs_printf("brk(-4k)=%x\n", (unsigned)brk(zoup - 4096));
069   bochs_printf("brk(0)=%x\n", (unsigned)brk(0));
070   bochs_printf("sbrk(0)=%x\n", (unsigned)sbrk(0));
071 
072   bochs_printf("malloc(0)=%x\n", (unsigned)malloc(0));
073   bochs_printf("malloc(1)=%x\n", (unsigned)malloc(1));
074   bochs_printf("malloc(2)=%x\n", (unsigned)malloc(2));
075   bochs_printf("malloc(3)=%x\n", (unsigned)malloc(3));
076   bochs_printf("malloc(4)=%x\n", (unsigned)malloc(4));
077   bochs_printf("malloc(5)=%x\n", (unsigned)malloc(5));
078   bochs_printf("malloc(6)=%x\n", (unsigned)malloc(6));
079   bochs_printf("malloc(7)=%x\n", (unsigned)malloc(7));
080   bochs_printf("malloc(8)=%x\n", (unsigned)malloc(8));
081   bochs_printf("malloc(9)=%x\n", (unsigned)malloc(9));
082   bochs_printf("malloc(0x30000)=%x\n", (unsigned)malloc(0x30000));
083   bochs_printf("malloc(1)=%x\n", (unsigned)malloc(1));
084 
085   bochs_printf("myprog13: The end\n");
086   return 0;
087 }

source navigation ] diff markup ] identifier search ] general search ]