diff options
author | Hans-Peter Nilsson <hp@axis.com> | 2007-06-10 12:54:35 +0000 |
---|---|---|
committer | Hans-Peter Nilsson <hp@axis.com> | 2007-06-10 12:54:35 +0000 |
commit | 32f67ec6ff30838169d7ded39dcfd6a7706b36d7 (patch) | |
tree | 7166256990adaee6c00505600b132780df42193a /newlib/libc | |
parent | 6fb374754dff1fbbe28b513b57caedc62e9a7cee (diff) | |
download | cygnal-32f67ec6ff30838169d7ded39dcfd6a7706b36d7.tar.gz cygnal-32f67ec6ff30838169d7ded39dcfd6a7706b36d7.tar.bz2 cygnal-32f67ec6ff30838169d7ded39dcfd6a7706b36d7.zip |
* libc/sys/mmixware/access.c (access): Do not try to use a magic
file-handle and a direct syscall, just use _open.
* libc/sys/mmixware/sys/syscall.h (TMPFNO): Remove this magic
file-handle.
* libc/sys/mmixware/_exit.c (_exit): Update comment about
passing on the exit value.
Diffstat (limited to 'newlib/libc')
-rw-r--r-- | newlib/libc/sys/mmixware/_exit.c | 8 | ||||
-rw-r--r-- | newlib/libc/sys/mmixware/access.c | 11 | ||||
-rw-r--r-- | newlib/libc/sys/mmixware/sys/syscall.h | 6 |
3 files changed, 11 insertions, 14 deletions
diff --git a/newlib/libc/sys/mmixware/_exit.c b/newlib/libc/sys/mmixware/_exit.c index 127bda75d..2f70154f2 100644 --- a/newlib/libc/sys/mmixware/_exit.c +++ b/newlib/libc/sys/mmixware/_exit.c @@ -18,9 +18,11 @@ void _exit (int n) { - /* Unfortunately, the return status is not returned by Knuth's mmix - simulator, so it seems in effect ineffective. We set it anyway; - there may be a purpose. */ + /* The return status is passed on at exit from the simulator by all + but the oldest versions of Knuth's mmixware simulator. Beware, + "TRAP 0,0,0" is the instruction corresponding to (int32_t) 0 and + the value 0 in $255 is common enough that a program crash jumping + to e.g. uninitialized memory will look like "exit (0)". */ __asm__ ("SET $255,%0\n\tTRAP 0,0,0" : /* No outputs. */ : "r" (n) diff --git a/newlib/libc/sys/mmixware/access.c b/newlib/libc/sys/mmixware/access.c index a7b664620..8927b91d8 100644 --- a/newlib/libc/sys/mmixware/access.c +++ b/newlib/libc/sys/mmixware/access.c @@ -1,6 +1,6 @@ /* access for MMIXware. - Copyright (C) 2001 Hans-Peter Nilsson + Copyright (C) 2001, 2007 Hans-Peter Nilsson Permission to use, copy, modify, and distribute this software is freely granted, provided that the above copyright notice, this notice @@ -24,18 +24,17 @@ access (const char *fn, int flags) implementations. Opening a directory as a file usually works, so let's try and open it and use the openability, regardless of what kind of test or file it is. */ - long ret; + int fd; /* We'll just assume that if we can open the file for reading, then it's Z-able, no matter what Z was. */ - ret = TRAP3f (SYS_Fopen, TMPFNO, fn, BinaryRead); - if (ret == 0) + fd = _open (fn, O_RDONLY); + if (fd >= 0) { /* Yes, this was readable. As in other simulator access functions, we always return success in this case (though the others check for directory access). */ - TRAP1f (SYS_Fclose, TMPFNO); - return 0; + return _close (fd); } errno = EACCES; diff --git a/newlib/libc/sys/mmixware/sys/syscall.h b/newlib/libc/sys/mmixware/sys/syscall.h index e9e1ff4db..4b4419cc0 100644 --- a/newlib/libc/sys/mmixware/sys/syscall.h +++ b/newlib/libc/sys/mmixware/sys/syscall.h @@ -1,6 +1,6 @@ /* syscall defines for MMIXware. - Copyright (C) 2001, 2002 Hans-Peter Nilsson + Copyright (C) 2001, 2002, 2007 Hans-Peter Nilsson Permission to use, copy, modify, and distribute this software is freely granted, provided that the above copyright notice, this notice @@ -42,10 +42,6 @@ enum MMIX_filemode track of it. A value of 0 denotes a free handle. */ extern unsigned char _MMIX_allocated_filehandle[N_MMIX_FILEHANDLES]; -/* We use this file-handle number as a temporary; not used by usual file - I/O. */ -#define TMPFNO 127 - /* Simulator call with one argument. Also used for zero-argument calls; pass a zero as ARG1. Make the asm volatile so we can safely ignore the return-value and only get the benefit from the supposed side-effect |