aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkinori Ito <aito@eie.yz.yamagata-u.ac.jp>2001-11-15 00:32:13 +0000
committerAkinori Ito <aito@eie.yz.yamagata-u.ac.jp>2001-11-15 00:32:13 +0000
commit85da7ee692072c643939e9f4b24fbd1e74e64e70 (patch)
tree9fc63298cf968fa560a9e3cf9b6c84516032fca8
parentUpdates from 0.2.1 into 0.2.1-inu-1.5 (diff)
downloadw3m-85da7ee692072c643939e9f4b24fbd1e74e64e70.tar.gz
w3m-85da7ee692072c643939e9f4b24fbd1e74e64e70.zip
Update to w3m-0.2.1-inu-1.6.
-rw-r--r--Str.c2
-rw-r--r--Str.h2
-rw-r--r--anchor.c2
-rwxr-xr-xconfigure28
-rw-r--r--cookie.c2
-rw-r--r--display.c2
-rw-r--r--etc.c28
-rw-r--r--file.c10
-rw-r--r--fm.h2
-rw-r--r--form.c2
-rw-r--r--frame.c32
-rw-r--r--funcname.tab1
-rw-r--r--gc/alpha_mach_dep.s2
-rw-r--r--gc/config.guess1121
-rw-r--r--gc/config.sub1232
-rw-r--r--gc/doc/README617
-rw-r--r--gc/doc/README.Mac385
-rw-r--r--gc/doc/README.MacOSX27
-rw-r--r--gc/doc/README.OS26
-rw-r--r--gc/doc/README.amiga322
-rw-r--r--gc/doc/README.autoconf59
-rw-r--r--gc/doc/README.changes1408
-rw-r--r--gc/doc/README.contributors57
-rw-r--r--gc/doc/README.cords53
-rw-r--r--gc/doc/README.dj12
-rw-r--r--gc/doc/README.environment44
-rw-r--r--gc/doc/README.hp18
-rw-r--r--gc/doc/README.linux135
-rw-r--r--gc/doc/README.macros78
-rw-r--r--gc/doc/README.rs60009
-rw-r--r--gc/doc/README.sgi41
-rw-r--r--gc/doc/README.solaris262
-rw-r--r--gc/doc/README.uts2
-rw-r--r--gc/doc/README.win32149
-rw-r--r--gc/doc/barrett_diagram106
-rw-r--r--gc/doc/debugging.html289
-rw-r--r--gc/doc/gc.man80
-rw-r--r--gc/doc/gcdescr.html438
-rw-r--r--gc/doc/tree.html198
-rw-r--r--gc/solaris_pthreads.c2
-rw-r--r--gc/tests/leak_test.c21
-rw-r--r--gc/tests/test.c1660
-rw-r--r--gc/tests/test_cpp.cc277
-rw-r--r--gc/tests/thread_leak_test.c40
-rw-r--r--gc/tests/trace_test.c28
-rw-r--r--html.c2
-rw-r--r--html.h3
-rw-r--r--indep.c10
-rw-r--r--indep.h3
-rw-r--r--istream.c2
-rw-r--r--istream.h2
-rw-r--r--keybind.c2
-rw-r--r--linein.c2
-rw-r--r--local.c41
-rw-r--r--mailcap.c2
-rw-r--r--main.c188
-rw-r--r--matrix.c2
-rw-r--r--matrix.h2
-rw-r--r--proto.h9
-rw-r--r--rc.c14
-rw-r--r--regex.c22
-rw-r--r--scripts/bm2menu/README21
-rw-r--r--scripts/bm2menu/bm2menu.pl58
-rw-r--r--scripts/dirlist.cgi2
-rw-r--r--scripts/multipart/Makefile35
-rw-r--r--scripts/multipart/README24
-rw-r--r--scripts/multipart/mailcap1
-rw-r--r--scripts/multipart/multipart.cgi272
-rw-r--r--scripts/multipart/multipart.cgi.in272
-rw-r--r--scripts/w3mman/Makefile46
-rw-r--r--scripts/w3mman/README47
-rw-r--r--scripts/w3mman/hlink.cgi97
-rw-r--r--scripts/w3mman/w3mman41
-rw-r--r--scripts/w3mman/w3mman.in41
-rw-r--r--scripts/w3mman/w3mman2html.cgi252
-rw-r--r--scripts/w3mman/w3mman2html.cgi.in252
-rw-r--r--table.c2
-rw-r--r--table.h2
-rw-r--r--terms.c18
-rw-r--r--textlist.c2
-rw-r--r--url.c233
-rw-r--r--version.c2
82 files changed, 10900 insertions, 217 deletions
diff --git a/Str.c b/Str.c
index a718607..ce2b818 100644
--- a/Str.c
+++ b/Str.c
@@ -1,4 +1,4 @@
-/* $Id: Str.c,v 1.2 2001/11/09 04:59:17 a-ito Exp $ */
+/* $Id: Str.c,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */
/*
* String manipulation library for Boehm GC
*
diff --git a/Str.h b/Str.h
index 6fefbde..288000d 100644
--- a/Str.h
+++ b/Str.h
@@ -1,4 +1,4 @@
-/* $Id: Str.h,v 1.2 2001/11/09 04:59:17 a-ito Exp $ */
+/* $Id: Str.h,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */
/*
* String manipulation library for Boehm GC
*
diff --git a/anchor.c b/anchor.c
index 855585e..3189756 100644
--- a/anchor.c
+++ b/anchor.c
@@ -1,4 +1,4 @@
-/* $Id: anchor.c,v 1.2 2001/11/09 04:59:17 a-ito Exp $ */
+/* $Id: anchor.c,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */
#ifdef __EMX__
#include <strings.h>
#endif
diff --git a/configure b/configure
index 344f29f..9782835 100755
--- a/configure
+++ b/configure
@@ -1316,6 +1316,23 @@ else
srandom_flg="#undef HAVE_SRANDOM"
fi
+####### getpassphrase
+cat > _zmachdep.c << EOF
+#include <unistd.h>
+main()
+{
+ getpassphrase("");
+}
+EOF
+if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1
+then
+ echo "You have getpassphrase()."
+ getpassphrase_flg="#define HAVE_GETPASSPHRASE"
+else
+ echo "You don't have getpassphrase()."
+ getpassphrase_flg="#undef HAVE_GETPASSPHRASE"
+fi
+
####### fclose
cat > _zmachdep.c << EOF
#include <stdio.h>
@@ -1750,6 +1767,11 @@ $def_ansi_color
*/
#undef NEXTPAGE_TOPLINE
+/*
+ Use alarm function.
+ */
+#undef USE_ALARM
+
/**********************************************************/
#ifdef makefile_parameter
@@ -1840,7 +1862,7 @@ $setenv_flg
$putenv_flg
$srand48_flg
$srandom_flg
-$readlink_flg
+$getpassphrase_flg
$fclose_dcl
$pclose_dcl
$setjmp_def
@@ -1882,6 +1904,10 @@ $no_float_h
#define SUPPORT_DOS_DRIVE_PREFIX 1
#endif
+#if defined( __CYGWIN__ )
+#define SUPPORT_NETBIOS_SHARE 1
+#endif
+
#endif /* makefile_parameter */
#endif /* _CONFIGURED_ */
diff --git a/cookie.c b/cookie.c
index 9fd9c32..e736a05 100644
--- a/cookie.c
+++ b/cookie.c
@@ -1,4 +1,4 @@
-/* $Id: cookie.c,v 1.2 2001/11/09 04:59:17 a-ito Exp $ */
+/* $Id: cookie.c,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */
/*
* References for version 0 cookie:
diff --git a/display.c b/display.c
index 57739c9..1d8a664 100644
--- a/display.c
+++ b/display.c
@@ -1,4 +1,4 @@
-/* $Id: display.c,v 1.2 2001/11/09 04:59:17 a-ito Exp $ */
+/* $Id: display.c,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */
#include <signal.h>
#include "fm.h"
diff --git a/etc.c b/etc.c
index c94f04a..d568f60 100644
--- a/etc.c
+++ b/etc.c
@@ -1,4 +1,4 @@
-/* $Id: etc.c,v 1.2 2001/11/09 04:59:17 a-ito Exp $ */
+/* $Id: etc.c,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */
#include "fm.h"
#include <pwd.h>
#include "myctype.h"
@@ -1215,12 +1215,28 @@ char *
file_to_url(char *file)
{
Str tmp;
-#if defined( __CYGWIN__ ) || defined( __EMX__ )
+#ifdef SUPPORT_DOS_DRIVE_PREFIX
char *drive = NULL;
#endif
+#ifdef SUPPORT_NETBIOS_SHARE
+ char *host = NULL;
+#endif
file = expandName(file);
-#if defined( __CYGWIN__ ) || defined( __EMX__ )
+#ifdef SUPPORT_NETBIOS_SHARE
+ if (file[0] == '/' && file[1] == '/') {
+ char *p;
+ file += 2;
+ if (*file) {
+ p = strchr(file, '/');
+ if (p != NULL && p != file) {
+ host = allocStr(file, (p - file));
+ file = p;
+ }
+ }
+ }
+#endif
+#ifdef SUPPORT_DOS_DRIVE_PREFIX
if (IS_ALPHA(file[0]) && file[1] == ':') {
drive = allocStr(file, 2);
file += 2;
@@ -1234,7 +1250,11 @@ file_to_url(char *file)
file = tmp->ptr;
}
tmp = Strnew_charp("file://");
-#if defined( __CYGWIN__ ) || defined( __EMX__ )
+#ifdef SUPPORT_NETBIOS_SHARE
+ if (host)
+ Strcat_charp(tmp, host);
+#endif
+#ifdef SUPPORT_DOS_DRIVE_PREFIX
if (drive)
Strcat_charp(tmp, drive);
#endif
diff --git a/file.c b/file.c
index aee2f3d..f074582 100644
--- a/file.c
+++ b/file.c
@@ -1,4 +1,4 @@
-/* $Id: file.c,v 1.2 2001/11/09 04:59:17 a-ito Exp $ */
+/* $Id: file.c,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */
#include "fm.h"
#include <sys/types.h>
#include "myctype.h"
@@ -861,7 +861,11 @@ getAuthCookie(char *realm, char *auth_header, TextList * extra_header, ParsedURL
fflush(stdout);
uname = Strfgets(stdin);
Strchop(uname);
+#ifdef HAVE_GETPASSPHRASE
+ pwd = Strnew_charp((char *) getpassphrase(proxy ? "Proxy Password: " : "Password: "));
+#else
pwd = Strnew_charp((char *) getpass(proxy ? "Proxy Password: " : "Password: "));
+#endif
}
Strcat_char(uname, ':');
Strcat(uname, pwd);
@@ -954,7 +958,7 @@ loadGeneralFile(char *path, ParsedURL * current, char *referer, int flag, FormLi
if (UseExternalDirBuffer) {
Str tmp = Strnew_charp(DirBufferCommand);
Strcat_m_charp(tmp, "?dir=",
- pu.file,
+ pu.real_file,
"#current",
NULL);
b = loadGeneralFile(tmp->ptr, NULL, NO_REFERER, 0, NULL);
@@ -2066,9 +2070,9 @@ purgeline(struct html_feed_environ *h_env)
q = p;
if (sloppy_parse_line(&p)) {
Strcat_charp_n(tmp, q, p - q);
- appendTextLine(h_env->buf ,tmp, 0);
}
}
+ appendTextLine(h_env->buf ,tmp, 0);
h_env->blank_lines--;
}
diff --git a/fm.h b/fm.h
index 7aedecc..c9b35bb 100644
--- a/fm.h
+++ b/fm.h
@@ -1,4 +1,4 @@
-/* $Id: fm.h,v 1.2 2001/11/09 04:59:17 a-ito Exp $ */
+/* $Id: fm.h,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */
/*
* w3m: WWW wo Miru utility
*
diff --git a/form.c b/form.c
index 290aeca..a2191ee 100644
--- a/form.c
+++ b/form.c
@@ -1,5 +1,5 @@
-/* $Id: form.c,v 1.2 2001/11/09 04:59:17 a-ito Exp $ */
+/* $Id: form.c,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */
/*
* HTML forms
*/
diff --git a/frame.c b/frame.c
index 46cd8ed..7ae066c 100644
--- a/frame.c
+++ b/frame.c
@@ -1,4 +1,4 @@
-/* $Id: frame.c,v 1.2 2001/11/09 04:59:17 a-ito Exp $ */
+/* $Id: frame.c,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */
#include "fm.h"
#include "parsetagx.h"
#include "myctype.h"
@@ -426,7 +426,7 @@ static int
createFrameFile(struct frameset *f, FILE * f1, Buffer * current, int level, int force_reload)
{
int r, c, t_stack;
- InputStream f2;
+ URLFile f2;
#ifdef JP_CHARSET
char code, ic, charset[2];
#endif /* JP_CHARSET */
@@ -508,6 +508,7 @@ createFrameFile(struct frameset *f, FILE * f1, Buffer * current, int level, int
if (!frame.body->name && f->name) {
frame.body->name = Sprintf("%s_%d", f->name, i)->ptr;
}
+ fflush(f1);
f_frameset = frame_download_source(frame.body,
currentURL,
current->baseURL,
@@ -519,17 +520,20 @@ createFrameFile(struct frameset *f, FILE * f1, Buffer * current, int level, int
}
/* fall through */
case F_BODY:
- f2 = NULL;
- if (frame.body->source == NULL ||
- (f2 = openIS(frame.body->source)) == NULL) {
+ init_stream(&f2, SCM_LOCAL, NULL);
+ if (frame.body->source) {
+ fflush(f1);
+ examineFile(frame.body->source, &f2);
+ }
+ if (f2.stream == NULL) {
frame.body->attr = F_UNLOADED;
if (frame.body->flags & FB_NO_BUFFER)
fprintf(f1, "Open %s with other method", frame.body->url);
- else if (frame.body->url)
+ else if (frame.body->url)
fprintf(f1, "Can't open %s", frame.body->url);
- else
- fprintf(f1, "This frame (%s) contains no src attribute",
- frame.body->name ? frame.body->name : "(no name)");
+ else
+ fprintf(f1, "This frame (%s) contains no src attribute",
+ frame.body->name ? frame.body->name : "(no name)");
break;
}
parseURL2(frame.body->url, &base, currentURL);
@@ -545,7 +549,7 @@ createFrameFile(struct frameset *f, FILE * f1, Buffer * current, int level, int
! strcasecmp(frame.body->type, "text/plain")) {
Str tmp;
fprintf(f1, "<pre>\n");
- while ((tmp = StrmyISgets(f2))->length) {
+ while ((tmp = StrmyUFgets(&f2))->length) {
#ifdef JP_CHARSET
if ((ic = checkShiftCode(tmp, code)) != '\0')
tmp = conv_str(tmp, (code = ic), InnerCode);
@@ -555,14 +559,14 @@ createFrameFile(struct frameset *f, FILE * f1, Buffer * current, int level, int
fprintf(f1, "%s", html_quote(tmp->ptr));
}
fprintf(f1, "</pre>\n");
- ISclose(f2);
+ UFclose(&f2);
break;
}
do {
status = R_ST_NORMAL;
do {
if (*p == '\0') {
- Str tmp = StrmyISgets(f2);
+ Str tmp = StrmyUFgets(&f2);
if (tmp->length == 0 && status != R_ST_NORMAL)
tmp = correct_irrtag(status);
if (tmp->length == 0)
@@ -735,10 +739,10 @@ createFrameFile(struct frameset *f, FILE * f1, Buffer * current, int level, int
}
token_end:
Strclear(tok);
- } while (*p != '\0' || !iseos(f2));
+ } while (*p != '\0' || !iseos(f2.stream));
while (t_stack--)
fputs("</TABLE>\n", f1);
- ISclose(f2);
+ UFclose(&f2);
break;
case F_FRAMESET:
render_frameset:
diff --git a/funcname.tab b/funcname.tab
index 96487cb..8f245c0 100644
--- a/funcname.tab
+++ b/funcname.tab
@@ -3,6 +3,7 @@
@@@ nulcmd
ABORT quitfm
ADD_BOOKMARK adBmark
+ALARM setAlarm
BACK backBf
BEGIN goLineF
BOOKMARK ldBmark
diff --git a/gc/alpha_mach_dep.s b/gc/alpha_mach_dep.s
index 0e6a842..9333dc6 100644
--- a/gc/alpha_mach_dep.s
+++ b/gc/alpha_mach_dep.s
@@ -1,4 +1,4 @@
- # $Id: alpha_mach_dep.s,v 1.2 2001/11/09 04:59:18 a-ito Exp $
+ # $Id: alpha_mach_dep.s,v 1.3 2001/11/15 00:32:13 a-ito Exp $
.arch ev6
.text
diff --git a/gc/config.guess b/gc/config.guess
new file mode 100644
index 0000000..e1b5871
--- /dev/null
+++ b/gc/config.guess
@@ -0,0 +1,1121 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999
+# Free Software Foundation, Inc.
+#
+# This file 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 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# 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 to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Written by Per Bothner <bothner@cygnus.com>.
+# The master version of this file is at the FSF in /home/gd/gnu/lib.
+# Please send patches to <autoconf-patches@gnu.org>.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub. If it succeeds, it prints the system name on stdout, and
+# exits with 0. Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit system type (host/target name).
+#
+# Only a few systems have been added to this list; please add others
+# (but try to keep the structure clean).
+#
+
+# Use $HOST_CC if defined. $CC may point to a cross-compiler
+if test x"$CC_FOR_BUILD" = x; then
+ if test x"$HOST_CC" != x; then
+ CC_FOR_BUILD="$HOST_CC"
+ else
+ if test x"$CC" != x; then
+ CC_FOR_BUILD="$CC"
+ else
+ CC_FOR_BUILD=cc
+ fi
+ fi
+fi
+
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 8/24/94.)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+ PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+dummy=dummy-$$
+trap 'rm -f $dummy.c $dummy.o $dummy; exit 1' 1 2 15
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+ alpha:OSF1:*:*)
+ if test $UNAME_RELEASE = "V4.0"; then
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+ fi
+ # A Vn.n version is a released version.
+ # A Tn.n version is a released field test version.
+ # A Xn.n version is an unreleased experimental baselevel.
+ # 1.2 uses "1.2" for uname -r.
+ cat <<EOF >$dummy.s
+ .globl main
+ .ent main
+main:
+ .frame \$30,0,\$26,0
+ .prologue 0
+ .long 0x47e03d80 # implver $0
+ lda \$2,259
+ .long 0x47e20c21 # amask $2,$1
+ srl \$1,8,\$2
+ sll \$2,2,\$2
+ sll \$0,3,\$0
+ addl \$1,\$0,\$0
+ addl \$2,\$0,\$0
+ ret \$31,(\$26),1
+ .end main
+EOF
+ $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
+ if test "$?" = 0 ; then
+ ./$dummy
+ case "$?" in
+ 7)
+ UNAME_MACHINE="alpha"
+ ;;
+ 15)
+ UNAME_MACHINE="alphaev5"
+ ;;
+ 14)
+ UNAME_MACHINE="alphaev56"
+ ;;
+ 10)
+ UNAME_MACHINE="alphapca56"
+ ;;
+ 16)
+ UNAME_MACHINE="alphaev6"
+ ;;
+ esac
+ fi
+ rm -f $dummy.s $dummy
+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ exit 0 ;;
+ Alpha\ *:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # Should we change UNAME_MACHINE based on the output of uname instead
+ # of the specific Alpha model?
+ echo alpha-pc-interix
+ exit 0 ;;
+ 21064:Windows_NT:50:3)
+ echo alpha-dec-winnt3.5
+ exit 0 ;;
+ Amiga*:UNIX_System_V:4.0:*)
+ echo m68k-cbm-sysv4
+ exit 0;;
+ amiga:NetBSD:*:*)
+ echo m68k-cbm-netbsd${UNAME_RELEASE}
+ exit 0 ;;
+ amiga:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ *:[Aa]miga[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-amigaos
+ exit 0 ;;
+ arc64:OpenBSD:*:*)
+ echo mips64el-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ arc:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ hkmips:OpenBSD:*:*)
+ echo mips-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ pmax:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ sgi:OpenBSD:*:*)
+ echo mips-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ wgrisc:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ *:OS/390:*:*)
+ echo i370-ibm-openedition
+ exit 0 ;;
+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+ echo arm-acorn-riscix${UNAME_RELEASE}
+ exit 0;;
+ arm32:NetBSD:*:*)
+ echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ exit 0 ;;
+ SR2?01:HI-UX/MPP:*:*)
+ echo hppa1.1-hitachi-hiuxmpp
+ exit 0;;
+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+ # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+ if test "`(/bin/universe) 2>/dev/null`" = att ; then
+ echo pyramid-pyramid-sysv3
+ else
+ echo pyramid-pyramid-bsd
+ fi
+ exit 0 ;;
+ NILE*:*:*:dcosx)
+ echo pyramid-pyramid-svr4
+ exit 0 ;;
+ sun4H:SunOS:5.*:*)
+ echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+ echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ i86pc:SunOS:5.*:*)
+ echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ sun4*:SunOS:6*:*)
+ # According to config.sub, this is the proper way to canonicalize
+ # SunOS6. Hard to guess exactly what SunOS6 will be like, but
+ # it's likely to be more like Solaris than SunOS4.
+ echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ sun4*:SunOS:*:*)
+ case "`/usr/bin/arch -k`" in
+ Series*|S4*)
+ UNAME_RELEASE=`uname -v`
+ ;;
+ esac
+ # Japanese Language versions have a version number like `4.1.3-JL'.
+ echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+ exit 0 ;;
+ sun3*:SunOS:*:*)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ exit 0 ;;
+ sun*:*:4.2BSD:*)
+ UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+ case "`/bin/arch`" in
+ sun3)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ ;;
+ sun4)
+ echo sparc-sun-sunos${UNAME_RELEASE}
+ ;;
+ esac
+ exit 0 ;;
+ aushp:SunOS:*:*)
+ echo sparc-auspex-sunos${UNAME_RELEASE}
+ exit 0 ;;
+ atari*:NetBSD:*:*)
+ echo m68k-atari-netbsd${UNAME_RELEASE}
+ exit 0 ;;
+ atari*:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ # The situation for MiNT is a little confusing. The machine name
+ # can be virtually everything (everything which is not
+ # "atarist" or "atariste" at least should have a processor
+ # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
+ # to the lowercase version "mint" (or "freemint"). Finally
+ # the system name "TOS" denotes a system which is actually not
+ # MiNT. But MiNT is downward compatible to TOS, so this should
+ # be no problem.
+ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit 0 ;;
+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit 0 ;;
+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit 0 ;;
+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+ echo m68k-milan-mint${UNAME_RELEASE}
+ exit 0 ;;
+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+ echo m68k-hades-mint${UNAME_RELEASE}
+ exit 0 ;;
+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+ echo m68k-unknown-mint${UNAME_RELEASE}
+ exit 0 ;;
+ sun3*:NetBSD:*:*)
+ echo m68k-sun-netbsd${UNAME_RELEASE}
+ exit 0 ;;
+ sun3*:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mac68k:NetBSD:*:*)
+ echo m68k-apple-netbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mac68k:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme68k:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme88k:OpenBSD:*:*)
+ echo m88k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ powerpc:machten:*:*)
+ echo powerpc-apple-machten${UNAME_RELEASE}
+ exit 0 ;;
+ macppc:NetBSD:*:*)
+ echo powerpc-apple-netbsd${UNAME_RELEASE}
+ exit 0 ;;
+ RISC*:Mach:*:*)
+ echo mips-dec-mach_bsd4.3
+ exit 0 ;;
+ RISC*:ULTRIX:*:*)
+ echo mips-dec-ultrix${UNAME_RELEASE}
+ exit 0 ;;
+ VAX*:ULTRIX*:*:*)
+ echo vax-dec-ultrix${UNAME_RELEASE}
+ exit 0 ;;
+ 2020:CLIX:*:* | 2430:CLIX:*:*)
+ echo clipper-intergraph-clix${UNAME_RELEASE}
+ exit 0 ;;
+ mips:*:*:UMIPS | mips:*:*:RISCos)
+ sed 's/^ //' << EOF >$dummy.c
+#ifdef __cplusplus
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+ #if defined (host_mips) && defined (MIPSEB)
+ #if defined (SYSTYPE_SYSV)
+ printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_SVR4)
+ printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+ printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+ #endif
+ #endif
+ exit (-1);
+ }
+EOF
+ $CC_FOR_BUILD $dummy.c -o $dummy \
+ && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
+ && rm $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
+ echo mips-mips-riscos${UNAME_RELEASE}
+ exit 0 ;;
+ Night_Hawk:Power_UNIX:*:*)
+ echo powerpc-harris-powerunix
+ exit 0 ;;
+ m88k:CX/UX:7*:*)
+ echo m88k-harris-cxux7
+ exit 0 ;;
+ m88k:*:4*:R4*)
+ echo m88k-motorola-sysv4
+ exit 0 ;;
+ m88k:*:3*:R3*)
+ echo m88k-motorola-sysv3
+ exit 0 ;;
+ AViiON:dgux:*:*)
+ # DG/UX returns AViiON for all architectures
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110]
+ then
+ if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+ [ ${TARGET_BINARY_INTERFACE}x = x ]
+ then
+ echo m88k-dg-dgux${UNAME_RELEASE}
+ else
+ echo m88k-dg-dguxbcs${UNAME_RELEASE}
+ fi
+ else
+ echo i586-dg-dgux${UNAME_RELEASE}
+ fi
+ exit 0 ;;
+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)
+ echo m88k-dolphin-sysv3
+ exit 0 ;;
+ M88*:*:R3*:*)
+ # Delta 88k system running SVR3
+ echo m88k-motorola-sysv3
+ exit 0 ;;
+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+ echo m88k-tektronix-sysv3
+ exit 0 ;;
+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+ echo m68k-tektronix-bsd
+ exit 0 ;;
+ *:IRIX*:*:*)
+ echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+ exit 0 ;;
+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+ echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
+ exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX '
+ i?86:AIX:*:*)
+ echo i386-ibm-aix
+ exit 0 ;;
+ *:AIX:2:3)
+ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+ sed 's/^ //' << EOF >$dummy.c
+ #include <sys/systemcfg.h>
+
+ main()
+ {
+ if (!__power_pc())
+ exit(1);
+ puts("powerpc-ibm-aix3.2.5");
+ exit(0);
+ }
+EOF
+ $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
+ echo rs6000-ibm-aix3.2.5
+ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+ echo rs6000-ibm-aix3.2.4
+ else
+ echo rs6000-ibm-aix3.2
+ fi
+ exit 0 ;;
+ *:AIX:*:4)
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'`
+ if /usr/sbin/lsattr -EHl ${IBM_CPU_ID} | grep POWER >/dev/null 2>&1; then
+ IBM_ARCH=rs6000
+ else
+ IBM_ARCH=powerpc
+ fi
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=4.${UNAME_RELEASE}
+ fi
+ echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+ exit 0 ;;
+ *:AIX:*:*)
+ echo rs6000-ibm-aix
+ exit 0 ;;
+ ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+ echo romp-ibm-bsd4.4
+ exit 0 ;;
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and
+ echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
+ exit 0 ;; # report: romp-ibm BSD 4.3
+ *:BOSX:*:*)
+ echo rs6000-bull-bosx
+ exit 0 ;;
+ DPX/2?00:B.O.S.:*:*)
+ echo m68k-bull-sysv3
+ exit 0 ;;
+ 9000/[34]??:4.3bsd:1.*:*)
+ echo m68k-hp-bsd
+ exit 0 ;;
+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+ echo m68k-hp-bsd4.4
+ exit 0 ;;
+ 9000/[34678]??:HP-UX:*:*)
+ case "${UNAME_MACHINE}" in
+ 9000/31? ) HP_ARCH=m68000 ;;
+ 9000/[34]?? ) HP_ARCH=m68k ;;
+ 9000/[678][0-9][0-9])
+ sed 's/^ //' << EOF >$dummy.c
+ #include <stdlib.h>
+ #include <unistd.h>
+
+ int main ()
+ {
+ #if defined(_SC_KERNEL_BITS)
+ long bits = sysconf(_SC_KERNEL_BITS);
+ #endif
+ long cpu = sysconf (_SC_CPU_VERSION);
+
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+ case CPU_PA_RISC2_0:
+ #if defined(_SC_KERNEL_BITS)
+ switch (bits)
+ {
+ case 64: puts ("hppa2.0w"); break;
+ case 32: puts ("hppa2.0n"); break;
+ default: puts ("hppa2.0"); break;
+ } break;
+ #else /* !defined(_SC_KERNEL_BITS) */
+ puts ("hppa2.0"); break;
+ #endif
+ default: puts ("hppa1.0"); break;
+ }
+ exit (0);
+ }
+EOF
+ (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy`
+ rm -f $dummy.c $dummy
+ esac
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+ exit 0 ;;
+ 3050*:HI-UX:*:*)
+ sed 's/^ //' << EOF >$dummy.c
+ #include <unistd.h>
+ int
+ main ()
+ {
+ long cpu = sysconf (_SC_CPU_VERSION);
+ /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+ true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
+ results, however. */
+ if (CPU_IS_PA_RISC (cpu))
+ {
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+ default: puts ("hppa-hitachi-hiuxwe2"); break;
+ }
+ }
+ else if (CPU_IS_HP_MC68K (cpu))
+ puts ("m68k-hitachi-hiuxwe2");
+ else puts ("unknown-hitachi-hiuxwe2");
+ exit (0);
+ }
+EOF
+ $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
+ echo unknown-hitachi-hiuxwe2
+ exit 0 ;;
+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+ echo hppa1.1-hp-bsd
+ exit 0 ;;
+ 9000/8??:4.3bsd:*:*)
+ echo hppa1.0-hp-bsd
+ exit 0 ;;
+ *9??*:MPE/iX:*:*)
+ echo hppa1.0-hp-mpeix
+ exit 0 ;;
+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+ echo hppa1.1-hp-osf
+ exit 0 ;;
+ hp8??:OSF1:*:*)
+ echo hppa1.0-hp-osf
+ exit 0 ;;
+ i?86:OSF1:*:*)
+ if [ -x /usr/sbin/sysversion ] ; then
+ echo ${UNAME_MACHINE}-unknown-osf1mk
+ else
+ echo ${UNAME_MACHINE}-unknown-osf1
+ fi
+ exit 0 ;;
+ parisc*:Lites*:*:*)
+ echo hppa1.1-hp-lites
+ exit 0 ;;
+ hppa*:OpenBSD:*:*)
+ echo hppa-unknown-openbsd
+ exit 0 ;;
+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+ echo c1-convex-bsd
+ exit 0 ;;
+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit 0 ;;
+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+ echo c34-convex-bsd
+ exit 0 ;;
+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+ echo c38-convex-bsd
+ exit 0 ;;
+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+ echo c4-convex-bsd
+ exit 0 ;;
+ CRAY*X-MP:*:*:*)
+ echo xmp-cray-unicos
+ exit 0 ;;
+ CRAY*Y-MP:*:*:*)
+ echo ymp-cray-unicos${UNAME_RELEASE}
+ exit 0 ;;
+ CRAY*[A-Z]90:*:*:*)
+ echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
+ exit 0 ;;
+ CRAY*TS:*:*:*)
+ echo t90-cray-unicos${UNAME_RELEASE}
+ exit 0 ;;
+ CRAY*T3E:*:*:*)
+ echo alpha-cray-unicosmk${UNAME_RELEASE}
+ exit 0 ;;
+ CRAY-2:*:*:*)
+ echo cray2-cray-unicos
+ exit 0 ;;
+ F300:UNIX_System_V:*:*)
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+ echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit 0 ;;
+ F301:UNIX_System_V:*:*)
+ echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
+ exit 0 ;;
+ hp3[0-9][05]:NetBSD:*:*)
+ echo m68k-hp-netbsd${UNAME_RELEASE}
+ exit 0 ;;
+ hp300:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ i?86:BSD/386:*:* | i?86:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+ exit 0 ;;
+ sparc*:BSD/OS:*:*)
+ echo sparc-unknown-bsdi${UNAME_RELEASE}
+ exit 0 ;;
+ *:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+ exit 0 ;;
+ *:FreeBSD:*:*)
+ if test -x /usr/bin/objformat; then
+ if test "elf" = "`/usr/bin/objformat`"; then
+ echo ${UNAME_MACHINE}-unknown-freebsdelf`echo ${UNAME_RELEASE}|sed -e 's/[-_].*//'`
+ exit 0
+ fi
+ fi
+ echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ exit 0 ;;
+ *:NetBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*//'`
+ exit 0 ;;
+ *:OpenBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ exit 0 ;;
+ i*:CYGWIN*:*)
+ echo ${UNAME_MACHINE}-pc-cygwin
+ exit 0 ;;
+ i*:MINGW*:*)
+ echo ${UNAME_MACHINE}-pc-mingw32
+ exit 0 ;;
+ i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+ # UNAME_MACHINE based on the output of uname instead of i386?
+ echo i386-pc-interix
+ exit 0 ;;
+ i*:UWIN*:*)
+ echo ${UNAME_MACHINE}-pc-uwin
+ exit 0 ;;
+ p*:CYGWIN*:*)
+ echo powerpcle-unknown-cygwin
+ exit 0 ;;
+ prep*:SunOS:5.*:*)
+ echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ *:GNU:*:*)
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ exit 0 ;;
+ *:Linux:*:*)
+
+ # The BFD linker knows what the default object file format is, so
+ # first see if it will tell us. cd to the root directory to prevent
+ # problems with other programs or directories called `ld' in the path.
+ ld_help_string=`cd /; ld --help 2>&1`
+ ld_supported_emulations=`echo $ld_help_string \
+ | sed -ne '/supported emulations:/!d
+ s/[ ][ ]*/ /g
+ s/.*supported emulations: *//
+ s/ .*//
+ p'`
+ case "$ld_supported_emulations" in
+ *ia64)
+ echo "${UNAME_MACHINE}-unknown-linux"
+ exit 0
+ ;;
+ i?86linux)
+ echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+ exit 0
+ ;;
+ i?86coff)
+ echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+ exit 0
+ ;;
+ sparclinux)
+ echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
+ exit 0
+ ;;
+ armlinux)
+ echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
+ exit 0
+ ;;
+ elf32arm*)
+ echo "${UNAME_MACHINE}-unknown-linux-gnu"
+ exit 0
+ ;;
+ armelf_linux*)
+ echo "${UNAME_MACHINE}-unknown-linux-gnu"
+ exit 0
+ ;;
+ m68klinux)
+ echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
+ exit 0
+ ;;
+ elf32ppc)
+ # Determine Lib Version
+ cat >$dummy.c <<EOF
+#include <features.h>
+#if defined(__GLIBC__)
+extern char __libc_version[];
+extern char __libc_release[];
+#endif
+main(argc, argv)
+ int argc;
+ char *argv[];
+{
+#if defined(__GLIBC__)
+ printf("%s %s\n", __libc_version, __libc_release);
+#else
+ printf("unkown\n");
+#endif
+ return 0;
+}
+EOF
+ LIBC=""
+ $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null
+ if test "$?" = 0 ; then
+ ./$dummy | grep 1\.99 > /dev/null
+ if test "$?" = 0 ; then
+ LIBC="libc1"
+ fi
+ fi
+ rm -f $dummy.c $dummy
+ echo powerpc-unknown-linux-gnu${LIBC}
+ exit 0
+ ;;
+ esac
+
+ if test "${UNAME_MACHINE}" = "alpha" ; then
+ sed 's/^ //' <<EOF >$dummy.s
+ .globl main
+ .ent main
+ main:
+ .frame \$30,0,\$26,0
+ .prologue 0
+ .long 0x47e03d80 # implver $0
+ lda \$2,259
+ .long 0x47e20c21 # amask $2,$1
+ srl \$1,8,\$2
+ sll \$2,2,\$2
+ sll \$0,3,\$0
+ addl \$1,\$0,\$0
+ addl \$2,\$0,\$0
+ ret \$31,(\$26),1
+ .end main
+EOF
+ LIBC=""
+ $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
+ if test "$?" = 0 ; then
+ ./$dummy
+ case "$?" in
+ 7)
+ UNAME_MACHINE="alpha"
+ ;;
+ 15)
+ UNAME_MACHINE="alphaev5"
+ ;;
+ 14)
+ UNAME_MACHINE="alphaev56"
+ ;;
+ 10)
+ UNAME_MACHINE="alphapca56"
+ ;;
+ 16)
+ UNAME_MACHINE="alphaev6"
+ ;;
+ esac
+
+ objdump --private-headers $dummy | \
+ grep ld.so.1 > /dev/null
+ if test "$?" = 0 ; then
+ LIBC="libc1"
+ fi
+ fi
+ rm -f $dummy.s $dummy
+ echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0
+ elif test "${UNAME_MACHINE}" = "mips" ; then
+ cat >$dummy.c <<EOF
+#ifdef __cplusplus
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+#ifdef __MIPSEB__
+ printf ("%s-unknown-linux-gnu\n", argv[1]);
+#endif
+#ifdef __MIPSEL__
+ printf ("%sel-unknown-linux-gnu\n", argv[1]);
+#endif
+ return 0;
+}
+EOF
+ $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
+ else
+ # Either a pre-BFD a.out linker (linux-gnuoldld)
+ # or one that does not give us useful --help.
+ # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
+ # If ld does not provide *any* "supported emulations:"
+ # that means it is gnuoldld.
+ echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:"
+ test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
+
+ case "${UNAME_MACHINE}" in
+ i?86)
+ VENDOR=pc;
+ ;;
+ *)
+ VENDOR=unknown;
+ ;;
+ esac
+ # Determine whether the default compiler is a.out or elf
+ cat >$dummy.c <<EOF
+#include <features.h>
+#ifdef __cplusplus
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+#ifdef __ELF__
+# ifdef __GLIBC__
+# if __GLIBC__ >= 2
+ printf ("%s-${VENDOR}-linux-gnu\n", argv[1]);
+# else
+ printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
+# endif
+# else
+ printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
+# endif
+#else
+ printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]);
+#endif
+ return 0;
+}
+EOF
+ $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
+ fi ;;
+# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions
+# are messed up and put the nodename in both sysname and nodename.
+ i?86:DYNIX/ptx:4*:*)
+ echo i386-sequent-sysv4
+ exit 0 ;;
+ i?86:UNIX_SV:4.2MP:2.*)
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+ # I am not positive that other SVR4 systems won't match this,
+ # I just have to hope. -- rms.
+ # Use sysv4.2uw... so that sysv4* matches it.
+ echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+ exit 0 ;;
+ i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
+ UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+ echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+ else
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+ fi
+ exit 0 ;;
+ i?86:*:5:7*)
+ # Fixed at (any) Pentium or better
+ UNAME_MACHINE=i586
+ if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then
+ echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}uw${UNAME_VERSION}
+ else
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
+ fi
+ exit 0 ;;
+ i?86:*:3.2:*)
+ if test -f /usr/options/cb.name; then
+ UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+ echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+ elif /bin/uname -X 2>/dev/null >/dev/null ; then
+ UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
+ && UNAME_MACHINE=i586
+ (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \
+ && UNAME_MACHINE=i686
+ (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
+ && UNAME_MACHINE=i686
+ echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+ else
+ echo ${UNAME_MACHINE}-pc-sysv32
+ fi
+ exit 0 ;;
+ pc:*:*:*)
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
+ # the processor, so we play safe by assuming i386.
+ echo i386-pc-msdosdjgpp
+ exit 0 ;;
+ Intel:Mach:3*:*)
+ echo i386-pc-mach3
+ exit 0 ;;
+ paragon:*:*:*)
+ echo i860-intel-osf1
+ exit 0 ;;
+ i860:*:4.*:*) # i860-SVR4
+ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+ echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+ else # Add other i860-SVR4 vendors below as they are discovered.
+ echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
+ fi
+ exit 0 ;;
+ mini*:CTIX:SYS*5:*)
+ # "miniframe"
+ echo m68010-convergent-sysv
+ exit 0 ;;
+ M68*:*:R3V[567]*:*)
+ test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
+ 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
+ OS_REL=''
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && echo i486-ncr-sysv4.3${OS_REL} && exit 0
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && echo i486-ncr-sysv4 && exit 0 ;;
+ m68*:LynxOS:2.*:*)
+ echo m68k-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ mc68030:UNIX_System_V:4.*:*)
+ echo m68k-atari-sysv4
+ exit 0 ;;
+ i?86:LynxOS:2.*:* | i?86:LynxOS:3.[01]*:*)
+ echo i386-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ TSUNAMI:LynxOS:2.*:*)
+ echo sparc-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*)
+ echo rs6000-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ SM[BE]S:UNIX_SV:*:*)
+ echo mips-dde-sysv${UNAME_RELEASE}
+ exit 0 ;;
+ RM*:ReliantUNIX-*:*:*)
+ echo mips-sni-sysv4
+ exit 0 ;;
+ RM*:SINIX-*:*:*)
+ echo mips-sni-sysv4
+ exit 0 ;;
+ *:SINIX-*:*:*)
+ if uname -p 2>/dev/null >/dev/null ; then
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ echo ${UNAME_MACHINE}-sni-sysv4
+ else
+ echo ns32k-sni-sysv
+ fi
+ exit 0 ;;
+ PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel@ccMail.Census.GOV>
+ echo i586-unisys-sysv4
+ exit 0 ;;
+ *:UNIX_System_V:4*:FTX*)
+ # From Gerald Hewes <hewes@openmarket.com>.
+ # How about differentiating between stratus architectures? -djm
+ echo hppa1.1-stratus-sysv4
+ exit 0 ;;
+ *:*:*:FTX*)
+ # From seanf@swdc.stratus.com.
+ echo i860-stratus-sysv4
+ exit 0 ;;
+ mc68*:A/UX:*:*)
+ echo m68k-apple-aux${UNAME_RELEASE}
+ exit 0 ;;
+ news*:NEWS-OS:*:6*)
+ echo mips-sony-newsos6
+ exit 0 ;;
+ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+ if [ -d /usr/nec ]; then
+ echo mips-nec-sysv${UNAME_RELEASE}
+ else
+ echo mips-unknown-sysv${UNAME_RELEASE}
+ fi
+ exit 0 ;;
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ echo powerpc-be-beos
+ exit 0 ;;
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
+ echo powerpc-apple-beos
+ exit 0 ;;
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
+ echo i586-pc-beos
+ exit 0 ;;
+ SX-4:SUPER-UX:*:*)
+ echo sx4-nec-superux${UNAME_RELEASE}
+ exit 0 ;;
+ SX-5:SUPER-UX:*:*)
+ echo sx5-nec-superux${UNAME_RELEASE}
+ exit 0 ;;
+ Power*:Rhapsody:*:*)
+ echo powerpc-apple-rhapsody${UNAME_RELEASE}
+ exit 0 ;;
+ *:Rhapsody:*:*)
+ echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+ exit 0 ;;
+ *:QNX:*:4*)
+ echo i386-qnx-qnx${UNAME_VERSION}
+ exit 0 ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+ /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
+ I don't know.... */
+ printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+ printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+ "4"
+#else
+ ""
+#endif
+ ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+ printf ("arm-acorn-riscix"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+ printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+ int version;
+ version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+ if (version < 4)
+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+ else
+ printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+ exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+ printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+ printf ("ns32k-encore-mach\n"); exit (0);
+#else
+ printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+ printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+ printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+ printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+ struct utsname un;
+
+ uname(&un);
+
+ if (strncmp(un.version, "V2", 2) == 0) {
+ printf ("i386-sequent-ptx2\n"); exit (0);
+ }
+ if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+ printf ("i386-sequent-ptx1\n"); exit (0);
+ }
+ printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+#if !defined (ultrix)
+ printf ("vax-dec-bsd\n"); exit (0);
+#else
+ printf ("vax-dec-ultrix\n"); exit (0);
+#endif
+#endif
+
+#if defined (alliant) && defined (i860)
+ printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+ exit (1);
+}
+EOF
+
+$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm $dummy.c $dummy && exit 0
+rm -f $dummy.c $dummy
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+ case `getsysinfo -f cpu_type` in
+ c1*)
+ echo c1-convex-bsd
+ exit 0 ;;
+ c2*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit 0 ;;
+ c34*)
+ echo c34-convex-bsd
+ exit 0 ;;
+ c38*)
+ echo c38-convex-bsd
+ exit 0 ;;
+ c4*)
+ echo c4-convex-bsd
+ exit 0 ;;
+ esac
+fi
+
+#echo '(Unable to guess system type)' 1>&2
+
+exit 1
diff --git a/gc/config.sub b/gc/config.sub
new file mode 100644
index 0000000..28426bb
--- /dev/null
+++ b/gc/config.sub
@@ -0,0 +1,1232 @@
+#! /bin/sh
+# Configuration validation subroutine script, version 1.1.
+# Copyright (C) 1991, 92-97, 1998, 1999 Free Software Foundation, Inc.
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine. It does not imply ALL GNU software can.
+#
+# This file 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 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# 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 to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support. The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+if [ x$1 = x ]
+then
+ echo Configuration name missing. 1>&2
+ echo "Usage: $0 CPU-MFR-OPSYS" 1>&2
+ echo "or $0 ALIAS" 1>&2
+ echo where ALIAS is a recognized configuration type. 1>&2
+ exit 1
+fi
+
+# First pass through any local machine types.
+case $1 in
+ *local*)
+ echo $1
+ exit 0
+ ;;
+ *)
+ ;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+ linux-gnu*)
+ os=-$maybe_os
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+ ;;
+ *)
+ basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+ if [ $basic_machine != $1 ]
+ then os=`echo $1 | sed 's/.*-/-/'`
+ else os=; fi
+ ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work. We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+ -sun*os*)
+ # Prevent following clause from handling this invalid input.
+ ;;
+ -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+ -apple)
+ os=
+ basic_machine=$1
+ ;;
+ -sim | -cisco | -oki | -wec | -winbond)
+ os=
+ basic_machine=$1
+ ;;
+ -scout)
+ ;;
+ -wrs)
+ os=-vxworks
+ basic_machine=$1
+ ;;
+ -hiux*)
+ os=-hiuxwe2
+ ;;
+ -sco5)
+ os=-sco3.2v5
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco4)
+ os=-sco3.2v4
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2.[4-9]*)
+ os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2v[4-9]*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco*)
+ os=-sco3.2v2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -udk*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -isc)
+ os=-isc2.2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -clix*)
+ basic_machine=clipper-intergraph
+ ;;
+ -isc*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -lynx*)
+ os=-lynxos
+ ;;
+ -ptx*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+ ;;
+ -windowsnt*)
+ os=`echo $os | sed -e 's/windowsnt/winnt/'`
+ ;;
+ -psos*)
+ os=-psos
+ ;;
+ -mint | -mint[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+ # Recognize the basic CPU types without company name.
+ # Some are omitted here because they have special meanings below.
+ tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
+ | arme[lb] | pyramid | mn10200 | mn10300 | tron | a29k \
+ | 580 | i960 | h8300 \
+ | hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \
+ | alpha | alphaev[4-7] | alphaev56 | alphapca5[67] \
+ | we32k | ns16k | clipper | i370 | sh | powerpc | powerpcle \
+ | 1750a | dsp16xx | pdp11 | mips16 | mips64 | mipsel | mips64el \
+ | mips64orion | mips64orionel | mipstx39 | mipstx39el \
+ | mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \
+ | mips64vr5000 | miprs64vr5000el | mcore \
+ | sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x \
+ | thumb | d10v | fr30)
+ basic_machine=$basic_machine-unknown
+ ;;
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65 | pj | pjl)
+ ;;
+
+ # We use `pc' rather than `unknown'
+ # because (1) that's what they normally are, and
+ # (2) the word "unknown" tends to confuse beginning users.
+ i[34567]86)
+ basic_machine=$basic_machine-pc
+ ;;
+ # Object if more than one company name word.
+ *-*-*)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+ # Recognize the basic CPU types with company name.
+ # FIXME: clean up the formatting here.
+ vax-* | tahoe-* | i[34567]86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \
+ | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \
+ | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
+ | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \
+ | xmp-* | ymp-* \
+ | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* | hppa2.0n-* \
+ | alpha-* | alphaev[4-7]-* | alphaev56-* | alphapca5[67]-* \
+ | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \
+ | clipper-* | orion-* \
+ | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
+ | sparc64-* | sparcv9-* | sparc86x-* | mips16-* | mips64-* | mipsel-* \
+ | mips64el-* | mips64orion-* | mips64orionel-* \
+ | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \
+ | mipstx39-* | mipstx39el-* | mcore-* \
+ | f301-* | armv*-* | t3e-* \
+ | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \
+ | thumb-* | v850-* | d30v-* | tic30-* | c30-* | fr30-* )
+ ;;
+ # Recognize the various machine names and aliases which stand
+ # for a CPU type and a company and sometimes even an OS.
+ 386bsd)
+ basic_machine=i386-unknown
+ os=-bsd
+ ;;
+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+ basic_machine=m68000-att
+ ;;
+ 3b*)
+ basic_machine=we32k-att
+ ;;
+ a29khif)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ adobe68k)
+ basic_machine=m68010-adobe
+ os=-scout
+ ;;
+ alliant | fx80)
+ basic_machine=fx80-alliant
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ ;;
+ am29k)
+ basic_machine=a29k-none
+ os=-bsd
+ ;;
+ amdahl)
+ basic_machine=580-amdahl
+ os=-sysv
+ ;;
+ amiga | amiga-*)
+ basic_machine=m68k-cbm
+ ;;
+ amigaos | amigados)
+ basic_machine=m68k-cbm
+ os=-amigaos
+ ;;
+ amigaunix | amix)
+ basic_machine=m68k-cbm
+ os=-sysv4
+ ;;
+ apollo68)
+ basic_machine=m68k-apollo
+ os=-sysv
+ ;;
+ apollo68bsd)
+ basic_machine=m68k-apollo
+ os=-bsd
+ ;;
+ aux)
+ basic_machine=m68k-apple
+ os=-aux
+ ;;
+ balance)
+ basic_machine=ns32k-sequent
+ os=-dynix
+ ;;
+ convex-c1)
+ basic_machine=c1-convex
+ os=-bsd
+ ;;
+ convex-c2)
+ basic_machine=c2-convex
+ os=-bsd
+ ;;
+ convex-c32)
+ basic_machine=c32-convex
+ os=-bsd
+ ;;
+ convex-c34)
+ basic_machine=c34-convex
+ os=-bsd
+ ;;
+ convex-c38)
+ basic_machine=c38-convex
+ os=-bsd
+ ;;
+ cray | ymp)
+ basic_machine=ymp-cray
+ os=-unicos
+ ;;
+ cray2)
+ basic_machine=cray2-cray
+ os=-unicos
+ ;;
+ [ctj]90-cray)
+ basic_machine=c90-cray
+ os=-unicos
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ ;;
+ da30 | da30-*)
+ basic_machine=m68k-da30
+ ;;
+ decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
+ ;;
+ delta | 3300 | motorola-3300 | motorola-delta \
+ | 3300-motorola | delta-motorola)
+ basic_machine=m68k-motorola
+ ;;
+ delta88)
+ basic_machine=m88k-motorola
+ os=-sysv3
+ ;;
+ dpx20 | dpx20-*)
+ basic_machine=rs6000-bull
+ os=-bosx
+ ;;
+ dpx2* | dpx2*-bull)
+ basic_machine=m68k-bull
+ os=-sysv3
+ ;;
+ ebmon29k)
+ basic_machine=a29k-amd
+ os=-ebmon
+ ;;
+ elxsi)
+ basic_machine=elxsi-elxsi
+ os=-bsd
+ ;;
+ encore | umax | mmax)
+ basic_machine=ns32k-encore
+ ;;
+ es1800 | OSE68k | ose68k | ose | OSE)
+ basic_machine=m68k-ericsson
+ os=-ose
+ ;;
+ fx2800)
+ basic_machine=i860-alliant
+ ;;
+ genix)
+ basic_machine=ns32k-ns
+ ;;
+ gmicro)
+ basic_machine=tron-gmicro
+ os=-sysv
+ ;;
+ h3050r* | hiux*)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ h8300hms)
+ basic_machine=h8300-hitachi
+ os=-hms
+ ;;
+ h8300xray)
+ basic_machine=h8300-hitachi
+ os=-xray
+ ;;
+ h8500hms)
+ basic_machine=h8500-hitachi
+ os=-hms
+ ;;
+ harris)
+ basic_machine=m88k-harris
+ os=-sysv3
+ ;;
+ hp300-*)
+ basic_machine=m68k-hp
+ ;;
+ hp300bsd)
+ basic_machine=m68k-hp
+ os=-bsd
+ ;;
+ hp300hpux)
+ basic_machine=m68k-hp
+ os=-hpux
+ ;;
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k2[0-9][0-9] | hp9k31[0-9])
+ basic_machine=m68000-hp
+ ;;
+ hp9k3[2-9][0-9])
+ basic_machine=m68k-hp
+ ;;
+ hp9k6[0-9][0-9] | hp6[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k7[0-79][0-9] | hp7[0-79][0-9])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k78[0-9] | hp78[0-9])
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][13679] | hp8[0-9][13679])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][0-9] | hp8[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hppa-next)
+ os=-nextstep3
+ ;;
+ hppaosf)
+ basic_machine=hppa1.1-hp
+ os=-osf
+ ;;
+ hppro)
+ basic_machine=hppa1.1-hp
+ os=-proelf
+ ;;
+ i370-ibm* | ibm*)
+ basic_machine=i370-ibm
+ ;;
+# I'm not sure what "Sysv32" means. Should this be sysv3.2?
+ i[34567]86v32)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv32
+ ;;
+ i[34567]86v4*)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv4
+ ;;
+ i[34567]86v)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv
+ ;;
+ i[34567]86sol2)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-solaris2
+ ;;
+ i386mach)
+ basic_machine=i386-mach
+ os=-mach
+ ;;
+ i386-vsta | vsta)
+ basic_machine=i386-unknown
+ os=-vsta
+ ;;
+ i386-go32 | go32)
+ basic_machine=i386-unknown
+ os=-go32
+ ;;
+ i386-mingw32 | mingw32)
+ basic_machine=i386-unknown
+ os=-mingw32
+ ;;
+ i386-qnx | qnx)
+ basic_machine=i386-qnx
+ ;;
+ iris | iris4d)
+ basic_machine=mips-sgi
+ case $os in
+ -irix*)
+ ;;
+ *)
+ os=-irix4
+ ;;
+ esac
+ ;;
+ isi68 | isi)
+ basic_machine=m68k-isi
+ os=-sysv
+ ;;
+ m88k-omron*)
+ basic_machine=m88k-omron
+ ;;
+ magnum | m3230)
+ basic_machine=mips-mips
+ os=-sysv
+ ;;
+ merlin)
+ basic_machine=ns32k-utek
+ os=-sysv
+ ;;
+ miniframe)
+ basic_machine=m68000-convergent
+ ;;
+ *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+ mipsel*-linux*)
+ basic_machine=mipsel-unknown
+ os=-linux-gnu
+ ;;
+ mips*-linux*)
+ basic_machine=mips-unknown
+ os=-linux-gnu
+ ;;
+ mips3*-*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+ ;;
+ mips3*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+ ;;
+ monitor)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ msdos)
+ basic_machine=i386-unknown
+ os=-msdos
+ ;;
+ mvs)
+ basic_machine=i370-ibm
+ os=-mvs
+ ;;
+ ncr3000)
+ basic_machine=i486-ncr
+ os=-sysv4
+ ;;
+ netbsd386)
+ basic_machine=i386-unknown
+ os=-netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-rebel
+ os=-linux
+ ;;
+ news | news700 | news800 | news900)
+ basic_machine=m68k-sony
+ os=-newsos
+ ;;
+ news1000)
+ basic_machine=m68030-sony
+ os=-newsos
+ ;;
+ news-3600 | risc-news)
+ basic_machine=mips-sony
+ os=-newsos
+ ;;
+ necv70)
+ basic_machine=v70-nec
+ os=-sysv
+ ;;
+ next | m*-next )
+ basic_machine=m68k-next
+ case $os in
+ -nextstep* )
+ ;;
+ -ns2*)
+ os=-nextstep2
+ ;;
+ *)
+ os=-nextstep3
+ ;;
+ esac
+ ;;
+ nh3000)
+ basic_machine=m68k-harris
+ os=-cxux
+ ;;
+ nh[45]000)
+ basic_machine=m88k-harris
+ os=-cxux
+ ;;
+ nindy960)
+ basic_machine=i960-intel
+ os=-nindy
+ ;;
+ mon960)
+ basic_machine=i960-intel
+ os=-mon960
+ ;;
+ np1)
+ basic_machine=np1-gould
+ ;;
+ op50n-* | op60c-*)
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+ OSE68000 | ose68000)
+ basic_machine=m68000-ericsson
+ os=-ose
+ ;;
+ os68k)
+ basic_machine=m68k-none
+ os=-os68k
+ ;;
+ pa-hitachi)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ paragon)
+ basic_machine=i860-intel
+ os=-osf
+ ;;
+ pbd)
+ basic_machine=sparc-tti
+ ;;
+ pbb)
+ basic_machine=m68k-tti
+ ;;
+ pc532 | pc532-*)
+ basic_machine=ns32k-pc532
+ ;;
+ pentium | p5 | k5 | k6 | nexen)
+ basic_machine=i586-pc
+ ;;
+ pentiumpro | p6 | 6x86)
+ basic_machine=i686-pc
+ ;;
+ pentiumii | pentium2)
+ basic_machine=i786-pc
+ ;;
+ pentium-* | p5-* | k5-* | k6-* | nexen-*)
+ basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumpro-* | p6-* | 6x86-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumii-* | pentium2-*)
+ basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pn)
+ basic_machine=pn-gould
+ ;;
+ power) basic_machine=rs6000-ibm
+ ;;
+ ppc) basic_machine=powerpc-unknown
+ ;;
+ ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppcle | powerpclittle | ppc-le | powerpc-little)
+ basic_machine=powerpcle-unknown
+ ;;
+ ppcle-* | powerpclittle-*)
+ basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ps2)
+ basic_machine=i386-ibm
+ ;;
+ rom68k)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ rm[46]00)
+ basic_machine=mips-siemens
+ ;;
+ rtpc | rtpc-*)
+ basic_machine=romp-ibm
+ ;;
+ sa29200)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ sequent)
+ basic_machine=i386-sequent
+ ;;
+ sh)
+ basic_machine=sh-hitachi
+ os=-hms
+ ;;
+ sparclite-wrs)
+ basic_machine=sparclite-wrs
+ os=-vxworks
+ ;;
+ sps7)
+ basic_machine=m68k-bull
+ os=-sysv2
+ ;;
+ spur)
+ basic_machine=spur-unknown
+ ;;
+ st2000)
+ basic_machine=m68k-tandem
+ ;;
+ stratus)
+ basic_machine=i860-stratus
+ os=-sysv4
+ ;;
+ sun2)
+ basic_machine=m68000-sun
+ ;;
+ sun2os3)
+ basic_machine=m68000-sun
+ os=-sunos3
+ ;;
+ sun2os4)
+ basic_machine=m68000-sun
+ os=-sunos4
+ ;;
+ sun3os3)
+ basic_machine=m68k-sun
+ os=-sunos3
+ ;;
+ sun3os4)
+ basic_machine=m68k-sun
+ os=-sunos4
+ ;;
+ sun4os3)
+ basic_machine=sparc-sun
+ os=-sunos3
+ ;;
+ sun4os4)
+ basic_machine=sparc-sun
+ os=-sunos4
+ ;;
+ sun4sol2)
+ basic_machine=sparc-sun
+ os=-solaris2
+ ;;
+ sun3 | sun3-*)
+ basic_machine=m68k-sun
+ ;;
+ sun4)
+ basic_machine=sparc-sun
+ ;;
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
+ ;;
+ symmetry)
+ basic_machine=i386-sequent
+ os=-dynix
+ ;;
+ t3e)
+ basic_machine=t3e-cray
+ os=-unicos
+ ;;
+ tx39)
+ basic_machine=mipstx39-unknown
+ ;;
+ tx39el)
+ basic_machine=mipstx39el-unknown
+ ;;
+ tower | tower-32)
+ basic_machine=m68k-ncr
+ ;;
+ udi29k)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ ultra3)
+ basic_machine=a29k-nyu
+ os=-sym1
+ ;;
+ v810 | necv810)
+ basic_machine=v810-nec
+ os=-none
+ ;;
+ vaxv)
+ basic_machine=vax-dec
+ os=-sysv
+ ;;
+ vms)
+ basic_machine=vax-dec
+ os=-vms
+ ;;
+ vpp*|vx|vx-*)
+ basic_machine=f301-fujitsu
+ ;;
+ vxworks960)
+ basic_machine=i960-wrs
+ os=-vxworks
+ ;;
+ vxworks68)
+ basic_machine=m68k-wrs
+ os=-vxworks
+ ;;
+ vxworks29k)
+ basic_machine=a29k-wrs
+ os=-vxworks
+ ;;
+ w65*)
+ basic_machine=w65-wdc
+ os=-none
+ ;;
+ w89k-*)
+ basic_machine=hppa1.1-winbond
+ os=-proelf
+ ;;
+ xmp)
+ basic_machine=xmp-cray
+ os=-unicos
+ ;;
+ xps | xps100)
+ basic_machine=xps100-honeywell
+ ;;
+ z8k-*-coff)
+ basic_machine=z8k-unknown
+ os=-sim
+ ;;
+ none)
+ basic_machine=none-none
+ os=-none
+ ;;
+
+# Here we handle the default manufacturer of certain CPU types. It is in
+# some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ basic_machine=hppa1.1-winbond
+ ;;
+ op50n)
+ basic_machine=hppa1.1-oki
+ ;;
+ op60c)
+ basic_machine=hppa1.1-oki
+ ;;
+ mips)
+ if [ x$os = x-linux-gnu ]; then
+ basic_machine=mips-unknown
+ else
+ basic_machine=mips-mips
+ fi
+ ;;
+ romp)
+ basic_machine=romp-ibm
+ ;;
+ rs6000)
+ basic_machine=rs6000-ibm
+ ;;
+ vax)
+ basic_machine=vax-dec
+ ;;
+ pdp11)
+ basic_machine=pdp11-dec
+ ;;
+ we32k)
+ basic_machine=we32k-att
+ ;;
+ sparc | sparcv9)
+ basic_machine=sparc-sun
+ ;;
+ cydra)
+ basic_machine=cydra-cydrome
+ ;;
+ orion)
+ basic_machine=orion-highlevel
+ ;;
+ orion105)
+ basic_machine=clipper-highlevel
+ ;;
+ mac | mpw | mac-mpw)
+ basic_machine=m68k-apple
+ ;;
+ pmac | pmac-mpw)
+ basic_machine=powerpc-apple
+ ;;
+ c4x*)
+ basic_machine=c4x-none
+ os=-coff
+ ;;
+ *)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+ *-digital*)
+ basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+ ;;
+ *-commodore*)
+ basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+ ;;
+ *)
+ ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+ # First match some system type aliases
+ # that might get confused with valid system types.
+ # -solaris* is a basic system type, with this one exception.
+ -solaris1 | -solaris1.*)
+ os=`echo $os | sed -e 's|solaris1|sunos4|'`
+ ;;
+ -solaris)
+ os=-solaris2
+ ;;
+ -svr4*)
+ os=-sysv4
+ ;;
+ -unixware*)
+ os=-sysv4.2uw
+ ;;
+ -gnu/linux*)
+ os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+ ;;
+ # First accept the basic system types.
+ # The portable systems comes first.
+ # Each alternative MUST END IN A *, to match a version number.
+ # -sysv* is not here because it comes later, after sysvr4.
+ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ | -aos* \
+ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+ | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
+ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -rhapsody* | -opened* | -openstep* | -oskit*)
+ # Remember, each alternative MUST END IN *, to match a version number.
+ ;;
+ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
+ | -macos* | -mpw* | -magic* | -mon960* | -lnews*)
+ ;;
+ -mac*)
+ os=`echo $os | sed -e 's|mac|macos|'`
+ ;;
+ -linux*)
+ os=`echo $os | sed -e 's|linux|linux-gnu|'`
+ ;;
+ -sunos5*)
+ os=`echo $os | sed -e 's|sunos5|solaris2|'`
+ ;;
+ -sunos6*)
+ os=`echo $os | sed -e 's|sunos6|solaris3|'`
+ ;;
+ -opened*)
+ os=-openedition
+ ;;
+ -osfrose*)
+ os=-osfrose
+ ;;
+ -osf*)
+ os=-osf
+ ;;
+ -utek*)
+ os=-bsd
+ ;;
+ -dynix*)
+ os=-bsd
+ ;;
+ -acis*)
+ os=-aos
+ ;;
+ -386bsd)
+ os=-bsd
+ ;;
+ -ctix* | -uts*)
+ os=-sysv
+ ;;
+ -ns2 )
+ os=-nextstep2
+ ;;
+ # Preserve the version number of sinix5.
+ -sinix5.*)
+ os=`echo $os | sed -e 's|sinix|sysv|'`
+ ;;
+ -sinix*)
+ os=-sysv4
+ ;;
+ -triton*)
+ os=-sysv3
+ ;;
+ -oss*)
+ os=-sysv3
+ ;;
+ -qnx)
+ os=-qnx4
+ ;;
+ -svr4)
+ os=-sysv4
+ ;;
+ -svr3)
+ os=-sysv3
+ ;;
+ -sysvr4)
+ os=-sysv4
+ ;;
+ # This must come after -sysvr4.
+ -sysv*)
+ ;;
+ -ose*)
+ os=-ose
+ ;;
+ -es1800*)
+ os=-ose
+ ;;
+ -xenix)
+ os=-xenix
+ ;;
+ -*mint | -*MiNT)
+ os=-mint
+ ;;
+ -none)
+ ;;
+ *)
+ # Get rid of the `-' at the beginning of $os.
+ os=`echo $os | sed 's/[^-]*-//'`
+ echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system. Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+ *-acorn)
+ os=-riscix1.2
+ ;;
+ arm*-rebel)
+ os=-linux
+ ;;
+ arm*-semi)
+ os=-aout
+ ;;
+ pdp11-*)
+ os=-none
+ ;;
+ *-dec | vax-*)
+ os=-ultrix4.2
+ ;;
+ m68*-apollo)
+ os=-domain
+ ;;
+ i386-sun)
+ os=-sunos4.0.2
+ ;;
+ m68000-sun)
+ os=-sunos3
+ # This also exists in the configure program, but was not the
+ # default.
+ # os=-sunos4
+ ;;
+ m68*-cisco)
+ os=-aout
+ ;;
+ mips*-cisco)
+ os=-elf
+ ;;
+ mips*-*)
+ os=-elf
+ ;;
+ *-tti) # must be before sparc entry or we get the wrong os.
+ os=-sysv3
+ ;;
+ sparc-* | *-sun)
+ os=-sunos4.1.1
+ ;;
+ *-be)
+ os=-beos
+ ;;
+ *-ibm)
+ os=-aix
+ ;;
+ *-wec)
+ os=-proelf
+ ;;
+ *-winbond)
+ os=-proelf
+ ;;
+ *-oki)
+ os=-proelf
+ ;;
+ *-hp)
+ os=-hpux
+ ;;
+ *-hitachi)
+ os=-hiux
+ ;;
+ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+ os=-sysv
+ ;;
+ *-cbm)
+ os=-amigaos
+ ;;
+ *-dg)
+ os=-dgux
+ ;;
+ *-dolphin)
+ os=-sysv3
+ ;;
+ m68k-ccur)
+ os=-rtu
+ ;;
+ m88k-omron*)
+ os=-luna
+ ;;
+ *-next )
+ os=-nextstep
+ ;;
+ *-sequent)
+ os=-ptx
+ ;;
+ *-crds)
+ os=-unos
+ ;;
+ *-ns)
+ os=-genix
+ ;;
+ i370-*)
+ os=-mvs
+ ;;
+ *-next)
+ os=-nextstep3
+ ;;
+ *-gould)
+ os=-sysv
+ ;;
+ *-highlevel)
+ os=-bsd
+ ;;
+ *-encore)
+ os=-bsd
+ ;;
+ *-sgi)
+ os=-irix
+ ;;
+ *-siemens)
+ os=-sysv4
+ ;;
+ *-masscomp)
+ os=-rtu
+ ;;
+ f301-fujitsu)
+ os=-uxpv
+ ;;
+ *-rom68k)
+ os=-coff
+ ;;
+ *-*bug)
+ os=-coff
+ ;;
+ *-apple)
+ os=-macos
+ ;;
+ *-atari*)
+ os=-mint
+ ;;
+ *)
+ os=-none
+ ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer. We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+ *-unknown)
+ case $os in
+ -riscix*)
+ vendor=acorn
+ ;;
+ -sunos*)
+ vendor=sun
+ ;;
+ -aix*)
+ vendor=ibm
+ ;;
+ -beos*)
+ vendor=be
+ ;;
+ -hpux*)
+ vendor=hp
+ ;;
+ -mpeix*)
+ vendor=hp
+ ;;
+ -hiux*)
+ vendor=hitachi
+ ;;
+ -unos*)
+ vendor=crds
+ ;;
+ -dgux*)
+ vendor=dg
+ ;;
+ -luna*)
+ vendor=omron
+ ;;
+ -genix*)
+ vendor=ns
+ ;;
+ -mvs* | -opened*)
+ vendor=ibm
+ ;;
+ -ptx*)
+ vendor=sequent
+ ;;
+ -vxsim* | -vxworks*)
+ vendor=wrs
+ ;;
+ -aux*)
+ vendor=apple
+ ;;
+ -hms*)
+ vendor=hitachi
+ ;;
+ -mpw* | -macos*)
+ vendor=apple
+ ;;
+ -*mint | -*MiNT)
+ vendor=atari
+ ;;
+ esac
+ basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+ ;;
+esac
+
+echo $basic_machine$os
diff --git a/gc/doc/README b/gc/doc/README
new file mode 100644
index 0000000..c6b48c3
--- /dev/null
+++ b/gc/doc/README
@@ -0,0 +1,617 @@
+Copyright (c) 1988, 1989 Hans-J. Boehm, Alan J. Demers
+Copyright (c) 1991-1996 by Xerox Corporation. All rights reserved.
+Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
+Copyright (c) 1999-2001 by Hewlett-Packard Company. All rights reserved.
+
+The file linux_threads.c is also
+Copyright (c) 1998 by Fergus Henderson. All rights reserved.
+
+The files Makefile.am, and configure.in are
+Copyright (c) 2001 by Red Hat Inc. All rights reserved.
+
+The files config.guess and a few others are copyrighted by the Free
+Software Foundation.
+
+THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
+
+Permission is hereby granted to use or copy this program
+for any purpose, provided the above notices are retained on all copies.
+Permission to modify the code and to distribute modified code is granted,
+provided the above notices are retained, and a notice that the code was
+modified is included with the above copyright notice.
+
+A few of the files needed to use the GNU-style build procedure come with
+slightly different licenses, though they are all similar in spirit. A few
+are GPL'ed, but with an exception that should cover all uses in the
+collector. (If you are concerned about such things, I recommend you look
+at the notice in config.guess or ltmain.sh.)
+
+This is version 6.0 of a conservative garbage collector for C and C++.
+
+You might find a more recent version of this at
+
+http://www.hpl.hp.com/personal/Hans_Boehm/gc
+
+OVERVIEW
+
+ This is intended to be a general purpose, garbage collecting storage
+allocator. The algorithms used are described in:
+
+Boehm, H., and M. Weiser, "Garbage Collection in an Uncooperative Environment",
+Software Practice & Experience, September 1988, pp. 807-820.
+
+Boehm, H., A. Demers, and S. Shenker, "Mostly Parallel Garbage Collection",
+Proceedings of the ACM SIGPLAN '91 Conference on Programming Language Design
+and Implementation, SIGPLAN Notices 26, 6 (June 1991), pp. 157-164.
+
+Boehm, H., "Space Efficient Conservative Garbage Collection", Proceedings
+of the ACM SIGPLAN '91 Conference on Programming Language Design and
+Implementation, SIGPLAN Notices 28, 6 (June 1993), pp. 197-206.
+
+Boehm H., "Reducing Garbage Collector Cache Misses", Proceedings of the
+2000 International Symposium on Memory Management.
+
+ Possible interactions between the collector and optimizing compilers are
+discussed in
+
+Boehm, H., and D. Chase, "A Proposal for GC-safe C Compilation",
+The Journal of C Language Translation 4, 2 (December 1992).
+
+and
+
+Boehm H., "Simple GC-safe Compilation", Proceedings
+of the ACM SIGPLAN '96 Conference on Programming Language Design and
+Implementation.
+
+(Some of these are also available from
+http://www.hpl.hp.com/personal/Hans_Boehm/papers/, among other places.)
+
+ Unlike the collector described in the second reference, this collector
+operates either with the mutator stopped during the entire collection
+(default) or incrementally during allocations. (The latter is supported
+on only a few machines.) On the most common platforms, it can be built
+with or without thread support. On a few platforms, it can take advantage
+of a multiprocessor to speed up garbage collection.
+
+ Many of the ideas underlying the collector have previously been explored
+by others. Notably, some of the run-time systems developed at Xerox PARC
+in the early 1980s conservatively scanned thread stacks to locate possible
+pointers (cf. Paul Rovner, "On Adding Garbage Collection and Runtime Types
+to a Strongly-Typed Statically Checked, Concurrent Language" Xerox PARC
+CSL 84-7). Doug McIlroy wrote a simpler fully conservative collector that
+was part of version 8 UNIX (tm), but appears to not have received
+widespread use.
+
+ Rudimentary tools for use of the collector as a leak detector are included
+(see http://www.hpl.hp.com/personal/Hans_Boehm/gc/leak.html),
+as is a fairly sophisticated string package "cord" that makes use of the
+collector. (See doc/README.cords and H.-J. Boehm, R. Atkinson, and M. Plass,
+"Ropes: An Alternative to Strings", Software Practice and Experience 25, 12
+(December 1995), pp. 1315-1330. This is very similar to the "rope" package
+in Xerox Cedar, or the "rope" package in the SGI STL or the g++ distribution.)
+
+Further collector documantation can be found at
+
+http://www.hpl.hp.com/personal/Hans_Boehm/gc
+
+
+GENERAL DESCRIPTION
+
+ This is a garbage collecting storage allocator that is intended to be
+used as a plug-in replacement for C's malloc.
+
+ Since the collector does not require pointers to be tagged, it does not
+attempt to ensure that all inaccessible storage is reclaimed. However,
+in our experience, it is typically more successful at reclaiming unused
+memory than most C programs using explicit deallocation. Unlike manually
+introduced leaks, the amount of unreclaimed memory typically stays
+bounded.
+
+ In the following, an "object" is defined to be a region of memory allocated
+by the routines described below.
+
+ Any objects not intended to be collected must be pointed to either
+from other such accessible objects, or from the registers,
+stack, data, or statically allocated bss segments. Pointers from
+the stack or registers may point to anywhere inside an object.
+The same is true for heap pointers if the collector is compiled with
+ ALL_INTERIOR_POINTERS defined, as is now the default.
+
+Compiling without ALL_INTERIOR_POINTERS may reduce accidental retention
+of garbage objects, by requiring pointers from the heap to to the beginning
+of an object. But this no longer appears to be a significant
+issue for most programs.
+
+There are a number of routines which modify the pointer recognition
+algorithm. GC_register_displacement allows certain interior pointers
+to be recognized even if ALL_INTERIOR_POINTERS is nor defined.
+GC_malloc_ignore_off_page allows some pointers into the middle of large objects
+to be disregarded, greatly reducing the probablility of accidental
+retention of large objects. For most purposes it seems best to compile
+with ALL_INTERIOR_POINTERS and to use GC_malloc_ignore_off_page if
+you get collector warnings from allocations of very large objects.
+See README.debugging for details.
+
+ WARNING: pointers inside memory allocated by the standard "malloc" are not
+seen by the garbage collector. Thus objects pointed to only from such a
+region may be prematurely deallocated. It is thus suggested that the
+standard "malloc" be used only for memory regions, such as I/O buffers, that
+are guaranteed not to contain pointers to garbage collectable memory.
+Pointers in C language automatic, static, or register variables,
+are correctly recognized. (Note that GC_malloc_uncollectable has semantics
+similar to standard malloc, but allocates objects that are traced by the
+collector.)
+
+ WARNING: the collector does not always know how to find pointers in data
+areas that are associated with dynamic libraries. This is easy to
+remedy IF you know how to find those data areas on your operating
+system (see GC_add_roots). Code for doing this under SunOS, IRIX 5.X and 6.X,
+HP/UX, Alpha OSF/1, Linux, and win32 is included and used by default. (See
+README.win32 for win32 details.) On other systems pointers from dynamic
+library data areas may not be considered by the collector.
+If you're writing a program that depends on the collector scanning
+dynamic library data areas, it may be a good idea to include at least
+one call to GC_is_visible() to ensure that those areas are visible
+to the collector.
+
+ Note that the garbage collector does not need to be informed of shared
+read-only data. However if the shared library mechanism can introduce
+discontiguous data areas that may contain pointers, then the collector does
+need to be informed.
+
+ Signal processing for most signals may be deferred during collection,
+and during uninterruptible parts of the allocation process.
+Like standard ANSI C mallocs, by default it is unsafe to invoke
+malloc (and other GC routines) from a signal handler while another
+malloc call may be in progress. Removing -DNO_SIGNALS from Makefile
+attempts to remedy that. But that may not be reliable with a compiler that
+substantially reorders memory operations inside GC_malloc.
+
+ The allocator/collector can also be configured for thread-safe operation.
+(Full signal safety can also be achieved, but only at the cost of two system
+calls per malloc, which is usually unacceptable.)
+WARNING: the collector does not guarantee to scan thread-local storage
+(e.g. of the kind accessed with pthread_getspecific()). The collector
+does scan thread stacks, though, so generally the best solution is to
+ensure that any pointers stored in thread-local storage are also
+stored on the thread's stack for the duration of their lifetime.
+(This is arguably a longstanding bug, but it hasn't been fixed yet.)
+
+INSTALLATION AND PORTABILITY
+
+ As distributed, the macro SILENT is defined in Makefile.
+In the event of problems, this can be removed to obtain a moderate
+amount of descriptive output for each collection.
+(The given statistics exhibit a few peculiarities.
+Things don't appear to add up for a variety of reasons, most notably
+fragmentation losses. These are probably much more significant for the
+contrived program "test.c" than for your application.)
+
+ Note that typing "make test" will automatically build the collector
+and then run setjmp_test and gctest. Setjmp_test will give you information
+about configuring the collector, which is useful primarily if you have
+a machine that's not already supported. Gctest is a somewhat superficial
+test of collector functionality. Failure is indicated by a core dump or
+a message to the effect that the collector is broken. Gctest takes about
+35 seconds to run on a SPARCstation 2. It may use up to 8 MB of memory. (The
+multi-threaded version will use more. 64-bit versions may use more.)
+"Make test" will also, as its last step, attempt to build and test the
+"cord" string library. This will fail without an ANSI C compiler, but
+the garbage collector itself should still be usable.
+
+ The Makefile will generate a library gc.a which you should link against.
+Typing "make cords" will add the cord library to gc.a.
+Note that this requires an ANSI C compiler.
+
+ It is suggested that if you need to replace a piece of the collector
+(e.g. GC_mark_rts.c) you simply list your version ahead of gc.a on the
+ld command line, rather than replacing the one in gc.a. (This will
+generate numerous warnings under some versions of AIX, but it still
+works.)
+
+ All include files that need to be used by clients will be put in the
+include subdirectory. (Normally this is just gc.h. "Make cords" adds
+"cord.h" and "ec.h".)
+
+ The collector currently is designed to run essentially unmodified on
+machines that use a flat 32-bit or 64-bit address space.
+That includes the vast majority of Workstations and X86 (X >= 3) PCs.
+(The list here was deleted because it was getting too long and constantly
+out of date.)
+ It does NOT run under plain 16-bit DOS or Windows 3.X. There are however
+various packages (e.g. win32s, djgpp) that allow flat 32-bit address
+applications to run under those systemsif the have at least an 80386 processor,
+and several of those are compatible with the collector.
+
+ In a few cases (Amiga, OS/2, Win32, MacOS) a separate makefile
+or equivalent is supplied. Many of these have separate README.system
+files.
+
+ Dynamic libraries are completely supported only under SunOS
+(and even that support is not functional on the last Sun 3 release),
+Linux, IRIX 5&6, HP-PA, Win32 (not Win32S) and OSF/1 on DEC AXP machines.
+On other machines we recommend that you do one of the following:
+
+ 1) Add dynamic library support (and send us the code).
+ 2) Use static versions of the libraries.
+ 3) Arrange for dynamic libraries to use the standard malloc.
+ This is still dangerous if the library stores a pointer to a
+ garbage collected object. But nearly all standard interfaces
+ prohibit this, because they deal correctly with pointers
+ to stack allocated objects. (Strtok is an exception. Don't
+ use it.)
+
+ In all cases we assume that pointer alignment is consistent with that
+enforced by the standard C compilers. If you use a nonstandard compiler
+you may have to adjust the alignment parameters defined in gc_priv.h.
+
+ A port to a machine that is not byte addressed, or does not use 32 bit
+or 64 bit addresses will require a major effort. A port to plain MSDOS
+or win16 is hard.
+
+ For machines not already mentioned, or for nonstandard compilers, the
+following are likely to require change:
+
+1. The parameters in gcconfig.h.
+ The parameters that will usually require adjustment are
+ STACKBOTTOM, ALIGNMENT and DATASTART. Setjmp_test
+ prints its guesses of the first two.
+ DATASTART should be an expression for computing the
+ address of the beginning of the data segment. This can often be
+ &etext. But some memory management units require that there be
+ some unmapped space between the text and the data segment. Thus
+ it may be more complicated. On UNIX systems, this is rarely
+ documented. But the adb "$m" command may be helpful. (Note
+ that DATASTART will usually be a function of &etext. Thus a
+ single experiment is usually insufficient.)
+ STACKBOTTOM is used to initialize GC_stackbottom, which
+ should be a sufficient approximation to the coldest stack address.
+ On some machines, it is difficult to obtain such a value that is
+ valid across a variety of MMUs, OS releases, etc. A number of
+ alternatives exist for using the collector in spite of this. See the
+ discussion in gcconfig.h immediately preceding the various
+ definitions of STACKBOTTOM.
+
+2. mach_dep.c.
+ The most important routine here is one to mark from registers.
+ The distributed file includes a generic hack (based on setjmp) that
+ happens to work on many machines, and may work on yours. Try
+ compiling and running setjmp_t.c to see whether it has a chance of
+ working. (This is not correct C, so don't blame your compiler if it
+ doesn't work. Based on limited experience, register window machines
+ are likely to cause trouble. If your version of setjmp claims that
+ all accessible variables, including registers, have the value they
+ had at the time of the longjmp, it also will not work. Vanilla 4.2 BSD
+ on Vaxen makes such a claim. SunOS does not.)
+ If your compiler does not allow in-line assembly code, or if you prefer
+ not to use such a facility, mach_dep.c may be replaced by a .s file
+ (as we did for the MIPS machine and the PC/RT).
+ At this point enough architectures are supported by mach_dep.c
+ that you will rarely need to do more than adjust for assembler
+ syntax.
+
+3. os_dep.c (and gc_priv.h).
+ Several kinds of operating system dependent routines reside here.
+ Many are optional. Several are invoked only through corresponding
+ macros in gc_priv.h, which may also be redefined as appropriate.
+ The routine GC_register_data_segments is crucial. It registers static
+ data areas that must be traversed by the collector. (User calls to
+ GC_add_roots may sometimes be used for similar effect.)
+ Routines to obtain memory from the OS also reside here.
+ Alternatively this can be done entirely by the macro GET_MEM
+ defined in gc_priv.h. Routines to disable and reenable signals
+ also reside here if they are need by the macros DISABLE_SIGNALS
+ and ENABLE_SIGNALS defined in gc_priv.h.
+ In a multithreaded environment, the macros LOCK and UNLOCK
+ in gc_priv.h will need to be suitably redefined.
+ The incremental collector requires page dirty information, which
+ is acquired through routines defined in os_dep.c. Unless directed
+ otherwise by gcconfig.h, these are implemented as stubs that simply
+ treat all pages as dirty. (This of course makes the incremental
+ collector much less useful.)
+
+4. dyn_load.c
+ This provides a routine that allows the collector to scan data
+ segments associated with dynamic libraries. Often it is not
+ necessary to provide this routine unless user-written dynamic
+ libraries are used.
+
+ For a different version of UN*X or different machines using the
+Motorola 68000, Vax, SPARC, 80386, NS 32000, PC/RT, or MIPS architecture,
+it should frequently suffice to change definitions in gcconfig.h.
+
+
+THE C INTERFACE TO THE ALLOCATOR
+
+ The following routines are intended to be directly called by the user.
+Note that usually only GC_malloc is necessary. GC_clear_roots and GC_add_roots
+calls may be required if the collector has to trace from nonstandard places
+(e.g. from dynamic library data areas on a machine on which the
+collector doesn't already understand them.) On some machines, it may
+be desirable to set GC_stacktop to a good approximation of the stack base.
+(This enhances code portability on HP PA machines, since there is no
+good way for the collector to compute this value.) Client code may include
+"gc.h", which defines all of the following, plus many others.
+
+1) GC_malloc(nbytes)
+ - allocate an object of size nbytes. Unlike malloc, the object is
+ cleared before being returned to the user. Gc_malloc will
+ invoke the garbage collector when it determines this to be appropriate.
+ GC_malloc may return 0 if it is unable to acquire sufficient
+ space from the operating system. This is the most probable
+ consequence of running out of space. Other possible consequences
+ are that a function call will fail due to lack of stack space,
+ or that the collector will fail in other ways because it cannot
+ maintain its internal data structures, or that a crucial system
+ process will fail and take down the machine. Most of these
+ possibilities are independent of the malloc implementation.
+
+2) GC_malloc_atomic(nbytes)
+ - allocate an object of size nbytes that is guaranteed not to contain any
+ pointers. The returned object is not guaranteed to be cleared.
+ (Can always be replaced by GC_malloc, but results in faster collection
+ times. The collector will probably run faster if large character
+ arrays, etc. are allocated with GC_malloc_atomic than if they are
+ statically allocated.)
+
+3) GC_realloc(object, new_size)
+ - change the size of object to be new_size. Returns a pointer to the
+ new object, which may, or may not, be the same as the pointer to
+ the old object. The new object is taken to be atomic iff the old one
+ was. If the new object is composite and larger than the original object,
+ then the newly added bytes are cleared (we hope). This is very likely
+ to allocate a new object, unless MERGE_SIZES is defined in gc_priv.h.
+ Even then, it is likely to recycle the old object only if the object
+ is grown in small additive increments (which, we claim, is generally bad
+ coding practice.)
+
+4) GC_free(object)
+ - explicitly deallocate an object returned by GC_malloc or
+ GC_malloc_atomic. Not necessary, but can be used to minimize
+ collections if performance is critical. Probably a performance
+ loss for very small objects (<= 8 bytes).
+
+5) GC_expand_hp(bytes)
+ - Explicitly increase the heap size. (This is normally done automatically
+ if a garbage collection failed to GC_reclaim enough memory. Explicit
+ calls to GC_expand_hp may prevent unnecessarily frequent collections at
+ program startup.)
+
+6) GC_malloc_ignore_off_page(bytes)
+ - identical to GC_malloc, but the client promises to keep a pointer to
+ the somewhere within the first 256 bytes of the object while it is
+ live. (This pointer should nortmally be declared volatile to prevent
+ interference from compiler optimizations.) This is the recommended
+ way to allocate anything that is likely to be larger than 100Kbytes
+ or so. (GC_malloc may result in failure to reclaim such objects.)
+
+7) GC_set_warn_proc(proc)
+ - Can be used to redirect warnings from the collector. Such warnings
+ should be rare, and should not be ignored during code development.
+
+8) GC_enable_incremental()
+ - Enables generational and incremental collection. Useful for large
+ heaps on machines that provide access to page dirty information.
+ Some dirty bit implementations may interfere with debugging
+ (by catching address faults) and place restrictions on heap arguments
+ to system calls (since write faults inside a system call may not be
+ handled well).
+
+9) Several routines to allow for registration of finalization code.
+ User supplied finalization code may be invoked when an object becomes
+ unreachable. To call (*f)(obj, x) when obj becomes inaccessible, use
+ GC_register_finalizer(obj, f, x, 0, 0);
+ For more sophisticated uses, and for finalization ordering issues,
+ see gc.h.
+
+ The global variable GC_free_space_divisor may be adjusted up from its
+default value of 4 to use less space and more collection time, or down for
+the opposite effect. Setting it to 1 or 0 will effectively disable collections
+and cause all allocations to simply grow the heap.
+
+ The variable GC_non_gc_bytes, which is normally 0, may be changed to reflect
+the amount of memory allocated by the above routines that should not be
+considered as a candidate for collection. Careless use may, of course, result
+in excessive memory consumption.
+
+ Some additional tuning is possible through the parameters defined
+near the top of gc_priv.h.
+
+ If only GC_malloc is intended to be used, it might be appropriate to define:
+
+#define malloc(n) GC_malloc(n)
+#define calloc(m,n) GC_malloc((m)*(n))
+
+ For small pieces of VERY allocation intensive code, gc_inl.h
+includes some allocation macros that may be used in place of GC_malloc
+and friends.
+
+ All externally visible names in the garbage collector start with "GC_".
+To avoid name conflicts, client code should avoid this prefix, except when
+accessing garbage collector routines or variables.
+
+ There are provisions for allocation with explicit type information.
+This is rarely necessary. Details can be found in gc_typed.h.
+
+THE C++ INTERFACE TO THE ALLOCATOR:
+
+ The Ellis-Hull C++ interface to the collector is included in
+the collector distribution. If you intend to use this, type
+"make c++" after the initial build of the collector is complete.
+See gc_cpp.h for the definition of the interface. This interface
+tries to approximate the Ellis-Detlefs C++ garbage collection
+proposal without compiler changes.
+
+Cautions:
+1. Arrays allocated without new placement syntax are
+allocated as uncollectable objects. They are traced by the
+collector, but will not be reclaimed.
+
+2. Failure to use "make c++" in combination with (1) will
+result in arrays allocated using the default new operator.
+This is likely to result in disaster without linker warnings.
+
+3. If your compiler supports an overloaded new[] operator,
+then gc_cpp.cc and gc_cpp.h should be suitably modified.
+
+4. Many current C++ compilers have deficiencies that
+break some of the functionality. See the comments in gc_cpp.h
+for suggested workarounds.
+
+USE AS LEAK DETECTOR:
+
+ The collector may be used to track down leaks in C programs that are
+intended to run with malloc/free (e.g. code with extreme real-time or
+portability constraints). To do so define FIND_LEAK in Makefile
+This will cause the collector to invoke the report_leak
+routine defined near the top of reclaim.c whenever an inaccessible
+object is found that has not been explicitly freed. Such objects will
+also be automatically reclaimed.
+ Productive use of this facility normally involves redefining report_leak
+to do something more intelligent. This typically requires annotating
+objects with additional information (e.g. creation time stack trace) that
+identifies their origin. Such code is typically not very portable, and is
+not included here, except on SPARC machines.
+ If all objects are allocated with GC_DEBUG_MALLOC (see next section),
+then the default version of report_leak will report the source file
+and line number at which the leaked object was allocated. This may
+sometimes be sufficient. (On SPARC/SUNOS4 machines, it will also report
+a cryptic stack trace. This can often be turned into a sympolic stack
+trace by invoking program "foo" with "callprocs foo". Callprocs is
+a short shell script that invokes adb to expand program counter values
+to symbolic addresses. It was largely supplied by Scott Schwartz.)
+ Note that the debugging facilities described in the next section can
+sometimes be slightly LESS effective in leak finding mode, since in
+leak finding mode, GC_debug_free actually results in reuse of the object.
+(Otherwise the object is simply marked invalid.) Also note that the test
+program is not designed to run meaningfully in FIND_LEAK mode.
+Use "make gc.a" to build the collector.
+
+DEBUGGING FACILITIES:
+
+ The routines GC_debug_malloc, GC_debug_malloc_atomic, GC_debug_realloc,
+and GC_debug_free provide an alternate interface to the collector, which
+provides some help with memory overwrite errors, and the like.
+Objects allocated in this way are annotated with additional
+information. Some of this information is checked during garbage
+collections, and detected inconsistencies are reported to stderr.
+
+ Simple cases of writing past the end of an allocated object should
+be caught if the object is explicitly deallocated, or if the
+collector is invoked while the object is live. The first deallocation
+of an object will clear the debugging info associated with an
+object, so accidentally repeated calls to GC_debug_free will report the
+deallocation of an object without debugging information. Out of
+memory errors will be reported to stderr, in addition to returning
+NIL.
+
+ GC_debug_malloc checking during garbage collection is enabled
+with the first call to GC_debug_malloc. This will result in some
+slowdown during collections. If frequent heap checks are desired,
+this can be achieved by explicitly invoking GC_gcollect, e.g. from
+the debugger.
+
+ GC_debug_malloc allocated objects should not be passed to GC_realloc
+or GC_free, and conversely. It is however acceptable to allocate only
+some objects with GC_debug_malloc, and to use GC_malloc for other objects,
+provided the two pools are kept distinct. In this case, there is a very
+low probablility that GC_malloc allocated objects may be misidentified as
+having been overwritten. This should happen with probability at most
+one in 2**32. This probability is zero if GC_debug_malloc is never called.
+
+ GC_debug_malloc, GC_malloc_atomic, and GC_debug_realloc take two
+additional trailing arguments, a string and an integer. These are not
+interpreted by the allocator. They are stored in the object (the string is
+not copied). If an error involving the object is detected, they are printed.
+
+ The macros GC_MALLOC, GC_MALLOC_ATOMIC, GC_REALLOC, GC_FREE, and
+GC_REGISTER_FINALIZER are also provided. These require the same arguments
+as the corresponding (nondebugging) routines. If gc.h is included
+with GC_DEBUG defined, they call the debugging versions of these
+functions, passing the current file name and line number as the two
+extra arguments, where appropriate. If gc.h is included without GC_DEBUG
+defined, then all these macros will instead be defined to their nondebugging
+equivalents. (GC_REGISTER_FINALIZER is necessary, since pointers to
+objects with debugging information are really pointers to a displacement
+of 16 bytes form the object beginning, and some translation is necessary
+when finalization routines are invoked. For details, about what's stored
+in the header, see the definition of the type oh in debug_malloc.c)
+
+INCREMENTAL/GENERATIONAL COLLECTION:
+
+The collector normally interrupts client code for the duration of
+a garbage collection mark phase. This may be unacceptable if interactive
+response is needed for programs with large heaps. The collector
+can also run in a "generational" mode, in which it usually attempts to
+collect only objects allocated since the last garbage collection.
+Furthermore, in this mode, garbage collections run mostly incrementally,
+with a small amount of work performed in response to each of a large number of
+GC_malloc requests.
+
+This mode is enabled by a call to GC_enable_incremental().
+
+Incremental and generational collection is effective in reducing
+pause times only if the collector has some way to tell which objects
+or pages have been recently modified. The collector uses two sources
+of information:
+
+1. Information provided by the VM system. This may be provided in
+one of several forms. Under Solaris 2.X (and potentially under other
+similar systems) information on dirty pages can be read from the
+/proc file system. Under other systems (currently SunOS4.X) it is
+possible to write-protect the heap, and catch the resulting faults.
+On these systems we require that system calls writing to the heap
+(other than read) be handled specially by client code.
+See os_dep.c for details.
+
+2. Information supplied by the programmer. We define "stubborn"
+objects to be objects that are rarely changed. Such an object
+can be allocated (and enabled for writing) with GC_malloc_stubborn.
+Once it has been initialized, the collector should be informed with
+a call to GC_end_stubborn_change. Subsequent writes that store
+pointers into the object must be preceded by a call to
+GC_change_stubborn.
+
+This mechanism performs best for objects that are written only for
+initialization, and such that only one stubborn object is writable
+at once. It is typically not worth using for short-lived
+objects. Stubborn objects are treated less efficiently than pointerfree
+(atomic) objects.
+
+A rough rule of thumb is that, in the absence of VM information, garbage
+collection pauses are proportional to the amount of pointerful storage
+plus the amount of modified "stubborn" storage that is reachable during
+the collection.
+
+Initial allocation of stubborn objects takes longer than allocation
+of other objects, since other data structures need to be maintained.
+
+We recommend against random use of stubborn objects in client
+code, since bugs caused by inappropriate writes to stubborn objects
+are likely to be very infrequently observed and hard to trace.
+However, their use may be appropriate in a few carefully written
+library routines that do not make the objects themselves available
+for writing by client code.
+
+
+BUGS:
+
+ Any memory that does not have a recognizable pointer to it will be
+reclaimed. Exclusive-or'ing forward and backward links in a list
+doesn't cut it.
+ Some C optimizers may lose the last undisguised pointer to a memory
+object as a consequence of clever optimizations. This has almost
+never been observed in practice. Send mail to boehm@acm.org
+for suggestions on how to fix your compiler.
+ This is not a real-time collector. In the standard configuration,
+percentage of time required for collection should be constant across
+heap sizes. But collection pauses will increase for larger heaps.
+(On SPARCstation 2s collection times will be on the order of 300 msecs
+per MB of accessible memory that needs to be scanned. Your mileage
+may vary.) The incremental/generational collection facility helps,
+but is portable only if "stubborn" allocation is used.
+ Please address bug reports to boehm@acm.org. If you are
+contemplating a major addition, you might also send mail to ask whether
+it's already been done (or whether we tried and discarded it).
+
diff --git a/gc/doc/README.Mac b/gc/doc/README.Mac
new file mode 100644
index 0000000..04f4682
--- /dev/null
+++ b/gc/doc/README.Mac
@@ -0,0 +1,385 @@
+Patrick Beard's Notes for building GC v4.12 with CodeWarrior Pro 2:
+----------------------------------------------------------------------------
+The current build environment for the collector is CodeWarrior Pro 2.
+Projects for CodeWarrior Pro 2 (and for quite a few older versions)
+are distributed in the file Mac_projects.sit.hqx. The project file
+:Mac_projects:gc.prj builds static library versions of the collector.
+:Mac_projects:gctest.prj builds the GC test suite.
+
+Configuring the collector is still done by editing the files
+:Mac_files:MacOS_config.h and :Mac_files:MacOS_Test_config.h.
+
+Lars Farm's suggestions on building the collector:
+----------------------------------------------------------------------------
+Garbage Collection on MacOS - a manual 'MakeFile'
+-------------------------------------------------
+
+Project files and IDE's are great on the Macintosh, but they do have
+problems when used as distribution media. This note tries to provide
+porting instructions in pure TEXT form to avoid those problems. A manual
+'makefile' if you like.
+
+ GC version: 4.12a2
+ Codewarrior: CWPro1
+ date: 18 July 1997
+
+The notes may or may not apply to earlier or later versions of the
+GC/CWPro. Actually, they do apply to earlier versions of both except that
+until recently a project could only build one target so each target was a
+separate project. The notes will most likely apply to future versions too.
+Possibly with minor tweaks.
+
+This is just to record my experiences. These notes do not mean I now
+provide a supported port of the GC to MacOS. It works for me. If it works
+for you, great. If it doesn't, sorry, try again...;-) Still, if you find
+errors, please let me know.
+
+ mailto: lars.farm@ite.mh.se
+
+ address: Lars Farm
+ Krönvägen 33b
+ 856 44 Sundsvall
+ Sweden
+
+Porting to MacOS is a bit more complex than it first seems. Which MacOS?
+68K/PowerPC? Which compiler? Each supports both 68K and PowerPC and offer a
+large number of (unique to each environment) compiler settings. Each
+combination of compiler/68K/PPC/settings require a unique combination of
+standard libraries. And the IDE's does not select them for you. They don't
+even check that the library is built with compatible setting and this is
+the major source of problems when porting the GC (and otherwise too).
+
+You will have to make choices when you configure the GC. I've made some
+choices here, but there are other combinations of settings and #defines
+that work too.
+
+As for target settings the major obstacles may be:
+- 68K Processor: check "4-byte Ints".
+- PPC Processor: uncheck "Store Static Data in TOC".
+
+What you need to do:
+===================
+
+1) Build the GC as a library
+2) Test that the library works with 'test.c'.
+3) Test that the C++ interface 'gc_cpp.cc/h' works with 'test_cpp.cc'.
+
+1) The Libraries:
+=================
+I made one project with four targets (68K/PPC tempmem or appheap). One target
+will suffice if you're able to decide which one you want. I wasn't...
+
+Codewarrior allows a large number of compiler/linker settings. I used these:
+
+Settings shared by all targets:
+------------------------------
+o Access Paths:
+ - User Paths: the GC folder
+ - System Paths: {Compiler}:Metrowerks Standard Library:
+ {Compiler}:MacOS Support:Headers:
+ {Compiler}:MacOS Support:MacHeaders:
+o C/C++ language:
+ - inlining: normal
+ - direct to SOM: off
+ - enable/check: exceptions, RTTI, bool (and if you like pool strings)
+
+PowerPC target settings
+-----------------------
+o Target Settings:
+ - name of target
+ - MacOS PPC Linker
+o PPC Target
+ - name of library
+o C/C++ language
+ - prefix file as described below
+o PPC Processor
+ - Struct Alignment: PowerPC
+ - uncheck "Store Static Data in TOC" -- important!
+ I don't think the others matter, I use full optimization and its ok
+o PPC Linker
+ - Factory Settings (SYM file with full paths, faster linking, dead-strip
+ static init, Main: __start)
+
+
+68K target settings
+-------------------
+o Target Settings:
+ - name of target
+ - MacOS 68K Linker
+o 68K Target
+ - name of library
+ - A5 relative data
+o C/C++ language
+ - prefix file as described below
+o 68K Processor
+ - Code model: smart
+ - Struct alignment: 68K
+ - FP: SANE
+ - enable 4-Byte Ints -- important!
+ I don't think the others matter. I selected...
+ - enable: 68020
+ - enable: global register allocation
+o IR Optimizer
+ - enable: Optimize Space, Optimize Speed
+ I suppose the others would work too, but haven't tried...
+o 68K Linker
+ - Factory Settings (New Style MacsBug,SYM file with full paths,
+ A6 Frames, fast link, Merge compiler glue into segment 1,
+ dead-strip static init)
+
+Prefix Files to configure the GC sources
+----------------------------------------
+The Codewarrior equivalent of commandline compilers -DNAME=X is to use
+prefix-files. A TEXT file that is automatically #included before the first byte
+of every source file. I used these:
+
+---- ( cut here ) ---- gc_prefix_tempmem.h -- 68K and PPC -----
+ #include "gc_prefix_common.h"
+ #undef USE_TEMPORARY_MEMORY
+ #define USE_TEMPORARY_MEMORY
+---- ( cut here ) ---- gc_prefix_appmem.h -- 68K and PPC -----
+ #include "gc_prefix_common.h"
+ #undef USE_TEMPORARY_MEMORY
+// #define USE_TEMPORARY_MEMORY
+
+---- ( cut here ) ---- gc_prefix_common.h --------------------
+// gc_prefix_common.h
+// ------------------
+// Codewarrior prefix file to configure the GC libraries
+//
+// prefix files are the Codewarrior equivalent of the
+// command line option -Dname=x frequently seen in makefiles
+
+#if !__MWERKS__
+ #error only tried this with Codewarrior
+#endif
+
+#if macintosh
+ #define MSL_USE_PRECOMPILED_HEADERS 0
+ #include <ansi_prefix.mac.h>
+ #ifndef __STDC__
+ #define __STDC__ 0
+ #endif
+
+ // See list of #defines to configure the library in: 'MakeFile'
+ // see also README
+
+ #define SILENT // no collection messages. In case
+ // of trouble you might want this off
+ #define ALL_INTERIOR_POINTERS // follows interior pointers.
+//#define DONT_ADD_BYTE_AT_END // disables the padding if defined.
+//#define SMALL_CONFIG // whether to use a smaller heap.
+ #define NO_SIGNALS // signals aren't real on the Macintosh.
+ #define ATOMIC_UNCOLLECTABLE // GC_malloc_atomic_uncollectable()
+
+ // define either or none as per personal preference
+ // used in malloc.c
+ #define REDIRECT_MALLOC GC_malloc
+//#define REDIRECT_MALLOC GC_malloc_uncollectable
+ // if REDIRECT_MALLOC is #defined make sure that the GC library
+ // is listed before the ANSI/ISO libs in the Codewarrior
+ // 'Link order' panel
+//#define IGNORE_FREE
+
+ // mac specific configs
+//#define USE_TEMPORARY_MEMORY // use Macintosh temporary memory.
+//#define SHARED_LIBRARY_BUILD // build for use in a shared library.
+
+#else
+ // could build Win32 here too, or in the future
+ // Rhapsody PPC-mach, Rhapsody PPC-MacOS,
+ // Rhapsody Intel-mach, Rhapsody Intel-Win32,...
+ // ... ugh this will get messy ...
+#endif
+
+// make sure ints are at least 32-bit
+// ( could be set to 16-bit by compiler settings (68K) )
+
+struct gc_private_assert_intsize_{ char x[ sizeof(int)>=4 ? 1 : 0 ]; };
+
+#if __powerc
+ #if __option(toc_data)
+ #error turn off "store static data in TOC" when using GC
+ // ... or find a way to add TOC to the root set...(?)
+ #endif
+#endif
+---- ( cut here ) ---- end of gc_prefix_common.h -----------------
+
+Files to build the GC libraries:
+--------------------------------
+ allchblk.c
+ alloc.c
+ blacklst.c
+ checksums.c
+ dbg_mlc.c
+ finalize.c
+ headers.c
+ mach_dep.c
+ MacOS.c -- contains MacOS code
+ malloc.c
+ mallocx.c
+ mark.c
+ mark_rts.c
+ misc.c
+ new_hblk.c
+ obj_map.c
+ os_dep.c -- contains MacOS code
+ ptr_chck.c
+ reclaim.c
+ stubborn.c
+ typd_mlc.c
+ gc++.cc -- this is 'gc_cpp.cc' with less 'inline' and
+ -- throw std::bad_alloc when out of memory
+ -- gc_cpp.cc works just fine too
+
+2) Test that the library works with 'test.c'.
+=============================================
+
+The test app is just an ordinary ANSI-C console app. Make sure settings
+match the library you're testing.
+
+Files
+-----
+ test.c
+ the GC library to test -- link order before ANSI libs
+ suitable Mac+ANSI libraries
+
+prefix:
+------
+---- ( cut here ) ---- gc_prefix_testlib.h -- all libs -----
+#define MSL_USE_PRECOMPILED_HEADERS 0
+#include <ansi_prefix.mac.h>
+#undef NDEBUG
+
+#define ALL_INTERIOR_POINTERS /* for GC_priv.h */
+---- ( cut here ) ----
+
+3) Test that the C++ interface 'gc_cpp.cc/h' works with 'test_cpp.cc'.
+
+The test app is just an ordinary ANSI-C console app. Make sure settings match
+the library you're testing.
+
+Files
+-----
+ test_cpp.cc
+ the GC library to test -- link order before ANSI libs
+ suitable Mac+ANSI libraries
+
+prefix:
+------
+same as for test.c
+
+For convenience I used one test-project with several targets so that all
+test apps are build at once. Two for each library to test: test.c and
+gc_app.cc. When I was satisfied that the libraries were ok. I put the
+libraries + gc.h + the c++ interface-file in a folder that I then put into
+the MSL hierarchy so that I don't have to alter access-paths in projects
+that use the GC.
+
+After that, just add the proper GC library to your project and the GC is in
+action! malloc will call GC_malloc and free GC_free, new/delete too. You
+don't have to call free or delete. You may have to be a bit cautious about
+delete if you're freeing other resources than RAM. See gc_cpp.h. You can
+also keep coding as always with delete/free. That works too. If you want,
+"include <gc.h> and tweak it's use a bit.
+
+Symantec SPM
+============
+It has been a while since I tried the GC in SPM, but I think that the above
+instructions should be sufficient to guide you through in SPM too. SPM
+needs to know where the global data is. Use the files 'datastart.c' and
+'dataend.c'. Put 'datastart.c' at the top of your project and 'dataend.c'
+at the bottom of your project so that all data is surrounded. This is not
+needed in Codewarrior because it provides intrinsic variables
+__datastart__, __data_end__ that wraps all globals.
+
+Source Changes (GC 4.12a2)
+==========================
+Very few. Just one tiny in the GC, not strictly needed.
+- MacOS.c line 131 in routine GC_MacFreeTemporaryMemory()
+ change # if !defined(SHARED_LIBRARY_BUILD)
+ to # if !defined(SILENT) && !defined(SHARED_LIBRARY_BUILD)
+ To turn off a message when the application quits (actually, I faked
+ this change by #defining SHARED_LIBRARY_BUILD in a statically linked
+ library for more than a year without ill effects but perhaps this is
+ better).
+
+- test_cpp.cc
+ made the first lines of main() look like this:
+ ------------
+ int main( int argc, char* argv[] ) {
+ #endif
+ #if macintosh // MacOS
+ char* argv_[] = {"test_cpp","10"}; // doesn't
+ argv=argv_; // have a
+ argc = sizeof(argv_)/sizeof(argv_[0]); // commandline
+ #endif //
+
+ int i, iters, n;
+ # ifndef __GNUC__
+ alloc dummy_to_fool_the_compiler_into_doing_things_it_currently_cant_handle;
+ ------------
+
+- config.h [now gcconfig.h]
+ __MWERKS__ does not have to mean MACOS. You can use Codewarrior to
+ build a Win32 or BeOS library and soon a Rhapsody library. You may
+ have to change that #if...
+
+
+
+ It worked for me, hope it works for you.
+
+ Lars Farm
+ 18 July 1997
+----------------------------------------------------------------------------
+
+
+Patrick Beard's instructions (may be dated):
+
+v4.3 of the collector now runs under Symantec C++/THINK C v7.0.4, and
+Metrowerks C/C++ v4.5 both 68K and PowerPC. Project files are provided
+to build and test the collector under both development systems.
+
+Configuration
+-------------
+
+To configure the collector, under both development systems, a prefix file
+is used to set preprocessor directives. This file is called "MacOS_config.h".
+Also to test the collector, "MacOS_Test_config.h" is provided.
+
+Testing
+-------
+
+To test the collector (always a good idea), build one of the gctest projects,
+gctest.¹ (Symantec C++/THINK C), mw/gctest.68K.¹, or mw/gctest.PPC.¹. The
+test will ask you how many times to run; 1 should be sufficient.
+
+Building
+--------
+
+For your convenience project files for the major Macintosh development
+systems are provided.
+
+For Symantec C++/THINK C, you must build the two projects gclib-1.¹ and
+gclib-2.¹. It has to be split up because the collector has more than 32k
+of static data and no library can have more than this in the Symantec
+environment. (Future versions will probably fix this.)
+
+For Metrowerks C/C++ 4.5 you build gc.68K.¹/gc.PPC.¹ and the result will
+be a library called gc.68K.lib/gc.PPC.lib.
+
+Using
+-----
+
+Under Symantec C++/THINK C, you can just add the gclib-1.¹ and gclib-2.¹
+projects to your own project. Under Metrowerks, you add gc.68K.lib or
+gc.PPC.lib and two additional files. You add the files called datastart.c
+and dataend.c to your project, bracketing all files that use the collector.
+See mw/gctest.¹ for an example.
+
+Include the projects/libraries you built above into your own project,
+#include "gc.h", and call GC_malloc. You don't have to call GC_free.
+
+
+Patrick C. Beard
+January 4, 1995
diff --git a/gc/doc/README.MacOSX b/gc/doc/README.MacOSX
new file mode 100644
index 0000000..2abf0b4
--- /dev/null
+++ b/gc/doc/README.MacOSX
@@ -0,0 +1,27 @@
+While the GC should work on MacOS X Server, MacOS X and Darwin, I only tested
+it on MacOS X Server.
+I've added a PPC assembly version of GC_push_regs(), thus the setjmp() hack is
+no longer necessary. Incremental collection is supported via mprotect/signal.
+The current solution isn't really optimal because the signal handler must decode
+the faulting PPC machine instruction in order to find the correct heap address.
+Further, it must poke around in the register state which the kernel saved away
+in some obscure register state structure before it calls the signal handler -
+needless to say the layout of this structure is no where documented.
+Threads and dynamic libraries are not yet supported (adding dynamic library
+support via the low-level dyld API shouldn't be that hard).
+
+The original MacOS X port was brought to you by Andrew Stone.
+
+
+June, 1 2000
+
+Dietmar Planitzer
+dave.pl@ping.at
+
+Note from Andrew Begel:
+
+One more fix to enable gc.a to link successfully into a shared library for
+MacOS X. You have to add -fno-common to the CFLAGS in the Makefile. MacOSX
+disallows common symbols in anything that eventually finds its way into a
+shared library. (I don't completely understand why, but -fno-common seems to
+work and doesn't mess up the garbage collector's functionality).
diff --git a/gc/doc/README.OS2 b/gc/doc/README.OS2
new file mode 100644
index 0000000..5345bbd
--- /dev/null
+++ b/gc/doc/README.OS2
@@ -0,0 +1,6 @@
+The code assumes static linking, and a single thread. The editor de has
+not been ported. The cord test program has. The supplied OS2_MAKEFILE
+assumes the IBM C Set/2 environment, but the code shouldn't.
+
+Since we haven't figured out hoe to do perform partial links or to build static
+libraries, clients currently need to link against a long list of executables.
diff --git a/gc/doc/README.amiga b/gc/doc/README.amiga
new file mode 100644
index 0000000..730dce3
--- /dev/null
+++ b/gc/doc/README.amiga
@@ -0,0 +1,322 @@
+===========================================================================
+ Kjetil S. Matheussen's notes (28-11-2000)
+===========================================================================
+Compiles under SAS/C again. Should allso still compile under other
+amiga compilers without big changes. I haven't checked if it still
+works under gcc, because I don't have gcc for amiga. But I have
+updated 'Makefile', and hope it compiles fine.
+
+
+WHATS NEW:
+
+1.
+ Made a pretty big effort in preventing GCs allocating-functions from returning
+ chip-mem.
+
+ The lower part of the new file AmigaOS.c does this in various ways, mainly by
+ wrapping GC_malloc, GC_malloc_atomic, GC_malloc_uncollectable,
+ GC_malloc_atomic_uncollectable, GC_malloc_stubborn, GC_malloc_ignore_off_page
+ and GC_malloc_atomic_ignore_off_page. GC_realloc is allso wrapped, but
+ doesn't do the same effort in preventing to return chip-mem.
+ Other allocating-functions (f.ex. GC_*_typed_) can probably be
+ used without any problems, but beware that the warn hook will not be called.
+ In case of problems, don't define GC_AMIGA_FASTALLOC.
+
+ Programs using more time actually using the memory allocated
+ (instead of just allocate and free rapidly) have
+ the most to earn on this, but even gctest now normally runs twice
+ as fast and uses less memory, on my poor 8MB machine.
+
+ The changes have only effect when there is no more
+ fast-mem left. But with the way GC works, it
+ could happen quite often. Beware that an atexit handler had to be added,
+ so using the abort() function will make a big memory-loss.
+ If you absolutely must call abort() instead of exit(), try calling
+ the GC_amiga_free_all_mem function before abort().
+
+ New amiga-spesific compilation flags:
+
+ GC_AMIGA_FASTALLOC - By NOT defining this option, GC will work like before,
+ it will not try to force fast-mem out of the OS, and
+ it will use normal calloc for allocation, and the rest
+ of the following flags will have no effect.
+
+ GC_AMIGA_ONLYFAST - Makes GC never to return chip-mem. GC_AMIGA_RETRY have
+ no effect if this flag is set.
+
+ GC_AMIGA_GC - If gc returns NULL, do a GC_gcollect, and try again. This
+ usually is a success with the standard GC configuration.
+ It is allso the most important flag to set to prevent
+ GC from returning chip-mem. Beware that it slows down a lot
+ when a program is rapidly allocating/deallocating when
+ theres either very little fast-memory left or verly little
+ chip-memory left. Its not a very common situation, but gctest
+ sometimes (very rare) use many minutes because of this.
+
+ GC_AMIGA_RETRY - If gc succeed allocating memory, but it is chip-mem,
+ try again and see if it is fast-mem. Most of the time,
+ it will actually return fast-mem for the second try.
+ I have set max number of retries to 9 or size/5000. You
+ can change this if you like. (see GC_amiga_rec_alloc())
+
+ GC_AMIGA_PRINTSTATS - Gather some statistics during the execution of a
+ program, and prints out the info when the atexit-handler
+ is called.
+
+ My reccomendation is to set all this flags, except GC_AMIGA_PRINTSTATS and
+ GC_AMIGA_ONLYFAST.
+
+ If your program demands high response-time, you should
+ not define GC_AMIGA_GC, and possible allso define GC_AMIGA_ONLYFAST.
+ GC_AMIGA_RETRY does not seem to slow down much.
+
+ Allso, when compiling up programs, and GC_AMIGA_FASTALLOC was not defined when
+ compilling gc, you can define GC_AMIGA_MAKINGLIB to avoid having these allocation-
+ functions wrapped. (see gc.h)
+
+ Note that GC_realloc must not be called before any of
+ the other above mentioned allocating-functions have been called. (shouldn't be
+ any programs doing so either, I hope).
+
+ Another note. The allocation-function is wrapped when defining
+ GC_AMIGA_FASTALLOC by letting the function go thru the new
+ GC_amiga_allocwrapper_do function-pointer (see gc.h). Means that
+ sending function-pointers, such as GC_malloc, GC_malloc_atomic, etc.,
+ for later to be called like f.ex this, (*GC_malloc_functionpointer)(size),
+ will not wrap the function. This is normally not a big problem, unless
+ all allocation function is called like this, which will cause the
+ atexit un-allocating function never to be called. Then you either
+ have to manually add the atexit handler, or call the allocation-
+ functions function-pointer functions like this;
+ (*GC_amiga_allocwrapper_do)(size,GC_malloc_functionpointer).
+ There are probably better ways this problem could be handled, unfortunately,
+ I didn't find any without rewriting or replacing a lot of the GC-code, which
+ I really didn't want to. (Making new GC_malloc_* functions, and just
+ define f.ex GC_malloc as GC_amiga_malloc should allso work).
+
+
+ New amiga-spesific function:
+
+ void GC_amiga_set_toany(void (*func)(void));
+
+ 'func' is a function that will be called right before gc has to change
+ allocation-method from MEMF_FAST to MEMF_ANY. Ie. when it is likely
+ it will return chip-mem.
+
+
+2. A few small compiler-spesific additions to make it compile with SAS/C again.
+
+3. Updated and rewritten the smakefile, so that it works again and that
+ the "unnecesarry" 'SCOPTIONS' files could be removed. Allso included
+ the cord-smakefile stuff in the main smakefile, so that the cord smakefile
+ could be removed too. By writing smake -f Smakefile.smk, both gc.lib and
+ cord.lib will be made.
+
+
+
+STILL MISSING:
+
+Programs can not be started from workbench, at least not for SAS/C. (Martin
+Tauchmanns note about that it now works with workbench is definitely wrong
+when concerning SAS/C). I guess it works if you use the old "#if 0'ed"-code,
+but I haven't tested it. I think the reason for MT to replace the
+"#if 0'ed"-code was only because it was a bit to SAS/C-spesific. But I
+don't know. An iconx-script solves this problem anyway.
+
+
+BEWARE!
+
+-To run gctest, set the stack to around 200000 bytes first.
+-SAS/C-spesific: cord will crash if you compile gc.lib with
+ either parm=reg or parm=both. (missing legal prototypes for
+ function-pointers someplace is the reason I guess.).
+
+
+tested with software: Radium, http://www.stud.ifi.uio.no/~ksvalast/radium/
+
+tested with hardware: MC68060
+
+
+-ksvalast@ifi.uio.no
+
+
+===========================================================================
+ Martin Tauchmann's notes (1-Apr-99)
+===========================================================================
+
+Works now, also with the GNU-C compiler V2.7.2.1. <ftp://ftp.unina.it/pub/amiga/geekgadgets/amiga/m68k/snapshots/971125/amiga-bin/>
+Modify the `Makefile`
+CC=cc $(ABI_FLAG)
+to
+CC=gcc $(ABI_FLAG)
+
+TECHNICAL NOTES
+
+- `GC_get_stack_base()`, `GC_register_data_segments()` works now with every
+ C compiler; also Workbench.
+
+- Removed AMIGA_SKIP_SEG, but the Code-Segment must not be scanned by GC.
+
+
+PROBLEMS
+- When the Linker, does`t merge all Code-Segments to an single one. LD of GCC
+ do it always.
+
+- With ixemul.library V47.3, when an GC program launched from another program
+ (example: `Make` or `if_mach M68K AMIGA gctest`), `GC_register_data_segments()`
+ found the Segment-List of the caller program.
+ Can be fixed, if the run-time initialization code (for C programs, usually *crt0*)
+ support `__data` and `__bss`.
+
+- PowerPC Amiga currently not supported.
+
+- Dynamic libraries (dyn_load.c) not supported.
+
+
+TESTED WITH SOFTWARE
+
+`Optimized Oberon 2 C` (oo2c) <http://cognac.informatik.uni-kl.de/download/index.html>
+
+
+TESTED WITH HARDWARE
+
+MC68030
+
+
+CONTACT
+
+Please, contact me at <martintauchmann@bigfoot.com>, when you change the
+Amiga port. <http://martintauchmann.home.pages.de>
+
+===========================================================================
+ Michel Schinz's notes
+===========================================================================
+WHO DID WHAT
+
+The original Amiga port was made by Jesper Peterson. I (Michel Schinz)
+modified it slightly to reflect the changes made in the new official
+distributions, and to take advantage of the new SAS/C 6.x features. I also
+created a makefile to compile the "cord" package (see the cord
+subdirectory).
+
+TECHNICAL NOTES
+
+In addition to Jesper's notes, I have the following to say:
+
+- Starting with version 4.3, gctest checks to see if the code segment is
+ added to the root set or not, and complains if it is. Previous versions
+ of this Amiga port added the code segment to the root set, so I tried to
+ fix that. The only problem is that, as far as I know, it is impossible to
+ know which segments are code segments and which are data segments (there
+ are indeed solutions to this problem, like scanning the program on disk
+ or patch the LoadSeg functions, but they are rather complicated). The
+ solution I have chosen (see os_dep.c) is to test whether the program
+ counter is in the segment we are about to add to the root set, and if it
+ is, to skip the segment. The problems are that this solution is rather
+ awkward and that it works only for one code segment. This means that if
+ your program has more than one code segment, all of them but one will be
+ added to the root set. This isn't a big problem in fact, since the
+ collector will continue to work correctly, but it may be slower.
+
+ Anyway, the code which decides whether to skip a segment or not can be
+ removed simply by not defining AMIGA_SKIP_SEG. But notice that if you do
+ so, gctest will complain (it will say that "GC_is_visible produced wrong
+ failure indication"). However, it may be useful if you happen to have
+ pointers stored in a code segment (you really shouldn't).
+
+ If anyone has a good solution to the problem of finding, when a program
+ is loaded in memory, whether a segment is a code or a data segment,
+ please let me know.
+
+PROBLEMS
+
+If you have any problem with this version, please contact me at
+schinz@alphanet.ch (but do *not* send long files, since we pay for
+every mail!).
+
+===========================================================================
+ Jesper Peterson's notes
+===========================================================================
+
+ADDITIONAL NOTES FOR AMIGA PORT
+
+These notes assume some familiarity with Amiga internals.
+
+WHY I PORTED TO THE AMIGA
+
+The sole reason why I made this port was as a first step in getting
+the Sather(*) language on the Amiga. A port of this language will
+be done as soon as the Sather 1.0 sources are made available to me.
+Given this motivation, the garbage collection (GC) port is rather
+minimal.
+
+(*) For information on Sather read the comp.lang.sather newsgroup.
+
+LIMITATIONS
+
+This port assumes that the startup code linked with target programs
+is that supplied with SAS/C versions 6.0 or later. This allows
+assumptions to be made about where to find the stack base pointer
+and data segments when programs are run from WorkBench, as opposed
+to running from the CLI. The compiler dependent code is all in the
+GC_get_stack_base() and GC_register_data_segments() functions, but
+may spread as I add Amiga specific features.
+
+Given that SAS/C was assumed, the port is set up to be built with
+"smake" using the "SMakefile". Compiler options in "SCoptions" can
+be set with "scopts" program. Both "smake" and "scopts" are part of
+the SAS/C commercial development system.
+
+In keeping with the porting philosophy outlined above, this port
+will not behave well with Amiga specific code. Especially not inter-
+process comms via messages, and setting up public structures like
+Intuition objects or anything else in the system lists. For the
+time being the use of this library is limited to single threaded
+ANSI/POSIX compliant or near-complient code. (ie. Stick to stdio
+for now). Given this limitation there is currently no mechanism for
+allocating "CHIP" or "PUBLIC" memory under the garbage collector.
+I'll add this after giving it considerable thought. The major
+problem is the entire physical address space may have to me scanned,
+since there is no telling who we may have passed memory to.
+
+If you allocate your own stack in client code, you will have to
+assign the pointer plus stack size to GC_stackbottom.
+
+The initial stack size of the target program can be compiled in by
+setting the __stack symbol (see SAS documentaion). It can be over-
+ridden from the CLI by running the AmigaDOS "stack" program, or from
+the WorkBench by setting the stack size in the tool types window.
+
+SAS/C COMPILER OPTIONS (SCoptions)
+
+You may wish to check the "CPU" code option is appropriate for your
+intended target system.
+
+Under no circumstances set the "StackExtend" code option in either
+compiling the library or *ANY* client code.
+
+All benign compiler warnings have been suppressed. These mainly
+involve lack of prototypes in the code, and dead assignments
+detected by the optimizer.
+
+THE GOOD NEWS
+
+The library as it stands is compatible with the GigaMem commercial
+virtual memory software, and probably similar PD software.
+
+The performance of "gctest" on an Amiga 2630 (68030 @ 25Mhz)
+compares favourably with an HP9000 with similar architecture (a 325
+with a 68030 I think).
+
+-----------------------------------------------------------------------
+
+The Amiga port has been brought to you by:
+
+Jesper Peterson.
+
+jep@mtiame.mtia.oz.au (preferred, but 1 week turnaround)
+jep@orca1.vic.design.telecom.au (that's orca<one>, 1 day turnaround)
+
+At least one of these addresses should be around for a while, even
+though I don't work for either of the companies involved.
+
diff --git a/gc/doc/README.autoconf b/gc/doc/README.autoconf
new file mode 100644
index 0000000..53fcf5a
--- /dev/null
+++ b/gc/doc/README.autoconf
@@ -0,0 +1,59 @@
+As of GC6.0alpha8, we attempt to support GNU-style builds based on automake,
+autoconf and libtool. This is based almost entirely on Tom Tromey's work
+with gcj.
+
+To build and install libraries use
+
+configure; make; make install
+
+The advantages of this process are:
+
+1) It should eventually do a better job of automatically determining the
+right compiler to use, etc. It probably already does in some cases.
+
+2) It tries to automatically set a good set of default GC parameters for
+the platform (e.g. thread support). It provides an easier way to configure
+some of the others.
+
+3) It integrates better with other projects using a GNU-style build process.
+
+4) It builds both dynamic and static libraries.
+
+The known disadvantages are:
+
+1) The build scripts are much more complex and harder to debug (though largely
+standard). I don't understand them all, and there's probably lots of redundant
+stuff.
+
+2) It probably doesn't work on all Un*x-like platforms yet. It probably will
+never work on the rest.
+
+3) The scripts are not yet complete. Some of the standard GNU targets don't
+yet work. (Corrections/additions are very welcome.)
+
+The distribution should contain all files needed to run "configure" and "make",
+as well as the sources needed to regenerate the derived files. (If I missed
+some, please let me know.)
+
+Note that the distribution comes with a "Makefile" which will be overwritten
+by "configure" with one that is not at all equiavelent to the original. The
+distribution contains a copy of the original "Makefile" in "Makefile.direct".
+
+Important options to configure:
+
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [/usr/local]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [same as prefix]
+ --enable-threads=TYPE choose threading package
+ --enable-parallel-mark parallelize marking and free list construction
+ --enable-full-debug include full support for pointer backtracing etc.
+
+Unless --prefix is set (or --exec-prefix or one of the more obscure options),
+make install will install libgc.a and libgc.so in /usr/local/bin, which
+would typically require the "make install" to be run as root.
+
+Most commonly --enable-threads=posix or will be needed. --enable-parallel-mark
+is recommended for multiprocessors if it is supported on the platform.
+
+
diff --git a/gc/doc/README.changes b/gc/doc/README.changes
new file mode 100644
index 0000000..c018c8b
--- /dev/null
+++ b/gc/doc/README.changes
@@ -0,0 +1,1408 @@
+This is a rough history of garbage collector bugs and versions.
+
+This has been maintained with varying diligence over the years.
+
+I made an attempt to include recent contributors here. I apologize for any
+omissions.
+
+-------------------------
+
+ Version 1.3 and immediately preceding versions contained spurious
+assembly language assignments to TMP_SP. Only the assignment in the PC/RT
+code is necessary. On other machines, with certain compiler options,
+the assignments can lead to an unsaved register being overwritten.
+Known to cause problems under SunOS 3.5 WITHOUT the -O option. (With
+-O the compiler recognizes it as dead code. It probably shouldn't,
+but that's another story.)
+
+ Version 1.4 and earlier versions used compile time determined values
+for the stack base. This no longer works on Sun 3s, since Sun 3/80s use
+a different stack base. We now use a straightforward heuristic on all
+machines on which it is known to work (incl. Sun 3s) and compile-time
+determined values for the rest. There should really be library calls
+to determine such values.
+
+ Version 1.5 and earlier did not ensure 8 byte alignment for objects
+allocated on a sparc based machine.
+
+ Version 1.8 added ULTRIX support in gc_private.h.
+
+ Version 1.9 fixed a major bug in gc_realloc.
+
+ Version 2.0 introduced a consistent naming convention for collector
+routines and added support for registering dynamic library data segments
+in the standard mark_roots.c. Most of the data structures were revamped.
+The treatment of interior pointers was completely changed. Finalization
+was added. Support for locking was added. Object kinds were added.
+We added a black listing facility to avoid allocating at addresses known
+to occur as integers somewhere in the address space. Much of this
+was accomplished by adapting ideas and code from the PCR collector.
+The test program was changed and expanded.
+
+ Version 2.1 was the first stable version since 1.9, and added support
+for PPCR.
+
+ Version 2.2 added debugging allocation, and fixed various bugs. Among them:
+- GC_realloc could fail to extend the size of the object for certain large object sizes.
+- A blatant subscript range error in GC_printf, which unfortunately
+ wasn't exercised on machines with sufficient stack alignment constraints.
+- GC_register_displacement did the wrong thing if it was called after
+ any allocation had taken place.
+- The leak finding code would eventually break after 2048 byte
+ byte objects leaked.
+- interface.c didn't compile.
+- The heap size remained much too small for large stacks.
+- The stack clearing code behaved badly for large stacks, and perhaps
+ on HP/PA machines.
+
+ Version 2.3 added ALL_INTERIOR_POINTERS and fixed the following bugs:
+- Missing declaration of etext in the A/UX version.
+- Some PCR root-finding problems.
+- Blacklisting was not 100% effective, because the plausible future
+ heap bounds were being miscalculated.
+- GC_realloc didn't handle out-of-memory correctly.
+- GC_base could return a nonzero value for addresses inside free blocks.
+- test.c wasn't really thread safe, and could erroneously report failure
+ in a multithreaded environment. (The locking primitives need to be
+ replaced for other threads packages.)
+- GC_CONS was thoroughly broken.
+- On a SPARC with dynamic linking, signals stayed diabled while the
+ client code was running.
+ (Thanks to Manuel Serrano at INRIA for reporting the last two.)
+
+ Version 2.4 added GC_free_space_divisor as a tuning knob, added
+ support for OS/2 and linux, and fixed the following bugs:
+- On machines with unaligned pointers (e.g. Sun 3), every 128th word could
+ fail to be considered for marking.
+- Dynamic_load.c erroneously added 4 bytes to the length of the data and
+ bss sections of the dynamic library. This could result in a bad memory
+ reference if the actual length was a multiple of a page. (Observed on
+ Sun 3. Can probably also happen on a Sun 4.)
+ (Thanks to Robert Brazile for pointing out that the Sun 3 version
+ was broken. Dynamic library handling is still broken on Sun 3s
+ under 4.1.1U1, but apparently not 4.1.1. If you have such a machine,
+ use -Bstatic.)
+
+ Version 2.5 fixed the following bugs:
+- Removed an explicit call to exit(1)
+- Fixed calls to GC_printf and GC_err_printf, so the correct number of
+ arguments are always supplied. The OS/2 C compiler gets confused if
+ the number of actuals and the number of formals differ. (ANSI C
+ doesn't require this to work. The ANSI sanctioned way of doing things
+ causes too many compatibility problems.)
+
+ Version 3.0 added generational/incremental collection and stubborn
+ objects.
+
+ Version 3.1 added the following features:
+- A workaround for a SunOS 4.X SPARC C compiler
+ misfeature that caused problems when the collector was turned into
+ a dynamic library.
+- A fix for a bug in GC_base that could result in a memory fault.
+- A fix for a performance bug (and several other misfeatures) pointed
+ out by Dave Detlefs and Al Dosser.
+- Use of dirty bit information for static data under Solaris 2.X.
+- DEC Alpha/OSF1 support (thanks to Al Dosser).
+- Incremental collection on more platforms.
+- A more refined heap expansion policy. Less space usage by default.
+- Various minor enhancements to reduce space usage, and to reduce
+ the amount of memory scanned by the collector.
+- Uncollectable allocation without per object overhead.
+- More conscientious handling of out-of-memory conditions.
+- Fixed a bug in debugging stubborn allocation.
+- Fixed a bug that resulted in occasional erroneous reporting of smashed
+ objects with debugging allocation.
+- Fixed bogus leak reports of size 4096 blocks with FIND_LEAK.
+
+ Version 3.2 fixed a serious and not entirely repeatable bug in
+ the incremental collector. It appeared only when dirty bit info
+ on the roots was available, which is normally only under Solaris.
+ It also added GC_general_register_disappearing_link, and some
+ testing code. Interface.c disappeared.
+
+ Version 3.3 fixes several bugs and adds new ports:
+- PCR-specific bugs.
+- Missing locking in GC_free, redundant FASTUNLOCK
+ in GC_malloc_stubborn, and 2 bugs in
+ GC_unregister_disappearing_link.
+ All of the above were pointed out by Neil Sharman
+ (neil@cs.mu.oz.au).
+- Common symbols allocated by the SunOS4.X dynamic loader
+ were not included in the root set.
+- Bug in GC_finalize (reported by Brian Beuning and Al Dosser)
+- Merged Amiga port from Jesper Peterson (untested)
+- Merged NeXT port from Thomas Funke (significantly
+ modified and untested)
+
+ Version 3.4:
+- Fixed a performance bug in GC_realloc.
+- Updated the amiga port.
+- Added NetBSD and 386BSD ports.
+- Added cord library.
+- Added trivial performance enhancement for
+ ALL_INTERIOR_POINTERS. (Don't scan last word.)
+
+ Version 3.5
+- Minor collections now mark from roots only once, if that
+ doesn't cause an excessive pause.
+- The stack clearing heuristic was refined to prevent anomalies
+ with very heavily recursive programs and sparse stacks.
+- Fixed a bug that prevented mark stack growth in some cases.
+ GC_objects_are_marked should be set to TRUE after a call
+ to GC_push_roots and as part of GC_push_marked, since
+ both can now set mark bits. I think this is only a performance
+ bug, but I wouldn't bet on it. It's certainly very hard to argue
+ that the old version was correct.
+- Fixed an incremental collection bug that prevented it from
+ working at all when HBLKSIZE != getpagesize()
+- Changed dynamic_loading.c to include gc_priv.h before testing
+ DYNAMIC_LOADING. SunOS dynamic library scanning
+ must have been broken in 3.4.
+- Object size rounding now adapts to program behavior.
+- Added a workaround (provided by Manuel Serrano and
+ colleagues) to a long-standing SunOS 4.X (and 3.X?) ld bug
+ that I had incorrectly assumed to have been squished.
+ The collector was broken if the text segment size was within
+ 32 bytes of a multiple of 8K bytes, and if the beginning of
+ the data segment contained interesting roots. The workaround
+ assumes a demand-loadable executable. The original may have
+ have "worked" in some other cases.
+- Added dynamic library support under IRIX5.
+- Added support for EMX under OS/2 (thanks to Ari Huttunen).
+
+Version 3.6:
+- fixed a bug in the mark stack growth code that was introduced
+ in 3.4.
+- fixed Makefile to work around DEC AXP compiler tail recursion
+ bug.
+
+Version 3.7:
+- Added a workaround for an HP/UX compiler bug.
+- Fixed another stack clearing performance bug. Reworked
+ that code once more.
+
+Version 4.0:
+- Added support for Solaris threads (which was possible
+ only by reimplementing some fraction of Solaris threads,
+ since Sun doesn't currently make the thread debugging
+ interface available).
+- Added non-threads win32 and win32S support.
+- (Grudgingly, with suitable muttering of obscenities) renamed
+ files so that the collector distribution could live on a FAT
+ file system. Files that are guaranteed to be useless on
+ a PC still have long names. Gc_inline.h and gc_private.h
+ still exist, but now just include gc_inl.h and gc_priv.h.
+- Fixed a really obscure bug in finalization that could cause
+ undetected mark stack overflows. (I would be surprised if
+ any real code ever tickled this one.)
+- Changed finalization code to dynamically resize the hash
+ tables it maintains. (This probably does not matter for well-
+ -written code. It no doubt does for C++ code that overuses
+ destructors.)
+- Added typed allocation primitives. Rewrote the marker to
+ accommodate them with more reasonable efficiency. This
+ change should also speed up marking for GC_malloc allocated
+ objects a little. See gc_typed.h for new primitives.
+- Improved debugging facilities slightly. Allocation time
+ stack traces are now kept by default on SPARC/SUNOS4.
+ (Thanks to Scott Schwartz.)
+- Added better support for small heap applications.
+- Significantly extended cord package. Fixed a bug in the
+ implementation of lazily read files. Printf and friends now
+ have cord variants. Cord traversals are a bit faster.
+- Made ALL_INTERIOR_POINTERS recognition the default.
+- Fixed de so that it can run in constant space, independent
+ of file size. Added simple string searching to cords and de.
+- Added the Hull-Ellis C++ interface.
+- Added dynamic library support for OSF/1.
+ (Thanks to Al Dosser and Tim Bingham at DEC.)
+- Changed argument to GC_expand_hp to be expressed
+ in units of bytes instead of heap blocks. (Necessary
+ since the heap block size now varies depending on
+ configuration. The old version was never very clean.)
+- Added GC_get_heap_size(). The previous "equivalent"
+ was broken.
+- Restructured the Makefile a bit.
+
+Since version 4.0:
+- Changed finalization implementation to guarantee that
+ finalization procedures are called outside of the allocation
+ lock, making direct use of the interface a little less dangerous.
+ MAY BREAK EXISTING CLIENTS that assume finalizers
+ are protected by a lock. Since there seem to be few multithreaded
+ clients that use finalization, this is hopefully not much of
+ a problem.
+- Fixed a gross bug in CORD_prev.
+- Fixed a bug in blacklst.c that could result in unbounded
+ heap growth during startup on machines that do not clear
+ memory obtained from the OS (e.g. win32S).
+- Ported de editor to win32/win32S. (This is now the only
+ version with a mouse-sensitive UI.)
+- Added GC_malloc_ignore_off_page to allocate large arrays
+ in the presence of ALL_INTERIOR_POINTERS.
+- Changed GC_call_with_alloc_lock to not disable signals in
+ the single-threaded case.
+- Reduced retry count in GC_collect_or_expand for garbage
+ collecting when out of memory.
+- Made uncollectable allocations bypass black-listing, as they
+ should.
+- Fixed a bug in typed_test in test.c that could cause (legitimate)
+ GC crashes.
+- Fixed some potential synchronization problems in finalize.c
+- Fixed a real locking problem in typd_mlc.c.
+- Worked around an AIX 3.2 compiler feature that results in
+ out of bounds memory references.
+- Partially worked around an IRIX5.2 beta problem (which may
+ or may not persist to the final release).
+- Fixed a bug in the heap integrity checking code that could
+ result in explicitly deallocated objects being identified as
+ smashed. Fixed a bug in the dbg_mlc stack saving code
+ that caused old argument pointers to be considered live.
+- Fixed a bug in CORD_ncmp (and hence CORD_str).
+- Repaired the OS2 port, which had suffered from bit rot
+ in 4.0. Worked around what appears to be CSet/2 V1.0
+ optimizer bug.
+- Fixed a Makefile bug for target "c++".
+
+Since version 4.1:
+- Multiple bug fixes/workarounds in the Solaris threads version.
+ (It occasionally failed to locate some register contents for
+ marking. It also turns out that thr_suspend and friends are
+ unreliable in Solaris 2.3. Dirty bit reads appear
+ to be unreliable under some weird
+ circumstances. My stack marking code
+ contained a serious performance bug. The new code is
+ extremely defensive, and has not failed in several cpu
+ hours of testing. But no guarantees ...)
+- Added MacOS support (thanks to Patrick Beard.)
+- Fixed several syntactic bugs in gc_c++.h and friends. (These
+ didn't bother g++, but did bother most other compilers.)
+ Fixed gc_c++.h finalization interface. (It didn't.)
+- 64 bit alignment for allocated objects was not guaranteed in a
+ few cases in which it should have been.
+- Added GC_malloc_atomic_ignore_off_page.
+- Added GC_collect_a_little.
+- Added some prototypes to gc.h.
+- Some other minor bug fixes (notably in Makefile).
+- Fixed OS/2 / EMX port (thanks to Ari Huttunen).
+- Fixed AmigaDOS port. (thanks to Michel Schinz).
+- Fixed the DATASTART definition under Solaris. There
+ was a 1 in 16K chance of the collector missing the first
+ 64K of static data (and thus crashing).
+- Fixed some blatant anachronisms in the README file.
+- Fixed PCR-Makefile for upcoming PPCR release.
+
+Since version 4.2:
+- Fixed SPARC alignment problem with GC_DEBUG.
+- Fixed Solaris threads /proc workaround. The real
+ problem was an interaction with mprotect.
+- Incorporated fix from Patrick Beard for gc_c++.h (now gc_cpp.h).
+- Slightly improved allocator space utilization by
+ fixing the GC_size_map mechanism.
+- Integrated some Sony News and MIPS RISCos 4.51
+ patches. (Thanks to Nobuyuki Hikichi of
+ Software Research Associates, Inc. Japan)
+- Fixed HP_PA alignment problem. (Thanks to
+ xjam@cork.cs.berkeley.edu.)
+- Added GC_same_obj and friends. Changed GC_base
+ to return 0 for pointers past the end of large objects.
+ Improved GC_base performance with ALL_INTERIOR_POINTERS
+ on machines with a slow integer mod operation.
+ Added GC_PTR_ADD, GC_PTR_STORE, etc. to prepare
+ for preprocessor.
+- changed the default on most UNIX machines to be that
+ signals are not disabled during critical GC operations.
+ This is still ANSI-conforming, though somewhat dangerous
+ in the presence of signal handlers. But the performance
+ cost of the alternative is sometimes problematic.
+ Can be changed back with a minor Makefile edit.
+- renamed IS_STRING in gc.h, to CORD_IS_STRING, thus
+ following my own naming convention. Added the function
+ CORD_to_const_char_star.
+- Fixed a gross bug in GC_finalize. Symptom: occasional
+ address faults in that function. (Thanks to Anselm
+ Baird-Smith (Anselm.BairdSmith@inria.fr)
+- Added port to ICL DRS6000 running DRS/NX. Restructured
+ things a bit to factor out common code, and remove obsolete
+ code. Collector should now run under SUNOS5 with either
+ mprotect or /proc dirty bits. (Thanks to Douglas Steel
+ (doug@wg.icl.co.uk)).
+- More bug fixes and workarounds for Solaris 2.X. (These were
+ mostly related to putting the collector in a dynamic library,
+ which didn't really work before. Also SOLARIS_THREADS
+ didn't interact well with dl_open.) Thanks to btlewis@eng.sun.com.
+- Fixed a serious performance bug on the DEC Alpha. The text
+ segment was getting registered as part of the root set.
+ (Amazingly, the result was still fast enough that the bug
+ was not conspicuous.) The fix works on OSF/1, version 1.3.
+ Hopefully it also works on other versions of OSF/1 ...
+- Fixed a bug in GC_clear_roots.
+- Fixed a bug in GC_generic_malloc_words_small that broke
+ gc_inl.h. (Reported by Antoine de Maricourt. I broke it
+ in trying to tweak the Mac port.)
+- Fixed some problems with cord/de under Linux.
+- Fixed some cord problems, notably with CORD_riter4.
+- Added DG/UX port.
+ Thanks to Ben A. Mesander (ben@piglet.cr.usgs.gov)
+- Added finalization registration routines with weaker ordering
+ constraints. (This is necessary for C++ finalization with
+ multiple inheritance, since the compiler often adds self-cycles.)
+- Filled the holes in the SCO port. (Thanks to Michael Arnoldus
+ <chime@proinf.dk>.)
+- John Ellis' additions to the C++ support: From John:
+
+* I completely rewrote the documentation in the interface gc_c++.h
+(later renamed gc_cpp.h). I've tried to make it both clearer and more
+precise.
+
+* The definition of accessibility now ignores pointers from an
+finalizable object (an object with a clean-up function) to itself.
+This allows objects with virtual base classes to be finalizable by the
+collector. Compilers typically implement virtual base classes using
+pointers from an object to itself, which under the old definition of
+accessibility prevented objects with virtual base classes from ever
+being collected or finalized.
+
+* gc_cleanup now includes gc as a virtual base. This was enabled by
+the change in the definition of accessibility.
+
+* I added support for operator new[]. Since most (all?) compilers
+don't yet support operator new[], it is conditionalized on
+-DOPERATOR_NEW_ARRAY. The code is untested, but its trivial and looks
+correct.
+
+* The test program test_gc_c++ (later renamed test_cpp.cc)
+tries to test for the C++-specific functionality not tested by the
+other programs.
+- Added <unistd.h> include to misc.c. (Needed for ppcr.)
+- Added PowerMac port. (Thanks to Patrick Beard again.)
+- Fixed "srcdir"-related Makefile problems. Changed things so
+ that all externally visible include files always appear in the
+ include subdirectory of the source. Made gc.h directly
+ includable from C++ code. (These were at Per
+ Bothner's suggestion.)
+- Changed Intel code to also mark from ebp (Kevin Warne's
+ suggestion).
+- Renamed C++ related files so they could live in a FAT
+ file system. (Charles Fiterman's suggestion.)
+- Changed Windows NT Makefile to include C++ support in
+ gc.lib. Added C++ test as Makefile target.
+
+Since version 4.3:
+ - ASM_CLEAR_CODE was erroneously defined for HP
+ PA machines, resulting in a compile error.
+ - Fixed OS/2 Makefile to create a library. (Thanks to
+ Mark Boulter (mboulter@vnet.ibm.com)).
+ - Gc_cleanup objects didn't work if they were created on
+ the stack. Fixed.
+ - One copy of Gc_cpp.h in the distribution was out of
+ synch, and failed to document some known compiler
+ problems with explicit destructor invocation. Partially
+ fixed. There are probably other compilers on which
+ gc_cleanup is miscompiled.
+ - Fixed Makefile to pass C compiler flags to C++ compiler.
+ - Added Mac fixes.
+ - Fixed os_dep.c to work around what appears to be
+ a new and different VirtualQuery bug under newer
+ versions of win32S.
+ - GC_non_gc_bytes was not correctly maintained by
+ GC_free. Fixed. Thanks to James Clark (jjc@jclark.com).
+ - Added GC_set_max_heap_size.
+ - Changed allocation code to ignore blacklisting if it is preventing
+ use of a very large block of memory. This has the advantage
+ that naive code allocating very large objects is much more
+ likely to work. The downside is you might no
+ longer find out that such code should really use
+ GC_malloc_ignore_off_page.
+ - Changed GC_printf under win32 to close and reopen the file
+ between calls. FAT file systems otherwise make the log file
+ useless for debugging.
+ - Added GC_try_to_collect and GC_get_bytes_since_gc. These
+ allow starting an abortable collection during idle times.
+ This facility does not require special OS support. (Thanks to
+ Michael Spertus of Geodesic Systems for suggesting this. It was
+ actually an easy addition. Kumar Srikantan previously added a similar
+ facility to a now ancient version of the collector. At the time
+ this was much harder, and the result was less convincing.)
+ - Added some support for the Borland development environment. (Thanks
+ to John Ellis and Michael Spertus.)
+ - Removed a misfeature from checksums.c that caused unexpected
+ heap growth. (Thanks to Scott Schwartz.)
+ - Changed finalize.c to call WARN if it encounters a finalization cycle.
+ WARN is defined in gc_priv.h to write a message, usually to stdout.
+ In many environments, this may be inappropriate.
+ - Renamed NO_PARAMS in gc.h to GC_NO_PARAMS, thus adhering to my own
+ naming convention.
+ - Added GC_set_warn_proc to intercept warnings.
+ - Fixed Amiga port. (Thanks to Michel Schinz (schinz@alphanet.ch).)
+ - Fixed a bug in mark.c that could result in an access to unmapped
+ memory from GC_mark_from_mark_stack on machines with unaligned
+ pointers.
+ - Fixed a win32 specific performance bug that could result in scanning of
+ objects allocated with the system malloc.
+ - Added REDIRECT_MALLOC.
+
+Since version 4.4:
+ - Fixed many minor and one major README bugs. (Thanks to Franklin Chen
+ (chen@adi.com) for pointing out many of them.)
+ - Fixed ALPHA/OSF/1 dynamic library support. (Thanks to Jonathan Bachrach
+ (jonathan@harlequin.com)).
+ - Added incremental GC support (MPROTECT_VDB) for Linux (with some
+ help from Bruno Haible).
+ - Altered SPARC recognition tests in gc.h and config.h (mostly as
+ suggested by Fergus Henderson).
+ - Added basic incremental GC support for win32, as implemented by
+ Windows NT and Windows 95. GC_enable_incremental is a noop
+ under win32s, which doesn't implement enough of the VM interface.
+ - Added -DLARGE_CONFIG.
+ - Fixed GC_..._ignore_off_page to also function without
+ -DALL_INTERIOR_POINTERS.
+ - (Hopefully) fixed RS/6000 port. (Only the test was broken.)
+ - Fixed a performance bug in the nonincremental collector running
+ on machines supporting incremental collection with MPROTECT_VDB
+ (e.g. SunOS 4, DEC AXP). This turned into a correctness bug under
+ win32s with win32 incremental collection. (Not all memory protection
+ was disabled.)
+ - Fixed some ppcr related bit rot.
+ - Caused dynamic libraries to be unregistered before reregistering.
+ The old way turned out to be a performance bug on some machines.
+ - GC_root_size was not properly maintained under MSWIN32.
+ - Added -DNO_DEBUGGING and GC_dump.
+ - Fixed a couple of bugs arising with SOLARIS_THREADS +
+ REDIRECT_MALLOC.
+ - Added NetBSD/M68K port. (Thanks to Peter Seebach
+ <seebs@taniemarie.solon.com>.)
+ - Fixed a serious realloc bug. For certain object sizes, the collector
+ wouldn't scan the expanded part of the object. (Thanks to Clay Spence
+ (cds@peanut.sarnoff.com) for noticing the problem, and helping me to
+ track it down.)
+
+Since version 4.5:
+ - Added Linux ELF support. (Thanks to Arrigo Triulzi <arrigo@ic.ac.uk>.)
+ - GC_base crashed if it was called before any other GC_ routines.
+ This could happen if a gc_cleanup object was allocated outside the heap
+ before any heap allocation.
+ - The heap expansion heuristic was not stable if all objects had finalization
+ enabled. Fixed finalize.c to count memory in finalization queue and
+ avoid explicit deallocation. Changed alloc.c to also consider this count.
+ (This is still not recommended. It's expensive if nothing else.) Thanks
+ to John Ellis for pointing this out.
+ - GC_malloc_uncollectable(0) was broken. Thanks to Phong Vo for pointing
+ this out.
+ - The collector didn't compile under Linux 1.3.X. (Thanks to Fred Gilham for
+ pointing this out.) The current workaround is ugly, but expected to be
+ temporary.
+ - Fixed a formatting problem for SPARC stack traces.
+ - Fixed some '=='s in os_dep.c that should have been assignments.
+ Fortunately these were in code that should never be executed anyway.
+ (Thanks to Fergus Henderson.)
+ - Fixed the heap block allocator to only drop blacklisted blocks in small
+ chunks. Made BL_LIMIT self adjusting. (Both of these were in response
+ to heap growth observed by Paul Graham.)
+ - Fixed the Metrowerks/68K Mac code to also mark from a6. (Thanks
+ to Patrick Beard.)
+ - Significantly updated README.debugging.
+ - Fixed some problems with longjmps out of signal handlers, especially under
+ Solaris. Added a workaround for the fact that siglongjmp doesn't appear to
+ do the right thing with -lthread under Solaris.
+ - Added MSDOS/djgpp port. (Thanks to Mitch Harris (maharri@uiuc.edu).)
+ - Added "make reserved_namespace" and "make user_namespace". The
+ first renames ALL "GC_xxx" identifiers as "_GC_xxx". The second is the
+ inverse transformation. Note that doing this is guaranteed to break all
+ clients written for the other names.
+ - descriptor field for kind NORMAL in GC_obj_kinds with ADD_BYTE_AT_END
+ defined should be -ALIGNMENT not WORDS_TO_BYTES(-1). This is
+ a serious bug on machines with pointer alignment of less than a word.
+ - GC_ignore_self_finalize_mark_proc didn't handle pointers to very near the
+ end of the object correctly. Caused failures of the C++ test on a DEC Alpha
+ with g++.
+ - gc_inl.h still had problems. Partially fixed. Added warnings at the
+ beginning to hopefully specify the remaining dangers.
+ - Added DATAEND definition to config.h.
+ - Fixed some of the .h file organization. Fixed "make floppy".
+
+Since version 4.6:
+ - Fixed some compilation problems with -DCHECKSUMS (thanks to Ian Searle)
+ - Updated some Mac specific files to synchronize with Patrick Beard.
+ - Fixed a serious bug for machines with non-word-aligned pointers.
+ (Thanks to Patrick Beard for pointing out the problem. The collector
+ should fail almost any conceivable test immediately on such machines.)
+
+Since version 4.7:
+ - Changed a "comment" in a MacOS specific part of mach-dep.c that caused
+ gcc to fail on other platforms.
+
+Since version 4.8
+ - More README.debugging fixes.
+ - Objects ready for finalization, but not finalized in the same GC
+ cycle, could be prematurely collected. This occasionally happened
+ in test_cpp.
+ - Too little memory was obtained from the system for very large
+ objects. That could cause a heap explosion if these objects were
+ not contiguous (e.g. under PCR), and too much of them was blacklisted.
+ - Due to an improper initialization, the collector was too hesitant to
+ allocate blacklisted objects immediately after system startup.
+ - Moved GC_arrays from the data into the bss segment by not explicitly
+ initializing it to zero. This significantly
+ reduces the size of executables, and probably avoids some disk accesses
+ on program startup. It's conceivable that it might break a port that I
+ didn't test.
+ - Fixed EMX_MAKEFILE to reflect the gc_c++.h to gc_cpp.h renaming which
+ occurred a while ago.
+
+Since 4.9:
+ - Fixed a typo around a call to GC_collect_or_expand in alloc.c. It broke
+ handling of out of memory. (Thanks to Patrick Beard for noticing.)
+
+Since 4.10:
+ - Rationalized (hopefully) GC_try_to_collect in an incremental collection
+ environment. It appeared to not handle a call while a collection was in
+ progress, and was otherwise too conservative.
+ - Merged GC_reclaim_or_delete_all into GC_reclaim_all to get rid of some
+ code.
+ - Added Patrick Beard's Mac fixes, with substantial completely untested
+ modifications.
+ - Fixed the MPROTECT_VDB code to deal with large pages and imprecise
+ fault addresses (as on an UltraSPARC running Solaris 2.5). Note that this
+ was not a problem in the default configuration, which uses PROC_VDB.
+ - The DEC Alpha assembly code needed to restore $gp between calls.
+ Thanks to Fergus Henderson for tracking this down and supplying a
+ patch.
+ - The write command for "de" was completely broken for large files.
+ I used the easiest portable fix, which involved changing the semantics
+ so that f.new is written instead of overwriting f. That's safer anyway.
+ - Added README.solaris2 with a discussion of the possible problems of
+ mixing the collector's sbrk allocation with malloc/realloc.
+ - Changed the data segment starting address for SGI machines. The
+ old code failed under IRIX6.
+ - Required double word alignment for MIPS.
+ - Various minor fixes to remove warnings.
+ - Attempted to fix some Solaris threads problems reported by Zhiying Chen.
+ In particular, the collector could try to fork a thread with the
+ world stopped as part of GC_thr_init. It also failed to deal with
+ the case in which the original thread terminated before the whole
+ process did.
+ - Added -DNO_EXECUTE_PERMISSION. This has a major performance impact
+ on the incremental collector under Irix, and perhaps under other
+ operating systems.
+ - Added some code to support allocating the heap with mmap. This may
+ be preferable under some circumstances.
+ - Integrated dynamic library support for HP.
+ (Thanks to Knut Tvedten <knuttv@ifi.uio.no>.)
+ - Integrated James Clark's win32 threads support, and made a number
+ of changes to it, many of which were suggested by Pontus Rydin.
+ This is still not 100% solid.
+ - Integrated Alistair Crooks' support for UTS4 running on an Amdahl
+ 370-class machine.
+ - Fixed a serious bug in explicitly typed allocation. Objects requiring
+ large descriptors where handled in a way that usually resulted in
+ a segmentation fault in the marker. (Thanks to Jeremy Fitzhardinge
+ for helping to track this down.)
+ - Added partial support for GNU win32 development. (Thanks to Fergus
+ Henderson.)
+ - Added optional support for Java-style finalization semantics. (Thanks
+ to Patrick Bridges.) This is recommended only for Java implementations.
+ - GC_malloc_uncollectable faulted instead of returning 0 when out of
+ memory. (Thanks to dan@math.uiuc.edu for noticing.)
+ - Calls to GC_base before the collector was initialized failed on a
+ DEC Alpha. (Thanks to Matthew Flatt.)
+ - Added base pointer checking to GC_REGISTER_FINALIZER in debugging
+ mode, at the suggestion of Jeremy Fitzhardinge.
+ - GC_debug_realloc failed for uncollectable objects. (Thanks to
+ Jeremy Fitzhardinge.)
+ - Explicitly typed allocation could crash if it ran out of memory.
+ (Thanks to Jeremy Fitzhardinge.)
+ - Added minimal support for a DEC Alpha running Linux.
+ - Fixed a problem with allocation of objects whose size overflowed
+ ptrdiff_t. (This now fails unconditionally, as it should.)
+ - Added the beginning of Irix pthread support.
+ - Integrated Xiaokun Zhu's fixes for djgpp 2.01.
+ - Added SGI-style STL allocator support (gc_alloc.h).
+ - Fixed a serious bug in README.solaris2. Multithreaded programs must include
+ gc.h with SOLARIS_THREADS defined.
+ - Changed GC_free so it actually deallocates uncollectable objects.
+ (Thanks to Peter Chubb for pointing out the problem.)
+ - Added Linux ELF support for dynamic libararies. (Thanks again to
+ Patrick Bridges.)
+ - Changed the Borland cc configuration so that the assembler is not
+ required.
+ - Fixed a bug in the C++ test that caused it to fail in 64-bit
+ environments.
+
+Since 4.11:
+ - Fixed ElfW definition in dyn_load.c. (Thanks to Fergus Henderson.)
+ This prevented the dynamic library support from compiling on some
+ older ELF Linux systems.
+ - Fixed UTS4 port (which I apparently mangled during the integration)
+ (Thanks to again to Alistair Crooks.)
+ - "Make C++" failed on Suns with SC4.0, due to a problem with "bool".
+ Fixed in gc_priv.h.
+ - Added more pieces for GNU win32. (Thanks to Timothy N. Newsham.)
+ The current state of things should suffice for at least some
+ applications.
+ - Changed the out of memory retry count handling as suggested by
+ Kenjiro Taura. (This matters only if GC_max_retries > 0, which
+ is no longer the default.)
+ - If a /proc read failed repeatedly, GC_written_pages was not updated
+ correctly. (Thanks to Peter Chubb for diagnosing this.)
+ - Under unlikely circumstances, the allocator could infinite loop in
+ an out of memory situation. (Thanks again to Kenjiro Taura for
+ identifying the problem and supplying a fix.)
+ - Fixed a syntactic error in the DJGPP code. (Thanks to Fergus
+ Henderson for finding this by inspection.) Also fixed a test program
+ problem with DJGPP (Thanks to Peter Monks.)
+ - Atomic uncollectable objects were not treated correctly by the
+ incremental collector. This resulted in weird log statistics and
+ occasional performance problems. (Thanks to Peter Chubb for pointing
+ this out.)
+ - Fixed some problems resulting from compilers that dont define
+ __STDC__. In this case void * and char * were used inconsistently
+ in some cases. (Void * should not have been used at all. If
+ you have an ANSI superset compiler that does not define __STDC__,
+ please compile with -D__STDC__=0. Thanks to Manuel Serrano and others
+ for pointing out the problem.)
+ - Fixed a compilation problem on Irix with -n32 and -DIRIX_THREADS.
+ Also fixed some other IRIX_THREADS problems which may or may not have
+ had observable symptoms.
+ - Fixed an HP PA compilation problem in dyn_load.c. (Thanks to
+ Philippe Queinnec.)
+ - SEGV fault handlers sometimes did not get reset correctly. (Thanks
+ to David Pickens.)
+ - Added a fix for SOLARIS_THREADS on Intel. (Thanks again to David
+ Pickens.) This probably needs more work to become functional.
+ - Fixed struct sigcontext_struct in os_dep.c for compilation under
+ Linux 2.1.X. (Thanks to Fergus Henderson.)
+ - Changed the DJGPP STACKBOTTOM and DATASTART values to those suggested
+ by Kristian Kristensen. These may still not be right, but it is
+ it is likely to work more often than what was there before. They may
+ even be exactly right.
+ - Added a #include <string.h> to test_cpp.cc. This appears to help
+ with HP/UX and gcc. (Thanks to assar@sics.se.)
+ - Version 4.11 failed to run in incremental mode on recent 64-bit Irix
+ kernels. This was a problem related to page unaligned heap segments.
+ Changed the code to page align heap sections on all platforms.
+ (I had mistakenly identified this as a kernel problem earlier.
+ It was not.)
+ - Version 4.11 did not make allocated storage executable, except on
+ one or two platforms, due to a bug in a #if test. (Thanks to Dave
+ Grove for pointing this out.)
+ - Added sparc_sunos4_mach_dep.s to support Sun's compilers under SunOS4.
+ - Added GC_exclude_static_roots.
+ - Fixed the object size mapping algorithm. This shouldn't matter,
+ but the old code was ugly.
+ - Heap checking code could die if one of the allocated objects was
+ larger than its base address. (Unsigned underflow problem. Thanks
+ to Clay Spence for isolating the problem.)
+ - Added RS6000 (AIX) dynamic library support and fixed STACK_BOTTOM.
+ (Thanks to Fred Stearns.)
+ - Added Fergus Henderson's patches for improved robustness with large
+ heaps and lots of blacklisting.
+ - Added Peter Chubb's changes to support Solaris Pthreads, to support
+ MMAP allocation in Solaris, to allow Solaris to find dynamic libraries
+ through /proc, to add malloc_typed_ignore_off_page, and a few other
+ minor features and bug fixes.
+ - The Solaris 2 port should not use sbrk. I received confirmation from
+ Sun that the use of sbrk and malloc in the same program is not
+ supported. The collector now defines USE_MMAP by default on Solaris.
+ - Replaced the djgpp makefile with Gary Leavens' version.
+ - Fixed MSWIN32 detection test.
+ - Added Fergus Henderson's patches to allow putting the collector into
+ a DLL under GNU win32.
+ - Added Ivan V. Demakov's port to Watcom C on X86.
+ - Added Ian Piumarta's Linux/PowerPC port.
+ - On Brian Burton's suggestion added PointerFreeGC to the placement
+ options in gc_cpp.h. This is of course unsafe, and may be controversial.
+ On the other hand, it seems to be needed often enough that it's worth
+ adding as a standard facility.
+
+Since 4.12:
+ - Fixed a crucial bug in the Watcom port. There was a redundant decl
+ of GC_push_one in gc_priv.h.
+ - Added FINALIZE_ON_DEMAND.
+ - Fixed some pre-ANSI cc problems in test.c.
+ - Removed getpagesize() use for Solaris. It seems to be missing in one
+ or two versions.
+ - Fixed bool handling for SPARCCompiler version 4.2.
+ - Fixed some files in include that had gotten unlinked from the main
+ copy.
+ - Some RS/6000 fixes (missing casts). Thanks to Toralf Foerster.
+ - Fixed several problems in GC_debug_realloc, affecting mostly the
+ FIND_LEAK case.
+ - GC_exclude_static_roots contained a buggy unsigned comparison to
+ terminate a loop. (Thanks to Wilson Ho.)
+ - CORD_str failed if the substring occurred at the last possible position.
+ (Only affects cord users.)
+ - Fixed Linux code to deal with RedHat 5.0 and integrated Peter Bigot's
+ os_dep.c code for dealing with various Linux versions.
+ - Added workaround for Irix pthreads sigaction bug and possible signal
+ misdirection problems.
+Since alpha1:
+ - Changed RS6000 STACKBOTTOM.
+ - Integrated Patrick Beard's Mac changes.
+ - Alpha1 didn't compile on Irix m.n, m < 6.
+ - Replaced Makefile.dj with a new one from Gary Leavens.
+ - Added Andrew Stitcher's changes to support SCO OpenServer.
+ - Added PRINT_BLACK_LIST, to allow debugging of high densities of false
+ pointers.
+ - Added code to debug allocator to keep track of return address
+ in GC_malloc caller, thus giving a bit more context.
+ - Changed default behavior of large block allocator to more
+ aggressively avoid fragmentation. This is likely to slow down the
+ collector when it succeeds at reducing space cost.
+ - Integrated Fergus Henderson's CYGWIN32 changes. They are untested,
+ but needed for newer versions.
+ - USE_MMAP had some serious bugs. This caused the collector to fail
+ consistently on Solaris with -DSMALL_CONFIG.
+ - Added Linux threads support, thanks largely to Fergus Henderson.
+Since alpha2:
+ - Fixed more Linux threads problems.
+ - Changed default GC_free_space_divisor to 3 with new large block allocation.
+ (Thanks to Matthew Flatt for some measurements that suggest the old
+ value sometimes favors space too much over time.)
+ - More CYGWIN32 fixes.
+ - Integrated Tyson-Dowd's Linux-M68K port.
+ - Minor HP PA and DEC UNIX fixes from Fergus Henderson.
+ - Integrated Christoffe Raffali's Linux-SPARC changes.
+ - Allowed for one more GC fixup iteration after a full GC in incremental
+ mode. Some quick measurements suggested that this significantly
+ reduces pause times even with smaller GC_RATE values.
+ - Moved some more GC data structures into GC_arrays. This decreases
+ pause times and GC overhead, but makes debugging slightly less convenient.
+ - Fixed namespace pollution problem ("excl_table").
+ - Made GC_incremental a constant for -DSMALL_CONFIG, hopefully shrinking
+ that slightly.
+ - Added some win32 threads fixes.
+ - Integrated Ivan Demakov and David Stes' Watcom fixes.
+ - Various other minor fixes contributed by many people.
+ - Renamed config.h to gcconfig.h, since config.h tends to be used for
+ many other things.
+ - Integrated Matthew Flatt's support for 68K MacOS "far globals".
+ - Fixed up some of the dynamic library Makefile targets for consistency
+ across platforms.
+ - Fixed a USE_MMAP typo that caused out-of-memory handling to fail
+ on Solaris.
+ - Added code to test.c to test thread creation a bit more.
+ - Integrated GC_win32_free_heap, as suggested by Ivan Demakov.
+ - Fixed Solaris 2.7 stack base finding problem. (This may actually
+ have been done in an earlier alpha release.)
+Since alpha3:
+ - Fixed MSWIN32 recognition test, which interfered with cygwin.
+ - Removed unnecessary gc_watcom.asm from distribution. Removed
+ some obsolete README.win32 text.
+ - Added Alpha Linux incremental GC support. (Thanks to Philipp Tomsich
+ for code for retrieving the fault address in a signal handler.)
+ Changed Linux signal handler context argument to be a pointer.
+ - Took care of some new warnings generated by the 7.3 SGI compiler.
+ - Integrated Phillip Musumeci's FreeBSD/ELF fixes.
+ - -DIRIX_THREADS was broken with the -o32 ABI (typo in gc_priv.h>
+
+Since 4.13:
+ - Fixed GC_print_source_ptr to not use a prototype.
+ - generalized CYGWIN test.
+ - gc::new did the wrong thing with PointerFreeGC placement.
+ (Thanks to Rauli Ruohonen.)
+ - In the ALL_INTERIOR_POINTERS (default) case, some callee-save register
+ values could fail to be scanned if the register was saved and
+ reused in a GC frame. This showed up in verbose mode with gctest
+ compiled with an unreleased SGI compiler. I vaguely recall an old
+ bug report that may have been related. The bug was probably quite old.
+ (The problem was that the stack scanning could be deferred until
+ after the relevant frame was overwritten, and the new save location
+ might be outside the scanned area. Fixed by more eager stack scanning.)
+ - PRINT_BLACK_LIST had some problems. A few source addresses were garbage.
+ - Replaced Makefile.dj and added -I flags to cord make targets.
+ (Thanks to Gary Leavens.)
+ - GC_try_to_collect was broken with the nonincremental collector.
+ - gc_cleanup destructors could pass the wrong address to
+ GC_register_finalizer_ignore_self in the presence of multiple
+ inheritance. (Thanks to Darrell Schiebel.)
+ - Changed PowerPC Linux stack finding code.
+
+Since 4.14alpha1
+ - -DSMALL_CONFIG did not work reliably with large (> 4K) pages.
+ Recycling the mark stack during expansion could result in a size
+ zero heap segment, which confused things. (This was probably also an
+ issue with the normal config and huge pages.)
+ - Did more work to make sure that callee-save registers were scanned
+ completely, even with the setjmp-based code. Added USE_GENERIC_PUSH_REGS
+ macro to facilitate testing on machines I have access to.
+ - Added code to explicitly push register contents for win32 threads.
+ This seems to be necessary. (Thanks to Pierre de Rop.)
+
+Since 4.14alpha2
+ - changed STACKBOTTOM for DJGPP (Thanks to Salvador Eduardo Tropea).
+
+Since 4.14
+ - Reworked large block allocator. Now uses multiple doubly linked free
+ lists to approximate best fit.
+ - Changed heap expansion heuristic. Entirely free blocks are no longer
+ counted towards the heap size. This seems to have a major impact on
+ heap size stability; the old version could expand the heap way too
+ much in the presence of large block fragmentation.
+ - added -DGC_ASSERTIONS and some simple assertions inside the collector.
+ This is mainlyt for collector debugging.
+ - added -DUSE_MUNMAP to allow the heap to shrink. Suupported on only
+ a few UNIX-like platforms for now.
+ - added GC_dump_regions() for debugging of fragmentation issues.
+ - Changed PowerPC pointer alignment under Linux to 4. (This needs
+ checking by someone who has one. The suggestions came to me via a
+ rather circuitous path.)
+ - Changed the Linux/Alpha port to walk the data segment backwards until
+ it encounters a SIGSEGV. The old way to find the start of the data
+ segment broke with a recent release.
+ - cordxtra.c needed to call GC_REGISTER_FINALIZER instead of
+ GC_register_finalizer, so that it would continue to work with GC_DEBUG.
+ - allochblk sometimes cleared the wrong block for debugging purposes
+ when it dropped blacklisted blocks. This could result in spurious
+ error reports with GC_DEBUG.
+ - added MACOS X Server support. (Thanks to Andrew Stone.)
+ - Changed the Solaris threads code to ignore stack limits > 8 MB with
+ a warning. Empirically, it is not safe to access arbitrary pages
+ in such large stacks. And the dirty bit implementation does not
+ guarantee that none of them will be accessed.
+ - Integrated Martin Tauchmann's Amiga changes.
+ - Integrated James Dominy's OpenBSD/SPARC port.
+
+Since 5.0alpha1
+ - Fixed bugs introduced in alpha1 (OpenBSD & large block initialization).
+ - Added -DKEEP_BACK_PTRS and backptr.h interface. (The implementation
+ idea came from Al Demers.)
+
+Since 5.0alpha2
+ - Added some highly incomplete code to support a copied young generation.
+ Comments on nursery.h are appreciated.
+ - Changed -DFIND_LEAK, -DJAVA_FINALIZATION, and -DFINALIZE_ON_DEMAND,
+ so the same effect could be obtained with a runtime switch. This is
+ a step towards standardizing on a single dynamic GC library.
+ - Significantly changed the way leak detection is handled, as a consequence
+ of the above.
+
+Since 5.0 alpha3
+ - Added protection fault handling patch for Linux/M68K from Fergus
+ Henderson and Roman Hodek.
+ - Removed the tests for SGI_SOURCE in new_gc_alloc.h. This was causing that
+ interface to fail on nonSGI platforms.
+ - Changed the Linux stack finding code to use /proc, after changing it
+ to use HEURISTIC1. (Thanks to David Mossberger for pointing out the
+ /proc hook.)
+ - Added HP/UX incremental GC support and HP/UX 11 thread support.
+ Thread support is currently still flakey.
+ - Added basic Linux/IA64 support.
+ - Integrated Anthony Green's PicoJava support.
+ - Integrated Scott Ananian's StrongARM/NetBSD support.
+ - Fixed some fairly serious performance bugs in the incremental
+ collector. These have probably been there essentially forever.
+ (Mark bits were sometimes set before scanning dirty pages.
+ The reclaim phase unnecessarily dirtied full small object pages.)
+ - Changed the reclaim phase to ignore nearly full pages to avoid
+ touching them.
+ - Limited GC_black_list_spacing to roughly the heap growth increment.
+ - Changed full collection triggering heuristic to decrease full GC
+ frequency by default, but to explicitly trigger full GCs during
+ heap growth. This doesn't always improve things, but on average it's
+ probably a win.
+ - GC_debug_free(0, ...) failed. Thanks to Fergus Henderson for the
+ bug report and fix.
+
+Since 5.0 alpha4
+ - GC_malloc_explicitly_typed and friends sometimes failed to
+ initialize first word.
+ - Added allocation routines and support in the marker for mark descriptors
+ in a type structure referenced by the first word of an object. This was
+ introduced to support gcj, but hopefully in a way that makes it
+ generically useful.
+ - Added GC_requested_heapsize, and inhibited collections in nonincremental
+ mode if the actual used heap size is less than what was explicitly
+ requested.
+ - The Solaris pthreads version of GC_pthread_create didn't handle a NULL
+ attribute pointer. Solaris thread support used the wrong default thread
+ stack size. (Thanks to Melissa O'Neill for the patch.)
+ - Changed PUSH_CONTENTS macro to no longer modify first parameter.
+ This usually doesn't matter, but it was certainly an accident waiting
+ to happen ...
+ - Added GC_register_finalizer_no_order and friends to gc.h. They're
+ needed by Java implementations.
+ - Integrated a fix for a win32 deadlock resulting from clock() calling
+ malloc. (Thanks to Chris Dodd.)
+ - Integrated Hiroshi Kawashima's port to Linux/MIPS. This was designed
+ for a handheld platform, and may or may not be sufficient for other
+ machines.
+ - Fixed a va_arg problem with the %c specifier in cordprnt.c. It appears
+ that this was always broken, but recent versions of gcc are the first to
+ report the (statically detectable) bug.
+ - Added an attempt at a more general solution to dlopen races/deadlocks.
+ GC_dlopen now temporarily disables collection. Still not ideal, but ...
+ - Added -DUSE_I686_PREFETCH, -DUSE_3DNOW_PREFETCH, and support for IA64
+ prefetch instructions. May improve performance measurably, but I'm not
+ sure the code will run correctly on processors that don't support the
+ instruction. Won't build except with very recent gcc.
+ - Added caching for header lookups in the marker. This seems to result
+ in a barely measurable performance gain. Added support for interleaved
+ lookups of two pointers, but unconfigured that since the performance
+ gain is currently near zero, and it adds to code size.
+ - Changed Linux DATA_START definition to check both data_start and
+ __data_start, since nothing else seems to be portable.
+ - Added -DUSE_LD_WRAP to optionally take advantage of the GNU ld function
+ wrapping mechanism. Probably currently useful only on Linux.
+ - Moved some variables for the scratch allocator into GC_arrays, on
+ Martin Hirzel's suggestion.
+ - Fixed a win32 threads bug that caused the collector to not look for
+ interior pointers from one of the thread stacks without
+ ALL_INTERIOR_POINTERS. (Thanks to Jeff Sturm.)
+ - Added Mingw32 support. (Thanks again to Jeff Sturm for the patch.)
+ - Changed the alpha port to use the generic register scanning code instead
+ of alpha_mach_dep.s. Alpha_mach_dep.s doesn't look for pointers in fp
+ registers, but gcc sometimes spills pointers there. (Thanks to Manuel
+ Serrano for helping me debug this by email.) Changed the IA64 code to
+ do something similar for similar reasons.
+
+[5.0alpha5 doesn't really exist, but it may have escaped.]
+
+Since 5.0alpha6:
+ - -DREDIRECT_MALLOC was broken in alpha6. Fixed.
+ - Cleaned up gc_ccp.h slightly, thus also causing the HP C++ compiler to
+ accept it.
+ - Removed accidental reference to dbg_mlc.c, which caused dbg_mlc.o to be
+ linked into every executable.
+ - Added PREFETCH to bitmap marker. Changed it to use the header cache.
+ - GC_push_marked sometimes pushed one object too many, resulting in a
+ segmentation fault in GC_mark_from_mark_stack. This was probably an old
+ bug. It finally showed up in gctest on win32.
+ - Gc_priv.h erroneously #defined GC_incremental to be TRUE instead of FALSE
+ when SMALL_CONFIG was defined. This was no doubt a major performance bug for
+ the default win32 configuration.
+ - Removed -DSMALL_CONFIG from NT_MAKEFILE. It seemed like an anchronism now
+ that the average PC has 64MB or so.
+ - Integrated Bryce McKinley's patches for linux threads and dynamic loading
+ from the libgcj tree. Turned on dynamic loading support for Linux/PPC.
+ - Changed the stack finding code to use environ on HP/UX. (Thanks
+ to Gustavo Rodriguez-Rivera for the suggestion.) This should probably
+ be done on other platforms, too. Since I can't test those, that'll
+ wait until after 5.0.
+
+Since 5.0alpha7:
+ - Fixed threadlibs.c for linux threads. -DUSE_LD_WRAP was broken and
+ -ldl was omitted. Fixed Linux stack finding code to handle
+ -DUSE_LD_WRAP correctly.
+ - Added MSWIN32 exception handler around marker, so that the collector
+ can recover from root segments that are unmapped during the collection.
+ This caused occasional failures under Windows 98, and may also be
+ an issue under Windows NT/2000.
+
+Since 5.0
+ - Fixed a gc.h header bug which showed up under Irix. (Thanks to
+ Dan Sullivan.)
+ - Fixed a typo in GC_double_descr in typd_mlc.c.
+ This probably could result in objects described by array descriptors not
+ getting traced correctly. (Thanks to Ben Hutchings for pointing this out.)
+ - The block nearly full tests in reclaim.c were not correct for 64 bit
+ environments. This could result in unnecessary heap growth under unlikely
+ conditions.
+
+Since 5.1
+ - dyn_load.c declared GC_scratch_last_end_ptr as an extern even if it
+ was defined as a macro. This prevented the collector from building on
+ Irix.
+ - We quietly assumed that indirect mark descriptors were never 0.
+ Our own typed allocation interface violated that. This could result
+ in segmentation faults in the marker with typed allocation.
+ - Fixed a _DUSE_MUNMAP bug in the heap block allocation code.
+ (Thanks to Ben Hutchings for the patch.)
+ - Taught the collector about VC++ handling array operator new.
+ (Thanks again to Ben Hutchings for the patch.)
+ - The two copies of gc_hdrs.h had diverged. Made one a link to the other
+ again.
+
+Since 5.2 (A few 5.2 patches are not in 6.0alpha1)
+ - Fixed _end declaration for OSF1.
+ - There were lots of spurious leak reports in leak detection mode, caused
+ by the fact that some pages were not being swept, and hence unmarked
+ objects weren't making it onto free lists. (This bug dated back to 5.0.)
+ - Fixed a typo in the liblinuxgc.so Makefile rule.
+ - Added the GetExitCodeThread to Win32 GC_stop_world to (mostly) work
+ around a Windows 95 GetOpenFileName problem. (Thanks to Jacob Navia.)
+
+Since 5.3
+ - Fixed a typo that prevented compilation with -DUSE_3DNOW_PREFETCH.
+ (Thanks to Shawn Wagner for actually testing this.)
+ - Fixed GC_is_thread_stack in solaris_threads.c. It forgot to return a value
+ in the common case. I wonder why nobody noticed?
+ - Fixed another silly syntax problem in GC_double_descr. (Thanks to
+ Fergus Henderson for finding it.)
+ - Fixed a GC_gcj_malloc bug: It tended to release the allocator lock twice.
+
+Since 5.4 (A few 5.3 patches are not in 6.0alpha2)
+ - Added HP/PA prefetch support.
+ - Added -DDBG_HDRS_ALL and -DSHORT_DBG_HDRS to reduce the cost and improve
+ the reliability of generating pointer backtrace information, e.g. in
+ the Bigloo environment.
+ - Added parallel marking support (-DPARALLEL_MARK). This currently
+ works only under IA32 and IA64 Linux, but it shouldn't be hard to adapt
+ to other platforms. This is intended to be a lighter-weight (less
+ new code, probably not as scalable) solution than the work by Toshio Endo
+ et al, at the University of Tokyo. A number of their ideas were
+ reused, though the code wasn't, and the underlying data structure
+ is significantly different. In particular, we keep the global mark
+ stack as a single shared data structure, but most of the work is done
+ on smaller thread-local mark stacks.
+ - Changed GC_malloc_many to be cheaper, and to require less mutual exclusion
+ with -DPARALLEL_MARK.
+ - Added full support for thread local allocation under Linux
+ (-DTHREAD_LOCAL_ALLOC). This is a thin veneer on GC_malloc_many, and
+ should be easily portable to other platforms, especially those that
+ support pthreads.
+ - CLEAR_DOUBLE was not always getting invoked when it should have been.
+ - GC_gcj_malloc and friends used different out of memory handling than
+ everything else, probably because I forgot about one when I implemented
+ the other. They now both call GC_oom_fn(), not GC_oom_action().
+ - Integrated Jakub Jelinek's fixes for Linux/SPARC.
+ - Moved GC_objfreelist, GC_aobjfreelist, and GC_words_allocd out of
+ GC_arrays, and separately registered the first two as excluded roots.
+ This makes code compiled with gc_inl.h less dependent on the
+ collector version. (It would be nice to remove the inclusion of
+ gc_priv.h by gc_inl.h completely, but we're not there yet. The
+ locking definitions in gc_priv.h are still referenced.)
+ This change was later coniditoned on SEPARATE_GLOBALS, which
+ is not defined by default, since it involves a performance hit.
+ - Register GC_obj_kinds separately as an excluded root region. The
+ attempt to register it with GC_arrays was usually failing. (This wasn't
+ serious, but seemed to generate some confusion.)
+ - Moved backptr.h to gc_backptr.h.
+
+Since 6.0alpha1
+ - Added USE_MARK_BYTES to reduce the need for compare-and-swap on platforms
+ for which that's expensive.
+ - Fixed a locking bug ib GC_gcj_malloc and some locking assertion problems.
+ - Added a missing volatile to OR_WORD and renamed the parameter to
+ GC_compare_and_swap so it's not a C++ reserved word. (Thanks to
+ Toshio Endo for pointing out both of those.)
+ - Changed Linux dynamic library registration code to look at /proc/self/maps
+ instead of the rld data structures when REDIRECT_MALLOC is defined.
+ Otherwise some of the rld data data structures may be prematurely garbage
+ collected. (Thanks to Eric Benson for helping to track this down.)
+ - Fixed USE_LD_WRAP a bit more, so it should now work without threads.
+ - Renamed XXX_THREADS macros to GC_XXX_THREADS for namespace correctness.
+ Tomporarily added some backward compatibility definitions. Renamed
+ USE_LD_WRAP to GC_USE_LD_WRAP.
+ - Many MACOSX POWERPC changes, some additions to the gctest output, and
+ a few minor generic bug fixes. (Thanks to Dietmar Planitzer.)
+
+Since 6.0 alpha2
+ - Fixed the /proc/self/maps code to not seek, since that apparently is not
+ reliable across all interesting kernels.
+ - Fixed some compilation problems in the absence of PARALLEL_MARK
+ (introduced in alpha2).
+ - Fixed an algorithmic problem with PARALLEL_MARK. If work needs to
+ be given back to the main mark "stack", the BOTTOM entries of the local
+ stack should be given away, not the top ones. This has substantial
+ performance impact, especially for > 2 processors, from what I can tell.
+ - Extracted gc_lock.h from gc_priv.h. This should eventually make it a
+ bit easier to avoid including gc_priv.h in clients.
+ - Moved all include files to include/ and removed duplicate links to the
+ same file. The old scheme was a bad idea because it was too easy to get the
+ copies out of sync, and many systems don't support hard links.
+ Unfortunately, it's likely that I broke some of the non-Unix Makefiles in
+ the process, although I tried to update them appropriately.
+ - Removed the partial support for a copied nursery. It's not clear that
+ this would be a tremendous win, since we don't consistently lose to
+ generational copying collectors. And it would significantly complicate
+ many things. May be reintroduced if/when it really turns out to win.
+ - Removed references to IRIX_JDK_THREADS, since I believe there never
+ were and never will be any clients.
+ - Added some code to linux_threads.c to possibly support HPUX threads
+ using the Linux code. Unfortunately, it doesn't work yet, and is
+ currently disabled.
+ - Added support under Linux/X86 for saving the call chain, both in (debug)
+ objects for client debugging, and in GC_arrays._last_stack for GC
+ debugging. This was previously supported only under Solaris. It is
+ not enabled by default under X86, since it requires that code be compiled
+ to explicitly dave frame pointers on the call stack. (With gcc this
+ currently happens by default, but is often turned off explicitly.)
+ To turn it on, define SAVE_CALL_CHAIN.
+
+Since 6.0 alpha3
+ - Moved up the detection of mostly full blocks to the initiatiation of the
+ sweep phase. This eliminates some lock conention in the PARALLEL_MARK case,
+ as multiple threads try to look at mostly full blocks concurrently.
+ - Restored the code in GC_malloc_many that grabs a prefix of the global
+ free list. This avoids the case in which every GC_malloc_many call
+ tries and fails to allocate a new heap block, and the returns a single
+ object from the global free list.
+ - Some minor fixes in new_hblk.c. (Attempted to build free lists in order
+ of increasing addresses instead of decreasing addresses for cache performance
+ reasons. But this seems to be only a very minor gain with -DEAGER_SWEEP,
+ and a loss in other cases. So the change was backed out.)
+ - Fixed some of the documentation. (Thanks in large part to Fergus
+ Henderson.)
+ - Fixed the Linux USE_PROC_FOR_LIBRARIES code to deal with apps that perform
+ large numbers of mmaps. (Thanks to Eric Benson.) Also fixed that code to
+ deal with short reads.
+ - Added GC_get_total_bytes().
+ - Fixed leak detection mode to avoid spurious messages under linuxthreads.
+ (This should also now be easy for the other supported threads packages.
+ But the code is tricky enough that I'm hesitant to do it without being able
+ to test. Everything allocated in the GC thread support itself should be
+ explicitly deallocated.)
+ - Made it possible (with luck) to redirect malloc to GC_local_malloc.
+
+Since 6.0 alpha4
+ - Changed the definition of GC_pause in linux_threads.c to use a volatile
+ asm. Some versions of gcc apparently optimize away writes to local volatile
+ variables. This caused poor locking behaviour starting at about
+ 4 processors.
+ - Added GC_start_blocking(), GC_end_blocking() calls and wrapper for sleep
+ to linux_threads.c.
+ The first two calls could be used to generally avoid sending GC signals to
+ blocked threads, avoiding both premature wakeups and unnecessary overhead.
+ - Fixed a serious bug in thread-local allocation. At thread termination,
+ GC_free could get called on small integers. Changed the code for thread
+ termination to more efficiently return left-over free-lists.
+ - Integrated Kjetil Matheussen's BeOS support.
+ - Rearranged the directory structure to create the doc and tests
+ subdirectories.
+ - Sort of integrated Eric Benson's patch for OSF1. This provided basic
+ OSF1 thread support by suitably extending hpux_irix_threads.c. Based
+ on earlier email conversations with David Butenhof, I suspect that it
+ will be more reliable in the long run to base this on linux_threads.c
+ instead. Thus I attempted to patch up linux_threads.c based on Eric's code.
+ The result is almost certainly broken, but hopefully close enough that
+ someone with access to a machine can pick it up.
+ - Integrated lots of minor changes from the NetBSD distribution. (These
+ were supplied by David Brownlee. I'm not sure about the original
+ authors.)
+ - Hacked a bit more on the HP/UX thread-support in linux_threads.c. It
+ now appears to work in the absence of incremental collection. Renamed
+ hpux_irix_threads.c back to irix_threads.c, and removed the attempt to
+ support HPUX there.
+ - Changed gc.h to define _REENTRANT in cases in which it should already
+ have been defined. It is still safer to also define it on the command
+ line.
+
+Since 6.0alpha5:
+ - Changed the definition of DATASTART on ALPHA and IA64, where data_start
+ and __data_start are not defined by earlier versions of glibc. This might
+ need to be fixed on other platforms as well.
+ - Changed the way the stack base and backing store base are found on IA64.
+ This should now remain reliable on future kernels. But since it relies
+ on /proc, it will no longer work in the simulated NUE environment.
+ - Made the call to random() in dbg_mlc.c with -DKEEP_BACK_PTRS dependent
+ on the OS. On non-Unix systems, rand() should be used instead. Handled
+ small RAND_MAX. (Thanks to Peter Ross for pointing this out.)
+ - Fixed the cord make rules to create the cord subdirectory, if necessary.
+ (Thanks to Doug Moen.)
+ - Changed fo_object_size calculation in finalize.c. Turned finalization
+ of nonheap object into a no-op. Removed anachronism from GC_size()
+ implementation.
+ - Changed GC_push_dirty call in solaris_threads.c to GC_push_selected.
+ It was missed in a previous renaming. (Thanks to Vladimir Tsichevski
+ for pointing this out.)
+ - Arranged to not not mask SIGABRT in linux_threads.c. (Thanks to Bryce
+ McKinlay.)
+ - Added GC_no_dls hook for applications that want to register their own
+ roots.
+ - Integrated Kjetil Matheussen's Amiga changes.
+ - Added FREEBSD_STACKBOTTOM. Changed the X86/FreeBSD port to use it.
+ (Thanks to Matthew Flatt.)
+ - Added pthread_detach interception for platforms supported by linux_threads.c
+ and irix_threads.c. Should also be added for Solaris?
+ - Changed the USE_MMAP code to check for the case in which we got the
+ high end of the address space, i.e. mem_ptr + mem_sz == 0. It appears
+ that this can happen under Solaris 7. It seems to be allowed by what
+ I would claim is an oversight in the mmap specification. (Thanks to Toshio
+ Endo for pointing out the problem.)
+ - Cleanup of linux_threads.c. Some code was originally cloned from
+ irix_threads.c and now unnecessary. Some comments were obviously wrong.
+ - (Mostly) fixed a longstanding problem with setting of dirty bits from
+ a signal handler. In the presence of threads, dirty bits could get lost,
+ since the etting of a bit in the bit vector was not atomic with respect
+ to other updates. The fix is 100% correct only for platforms for which
+ GC_test_and_set is defined. The goal is to make that all platforms with
+ thread support. Matters only if incremental GC and threads are both
+ enabled.
+ - made GC_all_interior_pointers (a.k.a. ALL_INTERIOR_POINTERS) an
+ initialization time, instead of build-time option. This is a
+ nontrivial, high risk change. It should slow down the code measurably
+ only if MERGE_SIZES is not defined, which is a very nonstandard
+ configuration.
+ - Added doc/README.environment, and implemented what it describes. This
+ allows a number of additional configuration options to be set through
+ the environment. It documents a few previously undocumented options.
+ - Integrated Eric Benson's leak testing improvements.
+ - Removed the option to throw away the beginning of each page (DISCARD_WORDS).
+ This became less and less useful as processors enforce stricter alignment.
+ And it hadn't been tested in ages, and was thus probably broken anyway.
+
+Since 6.0alpha6:
+ - Added GC_finalizer_notifier. Fixed GC_finalize_on_demand. (The variable
+ actually wasn't being tested at the right points. The build-time flag
+ was.)
+ - Added Tom Tromey's S390 Linux patch.
+ - Added code to push GC_finalize_now in GC_push_finalizer_structures.
+ (Thanks to Matthew Flatt.)
+ - Added GC_push_gc_structures() to push all GC internal roots.
+ - Integrated some FreeBSD changes from Matthew Flatt.
+ - It looks like USRSTACK is not always correctly defined under Solaris.
+ Hacked gcconfig.h to attempt to work around the problem. The result
+ is not well tested. (Thanks again to Matthew Flatt for pointing this
+ out. The gross hack is mine. - HB)
+ - Added Ji-Yong Chung's win32 threads and C++ fixes.
+ - Arranged for hpux_test_and_clear.s to no longer be needed or built.
+ It was causing build problems with gas, and it's not clear this is
+ better than the pthreads alternative on this platform.
+ - Some MINGW32 fixes from Hubert Garavel.
+ - Added Initial Hitachi SH4 port from Kaz Kojima.
+ - Ported thread-local allocation and parallel mark code to HP/UX on PA_RISC.
+ - Made include/gc_mark.h more public and separated out the really private
+ pieces. This is probably still not quite sufficient for clients that
+ want to supply their own kind of type information. But it's a start.
+ This involved lots of identifier renaming to make it namespace clean.
+ - Added GC_dont_precollect for clients that need complete control over
+ the root set.
+ - GC_is_visible didn't do the right thing with gcj objects. (Not that
+ many people are likely to care, but ...)
+ - Don't redefine read with GC_USE_LD_WRAP.
+ - Initial port to LINUX/HP_PA. Incremental collection and threads are not
+ yet supported. (Incremental collection should work if you have the
+ right kernel. Threads may work with a sufficiently patched pthread
+ library.)
+ - Changed gcconfig.h to recognize __i386__ as an alternative to i386 in
+ many places. (Thanks to Benjamin Lerman.)
+ - Made win32_threads.c more tolerant of detaching a thread that it didn't
+ know about. (Thanks to Paul Nash.)
+ - Added Makefile.am and configure.in from gcc to the distribution, with
+ minimal changes. For the moment, those are just placeholders. In the
+ future, we're planning to switch to a GNU-style build environment for
+ Un*x-like systems, though the old Makefile will remain as a backup.
+ - Turned off STUBBORN_ALLOC by default, and added it back as a Makefile
+ option.
+ - Redistributed some functions between malloc.c and mallocx.c, so that
+ simple statically linked apps no longer pull in mallocx.o.
+ - Changed large object allocation to clear the first and last few words
+ of each block before releassing the lock. Otherwise the marker could see
+ objects with nonsensical type descriptors.
+ - Fixed a couple of subtle problems that could result in not recognizing
+ interior pointers from the stack. (I believe these were introduced
+ in 6.0alpha6.)
+ - GC_debug_free_inner called GC_free, which tried to reacquire the
+ allocator lock, and hence deadlocked. (DBG_HDRS_ALL probably never worked
+ with threads?)
+ - Fixed several problems with back traces. Accidental references to a free
+ list could cause the free list pointer to be overwritten by a back pointer.
+ There seemed to be some problems with the encoding of root and finalizer
+ references.
+
+Since 6.0alpha7:
+ - Changed GC_debug_malloc_replacement and GC_debug_realloc_replacement
+ so that they compile under Irix. (Thanks to Dave Love.)
+ - Updated powerpc_macosx_mach_dep.s so that it works if the collector
+ is in a dynamic library. (Thanks to Andrew Begel.)
+ - Transformed README.debugging into debugging.html, updating and
+ expanding it in the process. Added gcdescr.html and tree.html
+ from the web site to the GC distribution.
+ - Fixed several problems related to PRINT_BLACK_LIST. This involved
+ restructuring some of the marker macros.
+ - Fixed some problems with the sizing of objects with debug information.
+ Finalization was broken KEEP_BACK_PTRS or PRINT_BLACK_LIST. Reduced the
+ object size with SHORT_DEBUG_HDRS by another word.
+ - The "Needed to allocate blacklisted ..." warning had inadvertently
+ been turned off by default, due to a buggy test in allchblk.c. Turned
+ it back on.
+ - Removed the marker macros to deal with 2 pointers in interleaved fashion.
+ They were messy and the performance improvement seemed minimal. We'll
+ leave such scheduling issues to the compiler.
+ - Changed Linux/PowerPC test to also check for __powerpc__ in response
+ to a discussion on the gcc mailing list.
+ - On Matthew Flatt's suggestion removed the "static" from the jmp_buf
+ declaration in GC_generic_push_regs. This was causing problems in
+ systems that register all of their own roots. It looks far more correct
+ to me without the "static" anyway.
+ - Fixed several problems with thread local allocation of pointerfree or
+ typed objects. The collector was reclaiming thread-local free lists, since
+ it wasn't following the link fields.
+ - There was apparently a long-standing race condition related to multithreaded
+ incremental collection. A collection could be started and a thread stopped
+ between the memory unprotect system call and the setting of the
+ corresponding dirt bit. I believe this did not affect Solaris or PCR, which
+ use a different dirty-bit implementation. Fixed this by installing
+ signal handlers with sigaction instead of signal, and disabling the thread
+ suspend signal while in the write-protect handler. (It is unclear
+ whether this scenario ever actually occurred. I found it while tracking
+ down the following:)
+ - Incremental collection did not cooperate correctly with the PARALLEL_MARK
+ implementation of GC_malloc_many or the local_malloc primitves. It still
+ doesn't work well, but it shouldn't lose memory anymore.
+ - Integrated some changes from the gcc source tree that I had previously
+ missed. (Thanks to Bryce McKinley for the reminder/diff.)
+ - Added Makefile.direct as a copy of the default Makefile, which would
+ normally be overwritten if configure is run.
+ - Changed the gc.tar target in Makefile.direct to embed the version number
+ in the gc directory name. This will affect future tar file distributions.
+ - Changed the Irix dynamic library finding code to no longer try to
+ eliminate writable text segments under Irix6.x, since that is probably no
+ longer necessary, and can apparently be unsafe on occasion. (Thanks to
+ Shiro Kawai for pointing this out.)
+ - GC_cleanup with GC_DEBUG enabled passed a real object base address to
+ GC_debug_register_finalizer_ignore_self, which expected a pointer past the
+ debug header. Call GC_register_finalizer_ignore_self instead, even with
+ debugging enabled. (Thanks to Jean-Daniel Fekete for catching this.)
+ - The collector didn't build with call chain saving enabled but NARGS=0.
+ (Thanks to Maarten Thibaut.)
+ - Fixed up the GNU-style build files enough so that they work in some
+ obvious cases.
+ - Added initial port to Digital Mars compiler for win32. (Thanks to Walter
+ Bright.)
+
+Since 6.0alpha8:
+ - added README.macros.
+ - Made gc.mak a symbolic link to work around winzip's tendency to ignore
+ hard links.
+ - Simplified the setting of NEED_FIND_LIMIT in os_dep.c, possibly breaking
+ it on untested platforms.
+ - Integrated initial GNU HURD port. (Thanks to Chris Lingard and Igor
+ Khavkine.)
+ - A few more fixes for Digital Mars compiler.
+ - Fixed gcc version recognition. Renamed OPERATOR_NEW_ARRAY to
+ GC_OPERATOR_NEW_ARRAY. Changed GC_OPERATOR_NEW_ARRAY to be the default.
+ It can be overridden with -DGC_NO_OPERATOR_NEW_ARRAY. (Thanks to
+ Cesar Eduardo Barros.)
+ - Changed the byte size to free-list mapping in thread local allocation
+ so that size 0 allocations are handled correctly.
+ - Fixed Linux/MIPS stackbottom for new toolchain. (Thanks to Ryan Murray.)
+ - Changed finalization registration to invoke GC_oom_fn when it runs out
+ of memory.
+ - Removed lvalue cast in finalize.c. This caused some debug configurations
+ not to build with some non-gcc compilers.
+
+Since 6.0alpha9:
+ - Two more bug fixes for KEEP_BACK_PTRS and DBG_HDRS_ALL.
+ - Fixed a stack clearing problem that resulted in SIGILL with a
+ misaligned stack pointer for multithreaded SPARC builds.
+ - Integrated another HURD patch (thanks to Igor Khavkine).
+
+
+To do:
+ - There seem to be outstanding issues on Solaris/X86, possibly with
+ finding the data segment starting address. Information/patches would
+ ne appreciated.
+ - New_gc_alloc.h is apparently no longer compatible with the latest C++
+ standard library in gcc3.0. (This isn't technically a bug, since it only
+ claimed compatibility with the SGI STL. But we may need a new C++ STL
+ allocator interface.)
+ - Very large root set sizes (> 16 MB or so) could cause the collector
+ to abort with an unexpected mark stack overflow. (Thanks again to
+ Peter Chubb.) NOT YET FIXED. Workaround is to increase the initial
+ size.
+ - The SGI version of the collector marks from mmapped pages, even
+ if they are not part of dynamic library static data areas. This
+ causes performance problems with some SGI libraries that use mmap
+ as a bitmap allocator. NOT YET FIXED. It may be possible to turn
+ off DYNAMIC_LOADING in the collector as a workaround. It may also
+ be possible to conditionally intercept mmap and use GC_exclude_static_roots.
+ The real fix is to walk rld data structures, which looks possible.
+ - Incremental collector should handle large objects better. Currently,
+ it looks like the whole object is treated as dirty if any part of it
+ is.
+ - Cord/cordprnt.c doesn't build on a few platforms (notably PowerPC), since
+ we make some unwarranted assumptions about how varargs are handled. This
+ currently makes the cord-aware versions of printf unusable on some platforms.
+ Fixing this is unfortunately not trivial.
diff --git a/gc/doc/README.contributors b/gc/doc/README.contributors
new file mode 100644
index 0000000..fd5c95f
--- /dev/null
+++ b/gc/doc/README.contributors
@@ -0,0 +1,57 @@
+This is an attempt to acknowledge early contributions to the garbage
+collector. Later contributions should instead be mentioned in
+README.changes.
+
+HISTORY -
+
+ Early versions of this collector were developed as a part of research
+projects supported in part by the National Science Foundation
+and the Defense Advance Research Projects Agency.
+
+The garbage collector originated as part of the run-time system for
+the Russell programming language implementation. The first version of the
+garbage collector was written primarily by Al Demers. It was then refined
+and mostly rewritten, primarily by Hans-J. Boehm, at Cornell U.,
+the University of Washington, Rice University (where it was first used for
+C and assembly code), Xerox PARC, SGI, and HP Labs. However, significant
+contributions have also been made by many others.
+
+Some other contributors:
+
+More recent contributors are mentioned in the modification history in
+README.changes. My apologies for any omissions.
+
+The SPARC specific code was originally contributed by Mark Weiser.
+The Encore Multimax modifications were supplied by
+Kevin Kenny (kenny@m.cs.uiuc.edu). The adaptation to the IBM PC/RT is largely
+due to Vernon Lee, on machines made available to Rice by IBM.
+Much of the HP specific code and a number of good suggestions for improving the
+generic code are due to Walter Underwood.
+Robert Brazile (brazile@diamond.bbn.com) originally supplied the ULTRIX code.
+Al Dosser (dosser@src.dec.com) and Regis Cridlig (Regis.Cridlig@cl.cam.ac.uk)
+subsequently provided updates and information on variation between ULTRIX
+systems. Parag Patel (parag@netcom.com) supplied the A/UX code.
+Jesper Peterson(jep@mtiame.mtia.oz.au), Michel Schinz, and
+Martin Tauchmann (martintauchmann@bigfoot.com) supplied the Amiga port.
+Thomas Funke (thf@zelator.in-berlin.de(?)) and
+Brian D.Carlstrom (bdc@clark.lcs.mit.edu) supplied the NeXT ports.
+Douglas Steel (doug@wg.icl.co.uk) provided ICL DRS6000 code.
+Bill Janssen (janssen@parc.xerox.com) supplied the SunOS dynamic loader
+specific code. Manuel Serrano (serrano@cornas.inria.fr) supplied linux and
+Sony News specific code. Al Dosser provided Alpha/OSF/1 code. He and
+Dave Detlefs(detlefs@src.dec.com) also provided several generic bug fixes.
+Alistair G. Crooks(agc@uts.amdahl.com) supplied the NetBSD and 386BSD ports.
+Jeffrey Hsu (hsu@soda.berkeley.edu) provided the FreeBSD port.
+Brent Benson (brent@jade.ssd.csd.harris.com) ported the collector to
+a Motorola 88K processor running CX/UX (Harris NightHawk).
+Ari Huttunen (Ari.Huttunen@hut.fi) generalized the OS/2 port to
+nonIBM development environments (a nontrivial task).
+Patrick Beard (beard@cs.ucdavis.edu) provided the initial MacOS port.
+David Chase, then at Olivetti Research, suggested several improvements.
+Scott Schwartz (schwartz@groucho.cse.psu.edu) supplied some of the
+code to save and print call stacks for leak detection on a SPARC.
+Jesse Hull and John Ellis supplied the C++ interface code.
+Zhong Shao performed much of the experimentation that led to the
+current typed allocation facility. (His dynamic type inference code hasn't
+made it into the released version of the collector, yet.)
+
diff --git a/gc/doc/README.cords b/gc/doc/README.cords
new file mode 100644
index 0000000..3485e01
--- /dev/null
+++ b/gc/doc/README.cords
@@ -0,0 +1,53 @@
+Copyright (c) 1993-1994 by Xerox Corporation. All rights reserved.
+
+THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
+
+Permission is hereby granted to use or copy this program
+for any purpose, provided the above notices are retained on all copies.
+Permission to modify the code and to distribute modified code is granted,
+provided the above notices are retained, and a notice that the code was
+modified is included with the above copyright notice.
+
+Please send bug reports to Hans-J. Boehm (Hans_Boehm@hp.com or
+boehm@acm.org).
+
+This is a string packages that uses a tree-based representation.
+See cord.h for a description of the functions provided. Ec.h describes
+"extensible cords", which are essentially output streams that write
+to a cord. These allow for efficient construction of cords without
+requiring a bound on the size of a cord.
+
+More details on the data structure can be found in
+
+Boehm, Atkinson, and Plass, "Ropes: An Alternative to Strings",
+Software Practice and Experience 25, 12, December 1995, pp. 1315-1330.
+
+A fundamentally similar "rope" data structure is also part of SGI's standard
+template library implementation, and its descendents, which include the
+GNU C++ library. That uses reference counting by default.
+There is a short description of that data structure at
+http://reality.sgi.com/boehm/ropeimpl.html . (The more official location
+http://www.sgi.com/tech/stl/ropeimpl.html is missing a figure.)
+
+All of these are descendents of the "ropes" in Xerox Cedar.
+
+de.c is a very dumb text editor that illustrates the use of cords.
+It maintains a list of file versions. Each version is simply a
+cord representing the file contents. Nonetheless, standard
+editing operations are efficient, even on very large files.
+(Its 3 line "user manual" can be obtained by invoking it without
+arguments. Note that ^R^N and ^R^P move the cursor by
+almost a screen. It does not understand tabs, which will show
+up as highlighred "I"s. Use the UNIX "expand" program first.)
+To build the editor, type "make cord/de" in the gc directory.
+
+This package assumes an ANSI C compiler such as gcc. It will
+not compile with an old-style K&R compiler.
+
+Note that CORD_printf iand friends use C functions with variable numbers
+of arguments in non-standard-conforming ways. This code is known to
+break on some platforms, notably PowerPC. It should be possible to
+build the remainder of the library (everything but cordprnt.c) on
+any platform that supports the collector.
+
diff --git a/gc/doc/README.dj b/gc/doc/README.dj
new file mode 100644
index 0000000..613bc42
--- /dev/null
+++ b/gc/doc/README.dj
@@ -0,0 +1,12 @@
+[Original version supplied by Xiaokun Zhu <xiaokun@aero.gla.ac.uk>]
+[This version came mostly from Gary Leavens. ]
+
+Look first at Makefile.dj, and possibly change the definitions of
+RM and MV if you don't have rm and mv installed.
+Then use Makefile.dj to compile the garbage collector.
+For example, you can do:
+
+ make -f Makefile.dj test
+
+All the tests should work fine.
+
diff --git a/gc/doc/README.environment b/gc/doc/README.environment
new file mode 100644
index 0000000..5760342
--- /dev/null
+++ b/gc/doc/README.environment
@@ -0,0 +1,44 @@
+The garbage collector looks at a number of environment variables which are
+the used to affect its operation. These are examined only on Un*x-like
+platforms.
+
+GC_INITIAL_HEAP_SIZE=<bytes> - Initial heap size in bytes. May speed up
+ process start-up.
+
+GC_LOOP_ON_ABORT - Causes the collector abort routine to enter a tight loop.
+ This may make it easier to debug, such a process, especially
+ for multithreaded platforms that don't produce usable core
+ files, or if a core file would be too large. On some
+ platforms, this also causes SIGSEGV to be caught and
+ result in an infinite loop in a handler, allowing
+ similar debugging techniques.
+
+GC_PRINT_STATS - Turn on as much logging as is easily feasible without
+ adding signifcant runtime overhead. Doesn't work if
+ the collector is built with SMALL_CONFIG. Overridden
+ by setting GC_quiet. On by default if the collector
+ was built without -DSILENT.
+
+GC_PRINT_ADDRESS_MAP - Linux only. Dump /proc/self/maps, i.e. various address
+ maps for the process, to stderr on every GC. Useful for
+ mapping root addresses to source for deciphering leak
+ reports.
+
+GC_NPROCS=<n> - Linux w/threads only. Explicitly sets the number of processors
+ that the GC should expect to use. Note that setting this to 1
+ when multiple processors are available will preserve
+ correctness, but may lead to really horrible performance.
+
+GC_NO_BLACKLIST_WARNING - Prevents the collector from issuing
+ "Needed to allocate blacklisted block at ..." warnings.
+
+The following turn on runtime flags that are also program settable. Checked
+only during initialization. We expect that they will usually be set through
+other means, but this may help with debugging and testing:
+
+GC_FIND_LEAK - Turns on GC_find_leak and thus leak detection.
+
+GC_ALL_INTERIOR_POINTERS - Turns on GC_all_interior_pointers and thus interior
+ pointer recognition.
+
+GC_DONT_GC - Turns off garbage collection. Use cautiously.
diff --git a/gc/doc/README.hp b/gc/doc/README.hp
new file mode 100644
index 0000000..caa8bdd
--- /dev/null
+++ b/gc/doc/README.hp
@@ -0,0 +1,18 @@
+Dynamic loading support requires that executables be linked with -ldld.
+The alternative is to build the collector without defining DYNAMIC_LOADING
+in gcconfig.h and ensuring that all garbage collectable objects are
+accessible without considering statically allocated variables in dynamic
+libraries.
+
+The collector should compile with either plain cc or cc -Ae. Cc -Aa
+fails to define _HPUX_SOURCE and thus will not configure the collector
+correctly.
+
+Incremental collection support was reccently added, and should now work.
+
+In spite of past claims, pthread support under HP/UX 11 should now work.
+Define GC_HPUX_THREADS for the build. Incremental collection still does not
+work in combination with it.
+
+The stack finding code can be confused by putenv calls before collector
+initialization. Call GC_malloc or GC_init before any putenv calls.
diff --git a/gc/doc/README.linux b/gc/doc/README.linux
new file mode 100644
index 0000000..efd0a26
--- /dev/null
+++ b/gc/doc/README.linux
@@ -0,0 +1,135 @@
+See README.alpha for Linux on DEC AXP info.
+
+This file applies mostly to Linux/Intel IA32. Ports to Linux on an M68K
+and PowerPC are also integrated. They should behave similarly, except that
+the PowerPC port lacks incremental GC support, and it is unknown to what
+extent the Linux threads code is functional. See below for M68K specific
+notes.
+
+Incremental GC is supported on Intel IA32 and M68K.
+
+Dynamic libraries are supported on an ELF system. A static executable
+should be linked with the gcc option "-Wl,-defsym,_DYNAMIC=0".
+
+The collector appears to work with Linux threads. We have seen
+intermittent hangs in sem_wait. So far we have been unable to reproduce
+these unless the process was being debugged or traced. Thus it's
+possible that the only real issue is that the debugger loses
+signals on rare occasions.
+
+The garbage collector uses SIGPWR and SIGXCPU if it is used with
+Linux threads. These should not be touched by the client program.
+
+To use threads, you need to abide by the following requirements:
+
+1) You need to use LinuxThreads (which are included in libc6).
+
+ The collector relies on some implementation details of the LinuxThreads
+ package. It is unlikely that this code will work on other
+ pthread implementations (in particular it will *not* work with
+ MIT pthreads).
+
+2) You must compile the collector with -DGC_LINUX_THREADS and -D_REENTRANT
+ specified in the Makefile.
+
+3a) Every file that makes thread calls should define GC_LINUX_THREADS and
+ _REENTRANT and then include gc.h. Gc.h redefines some of the
+ pthread primitives as macros which also provide the collector with
+ information it requires.
+
+3b) A new alternative to (3a) is to build the collector and compile GC clients
+ with -DGC_USE_LD_WRAP, and to link the final program with
+
+ (for ld) --wrap read --wrap dlopen --wrap pthread_create \
+ --wrap pthread_join --wrap pthread_detach \
+ --wrap pthread_sigmask --wrap sleep
+
+ (for gcc) -Wl,--wrap -Wl,read -Wl,--wrap -Wl,dlopen -Wl,--wrap \
+ -Wl,pthread_create -Wl,--wrap -Wl,pthread_join -Wl,--wrap \
+ -Wl,pthread_detach -Wl,--wrap -Wl,pthread_sigmask \
+ -Wl,--wrap -Wl,sleep
+
+ In any case, _REENTRANT should be defined during compilation.
+
+4) Dlopen() disables collection during its execution. (It can't run
+ concurrently with the collector, since the collector looks at its
+ data structures. It can't acquire the allocator lock, since arbitrary
+ user startup code may run as part of dlopen().) Under unusual
+ conditions, this may cause unexpected heap growth.
+
+5) The combination of GC_LINUX_THREADS, REDIRECT_MALLOC, and incremental
+ collection fails in seemingly random places. This hasn't been tracked
+ down yet, but is perhaps not completely astonishing. The thread package
+ uses malloc, and thus can presumably get SIGSEGVs while inside the
+ package. There is no real guarantee that signals are handled properly
+ at that point.
+
+6) Thread local storage may not be viewed as part of the root set by the
+ collector. This probably depends on the linuxthreads version. For the
+ time being, any collectable memory referenced by thread local storage should
+ also be referenced from elsewhere, or be allocated as uncollectable.
+ (This is really a bug that should be fixed somehow.)
+
+
+M68K LINUX:
+(From Richard Zidlicky)
+The bad news is that it can crash every linux-m68k kernel on a 68040,
+so an additional test is needed somewhere on startup. I have meanwhile
+patches to correct the problem in 68040 buserror handler but it is not
+yet in any standard kernel.
+
+Here is a simple test program to detect whether the kernel has the
+problem. It could be run as a separate check in configure or tested
+upon startup. If it fails (return !0) than mprotect can't be used
+on that system.
+
+/*
+ * test for bug that may crash 68040 based Linux
+ */
+
+#include <sys/mman.h>
+#include <signal.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+char *membase;
+int pagesize=4096;
+int pageshift=12;
+int x_taken=0;
+
+int sighandler(int sig)
+{
+ mprotect(membase,pagesize,PROT_READ|PROT_WRITE);
+ x_taken=1;
+}
+
+main()
+{
+ long l;
+
+ signal(SIGSEGV,sighandler);
+ l=(long)mmap(NULL,pagesize,PROT_READ,MAP_PRIVATE | MAP_ANON,-1,0);
+ if (l==-1)
+ {
+ perror("mmap/malloc");
+ abort();
+ }
+ membase=(char*)l;
+ *(long*)(membase+sizeof(long))=123456789;
+ if (*(long*)(membase+sizeof(long)) != 123456789 )
+ {
+ fprintf(stderr,"writeback failed !\n");
+ exit(1);
+ }
+ if (!x_taken)
+ {
+ fprintf(stderr,"exception not taken !\n");
+ exit(1);
+ }
+ fprintf(stderr,"vmtest Ok\n");
+ exit(0);
+}
+
+
diff --git a/gc/doc/README.macros b/gc/doc/README.macros
new file mode 100644
index 0000000..d9df8dd
--- /dev/null
+++ b/gc/doc/README.macros
@@ -0,0 +1,78 @@
+The collector uses a large amount of conditional compilation in order to
+deal with platform dependencies. This violates a number of known coding
+standards. On the other hand, it seems to be the only practical way to
+support this many platforms without excessive code duplication.
+
+A few guidelines have mostly been followed in order to keep this manageable:
+
+1) #if and #ifdef directives are properly indented whenever easily possible.
+All known C compilers allow whitespace between the "#" and the "if" to make
+this possible. ANSI C also allows white space before the "#", though we
+avoid that. It has the known disadvantages that it differs from the normal
+GNU conventions, and that it makes patches larger than otherwise necessary.
+In my opinion, it's still well worth it, for the same reason that we indent
+ordinary "if" statements.
+
+2) Whenever possible, tests are performed on the macros defined in gcconfig.h
+instead of directly testing patform-specific predefined macros. This makes it
+relatively easy to adapt to new compilers with a different set of predefined
+macros. Currently these macros generally identify platforms instead of
+features. In many cases, this is a mistake.
+
+3) The code currently avoids #elif, eventhough that would make it more
+readable. This was done since #elif would need to be understood by ALL
+compilers used to build the collector, and that hasn't always been the case.
+It makes sense to reconsider this decision at some point, since #elif has been
+standardized at least since 1989.
+
+Many of the tested configuration macros are at least somewhat defined in
+either include/private/gcconfig.h or in Makefile.direct. Here is an attempt
+at defining some of the remainder: (Thanks to Walter Bright for suggesting
+this. This is a work in progress)
+
+MACRO EXPLANATION
+----- -----------
+
+__DMC__ Always #define'd by the Digital Mars compiler. Expands
+ to the compiler version number in hex, i.e. 0x810 is
+ version 8.1b0
+
+_ENABLE_ARRAYNEW
+ #define'd by the Digital Mars C++ compiler when
+ operator new[] and delete[] are separately
+ overloadable. Used in gc_cpp.h.
+
+_MSC_VER Expands to the Visual C++ compiler version. Assumed to
+ not be defined for other compilers (at least if they behave
+ appreciably differently).
+
+_DLL Defined by Visual C++ if dynamic libraries are being built
+ or used. Used to test whether __declspec(dllimport) or
+ __declspec(dllexport) needs to be added to declarations
+ to support the case in which the collector is in a dll.
+
+GC_DLL User-settable macro that forces the effect of _DLL.
+
+GC_NOT_DLL User-settable macro that overrides _DLL, e.g. if dynamic
+ libraries are used, but the collector is in a static library.
+
+__STDC__ Assumed to be defined only by compilers that understand
+ prototypes and other C89 features. Its value is generally
+ not used, since we are fine with most nonconforming extensions.
+
+SUNOS5SIGS Solaris-like signal handling. This is probably misnamed,
+ since it really doesn't guarantee much more than Posix.
+ Currently set only for Solaris2.X, HPUX, and DRSNX. Should
+ probably be set for some other platforms.
+
+PCR Set if the collector is being built as part of the Xerox
+ Portable Common Runtime.
+
+SRC_M3 Set if the collector is being built as a replacement of the
+ one in the DEC/Compaq SRC Modula-3 runtime. I suspect this
+ was last used around 1994, and no doubt broke a long time ago.
+ It's there primarily incase someone wants to port to a similar
+ system.
+
+
+
diff --git a/gc/doc/README.rs6000 b/gc/doc/README.rs6000
new file mode 100644
index 0000000..f5630b2
--- /dev/null
+++ b/gc/doc/README.rs6000
@@ -0,0 +1,9 @@
+We have so far failed to find a good way to determine the stack base.
+It is highly recommended that GC_stackbottom be set explicitly on program
+startup. The supplied value sometimes causes failure under AIX 4.1, though
+it appears to work under 3.X. HEURISTIC2 seems to work under 4.1, but
+involves a substantial performance penalty, and will fail if there is
+no limit on stack size.
+
+There is no thread support. (I assume recent versions of AIX provide
+pthreads? I no longer have access to a machine ...)
diff --git a/gc/doc/README.sgi b/gc/doc/README.sgi
new file mode 100644
index 0000000..7bdb50a
--- /dev/null
+++ b/gc/doc/README.sgi
@@ -0,0 +1,41 @@
+Performance of the incremental collector can be greatly enhanced with
+-DNO_EXECUTE_PERMISSION.
+
+The collector should run with all of the -32, -n32 and -64 ABIs. Remember to
+define the AS macro in the Makefile to be "as -64", or "as -n32".
+
+If you use -DREDIRECT_MALLOC=GC_malloc with C++ code, your code should make
+at least one explicit call to malloc instead of new to ensure that the proper
+version of malloc is linked in.
+
+Sproc threads are not supported in this version, though there may exist other
+ports.
+
+Pthreads support is provided. This requires that:
+
+1) You compile the collector with -DGC_IRIX_THREADS specified in the Makefile.
+
+2) You have the latest pthreads patches installed.
+
+(Though the collector makes only documented pthread calls,
+it relies on signal/threads interactions working just right in ways
+that are not required by the standard. It is unlikely that this code
+will run on other pthreads platforms. But please tell me if it does.)
+
+3) Every file that makes thread calls should define IRIX_THREADS and then
+include gc.h. Gc.h redefines some of the pthread primitives as macros which
+also provide the collector with information it requires.
+
+4) pthread_cond_wait and pthread_cond_timed_wait should be prepared for
+premature wakeups. (I believe the pthreads and realted standards require this
+anyway. Irix pthreads often terminate a wait if a signal arrives.
+The garbage collector uses signals to stop threads.)
+
+5) It is expensive to stop a thread waiting in IO at the time the request is
+initiated. Applications with many such threads may not exhibit acceptable
+performance with the collector. (Increasing the heap size may help.)
+
+6) The collector should not be compiled with -DREDIRECT_MALLOC. This
+confuses some library calls made by the pthreads implementation, which
+expect the standard malloc.
+
diff --git a/gc/doc/README.solaris2 b/gc/doc/README.solaris2
new file mode 100644
index 0000000..6ed61dc
--- /dev/null
+++ b/gc/doc/README.solaris2
@@ -0,0 +1,62 @@
+The collector supports both incremental collection and threads under
+Solaris 2. The incremental collector normally retrieves page dirty information
+through the appropriate /proc calls. But it can also be configured
+(by defining MPROTECT_VDB instead of PROC_VDB in gcconfig.h) to use mprotect
+and signals. This may result in shorter pause times, but it is no longer
+safe to issue arbitrary system calls that write to the heap.
+
+Under other UNIX versions,
+the collector normally obtains memory through sbrk. There is some reason
+to expect that this is not safe if the client program also calls the system
+malloc, or especially realloc. The sbrk man page strongly suggests this is
+not safe: "Many library routines use malloc() internally, so use brk()
+and sbrk() only when you know that malloc() definitely will not be used by
+any library routine." This doesn't make a lot of sense to me, since there
+seems to be no documentation as to which routines can transitively call malloc.
+Nonetheless, under Solaris2, the collector now (since 4.12) allocates
+memory using mmap by default. (It defines USE_MMAP in gcconfig.h.)
+You may want to reverse this decisions if you use -DREDIRECT_MALLOC=...
+
+
+SOLARIS THREADS:
+
+The collector must be compiled with -DGC_SOLARIS_THREADS (thr_ functions)
+or -DGC_SOLARIS_PTHREADS (pthread_ functions) to be thread safe.
+It is also essential that gc.h be included in files that call thr_create,
+thr_join, thr_suspend, thr_continue, or dlopen. Gc.h macro defines
+these to also do GC bookkeeping, etc. Gc.h must be included with
+one or both of these macros defined, otherwise
+these replacements are not visible.
+A collector built in this way way only be used by programs that are
+linked with the threads library.
+
+In this mode, the collector contains various workarounds for older Solaris
+bugs. Mostly, these should not be noticeable unless you look at system
+call traces. However, it cannot protect a guard page at the end of
+a thread stack. If you know that you will only be running Solaris2.5
+or later, it should be possible to fix this by compiling the collector
+with -DSOLARIS23_MPROTECT_BUG_FIXED.
+
+Since 5.0 alpha5, dlopen disables collection temporarily,
+unless USE_PROC_FOR_LIBRARIES is defined. In some unlikely cases, this
+can result in unpleasant heap growth. But it seems better than the
+race/deadlock issues we had before.
+
+If solaris_threads are used on an X86 processor with malloc redirected to
+GC_malloc, it is necessary to call GC_thr_init explicitly before forking the
+first thread. (This avoids a deadlock arising from calling GC_thr_init
+with the allocation lock held.)
+
+It appears that there is a problem in using gc_cpp.h in conjunction with
+Solaris threads and Sun's C++ runtime. Apparently the overloaded new operator
+is invoked by some iostream initialization code before threads are correctly
+initialized. As a result, call to thr_self() in garbage collector
+initialization segfaults. Currently the only known workaround is to not
+invoke the garbage collector from a user defined global operator new, or to
+have it invoke the garbage-collector's allocators only after main has started.
+(Note that the latter requires a moderately expensive test in operator
+delete.)
+
+Hans-J. Boehm
+(The above contains my personal opinions, which are probably not shared
+by anyone else.)
diff --git a/gc/doc/README.uts b/gc/doc/README.uts
new file mode 100644
index 0000000..6be4966
--- /dev/null
+++ b/gc/doc/README.uts
@@ -0,0 +1,2 @@
+Alistair Crooks supplied the port. He used Lexa C version 2.1.3 with
+-Xa to compile.
diff --git a/gc/doc/README.win32 b/gc/doc/README.win32
new file mode 100644
index 0000000..417281d
--- /dev/null
+++ b/gc/doc/README.win32
@@ -0,0 +1,149 @@
+The collector has at various times been compiled under Windows 95 & NT,
+with the original Microsoft SDK, with Visual C++ 2.0, 4.0, and 6, with
+the GNU win32 environment, with Borland 4.5, and recently with
+Watcom C. It is likely that some of these have been broken in the
+meantime. Patches are appreciated.
+
+It runs under both win32s and win32, but with different semantics.
+Under win32, all writable pages outside of the heaps and stack are
+scanned for roots. Thus the collector sees pointers in DLL data
+segments. Under win32s, only the main data segment is scanned.
+(The main data segment should always be scanned. Under some
+versions of win32s, other regions may also be scanned.)
+Thus all accessible objects should be accessible from local variables
+or variables in the main data segment. Alternatively, other data
+segments (e.g. in DLLs) may be registered with the collector by
+calling GC_init() and then GC_register_root_section(a), where
+a is the address of some variable inside the data segment. (Duplicate
+registrations are ignored, but not terribly quickly.)
+
+(There are two reasons for this. We didn't want to see many 16:16
+pointers. And the VirtualQuery call has different semantics under
+the two systems, and under different versions of win32s.)
+
+The collector test program "gctest" is linked as a GUI application,
+but does not open any windows. Its output appears in the file
+"gc.log". It may be started from the file manager. The hour glass
+cursor may appear as long as it's running. If it is started from the
+command line, it will usually run in the background. Wait a few
+minutes (a few seconds on a modern machine) before you check the output.
+You should see either a failure indication or a "Collector appears to
+work" message.
+
+The cord test program has not been ported (but should port
+easily). A toy editor (cord/de.exe) based on cords (heavyweight
+strings represented as trees) has been ported and is included.
+It runs fine under either win32 or win32S. It serves as an example
+of a true Windows application, except that it was written by a
+nonexpert Windows programmer. (There are some peculiarities
+in the way files are displayed. The <cr> is displayed explicitly
+for standard DOS text files. As in the UNIX version, control
+characters are displayed explicitly, but in this case as red text.
+This may be suboptimal for some tastes and/or sets of default
+window colors.)
+
+In general -DREDIRECT_MALLOC is unlikely to work unless the
+application is completely statically linked.
+
+For Microsoft development tools, rename NT_MAKEFILE as
+MAKEFILE. (Make sure that the CPU environment variable is defined
+to be i386.) In order to use the gc_cpp.h C++ interface, all
+client code should include gc_cpp.h.
+
+Clients may need to define GC_NOT_DLL before including gc.h, if the
+collector was built as a static library (as it normally is in the
+absence of thread support).
+
+For GNU-win32, use the regular makefile, possibly after uncommenting
+the line "include Makefile.DLLs". The latter should be necessary only
+if you want to package the collector as a DLL. The GNU-win32 port is
+believed to work only for b18, not b19, probably dues to linker changes
+in b19. This is probably fixable with a different definition of
+DATASTART and DATAEND in gcconfig.h.
+
+For Borland tools, use BCC_MAKEFILE. Note that
+Borland's compiler defaults to 1 byte alignment in structures (-a1),
+whereas Visual C++ appears to default to 8 byte alignment (/Zp8).
+The garbage collector in its default configuration EXPECTS AT
+LEAST 4 BYTE ALIGNMENT. Thus the BORLAND DEFAULT MUST
+BE OVERRIDDEN. (In my opinion, it should usually be anyway.
+I expect that -a1 introduces major performance penalties on a
+486 or Pentium.) Note that this changes structure layouts. (As a last
+resort, gcconfig.h can be changed to allow 1 byte alignment. But
+this has significant negative performance implications.)
+The Makefile is set up to assume Borland 4.5. If you have another
+version, change the line near the top. By default, it does not
+require the assembler. If you do have the assembler, I recommend
+removing the -DUSE_GENERIC.
+
+There is some support for incremental collection. This is
+currently pretty simple-minded. Pages are protected. Protection
+faults are caught by a handler installed at the bottom of the handler
+stack. This is both slow and interacts poorly with a debugger.
+Whenever possible, I recommend adding a call to
+GC_enable_incremental at the last possible moment, after most
+debugging is complete. Unlike the UNIX versions, no system
+calls are wrapped by the collector itself. It may be necessary
+to wrap ReadFile calls that use a buffer in the heap, so that the
+call does not encounter a protection fault while it's running.
+(As usual, none of this is an issue unless GC_enable_incremental
+is called.)
+
+Note that incremental collection is disabled with -DSMALL_CONFIG.
+
+James Clark has contributed the necessary code to support win32 threads.
+Use NT_THREADS_MAKEFILE (a.k.a gc.mak) instead of NT_MAKEFILE
+to build this version. Note that this requires some files whose names
+are more than 8 + 3 characters long. Thus you should unpack the tar file
+so that long file names are preserved. To build the garbage collector
+test with VC++ from the command line, use
+
+nmake /F ".\gc.mak" CFG="gctest - Win32 Release"
+
+This requires that the subdirectory gctest\Release exist.
+The test program and DLL will reside in the Release directory.
+
+This version relies on the collector residing in a dll.
+
+This version currently supports incremental collection only if it is
+enabled before any additional threads are created.
+Version 4.13 attempts to fix some of the earlier problems, but there
+may be other issues. If you need solid support for win32 threads, you
+might check with Geodesic Systems. Their collector must be licensed,
+but they have invested far more time in win32-specific issues.
+
+Hans
+
+Ivan V. Demakov's README for the Watcom port:
+
+The collector has been compiled with Watcom C 10.6 and 11.0.
+It runs under win32, win32s, and even under msdos with dos4gw
+dos-extender. It should also run under OS/2, though this isn't
+tested. Under win32 the collector can be built either as dll
+or as static library.
+
+Note that all compilations were done under Windows 95 or NT.
+For unknown reason compiling under Windows 3.11 for NT (one
+attempt has been made) leads to broken executables.
+
+Incremental collection is not supported.
+
+cord is not ported.
+
+Before compiling you may need to edit WCC_MAKEFILE to set target
+platform, library type (dynamic or static), calling conventions, and
+optimization options.
+
+To compile the collector and testing programs use the command:
+ wmake -f WCC_MAKEFILE
+
+All programs using gc should be compiled with 4-byte alignment.
+For further explanations on this see comments about Borland.
+
+If gc compiled as dll, the macro ``GC_DLL'' should be defined before
+including "gc.h" (for example, with -DGC_DLL compiler option). It's
+important, otherwise resulting programs will not run.
+
+Ivan Demakov (email: ivan@tgrad.nsk.su)
+
+
diff --git a/gc/doc/barrett_diagram b/gc/doc/barrett_diagram
new file mode 100644
index 0000000..27e80dc
--- /dev/null
+++ b/gc/doc/barrett_diagram
@@ -0,0 +1,106 @@
+This is an ASCII diagram of the data structure used to check pointer
+validity. It was provided by Dave Barrett <barrett@asgard.cs.colorado.edu>,
+and should be of use to others attempting to understand the code.
+The data structure in GC4.X is essentially the same. -HB
+
+
+
+
+ Data Structure used by GC_base in gc3.7:
+ 21-Apr-94
+
+
+
+
+ 63 LOG_TOP_SZ[11] LOG_BOTTOM_SZ[10] LOG_HBLKSIZE[13]
+ +------------------+----------------+------------------+------------------+
+ p:| | TL_HASH(hi) | | HBLKDISPL(p) |
+ +------------------+----------------+------------------+------------------+
+ \-----------------------HBLKPTR(p)-------------------/
+ \------------hi-------------------/
+ \______ ________/ \________ _______/ \________ _______/
+ V V V
+ | | |
+ GC_top_index[] | | |
+ --- +--------------+ | | |
+ ^ | | | | |
+ | | | | | |
+ TOP +--------------+<--+ | |
+ _SZ +-<| [] | * | |
+(items)| +--------------+ if 0 < bi< HBLKSIZE | |
+ | | | | then large object | |
+ | | | | starts at the bi'th | |
+ v | | | HBLK before p. | i |
+ --- | +--------------+ | (word- |
+ v | aligned) |
+ bi= |GET_BI(p){->hash_link}->key==hi | |
+ v | |
+ | (bottom_index) \ scratch_alloc'd | |
+ | ( struct bi ) / by get_index() | |
+ --- +->+--------------+ | |
+ ^ | | | |
+ ^ | | | |
+ BOTTOM | | ha=GET_HDR_ADDR(p) | |
+_SZ(items)+--------------+<----------------------+ +-------+
+ | +--<| index[] | |
+ | | +--------------+ GC_obj_map: v
+ | | | | from / +-+-+-----+-+-+-+-+ ---
+ v | | | GC_add < 0| | | | | | | | ^
+ --- | +--------------+ _map_entry \ +-+-+-----+-+-+-+-+ |
+ | | asc_link | +-+-+-----+-+-+-+-+ MAXOBJSZ
+ | +--------------+ +-->| | | j | | | | | +1
+ | | key | | +-+-+-----+-+-+-+-+ |
+ | +--------------+ | +-+-+-----+-+-+-+-+ |
+ | | hash_link | | | | | | | | | | v
+ | +--------------+ | +-+-+-----+-+-+-+-+ ---
+ | | |<--MAX_OFFSET--->|
+ | | (bytes)
+HDR(p)| GC_find_header(p) | |<--MAP_ENTRIES-->|
+ | \ from | =HBLKSIZE/WORDSZ
+ | (hdr) (struct hblkhdr) / alloc_hdr() | (1024 on Alpha)
+ +-->+----------------------+ | (8/16 bits each)
+GET_HDR(p)| word hb_sz (words) | |
+ +----------------------+ |
+ | struct hblk *hb_next | |
+ +----------------------+ |
+ |mark_proc hb_mark_proc| |
+ +----------------------+ |
+ | char * hb_map |>-------------+
+ +----------------------+
+ | ushort hb_obj_kind |
+ +----------------------+
+ | hb_last_reclaimed |
+ --- +----------------------+
+ ^ | |
+ MARK_BITS| hb_marks[] | *if hdr is free, hb_sz + DISCARD_WORDS
+_SZ(words)| | is the size of a heap chunk (struct hblk)
+ v | | of at least MININCR*HBLKSIZE bytes (below),
+ --- +----------------------+ otherwise, size of each object in chunk.
+
+Dynamic data structures above are interleaved throughout the heap in blocks of
+size MININCR * HBLKSIZE bytes as done by gc_scratch_alloc which cannot be
+freed; free lists are used (e.g. alloc_hdr). HBLKs's below are collected.
+
+ (struct hblk)
+ --- +----------------------+ < HBLKSIZE --- --- DISCARD_
+ ^ |garbage[DISCARD_WORDS]| aligned ^ ^ HDR_BYTES WORDS
+ | | | | v (bytes) (words)
+ | +-----hb_body----------+ < WORDSZ | --- ---
+ | | | aligned | ^ ^
+ | | Object 0 | | hb_sz |
+ | | | i |(word- (words)|
+ | | | (bytes)|aligned) v |
+ | + - - - - - - - - - - -+ --- | --- |
+ | | | ^ | ^ |
+ n * | | j (words) | hb_sz BODY_SZ
+ HBLKSIZE | Object 1 | v v | (words)
+ (bytes) | |--------------- v MAX_OFFSET
+ | + - - - - - - - - - - -+ --- (bytes)
+ | | | !All_INTERIOR_PTRS ^ |
+ | | | sets j only for hb_sz |
+ | | Object N | valid object offsets. | |
+ v | | All objects WORDSZ v v
+ --- +----------------------+ aligned. --- ---
+
+DISCARD_WORDS is normally zero. Indeed the collector has not been tested
+with another value in ages.
diff --git a/gc/doc/debugging.html b/gc/doc/debugging.html
new file mode 100644
index 0000000..a186ff5
--- /dev/null
+++ b/gc/doc/debugging.html
@@ -0,0 +1,289 @@
+<HTML>
+<HEAD>
+<TITLE>Debugging Garbage Collector Related Problems</title>
+</head>
+<BODY>
+<H1>Debugging Garbage Collector Related Problems</h1>
+This page contains some hints on
+debugging issues specific to
+the Boehm-Demers-Weiser conservative garbage collector.
+It applies both to debugging issues in client code that manifest themselves
+as collector misbehavior, and to debugging the collector itself.
+<P>
+If you suspect a bug in the collector itself, it is strongly recommended
+that you try the latest collector release, even if it is labelled as "alpha",
+before proceeding.
+<H2>Bus Errors and Segmentation Violations</h2>
+<P>
+If the fault occurred in GC_find_limit, or with incremental collection enabled,
+this is probably normal. The collector installs handlers to take care of
+these. You will not see these unless you are using a debugger.
+Your debugger <I>should</i> allow you to continue.
+It's often preferable to tell the debugger to ignore SIGBUS and SIGSEGV
+("<TT>handle SIGSEGV SIGBUS nostop noprint</tt>" in gdb,
+"<TT>ignore SIGSEGV SIGBUS</tt>" in most versions of dbx)
+and set a breakpoint in <TT>abort</tt>.
+The collector will call abort if the signal had another cause,
+and there was not other handler previously installed.
+<P>
+We recommend debugging without incremental collection if possible.
+(This applies directly to UNIX systems.
+Debugging with incremental collection under win32 is worse. See README.win32.)
+<P>
+If the application generates an unhandled SIGSEGV or equivalent, it may
+often be easiest to set the environment variable GC_LOOP_ON_ABORT. On many
+platforms, this will cause the collector to loop in a handler when the
+SIGSEGV is encountered (or when the collector aborts for some other reason),
+and a debugger can then be attached to the looping
+process. This sidesteps common operating system problems related
+to incomplete core files for multithreaded applications, etc.
+<H2>Other Signals</h2>
+On most platforms, the multithreaded version of the collector needs one or
+two other signals for internal use by the collector in stopping threads.
+It is normally wise to tell the debugger to ignore these. On Linux,
+the collector currently uses SIGPWR and SIGXCPU by default.
+<H2>Warning Messages About Needing to Allocate Blacklisted Blocks</h2>
+The garbage collector generates warning messages of the form
+<PRE>
+Needed to allocate blacklisted block at 0x...
+</pre>
+when it needs to allocate a block at a location that it knows to be
+referenced by a false pointer. These false pointers can be either permanent
+(<I>e.g.</i> a static integer variable that never changes) or temporary.
+In the latter case, the warning is largely spurious, and the block will
+eventually be reclaimed normally.
+In the former case, the program will still run correctly, but the block
+will never be reclaimed. Unless the block is intended to be
+permanent, the warning indicates a memory leak.
+<OL>
+<LI>Ignore these warnings while you are using GC_DEBUG. Some of the routines
+mentioned below don't have debugging equivalents. (Alternatively, write
+the missing routines and send them to me.)
+<LI>Replace allocator calls that request large blocks with calls to
+<TT>GC_malloc_ignore_off_page</tt> or
+<TT>GC_malloc_atomic_ignore_off_page</tt>. You may want to set a
+breakpoint in <TT>GC_default_warn_proc</tt> to help you identify such calls.
+Make sure that a pointer to somewhere near the beginning of the resulting block
+is maintained in a (preferably volatile) variable as long as
+the block is needed.
+<LI>
+If the large blocks are allocated with realloc, we suggest instead allocating
+them with something like the following. Note that the realloc size increment
+should be fairly large (e.g. a factor of 3/2) for this to exhibit reasonable
+performance. But we all know we should do that anyway.
+<PRE>
+void * big_realloc(void *p, size_t new_size)
+{
+ size_t old_size = GC_size(p);
+ void * result;
+
+ if (new_size <= 10000) return(GC_realloc(p, new_size));
+ if (new_size <= old_size) return(p);
+ result = GC_malloc_ignore_off_page(new_size);
+ if (result == 0) return(0);
+ memcpy(result,p,old_size);
+ GC_free(p);
+ return(result);
+}
+</pre>
+
+<LI> In the unlikely case that even relatively small object
+(&lt;20KB) allocations are triggering these warnings, then your address
+space contains lots of "bogus pointers", i.e. values that appear to
+be pointers but aren't. Usually this can be solved by using GC_malloc_atomic
+or the routines in gc_typed.h to allocate large pointer-free regions of bitmaps, etc. Sometimes the problem can be solved with trivial changes of encoding
+in certain values. It is possible, to identify the source of the bogus
+pointers by building the collector with <TT>-DPRINT_BLACK_LIST</tt>,
+which will cause it to print the "bogus pointers", along with their location.
+
+<LI> If you get only a fixed number of these warnings, you are probably only
+introducing a bounded leak by ignoring them. If the data structures being
+allocated are intended to be permanent, then it is also safe to ignore them.
+The warnings can be turned off by calling GC_set_warn_proc with a procedure
+that ignores these warnings (e.g. by doing absolutely nothing).
+</ol>
+
+<H2>The Collector References a Bad Address in <TT>GC_malloc</tt></h2>
+
+This typically happens while the collector is trying to remove an entry from
+its free list, and the free list pointer is bad because the free list link
+in the last allocated object was bad.
+<P>
+With &gt; 99% probability, you wrote past the end of an allocated object.
+Try setting <TT>GC_DEBUG</tt> before including <TT>gc.h</tt> and
+allocating with <TT>GC_MALLOC</tt>. This will try to detect such
+overwrite errors.
+
+<H2>Unexpectedly Large Heap</h2>
+
+Unexpected heap growth can be due to one of the following:
+<OL>
+<LI> Data structures that are being unintentionally retained. This
+is commonly caused by data structures that are no longer being used,
+but were not cleared, or by caches growing without bounds.
+<LI> Pointer misidentification. The garbage collector is interpreting
+integers or other data as pointers and retaining the "referenced"
+objects.
+<LI> Heap fragmentation. This should never result in unbounded growth,
+but it may account for larger heaps. This is most commonly caused
+by allocation of large objects. On some platforms it can be reduced
+by building with -DUSE_MUNMAP, which will cause the collector to unmap
+memory corresponding to pages that have not been recently used.
+<LI> Per object overhead. This is usually a relatively minor effect, but
+it may be worth considering. If the collector recognizes interior
+pointers, object sizes are increased, so that one-past-the-end pointers
+are correctly recognized. The collector can be configured not to do this
+(<TT>-DDONT_ADD_BYTE_AT_END</tt>).
+<P>
+The collector rounds up object sizes so the result fits well into the
+chunk size (<TT>HBLKSIZE</tt>, normally 4K on 32 bit machines, 8K
+on 64 bit machines) used by the collector. Thus it may be worth avoiding
+objects of size 2K + 1 (or 2K if a byte is being added at the end.)
+</ol>
+The last two cases can often be identified by looking at the output
+of a call to <TT>GC_dump()</tt>. Among other things, it will print the
+list of free heap blocks, and a very brief description of all chunks in
+the heap, the object sizes they correspond to, and how many live objects
+were found in the chunk at the last collection.
+<P>
+Growing data structures can usually be identified by
+<OL>
+<LI> Building the collector with <TT>-DKEEP_BACK_PTRS</tt>,
+<LI> Preferably using debugging allocation (defining <TT>GC_DEBUG</tt>
+before including <TT>gc.h</tt> and allocating with <TT>GC_MALLOC</tt>),
+so that objects will be identified by their allocation site,
+<LI> Running the application long enough so
+that most of the heap is composed of "leaked" memory, and
+<LI> Then calling <TT>GC_generate_random_backtrace()</tt> from backptr.h
+a few times to determine why some randomly sampled objects in the heap are
+being retained.
+</ol>
+<P>
+The same technique can often be used to identify problems with false
+pointers, by noting whether the reference chains printed by
+<TT>GC_generate_random_backtrace()</tt> involve any misidentified pointers.
+An alternate technique is to build the collector with
+<TT>-DPRINT_BLACK_LIST</tt> which will cause it to report values that
+are almost, but not quite, look like heap pointers. It is very likely that
+actual false pointers will come from similar sources.
+<P>
+In the unlikely case that false pointers are an issue, it can usually
+be resolved using one or more of the following techniques:
+<OL>
+<LI> Use <TT>GC_malloc_atomic</tt> for objects containing no pointers.
+This is especially important for large arrays containing compressed data,
+pseudo-random numbers, and the like. It is also likely to improve GC
+performance, perhaps drastically so if the application is paging.
+<LI> If you allocate large objects containing only
+one or two pointers at the beginning, either try the typed allocation
+primitives is <TT>gc_typed.h</tt>, or separate out the pointerfree component.
+<LI> Consider using <TT>GC_malloc_ignore_off_page()</tt>
+to allocate large objects. (See <TT>gc.h</tt> and above for details.
+Large means &gt; 100K in most environments.)
+</ol>
+<H2>Prematurely Reclaimed Objects</h2>
+The usual symptom of this is a segmentation fault, or an obviously overwritten
+value in a heap object. This should, of course, be impossible. In practice,
+it may happen for reasons like the following:
+<OL>
+<LI> The collector did not intercept the creation of threads correctly in
+a multithreaded application, <I>e.g.</i> because the client called
+<TT>pthread_create</tt> without including <TT>gc.h</tt>, which redefines it.
+<LI> The last pointer to an object in the garbage collected heap was stored
+somewhere were the collector couldn't see it, <I>e.g.</i> in an
+object allocated with system <TT>malloc</tt>, in certain types of
+<TT>mmap</tt>ed files,
+or in some data structure visible only to the OS. (On some platforms,
+thread-local storage is one of these.)
+<LI> The last pointer to an object was somehow disguised, <I>e.g.</i> by
+XORing it with another pointer.
+<LI> Incorrect use of <TT>GC_malloc_atomic</tt> or typed allocation.
+<LI> An incorrect <TT>GC_free</tt> call.
+<LI> The client program overwrote an internal garbage collector data structure.
+<LI> A garbage collector bug.
+<LI> (Empirically less likely than any of the above.) A compiler optimization
+that disguised the last pointer.
+</ol>
+The following relatively simple techniques should be tried first to narrow
+down the problem:
+<OL>
+<LI> If you are using the incremental collector try turning it off for
+debugging.
+<LI> Try to reproduce the problem with fully debuggable unoptimized code.
+This will eliminate the last possibility, as well as making debugging easier.
+<LI> Try replacing any suspect typed allocation and <TT>GC_malloc_atomic</tt>
+calls with calls to <TT>GC_malloc</tt>.
+<LI> Try removing any GC_free calls (<I>e.g.</i> with a suitable
+<TT>#define</tt>).
+<LI> Rebuild the collector with <TT>-DGC_ASSERTIONS</tt>.
+<LI> If the following works on your platform (i.e. if gctest still works
+if you do this), try building the collector with
+<TT>-DREDIRECT_MALLOC=GC_malloc_uncollectable</tt>. This will cause
+the collector to scan memory allocated with malloc.
+</ol>
+If all else fails, you will have to attack this with a debugger.
+Suggested steps:
+<OL>
+<LI> Call <TT>GC_dump()</tt> from the debugger around the time of the failure. Verify
+that the collectors idea of the root set (i.e. static data regions which
+it should scan for pointers) looks plausible. If not, i.e. if it doesn't
+include some static variables, report this as
+a collector bug. Be sure to describe your platform precisely, since this sort
+of problem is nearly always very platform dependent.
+<LI> Especially if the failure is not deterministic, try to isolate it to
+a relatively small test case.
+<LI> Set a break point in <TT>GC_finish_collection</tt>. This is a good
+point to examine what has been marked, i.e. found reachable, by the
+collector.
+<LI> If the failure is deterministic, run the process
+up to the last collection before the failure.
+Note that the variable <TT>GC_gc_no</tt> counts collections and can be used
+to set a conditional breakpoint in the right one. It is incremented just
+before the call to GC_finish_collection.
+If object <TT>p</tt> was prematurely recycled, it may be helpful to
+look at <TT>*GC_find_header(p)</tt> at the failure point.
+The <TT>hb_last_reclaimed</tt> field will identify the collection number
+during which its block was last swept.
+<LI> Verify that the offending object still has its correct contents at
+this point.
+The call <TT>GC_is_marked(p)</tt> from the debugger to verify that the
+object has not been marked, and is about to be reclaimed.
+<LI> Determine a path from a root, i.e. static variable, stack, or
+register variable,
+to the reclaimed object. Call <TT>GC_is_marked(q)</tt> for each object
+<TT>q</tt> along the path, trying to locate the first unmarked object, say
+<TT>r</tt>.
+<LI> If <TT>r</tt> is pointed to by a static root,
+verify that the location
+pointing to it is part of the root set printed by <TT>GC_dump()</tt>. If it
+is on the stack in the main (or only) thread, verify that
+<TT>GC_stackbottom</tt> is set correctly to the base of the stack. If it is
+in another thread stack, check the collector's thread data structure
+(<TT>GC_thread[]</tt> on several platforms) to make sure that stack bounds
+are set correctly.
+<LI> If <TT>r</tt> is pointed to by heap object <TT>s</tt>, check that the
+collector's layout description for <TT>s</tt> is such that the pointer field
+will be scanned. Call <TT>*GC_find_header(s)</tt> to look at the descriptor
+for the heap chunk. The <TT>hb_descr</tt> field specifies the layout
+of objects in that chunk. See gc_mark.h for the meaning of the descriptor.
+(If it's low order 2 bits are zero, then it is just the length of the
+object prefix to be scanned. This form is always used for objects allocated
+with <TT>GC_malloc</tt> or <TT>GC_malloc_atomic</tt>.)
+<LI> If the failure is not deterministic, you may still be able to apply some
+of the above technique at the point of failure. But remember that objects
+allocated since the last collection will not have been marked, even if the
+collector is functioning properly. On some platforms, the collector
+can be configured to save call chains in objects for debugging.
+Enabling this feature will also cause it to save the call stack at the
+point of the last GC in GC_arrays._last_stack.
+<LI> When looking at GC internal data structures remember that a number
+of <TT>GC_</tt><I>xxx</i> variables are really macro defined to
+<TT>GC_arrays._</tt><I>xxx</i>, so that
+the collector can avoid scanning them.
+</ol>
+</body>
+</html>
+
+
+
+
diff --git a/gc/doc/gc.man b/gc/doc/gc.man
new file mode 100644
index 0000000..5409e70
--- /dev/null
+++ b/gc/doc/gc.man
@@ -0,0 +1,80 @@
+.TH GC_MALLOC 1L "12 February 1996"
+.SH NAME
+GC_malloc, GC_malloc_atomic, GC_free, GC_realloc, GC_enable_incremental, GC_register_finalizer, GC_malloc_ignore_off_page, GC_malloc_atomic_ignore_off_page, GC_set_warn_proc \- Garbage collecting malloc replacement
+.SH SYNOPSIS
+#include "gc.h"
+.br
+# define malloc(n) GC_malloc(n)
+.br
+... malloc(...) ...
+.br
+.sp
+cc ... gc.a
+.LP
+.SH DESCRIPTION
+.I GC_malloc
+and
+.I GC_free
+are plug-in replacements for standard malloc and free. However,
+.I
+GC_malloc
+will attempt to reclaim inaccessible space automatically by invoking a conservative garbage collector at appropriate points. The collector traverses all data structures accessible by following pointers from the machines registers, stack(s), data, and bss segments. Inaccessible structures will be reclaimed. A machine word is considered to be a valid pointer if it is an address inside an object allocated by
+.I
+GC_malloc
+or friends.
+.LP
+See the documentation in the include file gc_cpp.h for an alternate, C++ specific interface to the garbage collector.
+.LP
+Unlike the standard implementations of malloc,
+.I
+GC_malloc
+clears the newly allocated storage.
+.I
+GC_malloc_atomic
+does not. Furthermore, it informs the collector that the resulting object will never contain any pointers, and should therefore not be scanned by the collector.
+.LP
+.I
+GC_free
+can be used to deallocate objects, but its use is optional, and generally discouraged.
+.I
+GC_realloc
+has the standard realloc semantics. It preserves pointer-free-ness.
+.I
+GC_register_finalizer
+allows for registration of functions that are invoked when an object becomes inaccessible.
+.LP
+The garbage collector tries to avoid allocating memory at locations that already appear to be referenced before allocation. (Such apparent ``pointers'' are usually large integers and the like that just happen to look like an address.) This may make it hard to allocate very large objects. An attempt to do so may generate a warning.
+.LP
+.I
+GC_malloc_ignore_off_page
+and
+.I
+GC_malloc_atomic_ignore_off_page
+inform the collector that the client code will always maintain a pointer to near the beginning of the object (within the first 512 bytes), and that pointers beyond that can be ignored by the collector. This makes it much easier for the collector to place large objects. These are recommended for large object allocation. (Objects expected to be larger than about 100KBytes should be allocated this way.)
+.LP
+It is also possible to use the collector to find storage leaks in programs destined to be run with standard malloc/free. The collector can be compiled for thread-safe operation. Unlike standard malloc, it is safe to call malloc after a previous malloc call was interrupted by a signal, provided the original malloc call is not resumed.
+.LP
+The collector may, on rare occasion produce warning messages. On UNIX machines these appear on stderr. Warning messages can be filtered, redirected, or ignored with
+.I
+GC_set_warn_proc.
+This is recommended for production code. See gc.h for details.
+.LP
+Debugging versions of many of the above routines are provided as macros. Their names are identical to the above, but consist of all capital letters. If GC_DEBUG is defined before gc.h is included, these routines do additional checking, and allow the leak detecting version of the collector to produce slightly more useful output. Without GC_DEBUG defined, they behave exactly like the lower-case versions.
+.LP
+On some machines, collection will be performed incrementally after a call to
+.I
+GC_enable_incremental.
+This may temporarily write protect pages in the heap. See the README file for more information on how this interacts with system calls that write to the heap.
+.LP
+Other facilities not discussed here include limited facilities to support incremental collection on machines without appropriate VM support, provisions for providing more explicit object layout information to the garbage collector, more direct support for ``weak'' pointers, support for ``abortable'' garbage collections during idle time, etc.
+.LP
+.SH "SEE ALSO"
+The README and gc.h files in the distribution. More detailed definitions of the functions exported by the collector are given there. (The above list is not complete.)
+.LP
+Boehm, H., and M. Weiser, "Garbage Collection in an Uncooperative Environment",
+\fISoftware Practice & Experience\fP, September 1988, pp. 807-820.
+.LP
+The malloc(3) man page.
+.LP
+.SH AUTHOR
+Hans-J. Boehm (boehm@parc.xerox.com). Some of the code was written by others, most notably Alan Demers.
diff --git a/gc/doc/gcdescr.html b/gc/doc/gcdescr.html
new file mode 100644
index 0000000..65e8a8f
--- /dev/null
+++ b/gc/doc/gcdescr.html
@@ -0,0 +1,438 @@
+<HTML>
+<HEAD>
+ <TITLE> Conservative GC Algorithmic Overview </TITLE>
+ <AUTHOR> Hans-J. Boehm, Silicon Graphics</author>
+</HEAD>
+<BODY>
+<H1> <I>This is under construction</i> </h1>
+<H1> Conservative GC Algorithmic Overview </h1>
+<P>
+This is a description of the algorithms and data structures used in our
+conservative garbage collector. I expect the level of detail to increase
+with time. For a survey of GC algorithms, see for example
+<A HREF="ftp://ftp.cs.utexas.edu/pub/garbage/gcsurvey.ps"> Paul Wilson's
+excellent paper</a>. For an overview of the collector interface,
+see <A HREF="gcinterface.html">here</a>.
+<P>
+This description is targeted primarily at someone trying to understand the
+source code. It specifically refers to variable and function names.
+It may also be useful for understanding the algorithms at a higher level.
+<P>
+The description here assumes that the collector is used in default mode.
+In particular, we assume that it used as a garbage collector, and not just
+a leak detector. We initially assume that it is used in stop-the-world,
+non-incremental mode, though the presence of the incremental collector
+will be apparent in the design.
+We assume the default finalization model, but the code affected by that
+is very localized.
+<H2> Introduction </h2>
+The garbage collector uses a modified mark-sweep algorithm. Conceptually
+it operates roughly in four phases:
+
+<OL>
+
+<LI>
+<I>Preparation</i> Clear all mark bits, indicating that all objects
+are potentially unreachable.
+
+<LI>
+<I>Mark phase</i> Marks all objects that can be reachable via chains of
+pointers from variables. Normally the collector has no real information
+about the location of pointer variables in the heap, so it
+views all static data areas, stacks and registers as potentially containing
+containing pointers. Any bit patterns that represent addresses inside
+heap objects managed by the collector are viewed as pointers.
+Unless the client program has made heap object layout information
+available to the collector, any heap objects found to be reachable from
+variables are again scanned similarly.
+
+<LI>
+<I>Sweep phase</i> Scans the heap for inaccessible, and hence unmarked,
+objects, and returns them to an appropriate free list for reuse. This is
+not really a separate phase; even in non incremental mode this is operation
+is usually performed on demand during an allocation that discovers an empty
+free list. Thus the sweep phase is very unlikely to touch a page that
+would not have been touched shortly thereafter anyway.
+
+<LI>
+<I>Finalization phase</i> Unreachable objects which had been registered
+for finalization are enqueued for finalization outside the collector.
+
+</ol>
+
+<P>
+The remaining sections describe the memory allocation data structures,
+and then the last 3 collection phases in more detail. We conclude by
+outlining some of the additional features implemented in the collector.
+
+<H2>Allocation</h2>
+The collector includes its own memory allocator. The allocator obtains
+memory from the system in a platform-dependent way. Under UNIX, it
+uses either <TT>malloc</tt>, <TT>sbrk</tt>, or <TT>mmap</tt>.
+<P>
+Most static data used by the allocator, as well as that needed by the
+rest of the garbage collector is stored inside the
+<TT>_GC_arrays</tt> structure.
+This allows the garbage collector to easily ignore the collectors own
+data structures when it searches for root pointers. Other allocator
+and collector internal data structures are allocated dynamically
+with <TT>GC_scratch_alloc</tt>. <TT>GC_scratch_alloc</tt> does not
+allow for deallocation, and is therefore used only for permanent data
+structures.
+<P>
+The allocator allocates objects of different <I>kinds</i>.
+Different kinds are handled somewhat differently by certain parts
+of the garbage collector. Certain kinds are scanned for pointers,
+others are not. Some may have per-object type descriptors that
+determine pointer locations. Or a specific kind may correspond
+to one specific object layout. Two built-in kinds are uncollectable.
+One (<TT>STUBBORN</tt>) is immutable without special precautions.
+In spite of that, it is very likely that most applications currently
+use at most two kinds: <TT>NORMAL</tt> and <TT>PTRFREE</tt> objects.
+<P>
+The collector uses a two level allocator. A large block is defined to
+be one larger than half of <TT>HBLKSIZE</tt>, which is a power of 2,
+typically on the order of the page size.
+<P>
+Large block sizes are rounded up to
+the next multiple of <TT>HBLKSIZE</tt> and then allocated by
+<TT>GC_allochblk</tt>. This uses roughly what Paul Wilson has termed
+a "next fit" algorithm, i.e. first-fit with a rotating pointer.
+The implementation does check for a better fitting immediately
+adjacent block, which gives it somewhat better fragmentation characteristics.
+I'm now convinced it should use a best fit algorithm. The actual
+implementation of <TT>GC_allochblk</tt>
+is significantly complicated by black-listing issues
+(see below).
+<P>
+Small blocks are allocated in blocks of size <TT>HBLKSIZE</tt>.
+Each block is
+dedicated to only one object size and kind. The allocator maintains
+separate free lists for each size and kind of object.
+<P>
+In order to avoid allocating blocks for too many distinct object sizes,
+the collector normally does not directly allocate objects of every possible
+request size. Instead request are rounded up to one of a smaller number
+of allocated sizes, for which free lists are maintained. The exact
+allocated sizes are computed on demand, but subject to the constraint
+that they increase roughly in geometric progression. Thus objects
+requested early in the execution are likely to be allocated with exactly
+the requested size, subject to alignment constraints.
+See <TT>GC_init_size_map</tt> for details.
+<P>
+The actual size rounding operation during small object allocation is
+implemented as a table lookup in <TT>GC_size_map</tt>.
+<P>
+Both collector initialization and computation of allocated sizes are
+handled carefully so that they do not slow down the small object fast
+allocation path. An attempt to allocate before the collector is initialized,
+or before the appropriate <TT>GC_size_map</tt> entry is computed,
+will take the same path as an allocation attempt with an empty free list.
+This results in a call to the slow path code (<TT>GC_generic_malloc_inner</tt>)
+which performs the appropriate initialization checks.
+<P>
+In non-incremental mode, we make a decision about whether to garbage collect
+whenever an allocation would otherwise have failed with the current heap size.
+If the total amount of allocation since the last collection is less than
+the heap size divided by <TT>GC_free_space_divisor</tt>, we try to
+expand the heap. Otherwise, we initiate a garbage collection. This ensures
+that the amount of garbage collection work per allocated byte remains
+constant.
+<P>
+The above is in fat an oversimplification of the real heap expansion
+heuristic, which adjusts slightly for root size and certain kinds of
+fragmentation. In particular, programs with a large root set size and
+little live heap memory will expand the heap to amortize the cost of
+scanning the roots.
+<P>
+Versions 5.x of the collector actually collect more frequently in
+nonincremental mode. The large block allocator usually refuses to split
+large heap blocks once the garbage collection threshold is
+reached. This often has the effect of collecting well before the
+heap fills up, thus reducing fragmentation and working set size at the
+expense of GC time. 6.x will chose an intermediate strategy depending
+on how much large object allocation has taken place in the past.
+(If the collector is configured to unmap unused pages, versions 6.x
+will use the 5.x strategy.)
+<P>
+(It has been suggested that this should be adjusted so that we favor
+expansion if the resulting heap still fits into physical memory.
+In many cases, that would no doubt help. But it is tricky to do this
+in a way that remains robust if multiple application are contending
+for a single pool of physical memory.)
+
+<H2>Mark phase</h2>
+
+The marker maintains an explicit stack of memory regions that are known
+to be accessible, but that have not yet been searched for contained pointers.
+Each stack entry contains the starting address of the block to be scanned,
+as well as a descriptor of the block. If no layout information is
+available for the block, then the descriptor is simply a length.
+(For other possibilities, see <TT>gc_mark.h</tt>.)
+<P>
+At the beginning of the mark phase, all root segments are pushed on the
+stack by <TT>GC_push_roots</tt>. If <TT>ALL_INTERIOR_PTRS</tt> is not
+defined, then stack roots require special treatment. In this case, the
+normal marking code ignores interior pointers, but <TT>GC_push_all_stack</tt>
+explicitly checks for interior pointers and pushes descriptors for target
+objects.
+<P>
+The marker is structured to allow incremental marking.
+Each call to <TT>GC_mark_some</tt> performs a small amount of
+work towards marking the heap.
+It maintains
+explicit state in the form of <TT>GC_mark_state</tt>, which
+identifies a particular sub-phase. Some other pieces of state, most
+notably the mark stack, identify how much work remains to be done
+in each sub-phase. The normal progression of mark states for
+a stop-the-world collection is:
+<OL>
+<LI> <TT>MS_INVALID</tt> indicating that there may be accessible unmarked
+objects. In this case <TT>GC_objects_are_marked</tt> will simultaneously
+be false, so the mark state is advanced to
+<LI> <TT>MS_PUSH_UNCOLLECTABLE</tt> indicating that it suffices to push
+uncollectable objects, roots, and then mark everything reachable from them.
+<TT>Scan_ptr</tt> is advanced through the heap until all uncollectable
+objects are pushed, and objects reachable from them are marked.
+At that point, the next call to <TT>GC_mark_some</tt> calls
+<TT>GC_push_roots</tt> to push the roots. It the advances the
+mark state to
+<LI> <TT>MS_ROOTS_PUSHED</tt> asserting that once the mark stack is
+empty, all reachable objects are marked. Once in this state, we work
+only on emptying the mark stack. Once this is completed, the state
+changes to
+<LI> <TT>MS_NONE</tt> indicating that reachable objects are marked.
+</ol>
+
+The core mark routine <TT>GC_mark_from_mark_stack</tt>, is called
+repeatedly by several of the sub-phases when the mark stack starts to fill
+up. It is also called repeatedly in <TT>MS_ROOTS_PUSHED</tt> state
+to empty the mark stack.
+The routine is designed to only perform a limited amount of marking at
+each call, so that it can also be used by the incremental collector.
+It is fairly carefully tuned, since it usually consumes a large majority
+of the garbage collection time.
+<P>
+The marker correctly handles mark stack overflows. Whenever the mark stack
+overflows, the mark state is reset to <TT>MS_INVALID</tt>.
+Since there are already marked objects in the heap,
+this eventually forces a complete
+scan of the heap, searching for pointers, during which any unmarked objects
+referenced by marked objects are again pushed on the mark stack. This
+process is repeated until the mark phase completes without a stack overflow.
+Each time the stack overflows, an attempt is made to grow the mark stack.
+All pieces of the collector that push regions onto the mark stack have to be
+careful to ensure forward progress, even in case of repeated mark stack
+overflows. Every mark attempt results in additional marked objects.
+<P>
+Each mark stack entry is processed by examining all candidate pointers
+in the range described by the entry. If the region has no associated
+type information, then this typically requires that each 4-byte aligned
+quantity (8-byte aligned with 64-bit pointers) be considered a candidate
+pointer.
+<P>
+We determine whether a candidate pointer is actually the address of
+a heap block. This is done in the following steps:
+<NL>
+<LI> The candidate pointer is checked against rough heap bounds.
+These heap bounds are maintained such that all actual heap objects
+fall between them. In order to facilitate black-listing (see below)
+we also include address regions that the heap is likely to expand into.
+Most non-pointers fail this initial test.
+<LI> The candidate pointer is divided into two pieces; the most significant
+bits identify a <TT>HBLKSIZE</tt>-sized page in the address space, and
+the least significant bits specify an offset within that page.
+(A hardware page may actually consist of multiple such pages.
+HBLKSIZE is usually the page size divided by a small power of two.)
+<LI>
+The page address part of the candidate pointer is looked up in a
+<A HREF="tree.html">table</a>.
+Each table entry contains either 0, indicating that the page is not part
+of the garbage collected heap, a small integer <I>n</i>, indicating
+that the page is part of large object, starting at least <I>n</i> pages
+back, or a pointer to a descriptor for the page. In the first case,
+the candidate pointer i not a true pointer and can be safely ignored.
+In the last two cases, we can obtain a descriptor for the page containing
+the beginning of the object.
+<LI>
+The starting address of the referenced object is computed.
+The page descriptor contains the size of the object(s)
+in that page, the object kind, and the necessary mark bits for those
+objects. The size information can be used to map the candidate pointer
+to the object starting address. To accelerate this process, the page header
+also contains a pointer to a precomputed map of page offsets to displacements
+from the beginning of an object. The use of this map avoids a
+potentially slow integer remainder operation in computing the object
+start address.
+<LI>
+The mark bit for the target object is checked and set. If the object
+was previously unmarked, the object is pushed on the mark stack.
+The descriptor is read from the page descriptor. (This is computed
+from information <TT>GC_obj_kinds</tt> when the page is first allocated.)
+</nl>
+<P>
+At the end of the mark phase, mark bits for left-over free lists are cleared,
+in case a free list was accidentally marked due to a stray pointer.
+
+<H2>Sweep phase</h2>
+
+At the end of the mark phase, all blocks in the heap are examined.
+Unmarked large objects are immediately returned to the large object free list.
+Each small object page is checked to see if all mark bits are clear.
+If so, the entire page is returned to the large object free list.
+Small object pages containing some reachable object are queued for later
+sweeping.
+<P>
+This initial sweep pass touches only block headers, not
+the blocks themselves. Thus it does not require significant paging, even
+if large sections of the heap are not in physical memory.
+<P>
+Nonempty small object pages are swept when an allocation attempt
+encounters an empty free list for that object size and kind.
+Pages for the correct size and kind are repeatedly swept until at
+least one empty block is found. Sweeping such a page involves
+scanning the mark bit array in the page header, and building a free
+list linked through the first words in the objects themselves.
+This does involve touching the appropriate data page, but in most cases
+it will be touched only just before it is used for allocation.
+Hence any paging is essentially unavoidable.
+<P>
+Except in the case of pointer-free objects, we maintain the invariant
+that any object in a small object free list is cleared (except possibly
+for the link field). Thus it becomes the burden of the small object
+sweep routine to clear objects. This has the advantage that we can
+easily recover from accidentally marking a free list, though that could
+also be handled by other means. The collector currently spends a fair
+amount of time clearing objects, and this approach should probably be
+revisited.
+<P>
+In most configurations, we use specialized sweep routines to handle common
+small object sizes. Since we allocate one mark bit per word, it becomes
+easier to examine the relevant mark bits if the object size divides
+the word length evenly. We also suitably unroll the inner sweep loop
+in each case. (It is conceivable that profile-based procedure cloning
+in the compiler could make this unnecessary and counterproductive. I
+know of no existing compiler to which this applies.)
+<P>
+The sweeping of small object pages could be avoided completely at the expense
+of examining mark bits directly in the allocator. This would probably
+be more expensive, since each allocation call would have to reload
+a large amount of state (e.g. next object address to be swept, position
+in mark bit table) before it could do its work. The current scheme
+keeps the allocator simple and allows useful optimizations in the sweeper.
+
+<H2>Finalization</h2>
+Both <TT>GC_register_disappearing_link</tt> and
+<TT>GC_register_finalizer</tt> add the request to a corresponding hash
+table. The hash table is allocated out of collected memory, but
+the reference to the finalizable object is hidden from the collector.
+Currently finalization requests are processed non-incrementally at the
+end of a mark cycle.
+<P>
+The collector makes an initial pass over the table of finalizable objects,
+pushing the contents of unmarked objects onto the mark stack.
+After pushing each object, the marker is invoked to mark all objects
+reachable from it. The object itself is not explicitly marked.
+This assures that objects on which a finalizer depends are neither
+collected nor finalized.
+<P>
+If in the process of marking from an object the
+object itself becomes marked, we have uncovered
+a cycle involving the object. This usually results in a warning from the
+collector. Such objects are not finalized, since it may be
+unsafe to do so. See the more detailed
+<A HREF="finalization.html"> discussion of finalization semantics</a>.
+<P>
+Any objects remaining unmarked at the end of this process are added to
+a queue of objects whose finalizers can be run. Depending on collector
+configuration, finalizers are dequeued and run either implicitly during
+allocation calls, or explicitly in response to a user request.
+<P>
+The collector provides a mechanism for replacing the procedure that is
+used to mark through objects. This is used both to provide support for
+Java-style unordered finalization, and to ignore certain kinds of cycles,
+<I>e.g.</i> those arising from C++ implementations of virtual inheritance.
+
+<H2>Generational Collection and Dirty Bits</h2>
+We basically use the parallel and generational GC algorithm described in
+<A HREF="papers/pldi91.ps.gz">"Mostly Parallel Garbage Collection"</a>,
+by Boehm, Demers, and Shenker.
+<P>
+The most significant modification is that
+the collector always runs in the allocating thread.
+There is no separate garbage collector thread.
+If an allocation attempt either requests a large object, or encounters
+an empty small object free list, and notices that there is a collection
+in progress, it immediately performs a small amount of marking work
+as described above.
+<P>
+This change was made both because we wanted to easily accommodate
+single-threaded environments, and because a separate GC thread requires
+very careful control over the scheduler to prevent the mutator from
+out-running the collector, and hence provoking unneeded heap growth.
+<P>
+In incremental mode, the heap is always expanded when we encounter
+insufficient space for an allocation. Garbage collection is triggered
+whenever we notice that more than
+<TT>GC_heap_size</tt>/2 * <TT>GC_free_space_divisor</tt>
+bytes of allocation have taken place.
+After <TT>GC_full_freq</tt> minor collections a major collection
+is started.
+<P>
+All collections initially run interrupted until a predetermined
+amount of time (50 msecs by default) has expired. If this allows
+the collection to complete entirely, we can avoid correcting
+for data structure modifications during the collection. If it does
+not complete, we return control to the mutator, and perform small
+amounts of additional GC work during those later allocations that
+cannot be satisfied from small object free lists. When marking completes,
+the set of modified pages is retrieved, and we mark once again from
+marked objects on those pages, this time with the mutator stopped.
+<P>
+We keep track of modified pages using one of three distinct mechanisms:
+<OL>
+<LI>
+Through explicit mutator cooperation. Currently this requires
+the use of <TT>GC_malloc_stubborn</tt>.
+<LI>
+By write-protecting physical pages and catching write faults. This is
+implemented for many Unix-like systems and for win32. It is not possible
+in a few environments.
+<LI>
+By retrieving dirty bit information from /proc. (Currently only Sun's
+Solaris supports this. Though this is considerably cleaner, performance
+may actually be better with mprotect and signals.)
+</ol>
+
+<H2>Thread support</h2>
+We support several different threading models. Unfortunately Pthreads,
+the only reasonably well standardized thread model, supports too narrow
+an interface for conservative garbage collection. There appears to be
+no portable way to allow the collector to coexist with various Pthreads
+implementations. Hence we currently support only a few of the more
+common Pthreads implementations.
+<P>
+In particular, it is very difficult for the collector to stop all other
+threads in the system and examine the register contents. This is currently
+accomplished with very different mechanisms for different Pthreads
+implementations. The Solaris implementation temporarily disables much
+of the user-level threads implementation by stopping kernel-level threads
+("lwp"s). The Irix implementation sends signals to individual Pthreads
+and has them wait in the signal handler. The Linux implementation
+is similar in spirit to the Irix one.
+<P>
+The Irix implementation uses
+only documented Pthreads calls, but relies on extensions to their semantics,
+notably the use of mutexes and condition variables from signal
+handlers. The Linux implementation should be far closer to
+portable, though impirically it is not completely portable.
+<P>
+All implementations must
+intercept thread creation and a few other thread-specific calls to allow
+enumeration of threads and location of thread stacks. This is current
+accomplished with <TT># define</tt>'s in <TT>gc.h</tt>, or optionally
+by using ld's function call wrapping mechanism under Linux.
+<P>
+Comments are appreciated. Please send mail to
+<A HREF="mailto:boehm@acm.org"><TT>boehm@acm.org</tt></a>
+</body>
diff --git a/gc/doc/tree.html b/gc/doc/tree.html
new file mode 100644
index 0000000..89c515d
--- /dev/null
+++ b/gc/doc/tree.html
@@ -0,0 +1,198 @@
+<HTML>
+<HEAD>
+ <TITLE> Two-Level Tree Structure for Fast Pointer Lookup</TITLE>
+ <AUTHOR> Hans-J. Boehm, Silicon Graphics</author>
+</HEAD>
+<BODY>
+<H1>Two-Level Tree Structure for Fast Pointer Lookup</h1>
+<P>
+The conservative garbage collector described
+<A HREF="gc.html">here</a> uses a 2-level tree
+data structure to aid in fast pointer identification.
+This data structure is described in a bit more detail here, since
+<OL>
+<LI> Variations of the data structure are more generally useful.
+<LI> It appears to be hard to understand by reading the code.
+<LI> Some other collectors appear to use inferior data structures to
+solve the same problem.
+<LI> It is central to fast collector operation.
+</ol>
+A candidate pointer is divided into three sections, the <I>high</i>,
+<I>middle</i>, and <I>low</i> bits. The exact division between these
+three groups of bits is dependent on the detailed collector configuration.
+<P>
+The high and middle bits are used to look up an entry in the table described
+here. The resulting table entry consists of either a block descriptor
+(<TT>struct hblkhdr *</tt> or <TT>hdr *</tt>)
+identifying the layout of objects in the block, or an indication that this
+address range corresponds to the middle of a large block, together with a
+hint for locating the actual block descriptor. Such a hint consist
+of a displacement that can be subtracted from the middle bits of the candidate
+pointer without leaving the object.
+<P>
+In either case, the block descriptor (<TT>struct hblkhdr</tt>)
+refers to a table of object starting addresses (the <TT>hb_map</tt> field).
+The starting address table is indexed by the low bits if the candidate pointer.
+The resulting entry contains a displacement to the beginning of the object,
+or an indication that this cannot be a valid object pointer.
+(If all interior pointer are recognized, pointers into large objects
+are handled specially, as appropriate.)
+
+<H2>The Tree</h2>
+<P>
+The rest of this discussion focuses on the two level data structure
+used to map the high and middle bits to the block descriptor.
+<P>
+The high bits are used as an index into the <TT>GC_top_index</tt> (really
+<TT>GC_arrays._top_index</tt>) array. Each entry points to a
+<TT>bottom_index</tt> data structure. This structure in turn consists
+mostly of an array <TT>index</tt> indexed by the middle bits of
+the candidate pointer. The <TT>index</tt> array contains the actual
+<TT>hdr</tt> pointers.
+<P>
+Thus a pointer lookup consists primarily of a handful of memory references,
+and can be quite fast:
+<OL>
+<LI> The appropriate <TT>bottom_index</tt> pointer is looked up in
+<TT>GC_top_index</tt>, based on the high bits of the candidate pointer.
+<LI> The appropriate <TT>hdr</tt> pointer is looked up in the
+<TT>bottom_index</tt> structure, based on the middle bits.
+<LI> The block layout map pointer is retrieved from the <TT>hdr</tt>
+structure. (This memory reference is necessary since we try to share
+block layout maps.)
+<LI> The displacement to the beginning of the object is retrieved from the
+above map.
+</ol>
+<P>
+In order to conserve space, not all <TT>GC_top_index</tt> entries in fact
+point to distinct <TT>bottom_index</tt> structures. If no address with
+the corresponding high bits is part of the heap, then the entry points
+to <TT>GC_all_nils</tt>, a single <TT>bottom_index</tt> structure consisting
+only of NULL <TT>hdr</tt> pointers.
+<P>
+<TT>Bottom_index</tt> structures contain slightly more information than
+just <TT>hdr</tt> pointers. The <TT>asc_link</tt> field is used to link
+all <TT>bottom_index</tt> structures in ascending order for fast traversal.
+This list is pointed to be <TT>GC_all_bottom_indices</tt>.
+It is maintained with the aid of <TT>key</tt> field that contains the
+high bits corresponding to the <TT>bottom_index</tt>.
+
+<H2>64 bit addresses</h2>
+<P>
+In the case of 64 bit addresses, this picture is complicated slightly
+by the fact that one of the index structures would have to be huge to
+cover the entire address space with a two level tree. We deal with this
+by turning <TT>GC_top_index</tt> into a chained hash table, instead of
+a simple array. This adds a <TT>hash_link</tt> field to the
+<TT>bottom_index</tt> structure.
+<P>
+The "hash function" consists of dropping the high bits. This is cheap to
+compute, and guarantees that there will be no collisions if the heap
+is contiguous and not excessively large.
+
+<H2>A picture</h2>
+<P>
+The following is an ASCII diagram of the data structure.
+This was contributed by Dave Barrett several years ago.
+<PRE>
+
+ Data Structure used by GC_base in gc3.7:
+ 21-Apr-94
+
+
+
+
+ 63 LOG_TOP_SZ[11] LOG_BOTTOM_SZ[10] LOG_HBLKSIZE[13]
+ +------------------+----------------+------------------+------------------+
+ p:| | TL_HASH(hi) | | HBLKDISPL(p) |
+ +------------------+----------------+------------------+------------------+
+ \-----------------------HBLKPTR(p)-------------------/
+ \------------hi-------------------/
+ \______ ________/ \________ _______/ \________ _______/
+ V V V
+ | | |
+ GC_top_index[] | | |
+ --- +--------------+ | | |
+ ^ | | | | |
+ | | | | | |
+ TOP +--------------+<--+ | |
+ _SZ +-<| [] | * | |
+(items)| +--------------+ if 0 < bi< HBLKSIZE | |
+ | | | | then large object | |
+ | | | | starts at the bi'th | |
+ v | | | HBLK before p. | i |
+ --- | +--------------+ | (word- |
+ v | aligned) |
+ bi= |GET_BI(p){->hash_link}->key==hi | |
+ v | |
+ | (bottom_index) \ scratch_alloc'd | |
+ | ( struct bi ) / by get_index() | |
+ --- +->+--------------+ | |
+ ^ | | | |
+ ^ | | | |
+ BOTTOM | | ha=GET_HDR_ADDR(p) | |
+_SZ(items)+--------------+<----------------------+ +-------+
+ | +--<| index[] | |
+ | | +--------------+ GC_obj_map: v
+ | | | | from / +-+-+-----+-+-+-+-+ ---
+ v | | | GC_add < 0| | | | | | | | ^
+ --- | +--------------+ _map_entry \ +-+-+-----+-+-+-+-+ |
+ | | asc_link | +-+-+-----+-+-+-+-+ MAXOBJSZ
+ | +--------------+ +-->| | | j | | | | | +1
+ | | key | | +-+-+-----+-+-+-+-+ |
+ | +--------------+ | +-+-+-----+-+-+-+-+ |
+ | | hash_link | | | | | | | | | | v
+ | +--------------+ | +-+-+-----+-+-+-+-+ ---
+ | | |<--MAX_OFFSET--->|
+ | | (bytes)
+HDR(p)| GC_find_header(p) | |<--MAP_ENTRIES-->|
+ | \ from | =HBLKSIZE/WORDSZ
+ | (hdr) (struct hblkhdr) / alloc_hdr() | (1024 on Alpha)
+ +-->+----------------------+ | (8/16 bits each)
+GET_HDR(p)| word hb_sz (words) | |
+ +----------------------+ |
+ | struct hblk *hb_next | |
+ +----------------------+ |
+ |mark_proc hb_mark_proc| |
+ +----------------------+ |
+ | char * hb_map |>-------------+
+ +----------------------+
+ | ushort hb_obj_kind |
+ +----------------------+
+ | hb_last_reclaimed |
+ --- +----------------------+
+ ^ | |
+ MARK_BITS| hb_marks[] | *if hdr is free, hb_sz + DISCARD_WORDS
+_SZ(words)| | is the size of a heap chunk (struct hblk)
+ v | | of at least MININCR*HBLKSIZE bytes (below),
+ --- +----------------------+ otherwise, size of each object in chunk.
+
+Dynamic data structures above are interleaved throughout the heap in blocks of
+size MININCR * HBLKSIZE bytes as done by gc_scratch_alloc which cannot be
+freed; free lists are used (e.g. alloc_hdr). HBLK's below are collected.
+
+ (struct hblk)
+ --- +----------------------+ < HBLKSIZE --- --- DISCARD_
+ ^ |garbage[DISCARD_WORDS]| aligned ^ ^ HDR_BYTES WORDS
+ | | | | v (bytes) (words)
+ | +-----hb_body----------+ < WORDSZ | --- ---
+ | | | aligned | ^ ^
+ | | Object 0 | | hb_sz |
+ | | | i |(word- (words)|
+ | | | (bytes)|aligned) v |
+ | + - - - - - - - - - - -+ --- | --- |
+ | | | ^ | ^ |
+ n * | | j (words) | hb_sz BODY_SZ
+ HBLKSIZE | Object 1 | v v | (words)
+ (bytes) | |--------------- v MAX_OFFSET
+ | + - - - - - - - - - - -+ --- (bytes)
+ | | | !All_INTERIOR_PTRS ^ |
+ | | | sets j only for hb_sz |
+ | | Object N | valid object offsets. | |
+ v | | All objects WORDSZ v v
+ --- +----------------------+ aligned. --- ---
+
+DISCARD_WORDS is normally zero. Indeed the collector has not been tested
+with another value in ages.
+</pre>
+</body>
diff --git a/gc/solaris_pthreads.c b/gc/solaris_pthreads.c
index 8470eaf..48dd193 100644
--- a/gc/solaris_pthreads.c
+++ b/gc/solaris_pthreads.c
@@ -16,7 +16,7 @@
* Modified Peter C. for Solaris Posix Threads.
*/
/* Boehm, September 14, 1994 4:44 pm PDT */
-/* $Id: solaris_pthreads.c,v 1.2 2001/11/09 04:59:18 a-ito Exp $ */
+/* $Id: solaris_pthreads.c,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */
# if defined(GC_SOLARIS_PTHREADS) || defined(_SOLARIS_PTHREADS)
# include "private/gc_priv.h"
diff --git a/gc/tests/leak_test.c b/gc/tests/leak_test.c
new file mode 100644
index 0000000..421d0c6
--- /dev/null
+++ b/gc/tests/leak_test.c
@@ -0,0 +1,21 @@
+#include "leak_detector.h"
+
+main() {
+ int *p[10];
+ int i;
+ GC_find_leak = 1; /* for new collect versions not compiled */
+ /* with -DFIND_LEAK. */
+ for (i = 0; i < 10; ++i) {
+ p[i] = malloc(sizeof(int)+i);
+ }
+ CHECK_LEAKS();
+ for (i = 1; i < 10; ++i) {
+ free(p[i]);
+ }
+ for (i = 0; i < 9; ++i) {
+ p[i] = malloc(sizeof(int)+i);
+ }
+ CHECK_LEAKS();
+ CHECK_LEAKS();
+ CHECK_LEAKS();
+}
diff --git a/gc/tests/test.c b/gc/tests/test.c
new file mode 100644
index 0000000..1bd98d6
--- /dev/null
+++ b/gc/tests/test.c
@@ -0,0 +1,1660 @@
+/*
+ * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
+ * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved.
+ * Copyright (c) 1996 by Silicon Graphics. All rights reserved.
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program
+ * for any purpose, provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is granted,
+ * provided the above notices are retained, and a notice that the code was
+ * modified is included with the above copyright notice.
+ */
+/* An incomplete test for the garbage collector. */
+/* Some more obscure entry points are not tested at all. */
+/* This must be compiled with the same flags used to build the */
+/* GC. It uses GC internals to allow more precise results */
+/* checking for some of the tests. */
+
+# undef GC_BUILD
+
+#ifdef DBG_HDRS_ALL
+# define GC_DEBUG
+#endif
+
+# if defined(mips) && defined(SYSTYPE_BSD43)
+ /* MIPS RISCOS 4 */
+# else
+# include <stdlib.h>
+# endif
+# include <stdio.h>
+# ifdef _WIN32_WCE
+# include <winbase.h>
+# define assert ASSERT
+# else
+# include <assert.h> /* Not normally used, but handy for debugging. */
+# endif
+# include <assert.h> /* Not normally used, but handy for debugging. */
+# include "gc.h"
+# include "gc_typed.h"
+# ifdef THREAD_LOCAL_ALLOC
+# include "gc_local_alloc.h"
+# endif
+# include "private/gc_priv.h" /* For output, locking, MIN_WORDS, */
+ /* and some statistics. */
+# include "private/gcconfig.h"
+
+# if defined(MSWIN32) || defined(MSWINCE)
+# include <windows.h>
+# endif
+
+# ifdef PCR
+# include "th/PCR_ThCrSec.h"
+# include "th/PCR_Th.h"
+# undef GC_printf0
+# define GC_printf0 printf
+# undef GC_printf1
+# define GC_printf1 printf
+# endif
+
+# ifdef SOLARIS_THREADS
+# include <thread.h>
+# include <synch.h>
+# endif
+
+# if defined(IRIX_THREADS) || defined(LINUX_THREADS) || defined(HPUX_THREADS)
+# include <pthread.h>
+# endif
+
+# ifdef WIN32_THREADS
+# ifndef MSWINCE
+# include <process.h>
+# define GC_CreateThread(a,b,c,d,e,f) ((HANDLE) _beginthreadex(a,b,c,d,e,f))
+# endif
+ static CRITICAL_SECTION incr_cs;
+# endif
+
+
+/* Allocation Statistics */
+int stubborn_count = 0;
+int uncollectable_count = 0;
+int collectable_count = 0;
+int atomic_count = 0;
+int realloc_count = 0;
+
+#if defined(GC_AMIGA_FASTALLOC) && defined(AMIGA)
+
+ extern void GC_amiga_free_all_mem(void);
+ void Amiga_Fail(void){GC_amiga_free_all_mem();abort();}
+# define FAIL (void)Amiga_Fail()
+ void *GC_amiga_gctest_malloc_explicitly_typed(size_t lb, GC_descr d){
+ void *ret=GC_malloc_explicitly_typed(lb,d);
+ if(ret==NULL){
+ if(!GC_dont_gc){
+ GC_gcollect();
+ ret=GC_malloc_explicitly_typed(lb,d);
+ }
+ if(ret==NULL){
+ GC_printf0("Out of memory, (typed allocations are not directly "
+ "supported with the GC_AMIGA_FASTALLOC option.)\n");
+ FAIL;
+ }
+ }
+ return ret;
+ }
+ void *GC_amiga_gctest_calloc_explicitly_typed(size_t a,size_t lb, GC_descr d){
+ void *ret=GC_calloc_explicitly_typed(a,lb,d);
+ if(ret==NULL){
+ if(!GC_dont_gc){
+ GC_gcollect();
+ ret=GC_calloc_explicitly_typed(a,lb,d);
+ }
+ if(ret==NULL){
+ GC_printf0("Out of memory, (typed allocations are not directly "
+ "supported with the GC_AMIGA_FASTALLOC option.)\n");
+ FAIL;
+ }
+ }
+ return ret;
+ }
+# define GC_malloc_explicitly_typed(a,b) GC_amiga_gctest_malloc_explicitly_typed(a,b)
+# define GC_calloc_explicitly_typed(a,b,c) GC_amiga_gctest_calloc_explicitly_typed(a,b,c)
+
+#else /* !AMIGA_FASTALLOC */
+
+# ifdef PCR
+# define FAIL (void)abort()
+# else
+# ifdef MSWINCE
+# define FAIL DebugBreak()
+# else
+# define FAIL GC_abort("Test failed");
+# endif
+# endif
+
+#endif /* !AMIGA_FASTALLOC */
+
+/* AT_END may be defined to exercise the interior pointer test */
+/* if the collector is configured with ALL_INTERIOR_POINTERS. */
+/* As it stands, this test should succeed with either */
+/* configuration. In the FIND_LEAK configuration, it should */
+/* find lots of leaks, since we free almost nothing. */
+
+struct SEXPR {
+ struct SEXPR * sexpr_car;
+ struct SEXPR * sexpr_cdr;
+};
+
+
+typedef struct SEXPR * sexpr;
+
+# define INT_TO_SEXPR(x) ((sexpr)(unsigned long)(x))
+
+# undef nil
+# define nil (INT_TO_SEXPR(0))
+# define car(x) ((x) -> sexpr_car)
+# define cdr(x) ((x) -> sexpr_cdr)
+# define is_nil(x) ((x) == nil)
+
+
+int extra_count = 0; /* Amount of space wasted in cons node */
+
+/* Silly implementation of Lisp cons. Intentionally wastes lots of space */
+/* to test collector. */
+# ifdef VERY_SMALL_CONFIG
+# define cons small_cons
+# else
+sexpr cons (x, y)
+sexpr x;
+sexpr y;
+{
+ register sexpr r;
+ register int *p;
+ register int my_extra = extra_count;
+
+ stubborn_count++;
+ r = (sexpr) GC_MALLOC_STUBBORN(sizeof(struct SEXPR) + my_extra);
+ if (r == 0) {
+ (void)GC_printf0("Out of memory\n");
+ exit(1);
+ }
+ for (p = (int *)r;
+ ((char *)p) < ((char *)r) + my_extra + sizeof(struct SEXPR); p++) {
+ if (*p) {
+ (void)GC_printf1("Found nonzero at 0x%lx - allocator is broken\n",
+ (unsigned long)p);
+ FAIL;
+ }
+ *p = 13;
+ }
+# ifdef AT_END
+ r = (sexpr)((char *)r + (my_extra & ~7));
+# endif
+ r -> sexpr_car = x;
+ r -> sexpr_cdr = y;
+ my_extra++;
+ if ( my_extra >= 5000 ) {
+ extra_count = 0;
+ } else {
+ extra_count = my_extra;
+ }
+ GC_END_STUBBORN_CHANGE((char *)r);
+ return(r);
+}
+# endif
+
+sexpr small_cons (x, y)
+sexpr x;
+sexpr y;
+{
+ register sexpr r;
+
+ collectable_count++;
+ r = (sexpr) GC_MALLOC(sizeof(struct SEXPR));
+ if (r == 0) {
+ (void)GC_printf0("Out of memory\n");
+ exit(1);
+ }
+ r -> sexpr_car = x;
+ r -> sexpr_cdr = y;
+ return(r);
+}
+
+sexpr small_cons_uncollectable (x, y)
+sexpr x;
+sexpr y;
+{
+ register sexpr r;
+
+ uncollectable_count++;
+ r = (sexpr) GC_MALLOC_UNCOLLECTABLE(sizeof(struct SEXPR));
+ if (r == 0) {
+ (void)GC_printf0("Out of memory\n");
+ exit(1);
+ }
+ r -> sexpr_car = x;
+ r -> sexpr_cdr = (sexpr)(~(unsigned long)y);
+ return(r);
+}
+
+#ifdef GC_GCJ_SUPPORT
+
+#include "gc_mark.h"
+#include "private/dbg_mlc.h" /* For USR_PTR_FROM_BASE */
+#include "gc_gcj.h"
+
+/* The following struct emulates the vtable in gcj. */
+/* This assumes the default value of MARK_DESCR_OFFSET. */
+struct fake_vtable {
+ void * dummy; /* class pointer in real gcj. */
+ size_t descr;
+};
+
+struct fake_vtable gcj_class_struct1 = { 0, sizeof(struct SEXPR)
+ + sizeof(struct fake_vtable *) };
+ /* length based descriptor. */
+struct fake_vtable gcj_class_struct2 =
+ { 0, (3l << (CPP_WORDSZ - 3)) | GC_DS_BITMAP};
+ /* Bitmap based descriptor. */
+
+struct GC_ms_entry * fake_gcj_mark_proc(word * addr,
+ struct GC_ms_entry *mark_stack_ptr,
+ struct GC_ms_entry *mark_stack_limit,
+ word env )
+{
+ sexpr x;
+ if (1 == env) {
+ /* Object allocated with debug allocator. */
+ addr = (word *)USR_PTR_FROM_BASE(addr);
+ }
+ x = (sexpr)(addr + 1); /* Skip the vtable pointer. */
+ mark_stack_ptr = GC_MARK_AND_PUSH(
+ (GC_PTR)(x -> sexpr_cdr), mark_stack_ptr,
+ mark_stack_limit, (GC_PTR *)&(x -> sexpr_cdr));
+ mark_stack_ptr = GC_MARK_AND_PUSH(
+ (GC_PTR)(x -> sexpr_car), mark_stack_ptr,
+ mark_stack_limit, (GC_PTR *)&(x -> sexpr_car));
+ return(mark_stack_ptr);
+}
+
+sexpr gcj_cons(x, y)
+sexpr x;
+sexpr y;
+{
+ GC_word * r;
+ sexpr result;
+ static int count = 0;
+
+ if (++count & 1) {
+# ifdef USE_MARK_BYTES
+ r = (GC_word *) GC_GCJ_FAST_MALLOC(4, &gcj_class_struct1);
+# else
+ r = (GC_word *) GC_GCJ_FAST_MALLOC(3, &gcj_class_struct1);
+# endif
+ } else {
+ r = (GC_word *) GC_GCJ_MALLOC(sizeof(struct SEXPR)
+ + sizeof(struct fake_vtable*),
+ &gcj_class_struct2);
+ }
+ if (r == 0) {
+ (void)GC_printf0("Out of memory\n");
+ exit(1);
+ }
+ result = (sexpr)(r + 1);
+ result -> sexpr_car = x;
+ result -> sexpr_cdr = y;
+ return(result);
+}
+#endif
+
+/* Return reverse(x) concatenated with y */
+sexpr reverse1(x, y)
+sexpr x, y;
+{
+ if (is_nil(x)) {
+ return(y);
+ } else {
+ return( reverse1(cdr(x), cons(car(x), y)) );
+ }
+}
+
+sexpr reverse(x)
+sexpr x;
+{
+ return( reverse1(x, nil) );
+}
+
+sexpr ints(low, up)
+int low, up;
+{
+ if (low > up) {
+ return(nil);
+ } else {
+ return(small_cons(small_cons(INT_TO_SEXPR(low), nil), ints(low+1, up)));
+ }
+}
+
+#ifdef GC_GCJ_SUPPORT
+/* Return reverse(x) concatenated with y */
+sexpr gcj_reverse1(x, y)
+sexpr x, y;
+{
+ if (is_nil(x)) {
+ return(y);
+ } else {
+ return( gcj_reverse1(cdr(x), gcj_cons(car(x), y)) );
+ }
+}
+
+sexpr gcj_reverse(x)
+sexpr x;
+{
+ return( gcj_reverse1(x, nil) );
+}
+
+sexpr gcj_ints(low, up)
+int low, up;
+{
+ if (low > up) {
+ return(nil);
+ } else {
+ return(gcj_cons(gcj_cons(INT_TO_SEXPR(low), nil), gcj_ints(low+1, up)));
+ }
+}
+#endif /* GC_GCJ_SUPPORT */
+
+/* To check uncollectable allocation we build lists with disguised cdr */
+/* pointers, and make sure they don't go away. */
+sexpr uncollectable_ints(low, up)
+int low, up;
+{
+ if (low > up) {
+ return(nil);
+ } else {
+ return(small_cons_uncollectable(small_cons(INT_TO_SEXPR(low), nil),
+ uncollectable_ints(low+1, up)));
+ }
+}
+
+void check_ints(list, low, up)
+sexpr list;
+int low, up;
+{
+ if ((int)(GC_word)(car(car(list))) != low) {
+ (void)GC_printf0(
+ "List reversal produced incorrect list - collector is broken\n");
+ FAIL;
+ }
+ if (low == up) {
+ if (cdr(list) != nil) {
+ (void)GC_printf0("List too long - collector is broken\n");
+ FAIL;
+ }
+ } else {
+ check_ints(cdr(list), low+1, up);
+ }
+}
+
+# define UNCOLLECTABLE_CDR(x) (sexpr)(~(unsigned long)(cdr(x)))
+
+void check_uncollectable_ints(list, low, up)
+sexpr list;
+int low, up;
+{
+ if ((int)(GC_word)(car(car(list))) != low) {
+ (void)GC_printf0(
+ "Uncollectable list corrupted - collector is broken\n");
+ FAIL;
+ }
+ if (low == up) {
+ if (UNCOLLECTABLE_CDR(list) != nil) {
+ (void)GC_printf0("Uncollectable list too long - collector is broken\n");
+ FAIL;
+ }
+ } else {
+ check_uncollectable_ints(UNCOLLECTABLE_CDR(list), low+1, up);
+ }
+}
+
+/* Not used, but useful for debugging: */
+void print_int_list(x)
+sexpr x;
+{
+ if (is_nil(x)) {
+ (void)GC_printf0("NIL\n");
+ } else {
+ (void)GC_printf1("(%ld)", (long)(car(car(x))));
+ if (!is_nil(cdr(x))) {
+ (void)GC_printf0(", ");
+ (void)print_int_list(cdr(x));
+ } else {
+ (void)GC_printf0("\n");
+ }
+ }
+}
+
+/* Try to force a to be strangely aligned */
+struct {
+ char dummy;
+ sexpr aa;
+} A;
+#define a A.aa
+
+/*
+ * A tiny list reversal test to check thread creation.
+ */
+#ifdef THREADS
+
+# ifdef WIN32_THREADS
+ unsigned __stdcall tiny_reverse_test(void * arg)
+# else
+ void * tiny_reverse_test(void * arg)
+# endif
+{
+ check_ints(reverse(reverse(ints(1,10))), 1, 10);
+ return 0;
+}
+
+# if defined(IRIX_THREADS) || defined(LINUX_THREADS) \
+ || defined(SOLARIS_PTHREADS) || defined(HPUX_THREADS)
+ void fork_a_thread()
+ {
+ pthread_t t;
+ int code;
+ if ((code = pthread_create(&t, 0, tiny_reverse_test, 0)) != 0) {
+ (void)GC_printf1("Small thread creation failed %lu\n",
+ (unsigned long)code);
+ FAIL;
+ }
+ if ((code = pthread_join(t, 0)) != 0) {
+ (void)GC_printf1("Small thread join failed %lu\n",
+ (unsigned long)code);
+ FAIL;
+ }
+ }
+
+# elif defined(WIN32_THREADS)
+ void fork_a_thread()
+ {
+ unsigned thread_id;
+ HANDLE h;
+ h = GC_CreateThread(NULL, 0, tiny_reverse_test, 0, 0, &thread_id);
+ if (h == (HANDLE)NULL) {
+ (void)GC_printf1("Small thread creation failed %lu\n",
+ (unsigned long)GetLastError());
+ FAIL;
+ }
+ if (WaitForSingleObject(h, INFINITE) != WAIT_OBJECT_0) {
+ (void)GC_printf1("Small thread wait failed %lu\n",
+ (unsigned long)GetLastError());
+ FAIL;
+ }
+ }
+
+/* # elif defined(SOLARIS_THREADS) */
+
+# else
+
+# define fork_a_thread()
+
+# endif
+
+#else
+
+# define fork_a_thread()
+
+#endif
+
+/*
+ * Repeatedly reverse lists built out of very different sized cons cells.
+ * Check that we didn't lose anything.
+ */
+void reverse_test()
+{
+ int i;
+ sexpr b;
+ sexpr c;
+ sexpr d;
+ sexpr e;
+ sexpr *f, *g, *h;
+# if defined(MSWIN32) || defined(MACOS)
+ /* Win32S only allows 128K stacks */
+# define BIG 1000
+# else
+# if defined PCR
+ /* PCR default stack is 100K. Stack frames are up to 120 bytes. */
+# define BIG 700
+# else
+# if defined MSWINCE
+ /* WinCE only allows 64K stacks */
+# define BIG 500
+# else
+# if defined(OSF1)
+ /* OSF has limited stack space by default, and large frames. */
+# define BIG 200
+# else
+# define BIG 4500
+# endif
+# endif
+# endif
+# endif
+
+ A.dummy = 17;
+ a = ints(1, 49);
+ b = ints(1, 50);
+ c = ints(1, BIG);
+ d = uncollectable_ints(1, 100);
+ e = uncollectable_ints(1, 1);
+ /* Check that realloc updates object descriptors correctly */
+ collectable_count++;
+ f = (sexpr *)GC_MALLOC(4 * sizeof(sexpr));
+ realloc_count++;
+ f = (sexpr *)GC_REALLOC((GC_PTR)f, 6 * sizeof(sexpr));
+ f[5] = ints(1,17);
+ collectable_count++;
+ g = (sexpr *)GC_MALLOC(513 * sizeof(sexpr));
+ realloc_count++;
+ g = (sexpr *)GC_REALLOC((GC_PTR)g, 800 * sizeof(sexpr));
+ g[799] = ints(1,18);
+ collectable_count++;
+ h = (sexpr *)GC_MALLOC(1025 * sizeof(sexpr));
+ realloc_count++;
+ h = (sexpr *)GC_REALLOC((GC_PTR)h, 2000 * sizeof(sexpr));
+# ifdef GC_GCJ_SUPPORT
+ h[1999] = gcj_ints(1,200);
+ h[1999] = gcj_reverse(h[1999]);
+# else
+ h[1999] = ints(1,200);
+# endif
+ /* Try to force some collections and reuse of small list elements */
+ for (i = 0; i < 10; i++) {
+ (void)ints(1, BIG);
+ }
+ /* Superficially test interior pointer recognition on stack */
+ c = (sexpr)((char *)c + sizeof(char *));
+ d = (sexpr)((char *)d + sizeof(char *));
+
+# ifdef __STDC__
+ GC_FREE((void *)e);
+# else
+ GC_FREE((char *)e);
+# endif
+ check_ints(b,1,50);
+ check_ints(a,1,49);
+ for (i = 0; i < 50; i++) {
+ check_ints(b,1,50);
+ b = reverse(reverse(b));
+ }
+ check_ints(b,1,50);
+ check_ints(a,1,49);
+ for (i = 0; i < 60; i++) {
+ if (i % 10 == 0) fork_a_thread();
+ /* This maintains the invariant that a always points to a list of */
+ /* 49 integers. Thus this is thread safe without locks, */
+ /* assuming atomic pointer assignments. */
+ a = reverse(reverse(a));
+# if !defined(AT_END) && !defined(THREADS)
+ /* This is not thread safe, since realloc explicitly deallocates */
+ if (i & 1) {
+ a = (sexpr)GC_REALLOC((GC_PTR)a, 500);
+ } else {
+ a = (sexpr)GC_REALLOC((GC_PTR)a, 8200);
+ }
+# endif
+ }
+ check_ints(a,1,49);
+ check_ints(b,1,50);
+ c = (sexpr)((char *)c - sizeof(char *));
+ d = (sexpr)((char *)d - sizeof(char *));
+ check_ints(c,1,BIG);
+ check_uncollectable_ints(d, 1, 100);
+ check_ints(f[5], 1,17);
+ check_ints(g[799], 1,18);
+# ifdef GC_GCJ_SUPPORT
+ h[1999] = gcj_reverse(h[1999]);
+# endif
+ check_ints(h[1999], 1,200);
+# ifndef THREADS
+ a = 0;
+# endif
+ b = c = 0;
+}
+
+/*
+ * The rest of this builds balanced binary trees, checks that they don't
+ * disappear, and tests finalization.
+ */
+typedef struct treenode {
+ int level;
+ struct treenode * lchild;
+ struct treenode * rchild;
+} tn;
+
+int finalizable_count = 0;
+int finalized_count = 0;
+VOLATILE int dropped_something = 0;
+
+# ifdef __STDC__
+ void finalizer(void * obj, void * client_data)
+# else
+ void finalizer(obj, client_data)
+ char * obj;
+ char * client_data;
+# endif
+{
+ tn * t = (tn *)obj;
+
+# ifdef PCR
+ PCR_ThCrSec_EnterSys();
+# endif
+# ifdef SOLARIS_THREADS
+ static mutex_t incr_lock;
+ mutex_lock(&incr_lock);
+# endif
+# if defined(IRIX_THREADS) || defined(LINUX_THREADS) || defined(HPUX_THREADS)
+ static pthread_mutex_t incr_lock = PTHREAD_MUTEX_INITIALIZER;
+ pthread_mutex_lock(&incr_lock);
+# endif
+# ifdef WIN32_THREADS
+ EnterCriticalSection(&incr_cs);
+# endif
+ if ((int)(GC_word)client_data != t -> level) {
+ (void)GC_printf0("Wrong finalization data - collector is broken\n");
+ FAIL;
+ }
+ finalized_count++;
+# ifdef PCR
+ PCR_ThCrSec_ExitSys();
+# endif
+# ifdef SOLARIS_THREADS
+ mutex_unlock(&incr_lock);
+# endif
+# if defined(IRIX_THREADS) || defined(LINUX_THREADS) || defined(HPUX_THREADS)
+ pthread_mutex_unlock(&incr_lock);
+# endif
+# ifdef WIN32_THREADS
+ LeaveCriticalSection(&incr_cs);
+# endif
+}
+
+size_t counter = 0;
+
+# define MAX_FINALIZED 8000
+
+# if !defined(MACOS)
+ GC_FAR GC_word live_indicators[MAX_FINALIZED] = {0};
+#else
+ /* Too big for THINK_C. have to allocate it dynamically. */
+ GC_word *live_indicators = 0;
+#endif
+
+int live_indicators_count = 0;
+
+tn * mktree(n)
+int n;
+{
+# ifdef THREAD_LOCAL_ALLOC
+ tn * result = (tn *)GC_LOCAL_MALLOC(sizeof(tn));
+# else
+ tn * result = (tn *)GC_MALLOC(sizeof(tn));
+# endif
+
+ collectable_count++;
+# ifdef THREAD_LOCAL_ALLOC
+ /* Minimally exercise thread local allocation */
+ {
+ char * result = (char *)GC_LOCAL_MALLOC_ATOMIC(17);
+ memset(result, 'a', 17);
+ }
+# endif /* THREAD_LOCAL_ALLOC */
+# if defined(MACOS)
+ /* get around static data limitations. */
+ if (!live_indicators)
+ live_indicators =
+ (GC_word*)NewPtrClear(MAX_FINALIZED * sizeof(GC_word));
+ if (!live_indicators) {
+ (void)GC_printf0("Out of memory\n");
+ exit(1);
+ }
+# endif
+ if (n == 0) return(0);
+ if (result == 0) {
+ (void)GC_printf0("Out of memory\n");
+ exit(1);
+ }
+ result -> level = n;
+ result -> lchild = mktree(n-1);
+ result -> rchild = mktree(n-1);
+ if (counter++ % 17 == 0 && n >= 2) {
+ tn * tmp = result -> lchild -> rchild;
+
+ result -> lchild -> rchild = result -> rchild -> lchild;
+ result -> rchild -> lchild = tmp;
+ }
+ if (counter++ % 119 == 0) {
+ int my_index;
+
+ {
+# ifdef PCR
+ PCR_ThCrSec_EnterSys();
+# endif
+# ifdef SOLARIS_THREADS
+ static mutex_t incr_lock;
+ mutex_lock(&incr_lock);
+# endif
+# if defined(IRIX_THREADS) || defined(LINUX_THREADS) \
+ || defined(HPUX_THREADS)
+ static pthread_mutex_t incr_lock = PTHREAD_MUTEX_INITIALIZER;
+ pthread_mutex_lock(&incr_lock);
+# endif
+# ifdef WIN32_THREADS
+ EnterCriticalSection(&incr_cs);
+# endif
+ /* Losing a count here causes erroneous report of failure. */
+ finalizable_count++;
+ my_index = live_indicators_count++;
+# ifdef PCR
+ PCR_ThCrSec_ExitSys();
+# endif
+# ifdef SOLARIS_THREADS
+ mutex_unlock(&incr_lock);
+# endif
+# if defined(IRIX_THREADS) || defined(LINUX_THREADS) \
+ || defined(HPUX_THREADS)
+ pthread_mutex_unlock(&incr_lock);
+# endif
+# ifdef WIN32_THREADS
+ LeaveCriticalSection(&incr_cs);
+# endif
+ }
+
+ GC_REGISTER_FINALIZER((GC_PTR)result, finalizer, (GC_PTR)(GC_word)n,
+ (GC_finalization_proc *)0, (GC_PTR *)0);
+ if (my_index >= MAX_FINALIZED) {
+ GC_printf0("live_indicators overflowed\n");
+ FAIL;
+ }
+ live_indicators[my_index] = 13;
+ if (GC_GENERAL_REGISTER_DISAPPEARING_LINK(
+ (GC_PTR *)(&(live_indicators[my_index])),
+ (GC_PTR)result) != 0) {
+ GC_printf0("GC_general_register_disappearing_link failed\n");
+ FAIL;
+ }
+ if (GC_unregister_disappearing_link(
+ (GC_PTR *)
+ (&(live_indicators[my_index]))) == 0) {
+ GC_printf0("GC_unregister_disappearing_link failed\n");
+ FAIL;
+ }
+ if (GC_GENERAL_REGISTER_DISAPPEARING_LINK(
+ (GC_PTR *)(&(live_indicators[my_index])),
+ (GC_PTR)result) != 0) {
+ GC_printf0("GC_general_register_disappearing_link failed 2\n");
+ FAIL;
+ }
+ }
+ return(result);
+}
+
+void chktree(t,n)
+tn *t;
+int n;
+{
+ if (n == 0 && t != 0) {
+ (void)GC_printf0("Clobbered a leaf - collector is broken\n");
+ FAIL;
+ }
+ if (n == 0) return;
+ if (t -> level != n) {
+ (void)GC_printf1("Lost a node at level %lu - collector is broken\n",
+ (unsigned long)n);
+ FAIL;
+ }
+ if (counter++ % 373 == 0) {
+ collectable_count++;
+ (void) GC_MALLOC(counter%5001);
+ }
+ chktree(t -> lchild, n-1);
+ if (counter++ % 73 == 0) {
+ collectable_count++;
+ (void) GC_MALLOC(counter%373);
+ }
+ chktree(t -> rchild, n-1);
+}
+
+# if defined(SOLARIS_THREADS) && !defined(_SOLARIS_PTHREADS)
+thread_key_t fl_key;
+
+void * alloc8bytes()
+{
+# if defined(SMALL_CONFIG) || defined(GC_DEBUG)
+ collectable_count++;
+ return(GC_MALLOC(8));
+# else
+ void ** my_free_list_ptr;
+ void * my_free_list;
+
+ if (thr_getspecific(fl_key, (void **)(&my_free_list_ptr)) != 0) {
+ (void)GC_printf0("thr_getspecific failed\n");
+ FAIL;
+ }
+ if (my_free_list_ptr == 0) {
+ uncollectable_count++;
+ my_free_list_ptr = GC_NEW_UNCOLLECTABLE(void *);
+ if (thr_setspecific(fl_key, my_free_list_ptr) != 0) {
+ (void)GC_printf0("thr_setspecific failed\n");
+ FAIL;
+ }
+ }
+ my_free_list = *my_free_list_ptr;
+ if (my_free_list == 0) {
+ collectable_count++;
+ my_free_list = GC_malloc_many(8);
+ if (my_free_list == 0) {
+ (void)GC_printf0("alloc8bytes out of memory\n");
+ FAIL;
+ }
+ }
+ *my_free_list_ptr = GC_NEXT(my_free_list);
+ GC_NEXT(my_free_list) = 0;
+ return(my_free_list);
+# endif
+}
+
+#else
+
+# if defined(GC_SOLARIS_PTHREADS) || defined(GC_IRIX_THREADS) \
+ || defined(GC_LINUX_THREADS) || defined(GC_HPUX_THREADS) \
+ || defined(GC_SOLARIS_THREADS)
+pthread_key_t fl_key;
+
+void * alloc8bytes()
+{
+# if defined(SMALL_CONFIG) || defined(GC_DEBUG)
+ collectable_count++;
+ return(GC_MALLOC(8));
+# else
+ void ** my_free_list_ptr;
+ void * my_free_list;
+
+ my_free_list_ptr = (void **)pthread_getspecific(fl_key);
+ if (my_free_list_ptr == 0) {
+ uncollectable_count++;
+ my_free_list_ptr = GC_NEW_UNCOLLECTABLE(void *);
+ if (pthread_setspecific(fl_key, my_free_list_ptr) != 0) {
+ (void)GC_printf0("pthread_setspecific failed\n");
+ FAIL;
+ }
+ }
+ my_free_list = *my_free_list_ptr;
+ if (my_free_list == 0) {
+ my_free_list = GC_malloc_many(8);
+ if (my_free_list == 0) {
+ (void)GC_printf0("alloc8bytes out of memory\n");
+ FAIL;
+ }
+ }
+ *my_free_list_ptr = GC_NEXT(my_free_list);
+ GC_NEXT(my_free_list) = 0;
+ collectable_count++;
+ return(my_free_list);
+# endif
+}
+
+# else
+# define alloc8bytes() GC_MALLOC_ATOMIC(8)
+# endif
+#endif
+
+void alloc_small(n)
+int n;
+{
+ register int i;
+
+ for (i = 0; i < n; i += 8) {
+ atomic_count++;
+ if (alloc8bytes() == 0) {
+ (void)GC_printf0("Out of memory\n");
+ FAIL;
+ }
+ }
+}
+
+# if defined(THREADS) && defined(GC_DEBUG)
+# ifdef VERY_SMALL_CONFIG
+# define TREE_HEIGHT 12
+# else
+# define TREE_HEIGHT 15
+# endif
+# else
+# ifdef VERY_SMALL_CONFIG
+# define TREE_HEIGHT 13
+# else
+# define TREE_HEIGHT 16
+# endif
+# endif
+void tree_test()
+{
+ tn * root;
+ register int i;
+
+ root = mktree(TREE_HEIGHT);
+# ifndef VERY_SMALL_CONFIG
+ alloc_small(5000000);
+# endif
+ chktree(root, TREE_HEIGHT);
+ if (finalized_count && ! dropped_something) {
+ (void)GC_printf0("Premature finalization - collector is broken\n");
+ FAIL;
+ }
+ dropped_something = 1;
+ GC_noop(root); /* Root needs to remain live until */
+ /* dropped_something is set. */
+ root = mktree(TREE_HEIGHT);
+ chktree(root, TREE_HEIGHT);
+ for (i = TREE_HEIGHT; i >= 0; i--) {
+ root = mktree(i);
+ chktree(root, i);
+ }
+# ifndef VERY_SMALL_CONFIG
+ alloc_small(5000000);
+# endif
+}
+
+unsigned n_tests = 0;
+
+GC_word bm_huge[10] = {
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0xffffffff,
+ 0x00ffffff,
+};
+
+/* A very simple test of explicitly typed allocation */
+void typed_test()
+{
+ GC_word * old, * new;
+ GC_word bm3 = 0x3;
+ GC_word bm2 = 0x2;
+ GC_word bm_large = 0xf7ff7fff;
+ GC_descr d1 = GC_make_descriptor(&bm3, 2);
+ GC_descr d2 = GC_make_descriptor(&bm2, 2);
+# ifndef LINT
+ GC_descr dummy = GC_make_descriptor(&bm_large, 32);
+# endif
+ GC_descr d3 = GC_make_descriptor(&bm_large, 32);
+ GC_descr d4 = GC_make_descriptor(bm_huge, 320);
+ GC_word * x = (GC_word *)GC_malloc_explicitly_typed(2000, d4);
+ register int i;
+
+ collectable_count++;
+ old = 0;
+ for (i = 0; i < 4000; i++) {
+ collectable_count++;
+ new = (GC_word *) GC_malloc_explicitly_typed(4 * sizeof(GC_word), d1);
+ if (0 != new[0] || 0 != new[1]) {
+ GC_printf0("Bad initialization by GC_malloc_explicitly_typed\n");
+ FAIL;
+ }
+ new[0] = 17;
+ new[1] = (GC_word)old;
+ old = new;
+ collectable_count++;
+ new = (GC_word *) GC_malloc_explicitly_typed(4 * sizeof(GC_word), d2);
+ new[0] = 17;
+ new[1] = (GC_word)old;
+ old = new;
+ collectable_count++;
+ new = (GC_word *) GC_malloc_explicitly_typed(33 * sizeof(GC_word), d3);
+ new[0] = 17;
+ new[1] = (GC_word)old;
+ old = new;
+ collectable_count++;
+ new = (GC_word *) GC_calloc_explicitly_typed(4, 2 * sizeof(GC_word),
+ d1);
+ new[0] = 17;
+ new[1] = (GC_word)old;
+ old = new;
+ collectable_count++;
+ if (i & 0xff) {
+ new = (GC_word *) GC_calloc_explicitly_typed(7, 3 * sizeof(GC_word),
+ d2);
+ } else {
+ new = (GC_word *) GC_calloc_explicitly_typed(1001,
+ 3 * sizeof(GC_word),
+ d2);
+ if (0 != new[0] || 0 != new[1]) {
+ GC_printf0("Bad initialization by GC_malloc_explicitly_typed\n");
+ FAIL;
+ }
+ }
+ new[0] = 17;
+ new[1] = (GC_word)old;
+ old = new;
+ }
+ for (i = 0; i < 20000; i++) {
+ if (new[0] != 17) {
+ (void)GC_printf1("typed alloc failed at %lu\n",
+ (unsigned long)i);
+ FAIL;
+ }
+ new[0] = 0;
+ old = new;
+ new = (GC_word *)(old[1]);
+ }
+ GC_gcollect();
+ GC_noop(x);
+}
+
+int fail_count = 0;
+
+#ifndef __STDC__
+/*ARGSUSED*/
+void fail_proc1(x)
+GC_PTR x;
+{
+ fail_count++;
+}
+
+#else
+
+/*ARGSUSED*/
+void fail_proc1(GC_PTR x)
+{
+ fail_count++;
+}
+
+#endif /* __STDC__ */
+
+#ifdef THREADS
+# define TEST_FAIL_COUNT(n) 1
+#else
+# define TEST_FAIL_COUNT(n) (fail_count >= (n))
+#endif
+
+void run_one_test()
+{
+ char *x;
+# ifdef LINT
+ char *y = 0;
+# else
+ char *y = (char *)(size_t)fail_proc1;
+# endif
+ DCL_LOCK_STATE;
+
+# ifdef FIND_LEAK
+ (void)GC_printf0(
+ "This test program is not designed for leak detection mode\n");
+ (void)GC_printf0("Expect lots of problems.\n");
+# endif
+ GC_FREE(0);
+# ifndef DBG_HDRS_ALL
+ collectable_count += 3;
+ if (GC_size(GC_malloc(7)) != 8 &&
+ GC_size(GC_malloc(7)) != MIN_WORDS * sizeof(GC_word)
+ || GC_size(GC_malloc(15)) != 16) {
+ (void)GC_printf0("GC_size produced unexpected results\n");
+ FAIL;
+ }
+ collectable_count += 1;
+ if (GC_size(GC_malloc(0)) != MIN_WORDS * sizeof(GC_word)) {
+ (void)GC_printf1("GC_malloc(0) failed: GC_size returns %ld\n",
+ GC_size(GC_malloc(0)));
+ FAIL;
+ }
+ collectable_count += 1;
+ if (GC_size(GC_malloc_uncollectable(0)) != MIN_WORDS * sizeof(GC_word)) {
+ (void)GC_printf0("GC_malloc_uncollectable(0) failed\n");
+ FAIL;
+ }
+ GC_is_valid_displacement_print_proc = fail_proc1;
+ GC_is_visible_print_proc = fail_proc1;
+ collectable_count += 1;
+ x = GC_malloc(16);
+ if (GC_base(x + 13) != x) {
+ (void)GC_printf0("GC_base(heap ptr) produced incorrect result\n");
+ FAIL;
+ }
+# ifndef PCR
+ if (GC_base(y) != 0) {
+ (void)GC_printf0("GC_base(fn_ptr) produced incorrect result\n");
+ FAIL;
+ }
+# endif
+ if (GC_same_obj(x+5, x) != x + 5) {
+ (void)GC_printf0("GC_same_obj produced incorrect result\n");
+ FAIL;
+ }
+ if (GC_is_visible(y) != y || GC_is_visible(x) != x) {
+ (void)GC_printf0("GC_is_visible produced incorrect result\n");
+ FAIL;
+ }
+ if (!TEST_FAIL_COUNT(1)) {
+# if!(defined(RS6000) || defined(POWERPC) || defined(IA64))
+ /* ON RS6000s function pointers point to a descriptor in the */
+ /* data segment, so there should have been no failures. */
+ (void)GC_printf0("GC_is_visible produced wrong failure indication\n");
+ FAIL;
+# endif
+ }
+ if (GC_is_valid_displacement(y) != y
+ || GC_is_valid_displacement(x) != x
+ || GC_is_valid_displacement(x + 3) != x + 3) {
+ (void)GC_printf0(
+ "GC_is_valid_displacement produced incorrect result\n");
+ FAIL;
+ }
+# ifndef ALL_INTERIOR_POINTERS
+# if defined(RS6000) || defined(POWERPC)
+ if (!TEST_FAIL_COUNT(1)) {
+# else
+ if (GC_all_interior_pointers && !TEST_FAIL_COUNT(1)
+ || !GC_all_interior_pointers && !TEST_FAIL_COUNT(2)) {
+# endif
+ (void)GC_printf0("GC_is_valid_displacement produced wrong failure indication\n");
+ FAIL;
+ }
+# endif
+# endif /* DBG_HDRS_ALL */
+ /* Test floating point alignment */
+ collectable_count += 2;
+ *(double *)GC_MALLOC(sizeof(double)) = 1.0;
+ *(double *)GC_MALLOC(sizeof(double)) = 1.0;
+# ifdef GC_GCJ_SUPPORT
+ GC_REGISTER_DISPLACEMENT(sizeof(struct fake_vtable *));
+ GC_init_gcj_malloc(0, (void *)fake_gcj_mark_proc);
+# endif
+ /* Repeated list reversal test. */
+ reverse_test();
+# ifdef PRINTSTATS
+ GC_printf0("-------------Finished reverse_test\n");
+# endif
+# ifndef DBG_HDRS_ALL
+ typed_test();
+# ifdef PRINTSTATS
+ GC_printf0("-------------Finished typed_test\n");
+# endif
+# endif /* DBG_HDRS_ALL */
+ tree_test();
+ LOCK();
+ n_tests++;
+ UNLOCK();
+ /* GC_printf1("Finished %x\n", pthread_self()); */
+}
+
+void check_heap_stats()
+{
+ unsigned long max_heap_sz;
+ register int i;
+ int still_live;
+ int late_finalize_count = 0;
+
+# ifdef VERY_SMALL_CONFIG
+ /* these are something of a guess */
+ if (sizeof(char *) > 4) {
+ max_heap_sz = 4500000;
+ } else {
+ max_heap_sz = 2800000;
+ }
+# else
+ if (sizeof(char *) > 4) {
+ max_heap_sz = 15000000;
+ } else {
+ max_heap_sz = 11000000;
+ }
+# endif
+# ifdef GC_DEBUG
+ max_heap_sz *= 2;
+# ifdef SAVE_CALL_CHAIN
+ max_heap_sz *= 3;
+# ifdef SAVE_CALL_COUNT
+ max_heap_sz *= SAVE_CALL_COUNT/4;
+# endif
+# endif
+# endif
+ /* Garbage collect repeatedly so that all inaccessible objects */
+ /* can be finalized. */
+ while (GC_collect_a_little()) { }
+ for (i = 0; i < 16; i++) {
+ GC_gcollect();
+ late_finalize_count += GC_invoke_finalizers();
+ }
+ (void)GC_printf1("Completed %lu tests\n", (unsigned long)n_tests);
+ (void)GC_printf1("Allocated %lu collectable objects\n", (unsigned long)collectable_count);
+ (void)GC_printf1("Allocated %lu uncollectable objects\n", (unsigned long)uncollectable_count);
+ (void)GC_printf1("Allocated %lu atomic objects\n", (unsigned long)atomic_count);
+ (void)GC_printf1("Allocated %lu stubborn objects\n", (unsigned long)stubborn_count);
+ (void)GC_printf2("Finalized %lu/%lu objects - ",
+ (unsigned long)finalized_count,
+ (unsigned long)finalizable_count);
+# ifdef FINALIZE_ON_DEMAND
+ if (finalized_count != late_finalize_count) {
+ (void)GC_printf0("Demand finalization error\n");
+ FAIL;
+ }
+# endif
+ if (finalized_count > finalizable_count
+ || finalized_count < finalizable_count/2) {
+ (void)GC_printf0("finalization is probably broken\n");
+ FAIL;
+ } else {
+ (void)GC_printf0("finalization is probably ok\n");
+ }
+ still_live = 0;
+ for (i = 0; i < MAX_FINALIZED; i++) {
+ if (live_indicators[i] != 0) {
+ still_live++;
+ }
+ }
+ i = finalizable_count - finalized_count - still_live;
+ if (0 != i) {
+ (void)GC_printf2
+ ("%lu disappearing links remain and %ld more objects were not finalized\n",
+ (unsigned long) still_live, (long)i);
+ if (i > 10) {
+ GC_printf0("\tVery suspicious!\n");
+ } else {
+ GC_printf0("\tSlightly suspicious, but probably OK.\n");
+ }
+ }
+ (void)GC_printf1("Total number of bytes allocated is %lu\n",
+ (unsigned long)
+ WORDS_TO_BYTES(GC_words_allocd + GC_words_allocd_before_gc));
+ (void)GC_printf1("Final heap size is %lu bytes\n",
+ (unsigned long)GC_get_heap_size());
+ if (WORDS_TO_BYTES(GC_words_allocd + GC_words_allocd_before_gc)
+# ifdef VERY_SMALL_CONFIG
+ < 2700000*n_tests) {
+# else
+ < 33500000*n_tests) {
+# endif
+ (void)GC_printf0("Incorrect execution - missed some allocations\n");
+ FAIL;
+ }
+ if (GC_get_heap_size() > max_heap_sz*n_tests) {
+ (void)GC_printf0("Unexpected heap growth - collector may be broken\n");
+ FAIL;
+ }
+ (void)GC_printf0("Collector appears to work\n");
+}
+
+#if defined(MACOS)
+void SetMinimumStack(long minSize)
+{
+ long newApplLimit;
+
+ if (minSize > LMGetDefltStack())
+ {
+ newApplLimit = (long) GetApplLimit()
+ - (minSize - LMGetDefltStack());
+ SetApplLimit((Ptr) newApplLimit);
+ MaxApplZone();
+ }
+}
+
+#define cMinStackSpace (512L * 1024L)
+
+#endif
+
+#ifdef __STDC__
+ void warn_proc(char *msg, GC_word p)
+#else
+ void warn_proc(msg, p)
+ char *msg;
+ GC_word p;
+#endif
+{
+ GC_printf1(msg, (unsigned long)p);
+ /*FAIL;*/
+}
+
+
+#if !defined(PCR) && !defined(GC_SOLARIS_THREADS) \
+ && !defined(GC_WIN32_THREADS) \
+ && !defined(GC_IRIX_THREADS) && !defined(GC_LINUX_THREADS) \
+ && !defined(GC_HPUX_THREADS) || defined(LINT)
+#if defined(MSWIN32) && !defined(__MINGW32__)
+ int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prev, LPTSTR cmd, int n)
+#else
+ int main()
+#endif
+{
+# if defined(DJGPP)
+ int dummy;
+# endif
+ n_tests = 0;
+
+# if defined(DJGPP)
+ /* No good way to determine stack base from library; do it */
+ /* manually on this platform. */
+ GC_stackbottom = (GC_PTR)(&dummy);
+# endif
+# if defined(MACOS)
+ /* Make sure we have lots and lots of stack space. */
+ SetMinimumStack(cMinStackSpace);
+ /* Cheat and let stdio initialize toolbox for us. */
+ printf("Testing GC Macintosh port.\n");
+# endif
+ GC_INIT(); /* Only needed if gc is dynamic library. */
+ (void) GC_set_warn_proc(warn_proc);
+# if defined(MPROTECT_VDB) || defined(PROC_VDB)
+ GC_enable_incremental();
+ (void) GC_printf0("Switched to incremental mode\n");
+# if defined(MPROTECT_VDB)
+ (void)GC_printf0("Emulating dirty bits with mprotect/signals\n");
+# else
+ (void)GC_printf0("Reading dirty bits from /proc\n");
+# endif
+# endif
+ run_one_test();
+ check_heap_stats();
+# ifndef MSWINCE
+ (void)fflush(stdout);
+# endif
+# ifdef LINT
+ /* Entry points we should be testing, but aren't. */
+ /* Some can be tested by defining GC_DEBUG at the top of this file */
+ /* This is a bit SunOS4 specific. */
+ GC_noop(GC_expand_hp, GC_add_roots, GC_clear_roots,
+ GC_register_disappearing_link,
+ GC_register_finalizer_ignore_self,
+ GC_debug_register_displacement,
+ GC_print_obj, GC_debug_change_stubborn,
+ GC_debug_end_stubborn_change, GC_debug_malloc_uncollectable,
+ GC_debug_free, GC_debug_realloc, GC_generic_malloc_words_small,
+ GC_init, GC_make_closure, GC_debug_invoke_finalizer,
+ GC_page_was_ever_dirty, GC_is_fresh,
+ GC_malloc_ignore_off_page, GC_malloc_atomic_ignore_off_page,
+ GC_set_max_heap_size, GC_get_bytes_since_gc,
+ GC_get_total_bytes, GC_pre_incr, GC_post_incr);
+# endif
+# ifdef MSWIN32
+ GC_win32_free_heap();
+# endif
+ return(0);
+}
+# endif
+
+#ifdef GC_WIN32_THREADS
+
+unsigned __stdcall thr_run_one_test(void *arg)
+{
+ run_one_test();
+ return 0;
+}
+
+#ifdef MSWINCE
+HANDLE win_created_h;
+HWND win_handle;
+
+LRESULT CALLBACK window_proc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+ LRESULT ret = 0;
+ switch (uMsg) {
+ case WM_HIBERNATE:
+ GC_printf0("Received WM_HIBERNATE, calling GC_gcollect\n");
+ GC_gcollect();
+ break;
+ case WM_CLOSE:
+ GC_printf0("Received WM_CLOSE, closing window\n");
+ DestroyWindow(hwnd);
+ break;
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ break;
+ default:
+ ret = DefWindowProc(hwnd, uMsg, wParam, lParam);
+ break;
+ }
+ return ret;
+}
+
+unsigned __stdcall thr_window(void *arg)
+{
+ WNDCLASS win_class = {
+ CS_NOCLOSE,
+ window_proc,
+ 0,
+ 0,
+ GetModuleHandle(NULL),
+ NULL,
+ NULL,
+ (HBRUSH)(COLOR_APPWORKSPACE+1),
+ NULL,
+ L"GCtestWindow"
+ };
+ MSG msg;
+
+ if (!RegisterClass(&win_class))
+ FAIL;
+
+ win_handle = CreateWindowEx(
+ 0,
+ L"GCtestWindow",
+ L"GCtest",
+ 0,
+ CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
+ NULL,
+ NULL,
+ GetModuleHandle(NULL),
+ NULL);
+
+ if (win_handle == NULL)
+ FAIL;
+
+ SetEvent(win_created_h);
+
+ ShowWindow(win_handle, SW_SHOW);
+ UpdateWindow(win_handle);
+
+ while (GetMessage(&msg, NULL, 0, 0)) {
+ TranslateMessage(&msg);
+ DispatchMessage(&msg);
+ }
+
+ return 0;
+}
+#endif
+
+#define NTEST 2
+
+# ifdef MSWINCE
+int APIENTRY GC_WinMain(HINSTANCE instance, HINSTANCE prev, LPWSTR cmd, int n)
+# else
+int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prev, LPSTR cmd, int n)
+# endif
+{
+# if NTEST > 0
+ HANDLE h[NTEST];
+ int i;
+# endif
+# ifdef MSWINCE
+ HANDLE win_thr_h;
+# endif
+ unsigned thread_id;
+# if 0
+ GC_enable_incremental();
+# endif
+ InitializeCriticalSection(&incr_cs);
+ (void) GC_set_warn_proc(warn_proc);
+# ifdef MSWINCE
+ win_created_h = CreateEvent(NULL, FALSE, FALSE, NULL);
+ if (win_created_h == (HANDLE)NULL) {
+ (void)GC_printf1("Event creation failed %lu\n", (unsigned long)GetLastError());
+ FAIL;
+ }
+ win_thr_h = GC_CreateThread(NULL, 0, thr_window, 0, 0, &thread_id);
+ if (win_thr_h == (HANDLE)NULL) {
+ (void)GC_printf1("Thread creation failed %lu\n", (unsigned long)GetLastError());
+ FAIL;
+ }
+ if (WaitForSingleObject(win_created_h, INFINITE) != WAIT_OBJECT_0)
+ FAIL;
+ CloseHandle(win_created_h);
+# endif
+# if NTEST > 0
+ for (i = 0; i < NTEST; i++) {
+ h[i] = GC_CreateThread(NULL, 0, thr_run_one_test, 0, 0, &thread_id);
+ if (h[i] == (HANDLE)NULL) {
+ (void)GC_printf1("Thread creation failed %lu\n", (unsigned long)GetLastError());
+ FAIL;
+ }
+ }
+# endif /* NTEST > 0 */
+ run_one_test();
+# if NTEST > 0
+ for (i = 0; i < NTEST; i++) {
+ if (WaitForSingleObject(h[i], INFINITE) != WAIT_OBJECT_0) {
+ (void)GC_printf1("Thread wait failed %lu\n", (unsigned long)GetLastError());
+ FAIL;
+ }
+ }
+# endif /* NTEST > 0 */
+# ifdef MSWINCE
+ PostMessage(win_handle, WM_CLOSE, 0, 0);
+ if (WaitForSingleObject(win_thr_h, INFINITE) != WAIT_OBJECT_0)
+ FAIL;
+# endif
+ check_heap_stats();
+ return(0);
+}
+
+#endif /* GC_WIN32_THREADS */
+
+
+#ifdef PCR
+test()
+{
+ PCR_Th_T * th1;
+ PCR_Th_T * th2;
+ int code;
+
+ n_tests = 0;
+ /* GC_enable_incremental(); */
+ (void) GC_set_warn_proc(warn_proc);
+ th1 = PCR_Th_Fork(run_one_test, 0);
+ th2 = PCR_Th_Fork(run_one_test, 0);
+ run_one_test();
+ if (PCR_Th_T_Join(th1, &code, NIL, PCR_allSigsBlocked, PCR_waitForever)
+ != PCR_ERes_okay || code != 0) {
+ (void)GC_printf0("Thread 1 failed\n");
+ }
+ if (PCR_Th_T_Join(th2, &code, NIL, PCR_allSigsBlocked, PCR_waitForever)
+ != PCR_ERes_okay || code != 0) {
+ (void)GC_printf0("Thread 2 failed\n");
+ }
+ check_heap_stats();
+ return(0);
+}
+#endif
+
+#if defined(GC_SOLARIS_THREADS) || defined(GC_IRIX_THREADS) \
+ || defined(GC_HPUX_THREADS) || defined(GC_LINUX_THREADS)
+void * thr_run_one_test(void * arg)
+{
+ run_one_test();
+ return(0);
+}
+
+#ifdef GC_DEBUG
+# define GC_free GC_debug_free
+#endif
+
+#ifdef GC_SOLARIS_THREADS
+main()
+{
+ thread_t th1;
+ thread_t th2;
+ int code;
+
+ n_tests = 0;
+ GC_INIT(); /* Only needed if gc is dynamic library. */
+ GC_enable_incremental();
+ (void) GC_set_warn_proc(warn_proc);
+ if (thr_keycreate(&fl_key, GC_free) != 0) {
+ (void)GC_printf1("Key creation failed %lu\n", (unsigned long)code);
+ FAIL;
+ }
+ if ((code = thr_create(0, 1024*1024, thr_run_one_test, 0, 0, &th1)) != 0) {
+ (void)GC_printf1("Thread 1 creation failed %lu\n", (unsigned long)code);
+ FAIL;
+ }
+ if ((code = thr_create(0, 1024*1024, thr_run_one_test, 0, THR_NEW_LWP, &th2)) != 0) {
+ (void)GC_printf1("Thread 2 creation failed %lu\n", (unsigned long)code);
+ FAIL;
+ }
+ run_one_test();
+ if ((code = thr_join(th1, 0, 0)) != 0) {
+ (void)GC_printf1("Thread 1 failed %lu\n", (unsigned long)code);
+ FAIL;
+ }
+ if (thr_join(th2, 0, 0) != 0) {
+ (void)GC_printf1("Thread 2 failed %lu\n", (unsigned long)code);
+ FAIL;
+ }
+ check_heap_stats();
+ (void)fflush(stdout);
+ return(0);
+}
+#else /* pthreads */
+main()
+{
+ pthread_t th1;
+ pthread_t th2;
+ pthread_attr_t attr;
+ int code;
+
+# ifdef GC_IRIX_THREADS
+ /* Force a larger stack to be preallocated */
+ /* Since the initial cant always grow later. */
+ *((volatile char *)&code - 1024*1024) = 0; /* Require 1 Mb */
+# endif /* GC_IRIX_THREADS */
+ pthread_attr_init(&attr);
+# if defined(GC_IRIX_THREADS) || defined(GC_HPUX_THREADS)
+ pthread_attr_setstacksize(&attr, 1000000);
+# endif
+ n_tests = 0;
+# if defined(MPROTECT_VDB) && !defined(PARALLEL_MARK) &&!defined(REDIRECT_MALLOC)
+ GC_enable_incremental();
+ (void) GC_printf0("Switched to incremental mode\n");
+ (void) GC_printf0("Emulating dirty bits with mprotect/signals\n");
+# endif
+ (void) GC_set_warn_proc(warn_proc);
+ if ((code = pthread_key_create(&fl_key, 0)) != 0) {
+ (void)GC_printf1("Key creation failed %lu\n", (unsigned long)code);
+ FAIL;
+ }
+ if ((code = pthread_create(&th1, &attr, thr_run_one_test, 0)) != 0) {
+ (void)GC_printf1("Thread 1 creation failed %lu\n", (unsigned long)code);
+ FAIL;
+ }
+ if ((code = pthread_create(&th2, &attr, thr_run_one_test, 0)) != 0) {
+ (void)GC_printf1("Thread 2 creation failed %lu\n", (unsigned long)code);
+ FAIL;
+ }
+ run_one_test();
+ if ((code = pthread_join(th1, 0)) != 0) {
+ (void)GC_printf1("Thread 1 failed %lu\n", (unsigned long)code);
+ FAIL;
+ }
+ if (pthread_join(th2, 0) != 0) {
+ (void)GC_printf1("Thread 2 failed %lu\n", (unsigned long)code);
+ FAIL;
+ }
+ check_heap_stats();
+ (void)fflush(stdout);
+ pthread_attr_destroy(&attr);
+ GC_printf1("Completed %d collections\n", GC_gc_no);
+ return(0);
+}
+#endif /* pthreads */
+#endif /* SOLARIS_THREADS || IRIX_THREADS || LINUX_THREADS || HPUX_THREADS */
diff --git a/gc/tests/test_cpp.cc b/gc/tests/test_cpp.cc
new file mode 100644
index 0000000..75fd366
--- /dev/null
+++ b/gc/tests/test_cpp.cc
@@ -0,0 +1,277 @@
+/****************************************************************************
+Copyright (c) 1994 by Xerox Corporation. All rights reserved.
+
+THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
+
+Permission is hereby granted to use or copy this program for any
+purpose, provided the above notices are retained on all copies.
+Permission to modify the code and to distribute modified code is
+granted, provided the above notices are retained, and a notice that
+the code was modified is included with the above copyright notice.
+****************************************************************************
+Last modified on Mon Jul 10 21:06:03 PDT 1995 by ellis
+ modified on December 20, 1994 7:27 pm PST by boehm
+
+usage: test_cpp number-of-iterations
+
+This program tries to test the specific C++ functionality provided by
+gc_c++.h that isn't tested by the more general test routines of the
+collector.
+
+A recommended value for number-of-iterations is 10, which will take a
+few minutes to complete.
+
+***************************************************************************/
+
+#include "gc_cpp.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef __GNUC__
+# include "new_gc_alloc.h"
+#else
+# include "gc_alloc.h"
+#endif
+extern "C" {
+#include "private/gc_priv.h"
+}
+#ifdef MSWIN32
+# include <windows.h>
+#endif
+#ifdef GC_NAME_CONFLICT
+# define USE_GC UseGC
+ struct foo * GC;
+#else
+# define USE_GC GC
+#endif
+
+
+#define my_assert( e ) \
+ if (! (e)) { \
+ GC_printf1( "Assertion failure in " __FILE__ ", line %d: " #e "\n", \
+ __LINE__ ); \
+ exit( 1 ); }
+
+
+class A {public:
+ /* An uncollectable class. */
+
+ A( int iArg ): i( iArg ) {}
+ void Test( int iArg ) {
+ my_assert( i == iArg );}
+ int i;};
+
+
+class B: public gc, public A {public:
+ /* A collectable class. */
+
+ B( int j ): A( j ) {}
+ ~B() {
+ my_assert( deleting );}
+ static void Deleting( int on ) {
+ deleting = on;}
+ static int deleting;};
+
+int B::deleting = 0;
+
+
+class C: public gc_cleanup, public A {public:
+ /* A collectable class with cleanup and virtual multiple inheritance. */
+
+ C( int levelArg ): A( levelArg ), level( levelArg ) {
+ nAllocated++;
+ if (level > 0) {
+ left = new C( level - 1 );
+ right = new C( level - 1 );}
+ else {
+ left = right = 0;}}
+ ~C() {
+ this->A::Test( level );
+ nFreed++;
+ my_assert( level == 0 ?
+ left == 0 && right == 0 :
+ level == left->level + 1 && level == right->level + 1 );
+ left = right = 0;
+ level = -123456;}
+ static void Test() {
+ my_assert( nFreed <= nAllocated && nFreed >= .8 * nAllocated );}
+
+ static int nFreed;
+ static int nAllocated;
+ int level;
+ C* left;
+ C* right;};
+
+int C::nFreed = 0;
+int C::nAllocated = 0;
+
+
+class D: public gc {public:
+ /* A collectable class with a static member function to be used as
+ an explicit clean-up function supplied to ::new. */
+
+ D( int iArg ): i( iArg ) {
+ nAllocated++;}
+ static void CleanUp( void* obj, void* data ) {
+ D* self = (D*) obj;
+ nFreed++;
+ my_assert( self->i == (int) (long) data );}
+ static void Test() {
+ my_assert( nFreed >= .8 * nAllocated );}
+
+ int i;
+ static int nFreed;
+ static int nAllocated;};
+
+int D::nFreed = 0;
+int D::nAllocated = 0;
+
+
+class E: public gc_cleanup {public:
+ /* A collectable class with clean-up for use by F. */
+
+ E() {
+ nAllocated++;}
+ ~E() {
+ nFreed++;}
+
+ static int nFreed;
+ static int nAllocated;};
+
+int E::nFreed = 0;
+int E::nAllocated = 0;
+
+
+class F: public E {public:
+ /* A collectable class with clean-up, a base with clean-up, and a
+ member with clean-up. */
+
+ F() {
+ nAllocated++;}
+ ~F() {
+ nFreed++;}
+ static void Test() {
+ my_assert( nFreed >= .8 * nAllocated );
+ my_assert( 2 * nFreed == E::nFreed );}
+
+ E e;
+ static int nFreed;
+ static int nAllocated;};
+
+int F::nFreed = 0;
+int F::nAllocated = 0;
+
+
+long Disguise( void* p ) {
+ return ~ (long) p;}
+
+void* Undisguise( long i ) {
+ return (void*) ~ i;}
+
+
+#ifdef MSWIN32
+int APIENTRY WinMain(
+ HINSTANCE instance, HINSTANCE prev, LPSTR cmd, int cmdShow )
+{
+ int argc;
+ char* argv[ 3 ];
+
+ for (argc = 1; argc < sizeof( argv ) / sizeof( argv[ 0 ] ); argc++) {
+ argv[ argc ] = strtok( argc == 1 ? cmd : 0, " \t" );
+ if (0 == argv[ argc ]) break;}
+
+#else
+# ifdef MACOS
+ int main() {
+# else
+ int main( int argc, char* argv[] ) {
+# endif
+#endif
+
+# if defined(MACOS) // MacOS
+ char* argv_[] = {"test_cpp", "10"}; // doesn't
+ argv = argv_; // have a
+ argc = sizeof(argv_)/sizeof(argv_[0]); // commandline
+# endif
+ int i, iters, n;
+# if !defined(MACOS)
+# ifdef __GNUC__
+ int *x = (int *)gc_alloc::allocate(sizeof(int));
+# else
+ int *x = (int *)alloc::allocate(sizeof(int));
+# endif
+
+ *x = 29;
+ x -= 3;
+# endif
+ if (argc != 2 || (0 >= (n = atoi( argv[ 1 ] )))) {
+ GC_printf0( "usage: test_cpp number-of-iterations\n" );
+ exit( 1 );}
+
+ for (iters = 1; iters <= n; iters++) {
+ GC_printf1( "Starting iteration %d\n", iters );
+
+ /* Allocate some uncollectable As and disguise their pointers.
+ Later we'll check to see if the objects are still there. We're
+ checking to make sure these objects really are uncollectable. */
+ long as[ 1000 ];
+ long bs[ 1000 ];
+ for (i = 0; i < 1000; i++) {
+ as[ i ] = Disguise( new (NoGC) A( i ) );
+ bs[ i ] = Disguise( new (NoGC) B( i ) );}
+
+ /* Allocate a fair number of finalizable Cs, Ds, and Fs.
+ Later we'll check to make sure they've gone away. */
+ for (i = 0; i < 1000; i++) {
+ C* c = new C( 2 );
+ C c1( 2 ); /* stack allocation should work too */
+ D* d = ::new (USE_GC, D::CleanUp, (void*)(long)i) D( i );
+ F* f = new F;
+ if (0 == i % 10) delete c;}
+
+ /* Allocate a very large number of collectable As and Bs and
+ drop the references to them immediately, forcing many
+ collections. */
+ for (i = 0; i < 1000000; i++) {
+ A* a = new (USE_GC) A( i );
+ B* b = new B( i );
+ b = new (USE_GC) B( i );
+ if (0 == i % 10) {
+ B::Deleting( 1 );
+ delete b;
+ B::Deleting( 0 );}
+# ifdef FINALIZE_ON_DEMAND
+ GC_invoke_finalizers();
+# endif
+ }
+
+ /* Make sure the uncollectable As and Bs are still there. */
+ for (i = 0; i < 1000; i++) {
+ A* a = (A*) Undisguise( as[ i ] );
+ B* b = (B*) Undisguise( bs[ i ] );
+ a->Test( i );
+ delete a;
+ b->Test( i );
+ B::Deleting( 1 );
+ delete b;
+ B::Deleting( 0 );
+# ifdef FINALIZE_ON_DEMAND
+ GC_invoke_finalizers();
+# endif
+
+ }
+
+ /* Make sure most of the finalizable Cs, Ds, and Fs have
+ gone away. */
+ C::Test();
+ D::Test();
+ F::Test();}
+
+# if !defined(__GNUC__) && !defined(MACOS)
+ my_assert (29 == x[3]);
+# endif
+ GC_printf0( "The test appears to have succeeded.\n" );
+ return( 0 );}
+
+
diff --git a/gc/tests/thread_leak_test.c b/gc/tests/thread_leak_test.c
new file mode 100644
index 0000000..1174705
--- /dev/null
+++ b/gc/tests/thread_leak_test.c
@@ -0,0 +1,40 @@
+#define GC_LINUX_THREADS
+#include "leak_detector.h"
+#include <pthread.h>
+#include <stdio.h>
+
+void * test(void * arg) {
+ int *p[10];
+ int i;
+ GC_find_leak = 1; /* for new collect versions not compiled */
+ /* with -DFIND_LEAK. */
+ for (i = 0; i < 10; ++i) {
+ p[i] = malloc(sizeof(int)+i);
+ }
+ CHECK_LEAKS();
+ for (i = 1; i < 10; ++i) {
+ free(p[i]);
+ }
+}
+
+#define NTHREADS 5
+
+main() {
+ int i;
+ pthread_t t[NTHREADS];
+ int code;
+
+ for (i = 0; i < NTHREADS; ++i) {
+ if ((code = pthread_create(t + i, 0, test, 0)) != 0) {
+ printf("Thread creation failed %d\n", code);
+ }
+ }
+ for (i = 0; i < NTHREADS; ++i) {
+ if ((code = pthread_join(t[i], 0)) != 0) {
+ printf("Thread join failed %lu\n", code);
+ }
+ }
+ CHECK_LEAKS();
+ CHECK_LEAKS();
+ CHECK_LEAKS();
+}
diff --git a/gc/tests/trace_test.c b/gc/tests/trace_test.c
new file mode 100644
index 0000000..be9cb6c
--- /dev/null
+++ b/gc/tests/trace_test.c
@@ -0,0 +1,28 @@
+#include <stdio.h>
+#define GC_DEBUG
+#include "gc.h"
+
+struct treenode {
+ struct treenode *x;
+ struct treenode *y;
+} * root[10];
+
+struct treenode * mktree(int i) {
+ struct treenode * r = GC_MALLOC(sizeof(struct treenode));
+ if (0 == i) return 0;
+ r -> x = mktree(i-1);
+ r -> y = mktree(i-1);
+ return r;
+}
+
+main()
+{
+ int i;
+ for (i = 0; i < 10; ++i) {
+ root[i] = mktree(12);
+ }
+ GC_generate_random_backtrace();
+ GC_generate_random_backtrace();
+ GC_generate_random_backtrace();
+ GC_generate_random_backtrace();
+}
diff --git a/html.c b/html.c
index 5682856..599d29b 100644
--- a/html.c
+++ b/html.c
@@ -205,7 +205,7 @@ TagInfo TagMAP[MAX_HTMLTAG] =
{"title_alt", ALST_TITLE_ALT,MAXA_TITLE_ALT,TFLG_INT}, /* 118 HTML_TITLE_ALT */
{"form_int", ALST_FORM, MAXA_FORM, TFLG_INT}, /* 119 HTML_FORM_INT */
{"/form_int", NULL, 0, TFLG_INT|TFLG_END}, /* 120 HTML_N_FORM_INT */
- {"dl_compat", NULL, 0, TFLG_INT}, /* 121 HTML_DL_COMPACT */
+ {"dl_compact", NULL, 0, TFLG_INT}, /* 121 HTML_DL_COMPACT */
{"input_alt", ALST_INPUT_ALT,MAXA_INPUT_ALT,TFLG_INT}, /* 122 HTML_INPUT_ALT */
{"/input_alt", NULL, 0, TFLG_INT|TFLG_END}, /* 123 HTML_N_INPUT_ALT */
{"img_alt", ALST_IMG_ALT, MAXA_IMG_ALT, TFLG_INT}, /* 124 HTML_IMG_ALT */
diff --git a/html.h b/html.h
index c5cc0c6..e828427 100644
--- a/html.h
+++ b/html.h
@@ -1,4 +1,4 @@
-/* $Id: html.h,v 1.2 2001/11/09 04:59:17 a-ito Exp $ */
+/* $Id: html.h,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */
#ifndef _HTML_H
#define _HTML_H
#ifdef USE_SSL
@@ -56,6 +56,7 @@ typedef struct _ParsedURL {
int port;
char *file;
char *real_file;
+ char *query;
char *label;
int is_nocache;
} ParsedURL;
diff --git a/indep.c b/indep.c
index 159856e..b4cdc46 100644
--- a/indep.c
+++ b/indep.c
@@ -1,4 +1,4 @@
-/* $Id: indep.c,v 1.2 2001/11/09 04:59:17 a-ito Exp $ */
+/* $Id: indep.c,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */
#include "fm.h"
#include <stdio.h>
#include <pwd.h>
@@ -75,14 +75,14 @@ currentdir()
}
char *
-cleanupName2(char *name, int flag)
+cleanupName(char *name)
{
char *buf, *p, *q;
buf = allocStr(name, 0);
p = buf;
q = name;
- while (*q != '\0' && (*q != '?' || ! flag)) {
+ while (*q != '\0') {
if (strncmp(p, "/../", 4) == 0) { /* foo/bar/../FOO */
if (p - 2 == buf && strncmp(p - 2, "..", 2) == 0) {
/* ../../ */
@@ -125,13 +125,13 @@ cleanupName2(char *name, int flag)
}
else if (strncmp(p, "//", 2) == 0) { /* foo//bar */
/* -> foo/bar */
-#ifdef __CYGWIN__
+#if 0 /* ifdef SUPPORT_NETBIOS_SHARE */
if (p == buf) { /* //DRIVE/foo or //host/path */
p += 2;
q += 2;
continue;
}
-#endif /* __CYGWIN__ */
+#endif /* SUPPORT_NETBIOS_SHARE */
*p = '\0';
q++;
strcat(buf, q);
diff --git a/indep.h b/indep.h
index 1c84039..e077e28 100644
--- a/indep.h
+++ b/indep.h
@@ -20,8 +20,7 @@ extern char *getescapecmd(char **s);
extern char *allocStr(const char *s, int len);
extern int strCmp(const void *s1, const void *s2);
extern char *currentdir(void);
-extern char *cleanupName2(char *name, int flag);
-#define cleanupName(name) cleanupName2((name), TRUE)
+extern char *cleanupName(char *name);
extern char *expandPath(char *name);
extern char *strcasestr(char *s1, char *s2);
extern int strcasemstr(char *str, char *srch[], char **ret_ptr);
diff --git a/istream.c b/istream.c
index 401f9ef..63bac19 100644
--- a/istream.c
+++ b/istream.c
@@ -1,4 +1,4 @@
-/* $Id: istream.c,v 1.2 2001/11/09 04:59:17 a-ito Exp $ */
+/* $Id: istream.c,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */
#include "fm.h"
#include "istream.h"
#include <signal.h>
diff --git a/istream.h b/istream.h
index b6b4974..991cc9f 100644
--- a/istream.h
+++ b/istream.h
@@ -1,4 +1,4 @@
-/* $Id: istream.h,v 1.2 2001/11/09 04:59:17 a-ito Exp $ */
+/* $Id: istream.h,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */
#ifndef IO_STREAM_H
#define IO_STREAM_H
diff --git a/keybind.c b/keybind.c
index 6e12886..e5f25f4 100644
--- a/keybind.c
+++ b/keybind.c
@@ -1,4 +1,4 @@
-/* $Id: keybind.c,v 1.2 2001/11/09 04:59:17 a-ito Exp $ */
+/* $Id: keybind.c,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */
#include "funcname2.h"
char GlobalKeymap[128] =
diff --git a/linein.c b/linein.c
index ab03c19..e825fe5 100644
--- a/linein.c
+++ b/linein.c
@@ -1,4 +1,4 @@
-/* $Id: linein.c,v 1.2 2001/11/09 04:59:17 a-ito Exp $ */
+/* $Id: linein.c,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */
#include "fm.h"
#include "local.h"
#include "myctype.h"
diff --git a/local.c b/local.c
index 0b00c03..9ab7847 100644
--- a/local.c
+++ b/local.c
@@ -16,6 +16,9 @@
#define CGIFN_NORMAL 0
#define CGIFN_DROOT 1
#define CGIFN_CGIBIN 2
+#define CGIFN_MODE(x) ((x)&3)
+
+#define CGIFN_CONTAIN_SLASH 4
/* setup cookie for local CGI */
void
@@ -167,8 +170,14 @@ check_local_cgi(char *file, int status)
{
struct stat st;
+ if (status & CGIFN_CONTAIN_SLASH) {
+ /* local CGI file must be just under /cgi-bin/
+ or /$LIB/
+ */
+ return -1;
+ }
#ifdef __EMX__
- if (status != CGIFN_CGIBIN) {
+ if (CGIFN_MODE(status) != CGIFN_CGIBIN) {
char tmp[_MAX_PATH];
int len;
@@ -183,7 +192,7 @@ check_local_cgi(char *file, int status)
return -1;
}
#else /* not __EMX__ */
- if (status != CGIFN_CGIBIN) {
+ if (CGIFN_MODE(status) != CGIFN_CGIBIN) {
char *tmp = Strnew_charp(lib_dir)->ptr;
int len = strlen(tmp);
@@ -212,7 +221,8 @@ void
set_environ(char *var, char *value)
{
#ifdef HAVE_SETENV
- setenv(var, value, 1);
+ if ( var != NULL && value != NULL )
+ setenv(var, value, 1);
#else /* not HAVE_SETENV */
#ifdef HAVE_PUTENV
Str tmp = Strnew_m_charp(var, "=", value, NULL);
@@ -298,6 +308,8 @@ cgi_filename(char *fn, int *status)
struct stat st;
if (cgi_bin != NULL && strncmp(fn, "/cgi-bin/", 9) == 0) {
*status = CGIFN_CGIBIN;
+ if (strchr(fn+9,'/'))
+ *status |= CGIFN_CONTAIN_SLASH;
tmp = checkPath(fn + 9, cgi_bin);
if (tmp == NULL)
return fn;
@@ -307,6 +319,8 @@ cgi_filename(char *fn, int *status)
*status = CGIFN_NORMAL;
tmp = Strnew_charp(lib_dir);
fn += 5;
+ if (strchr(fn+1,'/'))
+ *status |= CGIFN_CONTAIN_SLASH;
if (Strlastchar(tmp) == '/')
fn++;
Strcat_charp(tmp, fn);
@@ -314,6 +328,8 @@ cgi_filename(char *fn, int *status)
}
if (*fn == '/' && document_root != NULL && stat(fn, &st) < 0) {
*status = CGIFN_DROOT;
+ if (strchr(fn+1,'/'))
+ *status |= CGIFN_CONTAIN_SLASH;
tmp = Strnew_charp(document_root);
if (Strlastchar(tmp) != '/')
Strcat_char(tmp, '/');
@@ -373,21 +389,15 @@ localcgi_popen_r(FILE **p_fp)
}
FILE *
-localcgi_post(char *uri, FormList * request, char *referer)
+localcgi_post(char *uri, char *qstr, FormList * request, char *referer)
{
FILE *f, *f1;
Str tmp1;
int status;
pid_t pid;
- char *name, *file, *qstr;
+ char *file;
- if ((qstr = strchr(uri, '?'))) {
- name = allocStr(uri, qstr - uri);
- qstr = allocStr(qstr + 1, 0);
- }
- else
- name = uri;
- file = cgi_filename(name, &status);
+ file = cgi_filename(uri, &status);
if (check_local_cgi(file, status) < 0)
return NULL;
tmp1 = tmpfname(TMPF_DFL, NULL);
@@ -399,7 +409,12 @@ localcgi_post(char *uri, FormList * request, char *referer)
fclose(f1);
return pid > 0 ? f : NULL;
}
- set_cgi_environ(Strnew_charp(name)->ptr, file, Strnew_charp(uri)->ptr);
+ if (qstr == NULL) {
+ set_cgi_environ(uri, file, uri);
+ } else {
+ set_cgi_environ(uri, file,
+ Strnew_m_charp(uri, "?", qstr, NULL)->ptr);
+ }
set_environ("REQUEST_METHOD", "POST");
if (qstr)
set_environ("QUERY_STRING", qstr);
diff --git a/mailcap.c b/mailcap.c
index 09ed7a6..e420654 100644
--- a/mailcap.c
+++ b/mailcap.c
@@ -1,4 +1,4 @@
-/* $Id: mailcap.c,v 1.2 2001/11/09 04:59:17 a-ito Exp $ */
+/* $Id: mailcap.c,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */
#include "fm.h"
#include "myctype.h"
#include <stdio.h>
diff --git a/main.c b/main.c
index f29f196..dc8ae6f 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.2 2001/11/09 04:59:17 a-ito Exp $ */
+/* $Id: main.c,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */
#define MAINPROGRAM
#include "fm.h"
#include <signal.h>
@@ -39,6 +39,12 @@ typedef struct {
static Event eventQueue[N_EVENT_QUEUE];
static int n_event_queue;
+#ifdef USE_ALARM
+static int alarm_sec = 0;
+static Event alarm_event;
+static MySignalHandler SigAlarm(SIGNAL_ARG);
+#endif
+
#ifdef USE_MARK
static char *MarkString = NULL;
#endif
@@ -67,6 +73,8 @@ int prec_num = 0;
int prev_key = -1;
int on_target = 1;
+void set_buffer_environ(Buffer*);
+
static void _followForm(int);
static void _goLine(char*);
#define PREC_NUM (prec_num ? prec_num : 1)
@@ -356,7 +364,7 @@ MAIN(int argc, char **argv, char **envp)
if (!strcmp("-t", argv[i])) {
if (++i >= argc)
usage();
- if (atoi(argv[i]) != 0)
+ if (atoi(argv[i]) > 0)
Tabstop = atoi(argv[i]);
}
else if (!strcmp("-r", argv[i]))
@@ -364,7 +372,8 @@ MAIN(int argc, char **argv, char **envp)
else if (!strcmp("-l", argv[i])) {
if (++i >= argc)
usage();
- PagerMax = atoi(argv[i]);
+ if (atoi(argv[i]) > 0)
+ PagerMax = atoi(argv[i]);
}
#ifdef JP_CHARSET
#ifndef DEBIAN /* XXX: use -o kanjicode={S|J|E} */
@@ -839,7 +848,18 @@ MAIN(int argc, char **argv, char **envp)
if (use_mouse)
mouse_active();
#endif /* MOUSE */
+#ifdef USE_ALARM
+ if (alarm_sec > 0) {
+ signal(SIGALRM, SigAlarm);
+ alarm(alarm_sec);
+ }
+#endif
c = getch();
+#ifdef USE_ALARM
+ if (alarm_sec > 0) {
+ alarm(0);
+ }
+#endif
#ifdef MOUSE
if (use_mouse)
mouse_inactive();
@@ -851,6 +871,7 @@ MAIN(int argc, char **argv, char **envp)
prec_num = PREC_LIMIT;
}
else {
+ set_buffer_environ(Currentbuf);
keyPressEventProc((int) c);
prec_num = 0;
}
@@ -899,8 +920,11 @@ dump_head(Buffer * buf)
{
TextListItem *ti;
- if (buf->document_header == NULL)
+ if (buf->document_header == NULL) {
+ if (w3m_dump & DUMP_EXTRA)
+ printf("\n");
return;
+ }
for (ti = buf->document_header->first; ti; ti = ti->next) {
printf("%s", ti->ptr);
}
@@ -1244,11 +1268,6 @@ srchbak(void)
term_raw();
displayBuffer(Currentbuf, B_NORMAL);
onA();
-/** by inu for 1902
- disp_message(Sprintf("%s%s",
- routine[reverse] == forwardSearch ? "Forward: " : "Backward: ",
- SearchString)->ptr, FALSE);
-**/
if (wrapped) {
disp_message("Search wrapped", FALSE);
}
@@ -1283,12 +1302,14 @@ srch_nxtprv(int reverse)
term_raw();
displayBuffer(Currentbuf, B_NORMAL);
onA();
- disp_message(Sprintf("%s%s",
- routine[reverse] == forwardSearch ? "Forward: " : "Backward: ",
- SearchString)->ptr, FALSE);
if (wrapped) {
disp_message("Search wrapped", FALSE);
}
+ else {
+ disp_message(Sprintf("%s%s",
+ routine[reverse] == forwardSearch ? "Forward: " : "Backward: ",
+ SearchString)->ptr, FALSE);
+ }
}
/* Search next matching */
@@ -2425,14 +2446,8 @@ followA(void)
return;
}
parseURL2(a->url, &u, baseURL(Currentbuf));
- if (u.scheme == Currentbuf->currentURL.scheme &&
- u.port == Currentbuf->currentURL.port &&
- ((u.host == NULL && Currentbuf->currentURL.host == NULL) ||
- (u.host != NULL && Currentbuf->currentURL.host != NULL &&
- strcasecmp(u.host, Currentbuf->currentURL.host) == 0)) &&
- ((u.file == NULL && Currentbuf->currentURL.file == NULL) ||
- (u.file != NULL && Currentbuf->currentURL.file != NULL &&
- strcmp(u.file, Currentbuf->currentURL.file) == 0))) {
+ if (Strcmp(parsedURL2Str(&u),
+ parsedURL2Str(&Currentbuf->currentURL)) == 0) {
/* index within this buffer */
if (u.label) {
gotoLabel(u.label);
@@ -2768,15 +2783,6 @@ _followForm(int submit)
goto do_submit;
if (fi->readonly)
disp_message_nsec("Read only field!", FALSE, 1, TRUE, FALSE);
-/*
- if (fi->rows == 1) {
- p = inputStrHist("TEXT:", fi->value ? fi->value->ptr : NULL, TextHist);
- if (p == NULL)
- return;
- fi->value = Strnew_charp(p);
- }
- else
-*/
input_textarea(fi);
formUpdateBuffer(a, Currentbuf, fi);
break;
@@ -2826,8 +2832,8 @@ _followForm(int submit)
if (!Strcmp_charp(tmp2, "!CURRENT_URL!")) {
/* It means "current URL" */
tmp2 = parsedURL2Str(&Currentbuf->currentURL);
- if ((p = strchr(tmp2->ptr, '?')) != NULL)
- Strshrink(tmp2, (tmp2->ptr + tmp2->length) - p);
+ if ((p = strchr(tmp2->ptr, '?')) != NULL)
+ Strshrink(tmp2, (tmp2->ptr + tmp2->length) - p);
}
if (fi->parent->method == FORM_METHOD_GET) {
@@ -3397,7 +3403,6 @@ cmd_loadURL(char *url, ParsedURL * current)
}
#endif /* USE_NNTP */
-/* message(Sprintf("loading %s", url)->ptr, 0, 0); */
refresh();
buf = loadGeneralFile(url, current, NO_REFERER, 0, NULL);
if (buf == NULL) {
@@ -3444,7 +3449,7 @@ goURL(void)
gotoLabel(url + 1);
return;
}
- parseURL2(url, &p_url, NULL);
+ parseURL2(url, &p_url, baseURL(Currentbuf));
pushHashHist(URLHist, parsedURL2Str(&p_url)->ptr);
cmd_loadURL(url, baseURL(Currentbuf));
}
@@ -3994,14 +3999,14 @@ chkURL(void)
{
static char *url_like_pat[] =
{
- "http://[a-zA-Z0-9][a-zA-Z0-9:%\\-\\./?=~_\\&+@#,\\$]*",
+ "http://[a-zA-Z0-9][a-zA-Z0-9:%\\-\\./?=~_\\&+@#,\\$]*[a-zA-Z0-9_/]",
#ifdef USE_SSL
- "https://[a-zA-Z0-9][a-zA-Z0-9:%\\-\\./?=~_\\&+@#,\\$]*",
+ "https://[a-zA-Z0-9][a-zA-Z0-9:%\\-\\./?=~_\\&+@#,\\$]*[a-zA-Z0-9_/]",
#endif /* USE_SSL */
#ifdef USE_GOPHER
"gopher://[a-zA-Z0-9][a-zA-Z0-9:%\\-\\./_]*",
#endif /* USE_GOPHER */
- "ftp://[a-zA-Z0-9][a-zA-Z0-9:%\\-\\./=_+@#,\\$]*",
+ "ftp://[a-zA-Z0-9][a-zA-Z0-9:%\\-\\./=_+@#,\\$]*[a-zA-Z0-9_/]",
#ifdef USE_NNTP
"news:[^<> ][^<> ]*",
"nntp://[a-zA-Z0-9][a-zA-Z0-9:%\\-\\./_]*",
@@ -4411,14 +4416,17 @@ wrapToggle(void)
}
}
-#ifdef DICT
static char *
GetWord(Buffer * buf)
{
Line *l = buf->currentLine;
- char *lb = l->lineBuf;
+ char *lb;
int i, b, e, pos = buf->pos;
+ if (l == NULL)
+ return NULL;
+ lb = l->lineBuf;
+
i = pos;
while (!IS_ALPHA(lb[i]) && i >= 0)
i--;
@@ -4436,6 +4444,7 @@ GetWord(Buffer * buf)
return Strnew_charp_n(&lb[b], e - b + 1)->ptr;
}
+#ifdef DICT
static void
execdict(char *word)
{
@@ -4491,6 +4500,58 @@ dictwordat(void)
}
#endif /* DICT */
+void
+set_buffer_environ(Buffer *buf)
+{
+ Anchor *a;
+ Str s;
+ ParsedURL pu;
+ TextListItem *ti;
+ struct frameset *f_set = NULL;
+ int all;
+
+ if (buf == NULL)
+ return;
+ set_environ("W3M_SOURCEFILE", buf->sourcefile);
+ set_environ("W3M_FILENAME",buf->filename);
+ set_environ("W3M_CURRENT_WORD",GetWord(buf));
+ set_environ("W3M_TITLE", buf->buffername);
+ set_environ("W3M_URL",parsedURL2Str(&buf->currentURL)->ptr);
+ if (buf->real_type)
+ set_environ("W3M_TYPE", buf->real_type);
+ else
+ set_environ("W3M_TYPE", "unknown");
+#ifdef JP_CHARSET
+ set_environ("W3M_CHARSET", code_to_str(buf->document_code));
+#endif /* JP_CHARSET */
+ a = retrieveCurrentAnchor(buf);
+ if (a == NULL) {
+ set_environ("W3M_CURRENT_LINK","");
+ }
+ else {
+ parseURL2(a->url, &pu, baseURL(buf));
+ s = parsedURL2Str(&pu);
+ set_environ("W3M_CURRENT_LINK", s->ptr);
+ }
+ a = retrieveCurrentImg(buf);
+ if (a == NULL) {
+ set_environ("W3M_CURRENT_IMG","");
+ }
+ else {
+ parseURL2(a->url, &pu, baseURL(buf));
+ s = parsedURL2Str(&pu);
+ set_environ("W3M_CURRENT_IMG",s->ptr);
+ }
+ a = retrieveCurrentForm(buf);
+ if (a == NULL) {
+ set_environ("W3M_CURRENT_FORM","");
+ }
+ else {
+ s = Strnew_charp(form2str((FormItemList *) a->url));
+ set_environ("W3M_CURRENT_FORM",s->ptr);
+ }
+}
+
char *
searchKeyData(void)
{
@@ -4545,3 +4606,54 @@ w3m_exit( int i )
#endif
exit( i );
}
+
+#ifdef USE_ALARM
+static MySignalHandler
+SigAlarm(SIGNAL_ARG)
+{
+ if (alarm_sec > 0) {
+ CurrentKey = -1;
+ CurrentKeyData = (char *)alarm_event.user_data;
+#ifdef MENU
+ CurrentMenuData = NULL;
+#endif
+ w3mFuncList[alarm_event.cmd].func();
+ signal(SIGALRM, SigAlarm);
+ alarm(alarm_sec);
+ }
+ SIGNAL_RETURN;
+}
+
+void
+setAlarm(void)
+{
+ char *data;
+ int sec = 0, cmd = -1;
+ extern int w3mNFuncList;
+
+ CurrentKeyData = NULL; /* not allowed in w3m-control: */
+ data = searchKeyData();
+ if (data == NULL || *data == '\0') {
+ data = inputStrHist("(Alarm)sec command: ", "", TextHist);
+ if (data == NULL) {
+ displayBuffer(Currentbuf, B_NORMAL);
+ return;
+ }
+ }
+ if (*data != '\0') {
+ sec = atoi(getWord(&data));
+ if (sec > 0)
+ cmd = getFuncList(getWord(&data), w3mFuncList, w3mNFuncList);
+ }
+ if (cmd >= 0) {
+ alarm_sec = sec;
+ alarm_event.cmd = cmd;
+ alarm_event.user_data = getQWord(&data);
+ signal(SIGALRM, SigAlarm);
+ alarm(alarm_sec);
+ } else {
+ alarm_sec = 0;
+ }
+ displayBuffer(Currentbuf, B_NORMAL);
+}
+#endif
diff --git a/matrix.c b/matrix.c
index a2c23e4..21124a6 100644
--- a/matrix.c
+++ b/matrix.c
@@ -1,7 +1,7 @@
/*
* matrix.h, matrix.c: Liner equation solver using LU decomposition.
- * $Id: matrix.c,v 1.2 2001/11/09 04:59:17 a-ito Exp $
+ * $Id: matrix.c,v 1.3 2001/11/15 00:32:13 a-ito Exp $
*
* by K.Okabe Aug. 1999
*
diff --git a/matrix.h b/matrix.h
index 50598cb..7bdc5b7 100644
--- a/matrix.h
+++ b/matrix.h
@@ -1,6 +1,6 @@
/*
* matrix.h, matrix.c: Liner equation solver using LU decomposition.
- * $Id: matrix.h,v 1.2 2001/11/09 04:59:17 a-ito Exp $
+ * $Id: matrix.h,v 1.3 2001/11/15 00:32:13 a-ito Exp $
*
* by K.Okabe Aug. 1999
*
diff --git a/proto.h b/proto.h
index 42cf1f9..691bea1 100644
--- a/proto.h
+++ b/proto.h
@@ -1,4 +1,4 @@
-/* $Id: proto.h,v 1.2 2001/11/09 04:59:18 a-ito Exp $ */
+/* $Id: proto.h,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */
/*
* This file was automatically generated by version 1.7 of cextract.
* Manual editing not recommended.
@@ -98,6 +98,11 @@ extern void rFrame(void);
extern void extbrz(void);
extern void linkbrz(void);
extern void curlno(void);
+#ifdef USE_ALARM
+extern void setAlarm(void);
+#else
+#define setAlarm nulcmd
+#endif
extern int currentLn(Buffer * buf);
extern void tmpClearBuffer(Buffer * buf);
extern char *filename_extension(char *patch, int is_url);
@@ -421,7 +426,7 @@ extern char *libFile(char *base);
extern char *helpFile(char *base);
extern void setLocalCookie(void);
extern Buffer *dirBuffer(char *dirname);
-extern FILE *localcgi_post(char *, FormList *, char*);
+extern FILE *localcgi_post(char *, char *, FormList *, char*);
extern FILE *localcgi_get(char *, char *, char*);
extern Str find_auth_cookie(char *host, char *realm);
extern void add_auth_cookie(char *host, char *realm, Str cookie);
diff --git a/rc.c b/rc.c
index 0149996..c3d48f4 100644
--- a/rc.c
+++ b/rc.c
@@ -50,6 +50,7 @@ static int rc_initialized = 0;
#define P_CODE 7
#endif
#define P_PIXELS 8
+#define P_NZINT 9
#if LANG == JA
#define CMT_HELPER "³°Éô¥Ó¥å¡¼¥¢¤ÎÊÔ½¸"
@@ -328,7 +329,7 @@ static struct sel_c badcookiestr[] = {
struct param_ptr params1[] =
{
- {"tabstop", P_INT, PI_TEXT, (void *) &Tabstop, CMT_TABSTOP, NULL},
+ {"tabstop", P_NZINT, PI_TEXT, (void *) &Tabstop, CMT_TABSTOP, NULL},
{"pixel_per_char", P_PIXELS, PI_TEXT, (void *) &pixel_per_char, CMT_PIXEL_PER_CHAR, NULL},
#ifdef JP_CHARSET
{"kanjicode", P_CODE, PI_SEL_C, (void *) &DisplayCode, CMT_KANJICODE, kcodestr},
@@ -372,7 +373,7 @@ struct param_ptr params2[] =
struct param_ptr params3[] =
{
- {"pagerline", P_INT, PI_TEXT, (void *) &PagerMax, CMT_PAGERLINE, NULL},
+ {"pagerline", P_NZINT, PI_TEXT, (void *) &PagerMax, CMT_PAGERLINE, NULL},
#ifdef USE_HISTORY
{"history", P_INT, PI_TEXT, (void *) &URLHistSize, CMT_HISTSIZE, NULL},
{"save_hist", P_INT, PI_ONOFF, (void *) &SaveURLHist, CMT_SAVEHIST, NULL},
@@ -626,6 +627,7 @@ show_params(FILE * fp)
case P_INT:
case P_SHORT:
case P_CHARINT:
+ case P_NZINT:
t = (sections[j].params[i].inputtype == PI_ONOFF) ? "bool" : "number";
break;
case P_CHAR:
@@ -812,8 +814,13 @@ set_param(char *name, char *value)
return 0;
switch (p->type) {
case P_INT:
- *(int *) p->varptr = (p->inputtype == PI_ONOFF)
+ if (atoi(value) >= 0)
+ *(int *) p->varptr = (p->inputtype == PI_ONOFF)
? str_to_bool(value, *(int *) p->varptr) : atoi(value);
+ break;
+ case P_NZINT:
+ if (atoi(value) > 0)
+ *(int *) p->varptr = atoi(value);
break;
case P_SHORT:
*(short *) p->varptr = (p->inputtype == PI_ONOFF)
@@ -1134,6 +1141,7 @@ to_str(struct param_ptr *p)
#ifdef COLOR
case P_COLOR:
#endif
+ case P_NZINT:
return Sprintf("%d", *(int *) p->varptr);
case P_SHORT:
return Sprintf("%d", *(short *) p->varptr);
diff --git a/regex.c b/regex.c
index 28686ee..e926872 100644
--- a/regex.c
+++ b/regex.c
@@ -210,6 +210,7 @@ regmatch(regexchar * re, char *str, int len, int firstp, char **lastpos)
char *lpos, *llpos = NULL;
longchar k;
+ *lastpos = NULL;
#ifdef REGEX_DEBUG
debugre(re, str);
#endif /* REGEX_DEBUG */
@@ -220,21 +221,16 @@ regmatch(regexchar * re, char *str, int len, int firstp, char **lastpos)
re++;
}
else if (re->mode & RE_ANYTIME) {
- short matched = 0, ok = 0;
- do {
+ short matched, ok = 0;
+ for (;;) {
+ matched = 0;
if (regmatch(re + 1, p, ep - p, firstp, &lpos) == 1) {
llpos = lpos;
matched = 1;
- }
- else if (matched) {
ok = 1;
- break;
}
- if (p >= ep) {
- if (matched)
- ok = 1;
+ if (p >= ep)
break;
- }
#ifdef JP_CHARSET
if (IS_KANJI1(*p)) {
k = RE_KANJI(p);
@@ -243,8 +239,6 @@ regmatch(regexchar * re, char *str, int len, int firstp, char **lastpos)
*lastpos = llpos;
p += 2;
}
- else if (matched)
- ok = 1;
else
break;
}
@@ -257,12 +251,10 @@ regmatch(regexchar * re, char *str, int len, int firstp, char **lastpos)
if (lastpos != NULL)
*lastpos = llpos;
}
- else if (matched)
- ok = 1;
else
- break;
+ break;
}
- } while (!ok);
+ }
if (lastpos != NULL)
*lastpos = llpos;
return ok;
diff --git a/scripts/bm2menu/README b/scripts/bm2menu/README
new file mode 100644
index 0000000..b44f144
--- /dev/null
+++ b/scripts/bm2menu/README
@@ -0,0 +1,21 @@
+
+bm2menu.pl
+
+ ¥Ö¥Ã¥¯¥Þ¡¼¥¯¥Õ¥¡¥¤¥ë ~/.w3m/bookmark.html ¤òÊÑ´¹¤·¤Æ w3m ¤Î
+ ¥Ö¥Ã¥¯¥Þ¡¼¥¯¥á¥Ë¥å¡¼¤È¤·¤Æ»È¤¨¤ëÍͤˤ¹¤ë¡£
+
+»ÈÍÑË¡
+
+ ~/.w3m/bookmark.html ¤òÊÑ´¹¤·¤Æ ~/.w3m/menu ¤ËÄɲá£
+
+ perl bm2menu.pl ~/.w3m/bookmark.html >> ~/.w3m/menu
+
+ ¼¡¤Ë¡¢~/.w3m/keymap ¤Ë
+
+ keymap x MENU Bookmarks
+
+ ¤ÎÍͤ˥­¡¼¤Î³ä¤êÅö¤Æ¤òÄɲä·¤Þ¤¹¡£
+
+ ¤³¤ì¤Ç¡¢¥­¡¼ `x' ¤Ç¥Ö¥Ã¥¯¥Þ¡¼¥¯¥á¥Ë¥å¡¼¤¬³«¤­¤Þ¤¹¡£
+ ¥á¥Ë¥å¡¼¤ÎÁàºî¤Ï doc-jp/README.menu ¤òÆɤó¤Ç¤¯¤À¤µ¤¤¡£
+
diff --git a/scripts/bm2menu/bm2menu.pl b/scripts/bm2menu/bm2menu.pl
new file mode 100644
index 0000000..d89f2b5
--- /dev/null
+++ b/scripts/bm2menu/bm2menu.pl
@@ -0,0 +1,58 @@
+#!/usr/bin/perl
+
+$PRE_MENU = "";
+$POST_MENU = <<EOF;
+ nop "----------------------"
+ func "¥Ö¥Ã¥¯¥Þ¡¼¥¯¤ËÄɲà (a)" ADD_BOOKMARK "aA"
+EOF
+# $POST_MENU = <<EOF;
+# nop "----------------------"
+# func "Add Bookmark (a)" ADD_BOOKMARK "aA"
+# EOF
+
+@section = ();
+%title = ();
+%url = ();
+while(<>) {
+ if (/<h2>(.*)<\/h2>/) {
+ $s = &unquote($1);
+ push(@section, $s);
+ } elsif (/<li><a href=\"(.*)\">(.*)<\/a>/) {
+ $u = &unquote($1);
+ $t = &unquote($2);
+ $url{$s} .= "$u\n";
+ $title{$s} .= "$t\n";
+ }
+}
+
+print "menu Bookmarks\n";
+print $PRE_MENU;
+foreach(@section) {
+ print " popup\t\"$_\"\t\"$_\"\n";
+}
+print $POST_MENU;
+print "end\n";
+
+foreach(@section) {
+ print "\n";
+ print "menu \"$_\"\n";
+ @ts = split("\n", $title{$_});
+ @us = split("\n", $url{$_});
+ while(@ts) {
+ $t = shift @ts;
+ $u = shift @us;
+ print " func\t\"$t\"\tGOTO\t\"\"\t\"$u\"\n";
+ }
+ print "end\n";
+}
+
+sub unquote {
+ local($_) = @_;
+
+ s/\&lt;/\</g;
+ s/\&gt;/\>/g;
+ s/\&nbsp;/ /g;
+ s/\&amp;/\&/g;
+
+ return $_;
+}
diff --git a/scripts/dirlist.cgi b/scripts/dirlist.cgi
index 618d4e5..2e723b4 100644
--- a/scripts/dirlist.cgi
+++ b/scripts/dirlist.cgi
@@ -1,4 +1,4 @@
-#!/usr/local/bin/perl
+#!/usr/bin/perl
#
# Directory list CGI by Hironori Sakamoto (hsaka@mth.biglobe.ne.jp)
#
diff --git a/scripts/multipart/Makefile b/scripts/multipart/Makefile
new file mode 100644
index 0000000..8f77b16
--- /dev/null
+++ b/scripts/multipart/Makefile
@@ -0,0 +1,35 @@
+
+prefix = /usr/local
+bindir = $(prefix)/bin
+libdir = $(prefix)/lib
+distdir = ./distfiles
+
+W3M_LIBDIR = $(libdir)/w3m
+
+INSTALL = install -c
+INSTALL_SCRIPT = $(INSTALL) -m 755
+
+PERL = /usr/local/bin/perl
+NKF = /usr/local/bin/nkf
+
+all: multipart.cgi
+
+multipart.cgi: multipart.cgi.in Makefile
+ sed -e 's%@PERL@%$(PERL)%g' \
+ -e 's%@NKF@%$(NKF)%g' \
+ multipart.cgi.in > multipart.cgi
+ chmod +x multipart.cgi
+
+install: multipart.cgi
+ $(INSTALL_SCRIPT) multipart.cgi $(W3M_LIBDIR)
+
+dist: all
+ @-rm -fr $(distdir)/multipart
+ mkdir -p $(distdir)/multipart
+ cp Makefile README multipart.cgi multipart.cgi.in \
+ $(distdir)/multipart
+ ( cd $(distdir); \
+ tar -cf - multipart | GZIP='' gzip ) \
+ > $(distdir)/multipart.tar.gz
+ -rm -fr $(distdir)/multipart
+
diff --git a/scripts/multipart/README b/scripts/multipart/README
new file mode 100644
index 0000000..54df29a
--- /dev/null
+++ b/scripts/multipart/README
@@ -0,0 +1,24 @@
+
+Content-Type: multipart/* ¤ò°·¤¦ local-CGI
+
+ Content-Type: multipart/* ¤Ê¥Õ¥¡¥¤¥ë¤ò°·¤¦¤¿¤á¤Î local-CGI ¤Ç¤¹¡£
+ ¼ç¤Ë mailx ¤Ê¤É¤Ç¥á¡¼¥ë¤ò PAGER="w3m -m" ¤ÇÆɤà¾ì¹ç¤òÁÛÄꤷ¤Æ¤¤¤Þ¤¹¡£
+
+¥¤¥ó¥¹¥È¡¼¥ë
+
+ * make install
+ ɬÍפʤé PERL, NKF, W3M_LIBDIR ¤òÀßÄꤷ¤Æ¤¯¤À¤µ¤¤¡£
+
+ * mailcap ¤ò ~/.w3m/mailcap ¤Ë¥Þ¡¼¥¸
+ multipart.cgi ¤Î¥Ñ¥¹¤ËÃí°Õ
+
+ * w3m ¤Î Option Setting Panel ¤Ç¡¢
+ ¡ØÊݸ»þ¤Ë Content-Transfer-Encoding ¤ò¥Ç¥³¡¼¥É¤¹¤ë¡Ù¤ò ON
+ źÉÕ¥Õ¥¡¥¤¥ë¤ÎÊݸ»þ¤ËÊØÍø¤Ç¤¹¡£
+
+ɬÍפʤâ¤Î
+
+ * NKF ¥â¥¸¥å¡¼¥ë¤Þ¤¿¤Ï nkf
+ ʸ»ú¥³¡¼¥ÉÊÑ´¹¤ä MIME ¥Ø¥Ã¥À¤Î¥Ç¥³¡¼¥É¤Ë¤ò»È¤Ã¤Æ¤Þ¤¹¡£
+ µ¤¤Ë¤¤¤é¤Ê¤±¤ì¤ÐÊѤ¨¤Æ¤¯¤À¤µ¤¤¡£
+
diff --git a/scripts/multipart/mailcap b/scripts/multipart/mailcap
new file mode 100644
index 0000000..323ee20
--- /dev/null
+++ b/scripts/multipart/mailcap
@@ -0,0 +1 @@
+multipart/*; /usr/local/lib/w3m/multipart.cgi %s %{boundary}; htmloutput
diff --git a/scripts/multipart/multipart.cgi b/scripts/multipart/multipart.cgi
new file mode 100644
index 0000000..e7c71e5
--- /dev/null
+++ b/scripts/multipart/multipart.cgi
@@ -0,0 +1,272 @@
+#!/usr/local/bin/perl
+
+if ($use_NKF = eval "use NKF;") {
+ $CONV = "-e";
+ $MIME_DECODE = "-m -e";
+} else {
+# $CONV = "w3m -dump -e";
+ $CONV = "/usr/local/bin/nkf -e";
+ $MIME_DECODE = "/usr/local/bin/nkf -m -e";
+}
+$MIME_TYPE = "$ENV{'HOME'}/.mime.types";
+
+if (defined($ENV{'QUERY_STRING'})) {
+ for (split('&', $ENV{'QUERY_STRING'})) {
+ s/^([^=]*)=//;
+ $v{$1} = $_;
+ }
+ $file = &form_decode($v{'file'});
+ $boundary = &form_decode($v{'boundary'});
+} else {
+ $file = $ARGV[0];
+ if (@ARGV >= 2) {
+ $boundary = $ARGV[1];
+ }
+ $CGI = "file:///\$LIB/multipart.cgi?file=" . &html_quote($file);
+}
+
+open(F, $file);
+$end = 0;
+$mbody = '';
+if (defined($boundary)) {
+ while(<F>) {
+ s/\r?\n$//;
+ ($_ eq "--$boundary") && last;
+ ($_ eq "--$boundary--") && ($end = 1, last);
+ $mbody .= "$_\n";
+ }
+} else {
+ while(<F>) {
+ s/\r?\n$//;
+ if (s/^\-\-//) {
+ $boundary = $_;
+ last;
+ }
+ $mbody .= "$_\n";
+ }
+}
+$CGI .= "&boundary=" . &html_quote($boundary);
+
+if (defined($v{'count'})) {
+ $count = 0;
+ while($count < $v{'count'}) {
+ while(<F>) {
+ s/\r?\n$//;
+ ($_ eq "--$boundary") && last;
+ }
+ eof(F) && exit;
+ $count++;
+ }
+
+ %header = ();
+ $hbody = '';
+ while(<F>) {
+ /^\s*$/ && last;
+ $x = $_;
+ s/\r?\n$//;
+ if (/=\?/) {
+ $_ = &decode($_, $MIME_DECODE);
+ }
+ if (s/^(\S+)\s*:\s*//) {
+ $hbody .= "$&$_\n";
+ $p = $1;
+ $p =~ tr/A-Z/a-z/;
+ $header{$p} = $_;
+ } elsif (s/^\s+//) {
+ chop $hbody;
+ $hbody .= "$_\n";
+ $header{$p} .= $_;
+ }
+ }
+ $type = $header{"content-type"};
+ $dispos = $header{"content-disposition"};
+ if ($type =~ /application\/octet-stream/) {
+ if ($type =~ /type\=gzip/) {
+ print "Content-Encoding: x-gzip\n";
+ }
+ if ($type =~ /name=\"?([^\"]+)\"?/ ||
+ $dispos =~ /filename=\"?([^\"]+)\"?/) {
+ $type = &guess_type($1);
+ if ($type) {
+ print "Content-Type: $type; name=\"$1\"\n";
+ } else {
+ print "Content-Type: text/plain; name=\"$1\"\n";
+ }
+ }
+ }
+ print $hbody;
+ print "\n";
+ while(<F>) {
+ $x = $_;
+ s/\r?\n$//;
+ ($_ eq "--$boundary") && last;
+ if ($_ eq "--$boundary--") {
+ last;
+ }
+ print $x;
+ }
+ close(F);
+ exit;
+}
+
+if ($mbody =~ /\S/) {
+ $_ = $mbody;
+ s/\&/\&amp;/g;
+ s/\</\&lt;/g;
+ s/\>/\&gt;/g;
+ print "<pre>\n";
+ print $_;
+ print "</pre>\n";
+}
+
+$count = 0;
+while(! $end) {
+ %header = ();
+ $hbody = '';
+ while(<F>) {
+ /^\s*$/ && last;
+ s/\r?\n$//;
+ if (/=\?/) {
+ $_ = &decode($_, $MIME_DECODE);
+ }
+ if (s/^(\S+)\s*:\s*//) {
+ $hbody .= "$&$_\n";
+ $p = $1;
+ $p =~ tr/A-Z/a-z/;
+ $header{$p} = $_;
+ } elsif (s/^\s+//) {
+ chop $hbody;
+ $hbody .= "$_\n";
+ $header{$p} .= $_;
+ }
+ }
+ $type = $header{"content-type"};
+ $dispos = $header{"content-disposition"};
+ if ((! $type || $type =~ /^text\/plain/i) &&
+ (! $dispos || $dispos =~ /^inline/i)) {
+ $plain = 1;
+ } else {
+ $plain = 0;
+ }
+ $body = '';
+ while(<F>) {
+ s/\r?\n$//;
+ ($_ eq "--$boundary") && last;
+ if ($_ eq "--$boundary--") {
+ $end = 1;
+ last;
+ }
+ if ($plain) {
+ $body .= "$_\n";
+ }
+ }
+ $| = 1;
+ print "<hr>\n";
+ {
+ $_ = $hbody;
+ s/\&/\&amp;/g;
+ s/\</\&lt;/g;
+ s/\>/\&gt;/g;
+ print "<pre>\n";
+ print $_;
+ if ($type =~ /name=\"?([^\"]+)\"?/ ||
+ $dispos =~ /filename=\"?([^\"]+)\"?/) {
+ $name = $1;
+ } else {
+ $name = "[Content]";
+ }
+ print "\n<a href=\"$CGI&count=$count\">", &html_quote($name), "</a>";
+ print "\n\n</pre>\n";
+ }
+ if ($plain) {
+ $body = &decode($body, $CONV);
+ $_ = $body;
+ s/\&/\&amp;/g;
+ s/\</\&lt;/g;
+ s/\>/\&gt;/g;
+ print "<pre>\n";
+ print $_;
+ print "</pre>\n";
+ }
+ eof(F) && last;
+ $count++;
+}
+close(F);
+
+sub decode {
+if ($use_NKF) {
+ local($body, $opt) = @_;
+ return nkf($opt, $body);
+}
+ local($body, @cmd) = @_;
+ local($_);
+
+ $| = 1;
+ pipe(R, W2);
+ pipe(R2, W);
+ if (! fork()) {
+ close(F);
+ close(R);
+ close(W);
+ open(STDIN, "<&R2");
+ open(STDOUT, ">&W2");
+ exec @cmd;
+ die;
+ }
+ close(R2);
+ close(W2);
+ print W $body;
+ close(W);
+ $body = '';
+ while(<R>) {
+ $body .= $_;
+ }
+ close(R);
+ return $body;
+}
+
+sub html_quote {
+ local($_) = @_;
+ local(%QUOTE) = (
+ '<', '&lt;',
+ '>', '&gt;',
+ '&', '&amp;',
+ '"', '&quot;',
+ );
+ s/[<>&"]/$QUOTE{$&}/g;
+ return $_;
+}
+
+sub form_decode {
+ local($_) = @_;
+ s/\+/ /g;
+ s/%([\da-f][\da-f])/pack('c', hex($1))/egi;
+ return $_;
+}
+
+sub guess_type {
+ local($_) = @_;
+
+ /\.(\w+)$/ || next;
+ $_ = $1;
+ tr/A-Z/a-z/;
+ %mime_type = &load_mime_type($MIME_TYPE);
+ $mime_type{$_};
+}
+
+sub load_mime_type {
+ local($file) = @_;
+ local(%m, $a, @b, $_);
+
+ open(M, $file) || return ();
+ while(<M>) {
+ /^#/ && next;
+ chop;
+ (($a, @b) = split(" ")) >= 2 || next;
+ for(@b) {
+ $m{$_} = $a;
+ }
+ }
+ close(M);
+ return %m;
+}
diff --git a/scripts/multipart/multipart.cgi.in b/scripts/multipart/multipart.cgi.in
new file mode 100644
index 0000000..be4e6a0
--- /dev/null
+++ b/scripts/multipart/multipart.cgi.in
@@ -0,0 +1,272 @@
+#!@PERL@
+
+if ($use_NKF = eval "use NKF;") {
+ $CONV = "-e";
+ $MIME_DECODE = "-m -e";
+} else {
+# $CONV = "w3m -dump -e";
+ $CONV = "@NKF@ -e";
+ $MIME_DECODE = "@NKF@ -m -e";
+}
+$MIME_TYPE = "$ENV{'HOME'}/.mime.types";
+
+if (defined($ENV{'QUERY_STRING'})) {
+ for (split('&', $ENV{'QUERY_STRING'})) {
+ s/^([^=]*)=//;
+ $v{$1} = $_;
+ }
+ $file = &form_decode($v{'file'});
+ $boundary = &form_decode($v{'boundary'});
+} else {
+ $file = $ARGV[0];
+ if (@ARGV >= 2) {
+ $boundary = $ARGV[1];
+ }
+ $CGI = "file:///\$LIB/multipart.cgi?file=" . &html_quote($file);
+}
+
+open(F, $file);
+$end = 0;
+$mbody = '';
+if (defined($boundary)) {
+ while(<F>) {
+ s/\r?\n$//;
+ ($_ eq "--$boundary") && last;
+ ($_ eq "--$boundary--") && ($end = 1, last);
+ $mbody .= "$_\n";
+ }
+} else {
+ while(<F>) {
+ s/\r?\n$//;
+ if (s/^\-\-//) {
+ $boundary = $_;
+ last;
+ }
+ $mbody .= "$_\n";
+ }
+}
+$CGI .= "&boundary=" . &html_quote($boundary);
+
+if (defined($v{'count'})) {
+ $count = 0;
+ while($count < $v{'count'}) {
+ while(<F>) {
+ s/\r?\n$//;
+ ($_ eq "--$boundary") && last;
+ }
+ eof(F) && exit;
+ $count++;
+ }
+
+ %header = ();
+ $hbody = '';
+ while(<F>) {
+ /^\s*$/ && last;
+ $x = $_;
+ s/\r?\n$//;
+ if (/=\?/) {
+ $_ = &decode($_, $MIME_DECODE);
+ }
+ if (s/^(\S+)\s*:\s*//) {
+ $hbody .= "$&$_\n";
+ $p = $1;
+ $p =~ tr/A-Z/a-z/;
+ $header{$p} = $_;
+ } elsif (s/^\s+//) {
+ chop $hbody;
+ $hbody .= "$_\n";
+ $header{$p} .= $_;
+ }
+ }
+ $type = $header{"content-type"};
+ $dispos = $header{"content-disposition"};
+ if ($type =~ /application\/octet-stream/) {
+ if ($type =~ /type\=gzip/) {
+ print "Content-Encoding: x-gzip\n";
+ }
+ if ($type =~ /name=\"?([^\"]+)\"?/ ||
+ $dispos =~ /filename=\"?([^\"]+)\"?/) {
+ $type = &guess_type($1);
+ if ($type) {
+ print "Content-Type: $type; name=\"$1\"\n";
+ } else {
+ print "Content-Type: text/plain; name=\"$1\"\n";
+ }
+ }
+ }
+ print $hbody;
+ print "\n";
+ while(<F>) {
+ $x = $_;
+ s/\r?\n$//;
+ ($_ eq "--$boundary") && last;
+ if ($_ eq "--$boundary--") {
+ last;
+ }
+ print $x;
+ }
+ close(F);
+ exit;
+}
+
+if ($mbody =~ /\S/) {
+ $_ = $mbody;
+ s/\&/\&amp;/g;
+ s/\</\&lt;/g;
+ s/\>/\&gt;/g;
+ print "<pre>\n";
+ print $_;
+ print "</pre>\n";
+}
+
+$count = 0;
+while(! $end) {
+ %header = ();
+ $hbody = '';
+ while(<F>) {
+ /^\s*$/ && last;
+ s/\r?\n$//;
+ if (/=\?/) {
+ $_ = &decode($_, $MIME_DECODE);
+ }
+ if (s/^(\S+)\s*:\s*//) {
+ $hbody .= "$&$_\n";
+ $p = $1;
+ $p =~ tr/A-Z/a-z/;
+ $header{$p} = $_;
+ } elsif (s/^\s+//) {
+ chop $hbody;
+ $hbody .= "$_\n";
+ $header{$p} .= $_;
+ }
+ }
+ $type = $header{"content-type"};
+ $dispos = $header{"content-disposition"};
+ if ((! $type || $type =~ /^text\/plain/i) &&
+ (! $dispos || $dispos =~ /^inline/i)) {
+ $plain = 1;
+ } else {
+ $plain = 0;
+ }
+ $body = '';
+ while(<F>) {
+ s/\r?\n$//;
+ ($_ eq "--$boundary") && last;
+ if ($_ eq "--$boundary--") {
+ $end = 1;
+ last;
+ }
+ if ($plain) {
+ $body .= "$_\n";
+ }
+ }
+ $| = 1;
+ print "<hr>\n";
+ {
+ $_ = $hbody;
+ s/\&/\&amp;/g;
+ s/\</\&lt;/g;
+ s/\>/\&gt;/g;
+ print "<pre>\n";
+ print $_;
+ if ($type =~ /name=\"?([^\"]+)\"?/ ||
+ $dispos =~ /filename=\"?([^\"]+)\"?/) {
+ $name = $1;
+ } else {
+ $name = "[Content]";
+ }
+ print "\n<a href=\"$CGI&count=$count\">", &html_quote($name), "</a>";
+ print "\n\n</pre>\n";
+ }
+ if ($plain) {
+ $body = &decode($body, $CONV);
+ $_ = $body;
+ s/\&/\&amp;/g;
+ s/\</\&lt;/g;
+ s/\>/\&gt;/g;
+ print "<pre>\n";
+ print $_;
+ print "</pre>\n";
+ }
+ eof(F) && last;
+ $count++;
+}
+close(F);
+
+sub decode {
+if ($use_NKF) {
+ local($body, $opt) = @_;
+ return nkf($opt, $body);
+}
+ local($body, @cmd) = @_;
+ local($_);
+
+ $| = 1;
+ pipe(R, W2);
+ pipe(R2, W);
+ if (! fork()) {
+ close(F);
+ close(R);
+ close(W);
+ open(STDIN, "<&R2");
+ open(STDOUT, ">&W2");
+ exec @cmd;
+ die;
+ }
+ close(R2);
+ close(W2);
+ print W $body;
+ close(W);
+ $body = '';
+ while(<R>) {
+ $body .= $_;
+ }
+ close(R);
+ return $body;
+}
+
+sub html_quote {
+ local($_) = @_;
+ local(%QUOTE) = (
+ '<', '&lt;',
+ '>', '&gt;',
+ '&', '&amp;',
+ '"', '&quot;',
+ );
+ s/[<>&"]/$QUOTE{$&}/g;
+ return $_;
+}
+
+sub form_decode {
+ local($_) = @_;
+ s/\+/ /g;
+ s/%([\da-f][\da-f])/pack('c', hex($1))/egi;
+ return $_;
+}
+
+sub guess_type {
+ local($_) = @_;
+
+ /\.(\w+)$/ || next;
+ $_ = $1;
+ tr/A-Z/a-z/;
+ %mime_type = &load_mime_type($MIME_TYPE);
+ $mime_type{$_};
+}
+
+sub load_mime_type {
+ local($file) = @_;
+ local(%m, $a, @b, $_);
+
+ open(M, $file) || return ();
+ while(<M>) {
+ /^#/ && next;
+ chop;
+ (($a, @b) = split(" ")) >= 2 || next;
+ for(@b) {
+ $m{$_} = $a;
+ }
+ }
+ close(M);
+ return %m;
+}
diff --git a/scripts/w3mman/Makefile b/scripts/w3mman/Makefile
new file mode 100644
index 0000000..1e596e0
--- /dev/null
+++ b/scripts/w3mman/Makefile
@@ -0,0 +1,46 @@
+
+prefix = /usr/local
+bindir = $(prefix)/bin
+libdir = $(prefix)/lib
+distdir = ./distfiles
+
+W3M_LIBDIR = $(libdir)/w3m
+
+INSTALL = install -c
+INSTALL_SCRIPT = $(INSTALL) -m 755
+
+PERL = /usr/local/bin/perl
+W3M = w3m
+# W3M = w3m -X -o confirm_qq=0
+MAN = man
+
+all: w3mman w3mman2html.cgi
+
+w3mman: w3mman.in Makefile
+ sed -e 's%@PERL@%$(PERL)%g' \
+ -e 's%@W3M@%$(W3M)%g' \
+ -e 's%@MAN@%$(MAN)%g' \
+ w3mman.in > w3mman
+ chmod +x w3mman
+
+w3mman2html.cgi: w3mman2html.cgi.in Makefile
+ sed -e 's%@PERL@%$(PERL)%g' \
+ -e 's%@MAN@%$(MAN)%g' \
+ w3mman2html.cgi.in > w3mman2html.cgi
+ chmod +x w3mman2html.cgi
+
+install: w3mman w3mman2html.cgi
+ $(INSTALL_SCRIPT) w3mman $(bindir)
+ $(INSTALL_SCRIPT) w3mman2html.cgi $(W3M_LIBDIR)
+
+dist: all
+ @-rm -fr $(distdir)/w3mman
+ mkdir -p $(distdir)/w3mman
+ cp Makefile README w3mman w3mman.in \
+ w3mman2html.cgi w3mman2html.cgi.in hlink.cgi \
+ $(distdir)/w3mman
+ ( cd $(distdir); \
+ tar -cf - w3mman | GZIP='' gzip ) \
+ > $(distdir)/w3mman.tar.gz
+ -rm -fr $(distdir)/w3mman
+
diff --git a/scripts/w3mman/README b/scripts/w3mman/README
new file mode 100644
index 0000000..699e068
--- /dev/null
+++ b/scripts/w3mman/README
@@ -0,0 +1,47 @@
+
+w3mman
+
+ ¾¤Î¥Þ¥Ë¥å¥¢¥ë¤ä¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë¤Ë¥ê¥ó¥¯¤ò¤Ï¤ë¤³¤È¤¬¤Ç¤­¤ë
+ man ¥³¥Þ¥ó¥É¤ÎÂåÂØ¥³¥Þ¥ó¥É¤Ç¤¹¡£
+
+»ÈÍÑË¡
+
+ w3mman
+ w3mman <command>[(<section>)]
+ w3mman [<section>] <command>
+ w3mman -k <keyword>
+
+¥¤¥ó¥¹¥È¡¼¥ë
+
+ make install
+ ɬÍפʤé PERL, MAN, W3M_LIBDIR ¤òÀßÄꤷ¤Æ¤¯¤À¤µ¤¤¡£
+ w3mman2html.cgi ¤â¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Þ¤¹¡£
+
+================
+
+w3mman2html.cgi
+
+»ÈÍÑË¡
+
+ w3m file:///$LIB/w3mman2html.cgi
+ w3m file:///$LIB/w3mman2html.cgi?<command>[(<section>)]
+ w3m file:///$LIB/w3mman2html.cgi?man=<command>[&section=<section>]
+ w3m file:///$LIB/w3mman2html.cgi?keyword=<keyword>
+
+¥¤¥ó¥¹¥È¡¼¥ë
+
+ make install
+ ɬÍפʤé PERL, MAN, W3M_LIBDIR ¤òÀßÄꤷ¤Æ¤¯¤À¤µ¤¤¡£
+ w3mman ¤â¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Þ¤¹¡£
+
+================
+
+hlink.cgi
+
+ ¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë¤Ê¤É¤Ë¥ê¥ó¥¯¤òÄ¥¤ë
+
+¥¤¥ó¥¹¥È¡¼¥ë
+
+ /$LIB/ ¤Ë¥³¥Ô¡¼
+ w3mman2html.cgi ¤Ç»ÈÍѤ¹¤ë¤Ê¤é¤Ð $CGI2 ¤ËÀßÄꤷ¤Æ¤¯¤À¤µ¤¤¡£
+
diff --git a/scripts/w3mman/hlink.cgi b/scripts/w3mman/hlink.cgi
new file mode 100644
index 0000000..a92ac1d
--- /dev/null
+++ b/scripts/w3mman/hlink.cgi
@@ -0,0 +1,97 @@
+#!/usr/local/bin/perl
+
+$SCRIPT_NAME = $ENV{'SCRIPT_NAME'} || $0;
+$CGI = "file://$SCRIPT_NAME?";
+
+if ($ENV{'QUERY_STRING'}) {
+ $file = $ENV{'QUERY_STRING'};
+} else {
+ $file = $ARGV[0];
+}
+$file = &cleanup($file);
+
+if (-d $file) {
+ print <<EOF;
+Location: file:$file
+EOF
+ exit;
+}
+if (! open(FILE, "< $file")) {
+ $file = &html_quote($file);
+ $_ = "$file: " . &html_quote($!);
+ print <<EOF;
+Content-Type: text/html
+
+<head><title>$file</title></head>
+<b>$_</b>
+EOF
+ exit 1;
+}
+
+$file = &html_quote($file);
+($dir = $file) =~ s@[^/]*$@@;
+
+print <<EOF;
+Content-Type: text/html
+
+<head><title>$file</title></head>
+<pre>
+EOF
+while (<FILE>) {
+ $_ = &html_quote($_);
+
+ s/^(\#\s*include\s+)(\&quot;.*\&quot;|\&lt\;.*\&gt\;)/$1 . &header_ref($2)/ge;
+
+ print;
+}
+close(FILE);
+print "</pre>\n";
+
+sub header_ref {
+ local($_) = @_;
+ local($d);
+
+ if (s/^\&quot;//) {
+ s/\&quot;$//;
+ return "&quot;<a href=\"$CGI$dir$_\">$_</a>&quot;";
+ }
+ s/^\&lt\;//;
+ s/\&gt\;$//;
+
+ for $d (
+ "/usr/include",
+ "/usr/local/include",
+ "/usr/X11R6/include",
+ "/usr/X11/include",
+ "/usr/X/include",
+ "/usr/include/X11"
+ ) {
+ -f "$d/$_" && return "&lt;<a href=\"$CGI$d/$_\">$_</a>&gt;";
+ }
+ return $_;
+}
+
+
+sub html_quote {
+ local($_) = @_;
+ local(%QUOTE) = (
+ '<', '&lt;',
+ '>', '&gt;',
+ '&', '&amp;',
+ '"', '&quot;',
+ );
+ s/[<>&"]/$QUOTE{$&}/g;
+ return $_;
+}
+
+sub cleanup {
+ local($_) = @_;
+
+ s@//+@/@g;
+ s@/\./@/@g;
+ while(m@/\.\./@) {
+ s@^/(\.\./)+@/@;
+ s@/[^/]+/\.\./@/@;
+ }
+ return $_;
+}
diff --git a/scripts/w3mman/w3mman b/scripts/w3mman/w3mman
new file mode 100644
index 0000000..44aba2f
--- /dev/null
+++ b/scripts/w3mman/w3mman
@@ -0,0 +1,41 @@
+#!/usr/local/bin/perl
+
+@W3M = split(' ', 'w3m');
+$ENV{'MAN'} = 'man';
+$SCRIPT = 'file:///$LIB/w3mman2html.cgi';
+
+sub usage {
+ ($_ = $0) =~ s@.*/@@;
+ print STDERR "$_ [-M <path>] [[<section>] <command>]\n";
+ print STDERR "$_ [-M <path>] [-k <keyword>]\n";
+ exit 1;
+}
+
+$query = "";
+while (@ARGV) {
+ $_ = shift @ARGV;
+ if (/^-M$/) {
+ @ARGV || &usage();
+ $ENV{'MANPATH'} = shift @ARGV;
+ } elsif (/^-k$/) {
+ @ARGV || &usage();
+ $query = "?keyword=" . &form_encode(shift @ARGV);
+ } elsif (/^-/) {
+ &usage();
+ } elsif (/^\d/ || $_ eq 'n') {
+ @ARGV || &usage();
+ $query = "?quit=ok&man=" . &form_encode(shift @ARGV);
+ $query .= "&section=" . &form_encode($_);
+ } else {
+ $query = "?quit=ok&man=" . &form_encode($_);
+ }
+}
+
+exec @W3M, "$SCRIPT$query";
+
+sub form_encode {
+ local($_) = @_;
+ s/[\000-\040\+:#?&%<>"\177-\377]/sprintf('%%%02X', unpack('C', $&))/eg;
+ return $_;
+}
+
diff --git a/scripts/w3mman/w3mman.in b/scripts/w3mman/w3mman.in
new file mode 100644
index 0000000..0c57135
--- /dev/null
+++ b/scripts/w3mman/w3mman.in
@@ -0,0 +1,41 @@
+#!@PERL@
+
+@W3M = split(' ', '@W3M@');
+$ENV{'MAN'} = '@MAN@';
+$SCRIPT = 'file:///$LIB/w3mman2html.cgi';
+
+sub usage {
+ ($_ = $0) =~ s@.*/@@;
+ print STDERR "$_ [-M <path>] [[<section>] <command>]\n";
+ print STDERR "$_ [-M <path>] [-k <keyword>]\n";
+ exit 1;
+}
+
+$query = "";
+while (@ARGV) {
+ $_ = shift @ARGV;
+ if (/^-M$/) {
+ @ARGV || &usage();
+ $ENV{'MANPATH'} = shift @ARGV;
+ } elsif (/^-k$/) {
+ @ARGV || &usage();
+ $query = "?keyword=" . &form_encode(shift @ARGV);
+ } elsif (/^-/) {
+ &usage();
+ } elsif (/^\d/ || $_ eq 'n') {
+ @ARGV || &usage();
+ $query = "?quit=ok&man=" . &form_encode(shift @ARGV);
+ $query .= "&section=" . &form_encode($_);
+ } else {
+ $query = "?quit=ok&man=" . &form_encode($_);
+ }
+}
+
+exec @W3M, "$SCRIPT$query";
+
+sub form_encode {
+ local($_) = @_;
+ s/[\000-\040\+:#?&%<>"\177-\377]/sprintf('%%%02X', unpack('C', $&))/eg;
+ return $_;
+}
+
diff --git a/scripts/w3mman/w3mman2html.cgi b/scripts/w3mman/w3mman2html.cgi
new file mode 100644
index 0000000..0f75502
--- /dev/null
+++ b/scripts/w3mman/w3mman2html.cgi
@@ -0,0 +1,252 @@
+#!/usr/local/bin/perl
+
+$MAN = $ENV{'MAN'} || 'man';
+$QUERY = $ENV{'QUERY_STRING'} || $ARGV[0];
+$SCRIPT_NAME = $ENV{'SCRIPT_NAME'} || $0;
+$CGI = "file://$SCRIPT_NAME";
+$CGI2 = "file:";
+# $CGI2 = "file:///\$LIB/hlink.cgi?";
+$SQUEEZE = 1;
+
+if ($QUERY =~ /\=/) {
+ for (split('&', $QUERY)) {
+ ($v, $q) = split('=', $_, 2);
+ $query{$v} = &form_decode($q);
+ }
+} else {
+ $QUERY =~ s/^man=//;
+ $query{"man"} = &form_decode($QUERY);
+}
+
+if (! $query{"man"}) {
+ if ($query{"keyword"}) {
+ $keyword = $query{"keyword"};
+ $k = &html_quote($keyword);
+ print <<EOF;
+Content-Type: text/html
+
+<html>
+<head><title>man -k $k</title></head>
+<body>
+<h2>man -k <b>$k</b></h2>
+<ul>
+EOF
+ $keyword =~ s:([^\w./]):\\$1:g;
+ open(F, "$MAN -k $keyword 2> /dev/null |");
+ @line = ();
+ while(<F>) {
+ chop;
+ $_ = &html_quote($_);
+ s/(\s+-.*)$//;
+ $title = $1;
+ s@(\w[\w.\-]*(\s*\,\s*\w[\w.\-]*)*)\s*(\([\dn]\w*\))@&keyword_ref($1, $3)@ge;
+ print "<li>$_$title\n";
+ }
+ close(F);
+ print <<EOF;
+</ul>
+</body>
+</html>
+EOF
+ exit;
+ }
+ print <<EOF;
+Content-Type: text/html
+
+<html>
+<head><title>man</title></head>
+<body>
+<form action="$CGI">
+<table>
+<tr><td>Manual:<td><input name=man>
+<tr><td>Section:<td><input name=section>
+<tr><td>Keyword:<td><input name=keyword>
+<tr><td><td><input type=submit> <input type=reset>
+</table>
+</form>
+</body>
+</html>
+EOF
+ exit;
+}
+
+$man = $query{"man"};
+if ($man =~ s/\((\w+)\)$//) {
+ $section = $1;
+ $man_section = "$man($1)";
+} elsif ($query{"section"}) {
+ $section = $query{"section"};
+ $man_section = "$man($section)";
+} else {
+ $section = "";
+ $man_section = "$man";
+}
+
+$section =~ s:([^\w./]):\\$1:g;
+$man =~ s:([^\w./]):\\$1:g;
+open(F, "$MAN $section $man 2> /dev/null |");
+$ok = 0;
+undef $header;
+$blank = -1;
+while(<F>) {
+ if (! defined($header)) {
+ /^\s*$/ && next;
+ $header = $_;
+ $space = $header;
+ chop $space;
+ $space =~ s/\S.*//;
+ } elsif ($_ eq $header) { # delete header
+ $blank = -1;
+ next;
+ } elsif (!/\010/ && /^$space[\w\200-\377].*\s\S/o) { # delete footer
+ $blank = -1;
+ next;
+ }
+ if ($SQUEEZE) {
+ if (/^\s*$/) {
+ $blank || $blank++;
+ next;
+ } elsif ($blank) {
+ $blank > 0 && print "\n";
+ $blank = 0;
+ }
+ }
+
+ s/\&/\&amp;/g;
+ s/\</\&lt;/g;
+ s/\>/\&gt;/g;
+
+ s@([\200-\377].)(\010{1,2}\1)+@<b>$1</b>@g;
+ s@(\&\w+;|.)(\010\1)+@<b>$1</b>@g;
+ s@__\010{1,2}((\<b\>)?[\200-\377].(\</b\>)?)@<u>$1</u>@g;
+ s@_\010((\<b\>)?(\&\w+\;|.)(\</b\>)?)@<u>$1</u>@g;
+ s@((\<b\>)?[\200-\377].(\</b\>)?)\010{1,2}__@<u>$1</u>@g;
+ s@((\<b\>)?(\&\w+\;|.)(\</b\>)?)\010_@<u>$1</u>@g;
+ s@.\010(.)@$1@g;
+
+ s@\</b\>\</u\>\<b\>_\</b\>\<u\>\<b\>@_@g;
+ s@\</u\>\<b\>_\</b\>\<u\>@_@g;
+ s@\</u\>\<u\>@@g;
+ s@\</b\>\<b\>@@g;
+
+ if (! $ok) {
+ /^No/ && last;
+ print <<EOF;
+Content-Type: text/html
+
+<html>
+<head><title>man $man_section</title></head>
+<body>
+<pre>
+EOF
+ print;
+ $ok = 1;
+ next;
+ }
+
+ s@(http|ftp)://[\w.\-/~]+[\w/]@<a href="$&">$&</a>@g;
+ s@(\W)(mailto:)?(\w[\w.\-]*\@\w[\w.\-]*\.[\w.\-]*\w)@$1<a href="mailto:$3">$2$3</a>@g;
+ s@(\W)(\~?/[\w.][/\w.\-]*)@$1 . &file_ref($2)@ge;
+ s@(include(<\/?[bu]\>|\s)*\&lt;)([/\w.\-]+)@$1 . &include_ref($3)@ge;
+ s@(\w[\w.\-]*)((\</[bu]\>)*)(\([\dm]\w*\))@<a href="$CGI?$1$4">$1</a>$2$4@g;
+ print;
+}
+close(F);
+if (! $ok) {
+ if ($query{'quit'}) {
+ print STDERR "No manual entry for $man_section.\n";
+ print <<EOF;
+w3m-control: EXIT
+EOF
+ exit 1;
+ }
+ print <<EOF;
+Content-Type: text/html
+
+<html>
+<head><title>man $man_section</title></head>
+<body>
+<pre>
+EOF
+ print "No manual entry for <B>$man_section</B>.\n";
+}
+print <<EOF;
+</pre>
+</body>
+</html>
+EOF
+
+sub is_command {
+ local($_) = @_;
+ local($p);
+
+ (! -d && -x) || return 0;
+ if (! defined(%PATH)) {
+ for $p (split(":", $ENV{'PATH'})) {
+ $p =~ s@/+$@@;
+ $PATH{$p} = 1;
+ }
+ }
+ s@/[^/]*$@@;
+ return defined($PATH{$_});
+}
+
+sub file_ref {
+ local($_) = @_;
+
+ if (&is_command($_)) {
+ ($man = $_) =~ s@.*/@@;
+ return "<a href=\"$CGI?$man\">$_</a>";
+ }
+ if (/^\~/ || -f || -d) {
+ return "<a href=\"$CGI2$_\">$_</a>";
+ }
+ return $_;
+}
+
+sub include_ref {
+ local($_) = @_;
+ local($d);
+
+ for $d (
+ "/usr/include",
+ "/usr/local/include",
+ "/usr/X11R6/include",
+ "/usr/X11/include",
+ "/usr/X/include",
+ "/usr/include/X11"
+ ) {
+ -f "$d/$_" && return "<a href=\"$CGI2$d/$_\">$_</a>";
+ }
+ return $_;
+}
+
+sub keyword_ref {
+ local($_, $s) = @_;
+ local(@a) = ();
+
+ for (split(/\s*,\s*/)) {
+ push(@a, "<a href=\"$CGI?$_$s\">$_</a>");
+ }
+ return join(", ", @a) . $s;
+}
+
+sub html_quote {
+ local($_) = @_;
+ local(%QUOTE) = (
+ '<', '&lt;',
+ '>', '&gt;',
+ '&', '&amp;',
+ '"', '&quot;',
+ );
+ s/[<>&"]/$QUOTE{$&}/g;
+ return $_;
+}
+
+sub form_decode {
+ local($_) = @_;
+ s/\+/ /g;
+ s/%([\da-f][\da-f])/pack('c', hex($1))/egi;
+ return $_;
+}
+
diff --git a/scripts/w3mman/w3mman2html.cgi.in b/scripts/w3mman/w3mman2html.cgi.in
new file mode 100644
index 0000000..68f318a
--- /dev/null
+++ b/scripts/w3mman/w3mman2html.cgi.in
@@ -0,0 +1,252 @@
+#!@PERL@
+
+$MAN = $ENV{'MAN'} || '@MAN@';
+$QUERY = $ENV{'QUERY_STRING'} || $ARGV[0];
+$SCRIPT_NAME = $ENV{'SCRIPT_NAME'} || $0;
+$CGI = "file://$SCRIPT_NAME";
+$CGI2 = "file:";
+# $CGI2 = "file:///\$LIB/hlink.cgi?";
+$SQUEEZE = 1;
+
+if ($QUERY =~ /\=/) {
+ for (split('&', $QUERY)) {
+ ($v, $q) = split('=', $_, 2);
+ $query{$v} = &form_decode($q);
+ }
+} else {
+ $QUERY =~ s/^man=//;
+ $query{"man"} = &form_decode($QUERY);
+}
+
+if (! $query{"man"}) {
+ if ($query{"keyword"}) {
+ $keyword = $query{"keyword"};
+ $k = &html_quote($keyword);
+ print <<EOF;
+Content-Type: text/html
+
+<html>
+<head><title>man -k $k</title></head>
+<body>
+<h2>man -k <b>$k</b></h2>
+<ul>
+EOF
+ $keyword =~ s:([^\w./]):\\$1:g;
+ open(F, "$MAN -k $keyword 2> /dev/null |");
+ @line = ();
+ while(<F>) {
+ chop;
+ $_ = &html_quote($_);
+ s/(\s+-.*)$//;
+ $title = $1;
+ s@(\w[\w.\-]*(\s*\,\s*\w[\w.\-]*)*)\s*(\([\dn]\w*\))@&keyword_ref($1, $3)@ge;
+ print "<li>$_$title\n";
+ }
+ close(F);
+ print <<EOF;
+</ul>
+</body>
+</html>
+EOF
+ exit;
+ }
+ print <<EOF;
+Content-Type: text/html
+
+<html>
+<head><title>man</title></head>
+<body>
+<form action="$CGI">
+<table>
+<tr><td>Manual:<td><input name=man>
+<tr><td>Section:<td><input name=section>
+<tr><td>Keyword:<td><input name=keyword>
+<tr><td><td><input type=submit> <input type=reset>
+</table>
+</form>
+</body>
+</html>
+EOF
+ exit;
+}
+
+$man = $query{"man"};
+if ($man =~ s/\((\w+)\)$//) {
+ $section = $1;
+ $man_section = "$man($1)";
+} elsif ($query{"section"}) {
+ $section = $query{"section"};
+ $man_section = "$man($section)";
+} else {
+ $section = "";
+ $man_section = "$man";
+}
+
+$section =~ s:([^\w./]):\\$1:g;
+$man =~ s:([^\w./]):\\$1:g;
+open(F, "$MAN $section $man 2> /dev/null |");
+$ok = 0;
+undef $header;
+$blank = -1;
+while(<F>) {
+ if (! defined($header)) {
+ /^\s*$/ && next;
+ $header = $_;
+ $space = $header;
+ chop $space;
+ $space =~ s/\S.*//;
+ } elsif ($_ eq $header) { # delete header
+ $blank = -1;
+ next;
+ } elsif (!/\010/ && /^$space[\w\200-\377].*\s\S/o) { # delete footer
+ $blank = -1;
+ next;
+ }
+ if ($SQUEEZE) {
+ if (/^\s*$/) {
+ $blank || $blank++;
+ next;
+ } elsif ($blank) {
+ $blank > 0 && print "\n";
+ $blank = 0;
+ }
+ }
+
+ s/\&/\&amp;/g;
+ s/\</\&lt;/g;
+ s/\>/\&gt;/g;
+
+ s@([\200-\377].)(\010{1,2}\1)+@<b>$1</b>@g;
+ s@(\&\w+;|.)(\010\1)+@<b>$1</b>@g;
+ s@__\010{1,2}((\<b\>)?[\200-\377].(\</b\>)?)@<u>$1</u>@g;
+ s@_\010((\<b\>)?(\&\w+\;|.)(\</b\>)?)@<u>$1</u>@g;
+ s@((\<b\>)?[\200-\377].(\</b\>)?)\010{1,2}__@<u>$1</u>@g;
+ s@((\<b\>)?(\&\w+\;|.)(\</b\>)?)\010_@<u>$1</u>@g;
+ s@.\010(.)@$1@g;
+
+ s@\</b\>\</u\>\<b\>_\</b\>\<u\>\<b\>@_@g;
+ s@\</u\>\<b\>_\</b\>\<u\>@_@g;
+ s@\</u\>\<u\>@@g;
+ s@\</b\>\<b\>@@g;
+
+ if (! $ok) {
+ /^No/ && last;
+ print <<EOF;
+Content-Type: text/html
+
+<html>
+<head><title>man $man_section</title></head>
+<body>
+<pre>
+EOF
+ print;
+ $ok = 1;
+ next;
+ }
+
+ s@(http|ftp)://[\w.\-/~]+[\w/]@<a href="$&">$&</a>@g;
+ s@(\W)(mailto:)?(\w[\w.\-]*\@\w[\w.\-]*\.[\w.\-]*\w)@$1<a href="mailto:$3">$2$3</a>@g;
+ s@(\W)(\~?/[\w.][/\w.\-]*)@$1 . &file_ref($2)@ge;
+ s@(include(<\/?[bu]\>|\s)*\&lt;)([/\w.\-]+)@$1 . &include_ref($3)@ge;
+ s@(\w[\w.\-]*)((\</[bu]\>)*)(\([\dm]\w*\))@<a href="$CGI?$1$4">$1</a>$2$4@g;
+ print;
+}
+close(F);
+if (! $ok) {
+ if ($query{'quit'}) {
+ print STDERR "No manual entry for $man_section.\n";
+ print <<EOF;
+w3m-control: EXIT
+EOF
+ exit 1;
+ }
+ print <<EOF;
+Content-Type: text/html
+
+<html>
+<head><title>man $man_section</title></head>
+<body>
+<pre>
+EOF
+ print "No manual entry for <B>$man_section</B>.\n";
+}
+print <<EOF;
+</pre>
+</body>
+</html>
+EOF
+
+sub is_command {
+ local($_) = @_;
+ local($p);
+
+ (! -d && -x) || return 0;
+ if (! defined(%PATH)) {
+ for $p (split(":", $ENV{'PATH'})) {
+ $p =~ s@/+$@@;
+ $PATH{$p} = 1;
+ }
+ }
+ s@/[^/]*$@@;
+ return defined($PATH{$_});
+}
+
+sub file_ref {
+ local($_) = @_;
+
+ if (&is_command($_)) {
+ ($man = $_) =~ s@.*/@@;
+ return "<a href=\"$CGI?$man\">$_</a>";
+ }
+ if (/^\~/ || -f || -d) {
+ return "<a href=\"$CGI2$_\">$_</a>";
+ }
+ return $_;
+}
+
+sub include_ref {
+ local($_) = @_;
+ local($d);
+
+ for $d (
+ "/usr/include",
+ "/usr/local/include",
+ "/usr/X11R6/include",
+ "/usr/X11/include",
+ "/usr/X/include",
+ "/usr/include/X11"
+ ) {
+ -f "$d/$_" && return "<a href=\"$CGI2$d/$_\">$_</a>";
+ }
+ return $_;
+}
+
+sub keyword_ref {
+ local($_, $s) = @_;
+ local(@a) = ();
+
+ for (split(/\s*,\s*/)) {
+ push(@a, "<a href=\"$CGI?$_$s\">$_</a>");
+ }
+ return join(", ", @a) . $s;
+}
+
+sub html_quote {
+ local($_) = @_;
+ local(%QUOTE) = (
+ '<', '&lt;',
+ '>', '&gt;',
+ '&', '&amp;',
+ '"', '&quot;',
+ );
+ s/[<>&"]/$QUOTE{$&}/g;
+ return $_;
+}
+
+sub form_decode {
+ local($_) = @_;
+ s/\+/ /g;
+ s/%([\da-f][\da-f])/pack('c', hex($1))/egi;
+ return $_;
+}
+
diff --git a/table.c b/table.c
index 00d3b2d..810a5d9 100644
--- a/table.c
+++ b/table.c
@@ -1,4 +1,4 @@
-/* $Id: table.c,v 1.2 2001/11/09 04:59:18 a-ito Exp $ */
+/* $Id: table.c,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */
/*
* HTML table
*/
diff --git a/table.h b/table.h
index 532c803..6076b4b 100644
--- a/table.h
+++ b/table.h
@@ -1,4 +1,4 @@
-/* $Id: table.h,v 1.2 2001/11/09 04:59:18 a-ito Exp $ */
+/* $Id: table.h,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */
#if (defined(MESCHACH) && !defined(MATRIX))
#define MATRIX
#endif /* (defined(MESCHACH) && !defined(MATRIX))
diff --git a/terms.c b/terms.c
index 1709064..220b72c 100644
--- a/terms.c
+++ b/terms.c
@@ -1,4 +1,4 @@
-/* $Id: terms.c,v 1.2 2001/11/09 04:59:18 a-ito Exp $ */
+/* $Id: terms.c,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */
/*
* An original curses library for EUC-kanji by Akinori ITO, December 1989
* revised by Akinori ITO, January 1995
@@ -411,6 +411,11 @@ getTCstr(void)
fprintf(stderr, "Can't find termcap entry %s\n", ent);
reset_exit(SIGNAL_ARGLIST);
}
+#ifdef MOUSE
+ if (tgetstr("Km", &pt)) {
+ is_xterm = 1;
+ }
+#endif
GETSTR(T_ce, "ce"); /* clear to the end of line */
GETSTR(T_cd, "cd"); /* clear to the end of display */
@@ -449,7 +454,7 @@ getTCstr(void)
GETSTR(T_ac, "ac"); /* graphics charset pairs */
GETSTR(T_op, "op"); /* set default color pair to its original
* * * * * * * value */
-#ifdef CYGWIN
+#if defined( CYGWIN ) && CYGWIN < 1
/* for TERM=pcansi on MS-DOS prompt.
T_eA = "";
T_as = "\033[12m";
@@ -862,7 +867,7 @@ addch(char c)
void
wrap(void)
{
- if (CurLine == LINES - 1)
+ if (CurLine == LASTLINE)
return;
CurLine++;
CurColumn = 0;
@@ -1012,7 +1017,7 @@ refresh(void)
#endif /* BG_COLOR */
short *dirty;
- for (line = 0; line < LINES; line++) {
+ for (line = 0; line <= LASTLINE; line++) {
dirty = &ScreenImage[line]->isdirty;
if (*dirty & L_DIRTY) {
*dirty &= ~L_DIRTY;
@@ -1078,7 +1083,10 @@ refresh(void)
* avoid the scroll, I prohibit to draw character on
* (COLS-1,LINES-1).
*/
-#ifndef BG_COLOR
+#if !defined( BG_COLOR ) || defined( CYGWIN )
+#ifdef CYGWIN
+ if (isWinConsole)
+#endif
if (line == LINES - 1 && col == COLS - 1)
break;
#endif /* not BG_COLOR */
diff --git a/textlist.c b/textlist.c
index 08e84ce..4b61173 100644
--- a/textlist.c
+++ b/textlist.c
@@ -1,4 +1,4 @@
-/* $Id: textlist.c,v 1.2 2001/11/09 04:59:18 a-ito Exp $ */
+/* $Id: textlist.c,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */
#include "textlist.h"
#include "indep.h"
#include "Str.h"
diff --git a/url.c b/url.c
index 9fe6f32..d0abe2f 100644
--- a/url.c
+++ b/url.c
@@ -571,6 +571,7 @@ parseURL(char *url, ParsedURL * p_url, ParsedURL * current)
p_url->is_nocache = 0;
p_url->file = NULL;
p_url->real_file = NULL;
+ p_url->query = NULL;
p_url->label = NULL;
if (*url == '#') { /* label only */
@@ -593,29 +594,33 @@ parseURL(char *url, ParsedURL * p_url, ParsedURL * current)
#endif /* SUPPORT_DOS_DRIVE_PREFIX */
/* search for scheme */
p_url->scheme = getURLScheme(&p);
- if (p_url->scheme == SCM_MISSING) { /* scheme not found */
+ if (p_url->scheme == SCM_MISSING) {
+ /* scheme part is not found in the url. This means either
+ (a) the url is relative to the current or (b) the url
+ denotes a filename (therefore the scheme is SCM_LOCAL).
+ */
if (current) {
- copyParsedURL(p_url, current);
- if (p_url->scheme == SCM_LOCAL_CGI)
- p_url->scheme = SCM_LOCAL;
+ copyParsedURL(p_url, current);
+ if (p_url->scheme == SCM_LOCAL_CGI)
+ p_url->scheme = SCM_LOCAL;
+ /* label part and query part don't inherit */
+ p_url->label = NULL;
+ p_url->query = NULL;
} else
- p_url->scheme = SCM_LOCAL;
- p = url;
+ p_url->scheme = SCM_LOCAL;
+ p = url;
if (!strncmp(p,"//",2)) {
/* URL begins with // */
/* it means that 'scheme:' is abbreviated */
-#ifdef __CYGWIN__
- /* in CYGWIN, '//host/share' doesn't means 'http://host/share' */
- p_url->scheme = SCM_LOCAL;
- goto analyze_file;
-#endif /* __CYGWIN__ */
p += 2;
goto analyze_url;
}
- goto analyze_file;
+ /* the url doesn't begin with '//' */
+ goto analyze_file;
}
+ /* scheme part has been found */
/* get host and port */
- if (p[0] != '/' || p[1] != '/') { /* scheme:foo or * scheme:/foo */
+ if (p[0] != '/' || p[1] != '/') { /* scheme:foo or scheme:/foo */
p_url->host = NULL;
if (p_url->scheme != SCM_UNKNOWN)
p_url->port = DefaultPort[p_url->scheme];
@@ -623,27 +628,29 @@ parseURL(char *url, ParsedURL * p_url, ParsedURL * current)
p_url->port = 0;
goto analyze_file;
}
+ /* after here, p begins with // */
if (p_url->scheme == SCM_LOCAL) { /* file://foo */
#ifdef __EMX__
p += 2;
goto analyze_file;
#else
- if (p[2] == '/' || p[2] == '~') { /* file:///foo */
- p += 2; /* file://~user */
+ if (p[2] == '/' || p[2] == '~'
+ /* <A HREF="file:///foo">file:///foo</A> or <A HREF="file://~user">file://~user</A> */
+#ifdef SUPPORT_DOS_DRIVE_PREFIX
+ || (IS_ALPHA(p[2]) && (p[3] == ':' || p[3] == '|'))
+ /* <A HREF="file://DRIVE/foo">file://DRIVE/foo</A> */
+#endif /* SUPPORT_DOS_DRIVE_PREFIX */
+ ) {
+ p += 2;
goto analyze_file;
}
-#endif
-#if defined( __CYGWIN__ ) && defined( SUPPORT_DOS_DRIVE_PREFIX )
- if (IS_ALPHA(p[2]) && (p[3] == ':' || p[3] == '|'))
- p += 2;
- goto analyze_file; /* file://DRIVE/foo or
- file://machine/share/foo */
-#endif /* __CYGWIN__ && SUPPORT_DOS_DRIVE_PREFIX */
+#endif /* __EMX__ */
}
p += 2; /* scheme://foo */
+ /* ^p is here */
analyze_url:
q = p;
- while (*p && *p != ':' && *p != '/' && *p != '@' && *p != '?') {
+ while (*p && strchr(":/@?#",*p) == NULL) {
#ifdef INET6
if (*p == '[') { /* rfc2732 compliance */
char *p_colon = NULL;
@@ -665,46 +672,53 @@ parseURL(char *url, ParsedURL * p_url, ParsedURL * current)
p++;
}
switch (*p) {
- case '\0': /* scheme://host */
- /* scheme://user@host */
- /* scheme://user:pass@host */
+ case '\0':
+ /* scheme://host */
p_url->host = copyPath(q, -1, COPYPATH_SPC_IGNORE);
p_url->port = DefaultPort[p_url->scheme];
- goto analyze_file;
+ p_url->file = DefaultFile(p_url->scheme);
+ return;
case ':':
+ /* scheme://user:pass@host or
+ scheme://host:port
+ */
p_url->host = copyPath(q, p - q, COPYPATH_SPC_IGNORE);
q = ++p;
- while (*p && *p != '/' && *p != '@')
+ while (*p && strchr("@/?#",*p) == NULL)
p++;
- if (*p == '@') { /* scheme://user:pass@... */
+ if (*p == '@') {
+ /* scheme://user:pass@... */
p_url->pass = copyPath(q, p - q, COPYPATH_SPC_ALLOW);
q = ++p;
p_url->user = p_url->host;
p_url->host = NULL;
goto analyze_url;
}
+ /* scheme://host:port/ */
tmp = Strnew_charp_n(q, p - q);
p_url->port = atoi(tmp->ptr);
- if (*p == '\0') { /* scheme://host:port */
+ if (*p == '\0') {
/* scheme://user@host:port */
/* scheme://user:pass@host:port */
p_url->file = DefaultFile(p_url->scheme);
p_url->label = NULL;
return;
}
+ /* *p is one of ['/', '?', '#'] */
break;
- case '@': /* scheme://user@... */
+ case '@':
+ /* scheme://user@... */
p_url->user = copyPath(q, p - q, COPYPATH_SPC_IGNORE);
q = ++p;
goto analyze_url;
- case '/': /* scheme://host/... */
+ case '/':
case '?':
- /* scheme://user@host/... */
- /* scheme://user:pass@host/... */
+ case '#':
p_url->host = copyPath(q, p - q, COPYPATH_SPC_IGNORE);
p_url->port = DefaultPort[p_url->scheme];
break;
}
+ analyze_file:
#ifdef INET6
/* rfc2732 compliance */
if (p_url->host != NULL && p_url->host[0] == '[' &&
@@ -713,10 +727,18 @@ parseURL(char *url, ParsedURL * p_url, ParsedURL * current)
++(p_url->host);
}
#endif
- analyze_file:
-#ifndef __CYGWIN__
+#ifndef SUPPORT_NETBIOS_SHARE
if (p_url->scheme == SCM_LOCAL && p_url->user == NULL &&
p_url->host != NULL && strcmp(p_url->host, "localhost")) {
+ /*
+ In the environments other than CYGWIN, a URL like
+ file://host/file is regarded as ftp://host/file.
+ On the other hand, file://host/file on CYGWIN is
+ regarded as local access to the file //host/file.
+ `host' is a netbios-hostname, drive, or any other
+ name; It is CYGWIN system call who interprets that.
+ */
+
p_url->scheme = SCM_FTP; /* ftp://host/... */
if (p_url->port == 0)
p_url->port = DefaultPort[SCM_FTP];
@@ -729,11 +751,11 @@ parseURL(char *url, ParsedURL * p_url, ParsedURL * current)
q++;
if (IS_ALPHA(q[0]) && (q[1] == ':' || q[1] == '|')) {
if (q[1] == '|') {
- p = allocStr(q, 0);
- p[1] = ':';
+ p = allocStr(q, 0);
+ p[1] = ':';
}
else
- p = q;
+ p = q;
}
}
#endif
@@ -771,7 +793,7 @@ parseURL(char *url, ParsedURL * p_url, ParsedURL * current)
{
char *cgi = strchr(p, '?');
again:
- while (*p && *p != '#')
+ while (*p && *p != '#' && p != cgi)
p++;
if (*p == '#' && p_url->scheme == SCM_LOCAL) {
/*
@@ -803,7 +825,14 @@ parseURL(char *url, ParsedURL * p_url, ParsedURL * current)
else
p_url->file = copyPath(q, p - q, COPYPATH_SPC_IGNORE);
}
- do_label:
+ do_query:
+ if (*p == '?') {
+ q = ++p;
+ while (*p && *p != '#')
+ p++;
+ p_url->query = copyPath(q,p-q,COPYPATH_SPC_ALLOW);
+ }
+ do_label:
if (p_url->scheme == SCM_MISSING) {
p_url->scheme = SCM_LOCAL;
p_url->file = allocStr(p, 0);
@@ -816,6 +845,7 @@ parseURL(char *url, ParsedURL * p_url, ParsedURL * current)
}
#define initParsedURL(p) bzero(p,sizeof(ParsedURL))
+#define ALLOC_STR(s) ((s)==NULL?NULL:allocStr(s,0))
void
copyParsedURL(ParsedURL * p, ParsedURL * q)
@@ -823,30 +853,13 @@ copyParsedURL(ParsedURL * p, ParsedURL * q)
p->scheme = q->scheme;
p->port = q->port;
p->is_nocache = q->is_nocache;
- if (q->user)
- p->user = allocStr(q->user, 0);
- else
- p->user = NULL;
- if (q->pass)
- p->pass = allocStr(q->pass, 0);
- else
- p->pass = NULL;
- if (q->host)
- p->host = allocStr(q->host, 0);
- else
- p->host = NULL;
- if (q->file)
- p->file = allocStr(q->file, 0);
- else
- p->file = NULL;
- if (q->real_file)
- p->real_file = allocStr(q->real_file, 0);
- else
- p->real_file = NULL;
- if (q->label)
- p->label = allocStr(q->label, 0);
- else
- p->label = NULL;
+ p->user = ALLOC_STR(q->user);
+ p->pass = ALLOC_STR(q->pass);
+ p->host = ALLOC_STR(q->host);
+ p->file = ALLOC_STR(q->file);
+ p->real_file = ALLOC_STR(q->real_file);
+ p->label = ALLOC_STR(q->label);
+ p->query = ALLOC_STR(q->query);
}
void
@@ -854,6 +867,7 @@ parseURL2(char *url, ParsedURL * pu, ParsedURL * current)
{
char *p, *q;
Str tmp;
+ int relative_uri = FALSE;
parseURL(url, pu, current);
if (pu->scheme == SCM_MAILTO)
@@ -863,6 +877,7 @@ parseURL2(char *url, ParsedURL * pu, ParsedURL * current)
pu->file = expandName(pu->file);
if (current && pu->scheme == current->scheme) {
+ /* Copy omitted element from the current URL */
if (pu->user == NULL) {
pu->user = current->user;
}
@@ -885,18 +900,18 @@ parseURL2(char *url, ParsedURL * pu, ParsedURL * current)
&& !(pu->scheme == SCM_LOCAL && IS_ALPHA(pu->file[0]) && pu->file[1] == ':')
#endif
) {
+ /* file is relative [process 1]*/
p = pu->file;
if (current->file) {
tmp = Strnew_charp(current->file);
- if ((q = strchr(tmp->ptr, '?')) != NULL)
- Strshrink(tmp, (tmp->ptr + tmp->length) - q);
while (tmp->length > 0) {
if (Strlastchar(tmp) == '/')
break;
Strshrink(tmp, 1);
}
Strcat_charp(tmp, p);
- pu->file = allocStr(tmp->ptr, 0);
+ pu->file = tmp->ptr;
+ relative_uri = TRUE;
}
}
#ifdef USE_GOPHER
@@ -911,6 +926,8 @@ parseURL2(char *url, ParsedURL * pu, ParsedURL * current)
/* pu has only label */
pu->file = current->file;
}
+ /* comment: query part need not to be completed
+ from the current URL. */
}
if (pu->file) {
#ifdef __EMX__
@@ -932,10 +949,11 @@ parseURL2(char *url, ParsedURL * pu, ParsedURL * current)
}
#else
if (pu->scheme == SCM_LOCAL && pu->file[0] != '/' &&
-#if defined( __CYGWIN__ ) && defined( SUPPORT_DOS_DRIVE_PREFIX ) /* for 'drive:' */
+#ifdef SUPPORT_DOS_DRIVE_PREFIX /* for 'drive:' */
! (IS_ALPHA(pu->file[0]) && pu->file[1] == ':') &&
#endif
strcmp(pu->file, "-")) {
+ /* local file, relative path */
tmp = Strnew_charp(CurrentDir);
if (Strlastchar(tmp) != '/')
Strcat_char(tmp, '/');
@@ -943,15 +961,21 @@ parseURL2(char *url, ParsedURL * pu, ParsedURL * current)
pu->file = cleanupName(tmp->ptr);
}
#endif
- else if ((pu->scheme == SCM_HTTP
+ else if (pu->scheme == SCM_HTTP
#ifdef USE_SSL
|| pu->scheme == SCM_HTTPS
#endif
- ) && pu->file[0] == '/') {
- char *p = &pu->file[1];
- int s = getURLScheme(&p);
- if (s == SCM_MISSING || s == SCM_UNKNOWN)
- pu->file = cleanupName(pu->file);
+ ) {
+ if (relative_uri) {
+ /* In this case, pu->file is created by [process 1] above.
+ pu->file may contain relative path (for example,
+ "/foo/../bar/./baz.html"), cleanupName() must be applied.
+ When the entire abs_path is given, it still may contain
+ elements like `//', `..' or `.' in the pu->file. It is
+ server's responsibility to canonicalize such path.
+ */
+ pu->file = cleanupName(pu->file);
+ }
} else if (
#ifdef USE_GOPHER
pu->scheme != SCM_GOPHER &&
@@ -960,10 +984,27 @@ parseURL2(char *url, ParsedURL * pu, ParsedURL * current)
pu->scheme != SCM_NEWS &&
#endif /* USE_NNTP */
pu->file[0] == '/') {
+ /*
+ this happens on the following conditions:
+ (1) ftp scheme (2) local, looks like absolute path.
+ In both case, there must be no side effect with
+ cleanupName(). (I hope so...)
+ */
pu->file = cleanupName(pu->file);
}
- if (pu->scheme == SCM_LOCAL)
- pu->real_file = cleanupName2(file_unquote(pu->file), FALSE);
+ if (pu->scheme == SCM_LOCAL) {
+#ifdef SUPPORT_NETBIOS_SHARE
+ if (pu->host && strcmp(pu->host,"localhost") != 0) {
+ Str tmp = Strnew_charp("//");
+ Strcat_m_charp(tmp, pu->host,
+ cleanupName(file_unquote(pu->file)),
+ NULL);
+ pu->real_file = tmp->ptr;
+ }
+ else
+#endif
+ pu->real_file = cleanupName(file_unquote(pu->file));
+ }
}
}
@@ -1025,13 +1066,17 @@ _parsedURL2Str(ParsedURL * pu, int pass)
#ifdef USE_NNTP
pu->scheme != SCM_NEWS &&
#endif /* USE_NNTP */
+ (pu->file == NULL || (pu->file[0] != '/'
#ifdef SUPPORT_DOS_DRIVE_PREFIX
- (pu->file == NULL || (pu->file[0] != '/' && pu->file[1] != ':')))
-#else
- (pu->file == NULL || pu->file[0] != '/'))
+ && !(IS_ALPHA(pu->file[0]) && pu->file[1] == ':' && pu->host == NULL)
#endif
+ )))
Strcat_char(tmp, '/');
Strcat_charp(tmp, pu->file);
+ if (pu->query) {
+ Strcat_char(tmp,'?');
+ Strcat_charp(tmp,pu->query);
+ }
if (pu->label) {
Strcat_char(tmp, '#');
Strcat_charp(tmp, pu->label);
@@ -1149,6 +1194,10 @@ HTTPrequest(ParsedURL * pu, ParsedURL * current, HRequest * hr, TextList * extra
}
else if (hr->flag & HR_FLAG_LOCAL) {
Strcat_charp(tmp, pu->file);
+ if (pu->query) {
+ Strcat_char(tmp,'?');
+ Strcat_charp(tmp,pu->query);
+ }
}
else {
Strcat(tmp, _parsedURL2Str(pu, TRUE));
@@ -1261,7 +1310,7 @@ openURL(char *url, ParsedURL * pu, ParsedURL * current,
Str tmp2 = Strnew_charp("#");
Strcat_charp(tmp2, pu->label);
pu->file = tmp2->ptr;
- pu->real_file = cleanupName2(file_unquote(pu->file), FALSE);
+ pu->real_file = cleanupName(file_unquote(pu->file));
pu->label = NULL;
}
else {
@@ -1287,18 +1336,24 @@ openURL(char *url, ParsedURL * pu, ParsedURL * current,
case SCM_LOCAL_CGI:
if (request && request->body) {
/* local CGI: POST */
- uf.stream = newFileStream(localcgi_post(pu->real_file, request,
- option->referer), (void (*)()) pclose);
+ if ((q = strchr(pu->file, '?')) != NULL) {
+ p = Strnew_charp_n(pu->file, (int)(q - pu->file))->ptr;
+ pu->real_file = cleanupName(file_unquote(p));
+ q++;
+ }
+ uf.stream = newFileStream(localcgi_post(pu->real_file,
+ pu->query,
+ request,
+ option->referer),
+ (void (*)()) pclose);
if (uf.stream == NULL)
goto ordinary_local_file;
uf.is_cgi = TRUE;
uf.scheme = pu->scheme = SCM_LOCAL_CGI;
}
- else if ((q = strchr(pu->file, '?')) != NULL) {
+ else if (pu->query != NULL) {
/* lodal CGI: GET */
- p = Strnew_charp_n(pu->file, (int)(q - pu->file))->ptr;
- pu->real_file = cleanupName2(file_unquote(p), FALSE);
- uf.stream = newFileStream(localcgi_get(pu->real_file, q + 1,
+ uf.stream = newFileStream(localcgi_get(pu->real_file, pu->query,
option->referer), (void (*)()) pclose);
if (uf.stream == NULL) {
pu->file = p;
@@ -1338,7 +1393,7 @@ openURL(char *url, ParsedURL * pu, ParsedURL * current,
Strcat_char(tmp, '/');
Strcat_charp(tmp, pu->file);
p = cleanupName(tmp->ptr);
- q = cleanupName2(file_unquote(p), FALSE);
+ q = cleanupName(file_unquote(p));
if (dir_exist(q)) {
pu->file = p;
pu->real_file = q;
@@ -1622,7 +1677,7 @@ add_index_file(ParsedURL * pu, URLFile *uf)
}
p = Strnew_m_charp(pu->file, "/", file_quote(index_file), NULL)->ptr;
p = cleanupName(p);
- q = cleanupName2(file_unquote(p), FALSE);
+ q = cleanupName(file_unquote(p));
examineFile(q, uf);
if (uf->stream == NULL)
return;
diff --git a/version.c b/version.c
index 8f0b320..c8725ca 100644
--- a/version.c
+++ b/version.c
@@ -1,4 +1,4 @@
-#define CURRENT_VERSION "w3m/0.2.1-inu-1.5"
+#define CURRENT_VERSION "w3m/0.2.1-inu-1.6"
#ifndef FM_H
char *version = CURRENT_VERSION;