shithub: mc

Download patch

ref: 5d673da99765b72afdf514bab2f03f34c3dce031
parent: bfeab45bbb861b1d2f054452678b3c1782a3566f
author: Ori Bernstein <[email protected]>
date: Sun Oct 5 14:18:19 EDT 2014

Add plan9 mkfiles and runtime.

--- /dev/null
+++ b/6/mkfile
@@ -1,0 +1,15 @@
+</$objtype/mkfile
+CC=pcc
+CFLAGS=-c -D_POSIX_SOURCE -D_SUSV2_SOURCE -D_C99_SNPRINTF_EXTENSION -I../parse -I../opt
+LDFLAGS=-L../parse -lparse -L../opt -lopt 
+
+TARG=6m
+OFILES=isel.$O \
+    locs.$O \
+    main.$O \
+    ra.$O \
+    simp.$O \
+
+LIB=../parse/libparse.a ../opt/libopt.a
+
+</sys/src/cmd/mkone
\ No newline at end of file
--- /dev/null
+++ b/libstd/mkfile
@@ -1,0 +1,66 @@
+MYRLIB=std
+MYRSRC= \
+    alloc.myr \
+    bigint.myr \
+    bitset.myr \
+    blat.myr \
+    chartype.myr \
+    cmp.myr \
+    dial.myr \
+    die.myr \
+    dir.myr \
+    endian.myr \
+    env.myr \
+    execvp.myr \
+    extremum.myr \
+    fltbits.myr \
+    fmt.myr \
+    fltfmt.myr \
+    hashfuncs.myr \
+    hasprefix.myr \
+    hassuffix.myr \
+    htab.myr \
+    ifreq.myr \
+    intparse.myr \
+    ipparse.myr \
+    mk.myr \
+    now.myr \
+    option.myr \
+    optparse.myr \
+    pathjoin.myr \
+    rand.myr \
+    resolve.myr \
+    result.myr \
+    search.myr \
+    slcp.myr \
+    sldup.myr \
+    sleq.myr \
+    slfill.myr \
+    sljoin.myr \
+    slpush.myr \
+    slput.myr \
+    slurp.myr \
+    sort.myr \
+    spork.myr \
+    strfind.myr \
+    strjoin.myr \
+    strsplit.myr \
+    strstrip.myr \
+    swap.myr \
+    sys.myr \
+    try.myr \
+    types.myr \
+    units.myr \
+    utf.myr \
+    varargs.myr \
+    waitstatus.myr \
+
+all: lib$MYRLIB.a  test
+
+test: libstd.a test.myr ../6/$O.out
+	../myrbuild/myrbuild -C../6/$O.out -M../muse/muse -b test -I. -r../rt/_myrrt.o test.myr
+
+
+lib$MYRLIB.a: $MYRSRC $ASMSRC
+	../myrbuild/$O.out -C../6/$O.out -M../muse/$O.out -l $MYRLIB $MYRSRC $ASMSRC
+
--- /dev/null
+++ b/mkfile
@@ -1,0 +1,46 @@
+</$objtype/mkfile
+
+SUB = parse \
+      opt \
+      6 \
+      muse \
+      myrbuild \
+      rt \
+      libstd \
+      doc
+
+all:V: $SUB config.h
+	for(dir in $SUB)@{
+		cd $dir
+		mk $MKFLAGS
+	}
+nuke:V: $SUB
+	rm -f config.h
+	rm -f config.mk
+	for(dir in $SUB)@{
+		cd $dir
+		mk $MKFLAGS nuke
+	}
+
+clean:V: $SUB config.h
+	for(dir in $SUB)@{
+		cd $dir
+		mk $MKFLAGS clean
+	}
+
+install:V: $SUB config.h
+	for(dir in $SUB)@{
+		cd $dir
+		mk $MKFLAGS install
+	}
+
+uninstall:V: $SUB config.h
+	for(dir in $SUB)@{
+		cd $dir
+		mk $MKFLAGS
+	}
+
+config.h:
+	echo '#define Instroot "'/'"' > config.h
+	echo '#define Asmcmd {"6a", "-o", NULL}' >> config.h
+	echo '#define Symprefix "_"' >> config.h
--- /dev/null
+++ b/muse/mkfile
@@ -1,0 +1,10 @@
+</$objtype/mkfile
+CC=pcc
+CFLAGS=-c -D_POSIX_SOURCE -D_SUSV2_SOURCE -D_C99_SNPRINTF_EXTENSION -I../parse -I../opt
+LDFLAGS=-L../parse -lparse -L../opt -lopt 
+
+TARG=muse
+OFILES=muse.$O
+LIB=../parse/libparse.a ../opt/libopt.a
+
+</sys/src/cmd/mkone
\ No newline at end of file
--- /dev/null
+++ b/myrbuild/mkfile
@@ -1,0 +1,10 @@
+</$objtype/mkfile
+CC=pcc
+CFLAGS=-c -D_POSIX_SOURCE -D_SUSV2_SOURCE -D_C99_SNPRINTF_EXTENSION -I../parse -I../opt
+LDFLAGS=-L../parse -lparse -L../opt -lopt 
+
+TARG=myrbuild
+OFILES=myrbuild.$O
+LIB=../parse/libparse.a ../opt/libopt.a
+
+</sys/src/cmd/mkone
\ No newline at end of file
--- /dev/null
+++ b/opt/mkfile
@@ -1,0 +1,13 @@
+</$objtype/mkfile
+CC=pcc
+LD=pcc
+CFLAGS=-c -D_POSIX_SOURCE -D_SUSV2_SOURCE -D_C99_SNPRINTF_EXTENSION -I../parse
+
+LIB=libopt.a
+OFILES=cfg.$O \
+    fold.$O \
+    df.$O
+
+HFILES=opt.h
+
+</sys/src/cmd/mklib
--- a/parse/gram.y
+++ b/parse/gram.y
@@ -4,7 +4,7 @@
 
 #include <stdlib.h>
 #include <stdio.h>
