* 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.
This commit is contained in:
Hans-Peter Nilsson 2007-06-10 12:54:35 +00:00
parent 6fb374754d
commit 32f67ec6ff
4 changed files with 21 additions and 14 deletions

View File

@ -1,3 +1,13 @@
2007-06-10 Hans-Peter Nilsson <hp@bitrange.com>
* 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.
2007-06-08 Jeff Johnston <jjohnstn@redhat.com> 2007-06-08 Jeff Johnston <jjohnstn@redhat.com>
* libc/string/strcasestr.c: New file. * libc/string/strcasestr.c: New file.

View File

@ -18,9 +18,11 @@
void _exit (int n) void _exit (int n)
{ {
/* Unfortunately, the return status is not returned by Knuth's mmix /* The return status is passed on at exit from the simulator by all
simulator, so it seems in effect ineffective. We set it anyway; but the oldest versions of Knuth's mmixware simulator. Beware,
there may be a purpose. */ "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" __asm__ ("SET $255,%0\n\tTRAP 0,0,0"
: /* No outputs. */ : /* No outputs. */
: "r" (n) : "r" (n)

View File

@ -1,6 +1,6 @@
/* access for MMIXware. /* 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 Permission to use, copy, modify, and distribute this software is
freely granted, provided that the above copyright notice, this notice 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 implementations. Opening a directory as a file usually works, so
let's try and open it and use the openability, regardless of what let's try and open it and use the openability, regardless of what
kind of test or file it is. */ 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 /* We'll just assume that if we can open the file for reading, then it's
Z-able, no matter what Z was. */ Z-able, no matter what Z was. */
ret = TRAP3f (SYS_Fopen, TMPFNO, fn, BinaryRead); fd = _open (fn, O_RDONLY);
if (ret == 0) if (fd >= 0)
{ {
/* Yes, this was readable. As in other simulator access functions, /* Yes, this was readable. As in other simulator access functions,
we always return success in this case (though the others check we always return success in this case (though the others check
for directory access). */ for directory access). */
TRAP1f (SYS_Fclose, TMPFNO); return _close (fd);
return 0;
} }
errno = EACCES; errno = EACCES;

View File

@ -1,6 +1,6 @@
/* syscall defines for MMIXware. /* 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 Permission to use, copy, modify, and distribute this software is
freely granted, provided that the above copyright notice, this notice 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. */ track of it. A value of 0 denotes a free handle. */
extern unsigned char _MMIX_allocated_filehandle[N_MMIX_FILEHANDLES]; 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; /* 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 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 return-value and only get the benefit from the supposed side-effect