Bodge the ancient em monitor library into building as a libsys for the em22
authorDavid Given <dg@cowlark.com>
Wed, 13 Jun 2018 12:44:25 +0000 (21:44 +0900)
committerDavid Given <dg@cowlark.com>
Wed, 13 Jun 2018 12:44:25 +0000 (21:44 +0900)
plat. It's completely untested, but it builds and makes e.out executables.

101 files changed:
lang/cem/libcc.ansi/stdlib/system.c
lang/cem/libcc/mon/cleanup.c [deleted file]
lang/m2/libm2/init.c
plat/em/libsys/LIST [moved from lang/cem/libcc/mon/LIST with 100% similarity]
plat/em/libsys/_alarm.e [moved from lang/cem/libcc/mon/_alarm.e with 100% similarity]
plat/em/libsys/_brk.e [moved from lang/cem/libcc/mon/_brk.e with 100% similarity]
plat/em/libsys/_close.e [moved from lang/cem/libcc/mon/_close.e with 100% similarity]
plat/em/libsys/_creat.e [moved from lang/cem/libcc/mon/_creat.e with 100% similarity]
plat/em/libsys/_dup.e [moved from lang/cem/libcc/mon/_dup.e with 100% similarity]
plat/em/libsys/_dup2.e [moved from lang/cem/libcc/mon/_dup2.e with 100% similarity]
plat/em/libsys/_execl.e [moved from lang/cem/libcc/mon/_execl.e with 92% similarity]
plat/em/libsys/_execve.e [moved from lang/cem/libcc/mon/_execve.e with 100% similarity]
plat/em/libsys/_exit.e [moved from lang/cem/libcc/mon/_exit.e with 100% similarity]
plat/em/libsys/_fork.e [moved from lang/cem/libcc/mon/_fork.e with 100% similarity]
plat/em/libsys/_fstat.e [moved from lang/cem/libcc/mon/_fstat.e with 100% similarity]
plat/em/libsys/_ftime.e [moved from lang/cem/libcc/mon/_ftime.e with 100% similarity]
plat/em/libsys/_getpid.e [moved from lang/cem/libcc/mon/_getpid.e with 100% similarity]
plat/em/libsys/_gtty.c [moved from lang/cem/libcc/mon/_gtty.c with 100% similarity]
plat/em/libsys/_ioctl.e [moved from lang/cem/libcc/mon/_ioctl.e with 100% similarity]
plat/em/libsys/_kill.e [moved from lang/cem/libcc/mon/_kill.e with 100% similarity]
plat/em/libsys/_link.e [moved from lang/cem/libcc/mon/_link.e with 100% similarity]
plat/em/libsys/_lseek.e [moved from lang/cem/libcc/mon/_lseek.e with 100% similarity]
plat/em/libsys/_open.e [moved from lang/cem/libcc/mon/_open.e with 100% similarity]
plat/em/libsys/_pause.e [moved from lang/cem/libcc/mon/_pause.e with 100% similarity]
plat/em/libsys/_pipe.e [moved from lang/cem/libcc/mon/_pipe.e with 100% similarity]
plat/em/libsys/_read.e [moved from lang/cem/libcc/mon/_read.e with 100% similarity]
plat/em/libsys/_sbrk.e [moved from lang/cem/libcc/mon/_sbrk.e with 100% similarity]
plat/em/libsys/_stty.c [moved from lang/cem/libcc/mon/_stty.c with 100% similarity]
plat/em/libsys/_times.e [moved from lang/cem/libcc/mon/_times.e with 100% similarity]
plat/em/libsys/_unlink.e [moved from lang/cem/libcc/mon/_unlink.e with 100% similarity]
plat/em/libsys/_wait.e [moved from lang/cem/libcc/mon/_wait.e with 100% similarity]
plat/em/libsys/_write.e [moved from lang/cem/libcc/mon/_write.e with 100% similarity]
plat/em/libsys/access.e [moved from lang/cem/libcc/mon/access.e with 100% similarity]
plat/em/libsys/acct.e [moved from lang/cem/libcc/mon/acct.e with 100% similarity]
plat/em/libsys/alarm.e [moved from lang/cem/libcc/mon/alarm.e with 100% similarity]
plat/em/libsys/brk.e [moved from lang/cem/libcc/mon/brk.e with 100% similarity]
plat/em/libsys/chdir.e [moved from lang/cem/libcc/mon/chdir.e with 100% similarity]
plat/em/libsys/chmod.e [moved from lang/cem/libcc/mon/chmod.e with 100% similarity]
plat/em/libsys/chown.e [moved from lang/cem/libcc/mon/chown.e with 100% similarity]
plat/em/libsys/chroot.e [moved from lang/cem/libcc/mon/chroot.e with 100% similarity]
plat/em/libsys/close.e [moved from lang/cem/libcc/mon/close.e with 100% similarity]
plat/em/libsys/creat.e [moved from lang/cem/libcc/mon/creat.e with 100% similarity]
plat/em/libsys/dup.e [moved from lang/cem/libcc/mon/dup.e with 100% similarity]
plat/em/libsys/dup2.e [moved from lang/cem/libcc/mon/dup2.e with 100% similarity]
plat/em/libsys/errno.e [moved from lang/cem/libcc/mon/errno.e with 100% similarity]
plat/em/libsys/execl.e [moved from lang/cem/libcc/mon/execl.e with 92% similarity]
plat/em/libsys/execle.e [moved from lang/cem/libcc/mon/execle.e with 100% similarity]
plat/em/libsys/execv.e [moved from lang/cem/libcc/mon/execv.e with 91% similarity]
plat/em/libsys/execve.e [moved from lang/cem/libcc/mon/execve.e with 100% similarity]
plat/em/libsys/fork.e [moved from lang/cem/libcc/mon/fork.e with 100% similarity]
plat/em/libsys/fstat.e [moved from lang/cem/libcc/mon/fstat.e with 100% similarity]
plat/em/libsys/ftime.e [moved from lang/cem/libcc/mon/ftime.e with 100% similarity]
plat/em/libsys/getegid.e [moved from lang/cem/libcc/mon/getegid.e with 100% similarity]
plat/em/libsys/geteuid.e [moved from lang/cem/libcc/mon/geteuid.e with 100% similarity]
plat/em/libsys/getgid.e [moved from lang/cem/libcc/mon/getgid.e with 100% similarity]
plat/em/libsys/getpid.e [moved from lang/cem/libcc/mon/getpid.e with 100% similarity]
plat/em/libsys/getuid.e [moved from lang/cem/libcc/mon/getuid.e with 100% similarity]
plat/em/libsys/gtty.c [moved from lang/cem/libcc/mon/gtty.c with 100% similarity]
plat/em/libsys/ioctl.e [moved from lang/cem/libcc/mon/ioctl.e with 100% similarity]
plat/em/libsys/isatty.c [new file with mode: 0644]
plat/em/libsys/kill.e [moved from lang/cem/libcc/mon/kill.e with 100% similarity]
plat/em/libsys/link.e [moved from lang/cem/libcc/mon/link.e with 100% similarity]
plat/em/libsys/lock.e [moved from lang/cem/libcc/mon/lock.e with 100% similarity]
plat/em/libsys/lseek.e [moved from lang/cem/libcc/mon/lseek.e with 100% similarity]
plat/em/libsys/mknod.e [moved from lang/cem/libcc/mon/mknod.e with 100% similarity]
plat/em/libsys/mount.e [moved from lang/cem/libcc/mon/mount.e with 100% similarity]
plat/em/libsys/mpxcall.e [moved from lang/cem/libcc/mon/mpxcall.e with 100% similarity]
plat/em/libsys/nice.e [moved from lang/cem/libcc/mon/nice.e with 100% similarity]
plat/em/libsys/open.e [moved from lang/cem/libcc/mon/open.e with 100% similarity]
plat/em/libsys/pause.e [moved from lang/cem/libcc/mon/pause.e with 100% similarity]
plat/em/libsys/pipe.e [moved from lang/cem/libcc/mon/pipe.e with 100% similarity]
plat/em/libsys/prof.e [moved from lang/cem/libcc/mon/prof.e with 100% similarity]
plat/em/libsys/ptrace.e [moved from lang/cem/libcc/mon/ptrace.e with 100% similarity]
plat/em/libsys/read.e [moved from lang/cem/libcc/mon/read.e with 100% similarity]
plat/em/libsys/sbrk.e [moved from lang/cem/libcc/mon/sbrk.e with 100% similarity]
plat/em/libsys/setgid.e [moved from lang/cem/libcc/mon/setgid.e with 100% similarity]
plat/em/libsys/setsig.e [moved from lang/cem/libcc/mon/setsig.e with 100% similarity]
plat/em/libsys/setuid.e [moved from lang/cem/libcc/mon/setuid.e with 100% similarity]
plat/em/libsys/signal.c [moved from lang/cem/libcc/mon/signal.c with 100% similarity]
plat/em/libsys/sigtrp.e [moved from lang/cem/libcc/mon/sigtrp.e with 100% similarity]
plat/em/libsys/stat.e [moved from lang/cem/libcc/mon/stat.e with 100% similarity]
plat/em/libsys/stime.e [moved from lang/cem/libcc/mon/stime.e with 100% similarity]
plat/em/libsys/stty.c [moved from lang/cem/libcc/mon/stty.c with 100% similarity]
plat/em/libsys/sync.e [moved from lang/cem/libcc/mon/sync.e with 100% similarity]
plat/em/libsys/tell.c [moved from lang/cem/libcc/mon/tell.c with 100% similarity]
plat/em/libsys/time.c [moved from lang/cem/libcc/mon/time.c with 100% similarity]
plat/em/libsys/times.e [moved from lang/cem/libcc/mon/times.e with 100% similarity]
plat/em/libsys/types [moved from lang/cem/libcc/mon/types with 100% similarity]
plat/em/libsys/umask.e [moved from lang/cem/libcc/mon/umask.e with 100% similarity]
plat/em/libsys/umount.e [moved from lang/cem/libcc/mon/umount.e with 100% similarity]
plat/em/libsys/unlink.e [moved from lang/cem/libcc/mon/unlink.e with 100% similarity]
plat/em/libsys/utime.e [moved from lang/cem/libcc/mon/utime.e with 100% similarity]
plat/em/libsys/wait.e [moved from lang/cem/libcc/mon/wait.e with 100% similarity]
plat/em/libsys/write.e [moved from lang/cem/libcc/mon/write.e with 100% similarity]
plat/em22/build-pkg.lua
plat/em22/include/build.lua
plat/em22/include/sgtty.h [new file with mode: 0644]
plat/em22/include/sys/timeb.h [moved from lang/cem/libcc/mon/exit.c with 66% similarity]
plat/em22/include/sys/types.h [new file with mode: 0644]
plat/em22/include/unistd.h
plat/em22/libsys/build.lua [new file with mode: 0644]

