diff options
| author | Charles.Forsyth <devnull@localhost> | 2006-12-22 21:39:35 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2006-12-22 21:39:35 +0000 |
| commit | 74a4d8c26dd3c1e9febcb717cfd6cb6512991a7a (patch) | |
| tree | c6e220ba61db3a6ea4052e6841296d829654e664 /utils/0l/Nt.c | |
| parent | 46439007cf417cbd9ac8049bb4122c890097a0fa (diff) | |
20060303
Diffstat (limited to 'utils/0l/Nt.c')
| -rw-r--r-- | utils/0l/Nt.c | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/utils/0l/Nt.c b/utils/0l/Nt.c new file mode 100644 index 00000000..2efff499 --- /dev/null +++ b/utils/0l/Nt.c @@ -0,0 +1,77 @@ +#include <windows.h> +#include "l.h" + +/* + * fake malloc + */ +void* +malloc(uint n) +{ + void *p; + + while(n & 7) + n++; + while(nhunk < n) + gethunk(); + p = hunk; + nhunk -= n; + hunk += n; + return p; +} + +void +free(void *p) +{ + USED(p); +} + +void* +calloc(uint m, uint n) +{ + void *p; + + n *= m; + p = malloc(n); + memset(p, 0, n); + return p; +} + +void* +realloc(void *p, uint n) +{ + void *new; + + new = malloc(n); + if(new && p) + memmove(new, p, n); + return new; +} + +#define Chunk (1*1024*1024) + +void* +mysbrk(ulong size) +{ + void *v; + static int chunk; + static uchar *brk; + + if(chunk < size) { + chunk = Chunk; + if(chunk < size) + chunk = Chunk + size; + brk = VirtualAlloc(NULL, chunk, MEM_COMMIT, PAGE_EXECUTE_READWRITE); + if(brk == 0) + return (void*)-1; + } + v = brk; + chunk -= size; + brk += size; + return v; +} + +double +cputime(void) +{ + return ((double)0); +} |
