2001-11-12 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.
This commit is contained in:
Jeff Johnston 2001-11-12 21:04:41 +00:00
parent 5e051b1bf7
commit 8be9b48be6
39 changed files with 3471 additions and 0 deletions

View File

@ -1,3 +1,27 @@
2001-11-12 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.
2001-11-05 Corinna Vinschen <corinna@vinschen.de>
* libc/include/sys/unistd.h: Add prototypes for endusershell(),

View File

@ -125,6 +125,8 @@ case "${host_cpu}" in
mips*)
machine_dir=mips
;;
mmix)
;;
mn10200)
machine_dir=mn10200
;;
@ -276,6 +278,9 @@ case "${host}" in
mips*-dec-*)
sys_dir=decstation
;;
mmix-knuth-mmixware)
sys_dir=mmixware
;;
powerpcle-*-pe)
sys_dir=cygwin
posix_dir=posix
@ -423,6 +428,12 @@ case "${host}" in
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
;;

View File

@ -98,6 +98,10 @@
#define __IEEE_BIG_ENDIAN
#endif
#ifdef __MMIX__
#define __IEEE_BIG_ENDIAN
#endif
/* necv70 was __IEEE_LITTLE_ENDIAN. */
#ifdef __W65__

View File

@ -145,6 +145,12 @@ typedef int jmp_buf[_JBLEN];
#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];

View File

@ -73,6 +73,10 @@
#define __IEEE_LITTLE_ENDIAN
#endif
#ifdef __MMIX__
#define __IEEE_BIG_ENDIAN
#endif
#ifdef __AVR__
#define _DOUBLE_IS_32BITS
#define __SMALL_BITFIELDS

View File

@ -0,0 +1,18 @@
## 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
all: crt0.o
ACLOCAL_AMFLAGS = -I ../../..
CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host

View File

