Minimal changes to get it to compile (a few taken from David Given ack-6.0pre5)
authorNick Downing <nick@ndcode.org>
Tue, 16 Apr 2019 14:59:30 +0000 (00:59 +1000)
committerNick Downing <nick@ndcode.org>
Tue, 16 Apr 2019 14:59:30 +0000 (00:59 +1000)
22 files changed:
.gitignore [new file with mode: 0644]
doc/LLgen/proto.make
env.sh [new file with mode: 0644]
lang/cem/cemcom.ansi/cstoper.c
lang/cem/cemcom/cstoper.c
modules/src/em_code/em.c
n.sh [new file with mode: 0755]
util/ack/ack.h
util/ack/rmach.c
util/ack/svars.c
util/ack/util.c
util/ceg/EM_parser/common/pars.g
util/ceg/EM_parser/common/scan.c
util/cmisc/tabgen.c
util/ego/lv/lv.c
util/int/m_ioctl.c
util/int/moncalls.c
util/int/monstruct.c
util/int/v7_sgtty.h [new file with mode: 0644]
util/opt/alloc.h
util/opt/peephole.c
util/opt/pop_push.awk

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..834f7e2
--- /dev/null
@@ -0,0 +1,2 @@
+/build
+/stage
index 4356282..361f17d 100644 (file)
@@ -10,7 +10,7 @@ EQN=eqn
 REFER=refer
 TBL=tbl
 
-all:   $(TARGET_HOME)/doc/LLgen.doc $(TARGET_HOME)/doc/LLgen_NCER.doc
+#all:  $(TARGET_HOME)/doc/LLgen.doc $(TARGET_HOME)/doc/LLgen_NCER.doc
 
 $(TARGET_HOME)/doc/LLgen.doc:  $(SRC_DIR)/LLgen.n $(SRC_DIR)/LLgen.refs
        $(REFER) -sA+T -p $(SRC_DIR)/LLgen.refs $(SRC_DIR)/LLgen.n | $(EQN) | $(TBL) > $@
diff --git a/env.sh b/env.sh
new file mode 100644 (file)
index 0000000..87f1205
--- /dev/null
+++ b/env.sh
@@ -0,0 +1,21 @@
+TARGET_HOME="/home/nick/src/Ack-5.5/stage"; export TARGET_HOME
+UTIL_HOME="/home/nick/src/Ack-5.5/stage"; export UTIL_HOME
+SRC_HOME="/home/nick/src/Ack-5.5"; export SRC_HOME
+SYSNAME=""; export SYSNAME
+ACM="z80"; export ACM
+CURRENT="y"; export CURRENT
+SYS="V7"; export SYS
+LIMIT="y"; export LIMIT
+CONFIG="/home/nick/src/Ack-5.5/build"; export CONFIG
+DISABLE_LANG=" Modula-2 Pascal Occam Basic Fortran"; export DISABLE_LANG
+DISABLE_SUP=" i86 xenix3 minix i386 6500 6800 6805 6809 i80 em22 em24 em44 m68k2 pmds minixST m68k4 pmds4 sun2 mantra m68020 sun3 sparc sparc_solaris ns pdp s2650 vax4 z8000 arm"; export DISABLE_SUP
+DO_MACHINE_INDEP="y"; export DO_MACHINE_INDEP
+MACH_LIST="i86 xenix3 minix i386 6500 6800 6805 6809 i80 em22 em24 em44 m68k2 pmds minixST m68k4 pmds4 sun2 mantra m68020 sun3 sparc sparc_solaris ns pdp s2650 vax4 z80 z8000 arm"; export MACH_LIST
+SYSVAX=""; export SYSVAX
+MACH="XXX"; export MACH
+WS="4"; export WS
+PS="8"; export PS
+DO_FAST="n"; export DO_FAST
+
+PATH=::$CONFIG/bin:$UTIL_HOME/bin:/usr/ccs/bin:/usr/ucb:$PATH
+export PATH
index 6ec57f4..f0ef320 100644 (file)
@@ -16,7 +16,7 @@
 #include       "Lpars.h"
 #include       "assert.h"
 
-arith full_mask[MAXSIZE];/* full_mask[1] == 0XFF, full_mask[2] == 0XFFFF, .. */
+arith full_mask[MAXSIZE + 1];/* full_mask[1] == 0XFF, full_mask[2] == 0XFFFF, .. */
 #ifndef NOCROSS
 arith max_int;         /* maximum integer on target machine    */
 arith max_unsigned;    /* maximum unsigned on target machine   */
