diff options
| author | Charles.Forsyth <devnull@localhost> | 2009-05-31 00:07:21 +0000 |
|---|---|---|
| committer | Charles.Forsyth <devnull@localhost> | 2009-05-31 00:07:21 +0000 |
| commit | b370703f35244a5152bf72daf6a871fba74ed373 (patch) | |
| tree | 5eccdee9672ff9c51740fe9c8b933a21ccfdf7e4 /utils/6l/Nt.c | |
| parent | b18a52b7bbe9230f3398a16cfc224f42a7cb393b (diff) | |
20090531-0106
Diffstat (limited to 'utils/6l/Nt.c')
| -rw-r--r-- | utils/6l/Nt.c | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/utils/6l/Nt.c b/utils/6l/Nt.c new file mode 100644 index 00000000..73c6f795 --- /dev/null +++ b/utils/6l/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); +} |
