Charles.Forsyth20060303644188019 years agoHistory
131 lines · 1.4 KB · C
RawDownload
#include	<windows.h>  #include	<lib9.h> #define	Windows	(1<<2)		/* hack - can't include cc.h because of clashes */#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;} intmycreat(char *n, int p){ 	return create(n, 1, p);} intmywait(int *s){	fprint(2, "mywait called\n");	abort();	return 0;} intmydup(int f1, int f2){	int ok; 	ok = _dup2(f1, f2);	if(ok < 0)		return -1;	return f2;/*	fprint(2, "mydup called\n");	abort();	return 0;*/} intmypipe(int *fd){	fprint(2, "mypipe called\n");	abort();	return 0;} intsystemtype(int sys){ 	return sys&Windows;} intpathchar(void){	return '/';} char*mygetwd(char *path, int len){	return getcwd(path, len);} intmyexec(char *path, char *argv[]){	fprint(2, "myexec called\n");	abort();	return 0;} intmyfork(void){	fprint(2, "myfork called\n");	abort();	return 0;} /* * fake mallocs */void*malloc(uint n){	return mysbrk(n);} void*calloc(uint m, uint n){	return mysbrk(m*n);} void*realloc(void *p, uint n){	void *new; 	new = malloc(n);	if(new && p)		memmove(new, p, n);	return new;} voidfree(void *p){}