diff --git a/scsh/aix/Makefile.inc b/scsh/aix/Makefile.inc new file mode 100644 index 0000000..826e6fe --- /dev/null +++ b/scsh/aix/Makefile.inc @@ -0,0 +1,8 @@ +AIX_P = exportlist.aix + +exportlist.aix: $(OBJS) + $(RM) exportlist.aix + for f in $(OBJS); do \ + /usr/ccs/bin/nm -B -e $$f | grep ' T [^ ][^ ]*$$' | \ + sed -e 's/^.* T \.*\([^ ][^ ]*\)$$/\1/' >> exportlist.aix; \ + done; diff --git a/scsh/aix/bufpol.scm b/scsh/aix/bufpol.scm new file mode 100644 index 0000000..5172dd1 --- /dev/null +++ b/scsh/aix/bufpol.scm @@ -0,0 +1,12 @@ +;;; Flags that control buffering policy. +;;; Copyright (c) 1993 by Olin Shivers. See file COPYING. + +;;; These are for the SET-PORT-BUFFERING procedure, essentially a Scheme +;;; analog of the setbuf(3S) stdio call. We use the actual stdio values. +;;; These constants are not likely to change from stdio lib to stdio lib, +;;; but you need to check when you do a port. + +(define-enum-constants bufpol + (block 0) ; _IOFBF + (line #o100) ; _IOLBF + (none 4)) ; _IONBF diff --git a/scsh/aix/errno.scm b/scsh/aix/errno.scm new file mode 100644 index 0000000..241e8fa --- /dev/null +++ b/scsh/aix/errno.scm @@ -0,0 +1,140 @@ +;;; Errno constant definitions. +;;; Copyright (c) 1993 by Olin Shivers. See file COPYING. +;;; AIX version by Chipsy Sperber + +(define errno/2big 7) ; 2big is not a legit Scheme symbol. Lose, lose. + +(define-enum-constants errno + ;; POSIX: + (perm 1) ; Operation not permitted + (noent 2) ; No such file or directory + (srch 3) ; No such process + (intr 4) ; Interrupted function call + (io 5) ; Input/output error + (nxio 6) ; No such device or address +; (2big 7) ; Arg list too long + (noexec 8) ; Exec format error + (badf 9) ; Bad file descriptor + (child 10) ; No child processes + (again 11) ; Resource temporarily unavailable + (nomem 12) ; Not enough space + (acces 13) ; Permission denied + (fault 14) ; Bad address + (notblk 15) ; Block device required + (busy 16) ; Resource busy + (exist 17) ; File exists + (xdev 18) ; Improper link + (nodev 19) ; No such device + (notdir 20) ; Not a directory + (isdir 21) ; Is a directory + (inval 22) ; Invalid argument + (nfile 23) ; Too many open files in system + (mfile 24) ; Too many open files + (notty 25) ; Inappropriate I/O control operation + (xtbsy 26) ; Text file busy + (fbig 27) ; File too large + (nospc 28) ; No space left on device + (spipe 29) ; Invalid seek + (rofs 30) ; Read-only file system + (mlink 31) ; Too many links + (pipe 32) ; Broken pipe + + ;; POSIX: + ;; math software + (dom 33) ; Domain error + (range 34) ; Result too large + + (nomsg 35) ; No message of desired type + (idrm 36) ; Identifier removed + (chrng 37) ; Channel number out of range + (l2nsync 38) ; Level 2 not synchronized + (l3hlt 39) ; Level 3 halted + (l3rst 40) ; Level 3 reset + (lnrng 41) ; Link number out of range + (unatch 42) ; Protocol driver not attached + (nocsi 43) ; No CSI structure available + (l2hlt 44) ; Level 2 halted + (deadlk 45) ; Resource deadlock avoided + + (notready 46) ; Device not ready + (wrprotect 47) ; Write-protected media + (format 48) ; Unformatted media + + (nolck 49) ; No locks available + + ;; non-blocking and interrupt i/o + (wouldblock 54) ; Operation would block + + (inprogress 55) ; Operation now in progress + (already 56) ; Operation already in progress + + ;; ipc/network software + (notsock 57) ; Socket operation on non-socket + (destaddrreq 58) ; Destination address required + (msgsize 59) ; Message too long + (prototype 60) ; Protocol wrong type for socket + (noprotoopt 61) ; Protocol not available + (protonosupport 62) ; Protocol not supported + (socktnosupport 63) ; Socket type not supported + (opnotsupp 64) ; Operation not supported on socket + (pfnosupport 65) ; Protocol family not supported + (afnosupport 66) ; Address family not supported by protocol family + (addrinuse 67) ; Address already in use + (addrnotavail 68) ; Can't assign requested address + (netdown 69) ; Network is down + (netunreach 70) ; Network is unreachable + (netreset 71) ; Network dropped connection on reset + (connaborted 72) ; Software caused connection abort + (connreset 73) ; Connection reset by peer + (nobufs 74) ; No buffer space available + (isconn 75) ; Socket is already connected + (notconn 76) ; Socket is not connected + (shutdown 77) ; Can't send after socket shutdown + + (timedout 78) ; Connection timed out + (connrefused 79) ; Connection refused + + (hostdown 80) ; Host is down + (hostunreach 81) ; No route to host + + (restart 82) ; restart the system call + + ;; quotas and limits + (proclim 83) ; Too many processes + (users 84) ; Too many users + (loop 85) ; Too many levels of symbolic links + (nametoolong 86) ; File name too long + + (notempty 87) ; Directory not empty + (dquot 88) ; Disc quota exceeded + + ;; network file system + (remote 93) ; Item is not local to host + + (nosys 109) ; Function not implemented POSIX + + ;; disk device driver + (media 110) ; media surface error + (soft 111) ; I/O completed, but needs relocation + + ;; security + (noattr 112) ; no attribute found + (sad 113) ; security authentication denied + (notrust 114) ; not a trusted program + + ;; BSD 4.3 RENO + (toomanyrefs 115) ; Too many references: can't splice + + (ilseq 116) ; Invalid wide character + (canceled 117) ; asynchronous i/o cancelled + + ;; SVR4 STREAMS + (nosr 118) ; temp out of streams resources + (time 119) ; I_STR ioctl timed out + (badmsg 120) ; wrong message type at stream head + (proto 121) ; STREAMS protocol error + (nodata 122) ; no message ready at stream head + (nostr 123) ; fd is not a stream + + (cloneme 82) ; this is the way we clone a stream +) diff --git a/scsh/aix/fdflags.scm b/scsh/aix/fdflags.scm new file mode 100644 index 0000000..30fe529 --- /dev/null +++ b/scsh/aix/fdflags.scm @@ -0,0 +1,48 @@ +;;; Flags for open(2) and fcntl(2). +;;; Copyright (c) 1993 by Olin Shivers. See file COPYING. +;;; AIX version by Chipsy Sperber + +(define-enum-constants open + (read 0) + (write 1) + (read+write 2) + (append 8) + (create #x0100) + (exclusive #x0400) + (no-control-tty #x0800) + (non-blocking #x0004) + (truncate #x0200) + +;;; Not POSIX. + (no-delay #x8000) + (sync #x0010)) + +(define open/access-mask + (bitwise-ior open/read + (bitwise-ior open/write open/read+write))) + +;;; fcntl() commands +(define-enum-constants fcntl + (dup-fdes 0) ; F_DUPFD + (get-fdes-flags 1) ; F_GETFD + (set-fdes-flags 2) ; F_SETFD + (get-status-flags 3) ; F_GETFL + (set-status-flags 4) ; F_SETFL + (get-record-lock 5) ; F_GETLK + (set-record-lock-no-block 6) ; F_SETLK + (set-record-lock 7)) ; F_SETLKW + +;;; fcntl fdes-flags (F_GETFD) + +(define fdflags/close-on-exec 1) + +;;; fcntl status-flags (F_GETFL) +;;; Mostly, these are OPEN/... flags, like OPEN/APPEND. +;;; (define fdstatus/... ...) + +;;; fcntl lock values. + +(define-enum-constants lock + (read 1) ; F_RDLCK + (write 2) ; F_WRLCK + (release 3)) ; F_UNLCK diff --git a/scsh/aix/libansi.c b/scsh/aix/libansi.c new file mode 100644 index 0000000..bcd6e0e --- /dev/null +++ b/scsh/aix/libansi.c @@ -0,0 +1,3 @@ +/* OS-dependent support for what is supposed to be the standard ANSI C Library. +** Copyright (c) 1996 by Brian D. Carlstrom. +*/ diff --git a/scsh/aix/netconst.scm b/scsh/aix/netconst.scm new file mode 100644 index 0000000..edf8ed5 --- /dev/null +++ b/scsh/aix/netconst.scm @@ -0,0 +1,133 @@ +;;; Magic Numbers for Networking +;;; Copyright (c) 1994 by Brian D. Carlstrom. See file COPYING. + +;;; magic numbers not from header file +;;; but from man page +;;; why can't unix make up its mind +(define shutdown/receives 0) +(define shutdown/sends 1) +(define shutdown/sends+receives 2) + +;;;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +;;; BELOW THIS POINT ARE BITS FROM: +;;; +;;; +;;; +;;; +;;; +;;;-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + +;;; ADDRESS FAMILIES -- +(define address-family/unspecified 0) ; unspecified +(define address-family/unix 1) ; local to host (pipes, portals) +(define address-family/internet 2) ; internetwork: UDP, TCP, etc. + +;;; SOCKET TYPES -- +(define socket-type/stream 1) ; stream socket +(define socket-type/datagram 2) ; datagram socket +(define socket-type/raw 3) ; raw-protocol interface +;;(define socket-type/rdm 4) ; reliably-delivered message +;;(define socket-type/seqpacket 5) ; sequenced packet stream + +;;; PROTOCOL FAMILIES -- +(define protocol-family/unspecified 0) ; unspecified +(define protocol-family/unix 1) ; local to host (pipes, portals) +(define protocol-family/internet 2) ; internetwork: UDP, TCP, etc. + +;;; Well know addresses -- +(define internet-address/any #x00000000) +(define internet-address/loopback #x7f000001) +(define internet-address/broadcast #xffffffff) ; must be masked + +;;; errors from host lookup -- +(define herror/host-not-found 1) ;Authoritative Answer Host not found +(define herror/try-again 2) ;Non-Authoritive Host not found, or SERVERFAIL +(define herror/no-recovery 3) ;Non recoverable errors, FORMERR, REFUSED, NOTIMP +(define herror/no-data 4) ;Valid name, no data record of requested type +(define herror/no-address herror/no-data) ;no address, look for MX record + +;;; flags for send/recv -- +(define message/out-of-band 1) ; process out-of-band data +(define message/peek 2) ; peek at incoming message +(define message/dont-route 4) ; send without using routing tables +(define message/eor #x8) ; data completes record +(define message/trunc #x10) ; data discarded before delivery +(define message/ctrunc #x20) ; control data lost before delivery +(define message/waitall #x40) ; wait for full request or error + +;;; protocol level for socket options -- +(define level/socket #xffff) ; SOL_SOCKET: options for socket level + +;;; socket options -- +(define socket/debug #x0001) ; turn on debugging info recording +(define socket/accept-connect #x0002) ; socket has had listen() +(define socket/reuse-address #x0004) ; allow local address reuse +(define socket/keep-alive #x0008) ; keep connections alive +(define socket/dont-route #x0010) ; just use interface addresses +(define socket/broadcast #x0020) ; permit sending of broadcast msgs +(define socket/use-loop-back #x0040) ; bypass hardware when possible +(define socket/linger #x0080) ; linger on close if data present +(define socket/oob-inline #x0100) ; leave received OOB data in line +;(define socket/use-privileged #x4000) ; allocate from privileged port area +;(define socket/cant-signal #x8000) ; prevent SIGPIPE on SS_CANTSENDMORE +(define socket/send-buffer #x1001) ; send buffer size +(define socket/receive-buffer #x1002) ; receive buffer size +(define socket/send-low-water #x1003) ; send low-water mark +(define socket/receive-low-water #x1004) ; receive low-water mark +(define socket/send-timeout #x1005) ; send timeout +(define socket/receive-timeout #x1006) ; receive timeout +(define socket/error #x1007) ; get error status and clear +(define socket/type #x1008) ; get socket type + +;;; ip options -- +(define ip/options 1) ; set/get IP per-packet options +(define ip/include-header 2) ; int; header is included with data (raw) +(define ip/type-of-service 3) ; int; IP type of service and precedence +(define ip/time-to-live 4) ; int; IP time to live +(define ip/recvopt 5) ; bool; receive all IP options w/datagram +(define ip/recvret 6) ; bool; receive IP options for response +(define ip/recvdst 7) ; bool; receive IP dst addr w/datagram +(define ip/retopts 8) ; ip_opts; set/get IP per-packet options + +;;; tcp options -- +(define tcp/no-delay #x01) ; don't delay send to coalesce packets +(define tcp/max-segment #x02) ; set maximum segment size + +;;; -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- +;;; OPTION SETS FOR SOCKET-OPTION AND SET-SOCKET-OPTION + +;;; Boolean Options +(define options/boolean + (list socket/debug + socket/accept-connect + socket/reuse-address + socket/keep-alive + socket/dont-route + socket/broadcast + socket/use-loop-back + socket/oob-inline +; socket/use-privileged +; socket/cant-signal + ip/include-header + tcp/no-delay)) + +;;; Integer Options +(define options/value + (list socket/send-buffer + socket/receive-buffer + socket/send-low-water + socket/receive-low-water + socket/error + socket/type + ip/time-to-live + ip/type-of-service + tcp/max-segment)) + +;;; #f or Positive Integer +(define options/linger + (list socket/linger)) + +;;; Real Number +(define options/timeout + (list socket/send-timeout + socket/receive-timeout)) diff --git a/scsh/aix/packages.scm b/scsh/aix/packages.scm new file mode 100644 index 0000000..944e109 --- /dev/null +++ b/scsh/aix/packages.scm @@ -0,0 +1,143 @@ +;;; Interfaces and packages for the machine specific parts of scsh. +;;; Copyright (c) 1994 by Olin Shivers. See file COPYING. +;;; Copyright (c) 1994 by Brian D. Carlstrom. +;;; AIX version by Chipsy Sperber + +(define-interface aix-fdflags-extras-interface + (export open/no-delay + open/sync)) + +(define-interface aix-errno-extras-interface + (export errno/nomsg + errno/idrm + errno/chrng + errno/l2nsync + errno/l3hlt + errno/l3rst + errno/lnrng + errno/unatch + errno/nocsi + errno/l2hlt + errno/notready + errno/wrprotect + errno/format + errno/wouldblock + errno/inprogress + errno/already + errno/notsock + errno/destaddrreq + errno/msgsize + errno/prototype + errno/noprotoopt + errno/protonosupport + errno/socktnosupport + errno/opnotsupp + errno/pfnosupport + errno/afnosupport + errno/addrinuse + errno/addrnotavail + errno/netdown + errno/netunreach + errno/netreset + errno/connaborted + errno/connreset + errno/nobufs + errno/isconn + errno/notconn + errno/shutdown + errno/timedout + errno/connrefused + errno/hostdown + errno/hostunreach + errno/restart + errno/proclim + errno/users + errno/loop + errno/dquot + errno/remote + errno/media + errno/soft + errno/noattr + errno/sad + errno/notrust + errno/toomanyrefs + errno/ilseq + errno/canceled + errno/nosr + errno/time + errno/badmsg + errno/proto + errno/nodata + errno/nostr + errno/cloneme)) + +(define-interface aix-signals-extras-interface + (export signal/io + signal/xcpu + signal/xfsz + signal/msg + signal/winch + signal/pwr + signal/prof + signal/danger + signal/vtalrm + signal/migrate + signal/pre + signal/virt)) + +(define-interface aix-network-extras-interface + (export socket/debug + socket/accept-connect + socket/reuse-address + socket/keep-alive + socket/dont-route + socket/broadcast + socket/use-loop-back + socket/linger + socket/oob-inline +; socket/use-privileged +; socket/cant-signal + socket/send-buffer + socket/receive-buffer + socket/send-low-water + socket/receive-low-water + socket/send-timeout + socket/receive-timeout + socket/error + socket/type + ip/options + ip/include-header + ip/type-of-service + ip/time-to-live + ip/recvopt + ip/recvret + ip/recvdst + ip/retopts + tcp/no-delay + tcp/max-segment + message/eor + message/trunc + message/ctrunc + message/waitall + )) + +(define-interface aix-extras-interface + (compound-interface aix-errno-extras-interface + aix-fdflags-extras-interface + aix-network-extras-interface + aix-signals-extras-interface)) + +(define-interface aix-defs-interface + (compound-interface aix-extras-interface + sockets-network-interface + posix-errno-interface + posix-fdflags-interface + posix-signals-interface + signals-internals-interface)) + +(define-structure aix-defs aix-defs-interface + (open scheme bitwise defenum-package) + (files fdflags errno signals netconst)) + +(define-interface os-extras-interface aix-extras-interface) +(define os-dependent aix-defs) diff --git a/scsh/aix/signals.scm b/scsh/aix/signals.scm new file mode 100644 index 0000000..36420bb --- /dev/null +++ b/scsh/aix/signals.scm @@ -0,0 +1,53 @@ +;;; Signal constant definitions for AIX +;;; Copyright (c) 1994 by Olin Shivers. See file COPYING. +;;; Copyright (c) 1994 by Brian D. Carlstrom. +;;; AIX version by Chipsy Sperber + +;;POSIX only defined here. + +(define-enum-constants signal + ;; POSIX + (hup 1) ; hangup + (int 2) ; interrupt + (quit 3) ; quit + (ill 4) ; illegal instruction (not reset when caught) + (iot 5) ; IOT instruction + (abrt 6) ; used by abort, replace SIGIOT in the future + (fpe 8) ; floating point exception + (emt 7) ; EMT intruction + (fpe 8) ; floating point exception + (kill 9) ; kill (cannot be caught or ignored) + (bus 10) ; bus error (specification exception) + (segv 11) ; segmentation violation + (sys 12) ; bad argument to system call + (pipe 13) ; write on a pipe with no one to read it + (alrm 14) ; alarm clock + (term 15) ; software termination signal from kill + (urg 16) ; urgent contition on I/O channel + (stop 17) ; sendable stop signal not from tty + (tstp 18) ; stop signal from tty + (cont 19) ; continue a stopped process + (chld 20) ; to parent on child stop or exit + (ttin 21) ; to readers pgrp upon background tty read + (ttou 22) ; like TTIN for output if (tp->t_local<OSTOP) + + (io 23) ; I/O possible, or completed + (xcpu 24) ; cpu time limit exceeded (see setrlimit) + (xfsz 25) ; file size limit exceeded (see setrlimit) + (msg 27) ; input data is in the HFT ring buffer + (winch 28) ; window size changed + (pwr 29) ; power-fail restart + (usr1 30) ; user defined signal 1 + (usr2 31) ; user defined signal 2 + (prof 32) ; profiling time alarm (see setitimer) + (danger 33) ; system crash imminent; free up some page space + (vtalrm 34) ; virtual time alarm (see setitimer) + (migrate 35) ; migrate process (see TCF) + (pre 36) ; programming exception + (virt 37) ; AIX virtual time alarm + ) + +(define signals-ignored-by-default + (list signal/chld signal/cont ; These are Posix. + signal/urg signal/io signal/winch signal/pwr ; These are AIX + signal/danger)) diff --git a/scsh/aix/signals1.c b/scsh/aix/signals1.c new file mode 100644 index 0000000..f8b1205 --- /dev/null +++ b/scsh/aix/signals1.c @@ -0,0 +1,136 @@ +/* Need to turn off synchronous error signals (SIGPIPE, SIGSYS). */ + +#include "../scsh_aux.h" + +/* Make sure our exports match up w/the implementation: */ +#include "../signals1.h" + +/* This table converts Unix signal numbers to S48/scsh interrupt numbers. +** If the signal doesn't have an interrupt number, the entry is -1. +** (Only asynchronous signals have interrupt numbers.) +** +** Note that we bake into this table the integer values of the signals -- +** i.e., we assume that SIGHUP=1, SIGALRM=15, etc. So this definition is +** very system-dependent. +*/ +const int sig2int[] = { + -1, /* 0 is not a signal */ + scshint_hup, /* SIGHUP */ + scshint_keyboard, /* SIGINT */ + scshint_quit, /* SIGQUIT */ + -1, /* SIGILL */ + -1, /* SIGTRAP */ + -1, /* SIGABRT & SIGIOT */ + -1, /* SIGEMT */ + -1, /* SIGFPE */ + -1, /* SIGKILL */ + -1, /* SIGBUS */ + -1, /* SIGSEGV */ + -1, /* SIGSYS */ + -1, /* SIGPIPE */ + scshint_alarm, /* SIGALRM */ + scshint_term, /* SIGTERM */ + scshint_urg, /* SIGURG */ + -1, /* SIGSTOP */ + scshint_tstp, /* SIGTSTP */ + scshint_cont, /* SIGCONT */ + scshint_chld, /* SIGCHLD */ + -1, /* scshint_ttyin, /* SIGTTIN */ + -1, /* scshint_ttou, /* SIGTTOU */ + scshint_io, /* SIGIO */ + scshint_xcpu, /* SIGXCPU */ + scshint_xfsz, /* SIGXFSZ */ + -1, /* SIGMSG */ + scshint_winch, /* SIGWINCH */ + scshint_pwr, /* SIGPWR */ + scshint_usr1, /* SIGUSR1 */ + scshint_usr2, /* SIGUSR2 */ + scshint_prof, /* SIGPROF */ + -1, /* SIGDANGER */ + scshint_vtalrm, /* SIGVTALRM */ + -1, /* SIGMIGRATE */ + -1, /* SIGPRE */ + -1, /* SIGVIRT */ + -1, /* SIGALRM1 */ + -1 /* SIGWAITING */ + }; + +const int max_sig = 39; /* SIGWAITING */ + +/* +scshint_alarm +scshint_keyboard +scshint_memory_shortage +scshint_chld +scshint_cont +scshint_hup +scshint_quit +scshint_term +scshint_tstp +scshint_usr1 +scshint_usr2 +scshint_info +scshint_io +scshint_poll +scshint_prof +scshint_pwr +scshint_urg +scshint_vtalrm +scshint_winch +scshint_xcpu +scshint_xfsz + +SIGALRM +SIGCHLD +SIGCONT +SIGHUP +SIGINFO +SIGINT +SIGIO +SIGPROF +SIGQUIT +SIGTERM +SIGTSTP +SIGTTIN +SIGTTOU +SIGURG +SIGUSR1 +SIGUSR2 +SIGVTALRM +SIGWINCH +SIGXCPU +SIGXFSZ + +SIGHUP 1 +SIGINT 2 +SIGQUIT 3 +SIGILL 4 +SIGTRAP 5 +SIGABRT 6 +SIGIOT SIGABRT +SIGEMT 7 +SIGFPE 8 +SIGKILL 9 +SIGBUS 10 +SIGSEGV 11 +SIGSYS 12 +SIGPIPE 13 +SIGALRM 14 +SIGTERM 15 +SIGURG 16 +SIGSTOP 17 +SIGTSTP 18 +SIGCONT 19 +SIGCHLD 20 +SIGTTIN 21 +SIGTTOU 22 +SIGIO 23 +SIGXCPU 24 +SIGXFSZ 25 +SIGVTALRM 26 +SIGPROF 27 +SIGWINCH 28 +SIGINFO 29 +SIGUSR1 30 +SIGUSR2 31 +*/ diff --git a/scsh/aix/sigset.h b/scsh/aix/sigset.h new file mode 100644 index 0000000..ca6e50f --- /dev/null +++ b/scsh/aix/sigset.h @@ -0,0 +1,10 @@ +/* Convert between a lo24/hi integer-pair bitset and a sigset_t value. +** These macros are OS-dependent, and must be defined per-OS. +*/ + +#define make_sigset(maskp, hi, lo) ((maskp)->losigs=((hi)<<24)|(lo)) + +/* Not a procedure: */ +#define split_sigset(mask, hip, lop) \ + ((*(hip)=(mask.losigs>>24)&0xff), \ + (*(lop)=(mask.losigs&0xffffff))) diff --git a/scsh/aix/stdio_dep.c b/scsh/aix/stdio_dep.c new file mode 100644 index 0000000..9b3d1b7 --- /dev/null +++ b/scsh/aix/stdio_dep.c @@ -0,0 +1,85 @@ +/* Copyright (c) 1994 by Olin Shivers. +** Copyright (c) 1994-1995 by Brian D. Carlstrom. +** AIX version by Chipsy Sperber +** +** This file implements the char-ready? procedure for file descriptors +** and Scsh's fdports. It is not Posix, so it must be implemented for +** each OS to which scsh is ported. +** +** This version assumes two things: +** - the existence of select to tell if there is data +** available for the file descriptor. +** - the existence of the _cnt field in the stdio FILE struct, telling +** if there is any buffered input in the struct. +** +** Most Unixes have these things, so this file should work for them. +** However, Your Mileage May Vary. +** +** You could also replace the select() with a iotctl(FIONREAD) call, if you +** had one but not the other. +** -Olin&Brian +*/ + +#include +#include +#include +#include +#include "libcig.h" +#include +#include + +#include "stdio_dep.h" /* Make sure the .h interface agrees with the code. */ + +/* These two procs return #t if data ready, #f data not ready, +** and errno if error. +*/ + +s48_value char_ready_fdes(int fd) +{ + fd_set readfds; + struct timeval timeout; + int result; + + FD_ZERO(&readfds); + FD_SET(fd,&readfds); + + timeout.tv_sec=0; + timeout.tv_usec=0; + + result=select(fd+1, &readfds, NULL, NULL, &timeout); + + if(result == -1 ) + return(s48_enter_fixnum(errno)); + if(result) + return(S48_TRUE); + return(S48_FALSE); +} + +s48_value stream_char_readyp(FILE *f) +{ + int fd = fileno(f); + return f->_cnt > 0 ? S48_TRUE : char_ready_fdes(fd); +} + +void setfileno(FILE *fs, int fd) +{ + fileno(fs) = fd; +} + +int fbufcount(FILE* fs) +{ + return(fs->_cnt); +} + +/* Returns true if there is no buffered data in stream FS +** (or there is no buffering, period.) +*/ + +int ibuf_empty(FILE *fs) {return fs->_cnt <= 0;} + + +/* Returns true if the buffer in stream FS is full +** (or there is no buffering, period). +*/ + +int obuf_full(FILE *fs) {return fs->_cnt <= 0;} diff --git a/scsh/aix/stdio_dep.h b/scsh/aix/stdio_dep.h new file mode 100644 index 0000000..435ebf0 --- /dev/null +++ b/scsh/aix/stdio_dep.h @@ -0,0 +1,13 @@ +/* Exports from stdio_dep.h. */ + +s48_value char_ready_fdes(int fd); + +s48_value stream_char_readyp(FILE *f); + +void setfileno(FILE *fs, int fd); + +int fbufcount(FILE* fs); + +int ibuf_empty(FILE *fs); + +int obuf_full(FILE *fs); diff --git a/scsh/aix/sysdep.h b/scsh/aix/sysdep.h new file mode 100644 index 0000000..3f09423 --- /dev/null +++ b/scsh/aix/sysdep.h @@ -0,0 +1,4 @@ +#undef HAVE_DLOPEN + +#undef HAVE_TZNAME +#define HAVE_TZNAME diff --git a/scsh/aix/time_dep.scm b/scsh/aix/time_dep.scm new file mode 100644 index 0000000..b9b2063 --- /dev/null +++ b/scsh/aix/time_dep.scm @@ -0,0 +1,8 @@ +;;; OS-dependent time stuff +;;; Copyright (c) 1995 by Olin Shivers. See file COPYING. + +;;; This suffices for BSD systems with the gettimeofday() +;;; microsecond-resolution timer. + +(define (ticks/sec) 1000000) ; usec + diff --git a/scsh/aix/time_dep1.c b/scsh/aix/time_dep1.c new file mode 100644 index 0000000..8e799e0 --- /dev/null +++ b/scsh/aix/time_dep1.c @@ -0,0 +1,38 @@ +/* OS-dependent support for fine-grained timer. +** Copyright (c) 1995 by Olin Shivers. +** +** We return the current time in seconds and sub-second "ticks" where the +** number of ticks/second is OS dependent (and is defined in time_dep.scm). +** This definition works on any BSD Unix with the gettimeofday() +** microsecond-resolution timer. +*/ + +#include +#include +#include "scheme48.h" +#include "../time1.h" + +/* Sux because it's dependent on 32-bitness. */ +#define hi8(i) (((i)>>24) & 0xff) +#define lo24(i) ((i) & 0xffffff) +#define comp8_24(hi, lo) (((hi)<<24) + (lo)) + +s48_value time_plus_ticks(int *hi_secs, int *lo_secs, + int *hi_ticks, int *lo_ticks) +{ + struct timeval t; + struct timezone tz; + + if( gettimeofday(&t, &tz) ) return s48_enter_fixnum(errno); + + { long int secs = t.tv_sec; + long int ticks = t.tv_usec; + + *hi_secs = hi8(secs); + *lo_secs = lo24(secs); + *hi_ticks = hi8(ticks); + *lo_ticks = lo24(ticks); + } + + return S48_FALSE; + } diff --git a/scsh/aix/tty-consts.scm b/scsh/aix/tty-consts.scm new file mode 100644 index 0000000..f4475c7 --- /dev/null +++ b/scsh/aix/tty-consts.scm @@ -0,0 +1,216 @@ +;;; Constant definitions for tty control code (POSIX termios). +;;; Copyright (c) 1995 by Brian Carlstrom. See file COPYING. +;;; Largely rehacked by Olin. + +;;; These constants are for AIX 3.2.x, +;;; and are taken from /usr/include/sys/termio.h +;;; and /usr/include/sys/ttydev.h + +;;; Non-standard (POSIX, SVR4, 4.3+BSD) things: +;;; - Some of the baud rates. + + +;;; Special Control Characters +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;; Indices into the c_cc[] character array. + +;;; Name Subscript Enabled by +;;; ---- --------- ---------- +;;; POSIX +(define ttychar/eof 4) ; ^d icanon +(define ttychar/eol 5) ; icanon +(define ttychar/delete-char 2) ; ^? icanon +(define ttychar/delete-line 3) ; ^u icanon +(define ttychar/interrupt 0) ; ^c isig +(define ttychar/quit 1) ; ^\ isig +(define ttychar/suspend 9) ; ^z isig +(define ttychar/start 7) ; ^q ixon, ixoff +(define ttychar/stop 8) ; ^s ixon, ixoff +(define ttychar/min 4) ; !icanon ; Not exported +(define ttychar/time 5) ; !icanon ; Not exported + +;;; SVR4 & 4.3+BSD +(define ttychar/delete-word 13) ; ^w icanon +(define ttychar/reprint 11) ; ^r icanon +(define ttychar/literal-next 14) ; ^v iexten +(define ttychar/discard 12) ; ^o iexten +(define ttychar/delayed-suspend 10) ; ^y isig +(define ttychar/eol2 6) ; icanon + +;;; 4.3+BSD +(define ttychar/status #f) ; ^t icanon + +;;; Length of control-char string -- *Not Exported* +(define num-ttychars 16) + +;;; Magic "disable feature" tty character +(define disable-tty-char (ascii->char #xff)) ; _POSIX_VDISABLE + +;;; Flags controllling input processing +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;; POSIX +(define ttyin/ignore-break #x00001) ; ignbrk +(define ttyin/interrupt-on-break #x00002) ; brkint +(define ttyin/ignore-bad-parity-chars #x00004) ; ignpar +(define ttyin/mark-parity-errors #x00008) ; parmrk +(define ttyin/check-parity #x00010) ; inpck +(define ttyin/7bits #x00020) ; istrip +(define ttyin/nl->cr #x00040) ; inlcr +(define ttyin/ignore-cr #x00080) ; igncr +(define ttyin/cr->nl #x00100) ; icrnl +(define ttyin/output-flow-ctl #x00200) ; ixon +(define ttyin/input-flow-ctl #x00400) ; ixoff + + +;;; SVR4 & 4.3+BSD +(define ttyin/xon-any #x1000) ; ixany: Any char restarts after stop +(define ttyin/beep-on-overflow #x10000) ; imaxbel: queue full => ring bell + +;;; SVR4 +(define ttyin/lowercase #x800) ; iuclc: Map upper-case to lower case + + +;;; Flags controlling output processing +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;; POSIX +(define ttyout/enable #o000001) ; opost: enable output processing + +;;; SVR4 & 4.3+BSD +(define ttyout/nl->crnl #o000004) ; onlcr: map nl to cr-nl + +;;; 4.3+BSD +(define ttyout/discard-eot #f) ; onoeot +(define ttyout/expand-tabs #f) ; oxtabs (NOT xtabs) + +;;; SVR4 +(define ttyout/cr->nl #x000008) ; ocrnl +(define ttyout/fill-w/del #x000080) ; ofdel +(define ttyout/delay-w/fill-char #x000040) ; ofill +(define ttyout/uppercase #x000002) ; olcuc +(define ttyout/nl-does-cr #x000020) ; onlret +(define ttyout/no-col0-cr #x000010) ; onocr + +;;; Newline delay +(define ttyout/nl-delay #x004000) ; mask (nldly) +(define ttyout/nl-delay0 #x000000) +(define ttyout/nl-delay1 #x004000) ; tty 37 + +;;; Horizontal-tab delay +(define ttyout/tab-delay #x000c00) ; mask (tabdly) +(define ttyout/tab-delay0 #x000000) +(define ttyout/tab-delay1 #x000400) ; tty 37 +(define ttyout/tab-delay2 #x000800) +(define ttyout/tab-delayx #x000c00) ; Expand tabs (xtabs, tab3) + +;;; Carriage-return delay +(define ttyout/cr-delay #x000300) ; mask (crdly) +(define ttyout/cr-delay0 #x000000) +(define ttyout/cr-delay1 #x000100) ; tn 300 +(define ttyout/cr-delay2 #x000200) ; tty 37 +(define ttyout/cr-delay3 #x000300) ; concept 100 + +;;; Vertical tab delay +(define ttyout/vtab-delay #x008000) ; mask (vtdly) +(define ttyout/vtab-delay0 #x000000) +(define ttyout/vtab-delay1 #x008000) ; tty 37 + +;;; Backspace delay +(define ttyout/bs-delay #x001000) ; mask (bsdly) +(define ttyout/bs-delay0 #x000000) +(define ttyout/bs-delay1 #x001000) + +;;; Form-feed delay +(define ttyout/ff-delay #x002000) ; mask (ffdly) +(define ttyout/ff-delay0 #x000000) +(define ttyout/ff-delay1 #x002000) + +(define ttyout/all-delay + (bitwise-ior (bitwise-ior (bitwise-ior ttyout/nl-delay ttyout/tab-delay) + (bitwise-ior ttyout/cr-delay ttyout/vtab-delay)) + (bitwise-ior ttyout/bs-delay ttyout/ff-delay))) + + +;;; Control flags - hacking the serial-line. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;; POSIX +(define ttyc/char-size #x00030) ; csize: character size mask +(define ttyc/char-size5 #x00000) ; 5 bits (cs5) +(define ttyc/char-size6 #x00010) ; 6 bits (cs6) +(define ttyc/char-size7 #x00020) ; 7 bits (cs7) +(define ttyc/char-size8 #x00030) ; 8 bits (cs8) +(define ttyc/2-stop-bits #x00040) ; cstopb: Send 2 stop bits. +(define ttyc/enable-read #x00080) ; cread: Enable receiver. +(define ttyc/enable-parity #x00100) ; parenb +(define ttyc/odd-parity #x00200) ; parodd +(define ttyc/hup-on-close #x00400) ; hupcl: Hang up on last close. +(define ttyc/no-modem-sync #x00800) ; clocal: Ignore modem lines. + +;;; 4.3+BSD +(define ttyc/ignore-flags #f) ; cignore: ignore control flags +(define ttyc/CTS-output-flow-ctl #f) ; ccts_oflow: CTS flow control of output +(define ttyc/RTS-input-flow-ctl #f) ; crts_iflow: RTS flow control of input +(define ttyc/carrier-flow-ctl #f) ; mdmbuf + +;;; Local flags -- hacking the tty driver / user interface. +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +;;; POSIX +(define ttyl/visual-delete #x010) ; echoe: Visually erase chars +(define ttyl/echo-delete-line #x020) ; echok: Echo nl after line kill +(define ttyl/echo #x008) ; echo: Enable echoing +(define ttyl/echo-nl #x040) ; echonl: Echo nl even if echo is off +(define ttyl/canonical #x002) ; icanon: Canonicalize input +(define ttyl/enable-signals #x001) ; isig: Enable ^c, ^z signalling +(define ttyl/extended #x00200000); iexten: Enable extensions +(define ttyl/ttou-signal #x10000) ; tostop: SIGTTOU on background output +(define ttyl/no-flush-on-interrupt #x80) ; noflsh + +;;; SVR4 & 4.3+BSD +(define ttyl/visual-delete-line #x080000); echoke: visually erase a line-kill +(define ttyl/hardcopy-delete #x040000); echoprt: visual erase for hardcopy +(define ttyl/echo-ctl #x020000); echoctl: echo control chars as "^X" +(define ttyl/flush-output #x100000); flusho: output is being flushed +(define ttyl/reprint-unread-chars #x20000000); pendin: retype pending input + +;;; 4.3+BSD +(define ttyl/alt-delete-word #f) ; altwerase +(define ttyl/no-kernel-status #f) ; nokerninfo: no kernel status on ^T + +;;; SVR4 +(define ttyl/case-map #x4) ; xcase: canonical upper/lower presentation + +;;; Vector of (speed . code) pairs. + +(define baud-rates '#((0 . 0) (1 . 50) (2 . 75) + (3 . 110) (4 . 134) (5 . 150) + (6 . 200) (7 . 300) (8 . 600) + (9 . 1200) (10 . 1800) (11 . 2400) + (12 . 4800) (13 . 9600) (14 . 19200) + (15 . 38400) (14 . exta) (15 . extb))) + +;;; tcflush() constants +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define %flush-tty/input 0) ; TCIFLUSH +(define %flush-tty/output 1) ; TCOFLUSH +(define %flush-tty/both 2) ; TCIOFLUSH + + +;;; tcflow() constants +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define %tcflow/start-out 1) ; TCOON +(define %tcflow/stop-out 0) ; TCOOFF +(define %tcflow/start-in 3) ; TCION +(define %tcflow/stop-in 2) ; TCIOFF + + +;;; tcsetattr() constants +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(define %set-tty-info/now 0) ; TCSANOW Make change immediately. +(define %set-tty-info/drain 1) ; TCSADRAIN Drain output, then change. +(define %set-tty-info/flush 2) ; TCSAFLUSH Drain output, flush input. diff --git a/scsh/aix/waitcodes.scm b/scsh/aix/waitcodes.scm new file mode 100644 index 0000000..a0fd9c7 --- /dev/null +++ b/scsh/aix/waitcodes.scm @@ -0,0 +1,40 @@ +;;; Scsh routines for analysing exit codes returned by WAIT. +;;; Copyright (c) 1994 by Olin Shivers. See file COPYING. +;;; +;;; To port these to a new OS, consult /usr/include/sys/wait.h, +;;; and check the WIFEXITED, WEXITSTATUS, WIFSTOPPED, WSTOPSIG, +;;; WIFSIGNALED, and WTERMSIG macros for the magic fields they use. +;;; These definitions are for NeXTSTEP. +;;; +;;; I could have done a portable version by making C calls for this, +;;; but it's such overkill. + + +;;; If process terminated normally, return the exit code, otw #f. + +(define (status:exit-val status) + (and (zero? (bitwise-and #xFF status)) + (bitwise-and #xFF (arithmetic-shift status -8)))) + + + +;;; If the process was suspended, return the suspending signal, otw #f. + +(define (status:stop-sig status) + (and (not (zero? (bitwise-and status #x40))) + (bitwise-and #x7F (arithmetic-shift status -8)))) + + +;;; If the process terminated abnormally, +;;; return the terminating signal, otw #f. + +(define (status:term-sig status) + (and (not (zero? (bitwise-and status #xFF))) ; Didn't exit. + (zero? (bitwise-and status #x40)) ; Not suspended. + (bitwise-and status #x7F))) + + + +;;; Flags. +(define wait/poll 1) ; Don't hang if nothing to wait for. +(define wait/stopped-children 2) ; Report on suspended subprocs, too.