1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2% 3% File: PXK:EXTERNALS.SL 4% Description: Definitions of foreign language functions 5% Author: Brian Beach, Hewlett-Packard CRC 6% Created: 19-Apr-84 7% Modified: 15-Feb-85 13:25:43 8% Mode: Lisp 9% Package: 10% Status: Experimental (Do Not Distribute) 11% 12% (c) Copyright 1984, Hewlett-Packard Company, all rights reserved. 13% 14%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 15% 16% Revisions: 17% 18% 29-May-87 (Harold Carr & Leigh Stoller) 19% Added external definition for setenv. 20% 05-May-87 (Leigh Stoller) 21% Added external definitions for fast-math.sl. They are in float.c 22% 13-Apr-87 (Leigh Stoller & Harold Carr) 23% Added external definition of allocatemorebps, defined in bpsheap.c. 24% 26-Sep-86 (Leigh Stoller) 25% Added external entry for exit which is needed on the sun to pass an exit 26% code back to unix. 27% 01-Sep-86 (Leigh Stoller) 28% Added external-system to do a standard system call from C. 29% 19-Aug-86 (Leigh Stoller) 30% Added entries for get_file_status, sigrelse, and sigset. 31% 15-Feb-85 13:25:18 (Brian Beach) 32% Commented out a couple of functions for Pisces. 33% 01-Feb-85 (Bill Williams) 34% Add external entries for Lisp terminal emulator. 35% 24-Jan-85 (Vicki O'Day) 36% Added sleep entry. 37% 7-Jan-85 (Vicki O'Day) 38% Removed nmodekeys entry. 39% 17-Dec-84 (Vicki O'Day) 40% Added setlinebuf entry. 41% Added syscall entry, for access to HP-UX system calls. The syntax 42% of this command is (syscall <system call #> <arg1> <arg2> ...). 43% Currently, a limit of four arguments to the system call is imposed, 44% since no system calls that we can use have more than this. The 45% various forms of execl do, but since we can't use fork now, we don't 46% need this. When we can use fork, the number of arguments allowed 47% by syscall should be increased. 48% 7-Dec-84 (Vicki O'Day) 49% Added nmodekeys entry, so 9836-users can call it. 50% 27-Sep-84 19:57:38 (Dave Matthews) 51% Added an external function declaration for the new alterheapsize function. 52% 17-Jul-84 22:51:12 (RAM) 53% Changed chdir to unixcd and time to external_time. 54% Added external_stat, link, and unlink. 55% 56%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 57 58(compiletime 59 (setf *foreign-functions* nil) 60 ) 61 62(compiletime 63 (defmacro external-function (name args) 64 (setf *foreign-functions* (cons name *foreign-functions*)) 65 (flag1 name 'foreignfunction) 66 `(de ,name ,args 67 (,name ,@args) 68 ))) 69 (defmacro external-64-function (name args) 70 (setf *foreign-functions* (cons name *foreign-functions*)) 71 (flag1 name '64-foreignfunction) 72 `(de ,name ,args 73 (,name ,@args) 74 ))) 75 76(off r2i) 77 78% Defined in echo.c 79% 80%(external-function echoon ()) 81%(external-function echooff ()) 82%(external-function external_charsininputbuffer (chan)) 83(external-function flushstdoutputbuffer ()) 84(external-function external_user_homedir_string ()) 85(external-function external_anyuser_homedir_string (user)) 86 87 88% Defined in bpsheap.c 89% 90(external-function alterheapsize (integer)) 91(external-function allocatemorebps (amount)) 92 93% Defined in file-status.c 94% 95(external-function get_file_status (filename block flag)) 96 97 98% Defined in os-hooks.c 99% 100(external-function os_startup_hook (pargc pargv)) 101(external-function os_cleanup_hook ()) 102 103 104% Defined in pslextras.c 105% 106(external-function external_alarm (sec)) 107(external-function external_ualarm (usec repeat)) 108(external-function external_time (buffer)) 109(external-function external_timc (buffer)) 110(external-function external_stat (path buf)) 111(external-function external_link (path1 path2)) 112(external-function external_unlink (path)) 113(external-function external_strlen (strptr)) 114(external-function external_setenv (varstring valstring)) 115(external-function external_getenv (envstring)) 116(external-function uxfloat (buffer integer)) 117(external-function uxfix (buffer)) 118(external-function uxassign (arg1-buffer arg2-buffere)) 119(external-function uxplus2 (result-buffer arg1-buffer arg2-buffer)) 120(external-function uxdifference (result-buffer arg1-buffer arg2-buffer)) 121(external-function uxtimes2 (result-buffer arg1-buffer arg2-buffer)) 122(external-function uxquotient (result-buffer arg1-buffer arg2-buffer)) 123(external-function uxgreaterp (arg1-buffer arg2-buffer tee nill)) 124(external-function uxlessp (arg1-buffer arg2-buffer tee nill)) 125(external-function uxwritefloat (buffer floatptr convstr)) 126(external-function uxdoubletofloat (x y)) 127(external-function uxfloattodouble (y y)) 128(external-function uxsin (r x)) 129(external-function uxcos (r x)) 130(external-function uxtan (r x)) 131(external-function uxasin (r x)) 132(external-function uxacos (r x)) 133(external-function uxatan (r x)) 134(external-function uxsqrt (r x)) 135(external-function uxexp (r x)) 136(external-function uxlog (r x)) 137(external-function uxatan2 (r y x)) 138 139 140% Defined in pwd-fn.c 141% 142(external-function external_pwd ()) 143 144 145% Defined in sigs.c 146% 147(external-function psl_sigset (signame handler)) 148(external-function sigrelse (signame handler)) 149 150 151% Defined In unexec.c 152% 153(external-function unexec (newname aname dstart bstart)) 154 155 156% Defined in unix-io.c 157% 158(external-function unixputc (ch)) 159(external-function unixputs (str)) 160(external-function unixputn (num)) 161(external-function unixcleario ()) 162(external-function expand_file_name (str)) 163(external-function unixopen (name mode)) 164(external-function unixcd (dir)) 165(external-function ctime (buffer)) 166(external-function external_system (command)) 167 168 169% Defined In the C Library 170% 171(external-function external_exit (status)) 172(external-function fopen (name mode)) 173(external-function fclose (fp)) 174(external-function fread (buf size count fp)) 175(external-function fputc (ch fp)) 176(external-function fgetc (fp)) 177(external-function fgets (buf count fp)) 178(external-function fwrite (str strlen count fp)) 179(external-function fflush (fp)) 180(external-function fseek (fp offset ptrname)) 181(external-function clearerr (fp)) 182(external-function getw (fp)) 183%(external-function xgetw (fp)) 184 185(lap '((*entry xgetw expr 1) 186 (*alloc 5) 187 (*foreignlink xgetw expr 1) 188 (*move (reg 1) (reg r2)) 189 (*move (reg 2) (reg 1)) 190 (rldimi (reg 1) (reg r2) 32 0) 191 (*exit 5))) 192 193%(external-function ieee_handler (set common signalhandler)) 194(external-function putw (w fp)) 195(external-function signal (signame handler)) 196(external-function sleep (sec)) 197(external-function setjmp (env)) % added for sparc 198(external-function longjmp (env val)) % to process interrupts. 199 200(external-function fork ()) 201(external-function wait(ptr)) 202 203%(external-function vvm_cflush (addr len)) % flush the cache(s) 204(external-function datetag()) % returns date of bpsl build 205 206 207%% See $pxnk/sys-io.sl for the call to this. In SYS V, it may have to be 208%% moved into the microkernel since it is not directly supported. Under 209%% SYS V, buffering can only be changed before any writes on the stream, 210%% which means it must be called before setupbpsandheap. Also, under BSD, 211%% setlinebuf is a system call, while under SYS V, it must be written using 212%% setbuf and setvbuf. See the Bobcat version of setlinebuf.c in $pb. 213(external-function setlinebuf (iobuffer)) 214 215 216(external-function getpid ()) 217 218%%socketinterface 219 220(external-function unixsocketopen (name number)) 221(external-function getsocket (fd name number)) 222(external-function writesocket (fd name number)) 223(external-function unixclosesocket (number)) 224 225%% popen pclose 226 227(external-function popen (cmd mode)) 228(external-function pclose (stream)) 229 230%% shared memory , semaphores 231 232(external-function shmctl (shmid cmd buf)) 233(external-function shmget (key size shmflg)) 234(external-function shmat (shmid shmaddr shmflag)) 235(external-function shmdt (shmaddr)) 236 237(external-function semctl (semid semnum cmd arg)) 238(external-function semget (key nsems semflg)) 239(external-function semop (semid sembuf nsops)) 240 241(on r2i) 242 243(compiletime 244 (for (in name *foreign-functions*) 245 (do (remflag1 name 'foreignfunction)) 246 )) 247