diff -urN ezm3-1.1.orig/language/modula3/m3compiler/m3middle/src/Target.m3 ezm3-1.1/language/modula3/m3compiler/m3middle/src/Target.m3 --- ezm3-1.1.orig/language/modula3/m3compiler/m3middle/src/Target.m3 2004-02-14 22:17:45.000000000 -0500 +++ ezm3-1.1/language/modula3/m3compiler/m3middle/src/Target.m3 2004-02-14 22:18:51.000000000 -0500 @@ -17,7 +17,7 @@ AIX386, ALPHA_OSF, AP3000, ARM, BSDI4, DS3100, FBSD_ALPHA, FBSD_SPARC64, FreeBSD, FreeBSD2, FreeBSD3, FreeBSD4, HP300, HPPA, IBMR2, - IBMRT, IRIX5, LINUX, LINUXELF, LINUXLIBC6, + IBMRT, IRIX5, LINUX, LINUXELF, LINUXLIBC6, LINUXSPARC, NetBSDarm, NetBSDi386, NetBSDsparc, NEXT, NT386, NT386GNU, OKI, OpenBSD_386, SEQUENT, SOLgnu, SOLsun, SPARC, SUN3, SUN386, Tru64v5, @@ -29,7 +29,7 @@ "AIX386", "ALPHA_OSF", "AP3000", "ARM", "BSDI4", "DS3100", "FBSD_ALPHA", "FBSD_SPARC64", "FreeBSD", "FreeBSD2", "FreeBSD3", "FreeBSD4", "HP300", "HPPA", "IBMR2", - "IBMRT", "IRIX5", "LINUX", "LINUXELF", "LINUXLIBC6", + "IBMRT", "IRIX5", "LINUX", "LINUXELF", "LINUXLIBC6", "LINUXSPARC", "NetBSDarm", "NetBSDi386", "NetBSDsparc", "NEXT", "NT386", "NT386GNU", "OKI", "OpenBSD_386", "SEQUENT", "SOLgnu", "SOLsun", "SPARC", "SUN3", "SUN386", "Tru64v5", @@ -533,6 +533,25 @@ LINUXELFCall (0, "C", 0); END; + | Systems.LINUXSPARC => + max_align := 64; + Little_endian := FALSE; + PCC_bitfield_type_matters := TRUE; + Structure_size_boundary := 8; + Bitfield_can_overlap := FALSE; + First_readable_addr := 0; (* 8192 * Char.size; *) + Jumpbuf_size := 10 * Address.size; + Jumpbuf_align := Address.align; + Fixed_frame_size := 8 * Address.size; + Guard_page_size := 0 * Char.size; + All_floats_legal := TRUE; + Has_stack_walker := FALSE; + Setjmp := "_setjmp"; + Checks_integer_ops := FALSE; + Global_handler_stack := TRUE; + Aligned_procedures := FALSE; + EOL := "\n"; + | Systems.NEXT => max_align := 16; Little_endian := FALSE; diff -urN ezm3-1.1.orig/libs/libm3/src/random/m3makefile ezm3-1.1/libs/libm3/src/random/m3makefile --- ezm3-1.1.orig/libs/libm3/src/random/m3makefile 2004-02-14 22:17:45.000000000 -0500 +++ ezm3-1.1/libs/libm3/src/random/m3makefile 2004-02-14 22:19:28.000000000 -0500 @@ -32,6 +32,7 @@ "LINUX" : [ _LittleEndian ], "LINUXELF" : [ _LittleEndian ], "LINUXLIBC6" : [ _LittleEndian ], + "LINUXSPARC" : [ _BigEndian ], "NetBSDarm" : [ _LittleEndian ], "NetBSDi386" : [ _LittleEndian ], "NetBSDsparc": [ _BigEndian ], diff -urN ezm3-1.1.orig/libs/m3core/src/C/LINUXSPARC/Csetjmp.i3 ezm3-1.1/libs/m3core/src/C/LINUXSPARC/Csetjmp.i3 --- ezm3-1.1.orig/libs/m3core/src/C/LINUXSPARC/Csetjmp.i3 1969-12-31 19:00:00.000000000 -0500 +++ ezm3-1.1/libs/m3core/src/C/LINUXSPARC/Csetjmp.i3 2004-02-14 22:22:47.000000000 -0500 @@ -0,0 +1,19 @@ +(* Copyright (C) 1990, Digital Equipment Corporation *) +(* All rights reserved. *) +(* See the file COPYRIGHT for a full description. *) + +(* Last modified on Fri Apr 30 16:25:40 PDT 1993 by muller *) + +INTERFACE Csetjmp; (* for LINUX *) + +FROM Ctypes IMPORT int; + +TYPE jmp_buf = ARRAY [0..9] OF int; + +<*EXTERNAL*> PROCEDURE setjmp (VAR env: jmp_buf): int; +<*EXTERNAL*> PROCEDURE longjmp (VAR env: jmp_buf; val: int); + +<*EXTERNAL "_setjmp" *> PROCEDURE usetjmp (VAR env: jmp_buf): int; +<*EXTERNAL "_longjmp" *> PROCEDURE ulongjmp (VAR env: jmp_buf; val: int); + +END Csetjmp. diff -urN ezm3-1.1.orig/libs/m3core/src/C/LINUXSPARC/Csignal.i3 ezm3-1.1/libs/m3core/src/C/LINUXSPARC/Csignal.i3 --- ezm3-1.1.orig/libs/m3core/src/C/LINUXSPARC/Csignal.i3 1969-12-31 19:00:00.000000000 -0500 +++ ezm3-1.1/libs/m3core/src/C/LINUXSPARC/Csignal.i3 2004-02-14 22:26:26.000000000 -0500 @@ -0,0 +1,17 @@ +(* Copyright (C) 1992, Digital Equipment Corporation *) +(* All rights reserved. *) +(* See the file COPYRIGHT for a full description. *) +(* *) +(* Last modified on Tue May 4 10:06:17 PDT 1993 by muller *) + +INTERFACE Csignal; + +FROM Ctypes IMPORT int; + +TYPE + Handler = PROCEDURE (s: int); + +<*EXTERNAL*> +PROCEDURE signal (sig: int; func: Handler): Handler; + +END Csignal. diff -urN ezm3-1.1.orig/libs/m3core/src/C/LINUXSPARC/Cstdio.i3 ezm3-1.1/libs/m3core/src/C/LINUXSPARC/Cstdio.i3 --- ezm3-1.1.orig/libs/m3core/src/C/LINUXSPARC/Cstdio.i3 1969-12-31 19:00:00.000000000 -0500 +++ ezm3-1.1/libs/m3core/src/C/LINUXSPARC/Cstdio.i3 2004-02-14 22:25:47.000000000 -0500 @@ -0,0 +1,70 @@ +(* Copyright (C) 1995, Digital Equipment Corporation. *) +(* All rights reserved. *) +(* See the file COPYRIGHT for a full description. *) +(* *) +(* Last modified on Mon Feb 27 08:51:20 PST 1995 by kalsow *) +(* modified on Thu May 6 09:18:19 PDT 1993 by muller *) + +INTERFACE Cstdio; + +FROM Ctypes IMPORT char, int, long, char_star, unsigned_short, void_star; + +CONST + NIOBRW = 3; + IOEOF = 8_20; + +TYPE (* The C declarations prefix these fields with "_" *) + FILE = RECORD + flags: int; (* High-order word is _IO_MAGIC; rest is flags. *) + (* C #define's "_IO_file_flags" to be "flags" *) + + (* The following pointers correspond to the C++ streambuf protocol. *) + IO_read_ptr : char_star; (* Current read pointer *) + IO_read_end : char_star; (* End of get area. *) + IO_read_base : char_star; (* Start of putback+get area. *) + IO_write_base : char_star; (* Start of put area. *) + IO_write_ptr : char_star; (* Current put pointer. *) + IO_write_end : char_star; (* End of put area. *) + IO_buf_base : char_star; (* Start of reserve area. *) + IO_buf_end : char_star; (* End of reserve area. *) + + (* The following fields are used to support backing up and undo. *) + IO_save_base : char_star; (* Pointer to start of non-current get area. *) + IO_backup_base : char_star; (* Pointer to first valid char in backup *) + IO_save_end : char_star; (* Pointer to end of non-current get area. *) + + markers : IO_marker_star; + chain : FILE_star; + (* No longer present in GNU libc *) + (* jumps : IO_jump_t_star; (* Jump table *)*) + fileno : int; + blksize : int; + offset : long; (* _IO_off_t is same?? *) + + (*** #define __HAVE_COLUMN (* temporary *) ***) + (* 1+column number of pbase(); 0 is unknown. *) + cur_column : unsigned_short; + unused : char; + shortbuf : ARRAY [0..0] OF char; + + lock : void_star; (* Actually an _IO_lock_t * *) + (* char* _save_gptr; char* _save_egptr; *) + END; + + FILE_star = UNTRACED REF FILE; + IO_jump_t_star = ADDRESS; (* UNTRACED REF IO_jump_t ??*) + IO_marker_star = ADDRESS; (* UNTRACED REF IO_marker ??*) + +VAR iob: ARRAY [0..NIOBRW-1] OF FILE_star; + +<*EXTERNAL "_IO_stdin_"*> VAR stdin_file: FILE; +<*EXTERNAL "_IO_stdout_"*> VAR stdout_file: FILE; +<*EXTERNAL "_IO_stderr_"*> VAR stderr_file: FILE; + +<*EXTERNAL feof*> PROCEDURE feof (f: FILE_star): int; +<*EXTERNAL getc*> PROCEDURE getc (f: FILE_star): int; +<*EXTERNAL ungetc*> PROCEDURE ungetc (c: int; f: FILE_star): int; +<*EXTERNAL putc*> PROCEDURE putc (c: int; f: FILE_star): int; +<*EXTERNAL fflush*> PROCEDURE fflush (f: FILE_star): int; + +END Cstdio. diff -urN ezm3-1.1.orig/libs/m3core/src/C/LINUXSPARC/Cstdio.m3 ezm3-1.1/libs/m3core/src/C/LINUXSPARC/Cstdio.m3 --- ezm3-1.1.orig/libs/m3core/src/C/LINUXSPARC/Cstdio.m3 1969-12-31 19:00:00.000000000 -0500 +++ ezm3-1.1/libs/m3core/src/C/LINUXSPARC/Cstdio.m3 2004-02-15 00:40:36.000000000 -0500 @@ -0,0 +1,13 @@ +(* Copyright (C) 1992, Digital Equipment Corporation *) +(* All rights reserved. *) +(* See the file COPYRIGHT for a full description. *) +(* *) +(* Last modified on Thu May 6 09:24:47 PDT 1993 by muller *) + +UNSAFE MODULE Cstdio; + +BEGIN + iob[0] := ADR (stdin_file); + iob[1] := ADR (stdout_file); + iob[2] := ADR (stderr_file); +END Cstdio. diff -urN ezm3-1.1.orig/libs/m3core/src/C/LINUXSPARC/Cstring.i3 ezm3-1.1/libs/m3core/src/C/LINUXSPARC/Cstring.i3 --- ezm3-1.1.orig/libs/m3core/src/C/LINUXSPARC/Cstring.i3 1969-12-31 19:00:00.000000000 -0500 +++ ezm3-1.1/libs/m3core/src/C/LINUXSPARC/Cstring.i3 2004-02-14 22:24:57.000000000 -0500 @@ -0,0 +1,88 @@ +(* Copyright (C) 1989, Digital Equipment Corporation *) +(* All rights reserved. *) +(* See the file COPYRIGHT for a full description. *) + +(* File: Cstring.i3 *) +(* Last modified on Tue Apr 20 20:16:18 PDT 1993 by muller *) +(* modified on Sat Jan 20 22:31:44 1990 by jerome *) + + +INTERFACE Cstring; + +FROM Ctypes IMPORT char_star, const_char_star, const_void_star, + int, void_star, unsigned_long; + + +TYPE + size_t = unsigned_long; + +<*EXTERNAL*> +PROCEDURE memchr (s: const_void_star; c: int; n: size_t): void_star; + +<*EXTERNAL*> +PROCEDURE memcpy (s1: void_star; s2: const_void_star; n: size_t): void_star; + +<*EXTERNAL*> +PROCEDURE memset (s: void_star; c: int; n: size_t): void_star; + +<*EXTERNAL*> +PROCEDURE memcmp (s1: const_void_star; s2: const_void_star; n: size_t): int; + +<*EXTERNAL*> +PROCEDURE strcpy (s1: char_star; s2: const_char_star): char_star; + +<*EXTERNAL*> +PROCEDURE strncpy (s1: char_star; s2: const_char_star; n: size_t): char_star; + +<*EXTERNAL*> +PROCEDURE strcat (s1: char_star; s2: const_char_star): char_star; + +<*EXTERNAL*> +PROCEDURE strncat (s1: char_star; s2: const_char_star; n: size_t): char_star; + +<*EXTERNAL*> +PROCEDURE strchr (s: const_char_star; c: int): char_star; + +<*EXTERNAL*> +PROCEDURE strrchr (s: const_char_star; c: int): char_star; + +<*EXTERNAL*> +PROCEDURE strpbrk (s1: const_char_star; s2: const_char_star): char_star; + +<*EXTERNAL*> +PROCEDURE strtok (s1: char_star; s2: const_char_star): char_star; + +<*EXTERNAL*> +PROCEDURE strcmp (s1: const_char_star; s2: const_char_star): int; + +<*EXTERNAL*> +PROCEDURE strncmp (s1: const_char_star; s2: const_char_star; n: size_t): int; + +<*EXTERNAL*> +PROCEDURE strlen (s: const_char_star): size_t; + +<*EXTERNAL*> +PROCEDURE strspn (s1: const_char_star; s2: const_char_star): int; + +<*EXTERNAL*> +PROCEDURE strcspn (s1: const_char_star; s2: const_char_star): size_t; + +<*EXTERNAL*> +PROCEDURE memmove (s1: void_star; s2: const_void_star; n: size_t): void_star; + +<*EXTERNAL*> +PROCEDURE strcoll (s1: const_char_star; s2: const_char_star): int; + +(* +<*EXTERNAL*> +PROCEDURE strxrfm (s1: char_star; s2: const_char_star; n: size_t): size_t; +*) + +<*EXTERNAL*> +PROCEDURE strstr (s1: const_char_star; s2: const_char_star): char_star; + +<*EXTERNAL*> +PROCEDURE strerror (errnum: int): char_star; + +END Cstring. + diff -urN ezm3-1.1.orig/libs/m3core/src/C/LINUXSPARC/m3makefile ezm3-1.1/libs/m3core/src/C/LINUXSPARC/m3makefile --- ezm3-1.1.orig/libs/m3core/src/C/LINUXSPARC/m3makefile 1969-12-31 19:00:00.000000000 -0500 +++ ezm3-1.1/libs/m3core/src/C/LINUXSPARC/m3makefile 2004-02-14 22:26:36.000000000 -0500 @@ -0,0 +1,15 @@ +% Copyright (C) 1992, Digital Equipment Corporation +% All rights reserved. +% See the file COPYRIGHT for a full description. + +% Last modified on Fri Jun 18 13:20:32 PDT 1993 by harrison +% modified on Thu May 6 13:16:32 PDT 1993 by muller + +Interface ("Csetjmp") +Interface ("Csignal") +Interface ("Cstring") + +Module ("Cstdio") + +%s_source("CsetjmpASM") + diff -urN ezm3-1.1.orig/libs/m3core/src/Csupport/LINUXSPARC/dtoa.c ezm3-1.1/libs/m3core/src/Csupport/LINUXSPARC/dtoa.c --- ezm3-1.1.orig/libs/m3core/src/Csupport/LINUXSPARC/dtoa.c 1969-12-31 19:00:00.000000000 -0500 +++ ezm3-1.1/libs/m3core/src/Csupport/LINUXSPARC/dtoa.c 2004-02-15 00:41:55.000000000 -0500 @@ -0,0 +1,14 @@ +/* Copyright (C) 1992, Digital Equipment Corporation */ +/* All rights reserved. */ +/* See the file COPYRIGHT for a full description. */ + + +#ifndef KR_headers +#define KR_headers +#endif + +#ifndef IEEE_MC68k +#define IEEE_MC68k +#endif + +#include "dtoa.h" diff -urN ezm3-1.1.orig/libs/m3core/src/Csupport/LINUXSPARC/m3makefile ezm3-1.1/libs/m3core/src/Csupport/LINUXSPARC/m3makefile --- ezm3-1.1.orig/libs/m3core/src/Csupport/LINUXSPARC/m3makefile 1969-12-31 19:00:00.000000000 -0500 +++ ezm3-1.1/libs/m3core/src/Csupport/LINUXSPARC/m3makefile 2004-02-15 00:42:40.000000000 -0500 @@ -0,0 +1,8 @@ +% Copyright (C) 1992, Digital Equipment Corporation +% All rights reserved. +% See the file COPYRIGHT for a full description. + +% Last modified on Fri Feb 18 14:11:06 PST 1994 by kalsow +% modified on Mon Oct 12 14:02:53 PDT 1992 by muller + +c_source ("dtoa") diff -urN ezm3-1.1.orig/libs/m3core/src/float/m3makefile ezm3-1.1/libs/m3core/src/float/m3makefile --- ezm3-1.1.orig/libs/m3core/src/float/m3makefile 2004-02-14 22:17:46.000000000 -0500 +++ ezm3-1.1/libs/m3core/src/float/m3makefile 2004-02-15 00:43:37.000000000 -0500 @@ -32,6 +32,7 @@ "LINUX" : _float_le, "LINUXELF" : _float_le, "LINUXLIBC6" : _float_le, + "LINUXSPARC" : _float_be, "NEXT" : _float_be, "NetBSDarm" : _float_le, "NetBSDi386" : _float_le, diff -urN ezm3-1.1.orig/libs/m3core/src/runtime/LINUXSPARC/RTHeapDep.m3 ezm3-1.1/libs/m3core/src/runtime/LINUXSPARC/RTHeapDep.m3 --- ezm3-1.1.orig/libs/m3core/src/runtime/LINUXSPARC/RTHeapDep.m3 1969-12-31 19:00:00.000000000 -0500 +++ ezm3-1.1/libs/m3core/src/runtime/LINUXSPARC/RTHeapDep.m3 2004-02-15 01:40:15.000000000 -0500 @@ -0,0 +1,172 @@ +(* Copyright (C) 1993, Digital Equipment Corporation *) +(* All rights reserved. *) +(* See the file COPYRIGHT for a full description. *) +(* *) +(*| Last modified on Fri Jan 20 09:39:09 PST 1995 by kalsow *) +(*| modified on Thu Jan 28 19:24:55 PST 1993 by jdd *) + +UNSAFE MODULE RTHeapDep; + +IMPORT RT0u, RTMachine, RTHeapRep, RTCollectorSRC; +IMPORT Cstdlib, Ctypes, Umman, Unix, Uresource, Usignal, Utypes, Word; + +VAR + initialized := FALSE; + defaultActionSIGSEGV: Usignal.SignalActionHandler := NIL; + defaultSIGSEGV: Usignal.SignalHandler := NIL; (* previous handler *) + +PROCEDURE Protect (p: Page; n: CARDINAL; readable, writable: BOOLEAN) = + BEGIN + IF NOT initialized THEN Init(); initialized := TRUE; END; + IF NOT readable THEN writable := FALSE; END; (* processor limitation *) + VAR prot: Ctypes.int := 0; + BEGIN + IF readable THEN prot := Word.Or(prot, Umman.PROT_READ); END; + IF writable THEN prot := Word.Or(prot, Umman.PROT_WRITE); END; + VAR + ret := Umman.mprotect(LOOPHOLE(p * BytesPerPage, Utypes.caddr_t), + n * BytesPerPage, prot); + BEGIN + <* ASSERT ret = 0 *> + END; + END; + END Protect; + +(* Init establishes a handler for SIGSEGV, caused by VM faults, and for all + other signals that cause core dumps. *) + +PROCEDURE Init () = + BEGIN + (* sanity check *) + VAR vmPageBytes := Unix.getpagesize(); + BEGIN + <* ASSERT BytesPerPage >= vmPageBytes *> + <* ASSERT BytesPerPage MOD vmPageBytes = 0 *> + END; + + (* establish SIGSEGV handler; remember previous handler *) + VAR + newHandler := LOOPHOLE(Fault,Usignal.SignalActionHandler); + vec := Usignal.struct_sigaction{ + sa_handler := newHandler, + sa_mask := Usignal.empty_sigset_t, + sa_flags := Usignal.SA_RESTART, + sa_restorer := NIL}; + ovec: Usignal.struct_sigaction; + ret, tmp: Ctypes.int; + + BEGIN + vec.sa_mask.val[0] := Word.LeftShift(1, Usignal.SIGVTALRM - 1); + tmp := Usignal.SA_RESTART; + ret := Usignal.sigaction(Usignal.SIGSEGV, ADR(vec), ADR(ovec)); + <* ASSERT ret = 0 *> + defaultActionSIGSEGV := ovec.sa_handler; + defaultSIGSEGV := LOOPHOLE(defaultActionSIGSEGV,Usignal.SignalHandler); + END; + + (* establish signal handler for all other signals that dump core, if no + handler exists *) + PROCEDURE OverrideDefault (sig: Ctypes.int) = + VAR + newHandler := LOOPHOLE(Core,Usignal.SignalActionHandler); + vec := Usignal.struct_sigaction{ + sa_handler := newHandler, + sa_mask := Usignal.empty_sigset_t, + sa_flags := Usignal.SA_RESTART, + sa_restorer := NIL}; + ovec: Usignal.struct_sigaction; + ret := Usignal.sigaction(sig, ADR(vec), ADR(ovec)); + BEGIN + vec.sa_mask.val[0] := Word.LeftShift(1, Usignal.SIGVTALRM - 1); + <* ASSERT ret = 0 *> + IF ovec.sa_handler # Usignal.SIG_DFL THEN + ret := Usignal.sigaction(sig, ADR(ovec), ADR(vec)); + <* ASSERT ret = 0 *> + END; + END OverrideDefault; + BEGIN + OverrideDefault(Usignal.SIGQUIT); + OverrideDefault(Usignal.SIGILL); + OverrideDefault(Usignal.SIGTRAP); + OverrideDefault(Usignal.SIGIOT); + OverrideDefault(Usignal.SIGEMT); + OverrideDefault(Usignal.SIGFPE); + OverrideDefault(Usignal.SIGBUS); + OverrideDefault(Usignal.SIGSYS); + END; + END Init; + +(* Fault is called upon a SIGSEGV signal, caused by a VM fault. If + RTHeapRep.Fault is not able to handle the fault, it invokes the previous + action. *) + +PROCEDURE Fault (sig : Ctypes.int; + scp : Usignal.struct_sigcontext; + code: Ctypes.int) = + BEGIN + IF RTHeapRep.Fault(LOOPHOLE(scp.cr2, ADDRESS)) THEN + RETURN; + END; + IF defaultActionSIGSEGV = Usignal.SIG_IGN THEN RETURN; END; + IF defaultActionSIGSEGV = Usignal.SIG_DFL THEN + Core(sig, scp, code); + ELSE + defaultSIGSEGV(sig, scp, code); + END; + END Fault; + +(* Core is a signal handler for signals that dump core, to complete the + current collection before dumping core. This makes core files easier to + debug, and avoids an Ultrix bug that creates incomplete core files if + heap pages are read-protected. *) + +VAR dumped_core := FALSE; + +PROCEDURE Core ( sig : Ctypes.int; + <* UNUSED *> scp : Usignal.struct_sigcontext; + <* UNUSED *> code: Ctypes.int) = + VAR + ovec: Usignal.struct_sigaction; + vec := Usignal.struct_sigaction{sa_handler := Usignal.SIG_DFL, + sa_mask := Usignal.empty_sigset_t, + sa_flags := Usignal.SA_RESTART, sa_restorer := NIL}; + BEGIN + INC(RT0u.inCritical); + IF NOT dumped_core THEN + dumped_core := TRUE; + EVAL RTHeapRep.Crash(); (* clean up the heap *) + EVAL Usignal.sigaction(sig, ADR(vec), ADR(ovec)); (* establish default action *) + EVAL Usignal.sigsetmask(0); + (** EVAL Usignal.kill(Uprocess.getpid(), sig); (* dump core *) **) + Cstdlib.abort (); (* dump core *) + <* ASSERT FALSE *> + END; + DEC(RT0u.inCritical); + END Core; + +(* System-call faults are handled in RTHeapDepC.c *) + +PROCEDURE TimeUsed (): REAL = + VAR usage: Uresource.struct_rusage; + BEGIN + VAR ret := Uresource.getrusage(Uresource.RUSAGE_SELF, ADR(usage)); + BEGIN + <* ASSERT ret # -1 *> + END; + RETURN (FLOAT(usage.ru_utime.tv_sec) + + FLOAT(usage.ru_utime.tv_usec) / 1000000.0) + + (FLOAT(usage.ru_utime.tv_sec) + + FLOAT(usage.ru_utime.tv_usec) / 1000000.0); + END TimeUsed; + +PROCEDURE VMFaultTime (): REAL = + BEGIN + RETURN 0.010; (* guess 10ms to handle a page fault *) + END VMFaultTime; + +BEGIN + IF VM THEN + RTMachine.RTHeapRep_Fault := LOOPHOLE (RTHeapRep.Fault, ADDRESS); + RTMachine.RTCSRC_FinishVM := LOOPHOLE (RTCollectorSRC.FinishVM, ADDRESS); + END; +END RTHeapDep. diff -urN ezm3-1.1.orig/libs/m3core/src/runtime/LINUXSPARC/RTMachine.i3 ezm3-1.1/libs/m3core/src/runtime/LINUXSPARC/RTMachine.i3 --- ezm3-1.1.orig/libs/m3core/src/runtime/LINUXSPARC/RTMachine.i3 1969-12-31 19:00:00.000000000 -0500 +++ ezm3-1.1/libs/m3core/src/runtime/LINUXSPARC/RTMachine.i3 2004-02-15 01:40:15.000000000 -0500 @@ -0,0 +1,77 @@ +(* Copyright (C) 1994, Digital Equipment Corporation. *) +(* All rights reserved. *) +(* See the file COPYRIGHT for a full description. *) +(* *) +(* Last modified on Tue May 2 11:41:35 PDT 1995 by kalsow *) + +(* This interface defines platform (machine + OS) dependent + types and constants. *) + +INTERFACE RTMachine; + +IMPORT Csetjmp; + +(*--------------------------------------------------------- thread state ---*) + +TYPE + State = Csetjmp.jmp_buf; + (* The machine state is saved in a "State". This type is really + opaque to the client, i.e. it does not need to be an array. *) + +<*EXTERNAL "_setjmp" *> +PROCEDURE SaveState (VAR s: State): INTEGER; +(* Capture the currently running thread's state *) + +CONST + FramePadBottom = 14; + FramePadTop = 0; + (* Additional padding words from above and below an existing + thread's stack pointer to copy when creating a new thread *) + +(*------------------------------------------------------------------ heap ---*) + +(* The heap page size is machine-dependent, since it might depend on the + architecture's VM page size (if VM is TRUE). Otherwise, 8192 bytes is a + reasonable page size. The page size must be a power of two. *) + +CONST + BytesPerHeapPage = 4096; (* bytes per page *) + LogBytesPerHeapPage = 12; + AdrPerHeapPage = 4096; (* addresses per page *) + LogAdrPerHeapPage = 12; + +CONST + VMHeap = FALSE; + +<*EXTERNAL*> VAR RTHeapRep_Fault: ADDRESS; (* => RTHeapRep.Fault *) +<*EXTERNAL*> VAR RTCSRC_FinishVM: ADDRESS; (* => RTCollectorSRC.FinishVM *) + +(*--------------------------------------------------------- thread stacks ---*) + +CONST + PointerAlignment = 8; + (* The C compiler allocates all pointers on 'PointerAlignment'-byte + boundaries. The garbage collector scans thread stacks, but only + looks at these possible pointer locations. Setting this value + smaller than is needed will only make your system run slower. + Setting it too large will cause the collector to collect storage + that is not free. *) + +CONST + StackFrameAlignment = 8; + (* Stack frames must be aligned to this constraint (in ADRSIZE units). + It's not a big deal if this value is too large, but it may break + the thread mechanism to make it too small. *) + +(*----------------------------------------------- exception stack walking ---*) +(* The "FrameInfo" type must minimally include fields named "pc" and "sp". *) + +CONST + Has_stack_walker = FALSE; + (* Indicates whether this platform supports the stack walking functions + defined in the "RTStack" interface. *) + +TYPE FrameInfo = RECORD pc, sp: ADDRESS END; + +END RTMachine. + diff -urN ezm3-1.1.orig/libs/m3core/src/runtime/LINUXSPARC/RTSignal.m3 ezm3-1.1/libs/m3core/src/runtime/LINUXSPARC/RTSignal.m3 --- ezm3-1.1.orig/libs/m3core/src/runtime/LINUXSPARC/RTSignal.m3 1969-12-31 19:00:00.000000000 -0500 +++ ezm3-1.1/libs/m3core/src/runtime/LINUXSPARC/RTSignal.m3 2004-02-15 01:40:15.000000000 -0500 @@ -0,0 +1,86 @@ +(* Copyright (C) 1992, Digital Equipment Corporation *) +(* All rights reserved. *) +(* See the file COPYRIGHT for a full description. *) +(* *) +(* Last modified on Mon Nov 21 11:26:41 PST 1994 by kalsow *) +(* modified on Mon Mar 16 18:10:15 PST 1992 by muller *) + +UNSAFE MODULE RTSignal; + +IMPORT RTMisc, RTProcess, Csignal, Usignal, Uprocess; +FROM Ctypes IMPORT int; + +VAR + DefaultHandler : Csignal.Handler; + IgnoreSignal : Csignal.Handler; + initial_handlers : ARRAY [0..5] OF Csignal.Handler; + +PROCEDURE InstallHandlers () = + BEGIN + DefaultHandler := LOOPHOLE (0, Csignal.Handler); + IgnoreSignal := LOOPHOLE (1, Csignal.Handler); + + SetHandler (0, Usignal.SIGHUP, Shutdown); + SetHandler (1, Usignal.SIGINT, Interrupt); + SetHandler (2, Usignal.SIGQUIT, Quit); + SetHandler (3, Usignal.SIGSEGV, SegV); + SetHandler (4, Usignal.SIGPIPE, IgnoreSignal); + SetHandler (5, Usignal.SIGTERM, Shutdown); + END InstallHandlers; + +PROCEDURE SetHandler (id: INTEGER; sig: int; handler: Csignal.Handler) = + VAR old := Csignal.signal (sig, handler); + BEGIN + initial_handlers[id] := old; + IF (old # DefaultHandler) THEN + (* don't override inherited, non-default handlers *) + EVAL Csignal.signal (sig, old); + END; + END SetHandler; + +PROCEDURE RestoreHandlers () = + BEGIN + RestoreHandler (0, Usignal.SIGHUP); + RestoreHandler (1, Usignal.SIGINT); + RestoreHandler (2, Usignal.SIGQUIT); + RestoreHandler (3, Usignal.SIGSEGV); + RestoreHandler (4, Usignal.SIGPIPE); + RestoreHandler (5, Usignal.SIGTERM); + END RestoreHandlers; + +PROCEDURE RestoreHandler (id: INTEGER; sig: int) = + BEGIN + EVAL Csignal.signal (sig, initial_handlers[id]); + END RestoreHandler; + +PROCEDURE Shutdown (sig: int) = + BEGIN + RTProcess.InvokeExitors (); (* flush stdio... *) + EVAL Csignal.signal (sig, DefaultHandler); (* restore default handler *) + EVAL Usignal.kill (Uprocess.getpid (), sig); (* and resend the signal *) + END Shutdown; + +PROCEDURE Interrupt (sig: int) = + VAR h := RTProcess.OnInterrupt (NIL); + BEGIN + IF (h = NIL) THEN + Shutdown (sig); + ELSE + EVAL RTProcess.OnInterrupt (h); (* reinstall the handler *) + h (); + END; + END Interrupt; + +PROCEDURE Quit (<*UNUSED*> sig: int) = + BEGIN + RTMisc.FatalErrorI ("aborted", 0); + END Quit; + +PROCEDURE SegV (<*UNUSED*> sig: int) = + BEGIN + RTMisc.FatalErrorI ( + "Segmentation violation - possible attempt to dereference NIL", 0); + END SegV; + +BEGIN +END RTSignal. diff -urN ezm3-1.1.orig/libs/m3core/src/runtime/LINUXSPARC/RTThread.m3 ezm3-1.1/libs/m3core/src/runtime/LINUXSPARC/RTThread.m3 --- ezm3-1.1.orig/libs/m3core/src/runtime/LINUXSPARC/RTThread.m3 1969-12-31 19:00:00.000000000 -0500 +++ ezm3-1.1/libs/m3core/src/runtime/LINUXSPARC/RTThread.m3 2004-02-15 01:40:15.000000000 -0500 @@ -0,0 +1,111 @@ +(* Copyright (C) 1992, Digital Equipment Corporation *) +(* All rights reserved. *) +(* See the file COPYRIGHT for a full description. *) +(* *) +(* Last modified on Mon Nov 21 11:28:44 PST 1994 by kalsow *) +(* modified on Tue May 4 18:49:28 PDT 1993 by muller *) + +UNSAFE MODULE RTThread; + +IMPORT Usignal, Unix, Umman, RTMisc, Word; + +CONST + SP_pos = 2; + +PROCEDURE SP (READONLY s: State): ADDRESS = + BEGIN + RETURN LOOPHOLE (s [SP_pos], ADDRESS); + END SP; + +(*--------------------------------------------------------- thread stacks ---*) + +VAR page_bytes : CARDINAL := 0; +VAR stack_slop : CARDINAL; + +PROCEDURE NewStack (size: INTEGER; VAR(*OUT*)s: Stack) = + VAR (* i: INTEGER; see below *) start: ADDRESS; + BEGIN + IF (page_bytes = 0) THEN + page_bytes := Unix.getpagesize (); + stack_slop := 2 * (page_bytes DIV BYTESIZE (INTEGER)); + END; + + (* allocate enough so that we're guaranteed to get a full, aligned page *) + INC (size, stack_slop); + s.words := NEW (StackSpace, size); + + (* find the aligned page and unmap it *) + start := RTMisc.Align (ADR (s.words[0]), page_bytes); + (* FIXME: + Perhaps someone who knows more about this ninja stuff can + properly implement this + i := Umman.mprotect (start, page_bytes, Umman.PROT_READ); + <* ASSERT i = 0 *> + *) + + (* finally, set the bounds of the usable region *) + s.first := start + page_bytes; + s.last := ADR (s.words[0]) + size * ADRSIZE (s.words[0]); + END NewStack; + +PROCEDURE DisposeStack (VAR s: Stack) = + (* VAR i: INTEGER; start := RTMisc.Align (ADR (s.words[0]), page_bytes); *) + BEGIN + (* find the aligned page and re-map it *) + (* see above + i := Umman.mprotect (start, page_bytes, Umman.PROT_READ+Umman.PROT_WRITE); + <* ASSERT i = 0 *> + *) + + (* and finally, free the storage *) + DISPOSE (s.words); + s.words := NIL; + s.first := NIL; + s.last := NIL; + END DisposeStack; + +PROCEDURE FlushStackCache () = + VAR d: State; + BEGIN + Transfer (d, d); + END FlushStackCache; + +(*-------------------------------------------------- modifying the models ---*) + +PROCEDURE UpdateStateForNewSP (VAR s: State; offset: INTEGER) = + BEGIN + INC (s [SP_pos], offset); + END UpdateStateForNewSP; + +PROCEDURE UpdateFrameForNewSP (<*UNUSED*> a: ADDRESS; + <*UNUSED*> offset: INTEGER) = + BEGIN + END UpdateFrameForNewSP; + +(*------------------------------------ manipulating the SIGVTALRM handler ---*) + +PROCEDURE setup_sigvtalrm (handler: Usignal.SignalHandler) = + VAR x: Usignal.struct_sigaction; + BEGIN + x.sa_handler := LOOPHOLE (handler, Usignal.SignalActionHandler); + x.sa_mask := Usignal.empty_sigset_t; + x.sa_flags := Usignal.SA_RESTART; + EVAL Usignal.sigaction (Usignal.SIGVTALRM, ADR (x), NIL); + END setup_sigvtalrm; + +PROCEDURE allow_sigvtalrm () = + BEGIN + EVAL Usignal.sigprocmask(Usignal.SIG_UNBLOCK,ADR(sigvtalrmMask),NIL); + END allow_sigvtalrm; + +PROCEDURE disallow_sigvtalrm () = + BEGIN + EVAL Usignal.sigprocmask(Usignal.SIG_BLOCK,ADR(sigvtalrmMask),NIL); + END disallow_sigvtalrm; + +VAR + sigvtalrmMask: Usignal.sigset_t; + +BEGIN + sigvtalrmMask.val[0] := Usignal.sigmask(Usignal.SIGVTALRM); +END RTThread. diff -urN ezm3-1.1.orig/libs/m3core/src/runtime/LINUXSPARC/RTThreadC.c ezm3-1.1/libs/m3core/src/runtime/LINUXSPARC/RTThreadC.c --- ezm3-1.1.orig/libs/m3core/src/runtime/LINUXSPARC/RTThreadC.c 1969-12-31 19:00:00.000000000 -0500 +++ ezm3-1.1/libs/m3core/src/runtime/LINUXSPARC/RTThreadC.c 2004-02-15 01:40:15.000000000 -0500 @@ -0,0 +1,26 @@ +/* Copyright (C) 1990, Digital Equipment Corporation */ +/* All rights reserved. */ +/* See the file COPYRIGHT for a full description. */ +/* Last modified on Mon Dec 6 16:14:35 PST 1993 by kalsow */ +/* modified on Tue Jan 19 15:20:48 PST 1993 by burrows */ + +/* This file implements the coroutine transfer: RTThread.Transfer */ + +#include + +RTThread__Transfer (from, to) +jmp_buf *from, *to; +{ + if (setjmp(*from) == 0) longjmp (*to, 1); +} + + +/* global thread ID used by 'etp' */ +int ThreadF__myId = 1; + +/* low-level runtime lock */ +int RT0u__inCritical = 0; + +/* global, per-thread linked list of exception handlers */ +void* RTThread__handlerStack = 0; + diff -urN ezm3-1.1.orig/libs/m3core/src/runtime/LINUXSPARC/m3makefile ezm3-1.1/libs/m3core/src/runtime/LINUXSPARC/m3makefile --- ezm3-1.1.orig/libs/m3core/src/runtime/LINUXSPARC/m3makefile 1969-12-31 19:00:00.000000000 -0500 +++ ezm3-1.1/libs/m3core/src/runtime/LINUXSPARC/m3makefile 2004-02-15 01:49:31.000000000 -0500 @@ -0,0 +1,14 @@ +% Copyright (C) 1994, Digital Equipment Corporation +% All rights reserved. +% See the file COPYRIGHT for a full description. +% +% Last modified on Mon Nov 21 11:09:38 PST 1994 by kalsow +% modified on Mon Dec 14 19:59:03 PST 1992 by jdd +% modified on Wed May 20 17:21:29 PDT 1992 by muller + +Interface ("RTMachine") +implementation ("RTHeapDep") +implementation ("RTSignal") +implementation ("RTThread") +c_source ("RTThreadC") + diff -urN ezm3-1.1.orig/libs/m3core/src/runtime/m3makefile ezm3-1.1/libs/m3core/src/runtime/m3makefile --- ezm3-1.1.orig/libs/m3core/src/runtime/m3makefile 2004-02-14 22:17:46.000000000 -0500 +++ ezm3-1.1/libs/m3core/src/runtime/m3makefile 2004-03-12 09:58:19.993246360 -0500 @@ -26,6 +26,7 @@ "LINUX" : "ex_frame", "LINUXELF" : "ex_frame", "LINUXLIBC6" : "ex_frame", + "LINUXSPARC" : "ex_frame", "NEXT" : "ex_frame", "NetBSDarm" : "ex_frame", "NetBSDi386" : "ex_frame", diff -urN ezm3-1.1.orig/libs/m3core/src/time/POSIX/m3makefile ezm3-1.1/libs/m3core/src/time/POSIX/m3makefile --- ezm3-1.1.orig/libs/m3core/src/time/POSIX/m3makefile 2004-02-14 22:17:46.000000000 -0500 +++ ezm3-1.1/libs/m3core/src/time/POSIX/m3makefile 2004-03-12 09:57:50.545723064 -0500 @@ -29,6 +29,7 @@ "LINUX" : "DateLinux", "LINUXELF" : "DateLinux", "LINUXLIBC6" : "DateBsd", + "LINUXSPARC" : "DateBsd", "NetBSDarm" : "DateBsd", "NetBSDi386" : "DateBsd", "NetBSDsparc": "DateBsd", diff -urN ezm3-1.1.orig/libs/m3core/src/unix/m3makefile ezm3-1.1/libs/m3core/src/unix/m3makefile --- ezm3-1.1.orig/libs/m3core/src/unix/m3makefile 2004-02-14 22:17:46.000000000 -0500 +++ ezm3-1.1/libs/m3core/src/unix/m3makefile 2004-03-12 09:58:45.176417936 -0500 @@ -33,6 +33,7 @@ "LINUX" : [ "linux" ], "LINUXELF" : [ "linux" ], "LINUXLIBC6" : [ "linux-libc6" ], + "LINUXSPARC" : [ "linux-libc6" ], "NEXT" : [ "ultrix-3-1.generic", "ultrix-3-1.NEXT" ], "NetBSDarm" : [ "netbsd-1" ], "NetBSDi386" : [ "netbsd-1" ], diff -urN ezm3-1.1.orig/m3config/src/COMMON ezm3-1.1/m3config/src/COMMON --- ezm3-1.1.orig/m3config/src/COMMON 2004-02-14 22:17:46.000000000 -0500 +++ ezm3-1.1/m3config/src/COMMON 2004-03-12 10:01:02.659517328 -0500 @@ -600,6 +600,7 @@ "LINUX" : [ "POSIX", "32BITS", "i486--linux", "" ], "LINUXELF" : [ "POSIX", "32BITS", "i486--linuxelf", "T" ], "LINUXLIBC6": [ "POSIX", "32BITS", "i486--linuxelf", "T" ], + "LINUXSPARC": [ "POSIX", "32BITS", "sparc--linuxelf", "T" ], "NEXT" : [ "POSIX", "32BITS", "next-bsd", "" ], "NetBSDarm" : [ "POSIX", "32BITS", "arm-unknown-netbsd", "T" ], "NetBSDi386": [ "POSIX", "32BITS", "i486-unknown-netbsdelf", "T" ], diff -urN ezm3-1.1.orig/m3config/src/LINUXSPARC ezm3-1.1/m3config/src/LINUXSPARC --- ezm3-1.1.orig/m3config/src/LINUXSPARC 1969-12-31 19:00:00.000000000 -0500 +++ ezm3-1.1/m3config/src/LINUXSPARC 2004-03-12 09:59:23.918528240 -0500 @@ -0,0 +1,13 @@ + +readonly TARGET = "LINUXSPARC" + +include("COMMON") + +INSTALL_ROOT = "/usr/local" +X11ROOT = "/usr/X11R6/lib" + +% The internal back end is disabled in ezm3. +%PLATFORM_SUPPORTS_INTERNAL_BACKEND = "T" +PLATFORM_SUPPORTS_SHARED_LIB = "T" + +setDefault("","")