1 #include <windows.h> 2 #include <lib9.h> 3 4 /* 5 * We can't include l.h, because Windoze wants to use some names 6 * like FLOAT and ABC which we declare. Define what we need here. 7 */ 8 typedef unsigned char uchar; 9 typedef unsigned int uint; 10 typedef unsigned long ulong; 11 12 #define Chunk (1*1024*1024) 13 14 void* mysbrk(ulong size)15mysbrk(ulong size) 16 { 17 void *v; 18 static int chunk; 19 static uchar *brk; 20 21 if(chunk < size) { 22 chunk = Chunk; 23 if(chunk < size) 24 chunk = Chunk + size; 25 brk = VirtualAlloc(NULL, chunk, MEM_COMMIT, PAGE_EXECUTE_READWRITE); 26 if(brk == 0) 27 return (void*)-1; 28 } 29 v = brk; 30 chunk -= size; 31 brk += size; 32 return v; 33 } 34 35 double cputime(void)36cputime(void) 37 { 38 return 0.0; 39 } 40 41 int fileexists(char * name)42fileexists(char *name) 43 { 44 int fd; 45 46 fd = open(name, OREAD); 47 if(fd < 0) 48 return 0; 49 close(fd); 50 return 1; 51 } 52