Michel Dagenais
!
Michel Dagenais, GNU General Public License, 1998-1999
michel.dagenais@polymtl.ca
Ecole Polytechnique
***************
*** 20,26 ****
Maintained by Michel Dagenais
(michel.dagenais@polymtl.ca),
suggestions are most welcome.
! Last updated 2 April 1998.
The latest copy of this FAQ may be obtained from the
Polytechnique Montreal Modula-3 Home.
--- 20,26 ----
Maintained by Michel Dagenais
(michel.dagenais@polymtl.ca),
suggestions are most welcome.
! Last updated 4 May 1999.
The latest copy of this FAQ may be obtained from the
Polytechnique Montreal Modula-3 Home.
***************
*** 50,56 ****
Miscellaneous Questions
- - Where to find Modula-3 books?
- Can I get Modula-3 other than by FTP or HTTP?
- How to call Modula-3 procedures from a C program?
- Can Modula-3 code call C++ and vice-versa?
--- 50,55 ----
Index: m3/pm3/intro/src/questions/uppercase.html
diff -c m3/pm3/intro/src/questions/uppercase.html:1.1.1.1 m3/pm3/intro/src/questions/uppercase.html:1.2
*** m3/pm3/intro/src/questions/uppercase.html:1.1.1.1 Sat Jan 31 14:47:15 1998
--- m3/pm3/intro/src/questions/uppercase.html Mon Jun 7 13:10:13 1999
***************
*** 6,10 ****
and there is no solution that will completely satisfy everyone's tastes.
Fortunately this is a very minor issue and you can easily have lowercase
keywords automatically converted for you using an emacs macro package like
! m3su .
--- 6,10 ----
and there is no solution that will completely satisfy everyone's tastes.
Fortunately this is a very minor issue and you can easily have lowercase
keywords automatically converted for you using an emacs macro package like
! m3su .
Index: m3/pm3/language/modula3/m3compiler/m3bootstrap/src/m3makefile
diff -c m3/pm3/language/modula3/m3compiler/m3bootstrap/src/m3makefile:1.15 m3/pm3/language/modula3/m3compiler/m3bootstrap/src/m3makefile:1.18
*** m3/pm3/language/modula3/m3compiler/m3bootstrap/src/m3makefile:1.15 Fri Jan 29 20:50:45 1999
--- m3/pm3/language/modula3/m3compiler/m3bootstrap/src/m3makefile Mon Jun 7 13:48:13 1999
***************
*** 28,34 ****
" in " & target & CR) end
>> "pm3-" & target & SL & "config.tmpl" in
! write("override(\"" & pkg & "\",\".." & SL & "..\")")
end
end
--- 28,34 ----
" in " & target & CR) end
>> "pm3-" & target & SL & "config.tmpl" in
! write("override(\"" & pkg & "\",\".." & SL & "..\")" & CR)
end
end
***************
*** 199,211 ****
write("option(\"bootstrap\",\"T\")",CR)
write("option(\"shared_lib\",\"\")",CR)
if equal(target,"HPPA") or equal(target,"DS3100") or equal(target,"IRIX5")
! or equal(target,"NT386GNU") or equal(target,"ALPHA_OSF") or
! equal(target,"IBMR2")
write("option(\"optimization\",\"\")",CR)
else
write("option(\"optimization\",\"T\")",CR)
end
! write("option(\"debuginfo\",\"" & BOOTDEBUG & "\")",CR)
write("HOST=\"" & host & "\"",CR)
write("USE_M3DOC=\"\"",CR)
write("IBACK=\"\"",CR)
--- 199,215 ----
write("option(\"bootstrap\",\"T\")",CR)
write("option(\"shared_lib\",\"\")",CR)
if equal(target,"HPPA") or equal(target,"DS3100") or equal(target,"IRIX5")
! or equal(target,"NT386GNU") or equal(target,"IBMR2")
write("option(\"optimization\",\"\")",CR)
else
write("option(\"optimization\",\"T\")",CR)
end
! if equal(target,"ALPHA_OSF")
! % m3cgc1 generates bad code when -g flag is not used
! write("option(\"debuginfo\",\"T\")",CR)
! else
! write("option(\"debuginfo\",\"" & BOOTDEBUG & "\")",CR)
! end
write("HOST=\"" & host & "\"",CR)
write("USE_M3DOC=\"\"",CR)
write("IBACK=\"\"",CR)
***************
*** 249,255 ****
CleanPkg("m3ship",target)
local header = "M3OPTIONS=" & CR
! local options = "\"CC=${CC}\" \"CCFLAGS=${CCFLAGS}\"" &
" \"AS=${AS}\" \"ASFLAGS=${ASFLAGS}\"" &
" \"AR=${AR}\" \"ARFLAGS=${ARFLAGS}\"" &
" \"RANLIB=${RANLIB}\" \"EXTRALIBS=${EXTRALIBS}\"" &
--- 253,259 ----
CleanPkg("m3ship",target)
local header = "M3OPTIONS=" & CR
! local options = "\"CC=${CC}\" \"CFLAGS=${CFLAGS}\"" &
" \"AS=${AS}\" \"ASFLAGS=${ASFLAGS}\"" &
" \"AR=${AR}\" \"ARFLAGS=${ARFLAGS}\"" &
" \"RANLIB=${RANLIB}\" \"EXTRALIBS=${EXTRALIBS}\"" &
***************
*** 257,272 ****
if equal(target,"NT386GNU")
header = header & "EXTRALIBS=-ladvapi32" & CR
else
! if equal(target,"SOLsun")
! header = header & "EXTRALIBS=-lsunmath -lm" & CR
! else
! if equal(target,"HPPA")
! header = header & "EXTRALIBS=-lm -lBSD" & CR
! else
! header = header & "EXTRALIBS=-lm" & CR
! end
! end
end
if equal(target,"SOLgnu") or equal(target,"SOLsun")
--- 261,274 ----
if equal(target,"NT386GNU")
header = header & "EXTRALIBS=-ladvapi32" & CR
+ else if equal(target,"SOLsun")
+ header = header & "EXTRALIBS=-lsunmath -lm" & CR
+ else if equal(target,"HPPA")
+ header = header & "EXTRALIBS=-lm -lBSD" & CR
else
! header = header & "EXTRALIBS=-lm" & CR
! end
! end
end
if equal(target,"SOLgnu") or equal(target,"SOLsun")
***************
*** 278,284 ****
header = header & "CC=gcc" & CR
end
! header = header & "RANLIB=touch" & CR
CreateMakefile("pm3-" & target & SL & "Makefile." & target,target,
header, options)
--- 280,301 ----
header = header & "CC=gcc" & CR
end
! if equal(target,"LINUXLIBC6")
! include("../../../../../m3config/src/GCWRAP")
! header = header & "LDFLAGS=" & GCWRAPFLAGS & CR
! end
!
! if equal(target,"ALPHA_OSF")
! header = header & "CFLAGS=-ieee_with_no_inexact -g3" & CR
! header = header & "LDFLAGS=-ieee_with_no_inexact" & CR
! header = header & "ASFLAGS=-g3" & CR
! end
!
! if equal(target,"FreeBSD2")
! header = header & "RANLIB=ranlib" & CR
! else
! header = header & "RANLIB=touch" & CR
! end
CreateMakefile("pm3-" & target & SL & "Makefile." & target,target,
header, options)
Index: m3/pm3/language/modula3/m3compiler/m3build/src/Main.m3
diff -c m3/pm3/language/modula3/m3compiler/m3build/src/Main.m3:1.7 m3/pm3/language/modula3/m3compiler/m3build/src/Main.m3:1.8
*** m3/pm3/language/modula3/m3compiler/m3build/src/Main.m3:1.7 Wed Aug 26 10:54:10 1998
--- m3/pm3/language/modula3/m3compiler/m3build/src/Main.m3 Mon Jun 7 13:10:36 1999
***************
*** 14,20 ****
CONST
SL = M3Config.PATH_SEP;
! M3_VERSION = "SRC Modula-3 version XX.X";
TYPE
DefineList = REF RECORD
--- 14,21 ----
CONST
SL = M3Config.PATH_SEP;
! M3_VERSION = "PM3 Version " & M3Config.M3_VERSION &
! " (" & M3Config.M3_VERSION_DATE & ")";
TYPE
DefineList = REF RECORD
Index: m3/pm3/language/modula3/m3compiler/m3cc/gcc/configure
diff -c m3/pm3/language/modula3/m3compiler/m3cc/gcc/configure:1.1.1.1 m3/pm3/language/modula3/m3compiler/m3cc/gcc/configure:1.2
*** m3/pm3/language/modula3/m3compiler/m3cc/gcc/configure:1.1.1.1 Thu Feb 6 16:32:12 1997
--- m3/pm3/language/modula3/m3compiler/m3cc/gcc/configure Mon Jun 7 13:10:48 1999
***************
*** 598,603 ****
--- 598,613 ----
a29k-*-*) # Default a29k environment.
use_collect2=yes
;;
+ alpha-*-freebsd*)
+ tm_file=alpha/freebsd.h
+ xm_file=alpha/xm-freebsd.h
+ # On FreeBSD, the headers are already ok.
+ fixincludes=Makefile.in
+ xmake_file=alpha/x-freebsd
+ gas=yes
+ gnu_ld=yes
+ stabs=yes
+ ;;
alpha-*-linux*ecoff*)
tm_file="${tm_file} alpha/linux.h"
xm_file="${xm_file} alpha/xm-linux.h"
Index: m3/pm3/language/modula3/m3compiler/m3cc/gcc/m3.c
diff -c m3/pm3/language/modula3/m3compiler/m3cc/gcc/m3.c:1.2 m3/pm3/language/modula3/m3compiler/m3cc/gcc/m3.c:1.3
*** m3/pm3/language/modula3/m3compiler/m3cc/gcc/m3.c:1.2 Sun Oct 11 17:14:19 1998
--- m3/pm3/language/modula3/m3compiler/m3cc/gcc/m3.c Mon Jun 7 13:10:53 1999
***************
*** 632,638 ****
#define PROC(x) tree x = scan_proc ()
! static tree all_procs [1000];
static tree scan_proc ()
{
--- 632,638 ----
#define PROC(x) tree x = scan_proc ()
! static tree all_procs [5000];
static tree scan_proc ()
{
Index: m3/pm3/language/modula3/m3compiler/m3cc/gcc/config/alpha/alpha.c
diff -c m3/pm3/language/modula3/m3compiler/m3cc/gcc/config/alpha/alpha.c:1.1.1.1 m3/pm3/language/modula3/m3compiler/m3cc/gcc/config/alpha/alpha.c:1.2
*** m3/pm3/language/modula3/m3compiler/m3cc/gcc/config/alpha/alpha.c:1.1.1.1 Thu Feb 6 16:32:26 1997
--- m3/pm3/language/modula3/m3compiler/m3cc/gcc/config/alpha/alpha.c Mon Jun 7 13:11:02 1999
***************
*** 919,925 ****
for (; bits > 0; bits--)
if ((temp = (alpha_emit_set_const
(subtarget, mode,
! (unsigned HOST_WIDE_INT) c >> bits, i))) != 0
|| ((temp = (alpha_emit_set_const
(subtarget, mode,
((unsigned HOST_WIDE_INT) c) >> bits, i)))
--- 919,925 ----
for (; bits > 0; bits--)
if ((temp = (alpha_emit_set_const
(subtarget, mode,
! c >> bits, i))) != 0
|| ((temp = (alpha_emit_set_const
(subtarget, mode,
((unsigned HOST_WIDE_INT) c) >> bits, i)))
***************
*** 1579,1585 ****
/* Write a version stamp. Don't write anything if we are running as a
cross-compiler. Otherwise, use the versions in /usr/include/stamp.h. */
! #if !defined(CROSS_COMPILE) && !defined(_WIN32) && !defined(__linux__)
#include
#endif
--- 1579,1586 ----
/* Write a version stamp. Don't write anything if we are running as a
cross-compiler. Otherwise, use the versions in /usr/include/stamp.h. */
! #if !defined(CROSS_COMPILE) && !defined(_WIN32) && !defined(__linux__) && \
! !defined(__FreeBSD__)
#include
#endif
Index: m3/pm3/language/modula3/m3compiler/m3cc/gcc/config/alpha/freebsd.h
diff -c /dev/null m3/pm3/language/modula3/m3compiler/m3cc/gcc/config/alpha/freebsd.h:1.1
*** /dev/null Mon Jun 7 17:07:27 1999
--- m3/pm3/language/modula3/m3compiler/m3cc/gcc/config/alpha/freebsd.h Mon Jun 7 13:11:02 1999
***************
*** 0 ****
--- 1,48 ----
+ /*
+ * Minimal alpha/freebsd.h file for compiling m3cgc1.
+ *
+ * This file is in the public domain.
+ */
+
+ #include "alpha/alpha.h"
+ #include "alpha/elf.h"
+
+ #undef WCHAR_TYPE
+ #define WCHAR_TYPE "int"
+
+ #undef WCHAR_TYPE_SIZE
+ #define WCHAR_TYPE_SIZE 32
+
+ #undef ASM_SPEC
+ #define ASM_SPEC " %|"
+
+ #undef ASM_FINAL_SPEC
+
+ #undef FUNCTION_PROFILER
+ #define FUNCTION_PROFILER(FILE, LABELNO) \
+ fputs ("\tjsr $28,_mcount\n", (FILE)); /* at */
+
+ #define TARGET_PROFILING_NEEDS_GP
+
+ #define bsd4_4
+ #undef HAS_INIT_SECTION
+
+ #undef TARGET_DEFAULT
+ #define TARGET_DEFAULT MASK_FP|MASK_FPREGS|MASK_IEEE|MASK_IEEE_CONFORMANT
+
+ #undef TARGET_VERSION
+ #define TARGET_VERSION fprintf (stderr, " (FreeBSD/alpha ELF)");
+
+ #undef SDB_DEBUGGING_INFO
+ #define SDB_DEBUGGING_INFO
+ #undef DBS_DEBUGGING_INFO
+ #define DBX_DEBUGGING_INFO
+
+ #undef PREFERRED_DEBUGGING_TYPE
+ #define PREFERRED_DEBUGGING_TYPE \
+ ((len > 1 && !strncmp (str, "gsdb", len)) ? SDB_DEBUG : DBX_DEBUG)
+
+ #define HANDLE_SYSV_PRAGMA
+
+ #undef SET_ASM_OP
+ #define SET_ASM_OP ".set"
Index: m3/pm3/language/modula3/m3compiler/m3cc/gcc/config/alpha/x-freebsd
diff -c /dev/null m3/pm3/language/modula3/m3compiler/m3cc/gcc/config/alpha/x-freebsd:1.1
*** /dev/null Mon Jun 7 17:07:27 1999
--- m3/pm3/language/modula3/m3compiler/m3cc/gcc/config/alpha/x-freebsd Mon Jun 7 13:11:02 1999
***************
*** 0 ****
--- 1,4 ----
+ # Don't run fixproto
+ STMP_FIXPROTO =
+ # Use only native include files
+ USER_H =
Index: m3/pm3/language/modula3/m3compiler/m3cc/gcc/config/alpha/xm-freebsd.h
diff -c /dev/null m3/pm3/language/modula3/m3compiler/m3cc/gcc/config/alpha/xm-freebsd.h:1.1
*** /dev/null Mon Jun 7 17:07:27 1999
--- m3/pm3/language/modula3/m3compiler/m3cc/gcc/config/alpha/xm-freebsd.h Mon Jun 7 13:11:02 1999
***************
*** 0 ****
--- 1,4 ----
+ /* Configuration for GCC for Intel i386 running FreeBSD as host. */
+
+ #include
+ #include
Index: m3/pm3/language/modula3/m3compiler/m3cc/gcc/config/i386/freebsd.h
diff -c m3/pm3/language/modula3/m3compiler/m3cc/gcc/config/i386/freebsd.h:1.1.1.1 m3/pm3/language/modula3/m3compiler/m3cc/gcc/config/i386/freebsd.h:1.2
*** m3/pm3/language/modula3/m3compiler/m3cc/gcc/config/i386/freebsd.h:1.1.1.1 Thu Feb 6 16:32:29 1997
--- m3/pm3/language/modula3/m3compiler/m3cc/gcc/config/i386/freebsd.h Mon Jun 7 13:11:07 1999
***************
*** 20,28 ****
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
- /* This goes away when the math-emulator is fixed */
- #define TARGET_CPU_DEFAULT 0400 /* TARGET_NO_FANCY_MATH_387 */
-
/* This is tested by i386gas.h. */
#define YES_UNDERSCORES
--- 20,25 ----
Index: m3/pm3/language/modula3/m3compiler/m3cc/src/m3makefile
diff -c m3/pm3/language/modula3/m3compiler/m3cc/src/m3makefile:1.5 m3/pm3/language/modula3/m3compiler/m3cc/src/m3makefile:1.8
*** m3/pm3/language/modula3/m3compiler/m3cc/src/m3makefile:1.5 Mon May 25 09:46:00 1998
--- m3/pm3/language/modula3/m3compiler/m3cc/src/m3makefile Mon Jun 7 13:11:20 1999
***************
*** 9,18 ****
readonly m3cc_config = {
! "HPPA" : "--with-gnu-as",
% The HP assembler doesn't understand inline debugger info.
! "IRIX5" : "--with-stabs --with-gnu-as"
% mips-sgi-irix5 does not support debugging using the native
% assembler. If you don't have gas, delete the config options above.
% You will need the latest version of gas (binutils-2.5 or better).
--- 9,18 ----
readonly m3cc_config = {
! "HPPA" : [ "--with-gnu-as" ],
% The HP assembler doesn't understand inline debugger info.
! "IRIX5" : [ "--with-stabs", "--with-gnu-as" ]
% mips-sgi-irix5 does not support debugging using the native
% assembler. If you don't have gas, delete the config options above.
% You will need the latest version of gas (binutils-2.5 or better).
***************
*** 27,33 ****
if m3cc_config contains target
return m3cc_config {target}
else
! return ""
end
end
--- 27,33 ----
if m3cc_config contains target
return m3cc_config {target}
else
! return []
end
end
***************
*** 35,41 ****
if equal (ov, "*")
return ""
else
! return format ("%s=\"%s\"", nm, ov)
end
end
--- 35,41 ----
if equal (ov, "*")
return ""
else
! return format ("%s=%s", nm, ov)
end
end
***************
*** 82,89 ****
if equal (M3CC_HOST, M3CC_TARGET)
LibdExport (program_name("m3cgc1"))
if equal (M3CC_HOST, "DS3100") or equal (M3CC_HOST, "ALPHA_OSF")
! pgms = "m3cgc1 mips-tfile"
LibdExport ("mips-tfile")
end
end
--- 82,101 ----
if equal (M3CC_HOST, M3CC_TARGET)
LibdExport (program_name("m3cgc1"))
if equal (M3CC_HOST, "DS3100") or equal (M3CC_HOST, "ALPHA_OSF")
! pgms = ["m3cgc1", "mips-tfile"]
LibdExport ("mips-tfile")
+ end
+ if equal (M3CC_HOST, "ALPHA_OSF")
+ > "as" in
+ write("#!/bin/sh",CR)
+ write("/bin/as $*",CR)
+ end
+ > "fixobj" in
+ write("#!/bin/sh",CR)
+ write(LIB_USE & "/mips-tfile $*",CR)
+ end
+ LibdExport ("as")
+ LibdExport ("fixobj")
end
end
Index: m3/pm3/language/modula3/m3compiler/m3driver/src/M3Driver.i3
diff -c m3/pm3/language/modula3/m3compiler/m3driver/src/M3Driver.i3:1.4 m3/pm3/language/modula3/m3compiler/m3driver/src/M3Driver.i3:1.5
*** m3/pm3/language/modula3/m3compiler/m3driver/src/M3Driver.i3:1.4 Thu Feb 26 11:27:27 1998
--- m3/pm3/language/modula3/m3compiler/m3driver/src/M3Driver.i3 Mon Jun 7 13:11:25 1999
***************
*** 47,52 ****
--- 47,53 ----
Interface = OBJECT
dump_config : BOOLEAN := FALSE;
bootstrap_mode : BOOLEAN := FALSE;
+ bootstrap_il : BOOLEAN := FALSE;
gui : BOOLEAN := FALSE;
do_debug : BOOLEAN := FALSE;
heap_stats : BOOLEAN := FALSE;
Index: m3/pm3/language/modula3/m3compiler/m3driver/src/M3Driver.m3
diff -c m3/pm3/language/modula3/m3compiler/m3driver/src/M3Driver.m3:1.10 m3/pm3/language/modula3/m3compiler/m3driver/src/M3Driver.m3:1.11
*** m3/pm3/language/modula3/m3compiler/m3driver/src/M3Driver.m3:1.10 Fri Oct 2 12:33:55 1998
--- m3/pm3/language/modula3/m3compiler/m3driver/src/M3Driver.m3 Mon Jun 7 13:11:25 1999
***************
*** 65,70 ****
--- 65,71 ----
gen_static : BOOLEAN := FALSE;
new_linkInfo : BOOLEAN := FALSE;
bootstrap_mode: BOOLEAN := FALSE;
+ bootstrap_il : BOOLEAN := FALSE;
compile_once : BOOLEAN := FALSE;
gui : BOOLEAN := FALSE; (* for NT *)
heap_stats : BOOLEAN := FALSE;
***************
*** 130,135 ****
--- 131,137 ----
interface := i;
dump_config := i.dump_config;
bootstrap_mode := i.bootstrap_mode;
+ bootstrap_il := i.bootstrap_il;
gui := i.gui;
do_debug := i.do_debug;
heap_stats := i.heap_stats;
***************
*** 227,232 ****
--- 229,235 ----
gen_static := FALSE;
new_linkInfo := FALSE;
bootstrap_mode:= FALSE;
+ bootstrap_il := FALSE;
compile_once := FALSE;
gui := FALSE; (* for NT *)
heap_stats := FALSE;
***************
*** 417,422 ****
--- 420,426 ----
Msg.OutL ("lib path := ", NIL, lib_path);
Msg.Out ("make mode := ", Bool [make_mode], Wr.EOL);
Msg.Out ("bootstrap := ", Bool [bootstrap_mode], Wr.EOL);
+ Msg.Out ("bootstrap IL := ", Bool [bootstrap_il], Wr.EOL);
Msg.Out ("keep files := ", Bool [keep_files], Wr.EOL);
Msg.Out ("coverage := ", Bool [do_coverage]," ",link_coverage,Wr.EOL);
Msg.Out ("keep_cache := ", Bool [keep_cache], Wr.EOL);
***************
*** 1102,1113 ****
| 6, (* +bootstrap, +pass 6, -pass 7 *)
7 => (* +bootstrap, +pass 6, +pass 7 *)
tmpC := TempCName (f);
! IF (NOT keep_files) THEN Utils.NoteTempFile (tmpC) END;
IF Pass0 (f, tmpC) THEN
! EVAL Pass6 (tmpC, f.object, f.name.base);
need_merge := TRUE;
END;
! IF (NOT keep_files) THEN Utils.Remove (tmpC) END;
END; (* CASE plan *)
Utils.NoteNewFile (f.object);
--- 1106,1121 ----
| 6, (* +bootstrap, +pass 6, -pass 7 *)
7 => (* +bootstrap, +pass 6, +pass 7 *)
tmpC := TempCName (f);
! IF (NOT keep_files AND NOT bootstrap_il) THEN
! Utils.NoteTempFile (tmpC)
! END;
IF Pass0 (f, tmpC) THEN
! IF NOT bootstrap_il THEN
! EVAL Pass6 (tmpC, f.object, f.name.base)
! END;
need_merge := TRUE;
END;
! IF (NOT keep_files AND NOT bootstrap_il) THEN Utils.Remove (tmpC) END;
END; (* CASE plan *)
Utils.NoteNewFile (f.object);
***************
*** 2258,2278 ****
wr := Utils.OpenWriter (Makefile, fatal := TRUE);
TRY
Wr.PutText (wr, "# bootstrap Modula-3 makefile");
Wr.PutText (wr, Target.EOL);
Wr.PutText (wr, Target.EOL);
-
- Wr.PutText (wr, "%_m.o: %.ms");
- Wr.PutText (wr, Target.EOL);
- Wr.PutText (wr, "\t$(AS) -o $@ $(ASFLAGS) $<");
- Wr.PutText (wr, Target.EOL);
- Wr.PutText (wr, Target.EOL);
-
! Wr.PutText (wr, "%_i.o: %.is");
! Wr.PutText (wr, Target.EOL);
! Wr.PutText (wr, "\t$(AS) -o $@ $(ASFLAGS) $<");
! Wr.PutText (wr, Target.EOL);
! Wr.PutText (wr, Target.EOL);
Wr.PutText (wr, "all: ");
Wr.PutText (wr, pgm_name);
--- 2266,2312 ----
wr := Utils.OpenWriter (Makefile, fatal := TRUE);
TRY
Wr.PutText (wr, "# bootstrap Modula-3 makefile");
+ IF bootstrap_il THEN
+ Wr.PutText (wr, " (bootstrap_il = TRUE)");
+ ELSE
+ Wr.PutText (wr, " (bootstrap_il = FALSE)");
+ END;
Wr.PutText (wr, Target.EOL);
Wr.PutText (wr, Target.EOL);
! IF bootstrap_il THEN
! Wr.PutText (wr, "M3CG = m3cgc1");
! Wr.PutText (wr, Target.EOL);
! Wr.PutText (wr, "M3CGFLAGS = -fno-strength-reduce -quiet -fPIC -g");
! Wr.PutText (wr, Target.EOL);
! Wr.PutText (wr, Target.EOL);
!
! Wr.PutText (wr, "%_m.o: %.mc");
! Wr.PutText (wr, Target.EOL);
! Wr.PutText (wr,
! "\t$(M3CG) -o - $(M3CGFLAGS) $< | $(AS) -o $@ $(ASFLAGS) -");
! Wr.PutText (wr, Target.EOL);
! Wr.PutText (wr, Target.EOL);
!
! Wr.PutText (wr, "%_i.o: %.ic");
! Wr.PutText (wr, Target.EOL);
! Wr.PutText (wr,
! "\t$(M3CG) -o - $(M3CGFLAGS) $< | $(AS) -o $@ $(ASFLAGS) -");
! Wr.PutText (wr, Target.EOL);
! Wr.PutText (wr, Target.EOL);
! ELSE
! Wr.PutText (wr, "%_m.o: %.ms");
! Wr.PutText (wr, Target.EOL);
! Wr.PutText (wr, "\t$(AS) -o $@ $(ASFLAGS) $<");
! Wr.PutText (wr, Target.EOL);
! Wr.PutText (wr, Target.EOL);
!
! Wr.PutText (wr, "%_i.o: %.is");
! Wr.PutText (wr, Target.EOL);
! Wr.PutText (wr, "\t$(AS) -o $@ $(ASFLAGS) $<");
! Wr.PutText (wr, Target.EOL);
! Wr.PutText (wr, Target.EOL);
! END;
Wr.PutText (wr, "all: ");
Wr.PutText (wr, pgm_name);
***************
*** 2352,2358 ****
END;
IF ext_pass_7 THEN
target := base & "_i.o";
! dep := base & ".is";
ELSE
RETURN base & "_i.o";
END;
--- 2386,2396 ----
END;
IF ext_pass_7 THEN
target := base & "_i.o";
! IF bootstrap_il THEN
! dep := base & ".ic"
! ELSE
! dep := base & ".is"
! END;
ELSE
RETURN base & "_i.o";
END;
***************
*** 2364,2370 ****
END;
IF ext_pass_7 THEN
target := base & "_m.o";
! dep := base & ".ms";
ELSE
RETURN base & "_m.o";
END;
--- 2402,2412 ----
END;
IF ext_pass_7 THEN
target := base & "_m.o";
! IF bootstrap_il THEN
! dep := base & ".mc"
! ELSE
! dep := base & ".ms"
! END;
ELSE
RETURN base & "_m.o";
END;
***************
*** 2474,2494 ****
wr := Utils.OpenWriter (Makefile, fatal := TRUE);
TRY
Wr.PutText (wr, "# bootstrap Modula-3 makefile");
Wr.PutText (wr, Target.EOL);
Wr.PutText (wr, Target.EOL);
-
- Wr.PutText (wr, "%_m.o: %.ms");
- Wr.PutText (wr, Target.EOL);
- Wr.PutText (wr, "\t$(AS) -o $@ $(ASFLAGS) $<");
- Wr.PutText (wr, Target.EOL);
- Wr.PutText (wr, Target.EOL);
-
! Wr.PutText (wr, "%_i.o: %.is");
! Wr.PutText (wr, Target.EOL);
! Wr.PutText (wr, "\t$(AS) -o $@ $(ASFLAGS) $<");
! Wr.PutText (wr, Target.EOL);
! Wr.PutText (wr, Target.EOL);
Wr.PutText (wr, "all: ");
Wr.PutText (wr, lib_name);
--- 2516,2562 ----
wr := Utils.OpenWriter (Makefile, fatal := TRUE);
TRY
Wr.PutText (wr, "# bootstrap Modula-3 makefile");
+ IF bootstrap_il THEN
+ Wr.PutText (wr, " (bootstrap_il = TRUE)");
+ ELSE
+ Wr.PutText (wr, " (bootstrap_il = FALSE)");
+ END;
Wr.PutText (wr, Target.EOL);
Wr.PutText (wr, Target.EOL);
! IF bootstrap_il THEN
! Wr.PutText (wr, "M3CG = m3cgc1");
! Wr.PutText (wr, Target.EOL);
! Wr.PutText (wr, "M3CGFLAGS = -fno-strength-reduce -quiet -fPIC -g");
! Wr.PutText (wr, Target.EOL);
! Wr.PutText (wr, Target.EOL);
!
! Wr.PutText (wr, "%_m.o: %.mc");
! Wr.PutText (wr, Target.EOL);
! Wr.PutText (wr,
! "\t$(M3CG) -o - $(M3CGFLAGS) $< | $(AS) -o $@ $(ASFLAGS) -");
! Wr.PutText (wr, Target.EOL);
! Wr.PutText (wr, Target.EOL);
!
! Wr.PutText (wr, "%_i.o: %.ic");
! Wr.PutText (wr, Target.EOL);
! Wr.PutText (wr,
! "\t$(M3CG) -o - $(M3CGFLAGS) $< | $(AS) -o $@ $(ASFLAGS) -");
! Wr.PutText (wr, Target.EOL);
! Wr.PutText (wr, Target.EOL);
! ELSE
! Wr.PutText (wr, "%_m.o: %.ms");
! Wr.PutText (wr, Target.EOL);
! Wr.PutText (wr, "\t$(AS) -o $@ $(ASFLAGS) $<");
! Wr.PutText (wr, Target.EOL);
! Wr.PutText (wr, Target.EOL);
!
! Wr.PutText (wr, "%_i.o: %.is");
! Wr.PutText (wr, Target.EOL);
! Wr.PutText (wr, "\t$(AS) -o $@ $(ASFLAGS) $<");
! Wr.PutText (wr, Target.EOL);
! Wr.PutText (wr, Target.EOL);
! END;
Wr.PutText (wr, "all: ");
Wr.PutText (wr, lib_name);
***************
*** 2691,2696 ****
--- 2759,2776 ----
| NK.IO, NK.MO, NK.O => RETURN f.source;
ELSE RETURN NIL;
END;
+
+ ELSIF bootstrap_il THEN
+ CASE ext OF
+ | NK.I3 => ext := NK.IC;
+ | NK.M3 => ext := NK.MC;
+ | NK.IS => shorten := TRUE;
+ | NK.MS => shorten := TRUE;
+ | NK.IC, NK.MC => (* skip *)
+ | NK.C, NK.S, NK.H => (* skip *)
+ | NK.IO, NK.MO, NK.O => (* skip *)
+ ELSE RETURN NIL;
+ END;
ELSIF (ext_pass_7) THEN
(* bootstrap with an assembler *)
Index: m3/pm3/language/modula3/m3compiler/m3export/src/m3makefile
diff -c m3/pm3/language/modula3/m3compiler/m3export/src/m3makefile:1.21 m3/pm3/language/modula3/m3compiler/m3export/src/m3makefile:1.22
*** m3/pm3/language/modula3/m3compiler/m3export/src/m3makefile:1.21 Fri Jan 29 20:51:22 1999
--- m3/pm3/language/modula3/m3compiler/m3export/src/m3makefile Mon Jun 7 13:11:31 1999
***************
*** 167,175 ****
CheckExec(["cvs","export","-D",NOW,"-d",versionName,"m3/pm3"],[],
EXPORT_TMP_SRC,"cvs export failed")
! > EXPORT_TMP_SRC & "/" & versionName & "/" & "m3config/src/VERSION" in
! write("VERSION=\"", VersionNumber(version),"\"",CR,
! "VERSION_DATE=\"",NOW,"\"",CR)
end
> EXPORT_TMP_SRC & "/" & versionName & "/" & "README" in
--- 167,175 ----
CheckExec(["cvs","export","-D",NOW,"-d",versionName,"m3/pm3"],[],
EXPORT_TMP_SRC,"cvs export failed")
! >> EXPORT_TMP_SRC & "/" & versionName & "/" & "m3config/src/COMMON" in
! write("M3_VERSION=\"", VersionNumber(version),"\"",CR,
! "M3_VERSION_DATE=\"",NOW,"\"",CR)
end
> EXPORT_TMP_SRC & "/" & versionName & "/" & "README" in
***************
*** 258,264 ****
VersionName(previousVersion)],[],".")
ret = Exec(["rm", "-r",
! EXPORT_SRC & "/" & "targzip" & "/" &
VersionName(previousVersion) & "-" & platform & "-boot.tgz"],
[],".")
--- 258,264 ----
VersionName(previousVersion)],[],".")
ret = Exec(["rm", "-r",
! EXPORT_ROOT & "/" & "targzip" & "/" &
VersionName(previousVersion) & "-" & platform & "-boot.tgz"],
[],".")
***************
*** 291,297 ****
CheckExec(["tar", "cfz", versionName & "-src.tgz", versionName],[],
EXPORT_TMP_SRC,"building src.tgz failed")
CheckExec(["mv", EXPORT_TMP_SRC & "/" & versionName & "-src.tgz",
! EXPORT_SRC & "/" & "targzip"],[],".","export tar source failed")
%
% Move the source tree
--- 291,297 ----
CheckExec(["tar", "cfz", versionName & "-src.tgz", versionName],[],
EXPORT_TMP_SRC,"building src.tgz failed")
CheckExec(["mv", EXPORT_TMP_SRC & "/" & versionName & "-src.tgz",
! EXPORT_ROOT & "/" & "targzip"],[],".","export tar source failed")
%
% Move the source tree
***************
*** 318,324 ****
"building boot.tgz failed")
CheckExec(["mv", EXPORT_TMP_BOOTSTRAP & "/" & platform & "/" &
versionName & "-" & platform & "-boot.tgz",
! EXPORT_SRC & "/" & "targzip"],
[],".","export tar boot failed")
%
--- 318,324 ----
"building boot.tgz failed")
CheckExec(["mv", EXPORT_TMP_BOOTSTRAP & "/" & platform & "/" &
versionName & "-" & platform & "-boot.tgz",
! EXPORT_ROOT & "/" & "targzip"],
[],".","export tar boot failed")
%
***************
*** 817,825 ****
CheckExec(["mv", "boot-" & TARGET, "Makefile",path_of("../../../../..")],
[], "../../m3bootstrap/" & TARGET & "/pm3-" & TARGET,
"move bootstrap to build binaries failed")
! CheckExec(["make","exportall","M3OPTIONS=" & M3MAKEOPTIONS],
! ["","make.stdout","make.stderr"],
! path_of("../../../../.."),"building bootstrap failed")
% Not in pre-release test mode
--- 817,827 ----
CheckExec(["mv", "boot-" & TARGET, "Makefile",path_of("../../../../..")],
[], "../../m3bootstrap/" & TARGET & "/pm3-" & TARGET,
"move bootstrap to build binaries failed")
! if not equal(PRERELEASE,"BOOTSTRAP")
! CheckExec(["make","exportall","M3OPTIONS=" & M3MAKEOPTIONS],
! ["","make.stdout","make.stderr"],
! path_of("../../../../.."),"building bootstrap failed")
! end
% Not in pre-release test mode
Index: m3/pm3/language/modula3/m3compiler/m3linker/src/MxGenCG.m3
diff -c m3/pm3/language/modula3/m3compiler/m3linker/src/MxGenCG.m3:1.4 m3/pm3/language/modula3/m3compiler/m3linker/src/MxGenCG.m3:1.5
*** m3/pm3/language/modula3/m3compiler/m3linker/src/MxGenCG.m3:1.4 Sun Oct 4 22:53:41 1998
--- m3/pm3/language/modula3/m3compiler/m3linker/src/MxGenCG.m3 Mon Jun 7 13:11:37 1999
***************
*** 391,416 ****
{ /* initialize RTLinker's global data */
_LINKER* linker = (_LINKER* )&@IR_Prefix[TRUE]@RTLinker;
*)
! s.main_proc.id := M3ID.Add("WinMain");
s.main_proc.proc :=
s.cg.declare_procedure(s.main_proc.id, 4, Target.CGType.Int,
0, Target.DefaultCall, TRUE, NIL);
s.self_var.id := M3ID.Add("self");
s.self_var.var :=
s.cg.declare_param(s.self_var.id, Target.Address.bytes,
! align, Target.CGType.Addr, 0, FALSE, FALSE, 1);
s.prev_var.id := M3ID.Add("pref");
s.prev_var.var :=
s.cg.declare_param(s.prev_var.id, Target.Address.bytes,
! align, Target.CGType.Addr, 0, FALSE, FALSE, 1);
s.argv_var.id := M3ID.Add("args");
s.argv_var.var :=
s.cg.declare_param(s.argv_var.id, Target.Address.bytes,
! align, Target.CGType.Addr, 0, FALSE, FALSE, 1);
s.mode_var.id := M3ID.Add("mode");
s.mode_var.var :=
s.cg.declare_param(s.mode_var.id, Target.Integer.bytes,
! align, Target.CGType.Int, 0, FALSE, FALSE, 1);
s.cg.begin_procedure(s.main_proc.proc);
s.linker_var.var :=
s.cg.declare_temp(Target.Address.bytes, align, Target.CGType.Addr,
--- 391,416 ----
{ /* initialize RTLinker's global data */
_LINKER* linker = (_LINKER* )&@IR_Prefix[TRUE]@RTLinker;
*)
! s.main_proc.id := M3ID.Add("WinMain@16");
s.main_proc.proc :=
s.cg.declare_procedure(s.main_proc.id, 4, Target.CGType.Int,
0, Target.DefaultCall, TRUE, NIL);
s.self_var.id := M3ID.Add("self");
s.self_var.var :=
s.cg.declare_param(s.self_var.id, Target.Address.bytes,
! 4, Target.CGType.Addr, 0, FALSE, FALSE, 1);
s.prev_var.id := M3ID.Add("pref");
s.prev_var.var :=
s.cg.declare_param(s.prev_var.id, Target.Address.bytes,
! 4, Target.CGType.Addr, 0, FALSE, FALSE, 1);
s.argv_var.id := M3ID.Add("args");
s.argv_var.var :=
s.cg.declare_param(s.argv_var.id, Target.Address.bytes,
! 4, Target.CGType.Addr, 0, FALSE, FALSE, 1);
s.mode_var.id := M3ID.Add("mode");
s.mode_var.var :=
s.cg.declare_param(s.mode_var.id, Target.Integer.bytes,
! 4, Target.CGType.Int, 0, FALSE, FALSE, 1);
s.cg.begin_procedure(s.main_proc.proc);
s.linker_var.var :=
s.cg.declare_temp(Target.Address.bytes, align, Target.CGType.Addr,
***************
*** 435,446 ****
s.cg.store(s.m3_link_info_var.var,
Target.Address.bytes + Target.Integer.bytes,
Target.CGType.Int);
! s.cg.load(s.argc_var.var, 0, Target.CGType.Addr);
s.cg.store(s.m3_link_info_var.var,
Target.Address.bytes + Target.Integer.bytes * 2,
Target.CGType.Addr);
! proc := s.cg.import_procedure(M3ID.Add("GetEnvironmentStrings"), 0,
Target.CGType.Addr, Target.DefaultCall);
s.cg.start_call_direct(proc, 0, Target.CGType.Addr);
s.cg.call_direct(proc, Target.CGType.Addr);
--- 435,446 ----
s.cg.store(s.m3_link_info_var.var,
Target.Address.bytes + Target.Integer.bytes,
Target.CGType.Int);
! s.cg.load(s.argv_var.var, 0, Target.CGType.Addr);
s.cg.store(s.m3_link_info_var.var,
Target.Address.bytes + Target.Integer.bytes * 2,
Target.CGType.Addr);
! proc := s.cg.import_procedure(M3ID.Add("GetEnvironmentStrings@0"), 0,
Target.CGType.Addr, Target.DefaultCall);
s.cg.start_call_direct(proc, 0, Target.CGType.Addr);
s.cg.call_direct(proc, Target.CGType.Addr);
***************
*** 555,562 ****
*)
<* ASSERT s.MM_RTLinker_var.var # NIL *>
s.cg.start_call_indirect(Target.CGType.Void, Target.DefaultCall);
! s.cg.load(s.MM_RTLinker_var.var, Target.Address.bytes * 10,
! Target.CGType.Addr);
s.cg.call_indirect(Target.CGType.Void, Target.DefaultCall);
(*
return 0;
--- 555,561 ----
*)
<* ASSERT s.MM_RTLinker_var.var # NIL *>
s.cg.start_call_indirect(Target.CGType.Void, Target.DefaultCall);
! s.cg.load(s.MM_RTLinker_var.var, 40, Target.CGType.Addr);
s.cg.call_indirect(Target.CGType.Void, Target.DefaultCall);
(*
return 0;
Index: m3/pm3/language/modula3/m3compiler/m3middle/src/M3File.m3
diff -c m3/pm3/language/modula3/m3compiler/m3middle/src/M3File.m3:1.1.1.1 m3/pm3/language/modula3/m3compiler/m3middle/src/M3File.m3:1.2
*** m3/pm3/language/modula3/m3compiler/m3middle/src/M3File.m3:1.1.1.1 Thu Jan 16 16:30:29 1997
--- m3/pm3/language/modula3/m3compiler/m3middle/src/M3File.m3 Mon Jun 7 13:11:43 1999
***************
*** 17,23 ****
RAISES {OSError.E} =
VAR ptr: BufPtr;
BEGIN
! IF (NUMBER (buf) <= 0) THEN RETURN 0 END;
ptr := LOOPHOLE (ADR (buf[0]), BufPtr);
RETURN f.read (SUBARRAY (ptr^, 0, MIN (len, NUMBER (buf))),
mayBlock := TRUE);
--- 17,23 ----
RAISES {OSError.E} =
VAR ptr: BufPtr;
BEGIN
! IF (NUMBER (buf) <= 0 OR len <= 0) THEN RETURN 0 END;
ptr := LOOPHOLE (ADR (buf[0]), BufPtr);
RETURN f.read (SUBARRAY (ptr^, 0, MIN (len, NUMBER (buf))),
mayBlock := TRUE);
Index: m3/pm3/language/modula3/m3compiler/m3middle/src/Target.m3
diff -c m3/pm3/language/modula3/m3compiler/m3middle/src/Target.m3:1.8 m3/pm3/language/modula3/m3compiler/m3middle/src/Target.m3:1.9
*** m3/pm3/language/modula3/m3compiler/m3middle/src/Target.m3:1.8 Wed Aug 26 10:54:26 1998
--- m3/pm3/language/modula3/m3compiler/m3middle/src/Target.m3 Mon Jun 7 13:11:43 1999
***************
*** 15,21 ****
TYPE
Systems = {
AIX386, ALPHA_OSF, AP3000, ARM, DS3100,
! FreeBSD, FreeBSD2, HP300, HPPA, IBMR2,
IBMRT, IRIX5, LINUX, LINUXELF, LINUXLIBC6,
NEXT, NT386, NT386GNU, OKI, SEQUENT,
SOLgnu, SOLsun, SPARC, SUN3, SUN386,
--- 15,21 ----
TYPE
Systems = {
AIX386, ALPHA_OSF, AP3000, ARM, DS3100,
! FBSD_ALPHA, FreeBSD, FreeBSD2, FreeBSD3, HP300, HPPA, IBMR2,
IBMRT, IRIX5, LINUX, LINUXELF, LINUXLIBC6,
NEXT, NT386, NT386GNU, OKI, SEQUENT,
SOLgnu, SOLsun, SPARC, SUN3, SUN386,
***************
*** 25,31 ****
CONST
SystemNames = ARRAY Systems OF TEXT {
"AIX386", "ALPHA_OSF", "AP3000", "ARM", "DS3100",
! "FreeBSD", "FreeBSD2", "HP300", "HPPA", "IBMR2",
"IBMRT", "IRIX5", "LINUX", "LINUXELF", "LINUXLIBC6",
"NEXT", "NT386", "NT386GNU", "OKI", "SEQUENT",
"SOLgnu", "SOLsun", "SPARC", "SUN3", "SUN386",
--- 25,31 ----
CONST
SystemNames = ARRAY Systems OF TEXT {
"AIX386", "ALPHA_OSF", "AP3000", "ARM", "DS3100",
! "FBSD_ALPHA", "FreeBSD", "FreeBSD2", "FreeBSD3", "HP300", "HPPA", "IBMR2",
"IBMRT", "IRIX5", "LINUX", "LINUXELF", "LINUXLIBC6",
"NEXT", "NT386", "NT386GNU", "OKI", "SEQUENT",
"SOLgnu", "SOLsun", "SPARC", "SUN3", "SUN386",
***************
*** 248,254 ****
Aligned_procedures := TRUE;
EOL := "\n";
! | Systems.FreeBSD, Systems.FreeBSD2 =>
max_align := 32;
Little_endian := TRUE;
PCC_bitfield_type_matters := TRUE;
--- 248,293 ----
Aligned_procedures := TRUE;
EOL := "\n";
! | Systems.FBSD_ALPHA =>
! Int_C.cg_type := CGType.Int_C;
! Word_C.cg_type := CGType.Word_C;
! Word_C.max.x[1] := FF;
!
! Int_D.cg_type := CGType.Int_D;
! Int_D.size := 64;
! Int_D.align := 64;
! Int_D.min.x := IChunks { 00, 00, 00, 16_8000 };
! Int_D.max.x := IChunks { FF, FF, FF, 16_7fff };
!
! Word_D.cg_type := CGType.Word_D;
! Word_D.size := 64;
! Word_D.align := 64;
! Word_D.min.x := IChunks { 00, 00, 00, 00 };
! Word_D.max.x := IChunks { FF, FF, FF, FF };
!
! Integer := Int_D;
! Address := Word_D;
! Address.cg_type := CGType.Addr;
!
! max_align := 64;
! Little_endian := TRUE;
! PCC_bitfield_type_matters := TRUE;
! Structure_size_boundary := 8;
! Bitfield_can_overlap := FALSE;
! First_readable_addr := 8192 * Char.size;
! Jumpbuf_size := 82 * Address.size;
! Jumpbuf_align := Address.align;
! Fixed_frame_size := 4 * Address.size;
! Guard_page_size := 8192 * Char.size;
! All_floats_legal := TRUE;
! Has_stack_walker := FALSE;
! Setjmp := "_setjmp";
! Checks_integer_ops := FALSE;
! Global_handler_stack := TRUE;
! Aligned_procedures := TRUE;
! EOL := "\n";
!
! | Systems.FreeBSD, Systems.FreeBSD2, Systems.FreeBSD3 =>
max_align := 32;
Little_endian := TRUE;
PCC_bitfield_type_matters := TRUE;
Index: m3/pm3/language/modula3/m3compiler/m3ship/src/Main.m3
diff -c m3/pm3/language/modula3/m3compiler/m3ship/src/Main.m3:1.5 m3/pm3/language/modula3/m3compiler/m3ship/src/Main.m3:1.6
*** m3/pm3/language/modula3/m3compiler/m3ship/src/Main.m3:1.5 Fri Nov 28 09:23:31 1997
--- m3/pm3/language/modula3/m3compiler/m3ship/src/Main.m3 Mon Jun 7 13:11:49 1999
***************
*** 13,19 ****
CONST
SL = M3Config.PATH_SEP;
! M3_VERSION = "SRC Modula-3 version XX.X";
TYPE
DefineList = REF RECORD
--- 13,20 ----
CONST
SL = M3Config.PATH_SEP;
! M3_VERSION = "PM3 Version " & M3Config.M3_VERSION &
! " (" & M3Config.M3_VERSION_DATE & ")";
TYPE
DefineList = REF RECORD
Index: m3/pm3/language/modula3/m3compiler/m3templates/src/BldFace.m3
diff -c m3/pm3/language/modula3/m3compiler/m3templates/src/BldFace.m3:1.5 m3/pm3/language/modula3/m3compiler/m3templates/src/BldFace.m3:1.6
*** m3/pm3/language/modula3/m3compiler/m3templates/src/BldFace.m3:1.5 Tue Aug 25 12:50:09 1998
--- m3/pm3/language/modula3/m3compiler/m3templates/src/BldFace.m3 Mon Jun 7 13:11:54 1999
***************
*** 70,75 ****
--- 70,78 ----
GetIt("INTERNAL_BACKEND",val);
t.ext_pass_6 := NOT QVal.ToBool(m,val);
+ GetIt("BOOTSTRAP_TO_IL",val);
+ t.bootstrap_il := QVal.ToBool(m,val);
+
GetIt("M3_BACKEND_OUTPUT",val);
id := QVal.ToID(m,val);
FOR i := FIRST(outarr) TO LAST(outarr) DO
Index: m3/pm3/language/modula3/m3compiler/m3templates/src/BldQuake.m3
diff -c m3/pm3/language/modula3/m3compiler/m3templates/src/BldQuake.m3:1.34 m3/pm3/language/modula3/m3compiler/m3templates/src/BldQuake.m3:1.35
*** m3/pm3/language/modula3/m3compiler/m3templates/src/BldQuake.m3:1.34 Tue Aug 25 12:50:09 1998
--- m3/pm3/language/modula3/m3compiler/m3templates/src/BldQuake.m3 Mon Jun 7 13:11:54 1999
***************
*** 1598,1604 ****
--- 1598,1641 ----
QVal.ToText(t, dest));
END DoInstallLink;
+ PROCEDURE InstallAliasLink(t: T; src, target, alias, dest: TEXT) RAISES {Error}=
+ VAR
+ val : QValue.T;
+ link : TEXT;
+ wr : Wr.T;
+ BEGIN
+ IF t.get(M3ID.Add("HAVE_PKGTOOLS"), val) AND QVal.ToBool(t, val) THEN
+ RAISE Error("install_alias_link not implemented for pkgtools");
+ ELSE
+ target := target & t.SL & src;
+ link := dest & t.SL & alias;
+ TRY
+ wr := FileWr.OpenAppend(M3SHIP_FILE);
+
+ U_InstallDir(t, dest, wr);
+ Wr.PutText(wr, "link_file(\""& Escape(target) & "\", \"" & Escape(link) & "\")" & t.CR);
+ Utils.CloseWriter(wr, M3SHIP_FILE);
+ EXCEPT
+ M3Driver.Error, OSError.E, Thread.Alerted,
+ Wr.Failure => FErr(M3SHIP_FILE);
+ END;
+ END;
+ END InstallAliasLink;
+
+ PROCEDURE DoInstallAliasLink(t: QMachine.T; n_args: INTEGER) RAISES {Error}=
+ VAR src, target, alias, dest: QValue.T;
+ BEGIN
+ <* ASSERT n_args = 4 *>
+ t.pop(dest);
+ t.pop(alias);
+ t.pop(target);
+ t.pop(src);
+ InstallAliasLink(t, QVal.ToText(t, src), QVal.ToText(t, target),
+ QVal.ToText(t, alias), QVal.ToText(t, dest));
+ END DoInstallAliasLink;
+
+
(*--------------------------------------------------- exported interfaces ---*)
(* installation of exported interfaces & implementations *)
***************
*** 2315,2322 ****
IF GenUnit(t.s_sources) THEN RETURN END;
arr := BldHooks.WhereUnitsHooks(t);
! FOR i := FIRST(arr^) TO LAST(arr^) DO
! IF GenUnit(arr[i]) THEN RETURN END;
END;
Wr.PutText(t.cur_wr(), "\"" & unit & "\" not found" & t.CR); <* NOWARN *>
--- 2352,2361 ----
IF GenUnit(t.s_sources) THEN RETURN END;
arr := BldHooks.WhereUnitsHooks(t);
! IF (arr # NIL) THEN
! FOR i := FIRST(arr^) TO LAST(arr^) DO
! IF GenUnit(arr[i]) THEN RETURN END;
! END;
END;
Wr.PutText(t.cur_wr(), "\"" & unit & "\" not found" & t.CR); <* NOWARN *>
***************
*** 3052,3058 ****
PROCEDURE InitProcs(): REF ARRAY OF ProcRec =
VAR
! Procs := NEW(REF ARRAY OF ProcRec, 117);
BEGIN
Procs[0].proc := NewProc ("reset_cache", DoResetCache, 0, FALSE);
Procs[1].proc := NewProc ("m3", DoM3, 0, FALSE);
--- 3091,3097 ----
PROCEDURE InitProcs(): REF ARRAY OF ProcRec =
VAR
! Procs := NEW(REF ARRAY OF ProcRec, 118);
BEGIN
Procs[0].proc := NewProc ("reset_cache", DoResetCache, 0, FALSE);
Procs[1].proc := NewProc ("m3", DoM3, 0, FALSE);
***************
*** 3188,3193 ****
--- 3227,3234 ----
Procs[114].proc := NewProc("install_sources", DoInstallSources, 0, FALSE);
Procs[115].proc := NewProc("_install_file", DoInstallFile, 4, FALSE);
Procs[116].proc := NewProc("inc", DoInc, 2, TRUE);
+ Procs[117].proc := NewProc("install_alias_link", DoInstallAliasLink, 4,
+ FALSE);
RETURN Procs;
END InitProcs;
Index: m3/pm3/language/modula3/m3compiler/m3where/src/Main.m3
diff -c m3/pm3/language/modula3/m3compiler/m3where/src/Main.m3:1.5 m3/pm3/language/modula3/m3compiler/m3where/src/Main.m3:1.6
*** m3/pm3/language/modula3/m3compiler/m3where/src/Main.m3:1.5 Fri Nov 28 09:23:58 1997
--- m3/pm3/language/modula3/m3compiler/m3where/src/Main.m3 Mon Jun 7 13:12:38 1999
***************
*** 13,19 ****
CONST
SL = M3Config.PATH_SEP;
! M3_VERSION = "SRC Modula-3 version XX.X";
TYPE
DefineList = REF RECORD
--- 13,20 ----
CONST
SL = M3Config.PATH_SEP;
! M3_VERSION = "PM3 Version " & M3Config.M3_VERSION &
! " (" & M3Config.M3_VERSION_DATE & ")";
TYPE
DefineList = REF RECORD
Index: m3/pm3/language/modula3/m3compiler/src/m3args.html
diff -c m3/pm3/language/modula3/m3compiler/src/m3args.html:1.2 m3/pm3/language/modula3/m3compiler/src/m3args.html:1.3
*** m3/pm3/language/modula3/m3compiler/src/m3args.html:1.2 Tue Feb 10 22:57:47 1998
--- m3/pm3/language/modula3/m3compiler/src/m3args.html Mon Jun 7 13:12:47 1999
***************
*** 82,87 ****
--- 82,103 ----
the dump includes exception and procedure frames. On other systems only
the exception frames are dumped.
+ - @M3nopreemption disables preemptive scheduling, on platforms where
+ user level threads are used.
+
+
- @M3netobjlog produces debugging information for tracing network
+ objects invocations.
+
+
- @M3ngcmonitor produces debugging information for tracing network
+ objects distributed garbage collection.
+
+
- @M3StarTrek disables showing a StarTrek shaped icon during
+ garbage collection pauses when using the Trestle library.
+
+
- Options @M3CheckShape, @M3TraceWinMsgs, and @M3SlowTrace are available
+ to activate sanity checks on VBT shapes, and to produce a trace of Windows
+ messages for Trestle in Win32.
+
Index: m3/pm3/language/modula3/m3tools/coverage/src/analyze_coverage.c
diff -c m3/pm3/language/modula3/m3tools/coverage/src/analyze_coverage.c:1.2 m3/pm3/language/modula3/m3tools/coverage/src/analyze_coverage.c:1.3
*** m3/pm3/language/modula3/m3tools/coverage/src/analyze_coverage.c:1.2 Fri Jan 17 14:21:26 1997
--- m3/pm3/language/modula3/m3tools/coverage/src/analyze_coverage.c Mon Jun 7 13:12:52 1999
***************
*** 26,32 ****
char text[100] = "";
FILE *code;
! FILE* output_file = stdout;
/*****
long current_line, line, count, p, number;
char c;
--- 26,32 ----
char text[100] = "";
FILE *code;
! FILE* output_file;
/*****
long current_line, line, count, p, number;
char c;
***************
*** 560,565 ****
--- 560,566 ----
char *s;
program_name = basename (argv[0]);
+ output_file = stdout;
init_command (argc-1, argv+1);
source_path = getenv ("COVERAGE_PATH");
Index: m3/pm3/language/modula3/m3tools/gnuemacs/src/lex-yacc/lex.yy.c
diff -c m3/pm3/language/modula3/m3tools/gnuemacs/src/lex-yacc/lex.yy.c:1.1.1.1 m3/pm3/language/modula3/m3tools/gnuemacs/src/lex-yacc/lex.yy.c:1.2
*** m3/pm3/language/modula3/m3tools/gnuemacs/src/lex-yacc/lex.yy.c:1.1.1.1 Thu Jan 16 16:31:51 1997
--- m3/pm3/language/modula3/m3tools/gnuemacs/src/lex-yacc/lex.yy.c Thu Apr 29 23:57:01 1999
***************
*** 1,23 ****
! # include "stdio.h"
! # define U(x) ((x)&0377)
# define NLSTATE yyprevious=YYNEWLINE
# define BEGIN yybgin = yysvec + 1 +
# define INITIAL 0
# define YYLERR yysvec
# define YYSTATE (yyestate-yysvec-1)
# define YYOPTIM 1
! # define YYLMAX 200
! # define output(c) putc(c,yyout)
! # define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)
# define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;}
# define yymore() (yymorfg=1)
! # define ECHO fprintf(yyout, "%s",yytext)
# define REJECT { nstr = yyreject(); goto yyfussy;}
! int yyleng; extern char yytext[];
int yymorfg;
extern char *yysptr, yysbuf[];
int yytchar;
! FILE *yyin ={stdin}, *yyout ={stdout};
extern int yylineno;
struct yysvf {
struct yywork *yystoff;
--- 1,73 ----
! #include
! # define U(x) x
# define NLSTATE yyprevious=YYNEWLINE
# define BEGIN yybgin = yysvec + 1 +
# define INITIAL 0
# define YYLERR yysvec
# define YYSTATE (yyestate-yysvec-1)
# define YYOPTIM 1
! # define YYLMAX BUFSIZ
! #ifndef __cplusplus
! # define output(c) (void)putc(c,yyout)
! #else
! # define lex_output(c) (void)putc(c,yyout)
! #endif
!
! #if defined(__cplusplus) || defined(__STDC__)
!
! #if defined(__cplusplus) && defined(__EXTERN_C__)
! extern "C" {
! #endif
! int yyback(int *, int);
! int yyinput(void);
! int yylook(void);
! void yyoutput(int);
! int yyracc(int);
! int yyreject(void);
! void yyunput(int);
! int yylex(void);
! #ifdef YYLEX_E
! void yywoutput(wchar_t);
! wchar_t yywinput(void);
! #endif
! #ifndef yyless
! int yyless(int);
! #endif
! #ifndef yywrap
! int yywrap(void);
! #endif
! #ifdef LEXDEBUG
! void allprint(char);
! void sprint(char *);
! #endif
! #if defined(__cplusplus) && defined(__EXTERN_C__)
! }
! #endif
!
! #ifdef __cplusplus
! extern "C" {
! #endif
! void exit(int);
! #ifdef __cplusplus
! }
! #endif
!
! #endif
# define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;}
# define yymore() (yymorfg=1)
! #ifndef __cplusplus
! # define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)
! #else
! # define lex_input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)
! #endif
! #define ECHO fprintf(yyout, "%s",yytext)
# define REJECT { nstr = yyreject(); goto yyfussy;}
! int yyleng;
! char yytext[YYLMAX];
int yymorfg;
extern char *yysptr, yysbuf[];
int yytchar;
! FILE *yyin = {stdin}, *yyout = {stdout};
extern int yylineno;
struct yysvf {
struct yywork *yystoff;
***************
*** 25,30 ****
--- 75,107 ----
int *yystops;};
struct yysvf *yyestate;
extern struct yysvf yysvec[], *yybgin;
+
+ # line 2 "../parse.lex"
+ /* Copyright (C) 1989, Digital Equipment Corporation */
+
+ # line 3 "../parse.lex"
+ /* All rights reserved. */
+
+ # line 4 "../parse.lex"
+ /* See the file COPYRIGHT for a full description. */
+
+ # line 5 "../parse.lex"
+ /* */
+
+ # line 6 "../parse.lex"
+ /* Last modified on Mon Jan 30 09:18:47 PST 1995 by kalsow */
+
+ # line 7 "../parse.lex"
+ /* modified on Fri Mar 20 20:11:40 PST 1992 by muller */
+
+ # line 8 "../parse.lex"
+ /* modified on Fri Jan 31 16:09:58 PST 1992 by goldberg@xerox.com */
+
+ # line 9 "../parse.lex"
+ /* modified on Mon Nov 25 17:41:09 PST 1991 by meehan */
+
+ # line 10 "../parse.lex"
+ /* modified on Mon Aug 19 14:51:03 1991 by nichols@xerox.com */
# define Prog 2
# define Com 4
# define Prag 6
***************
*** 43,139 ****
}
initializeLex ()
{
! BEGIN Prog;
! }
# define YYNEWLINE 10
yylex(){
int nstr; extern int yyprevious;
while((nstr = yylook()) >= 0)
yyfussy: switch(nstr){
case 0:
if(yywrap()) return(0); break;
case 1:
{eot(); return(PLUS);}
break;
case 2:
{eot(); return(MINUS);}
break;
case 3:
{eot(); return(ASTERISK);}
break;
case 4:
{eot(); return(SLASH);}
break;
case 5:
{eot(); return(ASSIGN);}
break;
case 6:
{eot(); return(AMPERSAND);}
break;
case 7:
{eot(); return(DOT);}
break;
case 8:
{eot(); return(COMMA);}
break;
case 9:
{eot(); return(SEMICOLON);}
break;
case 10:
{eot(); return(LPAREN);}
break;
case 11:
{eot(); return(LBRACKET);}
break;
case 12:
{eot(); return(LBRACE);}
break;
case 13:
{eot(); return(UPARROW);}
break;
case 14:
{eot(); return(EQUAL);}
break;
case 15:
{eot(); return(RARROW);}
break;
case 16:
{eot(); return(SHARP);}
break;
case 17:
{eot(); return(LESS);}
break;
case 18:
{eot(); return(GREATER);}
break;
case 19:
{eot(); return(LSEQUAL);}
break;
case 20:
{eot(); return(SUBTYPE);}
break;
case 21:
{eot(); return(GREQUAL);}
break;
case 22:
{eot(); return(DOTDOT);}
break;
case 23:
{eot(); return(COLON);}
break;
case 24:
{eot(); return(RPAREN);}
break;
case 25:
{eot(); return(RBRACKET);}
break;
case 26:
{eot(); return(RBRACE);}
break;
case 27:
{eot(); return(BAR);}
break;
case 28:
{PTRKEYWORDENTRY tempp;
eot();
if ((tempp=lookup(yytext))!=NULL){
--- 120,277 ----
}
initializeLex ()
{
! BEGIN Prog;
! }
# define YYNEWLINE 10
yylex(){
int nstr; extern int yyprevious;
+ #ifdef __cplusplus
+ /* to avoid CC and lint complaining yyfussy not being used ...*/
+ static int __lex_hack = 0;
+ if (__lex_hack) goto yyfussy;
+ #endif
while((nstr = yylook()) >= 0)
yyfussy: switch(nstr){
case 0:
if(yywrap()) return(0); break;
case 1:
+
+ # line 36 "../parse.lex"
{eot(); return(PLUS);}
break;
case 2:
+
+ # line 37 "../parse.lex"
{eot(); return(MINUS);}
break;
case 3:
+
+ # line 38 "../parse.lex"
{eot(); return(ASTERISK);}
break;
case 4:
+
+ # line 39 "../parse.lex"
{eot(); return(SLASH);}
break;
case 5:
+
+ # line 40 "../parse.lex"
{eot(); return(ASSIGN);}
break;
case 6:
+
+ # line 41 "../parse.lex"
{eot(); return(AMPERSAND);}
break;
case 7:
+
+ # line 42 "../parse.lex"
{eot(); return(DOT);}
break;
case 8:
+
+ # line 43 "../parse.lex"
{eot(); return(COMMA);}
break;
case 9:
+
+ # line 44 "../parse.lex"
{eot(); return(SEMICOLON);}
break;
case 10:
+
+ # line 45 "../parse.lex"
{eot(); return(LPAREN);}
break;
case 11:
+
+ # line 46 "../parse.lex"
{eot(); return(LBRACKET);}
break;
case 12:
+
+ # line 47 "../parse.lex"
{eot(); return(LBRACE);}
break;
case 13:
+
+ # line 48 "../parse.lex"
{eot(); return(UPARROW);}
break;
case 14:
+
+ # line 49 "../parse.lex"
{eot(); return(EQUAL);}
break;
case 15:
+
+ # line 50 "../parse.lex"
{eot(); return(RARROW);}
break;
case 16:
+
+ # line 51 "../parse.lex"
{eot(); return(SHARP);}
break;
case 17:
+
+ # line 52 "../parse.lex"
{eot(); return(LESS);}
break;
case 18:
+
+ # line 53 "../parse.lex"
{eot(); return(GREATER);}
break;
case 19:
+
+ # line 54 "../parse.lex"
{eot(); return(LSEQUAL);}
break;
case 20:
+
+ # line 55 "../parse.lex"
{eot(); return(SUBTYPE);}
break;
case 21:
+
+ # line 56 "../parse.lex"
{eot(); return(GREQUAL);}
break;
case 22:
+
+ # line 57 "../parse.lex"
{eot(); return(DOTDOT);}
break;
case 23:
+
+ # line 58 "../parse.lex"
{eot(); return(COLON);}
break;
case 24:
+
+ # line 59 "../parse.lex"
{eot(); return(RPAREN);}
break;
case 25:
+
+ # line 60 "../parse.lex"
{eot(); return(RBRACKET);}
break;
case 26:
+
+ # line 61 "../parse.lex"
{eot(); return(RBRACE);}
break;
case 27:
+
+ # line 62 "../parse.lex"
{eot(); return(BAR);}
break;
case 28:
+
+ # line 64 "../parse.lex"
{PTRKEYWORDENTRY tempp;
eot();
if ((tempp=lookup(yytext))!=NULL){
***************
*** 145,214 ****
}
break;
case 29:
{eot(); return(CARD_CONST);}
break;
case 30:
{eot(); return(REAL_CONST);}
break;
case 31:
{
eot();
return(STR_CONST);}
break;
case 32:
{
eot();
return(STR_CONST);}
break;
case 33:
{eot(); eol();}
break;
case 34:
{eot(); }
break;
case 35:
/* other spaces */ /* putchar(' ')*/ eot();
break;
case 36:
{eot(); BEGIN Com; comdepth=1; }
break;
case 37:
{eot(); comdepth++; }
break;
case 38:
{eot(); comdepth--; if (comdepth==0) BEGIN Prog; }
break;
case 39:
{eot(); BEGIN Prag; pragdepth=1; }
break;
case 40:
{eot(); pragdepth++; }
break;
case 41:
{eot(); pragdepth--; if (pragdepth==0) BEGIN Prog; }
break;
case 42:
{eot(); eol();}
break;
case 43:
{eot(); eol();}
break;
case 44:
{eot();}
break;
case 45:
{eot();}
break;
case 46:
{yyless(0); BEGIN Prog;}
break;
case -1:
break;
default:
! fprintf(yyout,"bad switch yylook %d",nstr);
} return(0); }
/* end of yylex */
! int yyvstop[] ={
0,
46,
--- 283,388 ----
}
break;
case 29:
+
+ # line 74 "../parse.lex"
{eot(); return(CARD_CONST);}
break;
case 30:
+
+ # line 76 "../parse.lex"
{eot(); return(REAL_CONST);}
break;
case 31:
+
+ # line 78 "../parse.lex"
{
eot();
return(STR_CONST);}
break;
case 32:
+
+ # line 82 "../parse.lex"
{
eot();
return(STR_CONST);}
break;
case 33:
+
+ # line 86 "../parse.lex"
{eot(); eol();}
break;
case 34:
+
+ # line 87 "../parse.lex"
{eot(); }
break;
case 35:
+
+ # line 88 "../parse.lex"
/* other spaces */ /* putchar(' ')*/ eot();
break;
case 36:
+
+ # line 91 "../parse.lex"
{eot(); BEGIN Com; comdepth=1; }
break;
case 37:
+
+ # line 92 "../parse.lex"
{eot(); comdepth++; }
break;
case 38:
+
+ # line 93 "../parse.lex"
{eot(); comdepth--; if (comdepth==0) BEGIN Prog; }
break;
case 39:
+
+ # line 95 "../parse.lex"
{eot(); BEGIN Prag; pragdepth=1; }
break;
case 40:
+
+ # line 96 "../parse.lex"
{eot(); pragdepth++; }
break;
case 41:
+
+ # line 97 "../parse.lex"
{eot(); pragdepth--; if (pragdepth==0) BEGIN Prog; }
break;
case 42:
+
+ # line 99 "../parse.lex"
{eot(); eol();}
break;
case 43:
+
+ # line 100 "../parse.lex"
{eot(); eol();}
break;
case 44:
+
+ # line 101 "../parse.lex"
{eot();}
break;
case 45:
+
+ # line 102 "../parse.lex"
{eot();}
break;
case 46:
+
+ # line 104 "../parse.lex"
{yyless(0); BEGIN Prog;}
break;
case -1:
break;
default:
! (void)fprintf(yyout,"bad switch yylook %d",nstr);
} return(0); }
/* end of yylex */
! int yyvstop[] = {
0,
46,
***************
*** 433,439 ****
0,
0};
# define YYTYPE unsigned char
! struct yywork { YYTYPE verify, advance; } yycrank[] ={
0,0, 0,0, 1,9, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 1,9, 1,0,
--- 607,613 ----
0,
0};
# define YYTYPE unsigned char
! struct yywork { YYTYPE verify, advance; } yycrank[] = {
0,0, 0,0, 1,9, 0,0,
0,0, 0,0, 0,0, 0,0,
0,0, 0,0, 1,9, 1,0,
***************
*** 568,574 ****
0,0, 0,0, 57,73, 57,73,
57,73, 57,73, 57,73, 57,73,
0,0};
! struct yysvf yysvec[] ={
0, 0, 0,
yycrank+-1, 0, 0,
yycrank+-2, yysvec+1, 0,
--- 742,748 ----
0,0, 0,0, 57,73, 57,73,
57,73, 57,73, 57,73, 57,73,
0,0};
! struct yysvf yysvec[] = {
0, 0, 0,
yycrank+-1, 0, 0,
yycrank+-2, yysvec+1, 0,
***************
*** 649,689 ****
0, 0, 0};
struct yywork *yytop = yycrank+531;
struct yysvf *yybgin = yysvec+1;
! char yymatch[] ={
! 00 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
! 01 ,011 ,012 ,01 ,011 ,01 ,01 ,01 ,
! 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
! 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
! 011 ,01 ,'"' ,01 ,01 ,01 ,01 ,047 ,
! 01 ,01 ,01 ,'+' ,01 ,'+' ,'.' ,01 ,
! '0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,
! '0' ,'0' ,01 ,01 ,01 ,01 ,01 ,01 ,
! 01 ,'A' ,'A' ,'A' ,'D' ,'D' ,'A' ,'G' ,
! 'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,
! 'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,
! 'X' ,'G' ,'G' ,01 ,0134,01 ,01 ,'_' ,
! 01 ,'A' ,'A' ,'A' ,'D' ,'D' ,'A' ,'G' ,
! 'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,
! 'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,
! 'X' ,'G' ,'G' ,01 ,01 ,01 ,01 ,01 ,
! 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
! 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
! 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
! 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
! 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
! 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
! 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
! 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
! 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
! 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
! 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
! 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
! 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
! 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
! 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
! 01 ,01 ,01 ,01 ,01 ,01 ,01 ,01 ,
0};
! char yyextra[] ={
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
--- 823,863 ----
0, 0, 0};
struct yywork *yytop = yycrank+531;
struct yysvf *yybgin = yysvec+1;
! char yymatch[] = {
! 0, 1, 1, 1, 1, 1, 1, 1,
! 1, 9, 10, 1, 9, 1, 1, 1,
! 1, 1, 1, 1, 1, 1, 1, 1,
! 1, 1, 1, 1, 1, 1, 1, 1,
! 9, 1, 34, 1, 1, 1, 1, 39,
! 1, 1, 1, 43, 1, 43, 46, 1,
! 48, 48, 48, 48, 48, 48, 48, 48,
! 48, 48, 1, 1, 1, 1, 1, 1,
! 1, 65, 65, 65, 68, 68, 65, 71,
! 71, 71, 71, 71, 71, 71, 71, 71,
! 71, 71, 71, 71, 71, 71, 71, 71,
! 88, 71, 71, 1, 92, 1, 1, 95,
! 1, 65, 65, 65, 68, 68, 65, 71,
! 71, 71, 71, 71, 71, 71, 71, 71,
! 71, 71, 71, 71, 71, 71, 71, 71,
! 88, 71, 71, 1, 1, 1, 1, 1,
! 1, 1, 1, 1, 1, 1, 1, 1,
! 1, 1, 1, 1, 1, 1, 1, 1,
! 1, 1, 1, 1, 1, 1, 1, 1,
! 1, 1, 1, 1, 1, 1, 1, 1,
! 1, 1, 1, 1, 1, 1, 1, 1,
! 1, 1, 1, 1, 1, 1, 1, 1,
! 1, 1, 1, 1, 1, 1, 1, 1,
! 1, 1, 1, 1, 1, 1, 1, 1,
! 1, 1, 1, 1, 1, 1, 1, 1,
! 1, 1, 1, 1, 1, 1, 1, 1,
! 1, 1, 1, 1, 1, 1, 1, 1,
! 1, 1, 1, 1, 1, 1, 1, 1,
! 1, 1, 1, 1, 1, 1, 1, 1,
! 1, 1, 1, 1, 1, 1, 1, 1,
! 1, 1, 1, 1, 1, 1, 1, 1,
! 1, 1, 1, 1, 1, 1, 1, 1,
0};
! char yyextra[] = {
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
***************
*** 691,713 ****
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0};
! /* ncform 4.1 83/08/11 */
int yylineno =1;
# define YYU(x) x
# define NLSTATE yyprevious=YYNEWLINE
- char yytext[YYLMAX];
struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
char yysbuf[YYLMAX];
char *yysptr = yysbuf;
int *yyfnd;
extern struct yysvf *yyestate;
int yyprevious = YYNEWLINE;
! yylook(){
register struct yysvf *yystate, **lsp;
register struct yywork *yyt;
struct yysvf *yyz;
! int yych;
struct yywork *yyr;
# ifdef LEXDEBUG
int debug;
--- 865,898 ----
0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,
0};
! /* Copyright (c) 1989 AT&T */
! /* All Rights Reserved */
!
! /* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */
! /* The copyright notice above does not evidence any */
! /* actual or intended publication of such source code. */
+ #pragma ident "@(#)ncform 6.8 95/02/11 SMI"
+
int yylineno =1;
# define YYU(x) x
# define NLSTATE yyprevious=YYNEWLINE
struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
char yysbuf[YYLMAX];
char *yysptr = yysbuf;
int *yyfnd;
extern struct yysvf *yyestate;
int yyprevious = YYNEWLINE;
! #if defined(__cplusplus) || defined(__STDC__)
! int yylook(void)
! #else
! yylook()
! #endif
! {
register struct yysvf *yystate, **lsp;
register struct yywork *yyt;
struct yysvf *yyz;
! int yych, yyfirst;
struct yywork *yyr;
# ifdef LEXDEBUG
int debug;
***************
*** 717,722 ****
--- 902,908 ----
# ifdef LEXDEBUG
debug = 0;
# endif
+ yyfirst=1;
if (!yymorfg)
yylastch = yytext;
else {
***************
*** 732,747 ****
if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
# endif
yyt = yystate->yystoff;
! if(yyt == yycrank){ /* may not be any transitions */
yyz = yystate->yyother;
if(yyz == 0)break;
if(yyz->yystoff == yycrank)break;
}
*yylastch++ = yych = input();
tryagain:
# ifdef LEXDEBUG
if(debug){
! fprintf(yyout,"unsigned char ");
allprint(yych);
putchar('\n');
}
--- 918,942 ----
if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
# endif
yyt = yystate->yystoff;
! if(yyt == yycrank && !yyfirst){ /* may not be any transitions */
yyz = yystate->yyother;
if(yyz == 0)break;
if(yyz->yystoff == yycrank)break;
}
+ #ifndef __cplusplus
*yylastch++ = yych = input();
+ #else
+ *yylastch++ = yych = lex_input();
+ #endif
+ if(yylastch > &yytext[YYLMAX]) {
+ fprintf(yyout,"Input string too long, limit %d\n",YYLMAX);
+ exit(1);
+ }
+ yyfirst=0;
tryagain:
# ifdef LEXDEBUG
if(debug){
! fprintf(yyout,"char ");
allprint(yych);
putchar('\n');
}
***************
*** 753,758 ****
--- 948,957 ----
if(yyt->advance+yysvec == YYLERR) /* error transitions */
{unput(*--yylastch);break;}
*lsp++ = yystate = yyt->advance+yysvec;
+ if(lsp > &yylstate[YYLMAX]) {
+ fprintf(yyout,"Input string too long, limit %d\n",YYLMAX);
+ exit(1);
+ }
goto contin;
}
}
***************
*** 767,772 ****
--- 966,975 ----
if(yyt->advance+yysvec == YYLERR) /* error transitions */
{unput(*--yylastch);break;}
*lsp++ = yystate = yyt->advance+yysvec;
+ if(lsp > &yylstate[YYLMAX]) {
+ fprintf(yyout,"Input string too long, limit %d\n",YYLMAX);
+ exit(1);
+ }
goto contin;
}
yyt = yyr + YYU(yymatch[yych]);
***************
*** 781,786 ****
--- 984,993 ----
if(yyt->advance+yysvec == YYLERR) /* error transition */
{unput(*--yylastch);break;}
*lsp++ = yystate = yyt->advance+yysvec;
+ if(lsp > &yylstate[YYLMAX]) {
+ fprintf(yyout,"Input string too long, limit %d\n",YYLMAX);
+ exit(1);
+ }
goto contin;
}
}
***************
*** 840,874 ****
yysptr=yysbuf;
return(0);
}
yyprevious = yytext[0] = input();
if (yyprevious>0)
output(yyprevious);
yylastch=yytext;
# ifdef LEXDEBUG
if(debug)putchar('\n');
# endif
}
}
yyback(p, m)
int *p;
{
! if (p==0) return(0);
! while (*p)
! {
! if (*p++ == m)
! return(1);
}
! return(0);
}
/* the following are only used in the lex library */
! yyinput(){
return(input());
}
yyoutput(c)
! int c; {
output(c);
}
yyunput(c)
! int c; {
unput(c);
}
--- 1047,1113 ----
yysptr=yysbuf;
return(0);
}
+ #ifndef __cplusplus
yyprevious = yytext[0] = input();
if (yyprevious>0)
output(yyprevious);
+ #else
+ yyprevious = yytext[0] = lex_input();
+ if (yyprevious>0)
+ lex_output(yyprevious);
+ #endif
yylastch=yytext;
# ifdef LEXDEBUG
if(debug)putchar('\n');
# endif
}
}
+ #if defined(__cplusplus) || defined(__STDC__)
+ int yyback(int *p, int m)
+ #else
yyback(p, m)
int *p;
+ #endif
{
! if (p==0) return(0);
! while (*p) {
! if (*p++ == m)
! return(1);
}
! return(0);
}
/* the following are only used in the lex library */
! #if defined(__cplusplus) || defined(__STDC__)
! int yyinput(void)
! #else
! yyinput()
! #endif
! {
! #ifndef __cplusplus
return(input());
+ #else
+ return(lex_input());
+ #endif
}
+ #if defined(__cplusplus) || defined(__STDC__)
+ void yyoutput(int c)
+ #else
yyoutput(c)
! int c;
! #endif
! {
! #ifndef __cplusplus
output(c);
+ #else
+ lex_output(c);
+ #endif
}
+ #if defined(__cplusplus) || defined(__STDC__)
+ void yyunput(int c)
+ #else
yyunput(c)
! int c;
! #endif
! {
unput(c);
}
Index: m3/pm3/language/modula3/m3tools/gnuemacs/src/lex-yacc/y.tab.c
diff -c m3/pm3/language/modula3/m3tools/gnuemacs/src/lex-yacc/y.tab.c:1.1.1.1 m3/pm3/language/modula3/m3tools/gnuemacs/src/lex-yacc/y.tab.c:1.2
*** m3/pm3/language/modula3/m3tools/gnuemacs/src/lex-yacc/y.tab.c:1.1.1.1 Thu Jan 16 16:31:51 1997
--- m3/pm3/language/modula3/m3tools/gnuemacs/src/lex-yacc/y.tab.c Thu Apr 29 23:57:01 1999
***************
*** 1,104 ****
! /* A Bison parser, made from ../parse.yacc with Bison version GNU Bison version 1.22
*/
#define YYBISON 1 /* Identify Bison output. */
! #define ENDOFFILE 258
! #define AMPERSAND 259
! #define ASSIGN 260
! #define ASTERISK 261
! #define BAR 262
! #define COLON 263
! #define COMMA 264
! #define DOT 265
! #define DOTDOT 266
! #define EQUAL 267
! #define GREATER 268
! #define GREQUAL 269
! #define LESS 270
! #define LSEQUAL 271
! #define MINUS 272
! #define SHARP 273
! #define PERIOD 274
! #define PLUS 275
! #define RARROW 276
! #define RBRACE 277
! #define RBRACKET 278
! #define RPAREN 279
! #define SEMICOLON 280
! #define SLASH 281
! #define SUBTYPE 282
! #define UPARROW 283
! #define LPAREN 284
! #define LBRACKET 285
! #define LBRACE 286
! #define IDENT 287
! #define CARD_CONST 288
! #define REAL_CONST 289
! #define CHAR_CONST 290
! #define STR_CONST 291
! #define AND 292
! #define ANY 293
! #define ARRAY 294
! #define AS 295
! #define BGN 296
! #define BITS 297
! #define BRANDED 298
! #define BY 299
! #define CASE 300
! #define CONST 301
! #define DIV 302
! #define DO 303
! #define ELSE 304
! #define ELSIF 305
! #define END 306
! #define EVAL 307
! #define EXCEPT 308
! #define EXCEPTION 309
! #define EXIT 310
! #define EXPORTS 311
! #define FINALLY 312
! #define FOR 313
! #define FROM 314
! #define GENERIC 315
! #define IF 316
! #define IMPORT 317
! #define IN 318
! #define INTERFACE 319
! #define LOCK 320
! #define LOOP 321
! #define METHODS 322
! #define MOD 323
! #define MODULE 324
! #define NOT 325
! #define OBJECT 326
! #define OF 327
! #define OR 328
! #define OVERRIDES 329
! #define PROCEDURE 330
! #define RAISE 331
! #define RAISES 332
! #define READONLY 333
! #define RECORD 334
! #define REF 335
! #define REPEAT 336
! #define RETURN 337
! #define REVEAL 338
! #define ROOT 339
! #define SET 340
! #define THEN 341
! #define TO 342
! #define TRY 343
! #define TYPE 344
! #define TYPECASE 345
! #define UNSAFE 346
! #define UNTIL 347
! #define UNTRACED 348
! #define VALUE 349
! #define VAR 350
! #define WHILE 351
! #define WITH 352
#line 39 "../parse.yacc"
--- 1,105 ----
! /* A Bison parser, made from ../parse.yacc
! by GNU Bison version 1.27
*/
#define YYBISON 1 /* Identify Bison output. */
! #define ENDOFFILE 257
! #define AMPERSAND 258
! #define ASSIGN 259
! #define ASTERISK 260
! #define BAR 261
! #define COLON 262
! #define COMMA 263
! #define DOT 264
! #define DOTDOT 265
! #define EQUAL 266
! #define GREATER 267
! #define GREQUAL 268
! #define LESS 269
! #define LSEQUAL 270
! #define MINUS 271
! #define SHARP 272
! #define PERIOD 273
! #define PLUS 274
! #define RARROW 275
! #define RBRACE 276
! #define RBRACKET 277
! #define RPAREN 278
! #define SEMICOLON 279
! #define SLASH 280
! #define SUBTYPE 281
! #define UPARROW 282
! #define LPAREN 283
! #define LBRACKET 284
! #define LBRACE 285
! #define IDENT 286
! #define CARD_CONST 287
! #define REAL_CONST 288
! #define CHAR_CONST 289
! #define STR_CONST 290
! #define AND 291
! #define ANY 292
! #define ARRAY 293
! #define AS 294
! #define BGN 295
! #define BITS 296
! #define BRANDED 297
! #define BY 298
! #define CASE 299
! #define CONST 300
! #define DIV 301
! #define DO 302
! #define ELSE 303
! #define ELSIF 304
! #define END 305
! #define EVAL 306
! #define EXCEPT 307
! #define EXCEPTION 308
! #define EXIT 309
! #define EXPORTS 310
! #define FINALLY 311
! #define FOR 312
! #define FROM 313
! #define GENERIC 314
! #define IF 315
! #define IMPORT 316
! #define IN 317
! #define INTERFACE 318
! #define LOCK 319
! #define LOOP 320
! #define METHODS 321
! #define MOD 322
! #define MODULE 323
! #define NOT 324
! #define OBJECT 325
! #define OF 326
! #define OR 327
! #define OVERRIDES 328
! #define PROCEDURE 329
! #define RAISE 330
! #define RAISES 331
! #define READONLY 332
! #define RECORD 333
! #define REF 334
! #define REPEAT 335
! #define RETURN 336
! #define REVEAL 337
! #define ROOT 338
! #define SET 339
! #define THEN 340
! #define TO 341
! #define TRY 342
! #define TYPE 343
! #define TYPECASE 344
! #define UNSAFE 345
! #define UNTIL 346
! #define UNTRACED 347
! #define VALUE 348
! #define VAR 349
! #define WHILE 350
! #define WITH 351
#line 39 "../parse.yacc"
***************
*** 120,142 ****
int pragdepth = 0;
/* depth of pragmas, used only by lexer. */
-
- #ifndef YYLTYPE
- typedef
- struct yyltype
- {
- int timestamp;
- int first_line;
- int first_column;
- int last_line;
- int last_column;
- char *text;
- }
- yyltype;
-
- #define YYLTYPE yyltype
- #endif
-
#ifndef YYSTYPE
#define YYSTYPE int
#endif
--- 121,126 ----
***************
*** 154,160 ****
#define YYFLAG -32768
#define YYNTBASE 98
! #define YYTRANSLATE(x) ((unsigned)(x) <= 352 ? yytranslate[x] : 234)
static const char yytranslate[] = { 0,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
--- 138,144 ----
#define YYFLAG -32768
#define YYNTBASE 98
! #define YYTRANSLATE(x) ((unsigned)(x) <= 351 ? yytranslate[x] : 234)
static const char yytranslate[] = { 0,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
***************
*** 182,198 ****
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
! 2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
! 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
! 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
! 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
! 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
! 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
! 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
! 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
! 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
! 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
! 96, 97
};
#if YYDEBUG != 0
--- 166,182 ----
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
! 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
! 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
! 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
! 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
! 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
! 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
! 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
! 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
! 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
! 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
! 97
};
#if YYDEBUG != 0
***************
*** 366,373 ****
638, 640, 643, 645, 648, 650, 651, 654, 656, 659,
661, 662, 665, 667, 670, 672, 675, 677
};
! static const char * const yytname[] = { "$","error","$illegal.","ENDOFFILE",
"AMPERSAND","ASSIGN","ASTERISK","BAR","COLON","COMMA","DOT","DOTDOT","EQUAL",
"GREATER","GREQUAL","LESS","LSEQUAL","MINUS","SHARP","PERIOD","PLUS","RARROW",
"RBRACE","RBRACKET","RPAREN","SEMICOLON","SLASH","SUBTYPE","UPARROW","LPAREN",
--- 350,361 ----
638, 640, 643, 645, 648, 650, 651, 654, 656, 659,
661, 662, 665, 667, 670, 672, 675, 677
};
+ #endif
+
! #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
!
! static const char * const yytname[] = { "$","error","$undefined.","ENDOFFILE",
"AMPERSAND","ASSIGN","ASTERISK","BAR","COLON","COMMA","DOT","DOTDOT","EQUAL",
"GREATER","GREQUAL","LESS","LSEQUAL","MINUS","SHARP","PERIOD","PLUS","RARROW",
"RBRACE","RBRACKET","RPAREN","SEMICOLON","SLASH","SUBTYPE","UPARROW","LPAREN",
***************
*** 397,403 ****
"override_semi_list","override_semi","override","expr","zexpr","e1","ze1","e2",
"e3","ze3","relop","e4","ze4","addop","e5","ze5","mulop","e6","e7","e8","selector_list",
"selector","expr_list","actual_list","actual","elem_list","elem","elem_tail",
! "opt_id_list","id_list",""
};
#endif
--- 385,391 ----
"override_semi_list","override_semi","override","expr","zexpr","e1","ze1","e2",
"e3","ze3","relop","e4","ze4","addop","e5","ze5","mulop","e6","e7","e8","selector_list",
"selector","expr_list","actual_list","actual","elem_list","elem","elem_tail",
! "opt_id_list","id_list", NULL
};
#endif
***************
*** 825,838 ****
-1, -1, 93, 95
};
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
! #line 3 "/contrib/share/lib/bison.simple"
/* Skeleton output parser for bison,
! Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
! the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
--- 813,827 ----
-1, -1, 93, 95
};
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
! #line 3 "/p/gnu/lib/bison-1.27/bison.simple"
! /* This file comes from bison-1.27. */
/* Skeleton output parser for bison,
! Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
! the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
***************
*** 842,883 ****
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
! #ifndef alloca
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* not GNU C. */
! #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
#include
#else /* not sparc */
! #if defined (MSDOS) && !defined (__TURBOC__)
#include
#else /* not MSDOS, or __TURBOC__ */
#if defined(_AIX)
! #include
#pragma alloca
! #else /* not MSDOS, __TURBOC__, or _AIX */
! #ifdef __hpux
! #ifdef __cplusplus
! extern "C" {
! void *alloca (unsigned int);
! };
! #else /* not __cplusplus */
! void *alloca ();
! #endif /* not __cplusplus */
#endif /* __hpux */
#endif /* not _AIX */
#endif /* not MSDOS, or __TURBOC__ */
! #endif /* not sparc. */
! #endif /* not GNU C. */
! #endif /* alloca not defined. */
! /* This is the parser code that is written into each bison parser
! when the %semantic_parser declaration is not specified in the grammar.
! It was written by Richard Stallman by simplifying the hairy parser
! used when %semantic_parser is specified. */
/* Note: there must be only one dollar sign in this file.
It is replaced by the list of actions, each action
--- 831,896 ----
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
! Foundation, Inc., 59 Temple Place - Suite 330,
! Boston, MA 02111-1307, USA. */
+ /* As a special exception, when this file is copied by Bison into a
+ Bison output file, you may use that output file without restriction.
+ This special exception was added by the Free Software Foundation
+ in version 1.24 of Bison. */
! /* This is the parser code that is written into each bison parser
! when the %semantic_parser declaration is not specified in the grammar.
! It was written by Richard Stallman by simplifying the hairy parser
! used when %semantic_parser is specified. */
!
! #ifndef YYSTACK_USE_ALLOCA
! #ifdef alloca
! #define YYSTACK_USE_ALLOCA
! #else /* alloca not defined */
#ifdef __GNUC__
+ #define YYSTACK_USE_ALLOCA
#define alloca __builtin_alloca
#else /* not GNU C. */
! #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
! #define YYSTACK_USE_ALLOCA
#include
#else /* not sparc */
! /* We think this test detects Watcom and Microsoft C. */
! /* This used to test MSDOS, but that is a bad idea
! since that symbol is in the user namespace. */
! #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
! #if 0 /* No need for malloc.h, which pollutes the namespace;
! instead, just don't use alloca. */
#include
+ #endif
#else /* not MSDOS, or __TURBOC__ */
#if defined(_AIX)
! /* I don't know what this was needed for, but it pollutes the namespace.
! So I turned it off. rms, 2 May 1997. */
! /* #include */
#pragma alloca
! #define YYSTACK_USE_ALLOCA
! #else /* not MSDOS, or __TURBOC__, or _AIX */
! #if 0
! #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
! and on HPUX 10. Eventually we can turn this on. */
! #define YYSTACK_USE_ALLOCA
! #define alloca __builtin_alloca
#endif /* __hpux */
+ #endif
#endif /* not _AIX */
#endif /* not MSDOS, or __TURBOC__ */
! #endif /* not sparc */
! #endif /* not GNU C */
! #endif /* alloca not defined */
! #endif /* YYSTACK_USE_ALLOCA not defined */
! #ifdef YYSTACK_USE_ALLOCA
! #define YYSTACK_ALLOC alloca
! #else
! #define YYSTACK_ALLOC malloc
! #endif
/* Note: there must be only one dollar sign in this file.
It is replaced by the list of actions, each action
***************
*** 887,894 ****
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY -2
#define YYEOF 0
! #define YYACCEPT return(0)
! #define YYABORT return(1)
#define YYERROR goto yyerrlab1
/* Like YYERROR except do call yyerror.
This remains here temporarily to ease the
--- 900,907 ----
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY -2
#define YYEOF 0
! #define YYACCEPT goto yyacceptlab
! #define YYABORT goto yyabortlab
#define YYERROR goto yyerrlab1
/* Like YYERROR except do call yyerror.
This remains here temporarily to ease the
***************
*** 917,926 ****
--- 930,947 ----
#ifdef YYPURE
#ifdef YYLSP_NEEDED
+ #ifdef YYLEX_PARAM
+ #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
+ #else
#define YYLEX yylex(&yylval, &yylloc)
+ #endif
+ #else /* not YYLSP_NEEDED */
+ #ifdef YYLEX_PARAM
+ #define YYLEX yylex(&yylval, YYLEX_PARAM)
#else
#define YYLEX yylex(&yylval)
#endif
+ #endif /* not YYLSP_NEEDED */
#endif
/* If nonreentrant, generate the variables here */
***************
*** 961,984 ****
#ifndef YYMAXDEPTH
#define YYMAXDEPTH 10000
#endif
-
- /* Prevent warning if -Wstrict-prototypes. */
- #ifdef __GNUC__
- int yyparse (void);
- #endif
#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
! #define __yy_bcopy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT)
#else /* not GNU C or C++ */
#ifndef __cplusplus
/* This is the most reliable way to avoid incompatibilities
in available built-in functions on various systems. */
static void
! __yy_bcopy (from, to, count)
! char *from;
char *to;
! int count;
{
register char *f = from;
register char *t = to;
--- 982,1005 ----
#ifndef YYMAXDEPTH
#define YYMAXDEPTH 10000
#endif
+ /* Define __yy_memcpy. Note that the size argument
+ should be passed with type unsigned int, because that is what the non-GCC
+ definitions require. With GCC, __builtin_memcpy takes an arg
+ of type size_t, but it can handle unsigned int. */
+
#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
! #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
#else /* not GNU C or C++ */
#ifndef __cplusplus
/* This is the most reliable way to avoid incompatibilities
in available built-in functions on various systems. */
static void
! __yy_memcpy (to, from, count)
char *to;
! char *from;
! unsigned int count;
{
register char *f = from;
register char *t = to;
***************
*** 993,1002 ****
/* This is the most reliable way to avoid incompatibilities
in available built-in functions on various systems. */
static void
! __yy_bcopy (char *from, char *to, int count)
{
- register char *f = from;
register char *t = to;
register int i = count;
while (i-- > 0)
--- 1014,1023 ----
/* This is the most reliable way to avoid incompatibilities
in available built-in functions on various systems. */
static void
! __yy_memcpy (char *to, char *from, unsigned int count)
{
register char *t = to;
+ register char *f = from;
register int i = count;
while (i-- > 0)
***************
*** 1006,1014 ****
#endif
#endif
! #line 184 "/contrib/share/lib/bison.simple"
int
! yyparse()
{
register int yystate;
register int yyn;
--- 1027,1065 ----
#endif
#endif
! #line 216 "/p/gnu/lib/bison-1.27/bison.simple"
!
! /* The user can define YYPARSE_PARAM as the name of an argument to be passed
! into yyparse. The argument should have type void *.
! It should actually point to an object.
! Grammar actions can access the variable by casting it
! to the proper pointer type. */
!
! #ifdef YYPARSE_PARAM
! #ifdef __cplusplus
! #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
! #define YYPARSE_PARAM_DECL
! #else /* not __cplusplus */
! #define YYPARSE_PARAM_ARG YYPARSE_PARAM
! #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
! #endif /* not __cplusplus */
! #else /* not YYPARSE_PARAM */
! #define YYPARSE_PARAM_ARG
! #define YYPARSE_PARAM_DECL
! #endif /* not YYPARSE_PARAM */
!
! /* Prevent warning if -Wstrict-prototypes. */
! #ifdef __GNUC__
! #ifdef YYPARSE_PARAM
! int yyparse (void *);
! #else
! int yyparse (void);
! #endif
! #endif
!
int
! yyparse(YYPARSE_PARAM_ARG)
! YYPARSE_PARAM_DECL
{
register int yystate;
register int yyn;
***************
*** 1034,1039 ****
--- 1085,1091 ----
#endif
int yystacksize = YYINITDEPTH;
+ int yyfree_stacks = 0;
#ifdef YYPURE
int yychar;
***************
*** 1118,1135 ****
if (yystacksize >= YYMAXDEPTH)
{
yyerror("parser stack overflow");
return 2;
}
yystacksize *= 2;
if (yystacksize > YYMAXDEPTH)
yystacksize = YYMAXDEPTH;
! yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
! __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
! yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
! __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
#ifdef YYLSP_NEEDED
! yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
! __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
#endif
#endif /* no yyoverflow */
--- 1170,1201 ----
if (yystacksize >= YYMAXDEPTH)
{
yyerror("parser stack overflow");
+ if (yyfree_stacks)
+ {
+ free (yyss);
+ free (yyvs);
+ #ifdef YYLSP_NEEDED
+ free (yyls);
+ #endif
+ }
return 2;
}
yystacksize *= 2;
if (yystacksize > YYMAXDEPTH)
yystacksize = YYMAXDEPTH;
! #ifndef YYSTACK_USE_ALLOCA
! yyfree_stacks = 1;
! #endif
! yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
! __yy_memcpy ((char *)yyss, (char *)yyss1,
! size * (unsigned int) sizeof (*yyssp));
! yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
! __yy_memcpy ((char *)yyvs, (char *)yyvs1,
! size * (unsigned int) sizeof (*yyvsp));
#ifdef YYLSP_NEEDED
! yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
! __yy_memcpy ((char *)yyls, (char *)yyls1,
! size * (unsigned int) sizeof (*yylsp));
#endif
#endif /* no yyoverflow */
***************
*** 1351,1357 ****
break;}
}
/* the action file gets copied in in place of this dollarsign */
! #line 465 "/contrib/share/lib/bison.simple"
yyvsp -= yylen;
yyssp -= yylen;
--- 1417,1423 ----
break;}
}
/* the action file gets copied in in place of this dollarsign */
! #line 542 "/p/gnu/lib/bison-1.27/bison.simple"
yyvsp -= yylen;
yyssp -= yylen;
***************
*** 1546,1551 ****
--- 1612,1641 ----
yystate = yyn;
goto yynewstate;
+
+ yyacceptlab:
+ /* YYACCEPT comes here. */
+ if (yyfree_stacks)
+ {
+ free (yyss);
+ free (yyvs);
+ #ifdef YYLSP_NEEDED
+ free (yyls);
+ #endif
+ }
+ return 0;
+
+ yyabortlab:
+ /* YYABORT comes here. */
+ if (yyfree_stacks)
+ {
+ free (yyss);
+ free (yyvs);
+ #ifdef YYLSP_NEEDED
+ free (yyls);
+ #endif
+ }
+ return 1;
}
#line 681 "../parse.yacc"
***************
*** 1571,1576 ****
--- 1661,1667 ----
char qualifier[200];
recordQual(name)
+ char *name;
{
strcpy(qualifier, name);
}
Index: m3/pm3/language/modula3/m3tools/m3gdb/gdb/gdb/m3-lang.c
diff -c m3/pm3/language/modula3/m3tools/m3gdb/gdb/gdb/m3-lang.c:1.9 m3/pm3/language/modula3/m3tools/m3gdb/gdb/gdb/m3-lang.c:1.10
*** m3/pm3/language/modula3/m3tools/m3gdb/gdb/gdb/m3-lang.c:1.9 Sun Nov 15 23:38:20 1998
--- m3/pm3/language/modula3/m3tools/m3gdb/gdb/gdb/m3-lang.c Wed Apr 28 11:53:28 1999
***************
*** 460,465 ****
--- 460,466 ----
{
int thread__t__context_size, thread__t__context_offset;
struct type * thread__t__context_type;
+ int dataOffset = TARGET_PTR_BIT;
if (thread__t) return;
***************
*** 489,502 ****
find_m3_rec_field (thread__t__context_type, "buf",
&thread__t__buf_size, &thread__t__buf_offset, 0);
! /* skip past the method pointer */
! thread__t__id_offset += TARGET_PTR_BIT;
! thread__t__state_offset += TARGET_PTR_BIT;
! thread__t__next_offset += TARGET_PTR_BIT;
! thread__t__cond_offset += TARGET_PTR_BIT;
! thread__t__mutex_offset += TARGET_PTR_BIT;
! thread__t__time_offset += TARGET_PTR_BIT;
! thread__t__buf_offset += TARGET_PTR_BIT + thread__t__context_offset;
}
/*--------------------------------------------------------- jmpbuf layout ---*/
--- 490,507 ----
find_m3_rec_field (thread__t__context_type, "buf",
&thread__t__buf_size, &thread__t__buf_offset, 0);
! #if defined(sparc)
! /* deal with sparc realignment */
! dataOffset += TARGET_PTR_BIT;
! #endif
!
! thread__t__id_offset += dataOffset;
! thread__t__state_offset += dataOffset;
! thread__t__next_offset += dataOffset;
! thread__t__cond_offset += dataOffset;
! thread__t__mutex_offset += dataOffset;
! thread__t__time_offset += dataOffset;
! thread__t__buf_offset += dataOffset + thread__t__context_offset;
}
/*--------------------------------------------------------- jmpbuf layout ---*/
***************
*** 1421,1431 ****
TARGET_PTR_BIT / TARGET_CHAR_BIT);
/* the typecode is in Modula-3 bits 1..21 */
! #if TARGET_BYTE_ORDER == BIG_ENDIAN
! typecode = (typecode >> 11) & 0xfffff;
! #else
! typecode = (typecode >> 1) & 0xfffff;
! #endif
target_read_memory (rt0u_types_value
+ typecode * TARGET_PTR_BIT / TARGET_CHAR_BIT,
--- 1426,1432 ----
TARGET_PTR_BIT / TARGET_CHAR_BIT);
/* the typecode is in Modula-3 bits 1..21 */
! typecode = m3_unpack_ord((char *)&typecode, 1, 20, 0);
target_read_memory (rt0u_types_value
+ typecode * TARGET_PTR_BIT / TARGET_CHAR_BIT,
Index: m3/pm3/language/modula3/m3tools/pp/src/lex-yacc/lex.yy.c
diff -c m3/pm3/language/modula3/m3tools/pp/src/lex-yacc/lex.yy.c:1.1.1.1 m3/pm3/language/modula3/m3tools/pp/src/lex-yacc/lex.yy.c:1.2
*** m3/pm3/language/modula3/m3tools/pp/src/lex-yacc/lex.yy.c:1.1.1.1 Thu Jan 16 16:31:51 1997
--- m3/pm3/language/modula3/m3tools/pp/src/lex-yacc/lex.yy.c Thu Apr 29 23:53:50 1999
***************
*** 1,23 ****
! # include "stdio.h"
! # define U(x) ((x)&0377)
# define NLSTATE yyprevious=YYNEWLINE
# define BEGIN yybgin = yysvec + 1 +
# define INITIAL 0
# define YYLERR yysvec
# define YYSTATE (yyestate-yysvec-1)
# define YYOPTIM 1
! # define YYLMAX 200
! # define output(c) putc(c,yyout)
! # define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)
# define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;}
# define yymore() (yymorfg=1)
! # define ECHO fprintf(yyout, "%s",yytext)
# define REJECT { nstr = yyreject(); goto yyfussy;}
! int yyleng; extern char yytext[];
int yymorfg;
extern char *yysptr, yysbuf[];
int yytchar;
! FILE *yyin ={stdin}, *yyout ={stdout};
extern int yylineno;
struct yysvf {
struct yywork *yystoff;
--- 1,73 ----
! #include
! # define U(x) x
# define NLSTATE yyprevious=YYNEWLINE
# define BEGIN yybgin = yysvec + 1 +
# define INITIAL 0
# define YYLERR yysvec
# define YYSTATE (yyestate-yysvec-1)
# define YYOPTIM 1
! # define YYLMAX BUFSIZ
! #ifndef __cplusplus
! # define output(c) (void)putc(c,yyout)
! #else
! # define lex_output(c) (void)putc(c,yyout)
! #endif
!
! #if defined(__cplusplus) || defined(__STDC__)
!
! #if defined(__cplusplus) && defined(__EXTERN_C__)
! extern "C" {
! #endif
! int yyback(int *, int);
! int yyinput(void);
! int yylook(void);
! void yyoutput(int);
! int yyracc(int);
! int yyreject(void);
! void yyunput(int);
! int yylex(void);
! #ifdef YYLEX_E
! void yywoutput(wchar_t);
! wchar_t yywinput(void);
! #endif
! #ifndef yyless
! int yyless(int);
! #endif
! #ifndef yywrap
! int yywrap(void);
! #endif
! #ifdef LEXDEBUG
! void allprint(char);
! void sprint(char *);
! #endif
! #if defined(__cplusplus) && defined(__EXTERN_C__)
! }
! #endif
!
! #ifdef __cplusplus
! extern "C" {
! #endif
! void exit(int);
! #ifdef __cplusplus
! }
! #endif
!
! #endif
# define unput(c) {yytchar= (c);if(yytchar=='\n')yylineno--;*yysptr++=yytchar;}
# define yymore() (yymorfg=1)
! #ifndef __cplusplus
! # define input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)
! #else
! # define lex_input() (((yytchar=yysptr>yysbuf?U(*--yysptr):getc(yyin))==10?(yylineno++,yytchar):yytchar)==EOF?0:yytchar)
! #endif
! #define ECHO fprintf(yyout, "%s",yytext)
# define REJECT { nstr = yyreject(); goto yyfussy;}
! int yyleng;
! char yytext[YYLMAX];
int yymorfg;
extern char *yysptr, yysbuf[];
int yytchar;
! FILE *yyin = {stdin}, *yyout = {stdout};
extern int yylineno;
struct yysvf {
struct yywork *yystoff;
***************
*** 25,37 ****
--- 75,101 ----
int *yystops;};
struct yysvf *yyestate;
extern struct yysvf yysvec[], *yybgin;
+
+ # line 3 "../Parse.lex"
/* Copyright (C) 1989, Digital Equipment Corporation */
+
+ # line 4 "../Parse.lex"
/* All rights reserved. */
+
+ # line 5 "../Parse.lex"
/* See the file COPYRIGHT for a full description. */
+
+ # line 7 "../Parse.lex"
/* Last modified on Wed Aug 10 13:21:55 PDT 1994 by kalsow */
+
+ # line 8 "../Parse.lex"
/* modified on Thu Apr 23 18:08:06 PDT 1992 by muller */
+
+ # line 9 "../Parse.lex"
/* modified on Mon Apr 20 15:59:06 1992 by nichols@xerox.com */
+
+ # line 10 "../Parse.lex"
/* modified on Mon Nov 25 17:41:09 PST 1991 by meehan */
# define Prog 2
# define Com 4
***************
*** 39,139 ****
--- 103,270 ----
# define YYNEWLINE 10
yylex(){
int nstr; extern int yyprevious;
+ #ifdef __cplusplus
+ /* to avoid CC and lint complaining yyfussy not being used ...*/
+ static int __lex_hack = 0;
+ if (__lex_hack) goto yyfussy;
+ #endif
while((nstr = yylook()) >= 0)
yyfussy: switch(nstr){
case 0:
if(yywrap()) return(0); break;
case 1:
+
+ # line 16 "../Parse.lex"
{ return (HandleNPS()); }
break;
case 2:
+
+ # line 17 "../Parse.lex"
{ return (HandleNPS()); }
break;
case 3:
+
+ # line 18 "../Parse.lex"
{ return (HandleNPS()); }
break;
case 4:
+
+ # line 19 "../Parse.lex"
{BufferLexeme(1); return(PLUS);}
break;
case 5:
+
+ # line 20 "../Parse.lex"
{BufferLexeme(1); return(MINUS);}
break;
case 6:
+
+ # line 21 "../Parse.lex"
{BufferLexeme(1); return(ASTERISK);}
break;
case 7:
+
+ # line 22 "../Parse.lex"
{BufferLexeme(1); return(SLASH);}
break;
case 8:
+
+ # line 23 "../Parse.lex"
{BufferLexeme(1); return(ASSIGN);}
break;
case 9:
+
+ # line 24 "../Parse.lex"
{BufferLexeme(1); return(AMPERSAND);}
break;
case 10:
+
+ # line 25 "../Parse.lex"
{BufferLexeme(1); return(DOT);}
break;
case 11:
+
+ # line 26 "../Parse.lex"
{BufferLexeme(1); return(COMMA);}
break;
case 12:
+
+ # line 27 "../Parse.lex"
{BufferLexeme(1); return(SEMICOLON);}
break;
case 13:
+
+ # line 28 "../Parse.lex"
{BufferLexeme(1); return(LPAREN);}
break;
case 14:
+
+ # line 29 "../Parse.lex"
{BufferLexeme(1); return(LBRACKET);}
break;
case 15:
+
+ # line 30 "../Parse.lex"
{BufferLexeme(1); return(LBRACE);}
break;
case 16:
+
+ # line 31 "../Parse.lex"
{BufferLexeme(1); return(UPARROW);}
break;
case 17:
+
+ # line 32 "../Parse.lex"
{BufferLexeme(1); return(EQUAL);}
break;
case 18:
+
+ # line 33 "../Parse.lex"
{BufferLexeme(1); return(RARROW);}
break;
case 19:
+
+ # line 34 "../Parse.lex"
{BufferLexeme(1); return(SHARP);}
break;
case 20:
+
+ # line 35 "../Parse.lex"
{BufferLexeme(1); return(LESS);}
break;
case 21:
+
+ # line 36 "../Parse.lex"
{BufferLexeme(1); return(GREATER);}
break;
case 22:
+
+ # line 37 "../Parse.lex"
{BufferLexeme(1); return(LSEQUAL);}
break;
case 23:
+
+ # line 38 "../Parse.lex"
{BufferLexeme(1); return(SUBTYPE);}
break;
case 24:
+
+ # line 39 "../Parse.lex"
{BufferLexeme(1); return(GREQUAL);}
break;
case 25:
+
+ # line 40 "../Parse.lex"
{BufferLexeme(1); return(DOTDOT);}
break;
case 26:
+
+ # line 41 "../Parse.lex"
{BufferLexeme(1); return(COLON);}
break;
case 27:
+
+ # line 42 "../Parse.lex"
{BufferLexeme(1); return(RPAREN);}
break;
case 28:
+
+ # line 43 "../Parse.lex"
{BufferLexeme(1); return(RBRACKET);}
break;
case 29:
+
+ # line 44 "../Parse.lex"
{BufferLexeme(1); return(RBRACE);}
break;
case 30:
+
+ # line 45 "../Parse.lex"
{BufferLexeme(1); return(BAR);}
break;
case 31:
+
+ # line 47 "../Parse.lex"
{PTRKEYWORDENTRY tempp;
if ((tempp=lookup(yytext))!=NULL){
CapBufferLexeme(1);
***************
*** 141,160 ****
--- 272,301 ----
else {BufferLexeme(1); return(IDENT);}}
break;
case 32:
+
+ # line 53 "../Parse.lex"
{BufferLexeme(1); return(CARD_CONST);}
break;
case 33:
+
+ # line 55 "../Parse.lex"
{BufferLexeme(1); return(REAL_CONST);}
break;
case 34:
+
+ # line 57 "../Parse.lex"
{
BufferLexeme(1); return(STR_CONST);}
break;
case 35:
+
+ # line 60 "../Parse.lex"
{
BufferLexeme(1); return(STR_CONST);}
break;
case 36:
+
+ # line 63 "../Parse.lex"
{
BufferLexeme(0);
/* Due to bison bug, we return 0 explicitly instead of ENDOFFILE. */
***************
*** 162,182 ****
}
break;
case 37:
{BufferLexeme(0);return(MODUNIT);}
break;
case 38:
{BufferLexeme(0);return(DEFUNIT);}
break;
case 39:
{BufferLexeme(1); return(BAD);}
break;
case -1:
break;
default:
! fprintf(yyout,"bad switch yylook %d",nstr);
} return(0); }
/* end of yylex */
! int yyvstop[] ={
0,
36,
--- 303,329 ----
}
break;
case 37:
+
+ # line 68 "../Parse.lex"
{BufferLexeme(0);return(MODUNIT);}
break;
case 38:
+
+ # line 69 "../Parse.lex"
{BufferLexeme(0);return(DEFUNIT);}
break;
case 39:
+
+ # line 70 "../Parse.lex"
{BufferLexeme(1); return(BAD);}
break;
case -1:
break;
default:
! (void)fprintf(yyout,"bad switch yylook %d",nstr);
} return(0); }
/* end of yylex */
! int yyvstop[] = {
0,
36,
***************
*** 371,377 ****
0,
0};
# define YYTYPE unsigned char
! struct yywork { YYTYPE verify, advance; } yycrank[] ={
0,0, 0,0, 1,9, 1,10,
1,11, 44,0, 1,12, 47,0,
0,0, 0,0, 1,13, 1,14,
--- 518,524 ----
0,
0};
# define YYTYPE unsigned char
! struct yywork { YYTYPE verify, advance; } yycrank[] = {
0,0, 0,0, 1,9, 1,10,
1,11, 44,0, 1,12, 47,0,
0,0, 0,0, 1,13, 1,14,
***************
*** 535,541 ****
54,65, 54,65, 54,65, 54,65,
54,65, 0,0, 0,0, 0,0,
0,0};
! struct yysvf yysvec[] ={
0, 0, 0,
yycrank+-1, 0, 0,
yycrank+-39, yysvec+1, 0,
--- 682,688 ----
54,65, 54,65, 54,65, 54,65,
54,65, 0,0, 0,0, 0,0,
0,0};
! struct yysvf yysvec[] = {
0, 0, 0,
yycrank+-1, 0, 0,
yycrank+-39, yysvec+1, 0,
***************
*** 608,671 ****
0, 0, 0};
struct yywork *yytop = yycrank+644;
struct yysvf *yybgin = yysvec+1;
! char yymatch[] ={
! 00 ,01 ,02 ,03 ,03 ,05 ,03 ,03 ,
! 03 ,011 ,012 ,03 ,011 ,011 ,03 ,03 ,
! 03 ,03 ,03 ,03 ,03 ,03 ,03 ,03 ,
! 03 ,03 ,03 ,03 ,03 ,03 ,03 ,03 ,
! ' ' ,03 ,'"' ,03 ,03 ,03 ,03 ,047 ,
! 03 ,03 ,03 ,'+' ,03 ,'+' ,'.' ,03 ,
! '0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,'0' ,
! '0' ,'0' ,03 ,03 ,03 ,03 ,03 ,03 ,
! 03 ,'A' ,'A' ,'A' ,'D' ,'D' ,'A' ,'G' ,
! 'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,
! 'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,
! 'X' ,'G' ,'G' ,03 ,0134,03 ,03 ,'_' ,
! 03 ,'A' ,'A' ,'A' ,'D' ,'D' ,'A' ,'G' ,
! 'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,
! 'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,'G' ,
! 'X' ,'G' ,'G' ,03 ,03 ,03 ,03 ,03 ,
! 03 ,03 ,03 ,03 ,03 ,03 ,03 ,03 ,
! 03 ,03 ,03 ,03 ,03 ,03 ,03 ,03 ,
! 03 ,03 ,03 ,03 ,03 ,03 ,03 ,03 ,
! 03 ,03 ,03 ,03 ,03 ,03 ,03 ,03 ,
! 03 ,03 ,03 ,03 ,03 ,03 ,03 ,03 ,
! 03 ,03 ,03 ,03 ,03 ,03 ,03 ,03 ,
! 03 ,03 ,03 ,03 ,03 ,03 ,03 ,03 ,
! 03 ,03 ,03 ,03 ,03 ,03 ,03 ,03 ,
! 03 ,03 ,03 ,03 ,03 ,03 ,03 ,03 ,
! 03 ,03 ,03 ,03 ,03 ,03 ,03 ,03 ,
! 03 ,03 ,03 ,03 ,03 ,03 ,03 ,03 ,
! 03 ,03 ,03 ,03 ,03 ,03 ,03 ,03 ,
! 03 ,03 ,03 ,03 ,03 ,03 ,03 ,03 ,
! 03 ,03 ,03 ,03 ,03 ,03 ,03 ,03 ,
! 03 ,03 ,03 ,03 ,03 ,03 ,03 ,03 ,
! 03 ,03 ,03 ,03 ,03 ,03 ,03 ,03 ,
0};
! char yyextra[] ={
0,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,
0,1,0,0,0,0,0,0,
0};
! /* ncform 4.1 83/08/11 */
int yylineno =1;
# define YYU(x) x
# define NLSTATE yyprevious=YYNEWLINE
- char yytext[YYLMAX];
struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
char yysbuf[YYLMAX];
char *yysptr = yysbuf;
int *yyfnd;
extern struct yysvf *yyestate;
int yyprevious = YYNEWLINE;
! yylook(){
register struct yysvf *yystate, **lsp;
register struct yywork *yyt;
struct yysvf *yyz;
! int yych;
struct yywork *yyr;
# ifdef LEXDEBUG
int debug;
--- 755,829 ----
0, 0, 0};
struct yywork *yytop = yycrank+644;
struct yysvf *yybgin = yysvec+1;
! char yymatch[] = {
! 0, 1, 2, 3, 3, 5, 3, 3,
! 3, 9, 10, 3, 9, 9, 3, 3,
! 3, 3, 3, 3, 3, 3, 3, 3,
! 3, 3, 3, 3, 3, 3, 3, 3,
! 32, 3, 34, 3, 3, 3, 3, 39,
! 3, 3, 3, 43, 3, 43, 46, 3,
! 48, 48, 48, 48, 48, 48, 48, 48,
! 48, 48, 3, 3, 3, 3, 3, 3,
! 3, 65, 65, 65, 68, 68, 65, 71,
! 71, 71, 71, 71, 71, 71, 71, 71,
! 71, 71, 71, 71, 71, 71, 71, 71,
! 88, 71, 71, 3, 92, 3, 3, 95,
! 3, 65, 65, 65, 68, 68, 65, 71,
! 71, 71, 71, 71, 71, 71, 71, 71,
! 71, 71, 71, 71, 71, 71, 71, 71,
! 88, 71, 71, 3, 3, 3, 3, 3,
! 3, 3, 3, 3, 3, 3, 3, 3,
! 3, 3, 3, 3, 3, 3, 3, 3,
! 3, 3, 3, 3, 3, 3, 3, 3,
! 3, 3, 3, 3, 3, 3, 3, 3,
! 3, 3, 3, 3, 3, 3, 3, 3,
! 3, 3, 3, 3, 3, 3, 3, 3,
! 3, 3, 3, 3, 3, 3, 3, 3,
! 3, 3, 3, 3, 3, 3, 3, 3,
! 3, 3, 3, 3, 3, 3, 3, 3,
! 3, 3, 3, 3, 3, 3, 3, 3,
! 3, 3, 3, 3, 3, 3, 3, 3,
! 3, 3, 3, 3, 3, 3, 3, 3,
! 3, 3, 3, 3, 3, 3, 3, 3,
! 3, 3, 3, 3, 3, 3, 3, 3,
! 3, 3, 3, 3, 3, 3, 3, 3,
! 3, 3, 3, 3, 3, 3, 3, 3,
0};
! char yyextra[] = {
0,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,
0,1,0,0,0,0,0,0,
0};
! /* Copyright (c) 1989 AT&T */
! /* All Rights Reserved */
!
! /* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */
! /* The copyright notice above does not evidence any */
! /* actual or intended publication of such source code. */
+ #pragma ident "@(#)ncform 6.8 95/02/11 SMI"
+
int yylineno =1;
# define YYU(x) x
# define NLSTATE yyprevious=YYNEWLINE
struct yysvf *yylstate [YYLMAX], **yylsp, **yyolsp;
char yysbuf[YYLMAX];
char *yysptr = yysbuf;
int *yyfnd;
extern struct yysvf *yyestate;
int yyprevious = YYNEWLINE;
! #if defined(__cplusplus) || defined(__STDC__)
! int yylook(void)
! #else
! yylook()
! #endif
! {
register struct yysvf *yystate, **lsp;
register struct yywork *yyt;
struct yysvf *yyz;
! int yych, yyfirst;
struct yywork *yyr;
# ifdef LEXDEBUG
int debug;
***************
*** 675,680 ****
--- 833,839 ----
# ifdef LEXDEBUG
debug = 0;
# endif
+ yyfirst=1;
if (!yymorfg)
yylastch = yytext;
else {
***************
*** 690,705 ****
if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
# endif
yyt = yystate->yystoff;
! if(yyt == yycrank){ /* may not be any transitions */
yyz = yystate->yyother;
if(yyz == 0)break;
if(yyz->yystoff == yycrank)break;
}
*yylastch++ = yych = input();
tryagain:
# ifdef LEXDEBUG
if(debug){
! fprintf(yyout,"unsigned char ");
allprint(yych);
putchar('\n');
}
--- 849,873 ----
if(debug)fprintf(yyout,"state %d\n",yystate-yysvec-1);
# endif
yyt = yystate->yystoff;
! if(yyt == yycrank && !yyfirst){ /* may not be any transitions */
yyz = yystate->yyother;
if(yyz == 0)break;
if(yyz->yystoff == yycrank)break;
}
+ #ifndef __cplusplus
*yylastch++ = yych = input();
+ #else
+ *yylastch++ = yych = lex_input();
+ #endif
+ if(yylastch > &yytext[YYLMAX]) {
+ fprintf(yyout,"Input string too long, limit %d\n",YYLMAX);
+ exit(1);
+ }
+ yyfirst=0;
tryagain:
# ifdef LEXDEBUG
if(debug){
! fprintf(yyout,"char ");
allprint(yych);
putchar('\n');
}
***************
*** 711,716 ****
--- 879,888 ----
if(yyt->advance+yysvec == YYLERR) /* error transitions */
{unput(*--yylastch);break;}
*lsp++ = yystate = yyt->advance+yysvec;
+ if(lsp > &yylstate[YYLMAX]) {
+ fprintf(yyout,"Input string too long, limit %d\n",YYLMAX);
+ exit(1);
+ }
goto contin;
}
}
***************
*** 725,730 ****
--- 897,906 ----
if(yyt->advance+yysvec == YYLERR) /* error transitions */
{unput(*--yylastch);break;}
*lsp++ = yystate = yyt->advance+yysvec;
+ if(lsp > &yylstate[YYLMAX]) {
+ fprintf(yyout,"Input string too long, limit %d\n",YYLMAX);
+ exit(1);
+ }
goto contin;
}
yyt = yyr + YYU(yymatch[yych]);
***************
*** 739,744 ****
--- 915,924 ----
if(yyt->advance+yysvec == YYLERR) /* error transition */
{unput(*--yylastch);break;}
*lsp++ = yystate = yyt->advance+yysvec;
+ if(lsp > &yylstate[YYLMAX]) {
+ fprintf(yyout,"Input string too long, limit %d\n",YYLMAX);
+ exit(1);
+ }
goto contin;
}
}
***************
*** 798,832 ****
yysptr=yysbuf;
return(0);
}
yyprevious = yytext[0] = input();
if (yyprevious>0)
output(yyprevious);
yylastch=yytext;
# ifdef LEXDEBUG
if(debug)putchar('\n');
# endif
}
}
yyback(p, m)
int *p;
{
! if (p==0) return(0);
! while (*p)
! {
! if (*p++ == m)
! return(1);
}
! return(0);
}
/* the following are only used in the lex library */
! yyinput(){
return(input());
}
yyoutput(c)
! int c; {
output(c);
}
yyunput(c)
! int c; {
unput(c);
}
--- 978,1044 ----
yysptr=yysbuf;
return(0);
}
+ #ifndef __cplusplus
yyprevious = yytext[0] = input();
if (yyprevious>0)
output(yyprevious);
+ #else
+ yyprevious = yytext[0] = lex_input();
+ if (yyprevious>0)
+ lex_output(yyprevious);
+ #endif
yylastch=yytext;
# ifdef LEXDEBUG
if(debug)putchar('\n');
# endif
}
}
+ #if defined(__cplusplus) || defined(__STDC__)
+ int yyback(int *p, int m)
+ #else
yyback(p, m)
int *p;
+ #endif
{
! if (p==0) return(0);
! while (*p) {
! if (*p++ == m)
! return(1);
}
! return(0);
}
/* the following are only used in the lex library */
! #if defined(__cplusplus) || defined(__STDC__)
! int yyinput(void)
! #else
! yyinput()
! #endif
! {
! #ifndef __cplusplus
return(input());
+ #else
+ return(lex_input());
+ #endif
}
+ #if defined(__cplusplus) || defined(__STDC__)
+ void yyoutput(int c)
+ #else
yyoutput(c)
! int c;
! #endif
! {
! #ifndef __cplusplus
output(c);
+ #else
+ lex_output(c);
+ #endif
}
+ #if defined(__cplusplus) || defined(__STDC__)
+ void yyunput(int c)
+ #else
yyunput(c)
! int c;
! #endif
! {
unput(c);
}
Index: m3/pm3/language/modula3/m3tools/pp/src/lex-yacc/y.tab.c
diff -c m3/pm3/language/modula3/m3tools/pp/src/lex-yacc/y.tab.c:1.1.1.1 m3/pm3/language/modula3/m3tools/pp/src/lex-yacc/y.tab.c:1.2
*** m3/pm3/language/modula3/m3tools/pp/src/lex-yacc/y.tab.c:1.1.1.1 Thu Jan 16 16:31:51 1997
--- m3/pm3/language/modula3/m3tools/pp/src/lex-yacc/y.tab.c Thu Apr 29 23:53:50 1999
***************
*** 1,114 ****
! /* A Bison parser, made from ../Parse.yacc with Bison version GNU Bison version 1.22
*/
#define YYBISON 1 /* Identify Bison output. */
! #define ENDOFFILE 258
! #define AMPERSAND 259
! #define ASSIGN 260
! #define ASTERISK 261
! #define BAR 262
! #define COLON 263
! #define COMMA 264
! #define DOT 265
! #define DOTDOT 266
! #define EQUAL 267
! #define GREATER 268
! #define GREQUAL 269
! #define LESS 270
! #define LSEQUAL 271
! #define MINUS 272
! #define SHARP 273
! #define PERIOD 274
! #define PLUS 275
! #define RARROW 276
! #define RBRACE 277
! #define RBRACKET 278
! #define RPAREN 279
! #define SEMICOLON 280
! #define SLASH 281
! #define SUBTYPE 282
! #define UPARROW 283
! #define LPAREN 284
! #define LBRACKET 285
! #define LBRACE 286
! #define IDENT 287
! #define CARD_CONST 288
! #define REAL_CONST 289
! #define CHAR_CONST 290
! #define STR_CONST 291
! #define PR_EXTERNAL 292
! #define PR_INLINE 293
! #define PR_OBSOLETE 294
! #define PR_UNUSED 295
! #define AND 296
! #define ANY 297
! #define ARRAY 298
! #define AS 299
! #define BGN 300
! #define BITS 301
! #define BRANDED 302
! #define BY 303
! #define CASE 304
! #define CONST 305
! #define DIV 306
! #define DO 307
! #define ELSE 308
! #define ELSIF 309
! #define END 310
! #define EVAL 311
! #define EXCEPT 312
! #define EXCEPTION 313
! #define EXIT 314
! #define EXPORTS 315
! #define FINALLY 316
! #define FOR 317
! #define FROM 318
! #define GENERIC 319
! #define IF 320
! #define IMPORT 321
! #define IN 322
! #define INTERFACE 323
! #define LOCK 324
! #define LOOP 325
! #define METHODS 326
! #define MOD 327
! #define MODULE 328
! #define NOT 329
! #define OBJECT 330
! #define OF 331
! #define OR 332
! #define OVERRIDES 333
! #define PROCEDURE 334
! #define RAISE 335
! #define RAISES 336
! #define READONLY 337
! #define RECORD 338
! #define REF 339
! #define REPEAT 340
! #define RETURN 341
! #define REVEAL 342
! #define ROOT 343
! #define SET 344
! #define THEN 345
! #define TO 346
! #define TRY 347
! #define TYPE 348
! #define TYPECASE 349
! #define UNSAFE 350
! #define UNTIL 351
! #define UNTRACED 352
! #define VALUE 353
! #define VAR 354
! #define WHILE 355
! #define WITH 356
! #define BAD 357
! #define WHITESPACE 358
! #define MODUNIT 359
! #define DEFUNIT 360
! #line 91 "../Parse.yacc"
#define lexbufsize 500
--- 1,115 ----
! /* A Bison parser, made from ../Parse.yacc
! by GNU Bison version 1.27
*/
#define YYBISON 1 /* Identify Bison output. */
! #define ENDOFFILE 257
! #define AMPERSAND 258
! #define ASSIGN 259
! #define ASTERISK 260
! #define BAR 261
! #define COLON 262
! #define COMMA 263
! #define DOT 264
! #define DOTDOT 265
! #define EQUAL 266
! #define GREATER 267
! #define GREQUAL 268
! #define LESS 269
! #define LSEQUAL 270
! #define MINUS 271
! #define SHARP 272
! #define PERIOD 273
! #define PLUS 274
! #define RARROW 275
! #define RBRACE 276
! #define RBRACKET 277
! #define RPAREN 278
! #define SEMICOLON 279
! #define SLASH 280
! #define SUBTYPE 281
! #define UPARROW 282
! #define LPAREN 283
! #define LBRACKET 284
! #define LBRACE 285
! #define IDENT 286
! #define CARD_CONST 287
! #define REAL_CONST 288
! #define CHAR_CONST 289
! #define STR_CONST 290
! #define PR_EXTERNAL 291
! #define PR_INLINE 292
! #define PR_OBSOLETE 293
! #define PR_UNUSED 294
! #define AND 295
! #define ANY 296
! #define ARRAY 297
! #define AS 298
! #define BGN 299
! #define BITS 300
! #define BRANDED 301
! #define BY 302
! #define CASE 303
! #define CONST 304
! #define DIV 305
! #define DO 306
! #define ELSE 307
! #define ELSIF 308
! #define END 309
! #define EVAL 310
! #define EXCEPT 311
! #define EXCEPTION 312
! #define EXIT 313
! #define EXPORTS 314
! #define FINALLY 315
! #define FOR 316
! #define FROM 317
! #define GENERIC 318
! #define IF 319
! #define IMPORT 320
! #define IN 321
! #define INTERFACE 322
! #define LOCK 323
! #define LOOP 324
! #define METHODS 325
! #define MOD 326
! #define MODULE 327
! #define NOT 328
! #define OBJECT 329
! #define OF 330
! #define OR 331
! #define OVERRIDES 332
! #define PROCEDURE 333
! #define RAISE 334
! #define RAISES 335
! #define READONLY 336
! #define RECORD 337
! #define REF 338
! #define REPEAT 339
! #define RETURN 340
! #define REVEAL 341
! #define ROOT 342
! #define SET 343
! #define THEN 344
! #define TO 345
! #define TRY 346
! #define TYPE 347
! #define TYPECASE 348
! #define UNSAFE 349
! #define UNTIL 350
! #define UNTRACED 351
! #define VALUE 352
! #define VAR 353
! #define WHILE 354
! #define WITH 355
! #define BAD 356
! #define WHITESPACE 357
! #define MODUNIT 358
! #define DEFUNIT 359
! #line 92 "../Parse.yacc"
#define lexbufsize 500
***************
*** 182,204 ****
typedef enum {NonOptimal, OptimalBreak, OptimalNoBreak} Formatter_BreakType;
-
- #ifndef YYLTYPE
- typedef
- struct yyltype
- {
- int timestamp;
- int first_line;
- int first_column;
- int last_line;
- int last_column;
- char *text;
- }
- yyltype;
-
- #define YYLTYPE yyltype
- #endif
-
#ifndef YYSTYPE
#define YYSTYPE int
#endif
--- 183,188 ----
***************
*** 216,222 ****
#define YYFLAG -32768
#define YYNTBASE 106
! #define YYTRANSLATE(x) ((unsigned)(x) <= 360 ? yytranslate[x] : 488)
static const char yytranslate[] = { 0,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
--- 200,206 ----
#define YYFLAG -32768
#define YYNTBASE 106
! #define YYTRANSLATE(x) ((unsigned)(x) <= 359 ? yytranslate[x] : 488)
static const char yytranslate[] = { 0,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
***************
*** 244,260 ****
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
! 2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
! 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
! 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
! 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
! 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
! 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
! 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
! 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
! 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
! 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
! 96, 97, 98, 99, 100, 101, 102, 103, 104, 105
};
#if YYDEBUG != 0
--- 228,244 ----
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
! 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
! 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
! 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
! 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
! 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
! 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
! 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
! 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
! 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
! 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
! 97, 98, 99, 100, 101, 102, 103, 104, 105
};
#if YYDEBUG != 0
***************
*** 574,642 ****
#if YYDEBUG != 0
static const short yyrline[] = { 0,
! 206, 207, 208, 208, 209, 209, 212, 214, 217, 219,
! 222, 224, 225, 226, 229, 231, 234, 236, 237, 240,
! 242, 243, 244, 245, 246, 249, 254, 258, 262, 266,
! 273, 280, 282, 285, 287, 290, 292, 295, 297, 300,
! 302, 303, 304, 307, 311, 315, 317, 320, 322, 323,
! 324, 325, 326, 327, 328, 329, 330, 331, 332, 335,
! 337, 338, 339, 340, 343, 345, 348, 351, 354, 356,
! 359, 361, 364, 366, 369, 373, 376, 381, 384, 387,
! 390, 393, 397, 401, 403, 406, 408, 409, 412, 414,
! 415, 416, 419, 421, 424, 428, 432, 434, 435, 436,
! 439, 441, 442, 445, 447, 448, 453, 455, 456, 460,
! 462, 466, 468, 471, 473, 476, 478, 479, 480, 481,
! 482, 483, 484, 485, 486, 487, 488, 489, 490, 491,
! 492, 493, 494, 497, 502, 506, 508, 511, 513, 516,
! 520, 522, 525, 527, 530, 534, 539, 546, 548, 551,
! 555, 557, 560, 562, 565, 569, 573, 577, 581, 585,
! 587, 590, 594, 596, 599, 601, 604, 606, 609, 611,
! 614, 616, 619, 621, 624, 628, 632, 634, 637, 641,
! 643, 646, 648, 651, 653, 658, 660, 663, 665, 666,
! 667, 668, 671, 675, 677, 680, 682, 683, 684, 685,
! 686, 687, 688, 689, 692, 694, 698, 700, 701, 702,
! 705, 707, 710, 714, 716, 719, 721, 724, 726, 727,
! 730, 732, 733, 734, 737, 739, 742, 745, 749, 751,
! 752, 753, 756, 758, 761, 763, 764, 767, 769, 770,
! 773, 775, 776, 777, 780, 782, 785, 789, 795, 796,
! 796, 798, 799, 799, 801, 801, 803, 804, 804, 805,
! 805, 805, 805, 805, 805, 805, 807, 808, 808, 809,
! 809, 809, 811, 812, 812, 813, 813, 813, 813, 815,
! 815, 815, 818, 820, 820, 820, 820, 820, 821, 821,
! 823, 825, 828, 830, 833, 834, 835, 836, 837, 843,
! 844, 844, 846, 847, 847, 849, 849, 851, 852, 852,
! 854, 855, 855, 857, 858, 858, 860, 860, 860, 862,
! 863, 864, 865, 866, 867, 868, 869, 870, 873, 873,
! 873, 873, 875, 877, 880, 882, 885, 886, 887, 888,
! 889, 892, 894, 901, 903, 904, 904, 906, 908, 909,
! 910, 911, 916, 918, 921, 923, 926, 928, 931, 933,
! 936, 938, 939, 942, 944, 947, 949, 952, 954, 960,
! 960, 961, 961, 962, 962, 963, 963, 964, 964, 965,
! 965, 966, 966, 967, 967, 968, 968, 969, 969, 970,
! 970, 971, 971, 972, 972, 973, 973, 974, 974, 975,
! 975, 976, 976, 977, 977, 978, 978, 979, 979, 980,
! 980, 981, 982, 982, 983, 983, 984, 984, 987, 987,
! 988, 988, 989, 989, 990, 990, 995, 995, 996, 996,
! 997, 997, 998, 998, 1000, 1000, 1001, 1001, 1002, 1002,
! 1003, 1003, 1004, 1004, 1005, 1005, 1007, 1007, 1008, 1008,
! 1009, 1009, 1010, 1010, 1011, 1011, 1012, 1012, 1013, 1013,
! 1014, 1014, 1015, 1015, 1016, 1016, 1017, 1017, 1018, 1018,
! 1019, 1019, 1020, 1020, 1021, 1021, 1022, 1022, 1023, 1023,
! 1024, 1024, 1025, 1025, 1026, 1026, 1027, 1027, 1028, 1028,
! 1029, 1029, 1030, 1030, 1031, 1031, 1032, 1032, 1033, 1033,
! 1034, 1034, 1035, 1035, 1036, 1036, 1037, 1037, 1038, 1038,
! 1039, 1039, 1040, 1040, 1041, 1041, 1042, 1042, 1043, 1043,
! 1044, 1044, 1045, 1045, 1046, 1046, 1049, 1049, 1050, 1050,
! 1051, 1051, 1052, 1052, 1053, 1053, 1054, 1054, 1055, 1055,
! 1056, 1056, 1057, 1057, 1058, 1058, 1059, 1059, 1060, 1060,
! 1061, 1061, 1062, 1062, 1063, 1063, 1064, 1064, 1065, 1065,
! 1066, 1066, 1067, 1067, 1068, 1068, 1069, 1069, 1073, 1077,
! 1079, 1084, 1085, 1086, 1087, 1088, 1089, 1091, 1092, 1093,
! 1095, 1096, 1097, 1099, 1100, 1101, 1103, 1105, 1106, 1107,
! 1108, 1110, 1112, 1113, 1114, 1116, 1117
};
! static const char * const yytname[] = { "$","error","$illegal.","ENDOFFILE",
"AMPERSAND","ASSIGN","ASTERISK","BAR","COLON","COMMA","DOT","DOTDOT","EQUAL",
"GREATER","GREQUAL","LESS","LSEQUAL","MINUS","SHARP","PERIOD","PLUS","RARROW",
"RBRACE","RBRACKET","RPAREN","SEMICOLON","SLASH","SUBTYPE","UPARROW","LPAREN",
--- 558,630 ----
#if YYDEBUG != 0
static const short yyrline[] = { 0,
! 207, 208, 209, 209, 210, 210, 213, 215, 218, 220,
! 223, 225, 226, 227, 230, 232, 235, 237, 238, 241,
! 243, 244, 245, 246, 247, 250, 255, 259, 263, 267,
! 274, 281, 283, 286, 288, 291, 293, 296, 298, 301,
! 303, 304, 305, 308, 312, 316, 318, 321, 323, 324,
! 325, 326, 327, 328, 329, 330, 331, 332, 333, 336,
! 338, 339, 340, 341, 344, 346, 349, 352, 355, 357,
! 360, 362, 365, 367, 370, 374, 377, 382, 385, 388,
! 391, 394, 398, 402, 404, 407, 409, 410, 413, 415,
! 416, 417, 420, 422, 425, 429, 433, 435, 436, 437,
! 440, 442, 443, 446, 448, 449, 454, 456, 457, 461,
! 463, 467, 469, 472, 474, 477, 479, 480, 481, 482,
! 483, 484, 485, 486, 487, 488, 489, 490, 491, 492,
! 493, 494, 495, 498, 503, 507, 509, 512, 514, 517,
! 521, 523, 526, 528, 531, 535, 540, 547, 549, 552,
! 556, 558, 561, 563, 566, 570, 574, 578, 582, 586,
! 588, 591, 595, 597, 600, 602, 605, 607, 610, 612,
! 615, 617, 620, 622, 625, 629, 633, 635, 638, 642,
! 644, 647, 649, 652, 654, 659, 661, 664, 666, 667,
! 668, 669, 672, 676, 678, 681, 683, 684, 685, 686,
! 687, 688, 689, 690, 693, 695, 699, 701, 702, 703,
! 706, 708, 711, 715, 717, 720, 722, 725, 727, 728,
! 731, 733, 734, 735, 738, 740, 743, 746, 750, 752,
! 753, 754, 757, 759, 762, 764, 765, 768, 770, 771,
! 774, 776, 777, 778, 781, 783, 786, 790, 796, 797,
! 797, 799, 800, 800, 802, 802, 804, 805, 805, 806,
! 806, 806, 806, 806, 806, 806, 808, 809, 809, 810,
! 810, 810, 812, 813, 813, 814, 814, 814, 814, 816,
! 816, 816, 819, 821, 821, 821, 821, 821, 822, 822,
! 824, 826, 829, 831, 834, 835, 836, 837, 838, 844,
! 845, 845, 847, 848, 848, 850, 850, 852, 853, 853,
! 855, 856, 856, 858, 859, 859, 861, 861, 861, 863,
! 864, 865, 866, 867, 868, 869, 870, 871, 874, 874,
! 874, 874, 876, 878, 881, 883, 886, 887, 888, 889,
! 890, 893, 895, 902, 904, 905, 905, 907, 909, 910,
! 911, 912, 917, 919, 922, 924, 927, 929, 932, 934,
! 937, 939, 940, 943, 945, 948, 950, 953, 955, 961,
! 961, 962, 962, 963, 963, 964, 964, 965, 965, 966,
! 966, 967, 967, 968, 968, 969, 969, 970, 970, 971,
! 971, 972, 972, 973, 973, 974, 974, 975, 975, 976,
! 976, 977, 977, 978, 978, 979, 979, 980, 980, 981,
! 981, 982, 983, 983, 984, 984, 985, 985, 988, 988,
! 989, 989, 990, 990, 991, 991, 996, 996, 997, 997,
! 998, 998, 999, 999, 1001, 1001, 1002, 1002, 1003, 1003,
! 1004, 1004, 1005, 1005, 1006, 1006, 1008, 1008, 1009, 1009,
! 1010, 1010, 1011, 1011, 1012, 1012, 1013, 1013, 1014, 1014,
! 1015, 1015, 1016, 1016, 1017, 1017, 1018, 1018, 1019, 1019,
! 1020, 1020, 1021, 1021, 1022, 1022, 1023, 1023, 1024, 1024,
! 1025, 1025, 1026, 1026, 1027, 1027, 1028, 1028, 1029, 1029,
! 1030, 1030, 1031, 1031, 1032, 1032, 1033, 1033, 1034, 1034,
! 1035, 1035, 1036, 1036, 1037, 1037, 1038, 1038, 1039, 1039,
! 1040, 1040, 1041, 1041, 1042, 1042, 1043, 1043, 1044, 1044,
! 1045, 1045, 1046, 1046, 1047, 1047, 1050, 1050, 1051, 1051,
! 1052, 1052, 1053, 1053, 1054, 1054, 1055, 1055, 1056, 1056,
! 1057, 1057, 1058, 1058, 1059, 1059, 1060, 1060, 1061, 1061,
! 1062, 1062, 1063, 1063, 1064, 1064, 1065, 1065, 1066, 1066,
! 1067, 1067, 1068, 1068, 1069, 1069, 1070, 1070, 1074, 1078,
! 1080, 1085, 1086, 1087, 1088, 1089, 1090, 1092, 1093, 1094,
! 1096, 1097, 1098, 1100, 1101, 1102, 1104, 1106, 1107, 1108,
! 1109, 1111, 1113, 1114, 1115, 1117, 1118
};
+ #endif
+
+
+ #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
! static const char * const yytname[] = { "$","error","$undefined.","ENDOFFILE",
"AMPERSAND","ASSIGN","ASTERISK","BAR","COLON","COMMA","DOT","DOTDOT","EQUAL",
"GREATER","GREQUAL","LESS","LSEQUAL","MINUS","SHARP","PERIOD","PLUS","RARROW",
"RBRACE","RBRACKET","RPAREN","SEMICOLON","SLASH","SUBTYPE","UPARROW","LPAREN",
***************
*** 689,695 ****
"@93","Type","@94","Typecase","@95","Unsafe","@96","Until","@97","Untraced",
"@98","Value","@99","Var","@100","While","@101","With","@102","InitialNPS","NPS",
"G","B0","B","B2","E","EF","A","AO","AX","V","VZ","VC","Z","SP","XSP","BL","AL2",
! "AL3","ALZ5","EA","ALNL","SPNL","QSP","NL","Inc","Dec",""
};
#endif
--- 677,683 ----
"@93","Type","@94","Typecase","@95","Unsafe","@96","Until","@97","Untraced",
"@98","Value","@99","Var","@100","While","@101","With","@102","InitialNPS","NPS",
"G","B0","B","B2","E","EF","A","AO","AX","V","VZ","VC","Z","SP","XSP","BL","AL2",
! "AL3","ALZ5","EA","ALNL","SPNL","QSP","NL","Inc","Dec", NULL
};
#endif
***************
*** 1945,1958 ****
-1, -1, 1411
};
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
! #line 3 "/contrib/share/lib/bison.simple"
/* Skeleton output parser for bison,
! Copyright (C) 1984, 1989, 1990 Bob Corbett and Richard Stallman
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
! the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
--- 1933,1947 ----
-1, -1, 1411
};
/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
! #line 3 "/p/gnu/lib/bison-1.27/bison.simple"
! /* This file comes from bison-1.27. */
/* Skeleton output parser for bison,
! Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
! the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
***************
*** 1962,2003 ****
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
! Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
! #ifndef alloca
#ifdef __GNUC__
#define alloca __builtin_alloca
#else /* not GNU C. */
! #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
#include
#else /* not sparc */
! #if defined (MSDOS) && !defined (__TURBOC__)
#include
#else /* not MSDOS, or __TURBOC__ */
#if defined(_AIX)
! #include
#pragma alloca
! #else /* not MSDOS, __TURBOC__, or _AIX */
! #ifdef __hpux
! #ifdef __cplusplus
! extern "C" {
! void *alloca (unsigned int);
! };
! #else /* not __cplusplus */
! void *alloca ();
! #endif /* not __cplusplus */
#endif /* __hpux */
#endif /* not _AIX */
#endif /* not MSDOS, or __TURBOC__ */
! #endif /* not sparc. */
! #endif /* not GNU C. */
! #endif /* alloca not defined. */
! /* This is the parser code that is written into each bison parser
! when the %semantic_parser declaration is not specified in the grammar.
! It was written by Richard Stallman by simplifying the hairy parser
! used when %semantic_parser is specified. */
/* Note: there must be only one dollar sign in this file.
It is replaced by the list of actions, each action
--- 1951,2016 ----
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
! Foundation, Inc., 59 Temple Place - Suite 330,
! Boston, MA 02111-1307, USA. */
+ /* As a special exception, when this file is copied by Bison into a
+ Bison output file, you may use that output file without restriction.
+ This special exception was added by the Free Software Foundation
+ in version 1.24 of Bison. */
! /* This is the parser code that is written into each bison parser
! when the %semantic_parser declaration is not specified in the grammar.
! It was written by Richard Stallman by simplifying the hairy parser
! used when %semantic_parser is specified. */
!
! #ifndef YYSTACK_USE_ALLOCA
! #ifdef alloca
! #define YYSTACK_USE_ALLOCA
! #else /* alloca not defined */
#ifdef __GNUC__
+ #define YYSTACK_USE_ALLOCA
#define alloca __builtin_alloca
#else /* not GNU C. */
! #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
! #define YYSTACK_USE_ALLOCA
#include
#else /* not sparc */
! /* We think this test detects Watcom and Microsoft C. */
! /* This used to test MSDOS, but that is a bad idea
! since that symbol is in the user namespace. */
! #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
! #if 0 /* No need for malloc.h, which pollutes the namespace;
! instead, just don't use alloca. */
#include
+ #endif
#else /* not MSDOS, or __TURBOC__ */
#if defined(_AIX)
! /* I don't know what this was needed for, but it pollutes the namespace.
! So I turned it off. rms, 2 May 1997. */
! /* #include */
#pragma alloca
! #define YYSTACK_USE_ALLOCA
! #else /* not MSDOS, or __TURBOC__, or _AIX */
! #if 0
! #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
! and on HPUX 10. Eventually we can turn this on. */
! #define YYSTACK_USE_ALLOCA
! #define alloca __builtin_alloca
#endif /* __hpux */
+ #endif
#endif /* not _AIX */
#endif /* not MSDOS, or __TURBOC__ */
! #endif /* not sparc */
! #endif /* not GNU C */
! #endif /* alloca not defined */
! #endif /* YYSTACK_USE_ALLOCA not defined */
! #ifdef YYSTACK_USE_ALLOCA
! #define YYSTACK_ALLOC alloca
! #else
! #define YYSTACK_ALLOC malloc
! #endif
/* Note: there must be only one dollar sign in this file.
It is replaced by the list of actions, each action
***************
*** 2007,2014 ****
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY -2
#define YYEOF 0
! #define YYACCEPT return(0)
! #define YYABORT return(1)
#define YYERROR goto yyerrlab1
/* Like YYERROR except do call yyerror.
This remains here temporarily to ease the
--- 2020,2027 ----
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY -2
#define YYEOF 0
! #define YYACCEPT goto yyacceptlab
! #define YYABORT goto yyabortlab
#define YYERROR goto yyerrlab1
/* Like YYERROR except do call yyerror.
This remains here temporarily to ease the
***************
*** 2037,2046 ****
--- 2050,2067 ----
#ifdef YYPURE
#ifdef YYLSP_NEEDED
+ #ifdef YYLEX_PARAM
+ #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
+ #else
#define YYLEX yylex(&yylval, &yylloc)
+ #endif
+ #else /* not YYLSP_NEEDED */
+ #ifdef YYLEX_PARAM
+ #define YYLEX yylex(&yylval, YYLEX_PARAM)
#else
#define YYLEX yylex(&yylval)
#endif
+ #endif /* not YYLSP_NEEDED */
#endif
/* If nonreentrant, generate the variables here */
***************
*** 2081,2104 ****
#ifndef YYMAXDEPTH
#define YYMAXDEPTH 10000
#endif
-
- /* Prevent warning if -Wstrict-prototypes. */
- #ifdef __GNUC__
- int yyparse (void);
- #endif
#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
! #define __yy_bcopy(FROM,TO,COUNT) __builtin_memcpy(TO,FROM,COUNT)
#else /* not GNU C or C++ */
#ifndef __cplusplus
/* This is the most reliable way to avoid incompatibilities
in available built-in functions on various systems. */
static void
! __yy_bcopy (from, to, count)
! char *from;
char *to;
! int count;
{
register char *f = from;
register char *t = to;
--- 2102,2125 ----
#ifndef YYMAXDEPTH
#define YYMAXDEPTH 10000
#endif
+ /* Define __yy_memcpy. Note that the size argument
+ should be passed with type unsigned int, because that is what the non-GCC
+ definitions require. With GCC, __builtin_memcpy takes an arg
+ of type size_t, but it can handle unsigned int. */
+
#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
! #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
#else /* not GNU C or C++ */
#ifndef __cplusplus
/* This is the most reliable way to avoid incompatibilities
in available built-in functions on various systems. */
static void
! __yy_memcpy (to, from, count)
char *to;
! char *from;
! unsigned int count;
{
register char *f = from;
register char *t = to;
***************
*** 2113,2122 ****
/* This is the most reliable way to avoid incompatibilities
in available built-in functions on various systems. */
static void
! __yy_bcopy (char *from, char *to, int count)
{
- register char *f = from;
register char *t = to;
register int i = count;
while (i-- > 0)
--- 2134,2143 ----
/* This is the most reliable way to avoid incompatibilities
in available built-in functions on various systems. */
static void
! __yy_memcpy (char *to, char *from, unsigned int count)
{
register char *t = to;
+ register char *f = from;
register int i = count;
while (i-- > 0)
***************
*** 2126,2134 ****
#endif
#endif
! #line 184 "/contrib/share/lib/bison.simple"
int
! yyparse()
{
register int yystate;
register int yyn;
--- 2147,2185 ----
#endif
#endif
! #line 216 "/p/gnu/lib/bison-1.27/bison.simple"
!
! /* The user can define YYPARSE_PARAM as the name of an argument to be passed
! into yyparse. The argument should have type void *.
! It should actually point to an object.
! Grammar actions can access the variable by casting it
! to the proper pointer type. */
!
! #ifdef YYPARSE_PARAM
! #ifdef __cplusplus
! #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
! #define YYPARSE_PARAM_DECL
! #else /* not __cplusplus */
! #define YYPARSE_PARAM_ARG YYPARSE_PARAM
! #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
! #endif /* not __cplusplus */
! #else /* not YYPARSE_PARAM */
! #define YYPARSE_PARAM_ARG
! #define YYPARSE_PARAM_DECL
! #endif /* not YYPARSE_PARAM */
!
! /* Prevent warning if -Wstrict-prototypes. */
! #ifdef __GNUC__
! #ifdef YYPARSE_PARAM
! int yyparse (void *);
! #else
! int yyparse (void);
! #endif
! #endif
!
int
! yyparse(YYPARSE_PARAM_ARG)
! YYPARSE_PARAM_DECL
{
register int yystate;
register int yyn;
***************
*** 2154,2159 ****
--- 2205,2211 ----
#endif
int yystacksize = YYINITDEPTH;
+ int yyfree_stacks = 0;
#ifdef YYPURE
int yychar;
***************
*** 2238,2255 ****
if (yystacksize >= YYMAXDEPTH)
{
yyerror("parser stack overflow");
return 2;
}
yystacksize *= 2;
if (yystacksize > YYMAXDEPTH)
yystacksize = YYMAXDEPTH;
! yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
! __yy_bcopy ((char *)yyss1, (char *)yyss, size * sizeof (*yyssp));
! yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
! __yy_bcopy ((char *)yyvs1, (char *)yyvs, size * sizeof (*yyvsp));
#ifdef YYLSP_NEEDED
! yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
! __yy_bcopy ((char *)yyls1, (char *)yyls, size * sizeof (*yylsp));
#endif
#endif /* no yyoverflow */
--- 2290,2321 ----
if (yystacksize >= YYMAXDEPTH)
{
yyerror("parser stack overflow");
+ if (yyfree_stacks)
+ {
+ free (yyss);
+ free (yyvs);
+ #ifdef YYLSP_NEEDED
+ free (yyls);
+ #endif
+ }
return 2;
}
yystacksize *= 2;
if (yystacksize > YYMAXDEPTH)
yystacksize = YYMAXDEPTH;
! #ifndef YYSTACK_USE_ALLOCA
! yyfree_stacks = 1;
! #endif
! yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
! __yy_memcpy ((char *)yyss, (char *)yyss1,
! size * (unsigned int) sizeof (*yyssp));
! yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
! __yy_memcpy ((char *)yyvs, (char *)yyvs1,
! size * (unsigned int) sizeof (*yyvsp));
#ifdef YYLSP_NEEDED
! yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
! __yy_memcpy ((char *)yyls, (char *)yyls1,
! size * (unsigned int) sizeof (*yylsp));
#endif
#endif /* no yyoverflow */
***************
*** 2410,2953 ****
switch (yyn) {
case 1:
! #line 207 "../Parse.yacc"
{ depth=0; ;
break;}
case 3:
! #line 208 "../Parse.yacc"
{ depth=0; ;
break;}
case 4:
! #line 208 "../Parse.yacc"
{ Flush(); ;
break;}
case 5:
! #line 209 "../Parse.yacc"
{ depth=0; ;
break;}
case 6:
! #line 209 "../Parse.yacc"
{ Flush(); ;
break;}
case 370:
! #line 960 "../Parse.yacc"
{ PR ("&");;
break;}
case 372:
! #line 961 "../Parse.yacc"
{ PR (":=");;
break;}
case 374:
! #line 962 "../Parse.yacc"
{ PR ("*");;
break;}
case 376:
! #line 963 "../Parse.yacc"
{ PR ("|");;
break;}
case 378:
! #line 964 "../Parse.yacc"
{ PR (":");;
break;}
case 380:
! #line 965 "../Parse.yacc"
{ PR (",");;
break;}
case 382:
! #line 966 "../Parse.yacc"
{ PR (".");;
break;}
case 384:
! #line 967 "../Parse.yacc"
{ PR ("..");;
break;}
case 386:
! #line 968 "../Parse.yacc"
{ PR ("=");;
break;}
case 388:
! #line 969 "../Parse.yacc"
{ PR (">");;
break;}
case 390:
! #line 970 "../Parse.yacc"
{ PR (">=");;
break;}
case 392:
! #line 971 "../Parse.yacc"
{ PR ("<");;
break;}
case 394:
! #line 972 "../Parse.yacc"
{ PR ("<=");;
break;}
case 396:
! #line 973 "../Parse.yacc"
{ PR ("-");;
break;}
case 398:
! #line 974 "../Parse.yacc"
{ PR ("\043");;
break;}
case 400:
! #line 975 "../Parse.yacc"
{ PR ("+");;
break;}
case 402:
! #line 976 "../Parse.yacc"
{ PR ("=>");;
break;}
case 404:
! #line 977 "../Parse.yacc"
{ PR ("}");;
break;}
case 406:
! #line 978 "../Parse.yacc"
{ PR ("]");;
break;}
case 408:
! #line 979 "../Parse.yacc"
{ PR (")");;
break;}
case 410:
! #line 980 "../Parse.yacc"
{ PR (";");;
break;}
case 412:
! #line 981 "../Parse.yacc"
{ PR (";");;
break;}
case 413:
! #line 982 "../Parse.yacc"
{ PR ("/");;
break;}
case 415:
! #line 983 "../Parse.yacc"
{ PR ("<:");;
break;}
case 417:
! #line 984 "../Parse.yacc"
{ PR ("^");;
break;}
case 419:
! #line 987 "../Parse.yacc"
{ PR ("("); ;
break;}
case 421:
! #line 988 "../Parse.yacc"
{ PR ("("); ;
break;}
case 423:
! #line 989 "../Parse.yacc"
{ PR ("["); ;
break;}
case 425:
! #line 990 "../Parse.yacc"
{ PR ("{"); ;
break;}
case 427:
! #line 995 "../Parse.yacc"
{ PF (&lexbuf[yyvsp[0]], fonts->fixedComment);;
break;}
case 429:
! #line 996 "../Parse.yacc"
{ PF (&lexbuf[yyvsp[0]], fonts->fixedComment);;
break;}
case 431:
! #line 997 "../Parse.yacc"
{ PF (&lexbuf[yyvsp[0]], fonts->fixedComment);;
break;}
case 433:
! #line 998 "../Parse.yacc"
{ PF (&lexbuf[yyvsp[0]], fonts->fixedComment);;
break;}
case 435:
! #line 1000 "../Parse.yacc"
{ PRID (&lexbuf[yyvsp[0]]);;
break;}
case 437:
! #line 1001 "../Parse.yacc"
{ PF (&lexbuf[yyvsp[0]], fonts->procName);;
break;}
case 439:
! #line 1002 "../Parse.yacc"
{ PR (&lexbuf[yyvsp[0]]);;
break;}
case 441:
! #line 1003 "../Parse.yacc"
{ PR (&lexbuf[yyvsp[0]]);;
break;}
case 443:
! #line 1004 "../Parse.yacc"
{ PF (&lexbuf[yyvsp[0]], fonts->fixed);;
break;}
case 445:
! #line 1005 "../Parse.yacc"
{ PF (&lexbuf[yyvsp[0]], fonts->fixed);;
break;}
case 447:
! #line 1007 "../Parse.yacc"
{ PK ("AND");;
break;}
case 449:
! #line 1008 "../Parse.yacc"
{ PK ("ANY");;
break;}
case 451:
! #line 1009 "../Parse.yacc"
{ PK ("ARRAY");;
break;}
case 453:
! #line 1010 "../Parse.yacc"
{ PK ("AS");;
break;}
case 455:
! #line 1011 "../Parse.yacc"
{ PK ("BEGIN");;
break;}
case 457:
! #line 1012 "../Parse.yacc"
{ PK ("BITS");;
break;}
case 459:
! #line 1013 "../Parse.yacc"
{ PK ("BRANDED");;
break;}
case 461:
! #line 1014 "../Parse.yacc"
{ PK ("BY");;
break;}
case 463:
! #line 1015 "../Parse.yacc"
{ PK ("CASE");;
break;}
case 465:
! #line 1016 "../Parse.yacc"
{ PK ("CONST");;
break;}
case 467:
! #line 1017 "../Parse.yacc"
{ PR ("DIV");;
break;}
case 469:
! #line 1018 "../Parse.yacc"
{ PK ("DO");;
break;}
case 471:
! #line 1019 "../Parse.yacc"
{ PK ("ELSE");;
break;}
case 473:
! #line 1020 "../Parse.yacc"
{ PK ("ELSIF");;
break;}
case 475:
! #line 1021 "../Parse.yacc"
{ PK ("END");;
break;}
case 477:
! #line 1022 "../Parse.yacc"
{ PK ("EVAL");;
break;}
case 479:
! #line 1023 "../Parse.yacc"
{ PK ("EXCEPT");;
break;}
case 481:
! #line 1024 "../Parse.yacc"
{ PK ("EXCEPTION");;
break;}
case 483:
! #line 1025 "../Parse.yacc"
{ PK ("EXIT");;
break;}
case 485:
! #line 1026 "../Parse.yacc"
{ PK ("EXPORTS");;
break;}
case 487:
! #line 1027 "../Parse.yacc"
{ PK ("FINALLY");;
break;}
case 489:
! #line 1028 "../Parse.yacc"
{ PK ("FOR");;
break;}
case 491:
! #line 1029 "../Parse.yacc"
{ PK ("FROM");;
break;}
case 493:
! #line 1030 "../Parse.yacc"
{ PK ("GENERIC");;
break;}
case 495:
! #line 1031 "../Parse.yacc"
{ PK ("IF");;
break;}
case 497:
! #line 1032 "../Parse.yacc"
{ PK ("IMPORT");;
break;}
case 499:
! #line 1033 "../Parse.yacc"
{ PK ("IN");;
break;}
case 501:
! #line 1034 "../Parse.yacc"
{ PK ("INTERFACE");;
break;}
case 503:
! #line 1035 "../Parse.yacc"
{ PK ("LOCK");;
break;}
case 505:
! #line 1036 "../Parse.yacc"
{ PK ("LOOP");;
break;}
case 507:
! #line 1037 "../Parse.yacc"
{ PK ("METHODS");;
break;}
case 509:
! #line 1038 "../Parse.yacc"
{ PK ("MOD");;
break;}
case 511:
! #line 1039 "../Parse.yacc"
{ PK ("MODULE");;
break;}
case 513:
! #line 1040 "../Parse.yacc"
{ PK ("NOT");;
break;}
case 515:
! #line 1041 "../Parse.yacc"
{ PK ("OBJECT");;
break;}
case 517:
! #line 1042 "../Parse.yacc"
{ PK ("OF");;
break;}
case 519:
! #line 1043 "../Parse.yacc"
{ PK ("OR");;
break;}
case 521:
! #line 1044 "../Parse.yacc"
{ PK ("OVERRIDES");;
break;}
case 523:
! #line 1045 "../Parse.yacc"
{ PK ("PROCEDURE");;
break;}
case 525:
! #line 1046 "../Parse.yacc"
{ PK ("RAISE");;
break;}
case 527:
! #line 1049 "../Parse.yacc"
{ DoBreak(1, 2, 0.0); PK ("RAISES");;
break;}
case 529:
! #line 1050 "../Parse.yacc"
{ PK ("READONLY");;
break;}
case 531:
! #line 1051 "../Parse.yacc"
{ PK ("RECORD");;
break;}
case 533:
! #line 1052 "../Parse.yacc"
{ PK ("REF");;
break;}
case 535:
! #line 1053 "../Parse.yacc"
{ PK ("REPEAT");;
break;}
case 537:
! #line 1054 "../Parse.yacc"
{ PK ("RETURN");;
break;}
case 539:
! #line 1055 "../Parse.yacc"
{ PK ("REVEAL");;
break;}
case 541:
! #line 1056 "../Parse.yacc"
{ PK ("ROOT");;
break;}
case 543:
! #line 1057 "../Parse.yacc"
{ PK ("SET");;
break;}
case 545:
! #line 1058 "../Parse.yacc"
{ PK ("THEN");;
break;}
case 547:
! #line 1059 "../Parse.yacc"
{ PK ("TO");;
break;}
case 549:
! #line 1060 "../Parse.yacc"
{ PK ("TRY");;
break;}
case 551:
! #line 1061 "../Parse.yacc"
{ PK ("TYPE");;
break;}
case 553:
! #line 1062 "../Parse.yacc"
{ PK ("TYPECASE");;
break;}
case 555:
! #line 1063 "../Parse.yacc"
{ PK ("UNSAFE");;
break;}
case 557:
! #line 1064 "../Parse.yacc"
{ PK ("UNTIL");;
break;}
case 559:
! #line 1065 "../Parse.yacc"
{ PK ("UNTRACED");;
break;}
case 561:
! #line 1066 "../Parse.yacc"
{ PK ("VALUE");;
break;}
case 563:
! #line 1067 "../Parse.yacc"
{ PK ("VAR");;
break;}
case 565:
! #line 1068 "../Parse.yacc"
{ PK ("WHILE");;
break;}
case 567:
! #line 1069 "../Parse.yacc"
{ PK ("WITH");;
break;}
case 569:
! #line 1074 "../Parse.yacc"
{ blanklinep = 0; PrintNPS(1); ;
break;}
case 570:
! #line 1078 "../Parse.yacc"
{ blanklinep = 0; ;
break;}
case 571:
! #line 1079 "../Parse.yacc"
{ blanklinep = 0; PrintNPS(0); ;
break;}
case 572:
! #line 1084 "../Parse.yacc"
{ GR (); ;
break;}
case 573:
! #line 1085 "../Parse.yacc"
{ BE (0.0); ;
break;}
case 574:
! #line 1086 "../Parse.yacc"
{ BE (offset); ;
break;}
case 575:
! #line 1087 "../Parse.yacc"
{ BE (offset*2); ;
break;}
case 576:
! #line 1088 "../Parse.yacc"
{ EN (); ;
break;}
case 577:
! #line 1089 "../Parse.yacc"
{ ENF (); ;
break;}
case 578:
! #line 1091 "../Parse.yacc"
{ DoBreak (1, 2, 0.0); ;
break;}
case 579:
! #line 1092 "../Parse.yacc"
{ DoBreak (1, 3, 0.0); ;
break;}
case 580:
! #line 1093 "../Parse.yacc"
{ DoBreak (0, 3, 0.0); ;
break;}
case 581:
! #line 1095 "../Parse.yacc"
{ DoBreak (1, 1, 0.0); ;
break;}
case 582:
! #line 1096 "../Parse.yacc"
{ DoBreak (1, 1, -offset); ;
break;}
case 583:
! #line 1097 "../Parse.yacc"
{ DoBreak (1, 1, -offset + 2.0 * bodySpaceWidth); ;
break;}
case 584:
! #line 1099 "../Parse.yacc"
{ DoBreak (0, 0, 0.0); ;
break;}
case 585:
! #line 1100 "../Parse.yacc"
{ DoBreak (1, 0, 0.0); ;
break;}
case 586:
! #line 1101 "../Parse.yacc"
{ P2 (' '); ;
break;}
case 587:
! #line 1103 "../Parse.yacc"
{ BL (); ;
break;}
case 588:
! #line 1105 "../Parse.yacc"
{ DoAlign (2, 0); ;
break;}
case 589:
! #line 1106 "../Parse.yacc"
{ DoAlign (3, 0); ;
break;}
case 590:
! #line 1107 "../Parse.yacc"
{ DoAlign (5, 1); ;
break;}
case 591:
! #line 1108 "../Parse.yacc"
{ EndAlign (); ;
break;}
case 592:
! #line 1110 "../Parse.yacc"
{ ALNL(); ;
break;}
case 593:
! #line 1112 "../Parse.yacc"
{ DoSPNL (); ;
break;}
case 594:
! #line 1113 "../Parse.yacc"
{ DoQSP (); ;
break;}
case 595:
! #line 1114 "../Parse.yacc"
{ NL (); ;
break;}
case 596:
! #line 1116 "../Parse.yacc"
{ depth++; ;
break;}
case 597:
! #line 1117 "../Parse.yacc"
{ depth--; ;
break;}
}
/* the action file gets copied in in place of this dollarsign */
! #line 465 "/contrib/share/lib/bison.simple"
yyvsp -= yylen;
yyssp -= yylen;
--- 2476,3019 ----
switch (yyn) {
case 1:
! #line 208 "../Parse.yacc"
{ depth=0; ;
break;}
case 3:
! #line 209 "../Parse.yacc"
{ depth=0; ;
break;}
case 4:
! #line 209 "../Parse.yacc"
{ Flush(); ;
break;}
case 5:
! #line 210 "../Parse.yacc"
{ depth=0; ;
break;}
case 6:
! #line 210 "../Parse.yacc"
{ Flush(); ;
break;}
case 370:
! #line 961 "../Parse.yacc"
{ PR ("&");;
break;}
case 372:
! #line 962 "../Parse.yacc"
{ PR (":=");;
break;}
case 374:
! #line 963 "../Parse.yacc"
{ PR ("*");;
break;}
case 376:
! #line 964 "../Parse.yacc"
{ PR ("|");;
break;}
case 378:
! #line 965 "../Parse.yacc"
{ PR (":");;
break;}
case 380:
! #line 966 "../Parse.yacc"
{ PR (",");;
break;}
case 382:
! #line 967 "../Parse.yacc"
{ PR (".");;
break;}
case 384:
! #line 968 "../Parse.yacc"
{ PR ("..");;
break;}
case 386:
! #line 969 "../Parse.yacc"
{ PR ("=");;
break;}
case 388:
! #line 970 "../Parse.yacc"
{ PR (">");;
break;}
case 390:
! #line 971 "../Parse.yacc"
{ PR (">=");;
break;}
case 392:
! #line 972 "../Parse.yacc"
{ PR ("<");;
break;}
case 394:
! #line 973 "../Parse.yacc"
{ PR ("<=");;
break;}
case 396:
! #line 974 "../Parse.yacc"
{ PR ("-");;
break;}
case 398:
! #line 975 "../Parse.yacc"
{ PR ("\043");;
break;}
case 400:
! #line 976 "../Parse.yacc"
{ PR ("+");;
break;}
case 402:
! #line 977 "../Parse.yacc"
{ PR ("=>");;
break;}
case 404:
! #line 978 "../Parse.yacc"
{ PR ("}");;
break;}
case 406:
! #line 979 "../Parse.yacc"
{ PR ("]");;
break;}
case 408:
! #line 980 "../Parse.yacc"
{ PR (")");;
break;}
case 410:
! #line 981 "../Parse.yacc"
{ PR (";");;
break;}
case 412:
! #line 982 "../Parse.yacc"
{ PR (";");;
break;}
case 413:
! #line 983 "../Parse.yacc"
{ PR ("/");;
break;}
case 415:
! #line 984 "../Parse.yacc"
{ PR ("<:");;
break;}
case 417:
! #line 985 "../Parse.yacc"
{ PR ("^");;
break;}
case 419:
! #line 988 "../Parse.yacc"
{ PR ("("); ;
break;}
case 421:
! #line 989 "../Parse.yacc"
{ PR ("("); ;
break;}
case 423:
! #line 990 "../Parse.yacc"
{ PR ("["); ;
break;}
case 425:
! #line 991 "../Parse.yacc"
{ PR ("{"); ;
break;}
case 427:
! #line 996 "../Parse.yacc"
{ PF (&lexbuf[yyvsp[0]], fonts->fixedComment);;
break;}
case 429:
! #line 997 "../Parse.yacc"
{ PF (&lexbuf[yyvsp[0]], fonts->fixedComment);;
break;}
case 431:
! #line 998 "../Parse.yacc"
{ PF (&lexbuf[yyvsp[0]], fonts->fixedComment);;
break;}
case 433:
! #line 999 "../Parse.yacc"
{ PF (&lexbuf[yyvsp[0]], fonts->fixedComment);;
break;}
case 435:
! #line 1001 "../Parse.yacc"
{ PRID (&lexbuf[yyvsp[0]]);;
break;}
case 437:
! #line 1002 "../Parse.yacc"
{ PF (&lexbuf[yyvsp[0]], fonts->procName);;
break;}
case 439:
! #line 1003 "../Parse.yacc"
{ PR (&lexbuf[yyvsp[0]]);;
break;}
case 441:
! #line 1004 "../Parse.yacc"
{ PR (&lexbuf[yyvsp[0]]);;
break;}
case 443:
! #line 1005 "../Parse.yacc"
{ PF (&lexbuf[yyvsp[0]], fonts->fixed);;
break;}
case 445:
! #line 1006 "../Parse.yacc"
{ PF (&lexbuf[yyvsp[0]], fonts->fixed);;
break;}
case 447:
! #line 1008 "../Parse.yacc"
{ PK ("AND");;
break;}
case 449:
! #line 1009 "../Parse.yacc"
{ PK ("ANY");;
break;}
case 451:
! #line 1010 "../Parse.yacc"
{ PK ("ARRAY");;
break;}
case 453:
! #line 1011 "../Parse.yacc"
{ PK ("AS");;
break;}
case 455:
! #line 1012 "../Parse.yacc"
{ PK ("BEGIN");;
break;}
case 457:
! #line 1013 "../Parse.yacc"
{ PK ("BITS");;
break;}
case 459:
! #line 1014 "../Parse.yacc"
{ PK ("BRANDED");;
break;}
case 461:
! #line 1015 "../Parse.yacc"
{ PK ("BY");;
break;}
case 463:
! #line 1016 "../Parse.yacc"
{ PK ("CASE");;
break;}
case 465:
! #line 1017 "../Parse.yacc"
{ PK ("CONST");;
break;}
case 467:
! #line 1018 "../Parse.yacc"
{ PR ("DIV");;
break;}
case 469:
! #line 1019 "../Parse.yacc"
{ PK ("DO");;
break;}
case 471:
! #line 1020 "../Parse.yacc"
{ PK ("ELSE");;
break;}
case 473:
! #line 1021 "../Parse.yacc"
{ PK ("ELSIF");;
break;}
case 475:
! #line 1022 "../Parse.yacc"
{ PK ("END");;
break;}
case 477:
! #line 1023 "../Parse.yacc"
{ PK ("EVAL");;
break;}
case 479:
! #line 1024 "../Parse.yacc"
{ PK ("EXCEPT");;
break;}
case 481:
! #line 1025 "../Parse.yacc"
{ PK ("EXCEPTION");;
break;}
case 483:
! #line 1026 "../Parse.yacc"
{ PK ("EXIT");;
break;}
case 485:
! #line 1027 "../Parse.yacc"
{ PK ("EXPORTS");;
break;}
case 487:
! #line 1028 "../Parse.yacc"
{ PK ("FINALLY");;
break;}
case 489:
! #line 1029 "../Parse.yacc"
{ PK ("FOR");;
break;}
case 491:
! #line 1030 "../Parse.yacc"
{ PK ("FROM");;
break;}
case 493:
! #line 1031 "../Parse.yacc"
{ PK ("GENERIC");;
break;}
case 495:
! #line 1032 "../Parse.yacc"
{ PK ("IF");;
break;}
case 497:
! #line 1033 "../Parse.yacc"
{ PK ("IMPORT");;
break;}
case 499:
! #line 1034 "../Parse.yacc"
{ PK ("IN");;
break;}
case 501:
! #line 1035 "../Parse.yacc"
{ PK ("INTERFACE");;
break;}
case 503:
! #line 1036 "../Parse.yacc"
{ PK ("LOCK");;
break;}
case 505:
! #line 1037 "../Parse.yacc"
{ PK ("LOOP");;
break;}
case 507:
! #line 1038 "../Parse.yacc"
{ PK ("METHODS");;
break;}
case 509:
! #line 1039 "../Parse.yacc"
{ PK ("MOD");;
break;}
case 511:
! #line 1040 "../Parse.yacc"
{ PK ("MODULE");;
break;}
case 513:
! #line 1041 "../Parse.yacc"
{ PK ("NOT");;
break;}
case 515:
! #line 1042 "../Parse.yacc"
{ PK ("OBJECT");;
break;}
case 517:
! #line 1043 "../Parse.yacc"
{ PK ("OF");;
break;}
case 519:
! #line 1044 "../Parse.yacc"
{ PK ("OR");;
break;}
case 521:
! #line 1045 "../Parse.yacc"
{ PK ("OVERRIDES");;
break;}
case 523:
! #line 1046 "../Parse.yacc"
{ PK ("PROCEDURE");;
break;}
case 525:
! #line 1047 "../Parse.yacc"
{ PK ("RAISE");;
break;}
case 527:
! #line 1050 "../Parse.yacc"
{ DoBreak(1, 2, 0.0); PK ("RAISES");;
break;}
case 529:
! #line 1051 "../Parse.yacc"
{ PK ("READONLY");;
break;}
case 531:
! #line 1052 "../Parse.yacc"
{ PK ("RECORD");;
break;}
case 533:
! #line 1053 "../Parse.yacc"
{ PK ("REF");;
break;}
case 535:
! #line 1054 "../Parse.yacc"
{ PK ("REPEAT");;
break;}
case 537:
! #line 1055 "../Parse.yacc"
{ PK ("RETURN");;
break;}
case 539:
! #line 1056 "../Parse.yacc"
{ PK ("REVEAL");;
break;}
case 541:
! #line 1057 "../Parse.yacc"
{ PK ("ROOT");;
break;}
case 543:
! #line 1058 "../Parse.yacc"
{ PK ("SET");;
break;}
case 545:
! #line 1059 "../Parse.yacc"
{ PK ("THEN");;
break;}
case 547:
! #line 1060 "../Parse.yacc"
{ PK ("TO");;
break;}
case 549:
! #line 1061 "../Parse.yacc"
{ PK ("TRY");;
break;}
case 551:
! #line 1062 "../Parse.yacc"
{ PK ("TYPE");;
break;}
case 553:
! #line 1063 "../Parse.yacc"
{ PK ("TYPECASE");;
break;}
case 555:
! #line 1064 "../Parse.yacc"
{ PK ("UNSAFE");;
break;}
case 557:
! #line 1065 "../Parse.yacc"
{ PK ("UNTIL");;
break;}
case 559:
! #line 1066 "../Parse.yacc"
{ PK ("UNTRACED");;
break;}
case 561:
! #line 1067 "../Parse.yacc"
{ PK ("VALUE");;
break;}
case 563:
! #line 1068 "../Parse.yacc"
{ PK ("VAR");;
break;}
case 565:
! #line 1069 "../Parse.yacc"
{ PK ("WHILE");;
break;}
case 567:
! #line 1070 "../Parse.yacc"
{ PK ("WITH");;
break;}
case 569:
! #line 1075 "../Parse.yacc"
{ blanklinep = 0; PrintNPS(1); ;
break;}
case 570:
! #line 1079 "../Parse.yacc"
{ blanklinep = 0; ;
break;}
case 571:
! #line 1080 "../Parse.yacc"
{ blanklinep = 0; PrintNPS(0); ;
break;}
case 572:
! #line 1085 "../Parse.yacc"
{ GR (); ;
break;}
case 573:
! #line 1086 "../Parse.yacc"
{ BE (0.0); ;
break;}
case 574:
! #line 1087 "../Parse.yacc"
{ BE (offset); ;
break;}
case 575:
! #line 1088 "../Parse.yacc"
{ BE (offset*2); ;
break;}
case 576:
! #line 1089 "../Parse.yacc"
{ EN (); ;
break;}
case 577:
! #line 1090 "../Parse.yacc"
{ ENF (); ;
break;}
case 578:
! #line 1092 "../Parse.yacc"
{ DoBreak (1, 2, 0.0); ;
break;}
case 579:
! #line 1093 "../Parse.yacc"
{ DoBreak (1, 3, 0.0); ;
break;}
case 580:
! #line 1094 "../Parse.yacc"
{ DoBreak (0, 3, 0.0); ;
break;}
case 581:
! #line 1096 "../Parse.yacc"
{ DoBreak (1, 1, 0.0); ;
break;}
case 582:
! #line 1097 "../Parse.yacc"
{ DoBreak (1, 1, -offset); ;
break;}
case 583:
! #line 1098 "../Parse.yacc"
{ DoBreak (1, 1, -offset + 2.0 * bodySpaceWidth); ;
break;}
case 584:
! #line 1100 "../Parse.yacc"
{ DoBreak (0, 0, 0.0); ;
break;}
case 585:
! #line 1101 "../Parse.yacc"
{ DoBreak (1, 0, 0.0); ;
break;}
case 586:
! #line 1102 "../Parse.yacc"
{ P2 (' '); ;
break;}
case 587:
! #line 1104 "../Parse.yacc"
{ BL (); ;
break;}
case 588:
! #line 1106 "../Parse.yacc"
{ DoAlign (2, 0); ;
break;}
case 589:
! #line 1107 "../Parse.yacc"
{ DoAlign (3, 0); ;
break;}
case 590:
! #line 1108 "../Parse.yacc"
{ DoAlign (5, 1); ;
break;}
case 591:
! #line 1109 "../Parse.yacc"
{ EndAlign (); ;
break;}
case 592:
! #line 1111 "../Parse.yacc"
{ ALNL(); ;
break;}
case 593:
! #line 1113 "../Parse.yacc"
{ DoSPNL (); ;
break;}
case 594:
! #line 1114 "../Parse.yacc"
{ DoQSP (); ;
break;}
case 595:
! #line 1115 "../Parse.yacc"
{ NL (); ;
break;}
case 596:
! #line 1117 "../Parse.yacc"
{ depth++; ;
break;}
case 597:
! #line 1118 "../Parse.yacc"
{ depth--; ;
break;}
}
/* the action file gets copied in in place of this dollarsign */
! #line 542 "/p/gnu/lib/bison-1.27/bison.simple"
yyvsp -= yylen;
yyssp -= yylen;
***************
*** 3142,3149 ****
yystate = yyn;
goto yynewstate;
}
! #line 1119 "../Parse.yacc"
/*-------- additional C code to implement the semantic routines -----------*/
--- 3208,3239 ----
yystate = yyn;
goto yynewstate;
+
+ yyacceptlab:
+ /* YYACCEPT comes here. */
+ if (yyfree_stacks)
+ {
+ free (yyss);
+ free (yyvs);
+ #ifdef YYLSP_NEEDED
+ free (yyls);
+ #endif
+ }
+ return 0;
+
+ yyabortlab:
+ /* YYABORT comes here. */
+ if (yyfree_stacks)
+ {
+ free (yyss);
+ free (yyvs);
+ #ifdef YYLSP_NEEDED
+ free (yyls);
+ #endif
+ }
+ return 1;
}
! #line 1120 "../Parse.yacc"
/*-------- additional C code to implement the semantic routines -----------*/
***************
*** 3385,3390 ****
--- 3475,3481 ----
#define PRODUCE(x) {fprintf (stderr, "%d ", x); return (x); }
#include
+ #include
#include "hash.h"
#include "lex.yy.c"
#include "lex_help.h"
***************
*** 3467,3475 ****
temp2 = input(); /* input comes from the lex library. */
if ((calledFromEmacs && (temp2 == '\001')) || (temp2 == 0)) return;
temp = input();
! while ((temp != 0) && (!calledFromEmacs || (temp != '\001')))
{P (temp2); temp2 = temp; temp = input();}
! if ((temp2 != '\n') || (temp != 0)) P(temp2);
}
/* Print out first comment. Hidden down here so it can see the comment
--- 3558,3566 ----
temp2 = input(); /* input comes from the lex library. */
if ((calledFromEmacs && (temp2 == '\001')) || (temp2 == 0)) return;
temp = input();
! while ((temp > 0) && (!calledFromEmacs || (temp != '\001')))
{P (temp2); temp2 = temp; temp = input();}
! if ((temp2 != '\n') || (temp > 0)) P(temp2);
}
/* Print out first comment. Hidden down here so it can see the comment
Index: m3/pm3/libs/libm3/src/os/POSIX/FilePosix.m3
diff -c m3/pm3/libs/libm3/src/os/POSIX/FilePosix.m3:1.3 m3/pm3/libs/libm3/src/os/POSIX/FilePosix.m3:1.4
*** m3/pm3/libs/libm3/src/os/POSIX/FilePosix.m3:1.3 Fri Sep 26 08:41:41 1997
--- m3/pm3/libs/libm3/src/os/POSIX/FilePosix.m3 Thu Apr 29 11:38:48 1999
***************
*** 233,239 ****
ELSIF status = -1
AND errno # Uerror.EWOULDBLOCK
AND errno # Uerror.EAGAIN THEN
! OSErrorPosix.Raise()
ELSIF NOT mayBlock THEN
RETURN -1
END;
--- 233,239 ----
ELSIF status = -1
AND errno # Uerror.EWOULDBLOCK
AND errno # Uerror.EAGAIN THEN
! OSErrorPosix.Raise0(errno)
ELSIF NOT mayBlock THEN
RETURN -1
END;
***************
*** 276,282 ****
ELSIF status = -1
AND errno # Uerror.EWOULDBLOCK
AND errno # Uerror.EAGAIN THEN
! OSErrorPosix.Raise()
END;
EVAL SchedulerPosix.IOWait(h.fd, FALSE)
--- 276,282 ----
ELSIF status = -1
AND errno # Uerror.EWOULDBLOCK
AND errno # Uerror.EAGAIN THEN
! OSErrorPosix.Raise0(errno)
END;
EVAL SchedulerPosix.IOWait(h.fd, FALSE)
Index: m3/pm3/libs/libm3/src/random/m3makefile
diff -c m3/pm3/libs/libm3/src/random/m3makefile:1.5 m3/pm3/libs/libm3/src/random/m3makefile:1.6
*** m3/pm3/libs/libm3/src/random/m3makefile:1.5 Tue Apr 28 16:01:50 1998
--- m3/pm3/libs/libm3/src/random/m3makefile Mon Jun 7 13:13:26 1999
***************
*** 17,24 ****
--- 17,26 ----
"ARM" : [ _LittleEndian ],
"DS3100" : [ _LittleEndian ],
"DS3100_OSF" : [ _LittleEndian ],
+ "FBSD_ALPHA" : [ _LittleEndian ],
"FreeBSD" : [ _LittleEndian ],
"FreeBSD2" : [ _LittleEndian ],
+ "FreeBSD3" : [ _LittleEndian ],
"HP300" : [ _BigEndian ],
"HPPA" : [ _BigEndian ],
"IBMR2" : [ _BigEndian ],
Index: m3/pm3/libs/m3core/src/C/FBSD_ALPHA/COPYRIGHT
diff -c /dev/null m3/pm3/libs/m3core/src/C/FBSD_ALPHA/COPYRIGHT:1.1
*** /dev/null Mon Jun 7 17:09:05 1999
--- m3/pm3/libs/m3core/src/C/FBSD_ALPHA/COPYRIGHT Mon Jun 7 13:13:36 1999
***************
*** 0 ****
--- 1,93 ----
+
+ Digital License Agreement
+
+ SRC Modula-3
+
+ 1. Grant Of License. Digital Equipment Corporation, having a principal
+ office at 146 Main Street, Maynard, MA 01754 ("DIGITAL") grants to
+ you ("LICENSEE") the non-exclusive, non-transferable, royalty free
+ right to use, modify, reproduce and distribute SRC Modula-3 ("SOFTWARE")
+ subject to the terms set forth herein. Any distribution of SOFTWARE
+ shall include this Digital License Agreement in human readable form.
+
+ 2. Title to Intellectual Property and Software. Subject to the limited
+ rights and licenses granted under this License Agreement, all rights,
+ title and interests including patent, copyright, and trademark rights
+ in SOFTWARE are and shall remain vested in DIGITAL to the exclusion
+ of LICENSEE. DIGITAL represents and warrants that DIGITAL has the
+ legal right to grant such licenses as are expressly granted under
+ this Agreement.
+
+ 3. Copyright. The SOFTWARE is owned by DIGITAL or its suppliers and is
+ protected by United States copyright laws and international treaty
+ provisions. Therefore, you must treat the SOFTWARE like any other
+ copyrighted material (e.g., a book or musical recording) except
+ that you may use the SOFTWARE as provided in this Digital License
+ Agreement.
+
+ 4. Improvements. LICENSEE hereby grants to DIGITAL a non-exclusive,
+ non-transferable, royalty free right to use, modify, reproduce
+ and distribute with the right to sublicense at any tier, any
+ improvements, enhancements, extensions, or modifications that
+ LICENSEE make to SOFTWARE, provided such are returned to DIGITAL
+ by LICENSEE.
+
+ 5. DISCLAIMER OF WARRANTY. Because the SOFTWARE is a research work and
+ not a released product, it is provided "AS IS" WITHOUT WARRANTY OF ANY
+ KIND AND WITHOUT ANY SUPPORT SERVICES. EXCEPT AS SPECIFICALLY PROVIDED
+ ABOVE IN SECTION 2, DIGITAL FURTHER DISCLAIMS ALL OTHER EXPRESS OR
+ IMPLIED WARRANTIES OF MERCHANTABILITY OR OF FITNESS FOR A PARTICULAR
+ PURPOSE. THE ENTIRE RISK ARISING OUT OF THE USE OR PERFORMANCE OF
+ THE SOFTWARE REMAINS WITH YOU.
+
+ 6. Limitation of Liability. IN NO EVENT SHALL DIGITAL OR ITS SUPPLIERS BE
+ LIABLE IN AN AMOUNT THAT EXCEEDS THE LICENSE FEE PAID BY LICENSEE FOR
+ ANY DAMAGES (INCLUDING, WITH LIMITATION, DAMAGES FOR LOSS OF BUSINESS
+ PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER
+ PECUNIARY LOSS), REGARDLESS OF THE FORM OF CLAIM OR ACTIONS, ARISING
+ OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE OR DOCUMENTATION,
+ EVEN IF DIGITAL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ BECAUSE SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY
+ FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT
+ APPLY TO YOU.
+
+ 7. Acknowledgement of Allocation of Risk. LICENSEE acknowledges and agrees
+ that the fees charged by DIGITAL in this Agreement reflect the allocation
+ of risks provided by the foregoing limitation of liability. LICENSEE
+ acknowledges and represents that it has read and understands these
+ allocations of risk limiting the liability of DIGITAL and that it
+ understands that a modification of the allocation of risks set forth
+ in this agreement would affect the fees charged by DIGITAL, and that
+ LICENSEE, in consideration of such fees, agrees to such allocations
+ of risk.
+
+ 8. LICENSEE INDEMNIFICATION. LICENSEE SHALL INDEMNIFY DIGITAL AGAINST
+ ALL COSTS AND DAMAGE JUDGEMENTS, INCLUDING ATTORNEY'S FEES AND COSTS
+ OF DEFENSE, INCURRED BECAUSE OF CLAIMS OF DAMAGE ARISING FROM LICENSEE'S
+ POSSESSION OR USE OR INABILITY TO USE SOFTWARE.
+
+ 9. GOVERNMENT RESTRICTED RIGHTS. The SOFTWARE and documentation are provided
+ with RESTRICTED RIGHTS. Use duplication, or disclosure by the Government
+ is subject restrictions as set forth in subparagraph (c)(1)(ii) of The
+ Rights in Technical Data and Computer Software clause in DFARS
+ 252.227-7013, or subparagraphs (c)(i) and (2) of the Commercial Computer
+ Software -- Restricted Rights at 48 CFR 52.227-19, as applicable.
+ Manufacturer is Digital Equipment Corporation, 130 Lytton Avenue,
+ Palo Alto, CA 94301-1044.
+
+ 10. Severability. If any provision of the Agreement is held illegal or
+ unenforceable by any court of competent jurisdiction, such provision
+ shall be deemed separable from the remaining provisions of this Agreement
+ and shall not affect or impair the validity or enforceability of the
+ remaining provisions of this Agreement.
+
+ 11. Governing Law. This Agreement is governed by the laws of the
+ Commonwealth of Massachusetts.
+
+ 12. Publicity. You my not use the name of DIGITAL in any advertisement,
+ press release or other publicity with reference to SRC Modula-3
+ without prior written consent of DIGITAL.
+
+ 13. Should you have any questions concerning this Agreement, or if you
+ desire to contact Digital for any reason, please do so via E-mail:
+ M3-REQUEST@SRC.DEC.COM.
Index: m3/pm3/libs/m3core/src/C/FBSD_ALPHA/Csetjmp.i3
diff -c /dev/null m3/pm3/libs/m3core/src/C/FBSD_ALPHA/Csetjmp.i3:1.1
*** /dev/null Mon Jun 7 17:09:05 1999
--- m3/pm3/libs/m3core/src/C/FBSD_ALPHA/Csetjmp.i3 Mon Jun 7 13:13:36 1999
***************
*** 0 ****
--- 1,23 ----
+ (* Copyright (C) 1990, Digital Equipment Corporation *)
+ (* All rights reserved. *)
+ (* See the file COPYRIGHT for a full description. *)
+ (* *)
+ (* Last modified on Tue Oct 18 08:40:23 PDT 1994 by kalsow *)
+ (* modified on Fri Apr 30 16:25:40 PDT 1993 by muller *)
+ (* Olaf Wagner 12.09.1994 *)
+
+ INTERFACE Csetjmp; (* for FreeBSD *)
+
+ FROM Ctypes IMPORT int, long;
+
+ TYPE
+ jmp_buf = ARRAY [0..81] OF long;
+
+ <*EXTERNAL "setjmp" *> PROCEDURE setjmp (VAR env: jmp_buf): int;
+ <*EXTERNAL "longjmp" *> 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.
+
Index: m3/pm3/libs/m3core/src/C/FBSD_ALPHA/Csignal.i3
diff -c /dev/null m3/pm3/libs/m3core/src/C/FBSD_ALPHA/Csignal.i3:1.1
*** /dev/null Mon Jun 7 17:09:05 1999
--- m3/pm3/libs/m3core/src/C/FBSD_ALPHA/Csignal.i3 Mon Jun 7 13:13:36 1999
***************
*** 0 ****
--- 1,18 ----
+ (* Copyright (C) 1992, Digital Equipment Corporation *)
+ (* All rights reserved. *)
+ (* See the file COPYRIGHT for a full description. *)
+ (* *)
+ (* Last modified on Mon Oct 17 09:12:23 PDT 1994 by kalsow *)
+ (* 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.
Index: m3/pm3/libs/m3core/src/C/FBSD_ALPHA/Cstdio.i3
diff -c /dev/null m3/pm3/libs/m3core/src/C/FBSD_ALPHA/Cstdio.i3:1.1
*** /dev/null Mon Jun 7 17:09:05 1999
--- m3/pm3/libs/m3core/src/C/FBSD_ALPHA/Cstdio.i3 Mon Jun 7 13:13:36 1999
***************
*** 0 ****
--- 1,74 ----
+ (* Copyright (C) 1990, Digital Equipment Corporation. *)
+ (* All rights reserved. *)
+ (* See the file COPYRIGHT for a full description. *)
+ (* *)
+ (* Last modified on Sat Jan 7 13:12:39 PST 1995 by kalsow *)
+ (* modified on Thu May 6 09:18:19 PDT 1993 by muller *)
+ (* Olaf Wagner 16.09.1994 *)
+
+ INTERFACE Cstdio;
+
+ FROM Ctypes IMPORT int, void_star, char_star,
+ unsigned_char_star, short_int, unsigned_char;
+
+ FROM Utypes IMPORT off_t;
+
+ CONST
+ NIOBRW = 100;
+ NSTDBUF= 3;
+ EOF = VAL(-1, int);
+
+ TYPE
+ SBUF = RECORD
+ base : unsigned_char_star;
+ size : int;
+ END;
+
+ FILE = RECORD
+ p : unsigned_char_star; (* current position in (some) buffer *)
+ r : int; (* read space left for getc() *)
+ w : int; (* write space left for putc() *)
+ flags : short_int; (* flags, below; this FILE is free if 0 *)
+ file : short_int; (* fileno, if Unix descriptor, else -1 *)
+ bf : SBUF; (* the buffer (at least 1 byte, if !NULL) *)
+ lbfsize : int; (* 0 or -_bf._size, for inline putc *)
+
+ (* operations *)
+ cookie : void_star; (* cookie passed to io functions *)
+ xxclose: void_star;
+ xxread : void_star;
+ xxseek : void_star;
+ xxwrite: void_star;
+
+ (* separate buffer for long sequences of ungetc() *)
+ ub : SBUF; (* ungetc buffer *)
+ up : unsigned_char_star; (* saved _p when _p is doing ungetc data *)
+ ur : int; (* saved _r when _r is counting ungetc data *)
+
+ (* tricks to meet minimum requirements even when malloc() fails *)
+ ubuf : ARRAY[0..2] OF unsigned_char; (* guarantee an ungetc() buffer *)
+ nbuf : ARRAY[0..0] OF unsigned_char; (* guarantee a getc() buffer *)
+
+ (* separate buffer for fgetln() when line crosses buffer boundary *)
+ lb : SBUF; (* buffer for fgetln() *)
+
+ (* Unix stdio files get aligned to block boundaries on fseek() *)
+ blksize : int; (* stat.st_blksize (may be != _bf._size) *)
+ offset : off_t; (* current lseek offset *)
+
+ END;
+
+ FILE_star = UNTRACED REF FILE;
+
+ <*EXTERNAL "__sF"*> VAR sF : ARRAY [0..NSTDBUF-1] OF FILE;
+ VAR iF : ARRAY [0..NIOBRW-1] OF FILE_star;
+
+ <*EXTERNAL fbsd_feof*> PROCEDURE feof (f: FILE_star): int;
+ <*EXTERNAL fbsd_getc*> PROCEDURE getc (f: FILE_star): int;
+ <*EXTERNAL fbsd_ungetc*> PROCEDURE ungetc (c: int; f: FILE_star): int;
+ <*EXTERNAL fbsd_putc*> PROCEDURE putc (c: int; f: FILE_star): int;
+ <*EXTERNAL fbsd_fflush*> PROCEDURE fflush (f: FILE_star): int;
+ <*EXTERNAL fbsd_fdopen*> PROCEDURE fdopen (fd: int; mode: char_star): FILE_star;
+ <*EXTERNAL fbsd_fclose*> PROCEDURE fclose (f: FILE_star): int;
+
+ END Cstdio.
Index: m3/pm3/libs/m3core/src/C/FBSD_ALPHA/Cstdio.m3
diff -c /dev/null m3/pm3/libs/m3core/src/C/FBSD_ALPHA/Cstdio.m3:1.1
*** /dev/null Mon Jun 7 17:09:05 1999
--- m3/pm3/libs/m3core/src/C/FBSD_ALPHA/Cstdio.m3 Mon Jun 7 13:13:36 1999
***************
*** 0 ****
--- 1,17 ----
+ (* Copyright (C) 1992, Digital Equipment Corporation *)
+ (* All rights reserved. *)
+ (* See the file COPYRIGHT for a full description. *)
+ (* *)
+ (* Last modified on Mon Oct 17 09:17:55 PDT 1994 by kalsow *)
+ (* Olaf Wagner 16.09.1994 *)
+
+ UNSAFE MODULE Cstdio;
+
+ BEGIN
+ iF[0] := ADR(sF[0]);
+ iF[1] := ADR(sF[1]);
+ iF[2] := ADR(sF[2]);
+ FOR i := NSTDBUF TO NIOBRW-1 DO
+ iF[i] := NIL;
+ END;
+ END Cstdio.
Index: m3/pm3/libs/m3core/src/C/FBSD_ALPHA/CstdioC.c
diff -c /dev/null m3/pm3/libs/m3core/src/C/FBSD_ALPHA/CstdioC.c:1.1
*** /dev/null Mon Jun 7 17:09:05 1999
--- m3/pm3/libs/m3core/src/C/FBSD_ALPHA/CstdioC.c Mon Jun 7 13:13:36 1999
***************
*** 0 ****
--- 1,42 ----
+ /* Copyright (C) 1994, Digital Equipment Corporation */
+ /* All rights reserved. */
+ /* See the file COPYRIGHT for a full description. */
+ /* */
+ /* Last modified on Mon Oct 17 09:17:31 PDT 1994 by kalsow */
+ /* Olaf Wagner 16.09.1994 */
+
+ #include
+
+ int fbsd_feof(FILE *f){
+ return feof(f);
+ };
+
+ int fbsd_getc(FILE *f){
+ return fgetc(f);
+ };
+
+ int fbsd_ungetc(int c, FILE *f){
+ return ungetc(c, f);
+ };
+
+ int fbsd_putc(int c, FILE *f){
+ return fputc(c, f);
+ };
+
+ int fbsd_fflush(FILE *f){
+ return fflush(f);
+ };
+
+ FILE* fbsd_fdopen(int fildes, char *mode){
+ FILE* f;
+ f = fdopen(fildes, mode);
+ if (f == NULL){
+ fprintf(stderr, "fd: %d, mode: %s\n", fildes, mode);
+ perror("fdopen failed ");
+ }
+ return f;
+ }
+
+ int fbsd_fclose(FILE *f){
+ return fclose(f);
+ };
Index: m3/pm3/libs/m3core/src/C/FBSD_ALPHA/Cstring.i3
diff -c /dev/null m3/pm3/libs/m3core/src/C/FBSD_ALPHA/Cstring.i3:1.1
*** /dev/null Mon Jun 7 17:09:05 1999
--- m3/pm3/libs/m3core/src/C/FBSD_ALPHA/Cstring.i3 Mon Jun 7 13:13:36 1999
***************
*** 0 ****
--- 1,89 ----
+ (* Copyright (C) 1989, Digital Equipment Corporation *)
+ (* All rights reserved. *)
+ (* See the file COPYRIGHT for a full description. *)
+ (* *)
+ (* File: Cstring.i3 *)
+ (* Last modified on Mon Oct 17 09:19:10 PDT 1994 by kalsow *)
+ (* modified on Tue Apr 20 20:16:18 PDT 1993 by muller *)
+ (* modified on Sat Jan 20 22:31:44 1990 by jerome *)
+ (* Olaf Wagner 16.09.1994 *)
+
+
+ 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.
+
Index: m3/pm3/libs/m3core/src/C/FBSD_ALPHA/m3makefile
diff -c /dev/null m3/pm3/libs/m3core/src/C/FBSD_ALPHA/m3makefile:1.1
*** /dev/null Mon Jun 7 17:09:05 1999
--- m3/pm3/libs/m3core/src/C/FBSD_ALPHA/m3makefile Mon Jun 7 13:13:36 1999
***************
*** 0 ****
--- 1,17 ----
+ % Copyright (C) 1994, Digital Equipment Corporation
+ % All rights reserved.
+ % See the file COPYRIGHT for a full description.
+ %
+ % Last modified on Mon Oct 17 09:20:03 PDT 1994 by kalsow
+ % modified on Fri Jun 18 13:20:32 PDT 1993 by harrison
+ % modified on Thu May 6 13:16:32 PDT 1993 by muller
+ % Olaf Wagner 16.09.1994
+
+ Interface ("Csetjmp")
+ Interface ("Csignal")
+ Interface ("Cstring")
+ Module ("Cstdio")
+
+ c_source ("CstdioC")
+
+
Index: m3/pm3/libs/m3core/src/C/FreeBSD2/Cstdio.i3
diff -c m3/pm3/libs/m3core/src/C/FreeBSD2/Cstdio.i3:1.1.1.1 m3/pm3/libs/m3core/src/C/FreeBSD2/Cstdio.i3:1.2
*** m3/pm3/libs/m3core/src/C/FreeBSD2/Cstdio.i3:1.1.1.1 Thu Jan 16 16:29:59 1997
--- m3/pm3/libs/m3core/src/C/FreeBSD2/Cstdio.i3 Mon Jun 7 13:13:41 1999
***************
*** 55,60 ****
--- 55,61 ----
(* Unix stdio files get aligned to block boundaries on fseek() *)
blksize : int; (* stat.st_blksize (may be != _bf._size) *)
offset : off_t; (* current lseek offset *)
+ pad1 : int; (* assume high 4 bytes of offset are 0 *)
END;
Index: m3/pm3/libs/m3core/src/C/FreeBSD3/COPYRIGHT
diff -c /dev/null m3/pm3/libs/m3core/src/C/FreeBSD3/COPYRIGHT:1.1
*** /dev/null Mon Jun 7 17:09:05 1999
--- m3/pm3/libs/m3core/src/C/FreeBSD3/COPYRIGHT Mon Jun 7 13:13:45 1999
***************
*** 0 ****
--- 1,93 ----
+
+ Digital License Agreement
+
+ SRC Modula-3
+
+ 1. Grant Of License. Digital Equipment Corporation, having a principal
+ office at 146 Main Street, Maynard, MA 01754 ("DIGITAL") grants to
+ you ("LICENSEE") the non-exclusive, non-transferable, royalty free
+ right to use, modify, reproduce and distribute SRC Modula-3 ("SOFTWARE")
+ subject to the terms set forth herein. Any distribution of SOFTWARE
+ shall include this Digital License Agreement in human readable form.
+
+ 2. Title to Intellectual Property and Software. Subject to the limited
+ rights and licenses granted under this License Agreement, all rights,
+ title and interests including patent, copyright, and trademark rights
+ in SOFTWARE are and shall remain vested in DIGITAL to the exclusion
+ of LICENSEE. DIGITAL represents and warrants that DIGITAL has the
+ legal right to grant such licenses as are expressly granted under
+ this Agreement.
+
+ 3. Copyright. The SOFTWARE is owned by DIGITAL or its suppliers and is
+ protected by United States copyright laws and international treaty
+ provisions. Therefore, you must treat the SOFTWARE like any other
+ copyrighted material (e.g., a book or musical recording) except
+ that you may use the SOFTWARE as provided in this Digital License
+ Agreement.
+
+ 4. Improvements. LICENSEE hereby grants to DIGITAL a non-exclusive,
+ non-transferable, royalty free right to use, modify, reproduce
+ and distribute with the right to sublicense at any tier, any
+ improvements, enhancements, extensions, or modifications that
+ LICENSEE make to SOFTWARE, provided such are returned to DIGITAL
+ by LICENSEE.
+
+ 5. DISCLAIMER OF WARRANTY. Because the SOFTWARE is a research work and
+ not a released product, it is provided "AS IS" WITHOUT WARRANTY OF ANY
+ KIND AND WITHOUT ANY SUPPORT SERVICES. EXCEPT AS SPECIFICALLY PROVIDED
+ ABOVE IN SECTION 2, DIGITAL FURTHER DISCLAIMS ALL OTHER EXPRESS OR
+ IMPLIED WARRANTIES OF MERCHANTABILITY OR OF FITNESS FOR A PARTICULAR
+ PURPOSE. THE ENTIRE RISK ARISING OUT OF THE USE OR PERFORMANCE OF
+ THE SOFTWARE REMAINS WITH YOU.
+
+ 6. Limitation of Liability. IN NO EVENT SHALL DIGITAL OR ITS SUPPLIERS BE
+ LIABLE IN AN AMOUNT THAT EXCEEDS THE LICENSE FEE PAID BY LICENSEE FOR
+ ANY DAMAGES (INCLUDING, WITH LIMITATION, DAMAGES FOR LOSS OF BUSINESS
+ PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER
+ PECUNIARY LOSS), REGARDLESS OF THE FORM OF CLAIM OR ACTIONS, ARISING
+ OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE OR DOCUMENTATION,
+ EVEN IF DIGITAL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ BECAUSE SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY
+ FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT
+ APPLY TO YOU.
+
+ 7. Acknowledgement of Allocation of Risk. LICENSEE acknowledges and agrees
+ that the fees charged by DIGITAL in this Agreement reflect the allocation
+ of risks provided by the foregoing limitation of liability. LICENSEE
+ acknowledges and represents that it has read and understands these
+ allocations of risk limiting the liability of DIGITAL and that it
+ understands that a modification of the allocation of risks set forth
+ in this agreement would affect the fees charged by DIGITAL, and that
+ LICENSEE, in consideration of such fees, agrees to such allocations
+ of risk.
+
+ 8. LICENSEE INDEMNIFICATION. LICENSEE SHALL INDEMNIFY DIGITAL AGAINST
+ ALL COSTS AND DAMAGE JUDGEMENTS, INCLUDING ATTORNEY'S FEES AND COSTS
+ OF DEFENSE, INCURRED BECAUSE OF CLAIMS OF DAMAGE ARISING FROM LICENSEE'S
+ POSSESSION OR USE OR INABILITY TO USE SOFTWARE.
+
+ 9. GOVERNMENT RESTRICTED RIGHTS. The SOFTWARE and documentation are provided
+ with RESTRICTED RIGHTS. Use duplication, or disclosure by the Government
+ is subject restrictions as set forth in subparagraph (c)(1)(ii) of The
+ Rights in Technical Data and Computer Software clause in DFARS
+ 252.227-7013, or subparagraphs (c)(i) and (2) of the Commercial Computer
+ Software -- Restricted Rights at 48 CFR 52.227-19, as applicable.
+ Manufacturer is Digital Equipment Corporation, 130 Lytton Avenue,
+ Palo Alto, CA 94301-1044.
+
+ 10. Severability. If any provision of the Agreement is held illegal or
+ unenforceable by any court of competent jurisdiction, such provision
+ shall be deemed separable from the remaining provisions of this Agreement
+ and shall not affect or impair the validity or enforceability of the
+ remaining provisions of this Agreement.
+
+ 11. Governing Law. This Agreement is governed by the laws of the
+ Commonwealth of Massachusetts.
+
+ 12. Publicity. You my not use the name of DIGITAL in any advertisement,
+ press release or other publicity with reference to SRC Modula-3
+ without prior written consent of DIGITAL.
+
+ 13. Should you have any questions concerning this Agreement, or if you
+ desire to contact Digital for any reason, please do so via E-mail:
+ M3-REQUEST@SRC.DEC.COM.
Index: m3/pm3/libs/m3core/src/C/FreeBSD3/Csetjmp.i3
diff -c /dev/null m3/pm3/libs/m3core/src/C/FreeBSD3/Csetjmp.i3:1.1
*** /dev/null Mon Jun 7 17:09:05 1999
--- m3/pm3/libs/m3core/src/C/FreeBSD3/Csetjmp.i3 Mon Jun 7 13:13:45 1999
***************
*** 0 ****
--- 1,32 ----
+ (* Copyright (C) 1990, Digital Equipment Corporation *)
+ (* All rights reserved. *)
+ (* See the file COPYRIGHT for a full description. *)
+ (* *)
+ (* Last modified on Tue Oct 18 08:40:23 PDT 1994 by kalsow *)
+ (* modified on Fri Apr 30 16:25:40 PDT 1993 by muller *)
+ (* Olaf Wagner 12.09.1994 *)
+
+ INTERFACE Csetjmp; (* for FreeBSD *)
+
+ FROM Ctypes IMPORT int;
+
+ TYPE
+ jmp_buf = ARRAY [0..10] OF int; (* actually, this is a sigjmp_buf,
+ just in case *)
+
+ fpjmp_buf = ARRAY [0..36] OF int; (* this is needed to hold the
+ fpu state, which the ordinary
+ versions of setjmp/longjmp
+ do not save and restore *)
+
+ <*EXTERNAL "setjmp" *> PROCEDURE setjmp (VAR env: jmp_buf): int;
+ <*EXTERNAL "longjmp" *> 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);
+
+ <*EXTERNAL "_fpsetjmp" *> PROCEDURE fpsetjmp (VAR env: fpjmp_buf): int;
+ <*EXTERNAL "_fplongjmp" *> PROCEDURE fplongjmp (VAR env: fpjmp_buf; val: int);
+
+ END Csetjmp.
+
Index: m3/pm3/libs/m3core/src/C/FreeBSD3/Csignal.i3
diff -c /dev/null m3/pm3/libs/m3core/src/C/FreeBSD3/Csignal.i3:1.1
*** /dev/null Mon Jun 7 17:09:05 1999
--- m3/pm3/libs/m3core/src/C/FreeBSD3/Csignal.i3 Mon Jun 7 13:13:45 1999
***************
*** 0 ****
--- 1,18 ----
+ (* Copyright (C) 1992, Digital Equipment Corporation *)
+ (* All rights reserved. *)
+ (* See the file COPYRIGHT for a full description. *)
+ (* *)
+ (* Last modified on Mon Oct 17 09:12:23 PDT 1994 by kalsow *)
+ (* 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.
Index: m3/pm3/libs/m3core/src/C/FreeBSD3/Cstdio.i3
diff -c /dev/null m3/pm3/libs/m3core/src/C/FreeBSD3/Cstdio.i3:1.1
*** /dev/null Mon Jun 7 17:09:05 1999
--- m3/pm3/libs/m3core/src/C/FreeBSD3/Cstdio.i3 Mon Jun 7 13:13:45 1999
***************
*** 0 ****
--- 1,75 ----
+ (* Copyright (C) 1990, Digital Equipment Corporation. *)
+ (* All rights reserved. *)
+ (* See the file COPYRIGHT for a full description. *)
+ (* *)
+ (* Last modified on Sat Jan 7 13:12:39 PST 1995 by kalsow *)
+ (* modified on Thu May 6 09:18:19 PDT 1993 by muller *)
+ (* Olaf Wagner 16.09.1994 *)
+
+ INTERFACE Cstdio;
+
+ FROM Ctypes IMPORT int, void_star, char_star,
+ unsigned_char_star, short_int, unsigned_char;
+
+ FROM Utypes IMPORT off_t;
+
+ CONST
+ NIOBRW = 100;
+ NSTDBUF= 3;
+ EOF = VAL(-1, int);
+
+ TYPE
+ SBUF = RECORD
+ base : unsigned_char_star;
+ size : int;
+ END;
+
+ FILE = RECORD
+ p : unsigned_char_star; (* current position in (some) buffer *)
+ r : int; (* read space left for getc() *)
+ w : int; (* write space left for putc() *)
+ flags : short_int; (* flags, below; this FILE is free if 0 *)
+ file : short_int; (* fileno, if Unix descriptor, else -1 *)
+ bf : SBUF; (* the buffer (at least 1 byte, if !NULL) *)
+ lbfsize : int; (* 0 or -_bf._size, for inline putc *)
+
+ (* operations *)
+ cookie : void_star; (* cookie passed to io functions *)
+ xxclose: void_star;
+ xxread : void_star;
+ xxseek : void_star;
+ xxwrite: void_star;
+
+ (* separate buffer for long sequences of ungetc() *)
+ ub : SBUF; (* ungetc buffer *)
+ up : unsigned_char_star; (* saved _p when _p is doing ungetc data *)
+ ur : int; (* saved _r when _r is counting ungetc data *)
+
+ (* tricks to meet minimum requirements even when malloc() fails *)
+ ubuf : ARRAY[0..2] OF unsigned_char; (* guarantee an ungetc() buffer *)
+ nbuf : ARRAY[0..0] OF unsigned_char; (* guarantee a getc() buffer *)
+
+ (* separate buffer for fgetln() when line crosses buffer boundary *)
+ lb : SBUF; (* buffer for fgetln() *)
+
+ (* Unix stdio files get aligned to block boundaries on fseek() *)
+ blksize : int; (* stat.st_blksize (may be != _bf._size) *)
+ offset : off_t; (* current lseek offset *)
+ pad1 : int; (* assume high 4 bytes of offset are 0 *)
+
+ END;
+
+ FILE_star = UNTRACED REF FILE;
+
+ <*EXTERNAL "__sF"*> VAR sF : ARRAY [0..NSTDBUF-1] OF FILE;
+ VAR iF : ARRAY [0..NIOBRW-1] OF FILE_star;
+
+ <*EXTERNAL fbsd_feof*> PROCEDURE feof (f: FILE_star): int;
+ <*EXTERNAL fbsd_getc*> PROCEDURE getc (f: FILE_star): int;
+ <*EXTERNAL fbsd_ungetc*> PROCEDURE ungetc (c: int; f: FILE_star): int;
+ <*EXTERNAL fbsd_putc*> PROCEDURE putc (c: int; f: FILE_star): int;
+ <*EXTERNAL fbsd_fflush*> PROCEDURE fflush (f: FILE_star): int;
+ <*EXTERNAL fbsd_fdopen*> PROCEDURE fdopen (fd: int; mode: char_star): FILE_star;
+ <*EXTERNAL fbsd_fclose*> PROCEDURE fclose (f: FILE_star): int;
+
+ END Cstdio.
Index: m3/pm3/libs/m3core/src/C/FreeBSD3/Cstdio.i3.orig
diff -c /dev/null m3/pm3/libs/m3core/src/C/FreeBSD3/Cstdio.i3.orig:1.1
*** /dev/null Mon Jun 7 17:09:05 1999
--- m3/pm3/libs/m3core/src/C/FreeBSD3/Cstdio.i3.orig Mon Jun 7 13:13:45 1999
***************
*** 0 ****
--- 1,74 ----
+ (* Copyright (C) 1990, Digital Equipment Corporation. *)
+ (* All rights reserved. *)
+ (* See the file COPYRIGHT for a full description. *)
+ (* *)
+ (* Last modified on Sat Jan 7 13:12:39 PST 1995 by kalsow *)
+ (* modified on Thu May 6 09:18:19 PDT 1993 by muller *)
+ (* Olaf Wagner 16.09.1994 *)
+
+ INTERFACE Cstdio;
+
+ FROM Ctypes IMPORT int, void_star, char_star,
+ unsigned_char_star, short_int, unsigned_char;
+
+ FROM Utypes IMPORT off_t;
+
+ CONST
+ NIOBRW = 100;
+ NSTDBUF= 3;
+ EOF = VAL(-1, int);
+
+ TYPE
+ SBUF = RECORD
+ base : unsigned_char_star;
+ size : int;
+ END;
+
+ FILE = RECORD
+ p : unsigned_char_star; (* current position in (some) buffer *)
+ r : int; (* read space left for getc() *)
+ w : int; (* write space left for putc() *)
+ flags : short_int; (* flags, below; this FILE is free if 0 *)
+ file : short_int; (* fileno, if Unix descriptor, else -1 *)
+ bf : SBUF; (* the buffer (at least 1 byte, if !NULL) *)
+ lbfsize : int; (* 0 or -_bf._size, for inline putc *)
+
+ (* operations *)
+ cookie : void_star; (* cookie passed to io functions *)
+ xxclose: void_star;
+ xxread : void_star;
+ xxseek : void_star;
+ xxwrite: void_star;
+
+ (* separate buffer for long sequences of ungetc() *)
+ ub : SBUF; (* ungetc buffer *)
+ up : unsigned_char_star; (* saved _p when _p is doing ungetc data *)
+ ur : int; (* saved _r when _r is counting ungetc data *)
+
+ (* tricks to meet minimum requirements even when malloc() fails *)
+ ubuf : ARRAY[0..2] OF unsigned_char; (* guarantee an ungetc() buffer *)
+ nbuf : ARRAY[0..0] OF unsigned_char; (* guarantee a getc() buffer *)
+
+ (* separate buffer for fgetln() when line crosses buffer boundary *)
+ lb : SBUF; (* buffer for fgetln() *)
+
+ (* Unix stdio files get aligned to block boundaries on fseek() *)
+ blksize : int; (* stat.st_blksize (may be != _bf._size) *)
+ offset : off_t; (* current lseek offset *)
+
+ END;
+
+ FILE_star = UNTRACED REF FILE;
+
+ <*EXTERNAL "__sF"*> VAR sF : ARRAY [0..NSTDBUF-1] OF FILE;
+ VAR iF : ARRAY [0..NIOBRW-1] OF FILE_star;
+
+ <*EXTERNAL fbsd_feof*> PROCEDURE feof (f: FILE_star): int;
+ <*EXTERNAL fbsd_getc*> PROCEDURE getc (f: FILE_star): int;
+ <*EXTERNAL fbsd_ungetc*> PROCEDURE ungetc (c: int; f: FILE_star): int;
+ <*EXTERNAL fbsd_putc*> PROCEDURE putc (c: int; f: FILE_star): int;
+ <*EXTERNAL fbsd_fflush*> PROCEDURE fflush (f: FILE_star): int;
+ <*EXTERNAL fbsd_fdopen*> PROCEDURE fdopen (fd: int; mode: char_star): FILE_star;
+ <*EXTERNAL fbsd_fclose*> PROCEDURE fclose (f: FILE_star): int;
+
+ END Cstdio.
Index: m3/pm3/libs/m3core/src/C/FreeBSD3/Cstdio.m3
diff -c /dev/null m3/pm3/libs/m3core/src/C/FreeBSD3/Cstdio.m3:1.1
*** /dev/null Mon Jun 7 17:09:05 1999
--- m3/pm3/libs/m3core/src/C/FreeBSD3/Cstdio.m3 Mon Jun 7 13:13:45 1999
***************
*** 0 ****
--- 1,17 ----
+ (* Copyright (C) 1992, Digital Equipment Corporation *)
+ (* All rights reserved. *)
+ (* See the file COPYRIGHT for a full description. *)
+ (* *)
+ (* Last modified on Mon Oct 17 09:17:55 PDT 1994 by kalsow *)
+ (* Olaf Wagner 16.09.1994 *)
+
+ UNSAFE MODULE Cstdio;
+
+ BEGIN
+ iF[0] := ADR(sF[0]);
+ iF[1] := ADR(sF[1]);
+ iF[2] := ADR(sF[2]);
+ FOR i := NSTDBUF TO NIOBRW-1 DO
+ iF[i] := NIL;
+ END;
+ END Cstdio.
Index: m3/pm3/libs/m3core/src/C/FreeBSD3/CstdioC.c
diff -c /dev/null m3/pm3/libs/m3core/src/C/FreeBSD3/CstdioC.c:1.1
*** /dev/null Mon Jun 7 17:09:05 1999
--- m3/pm3/libs/m3core/src/C/FreeBSD3/CstdioC.c Mon Jun 7 13:13:45 1999
***************
*** 0 ****
--- 1,42 ----
+ /* Copyright (C) 1994, Digital Equipment Corporation */
+ /* All rights reserved. */
+ /* See the file COPYRIGHT for a full description. */
+ /* */
+ /* Last modified on Mon Oct 17 09:17:31 PDT 1994 by kalsow */
+ /* Olaf Wagner 16.09.1994 */
+
+ #include
+
+ int fbsd_feof(FILE *f){
+ return feof(f);
+ };
+
+ int fbsd_getc(FILE *f){
+ return fgetc(f);
+ };
+
+ int fbsd_ungetc(int c, FILE *f){
+ return ungetc(c, f);
+ };
+
+ int fbsd_putc(int c, FILE *f){
+ return fputc(c, f);
+ };
+
+ int fbsd_fflush(FILE *f){
+ return fflush(f);
+ };
+
+ FILE* fbsd_fdopen(int fildes, char *mode){
+ FILE* f;
+ f = fdopen(fildes, mode);
+ if (f == NULL){
+ fprintf(stderr, "fd: %d, mode: %s\n", fildes, mode);
+ perror("fdopen failed ");
+ }
+ return f;
+ }
+
+ int fbsd_fclose(FILE *f){
+ return fclose(f);
+ };
Index: m3/pm3/libs/m3core/src/C/FreeBSD3/Cstring.i3
diff -c /dev/null m3/pm3/libs/m3core/src/C/FreeBSD3/Cstring.i3:1.1
*** /dev/null Mon Jun 7 17:09:05 1999
--- m3/pm3/libs/m3core/src/C/FreeBSD3/Cstring.i3 Mon Jun 7 13:13:45 1999
***************
*** 0 ****
--- 1,89 ----
+ (* Copyright (C) 1989, Digital Equipment Corporation *)
+ (* All rights reserved. *)
+ (* See the file COPYRIGHT for a full description. *)
+ (* *)
+ (* File: Cstring.i3 *)
+ (* Last modified on Mon Oct 17 09:19:10 PDT 1994 by kalsow *)
+ (* modified on Tue Apr 20 20:16:18 PDT 1993 by muller *)
+ (* modified on Sat Jan 20 22:31:44 1990 by jerome *)
+ (* Olaf Wagner 16.09.1994 *)
+
+
+ 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.
+
Index: m3/pm3/libs/m3core/src/C/FreeBSD3/m3makefile
diff -c /dev/null m3/pm3/libs/m3core/src/C/FreeBSD3/m3makefile:1.1
*** /dev/null Mon Jun 7 17:09:05 1999
--- m3/pm3/libs/m3core/src/C/FreeBSD3/m3makefile Mon Jun 7 13:13:46 1999
***************
*** 0 ****
--- 1,17 ----
+ % Copyright (C) 1994, Digital Equipment Corporation
+ % All rights reserved.
+ % See the file COPYRIGHT for a full description.
+ %
+ % Last modified on Mon Oct 17 09:20:03 PDT 1994 by kalsow
+ % modified on Fri Jun 18 13:20:32 PDT 1993 by harrison
+ % modified on Thu May 6 13:16:32 PDT 1993 by muller
+ % Olaf Wagner 16.09.1994
+
+ Interface ("Csetjmp")
+ Interface ("Csignal")
+ Interface ("Cstring")
+ Module ("Cstdio")
+
+ c_source ("CstdioC")
+
+
Index: m3/pm3/libs/m3core/src/Csupport/FBSD_ALPHA/COPYRIGHT
diff -c /dev/null m3/pm3/libs/m3core/src/Csupport/FBSD_ALPHA/COPYRIGHT:1.1
*** /dev/null Mon Jun 7 17:09:06 1999
--- m3/pm3/libs/m3core/src/Csupport/FBSD_ALPHA/COPYRIGHT Mon Jun 7 13:13:52 1999
***************
*** 0 ****
--- 1,93 ----
+
+ Digital License Agreement
+
+ SRC Modula-3
+
+ 1. Grant Of License. Digital Equipment Corporation, having a principal
+ office at 146 Main Street, Maynard, MA 01754 ("DIGITAL") grants to
+ you ("LICENSEE") the non-exclusive, non-transferable, royalty free
+ right to use, modify, reproduce and distribute SRC Modula-3 ("SOFTWARE")
+ subject to the terms set forth herein. Any distribution of SOFTWARE
+ shall include this Digital License Agreement in human readable form.
+
+ 2. Title to Intellectual Property and Software. Subject to the limited
+ rights and licenses granted under this License Agreement, all rights,
+ title and interests including patent, copyright, and trademark rights
+ in SOFTWARE are and shall remain vested in DIGITAL to the exclusion
+ of LICENSEE. DIGITAL represents and warrants that DIGITAL has the
+ legal right to grant such licenses as are expressly granted under
+ this Agreement.
+
+ 3. Copyright. The SOFTWARE is owned by DIGITAL or its suppliers and is
+ protected by United States copyright laws and international treaty
+ provisions. Therefore, you must treat the SOFTWARE like any other
+ copyrighted material (e.g., a book or musical recording) except
+ that you may use the SOFTWARE as provided in this Digital License
+ Agreement.
+
+ 4. Improvements. LICENSEE hereby grants to DIGITAL a non-exclusive,
+ non-transferable, royalty free right to use, modify, reproduce
+ and distribute with the right to sublicense at any tier, any
+ improvements, enhancements, extensions, or modifications that
+ LICENSEE make to SOFTWARE, provided such are returned to DIGITAL
+ by LICENSEE.
+
+ 5. DISCLAIMER OF WARRANTY. Because the SOFTWARE is a research work and
+ not a released product, it is provided "AS IS" WITHOUT WARRANTY OF ANY
+ KIND AND WITHOUT ANY SUPPORT SERVICES. EXCEPT AS SPECIFICALLY PROVIDED
+ ABOVE IN SECTION 2, DIGITAL FURTHER DISCLAIMS ALL OTHER EXPRESS OR
+ IMPLIED WARRANTIES OF MERCHANTABILITY OR OF FITNESS FOR A PARTICULAR
+ PURPOSE. THE ENTIRE RISK ARISING OUT OF THE USE OR PERFORMANCE OF
+ THE SOFTWARE REMAINS WITH YOU.
+
+ 6. Limitation of Liability. IN NO EVENT SHALL DIGITAL OR ITS SUPPLIERS BE
+ LIABLE IN AN AMOUNT THAT EXCEEDS THE LICENSE FEE PAID BY LICENSEE FOR
+ ANY DAMAGES (INCLUDING, WITH LIMITATION, DAMAGES FOR LOSS OF BUSINESS
+ PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER
+ PECUNIARY LOSS), REGARDLESS OF THE FORM OF CLAIM OR ACTIONS, ARISING
+ OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE OR DOCUMENTATION,
+ EVEN IF DIGITAL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ BECAUSE SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY
+ FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT
+ APPLY TO YOU.
+
+ 7. Acknowledgement of Allocation of Risk. LICENSEE acknowledges and agrees
+ that the fees charged by DIGITAL in this Agreement reflect the allocation
+ of risks provided by the foregoing limitation of liability. LICENSEE
+ acknowledges and represents that it has read and understands these
+ allocations of risk limiting the liability of DIGITAL and that it
+ understands that a modification of the allocation of risks set forth
+ in this agreement would affect the fees charged by DIGITAL, and that
+ LICENSEE, in consideration of such fees, agrees to such allocations
+ of risk.
+
+ 8. LICENSEE INDEMNIFICATION. LICENSEE SHALL INDEMNIFY DIGITAL AGAINST
+ ALL COSTS AND DAMAGE JUDGEMENTS, INCLUDING ATTORNEY'S FEES AND COSTS
+ OF DEFENSE, INCURRED BECAUSE OF CLAIMS OF DAMAGE ARISING FROM LICENSEE'S
+ POSSESSION OR USE OR INABILITY TO USE SOFTWARE.
+
+ 9. GOVERNMENT RESTRICTED RIGHTS. The SOFTWARE and documentation are provided
+ with RESTRICTED RIGHTS. Use duplication, or disclosure by the Government
+ is subject restrictions as set forth in subparagraph (c)(1)(ii) of The
+ Rights in Technical Data and Computer Software clause in DFARS
+ 252.227-7013, or subparagraphs (c)(i) and (2) of the Commercial Computer
+ Software -- Restricted Rights at 48 CFR 52.227-19, as applicable.
+ Manufacturer is Digital Equipment Corporation, 130 Lytton Avenue,
+ Palo Alto, CA 94301-1044.
+
+ 10. Severability. If any provision of the Agreement is held illegal or
+ unenforceable by any court of competent jurisdiction, such provision
+ shall be deemed separable from the remaining provisions of this Agreement
+ and shall not affect or impair the validity or enforceability of the
+ remaining provisions of this Agreement.
+
+ 11. Governing Law. This Agreement is governed by the laws of the
+ Commonwealth of Massachusetts.
+
+ 12. Publicity. You my not use the name of DIGITAL in any advertisement,
+ press release or other publicity with reference to SRC Modula-3
+ without prior written consent of DIGITAL.
+
+ 13. Should you have any questions concerning this Agreement, or if you
+ desire to contact Digital for any reason, please do so via E-mail:
+ M3-REQUEST@SRC.DEC.COM.
Index: m3/pm3/libs/m3core/src/Csupport/FBSD_ALPHA/dtoa.c
diff -c /dev/null m3/pm3/libs/m3core/src/Csupport/FBSD_ALPHA/dtoa.c:1.1
*** /dev/null Mon Jun 7 17:09:06 1999
--- m3/pm3/libs/m3core/src/Csupport/FBSD_ALPHA/dtoa.c Mon Jun 7 13:13:52 1999
***************
*** 0 ****
--- 1,28 ----
+ /* Copyright (C) 1992, Digital Equipment Corporation */
+ /* All rights reserved. */
+ /* See the file COPYRIGHT for a full description. */
+
+ /* Last modified on Fri Aug 13 09:02:20 PDT 1993 by kalsow */
+ /* modified on Tue Feb 11 14:23:53 PST 1992 by muller */
+
+ #ifndef IEEE_8087
+ #define IEEE_8087
+ #endif
+
+ #define Int_32 int
+
+
+ #include "dtoa.h"
+
+ /* Apparently libc defines both "__dtoa" and "dtoa". ??? */
+
+ char * __dtoa
+ #ifdef KR_headers
+ (d, mode, ndigits, decpt, sign, rve)
+ double d; int mode, ndigits, *decpt, *sign; char **rve;
+ #else
+ (double d, int mode, int ndigits, int *decpt, int *sign, char **rve)
+ #endif
+ {
+ return dtoa(d, mode, ndigits, decpt, sign, rve);
+ }
Index: m3/pm3/libs/m3core/src/Csupport/FBSD_ALPHA/m3makefile
diff -c /dev/null m3/pm3/libs/m3core/src/Csupport/FBSD_ALPHA/m3makefile:1.1
*** /dev/null Mon Jun 7 17:09:06 1999
--- m3/pm3/libs/m3core/src/Csupport/FBSD_ALPHA/m3makefile Mon Jun 7 13:13:52 1999
***************
*** 0 ****
--- 1,10 ----
+ % Copyright (C) 1992, Digital Equipment Corporation
+ % All rights reserved.
+ % See the file COPYRIGHT for a full description.
+ %
+ % Last modified on Mon Oct 17 09:28:11 PDT 1994 by kalsow
+ % modified on Fri Jun 18 13:18:18 PDT 1993 by harrison
+ % modified on Thu Feb 4 15:58:38 PST 1993 by mjordan
+ % modified on Mon Oct 12 13:51:24 PDT 1992 by muller
+
+ c_source ("dtoa")
Index: m3/pm3/libs/m3core/src/Csupport/FreeBSD3/COPYRIGHT
diff -c /dev/null m3/pm3/libs/m3core/src/Csupport/FreeBSD3/COPYRIGHT:1.1
*** /dev/null Mon Jun 7 17:09:06 1999
--- m3/pm3/libs/m3core/src/Csupport/FreeBSD3/COPYRIGHT Mon Jun 7 13:13:56 1999
***************
*** 0 ****
--- 1,93 ----
+
+ Digital License Agreement
+
+ SRC Modula-3
+
+ 1. Grant Of License. Digital Equipment Corporation, having a principal
+ office at 146 Main Street, Maynard, MA 01754 ("DIGITAL") grants to
+ you ("LICENSEE") the non-exclusive, non-transferable, royalty free
+ right to use, modify, reproduce and distribute SRC Modula-3 ("SOFTWARE")
+ subject to the terms set forth herein. Any distribution of SOFTWARE
+ shall include this Digital License Agreement in human readable form.
+
+ 2. Title to Intellectual Property and Software. Subject to the limited
+ rights and licenses granted under this License Agreement, all rights,
+ title and interests including patent, copyright, and trademark rights
+ in SOFTWARE are and shall remain vested in DIGITAL to the exclusion
+ of LICENSEE. DIGITAL represents and warrants that DIGITAL has the
+ legal right to grant such licenses as are expressly granted under
+ this Agreement.
+
+ 3. Copyright. The SOFTWARE is owned by DIGITAL or its suppliers and is
+ protected by United States copyright laws and international treaty
+ provisions. Therefore, you must treat the SOFTWARE like any other
+ copyrighted material (e.g., a book or musical recording) except
+ that you may use the SOFTWARE as provided in this Digital License
+ Agreement.
+
+ 4. Improvements. LICENSEE hereby grants to DIGITAL a non-exclusive,
+ non-transferable, royalty free right to use, modify, reproduce
+ and distribute with the right to sublicense at any tier, any
+ improvements, enhancements, extensions, or modifications that
+ LICENSEE make to SOFTWARE, provided such are returned to DIGITAL
+ by LICENSEE.
+
+ 5. DISCLAIMER OF WARRANTY. Because the SOFTWARE is a research work and
+ not a released product, it is provided "AS IS" WITHOUT WARRANTY OF ANY
+ KIND AND WITHOUT ANY SUPPORT SERVICES. EXCEPT AS SPECIFICALLY PROVIDED
+ ABOVE IN SECTION 2, DIGITAL FURTHER DISCLAIMS ALL OTHER EXPRESS OR
+ IMPLIED WARRANTIES OF MERCHANTABILITY OR OF FITNESS FOR A PARTICULAR
+ PURPOSE. THE ENTIRE RISK ARISING OUT OF THE USE OR PERFORMANCE OF
+ THE SOFTWARE REMAINS WITH YOU.
+
+ 6. Limitation of Liability. IN NO EVENT SHALL DIGITAL OR ITS SUPPLIERS BE
+ LIABLE IN AN AMOUNT THAT EXCEEDS THE LICENSE FEE PAID BY LICENSEE FOR
+ ANY DAMAGES (INCLUDING, WITH LIMITATION, DAMAGES FOR LOSS OF BUSINESS
+ PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER
+ PECUNIARY LOSS), REGARDLESS OF THE FORM OF CLAIM OR ACTIONS, ARISING
+ OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE OR DOCUMENTATION,
+ EVEN IF DIGITAL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ BECAUSE SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY
+ FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT
+ APPLY TO YOU.
+
+ 7. Acknowledgement of Allocation of Risk. LICENSEE acknowledges and agrees
+ that the fees charged by DIGITAL in this Agreement reflect the allocation
+ of risks provided by the foregoing limitation of liability. LICENSEE
+ acknowledges and represents that it has read and understands these
+ allocations of risk limiting the liability of DIGITAL and that it
+ understands that a modification of the allocation of risks set forth
+ in this agreement would affect the fees charged by DIGITAL, and that
+ LICENSEE, in consideration of such fees, agrees to such allocations
+ of risk.
+
+ 8. LICENSEE INDEMNIFICATION. LICENSEE SHALL INDEMNIFY DIGITAL AGAINST
+ ALL COSTS AND DAMAGE JUDGEMENTS, INCLUDING ATTORNEY'S FEES AND COSTS
+ OF DEFENSE, INCURRED BECAUSE OF CLAIMS OF DAMAGE ARISING FROM LICENSEE'S
+ POSSESSION OR USE OR INABILITY TO USE SOFTWARE.
+
+ 9. GOVERNMENT RESTRICTED RIGHTS. The SOFTWARE and documentation are provided
+ with RESTRICTED RIGHTS. Use duplication, or disclosure by the Government
+ is subject restrictions as set forth in subparagraph (c)(1)(ii) of The
+ Rights in Technical Data and Computer Software clause in DFARS
+ 252.227-7013, or subparagraphs (c)(i) and (2) of the Commercial Computer
+ Software -- Restricted Rights at 48 CFR 52.227-19, as applicable.
+ Manufacturer is Digital Equipment Corporation, 130 Lytton Avenue,
+ Palo Alto, CA 94301-1044.
+
+ 10. Severability. If any provision of the Agreement is held illegal or
+ unenforceable by any court of competent jurisdiction, such provision
+ shall be deemed separable from the remaining provisions of this Agreement
+ and shall not affect or impair the validity or enforceability of the
+ remaining provisions of this Agreement.
+
+ 11. Governing Law. This Agreement is governed by the laws of the
+ Commonwealth of Massachusetts.
+
+ 12. Publicity. You my not use the name of DIGITAL in any advertisement,
+ press release or other publicity with reference to SRC Modula-3
+ without prior written consent of DIGITAL.
+
+ 13. Should you have any questions concerning this Agreement, or if you
+ desire to contact Digital for any reason, please do so via E-mail:
+ M3-REQUEST@SRC.DEC.COM.
Index: m3/pm3/libs/m3core/src/Csupport/FreeBSD3/dtoa.c
diff -c /dev/null m3/pm3/libs/m3core/src/Csupport/FreeBSD3/dtoa.c:1.1
*** /dev/null Mon Jun 7 17:09:06 1999
--- m3/pm3/libs/m3core/src/Csupport/FreeBSD3/dtoa.c Mon Jun 7 13:13:56 1999
***************
*** 0 ****
--- 1,29 ----
+ /* Copyright (C) 1992, Digital Equipment Corporation */
+ /* All rights reserved. */
+ /* See the file COPYRIGHT for a full description. */
+
+ /* Last modified on Wed Apr 5 08:44:12 PDT 1995 by kalsow */
+ /* modified on Mon Oct 12 13:50:54 PDT 1992 by muller */
+
+ #ifndef KR_headers
+ #define KR_headers
+ #endif
+
+ #ifndef IEEE_8087
+ #define IEEE_8087
+ #endif
+
+ #include "dtoa.h"
+
+ /* Apparently libc defines both "__dtoa" and "dtoa". ??? */
+
+ char * __dtoa
+ #ifdef KR_headers
+ (d, mode, ndigits, decpt, sign, rve)
+ double d; int mode, ndigits, *decpt, *sign; char **rve;
+ #else
+ (double d, int mode, int ndigits, int *decpt, int *sign, char **rve)
+ #endif
+ {
+ return dtoa(d, mode, ndigits, decpt, sign, rve);
+ }
Index: m3/pm3/libs/m3core/src/Csupport/FreeBSD3/m3makefile
diff -c /dev/null m3/pm3/libs/m3core/src/Csupport/FreeBSD3/m3makefile:1.1
*** /dev/null Mon Jun 7 17:09:06 1999
--- m3/pm3/libs/m3core/src/Csupport/FreeBSD3/m3makefile Mon Jun 7 13:13:56 1999
***************
*** 0 ****
--- 1,10 ----
+ % Copyright (C) 1992, Digital Equipment Corporation
+ % All rights reserved.
+ % See the file COPYRIGHT for a full description.
+ %
+ % Last modified on Mon Oct 17 09:28:11 PDT 1994 by kalsow
+ % modified on Fri Jun 18 13:18:18 PDT 1993 by harrison
+ % modified on Thu Feb 4 15:58:38 PST 1993 by mjordan
+ % modified on Mon Oct 12 13:51:24 PDT 1992 by muller
+
+ c_source ("dtoa")
Index: m3/pm3/libs/m3core/src/float/m3makefile
diff -c m3/pm3/libs/m3core/src/float/m3makefile:1.3 m3/pm3/libs/m3core/src/float/m3makefile:1.4
*** m3/pm3/libs/m3core/src/float/m3makefile:1.3 Tue Apr 28 16:26:54 1998
--- m3/pm3/libs/m3core/src/float/m3makefile Mon Jun 7 13:14:04 1999
***************
*** 17,24 ****
--- 17,26 ----
"ARM" : _float_le,
"DS3100" : [ "IEEE", "IEEE-le", "DS3100" ],
"DS3100_OSF" : [ "IEEE", "IEEE-le", "DS3100" ],
+ "FBSD_ALPHA" : _float_le,
"FreeBSD" : _float_le,
"FreeBSD2" : _float_le,
+ "FreeBSD3" : _float_le,
"HP300" : _float_be,
"HPPA" : _float_be,
"IBMR2" : _float_be,
Index: m3/pm3/libs/m3core/src/runtime/m3makefile
diff -c m3/pm3/libs/m3core/src/runtime/m3makefile:1.5 m3/pm3/libs/m3core/src/runtime/m3makefile:1.6
*** m3/pm3/libs/m3core/src/runtime/m3makefile:1.5 Tue Apr 28 16:26:58 1998
--- m3/pm3/libs/m3core/src/runtime/m3makefile Mon Jun 7 13:14:14 1999
***************
*** 11,18 ****
--- 11,20 ----
"AP3000" : "ex_frame",
"ARM" : "ex_frame",
"DS3100" : "ex_stack", % has a working stack walker
+ "FBSD_ALPHA" : "ex_frame",
"FreeBSD" : "ex_frame",
"FreeBSD2" : "ex_frame",
+ "FreeBSD3" : "ex_frame",
"HP300" : "ex_frame",
"HPPA" : "ex_frame",
"IBMR2" : "ex_frame",
Index: m3/pm3/libs/m3core/src/runtime/ALPHA_OSF/RTHeapDepC.c
diff -c m3/pm3/libs/m3core/src/runtime/ALPHA_OSF/RTHeapDepC.c:1.4 m3/pm3/libs/m3core/src/runtime/ALPHA_OSF/RTHeapDepC.c:1.5
*** m3/pm3/libs/m3core/src/runtime/ALPHA_OSF/RTHeapDepC.c:1.4 Fri Sep 26 08:35:35 1997
--- m3/pm3/libs/m3core/src/runtime/ALPHA_OSF/RTHeapDepC.c Mon Jun 7 13:14:19 1999
***************
*** 145,151 ****
#include
#include /* for quotactl(2) */
! extern int RT0u__inCritical;
#define ENTER_CRITICAL RT0u__inCritical++
#define EXIT_CRITICAL RT0u__inCritical--
--- 145,151 ----
#include
#include /* for quotactl(2) */
! extern long RT0u__inCritical;
#define ENTER_CRITICAL RT0u__inCritical++
#define EXIT_CRITICAL RT0u__inCritical--
Index: m3/pm3/libs/m3core/src/runtime/ALPHA_OSF/RTThreadC.c
diff -c m3/pm3/libs/m3core/src/runtime/ALPHA_OSF/RTThreadC.c:1.1.1.1 m3/pm3/libs/m3core/src/runtime/ALPHA_OSF/RTThreadC.c:1.2
*** m3/pm3/libs/m3core/src/runtime/ALPHA_OSF/RTThreadC.c:1.1.1.1 Thu Jan 16 16:29:55 1997
--- m3/pm3/libs/m3core/src/runtime/ALPHA_OSF/RTThreadC.c Mon Jun 7 13:14:20 1999
***************
*** 19,25 ****
int ThreadF__myId = 1;
/* low-level runtime lock */
! int RT0u__inCritical = 0;
/* global, per-thread linked list of exception handlers */
void* RTThread__handlerStack = 0;
--- 19,25 ----
int ThreadF__myId = 1;
/* low-level runtime lock */
! long RT0u__inCritical = 0;
/* global, per-thread linked list of exception handlers */
void* RTThread__handlerStack = 0;
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/COPYRIGHT
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/COPYRIGHT:1.1
*** /dev/null Mon Jun 7 17:09:10 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/COPYRIGHT Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,93 ----
+
+ Digital License Agreement
+
+ SRC Modula-3
+
+ 1. Grant Of License. Digital Equipment Corporation, having a principal
+ office at 146 Main Street, Maynard, MA 01754 ("DIGITAL") grants to
+ you ("LICENSEE") the non-exclusive, non-transferable, royalty free
+ right to use, modify, reproduce and distribute SRC Modula-3 ("SOFTWARE")
+ subject to the terms set forth herein. Any distribution of SOFTWARE
+ shall include this Digital License Agreement in human readable form.
+
+ 2. Title to Intellectual Property and Software. Subject to the limited
+ rights and licenses granted under this License Agreement, all rights,
+ title and interests including patent, copyright, and trademark rights
+ in SOFTWARE are and shall remain vested in DIGITAL to the exclusion
+ of LICENSEE. DIGITAL represents and warrants that DIGITAL has the
+ legal right to grant such licenses as are expressly granted under
+ this Agreement.
+
+ 3. Copyright. The SOFTWARE is owned by DIGITAL or its suppliers and is
+ protected by United States copyright laws and international treaty
+ provisions. Therefore, you must treat the SOFTWARE like any other
+ copyrighted material (e.g., a book or musical recording) except
+ that you may use the SOFTWARE as provided in this Digital License
+ Agreement.
+
+ 4. Improvements. LICENSEE hereby grants to DIGITAL a non-exclusive,
+ non-transferable, royalty free right to use, modify, reproduce
+ and distribute with the right to sublicense at any tier, any
+ improvements, enhancements, extensions, or modifications that
+ LICENSEE make to SOFTWARE, provided such are returned to DIGITAL
+ by LICENSEE.
+
+ 5. DISCLAIMER OF WARRANTY. Because the SOFTWARE is a research work and
+ not a released product, it is provided "AS IS" WITHOUT WARRANTY OF ANY
+ KIND AND WITHOUT ANY SUPPORT SERVICES. EXCEPT AS SPECIFICALLY PROVIDED
+ ABOVE IN SECTION 2, DIGITAL FURTHER DISCLAIMS ALL OTHER EXPRESS OR
+ IMPLIED WARRANTIES OF MERCHANTABILITY OR OF FITNESS FOR A PARTICULAR
+ PURPOSE. THE ENTIRE RISK ARISING OUT OF THE USE OR PERFORMANCE OF
+ THE SOFTWARE REMAINS WITH YOU.
+
+ 6. Limitation of Liability. IN NO EVENT SHALL DIGITAL OR ITS SUPPLIERS BE
+ LIABLE IN AN AMOUNT THAT EXCEEDS THE LICENSE FEE PAID BY LICENSEE FOR
+ ANY DAMAGES (INCLUDING, WITH LIMITATION, DAMAGES FOR LOSS OF BUSINESS
+ PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER
+ PECUNIARY LOSS), REGARDLESS OF THE FORM OF CLAIM OR ACTIONS, ARISING
+ OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE OR DOCUMENTATION,
+ EVEN IF DIGITAL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ BECAUSE SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY
+ FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT
+ APPLY TO YOU.
+
+ 7. Acknowledgement of Allocation of Risk. LICENSEE acknowledges and agrees
+ that the fees charged by DIGITAL in this Agreement reflect the allocation
+ of risks provided by the foregoing limitation of liability. LICENSEE
+ acknowledges and represents that it has read and understands these
+ allocations of risk limiting the liability of DIGITAL and that it
+ understands that a modification of the allocation of risks set forth
+ in this agreement would affect the fees charged by DIGITAL, and that
+ LICENSEE, in consideration of such fees, agrees to such allocations
+ of risk.
+
+ 8. LICENSEE INDEMNIFICATION. LICENSEE SHALL INDEMNIFY DIGITAL AGAINST
+ ALL COSTS AND DAMAGE JUDGEMENTS, INCLUDING ATTORNEY'S FEES AND COSTS
+ OF DEFENSE, INCURRED BECAUSE OF CLAIMS OF DAMAGE ARISING FROM LICENSEE'S
+ POSSESSION OR USE OR INABILITY TO USE SOFTWARE.
+
+ 9. GOVERNMENT RESTRICTED RIGHTS. The SOFTWARE and documentation are provided
+ with RESTRICTED RIGHTS. Use duplication, or disclosure by the Government
+ is subject restrictions as set forth in subparagraph (c)(1)(ii) of The
+ Rights in Technical Data and Computer Software clause in DFARS
+ 252.227-7013, or subparagraphs (c)(i) and (2) of the Commercial Computer
+ Software -- Restricted Rights at 48 CFR 52.227-19, as applicable.
+ Manufacturer is Digital Equipment Corporation, 130 Lytton Avenue,
+ Palo Alto, CA 94301-1044.
+
+ 10. Severability. If any provision of the Agreement is held illegal or
+ unenforceable by any court of competent jurisdiction, such provision
+ shall be deemed separable from the remaining provisions of this Agreement
+ and shall not affect or impair the validity or enforceability of the
+ remaining provisions of this Agreement.
+
+ 11. Governing Law. This Agreement is governed by the laws of the
+ Commonwealth of Massachusetts.
+
+ 12. Publicity. You my not use the name of DIGITAL in any advertisement,
+ press release or other publicity with reference to SRC Modula-3
+ without prior written consent of DIGITAL.
+
+ 13. Should you have any questions concerning this Agreement, or if you
+ desire to contact Digital for any reason, please do so via E-mail:
+ M3-REQUEST@SRC.DEC.COM.
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/RTHeapDep.m3
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/RTHeapDep.m3:1.1
*** /dev/null Mon Jun 7 17:09:10 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/RTHeapDep.m3 Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,172 ----
+ (* Copyright (C) 1994, Digital Equipment Corporation *)
+ (* All rights reserved. *)
+ (* See the file COPYRIGHT for a full description. *)
+ (* *)
+ (*| Last modified on Fri Jan 20 09:41:09 PST 1995 by kalsow *)
+ (*| modified on Mon Oct 31 00:04:38 MET 1994 by Olaf Wagner *)
+ (*| 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;
+ defaultSIGSEGV: Usignal.SignalHandler := NIL; (* previous handler *)
+ defaultSIGBUS: 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 = n * BytesPerPage *>
+ *)
+ <* 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
+ vec := Usignal.struct_sigvec{
+ sv_handler := Fault, sv_mask :=
+ Word.LeftShift(1, Usignal.SIGVTALRM - 1), sv_flags := 0};
+ ovec: Usignal.struct_sigvec;
+ ret := Usignal.sigvec(Usignal.SIGSEGV, vec, ovec);
+ vecb := Usignal.struct_sigvec{
+ sv_handler := Fault, sv_mask :=
+ Word.LeftShift(1, Usignal.SIGVTALRM - 1), sv_flags := 0};
+ ovecb: Usignal.struct_sigvec;
+ retb := Usignal.sigvec(Usignal.SIGBUS, vecb, ovecb);
+ BEGIN
+ <* ASSERT ret = 0 *>
+ <* ASSERT retb = 0 *>
+ defaultSIGSEGV := ovec.sv_handler;
+ defaultSIGBUS := ovecb.sv_handler;
+ END;
+
+ (* establish signal handler for all other signals that dump core, if no
+ handler exists *)
+ PROCEDURE OverrideDefault (sig: Ctypes.int) =
+ VAR
+ vec := Usignal.struct_sigvec{
+ sv_handler := Core, sv_mask :=
+ Word.LeftShift(1, Usignal.SIGVTALRM - 1), sv_flags := 0};
+ ovec: Usignal.struct_sigvec;
+ ret := Usignal.sigvec(sig, vec, ovec);
+ BEGIN
+ <* ASSERT ret = 0 *>
+ IF ovec.sv_handler # Usignal.SIG_DFL THEN
+ ret := Usignal.sigvec(sig, ovec, 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.SIGSYS);
+ END;
+ END Init;
+
+ (* Fault is called upon a SIGSEGV or SIGBUS 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;
+ code: Ctypes.int;
+ scp : UNTRACED REF Usignal.struct_sigcontext) =
+ VAR
+ sf_addr := LOOPHOLE(scp.sc_traparg_a0, ADDRESS);
+
+ BEGIN
+ IF RTHeapRep.Fault(sf_addr) THEN
+ RETURN;
+ END;
+ IF defaultSIGSEGV = Usignal.SIG_IGN THEN RETURN; END;
+ IF defaultSIGSEGV = Usignal.SIG_DFL THEN
+ Core(sig, code, scp);
+ ELSE
+ defaultSIGSEGV(sig, code, scp);
+ 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 *> code: Ctypes.int;
+ <* UNUSED *> scp : UNTRACED REF Usignal.struct_sigcontext) =
+ VAR
+ ovec: Usignal.struct_sigvec;
+ vec := Usignal.struct_sigvec{sv_handler := Usignal.SIG_DFL,
+ sv_mask := 0, sv_flags := 0};
+ BEGIN
+ INC(RT0u.inCritical);
+ IF NOT dumped_core THEN
+ dumped_core := TRUE;
+ EVAL RTHeapRep.Crash(); (* clean up the heap *)
+ EVAL Usignal.sigvec(sig, vec, 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.
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/RTHeapDepC.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/RTHeapDepC.c:1.1
*** /dev/null Mon Jun 7 17:09:10 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/RTHeapDepC.c Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,1391 ----
+ /* Copyright (C) 1992, Digital Equipment Corporation */
+ /* All rights reserved. */
+ /* See the file COPYRIGHT for a full description. */
+
+ /* modified on Tue Feb 2 11:15:57 PST 1993 by jdd */
+
+ /* This is RTHeapDepC.c for FreeBSD running on 386/486 processors. */
+ /*
+ * ow Sat Oct 29 14:10:19 MET 1994
+ * ow Sun Nov 6 16:39:26 MET 1994
+ * ow Sun Dec 4 17:58:49 1994 changes for FreeBSD 2.0
+ *
+ * I just tried to check the calls implemented for Ultrix,
+ * (almost) nothing else has been changed or added.
+ * So be careful to use any other system calls, some are
+ * probably missing.
+ */
+ /* This file implements wrappers for almost all Ultrix system calls
+ that take pointers as arguments. These wrappers allow the system
+ calls to take arguments that might point to the traced heap, which
+ may be VM-protected in the Ultrix implementation of the collector.
+ The wrappers read and write the referents of all pointers about to
+ passed to the system call, which ensures that the pages are not
+ protected when the call is made.
+
+ Each wrapper is a critical section, with RT0u__inCritical non-zero,
+ so that another thread cannot cause the pages to become reprotected
+ before the system call is performed.
+
+ A few system calls are not handled here, or are handled only
+ partially. This restricts the system calls that can be made from
+ Modula-3, or from libraries that are passed pointers into the
+ Modula-3 traced heap. These system calls are:
+
+ 1) sigvec. Sigvec takes 3 arguments, but passes 4 to the kernel.
+ The extra argument is the address of the sigtramp code, which is
+ copyrighted. The sigtramp code appears in the the standard .o
+ file that also defines sigvec, so that sigvec cannot be
+ redefined here without including sigtramp. Rewriting sigtramp
+ seemed too error-prone, so sigvec is not supported here, meaning
+ that sigvec cannot be called with arguments on the heap.
+
+ 2) syscall. Implementing syscall would require a huge case
+ statement, with one case per system call. This seemed too
+ error-prone, so syscall cannot take arguments that point into
+ the traced heap.
+
+ 3) ioctl. Ioctl's third argument may be a pointer, and some device
+ drivers might interpret the referent as containing more
+ pointers. These second-level pointers are not handled here, so
+ they must not point into the traced heap if they exist.
+ Handling this problem in general is impossible, since the set of
+ device drivers is open-ended.
+
+ 4) profil. The memory referenced by the "buff" argument is updated
+ after the call returns, and there is no mechanism to permanently
+ unprotect it.
+
+ 5) Undocumented system calls. There are private system calls with
+ no manual pages, so it was impossible to write wrappers.
+
+ 6) audgen, whose manpage is incomprehensible.
+
+ (Some calls in Section 2 are already wrappers for other system
+ calls; it is not necessary to reimplement them here.)
+
+ Also, longjmp must not be used from a signal handler to abnormally
+ exit from a system call.
+
+ Finally, if a system call references an object on the heap, each
+ pointer must reference only one object. Therefore, it is not
+ possible to write the heap contents with a single write. */
+
+ #define MFS
+ #define NFS
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #if __FreeBSD__ >= 2
+ #include
+ #include
+ #endif
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+
+ #if __FreeBSD__ >= 3
+ #include
+ #include
+ #include
+ #include
+ #include
+ #endif
+
+ #include
+ #include
+
+ #ifdef NULL
+ #undef NULL
+ #endif
+ #define NULL (void *)(0)
+ extern long RT0u__inCritical;
+ #define ENTER_CRITICAL RT0u__inCritical++
+ #define EXIT_CRITICAL RT0u__inCritical--
+
+ void (*RTHeapRep_Fault)(char*);
+ void (*RTCSRC_FinishVM)();
+
+ static char RTHeapDepC__c;
+ #define MAKE_READABLE(x) if (x != 0) { RTHeapDepC__c = *(char*)(x); }
+ #define MAKE_WRITABLE(x) if (x != 0) { *(char*)(x) = RTHeapDepC__c = *(char*)(x); }
+
+ /*
+ * Modula-3 compilation units are always compiled PIC. This causes
+ * the a.out linker to complain that there is no reference to
+ * _DYNAMIC if the program is linked with "-static". Provide a
+ * weak reference to it here so that static linking will work.
+ *
+ * This has nothing to do with the heap, so it doesn't really belong
+ * here. But it needs to be someplace that is guaranteed to be pulled
+ * into every executable.
+ */
+ #pragma weak _DYNAMIC
+ extern int _DYNAMIC;
+ static int *i __unused = &_DYNAMIC;
+
+ /* Unless otherwise noted, all the following wrappers have the same
+ structure. */
+
+ int access(path, mode) /* ok */
+ const char *path;
+ int mode;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_access, path, mode);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int acct(file) /* ok */
+ const char *file;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(file);
+ result = syscall(SYS_acct, file);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int adjtime(delta, olddelta) /* ok */
+ #if __FreeBSD__ >= 2
+ const struct timeval *delta;
+ #else
+ struct timeval *delta;
+ #endif
+ struct timeval *olddelta;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(delta);
+ MAKE_WRITABLE(olddelta);
+ result = syscall(SYS_adjtime, delta, olddelta);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ /* not implemented
+ int atomic_op(op, addr)
+ int op;
+ int *addr;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(addr);
+ result = syscall(SYS_atomic_op, op, addr);
+ EXIT_CRITICAL;
+ return result;
+ }
+ */
+
+ /* not implemented
+ int audcntl(request, argp, len, flag, audit_id)
+ int request;
+ char *argp;
+ int len;
+ int flag;
+ audit_ID_t audit_id;
+ { int result;
+
+ ENTER_CRITICAL;
+ switch (request) {
+ case GET_SYS_AMASK:
+ case GET_TRUSTED_AMASK:
+ case GET_PROC_AMASK:
+ MAKE_WRITABLE(argp);
+ break;
+ case SET_SYS_AMASK:
+ case SET_TRUSTED_AMASK:
+ case SET_PROC_AMASK:
+ MAKE_READABLE(argp);
+ break;
+ default:
+ break;
+ }
+ result = syscall(SYS_audcntl, request, argp, len, flag, audit_id);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int audgen(event, tokenp, argv)
+ int event;
+ char *tokenp, *argv[];
+ { int result;
+
+ ENTER_CRITICAL;
+
+ { char *t, **a;
+
+ for (t = tokenp, a = argv; t; t++, a++) {
+ if (A_TOKEN_PTR(*t)) {
+ MAKE_READABLE(*a);
+ }
+ }
+ }
+ result = syscall(SYS_audgen, tokenp, argv);
+ EXIT_CRITICAL;
+ return result;
+ }
+ */
+
+ /* not implemented
+ int cachectl(addr, nbytes, op)
+ char *addr;
+ int nbytes, op;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(addr);
+ result = syscall(SYS_cachectl, addr, nbytes, op);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int cacheflush(addr, nbytes, cache)
+ char *addr;
+ int nbytes, cache;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(addr);
+ result = syscall(SYS_cacheflush, addr, nbytes, cache);
+ EXIT_CRITICAL;
+ return result;
+ }
+ */
+
+ int chdir(path) /* ok */
+ const char *path;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_chdir, path);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int chflags(path, flags)
+ const char *path;
+ u_long flags;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_chflags, path, flags);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int chmod(path, mode) /* ok */
+ const char *path;
+ mode_t mode;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_chmod, path, mode);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int chown(path, owner, group) /* ok */
+ const char *path;
+ uid_t owner;
+ gid_t group;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_chown, path, owner, group);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int chroot(dirname) /* ok */
+ const char *dirname;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(dirname);
+ result = syscall(SYS_chroot, dirname);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ /* not implemented (obsolete)
+ int creat(name, mode)
+ const char *name;
+ mode_t mode;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(name);
+ result = syscall(SYS_creat, name, mode);
+ EXIT_CRITICAL;
+ return result;
+ }
+ */
+
+ /* execve is implemented differently since it does not return, which
+ would leave RT0u__inCritical set in the parent if called in the child
+ of a vfork. Many calls leave the process in an undefined state in the
+ case of EFAULT, but we assume that execve is not one of these. */
+
+ int execve(name, argv, envp) /* ok */
+ const char *name;
+ char * const argv[];
+ char * const envp[];
+ { int result;
+
+ for (;;) {
+ result = syscall(SYS_execve, name, argv, envp);
+ if (result == -1 && errno == EFAULT) {
+ MAKE_READABLE(name);
+ { char * const *a; for (a = argv; *a; a++) MAKE_READABLE(*a); }
+ { char * const *e; for (e = envp; *e; e++) MAKE_READABLE(*e); }
+ } else {
+ return result;
+ }
+ }
+ }
+
+ /* not implemented
+ int exportfs(name, rootuid, exflags)
+ char *name;
+ int rootuid, exflags;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(name);
+ result = syscall(SYS_exportfs, name, rootuid, exflags);
+ EXIT_CRITICAL;
+ return result;
+ }
+ */
+
+ int ufcntl(int fd, int request, int arg) /* ok */
+ { int result;
+ /* int arg;
+ va_list ap;
+
+ va_start(ap, request);
+ arg = va_arg(ap, int);
+ va_end(ap);
+ */
+
+ ENTER_CRITICAL;
+ switch (request) {
+ case F_GETLK:
+ MAKE_WRITABLE(arg);
+ break;
+ case F_SETLK:
+ case F_SETLKW:
+ MAKE_READABLE(arg);
+ break;
+ default:
+ break;
+ }
+ result = syscall(SYS_fcntl, fd, request, arg);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int fstat(fd, buf) /* ok */
+ int fd;
+ struct stat *buf;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(buf);
+ result = syscall(SYS_fstat, fd, buf);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int getdirentries(fd, buf, nbytes, basep) /* ok */
+ int fd;
+ char *buf;
+ int nbytes;
+ long *basep;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(buf);
+ MAKE_WRITABLE(basep);
+ result = syscall(SYS_getdirentries, fd, buf, nbytes, basep);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int getdomainname(name, namelen) /* ok */
+ char *name;
+ int namelen;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(name);
+ result = syscall(SYS_getdomainname, name, namelen);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int gethostname(name, namelen) /* ok */
+ char *name;
+ int namelen;
+ { int result;
+ #if __FreeBSD__ >= 2
+ int mib[2];
+ size_t size;
+ #endif
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(name);
+ #if __FreeBSD__ >= 2
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_HOSTNAME;
+ size = namelen;
+ if (sysctl(mib, 2, name, &size, NULL, 0) == -1){
+ result = -1;
+ }else{
+ result = 0;
+ }
+ #else
+ result = syscall(SYS_gethostname, name, namelen);
+ #endif
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int getgroups(gidsetsize, grouplist) /* ok */
+ int gidsetsize;
+ gid_t grouplist[];
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(grouplist);
+ result = syscall(SYS_getgroups, gidsetsize, grouplist);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int getitimer(which, value) /* ok */
+ int which;
+ struct itimerval *value;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(value);
+ result = syscall(SYS_getitimer, which, value);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ /* not implemented
+ int getmnt(start, buffer, nbytes, mode, path)
+ int *start;
+ struct fs_data *buffer;
+ int nbytes, mode;
+ char *path;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(start);
+ MAKE_WRITABLE(buffer);
+ MAKE_READABLE(path);
+ result = syscall(SYS_getmnt, start, buffer, nbytes, mode, path);
+ EXIT_CRITICAL;
+ return result;
+ }
+ */
+
+ int getrlimit(resource, rlp) /* ok */
+ int resource;
+ struct rlimit *rlp;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(rlp);
+ result = syscall(SYS_getrlimit, resource, rlp);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int getrusage(who, rusage) /* ok */
+ int who;
+ struct rusage *rusage;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(rusage);
+ result = syscall(SYS_getrusage, who, rusage);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int getsockopt(s, level, optname, optval, optlen) /* ok */
+ int s, level, optname;
+ void *optval;
+ int *optlen;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(optval);
+ MAKE_WRITABLE(optlen);
+ result = syscall(SYS_getsockopt, s, level, optname, optval, optlen);
+ EXIT_CRITICAL;
+ return result;
+ }
+ /* not implemented
+ int getsysinfo(op, buffer, nbytes, start, arg)
+ unsigned op;
+ char *buffer;
+ unsigned nbytes;
+ int *start;
+ char *arg;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(buffer);
+ MAKE_WRITABLE(start);
+ MAKE_WRITABLE(arg);
+ result = syscall(SYS_getsysinfo, op, buffer, nbytes, start, arg);
+ EXIT_CRITICAL;
+ return result;
+ }
+ */
+
+ int gettimeofday(tp, tzp) /* ok */
+ struct timeval *tp;
+ struct timezone *tzp;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(tp);
+ MAKE_WRITABLE(tzp);
+ result = syscall(SYS_gettimeofday, tp, tzp);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ /* ioctl must test the argp argument carefully. It may be a pointer,
+ or maybe not. At a slight expense, we call RTHeapRep.Fault to
+ unprotect the page if it's in the traced heap, but do nothing
+ otherwise. */
+
+ int ioctl(d, request, argp) /* ok */
+ int d;
+ unsigned long request;
+ char *argp;
+ { int result;
+
+ ENTER_CRITICAL;
+ if (RTHeapRep_Fault) RTHeapRep_Fault(argp); /* make it readable */
+ if (RTHeapRep_Fault) RTHeapRep_Fault(argp); /* make it writable */
+ result = syscall(SYS_ioctl, d, request, argp);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ #ifdef SYS_lchown
+ int lchown(path, owner, group) /* ok */
+ const char *path;
+ uid_t owner;
+ gid_t group;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_lchown, path, owner, group);
+ EXIT_CRITICAL;
+ return result;
+ }
+ #endif /* SYS_lchown */
+
+ int link(name1, name2) /* ok */
+ const char *name1;
+ const char *name2;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(name1);
+ MAKE_READABLE(name2);
+ result = syscall(SYS_link, name1, name2);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int lstat(path, buf) /* ok */
+ const char *path;
+ struct stat *buf;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ MAKE_WRITABLE(buf);
+ result = syscall(SYS_lstat, path, buf);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int mkdir(path, mode) /* ok */
+ const char *path;
+ mode_t mode;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_mkdir, path, mode);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int mkfifo(path, mode) /* ok */
+ const char *path;
+ mode_t mode;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_mkfifo, path, mode);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int mknod(path, mode, dev) /* ok */
+ const char *path;
+ mode_t mode;
+ dev_t dev;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_mknod, path, mode, dev);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ #if __FreeBSD_version >= 300001 /* New form of mount(2) */
+ int
+ mount(type, dir, flags, data)
+ const char *type;
+ const char *dir;
+ int flags;
+ void *data;
+ { int result;
+ struct ufs_args *u_data;
+ struct mfs_args *m_data;
+ struct nfs_args *n_data;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(type);
+ MAKE_READABLE(dir);
+ if (strcmp(type, "ufs") == 0) {
+ u_data = (struct ufs_args*) data;
+ MAKE_READABLE(u_data);
+ MAKE_READABLE(u_data->fspec);
+ result = syscall(SYS_mount, type, dir, flags, data);
+ } else if (strcmp(type, "mfs") == 0) {
+ m_data = (struct mfs_args*) data;
+ MAKE_READABLE(m_data);
+ MAKE_READABLE(m_data->fspec);
+ result = syscall(SYS_mount, type, dir, flags, data);
+ } else if (strcmp(type, "nfs") == 0) {
+ n_data = (struct nfs_args*) data;
+ MAKE_READABLE(n_data);
+ MAKE_READABLE(n_data->addr);
+ MAKE_READABLE(n_data->fh);
+ MAKE_READABLE(n_data->hostname);
+ result = syscall(SYS_mount, type, dir, flags, data);
+ } else { /* Not anything we recognize. */
+ MAKE_READABLE(data);
+ result = syscall(SYS_mount, type, dir, flags, data);
+ }
+ EXIT_CRITICAL;
+ if (result != -1) {
+ result = 0;
+ }
+ return result;
+ }
+
+ #else /* __FreeBSD_version >= 300001 */
+
+ int mount(type, dir, flags, data)
+ int type;
+ const char *dir;
+ int flags;
+ void *data;
+ { int result;
+ struct ufs_args *u_data;
+ struct mfs_args *m_data;
+ struct nfs_args *n_data;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(dir);
+ switch(type) {
+ case MOUNT_UFS: u_data = (struct ufs_args*) data;
+ MAKE_READABLE(u_data);
+ MAKE_READABLE(u_data->fspec); break;
+ case MOUNT_MFS: m_data = (struct mfs_args*) data;
+ MAKE_READABLE(m_data);
+ #if __FreeBSD__ >= 2
+ MAKE_READABLE(m_data->fspec); break;
+ #else
+ MAKE_READABLE(m_data->name); break;
+ #endif
+ case MOUNT_NFS: n_data = (struct nfs_args*) data;
+ MAKE_READABLE(n_data);
+ MAKE_READABLE(n_data->addr);
+ MAKE_READABLE(n_data->fh);
+ MAKE_READABLE(n_data->hostname); break;
+ }
+ result = syscall(SYS_mount, type, dir, flags, data);
+ EXIT_CRITICAL;
+ if (result != -1) {
+ result = 0;
+ }
+ return result;
+ }
+ #endif /* __FreeBSD_version >= 300001 */
+
+ int msgctl(msqid, cmd, buf) /* ok */
+ int msqid, cmd;
+ struct msqid_ds *buf;
+ { int result;
+
+ ENTER_CRITICAL;
+ switch (cmd) {
+ case IPC_SET:
+ MAKE_READABLE(buf);
+ break;
+ case IPC_STAT:
+ MAKE_WRITABLE(buf);
+ break;
+ default:
+ break;
+ }
+ result = syscall(SYS_msgsys, 0, msqid, cmd, buf);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int msgrcv(msqid, msgp, msgsz, msgtyp, msgflg) /* ok */
+ int msqid;
+ void *msgp;
+ size_t msgsz;
+ long msgtyp;
+ int msgflg;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(msgp);
+ result = syscall(SYS_msgsys, 3, msqid, msgp, msgsz, msgtyp, msgflg);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int msgsnd(msqid, msgp, msgsz, msgflg) /* ok */
+ int msqid;
+ void *msgp;
+ size_t msgsz;
+ int msgflg;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(msgp);
+ result = syscall(SYS_msgsys, 2, msqid, msgp, msgsz, msgflg);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int uopen(const char* path, int flags, mode_t mode) /* ok */
+ { int result;
+ /* mode_t mode;
+ va_list ap;
+
+ va_start(ap, flags);
+ mode = va_arg(ap, mode_t);
+ va_end(ap);
+ this does not work. Why?
+ */
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_open, path, flags, mode);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int quotactl(path, cmd, uid, addr) /* ok */
+ const char *path;
+ int cmd, uid;
+ #if __FreeBSD_version >= 400002
+ void *addr;
+ #else
+ char *addr;
+ #endif
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ switch (cmd) {
+ case Q_QUOTAON:
+ case Q_QUOTAOFF:
+ case Q_SETUSE:
+ case Q_SETQUOTA:
+ case Q_GETQUOTA:
+ MAKE_READABLE(addr);
+ break;
+ /*
+ case Q_GETDLIM:
+ MAKE_WRITABLE(addr);
+ break;
+ */
+ default:
+ break;
+ }
+ result = syscall(SYS_quotactl, path, cmd, uid, addr);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int readlink(path, buf, bufsiz) /* ok */
+ const char *path;
+ char *buf;
+ int bufsiz;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ MAKE_WRITABLE(buf);
+ result = syscall(SYS_readlink, path, buf, bufsiz);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ ssize_t readv(d, iov, iovcnt) /* ok */
+ int d;
+ const struct iovec *iov;
+ int iovcnt;
+ { int result;
+
+ ENTER_CRITICAL;
+ { int i;
+ for (i = 0; i < iovcnt; i++) {
+ MAKE_WRITABLE(iov[i].iov_base);
+ }
+ }
+ result = syscall(SYS_readv, d, iov, iovcnt);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ ssize_t recvmsg(s, msg, flags) /* ok */
+ int s;
+ struct msghdr msg[];
+ int flags;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(msg->msg_name);
+ { int i;
+ for (i = 0; i < msg->msg_iovlen; i++) {
+ if (msg->msg_iov[i].iov_len > 0) {
+ MAKE_WRITABLE(msg->msg_iov[i].iov_base);
+ }
+ }
+ }
+ MAKE_WRITABLE(msg->msg_control);
+ result = syscall(SYS_recvmsg, s, msg, flags);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int rename(from, to) /* ok */
+ char *from;
+ char *to;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(from);
+ MAKE_READABLE(to);
+ result = syscall(SYS_rename, from, to);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int rmdir(path) /* ok */
+ const char *path;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_rmdir, path);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int
+ #if (227002 <= __FreeBSD_version && __FreeBSD_version < 300000) || \
+ __FreeBSD_version >= 300002
+ semctl(int semid, int semnum, int cmd, ...)
+ #else
+ semctl(int semid, int semnum, int cmd, union semun arg)
+ #endif
+ {
+ int result;
+ #if (227002 <= __FreeBSD_version && __FreeBSD_version < 300000) || \
+ __FreeBSD_version >= 300002
+ union semun arg;
+ va_list ap;
+
+ va_start(ap, cmd);
+ arg = va_arg(ap, union semun);
+ va_end(ap);
+ #endif
+
+ ENTER_CRITICAL;
+ switch (cmd) {
+
+ case IPC_SET:
+ MAKE_READABLE(arg.buf);
+ break;
+
+ case SETALL:
+ MAKE_READABLE(arg.array);
+ break;
+
+ case IPC_STAT:
+ MAKE_WRITABLE(arg.buf);
+ break;
+
+ case GETALL:
+ MAKE_WRITABLE(arg.array);
+ break;
+ }
+ result = syscall(SYS_semsys, 0, semid, semnum, cmd, arg);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int semop(semid, sops, nsops) /* ok ? */
+ int semid;
+ struct sembuf *sops;
+ unsigned int nsops;
+ { int result;
+
+ ENTER_CRITICAL;
+ { unsigned int i;
+ for (i = 0; i < nsops; i++) {
+ MAKE_READABLE(sops);
+ }
+ }
+ result = syscall(SYS_semsys, 2, semid, sops, nsops);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ ssize_t sendmsg(s, msg, flags) /* ok */
+ int s;
+ const struct msghdr msg[];
+ int flags;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(msg->msg_name);
+ { int i;
+ for (i = 0; i < msg->msg_iovlen; i++) {
+ if (msg->msg_iov[i].iov_len > 0) {
+ MAKE_READABLE(msg->msg_iov[i].iov_base);
+ }
+ }
+ }
+ MAKE_WRITABLE(msg->msg_control);
+ result = syscall(SYS_sendmsg, s, msg, flags);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int setdomainname(name, namelen) /* ok */
+ const char *name;
+ int namelen;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(name);
+ result = syscall(SYS_setdomainname, name, namelen);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int setgroups(ngroups, gidset) /* ok */
+ int ngroups;
+ const gid_t *gidset;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(gidset);
+ result = syscall(SYS_setgroups, ngroups, gidset);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int sethostname(name, namelen) /* ok */
+ const char *name;
+ int namelen;
+ { int result;
+ #if __FreeBSD__ >= 2
+ int mib[2];
+ #endif
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(name);
+ #if __FreeBSD__ >= 2
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_HOSTNAME;
+ if (sysctl(mib, 2, NULL, NULL, (void *)name, namelen) == -1){
+ result = -1;
+ }else{
+ result = 0;
+ }
+ #else
+ result = syscall(SYS_sethostname, name, namelen);
+ #endif
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int setitimer(which, value, ovalue) /* ok */
+ int which;
+ #if __FreeBSD__ >= 2
+ const struct itimerval *value;
+ #else
+ struct itimerval *value;
+ #endif
+ struct itimerval *ovalue;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(value);
+ MAKE_WRITABLE(ovalue);
+ result = syscall(SYS_setitimer, which, value, ovalue);
+ EXIT_CRITICAL;
+ return result;
+ }
+ /* not implemented
+ int setquota(special, file)
+ char *special;
+ char *file;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(special);
+ MAKE_READABLE(file);
+ result = syscall(SYS_setquota, special, file);
+ EXIT_CRITICAL;
+ return result;
+ }
+ */
+
+ int setrlimit(resource, rlp) /* ok */
+ int resource;
+ struct rlimit *rlp;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(rlp);
+ result = syscall(SYS_setrlimit, resource, rlp);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int setsockopt(s, level, optname, optval, optlen) /* ok */
+ int s, level, optname;
+ const void *optval;
+ int optlen;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(optval);
+ result = syscall(SYS_setsockopt, s, level, optname, optval, optlen);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ /* not implemented
+ int setsysinfo(op, buffer, nbytes, arg, flag)
+ unsigned op;
+ char *buffer;
+ unsigned nbytes;
+ unsigned arg;
+ unsigned flag;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(buffer);
+ result = syscall(SYS_setsysinfo, op, buffer, nbytes, arg, flag);
+ EXIT_CRITICAL;
+ return result;
+ }
+ */
+
+ int settimeofday(tp, tzp) /* ok */
+ #if __FreeBSD__ >= 2
+ const struct timeval *tp;
+ const struct timezone *tzp;
+ #else
+ struct timeval *tp;
+ struct timezone *tzp;
+ #endif
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(tp);
+ MAKE_READABLE(tzp);
+ result = syscall(SYS_settimeofday, tp, tzp);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int sigaction(sig, act, oact)
+ int sig;
+ const struct sigaction *act;
+ struct sigaction *oact;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(act);
+ MAKE_WRITABLE(oact);
+ result = syscall(SYS_sigaction, sig, act, oact);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int sigaltstack(ss, oss) /* ok */
+ const struct sigaltstack *ss;
+ struct sigaltstack *oss;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(ss);
+ MAKE_WRITABLE(oss);
+ result = syscall(SYS_sigaltstack, ss, oss);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int socketpair(d, type, protocol, sv) /* ok */
+ int d, type, protocol;
+ int sv[2];
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(sv);
+ result = syscall(SYS_socketpair, d, type, protocol, sv);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int stat(path, buf) /* ok */
+ const char *path;
+ struct stat *buf;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ MAKE_WRITABLE(buf);
+ result = syscall(SYS_stat, path, buf);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int swapon(special) /* ok */
+ const char *special;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(special);
+ result = syscall(SYS_swapon, special);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int symlink(name1, name2) /* ok */
+ const char *name1;
+ const char *name2;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(name1);
+ MAKE_READABLE(name2);
+ result = syscall(SYS_symlink, name1, name2);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int truncate(path, length) /* ok */
+ const char *path;
+ off_t length;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ /* The casts below pad "path" out to a 64-bit value as required. */
+ result = __syscall(SYS_truncate, (u_quad_t)(u_long)path, length);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int uname(name) /* ok */
+ struct utsname *name;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(name);
+ result = syscall(SYS_uname, name);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int unlink(path) /* ok */
+ const char *path;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_unlink, path);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ /* not implemented
+ int ustat(dev, buf)
+ dev_t dev;
+ struct ustat *buf;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(buf);
+ result = syscall(SYS_ustat, dev, buf);
+ EXIT_CRITICAL;
+ return result;
+ }
+ */
+
+ int utimes(file, tvp) /* ok */
+ #if __FreeBSD__ >= 2
+ const char *file;
+ const struct timeval *tvp;
+ #else
+ char *file;
+ struct timeval *tvp;
+ #endif
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(file);
+ MAKE_READABLE(tvp);
+ result = syscall(SYS_utimes, file, tvp);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ pid_t wait(status) /* ok */
+ int *status;
+ {
+ return wait3(status, 0, 0);
+ }
+
+ pid_t wait3(status, options, rusage) /* ok */
+ int *status;
+ int options;
+ struct rusage *rusage;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(status);
+ MAKE_WRITABLE(rusage);
+ result = syscall(SYS_wait4, -1, status, options, rusage);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ pid_t wait4(wpid, status, options, rusage) /* ok */
+ pid_t wpid;
+ int *status;
+ int options;
+ struct rusage *rusage;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(status);
+ MAKE_WRITABLE(rusage);
+ result = syscall(SYS_wait4, wpid, status, options, rusage);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ pid_t waitpid(pid, status, options) /* ok */
+ pid_t pid;
+ int *status;
+ int options;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(status);
+ result = syscall(SYS_wait4, pid, status, options, NULL);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ ssize_t writev(fd, iov, ioveclen) /* ok */
+ int fd;
+ const struct iovec *iov;
+ int ioveclen;
+ { int result;
+
+ ENTER_CRITICAL;
+ { int i;
+ for (i = 0; i < ioveclen; i++) {
+ if (iov[i].iov_len > 0) {
+ MAKE_READABLE(iov[i].iov_base);
+ }
+ }
+ }
+ result = syscall(SYS_writev, fd, iov, ioveclen);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ /* fork also requires special treatment, although it takes no
+ argument. fork crashes Ultrix if some pages are unreadable, so we
+ must unprotect the heap before calling fork */
+ /* I don't know what happens in FreeBSD, so I just leave it in here */
+ pid_t fork()
+ {
+ pid_t result;
+ pid_t me = getpid();
+
+ ENTER_CRITICAL;
+ if (RTCSRC_FinishVM) RTCSRC_FinishVM();
+ result = syscall(SYS_fork);
+ EXIT_CRITICAL;
+ if (result == me) {
+ result = 0;
+ }
+ return result;
+ }
+
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/RTMachine.i3
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/RTMachine.i3:1.1
*** /dev/null Mon Jun 7 17:09:10 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/RTMachine.i3 Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,85 ----
+ (* 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:23 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 = 20;
+ FramePadTop = 20;
+ (* 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 = 8192; (* bytes per page *)
+ LogBytesPerHeapPage = 13;
+ AdrPerHeapPage = 8192; (* addresses per page *)
+ LogAdrPerHeapPage = 13;
+
+ (* The collector supports the use of VM protection to achieve incremental,
+ generational collection. This is not possible on all architectures, and
+ it may not be implemented in all cases where it is possible. The
+ boolean constant "VMHeap" is "TRUE" iff all necessary support is
+ present for this architecture. "VMHeap" is "TRUE" for the DS3100,
+ whose implementation you might use as a reference. *)
+
+ CONST
+ VMHeap = TRUE;
+
+ (*** hooks for the C wrapper functions ***)
+
+ <*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.
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/RTSignal.m3
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/RTSignal.m3:1.1
*** /dev/null Mon Jun 7 17:09:10 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/RTSignal.m3 Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,101 ----
+ (* Copyright (C) 1992, Digital Equipment Corporation *)
+ (* All rights reserved. *)
+ (* See the file COPYRIGHT for a full description. *)
+ (* *)
+ (* Last modified on Mon Nov 21 10:31:19 PST 1994 by kalsow *)
+ (* modified on Mon Mar 16 18:10:15 PST 1992 by muller *)
+
+ UNSAFE MODULE RTSignal;
+
+ IMPORT RTMisc, RTProcess, Usignal, Uprocess;
+ FROM Ctypes IMPORT int;
+
+ TYPE
+ SigInfo = UNTRACED REF Usignal.struct_sigcontext;
+
+ VAR
+ DefaultHandler : Usignal.SignalHandler;
+ IgnoreSignal : Usignal.SignalHandler;
+ initial_handlers : ARRAY [0..5] OF Usignal.struct_sigaction;
+
+ PROCEDURE InstallHandlers () =
+ BEGIN
+ DefaultHandler := LOOPHOLE (0, Usignal.SignalHandler);
+ IgnoreSignal := LOOPHOLE (1, Usignal.SignalHandler);
+
+ 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: Usignal.SignalHandler) =
+ (* Note: we use the LOOPHOLE to prevent the runtime check for
+ nested procedure. The runtime check crashes when
+ handler = IgnoreSignal = 1. *)
+ VAR new: Usignal.struct_sigaction;
+ BEGIN
+ new.sa_handler := LOOPHOLE (handler, Usignal.SignalHandler);
+ new.sa_flags := 0;
+ EVAL Usignal.sigaction (sig, ADR(new), ADR(initial_handlers[id]));
+ IF (initial_handlers[id].sa_handler # DefaultHandler) THEN
+ (* don't override inherited, non-default handlers *)
+ EVAL Usignal.sigaction (sig, ADR(initial_handlers[id]), ADR(new));
+ 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 Usignal.sigaction (sig, ADR(initial_handlers[id]), NIL);
+ END RestoreHandler;
+
+ PROCEDURE Shutdown (sig: int; <*UNUSED*> code: int; <*UNUSED*> scp: SigInfo) =
+ VAR new, old: Usignal.struct_sigaction;
+ BEGIN
+ new.sa_handler := DefaultHandler;
+ new.sa_flags := 0;
+ RTProcess.InvokeExitors (); (* flush stdio... *)
+ EVAL Usignal.sigaction (sig, ADR(new), ADR(old)); (* restore default handler *)
+ EVAL Usignal.kill (Uprocess.getpid (), sig); (* and resend the signal *)
+ END Shutdown;
+
+ PROCEDURE Interrupt (sig: int; code: int; scp: SigInfo) =
+ VAR h := RTProcess.OnInterrupt (NIL);
+ BEGIN
+ IF (h = NIL) THEN
+ Shutdown (sig, code, scp);
+ ELSE
+ EVAL RTProcess.OnInterrupt (h); (* reinstall the handler *)
+ h ();
+ END;
+ END Interrupt;
+
+ PROCEDURE Quit (<*UNUSED*> sig, code: int; scp: SigInfo) =
+ VAR pc := 0;
+ BEGIN
+ IF (scp # NIL) THEN pc := scp.sc_pc END;
+ RTMisc.FatalErrorPC (pc, "aborted");
+ END Quit;
+
+ PROCEDURE SegV (<*UNUSED*> sig, code: int; scp: SigInfo) =
+ VAR pc := 0;
+ BEGIN
+ IF (scp # NIL) THEN pc := scp.sc_pc END;
+ RTMisc.FatalErrorPC (pc,
+ "Segmentation violation - possible attempt to dereference NIL");
+ END SegV;
+
+ BEGIN
+ END RTSignal.
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/RTThread.m3
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/RTThread.m3:1.1
*** /dev/null Mon Jun 7 17:09:10 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/RTThread.m3 Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,115 ----
+ (* Copyright (C) 1992, Digital Equipment Corporation *)
+ (* All rights reserved. *)
+ (* See the file COPYRIGHT for a full description. *)
+ (* *)
+ (* Last modified on Wed Nov 23 13:01:14 PST 1994 by kalsow *)
+ (* modified on Tue May 4 18:49:28 PDT 1993 by muller *)
+ (* ow 16.09.1994 *)
+ (* ow 11.10.1994 *)
+
+ UNSAFE MODULE RTThread;
+
+ IMPORT Usignal, Unix, Umman, RTMisc;
+
+ CONST
+ SP_pos = 34; (* Index of stack pointer in jmp_buf array *)
+ FP_pos = 19; (* Index of frame pointer in jmp_buf array *)
+
+ 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; 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);
+ 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 *)
+ 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);
+ INC (s [FP_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 sv, osv: Usignal.struct_sigvec; i: INTEGER;
+ BEGIN
+ sv.sv_handler := handler;
+ sv.sv_mask := Usignal.empty_sv_mask;
+ sv.sv_flags := 0;
+ i := Usignal.sigvec (Usignal.SIGVTALRM, sv, osv);
+ <*ASSERT i = 0*>
+ END setup_sigvtalrm;
+
+ PROCEDURE allow_sigvtalrm () =
+ VAR svt : Usignal.sigset_t := Usignal.sigmask(Usignal.SIGVTALRM);
+ old : Usignal.sigset_t;
+ i : INTEGER;
+ BEGIN
+ i := Usignal.sigprocmask(Usignal.SIG_UNBLOCK, svt, old);
+ <*ASSERT i = 0 *>
+ END allow_sigvtalrm;
+
+ PROCEDURE disallow_sigvtalrm () =
+ VAR svt : Usignal.sigset_t := Usignal.sigmask(Usignal.SIGVTALRM);
+ old : Usignal.sigset_t;
+ i : INTEGER;
+ BEGIN
+ i := Usignal.sigprocmask(Usignal.SIG_BLOCK, svt, old);
+ <*ASSERT i = 0 *>
+ END disallow_sigvtalrm;
+
+ BEGIN
+ END RTThread.
+
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/RTThreadC.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/RTThreadC.c:1.1
*** /dev/null Mon Jun 7 17:09:10 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/RTThreadC.c Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,28 ----
+ /* Copyright (C) 1994, Digital Equipment Corporation */
+ /* All rights reserved. */
+ /* See the file COPYRIGHT for a full description. */
+ /* */
+ /* Last modified on Mon Nov 7 13:23:14 PST 1994 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' */
+ long ThreadF__myId = 1;
+
+ /* low-level runtime lock */
+ long RT0u__inCritical = 0;
+
+ /* global, per-thread linked list of exception handlers */
+ void* RTThread__handlerStack = 0;
+
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/accept.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/accept.c:1.1
*** /dev/null Mon Jun 7 17:09:10 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/accept.c Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,16 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ int
+ m3_accept(int s, struct sockaddr *addr, int *addrlen)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(addr);
+ MAKE_WRITABLE(addrlen);
+ result = accept(s, addr, addrlen);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/bind.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/bind.c:1.1
*** /dev/null Mon Jun 7 17:09:10 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/bind.c Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,15 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ int
+ m3_bind(int s, const struct sockaddr *name, int namelen)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(name);
+ result = bind(s, name, namelen);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/close.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/close.c:1.1
*** /dev/null Mon Jun 7 17:09:10 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/close.c Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,13 ----
+ #include "wrap.h"
+ #include
+
+ int
+ m3_close(int d)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ result = close(d);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/connect.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/connect.c:1.1
*** /dev/null Mon Jun 7 17:09:10 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/connect.c Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,15 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ int
+ m3_connect(int s, const struct sockaddr *name, int namelen)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(name);
+ result = connect(s, name, namelen);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/dup.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/dup.c:1.1
*** /dev/null Mon Jun 7 17:09:10 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/dup.c Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,13 ----
+ #include "wrap.h"
+ #include
+
+ int
+ m3_dup(int oldd)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ result = dup(oldd);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/dup2.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/dup2.c:1.1
*** /dev/null Mon Jun 7 17:09:10 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/dup2.c Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,13 ----
+ #include "wrap.h"
+ #include
+
+ int
+ m3_dup2(int oldd, int newd)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ result = dup2(oldd, newd);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/gethostbyaddr.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/gethostbyaddr.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/gethostbyaddr.c Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,14 ----
+ #include "wrap.h"
+ #include
+
+ struct hostent *
+ m3_gethostbyaddr(const char *addr, int len, int type)
+ {
+ struct hostent *result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(addr);
+ result = gethostbyaddr(addr, len, type);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/gethostbyname.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/gethostbyname.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/gethostbyname.c Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,14 ----
+ #include "wrap.h"
+ #include
+
+ struct hostent *
+ m3_gethostbyname(const char *name)
+ {
+ struct hostent *result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(name);
+ result = gethostbyname(name);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/getpeername.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/getpeername.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/getpeername.c Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,16 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ int
+ m3_getpeername(int s, struct sockaddr *name, int *namelen)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(name);
+ MAKE_WRITABLE(namelen);
+ result = getpeername(s, name, namelen);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/getsockname.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/getsockname.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/getsockname.c Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,16 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ int
+ m3_getsockname(int s, struct sockaddr *name, int *namelen)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(name);
+ MAKE_WRITABLE(namelen);
+ result = getsockname(s, name, namelen);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/listen.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/listen.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/listen.c Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,14 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ int
+ m3_listen(int s, int backlog)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ result = listen(s, backlog);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/m3makefile
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/m3makefile:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/m3makefile Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,40 ----
+ % Copyright (C) 1994, Digital Equipment Corporation
+ % All rights reserved.
+ % See the file COPYRIGHT for a full description.
+ %
+ % Last modified on Mon Nov 21 10:43:13 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")
+ c_source ("RTHeapDepC")
+ c_source ("malloc")
+
+ % These wrappers were extracted from RTHeapDepC.c and modified slightly,
+ % in order to make it possible to support SOCKS.
+ h_source ("socksconf")
+ h_source ("wrap")
+ c_source ("accept")
+ c_source ("bind")
+ c_source ("close")
+ c_source ("connect")
+ c_source ("dup")
+ c_source ("dup2")
+ c_source ("gethostbyaddr")
+ c_source ("gethostbyname")
+ c_source ("getpeername")
+ c_source ("getsockname")
+ c_source ("listen")
+ c_source ("read")
+ c_source ("recv")
+ c_source ("recvfrom")
+ c_source ("select")
+ c_source ("send")
+ c_source ("sendto")
+ c_source ("shutdown")
+ c_source ("socket")
+ c_source ("write")
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/malloc.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/malloc.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/malloc.c Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,1153 ----
+ /*
+ * ----------------------------------------------------------------------------
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * wrote this file. As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
+ * ----------------------------------------------------------------------------
+ *
+ * From FreeBSD: malloc.c,v 1.32 1997/08/31 05:59:39 phk Exp
+ * Modified for Modula-3 thread safety by jdp@polstra.com (John Polstra).
+ *
+ */
+
+ #define _THREAD_SAFE 1 /* Turn on thread safety for Modula-3 */
+
+ /*
+ * Defining EXTRA_SANITY will enable extra checks which are related
+ * to internal conditions and consistency in malloc.c. This has a
+ * noticeable runtime performance hit, and generally will not do you
+ * any good unless you fiddle with the internals of malloc or want
+ * to catch random pointer corruption as early as possible.
+ */
+ #ifndef MALLOC_EXTRA_SANITY
+ #undef MALLOC_EXTRA_SANITY
+ #endif
+
+ /*
+ * What to use for Junk. This is the byte value we use to fill with
+ * when the 'J' option is enabled.
+ */
+ #define SOME_JUNK 0xd0 /* as in "Duh" :-) */
+
+ /*
+ * The basic parameters you can tweak.
+ *
+ * malloc_pageshift pagesize = 1 << malloc_pageshift
+ * It's probably best if this is the native
+ * page size, but it doesn't have to be.
+ *
+ * malloc_minsize minimum size of an allocation in bytes.
+ * If this is too small it's too much work
+ * to manage them. This is also the smallest
+ * unit of alignment used for the storage
+ * returned by malloc/realloc.
+ *
+ */
+
+ #if defined(__FreeBSD__)
+ # if defined(__i386__)
+ # define malloc_pageshift 12U
+ # define malloc_minsize 16U
+ # endif
+ #endif /* __FreeBSD__ */
+
+ #if defined(__sparc__) && defined(sun)
+ # define malloc_pageshift 12U
+ # define malloc_minsize 16U
+ # define MAP_ANON (0)
+ static int fdzero;
+ # define MMAP_FD fdzero
+ # define INIT_MMAP() \
+ { if ((fdzero=open("/dev/zero", O_RDWR, 0000)) == -1) \
+ wrterror("open of /dev/zero"); }
+ # define MADV_FREE MADV_DONTNEED
+ #endif /* __sparc__ */
+
+ #if defined(__linux__)
+ # if defined(__i386__)
+ # define malloc_pageshift 12U
+ # define malloc_minsize 16U
+ # endif
+ #endif /* __linux__ */
+
+ #if defined(__alpha)
+ # define malloc_pageshift 13U
+ # define malloc_minsize 16U
+ #endif /* __alpha */
+
+ /* Insert your combination here... */
+ #if defined(__FOOCPU__) && defined(__BAROS__)
+ # define malloc_pageshift 12U
+ # define malloc_minsize 16U
+ #endif /* __FOOCPU__ && __BAROS__ */
+
+
+ /*
+ * No user serviceable parts behind this point.
+ */
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+
+ /*
+ * This structure describes a page worth of chunks.
+ */
+
+ struct pginfo {
+ struct pginfo *next; /* next on the free list */
+ void *page; /* Pointer to the page */
+ u_short size; /* size of this page's chunks */
+ u_short shift; /* How far to shift for this size chunks */
+ u_short free; /* How many free chunks */
+ u_short total; /* How many chunk */
+ u_int bits[1]; /* Which chunks are free */
+ };
+
+ /*
+ * This structure describes a number of free pages.
+ */
+
+ struct pgfree {
+ struct pgfree *next; /* next run of free pages */
+ struct pgfree *prev; /* prev run of free pages */
+ void *page; /* pointer to free pages */
+ void *end; /* pointer to end of free pages */
+ size_t size; /* number of bytes free */
+ };
+
+ /*
+ * How many bits per u_int in the bitmap.
+ * Change only if not 8 bits/byte
+ */
+ #define MALLOC_BITS (8*sizeof(u_int))
+
+ /*
+ * Magic values to put in the page_directory
+ */
+ #define MALLOC_NOT_MINE ((struct pginfo*) 0)
+ #define MALLOC_FREE ((struct pginfo*) 1)
+ #define MALLOC_FIRST ((struct pginfo*) 2)
+ #define MALLOC_FOLLOW ((struct pginfo*) 3)
+ #define MALLOC_MAGIC ((struct pginfo*) 4)
+
+ #ifndef malloc_pageshift
+ #define malloc_pageshift 12U
+ #endif
+
+ #ifndef malloc_minsize
+ #define malloc_minsize 16U
+ #endif
+
+ #if !defined(malloc_pagesize)
+ #define malloc_pagesize (1UL<>1)
+ #endif
+
+ /* A mask for the offset inside a page. */
+ #define malloc_pagemask ((malloc_pagesize)-1)
+
+ #define pageround(foo) (((foo) + (malloc_pagemask))&(~(malloc_pagemask)))
+ #define ptr2index(foo) (((u_long)(foo) >> malloc_pageshift)-malloc_origo)
+
+ #ifdef _THREAD_SAFE
+ extern long RT0u__inCritical; /* Flag set when in a critical region */
+ #define THREAD_LOCK() (++RT0u__inCritical)
+ #define THREAD_UNLOCK() (--RT0u__inCritical)
+ #endif
+
+ #ifndef THREAD_LOCK
+ #define THREAD_LOCK()
+ #endif
+
+ #ifndef THREAD_UNLOCK
+ #define THREAD_UNLOCK()
+ #endif
+
+ #ifndef MMAP_FD
+ #define MMAP_FD (-1)
+ #endif
+
+ #ifndef INIT_MMAP
+ #define INIT_MMAP()
+ #endif
+
+ /* This is needed at least by HP-UX 10.20 */
+ #if !defined(MAP_ANON) && defined(MAP_ANONYMOUS)
+ #define MAP_ANON MAP_ANONYMOUS
+ #endif
+
+ /* Set when initialization has been done */
+ static unsigned malloc_started;
+
+ /* Recusion flag for public interface. */
+ static int malloc_active;
+
+ /* Number of free pages we cache */
+ static unsigned malloc_cache = 16;
+
+ /* The offset from pagenumber to index into the page directory */
+ static u_long malloc_origo;
+
+ /* The last index in the page directory we care about */
+ static u_long last_index;
+
+ /* Pointer to page directory. Allocated "as if with" malloc */
+ static struct pginfo **page_dir;
+
+ /* How many slots in the page directory */
+ static unsigned malloc_ninfo;
+
+ /* Free pages line up here */
+ static struct pgfree free_list;
+
+ /* Abort(), user doesn't handle problems. */
+ static int malloc_abort;
+
+ /* Are we trying to die ? */
+ static int suicide;
+
+ /* always realloc ? */
+ static int malloc_realloc;
+
+ /* pass the kernel a hint on free pages ? */
+ static int malloc_hint = 1;
+
+ /* xmalloc behaviour ? */
+ static int malloc_xmalloc;
+
+ /* sysv behaviour for malloc(0) ? */
+ static int malloc_sysv;
+
+ /* zero fill ? */
+ static int malloc_zero;
+
+ /* junk fill ? */
+ static int malloc_junk;
+
+ #ifdef HAS_UTRACE
+
+ /* utrace ? */
+ static int malloc_utrace;
+
+ struct ut { void *p; size_t s; void *r; };
+
+ void utrace __P((struct ut *, int));
+
+ #define UTRACE(a, b, c) \
+ if (malloc_utrace) \
+ {struct ut u; u.p=a; u.s = b; u.r=c; utrace(&u, sizeof u);}
+ #else /* !HAS_UTRACE */
+ #define UTRACE(a,b,c)
+ #endif /* HAS_UTRACE */
+
+ /* my last break. */
+ static void *malloc_brk;
+
+ /* one location cache for free-list holders */
+ static struct pgfree *px;
+
+ /* compile-time options */
+ char *malloc_options;
+
+ /* Name of the current public function */
+ static char *malloc_func;
+
+ /* Macro for mmap */
+ #define MMAP(size) \
+ mmap((caddr_t)0, (size), PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, \
+ MMAP_FD, 0);
+
+ /*
+ * Necessary function declarations
+ */
+ static int extend_pgdir(u_long index);
+ static void *imalloc(size_t size);
+ static void ifree(void *ptr);
+ static void *irealloc(void *ptr, size_t size);
+
+ static void
+ wrterror(char *p)
+ {
+ char *q = " error: ";
+ write(STDERR_FILENO, malloc_func, strlen(malloc_func));
+ write(STDERR_FILENO, q, strlen(q));
+ write(STDERR_FILENO, p, strlen(p));
+ suicide = 1;
+ abort();
+ }
+
+ static void
+ wrtwarning(char *p)
+ {
+ char *q = " warning: ";
+ if (malloc_abort)
+ wrterror(p);
+ write(STDERR_FILENO, malloc_func, strlen(malloc_func));
+ write(STDERR_FILENO, q, strlen(q));
+ write(STDERR_FILENO, p, strlen(p));
+ }
+
+
+ /*
+ * Allocate a number of pages from the OS
+ */
+ static caddr_t
+ map_pages(int pages)
+ {
+ caddr_t result, tail;
+
+ result = (caddr_t)pageround((u_long)sbrk(0));
+ tail = result + (pages << malloc_pageshift);
+
+ if (brk(tail)) {
+ #ifdef EXTRA_SANITY
+ wrterror("(ES): map_pages fails\n");
+ #endif /* EXTRA_SANITY */
+ return 0;
+ }
+
+ last_index = ptr2index(tail) - 1;
+ malloc_brk = tail;
+
+ if ((last_index+1) >= malloc_ninfo && !extend_pgdir(last_index))
+ return 0;;
+
+ return result;
+ }
+
+ /*
+ * Extend page directory
+ */
+ static int
+ extend_pgdir(u_long index)
+ {
+ struct pginfo **new, **old;
+ int i, oldlen;
+
+ /* Make it this many pages */
+ i = index * sizeof *page_dir;
+ i /= malloc_pagesize;
+ i += 2;
+
+ /* remember the old mapping size */
+ oldlen = malloc_ninfo * sizeof *page_dir;
+
+ /*
+ * NOTE: we allocate new pages and copy the directory rather than tempt
+ * fate by trying to "grow" the region.. There is nothing to prevent
+ * us from accidently re-mapping space that's been allocated by our caller
+ * via dlopen() or other mmap().
+ *
+ * The copy problem is not too bad, as there is 4K of page index per
+ * 4MB of malloc arena.
+ *
+ * We can totally avoid the copy if we open a file descriptor to associate
+ * the anon mappings with. Then, when we remap the pages at the new
+ * address, the old pages will be "magically" remapped.. But this means
+ * keeping open a "secret" file descriptor.....
+ */
+
+ /* Get new pages */
+ new = (struct pginfo**) MMAP(i * malloc_pagesize);
+ if (new == (struct pginfo **)-1)
+ return 0;
+
+ /* Copy the old stuff */
+ memcpy(new, page_dir,
+ malloc_ninfo * sizeof *page_dir);
+
+ /* register the new size */
+ malloc_ninfo = i * malloc_pagesize / sizeof *page_dir;
+
+ /* swap the pointers */
+ old = page_dir;
+ page_dir = new;
+
+ /* Now free the old stuff */
+ munmap((caddr_t)old, oldlen);
+ return 1;
+ }
+
+ /*
+ * Initialize the world
+ */
+ static void
+ malloc_init ()
+ {
+ char *p, b[64];
+ int i, j;
+
+ INIT_MMAP();
+
+ #ifdef EXTRA_SANITY
+ malloc_junk = 1;
+ #endif /* EXTRA_SANITY */
+
+ for (i = 0; i < 3; i++) {
+ if (i == 0) {
+ j = readlink("/etc/malloc.conf", b, sizeof b - 1);
+ if (j <= 0)
+ continue;
+ b[j] = '\0';
+ p = b;
+ } else if (i == 1) {
+ p = getenv("MALLOC_OPTIONS");
+ } else {
+ p = malloc_options;
+ }
+ for (; p && *p; p++) {
+ switch (*p) {
+ case '>': malloc_cache <<= 1; break;
+ case '<': malloc_cache >>= 1; break;
+ case 'a': malloc_abort = 0; break;
+ case 'A': malloc_abort = 1; break;
+ case 'h': malloc_hint = 0; break;
+ case 'H': malloc_hint = 1; break;
+ case 'r': malloc_realloc = 0; break;
+ case 'R': malloc_realloc = 1; break;
+ case 'j': malloc_junk = 0; break;
+ case 'J': malloc_junk = 1; break;
+ #ifdef HAS_UTRACE
+ case 'u': malloc_utrace = 0; break;
+ case 'U': malloc_utrace = 1; break;
+ #endif
+ case 'v': malloc_sysv = 0; break;
+ case 'V': malloc_sysv = 1; break;
+ case 'x': malloc_xmalloc = 0; break;
+ case 'X': malloc_xmalloc = 1; break;
+ case 'z': malloc_zero = 0; break;
+ case 'Z': malloc_zero = 1; break;
+ default:
+ j = malloc_abort;
+ malloc_abort = 0;
+ wrtwarning("unknown char in MALLOC_OPTIONS\n");
+ malloc_abort = j;
+ break;
+ }
+ }
+ }
+
+ UTRACE(0, 0, 0);
+
+ /*
+ * We want junk in the entire allocation, and zero only in the part
+ * the user asked for.
+ */
+ if (malloc_zero)
+ malloc_junk=1;
+
+ /*
+ * If we run with junk (or implicitly from above: zero), we want to
+ * force realloc() to get new storage, so we can DTRT with it.
+ */
+ if (malloc_junk)
+ malloc_realloc=1;
+
+ /* Allocate one page for the page directory */
+ page_dir = (struct pginfo **) MMAP(malloc_pagesize);
+
+ if (page_dir == (struct pginfo **) -1)
+ wrterror("mmap(2) failed, check limits.\n");
+
+ /*
+ * We need a maximum of malloc_pageshift buckets, steal these from the
+ * front of the page_directory;
+ */
+ malloc_origo = ((u_long)pageround((u_long)sbrk(0))) >> malloc_pageshift;
+ malloc_origo -= malloc_pageshift;
+
+ malloc_ninfo = malloc_pagesize / sizeof *page_dir;
+
+ /* Recalculate the cache size in bytes, and make sure it's nonzero */
+
+ if (!malloc_cache)
+ malloc_cache++;
+
+ malloc_cache <<= malloc_pageshift;
+
+ /*
+ * This is a nice hack from Kaleb Keithly (kaleb@x.org).
+ * We can sbrk(2) further back when we keep this on a low address.
+ */
+ px = (struct pgfree *) imalloc (sizeof *px);
+
+ /* Been here, done that */
+ malloc_started++;
+ }
+
+ /*
+ * Allocate a number of complete pages
+ */
+ static void *
+ malloc_pages(size_t size)
+ {
+ void *p, *delay_free = 0;
+ int i;
+ struct pgfree *pf;
+ u_long index;
+
+ size = pageround(size);
+
+ p = 0;
+
+ /* Look for free pages before asking for more */
+ for(pf = free_list.next; pf; pf = pf->next) {
+
+ #ifdef EXTRA_SANITY
+ if (pf->size & malloc_pagemask)
+ wrterror("(ES): junk length entry on free_list\n");
+ if (!pf->size)
+ wrterror("(ES): zero length entry on free_list\n");
+ if (pf->page == pf->end)
+ wrterror("(ES): zero entry on free_list\n");
+ if (pf->page > pf->end)
+ wrterror("(ES): sick entry on free_list\n");
+ if ((void*)pf->page >= (void*)sbrk(0))
+ wrterror("(ES): entry on free_list past brk\n");
+ if (page_dir[ptr2index(pf->page)] != MALLOC_FREE)
+ wrterror("(ES): non-free first page on free-list\n");
+ if (page_dir[ptr2index(pf->end)-1] != MALLOC_FREE)
+ wrterror("(ES): non-free last page on free-list\n");
+ #endif /* EXTRA_SANITY */
+
+ if (pf->size < size)
+ continue;
+
+ if (pf->size == size) {
+ p = pf->page;
+ if (pf->next)
+ pf->next->prev = pf->prev;
+ pf->prev->next = pf->next;
+ delay_free = pf;
+ break;
+ }
+
+ p = pf->page;
+ pf->page = (char *)pf->page + size;
+ pf->size -= size;
+ break;
+ }
+
+ #ifdef EXTRA_SANITY
+ if (p && page_dir[ptr2index(p)] != MALLOC_FREE)
+ wrterror("(ES): allocated non-free page on free-list\n");
+ #endif /* EXTRA_SANITY */
+
+ size >>= malloc_pageshift;
+
+ /* Map new pages */
+ if (!p)
+ p = map_pages(size);
+
+ if (p) {
+
+ index = ptr2index(p);
+ page_dir[index] = MALLOC_FIRST;
+ for (i=1;ibits[0] *
+ (((malloc_pagesize >> bits)+MALLOC_BITS-1) / MALLOC_BITS);
+
+ /* Don't waste more than two chunks on this */
+ if ((1<<(bits)) <= l+l) {
+ bp = (struct pginfo *)pp;
+ } else {
+ bp = (struct pginfo *)imalloc(l);
+ if (!bp) {
+ ifree(pp);
+ return 0;
+ }
+ }
+
+ bp->size = (1<shift = bits;
+ bp->total = bp->free = malloc_pagesize >> bits;
+ bp->page = pp;
+
+ /* set all valid bits in the bitmap */
+ k = bp->total;
+ i = 0;
+
+ /* Do a bunch at a time */
+ for(;k-i >= MALLOC_BITS; i += MALLOC_BITS)
+ bp->bits[i / MALLOC_BITS] = ~0;
+
+ for(; i < k; i++)
+ bp->bits[i/MALLOC_BITS] |= 1<<(i%MALLOC_BITS);
+
+ if (bp == bp->page) {
+ /* Mark the ones we stole for ourselves */
+ for(i=0;l > 0;i++) {
+ bp->bits[i/MALLOC_BITS] &= ~(1<<(i%MALLOC_BITS));
+ bp->free--;
+ bp->total--;
+ l -= (1 << bits);
+ }
+ }
+
+ /* MALLOC_LOCK */
+
+ page_dir[ptr2index(pp)] = bp;
+
+ bp->next = page_dir[bits];
+ page_dir[bits] = bp;
+
+ /* MALLOC_UNLOCK */
+
+ return 1;
+ }
+
+ /*
+ * Allocate a fragment
+ */
+ static void *
+ malloc_bytes(size_t size)
+ {
+ int i,j;
+ u_int u;
+ struct pginfo *bp;
+ int k;
+ u_int *lp;
+
+ /* Don't bother with anything less than this */
+ if (size < malloc_minsize)
+ size = malloc_minsize;
+
+ /* Find the right bucket */
+ j = 1;
+ i = size-1;
+ while (i >>= 1)
+ j++;
+
+ /* If it's empty, make a page more of that size chunks */
+ if (!page_dir[j] && !malloc_make_chunks(j))
+ return 0;
+
+ bp = page_dir[j];
+
+ /* Find first word of bitmap which isn't empty */
+ for (lp = bp->bits; !*lp; lp++)
+ ;
+
+ /* Find that bit, and tweak it */
+ u = 1;
+ k = 0;
+ while (!(*lp & u)) {
+ u += u;
+ k++;
+ }
+ *lp ^= u;
+
+ /* If there are no more free, remove from free-list */
+ if (!--bp->free) {
+ page_dir[j] = bp->next;
+ bp->next = 0;
+ }
+
+ /* Adjust to the real offset of that chunk */
+ k += (lp-bp->bits)*MALLOC_BITS;
+ k <<= bp->shift;
+
+ if (malloc_junk)
+ memset((u_char*)bp->page + k, SOME_JUNK, bp->size);
+
+ return (u_char *)bp->page + k;
+ }
+
+ /*
+ * Allocate a piece of memory
+ */
+ static void *
+ imalloc(size_t size)
+ {
+ void *result;
+
+ if (suicide)
+ abort();
+
+ if ((size + malloc_pagesize) < size) /* Check for overflow */
+ result = 0;
+ else if (size <= malloc_maxsize)
+ result = malloc_bytes(size);
+ else
+ result = malloc_pages(size);
+
+ if (malloc_abort && !result)
+ wrterror("allocation failed.\n");
+
+ if (malloc_zero && result)
+ memset(result, 0, size);
+
+ return result;
+ }
+
+ /*
+ * Change the size of an allocation.
+ */
+ static void *
+ irealloc(void *ptr, size_t size)
+ {
+ void *p;
+ u_long osize, index;
+ struct pginfo **mp;
+ int i;
+
+ if (suicide)
+ abort();
+
+ index = ptr2index(ptr);
+
+ if (index < malloc_pageshift) {
+ wrtwarning("junk pointer, too low to make sense.\n");
+ return 0;
+ }
+
+ if (index > last_index) {
+ wrtwarning("junk pointer, too high to make sense.\n");
+ return 0;
+ }
+
+ mp = &page_dir[index];
+
+ if (*mp == MALLOC_FIRST) { /* Page allocation */
+
+ /* Check the pointer */
+ if ((u_long)ptr & malloc_pagemask) {
+ wrtwarning("modified (page-) pointer.\n");
+ return 0;
+ }
+
+ /* Find the size in bytes */
+ for (osize = malloc_pagesize; *++mp == MALLOC_FOLLOW;)
+ osize += malloc_pagesize;
+
+ if (!malloc_realloc && /* unless we have to, */
+ size <= osize && /* .. or are too small, */
+ size > (osize - malloc_pagesize)) { /* .. or can free a page, */
+ return ptr; /* don't do anything. */
+ }
+
+ } else if (*mp >= MALLOC_MAGIC) { /* Chunk allocation */
+
+ /* Check the pointer for sane values */
+ if (((u_long)ptr & ((*mp)->size-1))) {
+ wrtwarning("modified (chunk-) pointer.\n");
+ return 0;
+ }
+
+ /* Find the chunk index in the page */
+ i = ((u_long)ptr & malloc_pagemask) >> (*mp)->shift;
+
+ /* Verify that it isn't a free chunk already */
+ if ((*mp)->bits[i/MALLOC_BITS] & (1<<(i%MALLOC_BITS))) {
+ wrtwarning("chunk is already free.\n");
+ return 0;
+ }
+
+ osize = (*mp)->size;
+
+ if (!malloc_realloc && /* Unless we have to, */
+ size < osize && /* ..or are too small, */
+ (size > osize/2 || /* ..or could use a smaller size, */
+ osize == malloc_minsize)) { /* ..(if there is one) */
+ return ptr; /* ..Don't do anything */
+ }
+
+ } else {
+ wrtwarning("pointer to wrong page.\n");
+ return 0;
+ }
+
+ p = imalloc(size);
+
+ if (p) {
+ /* copy the lesser of the two sizes, and free the old one */
+ if (!size || !osize)
+ ;
+ else if (osize < size)
+ memcpy(p, ptr, osize);
+ else
+ memcpy(p, ptr, size);
+ ifree(ptr);
+ }
+ return p;
+ }
+
+ /*
+ * Free a sequence of pages
+ */
+
+ static __inline__ void
+ free_pages(void *ptr, int index, struct pginfo *info)
+ {
+ int i;
+ struct pgfree *pf, *pt=0;
+ u_long l;
+ void *tail;
+
+ if (info == MALLOC_FREE) {
+ wrtwarning("page is already free.\n");
+ return;
+ }
+
+ if (info != MALLOC_FIRST) {
+ wrtwarning("pointer to wrong page.\n");
+ return;
+ }
+
+ if ((u_long)ptr & malloc_pagemask) {
+ wrtwarning("modified (page-) pointer.\n");
+ return;
+ }
+
+ /* Count how many pages and mark them free at the same time */
+ page_dir[index] = MALLOC_FREE;
+ for (i = 1; page_dir[index+i] == MALLOC_FOLLOW; i++)
+ page_dir[index + i] = MALLOC_FREE;
+
+ l = i << malloc_pageshift;
+
+ if (malloc_junk)
+ memset(ptr, SOME_JUNK, l);
+
+ #ifdef MADV_FREE
+ if (malloc_hint)
+ madvise(ptr, l, MADV_FREE);
+ #endif
+
+ tail = (char *)ptr+l;
+
+ /* add to free-list */
+ if (!px)
+ px = imalloc(sizeof *pt); /* This cannot fail... */
+ px->page = ptr;
+ px->end = tail;
+ px->size = l;
+ if (!free_list.next) {
+
+ /* Nothing on free list, put this at head */
+ px->next = free_list.next;
+ px->prev = &free_list;
+ free_list.next = px;
+ pf = px;
+ px = 0;
+
+ } else {
+
+ /* Find the right spot, leave pf pointing to the modified entry. */
+ tail = (char *)ptr+l;
+
+ for(pf = free_list.next; pf->end < ptr && pf->next; pf = pf->next)
+ ; /* Race ahead here */
+
+ if (pf->page > tail) {
+ /* Insert before entry */
+ px->next = pf;
+ px->prev = pf->prev;
+ pf->prev = px;
+ px->prev->next = px;
+ pf = px;
+ px = 0;
+ } else if (pf->end == ptr ) {
+ /* Append to the previous entry */
+ pf->end = (char *)pf->end + l;
+ pf->size += l;
+ if (pf->next && pf->end == pf->next->page ) {
+ /* And collapse the next too. */
+ pt = pf->next;
+ pf->end = pt->end;
+ pf->size += pt->size;
+ pf->next = pt->next;
+ if (pf->next)
+ pf->next->prev = pf;
+ }
+ } else if (pf->page == tail) {
+ /* Prepend to entry */
+ pf->size += l;
+ pf->page = ptr;
+ } else if (!pf->next) {
+ /* Append at tail of chain */
+ px->next = 0;
+ px->prev = pf;
+ pf->next = px;
+ pf = px;
+ px = 0;
+ } else {
+ wrterror("freelist is destroyed.\n");
+ }
+ }
+
+ /* Return something to OS ? */
+ if (!pf->next && /* If we're the last one, */
+ pf->size > malloc_cache && /* ..and the cache is full, */
+ pf->end == malloc_brk && /* ..and none behind us, */
+ malloc_brk == sbrk(0)) { /* ..and it's OK to do... */
+
+ /*
+ * Keep the cache intact. Notice that the '>' above guarantees that
+ * the pf will always have at least one page afterwards.
+ */
+ pf->end = (char *)pf->page + malloc_cache;
+ pf->size = malloc_cache;
+
+ brk(pf->end);
+ malloc_brk = pf->end;
+
+ index = ptr2index(pf->end);
+ last_index = index - 1;
+
+ for(i=index;i <= last_index;)
+ page_dir[i++] = MALLOC_NOT_MINE;
+
+ /* XXX: We could realloc/shrink the pagedir here I guess. */
+ }
+ if (pt)
+ ifree(pt);
+ }
+
+ /*
+ * Free a chunk, and possibly the page it's on, if the page becomes empty.
+ */
+
+ static __inline__ void
+ free_bytes(void *ptr, int index, struct pginfo *info)
+ {
+ int i;
+ struct pginfo **mp;
+ void *vp;
+
+ /* Find the chunk number on the page */
+ i = ((u_long)ptr & malloc_pagemask) >> info->shift;
+
+ if (((u_long)ptr & (info->size-1))) {
+ wrtwarning("modified (chunk-) pointer.\n");
+ return;
+ }
+
+ if (info->bits[i/MALLOC_BITS] & (1<<(i%MALLOC_BITS))) {
+ wrtwarning("chunk is already free.\n");
+ return;
+ }
+
+ if (malloc_junk)
+ memset(ptr, SOME_JUNK, info->size);
+
+ info->bits[i/MALLOC_BITS] |= 1<<(i%MALLOC_BITS);
+ info->free++;
+
+ mp = page_dir + info->shift;
+
+ if (info->free == 1) {
+
+ /* Page became non-full */
+
+ mp = page_dir + info->shift;
+ /* Insert in address order */
+ while (*mp && (*mp)->next && (*mp)->next->page < info->page)
+ mp = &(*mp)->next;
+ info->next = *mp;
+ *mp = info;
+ return;
+ }
+
+ if (info->free != info->total)
+ return;
+
+ /* Find & remove this page in the queue */
+ while (*mp != info) {
+ mp = &((*mp)->next);
+ #ifdef EXTRA_SANITY
+ if (!*mp)
+ wrterror("(ES): Not on queue\n");
+ #endif /* EXTRA_SANITY */
+ }
+ *mp = info->next;
+
+ /* Free the page & the info structure if need be */
+ page_dir[ptr2index(info->page)] = MALLOC_FIRST;
+ vp = info->page; /* Order is important ! */
+ if(vp != (void*)info)
+ ifree(info);
+ ifree(vp);
+ }
+
+ static void
+ ifree(void *ptr)
+ {
+ struct pginfo *info;
+ int index;
+
+ /* This is legal */
+ if (!ptr)
+ return;
+
+ if (!malloc_started) {
+ wrtwarning("malloc() has never been called.\n");
+ return;
+ }
+
+ /* If we're already sinking, don't make matters any worse. */
+ if (suicide)
+ return;
+
+ index = ptr2index(ptr);
+
+ if (index < malloc_pageshift) {
+ wrtwarning("junk pointer, too low to make sense.\n");
+ return;
+ }
+
+ if (index > last_index) {
+ wrtwarning("junk pointer, too high to make sense.\n");
+ return;
+ }
+
+ info = page_dir[index];
+
+ if (info < MALLOC_MAGIC)
+ free_pages(ptr, index, info);
+ else
+ free_bytes(ptr, index, info);
+ return;
+ }
+
+ /*
+ * These are the public exported interface routines.
+ */
+
+
+ void *
+ malloc(size_t size)
+ {
+ register void *r;
+
+ malloc_func = " in malloc():";
+ THREAD_LOCK();
+ if (malloc_active++) {
+ wrtwarning("recursive call.\n");
+ malloc_active--;
+ return (0);
+ }
+ if (!malloc_started)
+ malloc_init();
+ if (malloc_sysv && !size)
+ r = 0;
+ else
+ r = imalloc(size);
+ UTRACE(0, size, r);
+ malloc_active--;
+ THREAD_UNLOCK();
+ if (malloc_xmalloc && !r)
+ wrterror("out of memory.\n");
+ return (r);
+ }
+
+ void
+ free(void *ptr)
+ {
+ malloc_func = " in free():";
+ THREAD_LOCK();
+ if (malloc_active++) {
+ wrtwarning("recursive call.\n");
+ malloc_active--;
+ return;
+ }
+ ifree(ptr);
+ UTRACE(ptr, 0, 0);
+ malloc_active--;
+ THREAD_UNLOCK();
+ return;
+ }
+
+ void *
+ realloc(void *ptr, size_t size)
+ {
+ register void *r;
+
+ malloc_func = " in realloc():";
+ THREAD_LOCK();
+ if (malloc_active++) {
+ wrtwarning("recursive call.\n");
+ malloc_active--;
+ return (0);
+ }
+ if (ptr && !malloc_started) {
+ wrtwarning("malloc() has never been called.\n");
+ ptr = 0;
+ }
+ if (!malloc_started)
+ malloc_init();
+ if (malloc_sysv && !size) {
+ ifree(ptr);
+ r = 0;
+ } else if (!ptr) {
+ r = imalloc(size);
+ } else {
+ r = irealloc(ptr, size);
+ }
+ UTRACE(ptr, size, r);
+ malloc_active--;
+ THREAD_UNLOCK();
+ if (malloc_xmalloc && !r)
+ wrterror("out of memory.\n");
+ return (r);
+ }
+
+ void *
+ calloc(size_t num, size_t size)
+ {
+ register void *r;
+
+ size *= num;
+ r = malloc(size);
+ if (r)
+ memset(r, 0, size);
+ return (r);
+ }
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/read.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/read.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/read.c Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,15 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ ssize_t
+ m3_read(int d, void *buf, size_t nbytes)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(buf);
+ result = read(d, buf, nbytes);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/recv.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/recv.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/recv.c Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,15 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ ssize_t
+ m3_recv(int s, void *buf, size_t len, int flags)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(buf);
+ result = recv(s, buf, len, flags);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/recvfrom.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/recvfrom.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/recvfrom.c Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,18 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ ssize_t
+ m3_recvfrom(int s, void *buf, size_t len, int flags,
+ struct sockaddr *from, int *fromlen)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(buf);
+ MAKE_WRITABLE(from);
+ MAKE_WRITABLE(fromlen);
+ result = recvfrom(s, buf, len, flags, from, fromlen);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/select.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/select.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/select.c Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,20 ----
+ #include "wrap.h"
+ #include
+ #include
+ #include
+
+ int
+ m3_select(int nfds, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, struct timeval *timeout)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(readfds);
+ MAKE_WRITABLE(writefds);
+ MAKE_WRITABLE(exceptfds);
+ MAKE_READABLE(timeout);
+ result = select(nfds, readfds, writefds, exceptfds, timeout);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/send.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/send.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/send.c Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,15 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ ssize_t
+ m3_send(int s, const void *msg, size_t len, int flags)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(msg);
+ result = send(s, msg, len, flags);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/sendto.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/sendto.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/sendto.c Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,17 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ ssize_t
+ m3_sendto(int s, const void *msg, size_t len, int flags,
+ const struct sockaddr *to, int tolen)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(msg);
+ MAKE_READABLE(to);
+ result = sendto(s, msg, len, flags, to, tolen);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/shutdown.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/shutdown.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/shutdown.c Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,14 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ int
+ m3_shutdown(int s, int how)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ result = shutdown(s, how);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/socket.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/socket.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/socket.c Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,14 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ int
+ m3_socket(int domain, int type, int protocol)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ result = socket(domain, type, protocol);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/socksconf.h
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/socksconf.h:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/socksconf.h Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,6 ----
+ /*
+ * Define 0 or 1 of these, to select the variety of SOCKS support you want.
+ */
+ #undef HPSOCKS
+ #undef SOCKS4
+ #undef SOCKS5
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/wrap.h
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/wrap.h:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/wrap.h Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,61 ----
+ #include "socksconf.h"
+
+ #if defined(HPSOCKS) /* { */
+ #define accept Raccept
+ #define bind Rxbind
+ #define close Rclose
+ #define connect Rconnect
+ #define dup Rdup
+ #define dup2 Rdup2
+ #define gethostbyaddr Rgethostbyaddr
+ #define gethostbyname Rgethostbyname
+ #define getpeername Rgetpeername
+ #define getsockname Rgetsockname
+ #define listen Rlisten
+ #define recv Rrecv
+ #define recvfrom Rrecvfrom
+ #define send Rsend
+ #define sendto Rsendto
+ #define shutdown Rshutdown
+ #define socket Rsocket
+ #elif defined(SOCKS4) /* } { */
+ #define accept Raccept
+ #define bind Rbind
+ #define connect Rconnect
+ #define getpeername Rgetpeername
+ #define getsockname Rgetsockname
+ #define listen Rlisten
+ #define select Rselect
+ #elif defined(SOCKS5) /* } { */
+ #define accept SOCKSaccept
+ #define bind SOCKSbind
+ #define close SOCKSclose
+ #define connect SOCKSconnect
+ #define dup SOCKSdup
+ #define dup2 SOCKSdup2
+ #define fclose SOCKSfclose
+ #define gethostbyname SOCKSgethostbyname
+ #define getpeername SOCKSgetpeername
+ #define getsockname SOCKSgetsockname
+ #define listen SOCKSlisten
+ #define read SOCKSread
+ #define recv SOCKSrecv
+ #define recvfrom SOCKSrecvfrom
+ #define rresvport SOCKSrresvport
+ #define select SOCKSselect
+ #define send SOCKSsend
+ #define sendto SOCKSsendto
+ #define shutdown SOCKSshutdown
+ #define write SOCKSwrite
+ #endif /* } */
+
+ extern long RT0u__inCritical;
+ #define ENTER_CRITICAL RT0u__inCritical++
+ #define EXIT_CRITICAL RT0u__inCritical--
+
+ static char RTHeapDepC__c;
+ #define MAKE_READABLE(x) \
+ if (x != 0) { RTHeapDepC__c = *(char*)(x); }
+
+ #define MAKE_WRITABLE(x) \
+ if (x != 0) { *(char*)(x) = RTHeapDepC__c = *(char*)(x); }
Index: m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/write.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/write.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FBSD_ALPHA/write.c Mon Jun 7 13:14:28 1999
***************
*** 0 ****
--- 1,15 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ size_t
+ m3_write(int fd, const void *buf, int nbytes)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(buf);
+ result = write(fd, buf, nbytes);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/RTHeapDepC.c
diff -c m3/pm3/libs/m3core/src/runtime/FreeBSD2/RTHeapDepC.c:1.1.1.1 m3/pm3/libs/m3core/src/runtime/FreeBSD2/RTHeapDepC.c:1.2
*** m3/pm3/libs/m3core/src/runtime/FreeBSD2/RTHeapDepC.c:1.1.1.1 Thu Jan 16 16:29:56 1997
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/RTHeapDepC.c Mon Jun 7 13:14:32 1999
***************
*** 80,86 ****
#include
#include
#if __FreeBSD__ >= 2
! # include
#endif
#include
#include
--- 80,87 ----
#include
#include
#if __FreeBSD__ >= 2
! #include
! #include
#endif
#include
#include
***************
*** 89,102 ****
#include
#include
#include
#include
#include
#ifdef NULL
#undef NULL
#endif
#define NULL (void *)(0)
! extern int RT0u__inCritical;
#define ENTER_CRITICAL RT0u__inCritical++
#define EXIT_CRITICAL RT0u__inCritical--
--- 90,115 ----
#include
#include
#include
+ #include
#include
#include
+ #if __FreeBSD__ >= 3
+ #include
+ #include
+ #include
+ #include
+ #include
+ #endif
+
+ #include
+ #include
+
#ifdef NULL
#undef NULL
#endif
#define NULL (void *)(0)
! extern long RT0u__inCritical;
#define ENTER_CRITICAL RT0u__inCritical++
#define EXIT_CRITICAL RT0u__inCritical--
***************
*** 104,131 ****
void (*RTCSRC_FinishVM)();
static char RTHeapDepC__c;
! #define MAKE_READABLE(x) if ((int)x) { RTHeapDepC__c = *(char*)(x); }
! #define MAKE_WRITABLE(x) if ((int)x) { *(char*)(x) = RTHeapDepC__c = *(char*)(x); }
/* Unless otherwise noted, all the following wrappers have the same
structure. */
- int accept(s, addr, addrlen) /* ok */
- int s;
- struct sockaddr *addr;
- int *addrlen;
- { int result;
-
- ENTER_CRITICAL;
- MAKE_WRITABLE(addr);
- MAKE_WRITABLE(addrlen);
- result = syscall(SYS_accept, s, addr, addrlen);
- EXIT_CRITICAL;
- return result;
- }
-
int access(path, mode) /* ok */
! char *path;
int mode;
{ int result;
--- 117,144 ----
void (*RTCSRC_FinishVM)();
static char RTHeapDepC__c;
! #define MAKE_READABLE(x) if (x != 0) { RTHeapDepC__c = *(char*)(x); }
! #define MAKE_WRITABLE(x) if (x != 0) { *(char*)(x) = RTHeapDepC__c = *(char*)(x); }
!
! /*
! * Modula-3 compilation units are always compiled PIC. This causes
! * the a.out linker to complain that there is no reference to
! * _DYNAMIC if the program is linked with "-static". Provide a
! * weak reference to it here so that static linking will work.
! *
! * This has nothing to do with the heap, so it doesn't really belong
! * here. But it needs to be someplace that is guaranteed to be pulled
! * into every executable.
! */
! #pragma weak _DYNAMIC
! extern int _DYNAMIC;
! static int *i __unused = &_DYNAMIC;
/* Unless otherwise noted, all the following wrappers have the same
structure. */
int access(path, mode) /* ok */
! const char *path;
int mode;
{ int result;
***************
*** 137,143 ****
}
int acct(file) /* ok */
! char *file;
{ int result;
ENTER_CRITICAL;
--- 150,156 ----
}
int acct(file) /* ok */
! const char *file;
{ int result;
ENTER_CRITICAL;
***************
*** 228,246 ****
}
*/
- int bind(s, name, namelen) /* ok */
- int s;
- const struct sockaddr *name;
- int namelen;
- { int result;
-
- ENTER_CRITICAL;
- MAKE_READABLE(name);
- result = syscall(SYS_bind, s, name, namelen);
- EXIT_CRITICAL;
- return result;
- }
-
/* not implemented
int cachectl(addr, nbytes, op)
char *addr;
--- 241,246 ----
***************
*** 268,274 ****
*/
int chdir(path) /* ok */
! char *path;
{ int result;
ENTER_CRITICAL;
--- 268,274 ----
*/
int chdir(path) /* ok */
! const char *path;
{ int result;
ENTER_CRITICAL;
***************
*** 278,285 ****
return result;
}
int chmod(path, mode) /* ok */
! char *path;
mode_t mode;
{ int result;
--- 278,297 ----
return result;
}
+ int chflags(path, flags)
+ const char *path;
+ u_long flags;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_chflags, path, flags);
+ EXIT_CRITICAL;
+ return result;
+ }
+
int chmod(path, mode) /* ok */
! const char *path;
mode_t mode;
{ int result;
***************
*** 291,297 ****
}
int chown(path, owner, group) /* ok */
! char *path;
uid_t owner;
gid_t group;
{ int result;
--- 303,309 ----
}
int chown(path, owner, group) /* ok */
! const char *path;
uid_t owner;
gid_t group;
{ int result;
***************
*** 304,310 ****
}
int chroot(dirname) /* ok */
! char *dirname;
{ int result;
ENTER_CRITICAL;
--- 316,322 ----
}
int chroot(dirname) /* ok */
! const char *dirname;
{ int result;
ENTER_CRITICAL;
***************
*** 314,332 ****
return result;
}
- int connect(s, name, namelen) /* ok */
- int s;
- const struct sockaddr *name;
- int namelen;
- { int result;
-
- ENTER_CRITICAL;
- MAKE_READABLE(name);
- result = syscall(SYS_connect, s, name, namelen);
- EXIT_CRITICAL;
- return result;
- }
-
/* not implemented (obsolete)
int creat(name, mode)
const char *name;
--- 326,331 ----
***************
*** 356,363 ****
result = syscall(SYS_execve, name, argv, envp);
if (result == -1 && errno == EFAULT) {
MAKE_READABLE(name);
! { char **a; for (a = argv; *a; a++) MAKE_READABLE(*a); }
! { char **e; for (e = envp; *e; e++) MAKE_READABLE(*e); }
} else {
return result;
}
--- 355,362 ----
result = syscall(SYS_execve, name, argv, envp);
if (result == -1 && errno == EFAULT) {
MAKE_READABLE(name);
! { char * const *a; for (a = argv; *a; a++) MAKE_READABLE(*a); }
! { char * const *e; for (e = envp; *e; e++) MAKE_READABLE(*e); }
} else {
return result;
}
***************
*** 473,479 ****
int getgroups(gidsetsize, grouplist) /* ok */
int gidsetsize;
! int grouplist[];
{ int result;
ENTER_CRITICAL;
--- 472,478 ----
int getgroups(gidsetsize, grouplist) /* ok */
int gidsetsize;
! gid_t grouplist[];
{ int result;
ENTER_CRITICAL;
***************
*** 513,532 ****
}
*/
- int getpeername(s, name, namelen) /* ok */
- int s;
- struct sockaddr *name;
- int *namelen;
- { int result;
-
- ENTER_CRITICAL;
- MAKE_WRITABLE(name);
- MAKE_WRITABLE(namelen);
- result = syscall(SYS_getpeername, s, name, namelen);
- EXIT_CRITICAL;
- return result;
- }
-
int getrlimit(resource, rlp) /* ok */
int resource;
struct rlimit *rlp;
--- 512,517 ----
***************
*** 551,570 ****
return result;
}
- int getsockname(s, name, namelen) /* ok */
- int s;
- struct sockaddr *name;
- int *namelen;
- { int result;
-
- ENTER_CRITICAL;
- MAKE_WRITABLE(name);
- MAKE_WRITABLE(namelen);
- result = syscall(SYS_getsockname, s, name, namelen);
- EXIT_CRITICAL;
- return result;
- }
-
int getsockopt(s, level, optname, optval, optlen) /* ok */
int s, level, optname;
void *optval;
--- 536,541 ----
***************
*** 629,637 ****
return result;
}
int link(name1, name2) /* ok */
! char *name1;
! char *name2;
{ int result;
ENTER_CRITICAL;
--- 600,623 ----
return result;
}
+ #ifdef SYS_lchown
+ int lchown(path, owner, group) /* ok */
+ const char *path;
+ uid_t owner;
+ gid_t group;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_lchown, path, owner, group);
+ EXIT_CRITICAL;
+ return result;
+ }
+ #endif /* SYS_lchown */
+
int link(name1, name2) /* ok */
! const char *name1;
! const char *name2;
{ int result;
ENTER_CRITICAL;
***************
*** 643,649 ****
}
int lstat(path, buf) /* ok */
! char *path;
struct stat *buf;
{ int result;
--- 629,635 ----
}
int lstat(path, buf) /* ok */
! const char *path;
struct stat *buf;
{ int result;
***************
*** 656,662 ****
}
int mkdir(path, mode) /* ok */
! char *path;
mode_t mode;
{ int result;
--- 642,648 ----
}
int mkdir(path, mode) /* ok */
! const char *path;
mode_t mode;
{ int result;
***************
*** 667,674 ****
return result;
}
int mknod(path, mode, dev) /* ok */
! char *path;
mode_t mode;
dev_t dev;
{ int result;
--- 653,672 ----
return result;
}
+ int mkfifo(path, mode) /* ok */
+ const char *path;
+ mode_t mode;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_mkfifo, path, mode);
+ EXIT_CRITICAL;
+ return result;
+ }
+
int mknod(path, mode, dev) /* ok */
! const char *path;
mode_t mode;
dev_t dev;
{ int result;
***************
*** 680,692 ****
return result;
}
! /* quite different ...
! int mount(special, name, rwflag, type, options)
! char *special;
! char *name;
! int rwflag, type;
! char *options;
! */
int mount(type, dir, flags, data)
int type;
const char *dir;
--- 678,728 ----
return result;
}
! #if __FreeBSD_version >= 300001 /* New form of mount(2) */
! int
! mount(type, dir, flags, data)
! const char *type;
! const char *dir;
! int flags;
! void *data;
! { int result;
! struct ufs_args *u_data;
! struct mfs_args *m_data;
! struct nfs_args *n_data;
!
! ENTER_CRITICAL;
! MAKE_READABLE(type);
! MAKE_READABLE(dir);
! if (strcmp(type, "ufs") == 0) {
! u_data = (struct ufs_args*) data;
! MAKE_READABLE(u_data);
! MAKE_READABLE(u_data->fspec);
! result = syscall(SYS_mount, type, dir, flags, data);
! } else if (strcmp(type, "mfs") == 0) {
! m_data = (struct mfs_args*) data;
! MAKE_READABLE(m_data);
! MAKE_READABLE(m_data->fspec);
! result = syscall(SYS_mount, type, dir, flags, data);
! } else if (strcmp(type, "nfs") == 0) {
! n_data = (struct nfs_args*) data;
! MAKE_READABLE(n_data);
! MAKE_READABLE(n_data->addr);
! MAKE_READABLE(n_data->fh);
! MAKE_READABLE(n_data->hostname);
! result = syscall(SYS_mount, type, dir, flags, data);
! } else { /* Not anything we recognize. */
! MAKE_READABLE(data);
! result = syscall(SYS_mount, type, dir, flags, data);
! }
! EXIT_CRITICAL;
! if (result != -1) {
! result = 0;
! }
! return result;
! }
!
! #else /* __FreeBSD_version >= 300001 */
!
int mount(type, dir, flags, data)
int type;
const char *dir;
***************
*** 723,728 ****
--- 759,765 ----
}
return result;
}
+ #endif /* __FreeBSD_version >= 300001 */
int msgctl(msqid, cmd, buf) /* ok */
int msqid, cmd;
***************
*** 793,801 ****
}
int quotactl(path, cmd, uid, addr) /* ok */
! const char *path;
! int cmd, uid;
! char *addr;
{ int result;
ENTER_CRITICAL;
--- 830,842 ----
}
int quotactl(path, cmd, uid, addr) /* ok */
! const char *path;
! int cmd, uid;
! #if __FreeBSD_version >= 400002
! void *addr;
! #else
! char *addr;
! #endif
{ int result;
ENTER_CRITICAL;
***************
*** 821,841 ****
return result;
}
- int read(d, buf, nbytes) /* ok */
- int d;
- char *buf;
- size_t nbytes;
- { int result;
-
- ENTER_CRITICAL;
- MAKE_WRITABLE(buf);
- result = syscall(SYS_read, d, buf, nbytes);
- EXIT_CRITICAL;
- return result;
- }
-
int readlink(path, buf, bufsiz) /* ok */
! char *path;
char *buf;
int bufsiz;
{ int result;
--- 862,869 ----
return result;
}
int readlink(path, buf, bufsiz) /* ok */
! const char *path;
char *buf;
int bufsiz;
{ int result;
***************
*** 848,854 ****
return result;
}
! int readv(d, iov, iovcnt) /* ok */
int d;
const struct iovec *iov;
int iovcnt;
--- 876,882 ----
return result;
}
! ssize_t readv(d, iov, iovcnt) /* ok */
int d;
const struct iovec *iov;
int iovcnt;
***************
*** 865,912 ****
return result;
}
! int recv(s, buf, len, flags) /* ok */
int s;
- void *buf;
- #if __FreeBSD__ >=2
- size_t len;
- #else
- int len;
- #endif
- int flags;
- { int result;
-
- ENTER_CRITICAL;
- MAKE_WRITABLE(buf);
- result = syscall(SYS_recvfrom, s, buf, len, flags, NULL, 0);
- EXIT_CRITICAL;
- return result;
- }
-
- int recvfrom(s, buf, len, flags, from, fromlen) /* ok */
- int s;
- void *buf;
- #if __FreeBSD__ >=2
- size_t len;
- #else
- int len;
- #endif
- int flags;
- struct sockaddr *from;
- int *fromlen;
- { int result;
-
- ENTER_CRITICAL;
- MAKE_WRITABLE(buf);
- MAKE_WRITABLE(from);
- MAKE_WRITABLE(fromlen);
- result = syscall(SYS_recvfrom, s, buf, len, flags, from, fromlen);
- EXIT_CRITICAL;
- return result;
- }
-
- int recvmsg(s, msg, flags) /* ok */
- int s;
struct msghdr msg[];
int flags;
{ int result;
--- 893,900 ----
return result;
}
! ssize_t recvmsg(s, msg, flags) /* ok */
int s;
struct msghdr msg[];
int flags;
{ int result;
***************
*** 940,946 ****
}
int rmdir(path) /* ok */
! char *path;
{ int result;
ENTER_CRITICAL;
--- 928,934 ----
}
int rmdir(path) /* ok */
! const char *path;
{ int result;
ENTER_CRITICAL;
***************
*** 950,993 ****
return result;
}
! int select(nfds, readfds, writefds, exceptfds, timeout) /* ok */
! int nfds;
! fd_set *readfds;
! fd_set *writefds;
! fd_set *exceptfds;
! struct timeval *timeout;
! { int result;
!
! ENTER_CRITICAL;
! MAKE_WRITABLE(readfds);
! MAKE_WRITABLE(writefds);
! MAKE_WRITABLE(exceptfds);
! MAKE_READABLE(timeout);
! result = syscall(SYS_select, nfds, readfds, writefds, exceptfds, timeout);
! EXIT_CRITICAL;
! return result;
! }
! int semctl(semid, semnum, cmd, arg) /* ok ? */
! int semid, cmd;
! int semnum;
! union semun arg;
! { int result;
ENTER_CRITICAL;
switch (cmd) {
! case GETNCNT:
! case GETPID:
! case GETVAL:
! case GETALL:
! case GETZCNT:
MAKE_READABLE(arg.buf);
break;
case SETALL:
! case SETVAL:
MAKE_WRITABLE(arg.buf);
break;
! default:
break;
}
result = syscall(SYS_semsys, 0, semid, semnum, cmd, arg);
--- 938,979 ----
return result;
}
! int
! #if (227002 <= __FreeBSD_version && __FreeBSD_version < 300000) || \
! __FreeBSD_version >= 300002
! semctl(int semid, int semnum, int cmd, ...)
! #else
! semctl(int semid, int semnum, int cmd, union semun arg)
! #endif
! {
! int result;
! #if (227002 <= __FreeBSD_version && __FreeBSD_version < 300000) || \
! __FreeBSD_version >= 300002
! union semun arg;
! va_list ap;
! va_start(ap, cmd);
! arg = va_arg(ap, union semun);
! va_end(ap);
! #endif
ENTER_CRITICAL;
switch (cmd) {
!
! case IPC_SET:
MAKE_READABLE(arg.buf);
break;
+
case SETALL:
! MAKE_READABLE(arg.array);
! break;
!
! case IPC_STAT:
MAKE_WRITABLE(arg.buf);
break;
!
! case GETALL:
! MAKE_WRITABLE(arg.array);
break;
}
result = syscall(SYS_semsys, 0, semid, semnum, cmd, arg);
***************
*** 1012,1037 ****
return result;
}
! int send(s, msg, len, flags) /* ok */
int s;
- const void *msg;
- #if __FreeBSD__ >=2
- size_t len;
- #else
- int len;
- #endif
- int flags;
- { int result;
-
- ENTER_CRITICAL;
- MAKE_READABLE(msg);
- result = syscall(SYS_sendto, s, msg, len, flags, NULL, 0);
- EXIT_CRITICAL;
- return result;
- }
-
- int sendmsg(s, msg, flags) /* ok */
- int s;
const struct msghdr msg[];
int flags;
{ int result;
--- 998,1005 ----
return result;
}
! ssize_t sendmsg(s, msg, flags) /* ok */
int s;
const struct msghdr msg[];
int flags;
{ int result;
***************
*** 1051,1079 ****
return result;
}
- int sendto(s, msg, len, flags, to, tolen) /* ok */
- int s;
- const void *msg;
- #if __FreeBSD__ >=2
- size_t len;
- #else
- int len;
- #endif
- int flags;
- const struct sockaddr *to;
- int tolen;
- { int result;
-
- ENTER_CRITICAL;
- MAKE_READABLE(msg);
- MAKE_READABLE(to);
- result = syscall(SYS_sendto, s, msg, len, flags, to, tolen);
- EXIT_CRITICAL;
- return result;
- }
-
int setdomainname(name, namelen) /* ok */
! char *name;
int namelen;
{ int result;
--- 1019,1026 ----
return result;
}
int setdomainname(name, namelen) /* ok */
! const char *name;
int namelen;
{ int result;
***************
*** 1086,1092 ****
int setgroups(ngroups, gidset) /* ok */
int ngroups;
! int *gidset;
{ int result;
ENTER_CRITICAL;
--- 1033,1039 ----
int setgroups(ngroups, gidset) /* ok */
int ngroups;
! const gid_t *gidset;
{ int result;
ENTER_CRITICAL;
***************
*** 1097,1103 ****
}
int sethostname(name, namelen) /* ok */
! char *name;
int namelen;
{ int result;
#if __FreeBSD__ >= 2
--- 1044,1050 ----
}
int sethostname(name, namelen) /* ok */
! const char *name;
int namelen;
{ int result;
#if __FreeBSD__ >= 2
***************
*** 1213,1232 ****
return result;
}
! /* not implemented
! int sigpending(set)
! sigset_t *set;
{ int result;
ENTER_CRITICAL;
! MAKE_WRITABLE(set);
! result = syscall(SYS_sigpending, set);
EXIT_CRITICAL;
return result;
}
- */
- #if __FreeBSD__ >= 2
int sigaltstack(ss, oss) /* ok */
const struct sigaltstack *ss;
struct sigaltstack *oss;
--- 1160,1179 ----
return result;
}
! int sigaction(sig, act, oact)
! int sig;
! const struct sigaction *act;
! struct sigaction *oact;
{ int result;
ENTER_CRITICAL;
! MAKE_READABLE(act);
! MAKE_WRITABLE(oact);
! result = syscall(SYS_sigaction, sig, act, oact);
EXIT_CRITICAL;
return result;
}
int sigaltstack(ss, oss) /* ok */
const struct sigaltstack *ss;
struct sigaltstack *oss;
***************
*** 1239,1259 ****
EXIT_CRITICAL;
return result;
}
- #else
- int sigstack(ss, oss) /* ok */
- const struct sigstack *ss;
- struct sigstack *oss;
- { int result;
- ENTER_CRITICAL;
- MAKE_READABLE(ss);
- MAKE_WRITABLE(oss);
- result = syscall(SYS_sigstack, ss, oss);
- EXIT_CRITICAL;
- return result;
- }
- #endif
-
int socketpair(d, type, protocol, sv) /* ok */
int d, type, protocol;
int sv[2];
--- 1186,1192 ----
***************
*** 1267,1273 ****
}
int stat(path, buf) /* ok */
! char *path;
struct stat *buf;
{ int result;
--- 1200,1206 ----
}
int stat(path, buf) /* ok */
! const char *path;
struct stat *buf;
{ int result;
***************
*** 1280,1286 ****
}
int swapon(special) /* ok */
! char *special;
{ int result;
ENTER_CRITICAL;
--- 1213,1219 ----
}
int swapon(special) /* ok */
! const char *special;
{ int result;
ENTER_CRITICAL;
***************
*** 1291,1298 ****
}
int symlink(name1, name2) /* ok */
! char *name1;
! char *name2;
{ int result;
ENTER_CRITICAL;
--- 1224,1231 ----
}
int symlink(name1, name2) /* ok */
! const char *name1;
! const char *name2;
{ int result;
ENTER_CRITICAL;
***************
*** 1304,1317 ****
}
int truncate(path, length) /* ok */
! char *path;
! long length;
{ int result;
- off_t len = (off_t)length;
ENTER_CRITICAL;
MAKE_READABLE(path);
! result = syscall(SYS_truncate, path, len);
EXIT_CRITICAL;
return result;
}
--- 1237,1250 ----
}
int truncate(path, length) /* ok */
! const char *path;
! off_t length;
{ int result;
ENTER_CRITICAL;
MAKE_READABLE(path);
! /* The casts below pad "path" out to a 64-bit value as required. */
! result = __syscall(SYS_truncate, (u_quad_t)(u_long)path, length);
EXIT_CRITICAL;
return result;
}
***************
*** 1328,1334 ****
}
int unlink(path) /* ok */
! char *path;
{ int result;
ENTER_CRITICAL;
--- 1261,1267 ----
}
int unlink(path) /* ok */
! const char *path;
{ int result;
ENTER_CRITICAL;
***************
*** 1417,1437 ****
EXIT_CRITICAL;
return result;
}
-
- int write(fd, buf, nbytes) /* ok */
- int fd;
- char *buf;
- int nbytes;
- { int result;
-
- ENTER_CRITICAL;
- MAKE_READABLE(buf);
- result = syscall(SYS_write, fd, buf, nbytes);
- EXIT_CRITICAL;
- return result;
- }
! int writev(fd, iov, ioveclen) /* ok */
int fd;
const struct iovec *iov;
int ioveclen;
--- 1350,1357 ----
EXIT_CRITICAL;
return result;
}
! ssize_t writev(fd, iov, ioveclen) /* ok */
int fd;
const struct iovec *iov;
int ioveclen;
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/RTSignal.m3
diff -c m3/pm3/libs/m3core/src/runtime/FreeBSD2/RTSignal.m3:1.1.1.1 m3/pm3/libs/m3core/src/runtime/FreeBSD2/RTSignal.m3:1.2
*** m3/pm3/libs/m3core/src/runtime/FreeBSD2/RTSignal.m3:1.1.1.1 Thu Jan 16 16:29:56 1997
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/RTSignal.m3 Mon Jun 7 13:14:33 1999
***************
*** 7,24 ****
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);
--- 7,27 ----
UNSAFE MODULE RTSignal;
! IMPORT RTMisc, RTProcess, Usignal, Uprocess;
FROM Ctypes IMPORT int;
+ TYPE
+ SigInfo = UNTRACED REF Usignal.struct_sigcontext;
+
VAR
! DefaultHandler : Usignal.SignalHandler;
! IgnoreSignal : Usignal.SignalHandler;
! initial_handlers : ARRAY [0..5] OF Usignal.struct_sigaction;
PROCEDURE InstallHandlers () =
BEGIN
! DefaultHandler := LOOPHOLE (0, Usignal.SignalHandler);
! IgnoreSignal := LOOPHOLE (1, Usignal.SignalHandler);
SetHandler (0, Usignal.SIGHUP, Shutdown);
SetHandler (1, Usignal.SIGINT, Interrupt);
***************
*** 28,40 ****
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;
--- 31,48 ----
SetHandler (5, Usignal.SIGTERM, Shutdown);
END InstallHandlers;
! PROCEDURE SetHandler (id: INTEGER; sig: int; handler: Usignal.SignalHandler) =
! (* Note: we use the LOOPHOLE to prevent the runtime check for
! nested procedure. The runtime check crashes when
! handler = IgnoreSignal = 1. *)
! VAR new: Usignal.struct_sigaction;
! BEGIN
! new.sa_handler := LOOPHOLE (handler, Usignal.SignalHandler);
! new.sa_flags := 0;
! EVAL Usignal.sigaction (sig, ADR(new), ADR(initial_handlers[id]));
! IF (initial_handlers[id].sa_handler # DefaultHandler) THEN
(* don't override inherited, non-default handlers *)
! EVAL Usignal.sigaction (sig, ADR(initial_handlers[id]), ADR(new));
END;
END SetHandler;
***************
*** 50,85 ****
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
--- 58,100 ----
PROCEDURE RestoreHandler (id: INTEGER; sig: int) =
BEGIN
! EVAL Usignal.sigaction (sig, ADR(initial_handlers[id]), NIL);
END RestoreHandler;
! PROCEDURE Shutdown (sig: int; <*UNUSED*> code: int; <*UNUSED*> scp: SigInfo) =
! VAR new, old: Usignal.struct_sigaction;
BEGIN
+ new.sa_handler := DefaultHandler;
+ new.sa_flags := 0;
RTProcess.InvokeExitors (); (* flush stdio... *)
! EVAL Usignal.sigaction (sig, ADR(new), ADR(old)); (* restore default handler *)
EVAL Usignal.kill (Uprocess.getpid (), sig); (* and resend the signal *)
END Shutdown;
! PROCEDURE Interrupt (sig: int; code: int; scp: SigInfo) =
VAR h := RTProcess.OnInterrupt (NIL);
BEGIN
IF (h = NIL) THEN
! Shutdown (sig, code, scp);
ELSE
EVAL RTProcess.OnInterrupt (h); (* reinstall the handler *)
h ();
END;
END Interrupt;
! PROCEDURE Quit (<*UNUSED*> sig, code: int; scp: SigInfo) =
! VAR pc := 0;
BEGIN
! IF (scp # NIL) THEN pc := scp.sc_eip END;
! RTMisc.FatalErrorPC (pc, "aborted");
END Quit;
! PROCEDURE SegV (<*UNUSED*> sig, code: int; scp: SigInfo) =
! VAR pc := 0;
BEGIN
! IF (scp # NIL) THEN pc := scp.sc_eip END;
! RTMisc.FatalErrorPC (pc,
! "Segmentation violation - possible attempt to dereference NIL");
END SegV;
BEGIN
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/RTStackASM.s
diff -c m3/pm3/libs/m3core/src/runtime/FreeBSD2/RTStackASM.s:1.1.1.1 m3/pm3/libs/m3core/src/runtime/FreeBSD2/RTStackASM.s:1.2
*** m3/pm3/libs/m3core/src/runtime/FreeBSD2/RTStackASM.s:1.1.1.1 Thu Jan 16 16:29:56 1997
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/RTStackASM.s Mon Jun 7 13:14:33 1999
***************
*** 3,8 ****
--- 3,10 ----
.globl _RTStack__CurrentFrame
_RTStack__CurrentFrame:
+ .globl RTStack__CurrentFrame
+ RTStack__CurrentFrame:
# STACK = ret frame
popl %eax # STACK = frame
pushl %eax
***************
*** 19,24 ****
--- 21,28 ----
.globl _RTStack__PreviousFrame
_RTStack__PreviousFrame:
+ .globl RTStack__PreviousFrame
+ RTStack__PreviousFrame:
movl 4(%esp), %eax # eax = ^callee
movl 4(%eax), %eax # eax = callee.ebp
pushl 0(%eax) # push bp of caller
***************
*** 33,38 ****
--- 37,44 ----
.globl _RTStack__Unwind
_RTStack__Unwind:
+ .globl RTStack__Unwind
+ RTStack__Unwind:
movl 4(%esp), %eax # eax = ^to
movl 8(%eax), %esp
movl 4(%eax), %ebp
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/_fpsetjmp.s
diff -c m3/pm3/libs/m3core/src/runtime/FreeBSD2/_fpsetjmp.s:1.1.1.1 m3/pm3/libs/m3core/src/runtime/FreeBSD2/_fpsetjmp.s:1.2
*** m3/pm3/libs/m3core/src/runtime/FreeBSD2/_fpsetjmp.s:1.1.1.1 Thu Jan 16 16:29:56 1997
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/_fpsetjmp.s Mon Jun 7 13:14:33 1999
***************
*** 55,60 ****
--- 55,63 ----
.globl __fpsetjmp;
.type __fpsetjmp,@function;
__fpsetjmp:
+ .globl _fpsetjmp;
+ .type _fpsetjmp,@function;
+ _fpsetjmp:
movl 4(%esp),%eax
movl 0(%esp),%edx
movl %edx, 0(%eax)
***************
*** 71,76 ****
--- 74,82 ----
.globl __fplongjmp;
.type __fplongjmp,@function;
__fplongjmp:
+ .globl _fplongjmp;
+ .type _fplongjmp,@function;
+ _fplongjmp:
movl 4(%esp),%edx
movl 8(%esp),%eax
movl 0(%edx),%ecx
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/accept.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD2/accept.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/accept.c Mon Jun 7 13:14:33 1999
***************
*** 0 ****
--- 1,16 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ int
+ m3_accept(int s, struct sockaddr *addr, int *addrlen)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(addr);
+ MAKE_WRITABLE(addrlen);
+ result = accept(s, addr, addrlen);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/bind.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD2/bind.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/bind.c Mon Jun 7 13:14:33 1999
***************
*** 0 ****
--- 1,15 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ int
+ m3_bind(int s, const struct sockaddr *name, int namelen)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(name);
+ result = bind(s, name, namelen);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/close.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD2/close.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/close.c Mon Jun 7 13:14:33 1999
***************
*** 0 ****
--- 1,13 ----
+ #include "wrap.h"
+ #include
+
+ int
+ m3_close(int d)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ result = close(d);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/connect.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD2/connect.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/connect.c Mon Jun 7 13:14:33 1999
***************
*** 0 ****
--- 1,15 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ int
+ m3_connect(int s, const struct sockaddr *name, int namelen)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(name);
+ result = connect(s, name, namelen);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/dup.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD2/dup.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/dup.c Mon Jun 7 13:14:33 1999
***************
*** 0 ****
--- 1,13 ----
+ #include "wrap.h"
+ #include
+
+ int
+ m3_dup(int oldd)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ result = dup(oldd);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/dup2.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD2/dup2.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/dup2.c Mon Jun 7 13:14:33 1999
***************
*** 0 ****
--- 1,13 ----
+ #include "wrap.h"
+ #include
+
+ int
+ m3_dup2(int oldd, int newd)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ result = dup2(oldd, newd);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/gethostbyaddr.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD2/gethostbyaddr.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/gethostbyaddr.c Mon Jun 7 13:14:33 1999
***************
*** 0 ****
--- 1,14 ----
+ #include "wrap.h"
+ #include
+
+ struct hostent *
+ m3_gethostbyaddr(const char *addr, int len, int type)
+ {
+ struct hostent *result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(addr);
+ result = gethostbyaddr(addr, len, type);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/gethostbyname.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD2/gethostbyname.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/gethostbyname.c Mon Jun 7 13:14:33 1999
***************
*** 0 ****
--- 1,14 ----
+ #include "wrap.h"
+ #include
+
+ struct hostent *
+ m3_gethostbyname(const char *name)
+ {
+ struct hostent *result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(name);
+ result = gethostbyname(name);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/getpeername.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD2/getpeername.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/getpeername.c Mon Jun 7 13:14:33 1999
***************
*** 0 ****
--- 1,16 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ int
+ m3_getpeername(int s, struct sockaddr *name, int *namelen)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(name);
+ MAKE_WRITABLE(namelen);
+ result = getpeername(s, name, namelen);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/getsockname.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD2/getsockname.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/getsockname.c Mon Jun 7 13:14:33 1999
***************
*** 0 ****
--- 1,16 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ int
+ m3_getsockname(int s, struct sockaddr *name, int *namelen)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(name);
+ MAKE_WRITABLE(namelen);
+ result = getsockname(s, name, namelen);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/listen.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD2/listen.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/listen.c Mon Jun 7 13:14:33 1999
***************
*** 0 ****
--- 1,14 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ int
+ m3_listen(int s, int backlog)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ result = listen(s, backlog);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/m3makefile
diff -c m3/pm3/libs/m3core/src/runtime/FreeBSD2/m3makefile:1.1.1.1 m3/pm3/libs/m3core/src/runtime/FreeBSD2/m3makefile:1.2
*** m3/pm3/libs/m3core/src/runtime/FreeBSD2/m3makefile:1.1.1.1 Thu Jan 16 16:29:56 1997
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/m3makefile Mon Jun 7 13:14:33 1999
***************
*** 13,18 ****
--- 13,44 ----
c_source ("RTThreadC")
c_source ("RTHeapDepC")
s_source ("_fpsetjmp")
+ c_source ("malloc")
+
+ % These wrappers were extracted from RTHeapDepC.c and modified slightly,
+ % in order to make it possible to support SOCKS.
+ h_source ("socksconf")
+ h_source ("wrap")
+ c_source ("accept")
+ c_source ("bind")
+ c_source ("close")
+ c_source ("connect")
+ c_source ("dup")
+ c_source ("dup2")
+ c_source ("gethostbyaddr")
+ c_source ("gethostbyname")
+ c_source ("getpeername")
+ c_source ("getsockname")
+ c_source ("listen")
+ c_source ("read")
+ c_source ("recv")
+ c_source ("recvfrom")
+ c_source ("select")
+ c_source ("send")
+ c_source ("sendto")
+ c_source ("shutdown")
+ c_source ("socket")
+ c_source ("write")
%% s_source (RTStackASM)
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/malloc.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD2/malloc.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/malloc.c Mon Jun 7 13:14:33 1999
***************
*** 0 ****
--- 1,1153 ----
+ /*
+ * ----------------------------------------------------------------------------
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * wrote this file. As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
+ * ----------------------------------------------------------------------------
+ *
+ * From FreeBSD: malloc.c,v 1.32 1997/08/31 05:59:39 phk Exp
+ * Modified for Modula-3 thread safety by jdp@polstra.com (John Polstra).
+ *
+ */
+
+ #define _THREAD_SAFE 1 /* Turn on thread safety for Modula-3 */
+
+ /*
+ * Defining EXTRA_SANITY will enable extra checks which are related
+ * to internal conditions and consistency in malloc.c. This has a
+ * noticeable runtime performance hit, and generally will not do you
+ * any good unless you fiddle with the internals of malloc or want
+ * to catch random pointer corruption as early as possible.
+ */
+ #ifndef MALLOC_EXTRA_SANITY
+ #undef MALLOC_EXTRA_SANITY
+ #endif
+
+ /*
+ * What to use for Junk. This is the byte value we use to fill with
+ * when the 'J' option is enabled.
+ */
+ #define SOME_JUNK 0xd0 /* as in "Duh" :-) */
+
+ /*
+ * The basic parameters you can tweak.
+ *
+ * malloc_pageshift pagesize = 1 << malloc_pageshift
+ * It's probably best if this is the native
+ * page size, but it doesn't have to be.
+ *
+ * malloc_minsize minimum size of an allocation in bytes.
+ * If this is too small it's too much work
+ * to manage them. This is also the smallest
+ * unit of alignment used for the storage
+ * returned by malloc/realloc.
+ *
+ */
+
+ #if defined(__FreeBSD__)
+ # if defined(__i386__)
+ # define malloc_pageshift 12U
+ # define malloc_minsize 16U
+ # endif
+ #endif /* __FreeBSD__ */
+
+ #if defined(__sparc__) && defined(sun)
+ # define malloc_pageshift 12U
+ # define malloc_minsize 16U
+ # define MAP_ANON (0)
+ static int fdzero;
+ # define MMAP_FD fdzero
+ # define INIT_MMAP() \
+ { if ((fdzero=open("/dev/zero", O_RDWR, 0000)) == -1) \
+ wrterror("open of /dev/zero"); }
+ # define MADV_FREE MADV_DONTNEED
+ #endif /* __sparc__ */
+
+ #if defined(__linux__)
+ # if defined(__i386__)
+ # define malloc_pageshift 12U
+ # define malloc_minsize 16U
+ # endif
+ #endif /* __linux__ */
+
+ #if defined(__alpha)
+ # define malloc_pageshift 13U
+ # define malloc_minsize 16U
+ #endif /* __alpha */
+
+ /* Insert your combination here... */
+ #if defined(__FOOCPU__) && defined(__BAROS__)
+ # define malloc_pageshift 12U
+ # define malloc_minsize 16U
+ #endif /* __FOOCPU__ && __BAROS__ */
+
+
+ /*
+ * No user serviceable parts behind this point.
+ */
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+
+ /*
+ * This structure describes a page worth of chunks.
+ */
+
+ struct pginfo {
+ struct pginfo *next; /* next on the free list */
+ void *page; /* Pointer to the page */
+ u_short size; /* size of this page's chunks */
+ u_short shift; /* How far to shift for this size chunks */
+ u_short free; /* How many free chunks */
+ u_short total; /* How many chunk */
+ u_int bits[1]; /* Which chunks are free */
+ };
+
+ /*
+ * This structure describes a number of free pages.
+ */
+
+ struct pgfree {
+ struct pgfree *next; /* next run of free pages */
+ struct pgfree *prev; /* prev run of free pages */
+ void *page; /* pointer to free pages */
+ void *end; /* pointer to end of free pages */
+ size_t size; /* number of bytes free */
+ };
+
+ /*
+ * How many bits per u_int in the bitmap.
+ * Change only if not 8 bits/byte
+ */
+ #define MALLOC_BITS (8*sizeof(u_int))
+
+ /*
+ * Magic values to put in the page_directory
+ */
+ #define MALLOC_NOT_MINE ((struct pginfo*) 0)
+ #define MALLOC_FREE ((struct pginfo*) 1)
+ #define MALLOC_FIRST ((struct pginfo*) 2)
+ #define MALLOC_FOLLOW ((struct pginfo*) 3)
+ #define MALLOC_MAGIC ((struct pginfo*) 4)
+
+ #ifndef malloc_pageshift
+ #define malloc_pageshift 12U
+ #endif
+
+ #ifndef malloc_minsize
+ #define malloc_minsize 16U
+ #endif
+
+ #if !defined(malloc_pagesize)
+ #define malloc_pagesize (1UL<>1)
+ #endif
+
+ /* A mask for the offset inside a page. */
+ #define malloc_pagemask ((malloc_pagesize)-1)
+
+ #define pageround(foo) (((foo) + (malloc_pagemask))&(~(malloc_pagemask)))
+ #define ptr2index(foo) (((u_long)(foo) >> malloc_pageshift)-malloc_origo)
+
+ #ifdef _THREAD_SAFE
+ extern int RT0u__inCritical; /* Flag set when in a critical region */
+ #define THREAD_LOCK() (++RT0u__inCritical)
+ #define THREAD_UNLOCK() (--RT0u__inCritical)
+ #endif
+
+ #ifndef THREAD_LOCK
+ #define THREAD_LOCK()
+ #endif
+
+ #ifndef THREAD_UNLOCK
+ #define THREAD_UNLOCK()
+ #endif
+
+ #ifndef MMAP_FD
+ #define MMAP_FD (-1)
+ #endif
+
+ #ifndef INIT_MMAP
+ #define INIT_MMAP()
+ #endif
+
+ /* This is needed at least by HP-UX 10.20 */
+ #if !defined(MAP_ANON) && defined(MAP_ANONYMOUS)
+ #define MAP_ANON MAP_ANONYMOUS
+ #endif
+
+ /* Set when initialization has been done */
+ static unsigned malloc_started;
+
+ /* Recusion flag for public interface. */
+ static int malloc_active;
+
+ /* Number of free pages we cache */
+ static unsigned malloc_cache = 16;
+
+ /* The offset from pagenumber to index into the page directory */
+ static u_long malloc_origo;
+
+ /* The last index in the page directory we care about */
+ static u_long last_index;
+
+ /* Pointer to page directory. Allocated "as if with" malloc */
+ static struct pginfo **page_dir;
+
+ /* How many slots in the page directory */
+ static unsigned malloc_ninfo;
+
+ /* Free pages line up here */
+ static struct pgfree free_list;
+
+ /* Abort(), user doesn't handle problems. */
+ static int malloc_abort;
+
+ /* Are we trying to die ? */
+ static int suicide;
+
+ /* always realloc ? */
+ static int malloc_realloc;
+
+ /* pass the kernel a hint on free pages ? */
+ static int malloc_hint = 1;
+
+ /* xmalloc behaviour ? */
+ static int malloc_xmalloc;
+
+ /* sysv behaviour for malloc(0) ? */
+ static int malloc_sysv;
+
+ /* zero fill ? */
+ static int malloc_zero;
+
+ /* junk fill ? */
+ static int malloc_junk;
+
+ #ifdef HAS_UTRACE
+
+ /* utrace ? */
+ static int malloc_utrace;
+
+ struct ut { void *p; size_t s; void *r; };
+
+ void utrace __P((struct ut *, int));
+
+ #define UTRACE(a, b, c) \
+ if (malloc_utrace) \
+ {struct ut u; u.p=a; u.s = b; u.r=c; utrace(&u, sizeof u);}
+ #else /* !HAS_UTRACE */
+ #define UTRACE(a,b,c)
+ #endif /* HAS_UTRACE */
+
+ /* my last break. */
+ static void *malloc_brk;
+
+ /* one location cache for free-list holders */
+ static struct pgfree *px;
+
+ /* compile-time options */
+ char *malloc_options;
+
+ /* Name of the current public function */
+ static char *malloc_func;
+
+ /* Macro for mmap */
+ #define MMAP(size) \
+ mmap((caddr_t)0, (size), PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, \
+ MMAP_FD, 0);
+
+ /*
+ * Necessary function declarations
+ */
+ static int extend_pgdir(u_long index);
+ static void *imalloc(size_t size);
+ static void ifree(void *ptr);
+ static void *irealloc(void *ptr, size_t size);
+
+ static void
+ wrterror(char *p)
+ {
+ char *q = " error: ";
+ write(STDERR_FILENO, malloc_func, strlen(malloc_func));
+ write(STDERR_FILENO, q, strlen(q));
+ write(STDERR_FILENO, p, strlen(p));
+ suicide = 1;
+ abort();
+ }
+
+ static void
+ wrtwarning(char *p)
+ {
+ char *q = " warning: ";
+ if (malloc_abort)
+ wrterror(p);
+ write(STDERR_FILENO, malloc_func, strlen(malloc_func));
+ write(STDERR_FILENO, q, strlen(q));
+ write(STDERR_FILENO, p, strlen(p));
+ }
+
+
+ /*
+ * Allocate a number of pages from the OS
+ */
+ static caddr_t
+ map_pages(int pages)
+ {
+ caddr_t result, tail;
+
+ result = (caddr_t)pageround((u_long)sbrk(0));
+ tail = result + (pages << malloc_pageshift);
+
+ if (brk(tail)) {
+ #ifdef EXTRA_SANITY
+ wrterror("(ES): map_pages fails\n");
+ #endif /* EXTRA_SANITY */
+ return 0;
+ }
+
+ last_index = ptr2index(tail) - 1;
+ malloc_brk = tail;
+
+ if ((last_index+1) >= malloc_ninfo && !extend_pgdir(last_index))
+ return 0;;
+
+ return result;
+ }
+
+ /*
+ * Extend page directory
+ */
+ static int
+ extend_pgdir(u_long index)
+ {
+ struct pginfo **new, **old;
+ int i, oldlen;
+
+ /* Make it this many pages */
+ i = index * sizeof *page_dir;
+ i /= malloc_pagesize;
+ i += 2;
+
+ /* remember the old mapping size */
+ oldlen = malloc_ninfo * sizeof *page_dir;
+
+ /*
+ * NOTE: we allocate new pages and copy the directory rather than tempt
+ * fate by trying to "grow" the region.. There is nothing to prevent
+ * us from accidently re-mapping space that's been allocated by our caller
+ * via dlopen() or other mmap().
+ *
+ * The copy problem is not too bad, as there is 4K of page index per
+ * 4MB of malloc arena.
+ *
+ * We can totally avoid the copy if we open a file descriptor to associate
+ * the anon mappings with. Then, when we remap the pages at the new
+ * address, the old pages will be "magically" remapped.. But this means
+ * keeping open a "secret" file descriptor.....
+ */
+
+ /* Get new pages */
+ new = (struct pginfo**) MMAP(i * malloc_pagesize);
+ if (new == (struct pginfo **)-1)
+ return 0;
+
+ /* Copy the old stuff */
+ memcpy(new, page_dir,
+ malloc_ninfo * sizeof *page_dir);
+
+ /* register the new size */
+ malloc_ninfo = i * malloc_pagesize / sizeof *page_dir;
+
+ /* swap the pointers */
+ old = page_dir;
+ page_dir = new;
+
+ /* Now free the old stuff */
+ munmap((caddr_t)old, oldlen);
+ return 1;
+ }
+
+ /*
+ * Initialize the world
+ */
+ static void
+ malloc_init ()
+ {
+ char *p, b[64];
+ int i, j;
+
+ INIT_MMAP();
+
+ #ifdef EXTRA_SANITY
+ malloc_junk = 1;
+ #endif /* EXTRA_SANITY */
+
+ for (i = 0; i < 3; i++) {
+ if (i == 0) {
+ j = readlink("/etc/malloc.conf", b, sizeof b - 1);
+ if (j <= 0)
+ continue;
+ b[j] = '\0';
+ p = b;
+ } else if (i == 1) {
+ p = getenv("MALLOC_OPTIONS");
+ } else {
+ p = malloc_options;
+ }
+ for (; p && *p; p++) {
+ switch (*p) {
+ case '>': malloc_cache <<= 1; break;
+ case '<': malloc_cache >>= 1; break;
+ case 'a': malloc_abort = 0; break;
+ case 'A': malloc_abort = 1; break;
+ case 'h': malloc_hint = 0; break;
+ case 'H': malloc_hint = 1; break;
+ case 'r': malloc_realloc = 0; break;
+ case 'R': malloc_realloc = 1; break;
+ case 'j': malloc_junk = 0; break;
+ case 'J': malloc_junk = 1; break;
+ #ifdef HAS_UTRACE
+ case 'u': malloc_utrace = 0; break;
+ case 'U': malloc_utrace = 1; break;
+ #endif
+ case 'v': malloc_sysv = 0; break;
+ case 'V': malloc_sysv = 1; break;
+ case 'x': malloc_xmalloc = 0; break;
+ case 'X': malloc_xmalloc = 1; break;
+ case 'z': malloc_zero = 0; break;
+ case 'Z': malloc_zero = 1; break;
+ default:
+ j = malloc_abort;
+ malloc_abort = 0;
+ wrtwarning("unknown char in MALLOC_OPTIONS\n");
+ malloc_abort = j;
+ break;
+ }
+ }
+ }
+
+ UTRACE(0, 0, 0);
+
+ /*
+ * We want junk in the entire allocation, and zero only in the part
+ * the user asked for.
+ */
+ if (malloc_zero)
+ malloc_junk=1;
+
+ /*
+ * If we run with junk (or implicitly from above: zero), we want to
+ * force realloc() to get new storage, so we can DTRT with it.
+ */
+ if (malloc_junk)
+ malloc_realloc=1;
+
+ /* Allocate one page for the page directory */
+ page_dir = (struct pginfo **) MMAP(malloc_pagesize);
+
+ if (page_dir == (struct pginfo **) -1)
+ wrterror("mmap(2) failed, check limits.\n");
+
+ /*
+ * We need a maximum of malloc_pageshift buckets, steal these from the
+ * front of the page_directory;
+ */
+ malloc_origo = ((u_long)pageround((u_long)sbrk(0))) >> malloc_pageshift;
+ malloc_origo -= malloc_pageshift;
+
+ malloc_ninfo = malloc_pagesize / sizeof *page_dir;
+
+ /* Recalculate the cache size in bytes, and make sure it's nonzero */
+
+ if (!malloc_cache)
+ malloc_cache++;
+
+ malloc_cache <<= malloc_pageshift;
+
+ /*
+ * This is a nice hack from Kaleb Keithly (kaleb@x.org).
+ * We can sbrk(2) further back when we keep this on a low address.
+ */
+ px = (struct pgfree *) imalloc (sizeof *px);
+
+ /* Been here, done that */
+ malloc_started++;
+ }
+
+ /*
+ * Allocate a number of complete pages
+ */
+ static void *
+ malloc_pages(size_t size)
+ {
+ void *p, *delay_free = 0;
+ int i;
+ struct pgfree *pf;
+ u_long index;
+
+ size = pageround(size);
+
+ p = 0;
+
+ /* Look for free pages before asking for more */
+ for(pf = free_list.next; pf; pf = pf->next) {
+
+ #ifdef EXTRA_SANITY
+ if (pf->size & malloc_pagemask)
+ wrterror("(ES): junk length entry on free_list\n");
+ if (!pf->size)
+ wrterror("(ES): zero length entry on free_list\n");
+ if (pf->page == pf->end)
+ wrterror("(ES): zero entry on free_list\n");
+ if (pf->page > pf->end)
+ wrterror("(ES): sick entry on free_list\n");
+ if ((void*)pf->page >= (void*)sbrk(0))
+ wrterror("(ES): entry on free_list past brk\n");
+ if (page_dir[ptr2index(pf->page)] != MALLOC_FREE)
+ wrterror("(ES): non-free first page on free-list\n");
+ if (page_dir[ptr2index(pf->end)-1] != MALLOC_FREE)
+ wrterror("(ES): non-free last page on free-list\n");
+ #endif /* EXTRA_SANITY */
+
+ if (pf->size < size)
+ continue;
+
+ if (pf->size == size) {
+ p = pf->page;
+ if (pf->next)
+ pf->next->prev = pf->prev;
+ pf->prev->next = pf->next;
+ delay_free = pf;
+ break;
+ }
+
+ p = pf->page;
+ pf->page = (char *)pf->page + size;
+ pf->size -= size;
+ break;
+ }
+
+ #ifdef EXTRA_SANITY
+ if (p && page_dir[ptr2index(p)] != MALLOC_FREE)
+ wrterror("(ES): allocated non-free page on free-list\n");
+ #endif /* EXTRA_SANITY */
+
+ size >>= malloc_pageshift;
+
+ /* Map new pages */
+ if (!p)
+ p = map_pages(size);
+
+ if (p) {
+
+ index = ptr2index(p);
+ page_dir[index] = MALLOC_FIRST;
+ for (i=1;ibits[0] *
+ (((malloc_pagesize >> bits)+MALLOC_BITS-1) / MALLOC_BITS);
+
+ /* Don't waste more than two chunks on this */
+ if ((1<<(bits)) <= l+l) {
+ bp = (struct pginfo *)pp;
+ } else {
+ bp = (struct pginfo *)imalloc(l);
+ if (!bp) {
+ ifree(pp);
+ return 0;
+ }
+ }
+
+ bp->size = (1<shift = bits;
+ bp->total = bp->free = malloc_pagesize >> bits;
+ bp->page = pp;
+
+ /* set all valid bits in the bitmap */
+ k = bp->total;
+ i = 0;
+
+ /* Do a bunch at a time */
+ for(;k-i >= MALLOC_BITS; i += MALLOC_BITS)
+ bp->bits[i / MALLOC_BITS] = ~0;
+
+ for(; i < k; i++)
+ bp->bits[i/MALLOC_BITS] |= 1<<(i%MALLOC_BITS);
+
+ if (bp == bp->page) {
+ /* Mark the ones we stole for ourselves */
+ for(i=0;l > 0;i++) {
+ bp->bits[i/MALLOC_BITS] &= ~(1<<(i%MALLOC_BITS));
+ bp->free--;
+ bp->total--;
+ l -= (1 << bits);
+ }
+ }
+
+ /* MALLOC_LOCK */
+
+ page_dir[ptr2index(pp)] = bp;
+
+ bp->next = page_dir[bits];
+ page_dir[bits] = bp;
+
+ /* MALLOC_UNLOCK */
+
+ return 1;
+ }
+
+ /*
+ * Allocate a fragment
+ */
+ static void *
+ malloc_bytes(size_t size)
+ {
+ int i,j;
+ u_int u;
+ struct pginfo *bp;
+ int k;
+ u_int *lp;
+
+ /* Don't bother with anything less than this */
+ if (size < malloc_minsize)
+ size = malloc_minsize;
+
+ /* Find the right bucket */
+ j = 1;
+ i = size-1;
+ while (i >>= 1)
+ j++;
+
+ /* If it's empty, make a page more of that size chunks */
+ if (!page_dir[j] && !malloc_make_chunks(j))
+ return 0;
+
+ bp = page_dir[j];
+
+ /* Find first word of bitmap which isn't empty */
+ for (lp = bp->bits; !*lp; lp++)
+ ;
+
+ /* Find that bit, and tweak it */
+ u = 1;
+ k = 0;
+ while (!(*lp & u)) {
+ u += u;
+ k++;
+ }
+ *lp ^= u;
+
+ /* If there are no more free, remove from free-list */
+ if (!--bp->free) {
+ page_dir[j] = bp->next;
+ bp->next = 0;
+ }
+
+ /* Adjust to the real offset of that chunk */
+ k += (lp-bp->bits)*MALLOC_BITS;
+ k <<= bp->shift;
+
+ if (malloc_junk)
+ memset((u_char*)bp->page + k, SOME_JUNK, bp->size);
+
+ return (u_char *)bp->page + k;
+ }
+
+ /*
+ * Allocate a piece of memory
+ */
+ static void *
+ imalloc(size_t size)
+ {
+ void *result;
+
+ if (suicide)
+ abort();
+
+ if ((size + malloc_pagesize) < size) /* Check for overflow */
+ result = 0;
+ else if (size <= malloc_maxsize)
+ result = malloc_bytes(size);
+ else
+ result = malloc_pages(size);
+
+ if (malloc_abort && !result)
+ wrterror("allocation failed.\n");
+
+ if (malloc_zero && result)
+ memset(result, 0, size);
+
+ return result;
+ }
+
+ /*
+ * Change the size of an allocation.
+ */
+ static void *
+ irealloc(void *ptr, size_t size)
+ {
+ void *p;
+ u_long osize, index;
+ struct pginfo **mp;
+ int i;
+
+ if (suicide)
+ abort();
+
+ index = ptr2index(ptr);
+
+ if (index < malloc_pageshift) {
+ wrtwarning("junk pointer, too low to make sense.\n");
+ return 0;
+ }
+
+ if (index > last_index) {
+ wrtwarning("junk pointer, too high to make sense.\n");
+ return 0;
+ }
+
+ mp = &page_dir[index];
+
+ if (*mp == MALLOC_FIRST) { /* Page allocation */
+
+ /* Check the pointer */
+ if ((u_long)ptr & malloc_pagemask) {
+ wrtwarning("modified (page-) pointer.\n");
+ return 0;
+ }
+
+ /* Find the size in bytes */
+ for (osize = malloc_pagesize; *++mp == MALLOC_FOLLOW;)
+ osize += malloc_pagesize;
+
+ if (!malloc_realloc && /* unless we have to, */
+ size <= osize && /* .. or are too small, */
+ size > (osize - malloc_pagesize)) { /* .. or can free a page, */
+ return ptr; /* don't do anything. */
+ }
+
+ } else if (*mp >= MALLOC_MAGIC) { /* Chunk allocation */
+
+ /* Check the pointer for sane values */
+ if (((u_long)ptr & ((*mp)->size-1))) {
+ wrtwarning("modified (chunk-) pointer.\n");
+ return 0;
+ }
+
+ /* Find the chunk index in the page */
+ i = ((u_long)ptr & malloc_pagemask) >> (*mp)->shift;
+
+ /* Verify that it isn't a free chunk already */
+ if ((*mp)->bits[i/MALLOC_BITS] & (1<<(i%MALLOC_BITS))) {
+ wrtwarning("chunk is already free.\n");
+ return 0;
+ }
+
+ osize = (*mp)->size;
+
+ if (!malloc_realloc && /* Unless we have to, */
+ size < osize && /* ..or are too small, */
+ (size > osize/2 || /* ..or could use a smaller size, */
+ osize == malloc_minsize)) { /* ..(if there is one) */
+ return ptr; /* ..Don't do anything */
+ }
+
+ } else {
+ wrtwarning("pointer to wrong page.\n");
+ return 0;
+ }
+
+ p = imalloc(size);
+
+ if (p) {
+ /* copy the lesser of the two sizes, and free the old one */
+ if (!size || !osize)
+ ;
+ else if (osize < size)
+ memcpy(p, ptr, osize);
+ else
+ memcpy(p, ptr, size);
+ ifree(ptr);
+ }
+ return p;
+ }
+
+ /*
+ * Free a sequence of pages
+ */
+
+ static __inline__ void
+ free_pages(void *ptr, int index, struct pginfo *info)
+ {
+ int i;
+ struct pgfree *pf, *pt=0;
+ u_long l;
+ void *tail;
+
+ if (info == MALLOC_FREE) {
+ wrtwarning("page is already free.\n");
+ return;
+ }
+
+ if (info != MALLOC_FIRST) {
+ wrtwarning("pointer to wrong page.\n");
+ return;
+ }
+
+ if ((u_long)ptr & malloc_pagemask) {
+ wrtwarning("modified (page-) pointer.\n");
+ return;
+ }
+
+ /* Count how many pages and mark them free at the same time */
+ page_dir[index] = MALLOC_FREE;
+ for (i = 1; page_dir[index+i] == MALLOC_FOLLOW; i++)
+ page_dir[index + i] = MALLOC_FREE;
+
+ l = i << malloc_pageshift;
+
+ if (malloc_junk)
+ memset(ptr, SOME_JUNK, l);
+
+ #ifdef MADV_FREE
+ if (malloc_hint)
+ madvise(ptr, l, MADV_FREE);
+ #endif
+
+ tail = (char *)ptr+l;
+
+ /* add to free-list */
+ if (!px)
+ px = imalloc(sizeof *pt); /* This cannot fail... */
+ px->page = ptr;
+ px->end = tail;
+ px->size = l;
+ if (!free_list.next) {
+
+ /* Nothing on free list, put this at head */
+ px->next = free_list.next;
+ px->prev = &free_list;
+ free_list.next = px;
+ pf = px;
+ px = 0;
+
+ } else {
+
+ /* Find the right spot, leave pf pointing to the modified entry. */
+ tail = (char *)ptr+l;
+
+ for(pf = free_list.next; pf->end < ptr && pf->next; pf = pf->next)
+ ; /* Race ahead here */
+
+ if (pf->page > tail) {
+ /* Insert before entry */
+ px->next = pf;
+ px->prev = pf->prev;
+ pf->prev = px;
+ px->prev->next = px;
+ pf = px;
+ px = 0;
+ } else if (pf->end == ptr ) {
+ /* Append to the previous entry */
+ pf->end = (char *)pf->end + l;
+ pf->size += l;
+ if (pf->next && pf->end == pf->next->page ) {
+ /* And collapse the next too. */
+ pt = pf->next;
+ pf->end = pt->end;
+ pf->size += pt->size;
+ pf->next = pt->next;
+ if (pf->next)
+ pf->next->prev = pf;
+ }
+ } else if (pf->page == tail) {
+ /* Prepend to entry */
+ pf->size += l;
+ pf->page = ptr;
+ } else if (!pf->next) {
+ /* Append at tail of chain */
+ px->next = 0;
+ px->prev = pf;
+ pf->next = px;
+ pf = px;
+ px = 0;
+ } else {
+ wrterror("freelist is destroyed.\n");
+ }
+ }
+
+ /* Return something to OS ? */
+ if (!pf->next && /* If we're the last one, */
+ pf->size > malloc_cache && /* ..and the cache is full, */
+ pf->end == malloc_brk && /* ..and none behind us, */
+ malloc_brk == sbrk(0)) { /* ..and it's OK to do... */
+
+ /*
+ * Keep the cache intact. Notice that the '>' above guarantees that
+ * the pf will always have at least one page afterwards.
+ */
+ pf->end = (char *)pf->page + malloc_cache;
+ pf->size = malloc_cache;
+
+ brk(pf->end);
+ malloc_brk = pf->end;
+
+ index = ptr2index(pf->end);
+ last_index = index - 1;
+
+ for(i=index;i <= last_index;)
+ page_dir[i++] = MALLOC_NOT_MINE;
+
+ /* XXX: We could realloc/shrink the pagedir here I guess. */
+ }
+ if (pt)
+ ifree(pt);
+ }
+
+ /*
+ * Free a chunk, and possibly the page it's on, if the page becomes empty.
+ */
+
+ static __inline__ void
+ free_bytes(void *ptr, int index, struct pginfo *info)
+ {
+ int i;
+ struct pginfo **mp;
+ void *vp;
+
+ /* Find the chunk number on the page */
+ i = ((u_long)ptr & malloc_pagemask) >> info->shift;
+
+ if (((u_long)ptr & (info->size-1))) {
+ wrtwarning("modified (chunk-) pointer.\n");
+ return;
+ }
+
+ if (info->bits[i/MALLOC_BITS] & (1<<(i%MALLOC_BITS))) {
+ wrtwarning("chunk is already free.\n");
+ return;
+ }
+
+ if (malloc_junk)
+ memset(ptr, SOME_JUNK, info->size);
+
+ info->bits[i/MALLOC_BITS] |= 1<<(i%MALLOC_BITS);
+ info->free++;
+
+ mp = page_dir + info->shift;
+
+ if (info->free == 1) {
+
+ /* Page became non-full */
+
+ mp = page_dir + info->shift;
+ /* Insert in address order */
+ while (*mp && (*mp)->next && (*mp)->next->page < info->page)
+ mp = &(*mp)->next;
+ info->next = *mp;
+ *mp = info;
+ return;
+ }
+
+ if (info->free != info->total)
+ return;
+
+ /* Find & remove this page in the queue */
+ while (*mp != info) {
+ mp = &((*mp)->next);
+ #ifdef EXTRA_SANITY
+ if (!*mp)
+ wrterror("(ES): Not on queue\n");
+ #endif /* EXTRA_SANITY */
+ }
+ *mp = info->next;
+
+ /* Free the page & the info structure if need be */
+ page_dir[ptr2index(info->page)] = MALLOC_FIRST;
+ vp = info->page; /* Order is important ! */
+ if(vp != (void*)info)
+ ifree(info);
+ ifree(vp);
+ }
+
+ static void
+ ifree(void *ptr)
+ {
+ struct pginfo *info;
+ int index;
+
+ /* This is legal */
+ if (!ptr)
+ return;
+
+ if (!malloc_started) {
+ wrtwarning("malloc() has never been called.\n");
+ return;
+ }
+
+ /* If we're already sinking, don't make matters any worse. */
+ if (suicide)
+ return;
+
+ index = ptr2index(ptr);
+
+ if (index < malloc_pageshift) {
+ wrtwarning("junk pointer, too low to make sense.\n");
+ return;
+ }
+
+ if (index > last_index) {
+ wrtwarning("junk pointer, too high to make sense.\n");
+ return;
+ }
+
+ info = page_dir[index];
+
+ if (info < MALLOC_MAGIC)
+ free_pages(ptr, index, info);
+ else
+ free_bytes(ptr, index, info);
+ return;
+ }
+
+ /*
+ * These are the public exported interface routines.
+ */
+
+
+ void *
+ malloc(size_t size)
+ {
+ register void *r;
+
+ malloc_func = " in malloc():";
+ THREAD_LOCK();
+ if (malloc_active++) {
+ wrtwarning("recursive call.\n");
+ malloc_active--;
+ return (0);
+ }
+ if (!malloc_started)
+ malloc_init();
+ if (malloc_sysv && !size)
+ r = 0;
+ else
+ r = imalloc(size);
+ UTRACE(0, size, r);
+ malloc_active--;
+ THREAD_UNLOCK();
+ if (malloc_xmalloc && !r)
+ wrterror("out of memory.\n");
+ return (r);
+ }
+
+ void
+ free(void *ptr)
+ {
+ malloc_func = " in free():";
+ THREAD_LOCK();
+ if (malloc_active++) {
+ wrtwarning("recursive call.\n");
+ malloc_active--;
+ return;
+ }
+ ifree(ptr);
+ UTRACE(ptr, 0, 0);
+ malloc_active--;
+ THREAD_UNLOCK();
+ return;
+ }
+
+ void *
+ realloc(void *ptr, size_t size)
+ {
+ register void *r;
+
+ malloc_func = " in realloc():";
+ THREAD_LOCK();
+ if (malloc_active++) {
+ wrtwarning("recursive call.\n");
+ malloc_active--;
+ return (0);
+ }
+ if (ptr && !malloc_started) {
+ wrtwarning("malloc() has never been called.\n");
+ ptr = 0;
+ }
+ if (!malloc_started)
+ malloc_init();
+ if (malloc_sysv && !size) {
+ ifree(ptr);
+ r = 0;
+ } else if (!ptr) {
+ r = imalloc(size);
+ } else {
+ r = irealloc(ptr, size);
+ }
+ UTRACE(ptr, size, r);
+ malloc_active--;
+ THREAD_UNLOCK();
+ if (malloc_xmalloc && !r)
+ wrterror("out of memory.\n");
+ return (r);
+ }
+
+ void *
+ calloc(size_t num, size_t size)
+ {
+ register void *r;
+
+ size *= num;
+ r = malloc(size);
+ if (r)
+ memset(r, 0, size);
+ return (r);
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/read.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD2/read.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/read.c Mon Jun 7 13:14:33 1999
***************
*** 0 ****
--- 1,15 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ ssize_t
+ m3_read(int d, void *buf, size_t nbytes)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(buf);
+ result = read(d, buf, nbytes);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/recv.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD2/recv.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/recv.c Mon Jun 7 13:14:33 1999
***************
*** 0 ****
--- 1,15 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ ssize_t
+ m3_recv(int s, void *buf, size_t len, int flags)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(buf);
+ result = recv(s, buf, len, flags);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/recvfrom.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD2/recvfrom.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/recvfrom.c Mon Jun 7 13:14:33 1999
***************
*** 0 ****
--- 1,18 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ ssize_t
+ m3_recvfrom(int s, void *buf, size_t len, int flags,
+ struct sockaddr *from, int *fromlen)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(buf);
+ MAKE_WRITABLE(from);
+ MAKE_WRITABLE(fromlen);
+ result = recvfrom(s, buf, len, flags, from, fromlen);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/select.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD2/select.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/select.c Mon Jun 7 13:14:33 1999
***************
*** 0 ****
--- 1,20 ----
+ #include "wrap.h"
+ #include
+ #include
+ #include
+
+ int
+ m3_select(int nfds, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, struct timeval *timeout)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(readfds);
+ MAKE_WRITABLE(writefds);
+ MAKE_WRITABLE(exceptfds);
+ MAKE_READABLE(timeout);
+ result = select(nfds, readfds, writefds, exceptfds, timeout);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/send.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD2/send.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/send.c Mon Jun 7 13:14:33 1999
***************
*** 0 ****
--- 1,15 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ ssize_t
+ m3_send(int s, const void *msg, size_t len, int flags)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(msg);
+ result = send(s, msg, len, flags);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/sendto.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD2/sendto.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/sendto.c Mon Jun 7 13:14:34 1999
***************
*** 0 ****
--- 1,17 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ ssize_t
+ m3_sendto(int s, const void *msg, size_t len, int flags,
+ const struct sockaddr *to, int tolen)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(msg);
+ MAKE_READABLE(to);
+ result = sendto(s, msg, len, flags, to, tolen);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/shutdown.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD2/shutdown.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/shutdown.c Mon Jun 7 13:14:34 1999
***************
*** 0 ****
--- 1,14 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ int
+ m3_shutdown(int s, int how)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ result = shutdown(s, how);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/socket.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD2/socket.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/socket.c Mon Jun 7 13:14:34 1999
***************
*** 0 ****
--- 1,14 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ int
+ m3_socket(int domain, int type, int protocol)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ result = socket(domain, type, protocol);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/socksconf.h
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD2/socksconf.h:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/socksconf.h Mon Jun 7 13:14:34 1999
***************
*** 0 ****
--- 1,6 ----
+ /*
+ * Define 0 or 1 of these, to select the variety of SOCKS support you want.
+ */
+ #undef HPSOCKS
+ #undef SOCKS4
+ #undef SOCKS5
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/wrap.h
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD2/wrap.h:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/wrap.h Mon Jun 7 13:14:34 1999
***************
*** 0 ****
--- 1,61 ----
+ #include "socksconf.h"
+
+ #if defined(HPSOCKS) /* { */
+ #define accept Raccept
+ #define bind Rxbind
+ #define close Rclose
+ #define connect Rconnect
+ #define dup Rdup
+ #define dup2 Rdup2
+ #define gethostbyaddr Rgethostbyaddr
+ #define gethostbyname Rgethostbyname
+ #define getpeername Rgetpeername
+ #define getsockname Rgetsockname
+ #define listen Rlisten
+ #define recv Rrecv
+ #define recvfrom Rrecvfrom
+ #define send Rsend
+ #define sendto Rsendto
+ #define shutdown Rshutdown
+ #define socket Rsocket
+ #elif defined(SOCKS4) /* } { */
+ #define accept Raccept
+ #define bind Rbind
+ #define connect Rconnect
+ #define getpeername Rgetpeername
+ #define getsockname Rgetsockname
+ #define listen Rlisten
+ #define select Rselect
+ #elif defined(SOCKS5) /* } { */
+ #define accept SOCKSaccept
+ #define bind SOCKSbind
+ #define close SOCKSclose
+ #define connect SOCKSconnect
+ #define dup SOCKSdup
+ #define dup2 SOCKSdup2
+ #define fclose SOCKSfclose
+ #define gethostbyname SOCKSgethostbyname
+ #define getpeername SOCKSgetpeername
+ #define getsockname SOCKSgetsockname
+ #define listen SOCKSlisten
+ #define read SOCKSread
+ #define recv SOCKSrecv
+ #define recvfrom SOCKSrecvfrom
+ #define rresvport SOCKSrresvport
+ #define select SOCKSselect
+ #define send SOCKSsend
+ #define sendto SOCKSsendto
+ #define shutdown SOCKSshutdown
+ #define write SOCKSwrite
+ #endif /* } */
+
+ extern int RT0u__inCritical;
+ #define ENTER_CRITICAL RT0u__inCritical++
+ #define EXIT_CRITICAL RT0u__inCritical--
+
+ static char RTHeapDepC__c;
+ #define MAKE_READABLE(x) \
+ if ((int)x) { RTHeapDepC__c = *(char*)(x); }
+
+ #define MAKE_WRITABLE(x) \
+ if ((int)x) { *(char*)(x) = RTHeapDepC__c = *(char*)(x); }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD2/write.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD2/write.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD2/write.c Mon Jun 7 13:14:34 1999
***************
*** 0 ****
--- 1,15 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ size_t
+ m3_write(int fd, const void *buf, int nbytes)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(buf);
+ result = write(fd, buf, nbytes);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/COPYRIGHT
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/COPYRIGHT:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/COPYRIGHT Mon Jun 7 13:14:38 1999
***************
*** 0 ****
--- 1,93 ----
+
+ Digital License Agreement
+
+ SRC Modula-3
+
+ 1. Grant Of License. Digital Equipment Corporation, having a principal
+ office at 146 Main Street, Maynard, MA 01754 ("DIGITAL") grants to
+ you ("LICENSEE") the non-exclusive, non-transferable, royalty free
+ right to use, modify, reproduce and distribute SRC Modula-3 ("SOFTWARE")
+ subject to the terms set forth herein. Any distribution of SOFTWARE
+ shall include this Digital License Agreement in human readable form.
+
+ 2. Title to Intellectual Property and Software. Subject to the limited
+ rights and licenses granted under this License Agreement, all rights,
+ title and interests including patent, copyright, and trademark rights
+ in SOFTWARE are and shall remain vested in DIGITAL to the exclusion
+ of LICENSEE. DIGITAL represents and warrants that DIGITAL has the
+ legal right to grant such licenses as are expressly granted under
+ this Agreement.
+
+ 3. Copyright. The SOFTWARE is owned by DIGITAL or its suppliers and is
+ protected by United States copyright laws and international treaty
+ provisions. Therefore, you must treat the SOFTWARE like any other
+ copyrighted material (e.g., a book or musical recording) except
+ that you may use the SOFTWARE as provided in this Digital License
+ Agreement.
+
+ 4. Improvements. LICENSEE hereby grants to DIGITAL a non-exclusive,
+ non-transferable, royalty free right to use, modify, reproduce
+ and distribute with the right to sublicense at any tier, any
+ improvements, enhancements, extensions, or modifications that
+ LICENSEE make to SOFTWARE, provided such are returned to DIGITAL
+ by LICENSEE.
+
+ 5. DISCLAIMER OF WARRANTY. Because the SOFTWARE is a research work and
+ not a released product, it is provided "AS IS" WITHOUT WARRANTY OF ANY
+ KIND AND WITHOUT ANY SUPPORT SERVICES. EXCEPT AS SPECIFICALLY PROVIDED
+ ABOVE IN SECTION 2, DIGITAL FURTHER DISCLAIMS ALL OTHER EXPRESS OR
+ IMPLIED WARRANTIES OF MERCHANTABILITY OR OF FITNESS FOR A PARTICULAR
+ PURPOSE. THE ENTIRE RISK ARISING OUT OF THE USE OR PERFORMANCE OF
+ THE SOFTWARE REMAINS WITH YOU.
+
+ 6. Limitation of Liability. IN NO EVENT SHALL DIGITAL OR ITS SUPPLIERS BE
+ LIABLE IN AN AMOUNT THAT EXCEEDS THE LICENSE FEE PAID BY LICENSEE FOR
+ ANY DAMAGES (INCLUDING, WITH LIMITATION, DAMAGES FOR LOSS OF BUSINESS
+ PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER
+ PECUNIARY LOSS), REGARDLESS OF THE FORM OF CLAIM OR ACTIONS, ARISING
+ OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE OR DOCUMENTATION,
+ EVEN IF DIGITAL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+ BECAUSE SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY
+ FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT
+ APPLY TO YOU.
+
+ 7. Acknowledgement of Allocation of Risk. LICENSEE acknowledges and agrees
+ that the fees charged by DIGITAL in this Agreement reflect the allocation
+ of risks provided by the foregoing limitation of liability. LICENSEE
+ acknowledges and represents that it has read and understands these
+ allocations of risk limiting the liability of DIGITAL and that it
+ understands that a modification of the allocation of risks set forth
+ in this agreement would affect the fees charged by DIGITAL, and that
+ LICENSEE, in consideration of such fees, agrees to such allocations
+ of risk.
+
+ 8. LICENSEE INDEMNIFICATION. LICENSEE SHALL INDEMNIFY DIGITAL AGAINST
+ ALL COSTS AND DAMAGE JUDGEMENTS, INCLUDING ATTORNEY'S FEES AND COSTS
+ OF DEFENSE, INCURRED BECAUSE OF CLAIMS OF DAMAGE ARISING FROM LICENSEE'S
+ POSSESSION OR USE OR INABILITY TO USE SOFTWARE.
+
+ 9. GOVERNMENT RESTRICTED RIGHTS. The SOFTWARE and documentation are provided
+ with RESTRICTED RIGHTS. Use duplication, or disclosure by the Government
+ is subject restrictions as set forth in subparagraph (c)(1)(ii) of The
+ Rights in Technical Data and Computer Software clause in DFARS
+ 252.227-7013, or subparagraphs (c)(i) and (2) of the Commercial Computer
+ Software -- Restricted Rights at 48 CFR 52.227-19, as applicable.
+ Manufacturer is Digital Equipment Corporation, 130 Lytton Avenue,
+ Palo Alto, CA 94301-1044.
+
+ 10. Severability. If any provision of the Agreement is held illegal or
+ unenforceable by any court of competent jurisdiction, such provision
+ shall be deemed separable from the remaining provisions of this Agreement
+ and shall not affect or impair the validity or enforceability of the
+ remaining provisions of this Agreement.
+
+ 11. Governing Law. This Agreement is governed by the laws of the
+ Commonwealth of Massachusetts.
+
+ 12. Publicity. You my not use the name of DIGITAL in any advertisement,
+ press release or other publicity with reference to SRC Modula-3
+ without prior written consent of DIGITAL.
+
+ 13. Should you have any questions concerning this Agreement, or if you
+ desire to contact Digital for any reason, please do so via E-mail:
+ M3-REQUEST@SRC.DEC.COM.
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/RTHeapDep.m3
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/RTHeapDep.m3:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/RTHeapDep.m3 Mon Jun 7 13:14:38 1999
***************
*** 0 ****
--- 1,186 ----
+ (* Copyright (C) 1994, Digital Equipment Corporation *)
+ (* All rights reserved. *)
+ (* See the file COPYRIGHT for a full description. *)
+ (* *)
+ (*| Last modified on Fri Jan 20 09:41:09 PST 1995 by kalsow *)
+ (*| modified on Mon Oct 31 00:04:38 MET 1994 by Olaf Wagner *)
+ (*| 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;
+ defaultSIGSEGV: Usignal.SignalHandler := NIL; (* previous handler *)
+ defaultSIGBUS: 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 = n * BytesPerPage *>
+ *)
+ <* 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
+ vec := Usignal.struct_sigvec{
+ sv_handler := Fault, sv_mask :=
+ Word.LeftShift(1, Usignal.SIGVTALRM - 1), sv_flags := 0};
+ ovec: Usignal.struct_sigvec;
+ ret := Usignal.sigvec(Usignal.SIGSEGV, vec, ovec);
+ vecb := Usignal.struct_sigvec{
+ sv_handler := Fault, sv_mask :=
+ Word.LeftShift(1, Usignal.SIGVTALRM - 1), sv_flags := 0};
+ ovecb: Usignal.struct_sigvec;
+ retb := Usignal.sigvec(Usignal.SIGBUS, vecb, ovecb);
+ BEGIN
+ <* ASSERT ret = 0 *>
+ <* ASSERT retb = 0 *>
+ defaultSIGSEGV := ovec.sv_handler;
+ defaultSIGBUS := ovecb.sv_handler;
+ END;
+
+ (* establish signal handler for all other signals that dump core, if no
+ handler exists *)
+ PROCEDURE OverrideDefault (sig: Ctypes.int) =
+ VAR
+ vec := Usignal.struct_sigvec{
+ sv_handler := Core, sv_mask :=
+ Word.LeftShift(1, Usignal.SIGVTALRM - 1), sv_flags := 0};
+ ovec: Usignal.struct_sigvec;
+ ret := Usignal.sigvec(sig, vec, ovec);
+ BEGIN
+ <* ASSERT ret = 0 *>
+ IF ovec.sv_handler # Usignal.SIG_DFL THEN
+ ret := Usignal.sigvec(sig, ovec, 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.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;
+ code: Ctypes.int;
+ scp : UNTRACED REF Usignal.struct_sigcontext) =
+ VAR sf_addr_addr: UNTRACED REF ARRAY[0..1] OF ADDRESS;
+ sf_addr : ADDRESS;
+ (*
+ * Signal frame of FreeBSD 1.1.5
+ *
+ * struct sigframe {
+ * int sf_signum;
+ * int sf_code;
+ * struct sigcontext *sf_scp;
+ * char *sf_addr; <-- this is the faulting address
+ * sig_t sf_handler;
+ * struct sigcontext sf_sc; <-- this address is passed in scp
+ * };
+ *)
+
+ BEGIN
+ sf_addr_addr := scp - ( 2 * BYTESIZE(ADDRESS));
+ sf_addr := sf_addr_addr[0];
+ IF scp # NIL AND RTHeapRep.Fault(sf_addr) THEN
+ RETURN;
+ END;
+ IF defaultSIGSEGV = Usignal.SIG_IGN THEN RETURN; END;
+ IF defaultSIGSEGV = Usignal.SIG_DFL THEN
+ Core(sig, code, scp);
+ ELSE
+ defaultSIGSEGV(sig, code, scp);
+ 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 *> code: Ctypes.int;
+ <* UNUSED *> scp : UNTRACED REF Usignal.struct_sigcontext) =
+ VAR
+ ovec: Usignal.struct_sigvec;
+ vec := Usignal.struct_sigvec{sv_handler := Usignal.SIG_DFL,
+ sv_mask := 0, sv_flags := 0};
+ BEGIN
+ INC(RT0u.inCritical);
+ IF NOT dumped_core THEN
+ dumped_core := TRUE;
+ EVAL RTHeapRep.Crash(); (* clean up the heap *)
+ EVAL Usignal.sigvec(sig, vec, 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.
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/RTHeapDepC.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/RTHeapDepC.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/RTHeapDepC.c Mon Jun 7 13:14:38 1999
***************
*** 0 ****
--- 1,1391 ----
+ /* Copyright (C) 1992, Digital Equipment Corporation */
+ /* All rights reserved. */
+ /* See the file COPYRIGHT for a full description. */
+
+ /* modified on Tue Feb 2 11:15:57 PST 1993 by jdd */
+
+ /* This is RTHeapDepC.c for FreeBSD running on 386/486 processors. */
+ /*
+ * ow Sat Oct 29 14:10:19 MET 1994
+ * ow Sun Nov 6 16:39:26 MET 1994
+ * ow Sun Dec 4 17:58:49 1994 changes for FreeBSD 2.0
+ *
+ * I just tried to check the calls implemented for Ultrix,
+ * (almost) nothing else has been changed or added.
+ * So be careful to use any other system calls, some are
+ * probably missing.
+ */
+ /* This file implements wrappers for almost all Ultrix system calls
+ that take pointers as arguments. These wrappers allow the system
+ calls to take arguments that might point to the traced heap, which
+ may be VM-protected in the Ultrix implementation of the collector.
+ The wrappers read and write the referents of all pointers about to
+ passed to the system call, which ensures that the pages are not
+ protected when the call is made.
+
+ Each wrapper is a critical section, with RT0u__inCritical non-zero,
+ so that another thread cannot cause the pages to become reprotected
+ before the system call is performed.
+
+ A few system calls are not handled here, or are handled only
+ partially. This restricts the system calls that can be made from
+ Modula-3, or from libraries that are passed pointers into the
+ Modula-3 traced heap. These system calls are:
+
+ 1) sigvec. Sigvec takes 3 arguments, but passes 4 to the kernel.
+ The extra argument is the address of the sigtramp code, which is
+ copyrighted. The sigtramp code appears in the the standard .o
+ file that also defines sigvec, so that sigvec cannot be
+ redefined here without including sigtramp. Rewriting sigtramp
+ seemed too error-prone, so sigvec is not supported here, meaning
+ that sigvec cannot be called with arguments on the heap.
+
+ 2) syscall. Implementing syscall would require a huge case
+ statement, with one case per system call. This seemed too
+ error-prone, so syscall cannot take arguments that point into
+ the traced heap.
+
+ 3) ioctl. Ioctl's third argument may be a pointer, and some device
+ drivers might interpret the referent as containing more
+ pointers. These second-level pointers are not handled here, so
+ they must not point into the traced heap if they exist.
+ Handling this problem in general is impossible, since the set of
+ device drivers is open-ended.
+
+ 4) profil. The memory referenced by the "buff" argument is updated
+ after the call returns, and there is no mechanism to permanently
+ unprotect it.
+
+ 5) Undocumented system calls. There are private system calls with
+ no manual pages, so it was impossible to write wrappers.
+
+ 6) audgen, whose manpage is incomprehensible.
+
+ (Some calls in Section 2 are already wrappers for other system
+ calls; it is not necessary to reimplement them here.)
+
+ Also, longjmp must not be used from a signal handler to abnormally
+ exit from a system call.
+
+ Finally, if a system call references an object on the heap, each
+ pointer must reference only one object. Therefore, it is not
+ possible to write the heap contents with a single write. */
+
+ #define MFS
+ #define NFS
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #if __FreeBSD__ >= 2
+ #include
+ #include
+ #endif
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+
+ #if __FreeBSD__ >= 3
+ #include
+ #include
+ #include
+ #include
+ #include
+ #endif
+
+ #include
+ #include
+
+ #ifdef NULL
+ #undef NULL
+ #endif
+ #define NULL (void *)(0)
+ extern long RT0u__inCritical;
+ #define ENTER_CRITICAL RT0u__inCritical++
+ #define EXIT_CRITICAL RT0u__inCritical--
+
+ void (*RTHeapRep_Fault)(char*);
+ void (*RTCSRC_FinishVM)();
+
+ static char RTHeapDepC__c;
+ #define MAKE_READABLE(x) if (x != 0) { RTHeapDepC__c = *(char*)(x); }
+ #define MAKE_WRITABLE(x) if (x != 0) { *(char*)(x) = RTHeapDepC__c = *(char*)(x); }
+
+ /*
+ * Modula-3 compilation units are always compiled PIC. This causes
+ * the a.out linker to complain that there is no reference to
+ * _DYNAMIC if the program is linked with "-static". Provide a
+ * weak reference to it here so that static linking will work.
+ *
+ * This has nothing to do with the heap, so it doesn't really belong
+ * here. But it needs to be someplace that is guaranteed to be pulled
+ * into every executable.
+ */
+ #pragma weak _DYNAMIC
+ extern int _DYNAMIC;
+ static int *i __unused = &_DYNAMIC;
+
+ /* Unless otherwise noted, all the following wrappers have the same
+ structure. */
+
+ int access(path, mode) /* ok */
+ const char *path;
+ int mode;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_access, path, mode);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int acct(file) /* ok */
+ const char *file;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(file);
+ result = syscall(SYS_acct, file);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int adjtime(delta, olddelta) /* ok */
+ #if __FreeBSD__ >= 2
+ const struct timeval *delta;
+ #else
+ struct timeval *delta;
+ #endif
+ struct timeval *olddelta;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(delta);
+ MAKE_WRITABLE(olddelta);
+ result = syscall(SYS_adjtime, delta, olddelta);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ /* not implemented
+ int atomic_op(op, addr)
+ int op;
+ int *addr;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(addr);
+ result = syscall(SYS_atomic_op, op, addr);
+ EXIT_CRITICAL;
+ return result;
+ }
+ */
+
+ /* not implemented
+ int audcntl(request, argp, len, flag, audit_id)
+ int request;
+ char *argp;
+ int len;
+ int flag;
+ audit_ID_t audit_id;
+ { int result;
+
+ ENTER_CRITICAL;
+ switch (request) {
+ case GET_SYS_AMASK:
+ case GET_TRUSTED_AMASK:
+ case GET_PROC_AMASK:
+ MAKE_WRITABLE(argp);
+ break;
+ case SET_SYS_AMASK:
+ case SET_TRUSTED_AMASK:
+ case SET_PROC_AMASK:
+ MAKE_READABLE(argp);
+ break;
+ default:
+ break;
+ }
+ result = syscall(SYS_audcntl, request, argp, len, flag, audit_id);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int audgen(event, tokenp, argv)
+ int event;
+ char *tokenp, *argv[];
+ { int result;
+
+ ENTER_CRITICAL;
+
+ { char *t, **a;
+
+ for (t = tokenp, a = argv; t; t++, a++) {
+ if (A_TOKEN_PTR(*t)) {
+ MAKE_READABLE(*a);
+ }
+ }
+ }
+ result = syscall(SYS_audgen, tokenp, argv);
+ EXIT_CRITICAL;
+ return result;
+ }
+ */
+
+ /* not implemented
+ int cachectl(addr, nbytes, op)
+ char *addr;
+ int nbytes, op;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(addr);
+ result = syscall(SYS_cachectl, addr, nbytes, op);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int cacheflush(addr, nbytes, cache)
+ char *addr;
+ int nbytes, cache;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(addr);
+ result = syscall(SYS_cacheflush, addr, nbytes, cache);
+ EXIT_CRITICAL;
+ return result;
+ }
+ */
+
+ int chdir(path) /* ok */
+ const char *path;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_chdir, path);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int chflags(path, flags)
+ const char *path;
+ u_long flags;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_chflags, path, flags);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int chmod(path, mode) /* ok */
+ const char *path;
+ mode_t mode;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_chmod, path, mode);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int chown(path, owner, group) /* ok */
+ const char *path;
+ uid_t owner;
+ gid_t group;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_chown, path, owner, group);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int chroot(dirname) /* ok */
+ const char *dirname;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(dirname);
+ result = syscall(SYS_chroot, dirname);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ /* not implemented (obsolete)
+ int creat(name, mode)
+ const char *name;
+ mode_t mode;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(name);
+ result = syscall(SYS_creat, name, mode);
+ EXIT_CRITICAL;
+ return result;
+ }
+ */
+
+ /* execve is implemented differently since it does not return, which
+ would leave RT0u__inCritical set in the parent if called in the child
+ of a vfork. Many calls leave the process in an undefined state in the
+ case of EFAULT, but we assume that execve is not one of these. */
+
+ int execve(name, argv, envp) /* ok */
+ const char *name;
+ char * const argv[];
+ char * const envp[];
+ { int result;
+
+ for (;;) {
+ result = syscall(SYS_execve, name, argv, envp);
+ if (result == -1 && errno == EFAULT) {
+ MAKE_READABLE(name);
+ { char * const *a; for (a = argv; *a; a++) MAKE_READABLE(*a); }
+ { char * const *e; for (e = envp; *e; e++) MAKE_READABLE(*e); }
+ } else {
+ return result;
+ }
+ }
+ }
+
+ /* not implemented
+ int exportfs(name, rootuid, exflags)
+ char *name;
+ int rootuid, exflags;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(name);
+ result = syscall(SYS_exportfs, name, rootuid, exflags);
+ EXIT_CRITICAL;
+ return result;
+ }
+ */
+
+ int ufcntl(int fd, int request, int arg) /* ok */
+ { int result;
+ /* int arg;
+ va_list ap;
+
+ va_start(ap, request);
+ arg = va_arg(ap, int);
+ va_end(ap);
+ */
+
+ ENTER_CRITICAL;
+ switch (request) {
+ case F_GETLK:
+ MAKE_WRITABLE(arg);
+ break;
+ case F_SETLK:
+ case F_SETLKW:
+ MAKE_READABLE(arg);
+ break;
+ default:
+ break;
+ }
+ result = syscall(SYS_fcntl, fd, request, arg);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int fstat(fd, buf) /* ok */
+ int fd;
+ struct stat *buf;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(buf);
+ result = syscall(SYS_fstat, fd, buf);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int getdirentries(fd, buf, nbytes, basep) /* ok */
+ int fd;
+ char *buf;
+ int nbytes;
+ long *basep;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(buf);
+ MAKE_WRITABLE(basep);
+ result = syscall(SYS_getdirentries, fd, buf, nbytes, basep);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int getdomainname(name, namelen) /* ok */
+ char *name;
+ int namelen;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(name);
+ result = syscall(SYS_getdomainname, name, namelen);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int gethostname(name, namelen) /* ok */
+ char *name;
+ int namelen;
+ { int result;
+ #if __FreeBSD__ >= 2
+ int mib[2];
+ size_t size;
+ #endif
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(name);
+ #if __FreeBSD__ >= 2
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_HOSTNAME;
+ size = namelen;
+ if (sysctl(mib, 2, name, &size, NULL, 0) == -1){
+ result = -1;
+ }else{
+ result = 0;
+ }
+ #else
+ result = syscall(SYS_gethostname, name, namelen);
+ #endif
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int getgroups(gidsetsize, grouplist) /* ok */
+ int gidsetsize;
+ gid_t grouplist[];
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(grouplist);
+ result = syscall(SYS_getgroups, gidsetsize, grouplist);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int getitimer(which, value) /* ok */
+ int which;
+ struct itimerval *value;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(value);
+ result = syscall(SYS_getitimer, which, value);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ /* not implemented
+ int getmnt(start, buffer, nbytes, mode, path)
+ int *start;
+ struct fs_data *buffer;
+ int nbytes, mode;
+ char *path;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(start);
+ MAKE_WRITABLE(buffer);
+ MAKE_READABLE(path);
+ result = syscall(SYS_getmnt, start, buffer, nbytes, mode, path);
+ EXIT_CRITICAL;
+ return result;
+ }
+ */
+
+ int getrlimit(resource, rlp) /* ok */
+ int resource;
+ struct rlimit *rlp;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(rlp);
+ result = syscall(SYS_getrlimit, resource, rlp);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int getrusage(who, rusage) /* ok */
+ int who;
+ struct rusage *rusage;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(rusage);
+ result = syscall(SYS_getrusage, who, rusage);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int getsockopt(s, level, optname, optval, optlen) /* ok */
+ int s, level, optname;
+ void *optval;
+ int *optlen;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(optval);
+ MAKE_WRITABLE(optlen);
+ result = syscall(SYS_getsockopt, s, level, optname, optval, optlen);
+ EXIT_CRITICAL;
+ return result;
+ }
+ /* not implemented
+ int getsysinfo(op, buffer, nbytes, start, arg)
+ unsigned op;
+ char *buffer;
+ unsigned nbytes;
+ int *start;
+ char *arg;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(buffer);
+ MAKE_WRITABLE(start);
+ MAKE_WRITABLE(arg);
+ result = syscall(SYS_getsysinfo, op, buffer, nbytes, start, arg);
+ EXIT_CRITICAL;
+ return result;
+ }
+ */
+
+ int gettimeofday(tp, tzp) /* ok */
+ struct timeval *tp;
+ struct timezone *tzp;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(tp);
+ MAKE_WRITABLE(tzp);
+ result = syscall(SYS_gettimeofday, tp, tzp);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ /* ioctl must test the argp argument carefully. It may be a pointer,
+ or maybe not. At a slight expense, we call RTHeapRep.Fault to
+ unprotect the page if it's in the traced heap, but do nothing
+ otherwise. */
+
+ int ioctl(d, request, argp) /* ok */
+ int d;
+ unsigned long request;
+ char *argp;
+ { int result;
+
+ ENTER_CRITICAL;
+ if (RTHeapRep_Fault) RTHeapRep_Fault(argp); /* make it readable */
+ if (RTHeapRep_Fault) RTHeapRep_Fault(argp); /* make it writable */
+ result = syscall(SYS_ioctl, d, request, argp);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ #ifdef SYS_lchown
+ int lchown(path, owner, group) /* ok */
+ const char *path;
+ uid_t owner;
+ gid_t group;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_lchown, path, owner, group);
+ EXIT_CRITICAL;
+ return result;
+ }
+ #endif /* SYS_lchown */
+
+ int link(name1, name2) /* ok */
+ const char *name1;
+ const char *name2;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(name1);
+ MAKE_READABLE(name2);
+ result = syscall(SYS_link, name1, name2);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int lstat(path, buf) /* ok */
+ const char *path;
+ struct stat *buf;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ MAKE_WRITABLE(buf);
+ result = syscall(SYS_lstat, path, buf);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int mkdir(path, mode) /* ok */
+ const char *path;
+ mode_t mode;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_mkdir, path, mode);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int mkfifo(path, mode) /* ok */
+ const char *path;
+ mode_t mode;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_mkfifo, path, mode);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int mknod(path, mode, dev) /* ok */
+ const char *path;
+ mode_t mode;
+ dev_t dev;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_mknod, path, mode, dev);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ #if __FreeBSD_version >= 300001 /* New form of mount(2) */
+ int
+ mount(type, dir, flags, data)
+ const char *type;
+ const char *dir;
+ int flags;
+ void *data;
+ { int result;
+ struct ufs_args *u_data;
+ struct mfs_args *m_data;
+ struct nfs_args *n_data;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(type);
+ MAKE_READABLE(dir);
+ if (strcmp(type, "ufs") == 0) {
+ u_data = (struct ufs_args*) data;
+ MAKE_READABLE(u_data);
+ MAKE_READABLE(u_data->fspec);
+ result = syscall(SYS_mount, type, dir, flags, data);
+ } else if (strcmp(type, "mfs") == 0) {
+ m_data = (struct mfs_args*) data;
+ MAKE_READABLE(m_data);
+ MAKE_READABLE(m_data->fspec);
+ result = syscall(SYS_mount, type, dir, flags, data);
+ } else if (strcmp(type, "nfs") == 0) {
+ n_data = (struct nfs_args*) data;
+ MAKE_READABLE(n_data);
+ MAKE_READABLE(n_data->addr);
+ MAKE_READABLE(n_data->fh);
+ MAKE_READABLE(n_data->hostname);
+ result = syscall(SYS_mount, type, dir, flags, data);
+ } else { /* Not anything we recognize. */
+ MAKE_READABLE(data);
+ result = syscall(SYS_mount, type, dir, flags, data);
+ }
+ EXIT_CRITICAL;
+ if (result != -1) {
+ result = 0;
+ }
+ return result;
+ }
+
+ #else /* __FreeBSD_version >= 300001 */
+
+ int mount(type, dir, flags, data)
+ int type;
+ const char *dir;
+ int flags;
+ void *data;
+ { int result;
+ struct ufs_args *u_data;
+ struct mfs_args *m_data;
+ struct nfs_args *n_data;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(dir);
+ switch(type) {
+ case MOUNT_UFS: u_data = (struct ufs_args*) data;
+ MAKE_READABLE(u_data);
+ MAKE_READABLE(u_data->fspec); break;
+ case MOUNT_MFS: m_data = (struct mfs_args*) data;
+ MAKE_READABLE(m_data);
+ #if __FreeBSD__ >= 2
+ MAKE_READABLE(m_data->fspec); break;
+ #else
+ MAKE_READABLE(m_data->name); break;
+ #endif
+ case MOUNT_NFS: n_data = (struct nfs_args*) data;
+ MAKE_READABLE(n_data);
+ MAKE_READABLE(n_data->addr);
+ MAKE_READABLE(n_data->fh);
+ MAKE_READABLE(n_data->hostname); break;
+ }
+ result = syscall(SYS_mount, type, dir, flags, data);
+ EXIT_CRITICAL;
+ if (result != -1) {
+ result = 0;
+ }
+ return result;
+ }
+ #endif /* __FreeBSD_version >= 300001 */
+
+ int msgctl(msqid, cmd, buf) /* ok */
+ int msqid, cmd;
+ struct msqid_ds *buf;
+ { int result;
+
+ ENTER_CRITICAL;
+ switch (cmd) {
+ case IPC_SET:
+ MAKE_READABLE(buf);
+ break;
+ case IPC_STAT:
+ MAKE_WRITABLE(buf);
+ break;
+ default:
+ break;
+ }
+ result = syscall(SYS_msgsys, 0, msqid, cmd, buf);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int msgrcv(msqid, msgp, msgsz, msgtyp, msgflg) /* ok */
+ int msqid;
+ void *msgp;
+ size_t msgsz;
+ long msgtyp;
+ int msgflg;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(msgp);
+ result = syscall(SYS_msgsys, 3, msqid, msgp, msgsz, msgtyp, msgflg);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int msgsnd(msqid, msgp, msgsz, msgflg) /* ok */
+ int msqid;
+ void *msgp;
+ size_t msgsz;
+ int msgflg;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(msgp);
+ result = syscall(SYS_msgsys, 2, msqid, msgp, msgsz, msgflg);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int uopen(const char* path, int flags, mode_t mode) /* ok */
+ { int result;
+ /* mode_t mode;
+ va_list ap;
+
+ va_start(ap, flags);
+ mode = va_arg(ap, mode_t);
+ va_end(ap);
+ this does not work. Why?
+ */
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_open, path, flags, mode);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int quotactl(path, cmd, uid, addr) /* ok */
+ const char *path;
+ int cmd, uid;
+ #if __FreeBSD_version >= 400002
+ void *addr;
+ #else
+ char *addr;
+ #endif
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ switch (cmd) {
+ case Q_QUOTAON:
+ case Q_QUOTAOFF:
+ case Q_SETUSE:
+ case Q_SETQUOTA:
+ case Q_GETQUOTA:
+ MAKE_READABLE(addr);
+ break;
+ /*
+ case Q_GETDLIM:
+ MAKE_WRITABLE(addr);
+ break;
+ */
+ default:
+ break;
+ }
+ result = syscall(SYS_quotactl, path, cmd, uid, addr);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int readlink(path, buf, bufsiz) /* ok */
+ const char *path;
+ char *buf;
+ int bufsiz;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ MAKE_WRITABLE(buf);
+ result = syscall(SYS_readlink, path, buf, bufsiz);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ ssize_t readv(d, iov, iovcnt) /* ok */
+ int d;
+ const struct iovec *iov;
+ int iovcnt;
+ { int result;
+
+ ENTER_CRITICAL;
+ { int i;
+ for (i = 0; i < iovcnt; i++) {
+ MAKE_WRITABLE(iov[i].iov_base);
+ }
+ }
+ result = syscall(SYS_readv, d, iov, iovcnt);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ ssize_t recvmsg(s, msg, flags) /* ok */
+ int s;
+ struct msghdr msg[];
+ int flags;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(msg->msg_name);
+ { int i;
+ for (i = 0; i < msg->msg_iovlen; i++) {
+ if (msg->msg_iov[i].iov_len > 0) {
+ MAKE_WRITABLE(msg->msg_iov[i].iov_base);
+ }
+ }
+ }
+ MAKE_WRITABLE(msg->msg_control);
+ result = syscall(SYS_recvmsg, s, msg, flags);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int rename(from, to) /* ok */
+ char *from;
+ char *to;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(from);
+ MAKE_READABLE(to);
+ result = syscall(SYS_rename, from, to);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int rmdir(path) /* ok */
+ const char *path;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_rmdir, path);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int
+ #if (227002 <= __FreeBSD_version && __FreeBSD_version < 300000) || \
+ __FreeBSD_version >= 300002
+ semctl(int semid, int semnum, int cmd, ...)
+ #else
+ semctl(int semid, int semnum, int cmd, union semun arg)
+ #endif
+ {
+ int result;
+ #if (227002 <= __FreeBSD_version && __FreeBSD_version < 300000) || \
+ __FreeBSD_version >= 300002
+ union semun arg;
+ va_list ap;
+
+ va_start(ap, cmd);
+ arg = va_arg(ap, union semun);
+ va_end(ap);
+ #endif
+
+ ENTER_CRITICAL;
+ switch (cmd) {
+
+ case IPC_SET:
+ MAKE_READABLE(arg.buf);
+ break;
+
+ case SETALL:
+ MAKE_READABLE(arg.array);
+ break;
+
+ case IPC_STAT:
+ MAKE_WRITABLE(arg.buf);
+ break;
+
+ case GETALL:
+ MAKE_WRITABLE(arg.array);
+ break;
+ }
+ result = syscall(SYS_semsys, 0, semid, semnum, cmd, arg);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int semop(semid, sops, nsops) /* ok ? */
+ int semid;
+ struct sembuf *sops;
+ unsigned int nsops;
+ { int result;
+
+ ENTER_CRITICAL;
+ { unsigned int i;
+ for (i = 0; i < nsops; i++) {
+ MAKE_READABLE(sops);
+ }
+ }
+ result = syscall(SYS_semsys, 2, semid, sops, nsops);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ ssize_t sendmsg(s, msg, flags) /* ok */
+ int s;
+ const struct msghdr msg[];
+ int flags;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(msg->msg_name);
+ { int i;
+ for (i = 0; i < msg->msg_iovlen; i++) {
+ if (msg->msg_iov[i].iov_len > 0) {
+ MAKE_READABLE(msg->msg_iov[i].iov_base);
+ }
+ }
+ }
+ MAKE_WRITABLE(msg->msg_control);
+ result = syscall(SYS_sendmsg, s, msg, flags);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int setdomainname(name, namelen) /* ok */
+ const char *name;
+ int namelen;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(name);
+ result = syscall(SYS_setdomainname, name, namelen);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int setgroups(ngroups, gidset) /* ok */
+ int ngroups;
+ const gid_t *gidset;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(gidset);
+ result = syscall(SYS_setgroups, ngroups, gidset);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int sethostname(name, namelen) /* ok */
+ const char *name;
+ int namelen;
+ { int result;
+ #if __FreeBSD__ >= 2
+ int mib[2];
+ #endif
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(name);
+ #if __FreeBSD__ >= 2
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_HOSTNAME;
+ if (sysctl(mib, 2, NULL, NULL, (void *)name, namelen) == -1){
+ result = -1;
+ }else{
+ result = 0;
+ }
+ #else
+ result = syscall(SYS_sethostname, name, namelen);
+ #endif
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int setitimer(which, value, ovalue) /* ok */
+ int which;
+ #if __FreeBSD__ >= 2
+ const struct itimerval *value;
+ #else
+ struct itimerval *value;
+ #endif
+ struct itimerval *ovalue;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(value);
+ MAKE_WRITABLE(ovalue);
+ result = syscall(SYS_setitimer, which, value, ovalue);
+ EXIT_CRITICAL;
+ return result;
+ }
+ /* not implemented
+ int setquota(special, file)
+ char *special;
+ char *file;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(special);
+ MAKE_READABLE(file);
+ result = syscall(SYS_setquota, special, file);
+ EXIT_CRITICAL;
+ return result;
+ }
+ */
+
+ int setrlimit(resource, rlp) /* ok */
+ int resource;
+ struct rlimit *rlp;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(rlp);
+ result = syscall(SYS_setrlimit, resource, rlp);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int setsockopt(s, level, optname, optval, optlen) /* ok */
+ int s, level, optname;
+ const void *optval;
+ int optlen;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(optval);
+ result = syscall(SYS_setsockopt, s, level, optname, optval, optlen);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ /* not implemented
+ int setsysinfo(op, buffer, nbytes, arg, flag)
+ unsigned op;
+ char *buffer;
+ unsigned nbytes;
+ unsigned arg;
+ unsigned flag;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(buffer);
+ result = syscall(SYS_setsysinfo, op, buffer, nbytes, arg, flag);
+ EXIT_CRITICAL;
+ return result;
+ }
+ */
+
+ int settimeofday(tp, tzp) /* ok */
+ #if __FreeBSD__ >= 2
+ const struct timeval *tp;
+ const struct timezone *tzp;
+ #else
+ struct timeval *tp;
+ struct timezone *tzp;
+ #endif
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(tp);
+ MAKE_READABLE(tzp);
+ result = syscall(SYS_settimeofday, tp, tzp);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int sigaction(sig, act, oact)
+ int sig;
+ const struct sigaction *act;
+ struct sigaction *oact;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(act);
+ MAKE_WRITABLE(oact);
+ result = syscall(SYS_sigaction, sig, act, oact);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int sigaltstack(ss, oss) /* ok */
+ const struct sigaltstack *ss;
+ struct sigaltstack *oss;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(ss);
+ MAKE_WRITABLE(oss);
+ result = syscall(SYS_sigaltstack, ss, oss);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int socketpair(d, type, protocol, sv) /* ok */
+ int d, type, protocol;
+ int sv[2];
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(sv);
+ result = syscall(SYS_socketpair, d, type, protocol, sv);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int stat(path, buf) /* ok */
+ const char *path;
+ struct stat *buf;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ MAKE_WRITABLE(buf);
+ result = syscall(SYS_stat, path, buf);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int swapon(special) /* ok */
+ const char *special;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(special);
+ result = syscall(SYS_swapon, special);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int symlink(name1, name2) /* ok */
+ const char *name1;
+ const char *name2;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(name1);
+ MAKE_READABLE(name2);
+ result = syscall(SYS_symlink, name1, name2);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int truncate(path, length) /* ok */
+ const char *path;
+ off_t length;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ /* The casts below pad "path" out to a 64-bit value as required. */
+ result = __syscall(SYS_truncate, (u_quad_t)(u_long)path, length);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int uname(name) /* ok */
+ struct utsname *name;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(name);
+ result = syscall(SYS_uname, name);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ int unlink(path) /* ok */
+ const char *path;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(path);
+ result = syscall(SYS_unlink, path);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ /* not implemented
+ int ustat(dev, buf)
+ dev_t dev;
+ struct ustat *buf;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(buf);
+ result = syscall(SYS_ustat, dev, buf);
+ EXIT_CRITICAL;
+ return result;
+ }
+ */
+
+ int utimes(file, tvp) /* ok */
+ #if __FreeBSD__ >= 2
+ const char *file;
+ const struct timeval *tvp;
+ #else
+ char *file;
+ struct timeval *tvp;
+ #endif
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(file);
+ MAKE_READABLE(tvp);
+ result = syscall(SYS_utimes, file, tvp);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ pid_t wait(status) /* ok */
+ int *status;
+ {
+ return wait3(status, 0, 0);
+ }
+
+ pid_t wait3(status, options, rusage) /* ok */
+ int *status;
+ int options;
+ struct rusage *rusage;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(status);
+ MAKE_WRITABLE(rusage);
+ result = syscall(SYS_wait4, -1, status, options, rusage);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ pid_t wait4(wpid, status, options, rusage) /* ok */
+ pid_t wpid;
+ int *status;
+ int options;
+ struct rusage *rusage;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(status);
+ MAKE_WRITABLE(rusage);
+ result = syscall(SYS_wait4, wpid, status, options, rusage);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ pid_t waitpid(pid, status, options) /* ok */
+ pid_t pid;
+ int *status;
+ int options;
+ { int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(status);
+ result = syscall(SYS_wait4, pid, status, options, NULL);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ ssize_t writev(fd, iov, ioveclen) /* ok */
+ int fd;
+ const struct iovec *iov;
+ int ioveclen;
+ { int result;
+
+ ENTER_CRITICAL;
+ { int i;
+ for (i = 0; i < ioveclen; i++) {
+ if (iov[i].iov_len > 0) {
+ MAKE_READABLE(iov[i].iov_base);
+ }
+ }
+ }
+ result = syscall(SYS_writev, fd, iov, ioveclen);
+ EXIT_CRITICAL;
+ return result;
+ }
+
+ /* fork also requires special treatment, although it takes no
+ argument. fork crashes Ultrix if some pages are unreadable, so we
+ must unprotect the heap before calling fork */
+ /* I don't know what happens in FreeBSD, so I just leave it in here */
+ pid_t fork()
+ {
+ pid_t result;
+ pid_t me = getpid();
+
+ ENTER_CRITICAL;
+ if (RTCSRC_FinishVM) RTCSRC_FinishVM();
+ result = syscall(SYS_fork);
+ EXIT_CRITICAL;
+ if (result == me) {
+ result = 0;
+ }
+ return result;
+ }
+
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/RTMachine.i3
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/RTMachine.i3:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/RTMachine.i3 Mon Jun 7 13:14:38 1999
***************
*** 0 ****
--- 1,86 ----
+ (* 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:23 PDT 1995 by kalsow *)
+
+ (* This interface defines platform (machine + OS) dependent
+ types and constants. *)
+
+ INTERFACE RTMachine;
+
+ IMPORT Csetjmp;
+
+ (*--------------------------------------------------------- thread state ---*)
+
+ TYPE
+ State = Csetjmp.fpjmp_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 "_fpsetjmp" *>
+ PROCEDURE SaveState (VAR s: State): INTEGER;
+ (* Capture the currently running thread's state *)
+
+ CONST
+ FramePadBottom = 2;
+ 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;
+
+ (* The collector supports the use of VM protection to achieve incremental,
+ generational collection. This is not possible on all architectures, and
+ it may not be implemented in all cases where it is possible. The
+ boolean constant "VMHeap" is "TRUE" iff all necessary support is
+ present for this architecture. "VMHeap" is "TRUE" for the DS3100,
+ whose implementation you might use as a reference. *)
+
+ CONST
+ VMHeap = TRUE;
+
+ (*** hooks for the C wrapper functions ***)
+
+ <*EXTERNAL *> VAR RTHeapRep_Fault: ADDRESS; (* => RTHeapRep.Fault *)
+ <*EXTERNAL *> VAR RTCSRC_FinishVM: ADDRESS; (* => RTCollectorSRC.FinishVM *)
+
+ (*--------------------------------------------------------- thread stacks ---*)
+
+ CONST
+ PointerAlignment = 4;
+ (* 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 = 16;
+ (* 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.
+
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/RTSignal.m3
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/RTSignal.m3:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/RTSignal.m3 Mon Jun 7 13:14:38 1999
***************
*** 0 ****
--- 1,101 ----
+ (* Copyright (C) 1992, Digital Equipment Corporation *)
+ (* All rights reserved. *)
+ (* See the file COPYRIGHT for a full description. *)
+ (* *)
+ (* Last modified on Mon Nov 21 10:31:19 PST 1994 by kalsow *)
+ (* modified on Mon Mar 16 18:10:15 PST 1992 by muller *)
+
+ UNSAFE MODULE RTSignal;
+
+ IMPORT RTMisc, RTProcess, Usignal, Uprocess;
+ FROM Ctypes IMPORT int;
+
+ TYPE
+ SigInfo = UNTRACED REF Usignal.struct_sigcontext;
+
+ VAR
+ DefaultHandler : Usignal.SignalHandler;
+ IgnoreSignal : Usignal.SignalHandler;
+ initial_handlers : ARRAY [0..5] OF Usignal.struct_sigaction;
+
+ PROCEDURE InstallHandlers () =
+ BEGIN
+ DefaultHandler := LOOPHOLE (0, Usignal.SignalHandler);
+ IgnoreSignal := LOOPHOLE (1, Usignal.SignalHandler);
+
+ 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: Usignal.SignalHandler) =
+ (* Note: we use the LOOPHOLE to prevent the runtime check for
+ nested procedure. The runtime check crashes when
+ handler = IgnoreSignal = 1. *)
+ VAR new: Usignal.struct_sigaction;
+ BEGIN
+ new.sa_handler := LOOPHOLE (handler, Usignal.SignalHandler);
+ new.sa_flags := 0;
+ EVAL Usignal.sigaction (sig, ADR(new), ADR(initial_handlers[id]));
+ IF (initial_handlers[id].sa_handler # DefaultHandler) THEN
+ (* don't override inherited, non-default handlers *)
+ EVAL Usignal.sigaction (sig, ADR(initial_handlers[id]), ADR(new));
+ 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 Usignal.sigaction (sig, ADR(initial_handlers[id]), NIL);
+ END RestoreHandler;
+
+ PROCEDURE Shutdown (sig: int; <*UNUSED*> code: int; <*UNUSED*> scp: SigInfo) =
+ VAR new, old: Usignal.struct_sigaction;
+ BEGIN
+ new.sa_handler := DefaultHandler;
+ new.sa_flags := 0;
+ RTProcess.InvokeExitors (); (* flush stdio... *)
+ EVAL Usignal.sigaction (sig, ADR(new), ADR(old)); (* restore default handler *)
+ EVAL Usignal.kill (Uprocess.getpid (), sig); (* and resend the signal *)
+ END Shutdown;
+
+ PROCEDURE Interrupt (sig: int; code: int; scp: SigInfo) =
+ VAR h := RTProcess.OnInterrupt (NIL);
+ BEGIN
+ IF (h = NIL) THEN
+ Shutdown (sig, code, scp);
+ ELSE
+ EVAL RTProcess.OnInterrupt (h); (* reinstall the handler *)
+ h ();
+ END;
+ END Interrupt;
+
+ PROCEDURE Quit (<*UNUSED*> sig, code: int; scp: SigInfo) =
+ VAR pc := 0;
+ BEGIN
+ IF (scp # NIL) THEN pc := scp.sc_eip END;
+ RTMisc.FatalErrorPC (pc, "aborted");
+ END Quit;
+
+ PROCEDURE SegV (<*UNUSED*> sig, code: int; scp: SigInfo) =
+ VAR pc := 0;
+ BEGIN
+ IF (scp # NIL) THEN pc := scp.sc_eip END;
+ RTMisc.FatalErrorPC (pc,
+ "Segmentation violation - possible attempt to dereference NIL");
+ END SegV;
+
+ BEGIN
+ END RTSignal.
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/RTStackASM.s
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/RTStackASM.s:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/RTStackASM.s Mon Jun 7 13:14:38 1999
***************
*** 0 ****
--- 1,46 ----
+ .text
+ .align 2
+
+ .globl _RTStack__CurrentFrame
+ _RTStack__CurrentFrame:
+ .globl RTStack__CurrentFrame
+ RTStack__CurrentFrame:
+ # STACK = ret frame
+ popl %eax # STACK = frame
+ pushl %eax
+ pushl %eax # STACK = PC ret frame
+ movl %esp, %eax
+ addl $8, %eax # correct for the thing we have pushed
+ # and our return address
+ pushl %eax # STACK = SP PC ret frame
+ movl 12(%esp), %eax # grab the address were to put the values
+ popl 8(%eax) # stuff our caller SP
+ popl 0(%eax) # stuff our caller PC
+ movl %ebp, 4(%eax) # stuff our caller BP
+ ret
+
+ .globl _RTStack__PreviousFrame
+ _RTStack__PreviousFrame:
+ .globl RTStack__PreviousFrame
+ RTStack__PreviousFrame:
+ movl 4(%esp), %eax # eax = ^callee
+ movl 4(%eax), %eax # eax = callee.ebp
+ pushl 0(%eax) # push bp of caller
+ pushl 4(%eax) # push pc of caller
+ addl $4, %eax
+ pushl %eax # push sp of caller
+ movl 20(%esp), %eax
+ popl 8(%eax)
+ popl 0(%eax)
+ popl 4(%eax)
+ ret
+
+ .globl _RTStack__Unwind
+ _RTStack__Unwind:
+ .globl RTStack__Unwind
+ RTStack__Unwind:
+ movl 4(%esp), %eax # eax = ^to
+ movl 8(%eax), %esp
+ movl 4(%eax), %ebp
+ jmp *(%eax)
+
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/RTThread.m3
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/RTThread.m3:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/RTThread.m3 Mon Jun 7 13:14:38 1999
***************
*** 0 ****
--- 1,115 ----
+ (* Copyright (C) 1992, Digital Equipment Corporation *)
+ (* All rights reserved. *)
+ (* See the file COPYRIGHT for a full description. *)
+ (* *)
+ (* Last modified on Wed Nov 23 13:01:14 PST 1994 by kalsow *)
+ (* modified on Tue May 4 18:49:28 PDT 1993 by muller *)
+ (* ow 16.09.1994 *)
+ (* ow 11.10.1994 *)
+
+ UNSAFE MODULE RTThread;
+
+ IMPORT Usignal, Unix, Umman, RTMisc;
+
+ CONST
+ SP_pos = 2;
+ FP_pos = 3;
+
+ 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; 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);
+ 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 *)
+ 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);
+ INC (s [FP_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 sv, osv: Usignal.struct_sigvec; i: INTEGER;
+ BEGIN
+ sv.sv_handler := handler;
+ sv.sv_mask := Usignal.empty_sv_mask;
+ sv.sv_flags := 0;
+ i := Usignal.sigvec (Usignal.SIGVTALRM, sv, osv);
+ <*ASSERT i = 0*>
+ END setup_sigvtalrm;
+
+ PROCEDURE allow_sigvtalrm () =
+ VAR svt : Usignal.sigset_t := Usignal.sigmask(Usignal.SIGVTALRM);
+ old : Usignal.sigset_t;
+ i : INTEGER;
+ BEGIN
+ i := Usignal.sigprocmask(Usignal.SIG_UNBLOCK, svt, old);
+ <*ASSERT i = 0 *>
+ END allow_sigvtalrm;
+
+ PROCEDURE disallow_sigvtalrm () =
+ VAR svt : Usignal.sigset_t := Usignal.sigmask(Usignal.SIGVTALRM);
+ old : Usignal.sigset_t;
+ i : INTEGER;
+ BEGIN
+ i := Usignal.sigprocmask(Usignal.SIG_BLOCK, svt, old);
+ <*ASSERT i = 0 *>
+ END disallow_sigvtalrm;
+
+ BEGIN
+ END RTThread.
+
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/RTThreadC.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/RTThreadC.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/RTThreadC.c Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,28 ----
+ /* Copyright (C) 1994, Digital Equipment Corporation */
+ /* All rights reserved. */
+ /* See the file COPYRIGHT for a full description. */
+ /* */
+ /* Last modified on Mon Nov 7 13:23:14 PST 1994 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 (_fpsetjmp(*from) == 0) _fplongjmp (*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;
+
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/_fpsetjmp.s
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/_fpsetjmp.s:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/_fpsetjmp.s Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,94 ----
+ /*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+ #if defined(LIBC_SCCS) && !defined(lint)
+ .asciz "@(#)_setjmp.s 5.1 (Berkeley) 4/23/90"
+ .align 2,0x90
+ #endif /* LIBC_SCCS and not lint */
+
+ /*
+ * _fpsetjmp, _fplongjmp
+ *
+ * _fplongjmp(a,v)
+ * will generate a "return(v)" from the last call to
+ * _fpsetjmp(a)
+ * by restoring registers from the environment 'a'.
+ * The previous signal state is NOT restored.
+ * The state of the floating point unit is saved.
+ */
+
+
+ .align 2,0x90;
+ .globl __fpsetjmp;
+ .type __fpsetjmp,@function;
+ __fpsetjmp:
+ .globl _fpsetjmp;
+ .type _fpsetjmp,@function;
+ _fpsetjmp:
+ movl 4(%esp),%eax
+ movl 0(%esp),%edx
+ movl %edx, 0(%eax)
+ movl %ebx, 4(%eax)
+ movl %esp, 8(%eax)
+ movl %ebp,12(%eax)
+ movl %esi,16(%eax)
+ movl %edi,20(%eax)
+ fnsave 28(%eax)
+ xorl %eax,%eax
+ ret
+
+ .align 2,0x90;
+ .globl __fplongjmp;
+ .type __fplongjmp,@function;
+ __fplongjmp:
+ .globl _fplongjmp;
+ .type _fplongjmp,@function;
+ _fplongjmp:
+ movl 4(%esp),%edx
+ movl 8(%esp),%eax
+ movl 0(%edx),%ecx
+ movl 4(%edx),%ebx
+ movl 8(%edx),%esp
+ movl 12(%edx),%ebp
+ movl 16(%edx),%esi
+ movl 20(%edx),%edi
+ frstor 28(%edx)
+ testl %eax,%eax
+ jnz 1f
+ incl %eax
+ 1: movl %ecx,0(%esp)
+ ret
+
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/accept.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/accept.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/accept.c Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,16 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ int
+ m3_accept(int s, struct sockaddr *addr, int *addrlen)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(addr);
+ MAKE_WRITABLE(addrlen);
+ result = accept(s, addr, addrlen);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/bind.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/bind.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/bind.c Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,15 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ int
+ m3_bind(int s, const struct sockaddr *name, int namelen)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(name);
+ result = bind(s, name, namelen);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/close.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/close.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/close.c Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,13 ----
+ #include "wrap.h"
+ #include
+
+ int
+ m3_close(int d)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ result = close(d);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/connect.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/connect.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/connect.c Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,15 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ int
+ m3_connect(int s, const struct sockaddr *name, int namelen)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(name);
+ result = connect(s, name, namelen);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/dup.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/dup.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/dup.c Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,13 ----
+ #include "wrap.h"
+ #include
+
+ int
+ m3_dup(int oldd)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ result = dup(oldd);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/dup2.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/dup2.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/dup2.c Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,13 ----
+ #include "wrap.h"
+ #include
+
+ int
+ m3_dup2(int oldd, int newd)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ result = dup2(oldd, newd);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/gethostbyaddr.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/gethostbyaddr.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/gethostbyaddr.c Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,14 ----
+ #include "wrap.h"
+ #include
+
+ struct hostent *
+ m3_gethostbyaddr(const char *addr, int len, int type)
+ {
+ struct hostent *result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(addr);
+ result = gethostbyaddr(addr, len, type);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/gethostbyname.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/gethostbyname.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/gethostbyname.c Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,14 ----
+ #include "wrap.h"
+ #include
+
+ struct hostent *
+ m3_gethostbyname(const char *name)
+ {
+ struct hostent *result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(name);
+ result = gethostbyname(name);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/getpeername.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/getpeername.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/getpeername.c Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,16 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ int
+ m3_getpeername(int s, struct sockaddr *name, int *namelen)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(name);
+ MAKE_WRITABLE(namelen);
+ result = getpeername(s, name, namelen);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/getsockname.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/getsockname.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/getsockname.c Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,16 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ int
+ m3_getsockname(int s, struct sockaddr *name, int *namelen)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(name);
+ MAKE_WRITABLE(namelen);
+ result = getsockname(s, name, namelen);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/listen.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/listen.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/listen.c Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,14 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ int
+ m3_listen(int s, int backlog)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ result = listen(s, backlog);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/m3makefile
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/m3makefile:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/m3makefile Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,44 ----
+ % Copyright (C) 1994, Digital Equipment Corporation
+ % All rights reserved.
+ % See the file COPYRIGHT for a full description.
+ %
+ % Last modified on Mon Nov 21 10:43:13 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")
+ c_source ("RTHeapDepC")
+ s_source ("_fpsetjmp")
+ c_source ("malloc")
+
+ % These wrappers were extracted from RTHeapDepC.c and modified slightly,
+ % in order to make it possible to support SOCKS.
+ h_source ("socksconf")
+ h_source ("wrap")
+ c_source ("accept")
+ c_source ("bind")
+ c_source ("close")
+ c_source ("connect")
+ c_source ("dup")
+ c_source ("dup2")
+ c_source ("gethostbyaddr")
+ c_source ("gethostbyname")
+ c_source ("getpeername")
+ c_source ("getsockname")
+ c_source ("listen")
+ c_source ("read")
+ c_source ("recv")
+ c_source ("recvfrom")
+ c_source ("select")
+ c_source ("send")
+ c_source ("sendto")
+ c_source ("shutdown")
+ c_source ("socket")
+ c_source ("write")
+
+ %% s_source (RTStackASM)
+
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/malloc.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/malloc.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/malloc.c Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,1153 ----
+ /*
+ * ----------------------------------------------------------------------------
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * wrote this file. As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
+ * ----------------------------------------------------------------------------
+ *
+ * From FreeBSD: malloc.c,v 1.32 1997/08/31 05:59:39 phk Exp
+ * Modified for Modula-3 thread safety by jdp@polstra.com (John Polstra).
+ *
+ */
+
+ #define _THREAD_SAFE 1 /* Turn on thread safety for Modula-3 */
+
+ /*
+ * Defining EXTRA_SANITY will enable extra checks which are related
+ * to internal conditions and consistency in malloc.c. This has a
+ * noticeable runtime performance hit, and generally will not do you
+ * any good unless you fiddle with the internals of malloc or want
+ * to catch random pointer corruption as early as possible.
+ */
+ #ifndef MALLOC_EXTRA_SANITY
+ #undef MALLOC_EXTRA_SANITY
+ #endif
+
+ /*
+ * What to use for Junk. This is the byte value we use to fill with
+ * when the 'J' option is enabled.
+ */
+ #define SOME_JUNK 0xd0 /* as in "Duh" :-) */
+
+ /*
+ * The basic parameters you can tweak.
+ *
+ * malloc_pageshift pagesize = 1 << malloc_pageshift
+ * It's probably best if this is the native
+ * page size, but it doesn't have to be.
+ *
+ * malloc_minsize minimum size of an allocation in bytes.
+ * If this is too small it's too much work
+ * to manage them. This is also the smallest
+ * unit of alignment used for the storage
+ * returned by malloc/realloc.
+ *
+ */
+
+ #if defined(__FreeBSD__)
+ # if defined(__i386__)
+ # define malloc_pageshift 12U
+ # define malloc_minsize 16U
+ # endif
+ #endif /* __FreeBSD__ */
+
+ #if defined(__sparc__) && defined(sun)
+ # define malloc_pageshift 12U
+ # define malloc_minsize 16U
+ # define MAP_ANON (0)
+ static int fdzero;
+ # define MMAP_FD fdzero
+ # define INIT_MMAP() \
+ { if ((fdzero=open("/dev/zero", O_RDWR, 0000)) == -1) \
+ wrterror("open of /dev/zero"); }
+ # define MADV_FREE MADV_DONTNEED
+ #endif /* __sparc__ */
+
+ #if defined(__linux__)
+ # if defined(__i386__)
+ # define malloc_pageshift 12U
+ # define malloc_minsize 16U
+ # endif
+ #endif /* __linux__ */
+
+ #if defined(__alpha)
+ # define malloc_pageshift 13U
+ # define malloc_minsize 16U
+ #endif /* __alpha */
+
+ /* Insert your combination here... */
+ #if defined(__FOOCPU__) && defined(__BAROS__)
+ # define malloc_pageshift 12U
+ # define malloc_minsize 16U
+ #endif /* __FOOCPU__ && __BAROS__ */
+
+
+ /*
+ * No user serviceable parts behind this point.
+ */
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+ #include
+
+ /*
+ * This structure describes a page worth of chunks.
+ */
+
+ struct pginfo {
+ struct pginfo *next; /* next on the free list */
+ void *page; /* Pointer to the page */
+ u_short size; /* size of this page's chunks */
+ u_short shift; /* How far to shift for this size chunks */
+ u_short free; /* How many free chunks */
+ u_short total; /* How many chunk */
+ u_int bits[1]; /* Which chunks are free */
+ };
+
+ /*
+ * This structure describes a number of free pages.
+ */
+
+ struct pgfree {
+ struct pgfree *next; /* next run of free pages */
+ struct pgfree *prev; /* prev run of free pages */
+ void *page; /* pointer to free pages */
+ void *end; /* pointer to end of free pages */
+ size_t size; /* number of bytes free */
+ };
+
+ /*
+ * How many bits per u_int in the bitmap.
+ * Change only if not 8 bits/byte
+ */
+ #define MALLOC_BITS (8*sizeof(u_int))
+
+ /*
+ * Magic values to put in the page_directory
+ */
+ #define MALLOC_NOT_MINE ((struct pginfo*) 0)
+ #define MALLOC_FREE ((struct pginfo*) 1)
+ #define MALLOC_FIRST ((struct pginfo*) 2)
+ #define MALLOC_FOLLOW ((struct pginfo*) 3)
+ #define MALLOC_MAGIC ((struct pginfo*) 4)
+
+ #ifndef malloc_pageshift
+ #define malloc_pageshift 12U
+ #endif
+
+ #ifndef malloc_minsize
+ #define malloc_minsize 16U
+ #endif
+
+ #if !defined(malloc_pagesize)
+ #define malloc_pagesize (1UL<>1)
+ #endif
+
+ /* A mask for the offset inside a page. */
+ #define malloc_pagemask ((malloc_pagesize)-1)
+
+ #define pageround(foo) (((foo) + (malloc_pagemask))&(~(malloc_pagemask)))
+ #define ptr2index(foo) (((u_long)(foo) >> malloc_pageshift)-malloc_origo)
+
+ #ifdef _THREAD_SAFE
+ extern int RT0u__inCritical; /* Flag set when in a critical region */
+ #define THREAD_LOCK() (++RT0u__inCritical)
+ #define THREAD_UNLOCK() (--RT0u__inCritical)
+ #endif
+
+ #ifndef THREAD_LOCK
+ #define THREAD_LOCK()
+ #endif
+
+ #ifndef THREAD_UNLOCK
+ #define THREAD_UNLOCK()
+ #endif
+
+ #ifndef MMAP_FD
+ #define MMAP_FD (-1)
+ #endif
+
+ #ifndef INIT_MMAP
+ #define INIT_MMAP()
+ #endif
+
+ /* This is needed at least by HP-UX 10.20 */
+ #if !defined(MAP_ANON) && defined(MAP_ANONYMOUS)
+ #define MAP_ANON MAP_ANONYMOUS
+ #endif
+
+ /* Set when initialization has been done */
+ static unsigned malloc_started;
+
+ /* Recusion flag for public interface. */
+ static int malloc_active;
+
+ /* Number of free pages we cache */
+ static unsigned malloc_cache = 16;
+
+ /* The offset from pagenumber to index into the page directory */
+ static u_long malloc_origo;
+
+ /* The last index in the page directory we care about */
+ static u_long last_index;
+
+ /* Pointer to page directory. Allocated "as if with" malloc */
+ static struct pginfo **page_dir;
+
+ /* How many slots in the page directory */
+ static unsigned malloc_ninfo;
+
+ /* Free pages line up here */
+ static struct pgfree free_list;
+
+ /* Abort(), user doesn't handle problems. */
+ static int malloc_abort;
+
+ /* Are we trying to die ? */
+ static int suicide;
+
+ /* always realloc ? */
+ static int malloc_realloc;
+
+ /* pass the kernel a hint on free pages ? */
+ static int malloc_hint = 1;
+
+ /* xmalloc behaviour ? */
+ static int malloc_xmalloc;
+
+ /* sysv behaviour for malloc(0) ? */
+ static int malloc_sysv;
+
+ /* zero fill ? */
+ static int malloc_zero;
+
+ /* junk fill ? */
+ static int malloc_junk;
+
+ #ifdef HAS_UTRACE
+
+ /* utrace ? */
+ static int malloc_utrace;
+
+ struct ut { void *p; size_t s; void *r; };
+
+ void utrace __P((struct ut *, int));
+
+ #define UTRACE(a, b, c) \
+ if (malloc_utrace) \
+ {struct ut u; u.p=a; u.s = b; u.r=c; utrace(&u, sizeof u);}
+ #else /* !HAS_UTRACE */
+ #define UTRACE(a,b,c)
+ #endif /* HAS_UTRACE */
+
+ /* my last break. */
+ static void *malloc_brk;
+
+ /* one location cache for free-list holders */
+ static struct pgfree *px;
+
+ /* compile-time options */
+ char *malloc_options;
+
+ /* Name of the current public function */
+ static char *malloc_func;
+
+ /* Macro for mmap */
+ #define MMAP(size) \
+ mmap((caddr_t)0, (size), PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, \
+ MMAP_FD, 0);
+
+ /*
+ * Necessary function declarations
+ */
+ static int extend_pgdir(u_long index);
+ static void *imalloc(size_t size);
+ static void ifree(void *ptr);
+ static void *irealloc(void *ptr, size_t size);
+
+ static void
+ wrterror(char *p)
+ {
+ char *q = " error: ";
+ write(STDERR_FILENO, malloc_func, strlen(malloc_func));
+ write(STDERR_FILENO, q, strlen(q));
+ write(STDERR_FILENO, p, strlen(p));
+ suicide = 1;
+ abort();
+ }
+
+ static void
+ wrtwarning(char *p)
+ {
+ char *q = " warning: ";
+ if (malloc_abort)
+ wrterror(p);
+ write(STDERR_FILENO, malloc_func, strlen(malloc_func));
+ write(STDERR_FILENO, q, strlen(q));
+ write(STDERR_FILENO, p, strlen(p));
+ }
+
+
+ /*
+ * Allocate a number of pages from the OS
+ */
+ static caddr_t
+ map_pages(int pages)
+ {
+ caddr_t result, tail;
+
+ result = (caddr_t)pageround((u_long)sbrk(0));
+ tail = result + (pages << malloc_pageshift);
+
+ if (brk(tail)) {
+ #ifdef EXTRA_SANITY
+ wrterror("(ES): map_pages fails\n");
+ #endif /* EXTRA_SANITY */
+ return 0;
+ }
+
+ last_index = ptr2index(tail) - 1;
+ malloc_brk = tail;
+
+ if ((last_index+1) >= malloc_ninfo && !extend_pgdir(last_index))
+ return 0;;
+
+ return result;
+ }
+
+ /*
+ * Extend page directory
+ */
+ static int
+ extend_pgdir(u_long index)
+ {
+ struct pginfo **new, **old;
+ int i, oldlen;
+
+ /* Make it this many pages */
+ i = index * sizeof *page_dir;
+ i /= malloc_pagesize;
+ i += 2;
+
+ /* remember the old mapping size */
+ oldlen = malloc_ninfo * sizeof *page_dir;
+
+ /*
+ * NOTE: we allocate new pages and copy the directory rather than tempt
+ * fate by trying to "grow" the region.. There is nothing to prevent
+ * us from accidently re-mapping space that's been allocated by our caller
+ * via dlopen() or other mmap().
+ *
+ * The copy problem is not too bad, as there is 4K of page index per
+ * 4MB of malloc arena.
+ *
+ * We can totally avoid the copy if we open a file descriptor to associate
+ * the anon mappings with. Then, when we remap the pages at the new
+ * address, the old pages will be "magically" remapped.. But this means
+ * keeping open a "secret" file descriptor.....
+ */
+
+ /* Get new pages */
+ new = (struct pginfo**) MMAP(i * malloc_pagesize);
+ if (new == (struct pginfo **)-1)
+ return 0;
+
+ /* Copy the old stuff */
+ memcpy(new, page_dir,
+ malloc_ninfo * sizeof *page_dir);
+
+ /* register the new size */
+ malloc_ninfo = i * malloc_pagesize / sizeof *page_dir;
+
+ /* swap the pointers */
+ old = page_dir;
+ page_dir = new;
+
+ /* Now free the old stuff */
+ munmap((caddr_t)old, oldlen);
+ return 1;
+ }
+
+ /*
+ * Initialize the world
+ */
+ static void
+ malloc_init ()
+ {
+ char *p, b[64];
+ int i, j;
+
+ INIT_MMAP();
+
+ #ifdef EXTRA_SANITY
+ malloc_junk = 1;
+ #endif /* EXTRA_SANITY */
+
+ for (i = 0; i < 3; i++) {
+ if (i == 0) {
+ j = readlink("/etc/malloc.conf", b, sizeof b - 1);
+ if (j <= 0)
+ continue;
+ b[j] = '\0';
+ p = b;
+ } else if (i == 1) {
+ p = getenv("MALLOC_OPTIONS");
+ } else {
+ p = malloc_options;
+ }
+ for (; p && *p; p++) {
+ switch (*p) {
+ case '>': malloc_cache <<= 1; break;
+ case '<': malloc_cache >>= 1; break;
+ case 'a': malloc_abort = 0; break;
+ case 'A': malloc_abort = 1; break;
+ case 'h': malloc_hint = 0; break;
+ case 'H': malloc_hint = 1; break;
+ case 'r': malloc_realloc = 0; break;
+ case 'R': malloc_realloc = 1; break;
+ case 'j': malloc_junk = 0; break;
+ case 'J': malloc_junk = 1; break;
+ #ifdef HAS_UTRACE
+ case 'u': malloc_utrace = 0; break;
+ case 'U': malloc_utrace = 1; break;
+ #endif
+ case 'v': malloc_sysv = 0; break;
+ case 'V': malloc_sysv = 1; break;
+ case 'x': malloc_xmalloc = 0; break;
+ case 'X': malloc_xmalloc = 1; break;
+ case 'z': malloc_zero = 0; break;
+ case 'Z': malloc_zero = 1; break;
+ default:
+ j = malloc_abort;
+ malloc_abort = 0;
+ wrtwarning("unknown char in MALLOC_OPTIONS\n");
+ malloc_abort = j;
+ break;
+ }
+ }
+ }
+
+ UTRACE(0, 0, 0);
+
+ /*
+ * We want junk in the entire allocation, and zero only in the part
+ * the user asked for.
+ */
+ if (malloc_zero)
+ malloc_junk=1;
+
+ /*
+ * If we run with junk (or implicitly from above: zero), we want to
+ * force realloc() to get new storage, so we can DTRT with it.
+ */
+ if (malloc_junk)
+ malloc_realloc=1;
+
+ /* Allocate one page for the page directory */
+ page_dir = (struct pginfo **) MMAP(malloc_pagesize);
+
+ if (page_dir == (struct pginfo **) -1)
+ wrterror("mmap(2) failed, check limits.\n");
+
+ /*
+ * We need a maximum of malloc_pageshift buckets, steal these from the
+ * front of the page_directory;
+ */
+ malloc_origo = ((u_long)pageround((u_long)sbrk(0))) >> malloc_pageshift;
+ malloc_origo -= malloc_pageshift;
+
+ malloc_ninfo = malloc_pagesize / sizeof *page_dir;
+
+ /* Recalculate the cache size in bytes, and make sure it's nonzero */
+
+ if (!malloc_cache)
+ malloc_cache++;
+
+ malloc_cache <<= malloc_pageshift;
+
+ /*
+ * This is a nice hack from Kaleb Keithly (kaleb@x.org).
+ * We can sbrk(2) further back when we keep this on a low address.
+ */
+ px = (struct pgfree *) imalloc (sizeof *px);
+
+ /* Been here, done that */
+ malloc_started++;
+ }
+
+ /*
+ * Allocate a number of complete pages
+ */
+ static void *
+ malloc_pages(size_t size)
+ {
+ void *p, *delay_free = 0;
+ int i;
+ struct pgfree *pf;
+ u_long index;
+
+ size = pageround(size);
+
+ p = 0;
+
+ /* Look for free pages before asking for more */
+ for(pf = free_list.next; pf; pf = pf->next) {
+
+ #ifdef EXTRA_SANITY
+ if (pf->size & malloc_pagemask)
+ wrterror("(ES): junk length entry on free_list\n");
+ if (!pf->size)
+ wrterror("(ES): zero length entry on free_list\n");
+ if (pf->page == pf->end)
+ wrterror("(ES): zero entry on free_list\n");
+ if (pf->page > pf->end)
+ wrterror("(ES): sick entry on free_list\n");
+ if ((void*)pf->page >= (void*)sbrk(0))
+ wrterror("(ES): entry on free_list past brk\n");
+ if (page_dir[ptr2index(pf->page)] != MALLOC_FREE)
+ wrterror("(ES): non-free first page on free-list\n");
+ if (page_dir[ptr2index(pf->end)-1] != MALLOC_FREE)
+ wrterror("(ES): non-free last page on free-list\n");
+ #endif /* EXTRA_SANITY */
+
+ if (pf->size < size)
+ continue;
+
+ if (pf->size == size) {
+ p = pf->page;
+ if (pf->next)
+ pf->next->prev = pf->prev;
+ pf->prev->next = pf->next;
+ delay_free = pf;
+ break;
+ }
+
+ p = pf->page;
+ pf->page = (char *)pf->page + size;
+ pf->size -= size;
+ break;
+ }
+
+ #ifdef EXTRA_SANITY
+ if (p && page_dir[ptr2index(p)] != MALLOC_FREE)
+ wrterror("(ES): allocated non-free page on free-list\n");
+ #endif /* EXTRA_SANITY */
+
+ size >>= malloc_pageshift;
+
+ /* Map new pages */
+ if (!p)
+ p = map_pages(size);
+
+ if (p) {
+
+ index = ptr2index(p);
+ page_dir[index] = MALLOC_FIRST;
+ for (i=1;ibits[0] *
+ (((malloc_pagesize >> bits)+MALLOC_BITS-1) / MALLOC_BITS);
+
+ /* Don't waste more than two chunks on this */
+ if ((1<<(bits)) <= l+l) {
+ bp = (struct pginfo *)pp;
+ } else {
+ bp = (struct pginfo *)imalloc(l);
+ if (!bp) {
+ ifree(pp);
+ return 0;
+ }
+ }
+
+ bp->size = (1<shift = bits;
+ bp->total = bp->free = malloc_pagesize >> bits;
+ bp->page = pp;
+
+ /* set all valid bits in the bitmap */
+ k = bp->total;
+ i = 0;
+
+ /* Do a bunch at a time */
+ for(;k-i >= MALLOC_BITS; i += MALLOC_BITS)
+ bp->bits[i / MALLOC_BITS] = ~0;
+
+ for(; i < k; i++)
+ bp->bits[i/MALLOC_BITS] |= 1<<(i%MALLOC_BITS);
+
+ if (bp == bp->page) {
+ /* Mark the ones we stole for ourselves */
+ for(i=0;l > 0;i++) {
+ bp->bits[i/MALLOC_BITS] &= ~(1<<(i%MALLOC_BITS));
+ bp->free--;
+ bp->total--;
+ l -= (1 << bits);
+ }
+ }
+
+ /* MALLOC_LOCK */
+
+ page_dir[ptr2index(pp)] = bp;
+
+ bp->next = page_dir[bits];
+ page_dir[bits] = bp;
+
+ /* MALLOC_UNLOCK */
+
+ return 1;
+ }
+
+ /*
+ * Allocate a fragment
+ */
+ static void *
+ malloc_bytes(size_t size)
+ {
+ int i,j;
+ u_int u;
+ struct pginfo *bp;
+ int k;
+ u_int *lp;
+
+ /* Don't bother with anything less than this */
+ if (size < malloc_minsize)
+ size = malloc_minsize;
+
+ /* Find the right bucket */
+ j = 1;
+ i = size-1;
+ while (i >>= 1)
+ j++;
+
+ /* If it's empty, make a page more of that size chunks */
+ if (!page_dir[j] && !malloc_make_chunks(j))
+ return 0;
+
+ bp = page_dir[j];
+
+ /* Find first word of bitmap which isn't empty */
+ for (lp = bp->bits; !*lp; lp++)
+ ;
+
+ /* Find that bit, and tweak it */
+ u = 1;
+ k = 0;
+ while (!(*lp & u)) {
+ u += u;
+ k++;
+ }
+ *lp ^= u;
+
+ /* If there are no more free, remove from free-list */
+ if (!--bp->free) {
+ page_dir[j] = bp->next;
+ bp->next = 0;
+ }
+
+ /* Adjust to the real offset of that chunk */
+ k += (lp-bp->bits)*MALLOC_BITS;
+ k <<= bp->shift;
+
+ if (malloc_junk)
+ memset((u_char*)bp->page + k, SOME_JUNK, bp->size);
+
+ return (u_char *)bp->page + k;
+ }
+
+ /*
+ * Allocate a piece of memory
+ */
+ static void *
+ imalloc(size_t size)
+ {
+ void *result;
+
+ if (suicide)
+ abort();
+
+ if ((size + malloc_pagesize) < size) /* Check for overflow */
+ result = 0;
+ else if (size <= malloc_maxsize)
+ result = malloc_bytes(size);
+ else
+ result = malloc_pages(size);
+
+ if (malloc_abort && !result)
+ wrterror("allocation failed.\n");
+
+ if (malloc_zero && result)
+ memset(result, 0, size);
+
+ return result;
+ }
+
+ /*
+ * Change the size of an allocation.
+ */
+ static void *
+ irealloc(void *ptr, size_t size)
+ {
+ void *p;
+ u_long osize, index;
+ struct pginfo **mp;
+ int i;
+
+ if (suicide)
+ abort();
+
+ index = ptr2index(ptr);
+
+ if (index < malloc_pageshift) {
+ wrtwarning("junk pointer, too low to make sense.\n");
+ return 0;
+ }
+
+ if (index > last_index) {
+ wrtwarning("junk pointer, too high to make sense.\n");
+ return 0;
+ }
+
+ mp = &page_dir[index];
+
+ if (*mp == MALLOC_FIRST) { /* Page allocation */
+
+ /* Check the pointer */
+ if ((u_long)ptr & malloc_pagemask) {
+ wrtwarning("modified (page-) pointer.\n");
+ return 0;
+ }
+
+ /* Find the size in bytes */
+ for (osize = malloc_pagesize; *++mp == MALLOC_FOLLOW;)
+ osize += malloc_pagesize;
+
+ if (!malloc_realloc && /* unless we have to, */
+ size <= osize && /* .. or are too small, */
+ size > (osize - malloc_pagesize)) { /* .. or can free a page, */
+ return ptr; /* don't do anything. */
+ }
+
+ } else if (*mp >= MALLOC_MAGIC) { /* Chunk allocation */
+
+ /* Check the pointer for sane values */
+ if (((u_long)ptr & ((*mp)->size-1))) {
+ wrtwarning("modified (chunk-) pointer.\n");
+ return 0;
+ }
+
+ /* Find the chunk index in the page */
+ i = ((u_long)ptr & malloc_pagemask) >> (*mp)->shift;
+
+ /* Verify that it isn't a free chunk already */
+ if ((*mp)->bits[i/MALLOC_BITS] & (1<<(i%MALLOC_BITS))) {
+ wrtwarning("chunk is already free.\n");
+ return 0;
+ }
+
+ osize = (*mp)->size;
+
+ if (!malloc_realloc && /* Unless we have to, */
+ size < osize && /* ..or are too small, */
+ (size > osize/2 || /* ..or could use a smaller size, */
+ osize == malloc_minsize)) { /* ..(if there is one) */
+ return ptr; /* ..Don't do anything */
+ }
+
+ } else {
+ wrtwarning("pointer to wrong page.\n");
+ return 0;
+ }
+
+ p = imalloc(size);
+
+ if (p) {
+ /* copy the lesser of the two sizes, and free the old one */
+ if (!size || !osize)
+ ;
+ else if (osize < size)
+ memcpy(p, ptr, osize);
+ else
+ memcpy(p, ptr, size);
+ ifree(ptr);
+ }
+ return p;
+ }
+
+ /*
+ * Free a sequence of pages
+ */
+
+ static __inline__ void
+ free_pages(void *ptr, int index, struct pginfo *info)
+ {
+ int i;
+ struct pgfree *pf, *pt=0;
+ u_long l;
+ void *tail;
+
+ if (info == MALLOC_FREE) {
+ wrtwarning("page is already free.\n");
+ return;
+ }
+
+ if (info != MALLOC_FIRST) {
+ wrtwarning("pointer to wrong page.\n");
+ return;
+ }
+
+ if ((u_long)ptr & malloc_pagemask) {
+ wrtwarning("modified (page-) pointer.\n");
+ return;
+ }
+
+ /* Count how many pages and mark them free at the same time */
+ page_dir[index] = MALLOC_FREE;
+ for (i = 1; page_dir[index+i] == MALLOC_FOLLOW; i++)
+ page_dir[index + i] = MALLOC_FREE;
+
+ l = i << malloc_pageshift;
+
+ if (malloc_junk)
+ memset(ptr, SOME_JUNK, l);
+
+ #ifdef MADV_FREE
+ if (malloc_hint)
+ madvise(ptr, l, MADV_FREE);
+ #endif
+
+ tail = (char *)ptr+l;
+
+ /* add to free-list */
+ if (!px)
+ px = imalloc(sizeof *pt); /* This cannot fail... */
+ px->page = ptr;
+ px->end = tail;
+ px->size = l;
+ if (!free_list.next) {
+
+ /* Nothing on free list, put this at head */
+ px->next = free_list.next;
+ px->prev = &free_list;
+ free_list.next = px;
+ pf = px;
+ px = 0;
+
+ } else {
+
+ /* Find the right spot, leave pf pointing to the modified entry. */
+ tail = (char *)ptr+l;
+
+ for(pf = free_list.next; pf->end < ptr && pf->next; pf = pf->next)
+ ; /* Race ahead here */
+
+ if (pf->page > tail) {
+ /* Insert before entry */
+ px->next = pf;
+ px->prev = pf->prev;
+ pf->prev = px;
+ px->prev->next = px;
+ pf = px;
+ px = 0;
+ } else if (pf->end == ptr ) {
+ /* Append to the previous entry */
+ pf->end = (char *)pf->end + l;
+ pf->size += l;
+ if (pf->next && pf->end == pf->next->page ) {
+ /* And collapse the next too. */
+ pt = pf->next;
+ pf->end = pt->end;
+ pf->size += pt->size;
+ pf->next = pt->next;
+ if (pf->next)
+ pf->next->prev = pf;
+ }
+ } else if (pf->page == tail) {
+ /* Prepend to entry */
+ pf->size += l;
+ pf->page = ptr;
+ } else if (!pf->next) {
+ /* Append at tail of chain */
+ px->next = 0;
+ px->prev = pf;
+ pf->next = px;
+ pf = px;
+ px = 0;
+ } else {
+ wrterror("freelist is destroyed.\n");
+ }
+ }
+
+ /* Return something to OS ? */
+ if (!pf->next && /* If we're the last one, */
+ pf->size > malloc_cache && /* ..and the cache is full, */
+ pf->end == malloc_brk && /* ..and none behind us, */
+ malloc_brk == sbrk(0)) { /* ..and it's OK to do... */
+
+ /*
+ * Keep the cache intact. Notice that the '>' above guarantees that
+ * the pf will always have at least one page afterwards.
+ */
+ pf->end = (char *)pf->page + malloc_cache;
+ pf->size = malloc_cache;
+
+ brk(pf->end);
+ malloc_brk = pf->end;
+
+ index = ptr2index(pf->end);
+ last_index = index - 1;
+
+ for(i=index;i <= last_index;)
+ page_dir[i++] = MALLOC_NOT_MINE;
+
+ /* XXX: We could realloc/shrink the pagedir here I guess. */
+ }
+ if (pt)
+ ifree(pt);
+ }
+
+ /*
+ * Free a chunk, and possibly the page it's on, if the page becomes empty.
+ */
+
+ static __inline__ void
+ free_bytes(void *ptr, int index, struct pginfo *info)
+ {
+ int i;
+ struct pginfo **mp;
+ void *vp;
+
+ /* Find the chunk number on the page */
+ i = ((u_long)ptr & malloc_pagemask) >> info->shift;
+
+ if (((u_long)ptr & (info->size-1))) {
+ wrtwarning("modified (chunk-) pointer.\n");
+ return;
+ }
+
+ if (info->bits[i/MALLOC_BITS] & (1<<(i%MALLOC_BITS))) {
+ wrtwarning("chunk is already free.\n");
+ return;
+ }
+
+ if (malloc_junk)
+ memset(ptr, SOME_JUNK, info->size);
+
+ info->bits[i/MALLOC_BITS] |= 1<<(i%MALLOC_BITS);
+ info->free++;
+
+ mp = page_dir + info->shift;
+
+ if (info->free == 1) {
+
+ /* Page became non-full */
+
+ mp = page_dir + info->shift;
+ /* Insert in address order */
+ while (*mp && (*mp)->next && (*mp)->next->page < info->page)
+ mp = &(*mp)->next;
+ info->next = *mp;
+ *mp = info;
+ return;
+ }
+
+ if (info->free != info->total)
+ return;
+
+ /* Find & remove this page in the queue */
+ while (*mp != info) {
+ mp = &((*mp)->next);
+ #ifdef EXTRA_SANITY
+ if (!*mp)
+ wrterror("(ES): Not on queue\n");
+ #endif /* EXTRA_SANITY */
+ }
+ *mp = info->next;
+
+ /* Free the page & the info structure if need be */
+ page_dir[ptr2index(info->page)] = MALLOC_FIRST;
+ vp = info->page; /* Order is important ! */
+ if(vp != (void*)info)
+ ifree(info);
+ ifree(vp);
+ }
+
+ static void
+ ifree(void *ptr)
+ {
+ struct pginfo *info;
+ int index;
+
+ /* This is legal */
+ if (!ptr)
+ return;
+
+ if (!malloc_started) {
+ wrtwarning("malloc() has never been called.\n");
+ return;
+ }
+
+ /* If we're already sinking, don't make matters any worse. */
+ if (suicide)
+ return;
+
+ index = ptr2index(ptr);
+
+ if (index < malloc_pageshift) {
+ wrtwarning("junk pointer, too low to make sense.\n");
+ return;
+ }
+
+ if (index > last_index) {
+ wrtwarning("junk pointer, too high to make sense.\n");
+ return;
+ }
+
+ info = page_dir[index];
+
+ if (info < MALLOC_MAGIC)
+ free_pages(ptr, index, info);
+ else
+ free_bytes(ptr, index, info);
+ return;
+ }
+
+ /*
+ * These are the public exported interface routines.
+ */
+
+
+ void *
+ malloc(size_t size)
+ {
+ register void *r;
+
+ malloc_func = " in malloc():";
+ THREAD_LOCK();
+ if (malloc_active++) {
+ wrtwarning("recursive call.\n");
+ malloc_active--;
+ return (0);
+ }
+ if (!malloc_started)
+ malloc_init();
+ if (malloc_sysv && !size)
+ r = 0;
+ else
+ r = imalloc(size);
+ UTRACE(0, size, r);
+ malloc_active--;
+ THREAD_UNLOCK();
+ if (malloc_xmalloc && !r)
+ wrterror("out of memory.\n");
+ return (r);
+ }
+
+ void
+ free(void *ptr)
+ {
+ malloc_func = " in free():";
+ THREAD_LOCK();
+ if (malloc_active++) {
+ wrtwarning("recursive call.\n");
+ malloc_active--;
+ return;
+ }
+ ifree(ptr);
+ UTRACE(ptr, 0, 0);
+ malloc_active--;
+ THREAD_UNLOCK();
+ return;
+ }
+
+ void *
+ realloc(void *ptr, size_t size)
+ {
+ register void *r;
+
+ malloc_func = " in realloc():";
+ THREAD_LOCK();
+ if (malloc_active++) {
+ wrtwarning("recursive call.\n");
+ malloc_active--;
+ return (0);
+ }
+ if (ptr && !malloc_started) {
+ wrtwarning("malloc() has never been called.\n");
+ ptr = 0;
+ }
+ if (!malloc_started)
+ malloc_init();
+ if (malloc_sysv && !size) {
+ ifree(ptr);
+ r = 0;
+ } else if (!ptr) {
+ r = imalloc(size);
+ } else {
+ r = irealloc(ptr, size);
+ }
+ UTRACE(ptr, size, r);
+ malloc_active--;
+ THREAD_UNLOCK();
+ if (malloc_xmalloc && !r)
+ wrterror("out of memory.\n");
+ return (r);
+ }
+
+ void *
+ calloc(size_t num, size_t size)
+ {
+ register void *r;
+
+ size *= num;
+ r = malloc(size);
+ if (r)
+ memset(r, 0, size);
+ return (r);
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/read.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/read.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/read.c Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,15 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ ssize_t
+ m3_read(int d, void *buf, size_t nbytes)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(buf);
+ result = read(d, buf, nbytes);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/recv.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/recv.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/recv.c Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,15 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ ssize_t
+ m3_recv(int s, void *buf, size_t len, int flags)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(buf);
+ result = recv(s, buf, len, flags);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/recvfrom.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/recvfrom.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/recvfrom.c Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,18 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ ssize_t
+ m3_recvfrom(int s, void *buf, size_t len, int flags,
+ struct sockaddr *from, int *fromlen)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(buf);
+ MAKE_WRITABLE(from);
+ MAKE_WRITABLE(fromlen);
+ result = recvfrom(s, buf, len, flags, from, fromlen);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/select.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/select.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/select.c Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,20 ----
+ #include "wrap.h"
+ #include
+ #include
+ #include
+
+ int
+ m3_select(int nfds, fd_set *readfds, fd_set *writefds,
+ fd_set *exceptfds, struct timeval *timeout)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_WRITABLE(readfds);
+ MAKE_WRITABLE(writefds);
+ MAKE_WRITABLE(exceptfds);
+ MAKE_READABLE(timeout);
+ result = select(nfds, readfds, writefds, exceptfds, timeout);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/send.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/send.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/send.c Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,15 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ ssize_t
+ m3_send(int s, const void *msg, size_t len, int flags)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(msg);
+ result = send(s, msg, len, flags);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/sendto.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/sendto.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/sendto.c Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,17 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ ssize_t
+ m3_sendto(int s, const void *msg, size_t len, int flags,
+ const struct sockaddr *to, int tolen)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(msg);
+ MAKE_READABLE(to);
+ result = sendto(s, msg, len, flags, to, tolen);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/shutdown.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/shutdown.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/shutdown.c Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,14 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ int
+ m3_shutdown(int s, int how)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ result = shutdown(s, how);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/socket.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/socket.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/socket.c Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,14 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ int
+ m3_socket(int domain, int type, int protocol)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ result = socket(domain, type, protocol);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/socksconf.h
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/socksconf.h:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/socksconf.h Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,6 ----
+ /*
+ * Define 0 or 1 of these, to select the variety of SOCKS support you want.
+ */
+ #undef HPSOCKS
+ #undef SOCKS4
+ #undef SOCKS5
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/wrap.h
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/wrap.h:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/wrap.h Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,61 ----
+ #include "socksconf.h"
+
+ #if defined(HPSOCKS) /* { */
+ #define accept Raccept
+ #define bind Rxbind
+ #define close Rclose
+ #define connect Rconnect
+ #define dup Rdup
+ #define dup2 Rdup2
+ #define gethostbyaddr Rgethostbyaddr
+ #define gethostbyname Rgethostbyname
+ #define getpeername Rgetpeername
+ #define getsockname Rgetsockname
+ #define listen Rlisten
+ #define recv Rrecv
+ #define recvfrom Rrecvfrom
+ #define send Rsend
+ #define sendto Rsendto
+ #define shutdown Rshutdown
+ #define socket Rsocket
+ #elif defined(SOCKS4) /* } { */
+ #define accept Raccept
+ #define bind Rbind
+ #define connect Rconnect
+ #define getpeername Rgetpeername
+ #define getsockname Rgetsockname
+ #define listen Rlisten
+ #define select Rselect
+ #elif defined(SOCKS5) /* } { */
+ #define accept SOCKSaccept
+ #define bind SOCKSbind
+ #define close SOCKSclose
+ #define connect SOCKSconnect
+ #define dup SOCKSdup
+ #define dup2 SOCKSdup2
+ #define fclose SOCKSfclose
+ #define gethostbyname SOCKSgethostbyname
+ #define getpeername SOCKSgetpeername
+ #define getsockname SOCKSgetsockname
+ #define listen SOCKSlisten
+ #define read SOCKSread
+ #define recv SOCKSrecv
+ #define recvfrom SOCKSrecvfrom
+ #define rresvport SOCKSrresvport
+ #define select SOCKSselect
+ #define send SOCKSsend
+ #define sendto SOCKSsendto
+ #define shutdown SOCKSshutdown
+ #define write SOCKSwrite
+ #endif /* } */
+
+ extern int RT0u__inCritical;
+ #define ENTER_CRITICAL RT0u__inCritical++
+ #define EXIT_CRITICAL RT0u__inCritical--
+
+ static char RTHeapDepC__c;
+ #define MAKE_READABLE(x) \
+ if ((int)x) { RTHeapDepC__c = *(char*)(x); }
+
+ #define MAKE_WRITABLE(x) \
+ if ((int)x) { *(char*)(x) = RTHeapDepC__c = *(char*)(x); }
Index: m3/pm3/libs/m3core/src/runtime/FreeBSD3/write.c
diff -c /dev/null m3/pm3/libs/m3core/src/runtime/FreeBSD3/write.c:1.1
*** /dev/null Mon Jun 7 17:09:11 1999
--- m3/pm3/libs/m3core/src/runtime/FreeBSD3/write.c Mon Jun 7 13:14:39 1999
***************
*** 0 ****
--- 1,15 ----
+ #include "wrap.h"
+ #include
+ #include
+
+ size_t
+ m3_write(int fd, const void *buf, int nbytes)
+ {
+ int result;
+
+ ENTER_CRITICAL;
+ MAKE_READABLE(buf);
+ result = write(fd, buf, nbytes);
+ EXIT_CRITICAL;
+ return result;
+ }
Index: m3/pm3/libs/m3core/src/runtime/LINUXLIBC6/RTHeapDepC.c
diff -c m3/pm3/libs/m3core/src/runtime/LINUXLIBC6/RTHeapDepC.c:1.6 m3/pm3/libs/m3core/src/runtime/LINUXLIBC6/RTHeapDepC.c:1.7
*** m3/pm3/libs/m3core/src/runtime/LINUXLIBC6/RTHeapDepC.c:1.6 Fri Jan 29 20:54:59 1999
--- m3/pm3/libs/m3core/src/runtime/LINUXLIBC6/RTHeapDepC.c Mon Jun 7 13:14:44 1999
***************
*** 104,115 ****
#include
#include