MMIX newlib port
Hans-Peter Nilsson
hp@bitrange.com
Sun Nov 11 05:56:00 GMT 2001
Hi.
Submitting the MMIX port under a BSD-style license, as requested. Please
consider accepting this port in newlib sources.
toplevel:
2001-11-10 Hans-Peter Nilsson <hp@bitrange.com>
* COPYING.NEWLIB: Add BSD-style license/copyright blurb for my work.
newlib:
(Note that the generated files configure, Makefile.in and aclocal.m4
aren't included. I'll send them on request. BTW, I considered
using libgloss and -lnosys, but thought it was a worse solution
than including the stubs here.)
2001-11-10 Hans-Peter Nilsson <hp@bitrange.com>
* libc/include/machine/ieeefp.h: Add support for mmix target.
* libc/include/machine/setjmp.h: Ditto.
* configure.host: Ditto.
* libc/sys/mmixware/Makefile.am, libc/sys/mmixware/_exit.c,
libc/sys/mmixware/access.c, libc/sys/mmixware/aclocal.m4,
libc/sys/mmixware/chmod.c, libc/sys/mmixware/chown.c,
libc/sys/mmixware/close.c, libc/sys/mmixware/configure.in,
libc/sys/mmixware/creat.c, libc/sys/mmixware/crt0.c,
libc/sys/mmixware/execv.c, libc/sys/mmixware/execve.c,
libc/sys/mmixware/fork.c, libc/sys/mmixware/fstat.c,
libc/sys/mmixware/getpid.c, libc/sys/mmixware/gettime.c,
libc/sys/mmixware/isatty.c, libc/sys/mmixware/kill.c,
libc/sys/mmixware/lseek.c, libc/sys/mmixware/open.c,
libc/sys/mmixware/pipe.c, libc/sys/mmixware/read.c,
libc/sys/mmixware/sbrk.c, libc/sys/mmixware/setjmp.S,
libc/sys/mmixware/stat.c, libc/sys/mmixware/sys/syscall.h,
libc/sys/mmixware/time.c, libc/sys/mmixware/times.c,
libc/sys/mmixware/unlink.c, libc/sys/mmixware/utime.c,
libc/sys/mmixware/wait.c, libc/sys/mmixware/write.c: New files.
* libc/sys/mmixware/configure, libc/sys/mmixware/Makefile.in,
libc/sys/mmixware/aclocal.m4: Generate.
Index: COPYING.NEWLIB
===================================================================
RCS file: /cvs/src/src/COPYING.NEWLIB,v
retrieving revision 1.2
diff -p -c -r1.2 COPYING.NEWLIB
*** COPYING.NEWLIB 2001/02/22 22:26:34 1.2
--- COPYING.NEWLIB 2001/11/10 20:29:50
*************** of the software without specific, writte
*** 112,118 ****
Hewlett-Packard Company makes no representations about the
suitability of this software for any purpose.
! (9) Unless otherwise stated in each remaining newlib file, the remaining
files in the newlib subdirectory are governed by the following copyright.
Copyright (c) 1994, 1997, 2001 Red Hat Incorporated.
--- 112,130 ----
Hewlett-Packard Company makes no representations about the
suitability of this software for any purpose.
! (9) Hans-Peter Nilsson
!
! Copyright (C) 2001 Hans-Peter Nilsson
!
! Permission to use, copy, modify, and distribute this software is
! freely granted, provided that this notice is preserved with no changes.
!
! THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
! IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
! WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
! PURPOSE.
!
! (10) Unless otherwise stated in each remaining newlib file, the remaining
files in the newlib subdirectory are governed by the following copyright.
Copyright (c) 1994, 1997, 2001 Red Hat Incorporated.
Index: newlib/configure.host
===================================================================
RCS file: /cvs/src/src/newlib/configure.host,v
retrieving revision 1.13
diff -p -c -r1.13 configure.host
*** configure.host 2001/08/29 13:26:31 1.13
--- configure.host 2001/11/10 20:29:53
*************** case "${host_cpu}" in
*** 125,130 ****
--- 125,132 ----
mips*)
machine_dir=mips
;;
+ mmix)
+ ;;
mn10200)
machine_dir=mn10200
;;
*************** case "${host}" in
*** 276,281 ****
--- 278,286 ----
mips*-dec-*)
sys_dir=decstation
;;
+ mmix-knuth-mmixware)
+ sys_dir=mmixware
+ ;;
powerpcle-*-pe)
sys_dir=cygwin
posix_dir=posix
*************** case "${host}" in
*** 422,427 ****
--- 427,438 ----
mcore-*-*)
newlib_cflags="${newlib_cflags}"
syscall_dir=syscalls
+ ;;
+ mmix-*)
+ syscall_dir=syscalls
+ # We need every symbol 32-bit aligned, so the invalid
+ # construct with attribute ((alias ("_ctype_b+127"))) breaks.
+ newlib_cflags="${newlib_cflags} -DCOMPACT_CTYPE"
;;
mn10?00-*-*)
syscall_dir=syscalls
Index: newlib/libc/include/machine/ieeefp.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/machine/ieeefp.h,v
retrieving revision 1.6
diff -p -c -r1.6 ieeefp.h
*** ieeefp.h 2001/06/28 10:40:09 1.6
--- ieeefp.h 2001/11/10 20:29:53
***************
*** 98,103 ****
--- 98,107 ----
#define __IEEE_BIG_ENDIAN
#endif
+ #ifdef __MMIX__
+ #define __IEEE_BIG_ENDIAN
+ #endif
+
/* necv70 was __IEEE_LITTLE_ENDIAN. */
#ifdef __W65__
Index: newlib/libc/include/machine/setjmp.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/machine/setjmp.h,v
retrieving revision 1.4
diff -p -c -r1.4 setjmp.h
*** setjmp.h 2001/08/14 14:36:57 1.4
--- setjmp.h 2001/11/10 20:29:54
*************** typedef int jmp_buf[_JBLEN];
*** 145,150 ****
--- 145,156 ----
#define _JBLEN 16
#endif
+ #ifdef __MMIX__
+ /* Using a layout compatible with GCC's built-in. */
+ #define _JBLEN 5
+ #define _JBTYPE unsigned long
+ #endif
+
#ifdef _JBLEN
#ifdef _JBTYPE
typedef _JBTYPE jmp_buf[_JBLEN];
Index: newlib/libc/include/sys/config.h
===================================================================
RCS file: /cvs/src/src/newlib/libc/include/sys/config.h,v
retrieving revision 1.8
diff -p -c -r1.8 config.h
*** config.h 2001/08/29 19:47:43 1.8
--- config.h 2001/11/10 20:29:54
***************
*** 73,78 ****
--- 73,82 ----
#define __IEEE_LITTLE_ENDIAN
#endif
+ #ifdef __MMIX__
+ #define __IEEE_BIG_ENDIAN
+ #endif
+
#ifdef __AVR__
#define _DOUBLE_IS_32BITS
#define __SMALL_BITFIELDS
diff -cprN libc/sys/nope/Makefile.am libc/sys/mmixware/Makefile.am
*** libc/sys/nope/Makefile.am Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/Makefile.am Mon Oct 30 02:53:52 2000
***************
*** 0 ****
--- 1,23 ----
+ ## Process this file with automake to generate Makefile.in
+
+ AUTOMAKE_OPTIONS = cygnus
+
+ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
+
+ noinst_LIBRARIES = lib.a
+
+ lib_a_SOURCES = _exit.c access.c chmod.c chown.c close.c creat.c \
+ execv.c execve.c fork.c fstat.c getpid.c isatty.c \
+ kill.c lseek.c open.c pipe.c read.c \
+ sbrk.c stat.c time.c unlink.c utime.c wait.c write.c \
+ times.c gettime.c setjmp.S
+
+ # This is a hack to force automake to include a definition for
+ # COMPILE.
+ EXTRA_LIBRARIES = libfoo.a
+ libfoo_a_SOURCES = crt0.c
+
+ all: crt0.o
+
+ ACLOCAL_AMFLAGS = -I ../../..
+ CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
diff -cprN libc/sys/nope/_exit.c libc/sys/mmixware/_exit.c
*** libc/sys/nope/_exit.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/_exit.c Sat Nov 10 16:11:35 2001
***************
*** 0 ****
--- 1,24 ----
+ /* _exit for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include "sys/syscall.h"
+
+ 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. */
+ __asm__ ("SET $255,%0\n\tTRAP 0,0,0"
+ : /* No outputs. */
+ : "r" (n)
+ : "memory");
+ }
diff -cprN --exclude=*.template libc/sys/nope/access.c libc/sys/mmixware/access.c
*** libc/sys/nope/access.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/access.c Sun Nov 11 14:45:43 2001
***************
*** 0 ****
--- 1,39 ----
+ /* access for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <fcntl.h>
+ #include <sys/stat.h>
+ #include <unistd.h>
+ #include "sys/syscall.h"
+ #include <errno.h>
+
+ int
+ access (const char *fn, int flags)
+ {
+ /* Ugh. We don't have stat (), so we can't copy the other
+ 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;
+
+ /* 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)
+ {
+ /* 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;
+ }
+
+ errno = EACCES;
+ return -1;
+ }
diff -cprN libc/sys/nope/chmod.c libc/sys/mmixware/chmod.c
*** libc/sys/nope/chmod.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/chmod.c Sat Nov 10 16:11:35 2001
***************
*** 0 ****
--- 1,22 ----
+ /* chmod stub for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include "sys/syscall.h"
+ #include <errno.h>
+
+ int
+ chmod (const char *path, mode_t mode)
+ {
+ UNIMPLEMENTED (("path: %s, mode: %lu", path, (unsigned long) mode));
+ errno = ENOSYS;
+ return -1;
+ }
diff -cprN libc/sys/nope/chown.c libc/sys/mmixware/chown.c
*** libc/sys/nope/chown.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/chown.c Sat Nov 10 16:11:36 2001
***************
*** 0 ****
--- 1,22 ----
+ /* chown stub for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include "sys/syscall.h"
+ #include <errno.h>
+
+ int
+ chown (const char *path, short owner, short group)
+ {
+ UNIMPLEMENTED (("path: %s, owner: %d, group: %d", path, owner, group));
+ errno = ENOSYS;
+ return -1;
+ }
diff -cprN libc/sys/nope/close.c libc/sys/mmixware/close.c
*** libc/sys/nope/close.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/close.c Sat Nov 10 16:11:36 2001
***************
*** 0 ****
--- 1,34 ----
+ /* close for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include "sys/syscall.h"
+ #include <errno.h>
+
+ int
+ _close (int file)
+ {
+ if ((unsigned int) file >= N_MMIX_FILEHANDLES
+ || _MMIX_allocated_filehandle[file] == 0)
+ {
+ errno = EBADF;
+ return -1;
+ }
+
+ _MMIX_allocated_filehandle[file] = 0;
+
+ if (TRAP1f (SYS_Fclose, file) != 0)
+ {
+ errno = EIO;
+ return -1;
+ }
+ return 0;
+ }
diff -cprN libc/sys/nope/configure.in libc/sys/mmixware/configure.in
*** libc/sys/nope/configure.in Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/configure.in Mon Oct 30 02:53:52 2000
***************
*** 0 ****
--- 1,12 ----
+ dnl This is the newlib/libc/sys/mmixware configure.in file.
+ dnl Process this file with autoconf to produce a configure script.
+
+ AC_PREREQ(2.5)
+ AC_INIT(crt0.c)
+
+ dnl Can't be done in NEWLIB_CONFIGURE because that confuses automake.
+ AC_CONFIG_AUX_DIR(../../../..)
+
+ NEWLIB_CONFIGURE(../../..)
+
+ AC_OUTPUT(Makefile)
diff -cprN libc/sys/nope/creat.c libc/sys/mmixware/creat.c
*** libc/sys/nope/creat.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/creat.c Sat Nov 10 16:11:36 2001
***************
*** 0 ****
--- 1,23 ----
+ /* creat for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <_ansi.h>
+ #include <fcntl.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include "sys/syscall.h"
+ #include <errno.h>
+
+ int
+ creat (const char *path,
+ /* We can't set the mode, so we have to ignore it. */
+ mode_t mode)
+ {
+ return open (path, O_CREAT|O_WRONLY|O_TRUNC);
+ }
diff -cprN libc/sys/nope/crt0.c libc/sys/mmixware/crt0.c
*** libc/sys/nope/crt0.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/crt0.c Sat Nov 10 16:11:36 2001
***************
*** 0 ****
--- 1,14 ----
+ /* crt0 stub for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ /* At present this is just a placeholder, to be filled in, if the need
+ arises. The main init contents is in gcc/config/mmix/crti.asm.
+
+ I think this file is not allowed to be empty. So here goes: */
+ extern int _Dummy;
diff -cprN libc/sys/nope/execv.c libc/sys/mmixware/execv.c
*** libc/sys/nope/execv.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/execv.c Sat Nov 10 16:11:36 2001
***************
*** 0 ****
--- 1,22 ----
+ /* execv stub for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include "sys/syscall.h"
+ #include <errno.h>
+
+ int
+ execv (const char *path, char *const argv[])
+ {
+ UNIMPLEMENTED (("path: %s, argv: %p", path, argv));
+ errno = ENOSYS;
+ return -1;
+ }
diff -cprN libc/sys/nope/execve.c libc/sys/mmixware/execve.c
*** libc/sys/nope/execve.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/execve.c Sat Nov 10 16:11:36 2001
***************
*** 0 ****
--- 1,22 ----
+ /* execve stub for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include "sys/syscall.h"
+ #include <errno.h>
+
+ int
+ _execve (const char *path, char *const argv[], char *const envp[])
+ {
+ UNIMPLEMENTED (("path: %s, argv: %p, envp: %p", path, argv, envp));
+ errno = ENOSYS;
+ return -1;
+ }
diff -cprN libc/sys/nope/fork.c libc/sys/mmixware/fork.c
*** libc/sys/nope/fork.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/fork.c Sat Nov 10 16:11:36 2001
***************
*** 0 ****
--- 1,22 ----
+ /* fork stub for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include "sys/syscall.h"
+ #include <errno.h>
+
+ int
+ _fork ()
+ {
+ UNIMPLEMENTED ((""));
+ errno = ENOSYS;
+ return -1;
+ }
diff -cprN libc/sys/nope/fstat.c libc/sys/mmixware/fstat.c
*** libc/sys/nope/fstat.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/fstat.c Sat Nov 10 16:11:36 2001
***************
*** 0 ****
--- 1,22 ----
+ /* fstat for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include "sys/syscall.h"
+
+ int
+ _fstat (int file,
+ struct stat *st)
+ {
+ st->st_mode = S_IFCHR;
+ st->st_blksize = 4096;
+ return 0;
+ }
diff -cprN libc/sys/nope/getpid.c libc/sys/mmixware/getpid.c
*** libc/sys/nope/getpid.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/getpid.c Sat Nov 10 16:11:36 2001
***************
*** 0 ****
--- 1,18 ----
+ /* getpid stub for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include "sys/syscall.h"
+
+ _getpid (n)
+ {
+ return 1;
+ }
diff -cprN libc/sys/nope/gettime.c libc/sys/mmixware/gettime.c
*** libc/sys/nope/gettime.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/gettime.c Sat Nov 10 16:11:36 2001
***************
*** 0 ****
--- 1,23 ----
+ /* gettime stub for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include "sys/syscall.h"
+ #include "sys/time.h"
+ #include <errno.h>
+
+ int
+ _gettimeofday (struct timeval *tp, void *tzp)
+ {
+ UNIMPLEMENTED (("timeval: %p, tzp: %p", tp, tzp));
+ errno = ENOSYS;
+ return -1;
+ }
diff -cprN libc/sys/nope/isatty.c libc/sys/mmixware/isatty.c
*** libc/sys/nope/isatty.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/isatty.c Sat Nov 10 16:11:36 2001
***************
*** 0 ****
--- 1,19 ----
+ /* isatty for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include "sys/syscall.h"
+
+ isatty (fd)
+ int fd;
+ {
+ return fd == 0 || fd == 1 || fd == 2;
+ }
diff -cprN libc/sys/nope/kill.c libc/sys/mmixware/kill.c
*** libc/sys/nope/kill.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/kill.c Sat Nov 10 16:11:36 2001
***************
*** 0 ****
--- 1,24 ----
+ /* kill for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include "sys/syscall.h"
+ #include <errno.h>
+
+ _kill (n, m)
+ {
+ if (n == 1)
+ return TRAP1i (SYS_halt, 0);
+
+ errno = EPERM;
+ return -1;
+ }
+
diff -cprN libc/sys/nope/lseek.c libc/sys/mmixware/lseek.c
*** libc/sys/nope/lseek.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/lseek.c Sat Nov 10 16:11:36 2001
***************
*** 0 ****
--- 1,59 ----
+ /* lseek for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <sys/unistd.h>
+ #include "sys/syscall.h"
+ #include <errno.h>
+
+ off_t
+ _lseek (int file,
+ off_t ptr,
+ int dir)
+ {
+ off_t simoff = dir == SEEK_END ? -(ptr + 1) : ptr;
+ long ret;
+
+ if ((unsigned int) file >= 32 || _MMIX_allocated_filehandle[file] == 0)
+ {
+ errno = EBADF;
+ return -1;
+ }
+
+ if (dir == SEEK_CUR)
+ {
+ long curpos = TRAP2f (SYS_Ftell, file, 0);
+
+ if (curpos == -1)
+ {
+ errno = EIO;
+ return -1;
+ }
+
+ ptr += (off_t) curpos;
+ }
+
+ ret = TRAP2f (SYS_Fseek, file, simoff);
+ if (ret == -1)
+ {
+ return -1;
+ errno = EIO;
+ }
+
+ ret = TRAP2f (SYS_Ftell, file, 0);
+ if (ret == -1)
+ {
+ errno = EIO;
+ return -1;
+ }
+
+ return ret;
+ }
diff -cprN libc/sys/nope/open.c libc/sys/mmixware/open.c
*** libc/sys/nope/open.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/open.c Sat Nov 10 16:11:36 2001
***************
*** 0 ****
--- 1,104 ----
+ /* open for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <fcntl.h>
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include "sys/syscall.h"
+ #include <errno.h>
+
+ /* Let's keep the filehandle array here, since this is a primary
+ initializer of it. */
+ unsigned char _MMIX_allocated_filehandle[32] =
+ {
+ 1,
+ 1,
+ 1,
+ 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0
+ };
+
+ int
+ _open (const char *path,
+ int flags, ...)
+ {
+ long fileno;
+ unsigned char mode;
+ long fffile = 0;
+ long ret;
+
+ for (fileno = 0;
+ fileno < (sizeof (_MMIX_allocated_filehandle) /
+ sizeof (_MMIX_allocated_filehandle[0]));
+ fileno++)
+ if (_MMIX_allocated_filehandle[fileno] == 0)
+ break;
+
+ if (fileno == (sizeof (_MMIX_allocated_filehandle) /
+ sizeof (_MMIX_allocated_filehandle[0])))
+ {
+ errno = EMFILE;
+ return -1;
+ }
+
+ /* We map this to a fopen call. The flags parameter is stymied because
+ we don't support more other than these flags. */
+ if (flags & ~(O_RDONLY | O_WRONLY | O_RDWR | O_CREAT | O_APPEND | O_TRUNC))
+ {
+ UNIMPLEMENTED (("path: %s, flags: %d", path, flags));
+ errno = ENOSYS;
+ return -1;
+ }
+
+ if ((flags & O_ACCMODE) == O_RDONLY)
+ mode = BinaryRead;
+ else if ((flags & (O_WRONLY | O_APPEND)) == (O_WRONLY | O_APPEND))
+ {
+ mode = BinaryReadWrite;
+ fffile = 1;
+ }
+ else if ((flags & (O_RDWR | O_APPEND)) == (O_RDWR | O_APPEND))
+ {
+ mode = BinaryReadWrite;
+ fffile = 1;
+ }
+ else if ((flags & (O_WRONLY | O_CREAT)) == (O_WRONLY | O_CREAT)
+ || (flags & (O_WRONLY | O_TRUNC)) == (O_WRONLY | O_TRUNC))
+ mode = BinaryWrite;
+ else if ((flags & (O_RDWR | O_CREAT)) == (O_RDWR | O_CREAT))
+ mode = BinaryReadWrite;
+ else if (flags & O_RDWR)
+ mode = BinaryReadWrite;
+ else
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ret = TRAP3f (SYS_Fopen, fileno, path, mode);
+ if (ret < 0)
+ {
+ /* It's totally unknown what the error was. We'll just take our
+ chances and assume ENOENT. */
+ errno = ENOENT;
+ return -1;
+ }
+
+ _MMIX_allocated_filehandle[fileno] = 1;
+
+ if (fffile)
+ {
+ TRAP2f (SYS_Fseek, fileno, -1);
+ }
+
+ return fileno;
+ }
diff -cprN libc/sys/nope/pipe.c libc/sys/mmixware/pipe.c
*** libc/sys/nope/pipe.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/pipe.c Sat Nov 10 16:11:36 2001
***************
*** 0 ****
--- 1,22 ----
+ /* pipe stub for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include "sys/syscall.h"
+ #include <errno.h>
+
+ int
+ pipe (int *fd)
+ {
+ UNIMPLEMENTED (("fd: %p", fd));
+ errno = ENOSYS;
+ return -1;
+ }
diff -cprN libc/sys/nope/read.c libc/sys/mmixware/read.c
*** libc/sys/nope/read.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/read.c Sat Nov 10 16:11:36 2001
***************
*** 0 ****
--- 1,47 ----
+ /* read for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include "sys/syscall.h"
+ #include <errno.h>
+
+ int
+ _read (int file,
+ char *ptr,
+ size_t len)
+ {
+ long ret;
+
+ if ((unsigned int) file >= 32 || _MMIX_allocated_filehandle[file] == 0)
+ {
+ errno = EBADF;
+ return -1;
+ }
+
+ ret = TRAP3f (SYS_Fread, file, ptr, len);
+
+ /* Map the return codes:
+ -1-len: an error. We return -1.
+ 0: success. We return len.
+ n-len: end-of-file after n chars read. We return n. */
+ if (ret == 0)
+ return len;
+
+ if (ret == -1 - (long) len)
+ {
+ /* We don't know the nature of the failure, so this is an
+ approximation. */
+ errno = EIO;
+ return -1;
+ }
+
+ return ret + len;
+ }
diff -cprN --exclude=*.template libc/sys/nope/sbrk.c libc/sys/mmixware/sbrk.c
*** libc/sys/nope/sbrk.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/sbrk.c Sun Nov 11 14:49:34 2001
***************
*** 0 ****
--- 1,39 ----
+ /* sbrk for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include "sys/syscall.h"
+
+ extern char *_Sbrk_high;
+
+ /* When the program is loaded, the first location in Pool_Segment holds
+ the first available octabyte in the memory pool (a.k.a. the heap);
+ somewhere after the command-line parameters. We don't have to
+ initialize that location, we can just use it straight up as a pointer;
+ just point the symbol there.
+
+ This file will be compiled with -no-builtin-syms, so we need to define
+ Pool_Segment and any other symbols that would be predefined in mmixal. */
+
+ __asm__ (" .global _Sbrk_high\n"
+ "_Sbrk_high IS Pool_Segment\n"
+ "Pool_Segment IS 0x40<<56");
+
+ caddr_t
+ _sbrk (size_t incr)
+ {
+ extern char end; /* Defined by the linker */
+ char *prev_heap_end;
+
+ prev_heap_end = _Sbrk_high;
+ _Sbrk_high += incr;
+ return (caddr_t) prev_heap_end;
+ }
diff -cprN libc/sys/nope/setjmp.S libc/sys/mmixware/setjmp.S
*** libc/sys/nope/setjmp.S Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/setjmp.S Sat Nov 10 21:56:38 2001
***************
*** 0 ****
--- 1,83 ----
+ /* Setjmp and longjmp for mmix.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE.
+
+ jmp_buf[5]:
+ 0: fp
+ 1: rJ (return-address)
+ 2: sp
+ 3: rO *before* the setjmp call.
+ 4: temporary storage. Reserved between setjmp and longjmp. */
+
+ #ifdef __MMIX_ABI_GNU__
+ #define arg1 $231
+ #define arg2 $232
+ #define outret $231
+ #define popval 0
+ #else
+ #define arg1 $0
+ #define arg2 $1
+ #define outret $0
+ #define popval 1
+ #endif
+
+ .section .text.setjmp,"ax",@progbits
+ .global setjmp
+ setjmp:
+ % Store fp, sp and return address. Recycle the static-chain and
+ % structure-return registers as temporary register, since we need to keep
+ % the jmp_buf (parameter 1) and the return address across a "POP".
+ SET $251,arg1
+ STOU $253,$251,0
+ GET $252,rJ
+ STOU $252,$251,8
+ STOU $254,$251,16
+ SETL outret,0
+
+ % Jump through hoops to get the value of rO *before* the setjmp call.
+ GETA $255,0f
+ PUT rJ,$255
+ POP popval,0
+ 0:
+ GET $255,rO
+ STOU $255,$251,24
+ GO $255,$252,0
+ .size setjmp,.-setjmp
+
+ .section .text.longjmp,"ax",@progbits
+ .global longjmp
+ longjmp:
+ % Reset arg2 to 1 if it is 0 (see longjmp(2)) and store it in jmp_buf.
+ % Save arg1 in a global register, since it will be destroyed by the POPs
+ % (in the mmixware ABI).
+ CSZ arg2,arg2,1
+ STOU arg2,arg1,32
+ SET $251,arg1
+
+ % Loop and "POP 0,0" until rO is the expected value, like
+ % the expansion of nonlocal_goto_receiver, except that we put the return
+ % value in the right register and make sure that the POP causes it to
+ % enter the right return-value register as seen by the caller. For the
+ % GNU ABI, it is unnecessary to do this in the loop and perhaps the memory
+ % access can be hoisted outside the loop, but this is safe and simple and
+ % I see no need to optimize longjmps.
+ GETA $255,0f
+ PUT rJ,$255
+ LDOU $255,$251,24
+ 0:
+ GET $252,rO
+ CMPU $252,$252,$255
+ BNP $252,1f
+ LDOU outret,$251,32
+ POP popval,0
+ 1:
+ LDOU $253,$251,0
+ LDOU $255,$251,8
+ LDOU $254,$251,16
+ GO $255,$255,0
+ .size longjmp,.-longjmp
diff -cprN libc/sys/nope/stat.c libc/sys/mmixware/stat.c
*** libc/sys/nope/stat.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/stat.c Sat Nov 10 16:11:37 2001
***************
*** 0 ****
--- 1,23 ----
+ /* stat stub for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include "sys/syscall.h"
+ #include <errno.h>
+
+ int
+ _stat (const char *path, struct stat *st)
+
+ {
+ UNIMPLEMENTED (("path: %s, st: %p", path, st));
+ errno = ENOSYS;
+ return -1;
+ }
diff -cprN libc/sys/nope/syscall.h libc/sys/mmixware/sys/syscall.h
*** libc/sys/nope/syscall.h Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/sys/syscall.h Sat Nov 10 23:06:52 2001
***************
*** 0 ****
--- 1,136 ----
+ /* syscall defines for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ /* These are the mmixware simulator calls that are of use in newlib. */
+
+ #define SYS_halt 0
+ #define SYS_Fopen 1
+ #define SYS_Fclose 2
+ #define SYS_Fread 3
+ #define SYS_Fwrite 6
+ #define SYS_Fseek 9
+ #define SYS_Ftell 10
+
+
+ enum MMIX_filemode
+ {
+ TextRead = 0,
+ TextWrite = 1,
+ BinaryRead = 2,
+ BinaryWrite = 3,
+ BinaryReadWrite = 4
+ };
+
+ #define N_MMIX_FILEHANDLES 32
+
+ /* We store a bitmap of allocated filehandles
+ _MMIX_allocated_filehandle[fileno] in an array. There are 32 of them.
+ Indexes 0, 1 and 2 are allocated from start. The reason we keep track
+ of them is that *we* have to allocate a filehandle when opening a file.
+ Had we got a filehandle from the simulator, we wouldn't have to keep
+ 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. */
+ #define TRAP1i(FUN, ARG1) \
+ ({ long ret_; \
+ __asm__ ("TRAP 0,%1,%2\n\tSET %0,$255" \
+ : "=r" (ret_) : "i" (FUN), "i" (ARG1) \
+ : "memory"); \
+ ret_; \
+ })
+
+ /* Helper macros to cope with the file-handle parameter to the simulator
+ being *constant*. We support up to 32 simultaneously open files. */
+ #define I3f(FUN, ARG1, N, ARGS) \
+ if (ARG1 == N) \
+ __asm__ ("SET $255,%3\n\tTRAP 0,%1,%2\n\tSET %0,$255" \
+ : "=r" (ret_) : "i" (FUN), "i" (N), "r" (ARGS) \
+ : "memory")
+
+ /* Using if:s rather than switches to help GCC optimize the rest away. */
+ #define DO32(FUN, ARG1, ARGS) \
+ I3f (FUN, ARG1, 0, ARGS); \
+ else I3f (FUN, ARG1, 1, ARGS); \
+ else I3f (FUN, ARG1, 2, ARGS); \
+ else I3f (FUN, ARG1, 3, ARGS); \
+ else I3f (FUN, ARG1, 4, ARGS); \
+ else I3f (FUN, ARG1, 5, ARGS); \
+ else I3f (FUN, ARG1, 6, ARGS); \
+ else I3f (FUN, ARG1, 7, ARGS); \
+ else I3f (FUN, ARG1, 8, ARGS); \
+ else I3f (FUN, ARG1, 9, ARGS); \
+ else I3f (FUN, ARG1, 10, ARGS); \
+ else I3f (FUN, ARG1, 11, ARGS); \
+ else I3f (FUN, ARG1, 12, ARGS); \
+ else I3f (FUN, ARG1, 13, ARGS); \
+ else I3f (FUN, ARG1, 14, ARGS); \
+ else I3f (FUN, ARG1, 15, ARGS); \
+ else I3f (FUN, ARG1, 16, ARGS); \
+ else I3f (FUN, ARG1, 17, ARGS); \
+ else I3f (FUN, ARG1, 18, ARGS); \
+ else I3f (FUN, ARG1, 19, ARGS); \
+ else I3f (FUN, ARG1, 20, ARGS); \
+ else I3f (FUN, ARG1, 21, ARGS); \
+ else I3f (FUN, ARG1, 22, ARGS); \
+ else I3f (FUN, ARG1, 23, ARGS); \
+ else I3f (FUN, ARG1, 24, ARGS); \
+ else I3f (FUN, ARG1, 25, ARGS); \
+ else I3f (FUN, ARG1, 26, ARGS); \
+ else I3f (FUN, ARG1, 27, ARGS); \
+ else I3f (FUN, ARG1, 28, ARGS); \
+ else I3f (FUN, ARG1, 29, ARGS); \
+ else I3f (FUN, ARG1, 30, ARGS); \
+ else I3f (FUN, ARG1, 31, ARGS); \
+ else \
+ { \
+ errno = EBADF; \
+ return -1; \
+ }
+
+ #define TRAP1f(FUN, ARG1) \
+ ({ long ret_; \
+ DO32 (FUN, ARG1, 0); \
+ ret_; \
+ })
+
+ #define TRAP2f(FUN, ARG1, ARG2) \
+ ({ long ret_; \
+ DO32 (FUN, ARG1, ARG2); \
+ ret_; \
+ })
+
+ #define TRAP3f(FUN, ARG1, ARG2, ARG3) \
+ ({ long ret_; \
+ unsigned long args_[] \
+ = { (unsigned long) (ARG2), (unsigned long) (ARG3) }; \
+ DO32 (FUN, ARG1, args_); \
+ ret_; \
+ })
+
+ #ifndef __GNUC__
+ /* Probably will not happen. Nevertheless... */
+ # define UNIMPLEMENTED(MSG)
+ #else
+ # define UNIMPLEMENTED(MSG) UNIMPLEMENTEDi MSG
+ # define UNIMPLEMENTEDi(MSG, ARGS...) \
+ do { \
+ char buf[2000]; \
+ sprintf (buf, "UNIMPLEMENTED %s in %s\n", __FUNCTION__, __FILE__); \
+ write (2, buf, strlen (buf)); \
+ sprintf (buf, MSG , ##ARGS); \
+ write (2, buf, strlen (buf)); \
+ write (2, "\n", 1); \
+ } while (0)
+ #endif
diff -cprN libc/sys/nope/time.c libc/sys/mmixware/time.c
*** libc/sys/nope/time.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/time.c Sat Nov 10 16:11:37 2001
***************
*** 0 ****
--- 1,26 ----
+ /* time stub for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include "sys/syscall.h"
+
+ time_t
+ time (time_t *tloc)
+ {
+ /* Nowhere to get time reasonably from; neither of rC, rI and rU seems
+ usable without assuming some scaling of mems and oops to real time. */
+ time_t thetime = 0;
+
+ if (tloc)
+ *tloc = thetime;
+
+ return thetime;
+ }
diff -cprN libc/sys/nope/times.c libc/sys/mmixware/times.c
*** libc/sys/nope/times.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/times.c Sat Nov 10 16:11:37 2001
***************
*** 0 ****
--- 1,21 ----
+ /* times stub for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include "sys/syscall.h"
+ #include "sys/times.h"
+
+ clock_t
+ times (struct tms *buffer)
+ {
+ memset (buffer, 0, sizeof (*buffer));
+ return 0;
+ }
diff -cprN libc/sys/nope/unlink.c libc/sys/mmixware/unlink.c
*** libc/sys/nope/unlink.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/unlink.c Sat Nov 10 16:11:37 2001
***************
*** 0 ****
--- 1,19 ----
+ /* unlink stub for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include "sys/syscall.h"
+
+ int
+ _unlink ()
+ {
+ return -1;
+ }
diff -cprN libc/sys/nope/utime.c libc/sys/mmixware/utime.c
*** libc/sys/nope/utime.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/utime.c Sat Nov 10 16:11:37 2001
***************
*** 0 ****
--- 1,24 ----
+ /* utime stub for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include "sys/syscall.h"
+ #include <errno.h>
+
+ int
+ utime (path, times)
+ const char *path;
+ char *times;
+ {
+ UNIMPLEMENTED (("path: %s, times: %p", path, times));
+ errno = ENOSYS;
+ return -1;
+ }
diff -cprN libc/sys/nope/wait.c libc/sys/mmixware/wait.c
*** libc/sys/nope/wait.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/wait.c Sat Nov 10 16:11:37 2001
***************
*** 0 ****
--- 1,23 ----
+ /* wait stub for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include "sys/syscall.h"
+ #include <errno.h>
+
+ int
+ _wait (statusp)
+ int *statusp;
+ {
+ UNIMPLEMENTED (("statusp: %p", statusp));
+ errno = ENOSYS;
+ return -1;
+ }
diff -cprN libc/sys/nope/write.c libc/sys/mmixware/write.c
*** libc/sys/nope/write.c Thu Jan 1 01:00:00 1970
--- libc/sys/mmixware/write.c Sat Nov 10 16:11:37 2001
***************
*** 0 ****
--- 1,38 ----
+ /* write for MMIXware.
+ Copyright (C) 2001 Hans-Peter Nilsson.
+ Permission to use, copy, modify, and distribute this software is freely
+ granted, provided that this notice is preserved with no changes.
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ PURPOSE. */
+
+ #include <_ansi.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include "sys/syscall.h"
+ #include <errno.h>
+
+ int
+ _write ( int file,
+ char *ptr,
+ size_t len)
+ {
+ long ret;
+
+ if ((unsigned int) file >= 32 || _MMIX_allocated_filehandle[file] == 0)
+ {
+ errno = EBADF;
+ return -1;
+ }
+
+ ret = TRAP3f (SYS_Fwrite, file, ptr, len);
+
+ if (ret < 0)
+ {
+ errno = EIO;
+ return -1;
+ }
+
+ return len;
+ }
brgds, H-P
More information about the Newlib
mailing list