From 9c29078d25134dda7b40588491e91ad7caaffb19 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Thu, 24 Jan 1991 11:26:25 +0000 Subject: [PATCH] Implement mechanism to pass system-call name and error code to Scheme error handler when system-call errors occur. --- v7/src/microcode/gpio.c | 8 +-- v7/src/microcode/prosenv.c | 16 ++++- v7/src/microcode/pruxfs.c | 22 +++--- v7/src/microcode/unxutl/ymkfile | 6 +- v7/src/microcode/utabmd.scm | 106 +++++++++++++++++++++++++--- v7/src/microcode/utils.c | 31 ++++++--- v7/src/microcode/ux.c | 6 +- v7/src/microcode/ux.h | 4 +- v7/src/microcode/uxenv.c | 27 ++++---- v7/src/microcode/uxfile.c | 13 ++-- v7/src/microcode/uxfs.c | 22 +++--- v7/src/microcode/uxio.c | 14 ++-- v7/src/microcode/uxproc.c | 12 ++-- v7/src/microcode/uxsock.c | 24 ++++--- v7/src/microcode/uxterm.c | 21 +++--- v7/src/microcode/uxtop.c | 119 ++++++++++++++++++++++++++++---- v7/src/microcode/version.h | 8 +-- v8/src/microcode/utabmd.scm | 106 +++++++++++++++++++++++++--- v8/src/microcode/version.h | 8 +-- 19 files changed, 440 insertions(+), 133 deletions(-) diff --git a/v7/src/microcode/gpio.c b/v7/src/microcode/gpio.c index 52efa82a0..90872ad93 100644 --- a/v7/src/microcode/gpio.c +++ b/v7/src/microcode/gpio.c @@ -1,6 +1,6 @@ /* -*-C-*- -Copyright (c) 1990 Massachusetts Institute of Technology +Copyright (c) 1990-1 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -30,7 +30,7 @@ Technology nor of any adaptation thereof in any advertising, promotional, or sales literature without prior written consent from MIT in each case. */ -/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/gpio.c,v 1.7 1990/10/02 21:51:25 jinx Rel $ */ +/* $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/gpio.c,v 1.8 1991/01/24 11:24:57 cph Exp $ */ /* Scheme primitives for GPIO */ @@ -149,7 +149,7 @@ DEFINE_PRIMITIVE ("GPIO-READ-STRING!", Prim_gpio_read_string, 4, 4, 0) (scr, (read (gpio_channel, data, count))); if (scr < 0) { - UX_prim_check_errno ("read"); + UX_prim_check_errno (syscall_read); continue; } if (scr > count) @@ -177,7 +177,7 @@ DEFINE_PRIMITIVE ("GPIO-WRITE-STRING", Prim_gpio_write_string, 4, 4, 0) (scr, (write (gpio_channel, data, count))); if (scr < 0) { - UX_prim_check_errno ("write"); + UX_prim_check_errno (syscall_write); continue; } if (scr > count) diff --git a/v7/src/microcode/prosenv.c b/v7/src/microcode/prosenv.c index 30cb1fb70..1d947cd41 100644 --- a/v7/src/microcode/prosenv.c +++ b/v7/src/microcode/prosenv.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/prosenv.c,v 1.3 1990/06/21 23:09:32 cph Rel $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/prosenv.c,v 1.4 1991/01/24 11:25:05 cph Exp $ -Copyright (c) 1987, 1988, 1989, 1990 Massachusetts Institute of Technology +Copyright (c) 1987-91 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -37,6 +37,7 @@ MIT in each case. */ #include "scheme.h" #include "prims.h" #include "osenv.h" +#include "ostop.h" DEFINE_PRIMITIVE ("GET-DECODED-TIME", Prim_get_decoded_time, 1, 1, "Return a vector with the current decoded time;\n\ @@ -214,3 +215,14 @@ DEFINE_PRIMITIVE ("CURRENT-USER-HOME-DIRECTORY", Prim_current_user_home_director PRIMITIVE_RETURN (char_pointer_to_string (OS_current_user_home_directory ())); } + +DEFINE_PRIMITIVE ("SYSTEM-CALL-ERROR-MESSAGE", Prim_system_call_error_message, 1, 1, 0) +{ + PRIMITIVE_HEADER (1); + { + CONST char * message = + (OS_error_code_to_message (arg_nonnegative_integer (1))); + PRIMITIVE_RETURN + ((message == 0) ? SHARP_F : (char_pointer_to_string (message))); + } +} diff --git a/v7/src/microcode/pruxfs.c b/v7/src/microcode/pruxfs.c index 50dd36dee..d9e980bef 100644 --- a/v7/src/microcode/pruxfs.c +++ b/v7/src/microcode/pruxfs.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/pruxfs.c,v 9.43 1990/11/08 11:06:12 cph Rel $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/pruxfs.c,v 9.44 1991/01/24 11:25:09 cph Exp $ -Copyright (c) 1987, 1988, 1989, 1990 Massachusetts Institute of Technology +Copyright (c) 1987-91 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -66,7 +66,7 @@ DEFINE_PRIMITIVE ("SET-FILE-MODES!", Prim_set_file_modes, 2, 2, { PRIMITIVE_HEADER (2); if ((UX_chmod ((STRING_ARG (1)), (arg_index_integer (2, 010000)))) < 0) - error_system_call (errno, "chmod"); + error_system_call (errno, syscall_chmod); PRIMITIVE_RETURN (SHARP_F); } @@ -302,12 +302,12 @@ DEFUN (file_touch, (filename), CONST char * filename) continue; } if (count >= FILE_TOUCH_OPEN_TRIES) - error_system_call (errno, "open"); + error_system_call (errno, syscall_open); } } { struct stat file_status; - STD_VOID_SYSTEM_CALL ("fstat", (UX_fstat (fd, (&file_status)))); + STD_VOID_SYSTEM_CALL (syscall_fstat, (UX_fstat (fd, (&file_status)))); if (((file_status . st_mode) & S_IFMT) != S_IFREG) error_bad_range_arg (1); /* CASE 3: file length of 0 needs special treatment. */ @@ -315,15 +315,15 @@ DEFUN (file_touch, (filename), CONST char * filename) { char buf [1]; (buf[0]) = '\0'; - STD_VOID_SYSTEM_CALL ("write", (UX_write (fd, buf, 1))); + STD_VOID_SYSTEM_CALL (syscall_write, (UX_write (fd, buf, 1))); #ifdef HAVE_TRUNCATE - STD_VOID_SYSTEM_CALL ("ftruncate", (UX_ftruncate (fd, 0))); + STD_VOID_SYSTEM_CALL (syscall_ftruncate, (UX_ftruncate (fd, 0))); transaction_commit (); #else /* not HAVE_TRUNCATE */ transaction_commit (); fd = (UX_open (filename, (O_WRONLY | O_TRUNC), MODE_REG)); if (fd >= 0) - STD_VOID_SYSTEM_CALL ("close", (UX_close (fd))); + STD_VOID_SYSTEM_CALL (syscall_close, (UX_close (fd))); #endif /* HAVE_TRUNCATE */ return (SHARP_F); } @@ -332,11 +332,11 @@ DEFUN (file_touch, (filename), CONST char * filename) { char buf [1]; int scr; - STD_UINT_SYSTEM_CALL ("read", scr, (UX_read (fd, buf, 1))); + STD_UINT_SYSTEM_CALL (syscall_read, scr, (UX_read (fd, buf, 1))); if (scr > 0) { - STD_VOID_SYSTEM_CALL ("lseek", (UX_lseek (fd, 0, SEEK_SET))); - STD_VOID_SYSTEM_CALL ("write", (UX_write (fd, buf, 1))); + STD_VOID_SYSTEM_CALL (syscall_lseek, (UX_lseek (fd, 0, SEEK_SET))); + STD_VOID_SYSTEM_CALL (syscall_write, (UX_write (fd, buf, 1))); } } transaction_commit (); diff --git a/v7/src/microcode/unxutl/ymkfile b/v7/src/microcode/unxutl/ymkfile index 5e15a2172..ccd90d0ac 100644 --- a/v7/src/microcode/unxutl/ymkfile +++ b/v7/src/microcode/unxutl/ymkfile @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/unxutl/Attic/ymkfile,v 1.39 1990/12/11 04:22:08 cph Rel $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/unxutl/Attic/ymkfile,v 1.40 1991/01/24 11:26:25 cph Exp $ -Copyright (c) 1989, 1990 Massachusetts Institute of Technology +Copyright (c) 1989-91 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -659,7 +659,7 @@ pruxfs.o : osfs.h pruxsock.o : osio.h uxsock.h $(OS_PRIM_OBJECTS) : scheme.touch prims.h posixtype.h os.h -prosenv.o : osenv.h +prosenv.o : osenv.h ostop.h prosfile.o : osfile.h prosfs.o : osfs.h prosio.o : osio.h diff --git a/v7/src/microcode/utabmd.scm b/v7/src/microcode/utabmd.scm index 77df4d31e..e69afefea 100644 --- a/v7/src/microcode/utabmd.scm +++ b/v7/src/microcode/utabmd.scm @@ -1,6 +1,8 @@ ;;; -*-Scheme-*- ;;; -;;; Copyright (c) 1987, 1989, 1990 Massachusetts Institute of Technology +;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/utabmd.scm,v 9.54 1991/01/24 11:25:15 cph Exp $ +;;; +;;; Copyright (c) 1987-91 Massachusetts Institute of Technology ;;; ;;; This material was developed by the Scheme project at the ;;; Massachusetts Institute of Technology, Department of @@ -37,8 +39,6 @@ ;;;; Machine Dependent Type Tables -;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/utabmd.scm,v 9.53 1990/11/26 16:58:32 jinx Rel $ - (declare (usual-integrations)) ;;; For quick access to any given table, @@ -63,8 +63,8 @@ #F ;06 MICROCODE-ERRORS-VECTOR ;07 MICROCODE-IDENTIFICATION-VECTOR ;08 - #F ;09 - #F ;0A + SYSTEM-CALL-NAMES ;09 + SYSTEM-CALL-ERRORS ;0A GC-DAEMON ;0B TRAP-HANDLER ;0C #F ;0D @@ -170,7 +170,7 @@ STACK-ENVIRONMENT ;3B (RECNUM COMPLEX) ;3C COMPILED-CODE-BLOCK ;3D - #F ;3E + RECORD ;3E #F ;3F #F ;40 #F ;41 @@ -476,7 +476,7 @@ UNBOUND-VARIABLE ;01 UNASSIGNED-VARIABLE ;02 UNDEFINED-PROCEDURE ;03 - #F ;04 + SYSTEM-CALL ;04 #F ;05 BAD-FRAME ;06 BROKEN-CVARIABLE ;07 @@ -571,6 +571,96 @@ 23 ;(fixed-objects-vector-slot 'MICROCODE-TERMINATION-PROCEDURES) #()) +;;; [] System-call names + +(vector-set! (get-fixed-objects-vector) + #x09 ;(fixed-objects-vector-slot 'SYSTEM-CALL-NAMES) + #(ACCEPT ;00 + BIND ;01 + CHDIR ;02 + CHMOD ;03 + CLOSE ;04 + CONNECT ;05 + FCNTL-GETFL ;06 + FCNTL-SETFL ;07 + FSTAT ;08 + FTRUNCATE ;09 + GETCWD ;0A + GETTIMEOFDAY ;0B + IOCTL-TIOCGPGRP ;0C + IOCTL-TIOCSIGSEND ;0D + KILL ;0E + LINK ;0F + LISTEN ;10 + LOCALTIME ;11 + LSEEK ;12 + MALLOC ;13 + MKDIR ;14 + OPEN ;15 + OPENDIR ;16 + PIPE ;17 + READ ;18 + READLINK ;19 + REALLOC ;1A + RENAME ;1B + SETITIMER ;1C + SOCKET ;1D + SYMLINK ;1E + TCDRAIN ;1F + TCFLUSH ;20 + TERMINAL-GET-STATE ;21 + TERMINAL-SET-STATE ;22 + TIME ;23 + TIMES ;24 + UNLINK ;25 + VFORK ;26 + WRITE ;27 + )) + +;;; [] System-call errors + +(vector-set! (get-fixed-objects-vector) + #x0A ;(fixed-objects-vector-slot 'SYSTEM-CALL-ERRORS) + #(UNKNOWN + ARG-LIST-TOO-LONG + BAD-ADDRESS + BAD-FILE-DESCRIPTOR + BROKEN-PIPE + DIRECTORY-NOT-EMPTY + DOMAIN-ERROR + EXEC-FORMAT-ERROR + FILE-EXISTS + FILE-TOO-LARGE + FILENAME-TOO-LONG + FUNCTION-NOT-IMPLEMENTED + IMPROPER-LINK + INAPPROPRIATE-IO-CONTROL-OPERATION + INTERRUPTED-FUNCTION-CALL + INVALID-ARGUMENT + INVALID-SEEK + IO-ERROR + IS-A-DIRECTORY + NO-CHILD-PROCESSES + NO-LOCKS-AVAILABLE + NO-SPACE-LEFT-ON-DEVICE + NO-SUCH-DEVICE + NO-SUCH-DEVICE-OR-ADDRESS + NO-SUCH-FILE-OR-DIRECTORY + NO-SUCH-PROCESS + NOT-A-DIRECTORY + NOT-ENOUGH-SPACE + OPERATION-NOT-PERMITTED + PERMISSION-DENIED + READ-ONLY-FILE-SYSTEM + RESOURCE-BUSY + RESOURCE-DEADLOCK-AVOIDED + RESOURCE-TEMPORARILY-UNAVAILABLE + RESULT-TOO-LARGE + TOO-MANY-LINKS + TOO-MANY-OPEN-FILES + TOO-MANY-OPEN-FILES + )) + ;;; [] Identification (vector-set! (get-fixed-objects-vector) @@ -590,4 +680,4 @@ ;;; This identification string is saved by the system. -"$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/utabmd.scm,v 9.53 1990/11/26 16:58:32 jinx Rel $" \ No newline at end of file +"$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/utabmd.scm,v 9.54 1991/01/24 11:25:15 cph Exp $" \ No newline at end of file diff --git a/v7/src/microcode/utils.c b/v7/src/microcode/utils.c index f7b5aaaab..e863ac022 100644 --- a/v7/src/microcode/utils.c +++ b/v7/src/microcode/utils.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/utils.c,v 9.47 1990/08/16 08:42:48 jinx Rel $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/utils.c,v 9.48 1991/01/24 11:25:25 cph Exp $ -Copyright (c) 1987, 1988, 1989, 1990 Massachusetts Institute of Technology +Copyright (c) 1987-91 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -440,6 +440,9 @@ interpreter_applicable_p (object) * and Interrupt-Enables. */ +unsigned int syscall_error_code; +unsigned int syscall_error_name; + void Do_Micro_Error (Err, From_Pop_Return) long Err; @@ -548,14 +551,24 @@ Do_Micro_Error (Err, From_Pop_Return) /* Arg 2: Int. mask */ STACK_PUSH (LONG_TO_FIXNUM(FETCH_INTERRUPT_MASK())); /* Arg 1: Err. No */ - if ((Err >= SMALLEST_FIXNUM) && (Err <= BIGGEST_FIXNUM)) - { - STACK_PUSH (LONG_TO_FIXNUM(Err)); - } + if (Err == ERR_IN_SYSTEM_CALL) + { + /* System call errors have some additional information. + Encode this as a vector in place of the error code. */ + SCHEME_OBJECT v = (allocate_marked_vector (TC_VECTOR, 3, 0)); + VECTOR_SET (v, 0, (LONG_TO_UNSIGNED_FIXNUM (ERR_IN_SYSTEM_CALL))); + VECTOR_SET (v, 1, (LONG_TO_UNSIGNED_FIXNUM (syscall_error_code))); + VECTOR_SET (v, 2, (LONG_TO_UNSIGNED_FIXNUM (syscall_error_name))); + STACK_PUSH (v); + } + else if ((Err >= SMALLEST_FIXNUM) && (Err <= BIGGEST_FIXNUM)) + { + STACK_PUSH (LONG_TO_FIXNUM (Err)); + } else - { - STACK_PUSH (LONG_TO_UNSIGNED_FIXNUM (ERR_BAD_ERROR_CODE)); - } + { + STACK_PUSH (LONG_TO_UNSIGNED_FIXNUM (ERR_BAD_ERROR_CODE)); + } /* Procedure: Handler */ STACK_PUSH (Handler); STACK_PUSH (STACK_FRAME_HEADER + 2); diff --git a/v7/src/microcode/ux.c b/v7/src/microcode/ux.c index 7272a2cfb..83c34fa8c 100644 --- a/v7/src/microcode/ux.c +++ b/v7/src/microcode/ux.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/ux.c,v 1.5 1991/01/07 23:56:50 cph Rel $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/ux.c,v 1.6 1991/01/24 11:25:31 cph Exp $ -Copyright (c) 1990 Massachusetts Institute of Technology +Copyright (c) 1990-1 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -35,7 +35,7 @@ MIT in each case. */ #include "ux.h" void -DEFUN (UX_prim_check_errno, (name), CONST char * name) +DEFUN (UX_prim_check_errno, (name), enum syscall_names name) { if (errno != EINTR) error_system_call (errno, name); diff --git a/v7/src/microcode/ux.h b/v7/src/microcode/ux.h index 02a852f00..f4559ae3e 100644 --- a/v7/src/microcode/ux.h +++ b/v7/src/microcode/ux.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/ux.h,v 1.19 1991/01/24 05:04:41 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/ux.h,v 1.20 1991/01/24 11:25:36 cph Exp $ Copyright (c) 1988-91 Massachusetts Institute of Technology @@ -143,7 +143,7 @@ enum syserr_names syserr_result_too_large, syserr_too_many_links, syserr_too_many_open_files, - syserr_too_many_open_files + syserr_too_many_open_files_in_system }; extern void EXFUN (error_system_call, (int code, enum syscall_names name)); diff --git a/v7/src/microcode/uxenv.c b/v7/src/microcode/uxenv.c index 2fde557ac..8d5693c92 100644 --- a/v7/src/microcode/uxenv.c +++ b/v7/src/microcode/uxenv.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxenv.c,v 1.2 1990/10/01 22:42:02 cph Rel $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxenv.c,v 1.3 1991/01/24 11:25:41 cph Exp $ -Copyright (c) 1990 Massachusetts Institute of Technology +Copyright (c) 1990-1 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -40,8 +40,8 @@ DEFUN (OS_current_time, (buffer), struct time_structure * buffer) { time_t t; struct tm * ts; - STD_UINT_SYSTEM_CALL ("time", t, (UX_time (0))); - STD_PTR_SYSTEM_CALL ("localtime", ts, (UX_localtime (&t))); + STD_UINT_SYSTEM_CALL (syscall_time, t, (UX_time (0))); + STD_PTR_SYSTEM_CALL (syscall_localtime, ts, (UX_localtime (&t))); (buffer -> year) = ((ts -> tm_year) + 1900); (buffer -> month) = ((ts -> tm_mon) + 1); (buffer -> day) = (ts -> tm_mday); @@ -72,7 +72,7 @@ DEFUN_VOID (OS_process_clock) { clock_t ct = (UX_SC_CLK_TCK ()); struct tms buffer; - STD_VOID_SYSTEM_CALL ("times", (UX_times (&buffer))); + STD_VOID_SYSTEM_CALL (syscall_times, (UX_times (&buffer))); return (((((buffer . tms_utime) - initial_process_clock) * 2000) + ct) / (2 * ct)); @@ -110,7 +110,8 @@ DEFUN_VOID (OS_real_time_clock) { struct timeval rtc; struct timezone tz; - STD_VOID_SYSTEM_CALL ("gettimeofday", (UX_gettimeofday ((&rtc), (&tz)))); + STD_VOID_SYSTEM_CALL + (syscall_gettimeofday, (UX_gettimeofday ((&rtc), (&tz)))); return ((((rtc . tv_sec) - (initial_rtc . tv_sec)) * 1000) + ((((rtc . tv_usec) - (initial_rtc . tv_usec)) + 500) / 1000)); @@ -134,7 +135,7 @@ DEFUN_VOID (OS_real_time_clock) clock_t ct = (UX_SC_CLK_TCK ()); struct tms buffer; clock_t t; - STD_UINT_SYSTEM_CALL ("times", t, (UX_times (&buffer))); + STD_UINT_SYSTEM_CALL (syscall_times, t, (UX_times (&buffer))); return ((((t - initial_rtc) * 2000) + ct) / (2 * ct)); } @@ -152,7 +153,7 @@ clock_t DEFUN_VOID (OS_real_time_clock) { time_t t; - STD_UINT_SYSTEM_CALL ("time", t, (UX_time (0))); + STD_UINT_SYSTEM_CALL (syscall_time, t, (UX_time (0))); return ((t - initial_rtc) * 1000); } @@ -174,7 +175,7 @@ DEFUN (set_timer, (which, first, interval), (value . it_interval . tv_sec) = (interval / 1000); (value . it_interval . tv_usec) = ((interval % 1000) * 1000); STD_VOID_SYSTEM_CALL - ("setitimer", (UX_setitimer (which, (&value), (&ovalue)))); + (syscall_setitimer, (UX_setitimer (which, (&value), (&ovalue)))); } void @@ -265,7 +266,7 @@ DEFUN_VOID (OS_working_dir_pathname) { path = (UX_malloc (1024)); if (path == 0) - error_system_call (ENOMEM, "malloc"); + error_system_call (ENOMEM, syscall_malloc); path_size = 1024; } while (1) @@ -273,14 +274,14 @@ DEFUN_VOID (OS_working_dir_pathname) if ((UX_getcwd (path, path_size)) != 0) return (path); if (errno != ERANGE) - error_system_call (errno, "getcwd"); + error_system_call (errno, syscall_getcwd); path_size *= 2; { char * new_path = (UX_realloc (path, path_size)); if (new_path == 0) /* ANSI C requires `path' to be unchanged -- we may have to discard it for systems that don't behave thus. */ - error_system_call (ENOMEM, "realloc"); + error_system_call (ENOMEM, syscall_realloc); path = new_path; } } @@ -289,7 +290,7 @@ DEFUN_VOID (OS_working_dir_pathname) void DEFUN (OS_set_working_dir_pathname, (name), CONST char * name) { - STD_VOID_SYSTEM_CALL ("chdir", (UX_chdir (name))); + STD_VOID_SYSTEM_CALL (syscall_chdir, (UX_chdir (name))); } CONST char * diff --git a/v7/src/microcode/uxfile.c b/v7/src/microcode/uxfile.c index a1056d907..d71bc72a0 100644 --- a/v7/src/microcode/uxfile.c +++ b/v7/src/microcode/uxfile.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxfile.c,v 1.3 1990/11/12 04:01:05 cph Rel $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxfile.c,v 1.4 1991/01/24 11:25:46 cph Exp $ -Copyright (c) 1990 Massachusetts Institute of Technology +Copyright (c) 1990-1 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -78,7 +78,8 @@ static Tchannel DEFUN (open_file, (filename, oflag), CONST char * filename AND int oflag) { int fd; - STD_UINT_SYSTEM_CALL ("open", fd, (UX_open (filename, oflag, MODE_REG))); + STD_UINT_SYSTEM_CALL + (syscall_open, fd, (UX_open (filename, oflag, MODE_REG))); return (OS_open_fd (fd)); } @@ -151,7 +152,7 @@ DEFUN (OS_file_length, (channel), Tchannel channel) { struct stat stat_buf; STD_VOID_SYSTEM_CALL - ("fstat", (UX_fstat ((CHANNEL_DESCRIPTOR (channel)), (&stat_buf)))); + (syscall_fstat, (UX_fstat ((CHANNEL_DESCRIPTOR (channel)), (&stat_buf)))); return (stat_buf . st_size); } @@ -160,7 +161,7 @@ DEFUN (OS_file_position, (channel), Tchannel channel) { off_t result; STD_UINT_SYSTEM_CALL - ("lseek", + (syscall_lseek, result, (UX_lseek ((CHANNEL_DESCRIPTOR (channel)), 0L, SEEK_CUR))); return (result); @@ -173,7 +174,7 @@ DEFUN (OS_file_set_position, (channel, position), { off_t result; STD_UINT_SYSTEM_CALL - ("lseek", + (syscall_lseek, result, (UX_lseek ((CHANNEL_DESCRIPTOR (channel)), position, SEEK_SET))); if (result != position) diff --git a/v7/src/microcode/uxfs.c b/v7/src/microcode/uxfs.c index 67d96cdee..965512f5f 100644 --- a/v7/src/microcode/uxfs.c +++ b/v7/src/microcode/uxfs.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxfs.c,v 1.2 1990/06/22 01:44:14 cph Rel $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxfs.c,v 1.3 1991/01/24 11:25:50 cph Exp $ -Copyright (c) 1990 Massachusetts Institute of Technology +Copyright (c) 1990-1 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -74,17 +74,17 @@ DEFUN (OS_file_soft_link_p, (name), CONST char * name) int buffer_length = 100; char * buffer = (UX_malloc (buffer_length)); if (buffer == 0) - error_system_call (ENOMEM, "malloc"); + error_system_call (ENOMEM, syscall_malloc); while (1) { STD_UINT_SYSTEM_CALL - ("readlink", scr, (UX_readlink (name, buffer, buffer_length))); + (syscall_readlink, scr, (UX_readlink (name, buffer, buffer_length))); if (scr < buffer_length) break; buffer_length *= 2; buffer = (UX_realloc (buffer, buffer_length)); if (buffer == 0) - error_system_call (ENOMEM, "realloc"); + error_system_call (ENOMEM, syscall_realloc); } (buffer[scr]) = '\0'; return ((CONST char *) buffer); @@ -97,7 +97,7 @@ DEFUN (OS_file_soft_link_p, (name), CONST char * name) void DEFUN (OS_file_remove, (name), CONST char * name) { - STD_VOID_SYSTEM_CALL ("unlink", (UX_unlink (name))); + STD_VOID_SYSTEM_CALL (syscall_unlink, (UX_unlink (name))); } void @@ -118,7 +118,7 @@ DEFUN (OS_file_link_hard, (from_name, to_name), CONST char * from_name AND CONST char * to_name) { - STD_VOID_SYSTEM_CALL ("link", (UX_link (from_name, to_name))); + STD_VOID_SYSTEM_CALL (syscall_link, (UX_link (from_name, to_name))); } void @@ -127,7 +127,7 @@ DEFUN (OS_file_link_soft, (from_name, to_name), CONST char * to_name) { #ifdef HAVE_SYMBOLIC_LINKS - STD_VOID_SYSTEM_CALL ("symlink", (UX_symlink (from_name, to_name))); + STD_VOID_SYSTEM_CALL (syscall_symlink, (UX_symlink (from_name, to_name))); #else error_unimplemented_primitive (); #endif @@ -138,13 +138,13 @@ DEFUN (OS_file_rename, (from_name, to_name), CONST char * from_name AND CONST char * to_name) { - STD_VOID_SYSTEM_CALL ("rename", (UX_rename (from_name, to_name))); + STD_VOID_SYSTEM_CALL (syscall_rename, (UX_rename (from_name, to_name))); } void DEFUN (OS_directory_make, (name), CONST char * name) { - STD_VOID_SYSTEM_CALL ("mkdir", (UX_mkdir (name, MODE_DIR))); + STD_VOID_SYSTEM_CALL (syscall_mkdir, (UX_mkdir (name, MODE_DIR))); } #if defined(HAVE_DIRENT) || defined(HAVE_DIR) @@ -177,7 +177,7 @@ DEFUN (OS_directory_open, (name), CONST char * name) directory_pointer = (opendir ((char *) name)); if (directory_pointer == 0) #ifdef HAVE_DIRENT - error_system_call (errno, "opendir"); + error_system_call (errno, syscall_opendir); #else error_external_return (); #endif diff --git a/v7/src/microcode/uxio.c b/v7/src/microcode/uxio.c index 48aa7fb7e..520a6c921 100644 --- a/v7/src/microcode/uxio.c +++ b/v7/src/microcode/uxio.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxio.c,v 1.7 1990/11/09 09:07:33 cph Rel $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxio.c,v 1.8 1991/01/24 11:25:55 cph Exp $ -Copyright (c) 1990 Massachusetts Institute of Technology +Copyright (c) 1990-1 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -101,7 +101,7 @@ DEFUN (OS_channel_close, (channel), Tchannel channel) if (! (CHANNEL_INTERNAL (channel))) { STD_VOID_SYSTEM_CALL - ("close", (UX_close (CHANNEL_DESCRIPTOR (channel)))); + (syscall_close, (UX_close (CHANNEL_DESCRIPTOR (channel)))); MARK_CHANNEL_CLOSED (channel); } } @@ -155,7 +155,7 @@ DEFUN (OS_channel_read, (channel, buffer, nbytes), if (errno == ERRNO_NONBLOCK) return (-1); #endif - UX_prim_check_errno ("read"); + UX_prim_check_errno (syscall_read); continue; } if (scr > nbytes) @@ -187,7 +187,7 @@ DEFUN (OS_channel_write, (channel, buffer, nbytes), if (errno == ERRNO_NONBLOCK) return (-1); #endif - UX_prim_check_errno ("write"); + UX_prim_check_errno (syscall_write); continue; } if (scr > nbytes) @@ -228,14 +228,14 @@ static int DEFUN (get_flags, (fd), int fd) { int scr; - STD_UINT_SYSTEM_CALL ("fcntl_GETFL", scr, (UX_fcntl (fd, F_GETFL, 0))); + STD_UINT_SYSTEM_CALL (syscall_fcntl_GETFL, scr, (UX_fcntl (fd, F_GETFL, 0))); return (scr); } static void DEFUN (set_flags, (fd, flags), int fd AND int flags) { - STD_VOID_SYSTEM_CALL ("fcntl_SETFL", (UX_fcntl (fd, F_SETFL, flags))); + STD_VOID_SYSTEM_CALL (syscall_fcntl_SETFL, (UX_fcntl (fd, F_SETFL, flags))); } int diff --git a/v7/src/microcode/uxproc.c b/v7/src/microcode/uxproc.c index 9e6b587cb..859394418 100644 --- a/v7/src/microcode/uxproc.c +++ b/v7/src/microcode/uxproc.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxproc.c,v 1.3 1990/11/08 11:10:56 cph Rel $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxproc.c,v 1.4 1991/01/24 11:26:00 cph Exp $ -Copyright (c) 1990 Massachusetts Institute of Technology +Copyright (c) 1990-1 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -156,12 +156,12 @@ DEFUN (OS_make_subprocess, (filename, argv, envp, ctty_type), if (ctty_type == ctty_type_pipe) { int pv [2]; - STD_VOID_SYSTEM_CALL ("pipe", (UX_pipe (pv))); + STD_VOID_SYSTEM_CALL (syscall_pipe, (UX_pipe (pv))); MAKE_CHANNEL ((pv[0]), channel_type_pipe, child_read =); OS_channel_close_on_abort (child_read); MAKE_CHANNEL ((pv[1]), channel_type_pipe, parent_write =); OS_channel_close_on_abort (parent_write); - STD_VOID_SYSTEM_CALL ("pipe", (UX_pipe (pv))); + STD_VOID_SYSTEM_CALL (syscall_pipe, (UX_pipe (pv))); MAKE_CHANNEL ((pv[0]), channel_type_pipe, parent_read =); OS_channel_close_on_abort (parent_read); MAKE_CHANNEL ((pv[1]), channel_type_pipe, child_write =); @@ -173,7 +173,7 @@ DEFUN (OS_make_subprocess, (filename, argv, envp, ctty_type), fflush (stdout); fflush (stderr); - STD_UINT_SYSTEM_CALL ("vfork", child_pid, (UX_vfork ())); + STD_UINT_SYSTEM_CALL (syscall_vfork, child_pid, (UX_vfork ())); if (child_pid > 0) { /* In the parent process. */ @@ -345,7 +345,7 @@ DEFUN (OS_process_output, (process), Tprocess process) void DEFUN (OS_process_send_signal, (process, sig), Tprocess process AND int sig) { - STD_VOID_SYSTEM_CALL ("kill", (UX_kill ((PROCESS_ID (process)), sig))); + STD_VOID_SYSTEM_CALL (syscall_kill, (UX_kill ((PROCESS_ID (process)), sig))); } void diff --git a/v7/src/microcode/uxsock.c b/v7/src/microcode/uxsock.c index 92bcd9183..acc1e76af 100644 --- a/v7/src/microcode/uxsock.c +++ b/v7/src/microcode/uxsock.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxsock.c,v 1.2 1990/11/08 11:11:38 cph Rel $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxsock.c,v 1.3 1991/01/24 11:26:04 cph Exp $ -Copyright (c) 1990 Massachusetts Institute of Technology +Copyright (c) 1990-1 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -49,7 +49,8 @@ Tchannel DEFUN (OS_open_tcp_stream_socket, (host, port), char * host AND int port) { int s; - STD_UINT_SYSTEM_CALL ("socket", s, (UX_socket (AF_INET, SOCK_STREAM, 0))); + STD_UINT_SYSTEM_CALL + (syscall_socket, s, (UX_socket (AF_INET, SOCK_STREAM, 0))); { struct sockaddr_in address; (address . sin_family) = AF_INET; @@ -61,7 +62,7 @@ DEFUN (OS_open_tcp_stream_socket, (host, port), char * host AND int port) } (address . sin_port) = port; STD_VOID_SYSTEM_CALL - ("connect", (UX_connect (s, (&address), (sizeof (address))))); + (syscall_connect, (UX_connect (s, (&address), (sizeof (address))))); } MAKE_CHANNEL (s, channel_type_tcp_stream_socket, return); } @@ -105,13 +106,14 @@ Tchannel DEFUN (OS_open_unix_stream_socket, (filename), CONST char * filename) { int s; - STD_UINT_SYSTEM_CALL ("socket", s, (UX_socket (AF_UNIX, SOCK_STREAM, 0))); + STD_UINT_SYSTEM_CALL + (syscall_socket, s, (UX_socket (AF_UNIX, SOCK_STREAM, 0))); { struct sockaddr_un address; (address . sun_family) = AF_UNIX; strncpy ((address . sun_path), filename, (sizeof (address . sun_path))); STD_VOID_SYSTEM_CALL - ("connect", (UX_connect (s, (&address), (sizeof (address))))); + (syscall_connect, (UX_connect (s, (&address), (sizeof (address))))); } MAKE_CHANNEL (s, channel_type_unix_stream_socket, return); } @@ -126,16 +128,18 @@ Tchannel DEFUN (OS_open_server_socket, (port), int port) { int s; - STD_UINT_SYSTEM_CALL ("socket", s, (UX_socket (AF_INET, SOCK_STREAM, 0))); + STD_UINT_SYSTEM_CALL + (syscall_socket, s, (UX_socket (AF_INET, SOCK_STREAM, 0))); { struct sockaddr_in address; (address . sin_family) = AF_INET; (address . sin_addr . s_addr) = INADDR_ANY; (address . sin_port) = port; STD_VOID_SYSTEM_CALL - ("bind", (UX_bind (s, (&address), (sizeof (struct sockaddr_in))))); + (syscall_bind, (UX_bind (s, (&address), (sizeof (struct sockaddr_in))))); } - STD_VOID_SYSTEM_CALL ("listen", (UX_listen (s, SOCKET_LISTEN_BACKLOG))); + STD_VOID_SYSTEM_CALL + (syscall_listen, (UX_listen (s, SOCKET_LISTEN_BACKLOG))); MAKE_CHANNEL (s, channel_type_tcp_server_socket, return); } @@ -160,7 +164,7 @@ DEFUN (OS_server_connection_accept, (channel, peer_host, peer_port), if (errno == EWOULDBLOCK) return (NO_CHANNEL); #endif - error_system_call (errno, "accept"); + error_system_call (errno, syscall_accept); } if (peer_host != 0) { diff --git a/v7/src/microcode/uxterm.c b/v7/src/microcode/uxterm.c index df1b6d61f..d71093278 100644 --- a/v7/src/microcode/uxterm.c +++ b/v7/src/microcode/uxterm.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxterm.c,v 1.10 1991/01/07 23:57:14 cph Rel $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxterm.c,v 1.11 1991/01/24 11:26:08 cph Exp $ -Copyright (c) 1990, 1991 Massachusetts Institute of Technology +Copyright (c) 1990-1 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -105,7 +105,7 @@ void DEFUN (get_terminal_state, (channel, s), Tchannel channel AND Ttty_state * s) { STD_VOID_SYSTEM_CALL - ("terminal_get_state", + (syscall_terminal_get_state, (UX_terminal_get_state ((CHANNEL_DESCRIPTOR (channel)), s))); } @@ -115,7 +115,7 @@ DEFUN (set_terminal_state, (channel, s), Tchannel channel AND Ttty_state * s) extern int EXFUN (UX_terminal_control_ok, (int fd)); if (UX_terminal_control_ok (CHANNEL_DESCRIPTOR (channel))) STD_VOID_SYSTEM_CALL - ("terminal_set_state", + (syscall_terminal_set_state, (UX_terminal_set_state ((CHANNEL_DESCRIPTOR (channel)), s))); } @@ -461,21 +461,21 @@ void DEFUN (OS_terminal_flush_input, (channel), Tchannel channel) { STD_VOID_SYSTEM_CALL - ("tcflush", (UX_tcflush ((CHANNEL_DESCRIPTOR (channel)), TCIFLUSH))); + (syscall_tcflush, (UX_tcflush ((CHANNEL_DESCRIPTOR (channel)), TCIFLUSH))); } void DEFUN (OS_terminal_flush_output, (channel), Tchannel channel) { STD_VOID_SYSTEM_CALL - ("tcflush", (UX_tcflush ((CHANNEL_DESCRIPTOR (channel)), TCOFLUSH))); + (syscall_tcflush, (UX_tcflush ((CHANNEL_DESCRIPTOR (channel)), TCOFLUSH))); } void DEFUN (OS_terminal_drain_output, (channel), Tchannel channel) { STD_VOID_SYSTEM_CALL - ("tcdrain", (UX_tcdrain (CHANNEL_DESCRIPTOR (channel)))); + (syscall_tcdrain, (UX_tcdrain (CHANNEL_DESCRIPTOR (channel)))); } int @@ -550,14 +550,15 @@ DEFUN (OS_pty_master_send_signal, (channel, sig), Tchannel channel AND int sig) { #ifdef TIOCSIGSEND STD_VOID_SYSTEM_CALL - ("ioctl_TIOCSIGSEND", + (syscall_ioctl_TIOCSIGSEND, (UX_ioctl ((CHANNEL_DESCRIPTOR (channel)), TIOCSIGSEND, sig))); #else /* not TIOCSIGSEND */ #ifdef HAVE_BSD_JOB_CONTROL int fd = (CHANNEL_DESCRIPTOR (channel)); int gid; - STD_VOID_SYSTEM_CALL ("ioctl_TIOCGPGRP", (UX_ioctl (fd, TIOCGPGRP, (&gid)))); - STD_VOID_SYSTEM_CALL ("kill", (UX_kill ((-gid), sig))); + STD_VOID_SYSTEM_CALL + (syscall_ioctl_TIOCGPGRP, (UX_ioctl (fd, TIOCGPGRP, (&gid)))); + STD_VOID_SYSTEM_CALL (syscall_kill, (UX_kill ((-gid), sig))); #else /* not HAVE_BSD_JOB_CONTROL */ error_unimplemented_primitive (); #endif /* HAVE_BSD_JOB_CONTROL */ diff --git a/v7/src/microcode/uxtop.c b/v7/src/microcode/uxtop.c index 0d1dfe463..dceba1b5f 100644 --- a/v7/src/microcode/uxtop.c +++ b/v7/src/microcode/uxtop.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxtop.c,v 1.7 1990/11/13 08:45:15 cph Rel $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/uxtop.c,v 1.8 1991/01/24 11:26:14 cph Exp $ -Copyright (c) 1990 Massachusetts Institute of Technology +Copyright (c) 1990-1 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -190,19 +190,114 @@ DEFUN_VOID (OS_restore_external_state) { UX_ctty_restore_external_state (); } + +static enum syserr_names +DEFUN (error_code_to_syserr, (code), int code) +{ + switch (code) + { + case E2BIG: return (syserr_arg_list_too_long); + case EACCES: return (syserr_permission_denied); + case EAGAIN: return (syserr_resource_temporarily_unavailable); + case EBADF: return (syserr_bad_file_descriptor); + case EBUSY: return (syserr_resource_busy); + case ECHILD: return (syserr_no_child_processes); + case EDEADLK: return (syserr_resource_deadlock_avoided); + case EDOM: return (syserr_domain_error); + case EEXIST: return (syserr_file_exists); + case EFAULT: return (syserr_bad_address); + case EFBIG: return (syserr_file_too_large); + case EINTR: return (syserr_interrupted_function_call); + case EINVAL: return (syserr_invalid_argument); + case EIO: return (syserr_io_error); + case EISDIR: return (syserr_is_a_directory); + case EMFILE: return (syserr_too_many_open_files); + case EMLINK: return (syserr_too_many_links); + case ENAMETOOLONG: return (syserr_filename_too_long); + case ENFILE: return (syserr_too_many_open_files_in_system); + case ENODEV: return (syserr_no_such_device); + case ENOENT: return (syserr_no_such_file_or_directory); + case ENOEXEC: return (syserr_exec_format_error); + case ENOLCK: return (syserr_no_locks_available); + case ENOMEM: return (syserr_not_enough_space); + case ENOSPC: return (syserr_no_space_left_on_device); + case ENOSYS: return (syserr_function_not_implemented); + case ENOTDIR: return (syserr_not_a_directory); + case ENOTEMPTY: return (syserr_directory_not_empty); + case ENOTTY: return (syserr_inappropriate_io_control_operation); + case ENXIO: return (syserr_no_such_device_or_address); + case EPERM: return (syserr_operation_not_permitted); + case EPIPE: return (syserr_broken_pipe); + case ERANGE: return (syserr_result_too_large); + case EROFS: return (syserr_read_only_file_system); + case ESPIPE: return (syserr_invalid_seek); + case ESRCH: return (syserr_no_such_process); + case EXDEV: return (syserr_improper_link); + default: return (syserr_unknown); + } +} + +static int +DEFUN (syserr_to_error_code, (syserr), enum syserr_names syserr) +{ + switch (syserr) + { + case syserr_arg_list_too_long: return (E2BIG); + case syserr_bad_address: return (EFAULT); + case syserr_bad_file_descriptor: return (EBADF); + case syserr_broken_pipe: return (EPIPE); + case syserr_directory_not_empty: return (ENOTEMPTY); + case syserr_domain_error: return (EDOM); + case syserr_exec_format_error: return (ENOEXEC); + case syserr_file_exists: return (EEXIST); + case syserr_file_too_large: return (EFBIG); + case syserr_filename_too_long: return (ENAMETOOLONG); + case syserr_function_not_implemented: return (ENOSYS); + case syserr_improper_link: return (EXDEV); + case syserr_inappropriate_io_control_operation: return (ENOTTY); + case syserr_interrupted_function_call: return (EINTR); + case syserr_invalid_argument: return (EINVAL); + case syserr_invalid_seek: return (ESPIPE); + case syserr_io_error: return (EIO); + case syserr_is_a_directory: return (EISDIR); + case syserr_no_child_processes: return (ECHILD); + case syserr_no_locks_available: return (ENOLCK); + case syserr_no_space_left_on_device: return (ENOSPC); + case syserr_no_such_device: return (ENODEV); + case syserr_no_such_device_or_address: return (ENXIO); + case syserr_no_such_file_or_directory: return (ENOENT); + case syserr_no_such_process: return (ESRCH); + case syserr_not_a_directory: return (ENOTDIR); + case syserr_not_enough_space: return (ENOMEM); + case syserr_operation_not_permitted: return (EPERM); + case syserr_permission_denied: return (EACCES); + case syserr_read_only_file_system: return (EROFS); + case syserr_resource_busy: return (EBUSY); + case syserr_resource_deadlock_avoided: return (EDEADLK); + case syserr_resource_temporarily_unavailable: return (EAGAIN); + case syserr_result_too_large: return (ERANGE); + case syserr_too_many_links: return (EMLINK); + case syserr_too_many_open_files: return (EMFILE); + case syserr_too_many_open_files_in_system: return (ENFILE); + default: return (0); + } +} void -DEFUN (error_system_call, (code, name), int code AND CONST char * name) +DEFUN (error_system_call, (code, name), int code AND enum syscall_names name) +{ + extern unsigned int syscall_error_code; + extern unsigned int syscall_error_name; + syscall_error_code = ((unsigned int) (error_code_to_syserr (code))); + syscall_error_name = ((unsigned int) name); + signal_error_from_primitive (ERR_IN_SYSTEM_CALL); +} + +CONST char * +DEFUN (OS_error_code_to_message, (syserr), unsigned int syserr) { - /* Improve this so that the code and name information is available - to the Scheme error handler. */ extern char * sys_errlist []; extern int sys_nerr; - if ((code >= 0) && (code <= sys_nerr)) - fprintf (stderr, "\nerror in system call: %s: %s\n", - name, (sys_errlist [code])); - else - fprintf (stderr, "\nunknown error %d in system call: %s\n", code, name); - fflush (stderr); - error_external_return (); + int code = (syserr_to_error_code ((enum syserr_names) syserr)); + return (((code > 0) && (code <= sys_nerr)) ? (sys_errlist [code]) : 0); } diff --git a/v7/src/microcode/version.h b/v7/src/microcode/version.h index 77f002699..62cb769b3 100644 --- a/v7/src/microcode/version.h +++ b/v7/src/microcode/version.h @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 11.60 1991/01/18 01:13:31 jinx Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/microcode/Attic/version.h,v 11.61 1991/01/24 11:26:20 cph Exp $ -Copyright (c) 1988, 1989, 1990, 1991 Massachusetts Institute of Technology +Copyright (c) 1988-91 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -37,7 +37,7 @@ MIT in each case. */ /* Scheme system release version */ #ifndef RELEASE -#define RELEASE "7.1.0 (beta)" +#define RELEASE "7.2.0 (alpha)" #endif /* Microcode release version */ @@ -46,5 +46,5 @@ MIT in each case. */ #define VERSION 11 #endif #ifndef SUBVERSION -#define SUBVERSION 60 +#define SUBVERSION 61 #endif diff --git a/v8/src/microcode/utabmd.scm b/v8/src/microcode/utabmd.scm index 85821fe87..ba3e0cd33 100644 --- a/v8/src/microcode/utabmd.scm +++ b/v8/src/microcode/utabmd.scm @@ -1,6 +1,8 @@ ;;; -*-Scheme-*- ;;; -;;; Copyright (c) 1987, 1989, 1990 Massachusetts Institute of Technology +;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/utabmd.scm,v 9.54 1991/01/24 11:25:15 cph Exp $ +;;; +;;; Copyright (c) 1987-91 Massachusetts Institute of Technology ;;; ;;; This material was developed by the Scheme project at the ;;; Massachusetts Institute of Technology, Department of @@ -37,8 +39,6 @@ ;;;; Machine Dependent Type Tables -;;; $Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/utabmd.scm,v 9.53 1990/11/26 16:58:32 jinx Rel $ - (declare (usual-integrations)) ;;; For quick access to any given table, @@ -63,8 +63,8 @@ #F ;06 MICROCODE-ERRORS-VECTOR ;07 MICROCODE-IDENTIFICATION-VECTOR ;08 - #F ;09 - #F ;0A + SYSTEM-CALL-NAMES ;09 + SYSTEM-CALL-ERRORS ;0A GC-DAEMON ;0B TRAP-HANDLER ;0C #F ;0D @@ -170,7 +170,7 @@ STACK-ENVIRONMENT ;3B (RECNUM COMPLEX) ;3C COMPILED-CODE-BLOCK ;3D - #F ;3E + RECORD ;3E #F ;3F #F ;40 #F ;41 @@ -476,7 +476,7 @@ UNBOUND-VARIABLE ;01 UNASSIGNED-VARIABLE ;02 UNDEFINED-PROCEDURE ;03 - #F ;04 + SYSTEM-CALL ;04 #F ;05 BAD-FRAME ;06 BROKEN-CVARIABLE ;07 @@ -571,6 +571,96 @@ 23 ;(fixed-objects-vector-slot 'MICROCODE-TERMINATION-PROCEDURES) #()) +;;; [] System-call names + +(vector-set! (get-fixed-objects-vector) + #x09 ;(fixed-objects-vector-slot 'SYSTEM-CALL-NAMES) + #(ACCEPT ;00 + BIND ;01 + CHDIR ;02 + CHMOD ;03 + CLOSE ;04 + CONNECT ;05 + FCNTL-GETFL ;06 + FCNTL-SETFL ;07 + FSTAT ;08 + FTRUNCATE ;09 + GETCWD ;0A + GETTIMEOFDAY ;0B + IOCTL-TIOCGPGRP ;0C + IOCTL-TIOCSIGSEND ;0D + KILL ;0E + LINK ;0F + LISTEN ;10 + LOCALTIME ;11 + LSEEK ;12 + MALLOC ;13 + MKDIR ;14 + OPEN ;15 + OPENDIR ;16 + PIPE ;17 + READ ;18 + READLINK ;19 + REALLOC ;1A + RENAME ;1B + SETITIMER ;1C + SOCKET ;1D + SYMLINK ;1E + TCDRAIN ;1F + TCFLUSH ;20 + TERMINAL-GET-STATE ;21 + TERMINAL-SET-STATE ;22 + TIME ;23 + TIMES ;24 + UNLINK ;25 + VFORK ;26 + WRITE ;27 + )) + +;;; [] System-call errors + +(vector-set! (get-fixed-objects-vector) + #x0A ;(fixed-objects-vector-slot 'SYSTEM-CALL-ERRORS) + #(UNKNOWN + ARG-LIST-TOO-LONG + BAD-ADDRESS + BAD-FILE-DESCRIPTOR + BROKEN-PIPE + DIRECTORY-NOT-EMPTY + DOMAIN-ERROR + EXEC-FORMAT-ERROR + FILE-EXISTS + FILE-TOO-LARGE + FILENAME-TOO-LONG + FUNCTION-NOT-IMPLEMENTED + IMPROPER-LINK + INAPPROPRIATE-IO-CONTROL-OPERATION + INTERRUPTED-FUNCTION-CALL + INVALID-ARGUMENT + INVALID-SEEK + IO-ERROR + IS-A-DIRECTORY + NO-CHILD-PROCESSES + NO-LOCKS-AVAILABLE + NO-SPACE-LEFT-ON-DEVICE + NO-SUCH-DEVICE + NO-SUCH-DEVICE-OR-ADDRESS + NO-SUCH-FILE-OR-DIRECTORY + NO-SUCH-PROCESS + NOT-A-DIRECTORY + NOT-ENOUGH-SPACE + OPERATION-NOT-PERMITTED + PERMISSION-DENIED + READ-ONLY-FILE-SYSTEM + RESOURCE-BUSY + RESOURCE-DEADLOCK-AVOIDED + RESOURCE-TEMPORARILY-UNAVAILABLE + RESULT-TOO-LARGE + TOO-MANY-LINKS + TOO-MANY-OPEN-FILES + TOO-MANY-OPEN-FILES + )) + ;;; [] Identification (vector-set! (get-fixed-objects-vector) @@ -590,4 +680,4 @@ ;;; This identification string is saved by the system. -"$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/utabmd.scm,v 9.53 1990/11/26 16:58:32 jinx Rel $" \ No newline at end of file +"$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/utabmd.scm,v 9.54 1991/01/24 11:25:15 cph Exp $" \ No newline at end of file diff --git a/v8/src/microcode/version.h b/v8/src/microcode/version.h index 60479a05b..b022a2d07 100644 --- a/v8/src/microcode/version.h +++ b/v8/src/microcode/version.h @@ -1,8 +1,8 @@ /* -*-C-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 11.60 1991/01/18 01:13:31 jinx Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/microcode/version.h,v 11.61 1991/01/24 11:26:20 cph Exp $ -Copyright (c) 1988, 1989, 1990, 1991 Massachusetts Institute of Technology +Copyright (c) 1988-91 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -37,7 +37,7 @@ MIT in each case. */ /* Scheme system release version */ #ifndef RELEASE -#define RELEASE "7.1.0 (beta)" +#define RELEASE "7.2.0 (alpha)" #endif /* Microcode release version */ @@ -46,5 +46,5 @@ MIT in each case. */ #define VERSION 11 #endif #ifndef SUBVERSION -#define SUBVERSION 60 +#define SUBVERSION 61 #endif -- 2.25.1