index efdb5c8..313ee32 100644 (file)
@@ -18,7 +18,7 @@ extern void _close(int);
 
 #define        FAIL    127
 
-extern const char **_penvp;
+extern const char **environ;
 static const char *exec_tab[] = {
        "sh",                   /* argv[0] */
        "-c",                   /* argument to the shell */
@@ -39,7 +39,7 @@ system(const char *str)
                        _close(i);
                if (!str) str = "cd .";         /* just testing for a shell */
                exec_tab[2] = str;              /* fill in command */
-               _execve("/bin/sh", exec_tab, _penvp);
+               _execve("/bin/sh", exec_tab, environ);
                /* get here if execve fails ... */
                _exit(FAIL);    /* see manual page */
        }
diff --git a/lang/cem/libcc/mon/cleanup.c b/lang/cem/libcc/mon/cleanup.c
deleted file mode 100644 (file)
index b19a5a0..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-/* $Id$ */
-_cleanup(){}
index c9fe9fb..d3c60bc 100644 (file)
@@ -93,6 +93,6 @@ killbss()
 extern int catch();
 
 int (*handler)() = catch;
-char **argv = 0, **environ = 0;
+char **argv = 0;
 int argc = 0;
 char *MainLB = 0;
similarity index 100%
rename from lang/cem/libcc/mon/LIST
rename to plat/em/libsys/LIST
similarity index 92%
rename from lang/cem/libcc/mon/_execl.e
rename to plat/em/libsys/_execl.e
index 1fcdfd7..3ce7ed5 100644 (file)
@@ -2,7 +2,7 @@
  mes 2,EM_WSIZE,EM_PSIZE
  exp $_execl
  pro $_execl,0