@ -0,0 +1,328 @@
# Makefile.in generated automatically by automake 1.4 from Makefile.am
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = .
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
AR = @AR@
AS = @AS@
CC = @CC@
CPP = @CPP@
EXEEXT = @EXEEXT@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
NEWLIB_CFLAGS = @NEWLIB_CFLAGS@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
VERSION = @VERSION@
machine_dir = @machine_dir@
newlib_basedir = @newlib_basedir@
sys_dir = @sys_dir@
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
ACLOCAL_AMFLAGS = -I ../../..
CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/../../../../mkinstalldirs
CONFIG_CLEAN_FILES =
LIBRARIES = $(noinst_LIBRARIES)
DEFS = @DEFS@ -I. -I$(srcdir)
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
lib_a_LIBADD =
lib_a_OBJECTS = _exit.o access.o chmod.o chown.o close.o creat.o \
execv.o execve.o fork.o fstat.o getpid.o isatty.o kill.o lseek.o open.o \
pipe.o read.o sbrk.o stat.o time.o unlink.o utime.o wait.o write.o \
times.o gettime.o setjmp.o
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
DIST_COMMON = Makefile.am Makefile.in aclocal.m4 configure configure.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = gtar
GZIP_ENV = --best
SOURCES = $(lib_a_SOURCES)
OBJECTS = $(lib_a_OBJECTS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .o .s
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --cygnus Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ configure.in \
../../../acinclude.m4 ../../../aclocal.m4
cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(srcdir)/configure: @MAINTAINER_MODE_TRUE@$(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
cd $(srcdir) && $(AUTOCONF)
mostlyclean-noinstLIBRARIES:
clean-noinstLIBRARIES:
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
distclean-noinstLIBRARIES:
maintainer-clean-noinstLIBRARIES:
.c.o:
$(COMPILE) -c $<
.s.o:
$(COMPILE) -c $<
.S.o:
$(COMPILE) -c $<
mostlyclean-compile:
-rm -f *.o core *.core
clean-compile:
distclean-compile:
-rm -f *.tab.c
maintainer-clean-compile:
lib.a: $(lib_a_OBJECTS) $(lib_a_DEPENDENCIES)
-rm -f lib.a
$(AR) cru lib.a $(lib_a_OBJECTS) $(lib_a_LIBADD)
$(RANLIB) lib.a
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS)
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
-rm -rf $(distdir)
GZIP=$(GZIP_ENV) $(TAR) zxf $(distdir).tar.gz
mkdir $(distdir)/=build
mkdir $(distdir)/=inst
dc_install_base=`cd $(distdir)/=inst && pwd`; \
cd $(distdir)/=build \
&& ../configure --srcdir=.. --prefix=$$dc_install_base \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) dist
-rm -rf $(distdir)
@banner="$(distdir).tar.gz is ready for distribution"; \
dashes=`echo "$$banner" | sed s/./=/g`; \
echo "$$dashes"; \
echo "$$banner"; \
echo "$$dashes"
dist: distdir
-chmod -R a+r $(distdir)
GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
-rm -rf $(distdir)
dist-all: distdir
-chmod -R a+r $(distdir)
GZIP=$(GZIP_ENV) $(TAR) chozf $(distdir).tar.gz $(distdir)
-rm -rf $(distdir)
distdir: $(DISTFILES)
-rm -rf $(distdir)
mkdir $(distdir)
-chmod 777 $(distdir)
@for file in $(DISTFILES); do \
if test -f $$file; then d=.; else d=$(srcdir); fi; \
if test -d $$d/$$file; then \
cp -pr $$d/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am:
check: check-am
installcheck-am:
installcheck: installcheck-am
install-info-am:
install-info: install-info-am
install-exec-am:
install-exec: install-exec-am
install-data-am:
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am:
uninstall: uninstall-am
all-am: Makefile $(LIBRARIES)
all-redirect: all-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
mostlyclean-generic:
clean-generic:
distclean-generic:
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
maintainer-clean-generic:
mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \
mostlyclean-tags mostlyclean-generic
mostlyclean: mostlyclean-am
clean-am: clean-noinstLIBRARIES clean-compile clean-tags clean-generic \
mostlyclean-am
clean: clean-am
distclean-am: distclean-noinstLIBRARIES distclean-compile \
distclean-tags distclean-generic clean-am
distclean: distclean-am
-rm -f config.status
maintainer-clean-am: maintainer-clean-noinstLIBRARIES \
maintainer-clean-compile maintainer-clean-tags \
maintainer-clean-generic distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
-rm -f config.status
.PHONY: mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \
clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \
mostlyclean-compile distclean-compile clean-compile \
maintainer-clean-compile tags mostlyclean-tags distclean-tags \
clean-tags maintainer-clean-tags distdir info-am info dvi-am dvi check \
check-am installcheck-am installcheck install-info-am install-info \
install-exec-am install-exec install-data-am install-data install-am \
install uninstall-am uninstall all-redirect all-am all installdirs \
mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
all: crt0.o
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -0,0 +1,26 @@
/* _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");
}

View File

@ -0,0 +1,41 @@
/* 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;
}

291
newlib/libc/sys/mmixware/aclocal.m4 vendored Normal file
View File

@ -0,0 +1,291 @@
dnl aclocal.m4 generated automatically by aclocal 1.4
dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
dnl PARTICULAR PURPOSE.
dnl This provides configure definitions used by all the newlib
dnl configure.in files.
dnl Basic newlib configury. This calls basic introductory stuff,
dnl including AM_INIT_AUTOMAKE and AC_CANONICAL_HOST. It also runs
dnl configure.host. The only argument is the relative path to the top
dnl newlib directory.
AC_DEFUN(NEWLIB_CONFIGURE,
[
dnl Default to --enable-multilib
AC_ARG_ENABLE(multilib,
[ --enable-multilib build many library versions (default)],
[case "${enableval}" in
yes) multilib=yes ;;
no) multilib=no ;;
*) AC_MSG_ERROR(bad value ${enableval} for multilib option) ;;
esac], [multilib=yes])dnl
dnl Support --enable-target-optspace
AC_ARG_ENABLE(target-optspace,
[ --enable-target-optspace optimize for space],
[case "${enableval}" in
yes) target_optspace=yes ;;
no) target_optspace=no ;;
*) AC_MSG_ERROR(bad value ${enableval} for target-optspace option) ;;
esac], [target_optspace=])dnl
dnl Support --enable-malloc-debugging - currently only supported for Cygwin
AC_ARG_ENABLE(malloc-debugging,
[ --enable-malloc-debugging indicate malloc debugging requested],
[case "${enableval}" in
yes) malloc_debugging=yes ;;
no) malloc_debugging=no ;;
*) AC_MSG_ERROR(bad value ${enableval} for malloc-debugging option) ;;
esac], [malloc_debugging=])dnl
dnl Support --enable-newlib-mb
AC_ARG_ENABLE(newlib-mb,
[ --enable-newlib-mb enable multibyte support],
[case "${enableval}" in
yes) newlib_mb=yes ;;
no) newlib_mb=no ;;
*) AC_MSG_ERROR(bad value ${enableval} for newlib-mb option) ;;
esac], [newlib_mb=no])dnl
dnl We may get other options which we don't document:
dnl --with-target-subdir, --with-multisrctop, --with-multisubdir
test -z "[$]{with_target_subdir}" && with_target_subdir=.
if test "[$]{srcdir}" = "."; then
if test "[$]{with_target_subdir}" != "."; then
newlib_basedir="[$]{srcdir}/[$]{with_multisrctop}../$1"
else
newlib_basedir="[$]{srcdir}/[$]{with_multisrctop}$1"
fi
else
newlib_basedir="[$]{srcdir}/$1"
fi
AC_SUBST(newlib_basedir)
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE(newlib, 1.9.0)
# FIXME: We temporarily define our own version of AC_PROG_CC. This is
# copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS. We
# are probably using a cross compiler, which will not be able to fully
# link an executable. This should really be fixed in autoconf
# itself.
AC_DEFUN(LIB_AC_PROG_CC,
[AC_BEFORE([$0], [AC_PROG_CPP])dnl
AC_CHECK_PROG(CC, gcc, gcc)
if test -z "$CC"; then
AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
fi
AC_PROG_CC_GNU
if test $ac_cv_prog_gcc = yes; then
GCC=yes
dnl Check whether -g works, even if CFLAGS is set, in case the package
dnl plays around with CFLAGS (such as to build both debugging and
dnl normal versions of a library), tasteless as that idea is.
ac_test_CFLAGS="${CFLAGS+set}"
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
AC_PROG_CC_G
if test "$ac_test_CFLAGS" = set; then
CFLAGS="$ac_save_CFLAGS"
elif test $ac_cv_prog_cc_g = yes; then
CFLAGS="-g -O2"
else
CFLAGS="-O2"
fi
else
GCC=
test "${CFLAGS+set}" = set || CFLAGS="-g"
fi
])
LIB_AC_PROG_CC
# AC_CHECK_TOOL does AC_REQUIRE (AC_CANONICAL_BUILD). If we don't
# run it explicitly here, it will be run implicitly before
# NEWLIB_CONFIGURE, which doesn't work because that means that it will
# be run before AC_CANONICAL_HOST.
AC_CANONICAL_BUILD
AC_CHECK_TOOL(AS, as)
AC_CHECK_TOOL(AR, ar)
AC_CHECK_TOOL(RANLIB, ranlib, :)
AC_PROG_INSTALL
AM_MAINTAINER_MODE
# We need AC_EXEEXT to keep automake happy in cygnus mode. However,
# at least currently, we never actually build a program, so we never
# need to use $(EXEEXT). Moreover, the test for EXEEXT normally
# fails, because we are probably configuring with a cross compiler
# which can't create executables. So we include AC_EXEEXT to keep
# automake happy, but we don't execute it, since we don't care about
# the result.
if false; then
AC_EXEEXT
fi
. [$]{newlib_basedir}/configure.host
case [$]{newlib_basedir} in
/* | [A-Za-z]:[/\\]*) newlib_flagbasedir=[$]{newlib_basedir} ;;
*) newlib_flagbasedir='[$](top_builddir)/'[$]{newlib_basedir} ;;
esac
newlib_cflags="[$]{newlib_cflags} -I"'[$](top_builddir)'"/$1/targ-include -I[$]{newlib_flagbasedir}/libc/include"
case "${host}" in
*-*-cygwin*)
newlib_cflags="[$]{newlib_cflags} -I[$]{newlib_flagbasedir}/../winsup/cygwin/include -I[$]{newlib_flagbasedir}/../winsup/w32api/include"
;;
esac
newlib_cflags="[$]{newlib_cflags} -fno-builtin"
NEWLIB_CFLAGS=${newlib_cflags}
AC_SUBST(NEWLIB_CFLAGS)
AC_SUBST(machine_dir)
AC_SUBST(sys_dir)
])
# Do all the work for Automake. This macro actually does too much --
# some checks are only needed if your package does certain things.
# But this isn't really a big deal.
# serial 1
dnl Usage:
dnl AM_INIT_AUTOMAKE(package,version, [no-define])
AC_DEFUN(AM_INIT_AUTOMAKE,
[AC_REQUIRE([AC_PROG_INSTALL])
PACKAGE=[$1]
AC_SUBST(PACKAGE)
VERSION=[$2]
AC_SUBST(VERSION)
dnl test to see if srcdir already configured
if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
fi
ifelse([$3],,
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
AC_REQUIRE([AM_SANITY_CHECK])
AC_REQUIRE([AC_ARG_PROGRAM])
dnl FIXME This is truly gross.
missing_dir=`cd $ac_aux_dir && pwd`
AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
AC_REQUIRE([AC_PROG_MAKE_SET])])
#
# Check to make sure that the build environment is sane.
#
AC_DEFUN(AM_SANITY_CHECK,
[AC_MSG_CHECKING([whether build environment is sane])
# Just in case
sleep 1
echo timestamp > conftestfile
# Do `set' in a subshell so we don't clobber the current shell's
# arguments. Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
if test "[$]*" = "X"; then
# -L didn't work.
set X `ls -t $srcdir/configure conftestfile`
fi
if test "[$]*" != "X $srcdir/configure conftestfile" \
&& test "[$]*" != "X conftestfile $srcdir/configure"; then
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
alias in your environment])
fi
test "[$]2" = conftestfile
)
then
# Ok.
:
else
AC_MSG_ERROR([newly created file is older than distributed files!
Check your system clock])
fi
rm -f conftest*
AC_MSG_RESULT(yes)])
dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
dnl The program must properly implement --version.
AC_DEFUN(AM_MISSING_PROG,
[AC_MSG_CHECKING(for working $2)
# Run test in a subshell; some versions of sh will print an error if
# an executable is not found, even if stderr is redirected.
# Redirect stdin to placate older versions of autoconf. Sigh.
if ($2 --version) < /dev/null > /dev/null 2>&1; then
$1=$2
AC_MSG_RESULT(found)
else
$1="$3/missing $2"
AC_MSG_RESULT(missing)
fi
AC_SUBST($1)])
# Add --enable-maintainer-mode option to configure.
# From Jim Meyering
# serial 1
AC_DEFUN(AM_MAINTAINER_MODE,
[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
dnl maintainer-mode is disabled by default
AC_ARG_ENABLE(maintainer-mode,
[ --enable-maintainer-mode enable make rules and dependencies not useful
(and sometimes confusing) to the casual installer],
USE_MAINTAINER_MODE=$enableval,
USE_MAINTAINER_MODE=no)
AC_MSG_RESULT($USE_MAINTAINER_MODE)
AM_CONDITIONAL(MAINTAINER_MODE, test $USE_MAINTAINER_MODE = yes)
MAINT=$MAINTAINER_MODE_TRUE
AC_SUBST(MAINT)dnl
]
)
# Define a conditional.
AC_DEFUN(AM_CONDITIONAL,
[AC_SUBST($1_TRUE)
AC_SUBST($1_FALSE)
if $2; then
$1_TRUE=
$1_FALSE='#'
else
$1_TRUE='#'
$1_FALSE=
fi])

View File

@ -0,0 +1,24 @@
/* 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;
}

View File

@ -0,0 +1,24 @@
/* 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;
}

View File

@ -0,0 +1,36 @@
/* 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;
}

1701
newlib/libc/sys/mmixware/configure vendored Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,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)

View File

@ -0,0 +1,25 @@
/* 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);
}

View File

@ -0,0 +1,16 @@
/* 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;

View File

@ -0,0 +1,24 @@
/* 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;
}

View File

@ -0,0 +1,24 @@
/* 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;
}

View File

@ -0,0 +1,24 @@
/* 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;
}

View File

@ -0,0 +1,24 @@
/* 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;
}

View File

@ -0,0 +1,20 @@
/* 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;
}

View File

@ -0,0 +1,25 @@
/* 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;
}

View File

@ -0,0 +1,21 @@
/* 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;
}

View File

@ -0,0 +1,26 @@
/* 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;
}

View File

@ -0,0 +1,61 @@
/* 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;
}

View File

@ -0,0 +1,106 @@
/* 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;
}

View File

@ -0,0 +1,24 @@
/* 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;
}

View File

@ -0,0 +1,49 @@
/* 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;
}

View File

@ -0,0 +1,41 @@
/* 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;
}

View File

@ -0,0 +1,85 @@
/* 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

View File

@ -0,0 +1,25 @@
/* 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;
}

View File

@ -0,0 +1,138 @@
/* 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

View File

@ -0,0 +1,28 @@
/* 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;
}

View File

@ -0,0 +1,23 @@
/* 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;
}

View File

@ -0,0 +1,21 @@
/* 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;
}

View File

@ -0,0 +1,26 @@
/* 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;
}

View File

@ -0,0 +1,25 @@
/* 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;
}

View File

@ -0,0 +1,40 @@
/* 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;
}