@@ -247,7 +247,7 @@ init_cst()
 
        while (!(bt < 0))       {
                bt = (bt << 8) + 0377, i++;
-               if (i == MAXSIZE)
+               if (i == MAXSIZE + 1)
                        fatal("array full_mask too small for this machine");
                full_mask[i] = bt;
        }
index f4cc09a..dfe1570 100644 (file)
@@ -17,7 +17,7 @@
 
 long mach_long_sign;   /* sign bit of the machine long */
 int mach_long_size;    /* size of long on this machine == sizeof(long) */
-long full_mask[MAXSIZE];/* full_mask[1] == 0XFF, full_mask[2] == 0XFFFF, .. */
+long full_mask[MAXSIZE + 1];/* full_mask[1] == 0XFF, full_mask[2] == 0XFFFF, .. */
 arith max_int;         /* maximum integer on target machine    */
 arith max_unsigned;    /* maximum unsigned on target machine   */
 
@@ -224,13 +224,13 @@ init_cst()
 
        while (!(bt < 0))       {
                bt = (bt << 8) + 0377, i++;
-               if (i == MAXSIZE)
+               if (i == MAXSIZE + 1)
                        fatal("array full_mask too small for this machine");
                full_mask[i] = bt;
        }
        mach_long_size = i;
        mach_long_sign = 1L << (mach_long_size * 8 - 1);
-       if ((int)long_size < mach_long_size)
+       if ((int)long_size > mach_long_size) /* Nick changed < to >, bug?? */
                fatal("sizeof (long) insufficient on this machine");
        max_int = full_mask[(int)int_size] & ~(1L << ((int)int_size * 8 - 1));
        max_unsigned = full_mask[(int)int_size];
index 3162fd3..e2da88d 100644 (file)
@@ -349,7 +349,7 @@ C_magic()
 }
 
 /***    the compact code generating routines   ***/
-#define        fit16i(x)       ((x) >= (long)0xFFFF8000 && (x) <= (long)0x00007FFF)
+#define fit16i(x)       ((x) >= -0x8000L && (x) <= 0x7FFFL)
 #define        fit8u(x)        ((x) <= 0xFF)           /* x is already unsigned */
 
 void
diff --git a/n.sh b/n.sh
new file mode 100755 (executable)
index 0000000..d121ebb
--- /dev/null
+++ b/n.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+#sudo apt-get install groff
+rm -rf build stage
+sh INSTALL
index 68106cb..c5f7a3e 100644 (file)
@@ -96,3 +96,12 @@ extern char *changecore();
 #else
 extern  int debug ;
 #endif
+
+#ifdef __STDC__
+/* Some arch need to be told not to use regcall for varargs functions */
+void fatal(const char *fmt, ...);
+void vprint(const char *fmt, ...);
+void fuerror(const char *fmt, ...);
+void werror(const char *fmt, ...);
+void error(const char *fmt, ...);
+#endif
index ad2d409..9b07983 100644 (file)
@@ -49,7 +49,7 @@ static char rcs_dmach[] = RCS_DMACH ;
 extern growstring scanb();
 extern growstring scanvars();
 
-int getline() ;
+int _getline() ;
 int getinchar() ;
 static char *ty_name ;
 static char *bol ;