- lae _penvp
+ lae environ
  loi EM_PSIZE
  lal EM_PSIZE
  lal 0
similarity index 92%
rename from lang/cem/libcc/mon/execl.e
rename to plat/em/libsys/execl.e
index e958d65..706ce37 100644 (file)
@@ -2,7 +2,7 @@
  mes 2,EM_WSIZE,EM_PSIZE
  exp $execl
  pro $execl,0
- lae _penvp
+ lae environ
  loi EM_PSIZE
  lal EM_PSIZE
  lal 0
similarity index 91%
rename from lang/cem/libcc/mon/execv.e
rename to plat/em/libsys/execv.e
index 5cbaa34..7b127ee 100644 (file)
@@ -2,7 +2,7 @@
  mes 2,EM_WSIZE,EM_PSIZE
  exp $execv
  pro $execv,0
- lae _penvp
+ lae environ
  loi EM_PSIZE
  lal 0
  loi 2*EM_PSIZE
diff --git a/plat/em/libsys/isatty.c b/plat/em/libsys/isatty.c
new file mode 100644 (file)
index 0000000..f0ccbdc
--- /dev/null
@@ -0,0 +1,12 @@
+/* $Id$ */
+isatty(f)
+{
+       char buf[128];
+       /* not a sgttyb struct; it might not be large enough;
+          I know for a fact that it is'nt large enough on PC/IX,
+          where gtty is an ioctl(..., TCGETA, ...)
+       */
+
+       if (gtty(f, buf) < 0) return 0;
+       return 1;
+}
index d69a0f0..5d65ed7 100644 (file)
@@ -12,6 +12,7 @@ installable {
        map = {
                "+libs",
         "./include+pkg",
+        ["$(PLATIND)/em22/libsys.a"] = "./libsys+lib",
        }
 }
 
