From 2b529d22cfeddb547b91c8fcbccb1dd4e1b7e36b Mon Sep 17 00:00:00 2001 From: "Taylor R. Campbell" Date: Tue, 4 Sep 2007 03:35:20 +0000 Subject: [PATCH] Revive SPARC Solaris support: - Do canonical host checking earlier in `microcode/configure.ac', so that OS-dependent customization can insert options to `LDFLAGS' for the configuration tests. Add `-lsocket -lnsl' to `LDFLAGS' in Solaris; this is necessary to get at sockets, `gethostbyname', &c. - Introduce a temporary variable `GNU_LD' in `microcode/configure.ac', set among the OS-dependent customization, which determines whether or not the GNU-specific `-export-dynamic' option should be passed to the C linker. Solaris's `ld' will see that option as `-e' with an argument of `xport-dynamic', and fail; it is safe to omit the option altogether, however, because the default (`-z record') is the behaviour we want. - Use `-f' and `-d' instead of `-e' in `test' in shell scripts. `test' in Solaris's `sh' does not recognize `-e'. - Use a horrid, horrid, hack to imitate the non-standard `-ef' in `test'. If there is a better (preferably standard, but widely supported is good enough) way to do this than grovelling through the output of `ls -l', please tell me! - Fix the emulation of in "confshared.h". Solaris needs this because if `-std=c99' is not passed to GCC, there is no , but if `-std=c99' is passed to GCC, elsewhere makes GCC choke. - Use "config.h" in `unstackify.c', not . - Use the `__sparc' cpp macro throughout the microcode to test for the SPARC, not `sparc'. - Update "uxtrap.h" to include support for SPARC Solaris. --- v7/src/compiler/configure | 4 +- v7/src/etc/Setup.sh | 4 +- v7/src/etc/functions.sh | 13 ++- v7/src/etc/install-bin-symlinks.sh | 4 +- v7/src/microcode/configure.ac | 146 ++++++++++++++++------------- v7/src/microcode/confshared.h | 6 +- v7/src/microcode/unstackify.c | 6 +- v7/src/microcode/ux.h | 6 +- v7/src/microcode/uxtop.c | 4 +- v7/src/microcode/uxtrap.h | 77 ++++++++++++++- 10 files changed, 185 insertions(+), 85 deletions(-) diff --git a/v7/src/compiler/configure b/v7/src/compiler/configure index 37cbdcc43..1d8b4c4e4 100755 --- a/v7/src/compiler/configure +++ b/v7/src/compiler/configure @@ -1,6 +1,6 @@ #!/bin/sh -# $Id: configure,v 1.18 2007/06/06 19:42:38 cph Exp $ +# $Id: configure,v 1.19 2007/09/04 03:35:19 riastradh Exp $ # # Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, # 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, @@ -55,7 +55,7 @@ if test "${MACHINE}" = C; then fi for FN in ${LINKS}; do - if [ ! -e ${FN} ]; then + if [ ! -f "${FN}" ]; then CMD="ln -s machine/${FN} ." echo "${CMD}"; eval "${CMD}" fi diff --git a/v7/src/etc/Setup.sh b/v7/src/etc/Setup.sh index 9db75e126..d26cf0049 100755 --- a/v7/src/etc/Setup.sh +++ b/v7/src/etc/Setup.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: Setup.sh,v 1.14 2007/05/14 16:50:47 cph Exp $ +# $Id: Setup.sh,v 1.15 2007/09/04 03:35:19 riastradh Exp $ # # Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, # 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, @@ -34,6 +34,6 @@ for FN in Clean.sh Stage.sh Tags.sh; do maybe_link ${FN} ../etc/${FN} done -if [ -e ed-ffi.scm ]; then +if [ -f ed-ffi.scm ]; then maybe_link .edwin-ffi ed-ffi.scm fi diff --git a/v7/src/etc/functions.sh b/v7/src/etc/functions.sh index cded81790..f90d74730 100644 --- a/v7/src/etc/functions.sh +++ b/v7/src/etc/functions.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: functions.sh,v 1.9 2007/06/15 03:40:17 cph Exp $ +# $Id: functions.sh,v 1.10 2007/09/04 03:35:19 riastradh Exp $ # # Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, # 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, @@ -64,14 +64,14 @@ get_fasl_file () maybe_mkdir () { - if [ ! -e "${1}" ]; then + if [ ! -d "${1}" ]; then run_cmd mkdir "${1}" fi } maybe_link () { - if [ ! -e "${1}" ] && [ ! -L "${1}" ]; then + if [ ! -f "${1}" ] && [ ! -L "${1}" ]; then run_cmd ln -s "${2}" "${1}" fi } @@ -88,7 +88,12 @@ maybe_unlink_p () ( cd `dirname "${1}"` BN=`basename "${1}"` - [ -L "${BN}" ] && [ "${BN}" -ef "${2}" ] + # What a wretched hack this is! I can find no standard way to + # compare two pathnames for identity of the file they name. There + # is a non-standard `-ef' option to `test', `test f1 -ef f2', but + # Solaris does not support this option. Ugh! --TRC + [ -L "${BN}" ] && [ -f "${2}" ] && \ + (ls -l "${BN}" | grep -- " -> ${2}\$" >/dev/null) ) } diff --git a/v7/src/etc/install-bin-symlinks.sh b/v7/src/etc/install-bin-symlinks.sh index 9c44632d5..b4a58944c 100755 --- a/v7/src/etc/install-bin-symlinks.sh +++ b/v7/src/etc/install-bin-symlinks.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: install-bin-symlinks.sh,v 1.2 2007/06/15 03:40:18 cph Exp $ +# $Id: install-bin-symlinks.sh,v 1.3 2007/09/04 03:35:19 riastradh Exp $ # # Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, # 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, @@ -37,7 +37,7 @@ else exit 1 fi -if [ "${EXE}" != mit-scheme ] && [ ! -e "${DIR}/mit-scheme" ]; then +if [ "${EXE}" != mit-scheme ] && [ ! -f "${DIR}/mit-scheme" ]; then run_cmd rm -f "${DIR}"/mit-scheme run_cmd ln -s "${EXE}" "${DIR}"/mit-scheme fi diff --git a/v7/src/microcode/configure.ac b/v7/src/microcode/configure.ac index 02cdaf17b..abe028294 100644 --- a/v7/src/microcode/configure.ac +++ b/v7/src/microcode/configure.ac @@ -1,7 +1,7 @@ dnl Process this file with autoconf to produce a configure script. AC_INIT([MIT/GNU Scheme microcode], [15.1], [bug-mit-scheme@gnu.org], [mit-scheme]) -AC_REVISION([$Id: configure.ac,v 1.55 2007/08/24 13:19:24 riastradh Exp $]) +AC_REVISION([$Id: configure.ac,v 1.56 2007/09/04 03:35:19 riastradh Exp $]) AC_CONFIG_SRCDIR([boot.c]) AC_CONFIG_HEADERS([config.h]) AC_PROG_MAKE_SET @@ -197,6 +197,8 @@ AUXDIR_NAME=mit-scheme EXE_NAME=mit-scheme-native INSTALL_INCLUDE= +AC_CANONICAL_HOST + dnl Checks for programs. AC_PROG_CC AC_C_BACKSLASH_A @@ -248,6 +250,83 @@ if test "x${FOO}" != x; then fi CCLD=${CC} +dnl Add OS-dependent customizations. This must happen before checking +dnl any headers or library routines, because it may add CFLAGS or +dnl LDFLAGS that the subsequent checks require. + +DO_GCC_TESTS=no +GNU_LD=no +case ${host_os} in +linux-gnu) + DO_GCC_TESTS=yes + GNU_LD=yes + ;; +freebsd*) + M4_FLAGS="${M4_FLAGS} -P SUPPRESS_LEADING_UNDERSCORE,1" + DO_GCC_TESTS=yes + GNU_LD=yes + ;; +dragonfly*) + M4_FLAGS="${M4_FLAGS} -P SUPPRESS_LEADING_UNDERSCORE,1" + DO_GCC_TESTS=yes + GNU_LD=yes + ;; +darwin*) + SCHEME_LDFLAGS="${SCHEME_LDFLAGS} -Wl,-pagezero_size,04000000" + MODULE_LDFLAGS="${MODULE_LDFLAGS} -bundle -flat_namespace -undefined suppress" + ;; +netbsd*) + DO_GCC_TESTS=yes + GNU_LD=yes + dnl NetBSD, by default, has programs find non-base libraries via RPATH + if test "x${x_libraries}" != x; then + FOO=-Wl,-rpath,`echo ${x_libraries} | sed -e "s/:/ -Wl,-rpath,/g"` + LDFLAGS="${LDFLAGS} ${FOO}" + fi + ;; +openbsd*) + M4_FLAGS="${M4_FLAGS} -P SUPPRESS_LEADING_UNDERSCORE,1" + DO_GCC_TESTS=yes + GNU_LD=yes + ;; +solaris*) + # How do we tell whether we're using GNU ld or Solaris ld? + if test ${GCC} = yes; then + DO_GCC_TESTS=yes + M4_FLAGS="${M4_FLAGS} -P SUPPRESS_LEADING_UNDERSCORE,1" + fi + LDFLAGS="${LDFLAGS} -lsocket -lnsl" + ;; +esac + +if test "${DO_GCC_TESTS}" = yes; then + if test "x${STATIC_LIBS}" != x; then + STATIC_PREFIX="-Xlinker -Bstatic" + STATIC_SUFFIX="-Xlinker -Bdynamic" + fi + if test "${GNU_LD}" = yes; then + SCHEME_LDFLAGS="${SCHEME_LDFLAGS} -export-dynamic" + fi + MODULE_CFLAGS="${MODULE_CFLAGS} -fPIC" + MODULE_LDFLAGS="${MODULE_LDFLAGS} -shared -fPIC" + AC_MSG_CHECKING([for ELF binaries]) + AC_RUN_IFELSE( + [AC_LANG_PROGRAM( + [[]], + [[ + #ifdef __ELF__ + return 0; + #endif + return 1; + ]] + )], + [ + AC_MSG_RESULT([yes]) + M4_FLAGS="${M4_FLAGS} -P SUPPRESS_LEADING_UNDERSCORE,1" + ], + [AC_MSG_RESULT([no])]) +fi + dnl Checks for libraries. AC_CHECK_LIB([m], [exp]) @@ -547,7 +626,6 @@ if test ${ac_cv_type_signal} = void; then fi dnl Checks for system characteristics. -AC_CANONICAL_HOST AC_PATH_X AC_SYS_LARGEFILE AC_SYS_LONG_FILE_NAMES @@ -815,70 +893,6 @@ if test "${no_x}" != yes; then OPTIONAL_BASES="${OPTIONAL_BASES} x11base x11term x11graph x11color" fi -dnl Add OS-dependent customizations. -DO_GCC_TESTS=no -case ${host_os} in -linux-gnu) - DO_GCC_TESTS=yes - ;; -freebsd*) - M4_FLAGS="${M4_FLAGS} -P SUPPRESS_LEADING_UNDERSCORE,1" - DO_GCC_TESTS=yes - ;; -dragonfly*) - M4_FLAGS="${M4_FLAGS} -P SUPPRESS_LEADING_UNDERSCORE,1" - DO_GCC_TESTS=yes - ;; -darwin*) - SCHEME_LDFLAGS="${SCHEME_LDFLAGS} -Wl,-pagezero_size,04000000" - MODULE_LDFLAGS="${MODULE_LDFLAGS} -bundle -flat_namespace -undefined suppress" - ;; -netbsd*) - DO_GCC_TESTS=yes - dnl NetBSD, by default, has programs find non-base libraries via RPATH - if test "x${x_libraries}" != x; then - FOO=-Wl,-rpath,`echo ${x_libraries} | sed -e "s/:/ -Wl,-rpath,/g"` - LDFLAGS="${LDFLAGS} ${FOO}" - fi - ;; -openbsd*) - M4_FLAGS="${M4_FLAGS} -P SUPPRESS_LEADING_UNDERSCORE,1" - DO_GCC_TESTS=yes - ;; -solaris*) - if test ${GCC} = yes; then - DO_GCC_TESTS=yes - M4_FLAGS="${M4_FLAGS} -P SUPPRESS_LEADING_UNDERSCORE,1" - fi - ;; -esac - -if test ${DO_GCC_TESTS} = yes; then - if test "x${STATIC_LIBS}" != x; then - STATIC_PREFIX="-Xlinker -Bstatic" - STATIC_SUFFIX="-Xlinker -Bdynamic" - fi - SCHEME_LDFLAGS="${SCHEME_LDFLAGS} -export-dynamic" - MODULE_CFLAGS="${MODULE_CFLAGS} -fPIC" - MODULE_LDFLAGS="${MODULE_LDFLAGS} -shared -fPIC" - AC_MSG_CHECKING([for ELF binaries]) - AC_RUN_IFELSE( - [AC_LANG_PROGRAM( - [[]], - [[ - #ifdef __ELF__ - return 0; - #endif - return 1; - ]] - )], - [ - AC_MSG_RESULT([yes]) - M4_FLAGS="${M4_FLAGS} -P SUPPRESS_LEADING_UNDERSCORE,1" - ], - [AC_MSG_RESULT([no])]) -fi - AC_MSG_CHECKING([for native-code support]) OPTIONAL_BASES="${OPTIONAL_BASES} cmpint cmpintmd comutl" GC_HEAD_FILES="gccode.h cmpgc.h cmpintmd-config.h cmpintmd.h" diff --git a/v7/src/microcode/confshared.h b/v7/src/microcode/confshared.h index a2ebe0f67..171ded7b9 100644 --- a/v7/src/microcode/confshared.h +++ b/v7/src/microcode/confshared.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: confshared.h,v 11.12 2007/04/22 16:31:22 cph Exp $ +$Id: confshared.h,v 11.13 2007/09/04 03:35:19 riastradh Exp $ Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, @@ -90,7 +90,7 @@ USA. # endif #endif -#if HAVE_STDBOOL_H +#ifdef HAVE_STDBOOL_H # include #else # if !HAVE__BOOL @@ -359,7 +359,7 @@ typedef enum #endif /* hp9000s500 */ -#ifdef sparc +#ifdef __sparc # define MACHINE_TYPE "sun4" # define CURRENT_FASL_ARCH FASL_SPARC # define FLOATING_ALIGNMENT 0x7 diff --git a/v7/src/microcode/unstackify.c b/v7/src/microcode/unstackify.c index 637d25514..ad9694346 100644 --- a/v7/src/microcode/unstackify.c +++ b/v7/src/microcode/unstackify.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: unstackify.c,v 11.5 2007/04/22 16:31:23 cph Exp $ +$Id: unstackify.c,v 11.6 2007/09/04 03:35:19 riastradh Exp $ Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, @@ -25,9 +25,11 @@ USA. */ +#include "config.h" + #include -#include #include + #define LIARC_IN_MICROCODE #include "liarc.h" #include "stackops.h" diff --git a/v7/src/microcode/ux.h b/v7/src/microcode/ux.h index 8ef442b6c..041533e33 100644 --- a/v7/src/microcode/ux.h +++ b/v7/src/microcode/ux.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: ux.h,v 1.85 2007/08/24 13:19:24 riastradh Exp $ +$Id: ux.h,v 1.86 2007/09/04 03:35:19 riastradh Exp $ Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, @@ -92,6 +92,10 @@ USA. # define SYSTEM_VARIANT "Pixel" #endif +#if defined(__sparc) && defined(__svr4__) +# define SYSTEM_VARIANT "Solaris" +#endif + #if defined(_SUNOS) || defined(_SUNOS3) || defined(_SUNOS4) # define SYSTEM_VARIANT "SunOS" #endif diff --git a/v7/src/microcode/uxtop.c b/v7/src/microcode/uxtop.c index 92b325684..a477cf461 100644 --- a/v7/src/microcode/uxtop.c +++ b/v7/src/microcode/uxtop.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: uxtop.c,v 1.36 2007/04/22 16:31:23 cph Exp $ +$Id: uxtop.c,v 1.37 2007/09/04 03:35:20 riastradh Exp $ Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, @@ -98,7 +98,7 @@ OS_initialize (void) OS_Name = SYSTEM_NAME; OS_Variant = SYSTEM_VARIANT; #if defined(_SUNOS) || defined(_SUNOS3) || defined(_SUNOS4) - vadvise (VA_ANOM); /* Anomolous paging, don't try to guess. */ + vadvise (VA_ANOM); /* Anomalous paging, don't try to guess. */ #endif } diff --git a/v7/src/microcode/uxtrap.h b/v7/src/microcode/uxtrap.h index 6afbb9f85..f4c50ddbd 100644 --- a/v7/src/microcode/uxtrap.h +++ b/v7/src/microcode/uxtrap.h @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: uxtrap.h,v 1.40 2007/08/24 13:19:24 riastradh Exp $ +$Id: uxtrap.h,v 1.41 2007/09/04 03:35:20 riastradh Exp $ Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, @@ -564,6 +564,81 @@ typedef struct #endif /* __alpha */ +#ifdef __sparc + +#ifdef __svr4__ +/* SPARC Solaris */ + +/* This is adapted from the MIPS SysV4 code above, + adjusted for the SPARC. */ + +#include +#include + +#define __SIGCONTEXT_REG(scp, ir) ((((scp) -> uc_mcontext) . gregs) [(ir)]) + +/* SIGINFO_T, SIGINFO_VALID_P, SIGINFO_CODE, SIGINFO_ARG_T, and SIGCONTEXT_T + are all defined by the conditional for _POSIX_REALTIME_SIGNALS below. */ + +#define HAVE_SIGCONTEXT +#define SIGCONTEXT_NREGS NGREG +#define SIGCONTEXT_FIRST_REG(scp) (& (__SIGCONTEXT_REG (scp, 0))) + +#define SIGCONTEXT_SP(scp) (__SIGCONTEXT_REG (scp, REG_SP)) +#define SIGCONTEXT_PC(scp) (__SIGCONTEXT_REG (scp, REG_PC)) + +/* I don't think that either of these actually matters for liarc, which + is all that we support on the SPARC at the moment. */ + +#define SIGCONTEXT_RFREE(scp) 0 +#define SIGCONTEXT_SCHSP(scp) 0 + +#define INITIALIZE_UX_SIGNAL_CODES() \ +{ \ + DECLARE_UX_SIGNAL_CODE \ + (SIGFPE, (~ 0L), FPE_INTDIV, "integer divide by 0 trap"); \ + DECLARE_UX_SIGNAL_CODE \ + (SIGFPE, (~ 0L), FPE_INTOVF, "integer overflow trap"); \ + DECLARE_UX_SIGNAL_CODE \ + (SIGFPE, (~ 0L), FPE_FLTDIV, "floating-point divide by 0 trap"); \ + DECLARE_UX_SIGNAL_CODE \ + (SIGFPE, (~ 0L), FPE_FLTOVF, "floating-point overflow trap"); \ + DECLARE_UX_SIGNAL_CODE \ + (SIGFPE, (~ 0L), FPE_FLTUND, "floating-point underflow trap"); \ + DECLARE_UX_SIGNAL_CODE \ + (SIGFPE, (~ 0L), FPE_FLTRES, "floating-point inexact result"); \ + DECLARE_UX_SIGNAL_CODE \ + (SIGFPE, (~ 0L), FPE_FLTSUB, "subscript-range trap"); \ + DECLARE_UX_SIGNAL_CODE \ + (SIGFPE, (~ 0L), FPE_FLTINV, "invalid floating-point operation"); \ + DECLARE_UX_SIGNAL_CODE \ + (SIGILL, (~ 0L), ILL_ILLOPC, "illegal opcode trap"); \ + DECLARE_UX_SIGNAL_CODE \ + (SIGILL, (~ 0L), ILL_ILLOPN, "illegal operand trap"); \ + DECLARE_UX_SIGNAL_CODE \ + (SIGILL, (~ 0L), ILL_ILLADR, "illegal addressing mode trap"); \ + DECLARE_UX_SIGNAL_CODE \ + (SIGILL, (~ 0L), ILL_ILLTRP, "illegal trap"); \ + DECLARE_UX_SIGNAL_CODE \ + (SIGILL, (~ 0L), ILL_PRVOPC, "privileged opcode trap"); \ + DECLARE_UX_SIGNAL_CODE \ + (SIGILL, (~ 0L), ILL_PRVREG, "privileged register trap"); \ + DECLARE_UX_SIGNAL_CODE \ + (SIGILL, (~ 0L), ILL_COPROC, "co-processor trap"); \ + DECLARE_UX_SIGNAL_CODE \ + (SIGILL, (~ 0L), ILL_BADSTK, "bad stack trap"); \ +} + +/* Solaris's siginfo(3HEAD) man page lists many more signal codes, but + so does Linux's sigaction(2) man page, and this is the same list as + in the Linux section. Unless this is used for anything other than + documentative purposes during trap recovery, then I can't imagine + why these lists aren't populated more completely. */ + +#endif /* __svr4__ */ + +#endif /* __sparc */ + #ifdef _POSIX_REALTIME_SIGNALS # define SIGINFO_T siginfo_t * # define SIGINFO_VALID_P(info) (1) -- 2.25.1