@@ -65,7 +65,7 @@ setlist(name) char *name ; {
 
        inname=name ;
        open_in(name) ;
-       while ( getline() ) {
+       while ( _getline() ) {
                if ( strcmp(VAR,ty_name)==0 ) {
                        doassign(bol,(char *)0,0) ;
                } else
@@ -114,7 +114,7 @@ intrf() {
        new= (trf *)getcore(sizeof *new) ;
        new->t_name= keeps(bol) ;
        for (;;) {
-               if ( !getline() ) {
+               if ( !_getline() ) {
                        fuerror("unexpected EOF on %s",inname) ;
                }
                twice= NO ;
@@ -366,7 +366,7 @@ int getinchar() {
        return token ;
 }
 
-int getline() {
+int _getline() {
        register char *c_ptr ;
 
        do {
index fa130bb..6209736 100644 (file)
@@ -39,13 +39,11 @@ static char rcs_id[] = "$Id: svars.c,v 2.3 1994/06/24 10:13:12 ceriel Exp $" ;
 
        Other routines called
 
-       fatal(args*)    When something goes wrong
        getcore(size)   Core allocation
 
 */
 
 extern  char    *getcore();
-extern          fatal();
 
 struct vars {
        char                            *v_name;
index 556d7b3..189fd20 100644 (file)
@@ -83,6 +83,82 @@ char *firstblank(str) char *str ; {
        return ptr ;
 }
 
+#ifdef __STDC__
+#include <stdarg.h>
+
+/* VARARGS1 */
+void fatal(const char *fmt, ...) {
+       va_list ap;
+
+       /* Fatal internal error */
+       fprintf(STDOUT,"%s: fatal internal error, ",progname) ;
+       va_start(ap, fmt);
+       vfprintf(STDOUT,fmt,ap);
+       va_end(ap);
+       fprintf(STDOUT,"\n") ;
+       quit(-2) ;
+}
+
+
+/* VARARGS1 */
+void vprint(const char *fmt, ...) {
+       va_list ap;
+
+       /* Diagnostic print, no auto NL */
+       va_start(ap, fmt);
+       vfprintf(STDOUT,fmt,ap);
+       va_end(ap);
+}
+
+#ifdef DEBUG
+prns(s) register char *s ; {
+       for ( ; *s ; s++ ) {
+               putc((*s&0377)&~NO_SCAN,STDOUT) ;
+       }
+       putc('\n',STDOUT) ;
+}
+#endif
+
+/* VARARGS1 */
+void fuerror(const char *fmt, ...) {
+       va_list ap;
+
+       /* Fatal user error */
+       fprintf(STDOUT,"%s: ",progname) ;
+       va_start(ap, fmt);
+       vfprintf(STDOUT,fmt,ap);
+       va_end(ap);
+       fprintf(STDOUT,"\n") ;
+       quit(-1) ;
+}
+
+/* VARARGS1 */
+void werror(const char *fmt, ...) {
+       va_list ap;
+
+       /* Warning user error, w_flag */
+       if ( w_flag ) return ;
+       fprintf(STDOUT,"%s: warning, ",progname) ;
+       va_start(ap, fmt);
+       vfprintf(STDOUT,fmt,ap);
+       va_end(ap);
+       fprintf(STDOUT,"\n") ;
+}
+
+/* VARARGS1 */
+void error(const char *fmt, ...) {
+       va_list ap;
+
+       /* User error, it is the callers responsibility to quit */
+       fprintf(STDOUT,"%s: ",progname) ;
+       va_start(ap, fmt);
+       vfprintf(STDOUT,fmt,ap);
+       va_end(ap);
+       fprintf(STDOUT,"\n") ;
+       n_error++ ;
+}
+#
+#else
 /* VARARGS1 */
 fatal(fmt,p1,p2,p3,p4,p5,p6,p7) char *fmt ; {
        /* Fatal internal error */
@@ -134,6 +210,7 @@ error(fmt,p1,p2,p3,p4,p5,p6,p7) char *fmt ; {
        fprintf(STDOUT,"\n") ;
        n_error++ ;
 }
+#endif
 
 do_flush() {
        fflush(stdout) ;
index 62bc9c0..a7a9ec0 100644 (file)
@@ -29,6 +29,7 @@
  */
 {
 
+#include <stdio.h>
 #include <system.h>
 #include "decl.h"
 #include "em.h"
@@ -302,6 +303,9 @@ main( argc, argv)
 int argc;
 char **argv;
 {
+       extern FILE *infile;
+       infile = stdin;
+
        outfile = STDOUT;
        if ( argc > 1) {
                if ( strcmp( argv[1], "-l") == 0)
index a5e3679..4b3af58 100644 (file)
@@ -29,7 +29,7 @@ int yylineno = 1;
 static char buf[BUF_SIZE],     /* Bufer to save backc()-characters */
             *bufptr = buf;     /* Pointer to space for backc()-character */
 
-static FILE *infile = stdin;
+FILE *infile; /*static FILE *infile = stdin;*/
 
 
 
index 5ae2723..60a0849 100644 (file)
@@ -291,7 +291,7 @@ quoted(pstr)
 }
 
 char *
-getline(s, n, fp)
+_getline(s, n, fp)
        char *s;
        FILE *fp;
 {
@@ -326,7 +326,7 @@ DoFile(name)
                fprintf(stderr, "%s: cannot read file %s\n", ProgCall, name);
                exit(1);
        }
-       while (getline(text, BUFSIZE, fp) != NULL) {
+       while (_getline(text, BUFSIZE, fp) != NULL) {
                if (text[0] == FILECOM) {
                        option(text);
                }
index fd9823a..9dd81ca 100644 (file)
@@ -311,6 +311,7 @@ STATIC line_p make_mesg(mesg,loc)
 
 
 
+STATIC app_block();
 STATIC block_entry(b,prev)
        bblock_p b,prev;
 {
index 7cde60d..9dc32aa 100644 (file)
@@ -10,7 +10,7 @@
 #include       "mem.h"
 #include       "warn.h"
 
-#include       <sgtty.h>
+#include       "v7_sgtty.h"
 
 #ifdef V7IOCTL                         /* define the proper V7 requests */
 
index ec48eec..18dfc42 100644 (file)
@@ -16,7 +16,8 @@
 #endif
 #include       <sys/times.h>
 
-extern int errno;                      /* UNIX error number */
+#include <errno.h>
+/*extern int errno;*/                  /* UNIX error number */
 
 extern int running;                    /* from main.c */
 extern int fd_limit;                   /* from io.c */
@@ -26,7 +27,7 @@ extern int fd_limit;                  /* from io.c */
 #ifdef BSD_X                           /* from system.h */
 #include       <sys/timeb.h>
 #endif /* BSD_X */
-#ifdef SYS_V
+#if 1 //def    SYS_V
 struct timeb {                 /* non-existing; we use an ad-hoc definition */
        long time;
        unsigned short millitm;
index 2f41284..9a48f6b 100644 (file)
 #include       <time.h>
 #endif
 #include       <sys/times.h>
-#include       <sgtty.h>
+#include       "v7_sgtty.h"
 
 #ifdef BSD_X                           /* from system.h */
 #include       <sys/timeb.h>
 #endif /* BSD_X */
-#ifdef SYS_V                           /* from system.h */
+#if 1 //def    SYS_V                           /* from system.h */
 struct timeb { /* non-existing; we use an ad-hoc definition */
        long time;
        unsigned short millitm;
diff --git a/util/int/v7_sgtty.h b/util/int/v7_sgtty.h
new file mode 100644 (file)
index 0000000..be6b89f
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * Structure for stty and gtty system calls.
+ */
+
+struct sgttyb {
+       char    sg_ispeed;              /* input speed */
+       char    sg_ospeed;              /* output speed */
+       char    sg_erase;               /* erase character */
+       char    sg_kill;                /* kill character */
+       int     sg_flags;               /* mode flags */
+};
+
+/*
+ * List of special characters
+ */
+struct tchars {
+       char    t_intrc;        /* interrupt */
+       char    t_quitc;        /* quit */
+       char    t_startc;       /* start output */
+       char    t_stopc;        /* stop output */
+       char    t_eofc;         /* end-of-file */
+       char    t_brkc;         /* input delimiter (like nl) */
+};
+
+/*
+ * Modes
+ */
+#define        TANDEM  01
+#define        CBREAK  02
+#define        LCASE   04
+#define        ECHO    010
+#define        CRMOD   020
+#define        RAW     040
+#define        ODDP    0100
+#define        EVENP   0200
+#define ANYP   0300
+#define        NLDELAY 001400
+#define        TBDELAY 006000
+#define        XTABS   06000
+#define        CRDELAY 030000
+#define        VTDELAY 040000
+#define BSDELAY 0100000
+#define ALLDELAY 0177400
+
+/*
+ * Delay algorithms
+ */
+#define        CR0     0
+#define        CR1     010000
+#define        CR2     020000
+#define        CR3     030000
+#define        NL0     0
+#define        NL1     000400
+#define        NL2     001000
+#define        NL3     001400
+#define        TAB0    0
+#define        TAB1    002000
+#define        TAB2    004000
+#define        FF0     0
+#define        FF1     040000
+#define        BS0     0
+#define        BS1     0100000
+
+/*
+ * Speeds
+ */
+#define B0     0
+#define B50    1
+#define B75    2
+#define B110   3
+#define B134   4
+#define B150   5
+#define B200   6
+#define B300   7
+#define B600   8
+#define B1200  9
+#define        B1800   10
+#define B2400  11
+#define B4800  12
+#define B9600  13
+#define EXTA   14
+#define EXTB   15
+
+/*
+ * tty ioctl commands
+ */
+#define        TIOCGETD        (('t'<<8)|0)
+#define        TIOCSETD        (('t'<<8)|1)
+#define        TIOCHPCL        (('t'<<8)|2)
+#define        TIOCMODG        (('t'<<8)|3)
+#define        TIOCMODS        (('t'<<8)|4)
+#define        TIOCGETP        (('t'<<8)|8)
+#define        TIOCSETP        (('t'<<8)|9)
+#define        TIOCSETN        (('t'<<8)|10)
+#define        TIOCEXCL        (('t'<<8)|13)
+#define        TIOCNXCL        (('t'<<8)|14)
+#define        TIOHMODE        (('t'<<8)|15)
+#define        TIOCTSTP        (('t'<<8)|16)
+#define        TIOCSETC        (('t'<<8)|17)
+#define        TIOCGETC        (('t'<<8)|18)
+#define        DIOCLSTN        (('d'<<8)|1)
+#define        DIOCNTRL        (('d'<<8)|2)
+#define        DIOCMPX         (('d'<<8)|3)
+#define        DIOCNMPX        (('d'<<8)|4)
+#define        DIOCSCALL       (('d'<<8)|5)
+#define        DIOCRCALL       (('d'<<8)|6)
+#define        DIOCPGRP        (('d'<<8)|7)
+#define        DIOCGETP        (('d'<<8)|8)
+#define        DIOCSETP        (('d'<<8)|9)
+#define        DIOCLOSE        (('d'<<8)|10)
+#define        DIOCTIME        (('d'<<8)|11)
+#define        DIOCRESET       (('d'<<8)|12)
+#define        FIOCLEX         (('f'<<8)|1)
+#define        FIONCLEX        (('f'<<8)|2)
+#define        MXLSTN          (('x'<<8)|1)
+#define        MXNBLK          (('x'<<8)|2)
index f8bc4ab..24d5812 100644 (file)
@@ -16,7 +16,7 @@ extern                oldline();
 extern         oldloc();
 extern         oldreg();
 
-#undef USEMALLOC       /* if defined malloc() and free() are used */
+#define USEMALLOC      /* if defined malloc() and free() are used */
 
 #undef COREDEBUG       /* keep records and print statistics */
 
index ae9c12a..0cf691b 100644 (file)
@@ -417,14 +417,14 @@ eval_t compute(pexp) register expr_p pexp; {
        case EX_SFIT:
                mask = 0;
                for (i=leaf2.e_v.e_con - 1;i < 8*sizeof(offset); i++)
-                       mask |= 1<<i;
+                       mask |= ((offset)1)<<i;
                res.e_v.e_con = (leaf1.e_v.e_con&mask) == 0 ||
                                       (leaf1.e_v.e_con&mask) == mask;
                break;
        case EX_UFIT:
                mask = 0;
                for (i=leaf2.e_v.e_con;i < 8*sizeof(offset); i++)
-                       mask |= 1<<i;
+                       mask |= ((offset)1)<<i;
                res.e_v.e_con = (leaf1.e_v.e_con&mask) == 0;
                break;
        case EX_ROTATE:
index 1dfb33d..6f45248 100644 (file)
@@ -2,27 +2,27 @@ BEGIN { print "#include \"pop_push.h\""
          print
          print "char *pop_push[] = {"
          print "\"\","
-         switch = 0
+         s = 0
 }
-/aar/  { switch = NR }
-       { if (switch) {
+/aar/  { s = NR }
+       { if (s) {
              if ($1 == "cal" || $1 == "cai") $3 = "-?"
              printf("/* %s */ \"%s\",\n",$1,$3) 
-             col_2[NR-switch] = $2
-             comment[NR-switch] = $1
+             col_2[NR-s] = $2
+             comment[NR-s] = $1
          }
        }
 END    { print "};"
          print
          print "char flow_tab[]= {"
-         print "'\000',"
-         for(i=0; i < NR-switch; i++) {
+         print "'\\000',"
+         for(i=0; i < NR-s; i++) {
                inf = col_2[i]
                f_out = "/* " comment[i] " */ "
                if (substr(inf,1,1)=="b") f_out = f_out "HASLABEL|"
                if (substr(inf,2,1)=="c") f_out = f_out "CONDBRA"
                else if (substr(inf,2,1)=="t") f_out = f_out "JUMP"
-               else f_out = f_out "'\000'"
+               else f_out = f_out "'\\000'"
                print f_out","
          }
          print "};"