-#include <stdint.h>
+#include <inttypes.h>
 #include <ctype.h>
 #include <string.h>
 #include <assert.h>
--- /dev/null
+++ b/parse/mkfile
@@ -1,0 +1,29 @@
+</$objtype/mkfile
+CC=pcc
+LD=pcc
+CFLAGS=-c -D_POSIX_SOURCE -D_SUSV2_SOURCE -D_C99_SNPRINTF_EXTENSION
+
+LIB=libparse.a
+OFILES=bitset.$O \
+    dump.$O \
+    gram.$O \
+    htab.$O \
+    infer.$O \
+    names.$O \
+    node.$O \
+    specialize.$O \
+    stab.$O \
+    tok.$O \
+    type.$O \
+    use.$O \
+    util.$O
+
+HFILES=parse.h
+CLEANFILES=gram.c gram.h
+
+</sys/src/cmd/mklib
+
+gram.c gram.h: gram.y
+	yacc -d -S gram.y
+    mv y.tab.c gram.c
+    mv y.tab.h gram.h
--- a/parse/util.c
+++ b/parse/util.c
@@ -1,6 +1,6 @@
 #include <stdlib.h>
 #include <stdio.h>
-#include <stdint.h>
+#include <inttypes.h>
 #include <stdarg.h>
 #include <ctype.h>
 #include <string.h>
@@ -40,7 +40,7 @@
 
     p = xrealloc(mem, sz);
     if (sz > oldsz)
-        bzero(&p[oldsz], sz - oldsz);
+        memset(&p[oldsz], 0, sz - oldsz);
     return p;
 }
 
@@ -210,11 +210,13 @@
     return v;
 }
 
-void wrbuf(FILE *fd, void *buf, size_t sz)
+void wrbuf(FILE *fd, void *p, size_t sz)
 {
     size_t n;
+    char *buf;
 
     n = 0;
+    buf = p;
     while (n < sz) {
 	n += fwrite(buf + n, 1, sz - n, fd);
 	if (feof(fd))
--- /dev/null
+++ b/rt/_myrrt-plan9.s
@@ -1,0 +1,19 @@
+#define NPRIVATES	16
+
+TEXT	_main(SB), 1, $(2*8+NPRIVATES*8)
+	MOVQ	AX, _tos(SB)
+	LEAQ	16(SP), AX
+	MOVQ	AX, _privates(SB)
+	MOVL	$NPRIVATES, _nprivates(SB)
+	MOVL	inargc-8(FP), RARG
+	LEAQ	inargv+0(FP), AX
+	MOVQ	AX, 8(SP)
+	CALL	main(SB)
+
+loop:
+	MOVQ	$_exits<>(SB), RARG
+	CALL	exits(SB)
+	JMP	loop
+
+DATA	_exits<>+0(SB)/4, $"main"
+GLOBL	_exits<>+0(SB), $5
--- /dev/null
+++ b/rt/mkfile
@@ -1,0 +1,6 @@
+</$objtype/mkfile
+
+_myrrt.$O: _myrrt-plan9.s
+	$AS -o _myrrt.$O _myrrt-plan9.s
+
+</sys/src/cmd/mkone