xref: /plan9-contrib/sys/src/cmd/ld/Nt.c (revision 40d015479ed36701ae6dcfd8814f849fc6285e8d)
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)15 mysbrk(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)36 cputime(void)
37 {
38 	return 0.0;
39 }
40 
41 int
fileexists(char * name)42 fileexists(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