summaryrefslogtreecommitdiff
path: root/utils/ld/Nt.c
diff options
context:
space:
mode:
authorforsyth <forsyth@lavoro.terzarima.net>2013-06-03 21:01:14 +0000
committerforsyth <forsyth@lavoro.terzarima.net>2013-06-03 21:01:14 +0000
commit45a20ab721a513710138340faff3d59a31c3e01e (patch)
treeeea29d2684c51cc73725b8992a2125bede48e118 /utils/ld/Nt.c
parentcd8e99851af33e52bcdf8faf34f9d4e62fa0cbaf (diff)
sync compilers with Plan 9
remove 1[acl] 2[acl]
Diffstat (limited to 'utils/ld/Nt.c')
-rw-r--r--utils/ld/Nt.c100
1 files changed, 100 insertions, 0 deletions
diff --git a/utils/ld/Nt.c b/utils/ld/Nt.c
new file mode 100644
index 00000000..938664c2
--- /dev/null
+++ b/utils/ld/Nt.c
@@ -0,0 +1,100 @@
+#include <windows.h>
+
+/*
+ * We can't include l.h, because Windoze wants to use some names
+ * like FLOAT and ABC which we declare. Define what we need here.
+ */
+typedef unsigned char uchar;
+typedef unsigned int uint;
+typedef unsigned long ulong;
+
+extern char *hunk;
+extern long nhunk;
+
+void gethunk(void);
+
+/*
+ * 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)
+{
+}
+
+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);
+}
+
+int
+fileexists(char *name)
+{
+ int fd;
+
+ fd = open(f, OREAD);
+ if(fd < 0)
+ return 0;
+ close(fd);
+ return 1;
+}