diff options
69 files changed, 2652 insertions, 1571 deletions
@@ -1,245 +1,22 @@ -2001-11-22 Kiyokazu SUTO <suto@ks-and-ks.ne.jp> +2001-11-23 Dai Sato <satodai@dog.intcul.tohoku.ac.jp> - * [w3m-dev 02509] ([w3m-dev 02499] [w3m-dev 02508]) - * terms.c (setlinescols): initialize LASTLINE - * terms.c: add LASTLINE - * fm.h: extern int LASTLINE - * linein.c: remove defined(__CYGWIN__) && defined(JP_CHARSET) - * main.c: remove MOUSE_* definition - * terms.h: move MOUSE_* definition from main.c - * terms.c: add tty - * terms.c (check_win32_console): added - * terms.c (init_win32_console_handle): ditto - * terms.c (read_win32_console_input): ditto - * terms.c (read_win32_console): ditto - * terms.c (set_tty) add call init_win32_console - * terms.c (getch) use read_win32_console - * terms.c (mouse_init): check hConIn - * terms.c (mouse_end): ditto + * README.inu: new file -2001-11-22 aito@fw.ipsj.or.jp + * Bohem GC: replaced with GC 6.1 alpha2 - * [w3m-dev 02503] - * indep.c (getescapechar): allow incomplete entity references in URL - closes: Debian Bug#120540 - -2001-11-22 Fumitoshi UKAI <ukai@debian.or.jp> - - * [w3m-dev 02506] - * anchor.c (putHmarker): remove #ifdef __CYGWIN__ for bzero() - * matrix.h (m_copy): ditto - * table.c (pushTable): ditto - -2001-11-22 Fumitoshi UKAI <ukai@debian.or.jp> - - * [w3m-dev 02505] - * configure (alarm): check alarm if USE_ALARM - -2001-11-22 Tsutomu Okada <okada@furuno.co.jp> - - * [w3m-dev 02501] - * .cvsignore: add funcname.c funcname1.h funcname2.h tagtable.c - * scripts/.cvsignore: added, dirlist.cgi - * scripts/multipart/.cvsignore: added, multipart.cgi - * scripts/w3mman/.cvsignore: added, w3mman w3mman2html.cgi - * doc-jp/README.kokb: deleted - * gc/makefile.depend: deleted - -2001-11-22 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp> - - * table.c (feed_table): fix the following table - <table border=1><tr><td>< <</table> - -2001-11-22 WATANABE Katsuyuki <katsuyuki_1.watanabe@toppan.co.jp> - - * [w3m-dev 02497] - * url.c (parseURL2): fix #ifdef __EMX__ code - * indep.c (cleanupName): remove #if 0 /* SUPPORT_NETBIOS_SHARE */ code - -2001-11-22 Fumitoshi UKAI <ukai@debian.or.jp> - - * [w3m-dev 02494] - * configure (MIME_TYPES): check if mimetypes is empty - * configure (label_topline): add missing = - * configure (nextpage_topline): ditto - -2001-11-22 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp> - - * [w3m-dev 02493] - * scripts/multipart/Makefile: s/DISTDIR/DESTDIR/ - -2001-11-21 Fumitoshi UKAI <ukai@debian.or.jp> - - * [w3m-dev 02481] - * s/BG_COLOR/USE_BG_COLOR/ - * s/ANSI_COLOR/USE_ANSI_COLOR/ - * s/COLOR/USE_COLOR/ - * s/MENU/USE_MENU/ - * s/MOUSE/USE_MOUSE/ - - * [w3m-dev 02480] new configure - * config.h.dist: updated - * configure: $def_emacs_like_lineedit, $def_vi_prec_num - $def_label_topline, $def_nextpage_topline - $def_use_mark, $def_use_gopher, $def_use_alarm - * configure: add --{ssl,gc}-{include,lib}dir, --mimetypes - * configure: BoehmGC Debian hack - * XMakefile: add $(OPTS) - * terms.c: use HAVE_SYS_SELECT_H - * configure: add sys/select.h detection - * configure: no_float_h -> float_h - * configure: add chdir() detection - * local.c (localcgi_post): use HAVE_CHDIR instead of __EMX__ - * local.c (localcgi_get): ditto - * main.c: <time.h> no need for #ifdef __EMX__ - other files already do #include <time.h> - - [w3m-dev 02479] - * rc.c (init_rc): remove #ifdef __EMX__ for tmpdir - * config.h.dit: updated - * url.c (openURL): use CGI_EXTENSION - add extlen - * rc.c (helpFile): remove #ifdef __EMX__ - use w3m_help_dir() - * w3mbookmark.c (lib_dir): removed - * w3mbookmark.c (print_bookmark_panel): use w3m_lib_dir() - * rc.c (libFile): remove #ifdef __EMX__ - use w3m_lib_dir() - * local.c (get_os2_dft): removed - * local.c (check_local_cgi): use w3m_lib_dir() instead of lib_dir - * local.c (cgi_filename): ditto - * indep.c (w3m_dir): added - * indep.c (w3m_lib_dir w3m_help_dir): ditto - * indep.h (w3m_lib_dir w3m_help_dir): ditto - * terms.c (set_tty): remove #ifdef __EMX__ - use DEV_TTY_PATH - * local.c (localcgi_get): use DEV_NULL_PATH - * w3mhelperpanel.c (printMailcapPanal): remove #ifdef __EMX__ - use W3mHELPERPANEL_CMDNAME - * rc.c (optionpanel_src1): ditto - * w3mbookmark.c (bkmark_src1): remove #ifdef __EMX__ - use W3MBOOKMARK_CMDNAME - * main.c (adBmark): ditto - use w3m_lib_dir() - * terms.c (getTCstr): remove #ifdef __DJGPP__ - use DEFAULT_TERM - check ent is NULL - * main.c (fusage): remove #ifdef SHOW_PARAMS - * main.c (MAIN): ditto - * rc.c (show_params): ditto - * fm.h (view_unseenobject): remove #ifdef VIEW_UNSEENOBJECTS - * url.c (check_no_proxy): remove #ifdef NOPROXY_NETADDR - * configure (show_params): removed - * configure (config.h): - - fix comment for USE_MARK - - add MENU_THIN_FRAME - - move $def_nntp (USE_NNTP), $def_ansi_color (ANSI_COLOR) - - remove VIEW_UNSEENOBJECTS - - remove $def_show_params (SHOW_PARAMS) - - define DEFAULT_TERM - - define W3MBOOKMARK_CMDNAME - - define W3MHELPERPANEL_CMDNAME - - define DEV_NULL_PATH - - define DEV_TTY_PATH - - define CGI_EXTENSION - - [w3m-dev 02478] - * Makefile: make -> $(MAKE) - -2001-11-21 Fumitoshi UKAI <ukai@debian.or.jp> - - * [w3m-dev 02473] - * scripts/Makefile: chmod +x - * scripts/Makefile: add clean target - * scripts/multipart/Makefile: ditto - * scripts/w3mman/Makefile: ditto - * XMakefile: clean scripts - * scripts/dirlist.cgi: removed from CVS - * Makefile (install-scripts): added - * XMakefile: (install-scripts): depends all-scripts - -2001-11-21 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp> - - * [w3m-dev 02470] - * XMakefile: all of scripts are generated by this instead of configure - * configure: add PERL, remove scripts/dirlist.cgi generation - * config.h.dist: add PERL - * scripts/Makefile: added - * scripts/multipart/Makefile scripts/w3mman/Makefile: - new scripts generation and installation - * scripts/multipart/README scripts/w3mman/README: update - -2001-11-21 Tsutomu Okada <okada@furuno.co.jp> - - * [w3m-dev 02472] cleanup CYGWIN macro - * display.c (displayBuffer): use __CYGWIN__ macro - * fm.h: ditto - * terms.c (refresh): add condition for isWinConsole which - defined only japanese cygwin environment - -2001-11-21 Akinori Ito <aito@fw.ipsj.or.jp> + * frame.c: fixed buffer overflow in newFrameSet() + * personally indecated by Suto-san. * [w3m-dev 02466] - Homepage URLs and author's mail addresses in the documents + * Homepage URLs and author's mail addresses in the documents are changed. -2001-11-21 Fumitoshi UKAI <ukai@debian.or.jp> - - * [w3m-dev 02459] - * XMakefile: update scripts/dirlist.cgi generation - * scripts/multipart/multipart.cgi: removed - * scripts/w3mman/w3mman scripts/w3mman/w3mman2html.cgi: removed - - * [w3m-dev 02462] - * scripts/dirlist.in scripts/dirlist.cgi: removed - * scripts/dirlist.cgi.in: added - -2001-11-21 Fumitoshi UKAI <ukai@debian.or.jp> - - * add rcsids - -2001-11-21 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp> - - * [w3m-dev 02454] - * buffer.c (newBuffer): set COLS - * display.c (displayBuffer redrawLine redrawLineRegion - cursorRight arrangeCursor cursorXY): - new showLineNumber implementation - * main.c (ctrCsrH shiftvisualpos shiftl shiftr _movL _movR - _followForm follow_map process_mouse): - use buf->COLS, buf->rootX - * menu.c (popupMenu mainMn initSelectMenu): - use buf->rootX - * etc.c (columnSkip): use buf->COLS - * file.c (HTMLlineproc2body loadBuffer saveBufferDelNum getNextPage) - remove old showLineNumber codes - * fm.h (Buffer): add rootX, COLS - -2001-11-21 Fumitoshi UKAI <ukai@debian.or.jp> - - * XMakefile (clean): rm tagtable.c - * .cvsignore: XXMakefile config.h config.param - -2001-11-20 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp> - * [w3m-dev 02455] * XMakefile.dist deflate.c: removed, not used * tagtable.c: removed, autogenerated files * XMakefile (mktable w3mbookmark w3mhelperpanel): use LIBS2 * configure: add $bsdlib -2001-11-20 Kiyokazu SUTO <suto@ks-and-ks.ne.jp> - - * frame.c (newFrameSet): fix possible buffer overrun - -2001-11-20 Fumitoshi UKAI <ukai@debian.or.jp> - - * XXMakefile config.h: removed from CVS - these are autogenerated files. - config.h is moved to config.h.dist as sample config file. - -2001-11-20 Tsutomu Okada <okada@furuno.co.jp> - * [w3m-dev 02449] * file.c (HTMLtagproc1): reimplement meta refresh with setAlarmEvent() @@ -254,105 +31,25 @@ * main.c (setAlarm): use setAlarmEvent() * proto.h: add setAlarmEvent() -2001-11-20 Fumitoshi UKAI <ukai@debian.or.jp> - - * w3mhelperpanel.c (extractMailcapEntry): remove unused variables - * istream.c (StrISgets): add parentheses around assignment used - as truth value - - * XMakefile (clean): remove funcname.c funcname1.h funcname2.h - these are autogenerated files. - * funcname.c funcname1.h funcname2.h: removed from CVS - - * main.c (MAIN): add braces to avoid ambiguous `else' - * main.c (set_buffer_environ): remove unused variables - * linein.c (_rcompl): not EMACS_LIKE_LINEEDIT only - * local.c (localcgi_get): remove unused variables - * mailcap.c (unquote_mailcap_loop): remove unused variables - * url.c (init_PRNG) add parentheses around assignment used as true value - * url.c (parseURL): remove unsed label - * url.c (parseURL2): remove unused variables - * ftp.c (ftp_escape_str ftp_restore_str): remove not used functions - * indep.c (getescapechar): remove unused variable - - * proto.h: add missing prototypes - -2001-11-20 Kiyokazu SUTO <suto@ks-and-ks.ne.jp> - - * [w3m-dev 02447] - * terms.c (skip_escseq): is_xterm && ESC [ M <ch> <ch> <ch> - -2001-11-20 Fumitoshi UKAI <ukai@debian.or.jp> - - * [w3m-dev 02448] + * [w3m-dev 2448] * terms.c (mouse_init): Gpm_Close() is required. closes: Debian Bug#120221: w3m-ssl: trashes terminal on exit -2001-11-20 Kiyokazu SUTO <suto@ks-and-ks.ne.jp> - - * [w3m-dev 02444] - * XMakefile (funcname1.h funcname2.h): sort as well as funcname.c - -2001-11-19 Fumitoshi UKAI <ukai@debian.or.jp> - - * [w3m-dev 02439] + * [w3m-dev 2439] * terms.c (xterm_mouse_term set_tty): add cygwin as xterm-style mouse terminal -2001-11-19 Hironori Sakamoto <hsaka@mth.biglobe.ne.jp> - - * [w3m-dev 02436] + * [w3m-dev 02436] * main.c (GetWord): closes: #482763 segmentation fault in main.c -2001-11-19 Fumitoshi UKAI <ukai@debian.or.jp> - - * gc/.cvsignore: - remove gctest, if_mach, if_not_there, threadlibs - closes: #482765 i386 binaries in gc directory + * [w3m-dev 02425] + * excess files are deleted + _zmachdep.c + doc/histroy, doc-jp/README.kokb + gc: if_mach, if_not_there, gctest, makefile.depend, threadlibs 2001-11-17 Fumitoshi UKAI <ukai@debian.or.jp> - * [w3m-dev 02432] - * configure: follow autoconf conventions - STRCASECMP -> HAVE_STRCASECMP - STRCHR -> HAVE_STRCHR - STRERROR -> HAVE_STRERROR - SYS_ERRLIST -> HAVE_SYS_ERRLIST - NOBCOPY -> HAVE_BCOPY - GETCWD -> HAVE_GETCWD - GETWD -> HAVE_GETWD - READLINK -> HAVE_READLINK (HAVE_LSTAT?) - TERMIO -> HAVE_TERMIO_H - TERMIOS -> HAVE_TERMIOS_H - SGTTY -> HAVE_SGTTY_H - DIRENT -> HAVE_DIRENT_H - NO_FLOAT_H -> HAVE_FLOAT_H - * etc.c fm.h config.h: HAVE_STRCASECMP - * etc.c config.h file.c: HAVE_STRCHR - strchr() moved from file.c to etc.c - * etc.c config.h: HAVE_STRERROR - * etc.c config.h main.c (MAIN): HAVE_SYS_ERRLIST - * etc.c fm.h: HAVE_BCOPY - * etc.c indep.c (currentdir) config.h: HAVE_GETCWD - * indep.c (currentdir) config.h: HAVE_GETWD - * form.c (form_write_from_file) local.c (dirBuffer) - config.h: HAVE_READLINK - * config.h terms.c: HAVE_TERMIO_H, HAVE_TERMIOS_H, HAVE_SGTTY_H - * config.h local.h: HAVE_DIRENT_H - * config.h matric.c: HAVE_FLOAT_H - - * anchor.c cookie.c file.c parsetagx.c regex.c table.c url.c: - remove include <strings.h> ifdef __EMX__ - it will be included in fm.h - * frame.c: remove include <strings.h> for bzero() and bcopy() - these are declared in fm.h - * indep.c: remove include <strings.h> for bcopy() - this is declared in fm.h - * istream.c mailcap.c: remove include <strings.h> for bzero() - this is declared in fm.h - * parsetag.c: remove include <strings.h> for bzero() - no bzero() used in this file - * [w3m-dev 02431] * terms.c (set_tty): "rxvt" is xterm (getTCstr): tgetstr("Km", &pt) is not xterm, removed diff --git a/README.inu b/README.inu new file mode 100644 index 0000000..5d4b022 --- /dev/null +++ b/README.inu @@ -0,0 +1,9 @@ + w3m-0.2.2-inu: version 1.1 + Maintained by Dai Sato <satodai@dog.intcul.tohoku.ac.jp> + +w3m-0.2.2-inu is a bug-fixed version of w3m-0.2.2. +And also Bohem GC is replaced from GC 6.0 to GC 6.1 alpha2. +Fixed bugs are listed in ChangeLog. + +If you interested in new functions added to w3m-0.2.2, check the head of +main trank. @@ -1,4 +1,3 @@ -# $Id: XMakefile,v 1.10 2001/11/21 18:51:48 ukai Exp $ SRCS=main.c file.c buffer.c display.c etc.c search.c linein.c table.c local.c \ form.c map.c frame.c rc.c menu.c mailcap.c\ func.c cookie.c history.c backend.c $(KEYBIND_SRC) @@ -20,20 +19,17 @@ HELPER=w3mhelperpanel$(EXT) INFLATE=inflate$(EXT) TARGETS=$(TARGET) $(EXT_TARGETS) -SCRIPTSUBDIRS = scripts scripts/multipart scripts/w3mman -SUBDIRS = $(SCRIPTSUBDIRS) - INCLUDES=-I. DEFS=$(INCLUDES) # -DDEBUG -CFLAGS=$(OPTS) $(MYCFLAGS) $(DEFS) +CFLAGS=$(MYCFLAGS) $(DEFS) LIBS=-L. -lindep $(GCLIB) $(MATHLIB) $(LOCAL_LIBRARIES) $(SYS_LIBRARIES) LIBS2=-L. -lindep $(GCLIB) $(LOCAL_LIBRARIES) INSTALL=sh install.sh INSTALL2=sh ../install.sh AR=ar -all: $(TARGETS) all-scripts +all: $(TARGETS) $(TARGET): $(ALLOBJS) $(ALIB) $(GCTARGET) $(CC) $(CFLAGS) -o $(TARGET) $(ALLOBJS) $(LIBS) @@ -59,10 +55,10 @@ funcname.c: funcname.tab sort funcname.tab | awk -f funcname0.awk > funcname.c funcname1.h: funcname.tab - sort funcname.tab | awk -f funcname1.awk > funcname1.h + awk -f funcname1.awk funcname.tab > funcname1.h funcname2.h: funcname.tab - sort funcname.tab | awk -f funcname2.awk > funcname2.h + awk -f funcname2.awk funcname.tab > funcname2.h mktable$(EXT): mktable.o hash.o $(ALIB) $(GCTARGET) $(CC) $(CFLAGS) -o mktable$(EXT) mktable.o hash.o $(LIBS2) @@ -80,10 +76,9 @@ inflate.o: inflate.c $(CC) $(CFLAGS) $(Z_CFLAGS) -c inflate.c gc/gc.a: - cd gc; $(MAKE) CC='$(CC)' CFLAGS='$(GCCFLAGS) $(GC_CFLAGS)' SPECIALCFLAGS='-I./\$(srcdir)/include $(GC_CFLAGS)' - + cd gc; make CC='$(CC)' CFLAGS='$(GCCFLAGS) $(GC_CFLAGS)' SPECIALCFLAGS='-I./\$(srcdir)/include $(GC_CFLAGS)' -install: $(TARGETS) all-scripts +install: $(TARGETS) -$(MKDIR) $(DESTDIR)$(BIN_DIR) -$(MKDIR) $(DESTDIR)$(HELP_DIR) -$(MKDIR) $(DESTDIR)$(LIB_DIR) @@ -96,18 +91,6 @@ install: $(TARGETS) all-scripts for d in $(EXT_TARGETS); do $(INSTALL) -m 755 $$d $(DESTDIR)$(LIB_DIR)/$$d; done (cd scripts; for i in *.cgi; do $(INSTALL2) -m 755 $$i $(DESTDIR)$(LIB_DIR)/$$i; done) -all-scripts: - for dir in $(SCRIPTSUBDIRS); \ - do \ - (cd $$dir; $(MAKE) PERL='$(PERL)' BIN_DIR='$(BIN_DIR)' LIB_DIR='$(LIB_DIR)'); \ - done - -install-scripts: all-scripts - for dir in $(SCRIPTSUBDIRS); \ - do \ - (cd $$dir; $(MAKE) PERL='$(PERL)' BIN_DIR='$(BIN_DIR)' LIB_DIR='$(LIB_DIR)' DESTDIR='$(DESTDIR)' INSTALL='sh $(PWD)/install.sh' install); \ - done - uninstall: -$(RM) $(BIN_DIR)/$(TARGET) -$(RM) $(HELP_DIR)/w3mhelp-lynx_en.html @@ -121,11 +104,6 @@ uninstall: clean: sweep rm -f *.o *.a $(TARGETS) mktable$(EXT) - rm -f funcname.c funcname1.h funcname2.h tagtable.c - for dir in $(SCRIPTSUBDIRS); \ - do \ - (cd $$dir; $(MAKE) clean); \ - done sweep: -rm -f core *~ *.bak *.orig *.rej @@ -1,5 +1,5 @@ #!/bin/sh -# $Id: configure,v 1.14 2001/11/22 13:53:19 ukai Exp $ +# # Configuration. # @@ -34,12 +34,6 @@ echo "# Configuration at $host" > config.param # parameters: prefix=/usr/local -ssl_includedir= -ssl_libdir= -gc_includedir= -gc_libdir= -mimetypes= - all_yes=0 while [ $# -gt 0 ] do @@ -85,22 +79,6 @@ do -cflags=*|--cflags=*) dcflags=`echo $1 | sed -e 's/-*cflags=//'` ;; - --ssl-includedir=*) - ssl_includedir=`expr "$1" : "--ssl-includedir=\(.*\)"` - ;; - --ssl-libdir=*) - ssl_libdir=`expr "$1" : "--ssl-libdir=\(.*\)"` - ;; - --gc-includedir=*) - gc_includedir=`expr "$1" : "--gc-includedir=\(.*\)"` - ;; - --gc-libdir=*) - gc_libdir=`expr "$1" : "--gc-libdir=\(.*\)"` - ;; - --mimetypes=*) - mime_types=`expr "$1" : "--mimetypes=\(.*)\"` - ;; - -help|--help) echo "-yes, -nonstop Set all parameters to the default" echo "-prefix=DIR Specify prefix (default: /usr/local)" @@ -110,11 +88,6 @@ do echo "-code=(S|E|j|N|n|m)" echo " Specify default kanji code" echo "-cflags=FLAGS Specify C flags" - echo "--ssl-includedir=DIR specify OpenSSL include dir" - echo "--ssl-libdir=DIR specify OpenSSL lib dir" - echo "--gc-includedir=DIR specify Boehm-GC include dir" - echo "--gc-libdir=DIR specify Boehm-GC lib dir" - echo "--mimetypes=PATH specify mime.types path" echo "-help Display help" exit 0 ;; @@ -126,7 +99,7 @@ done # version number: JMMAAA J: major MM: minor AAA: alpha # Alpha number of non-alpha version is 255. # version 4.14alpha1 => 414002 -mygcversion=600255 +mygcversion=601002 if [ -z "`echo -n aho | grep n`" ] ; then Echo() @@ -225,7 +198,7 @@ save_params() { find_ssl() { sslinclude="" - for i1 in $ssl_includedir /usr /usr/local $prefix + for i1 in /usr /usr/local $prefix do for i2 in /openssl /ssl / do @@ -252,9 +225,6 @@ find_ssl() { done done done - if [ -f "$ssl_libdir/libssl.$ext" -o -f "$ssl_libdir/libcrypto.$ext" ]; then - ssllib="-L$ssl_libdir $ssllib" - fi ssllib="$ssllib -lssl -lcrypto" if [ "$sslinclude" = "" ]; then echo "Where is ssl.h? (for example, /usr/crypto/include)" @@ -441,51 +411,6 @@ else keymap_file="keybind" fi -echo "Do you want to use Emacs-like key binding for filename completion?" -yesno emacs_like_lineedit "$emacs_like_lineedit" n -echo "emacs_like_lineedit=$emacs_like_lineedit" >> config.param -if [ "$emacs_like_lineedit" = y ]; then - def_emacs_like_lineedit="#define EMACS_LIKE_LINEEDIT" -else - def_emacs_like_lineedit="#undef EMACS_LIKE_LINEEDIT" -fi - -echo "Do you want to use vi-like behavior for numeric prefix like '2 SPC'?" -yesno vi_prec_num "$vi_prev_num" n -echo "vi_prec_num=$vi_prec_num" >> config.param -if [ "$vi_prec_num" = y ]; then - def_vi_prec_num="#define VI_PREC_NUM" -else - def_vi_prec_num="#undef VI_PREC_NUM" -fi - -echo "Do you want to use mark operations?" -yesno use_mark "$use_mark" n -echo "use_mark=$use_mark" >> config.param -if [ "$use_mark" = y ]; then - def_use_mark='#define USE_MARK' -else - def_use_mark='#undef USE_MARK' -fi - -echo "Do you want to move cursor to top line when going to label?" -yesno label_topline "$label_topline" n -echo "label_topline=$label_topline" >> config.param -if [ "$label_topline" = y ]; then - def_label_topline='#define LABEL_TOPLINE' -else - def_label_topline='#undef LABEL_TOPLINE' -fi - -echo "Do you want to move cursor to top line when moving to next page?" -yesno nextpage_topline "$nextpage_topline" n -echo "nextpage_topline=$nextpage_topline" >> config.param -if [ "$nextpage_topline" = y ]; then - def_nextpage_topline='#define NEXTPAGE_TOPLINE' -else - def_nextpage_topline='#undef NEXTPAGE_TOPLINE' -fi - if [ "$lang" = ja ]; then if [ "$lynx_key" = y ]; then helpfile="w3mhelp-lynx_ja.html" @@ -513,16 +438,6 @@ else def_kanji_symbols="#undef KANJI_SYMBOLS" fi -echo "Do you want ANSI color escape sequences support?" -yesno ansi_color "$ansi_color" n -echo "ansi_color=$ansi_color" >> config.param -if [ "$ansi_color" = y ]; then - def_ansi_color="#define USE_ANSI_COLOR" -else - def_ansi_color="#undef USE_ANSI_COLOR" -fi - - echo "Do you want to automatically generate domain parts of passwords for anonymous FTP logins" yesno ftppass_hostnamegen "$ftppass_hostnamegen" n echo "ftppass_hostnamegen=$ftppass_hostnamegen" >> config.param @@ -532,7 +447,16 @@ else def_ftppass_hostnamegen="#undef FTPPASS_HOSTNAMEGEN" fi -echo "Do you want NNTP support?" +echo "Do you want listing of options" +yesno show_params "$show_params" n +echo "show_params=$show_params" >> config.param +if [ "$show_params" = y ]; then + def_show_params="#define SHOW_PARAMS" +else + def_show_params="#undef SHOW_PARAMS" +fi + +echo "Do you want NNTP support" yesno use_nntp "$use_nntp" n echo "use_nntp=$use_nntp" >> config.param if [ "$use_nntp" = y ]; then @@ -541,22 +465,13 @@ else def_use_nntp="#undef USE_NNTP" fi -echo "Do you want Gopher support?" -yesno use_gopher "$use_gopher" n -echo "use_gopher=$use_gopher" >> config.param -if [ "$use_gopher" = y ]; then - def_use_gopher="#define USE_GOPHER" -else - def_use_gopher="#undef USE_GOPHER" -fi - -echo "Do you want use alarm function?" -yesno use_alarm "$use_alarm" n -echo "use_alarm=$use_alarm" >> config.param -if [ "$use_alarm" = y ]; then - def_use_alarm="#define USE_ALARM" +echo "Do you want ANSI color escape sequences support?" +yesno ansi_color "$ansi_color" n +echo "ansi_color=$ansi_color" >> config.param +if [ "$ansi_color" = y ]; then + def_ansi_color="#define ANSI_COLOR" else - def_use_alarm="#undef USE_ALARM" + def_ansi_color="#undef ANSI_COLOR" fi echo "" @@ -584,45 +499,45 @@ dmodel_save="$dmodel" dmodel=$ans case "$ans" in 1) - use_color=n; def_color="#undef USE_COLOR" - use_menu=n; def_menu="#undef USE_MENU" - use_mouse=n; def_mouse="#undef USE_MOUSE" + use_color=n; def_color="#undef COLOR" + use_menu=n; def_menu="#undef MENU" + use_mouse=n; def_mouse="#undef MOUSE" use_cookie=n; def_cookie="#undef USE_COOKIE" use_ssl=n; def_ssl="#undef USE_SSL" save_params customized=y ;; 2) - use_color=y; def_color="#define USE_COLOR" - use_menu=y; def_menu="#define USE_MENU" - use_mouse=n; def_mouse="#undef USE_MOUSE" + use_color=y; def_color="#define COLOR" + use_menu=y; def_menu="#define MENU" + use_mouse=n; def_mouse="#undef MOUSE" use_cookie=n; def_cookie="#undef USE_COOKIE" use_ssl=n; def_ssl="#undef USE_SSL" save_params customized=y ;; 3) - use_color=y; def_color="#define USE_COLOR" - use_menu=y; def_menu="#define USE_MENU" - use_mouse=y; def_mouse="#define USE_MOUSE" + use_color=y; def_color="#define COLOR" + use_menu=y; def_menu="#define MENU" + use_mouse=y; def_mouse="#define MOUSE" use_cookie=n; def_cookie="#undef USE_COOKIE" use_ssl=n; def_ssl="#undef USE_SSL" save_params customized=y ;; 4) - use_color=y; def_color="#define USE_COLOR" - use_menu=y; def_menu="#define USE_MENU" - use_mouse=y; def_mouse="#define USE_MOUSE" + use_color=y; def_color="#define COLOR" + use_menu=y; def_menu="#define MENU" + use_mouse=y; def_mouse="#define MOUSE" use_cookie=y; def_cookie="#define USE_COOKIE" use_ssl=n; def_ssl="#undef USE_SSL" save_params customized=y ;; 5) - use_color=y; def_color="#define USE_COLOR" - use_menu=y; def_menu="#define USE_MENU" - use_mouse=y; def_mouse="#define USE_MOUSE" + use_color=y; def_color="#define COLOR" + use_menu=y; def_menu="#define MENU" + use_mouse=y; def_mouse="#define MOUSE" use_cookie=y; def_cookie="#define USE_COOKIE" use_ssl=y; def_ssl="#define USE_SSL" find_ssl @@ -655,27 +570,27 @@ echo "Do you want to use color ESC sequence for kterm/pxvt " yesno use_color "$use_color" y echo "use_color=$use_color" >> config.param if [ "$use_color" = y ]; then - def_color="#define USE_COLOR" + def_color="#define COLOR" else - def_color="#undef USE_COLOR" + def_color="#undef COLOR" fi echo 'Do you want to use mouse? (It requires xterm/kterm)' yesno use_mouse "$use_mouse" n echo "use_mouse=$use_mouse" >> config.param if [ "$use_mouse" = y ]; then - def_mouse="#define USE_MOUSE" + def_mouse="#define MOUSE" else - def_mouse="#undef USE_MOUSE" + def_mouse="#undef MOUSE" fi echo "Do you want to use popup menu?" yesno use_menu "$use_menu" y echo "use_menu=$use_menu" >> config.param if [ "$use_menu" = y ]; then - def_menu="#define USE_MENU" + def_menu="#define MENU" else - def_menu="#undef USE_MENU" + def_menu="#undef MENU" fi #echo "Do you want to use matrix in rendering table?" @@ -888,14 +803,14 @@ case $sysname in ;; esac -extlib='' +bsdlib='' case $sysname in *bsd|*BSD) searchlibs="" ;; *) - searchlibs="bsd BSD 44bsd socket nsl" + searchlibs="bsd BSD 44bsd" ;; esac @@ -909,6 +824,7 @@ do fi done done + extlib='' searchlibs="socket nsl" @@ -958,7 +874,7 @@ fi gclib='' gcinclude='' gctarget='' -for libdir in ${gc_libdir} /lib /usr/lib /usr/local/lib /usr/ucblib /usr/ccslib /usr/ccs/lib $prefix/lib ${HOME}/lib +for libdir in /lib /usr/lib /usr/local/lib /usr/ucblib /usr/ccslib /usr/ccs/lib $prefix/lib ${HOME}/lib do if [ -f $libdir/libgc.a -o -f $libdir/libgc.$so_ext ] ; then echo "$libdir/libgc found" @@ -966,7 +882,7 @@ do break fi done -for inc in ${gc_includedir} /usr/include /usr/include/gc /usr/local/include /usr/local/include/gc $prefix/include ${HOME}/include +for inc in /usr/include /usr/include/gc /usr/local/include /usr/local/include/gc $prefix/include ${HOME}/include do if [ -f $inc/gc.h ]; then echo "$inc/gc.h found" @@ -977,19 +893,12 @@ done case $sysname in linux|Linux|LINUX|aix|Aix|AIX) - case $cflags in - *DEBIAN*) - # on Debian, we can use libgc*.deb - :;; - *) - # these OS requires gcmain.c, which include gc/gc_priv.h - # therefore we use gc library comes with w3m - echo "Your OS is $sysname; using gc library comes with w3m." - gcinclude="" - gclib="" - ;; - esac - ;; + # these OS requires gcmain.c, which include gc/gc_priv.h + # therefore we use gc library comes with w3m + echo "Your OS is $sysname; using gc library comes with w3m." + gcinclude="" + gclib="" + ;; esac if [ -n "$gclib" -a -n "$gcinclude" ]; then @@ -1071,17 +980,12 @@ echo "Checking machine dependency." ###### mime.types MIME_TYPES="" -if [ -n "$mimetypes" ] && [ -f "$mimetypes" ]; then - MIME_TYPES=$mimetypes -else - for d in /etc /usr/lib /usr/local/lib /usr/local/etc $prefix/lib /usr/local/etc/apache /usr/local/lib/mosaic /usr/local/mosaic /usr/local/netscape /usr/local/lib/netscape - do +for d in /etc /usr/local/etc /usr/lib /usr/local/lib $prefix/lib /usr/local/lib /mosaic /usr/local/mosaic /usr/local/netscape /usr/local/lib/netscape /usr/local/etc/apache +do if [ -f $d/mime.types ]; then MIME_TYPES="$d/mime.types" - break fi - done -fi +done if [ -z "$MIME_TYPES" ]; then echo "Global mime.types not found; Hope /usr/local/lib/mime.types works." MIME_TYPES=/usr/local/lib/mime.types @@ -1111,15 +1015,6 @@ else fi rm -rf hogege 2>&1 >/dev/null -####### perl -perl=`./which perl` -if [ `expr "$perl" : 'not found'` != 0 ]; then - echo "You don't have perl." - perl=/usr/local/bin/perl -else - echo "You have perl." -fi - ####### strcasecmp cat > _zmachdep.c << EOF #include <string.h> @@ -1132,10 +1027,10 @@ EOF if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 then echo "You have strcasecmp()." - strcasecmp_flg="#define HAVE_STRCASECMP" + strcasecmp_flg="#define STRCASECMP" else echo "You don't have strcasecmp()." - strcasecmp_flg="#undef HAVE_STRCASECMP" + strcasecmp_flg="#undef STRCASECMP" fi ####### strchr @@ -1150,10 +1045,10 @@ EOF if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 then echo "You have strchr()." - strchr_flg="#define HAVE_STRCHR" + strchr_flg="#define STRCHR" else echo "You don't have strchr()." - strchr_flg="#undef HAVE_STRCHR" + strchr_flg="#undef STRCHR" fi ####### strerror @@ -1167,10 +1062,10 @@ EOF if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 then echo "You have strerror()." - strerror_flg="#define HAVE_STRERROR" + strerror_flg="#define STRERROR" else echo "You don't have strerror()." - strerror_flg="#undef HAVE_STRERROR" + strerror_flg="#undef STRERROR" fi @@ -1184,10 +1079,10 @@ EOF if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 then echo "You have sys_errlist[]." - syserrlist_flg="#define HAVE_SYS_ERRLIST" + syserrlist_flg="#define SYS_ERRLIST" else echo "You don't have sys_errlist[]." - syserrlist_flg="#undef HAVE_SYS_ERRLIST" + syserrlist_flg="#undef SYS_ERRLIST" fi ####### bcopy @@ -1202,10 +1097,10 @@ EOF if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 then echo "You have bcopy()." - bcopy_flg="#define HAVE_BCOPY" + bcopy_flg="#undef NOBCOPY" else echo "You don't have bcopy()." - bcopy_flg="#undef HAVE_BCOPY" + bcopy_flg="#define NOBCOPY" fi ####### waitpid @@ -1300,10 +1195,10 @@ EOF if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 then echo "You have getcwd()." - getcwd_flg="#define HAVE_GETCWD" + getcwd_flg="#define GETCWD" else echo "You don't have getcwd()." - getcwd_flg="#undef HAVE_GETCWD" + getcwd_flg="#undef GETCWD" fi ####### getwd @@ -1317,10 +1212,10 @@ EOF if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 then echo "You have getwd()." - getwd_flg="#define HAVE_GETWD" + getwd_flg="#define GETWD" else echo "You don't have getwd()." - getwd_flg="#undef HAVE_GETWD" + getwd_flg="#undef GETWD" fi ####### readlink @@ -1334,10 +1229,10 @@ EOF if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 then echo "You have readlink()." - readlink_flg="#define HAVE_READLINK" + readlink_flg="#define READLINK" else echo "You don't have readlink()." - readlink_flg="#undef HAVE_READLINK" + readlink_flg="#undef READLINK" fi ####### setenv @@ -1450,24 +1345,6 @@ else getpassphrase_flg="#undef HAVE_GETPASSPHRASE" fi -####### chdir -cat > _zmachdep.c <<EOF -#include <stdio.h> -#include <unistd.h> -main() -{ - int (*c)() = chdir; -} -EOF -if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 -then - echo "You have chdir()." - chdir_flg="#define HAVE_CHDIR" -else - echo "You don't have chdir()." - chdir_flg="#undef HAVE_CHDIR" -fi - ####### fclose cat > _zmachdep.c << EOF #include <stdio.h> @@ -1508,22 +1385,22 @@ fi term_if='#define SGTTY' if [ $sysname = "HP-UX" ]; then echo "Your OS is HP-UX; using termio" - term_if="#define HAVE_TERMIO_H" + term_if="#define TERMIO" elif [ $sysname = "CYGWIN" ]; then echo "Your OS is CYGWIN; using termios" - term_if="#define HAVE_TERMIOS_H" + term_if="#define TERMIOS" elif [ $sysname = "OS/2" ]; then echo "Your OS is OS/2; using termios" - term_if='#define HAVE_TERMIOS_H' + term_if='#define TERMIOS' elif [ -r /usr/include/termios.h ]; then echo "You have termios." - term_if='#define HAVE_TERMIOS_H' + term_if='#define TERMIOS' elif [ -r /usr/include/termio.h ]; then echo "You have termio." - term_if='#define HAVE_TERMIO_H' + term_if='#define TERMIO' elif [ -r /usr/include/sgtty.h ]; then echo "You have sgtty." - term_if='#define HAVE_SGTTY_H' + term_if='#define SGTTY' else echo "Do you have tty interface? I can't find one but I hope sgtty works..." fi @@ -1532,13 +1409,13 @@ fi dir_if='' if [ $sysname = "CYGWIN" ]; then echo "Your OS is CYGWIN; using dirent.h" - dir_if='#define HAVE_DIRENT_H' + dir_if='#define DIRENT' elif [ $sysname = "OS/2" ]; then echo "Your OS is OS/2; using dirent.h" - dir_if='#define HAVE_DIRENT_H' + dir_if='#define DIRENT' elif [ -r /usr/include/dirent.h ]; then echo "You have dirent.h." - dir_if='#define HAVE_DIRENT_H' + dir_if='#define DIRENT' elif [ -r /usr/include/sys/dir.h ]; then echo "You have sys/dir.h." dir_if='' @@ -1590,27 +1467,6 @@ else fi fi -# check alarm() -if [ "$use_alarm" = y ]; then - cat > _zdmachdep.c <<EOF -#include <unistd.h> -#include <signal.h> -main() -{ - int sa = SIGALRM; - void (*)() = alarm; -} -EOF - if $cc $cflags -o _zmachdep _zmachdep.c > /dev/null 2>&1 - then - echo "You have alarm()." - else - echo "You don't have alarm(), disable USE_ALARM" - use_alarm=n - def_use_alarm="#undef USE_ALARM" - fi -fi - # check for float.h cat > _zmachdep.c << EOF #include <float.h> @@ -1622,25 +1478,9 @@ EOF if $cc $cflags -c _zmachdep.c > /dev/null 2>&1 then echo "You have float.h." - float_h='#define HAVE_FLOAT_H' + no_float_h='#undef NO_FLOAT_H' else - float_h='#undef HAVE_FLOAT_H' -fi - -####### check for sys/select.h -cat > _zmachdep.c <<EOF -#include <sys/select.h> -main() -{ - ; -} -EOF -if $cc $cflags -c _zmachdep.c > /dev/null 2>&1 -then - echo "You have sys/select.h." - sys_select_h='#define HAVE_SYS_SELECT_H' -else - sys_select_h='#undef HAVE_SYS_SELECT_H' + no_float_h='#define NO_FLOAT_H 1' fi ####### setpgrp(pid, pgrp) or setpgrp() ? @@ -1857,14 +1697,32 @@ cat > config.h << END_OF_CONFIG_H #undef DICT /* + If you define USE_MARK, you can use set-mark (C-SPC), + goto-next-mark (ESC p), goto-next-mark (ESC n) and + mark-by-regexp ("). +*/ +#undef USE_MARK + +/* If you want to load and save URL history. */ #define USE_HISTORY /* - USE_BG_COLOR enables w3m to set background color. + BG_COLOR enables w3m to set background color. + */ +#define BG_COLOR + +/* + VIEW_UNSEENOBJECTS enables w3m to make a link to unseen objects. + e.g. background image. */ -#define USE_BG_COLOR +#undef VIEW_UNSEENOBJECTS + +/* + VI_PREC_NUM enables vi-like behavior for '2 SPC' or '2 b' + */ +#undef VI_PREC_NUM /* * Do word fill @@ -1872,6 +1730,21 @@ cat > config.h << END_OF_CONFIG_H #undef FORMAT_NICE /* + * Support Gopher protocol + */ +#undef USE_GOPHER + +/* + * Support NNTP + */ +$def_use_nntp + +/* + * Support ANSI color escape sequences + */ +$def_ansi_color + +/* * Enable id attribute */ #define ID_EXT @@ -1887,14 +1760,29 @@ cat > config.h << END_OF_CONFIG_H #undef USE_EGD /* + * Use Emacs-like key binding for file name completion + */ +#undef EMACS_LIKE_LINEEDIT + +/* * Remove line trailing spaces in html buffer. */ #undef ENABLE_REMOVE_TRAILINGSPACES /* - * thin chars for menu frame + * Move cursor to top line when going to label. + */ +#undef LABEL_TOPLINE + +/* + * Move cursor to top line when moving to next page. */ -#undef MENU_THIN_FRAME +#undef NEXTPAGE_TOPLINE + +/* + Use alarm function. + */ +#undef USE_ALARM /**********************************************************/ #ifdef makefile_parameter @@ -1920,7 +1808,6 @@ GCLIB=$gclib GCTARGET=$gctarget RANLIB=$ranlib_cmd MKDIR=$MKDIR -PERL=$perl VERSION=$w3mversion MODEL=$sysname.$platform-$modelname-$lang #else @@ -1934,12 +1821,6 @@ $special_sys $use_lang $def_kanji_symbols $def_color -$def_ansi_color -$def_emacs_like_lineedit -$def_vi_prec_num -$def_use_mark -$def_label_topline -$def_nextpage_topline $def_mouse $use_gpm $use_sysmouse @@ -1948,9 +1829,7 @@ $def_cookie $def_ssl $def_use_ssl_verify $def_ftppass_hostnamegen -$def_use_nntp -$def_use_gopher -$def_use_alarm +$def_show_params #define DEF_EDITOR "$editor" #define DEF_MAILER "$mailer" @@ -1996,7 +1875,6 @@ $putenv_flg $srand48_flg $srandom_flg $getpassphrase_flg -$chdir_flg $fclose_dcl $pclose_dcl $setjmp_def @@ -2019,8 +1897,7 @@ $ipv6_ss_family #undef TABLE_NO_COMPACT #define NOWRAP 1 #define MATRIX 1 -$float_h -$sys_select_h +$no_float_h #ifndef HAVE_SRAND48 #ifdef HAVE_SRANDOM @@ -2043,26 +1920,6 @@ $sys_select_h #define SUPPORT_NETBIOS_SHARE 1 #endif -#if defined(__DJGPP__) -#define DEFAULT_TERM "dosansi" -#else -#define DEFAULT_TERM 0 /* XXX */ -#endif - -#if defined(__EMX__) /* use \$extension? */ -#define W3MBOOKMARK_CMDNAME "w3mbookmark.exe" -#define W3MHELPERPANEL_CMDNAME "w3mhelperpanel.exe" -#define DEV_NULL_PATH "nul" -#define DEV_TTY_PATH "con" -#define CGI_EXTENSION ".cmd" -#else -#define W3MBOOKMARK_CMDNAME "w3mbookmark" -#define W3MHELPERPANEL_CMDNAME "w3mhelperpanel" -#define DEV_NULL_PATH "/dev/null" -#define DEV_TTY_PATH "/dev/tty" -#define CGI_EXTENSION ".cgi" -#endif - #endif /* makefile_parameter */ #endif /* _CONFIGURED_ */ @@ -2071,5 +1928,13 @@ END_OF_CONFIG_H echo '' echo 'config.h is created. See config.h for further configuration.' echo '' +echo 'Generating dirlist.cgi' + +perl=`./which perl` +if [ `expr "$perl" : 'not found'` != 0 ]; then + perl=/usr/local/bin/perl +fi +sed -e "s;@PERL@;$perl;" \ + scripts/dirlist.in > scripts/dirlist.cgi echo 'Configuration done. Just type "make".' diff --git a/doc-jp/README b/doc-jp/README index 47bb104..501f707 100644 --- a/doc-jp/README +++ b/doc-jp/README @@ -1,5 +1,5 @@ - w3m: WWW wo Miru Tool version 0.2.2 - (C) Copyright by Akinori ITO November 2001 + w3m: WWW wo Miru Tool version 0.2.2 + (C) Copyright by Akinori ITO November 2001 1. ¤Ï¤¸¤á¤Ë @@ -105,5 +105,5 @@ Alan J. Demers ¤ª¤è¤Ó Xerox Corporation, Silicon Graphics ¤Ë°¤· »³·ÁÂç³Ø¹©³ØÉôÅŻҾðÊó¹©³Ø²Ê °ËÆ£ ¾´Â§ - aito@fw.ipsj.or.jp - http://w3m.sourceforge.net/ + aito@fw.ipsj.or.jp + http://w3m.sourceforge.net/ @@ -1,5 +1,5 @@ - w3m: WWW wo Miru Tool version 0.2.2 - (C) Copyright by Akinori ITO November 21, 2001 + w3m: WWW wo Miru Tool version 0.2.2 + (C) Copyright by Akinori ITO November 21, 2001 1. Introduction @@ -100,5 +100,5 @@ Feel free to send your opinion to the author. Akinori Ito Faculty of Engineering, Yamagata University - aito@fw.ipsj.or.jp - http://w3m.sourceforge.net/ + aito@fw.ipsj.or.jp + http://w3m.sourceforge.net/ @@ -1,4 +1,4 @@ -/* $Id: file.c,v 1.11 2001/11/21 19:24:35 ukai Exp $ */ +/* $Id: file.c,v 1.6.2.1 2001/11/22 17:52:28 inu Exp $ */ #include "fm.h" #include <sys/types.h> #include "myctype.h" @@ -7,6 +7,9 @@ #include <sys/wait.h> #include <stdio.h> #include <time.h> +#ifdef __EMX__ +#include <strings.h> +#endif /* __EMX__ */ #include <sys/stat.h> #include <fcntl.h> /* foo */ @@ -30,13 +33,13 @@ static Buffer *loadcmdout(char *cmd, Buffer *defaultbuf); static void close_textarea(struct html_feed_environ *h_env); static void addnewline(Buffer * buf, char *line, Lineprop * prop, -#ifdef USE_ANSI_COLOR +#ifdef ANSI_COLOR Linecolor * color, #endif int pos, int nlines); static Lineprop propBuffer[LINELEN]; -#ifdef USE_ANSI_COLOR +#ifdef ANSI_COLOR static Linecolor colorBuffer[LINELEN]; #endif @@ -147,6 +150,19 @@ char *violations[COO_EMAX] = { #define SAVE_BUF_SIZE 1536 +#ifndef STRCHR +char * +strchr(char *s, char c) +{ + while (*s) { + if (*s == c) + return s; + s++; + } + return NULL; +} +#endif /* not STRCHR */ + static MySignalHandler KeyAbort(SIGNAL_ARG) { @@ -487,14 +503,14 @@ readHeader(URLFile * uf, for (p = lineBuf2->ptr; *p; p = q) { for (q = p; *q && *q != '\r' && *q != '\n'; q++); lineBuf2 = checkType(Strnew_charp(p), propBuffer, -#ifdef USE_ANSI_COLOR +#ifdef ANSI_COLOR NULL, NULL, #endif min(LINELEN, q - p)); Strcat(tmp, lineBuf2); if (thru) addnewline(newBuf, lineBuf2->ptr, propBuffer, -#ifdef USE_ANSI_COLOR +#ifdef ANSI_COLOR NULL, #endif lineBuf2->length, -1); @@ -703,7 +719,7 @@ readHeader(URLFile * uf, } if (thru) addnewline(newBuf, "", propBuffer, -#ifdef USE_ANSI_COLOR +#ifdef ANSI_COLOR NULL, #endif 0, -1); @@ -3579,16 +3595,16 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env) } #ifdef USE_ALARM else if (!is_redisplay && refresh > 0 && MetaRefresh) { - setAlarmEvent(refresh, AL_IMPLICIT, FUNCNAME_goURL, s_tmp->ptr); + setAlarmEvent(refresh, AL_IMPLICIT, FUNCNAME_goURL, s_tmp->ptr); } #endif } #ifdef USE_ALARM else if (!is_redisplay && refresh > 0 && MetaRefresh) { - tmp = Sprintf("Refresh (%d sec)", refresh); - push_str(obuf, 0, tmp, PC_ASCII); - flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); - setAlarmEvent(refresh, AL_IMPLICIT, FUNCNAME_reload, NULL); + tmp = Sprintf("Refresh (%d sec)", refresh); + push_str(obuf, 0, tmp, PC_ASCII); + flushline(h_env, obuf, envs[h_env->envc].indent, 0, h_env->limit); + setAlarmEvent(refresh, AL_IMPLICIT, FUNCNAME_reload, NULL); } #endif } @@ -3614,6 +3630,7 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env) case HTML_N_FONT: case HTML_NOP: return 1; +#ifdef VIEW_UNSEENOBJECTS case HTML_BGSOUND: if (view_unseenobject) { if (parsedtag_get_value(tag, ATTR_SRC, &p)) { @@ -3644,7 +3661,9 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env) } } return 1; +#endif /* VIEW_UNSEENOBJECTS */ case HTML_BODY: +#ifdef VIEW_UNSEENOBJECTS if (view_unseenobject) { if (parsedtag_get_value(tag, ATTR_BACKGROUND, &p)) { Str s; @@ -3654,6 +3673,7 @@ HTMLtagproc1(struct parsed_tag *tag, struct html_feed_environ *h_env) HTMLlineproc1(s->ptr, h_env); } } +#endif /* VIEW_UNSEENOBJECTS */ case HTML_N_BODY: obuf->flag |= RB_IGNORE_P; return 1; @@ -3718,6 +3738,12 @@ HTMLlineproc2body(Buffer * buf, Str (*feed) (), int llimit) if (++nlines == llimit) break; pos = 0; + if (showLineNum) { + tmp = Sprintf("%4d:", nlines); + for (p = tmp->ptr; *p; p++) { + PPUSH(PC_ASCII, *p); + } + } #ifdef ENABLE_REMOVE_TRAILINGSPACES Strremovetrailingspaces(line); #endif @@ -4014,7 +4040,7 @@ HTMLlineproc2body(Buffer * buf, Str (*feed) (), int llimit) } /* end of processing for one line */ addnewline(buf, outc, outp, -#ifdef USE_ANSI_COLOR +#ifdef ANSI_COLOR NULL, #endif pos, nlines); @@ -4517,7 +4543,7 @@ extern Lineprop NullProp[]; static void addnewline(Buffer * buf, char *line, Lineprop * prop, -#ifdef USE_ANSI_COLOR +#ifdef ANSI_COLOR Linecolor * color, #endif int pos, int nlines) @@ -4534,7 +4560,7 @@ addnewline(Buffer * buf, char *line, Lineprop * prop, l->lineBuf = NullLine; l->propBuf = NullProp; } -#ifdef USE_ANSI_COLOR +#ifdef ANSI_COLOR if (pos > 0 && color) { l->colorBuf = NewAtom_N(Linecolor, pos); bcopy((void *) color, (void *) l->colorBuf, pos * sizeof(Linecolor)); @@ -4581,7 +4607,7 @@ loadHTMLBuffer(URLFile * f, Buffer * newBuf) if (newBuf->sourcefile == NULL && (f->scheme != SCM_LOCAL || newBuf->mailcap)) { tmp = tmpfname(TMPF_SRC, ".html"); - pushText(fileToDelete, tmp->ptr); + pushText(fileToDelete, tmp->ptr); src = fopen(tmp->ptr, "w"); if (src) newBuf->sourcefile = tmp->ptr; @@ -4849,12 +4875,12 @@ loadHTMLstream(URLFile * f, Buffer * newBuf, FILE * src, int internal) htmlenv1.buf = newTextLineList(); if (SETJMP(AbortLoading) != 0) { - HTMLlineproc1("<br>Transfer Interrupted!<br>", &htmlenv1); - goto phase2; + HTMLlineproc1("<br>Transfer Interrupted!<br>", &htmlenv1); + goto phase2; } if (fmInitialized) { - prevtrap = signal(SIGINT, KeyAbort); - term_cbreak(); + prevtrap = signal(SIGINT, KeyAbort); + term_cbreak(); } #ifdef JP_CHARSET @@ -5093,7 +5119,7 @@ loadBuffer(URLFile * uf, Buffer * newBuf) int nlines; Str tmpf; int linelen = 0, trbyte = 0; -#ifdef USE_ANSI_COLOR +#ifdef ANSI_COLOR int check_color; #endif MySignalHandler(*prevtrap) (); @@ -5144,6 +5170,11 @@ loadBuffer(URLFile * uf, Buffer * newBuf) pre_lbuf = lineBuf2->ptr[0]; } ++nlines; + if (showLineNum) { + Str tmp = Sprintf("%4d:", nlines); + Strcat(tmp, lineBuf2); + lineBuf2 = tmp; + } #ifdef USE_NNTP if (uf->scheme == SCM_NEWS) { if (Str_news_endline(lineBuf2)) { @@ -5154,12 +5185,12 @@ loadBuffer(URLFile * uf, Buffer * newBuf) #endif /* USE_NNTP */ Strchop(lineBuf2); lineBuf2 = checkType(lineBuf2, propBuffer, -#ifdef USE_ANSI_COLOR +#ifdef ANSI_COLOR colorBuffer, &check_color, #endif LINELEN); addnewline(newBuf, lineBuf2->ptr, propBuffer, -#ifdef USE_ANSI_COLOR +#ifdef ANSI_COLOR check_color ? colorBuffer : NULL, #endif lineBuf2->length, nlines); @@ -5239,6 +5270,8 @@ saveBufferDelNum(Buffer * buf, FILE * f, int del) else #endif tmp = Strnew_charp_n(l->lineBuf, l->len); + if (del && l->real_linenumber && (p = strchr(tmp->ptr, ':')) != NULL) + Strdelete(tmp, 0, p - tmp->ptr + 1); #ifdef JP_CHARSET tmp = conv_str(tmp, InnerCode, DisplayCode); #endif @@ -5405,7 +5438,7 @@ getNextPage(Buffer * buf, int plen) URLFile uf; char code; int squeeze_flag = 0; -#ifdef USE_ANSI_COLOR +#ifdef ANSI_COLOR int check_color; #endif @@ -5417,6 +5450,11 @@ getNextPage(Buffer * buf, int plen) if (pl != NULL) { nlines = pl->real_linenumber; pre_lbuf = *(pl->lineBuf); + if (showLineNum) { + char *p; + if ((p = strchr(pl->lineBuf, ':')) != NULL) + pre_lbuf = *(p + 1); + } if (pre_lbuf == '\0') pre_lbuf = '\n'; } @@ -5453,9 +5491,14 @@ getNextPage(Buffer * buf, int plen) pre_lbuf = lineBuf2->ptr[0]; } ++nlines; + if (showLineNum) { + Str tmp = Sprintf("%4d:", nlines); + Strcat(tmp, lineBuf2); + lineBuf2 = tmp; + } Strchop(lineBuf2); lineBuf2 = checkType(lineBuf2, propBuffer, -#ifdef USE_ANSI_COLOR +#ifdef ANSI_COLOR colorBuffer, &check_color, #endif LINELEN); @@ -5464,7 +5507,7 @@ getNextPage(Buffer * buf, int plen) l->lineBuf = lineBuf2->ptr; l->propBuf = NewAtom_N(Lineprop, len); bcopy((void *) propBuffer, (void *) l->propBuf, len * sizeof(Lineprop)); -#ifdef USE_ANSI_COLOR +#ifdef ANSI_COLOR if (check_color) { l->colorBuf = NewAtom_N(Linecolor, len); bcopy((void *) colorBuffer, (void *) l->colorBuf, len * sizeof(Linecolor)); @@ -1,4 +1,4 @@ -/* $Id: fm.h,v 1.11 2001/11/22 15:02:17 ukai Exp $ */ +/* $Id: fm.h,v 1.4.2.1 2001/11/22 17:52:28 inu Exp $ */ /* * w3m: WWW wo Miru utility * @@ -18,13 +18,13 @@ #include "config.h" #include "history.h" -#ifdef USE_MENU +#ifdef MENU #define MENU_SELECT #define MENU_MAP -#endif /* USE_MENU */ +#endif /* MENU */ -#ifndef USE_COLOR -#undef USE_ANSI_COLOR +#ifndef COLOR +#undef ANSI_COLOR #endif #include "ctrlcode.h" @@ -41,13 +41,12 @@ #include "funcname1.h" #include "terms.h" -#ifndef HAVE_BCOPY +#ifdef NOBCOPY void bcopy(void *, void *, int); void bzero(void *, int); -#endif /* HAVE_BCOPY */ -#ifdef __EMX__ -#include <strings.h> /* for bzero() and bcopy() */ -#endif +#else /* not NOBCOPY */ +#include <string.h> +#endif /* not NOBCOPY */ #ifdef MAINPROGRAM #define global @@ -230,7 +229,7 @@ extern int REV_LB[]; #define free(x) GC_free(x) /* let GC do it. */ #ifdef __EMX__ -#define HAVE_STRCASECMP +#define STRCASECMP #define strcasecmp stricmp #define strncasecmp strnicmp #endif /* __EMX__ */ @@ -255,7 +254,7 @@ extern int REV_LB[]; */ typedef unsigned short Lineprop; -#ifdef USE_ANSI_COLOR +#ifdef ANSI_COLOR typedef unsigned char Linecolor; #endif @@ -269,7 +268,7 @@ typedef struct _MapList { typedef struct _Line { char *lineBuf; Lineprop *propBuf; -#ifdef USE_ANSI_COLOR +#ifdef ANSI_COLOR Linecolor *colorBuf; #endif struct _Line *next; @@ -333,8 +332,6 @@ typedef struct _Buffer { short cursorY; short pos; short visualpos; - short rootX; - short COLS; InputStream pagerSource; AnchorList *href; AnchorList *name; @@ -603,11 +600,12 @@ typedef struct http_request { */ extern int LINES, COLS; -#if defined(__CYGWIN__) && LANG == JA -extern int LASTLINE; -#else /* not defined(__CYGWIN__) || LANG != JA */ +#if defined(CYGWIN) && LANG == JA +extern int isWinConsole; +#define LASTLINE (LINES-(isWinConsole ? 2 : 1)) +#else /* not defined(CYGWIN) && LANG == JA */ #define LASTLINE (LINES-1) -#endif /* not defined(__CYGWIN__) || LANG != JA */ +#endif /* not defined(CYGWIN) && LANG == JA */ global int Tabstop init(8); global int ShowEffect init(TRUE); @@ -668,7 +666,7 @@ global Buffer *Currentbuf; global Buffer *Firstbuf; global int CurrentKey; global char *CurrentKeyData; -#ifdef USE_MENU +#ifdef MENU global char *CurrentMenuData; #endif extern char *ullevel[]; @@ -688,20 +686,20 @@ global int w3m_halfload init(FALSE); global Str header_string init(NULL); global int override_content_type init(FALSE); -#ifdef USE_COLOR +#ifdef COLOR global int useColor init(TRUE); global int basic_color init(8); /* don't change */ global int anchor_color init(4); /* blue */ global int image_color init(2); /* green */ global int form_color init(1); /* red */ -#ifdef USE_BG_COLOR +#ifdef BG_COLOR global int bg_color init(8); /* don't change */ -#endif /* USE_BG_COLOR */ +#endif /* BG_COLOR */ global int useActiveColor init(FALSE); global int active_color init(6); /* cyan */ global int useVisitedColor init(FALSE); global int visited_color init(5); /* magenta */ -#endif /* USE_COLOR */ +#endif /* COLOR */ global int confirm_on_quit init(TRUE); global int displayLink init(FALSE); global int retryAsHttp init(TRUE); @@ -785,11 +783,11 @@ extern char UseAltEntity; global char *rc_dir; global int rc_dir_is_tmp init(FALSE); -#ifdef USE_MOUSE +#ifdef MOUSE global int use_mouse init(TRUE); extern int mouseActive; global int reverse_mouse init(FALSE); -#endif /* USE_MOUSE */ +#endif /* MOUSE */ #ifdef USE_COOKIE global int default_use_cookie init(TRUE); @@ -802,7 +800,9 @@ global TextList *Cookie_reject_domains; global TextList *Cookie_accept_domains; #endif /* USE_COOKIE */ +#ifdef VIEW_UNSEENOBJECTS global int view_unseenobject init(TRUE); +#endif /* VIEW_UNSEENOBJECTS */ #if defined(USE_SSL) && defined(USE_SSL_VERIFY) global int ssl_verify_server init(FALSE); @@ -1,9 +1,12 @@ -/* $Id: frame.c,v 1.5 2001/11/20 13:17:13 ukai Exp $ */ +/* $Id: frame.c,v 1.3.2.1 2001/11/22 17:52:28 inu Exp $ */ #include "fm.h" #include "parsetagx.h" #include "myctype.h" #include <signal.h> #include <setjmp.h> +#ifdef __EMX__ +#include <strings.h> /* for bzero() and bcopy() */ +#endif /* __EMX__ */ #ifdef KANJI_SYMBOLS #define RULE_WIDTH 2 @@ -38,10 +41,10 @@ newFrameSet(struct parsed_tag *tag) if (cols) { length[i] = p = cols; while (*p != '\0') - if (*p++ == ',') { + if (*p++ == ',') { length[++i] = p; - if (i >= sizeof(length) / sizeof(length[0]) - 2) break; - } + if (i >= sizeof(length) / sizeof(length[0]) - 2) break; + } length[++i] = p + 1; } if (i > 1) { @@ -76,10 +79,10 @@ newFrameSet(struct parsed_tag *tag) if (rows) { length[i] = p = rows; while (*p != '\0') - if (*p++ == ',') { + if (*p++ == ',') { length[++i] = p; - if (i >= sizeof(length) / sizeof(length[0]) - 2) break; - } + if (i >= sizeof(length) / sizeof(length[0]) - 2) break; + } length[++i] = p + 1; } if (i > 1) { diff --git a/gc/Makefile b/gc/Makefile index a5d24c6..8e8ed25 100644 --- a/gc/Makefile +++ b/gc/Makefile @@ -10,13 +10,20 @@ # c++ interface to gc.a # cord/de - builds dumb editor based on cords. ABI_FLAG= +# ABI_FLAG should be the cc flag that specifies the ABI. On most +# platforms this will be the empty string. Possible values: +# +DD64 for 64-bit executable on HP/UX. +# -n32, -n64, -o32 for SGI/MIPS ABIs. + +AS_ABI_FLAG=$(ABI_FLAG) +# ABI flag for assembler. On HP/UX this is +A64 for 64 bit +# executables. + CC=cc $(ABI_FLAG) CXX=g++ $(ABI_FLAG) -AS=as $(ABI_FLAG) +AS=as $(AS_ABI_FLAG) # The above doesn't work with gas, which doesn't run cpp. # Define AS as `gcc -c -x assembler-with-cpp' instead. -# Under Irix 6, you will have to specify the ABI (-o32, -n32, or -64) -# if you use something other than the default ABI on your machine. # Redefining srcdir allows object code for the nonPCR version of the collector # to be generated in different directories. @@ -54,12 +61,15 @@ HOSTCFLAGS=$(CFLAGS) # gc.h before performing thr_ or dl* or GC_ operations.) # Must also define -D_REENTRANT. # -DGC_SOLARIS_PTHREADS enables support for Solaris pthreads. -# Define SOLARIS_THREADS as well. +# (Internally this define GC_SOLARIS_THREADS as well.) # -DGC_IRIX_THREADS enables support for Irix pthreads. See README.irix. # -DGC_HPUX_THREADS enables support for HP/UX 11 pthreads. # Also requires -D_REENTRANT or -D_POSIX_C_SOURCE=199506L. See README.hp. # -DGC_LINUX_THREADS enables support for Xavier Leroy's Linux threads. # see README.linux. -D_REENTRANT may also be required. +# -DGC_OSF1_THREADS enables support for Tru64 pthreads. Untested. +# -DGC_FREEBSD_THREADS enables support for FreeBSD pthreads. Untested. +# Appeared to run into some underlying thread problems. # -DALL_INTERIOR_POINTERS allows all pointers to the interior # of objects to be recognized. (See gc_priv.h for consequences.) # Alternatively, GC_all_interior_pointers can be set at process @@ -136,8 +146,8 @@ HOSTCFLAGS=$(CFLAGS) # Works for Solaris and Irix. # -DUSE_MUNMAP causes memory to be returned to the OS under the right # circumstances. This currently disables VM-based incremental collection. -# This is currently experimental, and works only under some Unix and -# Linux versions. +# This is currently experimental, and works only under some Unix, +# Linux and Windows versions. # -DMMAP_STACKS (for Solaris threads) Use mmap from /dev/zero rather than # GC_scratch_alloc() to get stack memory. # -DPRINT_BLACK_LIST Whenever a black list entry is added, i.e. whenever @@ -191,8 +201,8 @@ HOSTCFLAGS=$(CFLAGS) # 15% or so. # -DUSE_3DNOW_PREFETCH causes the collector to issue AMD 3DNow style # prefetch instructions. Same restrictions as USE_I686_PREFETCH. -# UNTESTED!! -# -DGC_USE_LD_WRAP in combination with the gld flags listed in README.linux +# Minimally tested. Didn't appear to be an obvious win on a K6-2/500. +# -DGC_USE_LD_WRAP in combination with the old flags listed in README.linux # causes the collector some system and pthread calls in a more transparent # fashion than the usual macro-based approach. Requires GNU ld, and # currently probably works only with Linux. @@ -209,6 +219,14 @@ HOSTCFLAGS=$(CFLAGS) # These may otherwise alter its configuration, or turn off GC altogether. # I don't know of a reason to disable this, except possibly if the # resulting process runs as a privileged user? +# -DUSE_GLOBAL_ALLOC. Win32 only. Use GlobalAlloc instead of +# VirtualAlloc to allocate the heap. May be needed to work around +# a Windows NT/2000 issue. Incompatible with USE_MUNMAP. +# See README.win32 for details. +# -DMAKE_BACK_GRAPH. Enable GC_PRINT_BACK_HEIGHT environment variable. +# See README.environment for details. Experimental. Limited platform +# support. Implies DBG_HDRS_ALL. All allocation should be done using +# the debug interface. # -DSTUBBORN_ALLOC allows allocation of "hard to change" objects, and thus # makes incremental collection easier. Was enabled by default until 6.0. # Rarely used, to my knowledge. @@ -219,9 +237,9 @@ AR= ar RANLIB= ranlib -OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o dbg_mlc.o malloc.o stubborn.o checksums.o solaris_threads.o irix_threads.o linux_threads.o typd_mlc.o ptr_chck.o mallocx.o solaris_pthreads.o gcj_mlc.o specific.o gc_dlopen.o +OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o dbg_mlc.o malloc.o stubborn.o checksums.o solaris_threads.o irix_threads.o linux_threads.o typd_mlc.o ptr_chck.o mallocx.o solaris_pthreads.o gcj_mlc.o specific.o gc_dlopen.o backgraph.o -CSRCS= reclaim.c allchblk.c misc.c alloc.c mach_dep.c os_dep.c mark_rts.c headers.c mark.c obj_map.c pcr_interface.c blacklst.c finalize.c new_hblk.c real_malloc.c dyn_load.c dbg_mlc.c malloc.c stubborn.c checksums.c solaris_threads.c irix_threads.c linux_threads.c typd_mlc.c ptr_chck.c mallocx.c solaris_pthreads.c gcj_mlc.c specific.c gc_dlopen.c +CSRCS= reclaim.c allchblk.c misc.c alloc.c mach_dep.c os_dep.c mark_rts.c headers.c mark.c obj_map.c pcr_interface.c blacklst.c finalize.c new_hblk.c real_malloc.c dyn_load.c dbg_mlc.c malloc.c stubborn.c checksums.c solaris_threads.c irix_threads.c linux_threads.c typd_mlc.c ptr_chck.c mallocx.c solaris_pthreads.c gcj_mlc.c specific.c gc_dlopen.c backgraph.c CORD_SRCS= cord/cordbscs.c cord/cordxtra.c cord/cordprnt.c cord/de.c cord/cordtest.c include/cord.h include/ec.h include/private/cord_pos.h cord/de_win.c cord/de_win.h cord/de_cmds.h cord/de_win.ICO cord/de_win.RC @@ -242,7 +260,8 @@ SRCS= $(CSRCS) mips_sgi_mach_dep.s rs6000_mach_dep.s alpha_mach_dep.s \ include/gc_local_alloc.h include/private/dbg_mlc.h \ include/private/specific.h powerpc_macosx_mach_dep.s \ include/leak_detector.h include/gc_amiga_redirects.h \ - include/gc_pthread_redirects.h $(CORD_SRCS) + include/gc_pthread_redirects.h ia64_save_regs_in_stack.s \ + $(CORD_SRCS) DOC_FILES= README.QUICK doc/README.Mac doc/README.MacOSX doc/README.OS2 \ doc/README.amiga doc/README.cords doc/debugging.html \ @@ -251,7 +270,7 @@ DOC_FILES= README.QUICK doc/README.Mac doc/README.MacOSX doc/README.OS2 \ doc/README.win32 doc/barrett_diagram doc/README \ doc/README.contributors doc/README.changes doc/gc.man \ doc/README.environment doc/tree.html doc/gcdescr.html \ - doc/README.autoconf doc/README.macros + doc/README.autoconf doc/README.macros doc/README.ews4800 TESTS= tests/test.c tests/test_cpp.cc tests/trace_test.c \ tests/leak_test.c tests/thread_leak_test.c @@ -435,6 +454,9 @@ mach_dep.o: $(srcdir)/mach_dep.c $(srcdir)/mips_sgi_mach_dep.s $(srcdir)/mips_ul ./if_mach SPARC SUNOS4 $(AS) -o mach_dep.o $(srcdir)/sparc_sunos4_mach_dep.s ./if_mach SPARC OPENBSD $(AS) -o mach_dep.o $(srcdir)/sparc_sunos4_mach_dep.s ./if_mach SPARC NETBSD $(AS) -o mach_dep.o $(srcdir)/sparc_netbsd_mach_dep.s + ./if_mach IA64 "" as $(AS_ABI_FLAG) -o ia64_save_regs_in_stack.o $(srcdir)/ia64_save_regs_in_stack.s + ./if_mach IA64 "" $(CC) -c -o mach_dep1.o $(SPECIALCFLAGS) $(srcdir)/mach_dep.c + ./if_mach IA64 "" ld -r -o mach_dep.o mach_dep1.o ia64_save_regs_in_stack.o ./if_not_there mach_dep.o $(CC) -c $(SPECIALCFLAGS) $(srcdir)/mach_dep.c mark_rts.o: $(srcdir)/mark_rts.c $(UTILS) diff --git a/gc/Makefile.am b/gc/Makefile.am index 4fdf31b..2cefd82 100644 --- a/gc/Makefile.am +++ b/gc/Makefile.am @@ -42,7 +42,8 @@ libgc_la_SOURCES = allchblk.c alloc.c blacklst.c checksums.c dbg_mlc.c \ dyn_load.c finalize.c gc_dlopen.c gcj_mlc.c headers.c irix_threads.c \ linux_threads.c malloc.c mallocx.c mark.c mark_rts.c misc.c new_hblk.c \ obj_map.c os_dep.c pcr_interface.c ptr_chck.c real_malloc.c reclaim.c \ -solaris_pthreads.c solaris_threads.c specific.c stubborn.c typd_mlc.c +solaris_pthreads.c solaris_threads.c specific.c stubborn.c typd_mlc.c \ +backgraph.c # Include THREADLIBS here to ensure that the correct versions of # linuxthread semaphore functions get linked: @@ -53,7 +54,7 @@ libgc_la_LDFLAGS = -version-info 1:1:0 -rpath $(toolexeclibdir) EXTRA_libgc_la_SOURCES = alpha_mach_dep.s \ mips_sgi_mach_dep.s mips_ultrix_mach_dep.s powerpc_macosx_mach_dep.s \ rs6000_mach_dep.s sparc_mach_dep.s sparc_netbsd_mach_dep.s \ -sparc_sunos4_mach_dep.s +sparc_sunos4_mach_dep.s ia64_save_regs_in_stack.s AM_CXXFLAGS = @GC_CFLAGS@ AM_CFLAGS = @GC_CFLAGS@ @@ -62,7 +63,9 @@ check_PROGRAMS = gctest # The following hack produces a warning from automake, but we need it in order # to build a file from a subdirectory. FIXME. test.o: tests/test.c - $(COMPILE) -c $< + $(COMPILE) -c tests/test.c +# Using $< in the above seems to fail with the HP/UX on Itanium make. + gctest_OBJECTS = test.o gctest_LDADD = ./libgc.la $(THREADLIBS) $(EXTRA_TEST_LIBS) TESTS_ENVIRONMENT = LD_LIBRARY_PATH=../../$(MULTIBUILDTOP)gcc diff --git a/gc/Makefile.direct b/gc/Makefile.direct index a5d24c6..8e8ed25 100644 --- a/gc/Makefile.direct +++ b/gc/Makefile.direct @@ -10,13 +10,20 @@ # c++ interface to gc.a # cord/de - builds dumb editor based on cords. ABI_FLAG= +# ABI_FLAG should be the cc flag that specifies the ABI. On most +# platforms this will be the empty string. Possible values: +# +DD64 for 64-bit executable on HP/UX. +# -n32, -n64, -o32 for SGI/MIPS ABIs. + +AS_ABI_FLAG=$(ABI_FLAG) +# ABI flag for assembler. On HP/UX this is +A64 for 64 bit +# executables. + CC=cc $(ABI_FLAG) CXX=g++ $(ABI_FLAG) -AS=as $(ABI_FLAG) +AS=as $(AS_ABI_FLAG) # The above doesn't work with gas, which doesn't run cpp. # Define AS as `gcc -c -x assembler-with-cpp' instead. -# Under Irix 6, you will have to specify the ABI (-o32, -n32, or -64) -# if you use something other than the default ABI on your machine. # Redefining srcdir allows object code for the nonPCR version of the collector # to be generated in different directories. @@ -54,12 +61,15 @@ HOSTCFLAGS=$(CFLAGS) # gc.h before performing thr_ or dl* or GC_ operations.) # Must also define -D_REENTRANT. # -DGC_SOLARIS_PTHREADS enables support for Solaris pthreads. -# Define SOLARIS_THREADS as well. +# (Internally this define GC_SOLARIS_THREADS as well.) # -DGC_IRIX_THREADS enables support for Irix pthreads. See README.irix. # -DGC_HPUX_THREADS enables support for HP/UX 11 pthreads. # Also requires -D_REENTRANT or -D_POSIX_C_SOURCE=199506L. See README.hp. # -DGC_LINUX_THREADS enables support for Xavier Leroy's Linux threads. # see README.linux. -D_REENTRANT may also be required. +# -DGC_OSF1_THREADS enables support for Tru64 pthreads. Untested. +# -DGC_FREEBSD_THREADS enables support for FreeBSD pthreads. Untested. +# Appeared to run into some underlying thread problems. # -DALL_INTERIOR_POINTERS allows all pointers to the interior # of objects to be recognized. (See gc_priv.h for consequences.) # Alternatively, GC_all_interior_pointers can be set at process @@ -136,8 +146,8 @@ HOSTCFLAGS=$(CFLAGS) # Works for Solaris and Irix. # -DUSE_MUNMAP causes memory to be returned to the OS under the right # circumstances. This currently disables VM-based incremental collection. -# This is currently experimental, and works only under some Unix and -# Linux versions. +# This is currently experimental, and works only under some Unix, +# Linux and Windows versions. # -DMMAP_STACKS (for Solaris threads) Use mmap from /dev/zero rather than # GC_scratch_alloc() to get stack memory. # -DPRINT_BLACK_LIST Whenever a black list entry is added, i.e. whenever @@ -191,8 +201,8 @@ HOSTCFLAGS=$(CFLAGS) # 15% or so. # -DUSE_3DNOW_PREFETCH causes the collector to issue AMD 3DNow style # prefetch instructions. Same restrictions as USE_I686_PREFETCH. -# UNTESTED!! -# -DGC_USE_LD_WRAP in combination with the gld flags listed in README.linux +# Minimally tested. Didn't appear to be an obvious win on a K6-2/500. +# -DGC_USE_LD_WRAP in combination with the old flags listed in README.linux # causes the collector some system and pthread calls in a more transparent # fashion than the usual macro-based approach. Requires GNU ld, and # currently probably works only with Linux. @@ -209,6 +219,14 @@ HOSTCFLAGS=$(CFLAGS) # These may otherwise alter its configuration, or turn off GC altogether. # I don't know of a reason to disable this, except possibly if the # resulting process runs as a privileged user? +# -DUSE_GLOBAL_ALLOC. Win32 only. Use GlobalAlloc instead of +# VirtualAlloc to allocate the heap. May be needed to work around +# a Windows NT/2000 issue. Incompatible with USE_MUNMAP. +# See README.win32 for details. +# -DMAKE_BACK_GRAPH. Enable GC_PRINT_BACK_HEIGHT environment variable. +# See README.environment for details. Experimental. Limited platform +# support. Implies DBG_HDRS_ALL. All allocation should be done using +# the debug interface. # -DSTUBBORN_ALLOC allows allocation of "hard to change" objects, and thus # makes incremental collection easier. Was enabled by default until 6.0. # Rarely used, to my knowledge. @@ -219,9 +237,9 @@ AR= ar RANLIB= ranlib -OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o dbg_mlc.o malloc.o stubborn.o checksums.o solaris_threads.o irix_threads.o linux_threads.o typd_mlc.o ptr_chck.o mallocx.o solaris_pthreads.o gcj_mlc.o specific.o gc_dlopen.o +OBJS= alloc.o reclaim.o allchblk.o misc.o mach_dep.o os_dep.o mark_rts.o headers.o mark.o obj_map.o blacklst.o finalize.o new_hblk.o dbg_mlc.o malloc.o stubborn.o checksums.o solaris_threads.o irix_threads.o linux_threads.o typd_mlc.o ptr_chck.o mallocx.o solaris_pthreads.o gcj_mlc.o specific.o gc_dlopen.o backgraph.o -CSRCS= reclaim.c allchblk.c misc.c alloc.c mach_dep.c os_dep.c mark_rts.c headers.c mark.c obj_map.c pcr_interface.c blacklst.c finalize.c new_hblk.c real_malloc.c dyn_load.c dbg_mlc.c malloc.c stubborn.c checksums.c solaris_threads.c irix_threads.c linux_threads.c typd_mlc.c ptr_chck.c mallocx.c solaris_pthreads.c gcj_mlc.c specific.c gc_dlopen.c +CSRCS= reclaim.c allchblk.c misc.c alloc.c mach_dep.c os_dep.c mark_rts.c headers.c mark.c obj_map.c pcr_interface.c blacklst.c finalize.c new_hblk.c real_malloc.c dyn_load.c dbg_mlc.c malloc.c stubborn.c checksums.c solaris_threads.c irix_threads.c linux_threads.c typd_mlc.c ptr_chck.c mallocx.c solaris_pthreads.c gcj_mlc.c specific.c gc_dlopen.c backgraph.c CORD_SRCS= cord/cordbscs.c cord/cordxtra.c cord/cordprnt.c cord/de.c cord/cordtest.c include/cord.h include/ec.h include/private/cord_pos.h cord/de_win.c cord/de_win.h cord/de_cmds.h cord/de_win.ICO cord/de_win.RC @@ -242,7 +260,8 @@ SRCS= $(CSRCS) mips_sgi_mach_dep.s rs6000_mach_dep.s alpha_mach_dep.s \ include/gc_local_alloc.h include/private/dbg_mlc.h \ include/private/specific.h powerpc_macosx_mach_dep.s \ include/leak_detector.h include/gc_amiga_redirects.h \ - include/gc_pthread_redirects.h $(CORD_SRCS) + include/gc_pthread_redirects.h ia64_save_regs_in_stack.s \ + $(CORD_SRCS) DOC_FILES= README.QUICK doc/README.Mac doc/README.MacOSX doc/README.OS2 \ doc/README.amiga doc/README.cords doc/debugging.html \ @@ -251,7 +270,7 @@ DOC_FILES= README.QUICK doc/README.Mac doc/README.MacOSX doc/README.OS2 \ doc/README.win32 doc/barrett_diagram doc/README \ doc/README.contributors doc/README.changes doc/gc.man \ doc/README.environment doc/tree.html doc/gcdescr.html \ - doc/README.autoconf doc/README.macros + doc/README.autoconf doc/README.macros doc/README.ews4800 TESTS= tests/test.c tests/test_cpp.cc tests/trace_test.c \ tests/leak_test.c tests/thread_leak_test.c @@ -435,6 +454,9 @@ mach_dep.o: $(srcdir)/mach_dep.c $(srcdir)/mips_sgi_mach_dep.s $(srcdir)/mips_ul ./if_mach SPARC SUNOS4 $(AS) -o mach_dep.o $(srcdir)/sparc_sunos4_mach_dep.s ./if_mach SPARC OPENBSD $(AS) -o mach_dep.o $(srcdir)/sparc_sunos4_mach_dep.s ./if_mach SPARC NETBSD $(AS) -o mach_dep.o $(srcdir)/sparc_netbsd_mach_dep.s + ./if_mach IA64 "" as $(AS_ABI_FLAG) -o ia64_save_regs_in_stack.o $(srcdir)/ia64_save_regs_in_stack.s + ./if_mach IA64 "" $(CC) -c -o mach_dep1.o $(SPECIALCFLAGS) $(srcdir)/mach_dep.c + ./if_mach IA64 "" ld -r -o mach_dep.o mach_dep1.o ia64_save_regs_in_stack.o ./if_not_there mach_dep.o $(CC) -c $(SPECIALCFLAGS) $(srcdir)/mach_dep.c mark_rts.o: $(srcdir)/mark_rts.c $(UTILS) diff --git a/gc/Makefile.dj b/gc/Makefile.dj index 09fae4e..7aadaf3 100644 --- a/gc/Makefile.dj +++ b/gc/Makefile.dj @@ -5,6 +5,8 @@ # Primary targets: # gc.a - builds basic library # libgc.a - builds library for use with g++ "-fgc-keyword" extension +# -fgc-keyword was never really available. Historical +# interest only. # c++ - adds C++ interface to library # cords - adds cords (heavyweight strings) to library # test - prints porting information, then builds basic version of gc.a, diff --git a/gc/Makefile.in b/gc/Makefile.in index b9d776e..4215138 100644 --- a/gc/Makefile.in +++ b/gc/Makefile.in @@ -86,8 +86,6 @@ CXXINCLUDES = @CXXINCLUDES@ DLLTOOL = @DLLTOOL@ EXEEXT = @EXEEXT@ EXTRA_TEST_LIBS = @EXTRA_TEST_LIBS@ -GCJ = @GCJ@ -GCJFLAGS = @GCJFLAGS@ GC_CFLAGS = @GC_CFLAGS@ INCLUDES = @INCLUDES@ LIBTOOL = @LIBTOOL@ @@ -96,10 +94,8 @@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ MY_CFLAGS = @MY_CFLAGS@ OBJDUMP = @OBJDUMP@ -OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ RANLIB = @RANLIB@ -STRIP = @STRIP@ THREADLIBS = @THREADLIBS@ VERSION = @VERSION@ addobjs = @addobjs@ @@ -121,7 +117,7 @@ MULTICLEAN = true toolexeclib_LTLIBRARIES = $(target_all) EXTRA_LTLIBRARIES = libgc.la -libgc_la_SOURCES = allchblk.c alloc.c blacklst.c checksums.c dbg_mlc.c dyn_load.c finalize.c gc_dlopen.c gcj_mlc.c headers.c irix_threads.c linux_threads.c malloc.c mallocx.c mark.c mark_rts.c misc.c new_hblk.c obj_map.c os_dep.c pcr_interface.c ptr_chck.c real_malloc.c reclaim.c solaris_pthreads.c solaris_threads.c specific.c stubborn.c typd_mlc.c +libgc_la_SOURCES = allchblk.c alloc.c blacklst.c checksums.c dbg_mlc.c dyn_load.c finalize.c gc_dlopen.c gcj_mlc.c headers.c irix_threads.c linux_threads.c malloc.c mallocx.c mark.c mark_rts.c misc.c new_hblk.c obj_map.c os_dep.c pcr_interface.c ptr_chck.c real_malloc.c reclaim.c solaris_pthreads.c solaris_threads.c specific.c stubborn.c typd_mlc.c backgraph.c # Include THREADLIBS here to ensure that the correct versions of @@ -130,7 +126,7 @@ libgc_la_LIBADD = @addobjs@ $(THREADLIBS) libgc_la_DEPENDENCIES = @addobjs@ libgc_la_LDFLAGS = -version-info 1:1:0 -rpath $(toolexeclibdir) -EXTRA_libgc_la_SOURCES = alpha_mach_dep.s mips_sgi_mach_dep.s mips_ultrix_mach_dep.s powerpc_macosx_mach_dep.s rs6000_mach_dep.s sparc_mach_dep.s sparc_netbsd_mach_dep.s sparc_sunos4_mach_dep.s +EXTRA_libgc_la_SOURCES = alpha_mach_dep.s mips_sgi_mach_dep.s mips_ultrix_mach_dep.s powerpc_macosx_mach_dep.s rs6000_mach_dep.s sparc_mach_dep.s sparc_netbsd_mach_dep.s sparc_sunos4_mach_dep.s ia64_save_regs_in_stack.s AM_CXXFLAGS = @GC_CFLAGS@ @@ -138,6 +134,8 @@ AM_CXXFLAGS = @GC_CFLAGS@ AM_CFLAGS = @GC_CFLAGS@ check_PROGRAMS = gctest +# Using $< in the above seems to fail with the HP/UX on Itanium make. + gctest_OBJECTS = test.o gctest_LDADD = ./libgc.la $(THREADLIBS) $(EXTRA_TEST_LIBS) TESTS_ENVIRONMENT = LD_LIBRARY_PATH=../../$(MULTIBUILDTOP)gcc @@ -159,7 +157,7 @@ CONFIG_STATUS_DEPENDENCIES = $(srcdir)/configure.host MAKEOVERRIDES = ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +mkinstalldirs = $(SHELL) $(top_srcdir)/$gc_basedir/mkinstalldirs CONFIG_CLEAN_FILES = LTLIBRARIES = $(toolexeclib_LTLIBRARIES) @@ -173,7 +171,7 @@ dbg_mlc.lo dyn_load.lo finalize.lo gc_dlopen.lo gcj_mlc.lo headers.lo \ irix_threads.lo linux_threads.lo malloc.lo mallocx.lo mark.lo \ mark_rts.lo misc.lo new_hblk.lo obj_map.lo os_dep.lo pcr_interface.lo \ ptr_chck.lo real_malloc.lo reclaim.lo solaris_pthreads.lo \ -solaris_threads.lo specific.lo stubborn.lo typd_mlc.lo +solaris_threads.lo specific.lo stubborn.lo typd_mlc.lo backgraph.lo check_PROGRAMS = gctest$(EXEEXT) gctest_DEPENDENCIES = ./libgc.la gctest_LDFLAGS = @@ -182,7 +180,7 @@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CF CCLD = $(CC) DIST_COMMON = Makefile.am Makefile.in acinclude.m4 aclocal.m4 \ config.guess config.sub configure configure.in install-sh ltconfig \ -ltmain.sh +ltmain.sh mkinstalldirs DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) @@ -194,7 +192,7 @@ OBJECTS = $(libgc_la_OBJECTS) all: all-redirect .SUFFIXES: -.SUFFIXES: .S .c .lo .o .obj .s +.SUFFIXES: .S .c .lo .o .s $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --cygnus Makefile @@ -238,11 +236,6 @@ uninstall-toolexeclibLTLIBRARIES: .c.o: $(COMPILE) -c $< -# FIXME: We should only use cygpath when building on Windows, -# and only if it is available. -.c.obj: - $(COMPILE) -c `cygpath -w $<` - .s.o: $(COMPILE) -c $< @@ -251,7 +244,6 @@ uninstall-toolexeclibLTLIBRARIES: mostlyclean-compile: -rm -f *.o core *.core - -rm -f *.$(OBJEXT) clean-compile: diff --git a/gc/NT_THREADS_MAKEFILE b/gc/NT_THREADS_MAKEFILE index c90584e..5f0b546 100644 --- a/gc/NT_THREADS_MAKEFILE +++ b/gc/NT_THREADS_MAKEFILE @@ -114,10 +114,10 @@ CLEAN : CPP=cl.exe # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I include /D "NDEBUG" /D "SILENT" /D "GC_BUILD" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I include /D "NDEBUG" /D "SILENT" /D "GC_BUILD" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "GC_WIN32_THREADS" /FR /YX /c CPP_PROJ=/nologo /MD /W3 /GX /O2 /I include /D "NDEBUG" /D "SILENT" /D "GC_BUILD" /D\ "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D\ - "WIN32_THREADS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/gc.pch" /YX /Fo"$(INTDIR)/" /c + "GC_WIN32_THREADS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/gc.pch" /YX /Fo"$(INTDIR)/" /c CPP_OBJS=.\Release/ CPP_SBRS=.\Release/ @@ -296,10 +296,10 @@ CLEAN : CPP=cl.exe # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I include /D "_DEBUG" /D "SILENT" /D "GC_BUILD" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I include /D "_DEBUG" /D "SILENT" /D "GC_BUILD" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "GC_WIN32_THREADS" /FR /YX /c CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I include /D "_DEBUG" /D "SILENT" /D "GC_BUILD"\ /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D\ - "WIN32_THREADS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/gc.pch" /YX /Fo"$(INTDIR)/"\ + "GC_WIN32_THREADS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/gc.pch" /YX /Fo"$(INTDIR)/"\ /Fd"$(INTDIR)/" /c CPP_OBJS=.\Debug/ CPP_SBRS=.\Debug/ @@ -430,9 +430,9 @@ test.c : tests\test.c CPP=cl.exe # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I include /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /YX /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I include /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "GC_WIN32_THREADS" /YX /c CPP_PROJ=/nologo /MD /W3 /GX /O2 /I include /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D\ - "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS"\ + "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "GC_WIN32_THREADS"\ /Fp"$(INTDIR)/gctest.pch" /YX /Fo"$(INTDIR)/" /c CPP_OBJS=.\gctest\Release/ CPP_SBRS=.\. @@ -516,9 +516,9 @@ CLEAN : CPP=cl.exe # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "GC_WIN32_THREADS" /FR /YX /c CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I include /D "_DEBUG" /D "WIN32" /D "_WINDOWS"\ - /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR"$(INTDIR)/"\ + /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "GC_WIN32_THREADS" /FR"$(INTDIR)/"\ /Fp"$(INTDIR)/gctest.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c CPP_OBJS=.\gctest\Debug/ CPP_SBRS=.\gctest\Debug/ diff --git a/gc/allchblk.c b/gc/allchblk.c index 7629672..06582ec 100644 --- a/gc/allchblk.c +++ b/gc/allchblk.c @@ -774,6 +774,7 @@ signed_word size; if (HBLK_IS_FREE(hhdr)) { GC_printf1("Duplicate large block deallocation of 0x%lx\n", (unsigned long) hbp); + ABORT("Duplicate large block deallocation"); } GC_ASSERT(IS_MAPPED(hhdr)); @@ -78,7 +78,7 @@ char * GC_copyright[] = {"Copyright 1988,1989 Hans-J. Boehm and Alan J. Demers ", "Copyright (c) 1991-1995 by Xerox Corporation. All rights reserved. ", "Copyright (c) 1996-1998 by Silicon Graphics. All rights reserved. ", -"Copyright (c) 1999-2000 by Hewlett-Packard Company. All rights reserved. ", +"Copyright (c) 1999-2001 by Hewlett-Packard Company. All rights reserved. ", "THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY", " EXPRESSED OR IMPLIED. ANY USE IS AT YOUR OWN RISK.", "See source code for details." }; @@ -97,6 +97,8 @@ word GC_free_space_divisor = 3; extern GC_bool GC_collection_in_progress(); /* Collection is in progress, or was abandoned. */ +extern GC_bool GC_print_back_height; + int GC_never_stop_func GC_PROTO((void)) { return(0); } CLOCK_TYPE GC_start_time; /* Time at which we stopped world. */ @@ -434,7 +436,7 @@ GC_stop_func stop_func; { register int i; int dummy; -# ifdef PRINTTIMES +# if defined(PRINTTIMES) || defined(CONDPRINT) CLOCK_TYPE start_time, current_time; # endif @@ -442,6 +444,9 @@ GC_stop_func stop_func; # ifdef PRINTTIMES GET_TIME(start_time); # endif +# if defined(CONDPRINT) && !defined(PRINTTIMES) + if (GC_print_stats) GET_TIME(start_time); +# endif # ifdef CONDPRINT if (GC_print_stats) { GC_printf1("--> Marking for collection %lu ", @@ -451,6 +456,11 @@ GC_stop_func stop_func; (unsigned long) WORDS_TO_BYTES(GC_words_wasted)); } # endif +# ifdef MAKE_BACK_GRAPH + if (GC_print_back_height) { + GC_build_back_graph(); + } +# endif /* Mark from all roots. */ /* Minimize junk left in my registers and on the stack */ @@ -504,6 +514,14 @@ GC_stop_func stop_func; GET_TIME(current_time); GC_printf1("World-stopped marking took %lu msecs\n", MS_TIME_DIFF(current_time,start_time)); +# else +# ifdef CONDPRINT + if (GC_print_stats) { + GET_TIME(current_time); + GC_printf1("World-stopped marking took %lu msecs\n", + MS_TIME_DIFF(current_time,start_time)); + } +# endif # endif START_WORLD(); return(TRUE); @@ -610,6 +628,17 @@ void GC_finish_collection() GET_TIME(finalize_time); # endif + if (GC_print_back_height) { +# ifdef MAKE_BACK_GRAPH + GC_traverse_back_graph(); +# else +# ifndef SMALL_CONFIG + GC_err_printf0("Back height not available: " + "Rebuild collector with -DMAKE_BACK_GRAPH\n"); +# endif +# endif + } + /* Clear free list mark bits, in case they got accidentally marked */ /* (or GC_find_leak is set and they were intentionally marked). */ /* Also subtract memory remaining from GC_mem_found count. */ diff --git a/gc/alpha_mach_dep.s b/gc/alpha_mach_dep.s index 9333dc6..7d25633 100644 --- a/gc/alpha_mach_dep.s +++ b/gc/alpha_mach_dep.s @@ -1,4 +1,4 @@ - # $Id: alpha_mach_dep.s,v 1.3 2001/11/15 00:32:13 a-ito Exp $ + # $Id: alpha_mach_dep.s,v 1.3.2.1 2001/11/22 17:52:28 inu Exp $ .arch ev6 .text diff --git a/gc/backgraph.c b/gc/backgraph.c new file mode 100644 index 0000000..01ab738 --- /dev/null +++ b/gc/backgraph.c @@ -0,0 +1,447 @@ +/* + * Copyright (c) 2001 by Hewlett-Packard Company. 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. + * + */ + +/* + * This implements a full, though not well-tuned, representation of the + * backwards points-to graph. This is used to test for non-GC-robust + * data structures; the code is not used during normal garbage collection. + * + * One restriction is that we drop all back-edges from nodes with very + * high in-degree, and simply add them add them to a list of such + * nodes. They are then treated as permanent roots. Id this by itself + * doesn't introduce a space leak, then such nodes can't contribute to + * a growing space leak. + */ + +#ifdef MAKE_BACK_GRAPH + +#define MAX_IN 10 /* Maximum in-degree we handle directly */ + +#include "private/dbg_mlc.h" +#include <unistd.h> + +#if !defined(DBG_HDRS_ALL) || (ALIGNMENT != CPP_WORDSZ/8) || !defined(UNIX_LIKE) +# error Configuration doesnt support MAKE_BACK_GRAPH +#endif + +/* We store single back pointers directly in the object's oh_bg_ptr field. */ +/* If there is more than one ptr to an object, we store q | FLAG_MANY, */ +/* where q is a pointer to a back_edges object. */ +/* Every once in a while we use a back_edges object even for a single */ +/* pointer, since we need the other fields in the back_edges structure to */ +/* be present in some fraction of the objects. Otherwise we get serious */ +/* performance issues. */ +#define FLAG_MANY 2 + +typedef struct back_edges_struct { + word n_edges; /* Number of edges, including those in continuation */ + /* structures. */ + unsigned short flags; +# define RETAIN 1 /* Directly points to a reachable object; */ + /* retain for next GC. */ + unsigned short height_gc_no; + /* If height > 0, then the GC_gc_no value when it */ + /* was computed. If it was computed this cycle, then */ + /* it is current. If it was computed during the */ + /* last cycle, then it represents the old height, */ + /* which is only saved for live objects referenced by */ + /* dead ones. This may grow due to refs from newly */ + /* dead objects. */ + signed_word height; + /* Longest path through unreachable nodes to this node */ + /* that we found using depth first search. */ + +# define HEIGHT_UNKNOWN ((signed_word)(-2)) +# define HEIGHT_IN_PROGRESS ((signed_word)(-1)) + ptr_t edges[MAX_IN]; + struct back_edges_struct *cont; + /* Pointer to continuation structure; we use only the */ + /* edges field in the continuation. */ + /* also used as free list link. */ +} back_edges; + +/* Allocate a new back edge structure. Should be more sophisticated */ +/* if this were production code. */ +#define MAX_BACK_EDGE_STRUCTS 100000 +static back_edges *back_edge_space = 0; +int GC_n_back_edge_structs = 0; /* Serves as pointer to never used */ + /* back_edges space. */ +static back_edges *avail_back_edges = 0; + /* Pointer to free list of deallocated */ + /* back_edges structures. */ + +static back_edges * new_back_edges(void) +{ + if (0 == back_edge_space) { + back_edge_space = (back_edges *) + sbrk(MAX_BACK_EDGE_STRUCTS*sizeof(back_edges)); + } + if (0 != avail_back_edges) { + back_edges * result = avail_back_edges; + avail_back_edges = result -> cont; + result -> cont = 0; + return result; + } + if (GC_n_back_edge_structs >= MAX_BACK_EDGE_STRUCTS - 1) { + ABORT("needed too much space for back edges: adjust " + "MAX_BACK_EDGE_STRUCTS"); + } + return back_edge_space + (GC_n_back_edge_structs++); +} + +/* Deallocate p and its associated continuation structures. */ +static void deallocate_back_edges(back_edges *p) +{ + back_edges *last = p; + + while (0 != last -> cont) last = last -> cont; + last -> cont = avail_back_edges; + avail_back_edges = p; +} + +/* Table of objects that are currently on the depth-first search */ +/* stack. Only objects with in-degree one are in this table. */ +/* Other objects are identified using HEIGHT_IN_PROGRESS. */ +/* This data structure NEEDS IMPROVEMENT. */ +#define MAX_IN_PROGRESS 10000 +static ptr_t * in_progress_space = 0; +static int n_in_progress = 0; + +static void push_in_progress(ptr_t p) +{ + if (in_progress_space == 0) + in_progress_space = sbrk(MAX_IN_PROGRESS * sizeof(ptr_t)); + if (n_in_progress == MAX_IN_PROGRESS) + ABORT("Exceeded MAX_IN_PROGRESS"); + in_progress_space[n_in_progress++] = p; +} + +static GC_bool is_in_progress(ptr_t p) +{ + int i; + for (i = 0; i < n_in_progress; ++i) { + if (in_progress_space[i] == p) return TRUE; + } + return FALSE; +} + +static void pop_in_progress(ptr_t p) +{ + --n_in_progress; + GC_ASSERT(in_progress_space[n_in_progress] == p); +} + +#define GET_OH_BG_PTR(p) \ + (ptr_t)REVEAL_POINTER(((oh *)(p)) -> oh_bg_ptr) +#define SET_OH_BG_PTR(p,q) (((oh *)(p)) -> oh_bg_ptr) = HIDE_POINTER(q) + +/* Execute s once for each predecessor q of p in the points-to graph. */ +/* s should be a bracketed statement. We declare q. */ +#define FOR_EACH_PRED(q, p, s) \ + { \ + ptr_t q = GET_OH_BG_PTR(p); \ + if (!((word)q & FLAG_MANY)) { \ + if (q && !((word)q & 1)) s \ + /* !((word)q & 1) checks for a misnterpreted freelist link */ \ + } else { \ + back_edges *orig_be_ = (back_edges *)((word)q & ~FLAG_MANY); \ + back_edges *be_ = orig_be_; \ + int total_, local_; \ + int n_edges_ = be_ -> n_edges; \ + for (total_ = 0, local_ = 0; total_ < n_edges_; ++local_, ++total_) { \ + if (local_ == MAX_IN) { \ + be_ = be_ -> cont; \ + local_ = 0; \ + } \ + q = be_ -> edges[local_]; s \ + } \ + } \ + } + +/* Ensure that p has a back_edges structure associated with it. */ +static void ensure_struct(ptr_t p) +{ + ptr_t old_back_ptr = GET_OH_BG_PTR(p); + + if (!((word)old_back_ptr & FLAG_MANY)) { + back_edges *be = new_back_edges(); + be -> flags = 0; + if (0 == old_back_ptr) { + be -> n_edges = 0; + } else { + be -> n_edges = 1; + be -> edges[0] = old_back_ptr; + } + be -> height = HEIGHT_UNKNOWN; + be -> height_gc_no = GC_gc_no - 1; + GC_ASSERT(be >= back_edge_space); + SET_OH_BG_PTR(p, (word)be | FLAG_MANY); + } +} + +/* Add the (forward) edge from p to q to the backward graph. Both p */ +/* q are pointers to the object base, i.e. pointers to an oh. */ +static void add_edge(ptr_t p, ptr_t q) +{ + ptr_t old_back_ptr = GET_OH_BG_PTR(q); + back_edges * be, *be_cont; + word i; + static unsigned random_number = 13; +# define GOT_LUCKY_NUMBER (((++random_number) & 0x7f) == 0) + /* A not very random number we use to occasionally allocate a */ + /* back_edges structure even for a single backward edge. This */ + /* prevents us from repeatedly tracing back through very long */ + /* chains, since we will have some place to store height and */ + /* in_progress flags along the way. */ + + GC_ASSERT(p == GC_base(p) && q == GC_base(q)); + if (!GC_HAS_DEBUG_INFO(q) || !GC_HAS_DEBUG_INFO(p)) { + /* This is really a misinterpreted free list link, since we saw */ + /* a pointer to a free list. Dont overwrite it! */ + return; + } + if (0 == old_back_ptr) { + SET_OH_BG_PTR(q, p); + if (GOT_LUCKY_NUMBER) ensure_struct(q); + return; + } + /* Check whether it was already in the list of predecessors. */ + FOR_EACH_PRED(pred, q, { if (p == pred) return; }); + ensure_struct(q); + old_back_ptr = GET_OH_BG_PTR(q); + be = (back_edges *)((word)old_back_ptr & ~FLAG_MANY); + for (i = be -> n_edges, be_cont = be; i > MAX_IN; + be_cont = be_cont -> cont, i -= MAX_IN) {} + if (i == MAX_IN) { + be_cont -> cont = new_back_edges(); + be_cont = be_cont -> cont; + i = 0; + } + be_cont -> edges[i] = p; + be -> n_edges++; + if (be -> n_edges == 100) { +# if 0 + if (GC_print_stats) { + GC_err_printf0("The following object has in-degree >= 100:\n"); + GC_print_heap_obj(q); + } +# endif + } +} + +typedef void (*per_object_func)(ptr_t p, word n_words, word gc_descr); + +static void per_object_helper(struct hblk *h, word fn) +{ + hdr * hhdr = HDR(h); + word sz = hhdr -> hb_sz; + word descr = hhdr -> hb_descr; + per_object_func f = (per_object_func)fn; + int i = 0; + + do { + f((ptr_t)(h -> hb_body + i), sz, descr); + i += sz; + } while (i + sz <= BYTES_TO_WORDS(HBLKSIZE)); +} + +void GC_apply_to_each_object(per_object_func f) +{ + GC_apply_to_all_blocks(per_object_helper, (word)f); +} + +static void reset_back_edge(ptr_t p, word n_words, word gc_descr) +{ + /* Skip any free list links, or dropped blocks */ + if (GC_HAS_DEBUG_INFO(p)) { + ptr_t old_back_ptr = GET_OH_BG_PTR(p); + if ((word)old_back_ptr & FLAG_MANY) { + back_edges *be = (back_edges *)((word)old_back_ptr & ~FLAG_MANY); + if (!(be -> flags & RETAIN)) { + deallocate_back_edges(be); + SET_OH_BG_PTR(p, 0); + } else { + word *currentp; + + GC_ASSERT(GC_is_marked(p)); + + /* Back edges may point to objects that will not be retained. */ + /* Delete them for now, but remember the height. */ + /* Some will be added back at next GC. */ + be -> n_edges = 0; + if (0 != be -> cont) { + deallocate_back_edges(be -> cont); + be -> cont = 0; + } + + GC_ASSERT(GC_is_marked(p)); + + /* We only retain things for one GC cycle at a time. */ + be -> flags &= ~RETAIN; + } + } else /* Simple back pointer */ { + /* Clear to avoid dangling pointer. */ + SET_OH_BG_PTR(p, 0); + } + } +} + +static void add_back_edges(ptr_t p, word n_words, word gc_descr) +{ + word *currentp = (word *)(p + sizeof(oh)); + + /* For now, fix up non-length descriptors conservatively. */ + if((gc_descr & GC_DS_TAGS) != GC_DS_LENGTH) { + gc_descr = WORDS_TO_BYTES(n_words); + } + while (currentp < (word *)(p + gc_descr)) { + word current = *currentp++; + if (current >= (word)GC_least_plausible_heap_addr && + current <= (word)GC_greatest_plausible_heap_addr) { + ptr_t target = GC_base((GC_PTR)current); + if (0 != target) { + add_edge(p, target); + } + } + } +} + +/* Rebuild the reprentation of the backward reachability graph. */ +/* Does not examine mark bits. Can be called before GC. */ +void GC_build_back_graph(void) +{ + GC_apply_to_each_object(add_back_edges); +} + +/* Return an approximation to the length of the longest simple path */ +/* through unreachable objects to p. We refer to this as the height */ +/* of p. */ +static word backwards_height(ptr_t p) +{ + word result; + ptr_t back_ptr = GET_OH_BG_PTR(p); + back_edges *be; + + if (0 == back_ptr) return 1; + if (!((word)back_ptr & FLAG_MANY)) { + if (is_in_progress(p)) return 0; /* DFS back edge, i.e. we followed */ + /* an edge to an object already */ + /* on our stack: ignore */ + push_in_progress(p); + result = backwards_height(back_ptr)+1; + pop_in_progress(p); + return result; + } + be = (back_edges *)((word)back_ptr & ~FLAG_MANY); + if (be -> height >= 0 && be -> height_gc_no == GC_gc_no) + return be -> height; + /* Ignore back edges in DFS */ + if (be -> height == HEIGHT_IN_PROGRESS) return 0; + result = (be -> height > 0? be -> height : 1); + be -> height = HEIGHT_IN_PROGRESS; + FOR_EACH_PRED(q, p, { + word this_height; + if (GC_is_marked(q) && !(FLAG_MANY & (word)GET_OH_BG_PTR(p))) { + if (GC_print_stats) + GC_printf2("Found bogus pointer from 0x%lx to 0x%lx\n", q, p); + /* Reachable object "points to" unreachable one. */ + /* Could be caused by our lax treatment of GC descriptors. */ + this_height = 1; + } else { + this_height = backwards_height(q); + } + if (this_height >= result) result = this_height + 1; + }); + be -> height = result; + be -> height_gc_no = GC_gc_no; + return result; +} + +word GC_max_height; +ptr_t GC_deepest_obj; + +/* Compute the maximum height of every unreachable predecessor p of a */ +/* reachable object. Arrange to save the heights of all such objects p */ +/* so that they can be used in calculating the height of objects in the */ +/* next GC. */ +/* Set GC_max_height to be the maximum height we encounter, and */ +/* GC_deepest_obj to be the corresponding object. */ +static void update_max_height(ptr_t p, word n_words, word gc_descr) +{ + if (GC_is_marked(p) && GC_HAS_DEBUG_INFO(p)) { + int i; + word p_height = 0; + ptr_t p_deepest_obj = 0; + ptr_t back_ptr; + back_edges *be = 0; + + /* If we remembered a height last time, use it as a minimum. */ + /* It may have increased due to newly unreachable chains pointing */ + /* to p, but it can't have decreased. */ + back_ptr = GET_OH_BG_PTR(p); + if (0 != back_ptr && ((word)back_ptr & FLAG_MANY)) { + be = (back_edges *)((word)back_ptr & ~FLAG_MANY); + if (be -> height != HEIGHT_UNKNOWN) p_height = be -> height; + } + FOR_EACH_PRED(q, p, { + if (!GC_is_marked(q) && GC_HAS_DEBUG_INFO(q)) { + word q_height; + + q_height = backwards_height(q); + if (q_height > p_height) { + p_height = q_height; + p_deepest_obj = q; + } + } + }); + if (p_height > 0) { + /* Remember the height for next time. */ + if (be == 0) { + ensure_struct(p); + back_ptr = GET_OH_BG_PTR(p); + be = (back_edges *)((word)back_ptr & ~FLAG_MANY); + } + be -> flags |= RETAIN; + be -> height = p_height; + be -> height_gc_no = GC_gc_no; + } + if (p_height > GC_max_height) { + GC_max_height = p_height; + GC_deepest_obj = p_deepest_obj; + } + } +} + +void GC_traverse_back_graph(void) +{ + static word max_max_height = 0; + GC_max_height = 0; + GC_apply_to_each_object(update_max_height); + GC_printf2("Maximum backwards height of reachable objects at GC %lu is %ld\n", + (unsigned long) GC_gc_no, GC_max_height); + if (GC_max_height > max_max_height) { + max_max_height = GC_max_height; + GC_printf0("The following unreachable object is last in a longest chain " + "of unreachable objects:\n"); + GC_print_heap_obj(GC_deepest_obj); + } + if (GC_print_stats) { + GC_printf1("Needed max total of %ld back-edge structs\n", + GC_n_back_edge_structs); + } + GC_apply_to_each_object(reset_back_edge); + GC_deepest_obj = 0; +} + +#endif /* MAKE_BACK_GRAPH */ diff --git a/gc/base_lib b/gc/base_lib deleted file mode 100644 index 8b13789..0000000 --- a/gc/base_lib +++ /dev/null @@ -1 +0,0 @@ - diff --git a/gc/configure b/gc/configure index 1146ce6..e90a858 100644 --- a/gc/configure +++ b/gc/configure @@ -41,6 +41,8 @@ ac_help="$ac_help ac_help="$ac_help --with-ecos enable runtime eCos target support" ac_help="$ac_help + --enable-shared[=PKGS] build shared libraries [default=no]" +ac_help="$ac_help --enable-full-debug include full support for pointer backtracing etc." # Initialize some variables set by options. @@ -601,7 +603,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:605: checking host system type" >&5 +echo "configure:607: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -622,7 +624,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$host" 1>&6 echo $ac_n "checking target system type""... $ac_c" 1>&6 -echo "configure:626: checking target system type" >&5 +echo "configure:628: checking target system type" >&5 target_alias=$target case "$target_alias" in @@ -640,7 +642,7 @@ target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$target" 1>&6 echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:644: checking build system type" >&5 +echo "configure:646: checking build system type" >&5 build_alias=$build case "$build_alias" in @@ -675,7 +677,7 @@ test "$host_alias" != "$target_alias" && # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:679: checking for a BSD compatible install" >&5 +echo "configure:681: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -728,7 +730,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether build environment is sane""... $ac_c" 1>&6 -echo "configure:732: checking whether build environment is sane" >&5 +echo "configure:734: checking whether build environment is sane" >&5 # Just in case sleep 1 echo timestamp > conftestfile @@ -785,7 +787,7 @@ test "$program_suffix" != NONE && test "$program_transform_name" = "" && program_transform_name="s,x,x," echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6 -echo "configure:789: checking whether ${MAKE-make} sets \${MAKE}" >&5 +echo "configure:791: checking whether ${MAKE-make} sets \${MAKE}" >&5 set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -818,12 +820,12 @@ else fi echo $ac_n "checking for Cygwin environment""... $ac_c" 1>&6 -echo "configure:822: checking for Cygwin environment" >&5 +echo "configure:824: checking for Cygwin environment" >&5 if eval "test \"`echo '$''{'ac_cv_cygwin'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 827 "configure" +#line 829 "configure" #include "confdefs.h" int main() { @@ -834,7 +836,7 @@ int main() { return __CYGWIN__; ; return 0; } EOF -if { (eval echo configure:838: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:840: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_cygwin=yes else @@ -851,19 +853,19 @@ echo "$ac_t""$ac_cv_cygwin" 1>&6 CYGWIN= test "$ac_cv_cygwin" = yes && CYGWIN=yes echo $ac_n "checking for mingw32 environment""... $ac_c" 1>&6 -echo "configure:855: checking for mingw32 environment" >&5 +echo "configure:857: checking for mingw32 environment" >&5 if eval "test \"`echo '$''{'ac_cv_mingw32'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 860 "configure" +#line 862 "configure" #include "confdefs.h" int main() { return __MINGW32__; ; return 0; } EOF -if { (eval echo configure:867: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then +if { (eval echo configure:869: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_mingw32=yes else @@ -951,7 +953,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } fi echo $ac_n "checking host system type""... $ac_c" 1>&6 -echo "configure:955: checking host system type" >&5 +echo "configure:957: checking host system type" >&5 host_alias=$host case "$host_alias" in @@ -972,7 +974,7 @@ host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$host" 1>&6 echo $ac_n "checking target system type""... $ac_c" 1>&6 -echo "configure:976: checking target system type" >&5 +echo "configure:978: checking target system type" >&5 target_alias=$target case "$target_alias" in @@ -990,7 +992,7 @@ target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` echo "$ac_t""$target" 1>&6 echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:994: checking build system type" >&5 +echo "configure:996: checking build system type" >&5 build_alias=$build case "$build_alias" in @@ -1026,7 +1028,7 @@ fi missing_dir=`cd $ac_aux_dir && pwd` echo $ac_n "checking for working aclocal""... $ac_c" 1>&6 -echo "configure:1030: checking for working aclocal" >&5 +echo "configure:1032: checking for working aclocal" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1039,7 +1041,7 @@ else fi echo $ac_n "checking for working autoconf""... $ac_c" 1>&6 -echo "configure:1043: checking for working autoconf" >&5 +echo "configure:1045: checking for working autoconf" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1052,7 +1054,7 @@ else fi echo $ac_n "checking for working automake""... $ac_c" 1>&6 -echo "configure:1056: checking for working automake" >&5 +echo "configure:1058: checking for working automake" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1065,7 +1067,7 @@ else fi echo $ac_n "checking for working autoheader""... $ac_c" 1>&6 -echo "configure:1069: checking for working autoheader" >&5 +echo "configure:1071: checking for working autoheader" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1078,7 +1080,7 @@ else fi echo $ac_n "checking for working makeinfo""... $ac_c" 1>&6 -echo "configure:1082: checking for working makeinfo" >&5 +echo "configure:1084: checking for working makeinfo" >&5 # Run test in a subshell; some versions of sh will print an error if # an executable is not found, even if stderr is redirected. # Redirect stdin to placate older versions of autoconf. Sigh. @@ -1104,7 +1106,7 @@ fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1108: checking for $ac_word" >&5 +echo "configure:1110: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1134,7 +1136,7 @@ if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1138: checking for $ac_word" >&5 +echo "configure:1140: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1183,7 +1185,7 @@ fi fi echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 -echo "configure:1187: checking whether we are using GNU C" >&5 +echo "configure:1189: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1192,7 +1194,7 @@ else yes; #endif EOF -if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1196: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:1198: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no @@ -1207,7 +1209,7 @@ if test $ac_cv_prog_gcc = yes; then ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 -echo "configure:1211: checking whether ${CC-cc} accepts -g" >&5 +echo "configure:1213: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1244,7 +1246,7 @@ do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1248: checking for $ac_word" >&5 +echo "configure:1250: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CXX'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1277,7 +1279,7 @@ test -n "$CXX" || CXX="gcc" test -z "$CXX" && { echo "configure: error: no acceptable c++ found in \$PATH" 1>&2; exit 1; } echo $ac_n "checking whether we are using GNU C++""... $ac_c" 1>&6 -echo "configure:1281: checking whether we are using GNU C++" >&5 +echo "configure:1283: checking whether we are using GNU C++" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gxx'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1286,7 +1288,7 @@ else yes; #endif EOF -if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1290: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then +if { ac_try='${CXX-g++} -E conftest.C'; { (eval echo configure:1292: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gxx=yes else ac_cv_prog_gxx=no @@ -1301,7 +1303,7 @@ if test $ac_cv_prog_gxx = yes; then ac_save_CXXFLAGS="$CXXFLAGS" CXXFLAGS= echo $ac_n "checking whether ${CXX-g++} accepts -g""... $ac_c" 1>&6 -echo "configure:1305: checking whether ${CXX-g++} accepts -g" >&5 +echo "configure:1307: checking whether ${CXX-g++} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cxx_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1334,7 +1336,7 @@ fi # NEWLIB_CONFIGURE, which doesn't work because that means that it will # be run before AC_CANONICAL_HOST. echo $ac_n "checking build system type""... $ac_c" 1>&6 -echo "configure:1338: checking build system type" >&5 +echo "configure:1340: checking build system type" >&5 build_alias=$build case "$build_alias" in @@ -1355,7 +1357,7 @@ echo "$ac_t""$build" 1>&6 # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. set dummy ${ac_tool_prefix}as; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1359: checking for $ac_word" >&5 +echo "configure:1361: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1387,7 +1389,7 @@ fi # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. set dummy ${ac_tool_prefix}ar; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1391: checking for $ac_word" >&5 +echo "configure:1393: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1419,7 +1421,7 @@ fi # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1423: checking for $ac_word" >&5 +echo "configure:1425: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1451,7 +1453,7 @@ if test -n "$ac_tool_prefix"; then # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1455: checking for $ac_word" >&5 +echo "configure:1457: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1496,7 +1498,7 @@ fi # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 -echo "configure:1500: checking for a BSD compatible install" >&5 +echo "configure:1502: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1550,7 +1552,7 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6 -echo "configure:1554: checking whether to enable maintainer-specific portions of Makefiles" >&5 +echo "configure:1556: checking whether to enable maintainer-specific portions of Makefiles" >&5 # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then enableval="$enable_maintainer_mode" @@ -1588,7 +1590,7 @@ if false; then echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:1592: checking for executable suffix" >&5 +echo "configure:1594: checking for executable suffix" >&5 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1598,7 +1600,7 @@ else rm -f conftest* echo 'int main () { return 0; }' > conftest.$ac_ext ac_cv_exeext= - if { (eval echo configure:1602: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then + if { (eval echo configure:1604: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in *.c | *.o | *.obj) ;; @@ -1711,7 +1713,7 @@ fi # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 -echo "configure:1715: checking for $ac_word" >&5 +echo "configure:1717: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1750,7 +1752,7 @@ ac_prog=ld if test "$ac_cv_prog_gcc" = yes; then # Check if gcc -print-prog-name=ld gives a path. echo $ac_n "checking for ld used by GCC""... $ac_c" 1>&6 -echo "configure:1754: checking for ld used by GCC" >&5 +echo "configure:1756: checking for ld used by GCC" >&5 ac_prog=`($CC -print-prog-name=ld) 2>&5` case "$ac_prog" in # Accept absolute paths. @@ -1774,10 +1776,10 @@ echo "configure:1754: checking for ld used by GCC" >&5 esac elif test "$with_gnu_ld" = yes; then echo $ac_n "checking for GNU ld""... $ac_c" 1>&6 -echo "configure:1778: checking for GNU ld" >&5 +echo "configure:1780: checking for GNU ld" >&5 else echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6 -echo "configure:1781: checking for non-GNU ld" >&5 +echo "configure:1783: checking for non-GNU ld" >&5 fi if eval "test \"`echo '$''{'ac_cv_path_LD'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -1812,7 +1814,7 @@ else fi test -z "$LD" && { echo "configure: error: no acceptable ld found in \$PATH" 1>&2; exit 1; } echo $ac_n "checking if the linker ($LD) is GNU ld""... $ac_c" 1>&6 -echo "configure:1816: checking if the linker ($LD) is GNU ld" >&5 +echo "configure:1818: checking if the linker ($LD) is GNU ld" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gnu_ld'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1828,7 +1830,7 @@ echo "$ac_t""$ac_cv_prog_gnu_ld" 1>&6 echo $ac_n "checking for BSD-compatible nm""... $ac_c" 1>&6 -echo "configure:1832: checking for BSD-compatible nm" >&5 +echo "configure:1834: checking for BSD-compatible nm" >&5 if eval "test \"`echo '$''{'ac_cv_path_NM'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1864,7 +1866,7 @@ NM="$ac_cv_path_NM" echo "$ac_t""$NM" 1>&6 echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6 -echo "configure:1868: checking whether ln -s works" >&5 +echo "configure:1870: checking whether ln -s works" >&5 if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -1918,8 +1920,8 @@ test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" case "$lt_target" in *-*-irix6*) # Find out which ABI we are using. - echo '#line 1922 "configure"' > conftest.$ac_ext - if { (eval echo configure:1923: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then + echo '#line 1924 "configure"' > conftest.$ac_ext + if { (eval echo configure:1925: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then case "`/usr/bin/file conftest.o`" in *32-bit*) LD="${LD-ld} -32" @@ -1940,19 +1942,19 @@ case "$lt_target" in SAVE_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS -belf" echo $ac_n "checking whether the C compiler needs -belf""... $ac_c" 1>&6 -echo "configure:1944: checking whether the C compiler needs -belf" >&5 +echo "configure:1946: checking whether the C compiler needs -belf" >&5 if eval "test \"`echo '$''{'lt_cv_cc_needs_belf'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext <<EOF -#line 1949 "configure" +#line 1951 "configure" #include "confdefs.h" int main() { ; return 0; } EOF -if { (eval echo configure:1956: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:1958: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* lt_cv_cc_needs_belf=yes else @@ -2068,7 +2070,7 @@ fi echo $ac_n "checking whether to enable maintainer-specific portions of Makefiles""... $ac_c" 1>&6 -echo "configure:2072: checking whether to enable maintainer-specific portions of Makefiles" >&5 +echo "configure:2074: checking whether to enable maintainer-specific portions of Makefiles" >&5 # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given. if test "${enable_maintainer_mode+set}" = set; then enableval="$enable_maintainer_mode" @@ -2101,7 +2103,7 @@ if false; then echo $ac_n "checking for executable suffix""... $ac_c" 1>&6 -echo "configure:2105: checking for executable suffix" >&5 +echo "configure:2107: checking for executable suffix" >&5 if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else @@ -2111,7 +2113,7 @@ else rm -f conftest* echo 'int main () { return 0; }' > conftest.$ac_ext ac_cv_exeext= - if { (eval echo configure:2115: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then + if { (eval echo configure:2117: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; }; then for file in conftest.*; do case $file in *.c | *.o | *.obj) ;; @@ -2134,14 +2136,14 @@ ac_exeext=$EXEEXT fi echo $ac_n "checking for threads package to use""... $ac_c" 1>&6 -echo "configure:2138: checking for threads package to use" >&5 +echo "configure:2140: checking for threads package to use" >&5 # Check whether --enable-threads or --disable-threads was given. if test "${enable_threads+set}" = set; then enableval="$enable_threads" THREADS=$enableval else echo $ac_n "checking for thread model used by GCC""... $ac_c" 1>&6 -echo "configure:2145: checking for thread model used by GCC" >&5 +echo "configure:2147: checking for thread model used by GCC" >&5 THREADS=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'` if test -z "$THREADS"; then THREADS=no @@ -2227,7 +2229,7 @@ EOF *-*-freebsd*) echo "configure: warning: "FreeBSD does not yet fully support threads with Boehm GC."" 1>&2 cat >> confdefs.h <<\EOF -#define FREEBSD_THREADS 1 +#define GC_FREEBSD_THREADS 1 EOF INCLUDES="$INCLUDES -pthread" @@ -2261,7 +2263,7 @@ esac echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6 -echo "configure:2265: checking for dlopen in -ldl" >&5 +echo "configure:2267: checking for dlopen in -ldl" >&5 ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 @@ -2269,7 +2271,7 @@ else ac_save_LIBS="$LIBS" LIBS="-ldl $LIBS" cat > conftest.$ac_ext <<EOF -#line 2273 "configure" +#line 2275 "configure" #include "confdefs.h" /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 @@ -2280,7 +2282,7 @@ int main() { dlopen() ; return 0; } EOF -if { (eval echo configure:2284: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then +if { (eval echo configure:2286: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else @@ -2340,6 +2342,40 @@ case "$host" in # alpha*-*-*) # machdep="alpha_mach_dep.lo" # ;; + i?86-*-solaris2.[89]*) + cat >> confdefs.h <<\EOF +#define SOLARIS25_PROC_VDB_BUG_FIXED 1 +EOF + + ;; + alpha-*-openbsd*) + if test x"${ac_cv_lib_dl_dlopen}" != xyes ; then + echo "configure: warning: OpenBSD/Alpha without dlopen(). Shared library support is disabled" 1>&2 + # Check whether --enable-shared or --disable-shared was given. +if test "${enable_shared+set}" = set; then + enableval="$enable_shared" + p=${PACKAGE-default} +case "$enableval" in +yes) enable_shared=yes ;; +no) enable_shared=no ;; +*) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac +else + enable_shared=no +fi + + fi + ;; mipstx39-*-elf*) machdep="mips_ultrix_mach_dep.lo" cat >> confdefs.h <<\EOF @@ -2367,6 +2403,9 @@ EOF EOF ;; + ia64-*-*) + machdep="mach_dep.lo ia64_save_regs_in_stack.lo" + ;; esac if test x"$machdep" = x; then machdep="mach_dep.lo" @@ -2458,7 +2497,17 @@ EOF EOF case $host in + ia64-*-linux* ) + cat >> confdefs.h <<\EOF +#define MAKE_BACK_GRAPH 1 +EOF + + ;; x86-*-linux* | i586-*-linux* | i686-*-linux* ) + cat >> confdefs.h <<\EOF +#define MAKE_BACK_GRAPH 1 +EOF + echo "configure: warning: "Client must not use -fomit-frame-pointer."" 1>&2 cat >> confdefs.h <<\EOF #define SAVE_CALL_COUNT 8 diff --git a/gc/configure.in b/gc/configure.in index fa3f81a..aef5ebe 100644 --- a/gc/configure.in +++ b/gc/configure.in @@ -96,7 +96,7 @@ case "$THREADS" in ;; *-*-freebsd*) AC_MSG_WARN("FreeBSD does not yet fully support threads with Boehm GC.") - AC_DEFINE(FREEBSD_THREADS) + AC_DEFINE(GC_FREEBSD_THREADS) INCLUDES="$INCLUDES -pthread" THREADLIBS=-pthread ;; @@ -157,6 +157,15 @@ case "$host" in # alpha*-*-*) # machdep="alpha_mach_dep.lo" # ;; + i?86-*-solaris2.[[89]]*) + AC_DEFINE(SOLARIS25_PROC_VDB_BUG_FIXED) + ;; + alpha-*-openbsd*) + if test x"${ac_cv_lib_dl_dlopen}" != xyes ; then + AC_MSG_WARN(OpenBSD/Alpha without dlopen(). Shared library support is disabled) + AM_DISABLE_SHARED + fi + ;; mipstx39-*-elf*) machdep="mips_ultrix_mach_dep.lo" AC_DEFINE(STACKBASE, __stackbase) @@ -172,6 +181,9 @@ case "$host" in sparc-sun-solaris2.3*) AC_DEFINE(SUNOS53_SHARED_LIB) ;; + ia64-*-*) + machdep="mach_dep.lo ia64_save_regs_in_stack.lo" + ;; esac if test x"$machdep" = x; then machdep="mach_dep.lo" @@ -232,7 +244,11 @@ AC_ARG_ENABLE(full-debug, AC_DEFINE(KEEP_BACK_PTRS) AC_DEFINE(DBG_HDRS_ALL) case $host in + ia64-*-linux* ) + AC_DEFINE(MAKE_BACK_GRAPH) + ;; x86-*-linux* | i586-*-linux* | i686-*-linux* ) + AC_DEFINE(MAKE_BACK_GRAPH) AC_MSG_WARN("Client must not use -fomit-frame-pointer.") AC_DEFINE(SAVE_CALL_COUNT, 8) ;; diff --git a/gc/dbg_mlc.c b/gc/dbg_mlc.c index be3da8e..57de3da 100644 --- a/gc/dbg_mlc.c +++ b/gc/dbg_mlc.c @@ -40,7 +40,7 @@ ptr_t p; register word sz = GC_size((ptr_t) ohdr); if (HBLKPTR((ptr_t)ohdr) != HBLKPTR((ptr_t)body) - || sz < sizeof (oh)) { + || sz < DEBUG_BYTES + EXTRA_BYTES) { return(FALSE); } if (ohdr -> oh_sz == sz) { @@ -246,6 +246,9 @@ word integer; # ifdef KEEP_BACK_PTRS ((oh *)p) -> oh_back_ptr = HIDE_BACK_PTR(NOT_MARKED); # endif +# ifdef MAKE_BACK_GRAPH + ((oh *)p) -> oh_bg_ptr = HIDE_BACK_PTR((ptr_t)0); +# endif ((oh *)p) -> oh_string = string; ((oh *)p) -> oh_int = integer; # ifndef SHORT_DBG_HDRS @@ -275,6 +278,9 @@ word integer; # ifdef KEEP_BACK_PTRS ((oh *)p) -> oh_back_ptr = HIDE_BACK_PTR(NOT_MARKED); # endif +# ifdef MAKE_BACK_GRAPH + ((oh *)p) -> oh_bg_ptr = HIDE_BACK_PTR((ptr_t)0); +# endif ((oh *)p) -> oh_string = string; ((oh *)p) -> oh_int = integer; # ifndef SHORT_DBG_HDRS @@ -861,6 +867,28 @@ struct closure { (*(cl -> cl_fn))((GC_PTR)((char *)obj + sizeof(oh)), cl -> cl_data); } +/* Set ofn and ocd to reflect the values we got back. */ +static void store_old (obj, my_old_fn, my_old_cd, ofn, ocd) +GC_PTR obj; +GC_finalization_proc my_old_fn; +struct closure * my_old_cd; +GC_finalization_proc *ofn; +GC_PTR *ocd; +{ + if (0 != my_old_fn) { + if (my_old_fn != GC_debug_invoke_finalizer) { + GC_err_printf1("Debuggable object at 0x%lx had non-debug finalizer.\n", + obj); + /* This should probably be fatal. */ + } else { + if (ofn) *ofn = my_old_cd -> cl_fn; + if (ocd) *ocd = my_old_cd -> cl_data; + } + } else { + if (ofn) *ofn = 0; + if (ocd) *ocd = 0; + } +} # ifdef __STDC__ void GC_debug_register_finalizer(GC_PTR obj, GC_finalization_proc fn, @@ -875,14 +903,21 @@ struct closure { GC_PTR *ocd; # endif { + GC_finalization_proc my_old_fn; + GC_PTR my_old_cd; ptr_t base = GC_base(obj); if (0 == base || (ptr_t)obj - base != sizeof(oh)) { GC_err_printf1( "GC_register_finalizer called with non-base-pointer 0x%lx\n", obj); } - GC_register_finalizer(base, GC_debug_invoke_finalizer, - GC_make_closure(fn,cd), ofn, ocd); + if (0 == fn) { + GC_register_finalizer(base, 0, 0, &my_old_fn, &my_old_cd); + } else { + GC_register_finalizer(base, GC_debug_invoke_finalizer, + GC_make_closure(fn,cd), &my_old_fn, &my_old_cd); + } + store_old(obj, my_old_fn, (struct closure *)my_old_cd, ofn, ocd); } # ifdef __STDC__ @@ -900,14 +935,22 @@ struct closure { GC_PTR *ocd; # endif { + GC_finalization_proc my_old_fn; + GC_PTR my_old_cd; ptr_t base = GC_base(obj); if (0 == base || (ptr_t)obj - base != sizeof(oh)) { GC_err_printf1( "GC_register_finalizer_no_order called with non-base-pointer 0x%lx\n", obj); } - GC_register_finalizer_no_order(base, GC_debug_invoke_finalizer, - GC_make_closure(fn,cd), ofn, ocd); + if (0 == fn) { + GC_register_finalizer_no_order(base, 0, 0, &my_old_fn, &my_old_cd); + } else { + GC_register_finalizer_no_order(base, GC_debug_invoke_finalizer, + GC_make_closure(fn,cd), &my_old_fn, + &my_old_cd); + } + store_old(obj, my_old_fn, (struct closure *)my_old_cd, ofn, ocd); } # ifdef __STDC__ @@ -925,14 +968,22 @@ struct closure { GC_PTR *ocd; # endif { + GC_finalization_proc my_old_fn; + GC_PTR my_old_cd; ptr_t base = GC_base(obj); if (0 == base || (ptr_t)obj - base != sizeof(oh)) { GC_err_printf1( "GC_register_finalizer_ignore_self called with non-base-pointer 0x%lx\n", obj); } - GC_register_finalizer_ignore_self(base, GC_debug_invoke_finalizer, - GC_make_closure(fn,cd), ofn, ocd); + if (0 == fn) { + GC_register_finalizer_ignore_self(base, 0, 0, &my_old_fn, &my_old_cd); + } else { + GC_register_finalizer_ignore_self(base, GC_debug_invoke_finalizer, + GC_make_closure(fn,cd), &my_old_fn, + &my_old_cd); + } + store_old(obj, my_old_fn, (struct closure *)my_old_cd, ofn, ocd); } #ifdef GC_ADD_CALLER diff --git a/gc/doc/README b/gc/doc/README index c6b48c3..702bdd0 100644 --- a/gc/doc/README +++ b/gc/doc/README @@ -27,7 +27,7 @@ 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++. +This is version 6.1alpha2 of a conservative garbage collector for C and C++. You might find a more recent version of this at diff --git a/gc/doc/README.changes b/gc/doc/README.changes index c018c8b..4478da7 100644 --- a/gc/doc/README.changes +++ b/gc/doc/README.changes @@ -1360,7 +1360,7 @@ Since 6.0alpha8: it on untested platforms. - Integrated initial GNU HURD port. (Thanks to Chris Lingard and Igor Khavkine.) - - A few more fixes for Digital Mars compiler. + - A few more fixes for Digital Mars compiler (Walter Bright). - 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 @@ -1378,16 +1378,71 @@ Since 6.0alpha9: - 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). + +Since 6.0: + - Non-debug, atomic allocations could result in bogus smashed object + reports with debugging on. (Thanks to Patrick Doyle for the small + test case.) + - Fixed GC_get_register_stack_base (Itanium only) to work around a glibc + 2.2.4 bug. + - Initial port to HP/UX on Itanium. Thread support and both 32 and 64 + bit ABIs appear to work. Parallel mark support doesn't yet, due to + some inline assembly code issues. Thread local allocation does appear + to work. + - ifdef'ed out glibc2.1/Itanium workaround. I suspect nobody is using + that combination anymore. + - Added a patch to make new_gc_alloc.h usable with gcc3.0. (Thanks to + Dimitris Vyzovitis for the patch.) + - Debugged 64-bit support on HP/UX PA-RISC. + - Turned on dynamic loading support for FreeBSD/ELF. (Thanks to Peter + Housel.) + - Unregistering of finalizers with debugging allocation was broken. + (Thanks to Jani Kajala for the test case.) + - Old finalizers were not returned correctly from GC_debug_register_finalizer. + - Disabled MPROTECT_VDB for Linux/M68K based on a report that it doesn't work. + - Cleaned up some statistics gathering code in reclaim.c (Thanks to Walter + Bright.) + - Added some support for OpenBSD/ELF/Linux. (Thanks to Suzuki Toshiya.) + - Added Jakub Jelinek's patch to use dl_iterate_phdr for dynamic library + traversal to dyn_load.c. Changed it to weakly reference dl_iterate_phdr, + so that the old code is stilll used with old versions of glibc. + - Cleaned up feature test macros for various threads packages and + integrated (partially functional) FreeBSD threads code from Loren Rittle. + It's likely that the cleanup broke something, since it touched lots of + code. It's also likelly that it fixed some unreported bugs in the + less common thread implementations, since some of the original code + didn't stand up to close scrutiny. Support for the next pthreads + implementation should be easier to add. +Since 6.0alpha1: + - No longer wrap read by default in multithreaded applications. It was + pointed out on the libgcj list that this holds the allocation lock for + way too long if the read blocks. For now, reads into the heap are + broken with incremental collection. It's possible to turn this back on + if you make sure that read calls don't block (e.g. by calling select + first). + - Fix ifdef in Solaris_threads.h to refer to GC_SOLARIS_THREADS. + - Added check for environment variable GC_IGNORE_GCJ_INFO. + - Added printing of stop-the-world GC times if GC_PRINT_STATS environment + variable is set. + - The calloc definition in leak_detector.h was missing parentheses, and + realloc was missing a second argument to GC_REALLOC. (Thanks to Elrond.) + - Added GC_PRINT_BACK_HEIGHT environment variable and associated + code, mostly in the new file backgraph.c. See doc/README.environment. + - Added -DUSE_GLOBAL_ALLOC to work around a Windows NT issue. (Thanks to + Jonathan Clark.) + - Integrated port to NEC EWS4800 (MIPS-based workstation, with somewhat + different address-space layout). This may help for other machines with + holes in the data segment. (Thanks to Hironori Sakamoto.) + - Changed the order in which GC_push_roots and friends push things onto + the mark stack. GC_push_all calls need to come first, since we can't + necessarily recovere if thos overflow the mark stack. (Thanks to + Matthew Flatt for tracking down the problem.) 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.) + be appreciated. - 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 diff --git a/gc/doc/README.environment b/gc/doc/README.environment index 5760342..f540692 100644 --- a/gc/doc/README.environment +++ b/gc/doc/README.environment @@ -1,5 +1,5 @@ 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 +then 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 @@ -32,6 +32,27 @@ GC_NPROCS=<n> - Linux w/threads only. Explicitly sets the number of processors GC_NO_BLACKLIST_WARNING - Prevents the collector from issuing "Needed to allocate blacklisted block at ..." warnings. +GC_IGNORE_GCJ_INFO - Ignore the type descriptors implicitly supplied by + GC_gcj_malloc and friends. This is useful for debugging + descriptor generation problems, and possibly for + temporarily working around such problems. It forces a + fully conservative scan of all heap objects except + those known to be pointerfree, and may thus have other + adverse effects. + +GC_PRINT_BACK_HEIGHT - Print max length of chain through unreachable objects + ending in a reachable one. If this number remains + bounded, then the program is "GC robust". This ensures + that a fixed number of misidentified pointers can only + result in a bounded space leak. This currently only + works if debugging allocation is used throughout. + It increases GC space and time requirements appreciably. + This feature is still somewhat experimental, and requires + that the collector have been built with MAKE_BACK_GRAPH + defined. For details, see Boehm, "Bounding Space Usage + of Conservative Garbage Collectors", POPL 2001, or + http://lib.hpl.hp.com/techpubs/2001/HPL-2001-251.html . + 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: diff --git a/gc/doc/README.ews4800 b/gc/doc/README.ews4800 new file mode 100644 index 0000000..bced243 --- /dev/null +++ b/gc/doc/README.ews4800 @@ -0,0 +1,75 @@ +GC on EWS4800 +------------- + +1. About EWS4800 + EWS4800 is 32bit/64bit workstation. + + Vender: NEC Corporation + OS: UX/4800 R9.* - R13.* (SystemV R4.2) + CPU: R4000, R4400, R10000 (MIPS) + +2. Compiler + + 32bit: + Use ANSI C compiler. + CC = /usr/abiccs/bin/cc + + 64bit: + Use 64bit ANSI C compiler. + CC = /usr/ccs64/bin/cc + AR = /usr/ccs64/bin/ar + +3. ELF file format + *** Caution: The following infomation is empirical. *** + + 32bit: + ELF file has an unique format. (See a.out(4) and end(3C).) + + &_start + : text segment + &etext + DATASTART + : data segment (initialized) + &edata + DATASTART2 + : data segment (uninitialized) + &end + + Here, DATASTART and DATASTART2 are macros of GC, and are defined as + the following equations. (See include/private/gcconfig.h.) + The algorithm for DATASTART is similar with the function + GC_SysVGetDataStart() in os_dep.c. + + DATASTART = ((&etext + 0x3ffff) & ~0x3ffff) + (&etext & 0xffff) + + Dynamically linked: + DATASTART2 = (&_gp + 0x8000 + 0x3ffff) & ~0x3ffff + + Statically linked: + DATASTART2 = &edata + + GC has to check addresses both between DATASTART and &edata, and + between DATASTART2 and &end. If a program accesses between &etext + and DATASTART, or between &edata and DATASTART2, the segmentation + error occurs and the program stops. + + If a program is statically linked, there is not a gap between + &edata and DATASTART2. The global symbol &_DYNAMIC_LINKING is used + for the detection. + + 64bit: + ELF file has a simple format. (See end(3C).) + + _ftext + : text segment + _etext + _fdata = DATASTART + : data segment (initialized) + _edata + _fbss + : data segment (uninitialized) + _end = DATAEND + +-- +Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp> + diff --git a/gc/doc/README.win32 b/gc/doc/README.win32 index 417281d..b1a6ec5 100644 --- a/gc/doc/README.win32 +++ b/gc/doc/README.win32 @@ -1,8 +1,8 @@ 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. +the GNU win32 environment, with Borland 4.5, with Watcom C, and recently +with the Digital Mars compiler. 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 @@ -45,6 +45,13 @@ window colors.) In general -DREDIRECT_MALLOC is unlikely to work unless the application is completely statically linked. +The collector normally allocates memory from the OS with VirtualAlloc. +This appears to cause problems under Windows NT and Windows 2000 (but +not Windows 95/98) if the memory is later passed to CreateDIBitmap. +To work around this problem, build the collector with -DUSE_GLOBAL_ALLOC. +This is currently incompatible with -DUSE_MUNMAP. (Thanks to Jonathan +Clark for tracking this down.) + 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 diff --git a/gc/doc/debugging.html b/gc/doc/debugging.html index a186ff5..04773fa 100644 --- a/gc/doc/debugging.html +++ b/gc/doc/debugging.html @@ -209,6 +209,8 @@ down the problem: <OL> <LI> If you are using the incremental collector try turning it off for debugging. +<LI> If you are using shared libraries, try linking statically. If that works, +ensure that DYNAMIC_LOADING is defined on your platform. <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> diff --git a/gc/dyn_load.c b/gc/dyn_load.c index 5a86cf6..c970fa5 100644 --- a/gc/dyn_load.c +++ b/gc/dyn_load.c @@ -26,15 +26,18 @@ * None of this is safe with dlclose and incremental collection. * But then not much of anything is safe in the presence of dlclose. */ +#if defined(__linux__) && !defined(_GNU_SOURCE) + /* Can't test LINUX, since this must be define before other includes */ +# define _GNU_SOURCE +#endif #if !defined(MACOS) && !defined(_WIN32_WCE) # include <sys/types.h> #endif #include "private/gc_priv.h" -/* BTL: avoid circular redefinition of dlopen if SOLARIS_THREADS defined */ -# if (defined(LINUX_THREADS) || defined(SOLARIS_THREADS) \ - || defined(HPUX_THREADS) || defined(IRIX_THREADS)) && defined(dlopen) \ - && !defined(GC_USE_LD_WRAP) +/* BTL: avoid circular redefinition of dlopen if GC_SOLARIS_THREADS defined */ +# if (defined(GC_PTHREADS) || defined(GC_SOLARIS_THREADS)) \ + && defined(dlopen) && !defined(GC_USE_LD_WRAP) /* To support threads in Solaris, gc.h interposes on dlopen by */ /* defining "dlopen" to be "GC_dlopen", which is implemented below. */ /* However, both GC_FirstDLOpenedLinkMap() and GC_dlopen() use the */ @@ -53,6 +56,7 @@ !(defined(ALPHA) && defined(OSF1)) && \ !defined(HPUX) && !(defined(LINUX) && defined(__ELF__)) && \ !defined(RS6000) && !defined(SCO_ELF) && \ + !(defined(FREEBSD) && defined(__ELF__)) && \ !(defined(NETBSD) && defined(__ELF__)) && !defined(HURD) --> We only know how to find data segments of dynamic libraries for the --> above. Additional SVR4 variants might not be too @@ -124,7 +128,7 @@ GC_FirstDLOpenedLinkMap() #endif /* SUNOS5DL ... */ -/* BTL: added to fix circular dlopen definition if SOLARIS_THREADS defined */ +/* BTL: added to fix circular dlopen definition if GC_SOLARIS_THREADS defined */ # if defined(GC_must_restore_redefined_dlopen) # define dlopen GC_dlopen # endif @@ -171,7 +175,7 @@ static ptr_t GC_first_common() # if defined(SUNOS4) || defined(SUNOS5DL) /* Add dynamic library data sections to the root set. */ -# if !defined(PCR) && !defined(SOLARIS_THREADS) && defined(THREADS) +# if !defined(PCR) && !defined(GC_SOLARIS_THREADS) && defined(THREADS) # ifndef SRC_M3 --> fix mutual exclusion with dlopen # endif /* We assume M3 programs don't call dlopen for now */ @@ -243,6 +247,7 @@ void GC_register_dynamic_libraries() # endif /* SUNOS */ #if defined(LINUX) && defined(__ELF__) || defined(SCO_ELF) || \ + (defined(FREEBSD) && defined(__ELF__)) || \ (defined(NETBSD) && defined(__ELF__)) || defined(HURD) @@ -417,13 +422,91 @@ static char *parse_map_entry(char *buf_ptr, word *start, word *end, return buf_ptr; } -#else /* !USE_PROC_FOR_LIBRARIES */ +#endif /* USE_PROC_FOR_LIBRARIES */ + +#if !defined(USE_PROC_FOR_LIBRARIES) +/* The following is the preferred way to walk dynamic libraries */ +/* For glibc 2.2.4+. Unfortunately, it doesn't work for older */ +/* versions. Thanks to Jakub Jelinek for most of the code. */ + +#include <stddef.h> +#include <elf.h> +#include <link.h> + +# if defined(LINUX) /* Are others OK here, too? */ \ + && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2) \ + || (__GLIBC__ == 2 && __GLIBC_MINOR__ == 2 && defined(DT_CONFIG))) + +/* We have the header files for a glibc that includes dl_iterate_phdr. */ +/* It may still not be available in the library on the target system. */ +/* Thus we also treat it as a weak symbol. */ +#define HAVE_DL_ITERATE_PHDR + +static int GC_register_dynlib_callback(info, size, ptr) + struct dl_phdr_info * info; + size_t size; + void * ptr; +{ + const ElfW(Phdr) * p; + char * start; + register int i; + + /* Make sure struct dl_phdr_info is at least as big as we need. */ + if (size < offsetof (struct dl_phdr_info, dlpi_phnum) + + sizeof (info->dlpi_phnum)) + return -1; + + /* Skip the first object - it is the main program. */ + if (*(int *)ptr == 0) + { + *(int *)ptr = 1; + return 0; + } + + p = info->dlpi_phdr; + for( i = 0; i < (int)(info->dlpi_phnum); ((i++),(p++)) ) { + switch( p->p_type ) { + case PT_LOAD: + { + if( !(p->p_flags & PF_W) ) break; + start = ((char *)(p->p_vaddr)) + info->dlpi_addr; + GC_add_roots_inner(start, start + p->p_memsz, TRUE); + } + break; + default: + break; + } + } + + return 0; +} + +/* Return TRUE if we succeed, FALSE if dl_iterate_phdr wasn't there. */ + +#pragma weak dl_iterate_phdr + +GC_bool GC_register_dynamic_libraries_dl_iterate_phdr() +{ + int tmp = 0; + + if (dl_iterate_phdr) { + dl_iterate_phdr(GC_register_dynlib_callback, &tmp); + return TRUE; + } else { + return FALSE; + } +} + +# else /* !LINUX || version(glibc) < 2.2.4 */ /* Dynamic loading code for Linux running ELF. Somewhat tested on * Linux/x86, untested but hopefully should work on Linux/Alpha. * This code was derived from the Solaris/ELF support. Thanks to * whatever kind soul wrote that. - Patrick Bridges */ +/* This doesn't necessarily work in all cases, e.g. with preloaded + * dynamic libraries. */ + #if defined(NETBSD) # include <sys/exec_elf.h> #else @@ -431,6 +514,8 @@ static char *parse_map_entry(char *buf_ptr, word *start, word *end, #endif #include <link.h> +# endif + /* Newer versions of Linux/Alpha and Linux/x86 define this macro. We * define it for those older versions that don't. */ # ifndef ElfW @@ -472,9 +557,15 @@ GC_FirstDLOpenedLinkMap() void GC_register_dynamic_libraries() { - struct link_map *lm = GC_FirstDLOpenedLinkMap(); + struct link_map *lm; +# ifdef HAVE_DL_ITERATE_PHDR + if (GC_register_dynamic_libraries_dl_iterate_phdr()) { + return; + } +# endif + lm = GC_FirstDLOpenedLinkMap(); for (lm = GC_FirstDLOpenedLinkMap(); lm != (struct link_map *) 0; lm = lm->l_next) { @@ -649,7 +740,7 @@ void GC_register_dynamic_libraries() extern GC_bool GC_is_heap_base (ptr_t p); -# ifdef WIN32_THREADS +# ifdef GC_WIN32_THREADS extern void GC_get_next_stack(char *start, char **lo, char **hi); void GC_cond_add_roots(char *base, char * limit) { @@ -864,7 +955,7 @@ void GC_register_dynamic_libraries() /* Check if this is the end of the list or if some error occured */ if (status != 0) { -# ifdef HPUX_THREADS +# ifdef GC_HPUX_THREADS /* I've seen errno values of 0. The man page is not clear */ /* as to whether errno should get set on a -1 return. */ break; diff --git a/gc/finalize.c b/gc/finalize.c index 229d828..a316010 100644 --- a/gc/finalize.c +++ b/gc/finalize.c @@ -207,7 +207,7 @@ signed_word * log_size_ptr; UNLOCK(); ENABLE_SIGNALS(); # endif - new_dl == GC_oom_fn(sizeof(struct disappearing_link)); + new_dl = GC_oom_fn(sizeof(struct disappearing_link)); if (0 == new_dl) { GC_finalization_failures++; return(0); @@ -433,7 +433,7 @@ finalization_mark_proc * mp; UNLOCK(); ENABLE_SIGNALS(); # endif - new_fo == GC_oom_fn(sizeof(struct finalizable_object)); + new_fo = GC_oom_fn(sizeof(struct finalizable_object)); if (0 == new_fo) { GC_finalization_failures++; return; @@ -838,3 +838,4 @@ void GC_notify_or_invoke_finalizers GC_PROTO((void)) # endif return(result); } + @@ -114,10 +114,10 @@ CLEAN : CPP=cl.exe # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I include /D "NDEBUG" /D "SILENT" /D "GC_BUILD" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I include /D "NDEBUG" /D "SILENT" /D "GC_BUILD" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "GC_WIN32_THREADS" /FR /YX /c CPP_PROJ=/nologo /MD /W3 /GX /O2 /I include /D "NDEBUG" /D "SILENT" /D "GC_BUILD" /D\ "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D\ - "WIN32_THREADS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/gc.pch" /YX /Fo"$(INTDIR)/" /c + "GC_WIN32_THREADS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/gc.pch" /YX /Fo"$(INTDIR)/" /c CPP_OBJS=.\Release/ CPP_SBRS=.\Release/ @@ -296,10 +296,10 @@ CLEAN : CPP=cl.exe # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I include /D "_DEBUG" /D "SILENT" /D "GC_BUILD" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I include /D "_DEBUG" /D "SILENT" /D "GC_BUILD" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "GC_WIN32_THREADS" /FR /YX /c CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I include /D "_DEBUG" /D "SILENT" /D "GC_BUILD"\ /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D\ - "WIN32_THREADS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/gc.pch" /YX /Fo"$(INTDIR)/"\ + "GC_WIN32_THREADS" /FR"$(INTDIR)/" /Fp"$(INTDIR)/gc.pch" /YX /Fo"$(INTDIR)/"\ /Fd"$(INTDIR)/" /c CPP_OBJS=.\Debug/ CPP_SBRS=.\Debug/ @@ -430,9 +430,9 @@ test.c : tests\test.c CPP=cl.exe # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MD /W3 /GX /O2 /I include /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /YX /c +# ADD CPP /nologo /MD /W3 /GX /O2 /I include /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "GC_WIN32_THREADS" /YX /c CPP_PROJ=/nologo /MD /W3 /GX /O2 /I include /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D\ - "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS"\ + "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "GC_WIN32_THREADS"\ /Fp"$(INTDIR)/gctest.pch" /YX /Fo"$(INTDIR)/" /c CPP_OBJS=.\gctest\Release/ CPP_SBRS=.\. @@ -516,9 +516,9 @@ CLEAN : CPP=cl.exe # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR /YX /c +# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "GC_WIN32_THREADS" /FR /YX /c CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I include /D "_DEBUG" /D "WIN32" /D "_WINDOWS"\ - /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "WIN32_THREADS" /FR"$(INTDIR)/"\ + /D "ALL_INTERIOR_POINTERS" /D "__STDC__" /D "GC_WIN32_THREADS" /FR"$(INTDIR)/"\ /Fp"$(INTDIR)/gctest.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c CPP_OBJS=.\gctest\Debug/ CPP_SBRS=.\gctest\Debug/ diff --git a/gc/gc_dlopen.c b/gc/gc_dlopen.c index 943c4b0..eafaa2b 100644 --- a/gc/gc_dlopen.c +++ b/gc/gc_dlopen.c @@ -24,8 +24,7 @@ #include "private/gc_priv.h" -# if defined(LINUX_THREADS) || defined(SOLARIS_THREADS) \ - || defined(HPUX_THREADS) || defined(IRIX_THREADS) +# if defined(GC_PTHREADS) || defined(GC_SOLARIS_THREADS) # if defined(dlopen) && !defined(GC_USE_LD_WRAP) /* To support various threads pkgs, gc.h interposes on dlopen by */ @@ -90,7 +89,7 @@ # endif return(result); } -# endif /* LINUX_THREADS || SOLARIS_THREADS || ... */ +# endif /* GC_PTHREADS || GC_SOLARIS_THREADS ... */ diff --git a/gc/gcj_mlc.c b/gc/gcj_mlc.c index 7e79521..89f0d72 100644 --- a/gc/gcj_mlc.c +++ b/gc/gcj_mlc.c @@ -54,6 +54,7 @@ ptr_t * GC_gcjdebugobjfreelist; void GC_init_gcj_malloc(int mp_index, void * /* really GC_mark_proc */mp) { register int i; + GC_bool ignore_gcj_info; DCL_LOCK_STATE; GC_init(); /* In case it's not already done. */ @@ -65,6 +66,12 @@ void GC_init_gcj_malloc(int mp_index, void * /* really GC_mark_proc */mp) return; } GC_gcj_malloc_initialized = TRUE; + ignore_gcj_info = (0 != GETENV("GC_IGNORE_GCJ_INFO")); +# ifdef CONDPRINT + if (GC_print_stats && ignore_gcj_info) { + GC_printf0("Gcj-style type information is disabled!\n"); + } +# endif GC_mark_procs[mp_index] = (GC_mark_proc)mp; if (mp_index >= GC_n_mark_procs) ABORT("GC_init_gcj_malloc: bad index"); /* Set up object kind gcj-style indirect descriptor. */ @@ -75,9 +82,17 @@ void GC_init_gcj_malloc(int mp_index, void * /* really GC_mark_proc */mp) GC_gcj_kind = GC_n_kinds++; GC_obj_kinds[GC_gcj_kind].ok_freelist = GC_gcjobjfreelist; GC_obj_kinds[GC_gcj_kind].ok_reclaim_list = 0; - GC_obj_kinds[GC_gcj_kind].ok_descriptor = - (((word)(-MARK_DESCR_OFFSET - GC_INDIR_PER_OBJ_BIAS)) | GC_DS_PER_OBJECT); - GC_obj_kinds[GC_gcj_kind].ok_relocate_descr = FALSE; + if (ignore_gcj_info) { + /* Use a simple length-based descriptor, thus forcing a fully */ + /* conservative scan. */ + GC_obj_kinds[GC_gcj_kind].ok_descriptor = (0 | GC_DS_LENGTH); + GC_obj_kinds[GC_gcj_kind].ok_relocate_descr = TRUE; + } else { + GC_obj_kinds[GC_gcj_kind].ok_descriptor = + (((word)(-MARK_DESCR_OFFSET - GC_INDIR_PER_OBJ_BIAS)) + | GC_DS_PER_OBJECT); + GC_obj_kinds[GC_gcj_kind].ok_relocate_descr = FALSE; + } GC_obj_kinds[GC_gcj_kind].ok_init = TRUE; /* Set up object kind for objects that require mark proc call. */ GC_gcjdebugobjfreelist = (ptr_t *) @@ -88,9 +103,14 @@ void GC_init_gcj_malloc(int mp_index, void * /* really GC_mark_proc */mp) GC_gcj_debug_kind = GC_n_kinds++; GC_obj_kinds[GC_gcj_debug_kind].ok_freelist = GC_gcjdebugobjfreelist; GC_obj_kinds[GC_gcj_debug_kind].ok_reclaim_list = 0; - GC_obj_kinds[GC_gcj_debug_kind].ok_descriptor = - GC_MAKE_PROC(mp_index, 1 /* allocated with debug info */); - GC_obj_kinds[GC_gcj_debug_kind].ok_relocate_descr = FALSE; + if (ignore_gcj_info) { + GC_obj_kinds[GC_gcj_kind].ok_descriptor = (0 | GC_DS_LENGTH); + GC_obj_kinds[GC_gcj_kind].ok_relocate_descr = TRUE; + } else { + GC_obj_kinds[GC_gcj_debug_kind].ok_descriptor = + GC_MAKE_PROC(mp_index, 1 /* allocated with debug info */); + GC_obj_kinds[GC_gcj_debug_kind].ok_relocate_descr = FALSE; + } GC_obj_kinds[GC_gcj_debug_kind].ok_init = TRUE; UNLOCK(); ENABLE_SIGNALS(); diff --git a/gc/ia64_save_regs_in_stack.s b/gc/ia64_save_regs_in_stack.s new file mode 100644 index 0000000..3b18c08 --- /dev/null +++ b/gc/ia64_save_regs_in_stack.s @@ -0,0 +1,12 @@ + .text + .align 16 + .global GC_save_regs_in_stack + .proc GC_save_regs_in_stack +GC_save_regs_in_stack: + .body + flushrs + ;; + mov r8=ar.bsp + br.ret.sptk.few rp + .endp GC_save_regs_in_stack + diff --git a/gc/include/gc.h b/gc/include/gc.h index aaf29ee..8ac709b 100644 --- a/gc/include/gc.h +++ b/gc/include/gc.h @@ -30,13 +30,9 @@ # define _GC_H -#if defined(_SOLARIS_PTHREADS) && !defined(SOLARIS_THREADS) -# define SOLARIS_THREADS -#endif - /* * Some tests for old macros. These violate our namespace rules and will - * disappear shortly. + * disappear shortly. Use the GC_ names. */ #if defined(SOLARIS_THREADS) || defined(_SOLARIS_THREADS) # define GC_SOLARIS_THREADS @@ -72,6 +68,16 @@ /* depend on this were previously included. */ #endif +#if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS) +# define GC_SOLARIS_THREADS +#endif + +# if defined(GC_SOLARIS_PTHREADS) || defined(GC_FREEBSD_THREADS) || \ + defined(GC_IRIX_THREADS) || defined(GC_LINUX_THREADS) || \ + defined(GC_HPUX_THREADS) || defined(GC_OSF1_THREADS) +# define GC_PTHREADS +# endif + # define __GC # include <stddef.h> # ifdef _WIN32_WCE @@ -80,7 +86,7 @@ typedef long ptrdiff_t; /* ptrdiff_t is not defined */ # endif -#if defined(__MINGW32__) && defined(WIN32_THREADS) +#if defined(__MINGW32__) && defined(GC_WIN32_THREADS) # ifdef GC_BUILD # define GC_API __declspec(dllexport) # else @@ -815,16 +821,12 @@ GC_API void (*GC_is_visible_print_proc) /* thread library calls. We do that here by macro defining them. */ #if !defined(GC_USE_LD_WRAP) && \ - (defined(GC_LINUX_THREADS) || defined(GC_HPUX_THREADS) || \ - defined(GC_IRIX_THREADS) || defined(GC_SOLARIS_PTHREADS) || \ - defined(GC_SOLARIS_THREADS) || defined(GC_OSF1_THREADS)) + (defined(GC_PTHREADS) || defined(GC_SOLARIS_THREADS)) # include "gc_pthread_redirects.h" #endif # if defined(PCR) || defined(GC_SOLARIS_THREADS) || \ - defined(GC_SOLARIS_PTHREADS) || defined(GC_WIN32_THREADS) || \ - defined(GC_IRIX_THREADS) || defined(GC_LINUX_THREADS) || \ - defined(GC_HPUX_THREADS) + defined(GC_PTHREADS) || defined(GC_WIN32_THREADS) /* Any flavor of threads except SRC_M3. */ /* This returns a list of objects, linked through their first */ /* word. Its use can greatly reduce lock contention problems, since */ @@ -839,7 +841,7 @@ extern void GC_thr_init(); /* Needed for Solaris/X86 */ #endif /* THREADS && !SRC_M3 */ -#if defined(WIN32_THREADS) && defined(_WIN32_WCE) +#if defined(GC_WIN32_THREADS) && defined(_WIN32_WCE) # include <windows.h> /* diff --git a/gc/include/gc_gcj.h b/gc/include/gc_gcj.h index 9123a28..5e932af 100644 --- a/gc/include/gc_gcj.h +++ b/gc/include/gc_gcj.h @@ -47,8 +47,6 @@ /* The following allocators signal an out of memory condition with */ /* return GC_oom_fn(bytes); */ -extern void * (*GC_oom_action)(void); - /* The following function must be called before the gcj allocators */ /* can be invoked. */ /* mp_index and mp are the index and mark_proc (see gc_mark.h) */ diff --git a/gc/include/gc_pthread_redirects.h b/gc/include/gc_pthread_redirects.h index ac254a8..47284fb 100644 --- a/gc/include/gc_pthread_redirects.h +++ b/gc/include/gc_pthread_redirects.h @@ -44,9 +44,7 @@ #endif /* SOLARIS_THREADS || SOLARIS_PTHREADS */ -#if !defined(GC_USE_LD_WRAP) && \ - (defined(GC_IRIX_THREADS) || defined(GC_LINUX_THREADS) \ - || defined(GC_HPUX_THREADS) || defined(GC_OSF1_THREADS)) +#if !defined(GC_USE_LD_WRAP) && defined(GC_PTHREADS) && !defined(GC_SOLARIS_PTHREADS) /* We treat these similarly. */ # include <pthread.h> # include <signal.h> diff --git a/gc/include/leak_detector.h b/gc/include/leak_detector.h index 6786825..0674ab4 100644 --- a/gc/include/leak_detector.h +++ b/gc/include/leak_detector.h @@ -1,7 +1,7 @@ #define GC_DEBUG #include "gc.h" #define malloc(n) GC_MALLOC(n) -#define calloc(m,n) GC_MALLOC(m*n) +#define calloc(m,n) GC_MALLOC((m)*(n)) #define free(p) GC_FREE(p) -#define realloc(p,n) GC_REALLOC(n) +#define realloc(p,n) GC_REALLOC((p),(n)) #define CHECK_LEAKS() GC_gcollect() diff --git a/gc/include/new_gc_alloc.h b/gc/include/new_gc_alloc.h index 1187f0b..aad9446 100644 --- a/gc/include/new_gc_alloc.h +++ b/gc/include/new_gc_alloc.h @@ -50,7 +50,20 @@ #ifndef GC_ALLOC_H #include "gc.h" -#include <stack> // A more portable way to get stl_alloc.h . + +#if (__GNUC__ < 3) +# include <stack> // A more portable way to get stl_alloc.h . +#else +# include <bits/stl_alloc.h> +# ifndef __STL_BEGIN_NAMESPACE +# define __STL_BEGIN_NAMESPACE namespace std { +# define __STL_END_NAMESPACE }; +# endif +#ifndef __STL_USE_STD_ALLOCATORS +#define __STL_USE_STD_ALLOCATORS +#endif +#endif + #define GC_ALLOC_H diff --git a/gc/include/private/dbg_mlc.h b/gc/include/private/dbg_mlc.h index 6f5b3c8..5378835 100644 --- a/gc/include/private/dbg_mlc.h +++ b/gc/include/private/dbg_mlc.h @@ -46,7 +46,8 @@ /* Stored both one past the end of user object, and one before */ /* the end of the object as seen by the allocator. */ -# if defined(KEEP_BACK_PTRS) || defined(PRINT_BLACK_LIST) +# if defined(KEEP_BACK_PTRS) || defined(PRINT_BLACK_LIST) \ + || defined(MAKE_BACK_GRAPH) /* Pointer "source"s that aren't real locations. */ /* Used in oh_back_ptr fields and as "source" */ /* argument to some marking functions. */ @@ -60,28 +61,42 @@ /* Object header */ typedef struct { -# ifdef KEEP_BACK_PTRS - GC_hidden_pointer oh_back_ptr; - /* We make sure that we only store even valued */ - /* pointers here, so that the hidden version has */ - /* the least significant bit set. We never */ - /* overwrite a value with the least significant */ - /* bit clear, thus ensuring that we never overwrite */ - /* a free list link field. */ - /* Note that blocks dropped by black-listing will */ - /* also have the lsb clear once debugging has */ - /* started. */ - /* The following are special back pointer values. */ - /* Note that the "hidden" (i.e. bitwise */ - /* complemented version) of these is actually */ - /* stored. */ +# if defined(KEEP_BACK_PTRS) || defined(MAKE_BACK_GRAPH) + /* We potentially keep two different kinds of back */ + /* pointers. KEEP_BACK_PTRS stores a single back */ + /* pointer in each reachable object to allow reporting */ + /* of why an object was retained. MAKE_BACK_GRAPH */ + /* builds a graph containing the inverse of all */ + /* "points-to" edges including those involving */ + /* objects that have just become unreachable. This */ + /* allows detection of growing chains of unreachable */ + /* objects. It may be possible to eventually combine */ + /* both, but for now we keep them separate. Both */ + /* kinds of back pointers are hidden using the */ + /* following macros. In both cases, the plain version */ + /* is constrained to have an least significant bit of 1,*/ + /* to allow it to be distinguished from a free list */ + /* link. This means the plain version must have an */ + /* lsb of 0. */ + /* Note that blocks dropped by black-listing will */ + /* also have the lsb clear once debugging has */ + /* started. */ + /* We're careful never to overwrite a value with lsb 0. */ # if ALIGNMENT == 1 /* Fudge back pointer to be even. */ # define HIDE_BACK_PTR(p) HIDE_POINTER(~1 & (GC_word)(p)) # else # define HIDE_BACK_PTR(p) HIDE_POINTER(p) # endif -# ifdef ALIGN_DOUBLE + +# ifdef KEEP_BACK_PTRS + GC_hidden_pointer oh_back_ptr; +# endif +# ifdef MAKE_BACK_GRAPH + GC_hidden_pointer oh_bg_ptr; +# endif +# if defined(ALIGN_DOUBLE) && \ + (defined(KEEP_BACK_PTRS) != defined(MAKE_BACK_GRAPH)) word oh_dummy; # endif # endif @@ -139,9 +154,9 @@ typedef struct { GC_bool GC_has_other_debug_info(/* p */); #endif -#ifdef KEEP_BACK_PTRS +#if defined(KEEP_BACK_PTRS) || defined(MAKE_BACK_GRAPH) # define GC_HAS_DEBUG_INFO(p) \ - ((((oh *)p)->oh_back_ptr & 1) && GC_has_other_debug_info(p)) + ((*((word *)p) & 1) && GC_has_other_debug_info(p)) #else # define GC_HAS_DEBUG_INFO(p) GC_has_other_debug_info(p) #endif diff --git a/gc/include/private/gc_locks.h b/gc/include/private/gc_locks.h index eed9f10..5ea1e54 100644 --- a/gc/include/private/gc_locks.h +++ b/gc/include/private/gc_locks.h @@ -76,7 +76,7 @@ # define LOCK() RT0u__inCritical++ # define UNLOCK() RT0u__inCritical-- # endif -# ifdef SOLARIS_THREADS +# ifdef GC_SOLARIS_THREADS # include <thread.h> # include <signal.h> extern mutex_t GC_allocate_ml; @@ -261,8 +261,8 @@ # define USE_PTHREAD_LOCKS # endif -# if defined(LINUX_THREADS) || defined(OSF1_THREADS) \ - || defined(HPUX_THREADS) +# if defined(GC_PTHREADS) && !defined(GC_SOLARIS_THREADS) \ + && !defined(GC_IRIX_THREADS) # define NO_THREAD (pthread_t)(-1) # include <pthread.h> # if defined(PARALLEL_MARK) @@ -412,8 +412,8 @@ # ifdef GC_ASSERTIONS extern pthread_t GC_mark_lock_holder; # endif -# endif /* LINUX_THREADS || OSF1_THREADS || HPUX_THREADS */ -# if defined(IRIX_THREADS) +# endif /* GC_PTHREADS with linux_threads.c implementation */ +# if defined(GC_IRIX_THREADS) # include <pthread.h> /* This probably should never be included, but I can't test */ /* on Irix anymore. */ @@ -439,8 +439,8 @@ GC_collecting = 1; \ } # define EXIT_GC() GC_collecting = 0; -# endif /* IRIX_THREADS */ -# ifdef WIN32_THREADS +# endif /* GC_IRIX_THREADS */ +# ifdef GC_WIN32_THREADS # include <windows.h> GC_API CRITICAL_SECTION GC_allocate_ml; # define LOCK() EnterCriticalSection(&GC_allocate_ml); diff --git a/gc/include/private/gc_pmark.h b/gc/include/private/gc_pmark.h index cf70706..5936f2e 100644 --- a/gc/include/private/gc_pmark.h +++ b/gc/include/private/gc_pmark.h @@ -136,7 +136,8 @@ extern mse * GC_mark_stack; /* Set *new_hdr_p to corr. hdr. */ #ifdef __STDC__ # ifdef PRINT_BLACK_LIST - ptr_t GC_find_start(ptr_t current, hdr *hhdr, hdr **new_hdr_p, word source); + ptr_t GC_find_start(ptr_t current, hdr *hhdr, hdr **new_hdr_p, + ptr_t source); # else ptr_t GC_find_start(ptr_t current, hdr *hhdr, hdr **new_hdr_p); # endif diff --git a/gc/include/private/gc_priv.h b/gc/include/private/gc_priv.h index 5135e3e..5ca02a6 100644 --- a/gc/include/private/gc_priv.h +++ b/gc/include/private/gc_priv.h @@ -396,7 +396,8 @@ struct hblk; /* See below. */ + GC_page_size-1) # else # if defined(NEXT) || defined(MACOSX) || defined(DOS4GW) || \ - (defined(AMIGA) && !defined(GC_AMIGA_FASTALLOC)) + (defined(AMIGA) && !defined(GC_AMIGA_FASTALLOC)) || \ + (defined(SUNOS5) && !defined(USE_MMAP)) # define GET_MEM(bytes) HBLKPTR((size_t) \ calloc(1, (size_t)bytes + GC_page_size) \ + GC_page_size-1) @@ -443,18 +444,21 @@ struct hblk; /* See below. */ /* clear on that point). Standard malloc implementations are usually */ /* neither interruptable nor thread-safe, and thus correspond to */ /* empty definitions. */ +/* It probably doesn't make any sense to declare these to be nonempty */ +/* if the code is being optimized, since signal safety relies on some */ +/* ordering constraints that are typically not obeyed by optimizing */ +/* compilers. */ # ifdef PCR # define DISABLE_SIGNALS() \ PCR_Th_SetSigMask(PCR_allSigsBlocked,&GC_old_sig_mask) # define ENABLE_SIGNALS() \ PCR_Th_SetSigMask(&GC_old_sig_mask, NIL) # else -# if defined(SRC_M3) || defined(AMIGA) || defined(SOLARIS_THREADS) \ +# if defined(THREADS) || defined(AMIGA) \ || defined(MSWIN32) || defined(MSWINCE) || defined(MACOS) \ - || defined(DJGPP) || defined(NO_SIGNALS) || defined(IRIX_THREADS) \ - || defined(LINUX_THREADS) + || defined(DJGPP) || defined(NO_SIGNALS) /* Also useful for debugging. */ - /* Should probably use thr_sigsetmask for SOLARIS_THREADS. */ + /* Should probably use thr_sigsetmask for GC_SOLARIS_THREADS. */ # define DISABLE_SIGNALS() # define ENABLE_SIGNALS() # else @@ -479,9 +483,8 @@ struct hblk; /* See below. */ PCR_allSigsBlocked, \ PCR_waitForever); # else -# if defined(SOLARIS_THREADS) || defined(WIN32_THREADS) \ - || defined(IRIX_THREADS) || defined(LINUX_THREADS) \ - || defined(HPUX_THREADS) +# if defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) \ + || defined(GC_PTHREADS) void GC_stop_world(); void GC_start_world(); # define STOP_WORLD() GC_stop_world() @@ -566,7 +569,8 @@ extern GC_warn_proc GC_current_warn_proc; # ifdef SMALL_CONFIG # define CPP_LOG_HBLKSIZE 10 # else -# if CPP_WORDSZ == 32 +# if (CPP_WORDSZ == 32) || (defined(HPUX) && defined(HP_PA)) + /* HPUX/PA seems to use 4K pages with the 64 bit ABI */ # define CPP_LOG_HBLKSIZE 12 # else # define CPP_LOG_HBLKSIZE 13 @@ -1903,8 +1907,7 @@ void GC_err_puts GC_PROTO((GC_CONST char *s)); /* some other reason. */ # endif /* PARALLEL_MARK */ -# if defined(LINUX_THREADS) || defined(IRIX_THREADS) \ - || defined(HPUX_THREADS) || defined(OSF1_THREADS) +# if defined(GC_PTHREADS) && !defined(GC_SOLARIS_THREADS) /* We define the thread suspension signal here, so that we can refer */ /* to it in the dirty bit implementation, if necessary. Ideally we */ /* would allocate a (real-time ?) signal using the standard mechanism.*/ @@ -1912,16 +1915,16 @@ void GC_err_puts GC_PROTO((GC_CONST char *s)); /* in Linux glibc, but it's not exported.) Thus we continue to use */ /* the same hard-coded signals we've always used. */ # if !defined(SIG_SUSPEND) -# if defined(LINUX_THREADS) +# if defined(GC_LINUX_THREADS) # if defined(SPARC) && !defined(SIGPWR) /* SPARC/Linux doesn't properly define SIGPWR in <signal.h>. * It is aliased to SIGLOST in asm/signal.h, though. */ # define SIG_SUSPEND SIGLOST # else - /* Linuxthreads uses SIGUSR1 and SIGUSR2. */ + /* Linuxthreads itself uses SIGUSR1 and SIGUSR2. */ # define SIG_SUSPEND SIGPWR # endif -# else /* !LINUX_THREADS */ +# else /* !GC_LINUX_THREADS */ # define SIG_SUSPEND _SIGRTMIN + 6 # endif # endif /* !SIG_SUSPEND */ diff --git a/gc/include/private/gcconfig.h b/gc/include/private/gcconfig.h index a0d12c8..86020fc 100644 --- a/gc/include/private/gcconfig.h +++ b/gc/include/private/gcconfig.h @@ -33,6 +33,11 @@ # define NETBSD # endif +/* And one for OpenBSD: */ +# if defined(__OpenBSD__) +# define OPENBSD +# endif + /* Determine the machine type: */ # if defined(sun) && defined(mc68000) # define M68K @@ -44,25 +49,23 @@ # define HP # define mach_type_known # endif -# if defined(__OpenBSD__) && defined(m68k) +# if defined(OPENBSD) && defined(m68k) # define M68K -# define OPENBSD # define mach_type_known # endif -# if defined(__OpenBSD__) && defined(__sparc__) +# if defined(OPENBSD) && defined(__sparc__) # define SPARC -# define OPENBSD # define mach_type_known # endif -# if defined(__NetBSD__) && defined(m68k) +# if defined(NETBSD) && defined(m68k) # define M68K # define mach_type_known # endif -# if defined(__NetBSD__) && defined(__powerpc__) +# if defined(NETBSD) && defined(__powerpc__) # define POWERPC # define mach_type_known # endif -# if defined(__NetBSD__) && defined(__arm32__) +# if defined(NETBSD) && defined(__arm32__) # define ARM32 # define mach_type_known # endif @@ -75,9 +78,12 @@ # endif # define mach_type_known # endif -# if defined(mips) || defined(__mips) +# if defined(mips) || defined(__mips) || defined(_mips) # define MIPS -# if !defined(LINUX) +# if defined(nec_ews) || defined(_nec_ews) +# define EWS4800 +# endif +# if !defined(LINUX) && !defined(EWS4800) # if defined(ultrix) || defined(__ultrix) || defined(__NetBSD__) # define ULTRIX # else @@ -161,6 +167,11 @@ # endif # define mach_type_known # endif +# if defined(__ia64) && defined(_HPUX_SOURCE) +# define IA64 +# define HPUX +# define mach_type_known +# endif # if defined(__BEOS__) && defined(_X86_) # define I386 # define BEOS @@ -196,7 +207,7 @@ # endif # if defined(__alpha) || defined(__alpha__) # define ALPHA -# if !defined(LINUX) && !defined(NETBSD) +# if !defined(LINUX) && !defined(NETBSD) && !defined(OPENBSD) # define OSF1 /* a.k.a Digital Unix */ # endif # define mach_type_known @@ -386,7 +397,7 @@ /* RS6000 ==> IBM RS/6000 AIX3.X */ /* RT ==> IBM PC/RT */ /* HP_PA ==> HP9000/700 & /800 */ - /* HP/UX, LINUX */ + /* HP/UX, LINUX */ /* SPARC ==> SPARC v7/v8/v9 */ /* (SUNOS4, SUNOS5, LINUX, */ /* DRSNX variants) */ @@ -398,8 +409,11 @@ /* running Amdahl UTS4 */ /* or a 390 running LINUX */ /* ARM32 ==> Intel StrongARM */ - /* IA64 ==> Intel IA64 */ + /* IA64 ==> Intel IPF */ /* (e.g. Itanium) */ + /* (LINUX and HPUX) */ + /* IA64_32 ==> IA64 w/32 bit ABI */ + /* (HPUX) */ /* SH ==> Hitachi SuperH */ /* (LINUX & MSWINCE) */ @@ -533,7 +547,7 @@ # ifdef LINUX # define OS_TYPE "LINUX" # define STACKBOTTOM ((ptr_t)0xf0000000) -# define MPROTECT_VDB +/* # define MPROTECT_VDB - Reported to not work 9/17/01 */ # ifdef __ELF__ # define DYNAMIC_LOADING # include <features.h> @@ -715,8 +729,12 @@ extern char * GC_SysVGetDataStart(); # define DATASTART (ptr_t)GC_SysVGetDataStart(0x10000, &_etext) # define DATAEND (&_end) -# ifndef USE_MMAP +# if !defined(USE_MMAP) && defined(REDIRECT_MALLOC) # define USE_MMAP + /* Otherwise we now use calloc. Mmap may result in the */ + /* heap interleaved with thread stacks, which can result in */ + /* excessive blacklisting. Sbrk is unusable since it */ + /* doesn't interact correctly with the system malloc. */ # endif # ifdef USE_MMAP # define HEAP_START (ptr_t)0x40000000 @@ -838,21 +856,29 @@ # endif # ifdef SUNOS5 # define OS_TYPE "SUNOS5" - extern int etext, _start; + extern int _etext, _end; extern char * GC_SysVGetDataStart(); -# define DATASTART GC_SysVGetDataStart(0x1000, &etext) +# define DATASTART GC_SysVGetDataStart(0x1000, &_etext) +# define DATAEND (&_end) /* # define STACKBOTTOM ((ptr_t)(&_start)) worked through 2.7, */ /* but reportedly breaks under 2.8. It appears that the stack */ /* base is a property of the executable, so this should not break */ /* old executables. */ /* HEURISTIC2 probably works, but this appears to be preferable. */ -# include <sys/vmparam.h> +# include <sys/vm.h> # define STACKBOTTOM USRSTACK -/** At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */ -/*# define PROC_VDB*/ +/* At least in Solaris 2.5, PROC_VDB gives wrong values for dirty bits. */ +/* It appears to be fixed in 2.8 and 2.9. */ +# ifdef SOLARIS25_PROC_VDB_BUG_FIXED +# define PROC_VDB +# endif # define DYNAMIC_LOADING -# ifndef USE_MMAP +# if !defined(USE_MMAP) && defined(REDIRECT_MALLOC) # define USE_MMAP + /* Otherwise we now use calloc. Mmap may result in the */ + /* heap interleaved with thread stacks, which can result in */ + /* excessive blacklisting. Sbrk is unusable since it */ + /* doesn't interact correctly with the system malloc. */ # endif # ifdef USE_MMAP # define HEAP_START (ptr_t)0x40000000 @@ -888,7 +914,7 @@ /* with 2GB physical memory will usually move the user */ /* address space limit, and hence initial SP to 0x80000000. */ # endif -# if !defined(LINUX_THREADS) || !defined(REDIRECT_MALLOC) +# if !defined(GC_LINUX_THREADS) || !defined(REDIRECT_MALLOC) # define MPROTECT_VDB # else /* We seem to get random errors in incremental mode, */ @@ -1003,8 +1029,17 @@ # endif # ifdef FREEBSD # define OS_TYPE "FREEBSD" -# define MPROTECT_VDB +# ifndef GC_FREEBSD_THREADS +# define MPROTECT_VDB +# endif +# define SIG_SUSPEND SIGUSR1 +# define SIG_THR_RESTART SIGUSR2 # define FREEBSD_STACKBOTTOM +# ifdef __ELF__ +# define DYNAMIC_LOADING +# endif + extern char etext; +# define DATASTART ((ptr_t)(&etext)) # endif # ifdef NETBSD # define OS_TYPE "NETBSD" @@ -1015,7 +1050,7 @@ # ifdef BSDI # define OS_TYPE "BSDI" # endif -# if defined(OPENBSD) || defined(NETBSD) || defined(FREEBSD) \ +# if defined(OPENBSD) || defined(NETBSD) \ || defined(THREE86BSD) || defined(BSDI) # define HEURISTIC2 extern char etext; @@ -1083,6 +1118,29 @@ /* instead. But some kernel versions seem to give the wrong */ /* value from /proc. */ # endif /* Linux */ +# ifdef EWS4800 +# define HEURISTIC2 +# if defined(_MIPS_SZPTR) && (_MIPS_SZPTR == 64) + extern int _fdata[], _end[]; +# define DATASTART ((ptr_t)_fdata) +# define DATAEND ((ptr_t)_end) +# define CPP_WORDSZ _MIPS_SZPTR +# define ALIGNMENT (_MIPS_SZPTR/8) +# else + extern int etext, edata, end; + extern int _DYNAMIC_LINKING, _gp; +# define DATASTART ((ptr_t)((((word)&etext + 0x3ffff) & ~0x3ffff) \ + + ((word)&etext & 0xffff))) +# define DATAEND (&edata) +# define DATASTART2 (&_DYNAMIC_LINKING \ + ? (ptr_t)(((word)&_gp + 0x8000 + 0x3ffff) & ~0x3ffff) \ + : (ptr_t)&edata) +# define DATAEND2 (&end) +# define ALIGNMENT 4 +# endif +# define OS_TYPE "EWS4800" +# define USE_GENERIC_PUSH_REGS 1 +# endif # ifdef ULTRIX # define HEURISTIC2 # define DATASTART (ptr_t)0x10000000 @@ -1161,7 +1219,6 @@ # ifdef HP_PA # define MACH_TYPE "HP_PA" -# define OS_TYPE "HPUX" # ifdef __LP64__ # define CPP_WORDSZ 64 # define ALIGNMENT 8 @@ -1170,8 +1227,7 @@ # define ALIGNMENT 4 # define ALIGN_DOUBLE # endif -# if !defined(GC_HPUX_THREADS) && !defined(HPUX_THREADS) \ - && !defined(GC_LINUX_THREADS) && !defined(LINUX_THREADS) +# if !defined(GC_HPUX_THREADS) && !defined(GC_LINUX_THREADS) # ifndef LINUX /* For now. */ # define MPROTECT_VDB # endif @@ -1186,6 +1242,7 @@ # endif # define STACK_GROWS_UP # ifdef HPUX +# define OS_TYPE "HPUX" extern int __data_start; # define DATASTART ((ptr_t)(&__data_start)) # if 0 @@ -1242,6 +1299,19 @@ # define CPP_WORDSZ 64 # define DYNAMIC_LOADING # endif +# ifdef OPENBSD +# define OS_TYPE "OPENBSD" +# define HEURISTIC2 +# define CPP_WORDSZ 64 +# ifdef __ELF__ /* since OpenBSD/Alpha 2.9 */ +# define DATASTART GC_data_start +# define ELFCLASS32 32 +# define ELFCLASS64 64 +# define ELF_CLASS ELFCLASS64 +# else /* ECOFF, until OpenBSD/Alpha 2.7 */ +# define DATASTART ((ptr_t) 0x140000000) +# endif +# endif # ifdef OSF1 # define OS_TYPE "OSF1" # define DATASTART ((ptr_t) 0x140000000) @@ -1284,9 +1354,6 @@ # ifdef IA64 # define MACH_TYPE "IA64" -# define ALIGN_DOUBLE - /* Requires 16 byte alignment for malloc */ -# define ALIGNMENT 8 # define USE_GENERIC_PUSH_REGS /* We need to get preserved registers in addition to register */ /* windows. That's easiest to do with setjmp. */ @@ -1296,11 +1363,47 @@ /* setting mark bits. */ # endif # ifdef HPUX - --> needs work +# ifdef _ILP32 +# define CPP_WORDSZ 32 +# define ALIGN_DOUBLE + /* Requires 8 byte alignment for malloc */ +# define ALIGNMENT 4 +# else +# ifndef _LP64 + ---> unknown ABI +# endif +# define CPP_WORDSZ 64 +# define ALIGN_DOUBLE + /* Requires 16 byte alignment for malloc */ +# define ALIGNMENT 8 +# endif +# define OS_TYPE "HPUX" + extern int __data_start; +# define DATASTART ((ptr_t)(&__data_start)) + /* Gustavo Rodriguez-Rivera suggested changing HEURISTIC2 */ + /* to this. Note that the GC must be initialized before the */ + /* first putenv call. */ + extern char ** environ; +# define STACKBOTTOM ((ptr_t)environ) +# define DYNAMIC_LOADING +# include <unistd.h> +# define GETPAGESIZE() sysconf(_SC_PAGE_SIZE) + /* The following was empirically determined, and is probably */ + /* not very robust. */ + /* Note that the backing store base seems to be at a nice */ + /* address minus one page. */ +# define BACKING_STORE_DISPLACEMENT 0x1000000 +# define BACKING_STORE_ALIGNMENT 0x1000 +# define BACKING_STORE_BASE \ + (ptr_t)(((word)GC_stackbottom - BACKING_STORE_DISPLACEMENT - 1) \ + & ~(BACKING_STORE_ALIGNMENT - 1)) # endif # ifdef LINUX +# define CPP_WORDSZ 64 +# define ALIGN_DOUBLE + /* Requires 16 byte alignment for malloc */ +# define ALIGNMENT 8 # define OS_TYPE "LINUX" -# define CPP_WORDSZ 64 /* The following works on NUE and older kernels: */ /* # define STACKBOTTOM ((ptr_t) 0xa000000000000000l) */ /* This does not work on NUE: */ @@ -1315,7 +1418,13 @@ # define BACKING_STORE_BASE ((ptr_t)GC_register_stackbottom) # define SEARCH_FOR_DATA_START # define DATASTART GC_data_start -# define DYNAMIC_LOADING +# ifdef __GNUC__ +# define DYNAMIC_LOADING +# else + /* In the Intel compiler environment, we seem to end up with */ + /* statically linked executables and an undefined reference */ + /* to _DYNAMIC */ +# endif # define MPROTECT_VDB /* Requires Linux 2.3.47 or later. */ extern int _end; @@ -1581,57 +1690,33 @@ ((word*)x)[1] = 0; # endif /* CLEAR_DOUBLE */ -/* Internally to the collector we test only the XXX_THREADS macros */ -/* not the GC_XXX_THREADS versions. Here we make sure the latter */ -/* are treated as equivalent. */ -#if defined(GC_SOLARIS_THREADS) && !defined(_SOLARIS_THREADS) -# define _SOLARIS_THREADS -#endif -#if defined(GC_SOLARIS_THREADS) && !defined(_SOLARIS_PTHREADS) -# define _SOLARIS_PTHREADS -#endif -#if defined(GC_IRIX_THREADS) && !defined(IRIX_THREADS) -# define IRIX_THREADS -#endif -#if defined(GC_LINUX_THREADS) && !defined(LINUX_THREADS) -# define LINUX_THREADS -#endif -#if defined(GC_WIN32_THREADS) && !defined(WIN32_THREADS) -# define WIN32_THREADS -#endif -#if defined(GC_HPUX_THREADS) && !defined(HPUX_THREADS) -# define HPUX_THREADS -#endif -#if defined(GC_OSF1_THREADS) && !defined(OSF1_THREADS) -# define OSF1_THREADS -#endif - -/* Internally we use SOLARIS_THREADS to test for either old or pthreads. */ -# if defined(_SOLARIS_PTHREADS) && !defined(SOLARIS_THREADS) -# define SOLARIS_THREADS +/* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */ +# if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS) +# define GC_SOLARIS_THREADS # endif -# if defined(IRIX_THREADS) && !defined(IRIX5) + +# if defined(GC_IRIX_THREADS) && !defined(IRIX5) --> inconsistent configuration # endif -# if defined(LINUX_THREADS) && !defined(LINUX) +# if defined(GC_LINUX_THREADS) && !defined(LINUX) --> inconsistent configuration # endif -# if defined(SOLARIS_THREADS) && !defined(SUNOS5) +# if defined(GC_SOLARIS_THREADS) && !defined(SUNOS5) --> inconsistent configuration # endif -# if defined(HPUX_THREADS) && !defined(HPUX) +# if defined(GC_HPUX_THREADS) && !defined(HPUX) --> inconsistent configuration # endif -# if defined(WIN32_THREADS) && !defined(MSWIN32) - /* Ideally CYGWIN32 should work, in addition to MSWIN32. I suspect the necessary code */ - /* is mostly there, but nobody has actually made sure the right combination of pieces is */ - /* compiled in, etc. */ +# if defined(GC_WIN32_THREADS) && !defined(MSWIN32) + /* Ideally CYGWIN32 should work, in addition to MSWIN32. I suspect */ + /* the necessary code is mostly there, but nobody has actually made */ + /* sure the right combination of pieces is compiled in, etc. */ --> inconsistent configuration # endif + # if defined(PCR) || defined(SRC_M3) || \ - defined(SOLARIS_THREADS) || defined(WIN32_THREADS) || \ - defined(IRIX_THREADS) || defined(LINUX_THREADS) || \ - defined(HPUX_THREADS) || defined(OSF1_THREADS) + defined(GC_SOLARIS_THREADS) || defined(GC_WIN32_THREADS) || \ + defined(GC_PTHREADS) # define THREADS # endif @@ -1656,4 +1741,8 @@ /* include assembly code to do it well. */ # endif +# if defined(MAKE_BACK_GRAPH) && !defined(DBG_HDRS_ALL) +# define DBG_HDRS_ALL +# endif + # endif /* GCCONFIG_H */ diff --git a/gc/include/private/solaris_threads.h b/gc/include/private/solaris_threads.h index b2cdb36..1464bc1 100644 --- a/gc/include/private/solaris_threads.h +++ b/gc/include/private/solaris_threads.h @@ -1,4 +1,4 @@ -#ifdef SOLARIS_THREADS +#ifdef GC_SOLARIS_THREADS /* The set of all known threads. We intercept thread creation and */ /* joins. We never actually create detached threads. We allocate all */ @@ -30,5 +30,5 @@ extern size_t GC_page_sz; extern void GC_thr_init(void); -# endif /* SOLARIS_THREADS */ +# endif /* GC_SOLARIS_THREADS */ diff --git a/gc/irix_threads.c b/gc/irix_threads.c index 12aba54..c894a31 100644 --- a/gc/irix_threads.c +++ b/gc/irix_threads.c @@ -21,11 +21,11 @@ * HP/UX 11. * * Note that there is a lot of code duplication between linux_threads.c - * and hpux_irix_threads.c; any changes made here may need to be reflected + * and irix_threads.c; any changes made here may need to be reflected * there too. */ -# if defined(GC_IRIX_THREADS) || defined(IRIX_THREADS) +# if defined(GC_IRIX_THREADS) # include "private/gc_priv.h" # include <pthread.h> @@ -725,5 +725,5 @@ yield: int GC_no_Irix_threads; #endif -# endif /* IRIX_THREADS */ +# endif /* GC_IRIX_THREADS */ diff --git a/gc/linux_threads.c b/gc/linux_threads.c index 074be89..b63dfb7 100644 --- a/gc/linux_threads.c +++ b/gc/linux_threads.c @@ -50,13 +50,14 @@ /* ANSI C requires that a compilation unit contains something */ -# if defined(GC_LINUX_THREADS) || defined(LINUX_THREADS) \ - || defined(GC_HPUX_THREADS) || defined(HPUX_THREADS) \ - || defined(GC_OSF1_THREADS) || defined(OSF1_THREADS) \ +# include "gc.h" + +# if defined(GC_PTHREADS) && !defined(GC_SOLARIS_THREADS) \ + && !defined(GC_IRIX_THREADS) # include "private/gc_priv.h" -# if defined(HPUX_THREADS) && !defined(USE_PTHREAD_SPECIFIC) \ +# if defined(GC_HPUX_THREADS) && !defined(USE_PTHREAD_SPECIFIC) \ && !defined(USE_HPUX_TLS) # define USE_HPUX_TLS # endif @@ -449,7 +450,7 @@ GC_PTR GC_local_gcj_malloc(size_t bytes, */ #ifndef SIG_THR_RESTART -# if defined(HPUX_THREADS) || defined(GC_OSF1_THREADS) +# if defined(GC_HPUX_THREADS) || defined(GC_OSF1_THREADS) # define SIG_THR_RESTART _SIGRTMIN + 5 # else # define SIG_THR_RESTART SIGXCPU @@ -458,16 +459,19 @@ GC_PTR GC_local_gcj_malloc(size_t bytes, sem_t GC_suspend_ack_sem; -#if !defined(HPUX_THREADS) && !defined(GC_OSF1_THREADS) +#if 0 /* To make sure that we're using LinuxThreads and not some other thread package, we generate a dummy reference to `pthread_kill_other_threads_np' (was `__pthread_initial_thread_bos' but that disappeared), which is a symbol defined in LinuxThreads, but (hopefully) not in other thread packages. + +We no longer do this, since this code is now portable enough that it might +actually work for something else. */ void (*dummy_var_to_force_linux_threads)() = pthread_kill_other_threads_np; -#endif /* !HPUX_THREADS */ +#endif /* 0 */ #if defined(SPARC) || defined(IA64) extern word GC_save_regs_in_stack(); @@ -530,6 +534,24 @@ static void start_mark_threads() if (0 != pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)) ABORT("pthread_attr_setdetachstate failed"); + +# ifdef HPUX + /* Default stack size is usually too small: fix it. */ + /* Otherwise marker threads or GC may run out of */ + /* space. */ +# define MIN_STACK_SIZE (8*HBLKSIZE*sizeof(word)) + { + size_t old_size; + int code; + + if (pthread_attr_getstacksize(&attr, &old_size) != 0) + ABORT("pthread_attr_getstacksize failed\n"); + if (old_size < MIN_STACK_SIZE) { + if (pthread_attr_setstacksize(&attr, MIN_STACK_SIZE) != 0) + ABORT("pthread_attr_getstacksize failed\n"); + } + } +# endif /* HPUX */ # ifdef CONDPRINT if (GC_print_stats) { GC_printf1("Starting %ld marker threads\n", GC_markers - 1); @@ -969,7 +991,7 @@ int GC_segment_is_thread_stack(ptr_t lo, ptr_t hi) } #endif /* USE_PROC_FOR_LIBRARIES */ -#ifdef LINUX_THREADS +#ifdef GC_LINUX_THREADS /* Return the number of processors, or i<= 0 if it can't be determined. */ int GC_get_nprocs() { @@ -1005,7 +1027,7 @@ int GC_get_nprocs() } return result; } -#endif /* LINUX_THREADS */ +#endif /* GC_LINUX_THREADS */ /* We hold the allocation lock. */ void GC_thr_init() @@ -1063,13 +1085,13 @@ void GC_thr_init() if (nprocs_string != NULL) GC_nprocs = atoi(nprocs_string); } if (GC_nprocs <= 0) { -# if defined(HPUX_THREADS) +# if defined(GC_HPUX_THREADS) GC_nprocs = pthread_num_processors_np(); # endif -# if defined(OSF1_THREADS) +# if defined(GC_OSF1_THREADS) || defined(GC_FREEBSD_THREADS) GC_nprocs = 1; # endif -# ifdef LINUX_THREADS +# if defined(GC_LINUX_THREADS) GC_nprocs = GC_get_nprocs(); # endif } @@ -1249,6 +1271,17 @@ int WRAP_FUNC(pthread_join)(pthread_t thread, void **retval) /* cant have been recycled by pthreads. */ UNLOCK(); result = REAL_FUNC(pthread_join)(thread, retval); +# if defined (GC_FREEBSD_THREADS) + /* On FreeBSD, the wrapped pthread_join() sometimes returns (what + appears to be) a spurious EINTR which caused the test and real code + to gratuitously fail. Having looked at system pthread library source + code, I see how this return code may be generated. In one path of + code, pthread_join() just returns the errno setting of the thread + being joined. This does not match the POSIX specification or the + local man pages thus I have taken the liberty to catch this one + spurious return value properly conditionalized on GC_FREEBSD_THREADS. */ + if (result == EINTR) result = 0; +# endif if (result == 0) { LOCK(); /* Here the pthread thread id may have been recycled. */ @@ -1584,7 +1617,7 @@ void GC_lock() pthread_t GC_mark_lock_holder = NO_THREAD; #endif -#ifdef IA64 +#if 0 /* Ugly workaround for a linux threads bug in the final versions */ /* of glibc2.1. Pthread_mutex_trylock sets the mutex owner */ /* field even when it fails to acquire the mutex. This causes */ @@ -1691,5 +1724,5 @@ void GC_notify_all_marker() #endif /* PARALLEL_MARK */ -# endif /* LINUX_THREADS */ +# endif /* GC_LINUX_THREADS and friends */ diff --git a/gc/mach_dep.c b/gc/mach_dep.c index 776bf69..b582db0 100644 --- a/gc/mach_dep.c +++ b/gc/mach_dep.c @@ -429,7 +429,7 @@ ptr_t cold_gc_frame; *i = 0; } # if defined(POWERPC) || defined(MSWIN32) || defined(MSWINCE) \ - || defined(UTS4) || defined(LINUX) + || defined(UTS4) || defined(LINUX) || defined(EWS4800) (void) setjmp(regs); # else (void) _setjmp(regs); @@ -492,8 +492,11 @@ ptr_t cold_gc_frame; /* On IA64, we also need to flush register windows. But they end */ /* up on the other side of the stack segment. */ /* Returns the backing store pointer for the register stack. */ -# ifdef IA64 -# ifdef __GNUC__ +/* We now implement this as a separate assembly file, since inline */ +/* assembly code here doesn't work with either the Intel or HP */ +/* compilers. */ +# if 0 +# ifdef LINUX asm(" .text"); asm(" .psr abi64"); asm(" .psr lsb"); @@ -510,12 +513,25 @@ ptr_t cold_gc_frame; asm(" mov r8=ar.bsp"); asm(" br.ret.sptk.few rp"); asm(" .endp GC_save_regs_in_stack"); -# else - void GC_save_regs_in_stack() { - asm(" flushrs"); - asm(" ;;"); - asm(" mov r8=ar.bsp"); - asm(" br.ret.sptk.few rp"); +# endif /* LINUX */ +# if 0 /* Other alternatives that don't work on HP/UX */ + word GC_save_regs_in_stack() { +# if USE_BUILTINS + __builtin_ia64_flushrs(); + return __builtin_ia64_bsp(); +# else +# ifdef HPUX + _asm(" flushrs"); + _asm(" ;;"); + _asm(" mov r8=ar.bsp"); + _asm(" br.ret.sptk.few rp"); +# else + asm(" flushrs"); + asm(" ;;"); + asm(" mov r8=ar.bsp"); + asm(" br.ret.sptk.few rp"); +# endif +# endif } # endif # endif diff --git a/gc/malloc.c b/gc/malloc.c index 0bbb96a..943f27d 100644 --- a/gc/malloc.c +++ b/gc/malloc.c @@ -315,7 +315,7 @@ DCL_LOCK_STATE; /* It might help to manually inline the GC_malloc call here. */ /* But any decent compiler should reduce the extra procedure call */ /* to at most a jump instruction in this case. */ -# if defined(I386) && defined(SOLARIS_THREADS) +# if defined(I386) && defined(GC_SOLARIS_THREADS) /* * Thread initialisation can call malloc before * we're ready for it. @@ -324,7 +324,7 @@ DCL_LOCK_STATE; * inopportune times. */ if (!GC_is_initialized) return sbrk(lb); -# endif /* I386 && SOLARIS_THREADS */ +# endif /* I386 && GC_SOLARIS_THREADS */ return((GC_PTR)REDIRECT_MALLOC(lb)); } @@ -360,7 +360,7 @@ DCL_LOCK_STATE; h = HBLKPTR(p); hhdr = HDR(h); # if defined(REDIRECT_MALLOC) && \ - (defined(SOLARIS_THREADS) || defined(LINUX_THREADS) \ + (defined(GC_SOLARIS_THREADS) || defined(GC_LINUX_THREADS) \ || defined(__MINGW32__)) /* Should this be MSWIN32 in general? */ /* For Solaris, we have to redirect malloc calls during */ /* initialization. For the others, this seems to happen */ @@ -838,7 +838,7 @@ long GC_markers = 2; /* Normally changed by thread-library- */ /* -specific code. */ /* Mark using the local mark stack until the global mark stack is empty */ -/* and ther are no active workers. Update GC_first_nonempty to reflect */ +/* and there are no active workers. Update GC_first_nonempty to reflect */ /* progress. */ /* Caller does not hold mark lock. */ /* Caller has already incremented GC_helper_count. We decrement it, */ @@ -918,7 +918,7 @@ void GC_mark_local(mse *local_mark_stack, int id) return; } /* else there's something on the stack again, or */ - /* another help may push something. */ + /* another helper may push something. */ GC_active_count++; GC_ASSERT(GC_active_count > 0); GC_release_mark_lock(); @@ -950,8 +950,10 @@ void GC_do_parallel_mark() GC_acquire_mark_lock(); GC_ASSERT(I_HOLD_LOCK()); - GC_ASSERT(!GC_help_wanted); - GC_ASSERT(GC_active_count == 0); + /* This could be a GC_ASSERT, but it seems safer to keep it on */ + /* all the time, especially since it's cheap. */ + if (GC_help_wanted || GC_active_count != 0 || GC_helper_count != 0) + ABORT("Tried to start parallel mark in bad state"); # ifdef PRINTSTATS GC_printf1("Starting marking for mark phase number %lu\n", (unsigned long)GC_mark_no); @@ -1374,11 +1376,11 @@ ptr_t cold_gc_frame; return; } # ifdef STACK_GROWS_DOWN - GC_push_all_eager(bottom, cold_gc_frame); GC_push_all(cold_gc_frame - sizeof(ptr_t), top); + GC_push_all_eager(bottom, cold_gc_frame); # else /* STACK_GROWS_UP */ - GC_push_all_eager(cold_gc_frame, top); GC_push_all(bottom, cold_gc_frame + sizeof(ptr_t)); + GC_push_all_eager(cold_gc_frame, top); # endif /* STACK_GROWS_UP */ } else { GC_push_all_eager(bottom, top); diff --git a/gc/mark_rts.c b/gc/mark_rts.c index 251a0d1..628cba2 100644 --- a/gc/mark_rts.c +++ b/gc/mark_rts.c @@ -252,7 +252,7 @@ GC_bool tmp; n_root_sets++; } -static roots_were_cleared = FALSE; +static GC_bool roots_were_cleared = FALSE; void GC_clear_roots GC_PROTO((void)) { @@ -522,16 +522,6 @@ ptr_t cold_gc_frame; register int i; /* - * push registers - i.e., call GC_push_one(r) for each - * register contents r. - */ -# ifdef USE_GENERIC_PUSH_REGS - GC_generic_push_regs(cold_gc_frame); -# else - GC_push_regs(); /* usually defined in machine_dep.c */ -# endif - - /* * Next push static data. This must happen early on, since it's * not robust against mark stack overflow. */ @@ -564,19 +554,30 @@ ptr_t cold_gc_frame; # endif /* - * Now traverse stacks. + * Now traverse stacks, and mark from register contents. + * These must be done last, since they can legitimately overflow + * the mark stack. */ -# if !defined(USE_GENERIC_PUSH_REGS) +# ifdef USE_GENERIC_PUSH_REGS + GC_generic_push_regs(cold_gc_frame); + /* Also pushes stack, so that we catch callee-save registers */ + /* saved inside the GC_push_regs frame. */ +# else + /* + * push registers - i.e., call GC_push_one(r) for each + * register contents r. + */ + GC_push_regs(); /* usually defined in machine_dep.c */ GC_push_current_stack(cold_gc_frame); - /* IN the threads case, this only pushes collector frames. */ - /* In the USE_GENERIC_PUSH_REGS case, this is done inside */ - /* GC_push_regs, so that we catch callee-save registers saved */ - /* inside the GC_push_regs frame. */ - /* In the case of linux threads on Ia64, the hot section of */ + /* In the threads case, this only pushes collector frames. */ + /* In the case of linux threads on IA64, the hot section of */ /* the main stack is marked here, but the register stack */ /* backing store is handled in the threads-specific code. */ # endif if (GC_push_other_roots != 0) (*GC_push_other_roots)(); /* In the threads case, this also pushes thread stacks. */ + /* Note that without interior pointer recognition lots */ + /* of stuff may have been pushed already, and this */ + /* should be careful about mark stack overflows. */ } @@ -1,6 +1,7 @@ /* * Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers * Copyright (c) 1991-1994 by Xerox Corporation. All rights reserved. + * Copyright (c) 1999-2001 by Hewlett-Packard Company. All rights reserved. * * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED * OR IMPLIED. ANY USE IS AT YOUR OWN RISK. @@ -22,7 +23,7 @@ #define I_HIDE_POINTERS /* To make GC_call_with_alloc_lock visible */ #include "private/gc_pmark.h" -#ifdef SOLARIS_THREADS +#ifdef GC_SOLARIS_THREADS # include <sys/syscall.h> #endif #if defined(MSWIN32) || defined(MSWINCE) @@ -41,29 +42,27 @@ /* Critical section counter is defined in the M3 runtime */ /* That's all we use. */ # else -# ifdef SOLARIS_THREADS +# ifdef GC_SOLARIS_THREADS mutex_t GC_allocate_ml; /* Implicitly initialized. */ # else -# ifdef WIN32_THREADS +# ifdef GC_WIN32_THREADS # if !defined(GC_NOT_DLL) && (defined(_DLL) || defined(GC_DLL)) __declspec(dllexport) CRITICAL_SECTION GC_allocate_ml; # else CRITICAL_SECTION GC_allocate_ml; # endif # else -# if defined(IRIX_THREADS) \ - || (defined(LINUX_THREADS) && defined(USE_SPIN_LOCK)) - pthread_t GC_lock_holder = NO_THREAD; -# else -# if defined(HPUX_THREADS) \ - || defined(LINUX_THREADS) && !defined(USE_SPIN_LOCK) +# if defined(GC_PTHREADS) && !defined(GC_SOLARIS_THREADS) +# if defined(USE_SPIN_LOCK) + pthread_t GC_lock_holder = NO_THREAD; +# else pthread_mutex_t GC_allocate_ml = PTHREAD_MUTEX_INITIALIZER; pthread_t GC_lock_holder = NO_THREAD; /* Used only for assertions, and to prevent */ /* recursive reentry in the system call wrapper. */ -# else +# endif +# else --> declare allocator lock here -# endif # endif # endif # endif @@ -99,6 +98,8 @@ GC_bool GC_quiet = 0; GC_bool GC_print_stats = 0; +GC_bool GC_print_back_height = 0; + #ifdef FIND_LEAK int GC_find_leak = 1; #else @@ -499,6 +500,9 @@ void GC_init_inner() if (0 != GETENV("GC_DONT_GC")) { GC_dont_gc = 1; } + if (0 != GETENV("GC_PRINT_BACK_HEIGHT")) { + GC_print_back_height = 1; + } # ifdef UNIX_LIKE if (0 != GETENV("GC_LOOP_ON_ABORT")) { GC_set_and_save_fault_handler(looping_handler); @@ -524,20 +528,18 @@ void GC_init_inner() # if defined(SEARCH_FOR_DATA_START) GC_init_linux_data_start(); # endif -# if defined(NETBSD) && defined(__ELF__) +# if (defined(NETBSD) || defined(OPENBSD)) && defined(__ELF__) GC_init_netbsd_elf(); # endif -# if defined(IRIX_THREADS) || defined(LINUX_THREADS) \ - || defined(HPUX_THREADS) || defined(SOLARIS_THREADS) +# if defined(GC_PTHREADS) || defined(GC_SOLARIS_THREADS) GC_thr_init(); # endif -# ifdef SOLARIS_THREADS +# ifdef GC_SOLARIS_THREADS /* We need dirty bits in order to find live stack sections. */ GC_dirty_init(); # endif -# if !defined(THREADS) || defined(SOLARIS_THREADS) || defined(WIN32_THREADS) \ - || defined(IRIX_THREADS) || defined(LINUX_THREADS) \ - || defined(HPUX_THREADS) +# if !defined(THREADS) || defined(GC_PTHREADS) || defined(GC_WIN32_THREADS) \ + || defined(GC_SOLARIS_THREADS) if (GC_stackbottom == 0) { GC_stackbottom = GC_get_stack_base(); # if defined(LINUX) && defined(IA64) @@ -652,7 +654,7 @@ void GC_enable_incremental GC_PROTO(()) if (GC_is_win32s()) goto out; } # endif /* MSWIN32 */ -# ifndef SOLARIS_THREADS +# ifndef GC_SOLARIS_THREADS GC_dirty_init(); # endif if (!GC_is_initialized) { @@ -753,7 +755,7 @@ size_t len; register int result; while (bytes_written < len) { -# ifdef SOLARIS_THREADS +# ifdef GC_SOLARIS_THREADS result = syscall(SYS_write, fd, buf + bytes_written, len - bytes_written); # else diff --git a/gc/new_hblk.c b/gc/new_hblk.c index d904aed..1aa2c7a 100644 --- a/gc/new_hblk.c +++ b/gc/new_hblk.c @@ -247,6 +247,7 @@ int kind; ABORT("HBLK SZ inconsistency"); } # endif + if (GC_debugging_started) clear = TRUE; /* Allocate a new heap block */ h = GC_allochblk(sz, kind, 0); diff --git a/gc/os_dep.c b/gc/os_dep.c index 79bed4c..cfbd837 100644 --- a/gc/os_dep.c +++ b/gc/os_dep.c @@ -71,10 +71,6 @@ # define NEED_FIND_LIMIT # endif -# if defined(IRIX_THREADS) || defined(HPUX_THREADS) -# define NEED_FIND_LIMIT -# endif - # if (defined(SUNOS4) && defined(DYNAMIC_LOADING)) && !defined(PCR) # define NEED_FIND_LIMIT # endif @@ -219,7 +215,7 @@ static void *tiny_sbrk(ptrdiff_t increment) #define sbrk tiny_sbrk # endif /* ECOS */ -#if defined(NETBSD) && defined(__ELF__) +#if (defined(NETBSD) || defined(OPENBSD)) && defined(__ELF__) ptr_t GC_data_start; void GC_init_netbsd_elf() @@ -561,7 +557,7 @@ ptr_t GC_get_stack_base() /* signal mask. */ (void) sigemptyset(&act.sa_mask); -# ifdef IRIX_THREADS +# ifdef GC_IRIX_THREADS /* Older versions have a bug related to retrieving and */ /* and setting a handler at the same time. */ (void) sigaction(SIGSEGV, 0, &old_segv_act); @@ -575,7 +571,7 @@ ptr_t GC_get_stack_base() /* don't have to worry in the threads case. */ (void) sigaction(SIGBUS, &act, &old_bus_act); # endif -# endif /* IRIX_THREADS */ +# endif /* GC_IRIX_THREADS */ # else old_segv_handler = signal(SIGSEGV, h); # ifdef SIGBUS @@ -670,7 +666,12 @@ ptr_t GC_get_stack_base() ptr_t GC_get_register_stack_base(void) { - if (0 != &__libc_ia64_register_backing_store_base) { + if (0 != &__libc_ia64_register_backing_store_base + && 0 != __libc_ia64_register_backing_store_base) { + /* Glibc 2.2.4 has a bug such that for dynamically linked */ + /* executables __libc_ia64_register_backing_store_base is */ + /* defined but ininitialized during constructor calls. */ + /* Hence we check for both nonzero address and value. */ return __libc_ia64_register_backing_store_base; } else { word result = (word)GC_stackbottom - BACKING_STORE_DISPLACEMENT; @@ -1079,7 +1080,7 @@ void GC_register_data_segments() { # if !defined(PCR) && !defined(SRC_M3) && !defined(NEXT) && !defined(MACOS) \ && !defined(MACOSX) -# if defined(REDIRECT_MALLOC) && defined(SOLARIS_THREADS) +# if defined(REDIRECT_MALLOC) && defined(GC_SOLARIS_THREADS) /* As of Solaris 2.3, the Solaris threads implementation */ /* allocates the data structure for the initial thread with */ /* sbrk at process startup. It needs to be scanned, so that */ @@ -1090,6 +1091,9 @@ void GC_register_data_segments() GC_add_roots_inner(DATASTART, (char *)sbrk(0), FALSE); # else GC_add_roots_inner(DATASTART, (char *)(DATAEND), FALSE); +# if defined(DATASTART2) + GC_add_roots_inner(DATASTART2, (char *)(DATAEND2), FALSE); +# endif # endif # endif # if !defined(PCR) && (defined(NEXT) || defined(MACOSX)) @@ -1288,8 +1292,14 @@ void * os2_alloc(size_t bytes) SYSTEM_INFO GC_sysinfo; # endif - # ifdef MSWIN32 + +# ifdef USE_GLOBAL_ALLOC +# define GLOBAL_ALLOC_TEST 1 +# else +# define GLOBAL_ALLOC_TEST GC_win32s +# endif + word GC_n_heap_bases = 0; ptr_t GC_win32_get_mem(bytes) @@ -1297,7 +1307,7 @@ word bytes; { ptr_t result; - if (GC_win32s) { + if (GLOBAL_ALLOC_TEST) { /* VirtualAlloc doesn't like PAGE_EXECUTE_READWRITE. */ /* There are also unconfirmed rumors of other */ /* problems, so we dodge the issue. */ @@ -1640,9 +1650,8 @@ void GC_default_push_other_roots GC_PROTO((void)) # endif /* SRC_M3 */ -# if defined(SOLARIS_THREADS) || defined(WIN32_THREADS) \ - || defined(IRIX_THREADS) || defined(LINUX_THREADS) \ - || defined(HPUX_THREADS) +# if defined(GC_SOLARIS_THREADS) || defined(GC_PTHREADS) || \ + defined(GC_WIN32_THREADS) extern void GC_push_all_stacks(); @@ -1651,11 +1660,11 @@ void GC_default_push_other_roots GC_PROTO((void)) GC_push_all_stacks(); } -# endif /* SOLARIS_THREADS || ... */ +# endif /* GC_SOLARIS_THREADS || GC_PTHREADS */ void (*GC_push_other_roots) GC_PROTO((void)) = GC_default_push_other_roots; -#endif +#endif /* THREADS */ /* * Routines for accessing dirty bits on virtual pages. @@ -2399,7 +2408,7 @@ void GC_dirty_init() # if defined(SUNOS5SIGS) || defined(IRIX5) || defined(LINUX) \ || defined(OSF1) || defined(HURD) /* SUNOS5SIGS includes HPUX */ -# if defined(IRIX_THREADS) +# if defined(GC_IRIX_THREADS) sigaction(SIGSEGV, 0, &oldact); sigaction(SIGSEGV, &act, 0); # else @@ -2537,11 +2546,15 @@ word len; ((ptr_t)end_block - (ptr_t)start_block) + HBLKSIZE); } -#if !defined(MSWIN32) && !defined(MSWINCE) && !defined(LINUX_THREADS) \ +#if !defined(MSWIN32) && !defined(MSWINCE) && !defined(THREADS) \ && !defined(GC_USE_LD_WRAP) -/* Replacement for UNIX system call. */ -/* Other calls that write to the heap */ -/* should be handled similarly. */ +/* Replacement for UNIX system call. */ +/* Other calls that write to the heap should be handled similarly. */ +/* Note that this doesn't work well for blocking reads: It will hold */ +/* tha allocation lock for the entur duration of the call. Multithreaded */ +/* clients should really ensure that it won't block, either by setting */ +/* the descriptor nonblocking, or by calling select or poll first, to */ +/* make sure that input is available. */ # if defined(__STDC__) && !defined(SUNOS4) # include <unistd.h> # include <sys/uio.h> @@ -2561,7 +2574,7 @@ word len; GC_begin_syscall(); GC_unprotect_range(buf, (word)nbyte); -# if defined(IRIX5) || defined(LINUX_THREADS) +# if defined(IRIX5) || defined(GC_LINUX_THREADS) /* Indirect system call may not always be easily available. */ /* We could call _read, but that would interfere with the */ /* libpthread interception of read. */ @@ -2587,9 +2600,9 @@ word len; GC_end_syscall(); return(result); } -#endif /* !MSWIN32 && !MSWINCE && !LINUX_THREADS */ +#endif /* !MSWIN32 && !MSWINCE && !GC_LINUX_THREADS */ -#ifdef GC_USE_LD_WRAP +#if defined(GC_USE_LD_WRAP) && !defined(THREADS) /* We use the GNU ld call wrapping facility. */ /* This requires that the linker be invoked with "--wrap read". */ /* This can be done by passing -Wl,"--wrap read" to gcc. */ @@ -2660,7 +2673,7 @@ word n; word GC_proc_buf_size = INITIAL_BUF_SZ; char *GC_proc_buf; -#ifdef SOLARIS_THREADS +#ifdef GC_SOLARIS_THREADS /* We don't have exact sp values for threads. So we count on */ /* occasionally declaring stack pages to be fresh. Thus we */ /* need a real implementation of GC_is_fresh. We can't clear */ @@ -2715,7 +2728,7 @@ void GC_dirty_init() ABORT("/proc ioctl failed"); } GC_proc_buf = GC_scratch_alloc(GC_proc_buf_size); -# ifdef SOLARIS_THREADS +# ifdef GC_SOLARIS_THREADS GC_fresh_pages = (struct hblk **) GC_scratch_alloc(MAX_FRESH_PAGES * sizeof (struct hblk *)); if (GC_fresh_pages == 0) { @@ -2733,7 +2746,7 @@ struct hblk *h; { } -#ifdef SOLARIS_THREADS +#ifdef GC_SOLARIS_THREADS # define READ(fd,buf,nbytes) syscall(SYS_read, fd, buf, nbytes) #else # define READ(fd,buf,nbytes) read(fd, buf, nbytes) @@ -2772,7 +2785,7 @@ int dummy; /* Punt: */ memset(GC_grungy_pages, 0xff, sizeof (page_hash_table)); memset(GC_written_pages, 0xff, sizeof(page_hash_table)); -# ifdef SOLARIS_THREADS +# ifdef GC_SOLARIS_THREADS BZERO(GC_fresh_pages, MAX_FRESH_PAGES * sizeof (struct hblk *)); # endif @@ -2802,7 +2815,7 @@ int dummy; register word index = PHT_HASH(h); set_pht_entry_from_index(GC_grungy_pages, index); -# ifdef SOLARIS_THREADS +# ifdef GC_SOLARIS_THREADS { register int slot = FRESH_PAGE_SLOT(h); @@ -2820,7 +2833,7 @@ int dummy; } /* Update GC_written_pages. */ GC_or_pages(GC_written_pages, GC_grungy_pages); -# ifdef SOLARIS_THREADS +# ifdef GC_SOLARIS_THREADS /* Make sure that old stacks are considered completely clean */ /* unless written again. */ GC_old_stacks_are_fresh(); @@ -2836,7 +2849,7 @@ struct hblk *h; register GC_bool result; result = get_pht_entry_from_index(GC_grungy_pages, index); -# ifdef SOLARIS_THREADS +# ifdef GC_SOLARIS_THREADS if (result && PAGE_IS_FRESH(h)) result = FALSE; /* This happens only if page was declared fresh since */ /* the read_dirty call, e.g. because it's in an unused */ @@ -2854,7 +2867,7 @@ struct hblk *h; register GC_bool result; result = get_pht_entry_from_index(GC_written_pages, index); -# ifdef SOLARIS_THREADS +# ifdef GC_SOLARIS_THREADS if (result && PAGE_IS_FRESH(h)) result = FALSE; # endif return(result); @@ -2868,7 +2881,7 @@ word n; register word index; -# ifdef SOLARIS_THREADS +# ifdef GC_SOLARIS_THREADS register word i; if (GC_fresh_pages != 0) { diff --git a/gc/reclaim.c b/gc/reclaim.c index 78995f3..48db1e2 100644 --- a/gc/reclaim.c +++ b/gc/reclaim.c @@ -702,7 +702,8 @@ COUNT_DECL if (report_if_found) { GC_reclaim_check(hbp, hhdr, sz); } else { - *flh = GC_reclaim_generic(hbp, hhdr, sz, ok -> ok_init, + *flh = GC_reclaim_generic(hbp, hhdr, sz, + (ok -> ok_init || GC_debugging_started), *flh MEM_FOUND_ADDR); } } @@ -774,8 +775,12 @@ COUNT_DECL /* Routines to gather and print heap block info */ /* intended for debugging. Otherwise should be called */ /* with lock. */ -static size_t number_of_blocks; -static size_t total_bytes; + +struct Print_stats +{ + size_t number_of_blocks; + size_t total_bytes; +}; #ifdef USE_MARK_BYTES @@ -834,25 +839,30 @@ hdr * hhdr; { register hdr * hhdr = HDR(h); register size_t bytes = WORDS_TO_BYTES(hhdr -> hb_sz); + struct Print_stats *ps; GC_printf3("(%lu:%lu,%lu)", (unsigned long)(hhdr -> hb_obj_kind), (unsigned long)bytes, (unsigned long)(GC_n_set_marks(hhdr))); bytes += HBLKSIZE-1; bytes &= ~(HBLKSIZE-1); - total_bytes += bytes; - number_of_blocks++; + + ps = (struct Print_stats *)dummy; + ps->total_bytes += bytes; + ps->number_of_blocks++; } void GC_print_block_list() { + struct Print_stats pstats; + GC_printf0("(kind(0=ptrfree,1=normal,2=unc.,3=stubborn):size_in_bytes, #_marks_set)\n"); - number_of_blocks = 0; - total_bytes = 0; - GC_apply_to_all_blocks(GC_print_block_descr, (word)0); + pstats.number_of_blocks = 0; + pstats.total_bytes = 0; + GC_apply_to_all_blocks(GC_print_block_descr, (word)&pstats); GC_printf2("\nblocks = %lu, bytes = %lu\n", - (unsigned long)number_of_blocks, - (unsigned long)total_bytes); + (unsigned long)pstats.number_of_blocks, + (unsigned long)pstats.total_bytes); } #endif /* NO_DEBUGGING */ diff --git a/gc/solaris_pthreads.c b/gc/solaris_pthreads.c index 48dd193..8ff985f 100644 --- a/gc/solaris_pthreads.c +++ b/gc/solaris_pthreads.c @@ -16,9 +16,9 @@ * Modified Peter C. for Solaris Posix Threads. */ /* Boehm, September 14, 1994 4:44 pm PDT */ -/* $Id: solaris_pthreads.c,v 1.3 2001/11/15 00:32:13 a-ito Exp $ */ +/* $Id: solaris_pthreads.c,v 1.3.2.1 2001/11/22 17:52:29 inu Exp $ */ -# if defined(GC_SOLARIS_PTHREADS) || defined(_SOLARIS_PTHREADS) +# if defined(GC_SOLARIS_PTHREADS) # include "private/gc_priv.h" # include <pthread.h> # include <thread.h> @@ -176,5 +176,5 @@ GC_pthread_create(pthread_t *new_thread, int GC_no_sunOS_pthreads; #endif -# endif /* SOLARIS_THREADS */ +# endif /* GC_SOLARIS_PTHREADS */ diff --git a/gc/solaris_threads.c b/gc/solaris_threads.c index 8cc6319..11b0e03 100644 --- a/gc/solaris_threads.c +++ b/gc/solaris_threads.c @@ -16,7 +16,7 @@ */ /* Boehm, September 14, 1994 4:44 pm PDT */ -# if defined(GC_SOLARIS_THREADS) || defined(SOLARIS_THREADS) +# if defined(GC_SOLARIS_THREADS) # include "private/gc_priv.h" # include "private/solaris_threads.h" @@ -621,7 +621,18 @@ GC_thread GC_lookup_thread(thread_t id) return(p); } +/* Solaris 2/Intel uses an initial stack size limit slightly bigger than the + SPARC default of 8 MB. Account for this to warn only if the user has + raised the limit beyond the default. + + This is identical to DFLSSIZ defined in <sys/vm_machparam.h>. This file + is installed in /usr/platform/`uname -m`/include, which is not in the + default include directory list, so copy the definition here. */ +#ifdef I386 +# define MAX_ORIG_STACK_SIZE (8 * 1024 * 1024 + ((USRSTACK) & 0x3FFFFF)) +#else # define MAX_ORIG_STACK_SIZE (8 * 1024 * 1024) +#endif word GC_get_orig_stack_size() { struct rlimit rl; @@ -938,7 +949,7 @@ GC_thr_create(void *stack_base, size_t stack_size, return(result); } -# else /* SOLARIS_THREADS */ +# else /* !GC_SOLARIS_THREADS */ #ifndef LINT int GC_no_sunOS_threads; diff --git a/gc/specific.c b/gc/specific.c index 5afd10b..48b53ac 100644 --- a/gc/specific.c +++ b/gc/specific.c @@ -11,7 +11,7 @@ * modified is included with the above copyright notice. */ -#if defined(LINUX_THREADS) || defined(GC_LINUX_THREADS) +#if defined(GC_LINUX_THREADS) #include "private/gc_priv.h" /* For GC_compare_and_exchange, GC_memory_barrier */ #include "private/specific.h" @@ -105,4 +105,4 @@ void * PREFIXED(slow_getspecific) (tsd * key, unsigned long qtid, return entry -> value; } -#endif /* LINUX_THREADS */ +#endif /* GC_LINUX_THREADS */ diff --git a/gc/tests/test.c b/gc/tests/test.c index 1bd98d6..7cb4d0c 100644 --- a/gc/tests/test.c +++ b/gc/tests/test.c @@ -20,7 +20,7 @@ # undef GC_BUILD -#ifdef DBG_HDRS_ALL +#if defined(DBG_HDRS_ALL) || defined(MAKE_BACK_GRAPH) # define GC_DEBUG #endif @@ -59,16 +59,16 @@ # define GC_printf1 printf # endif -# ifdef SOLARIS_THREADS +# if defined(GC_SOLARIS_THREADS) && !defined(GC_SOLARIS_PTHREADS) # include <thread.h> # include <synch.h> # endif -# if defined(IRIX_THREADS) || defined(LINUX_THREADS) || defined(HPUX_THREADS) +# if defined(GC_PTHREADS) # include <pthread.h> # endif -# ifdef WIN32_THREADS +# ifdef GC_WIN32_THREADS # ifndef MSWINCE # include <process.h> # define GC_CreateThread(a,b,c,d,e,f) ((HANDLE) _beginthreadex(a,b,c,d,e,f)) @@ -447,7 +447,7 @@ struct { */ #ifdef THREADS -# ifdef WIN32_THREADS +# ifdef GC_WIN32_THREADS unsigned __stdcall tiny_reverse_test(void * arg) # else void * tiny_reverse_test(void * arg) @@ -457,8 +457,7 @@ struct { return 0; } -# if defined(IRIX_THREADS) || defined(LINUX_THREADS) \ - || defined(SOLARIS_PTHREADS) || defined(HPUX_THREADS) +# if defined(GC_PTHREADS) void fork_a_thread() { pthread_t t; @@ -475,7 +474,7 @@ struct { } } -# elif defined(WIN32_THREADS) +# elif defined(GC_WIN32_THREADS) void fork_a_thread() { unsigned thread_id; @@ -493,7 +492,7 @@ struct { } } -/* # elif defined(SOLARIS_THREADS) */ +/* # elif defined(GC_SOLARIS_THREADS) */ # else @@ -649,15 +648,15 @@ VOLATILE int dropped_something = 0; # ifdef PCR PCR_ThCrSec_EnterSys(); # endif -# ifdef SOLARIS_THREADS +# if defined(GC_SOLARIS_THREADS) && !defined(GC_SOLARIS_PTHREADS) static mutex_t incr_lock; mutex_lock(&incr_lock); # endif -# if defined(IRIX_THREADS) || defined(LINUX_THREADS) || defined(HPUX_THREADS) +# if defined(GC_PTHREADS) static pthread_mutex_t incr_lock = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_lock(&incr_lock); # endif -# ifdef WIN32_THREADS +# ifdef GC_WIN32_THREADS EnterCriticalSection(&incr_cs); # endif if ((int)(GC_word)client_data != t -> level) { @@ -668,13 +667,13 @@ VOLATILE int dropped_something = 0; # ifdef PCR PCR_ThCrSec_ExitSys(); # endif -# ifdef SOLARIS_THREADS +# if defined(GC_SOLARIS_THREADS) && !defined(GC_SOLARIS_PTHREADS) mutex_unlock(&incr_lock); # endif -# if defined(IRIX_THREADS) || defined(LINUX_THREADS) || defined(HPUX_THREADS) +# if defined(GC_PTHREADS) pthread_mutex_unlock(&incr_lock); # endif -# ifdef WIN32_THREADS +# ifdef GC_WIN32_THREADS LeaveCriticalSection(&incr_cs); # endif } @@ -740,16 +739,15 @@ int n; # ifdef PCR PCR_ThCrSec_EnterSys(); # endif -# ifdef SOLARIS_THREADS +# if defined(GC_SOLARIS_THREADS) && !defined(GC_SOLARIS_PTHREADS) static mutex_t incr_lock; mutex_lock(&incr_lock); # endif -# if defined(IRIX_THREADS) || defined(LINUX_THREADS) \ - || defined(HPUX_THREADS) +# if defined(GC_PTHREADS) static pthread_mutex_t incr_lock = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_lock(&incr_lock); # endif -# ifdef WIN32_THREADS +# ifdef GC_WIN32_THREADS EnterCriticalSection(&incr_cs); # endif /* Losing a count here causes erroneous report of failure. */ @@ -758,14 +756,13 @@ int n; # ifdef PCR PCR_ThCrSec_ExitSys(); # endif -# ifdef SOLARIS_THREADS +# if defined(GC_SOLARIS_THREADS) && !defined(GC_SOLARIS_PTHREADS) mutex_unlock(&incr_lock); # endif -# if defined(IRIX_THREADS) || defined(LINUX_THREADS) \ - || defined(HPUX_THREADS) +# if defined(GC_PTHREADS) pthread_mutex_unlock(&incr_lock); # endif -# ifdef WIN32_THREADS +# ifdef GC_WIN32_THREADS LeaveCriticalSection(&incr_cs); # endif } @@ -825,7 +822,7 @@ int n; chktree(t -> rchild, n-1); } -# if defined(SOLARIS_THREADS) && !defined(_SOLARIS_PTHREADS) +# if defined(GC_SOLARIS_THREADS) && !defined(GC_SOLARIS_PTHREADS) thread_key_t fl_key; void * alloc8bytes() @@ -866,9 +863,7 @@ void * alloc8bytes() #else -# if defined(GC_SOLARIS_PTHREADS) || defined(GC_IRIX_THREADS) \ - || defined(GC_LINUX_THREADS) || defined(GC_HPUX_THREADS) \ - || defined(GC_SOLARIS_THREADS) +# if defined(GC_PTHREADS) pthread_key_t fl_key; void * alloc8bytes() @@ -1319,9 +1314,8 @@ void SetMinimumStack(long minSize) #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) + && !defined(GC_WIN32_THREADS) && !defined(GC_PTHREADS) \ + || defined(LINT) #if defined(MSWIN32) && !defined(__MINGW32__) int APIENTRY WinMain(HINSTANCE instance, HINSTANCE prev, LPTSTR cmd, int n) #else @@ -1346,7 +1340,7 @@ void SetMinimumStack(long minSize) # endif GC_INIT(); /* Only needed if gc is dynamic library. */ (void) GC_set_warn_proc(warn_proc); -# if defined(MPROTECT_VDB) || defined(PROC_VDB) +# if (defined(MPROTECT_VDB) || defined(PROC_VDB)) && !defined(MAKE_BACK_GRAPH) GC_enable_incremental(); (void) GC_printf0("Switched to incremental mode\n"); # if defined(MPROTECT_VDB) @@ -1557,8 +1551,7 @@ test() } #endif -#if defined(GC_SOLARIS_THREADS) || defined(GC_IRIX_THREADS) \ - || defined(GC_HPUX_THREADS) || defined(GC_LINUX_THREADS) +#if defined(GC_SOLARIS_THREADS) || defined(GC_PTHREADS) void * thr_run_one_test(void * arg) { run_one_test(); @@ -1569,7 +1562,7 @@ void * thr_run_one_test(void * arg) # define GC_free GC_debug_free #endif -#ifdef GC_SOLARIS_THREADS +#if defined(GC_SOLARIS_THREADS) && !defined(GC_SOLARIS_PTHREADS) main() { thread_t th1; @@ -1578,7 +1571,9 @@ main() n_tests = 0; GC_INIT(); /* Only needed if gc is dynamic library. */ - GC_enable_incremental(); +# ifndef MAKE_BACK_GRAPH + GC_enable_incremental(); +# endif (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); @@ -1606,6 +1601,11 @@ main() return(0); } #else /* pthreads */ + +#ifndef GC_PTHREADS + --> bad news +#endif + main() { pthread_t th1; @@ -1618,12 +1618,19 @@ main() /* Since the initial cant always grow later. */ *((volatile char *)&code - 1024*1024) = 0; /* Require 1 Mb */ # endif /* GC_IRIX_THREADS */ +# if defined(GC_HPUX_THREADS) + /* Default stack size is too small, especially with the 64 bit ABI */ + /* Increase it. */ + if (pthread_default_stacksize_np(1024*1024, 0) != 0) { + (void)GC_printf0("pthread_default_stacksize_np failed.\n"); + } +# endif /* GC_HPUX_THREADS */ pthread_attr_init(&attr); -# if defined(GC_IRIX_THREADS) || defined(GC_HPUX_THREADS) +# if defined(GC_IRIX_THREADS) || defined(GC_FREEBSD_THREADS) pthread_attr_setstacksize(&attr, 1000000); # endif n_tests = 0; -# if defined(MPROTECT_VDB) && !defined(PARALLEL_MARK) &&!defined(REDIRECT_MALLOC) +# if defined(MPROTECT_VDB) && !defined(PARALLEL_MARK) &&!defined(REDIRECT_MALLOC) && !defined(MAKE_BACK_GRAPH) GC_enable_incremental(); (void) GC_printf0("Switched to incremental mode\n"); (void) GC_printf0("Emulating dirty bits with mprotect/signals\n"); @@ -1656,5 +1663,5 @@ main() GC_printf1("Completed %d collections\n", GC_gc_no); return(0); } -#endif /* pthreads */ -#endif /* SOLARIS_THREADS || IRIX_THREADS || LINUX_THREADS || HPUX_THREADS */ +#endif /* GC_PTHREADS */ +#endif /* GC_SOLARIS_THREADS || GC_PTHREADS */ diff --git a/gc/threadlibs.c b/gc/threadlibs.c index 0ac5451..991647e 100644 --- a/gc/threadlibs.c +++ b/gc/threadlibs.c @@ -9,21 +9,16 @@ int main() "-Wl,--wrap -Wl,pthread_detach " "-Wl,--wrap -Wl,pthread_sigmask -Wl,--wrap -Wl,sleep\n"); # endif -# if defined(LINUX_THREADS) - printf("-lpthread\n"); +# if defined(GC_LINUX_THREADS) || defined(GC_IRIX_THREADS) \ + || defined(GC_FREEBSD_THREADS) + printf("-lpthread\n"); # endif -# if defined(IRIX_THREADS) - printf("-lpthread\n"); -# endif -# if defined(HPUX_THREADS) +# if defined(GC_HPUX_THREADS) || defined(GC_OSF1_THREADS) printf("-lpthread -lrt\n"); # endif -# ifdef SOLARIS_THREADS +# if defined(GC_SOLARIS_THREADS) printf("-lthread -ldl\n"); # endif -# ifdef GC_OSF1_THREADS - printf("-lpthread -lrt\n"); -# endif return 0; } diff --git a/gc/version.h b/gc/version.h index 7efee18..e499379 100644 --- a/gc/version.h +++ b/gc/version.h @@ -1,6 +1,6 @@ #define GC_VERSION_MAJOR 6 -#define GC_VERSION_MINOR 0 -#define GC_ALPHA_VERSION GC_NOT_ALPHA +#define GC_VERSION_MINOR 1 +#define GC_ALPHA_VERSION 2 # define GC_NOT_ALPHA 0xff diff --git a/gc/win32_threads.c b/gc/win32_threads.c index e0d19d5..533b6a4 100755 --- a/gc/win32_threads.c +++ b/gc/win32_threads.c @@ -1,4 +1,4 @@ -#if defined(GC_WIN32_THREADS) || defined(WIN32_THREADS) +#if defined(GC_WIN32_THREADS) #include "private/gc_priv.h" @@ -614,4 +614,4 @@ BOOL WINAPI DllMain(HINSTANCE inst, ULONG reason, LPVOID reserved) # endif /* !MSWINCE */ -#endif /* WIN32_THREADS */ +#endif /* GC_WIN32_THREADS */ @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.16 2001/11/22 15:02:17 ukai Exp $ */ +/* $Id: main.c,v 1.6.2.1 2001/11/22 17:52:28 inu Exp $ */ #define MAINPROGRAM #include "fm.h" #include <signal.h> @@ -7,14 +7,15 @@ #include <sys/types.h> #include <fcntl.h> #include <sys/wait.h> -#include <time.h> #include "terms.h" #include "myctype.h" -#include "regex.h" -#ifdef USE_MOUSE +#ifdef MOUSE #ifdef USE_GPM #include <gpm.h> #endif /* USE_GPM */ +#ifdef __EMX__ +#include <time.h> /* for time() */ +#endif /* __EMX__ */ #if defined(USE_GPM) || defined(USE_SYSMOUSE) extern int do_getch(); #define getch() do_getch() @@ -61,8 +62,10 @@ static void keyPressEventProc(int c); #ifdef USE_MARK static void cmd_mark(Lineprop * p); #endif /* USE_MARK */ +#ifdef SHOW_PARAMS int show_params_p = 0; void show_params(FILE * fp); +#endif static int display_ok = FALSE; static void dump_source(Buffer *); @@ -107,9 +110,9 @@ fusage(FILE *f, int err) fprintf(f, " -T type specify content-type\n"); fprintf(f, " -m internet message mode\n"); fprintf(f, " -v visual startup mode\n"); -#ifdef USE_COLOR +#ifdef COLOR fprintf(f, " -M monochrome display\n"); -#endif /* USE_COLOR */ +#endif /* COLOR */ fprintf(f, " -F automatically render frame\n"); fprintf(f, " -cols width specify column width (used with -dump)\n"); fprintf(f, " -ppc count specify the number of pixels per character (4.0...32.0)\n"); @@ -123,9 +126,9 @@ fusage(FILE *f, int err) fprintf(f, " +<num> goto <num> line\n"); fprintf(f, " -num show line number\n"); fprintf(f, " -no-proxy don't use proxy\n"); -#ifdef USE_MOUSE +#ifdef MOUSE fprintf(f, " -no-mouse don't use mouse\n"); -#endif /* USE_MOUSE */ +#endif /* MOUSE */ #ifdef USE_COOKIE fprintf(f, " -cookie use cookie (-no-cookie: don't use cookie)\n"); #endif /* USE_COOKIE */ @@ -143,8 +146,10 @@ fusage(FILE *f, int err) fprintf(f, " -o opt=value assign value to config option\n"); fprintf(f, " -config file specify config file\n"); fprintf(f, " -debug DO NOT USE\n"); +#ifdef SHOW_PARAMS if (show_params_p) show_params(f); +#endif exit(err); } @@ -266,9 +271,9 @@ MAIN(int argc, char **argv, char **envp) char *post_file = NULL; Str err_msg; -#ifndef HAVE_SYS_ERRLIST +#ifndef SYS_ERRLIST prepare_sys_errlist(); -#endif /* not HAVE_SYS_ERRLIST */ +#endif /* not SYS_ERRLIST */ srand48(time(0)); @@ -425,10 +430,10 @@ MAIN(int argc, char **argv, char **envp) SearchHeader = search_header = TRUE; else if (!strcmp("-v", argv[i])) visual_start = TRUE; -#ifdef USE_COLOR +#ifdef COLOR else if (!strcmp("-M", argv[i])) useColor = FALSE; -#endif /* USE_COLOR */ +#endif /* COLOR */ else if (!strcmp("-B", argv[i])) load_bookmark = TRUE; else if (!strcmp("-bookmark", argv[i])) { @@ -508,18 +513,17 @@ MAIN(int argc, char **argv, char **envp) Str hs; if (++i >= argc) usage(); - if ((hs = make_optional_header_string(argv[i])) != NULL) { + if ((hs = make_optional_header_string(argv[i])) != NULL) if (header_string == NULL) header_string = hs; else Strcat (header_string, hs); - } } -#ifdef USE_MOUSE +#ifdef MOUSE else if (!strcmp("-no-mouse", argv[i])) { use_mouse = FALSE; } -#endif /* USE_MOUSE */ +#endif /* MOUSE */ #ifdef USE_COOKIE else if (!strcmp("-no-cookie", argv[i])) { use_cookie = FALSE; @@ -548,15 +552,24 @@ MAIN(int argc, char **argv, char **envp) else if (!strcmp("-X", argv[i])) Do_not_use_ti_te = TRUE; else if (!strcmp("-o", argv[i])) { +#ifdef SHOW_PARAMS if (++i >= argc || !strcmp(argv[i], "?")) { show_params_p = 1; usage(); } +#else + if (++i >= argc) + usage(); +#endif if (!set_param_option(argv[i])) { /* option set failed */ fprintf(stderr, "%s: bad option\n", argv[i]); +#ifdef SHOW_PARAMS show_params_p = 1; usage(); +#else + exit(1); +#endif } option_assigned = 1; } @@ -608,7 +621,7 @@ MAIN(int argc, char **argv, char **envp) backend(); if (!w3m_dump) { initKeymap(); -#ifdef USE_MENU +#ifdef MENU initMenu(); CurrentMenuData = NULL; #endif /* MENU */ @@ -633,11 +646,11 @@ MAIN(int argc, char **argv, char **envp) else if (visual_start) { Str s_page; s_page = Strnew_charp("<title>W3M startup page</title><center><b>Welcome to "); - Strcat_charp(s_page, "<a href='http://w3m.sourceforge.net/'>"); + Strcat_charp(s_page, "<a href='http://w3m.sourceforge.net/'>"); Strcat_m_charp(s_page, "w3m</a>!<p><p>This is w3m version ", version, - "<br>Written by <a href='mailto:aito@fw.ipsj.or.jp'>Akinori Ito</a>", + "<br>Written by <a href='mailto:aito@fw.ipsj.or.jp'>Akinori Ito</a>", NULL); #ifdef DEBIAN Strcat_m_charp(s_page, @@ -820,7 +833,7 @@ MAIN(int argc, char **argv, char **envp) for (i = 0; i < n_event_queue; i++) { CurrentKey = -1; CurrentKeyData = eventQueue[i].user_data; -#ifdef USE_MENU +#ifdef MENU CurrentMenuData = NULL; #endif w3mFuncList[eventQueue[i].cmd].func(); @@ -829,18 +842,18 @@ MAIN(int argc, char **argv, char **envp) } CurrentKeyData = NULL; /* get keypress event */ -#ifdef USE_MOUSE +#ifdef MOUSE if (use_mouse) mouse_active(); -#endif /* USE_MOUSE */ +#endif /* MOUSE */ #ifdef USE_ALARM - if (alarm_status == AL_IMPLICIT) { - alarm_buffer = Currentbuf; - alarm_status = AL_IMPLICIT_DONE; - } else if (alarm_status == AL_IMPLICIT_DONE && alarm_buffer != Currentbuf) { - alarm_sec = 0; - alarm_status = AL_UNSET; - } + if (alarm_status == AL_IMPLICIT) { + alarm_buffer = Currentbuf; + alarm_status = AL_IMPLICIT_DONE; + } else if (alarm_status == AL_IMPLICIT_DONE && alarm_buffer != Currentbuf) { + alarm_sec = 0; + alarm_status = AL_UNSET; + } if (alarm_sec > 0) { signal(SIGALRM, SigAlarm); alarm(alarm_sec); @@ -852,10 +865,10 @@ MAIN(int argc, char **argv, char **envp) alarm(0); } #endif -#ifdef USE_MOUSE +#ifdef MOUSE if (use_mouse) mouse_inactive(); -#endif /* USE_MOUSE */ +#endif /* MOUSE */ if (IS_ASCII(c)) { /* Ascii */ if (((prec_num && c == '0') || '1' <= c) && (c <= '9')) { prec_num = prec_num * 10 + (int) (c - '0'); @@ -1185,7 +1198,7 @@ ctrCsrH(void) int offsetx; if (Currentbuf->firstLine == NULL) return; - offsetx = Currentbuf->cursorX - Currentbuf->COLS / 2; + offsetx = Currentbuf->cursorX - COLS / 2; if (offsetx != 0) { columnSkip(Currentbuf, offsetx); arrangeCursor(Currentbuf); @@ -1322,8 +1335,8 @@ static void shiftvisualpos(Buffer * buf, int shift) { buf->visualpos -= shift; - if (buf->visualpos >= buf->COLS) - buf->visualpos = buf->COLS - 1; + if (buf->visualpos >= COLS) + buf->visualpos = COLS - 1; else if (buf->visualpos < 0) buf->visualpos = 0; arrangeLine(buf); @@ -1340,7 +1353,7 @@ shiftl(void) if (Currentbuf->firstLine == NULL) return; column = Currentbuf->currentColumn; - columnSkip(Currentbuf, searchKeyNum() * (- Currentbuf->COLS + 1) + 1); + columnSkip(Currentbuf, searchKeyNum() * (-COLS + 1) + 1); shiftvisualpos(Currentbuf, Currentbuf->currentColumn - column); displayBuffer(Currentbuf, B_NORMAL); } @@ -1354,7 +1367,7 @@ shiftr(void) if (Currentbuf->firstLine == NULL) return; column = Currentbuf->currentColumn; - columnSkip(Currentbuf, searchKeyNum() * (Currentbuf->COLS - 1) - 1); + columnSkip(Currentbuf, searchKeyNum() * (COLS - 1) - 1); shiftvisualpos(Currentbuf, Currentbuf->currentColumn - column); displayBuffer(Currentbuf, B_NORMAL); } @@ -1613,7 +1626,7 @@ _movL(int n) void movL(void) { - _movL(Currentbuf->COLS / 2); + _movL(COLS / 2); } void @@ -1685,7 +1698,7 @@ _movR(int n) void movR(void) { - _movR(Currentbuf->COLS / 2); + _movR(COLS / 2); } void @@ -2234,7 +2247,7 @@ reMark(void) return; } if ((p = regexCompile(str, 1)) != NULL) { - disp_message(p, TRUE); + disp_message(p, TRUE); return; } MarkString = str; @@ -2802,7 +2815,7 @@ _followForm(int submit) if (submit) goto do_submit; if (! formChooseOptionByMenu(fi, - Currentbuf->cursorX - Currentbuf->pos + a->start.pos + Currentbuf->rootX, + Currentbuf->cursorX - Currentbuf->pos + a->start.pos, Currentbuf->cursorY)) break; formUpdateBuffer(a, Currentbuf, fi); @@ -3479,9 +3492,13 @@ adBmark(void) { Str tmp; - tmp = Sprintf("file://%s/" W3MBOOKMARK_CMDNAME - "?mode=panel&bmark=%s&url=%s&title=%s", - w3m_lib_dir(), +#ifdef __EMX__ + tmp = Sprintf("file://%s/w3mbookmark.exe?mode=panel&bmark=%s&url=%s&title=%s", + get_os2_dft("W3M_LIB_DIR", LIB_DIR), +#else /* not __EMX__ */ + tmp = Sprintf("file://%s/w3mbookmark?mode=panel&bmark=%s&url=%s&title=%s", + LIB_DIR, +#endif /* not __EMX__ */ (Str_form_quote(Strnew_charp(BookmarkFile)))->ptr, (Str_form_quote(parsedURL2Str(&Currentbuf->currentURL)))->ptr, (Str_form_quote(Strnew_charp(Currentbuf->buffername)))->ptr); @@ -3558,9 +3575,9 @@ follow_map(struct parsed_tagarg *arg) a = retrieveCurrentImg(Currentbuf); if (a != NULL) - x = Currentbuf->cursorX - Currentbuf->pos + a->start.pos + Currentbuf->rootX; + x = Currentbuf->cursorX - Currentbuf->pos + a->start.pos; else - x = Currentbuf->cursorX + Currentbuf->rootX; + x = Currentbuf->cursorX; url = follow_map_menu(Currentbuf, arg, x, Currentbuf->cursorY + 2); if (url == NULL || *url == '\0') return; @@ -3999,7 +4016,7 @@ chkURL(void) "news:[^<> ][^<> ]*", "nntp://[a-zA-Z0-9][a-zA-Z0-9:%\\-\\./_]*", #endif /* USE_NNTP */ - "mailto:[^<> ][^<> ]*@[a-zA-Z0-9][a-zA-Z0-9\\-\\._]*[a-zA-Z0-9]", + "mailto:[^<> ][^<> ]*@[a-zA-Z0-9][a-zA-Z0-9\\-\\._]*[a-zA-Z0-9]", NULL, }; int i; @@ -4180,7 +4197,18 @@ curlno() disp_message(tmp->ptr, FALSE); } -#ifdef USE_MOUSE +#ifdef MOUSE +/* Addition:mouse event */ +#define MOUSE_BTN1_DOWN 0 +#define MOUSE_BTN2_DOWN 1 +#define MOUSE_BTN3_DOWN 2 +#define MOUSE_BTN4_DOWN_RXVT 3 +#define MOUSE_BTN5_DOWN_RXVT 4 +#define MOUSE_BTN4_DOWN_XTERM 64 +#define MOUSE_BTN5_DOWN_XTERM 65 +#define MOUSE_BTN_UP 3 +#define MOUSE_BTN_RESET -1 +#define MOUSE_SCROLL_LINE 5 static void process_mouse(int btn, int x, int y) @@ -4239,18 +4267,18 @@ process_mouse(int btn, int x, int y) return; } if (y == Currentbuf->cursorY && - (x == Currentbuf->cursorX + Currentbuf->rootX + (x == Currentbuf->cursorX #ifdef JP_CHARSET || (Currentbuf->currentLine != NULL && (Currentbuf->currentLine->propBuf[Currentbuf->pos] & PC_KANJI1) - && x == Currentbuf->cursorX + Currentbuf->rootX + 1) + && x == Currentbuf->cursorX + 1) #endif /* JP_CHARSET */ )) { followA(); return; } - if (x >= Currentbuf->rootX) - cursorXY(Currentbuf, x - Currentbuf->rootX, y); + + cursorXY(Currentbuf, x, y); displayBuffer(Currentbuf, B_NORMAL); } @@ -4259,12 +4287,11 @@ process_mouse(int btn, int x, int y) backBf(); break; case MOUSE_BTN3_DOWN: -#ifdef USE_MENU - if (x >= Currentbuf->rootX) - cursorXY(Currentbuf, x - Currentbuf->rootX, y); +#ifdef MENU + cursorXY(Currentbuf, x, y); onA(); mainMenu(x, y); -#endif /* USE_MENU */ +#endif /* MENU */ break; case MOUSE_BTN4_DOWN_RXVT: for (i = 0; i < MOUSE_SCROLL_LINE; i++) @@ -4374,7 +4401,7 @@ sysm_process_mouse(int x, int y, int nbs, int obs) return 0; } #endif /* USE_SYSMOUSE */ -#endif /* USE_MOUSE */ +#endif /* MOUSE */ void dispVer() @@ -4408,14 +4435,14 @@ GetWord(Buffer * buf) e = buf->pos; while (e > 0 && !IS_ALPHA(lb[e])) - e--; + e--; if (!IS_ALPHA(lb[e])) return NULL; b = e; while (b > 0 && IS_ALPHA(lb[b-1])) - b--; + b--; while (e < l->len && IS_ALPHA(lb[e])) - e++; + e++; return Strnew_charp_n(&lb[b], e - b)->ptr; } @@ -4481,6 +4508,9 @@ set_buffer_environ(Buffer *buf) Anchor *a; Str s; ParsedURL pu; + TextListItem *ti; + struct frameset *f_set = NULL; + int all; if (buf == NULL) return; @@ -4531,7 +4561,7 @@ searchKeyData(void) if (CurrentKeyData != NULL && *CurrentKeyData != '\0') return allocStr(CurrentKeyData, 0); -#ifdef USE_MENU +#ifdef MENU if (CurrentMenuData != NULL && *CurrentMenuData != '\0') return allocStr(CurrentMenuData, 0); #endif @@ -4586,17 +4616,17 @@ SigAlarm(SIGNAL_ARG) if (alarm_sec > 0) { CurrentKey = -1; CurrentKeyData = (char *)alarm_event.user_data; -#ifdef USE_MENU +#ifdef MENU CurrentMenuData = NULL; #endif w3mFuncList[alarm_event.cmd].func(); onA(); if (alarm_status == AL_IMPLICIT) { - alarm_buffer = Currentbuf; - alarm_status = AL_IMPLICIT_DONE; + alarm_buffer = Currentbuf; + alarm_status = AL_IMPLICIT_DONE; } else if (alarm_status == AL_IMPLICIT_DONE && alarm_buffer != Currentbuf) { alarm_sec = 0; - alarm_status = AL_UNSET; + alarm_status = AL_UNSET; } if (alarm_sec > 0) { signal(SIGALRM, SigAlarm); @@ -4628,7 +4658,7 @@ setAlarm(void) cmd = getFuncList(getWord(&data), w3mFuncList, w3mNFuncList); } if (cmd >= 0) { - setAlarmEvent(sec, AL_EXPLICIT, cmd, getQWord(&data)); + setAlarmEvent(sec, AL_EXPLICIT, cmd, getQWord(&data)); } else { alarm_sec = 0; } @@ -4639,12 +4669,12 @@ void setAlarmEvent(int sec, short status, int cmd, void *data) { if (status == AL_EXPLICIT || (status == AL_IMPLICIT && alarm_status != AL_EXPLICIT)) { - alarm_sec = sec; - alarm_status = status; - alarm_event.cmd = cmd; - alarm_event.user_data = data; - signal(SIGALRM, SigAlarm); - alarm(alarm_sec); + alarm_sec = sec; + alarm_status = status; + alarm_event.cmd = cmd; + alarm_event.user_data = data; + signal(SIGALRM, SigAlarm); + alarm(alarm_sec); } } #endif @@ -1,4 +1,4 @@ -/* $Id: proto.h,v 1.6 2001/11/21 19:24:35 ukai Exp $ */ +/* $Id: proto.h,v 1.3.2.1 2001/11/22 17:52:28 inu Exp $ */ /* * This file was automatically generated by version 1.7 of cextract. * Manual editing not recommended. @@ -190,7 +190,7 @@ extern void redrawNLine(Buffer * buf, int n); extern Line *redrawLine(Buffer * buf, Line * l, int i); extern int redrawLineRegion(Buffer * buf, Line * l, int i, int bpos, int epos); extern void do_effects(Lineprop m); -#ifdef USE_ANSI_COLOR +#ifdef ANSI_COLOR extern void do_color(Linecolor c); #endif extern void addChar(char c, Lineprop mode); @@ -201,7 +201,7 @@ extern void message(char *s, int return_x, int return_y); #define disp_err_message(s, f) (record_err_message((s)), disp_message((s), (f))) extern void disp_message_nsec(char *s, int redraw_current, int sec, int purge, int mouse); extern void disp_message(char *s, int redraw_current); -#ifdef USE_MOUSE +#ifdef MOUSE extern void disp_message_nomouse(char *s, int redraw_current); #else #define disp_message_nomouse disp_message @@ -223,7 +223,7 @@ extern Line *currentLineSkip(Buffer * buf, Line * line, int offset, int last); extern int gethtmlcmd(char **s, int *status); extern char *getAnchor(char *arg, char **arg_return); extern Str checkType(Str s, Lineprop * oprop, -#ifdef USE_ANSI_COLOR +#ifdef ANSI_COLOR Linecolor * ocolor, int * check_color, #endif int len); @@ -325,12 +325,12 @@ extern void underlineend(void); extern void graphstart(void); extern void graphend(void); extern int graph_ok(void); -#ifdef USE_COLOR +#ifdef COLOR extern void setfcolor(int color); -#ifdef USE_BG_COLOR +#ifdef BG_COLOR extern void setbcolor(int color); -#endif /* USE_BG_COLOR */ -#endif /* USE_COLOR */ +#endif /* BG_COLOR */ +#endif /* COLOR */ extern void refresh(void); extern void clear(void); extern void scroll(int); @@ -366,7 +366,6 @@ extern char str_to_code(char *str); extern char *code_to_str(char code); extern void put_sjis(Str os, unsigned char ub, unsigned char lb); #endif /* JP_CHARSET */ -extern void free_ssl_ctx(); extern ParsedURL *baseURL(Buffer * buf); extern int openSocket(char *hostname, char *remoteport_name, unsigned short remoteport_num); extern void parseURL(char *url, ParsedURL * p_url, ParsedURL * current); @@ -376,16 +375,13 @@ extern Str parsedURL2Str(ParsedURL * pu); extern int getURLScheme(char **url); extern void init_stream(URLFile *uf, int scheme, InputStream stream); extern URLFile openURL(char *url, ParsedURL * pu, ParsedURL * current, URLOption * option, FormList * request, TextList * extra_header, URLFile * ouf, unsigned char *status); -extern char *guessContentType(char *filename); -extern TextList* make_domain_list(char *domain_list); -extern int check_no_proxy(char *domain); -extern char *filename_extension(char *path, int is_url); extern int mailcapMatch(struct mailcap *mcap, char *type); extern struct mailcap *loadMailcap(char *filename); extern struct mailcap *searchMailcap(struct mailcap *table, char *type); extern void initMailcap(); extern struct mailcap *searchExtViewer(char *type); extern Str unquote_mailcap(char *qstr, char *type, char *name, char *attr, int *stat); +extern char *guessContentTypeFromTable(struct table2 *table, char *filename); extern char *guessContentType(char *filename); extern TextList *make_domain_list(char *domain_list); extern int check_no_proxy(char *domain); @@ -431,7 +427,6 @@ extern char *libFile(char *base); extern char *helpFile(char *base); extern void setLocalCookie(void); extern Buffer *dirBuffer(char *dirname); -extern void set_environ(char *var, char *value); extern FILE *localcgi_post(char *, char *, FormList *, char*); extern FILE *localcgi_get(char *, char *, char*); extern Str find_auth_cookie(char *host, char *realm); @@ -473,17 +468,17 @@ extern void reMark(void); #define reMark nulcmd #endif /* not USE_MARK */ -#ifdef USE_MOUSE +#ifdef MOUSE extern void mouse(void); extern void mouse_init(void); extern void mouse_end(void); extern void mouse_active(void); extern void mouse_inactive(void); extern void msToggle(void); -#else /* not USE_MOUSE */ +#else /* not MOUSE */ #define mouse nulcmd #define msToggle nulcmd -#endif /* not USE_MOUSE */ +#endif /* not MOUSE */ extern char *searchKeyData(void); @@ -496,7 +491,7 @@ extern KeyListItem *searchKeyList(KeyList *list, int key); extern char *getWord(char **str); extern char *getQWord(char **str); -#ifdef USE_MENU +#ifdef MENU extern void new_menu(Menu * menu, MenuItem * item); extern void geom_menu(Menu * menu, int x, int y, int select); extern void draw_all_menu(Menu * menu); @@ -521,10 +516,10 @@ extern void mainMn(void); extern void selMn(void); extern void optionMenu(int x, int y, char **label, int *variable, int initial, void (*func) ()); extern void initMenu(void); -#else /* not USE_MENU */ +#else /* not MENU */ #define mainMn nulcmd #define selMn selBuf -#endif /* not USE_MENU */ +#endif /* not MENU */ #ifdef DICT extern void dictword(void); diff --git a/scripts/dirlist.cgi b/scripts/dirlist.cgi new file mode 100644 index 0000000..618d4e5 --- /dev/null +++ b/scripts/dirlist.cgi @@ -0,0 +1,532 @@ +#!/usr/local/bin/perl +# +# Directory list CGI by Hironori Sakamoto (hsaka@mth.biglobe.ne.jp) +# + +if ( $^O =~ /^(ms)?(dos|win(32|nt)?)/i ) { + $WIN32 = 1; + $CYGPATH = 1; +} +elsif ( $^O =~ /cygwin|os2/i ) { + $WIN32 = 1; + $CYGPATH = 0; +} +else { + $WIN32 = 0; + $CYGPATH = 0; +} +$RC_DIR = '~/.w3m/'; + +$RC_DIR =~ s@^~/@$ENV{'HOME'}/@; +if ($CYGPATH) { + $RC_DIR = &cygwin_pathconv("$RC_DIR"); +} +$CONFIG = "$RC_DIR/dirlist"; +$CGI = $ENV{'SCRIPT_NAME'} || $0; +$CGI = "file://" . &file_encode("$CGI"); + +$AFMT = '<a href="%s"><nobr>%s</nobr></a>'; +$NOW = time(); + +@OPT = &init_option($CONFIG); + +$query = $ENV{'QUERY_STRING'}; +$cmd = ''; +$cgi = 0; +if ($query eq '') { + $_ = `pwd`; + chop; + s/\r$//; + $dir = $_; + $cgi = 0; +} elsif ($query =~ /^(opt\d+|dir|cmd)=/) { + foreach(split(/\&/, $query)) { + if (s/^dir=//) { + $dir = &form_decode($_); + } elsif (s/^opt(\d+)=//) { + $OPT[$1] = $_; + } elsif (s/^cmd=//) { + $cmd = $_; + } + } + $cgi = 1; +} else { + $dir = $query; + if (($dir !~ m@^/@) && + ($WIN32 && $dir !~ /^[a-z]:/i)) { + $_ = `pwd`; + chop; + s/\r$//; + $dir = "$_/$dir"; + } + $cgi = -1; +} +if ($dir !~ m@/$@) { + $dir .= '/'; +} +if ($dir =~ m@^/@ && $CYGPATH) { + $dir = &cygwin_pathconv("$dir"); +} +$ROOT = ''; +if ($WIN32) { + if (($dir =~ s@^//[^/]+@@) || ($dir =~ s@^[a-z]:@@i)) { + $ROOT = $&; + } + if ($CYGPATH) { + $ROOT = &cygwin_pathconv("$ROOT"); + } +} +if ($cgi) { + $dir = &cleanup($dir); +} + +$TYPE = $OPT[$OPT_TYPE]; +$FORMAT = $OPT[$OPT_FORMAT]; +$SORT = $OPT[$OPT_SORT]; +if ($cmd) { + &update_option($CONFIG); +} + +$qdir = "$ROOT" . &html_quote("$dir"); +$edir = "$ROOT" . &file_encode("$dir"); +if (! opendir(DIR, "$ROOT$dir")) { + print <<EOF; +Content-Type: text/html + +<html> +<head> +<title>Directory list of $qdir</title> +</head> +<body> +<b>$qdir</b>: $! ! +</body> +</html> +EOF + exit 1; +} + +# ($cgi > 0) && print <<EOF; +# w3m-control: DELETE_PREVBUF +# EOF +print <<EOF; +Content-Type: text/html + +<html> +<head> +<title>Directory list of $qdir</title> +</head> +<body> +<h1>Directory list of $qdir</h1> +EOF +&print_form($edir, @OPT); +print <<EOF; +<hr> +EOF +$dir =~ s@/$@@; +@sdirs = split('/', $dir); +$_ = $sdirs[0]; +if ($_ eq '') { + $_ = '/'; +} +if ($TYPE eq $TYPE_TREE) { + print <<EOF; +<table hborder width="640"> +<tr valign=top><td width="160"> +<pre> +EOF + $q = "$ROOT". &html_quote("$_"); + $e = "$ROOT" . &file_encode("$_"); + if ($dir =~ m@^$@) { + $n = "\" name=\"current"; + } else { + $n = ''; + } + printf("$AFMT\n", "$e$n", "<b>$q</b>"); + $N = 0; + $SKIPLINE = ""; + + &left_dir('', @sdirs); + + print <<EOF; +</pre> +</td><td width="400"> +<pre>$SKIPLINE +EOF +} else { + print <<EOF; +<pre> +EOF +} + +&right_dir($dir); + +if ($TYPE eq $TYPE_TREE) { + print <<EOF; +</pre> +</td></tr> +</table> +</body> +</html> +EOF +} else { + print <<EOF; +</pre> +</body> +</html> +EOF +} + +sub left_dir { + local($pre, $dir, @sdirs) = @_; + local($ok) = (@sdirs == 0); + local(@cdirs) = (); + local($_, $dir0, $d, $qdir, $q, $edir, $e); + + $dir0 = "$dir/"; + $dir = "$dir0"; + opendir(DIR, "$ROOT$dir") || return; + + foreach(sort readdir(DIR)) { + -d "$ROOT$dir$_" || next; + /^\.$/ && next; + /^\.\.$/ && next; + push(@cdirs, $_); + } + closedir(DIR); + + $qdir = "$ROOT" . &html_quote($dir); + $edir = "$ROOT" . &file_encode($dir); + while(@cdirs) { + $_ = shift @cdirs; + $q = &html_quote($_); + $e = &file_encode($_); + $N++; + if (!$ok && $_ eq $sdirs[0]) { + $d = $dir0 . shift @sdirs; + if (!@sdirs) { + $n = "\" name=\"current"; + $SKIPLINE = "\n" x $N; + } else { + $n = ''; + } + printf("${pre}o-$AFMT\n", "$edir$e$n", "<b>$q</b>"); + &left_dir(@cdirs ? "$pre| " : "$pre ", $d, @sdirs); + $ok = 1; + } else { + printf("${pre}+-$AFMT\n", "$edir$e", $q); + } + } +} + +sub right_dir { + local($dir) = @_; + local(@list); + local($_, $qdir, $q, $edir, $e, $f, $max, @d, $type, $u, $g); + local($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, + $atime,$mtime,$ctime,$blksize,$blocks); + local(%sizes, %ctimes, %prints); + + $dir = "$dir/"; + opendir(DIR, "$ROOT$dir") || return; + + $qdir = "$ROOT" . &html_quote($dir); + $edir = "$ROOT" . &file_encode($dir); + if ($TYPE eq $TYPE_TREE) { + print "<b>$qdir</b>\n"; + } + @list = (); + $max = 0; + foreach(readdir(DIR)) { + /^\.$/ && next; +# if ($TYPE eq $TYPE_TREE) { +# /^\.\.$/ && next; +# } + $f = "$ROOT$dir$_"; + (($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, + $atime,$mtime,$ctime,$blksize,$blocks) = lstat($f)) || next; + push(@list, $_); + $sizes{$_} = $size; + $ctimes{$_} = $ctime; + + if ($FORMAT eq $FORMAT_COLUMN) { + if (length($_) > $max) { + $max = length($_); + } + next; + } + $type = &utype($mode); + if ($FORMAT eq $FORMAT_SHORT) { + $prints{$_} = sprintf("%-6s ", "[$type]"); + next; + } + if ($type =~ /^[CB]/) { + $size = sprintf("%3u, %3u", ($rdev >> 8) & 0xff, $rdev & 0xffff00ff); + } + if ($FORMAT eq $FORMAT_LONG) { + $u = $USER{$uid} || ($USER{$uid} = getpwuid($uid) || $uid); + $g = $GROUP{$gid} || ($GROUP{$gid} = getgrgid($gid) || $gid); + $prints{$_} = sprintf( "%s %-8s %-8s %8s %s ", + &umode($mode), $u, $g, $size, &utime($ctime)); +# } elsif ($FORMAT eq $FORMAT_STANDARD) { + } else { + $prints{$_} = sprintf("%-6s %8s %s ", "[$type]", $size, &utime($ctime)); + } + } + closedir(DIR); + if ($SORT eq $SORT_SIZE) { + @list = sort { $sizes{$b} <=> $sizes{$a} || $a <=> $b } @list; + } elsif ($SORT eq $SORT_TIME) { + @list = sort { $ctimes{$b} <=> $ctimes{$a} || $a <=> $b } @list; + } else { + @list = sort @list; + } + if ($FORMAT eq $FORMAT_COLUMN) { + local($COLS, $l, $nr, $n); + if ($TYPE eq $TYPE_TREE) { + $COLS = 60; + } else { + $COLS = 80; + } + $l = int($COLS / ($max + 2)) || 1; + $nr = int($#list / $l + 1); + $n = 0; + print "<table>\n<tr valign=top>"; + foreach(@list) { + $f = "$ROOT$dir$_"; + $q = &html_quote($_); + $e = &file_encode($_); + if ($n % $nr == 0) { + print "<td>"; + } + if (-d $f) { + printf($AFMT, "$edir$e", "$q/"); + } else { + printf($AFMT, "$edir$e", $q); + } + $n++; + if ($n % $nr == 0) { + print "</td>\n"; + } else { + print "<br>\n"; + } + } + print "</tr></table>\n"; + return; + } + foreach(@list) { + $f = "$ROOT$dir$_"; + $q = &html_quote($_); + $e = &file_encode($_); + print $prints{$_}; + if (-d $f) { + printf($AFMT, "$edir$e", "$q/"); + } else { + printf($AFMT, "$edir$e", $q); + } + if (-l $f) { + print " -> ", &html_quote(readlink($f)); + } + print "\n"; + } +} + +sub init_option { + local($config) = @_; + $OPT_TYPE = 0; + $OPT_FORMAT = 1; + $OPT_SORT = 2; + $TYPE_TREE = 't'; + $TYPE_STANDARD = 'd'; + $FORMAT_SHORT = 's'; + $FORMAT_STANDARD = 'd'; + $FORMAT_LONG = 'l'; + $FORMAT_COLUMN = 'c'; + $SORT_NAME = 'n'; + $SORT_SIZE = 's'; + $SORT_TIME = 't'; + local(@opt) = ($TYPE_TREE, $FORMAT_STANDARD, $SORT_NAME); + local($_); + + open(CONFIG, "< $config") || return @opt; + while(<CONFIG>) { + chop; + s/^\s+//; + tr/A-Z/a-z/; + if (/^type\s+(\S)/i) { + $opt[$OPT_TYPE] = $1; + } elsif (/^format\s+(\S)/i) { + $opt[$OPT_FORMAT] = $1 + } elsif (/^sort\s+(\S)/i) { + $opt[$OPT_SORT] = $1; + } + } + close(CONFIG); + return @opt; +} + +sub update_option { + local($config) = @_; + + open(CONFIG, "> $config") || return; + print CONFIG <<EOF; +type $TYPE +format $FORMAT +sort $SORT +EOF + close(CONFIG); +} + +sub print_form { + local($d, @OPT) = @_; + local(@disc) = ('Type', 'Format', 'Sort'); + local(@val) = ( + "('t', 'd')", + "('s', 'd', 'c')", + "('n', 's', 't')", + ); + local(@opt) = ( + "('Tree', 'Standard')", + "('Short', 'Standard', 'Column')", + "('By Name', 'By Size', 'By Time')" + ); + local($_, @vs, @os, $v, $o); + + print <<EOF; +<form action=\"$CGI\"> +<center> +<table> +<tr valign=top> +EOF + foreach(0 .. 2) { + print "<td align> $disc[$_]</td>\n"; + } + print "</tr><tr>\n"; + foreach(0 .. 2) { + print "<td><select name=opt$_>\n"; + eval "\@vs = $val[$_]"; + eval "\@os = $opt[$_]"; + foreach $v (@vs) { + $o = shift(@os); + if ($v eq $OPT[$_]) { + print "<option value=$v selected>$o\n"; + } else { + print "<option value=$v>$o\n"; + } + } + print "</select></td>\n"; + } + print <<EOF; +<td><input type=submit name=cmd value="Update"></td> +</tr> +</table> +</center> +<input type=hidden name=dir value="$d"> +</form> +EOF +} + +sub html_quote { + local($_) = @_; + local(%QUOTE) = ( + '<', '<', + '>', '>', + '&', '&', + '"', '"', + ); + s/[<>&"]/$QUOTE{$&}/g; + return $_; +} +sub file_encode { + local($_) = @_; + s/[\000-\040\+:#?&%<>"\177-\377]/sprintf('%%%02X', unpack('C', $&))/eg; + return $_; +} + +sub form_decode { + local($_) = @_; + s/\+/ /g; + s/%([\da-f][\da-f])/pack('C', hex($1))/egi; + return $_; +} + +sub cleanup { + local($_) = @_; + + s@//+@/@g; + s@/\./@/@g; + while(m@/\.\./@) { + s@^/(\.\./)+@/@; + s@/[^/]+/\.\./@/@; + } + return $_; +} + +sub utype { + local($_) = @_; + local(%T) = ( + 0010000, 'PIPE', + 0020000, 'CHR', + 0040000, 'DIR', + 0060000, 'BLK', + 0100000, 'FILE', + 0120000, 'LINK', + 0140000, 'SOCK', + ); + return $T{($_ & 0170000)} || 'FILE'; +} + +sub umode { + local($_) = @_; + local(%T) = ( + 0010000, 'p', + 0020000, 'c', + 0040000, 'd', + 0060000, 'b', + 0100000, '-', + 0120000, 'l', + 0140000, 's', + ); + + return ($T{($_ & 0170000)} || '-') + . (($_ & 00400) ? 'r' : '-') + . (($_ & 00200) ? 'w' : '-') + . (($_ & 04000) ? 's' : + (($_ & 00100) ? 'x' : '-')) + . (($_ & 00040) ? 'r' : '-') + . (($_ & 00020) ? 'w' : '-') + . (($_ & 02000) ? 's' : + (($_ & 00010) ? 'x' : '-')) + . (($_ & 00004) ? 'r' : '-') + . (($_ & 00002) ? 'w' : '-') + . (($_ & 01000) ? 't' : + (($_ & 00001) ? 'x' : '-')); +} + +sub utime { + local($_) = @_; + local(@MON) = ( + 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', + 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' + ); + local($sec,$min,$hour,$mday,$mon, + $year,$wday,$yday,$isdst) = localtime($_); + + if ($_ > $NOW - 182*24*60*60 && $_ < $NOW + 183*24*60*60) { + return sprintf("%3s %2d %.2d:%.2d", $MON[$mon], $mday, $hour, $min); + } else { + return sprintf("%3s %2d %5d", $MON[$mon], $mday, 1900+$year); + } +} + +sub cygwin_pathconv { + local($_) = @_; + local(*CYGPATH); + + open(CYGPATH, '-|') or exec('cygpath', '-w', $_); + $_ = <CYGPATH>; + close(CYGPATH); + s/\r?\n$//; + s!\\!/!g; + s!/$!!; + return $_; +} @@ -1,4 +1,3 @@ -/* $Id: search.c,v 1.3 2001/11/20 17:49:23 ukai Exp $ */ #include "fm.h" #include "regex.h" @@ -15,10 +14,8 @@ forwardSearch(Buffer * buf, char *str) return FALSE; } l = begin = buf->currentLine; - if (l == NULL) { - disp_message("Not found", FALSE); - return FALSE; - } + if (l == NULL) + return FALSE; pos = buf->pos + 1; #ifdef JP_CHARSET if (l->propBuf[pos] & PC_KANJI2) @@ -83,10 +80,8 @@ backwardSearch(Buffer * buf, char *str) return FALSE; } l = begin = buf->currentLine; - if (l == NULL) { - disp_message("Not found", FALSE); - return FALSE; - } + if (l == NULL) + return FALSE; if (buf->pos > 0) { pos = buf->pos - 1; #ifdef JP_CHARSET @@ -1,4 +1,4 @@ -/* $Id: terms.c,v 1.14 2001/11/22 15:02:17 ukai Exp $ */ +/* $Id: terms.c,v 1.5.2.1 2001/11/22 17:52:28 inu Exp $ */ /* * An original curses library for EUC-kanji by Akinori ITO, December 1989 * revised by Akinori ITO, January 1995 @@ -12,10 +12,7 @@ #include <unistd.h> #include "config.h" #include <string.h> -#ifdef HAVE_SYS_SELECT_H -#include <sys/select.h> -#endif -#ifdef USE_MOUSE +#ifdef MOUSE #ifdef USE_GPM #include <gpm.h> #endif /* USE_GPM */ @@ -35,9 +32,11 @@ static int xpix, ypix, nbs, obs = 0; static int is_xterm = 0; void mouse_init(), mouse_end(); int mouseActive = 0; -#endif /* USE_MOUSE */ +#endif /* MOUSE */ -static int tty; +#ifdef AIX +#include <sys/select.h> +#endif /* AIX */ #include "terms.h" #include "fm.h" @@ -46,180 +45,13 @@ static int tty; #ifdef __EMX__ #define INCL_DOSNLS #include <os2.h> +#include <sys/select.h> #ifndef JP_CHARSET extern int CodePage; #endif /* !JP_CHARSET */ #endif /* __EMX__ */ -#if defined(__CYGWIN__) -#include <windows.h> -static HANDLE hConIn; -static int isWin95; -static INPUT_RECORD *ConInV; -static int iConIn, nConIn, nConInMax; -#ifdef USE_MOUSE -static char MouseConToXTerm[sizeof("\033[M !!") - sizeof("")]; -static int iMouseConToXTerm; -static MOUSE_EVENT_RECORD lastConMouse; -#endif - -void -check_win32_console(void) -{ - char *tty; - - tty = ttyname(1); - if (!strncmp(tty, "/dev/con", 8)) { - isWinConsole = TRUE; - } - else { - isWinConsole = FALSE; - } -} - -void -init_win32_console_handle(void) -{ - OSVERSIONINFO winVersionInfo; - - check_win32_console(); - winVersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - if (GetVersionEx (&winVersionInfo) == 0) { - fprintf(stderr, "can't get Windows version information.\n"); - exit(1); - } - if (winVersionInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) { - isWin95 = 1; - } - hConIn = INVALID_HANDLE_VALUE; - if (isWin95) { - if (isWinConsole) { - if (isatty(0)) { - hConIn = GetStdHandle(STD_INPUT_HANDLE); - } - else { - hConIn = CreateFile("CONIN$", GENERIC_READ, - FILE_SHARE_READ, - NULL, OPEN_EXISTING, - 0, NULL); - } - } - } -} - -static int -read_win32_console_input(void) -{ - INPUT_RECORD *p; - DWORD nevents; - - if (nConIn >= nConInMax) { - INPUT_RECORD *oldv; - - nConInMax = (nConInMax / 2 + 1) * 3; - oldv = ConInV; - ConInV = GC_MALLOC_ATOMIC(sizeof(ConInV[0]) * nConInMax); - memcpy(ConInV, oldv, sizeof(ConInV[0]) * nConIn); - } - - p = &ConInV[nConIn]; - - if (ReadConsoleInput(hConIn, p, 1, &nevents) && nevents) { - switch (p->EventType) { - case KEY_EVENT: - if (p->Event.KeyEvent.bKeyDown - || !p->Event.KeyEvent.uChar.AsciiChar) - break; -#ifdef USE_MOUSE - event_found: -#endif - ++nConIn; - return 1; -#ifdef USE_MOUSE - case MOUSE_EVENT: - if (mouseActive && p->Event.MouseEvent.dwButtonState & ~(~0 << 5)) - goto event_found; -#endif - default: - break; - } - } - return 0; -} - -int -read_win32_console(char *s, int n) -{ - int i; - KEY_EVENT_RECORD *ker; -#ifdef USE_MOUSE - int down, btn; - MOUSE_EVENT_RECORD *mer; -#endif - - if (hConIn == INVALID_HANDLE_VALUE) - return read(tty, s, n); - - for (i = 0 ; i < n ;) -#ifdef USE_MOUSE - if (iMouseConToXTerm) { - s[i++] = MouseConToXTerm[iMouseConToXTerm++]; - - if (iMouseConToXTerm >= sizeof(MouseConToXTerm)) - iMouseConToXTerm = 0; - } - else -#endif - if (iConIn < nConIn) - switch (ConInV[iConIn].EventType) { -#ifdef USE_MOUSE - case MOUSE_EVENT: - if (mouseActive) { - mer = &ConInV[iConIn++].Event.MouseEvent; - MouseConToXTerm[0] = '\033'; - MouseConToXTerm[1] = '['; - MouseConToXTerm[2] = 'M'; - MouseConToXTerm[4] = mer->dwMousePosition.X + '!'; - MouseConToXTerm[5] = mer->dwMousePosition.Y + '!'; - if (~(mer->dwButtonState) & lastConMouse.dwButtonState) - MouseConToXTerm[3] = MOUSE_BTN_UP + ' '; - else if (!(down = mer->dwButtonState & ~lastConMouse.dwButtonState & ~(~0 << 5))) { - lastConMouse = *mer; - break; - } - else - MouseConToXTerm[3] = (down & (1 << 0) ? MOUSE_BTN1_DOWN : - down & (1 << 1) ? MOUSE_BTN3_DOWN : - down & (1 << 2) ? MOUSE_BTN2_DOWN : - down & (1 << 3) ? MOUSE_BTN4_DOWN_XTERM : - MOUSE_BTN5_DOWN_XTERM) + ' '; - - s[i++] = MouseConToXTerm[iMouseConToXTerm++]; - lastConMouse = *mer; - } - else - ++iConIn; - break; -#endif - default: - s[i++] = ConInV[iConIn++].Event.KeyEvent.uChar.AsciiChar; - break; - } - else { - iConIn = nConIn = 0; - - if (!read_win32_console_input()) - break; - } - - if (iConIn >= nConIn) - iConIn = nConIn = 0; - - return i; -} -#endif - char *getenv(const char *); MySignalHandler reset_exit(SIGNAL_ARG), error_dump(SIGNAL_ARG); void setlinescols(void); @@ -229,7 +61,7 @@ void flush_tty(); #define SIGIOT SIGABRT #endif /* not SIGIOT */ -#ifdef HAVE_TERMIO_H +#ifdef TERMIO #include <sys/ioctl.h> #include <termio.h> typedef struct termio TerminalMode; @@ -237,9 +69,9 @@ typedef struct termio TerminalMode; #define TerminalGet(fd,x) ioctl(fd,TCGETA,x) #define MODEFLAG(d) ((d).c_lflag) #define IMODEFLAG(d) ((d).c_iflag) -#endif /* HAVE_TERMIO_H */ +#endif /* TERMIO */ -#ifdef HAVE_TERMIOS_H +#ifdef TERMIOS #include <termios.h> #include <unistd.h> typedef struct termios TerminalMode; @@ -247,16 +79,16 @@ typedef struct termios TerminalMode; #define TerminalGet(fd,x) tcgetattr(fd,x) #define MODEFLAG(d) ((d).c_lflag) #define IMODEFLAG(d) ((d).c_iflag) -#endif /* HAVE_TERMIOS_H */ +#endif /* TERMIOS */ -#ifdef HAVE_SGTTY_H +#ifdef SGTTY #include <sys/ioctl.h> #include <sgtty.h> typedef struct sgttyb TerminalMode; #define TerminalSet(fd,x) ioctl(fd,TIOCSETP,x) #define TerminalGet(fd,x) ioctl(fd,TIOCGETP,x) #define MODEFLAG(d) ((d).sg_flags) -#endif /* HAVE_SGTTY_H */ +#endif /* SGTTY */ #define MAX_LINE 200 #define MAX_COLUMN 400 @@ -295,7 +127,7 @@ typedef struct sgttyb TerminalMode; #define S_COLORED 0xf00 -#ifdef USE_BG_COLOR +#ifdef BG_COLOR /* Background Color */ #define COL_BCOLOR 0xf000 #define COL_BBLACK 0x8000 @@ -309,7 +141,7 @@ typedef struct sgttyb TerminalMode; #define COL_BTERM 0x0000 #define S_BCOLORED 0xf000 -#endif /* USE_BG_COLOR */ +#endif /* BG_COLOR */ #define S_GRAPHICS 0x10 @@ -352,9 +184,6 @@ char *T_cd, *T_ce, *T_kr, *T_kl, *T_cr, *T_bt, *T_ta, *T_sc, *T_rc, *T_ti, *T_te, *T_nd, *T_as, *T_ae, *T_eA, *T_ac, *T_op; int LINES, COLS; -#if defined(CYGWIN) && LANG == JA -int LASTLINE; -#endif /* defined(CYGWIN) && LANG == JA */ static int max_LINES = 0, max_COLS = 0; static int tab_step = 8; static int CurLine, CurColumn; @@ -390,7 +219,7 @@ writestr(char *s) #define MOVE(line,column) writestr(tgoto(T_cm,column,line)); -#ifdef USE_MOUSE +#ifdef MOUSE static char *xterm_mouse_term[] = { "xterm", "kterm", "rxvt", "cygwin", NULL @@ -401,31 +230,35 @@ int set_tty(void) { char *ttyn; +#ifdef MOUSE + char *term; +#endif if (isatty(0)) /* stdin */ ttyn = ttyname(0); else - ttyn = DEV_TTY_PATH; +#ifndef __EMX__ + ttyn = "/dev/tty"; +#else /* __EMX__ */ + ttyn = "con"; +#endif /* __EMX__ */ tty = open(ttyn, O_RDWR); if (tty < 0) { /* use stderr instead of stdin... is it OK???? */ tty = 2; } ttyf = fdopen(tty, "w"); -#ifdef __CYGWIN__ - init_win32_console_handle(); -#endif TerminalGet(tty, &d_ioval); -#ifdef USE_MOUSE +#ifdef MOUSE + term = getenv("TERM"); { - char *term = getenv("TERM"); - char **p; - for (p = xterm_mouse_term; *p != NULL; p++) { - if (!strncmp(term, *p, strlen(*p))) { - is_xterm = 1; - break; - } - } + char **p; + for (p = xterm_mouse_term; *p != NULL; p++) { + if (!strncmp(term, *p, strlen(*p))) { + is_xterm = 1; + break; + } + } } #endif return 0; @@ -438,9 +271,9 @@ ttymode_set(int mode, int imode) TerminalGet(tty, &ioval); MODEFLAG(ioval) |= mode; -#ifndef HAVE_SGTTY_H +#ifndef SGTTY IMODEFLAG(ioval) |= imode; -#endif /* not HAVE_SGTTY_H */ +#endif /* not SGTTY */ while (TerminalSet(tty, &ioval) == -1) { if (errno == EINTR || errno == EAGAIN) continue; @@ -456,9 +289,9 @@ ttymode_reset(int mode, int imode) TerminalGet(tty, &ioval); MODEFLAG(ioval) &= ~mode; -#ifndef HAVE_SGTTY_H +#ifndef SGTTY IMODEFLAG(ioval) &= ~imode; -#endif /* not HAVE_SGTTY_H */ +#endif /* not SGTTY */ while (TerminalSet(tty, &ioval) == -1) { if (errno == EINTR || errno == EAGAIN) continue; @@ -467,7 +300,7 @@ ttymode_reset(int mode, int imode) } } -#ifndef HAVE_SGTTY_H +#ifndef SGTTY void set_cc(int spec, int val) { @@ -481,7 +314,7 @@ set_cc(int spec, int val) reset_exit(SIGNAL_ARGLIST); } } -#endif /* not HAVE_SGTTY_H */ +#endif /* not SGTTY */ void close_tty(void) @@ -515,10 +348,10 @@ MySignalHandler reset_exit(SIGNAL_ARG) { reset_tty(); -#ifdef USE_MOUSE +#ifdef MOUSE if (mouseActive) mouse_end(); -#endif /* USE_MOUSE */ +#endif /* MOUSE */ w3m_exit(0); SIGNAL_RETURN; } @@ -580,12 +413,11 @@ getTCstr(void) char *pt = funcstr; int r; - ent = getenv("TERM") ? getenv("TERM") : DEFAULT_TERM; - if (ent == NULL) { - fprintf(stderr, "TERM is not set\n"); - reset_exit(SIGNAL_ARGLIST); - } - +#ifdef __DJGPP__ + ent = getenv("TERM") ? getenv("TERM") : "dosansi"; +#else + ent = getenv("TERM"); +#endif /* __DJGPP__ */ r = tgetent(bp, ent); if (r != 1) { /* Can't find termcap entry */ @@ -680,7 +512,7 @@ setlinescols(void) } #endif } -#elif defined(HAVE_TERMIOS_H) && defined(TIOCGWINSZ) +#elif defined(TERMIOS) && defined(TIOCGWINSZ) struct winsize wins; i = ioctl(tty, TIOCGWINSZ, &wins); @@ -688,7 +520,9 @@ setlinescols(void) LINES = wins.ws_row; COLS = wins.ws_col; } -#endif /* defined(HAVE-TERMIOS_H) && defined(TIOCGWINSZ) */ +#endif /* defined(TERMIOS) && defined(TIOCGWINSZ) + * + */ if (LINES <= 0 && (p = getenv("LINES")) != NULL && (i = atoi(p)) >= 0) @@ -705,9 +539,6 @@ setlinescols(void) COLS = MAX_COLUMN; if (LINES > MAX_LINE) LINES = MAX_LINE; -#if defined(CYGWIN) && LANG == JA - LASTLINE = LINES - (isWinConsole ? 2 : 1); -#endif /* defined(CYGWIN) && LANG == JA */ } void @@ -878,11 +709,11 @@ move(int line, int column) CurColumn = column; } -#ifdef USE_BG_COLOR +#ifdef BG_COLOR #define M_SPACE (S_SCREENPROP|S_COLORED|S_BCOLORED|S_GRAPHICS) -#else /* not USE_BG_COLOR */ +#else /* not BG_COLOR */ #define M_SPACE (S_SCREENPROP|S_COLORED|S_GRAPHICS) -#endif /* not USE_BG_COLOR */ +#endif /* not BG_COLOR */ static int need_redraw(char c1, l_prop pr1, char c2, l_prop pr2) @@ -1154,7 +985,7 @@ color_seq(int colmode) return seqbuf; } -#ifdef USE_BG_COLOR +#ifdef BG_COLOR void setbcolor(int color) { @@ -1170,16 +1001,16 @@ bcolor_seq(int colmode) sprintf(seqbuf, "\033[%dm", ((colmode >> 12) & 7) + 40); return seqbuf; } -#endif /* USE_BG_COLOR */ +#endif /* BG_COLOR */ #define RF_NEED_TO_MOVE 0 #define RF_CR_OK 1 #define RF_NONEED_TO_MOVE 2 -#ifdef USE_BG_COLOR +#ifdef BG_COLOR #define M_MEND (S_STANDOUT|S_UNDERLINE|S_BOLD|S_COLORED|S_BCOLORED|S_GRAPHICS) -#else /* not USE_BG_COLOR */ +#else /* not BG_COLOR */ #define M_MEND (S_STANDOUT|S_UNDERLINE|S_BOLD|S_COLORED|S_GRAPHICS) -#endif /* not USE_BG_COLOR */ +#endif /* not BG_COLOR */ void refresh(void) { @@ -1189,9 +1020,9 @@ refresh(void) char *pc; l_prop *pr, mode = 0; l_prop color = COL_FTERM; -#ifdef USE_BG_COLOR +#ifdef BG_COLOR l_prop bcolor = COL_BTERM; -#endif /* USE_BG_COLOR */ +#endif /* BG_COLOR */ short *dirty; for (line = 0; line <= LASTLINE; line++) { @@ -1260,25 +1091,25 @@ refresh(void) * avoid the scroll, I prohibit to draw character on * (COLS-1,LINES-1). */ -#if !defined(USE_BG_COLOR) || defined(__CYGWIN__) -#if defined(__CYGWIN__) && LANG == JA +#if !defined( BG_COLOR ) || defined( CYGWIN ) +#ifdef CYGWIN if (isWinConsole) -#endif /* defined(__CYGWIN__) && LANG == JA */ +#endif if (line == LINES - 1 && col == COLS - 1) break; -#endif /* !defined(USE_BG_COLOR) || defined(__CYGWIN__) */ +#endif /* not BG_COLOR */ if ((!(pr[col] & S_STANDOUT) && (mode & S_STANDOUT)) || (!(pr[col] & S_UNDERLINE) && (mode & S_UNDERLINE)) || (!(pr[col] & S_BOLD) && (mode & S_BOLD)) || (!(pr[col] & S_COLORED) && (mode & S_COLORED)) -#ifdef USE_BG_COLOR +#ifdef BG_COLOR || (!(pr[col] & S_BCOLORED) && (mode & S_BCOLORED)) -#endif /* USE_BG_COLOR */ +#endif /* BG_COLOR */ || (!(pr[col] & S_GRAPHICS) && (mode & S_GRAPHICS))) { if ((mode & S_COLORED) -#ifdef USE_BG_COLOR +#ifdef BG_COLOR || (mode & S_BCOLORED) -#endif /* USE_BG_COLOR */ +#endif /* BG_COLOR */ ) writestr(T_op); if (mode & S_GRAPHICS) @@ -1310,13 +1141,13 @@ refresh(void) mode = ((mode & ~COL_FCOLOR) | color); writestr(color_seq(color)); } -#ifdef USE_BG_COLOR +#ifdef BG_COLOR if ((pr[col] & S_BCOLORED) && (pr[col] ^ mode) & COL_BCOLOR) { bcolor = (pr[col] & COL_BCOLOR); mode = ((mode & ~COL_BCOLOR) | bcolor); writestr(bcolor_seq(bcolor)); } -#endif /* USE_BG_COLOR */ +#endif /* BG_COLOR */ if ((pr[col] & S_GRAPHICS) && !(mode & S_GRAPHICS)) { if (!graph_enabled) { graph_enabled = 1; @@ -1337,9 +1168,9 @@ refresh(void) *dirty &= ~(L_NEED_CE | L_CLRTOEOL); if (mode & M_MEND) { if (mode & (S_COLORED -#ifdef USE_BG_COLOR +#ifdef BG_COLOR | S_BCOLORED -#endif /* USE_BG_COLOR */ +#endif /* BG_COLOR */ )) writestr(T_op); if (mode & S_GRAPHICS) @@ -1502,7 +1333,7 @@ clrtoeol(void) } } -#ifdef USE_BG_COLOR +#ifdef BG_COLOR void clrtoeol_with_bcolor(void) { @@ -1528,14 +1359,14 @@ clrtoeolx(void) { clrtoeol_with_bcolor(); } -#else /* not USE_BG_COLOR */ +#else /* not BG_COLOR */ void clrtoeolx(void) { clrtoeol(); } -#endif /* not USE_BG_COLOR */ +#endif /* not BG_COLOR */ void clrtobot_eol(void (*clrtoeol) ()) @@ -1643,38 +1474,38 @@ addnstr_sup(char *s, int n) void crmode(void) -#ifndef HAVE_SGTTY_H +#ifndef SGTTY { ttymode_reset(ICANON, IXON); ttymode_set(ISIG, 0); -#ifdef HAVE_TERMIOS_H +#ifdef TERMIOS set_cc(VMIN, 1); -#else /* not HAVE_TERMIOS_H */ +#else /* not TERMIOS */ set_cc(VEOF, 1); -#endif /* not HAVE_TERMIOS_H */ +#endif /* not TERMIOS */ } -#else /* HAVE_SGTTY_H */ +#else /* SGTTY */ { ttymode_set(CBREAK, 0); } -#endif /* HAVE_SGTTY_H */ +#endif /* SGTTY */ void nocrmode(void) -#ifndef HAVE_SGTTY_H +#ifndef SGTTY { ttymode_set(ICANON, 0); -#ifdef HAVE_TERMIOS_H +#ifdef TERMIOS set_cc(VMIN, 4); -#else /* not HAVE_TERMIOS_H */ +#else /* not TERMIOS */ set_cc(VEOF, 4); -#endif /* not HAVE_TERMIOS_H */ +#endif /* not TERMIOS */ } -#else /* HAVE_SGTTY_H */ +#else /* SGTTY */ { ttymode_reset(CBREAK, 0); } -#endif /* HAVE_SGTTY_H */ +#endif /* SGTTY */ void term_echo(void) @@ -1690,7 +1521,7 @@ term_noecho(void) void term_raw(void) -#ifndef HAVE_SGTTY_H +#ifndef SGTTY #ifdef IEXTEN #define TTY_MODE ISIG|ICANON|ECHO|IEXTEN #else /* not IEXTEN */ @@ -1698,21 +1529,21 @@ term_raw(void) #endif /* not IEXTEN */ { ttymode_reset(TTY_MODE, IXON | IXOFF); -#ifdef HAVE_TERMIOS_H +#ifdef TERMIOS set_cc(VMIN, 1); -#else /* not HAVE_TERMIOS_H */ +#else /* not TERMIOS */ set_cc(VEOF, 1); -#endif /* not HAVE_TERMIOS_H */ +#endif /* not TERMIOS */ } -#else /* HAVE_SGTTY_H */ +#else /* SGTTY */ { ttymode_set(RAW, 0); } -#endif /* HAVE_SGTTY_H */ +#endif /* SGTTY */ void term_cooked(void) -#ifndef HAVE_SGTTY_H +#ifndef SGTTY { #ifdef __EMX__ /* On XFree86/OS2, some scrambled characters @@ -1722,17 +1553,17 @@ term_cooked(void) #else ttymode_set(TTY_MODE, 0); #endif -#ifdef HAVE_TERMIOS_H +#ifdef TERMIOS set_cc(VMIN, 4); -#else /* not HAVE_TERMIOS_H */ +#else /* not TERMIOS */ set_cc(VEOF, 4); -#endif /* not HAVE_TERMIOS_H */ +#endif /* not TERMIOS */ } -#else /* HAVE_SGTTY_H */ +#else /* SGTTY */ { ttymode_reset(RAW, 0); } -#endif /* HAVE_SGTTY_H */ +#endif /* SGTTY */ void term_cbreak(void) @@ -1746,13 +1577,7 @@ getch(void) { char c; - while ( -#ifdef __CYGWIN__ - read_win32_console(&c, 1) -#else - read(tty, &c, 1) -#endif - < (int)1) { + while (read(tty, &c, 1) < (int)1) { if (errno == EINTR || errno == EAGAIN) continue; /* error happend on read(2) */ quitfm(); @@ -1761,7 +1586,7 @@ getch(void) return c; } -#ifdef USE_MOUSE +#ifdef MOUSE #ifdef USE_GPM char wgetch(void) @@ -1831,7 +1656,7 @@ sysmouse(SIGNAL_ARG) ioctl(tty, CONS_MOUSECTL, &mi); } #endif /* USE_SYSMOUSE */ -#endif /* USE_MOUSE */ +#endif /* MOUSE */ void bell(void) @@ -1847,14 +1672,6 @@ skip_escseq(void) c = getch(); if (c == '[' || c == 'O') { c = getch(); -#ifdef USE_MOUSE - if (is_xterm && c == 'M') { - getch(); - getch(); - getch(); - } - else -#endif while (IS_DIGIT(c)) c = getch(); } @@ -1889,7 +1706,7 @@ sleep_till_anykey(int sec, int purge) } } -#ifdef USE_MOUSE +#ifdef MOUSE #define XTERM_ON {fputs("\033[?1001s\033[?1000h",ttyf); flush_tty();} #define XTERM_OFF {fputs("\033[?1000l\033[?1001r",ttyf); flush_tty();} @@ -1911,19 +1728,19 @@ mouse_init() conn.minMod = 0; if (Gpm_Open(&conn, 0) == -2) { /* - * If Gpm_Open() success, returns >= 0 - * Gpm_Open() returns -2 in case of xterm. - * Gpm_Close() is necessary here. Otherwise, - * xterm is being left in the mode where the mouse clicks are - * passed through to the application. - */ - Gpm_Close(); - is_xterm = 1; + * If Gpm_Open() success, returns >= 0 + * Gpm_Open() returns -2 in case of xterm. + * Gpm_Close() is necessary here. Otherwise, + * xterm is being left in the mode where the mouse clicks are + * passed through to the application. + */ + Gpm_Close(); + is_xterm = 1; } else { - gpm_handler = gpm_process_mouse; + gpm_handler = gpm_process_mouse; } if (is_xterm) { - XTERM_ON; + XTERM_ON; } mouseActive = 1; } @@ -2010,11 +1827,7 @@ mouse_init() { if (mouseActive) return; - if (is_xterm -#ifdef __CYGWIN__ - && hConIn == INVALID_HANDLE_VALUE -#endif - ) { + if (is_xterm) { XTERM_ON; } mouseActive = 1; @@ -2025,11 +1838,7 @@ mouse_end() { if (mouseActive == 0) return; - if (is_xterm -#ifdef __CYGWIN__ - && hConIn == INVALID_HANDLE_VALUE -#endif - ) { + if (is_xterm) { XTERM_OFF; } mouseActive = 0; @@ -2052,7 +1861,7 @@ mouse_inactive() mouse_end(); } -#endif /* USE_MOUSE */ +#endif /* MOUSE */ void flush_tty() @@ -1,5 +1,4 @@ -/* $Id: version.c,v 1.5 2001/11/20 17:49:23 ukai Exp $ */ -#define CURRENT_VERSION "w3m/0.2.2" +#define CURRENT_VERSION "w3m/0.2.2-inu-1.1" #ifndef FM_H char *version = CURRENT_VERSION; |