Return-Path: mikpe@majestix.ida.liu.se Received: by jove.pa.dec.com; id AA22826; Tue, 27 Feb 90 18:14:28 -0800 Received: by decpa.pa.dec.com; id AA02217; Tue, 27 Feb 90 18:13:51 -0800 Received: from majestix.ida.liu.se by sunic.sunet.se (5.61+IDA/KTH/LTH/1.119) id AAsunic26213; Wed, 28 Feb 90 02:32:59 +0100 Received: from mina.ida.liu.se by majestix.ida.liu.se; Wed, 28 Feb 90 02:32:57 +0100 Date: Wed, 28 Feb 90 02:32:57 +0100 From: Mikael Pettersson Message-Id: <9002280132.AA25609@majestix.ida.liu.se> To: bartlett Subject: Re: Scheme->C ported, non-portablities discovered Cc: mikpe@majestix.ida.liu.se Ok, the diffs are in the shell archive at the end of this mail. There are two files in it because I've found another Sun-related problem since my last mail. If one combines both the "-schf " and "-scgc 1" flags, then sc_restoreheap() will do some fprintf()-ing to stderr during heap reconstruction. This used to work because stderr was unbuffered; however, in SunOS stderr is line buffered. Ergo, there is some unwanted malloc-ing and the code fails in the first of the loops that picks stuff from the save.correct list. Easy to fix. Also, I wanted to build a small and fast compiler so I recompiled it with -Og to get rid of all that trace stuff. Unfortunately, there are two lines of "lap" in scrt/sceval.sc (function EXEC) that explicitly refer to the trace structure. I removed the corresponding lines from the C output by hand. /Mike #! /bin/sh # This is a shell archive. Remove anything before this line, then unpack # it by saving it into a file and typing "sh file". To overwrite existing # files, type "sh file -c". You can also feed this as standard input via # unshar, or by typing "sh fixes-sun3-1 <<'END_OF_fixes-sun3-1' Xdiff -rc /home/majestix/ida/mikpe/SchemeToC/SUN3 ./SUN3 X*** /home/majestix/ida/mikpe/SchemeToC/SUN3 Mon Feb 26 04:02:59 1990 X--- ./SUN3 Sun Feb 25 16:53:30 1990 X*************** X*** 0 **** X--- 1,29 ---- X+ # X+ # This is the header file for constructing make files for the Sun3 X+ # X+ X+ .SUFFIXES: X+ .SUFFIXES: .o .c .sc .s X+ X+ # Processor name: X+ X+ cpu = SUN3 X+ X+ # Default flags to use when invoking the C compiler. X+ X+ CFLAGS = -O X+ CC = cc X+ X+ # Assembly language object files. X+ X+ Aruntime = sun3.o X+ X+ # Profiled library X+ X+ Plib = X+ X+ # Heap size in megabytes for the compiler. X+ X+ scheapmb = 8 -scl 40 X+ X+ # End of Sun3 header. Xdiff -rc /home/majestix/ida/mikpe/SchemeToC/makefile ./makefile X*** /home/majestix/ida/mikpe/SchemeToC/makefile Fri Sep 15 04:44:47 1989 X--- ./makefile Mon Feb 26 21:23:58 1990 X*************** X*** 2,9 **** X # This file is used to make the Scheme->C system for multiple processor types. X # X X! SRCDIR = /wrl/Gen/src/schemetoc X X MIPSDIR = /wrl/pmax/src/schemetoc X MIPSBIN = /wrl/pmax/bin X MIPSLIB = /wrl/pmax/lib X--- 2,13 ---- X # This file is used to make the Scheme->C system for multiple processor types. X # X X! SRCDIR = /tmp/.mikpe X X+ SUN3DIR = /tmp/.mikpe/sun3 X+ SUN3BIN = /tmp/.mikpe/sun3/bin X+ SUN3LIB = /tmp/.mikpe/sun3/lib X+ X MIPSDIR = /wrl/pmax/src/schemetoc X MIPSBIN = /wrl/pmax/bin X MIPSLIB = /wrl/pmax/lib X*************** X*** 62,67 **** X--- 66,75 ---- X echo "LIBDIR = ${LIBDIR}" >> ${CPUDIR}/test/makefile X cat test/makefile-tail >> ${CPUDIR}/test/makefile X -cd ${CPUDIR}/test; make srclinks X+ X+ forSUN3: X+ make "CPU=SUN3" "CPUDIR=${SUN3DIR}" \ X+ "BINDIR=${SUN3BIN}" "LIBDIR=${SUN3LIB}" forCPU X X forMIPS: X make "CPU = MIPS" "CPUDIR = ${MIPSDIR}" \ Xdiff -rc /home/majestix/ida/mikpe/SchemeToC/scrt/apply.h ./scrt/apply.h X*** /home/majestix/ida/mikpe/SchemeToC/scrt/apply.h Fri Feb 23 02:46:36 1990 X--- ./scrt/apply.h Sun Feb 25 18:54:18 1990 X*************** X*** 44,49 **** X--- 44,53 ---- X by the compiler to call unknown functions. X */ X X+ #ifdef SUN3 X+ #define MAXARGS 25 X+ #endif X+ X #ifdef MIPS X #define MAXARGS 25 /* Maximum number of required arguments permitted. X Note that this does not preclude an optional Xdiff -rc /home/majestix/ida/mikpe/SchemeToC/scrt/heap.c ./scrt/heap.c X*** /home/majestix/ida/mikpe/SchemeToC/scrt/heap.c Fri Feb 23 02:47:13 1990 X--- ./scrt/heap.c Mon Feb 26 21:45:05 1990 X*************** X*** 43,48 **** X--- 43,56 ---- X X /* Import definitions */ X X+ #ifndef rusage X+ #ifdef SUN3 X+ #include X+ #else X+ #include X+ #endif X+ #include X+ #endif X #include "objects.h" X #include "scinit.h" X #include "heap.h" X*************** X*** 52,57 **** X--- 60,68 ---- X #ifdef GGC X #include "GGC.h" X #endif X+ #ifdef SUN3 X+ extern sc_a2to5d2to7(); X+ #endif X #ifdef MIPS X extern sc_s0tos8(); X #endif X*************** X*** 380,386 **** X--- 391,422 ---- X } X #endif MIPS X X+ #ifdef SUN3 X+ /* The following code is used to read the stack pointer. The register X+ number is passed in to force an argument to be on the stack, which in X+ turn can be used to find the address of the top of stack. X+ */ X X+ int *sc_processor_register( reg ) X+ int reg; X+ { X+ return( ®+1 ); X+ } X+ X+ /* All processor registers which might contain pointers are traced by the X+ following procedure. X+ */ X+ X+ static trace_stack_and_registers() X+ { X+ int i, a2to5d2to7[10], *pp; X+ X+ sc_a2to5d2to7( a2to5d2to7 ); X+ pp = STACKPTR; X+ while (pp != sc_stackbase) move_continuation_ptr( *pp++ ); X+ } X+ #endif SUN3 X+ X /* The size of an extended object in words is returned by the following X function. X */ X*************** X*** 1514,1520 **** X pp = sc_extobjp; X sc_extobjp = (SCP)(((int*)sc_extobjp)+FLOAT32SIZE); X sc_extobjwords = sc_extobjwords-FLOAT32SIZE; X! pp->unsi.gned = FLOAT32TAG; X } X else X pp = sc_allocateheap( FLOAT32SIZE, FLOAT32TAG, 0 ); X--- 1550,1556 ---- X pp = sc_extobjp; X sc_extobjp = (SCP)(((int*)sc_extobjp)+FLOAT32SIZE); X sc_extobjwords = sc_extobjwords-FLOAT32SIZE; X! pp->unsi.gned = UNSI_TAG( FLOAT32TAG ); X } X else X pp = sc_allocateheap( FLOAT32SIZE, FLOAT32TAG, 0 ); X*************** X*** 1539,1545 **** X pp = sc_extobjp; X sc_extobjp = (SCP)(((int*)sc_extobjp)+FLOAT64SIZE); X sc_extobjwords = sc_extobjwords-FLOAT64SIZE; X! pp->unsi.gned = FLOAT64TAG; X } X else X pp = sc_allocateheap( FLOAT64SIZE, FLOAT64TAG, 0 ); X--- 1575,1581 ---- X pp = sc_extobjp; X sc_extobjp = (SCP)(((int*)sc_extobjp)+FLOAT64SIZE); X sc_extobjwords = sc_extobjwords-FLOAT64SIZE; X! pp->unsi.gned = UNSI_TAG( FLOAT64TAG ); X } X else X pp = sc_allocateheap( FLOAT64SIZE, FLOAT64TAG, 0 ); Xdiff -rc /home/majestix/ida/mikpe/SchemeToC/scrt/heap.h ./scrt/heap.h X*** /home/majestix/ida/mikpe/SchemeToC/scrt/heap.h Fri Feb 23 02:47:07 1990 X--- ./scrt/heap.h Sun Feb 25 19:41:49 1990 X*************** X*** 39,51 **** X * SOFTWARE. X */ X X- /* Import definitions */ X- X- #ifndef rusage X- #include X- #include X- #endif X- X /* This module implements the object storage storage system for SCHEME->C. X X Unlike most Lisp systems, it is not intended that SCHEME->C provide a X--- 39,44 ---- X*************** X*** 306,311 **** X--- 299,308 ---- X */ X X extern int *sc_stackbase; X+ X+ #ifdef SUN3 X+ #define STACKPTR sc_processor_register( 15 ) X+ #endif X X #ifdef MIPS X #define STACKPTR sc_processor_register( 29 ) Xdiff -rc /home/majestix/ida/mikpe/SchemeToC/scrt/makefile-tail ./scrt/makefile-tail X*** /home/majestix/ida/mikpe/SchemeToC/scrt/makefile-tail Thu Apr 20 02:47:01 1989 X--- ./scrt/makefile-tail Mon Feb 26 19:22:28 1990 X*************** X*** 34,40 **** X scqquote.sc screp.sc \ X scrt1.sc scrt2.sc scrt3.sc scrt4.sc scrt5.sc scrt6.sc scrt7.sc X X! Smisc = GGC.c GGC.h GGCprivate.h mips.s predef.sc repdef.sc sci.sc sci.c vax.s X X ${Sruntimec} sci.c: ${predef.sc} ${objects.h} X X--- 34,41 ---- X scqquote.sc screp.sc \ X scrt1.sc scrt2.sc scrt3.sc scrt4.sc scrt5.sc scrt6.sc scrt7.sc X X! Smisc = GGC.c GGC.h GGCprivate.h mips.s predef.sc repdef.sc sci.sc sci.c \ X! vax.s sun3.s X X ${Sruntimec} sci.c: ${predef.sc} ${objects.h} X Xdiff -rc /home/majestix/ida/mikpe/SchemeToC/scrt/objects.h ./scrt/objects.h X*** /home/majestix/ida/mikpe/SchemeToC/scrt/objects.h Fri Feb 23 02:47:22 1990 X--- ./scrt/objects.h Mon Feb 26 22:01:13 1990 X*************** X*** 44,52 **** X--- 44,56 ---- X X /* Default the value of CPUTYPE if not currently defined. */ X X+ #ifndef SUN3 X #ifndef MIPS X #ifndef TITAN X #ifndef VAX X+ #ifdef sun3 X+ #define SUN3 1 X+ #endif X #ifdef mips X #define MIPS 1 X #endif X*************** X*** 59,64 **** X--- 63,69 ---- X #endif X #endif X #endif X+ #endif X X /* The Scheme->C installer may elect to have arithmetic overflow handled X gracefully on either the MIPS or the VAX implementations. The default X*************** X*** 65,70 **** X--- 70,78 ---- X is to handle it. X */ X X+ #ifdef SUN3 X+ #define MATHTRAPS 0 X+ #endif X #ifndef MATHTRAPS X #define MATHTRAPS 1 X #endif X*************** X*** 71,76 **** X--- 79,89 ---- X X /* A machine dependent definition: the setjmp/longjmp buffer. */ X X+ #ifdef SUN3 X+ #include X+ #define CPUTYPE SUN3 X+ #endif X+ X #ifdef MIPS X #include X #define CPUTYPE MIPS X*************** X*** 151,158 **** X--- 164,178 ---- X } vector; X struct { /* PROCEDURE */ X unsigned tag:8; X+ #ifdef SUN3 X+ /* if you change this, remember to fix sc_makeprocedure() */ X+ /* and the UNKNOWNCALL() macro */ X+ unsigned optional:16; X+ unsigned required:8; X+ #else X unsigned required:8; X unsigned optional:16; X+ #endif X TSCP (*code)(); X TSCP closure; X } procedure; X*************** X*** 202,207 **** X--- 222,231 ---- X #define U_TX( scp ) ((TSCP)((char*)(scp)+EXTENDEDTAG)) X #define U_TP( scp ) ((TSCP)((char*)(scp)+PAIRTAG)) X #define T_U( tscp ) ((SCP)((int)(tscp) & (~TAGMASK))) X+ #ifdef SUN3 X+ #define TX_U( tscp ) ((SCP)((char*)tscp-EXTENDEDTAG)) X+ #define TP_U( tscp ) ((SCP)((char*)tscp-PAIRTAG)) X+ #endif X #ifdef MIPS X #define TX_U( tscp ) ((SCP)((char*)tscp-EXTENDEDTAG)) X #define TP_U( tscp ) ((SCP)((char*)tscp-PAIRTAG)) X*************** X*** 701,706 **** X--- 725,733 ---- X #define STRING_CHAR( tscp, n ) (*(((char*)tscp)+FIXED_C( n )+3)) X X #define VECTOR_LENGTH( tscp ) (TX_U( tscp )->vector.length) X+ #ifdef SUN3 X+ #define VECTOR_ELEMENT( tscp, n ) (*((PATSCP)(((char*)( tscp ))+3+((int)n)))) X+ #endif X #ifdef MIPS X #define VECTOR_ELEMENT( tscp, n ) (*((PATSCP)(((char*)( tscp ))+3+((int)n)))) X #endif X*************** X*** 866,876 **** X--- 893,917 ---- X #define TRUE( x ) ((((int)(x)) & 247) != 2) X #define FALSE( x ) ((((int)(x)) & 247) == 2) X X+ /* fix for pp->unsi.gned = unportability */ X+ #ifdef SUN3 X+ #define UNSI_TAG(x) ((x) << 24) X+ #else X+ #define UNSI_TAG(x) (x) X+ #endif X+ X /* Short circuiting for procedure application. In order for this code X to work correctly, it requires that the tag field be in the least X significant 8 bits of the extended object header. X */ X X+ #ifdef SUN3 X+ #define UNKNOWNCALL( proc, argc ) \ X+ (sc_unknownargc = (argc), \ X+ sc_unknownproc[1] = (proc), \ X+ sc_unknownproc[UNSI_GNED(sc_unknownproc[TSCPTAG(proc)]) \ X+ == UNSI_TAG(PROCEDURETAG)+(argc)]) X+ #else X #define UNKNOWNCALL( proc, argc ) (sc_unknownargc = argc, \ X sc_unknownproc[ 1 ] = proc, \ X sc_unknownproc[ \ X*************** X*** 877,882 **** X--- 918,924 ---- X (UNSI_GNED( \ X sc_unknownproc[ TSCPTAG( proc ) ] ) \ X == (argc*256+PROCEDURETAG)) ]) X+ #endif X X /* Inline type conversions */ X Xdiff -rc /home/majestix/ida/mikpe/SchemeToC/scrt/scinit.c ./scrt/scinit.c X*** /home/majestix/ida/mikpe/SchemeToC/scrt/scinit.c Fri Feb 23 02:47:40 1990 X--- ./scrt/scinit.c Mon Feb 26 21:46:54 1990 X*************** X*** 53,58 **** X--- 53,64 ---- X extern errno; /* C-library Error flag */ X X extern etext; X+ #ifdef SUN3 X+ #define ETEXT ((int)&etext) /* First address after text */ X+ #include X+ #include X+ #define STACKBASE (int*)USRSTACK X+ #endif X #ifdef MIPS X #define ETEXT ((int)&etext) /* First address after text */ X #include X*************** X*** 96,103 **** X X /* Global data structure for this module. */ X X! static int emptyvector = VECTORTAG, X! emptystring[2] = {STRINGTAG, 0}; X X FILE *sc_stdin, /* Standard I/O Subroutine FILE pointers */ X *sc_stdout, X--- 102,109 ---- X X /* Global data structure for this module. */ X X! static int emptyvector = UNSI_TAG( VECTORTAG ), X! emptystring[2] = {UNSI_TAG( STRINGTAG ), 0}; X X FILE *sc_stdin, /* Standard I/O Subroutine FILE pointers */ X *sc_stdout, X*************** X*** 717,722 **** X--- 723,731 ---- X sc_cons( X sc_cstringtostring( "23feb90jfb" ), X sc_cons( X+ #ifdef SUN3 X+ sc_cstringtostring( "Sun-3" ), X+ #endif X #ifdef MIPS X sc_cstringtostring( "DECstation3100" ), X #endif X*************** X*** 727,732 **** X--- 736,744 ---- X sc_cstringtostring( "VAX" ), X #endif X sc_cons( X+ #ifdef SUN3 X+ sc_cstringtostring( "M68020" ), X+ #endif X #ifdef MIPS X sc_cstringtostring( "R2000" ), X #endif X*************** X*** 737,743 **** X--- 749,759 ---- X sc_cstringtostring( "VAX" ), X #endif X sc_cons( X+ #ifdef SUN3 X+ sc_cstringtostring( "SunOS" ), X+ #else X sc_cstringtostring( "ULTRIX" ), X+ #endif X sc_cons( X FALSEVALUE, X EMPTYLIST Xdiff -rc /home/majestix/ida/mikpe/SchemeToC/scrt/sun3.s ./scrt/sun3.s X*** /home/majestix/ida/mikpe/SchemeToC/scrt/sun3.s Mon Feb 26 04:03:19 1990 X--- ./scrt/sun3.s Sun Feb 25 22:23:40 1990 X*************** X*** 0 **** X--- 1,69 ---- X+ | X+ | SCHEME->C X+ | X+ | Sun3 assembly code. X+ | X+ X+ | X+ | Copyright 1989 Digital Equipment Corporation X+ | All Rights Reserved X+ | X+ | Permission to use, copy, and modify this software and its documentation is X+ | hereby granted only under the following terms and conditions. Both the X+ | above copyright notice and this permission notice must appear in all copies X+ | of the software, derivative works or modified versions, and any portions X+ | thereof, and both notices must appear in supporting documentation. X+ | X+ | Users of this software agree to the terms and conditions set forth herein, X+ | and hereby grant back to Digital a non-exclusive, unrestricted, royalty-free X+ | right and license under any changes, enhancements or extensions made to the X+ | core functions of the software, including but not limited to those affording X+ | compatibility with other hardware or software environments, but excluding X+ | applications which incorporate this software. Users further agree to use X+ | their best efforts to return to Digital any such changes, enhancements or X+ | extensions that they make and inform Digital of noteworthy uses of this X+ | software. Correspondence should be provided to Digital at: X+ | X+ | Director of Licensing X+ | Western Research Laboratory X+ | Digital Equipment Corporation X+ | 100 Hamilton Avenue X+ | Palo Alto, California 94301 X+ | X+ | This software may be distributed (but not offered for sale or transferred X+ | for compensation) to third parties, provided such third parties agree to X+ | abide by the terms and conditions of this notice. X+ | X+ | THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL X+ | WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF X+ | MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT X+ | CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL X+ | DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR X+ | PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS X+ | ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS X+ | SOFTWARE. X+ | X+ X+ | X+ | sc_a2to5d2to7 X+ | X+ | sc_a2to5d2to7( a ) X+ | will return the contents of A2, ..., A5, D2, ..., D7 starting at address 'a'. X+ | X+ | X+ .text X+ .globl _sc_a2to5d2to7 X+ .even X+ _sc_a2to5d2to7: X+ movl sp@(4),a0 X+ movl a2,a0@(0) X+ movl a3,a0@(4) X+ movl a4,a0@(8) X+ movl a5,a0@(12) X+ movl d2,a0@(16) X+ movl d3,a0@(20) X+ movl d4,a0@(24) X+ movl d5,a0@(28) X+ movl d6,a0@(32) X+ movl d7,a0@(36) X+ rts Xdiff -rc /home/majestix/ida/mikpe/SchemeToC/scsc/main.sc ./scsc/main.sc X*** /home/majestix/ida/mikpe/SchemeToC/scsc/main.sc Fri Feb 23 02:58:20 1990 X--- ./scsc/main.sc Tue Feb 27 00:00:12 1990 X*************** X*** 67,73 **** X X (define-c-external (getpid) int "getpid") X X! (define SCC-VERSION "23feb90jfb") X ; Compiler version string. X X (define FORCE-LD-OF-REP read-eval-print) X--- 67,73 ---- X X (define-c-external (getpid) int "getpid") X X! (define SCC-VERSION "27feb90mpe") X ; Compiler version string. X X (define FORCE-LD-OF-REP read-eval-print) X*************** X*** 81,87 **** X ;;; The following top-level variables define the implementation dependent X ;;; information: X X! (define PREDEF-DEFAULT "/udir/bartlett/scheme/scrt/predef.sc") X ; File holding the declarations for predefined X ; functions. X X--- 81,87 ---- X ;;; The following top-level variables define the implementation dependent X ;;; information: X X! (define PREDEF-DEFAULT "/home/majestix/ida/mikpe/sc2c/predef.sc") X ; File holding the declarations for predefined X ; functions. X X*************** X*** 88,104 **** X (define C-INCLUDE-FILE "objects.h") X ; #include file for the predefined functions. X X! (define C-INCLUDE-DIR "/udir/bartlett/scheme/scrt") X ; directory containing #include file for X ; predefined functions. X X! (define SC-LIBRARY "/udir/bartlett/scheme/scrt/libsc.a") X ; Scheme->C library file. X X! (define SC-LIBRARY_P "/udir/bartlett/scheme/scrt/libsc.a") X ; Scheme->C profiled library file. X X! (define SC-PROCESSOR "TITAN") ; Processor type. X X ;;; The compiler is "configured" and the heap image is saved by the following X ;;; function. It will set the previously defined variables to the values X--- 88,104 ---- X (define C-INCLUDE-FILE "objects.h") X ; #include file for the predefined functions. X X! (define C-INCLUDE-DIR "/home/majestix/ida/mikpe/sc2c") X ; directory containing #include file for X ; predefined functions. X X! (define SC-LIBRARY "/home/majestix/ida/mikpe/sc2c/libsc.a") X ; Scheme->C library file. X X! (define SC-LIBRARY_P "/home/majestix/ida/mikpe/sc2c/libsc.a") X ; Scheme->C profiled library file. X X! (define SC-PROCESSOR "SUN3") ; Processor type. X X ;;; The compiler is "configured" and the heap image is saved by the following X ;;; function. It will set the previously defined variables to the values END_OF_fixes-sun3-1 if test 17106 -ne `wc -c fixes-sun3-2 <<'END_OF_fixes-sun3-2' X*** scrt/scinit.c.~1~ Mon Feb 26 21:46:54 1990 X--- scrt/scinit.c Tue Feb 27 22:38:50 1990 X*************** X*** 559,564 **** X--- 559,569 ---- X if (scheap < save.heappages/(ONEMB/PAGEBYTES)) X scheap = save.heappages/(ONEMB/PAGEBYTES); X if (sclimit < save.limit) sclimit = save.limit; X+ #ifdef SUN3 X+ /* in SunOS, stderr is line buffered, which causes some unwanted malloc.. */ X+ if (sc_gcinfo) X+ setbuf(stderr, (char*)0); X+ #endif X if (sc_gcinfo) X fprintf( stderr, "***** SCGCINFO = %d SCHEAP = %d SCLIMIT = %d\n", X sc_gcinfo, scheap, sclimit ); END_OF_fixes-sun3-2 if test 578 -ne `wc -c