index a6f60c4..298f9b0 100644 (file)
@@ -9,7 +9,10 @@ local function addheader(h)
 end
 
 addheader("ack/config.h")
+addheader("sys/types.h")
+addheader("sys/timeb.h")
 addheader("unistd.h")
+addheader("sgtty.h")
 
 acklibrary {
        name = "headers",
diff --git a/plat/em22/include/sgtty.h b/plat/em22/include/sgtty.h
new file mode 100644 (file)
index 0000000..547a4ee
--- /dev/null
@@ -0,0 +1,119 @@
+/* $Id$ */
+/*
+ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+/* Data structures for ioctl/stty/gtty, sufficient for ACK libraries */
+
+#ifndef _SGTTY_H
+#define _SGTTY_H
+
+struct sgttyb {
+  char sg_ispeed;              /* input speed (not used) */
+  char sg_ospeed;              /* output speed (not used) */
+  char sg_erase;               /* erase character */
+  char sg_kill;                        /* kill character */
+#if defined(__USG) && !defined(_XENIX)
+  int sg_flags;                        /* mode flags */
+#else
+  short sg_flags;              /* mode flags */
+#endif
+};
+
+struct tchars {
+  char t_intrc;                        /* SIGINT char */
+  char t_quitc;                        /* SIGQUIT char */
+  char t_startc;               /* start output (initially CTRL-Q) */
+  char t_stopc;                        /* stop output  (initially CTRL-S) */
+  char t_eofc;                 /* EOF (initially CTRL-D) */
+  char t_brkc;                 /* input delimiter (like nl) */
+};
+
+/* Fields in t_flags. */
+#define ALLDELAY     0177400
+
+#define BSDELAY      0100000
+#  define BS0        0000000
+#  define BS1        0100000
+
+#define VTDELAY             0040000
+#  define FF0        0000000
+#  define FF1        0040000
+
+#define CRDELAY      0030000
+#  define CR0        0000000
+#  define CR1        0010000
+#  define CR2        0020000
+#  define CR3        0030000
+
+#if     defined(__USG) && !defined(_XENIX)
+#define XTABS       0000002    /* do tab expansion */
+#else
+#define XTABS       0006000    /* do tab expansion */
+#endif
+
+#define TBDELAY             0006000
+#  define TAB0       0000000
+#  define TAB1       0002000
+#  define TAB2       0004000
+
+#define NLDELAY             0001400
+#  define NL0       0000000
+#  define NL1        0000400
+#  define NL2        0001000
+#  define NL3        0001400
+
+#define ANYP         0000300
+#define EVENP        0000200
+#define ODDP         0000100
+
+#define RAW         0000040    /* enable raw mode */
+#define CRMOD       0000020    /* map lf to cr + lf */
+#define ECHO        0000010    /* echo input */
+#define LCASE       0000004
+#define CBREAK      0000002    /* enable cbreak mode */
+#if     defined(__BSD4_2) || defined(_XENIX)
+#define TANDEM      0000001
+#else
+#define HUPCL       0000001    /* unused ??? */
+#endif
+/*#define COOKED     0000000 */        /* neither CBREAK nor RAW */
+
+#ifdef __BDS4_2
+#define TIOCGETP (('t'<<8) | 8 | (6 << 16) | 0x40000000)
+#define TIOCSETP (('t'<<8) | 9 | (6 << 16) | 0x80000000)
+#define TIOCSETN (('t'<<8) | 10 | (6 << 16) | 0x80000000)
+#define TIOCEXCL (('t'<<8) | 13 | 0x20000000)
+#define TIOCNXCL (('t'<<8) | 14 | 0x20000000)
+#define TIOCHPCL (('t'<<8) | 2 | 0x20000000)
+#define TIOCGETC (('t'<<8) | 18 | (6 << 16) | 0x40000000)
+#define TIOCSETC (('t'<<8) | 17 | (6 << 16) | 0x80000000)
+#else
+#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 TIOCHPCL (('t'<<8) | 2)
+#define TIOCGETC (('t'<<8) | 18)
+#define TIOCSETC (('t'<<8) | 17)
+#endif
+
+#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
+
+#endif /* _SGTTY_H */
similarity index 66%
rename from lang/cem/libcc/mon/exit.c
rename to plat/em22/include/sys/timeb.h
index a73ec4d..92f48ed 100644 (file)
@@ -1,12 +1,11 @@
 /* $Id$ */
-
 /*
  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  * See the copyright notice in the ACK home directory, in the file "Copyright".
  */
-
-exit(code)
-{
-       _cleanup() ;
-       _exit(code) ;
-}
+struct timeb {
+       time_t  time;
+       unsigned short  millitm;
+       short   timezone;
+       short   dstflag;
+};
diff --git a/plat/em22/include/sys/types.h b/plat/em22/include/sys/types.h
new file mode 100644 (file)
index 0000000..8d431b0
--- /dev/null
@@ -0,0 +1,18 @@
+#ifndef _SYS_TYPES_H
+#define _SYS_TYPES_H
+
+#include <stddef.h> /* for off_t, ptrdiff_t, size_t */
+
+typedef int                    blkcnt_t; /* XXX should have 64 bits */
+typedef int                    blksize_t;
+typedef int                    dev_t;
+typedef unsigned int           gid_t;
+typedef unsigned int           ino_t;
+typedef unsigned short         mode_t;
+typedef unsigned short         nlink_t;
+typedef int                    pid_t;
+typedef ptrdiff_t              ssize_t;
+typedef unsigned int           uid_t;
+typedef unsigned long  time_t;
+
+#endif
index 30f13d9..7b45573 100644 (file)
@@ -59,11 +59,25 @@ typedef int sig_atomic_t;
 #define SIG_DFL ((sighandler_t) 0)            /* Default action.  */
 #define SIG_IGN ((sighandler_t) 1)            /* Ignore signal.  */
 
-#define SIGABRT         6       /* Abort (ANSI) */
-#define SIGILL          11      /* Illegal instruction */
+#define _NSIG             16   /* number of signals used */
+
+#define SIGHUP            1    /* hangup */
+#define SIGINT             2   /* interrupt (DEL) */
+#define SIGQUIT            3   /* quit (ASCII FS) */
+#define SIGILL             4   /* illegal instruction */
+#define SIGTRAP            5   /* trace trap (not reset when caught) */
+#define SIGABRT            6   /* IOT instruction */
+#define SIGIOT             6   /* SIGABRT for people who speak PDP-11 */
+#define SIGEMT             7   /* EMT instruction */
+#define SIGFPE             8   /* floating point exception */
+#define SIGKILL            9   /* kill (cannot be caught or ignored) */
+#define SIGBUS            10   /* bus error */
+#define SIGSEGV           11   /* segmentation violation */
+#define SIGSYS            12   /* bad argument to system call */
+#define SIGPIPE           13   /* write on a pipe with no one to read it */
+#define SIGALRM           14   /* alarm clock */
+#define SIGTERM           15   /* software termination signal from kill */
 
-#define _NSIG           32      /* Biggest signal number + 1
-                                   (not including real-time signals).  */
 typedef void (*sighandler_t)(int);
 extern sighandler_t signal(int signum, sighandler_t handler);
 extern int raise(int signum);
diff --git a/plat/em22/libsys/build.lua b/plat/em22/libsys/build.lua
new file mode 100644 (file)
index 0000000..7fdc388
--- /dev/null
@@ -0,0 +1,19 @@
+acklibrary {
+    name = "lib",
+    srcs = {
+        "./*.e",
+        "./*.c",
+        "plat/em/libsys/*.c",
+        "plat/em/libsys/*.e",
+    },
+       deps = {
+               "plat/em/libsys/*.h",
+               "lang/cem/libcc.ansi/headers+headers",
+        "plat/em22/include+pkg",
+               "h+emheaders",
+       },
+    vars = {
+        plat = "em22"
+    }
+}
+