*** ./build/minclude/sunw.jmk.orig Fri Feb 7 19:57:06 1997 --- ./build/minclude/sunw.jmk Wed Jun 11 10:40:23 1997 *************** *** 2,8 **** TOPDIR = ../../.. PACKAGE = sunw ! PLATFORM = solaris PRODUCT = sun # --- 2,8 ---- TOPDIR = ../../.. PACKAGE = sunw ! PLATFORM = freebsd PRODUCT = sun # *** ./build/minclude/sun_security_x509.jmk.orig Fri Feb 7 19:57:08 1997 --- ./build/minclude/sun_security_x509.jmk Wed Jun 11 10:40:23 1997 *************** *** 2,8 **** TOPDIR = ../../../../.. PACKAGE = sun.security.x509 ! PLATFORM = solaris PRODUCT = sun # --- 2,8 ---- TOPDIR = ../../../../.. PACKAGE = sun.security.x509 ! PLATFORM = freebsd PRODUCT = sun # *** ./build/freebsd/makefiles/Library.gmk.orig Fri Feb 7 19:56:04 1997 --- ./build/freebsd/makefiles/Library.gmk Wed Jun 11 10:40:14 1997 *************** *** 19,24 **** --- 19,29 ---- # in order to override the values defined inthat makefile. # LIB_LOCATION = $(LIBDIR)/$(ARCH)/$(TSOBJDIR) + + ifeq ($(LIBRARY), java) + LIBRARY_SUFFIX = a + endif + DEBUG = $(LIB_LOCATION)/lib$(LIBRARY)_g.$(LIBRARY_SUFFIX) OPTIMIZED = $(LIB_LOCATION)/lib$(LIBRARY).$(LIBRARY_SUFFIX) *************** *** 30,41 **** .library.headers $(FILES.o) @echo $(DEBUG) @echo "OBJDIR=$(OBJDIR)" ! $(LD) -G -o $@ $(FILES.o) $(LDFLAGS) $(LDLIBS) $(OPTIMIZED): $(INIT) $(OBJDIR)/.library.dirs.$(ARCH) classes \ .library.headers $(FILES.o) @echo $(OPTIMIZED) ! $(LD) -G -o $@ $(FILES.o) $(LDFLAGS) $(LDLIBS) ifneq ($(PRODUCT), java) vpath %.c $(TOPDIR)/src/share/$(PKG) --- 35,56 ---- .library.headers $(FILES.o) @echo $(DEBUG) @echo "OBJDIR=$(OBJDIR)" ! ifeq ($(LIBRARY), java) ! rm -f $@ ! $(LD) -r -o $@ $(FILES.o) ! else ! $(LD) -Bshareable -o $@ $(FILES.o) $(LDFLAGS) $(LDLIBS) ! endif $(OPTIMIZED): $(INIT) $(OBJDIR)/.library.dirs.$(ARCH) classes \ .library.headers $(FILES.o) @echo $(OPTIMIZED) ! ifeq ($(LIBRARY), java) ! rm -f $@ ! $(LD) -r -o $@ $(FILES.o) ! else ! $(LD) -Bshareable -o $@ $(FILES.o) $(LDFLAGS) $(LDLIBS) ! endif ifneq ($(PRODUCT), java) vpath %.c $(TOPDIR)/src/share/$(PKG) *************** *** 47,52 **** --- 62,71 ---- -I$(TOPDIR)/src/$(PLATFORM)/$(PKG) \ -I$(JAVAHOME)/include \ -I$(JAVAHOME)/include/$(PLATFORM) + endif + + ifneq ($(LIBRARY), java) + CFLAGS += -fPIC endif CLASSES.export = $(shell echo $(FILES.export) $(FILES.export2) | \ *** ./build/freebsd/java/javah/GNUmakefile.orig Fri Feb 7 19:56:06 1997 --- ./build/freebsd/java/javah/GNUmakefile Wed Jun 11 10:40:14 1997 *************** *** 1,7 **** # @(#)GNUmakefile 1.10 95/10/19 PROGRAM = javah ! PLATFORM = solaris PRODUCT = java TOPDIR=../../../.. --- 1,7 ---- # @(#)GNUmakefile 1.10 95/10/19 PROGRAM = javah ! PLATFORM = freebsd PRODUCT = java TOPDIR=../../../.. *** ./build/freebsd/java/javap/GNUmakefile.orig Fri Feb 7 19:56:06 1997 --- ./build/freebsd/java/javap/GNUmakefile Wed Jun 11 10:40:14 1997 *************** *** 1,7 **** # @(#)GNUmakefile 1.10 97/01/24 PROGRAM = javap ! PLATFORM = solaris PRODUCT = java TOPDIR = ../../../.. --- 1,7 ---- # @(#)GNUmakefile 1.10 97/01/24 PROGRAM = javap ! PLATFORM = freebsd PRODUCT = java TOPDIR = ../../../.. *** ./build/freebsd/java/java/GNUmakefile.orig Fri Feb 7 19:56:06 1997 --- ./build/freebsd/java/java/GNUmakefile Wed Jun 11 10:40:15 1997 *************** *** 5,19 **** # LIBRARY = java ! PLATFORM = solaris PRODUCT = java # # Directories # TOPDIR = ../../../.. ! # We need ARCH *before* we do the include that gets us Defs-solaris.gmk ! ARCH = $(shell uname -p) include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # --- 5,19 ---- # LIBRARY = java ! PLATFORM = freebsd PRODUCT = java # # Directories # TOPDIR = ../../../.. ! # We need ARCH *before* we do the include that gets us Defs-freebsd.gmk ! ARCH = $(shell uname -m) include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # *************** *** 100,106 **** ifeq ($(ARCH),sparc) EXTRAFILES-green = else ! EXTRAFILES-green = edi.s endif EXTRAFILES-native = solaris_regs.s --- 100,106 ---- ifeq ($(ARCH),sparc) EXTRAFILES-green = else ! #EXTRAFILES-green = edi.s endif EXTRAFILES-native = solaris_regs.s *************** *** 167,173 **** PKGPATH = $(PLATFORM_SRC)/java $(SHARE_SRC)/java ! LDLIBS += -lX11 -lsocket -lnsl -lresolv # # Now that the body of the runtime is in a shared object, it is built --- 167,173 ---- PKGPATH = $(PLATFORM_SRC)/java $(SHARE_SRC)/java ! #LDLIBS += -lX11 -lsocket -lnsl -lresolv # # Now that the body of the runtime is in a shared object, it is built *************** *** 184,190 **** rm -rf $(CLASSBINDIR)/java rm -rf $(OBJROOTS) rm -f classstubs.c .program* .library* .classes* ! rm -f lexer.c parser.c *.o *.asm *.s masm2as clobber :: FORCE rm -f $(OPTIMIZED) $(DEBUG) $(PRODUCT) $(PRODUCT)_g --- 184,190 ---- rm -rf $(CLASSBINDIR)/java rm -rf $(OBJROOTS) rm -f classstubs.c .program* .library* .classes* ! rm -f lexer.c parser.c *.o *.asm *.s masm2as avltree.o clobber :: FORCE rm -f $(OPTIMIZED) $(DEBUG) $(PRODUCT) $(PRODUCT)_g *************** *** 259,274 **** executeJava_p5.s: executeJava_p5.asm masm2as ! masm2as -gcc < executeJava_p5.asm > executeJava_p5.s executeJava_p5.asm : includes_p5 $(SHARE_SRC)/java/runtime/executeJava_p5.m4 $(SHARE_SRC)/java/runtime/executeJava_p5.inc rm -f fjconst.inc rm -f fjtables.inc rm -f executeJava_p5.asm ! includes_p5 . ! m4 -DSOLARIS -DCPU=5 $(SHARE_SRC)/java/runtime/executeJava_p5.m4 > executeJava_p5.asm ! m4 -DSOLARIS -DCPU=6 $(SHARE_SRC)/java/runtime/executeJava_p5.m4 >> executeJava_p5.asm chmod a=rx executeJava_p5.asm chmod a=rx fjconst.inc chmod a=rx fjtables.inc --- 259,279 ---- executeJava_p5.s: executeJava_p5.asm masm2as ! ./masm2as -gcc < executeJava_p5.asm | \ ! sed -e 's/GENSYM[0-9]*,/12,/' \ ! -e '/\(call.*__allmul\) /s//\1 ; add $$16, %esp /' \ ! -e '/\(call.*__moddi3\) /s//\1 ; add $$16, %esp /' \ ! -e '/\(call.*__divdi3\) /s//\1 ; add $$16, %esp /' \ ! > executeJava_p5.s executeJava_p5.asm : includes_p5 $(SHARE_SRC)/java/runtime/executeJava_p5.m4 $(SHARE_SRC)/java/runtime/executeJava_p5.inc rm -f fjconst.inc rm -f fjtables.inc rm -f executeJava_p5.asm ! ./includes_p5 . ! gm4 -G -D__allrem=___moddi3 -D__alldiv=___divdi3 -DCPU=5 $(SHARE_SRC)/java/runtime/executeJava_p5.m4 > executeJava_p5.asm ! gm4 -G -D__allrem=___moddi3 -D__alldiv=___divdi3 -DCPU=6 $(SHARE_SRC)/java/runtime/executeJava_p5.m4 >> executeJava_p5.asm chmod a=rx executeJava_p5.asm chmod a=rx fjconst.inc chmod a=rx fjtables.inc *************** *** 282,289 **** YFLAGS = -d -v LFLAGS = -n ! masm2as: parser.o lexer.o ! cc parser.o lexer.o -ll -o masm2as # this is ugly. We can't use the normal cc flags because it generates --- 287,294 ---- YFLAGS = -d -v LFLAGS = -n ! masm2as: parser.o lexer.o avltree.o ! cc parser.o lexer.o avltree.o -ll -o masm2as # this is ugly. We can't use the normal cc flags because it generates *************** *** 292,295 **** $(CC) -c lexer.c parser.o: parser.c ! $(CC) -c parser.c --- 297,303 ---- $(CC) -c lexer.c parser.o: parser.c ! $(CC) -Dtsearch=tsearchAVL -Dtfind=tfindAVL -c parser.c ! ! avltree.o: avltree.c ! $(CC) -DAVL -c avltree.c *** ./build/freebsd/java/java/parser.y.orig Fri Feb 7 19:56:06 1997 --- ./build/freebsd/java/java/parser.y Wed Jun 11 10:40:15 1997 *************** *** 37,42 **** --- 37,48 ---- #include #include #include + #ifdef __FreeBSD__ + #include + typedef char boolean_t; + #define B_FALSE 0 + #define B_TRUE 1 + #endif boolean_t isBranch; /* true if operand is a branch */ *************** *** 105,111 **** --- 111,121 ---- /* empty */ | Program OneLine NEWLINE { if (strlen($3) > 0) + #ifdef __FreeBSD__ + printf(" ## %s", $3); + #else printf(" // %s", $3); + #endif printf("\n"); } ; *************** *** 123,131 **** $1, getSize2($1, $4.size, $2.size), $4.svalue, $2.svalue); } | Opcode Operand ',' Operand ',' Operand ! { printf("\t%s%s\t%s, %s", /* elide the %cl */ $1, getSize3($1, $6.size, $4.size, $2.size), ! $4.svalue, $2.svalue); } | PREFIX Opcode { printf("\t%s;\t%s", $1, $2); } | IDENTIFIER ':' --- 133,149 ---- $1, getSize2($1, $4.size, $2.size), $4.svalue, $2.svalue); } | Opcode Operand ',' Operand ',' Operand ! { ! #ifdef __FreeBSD__ ! printf("\t%s%s\t%%cl, %s, %s", $1, getSize3($1, $6.size, $4.size, $2.size), ! $4.svalue, $2.svalue); ! #else ! printf("\t%s%s\t%s, %s", /* elide the %cl */ ! $1, getSize3($1, $6.size, $4.size, $2.size), ! $4.svalue, $2.svalue); ! #endif ! } | PREFIX Opcode { printf("\t%s;\t%s", $1, $2); } | IDENTIFIER ':' *************** *** 155,161 **** --- 173,183 ---- { printf("\t.%s %s", sizeToString($1), exprToString(&$2)); } | SIZE STRING ',' NUMBER { if ($1 == 8 && $4 == 0) + #ifdef __FreeBSD__ + printf("\t.asciz %s", $2); + #else printf("\t.string %s", $2); + #endif else { yyerror("syntax error"); YYERROR; } } | SIZE STRING *************** *** 428,434 **** --- 450,460 ---- if (opcode[0] == 'f') { if (opcode[1] == 'i') { switch(size) { + #ifdef __FreeBSD__ + case 64: return "q"; + #else case 64: return "ll"; + #endif case 32: return "l"; default: return mprintf("@@@@%d@@@@", size); } *************** *** 561,568 **** int ivalue; }; - - #include int IDcompare(const void *a, const void *b) { return strcmp(((struct ID *)a)->name, ((struct ID *)b)->name); --- 587,592 ---- *** ./build/freebsd/java/java/lexer.l.orig Fri Feb 7 19:56:06 1997 --- ./build/freebsd/java/java/lexer.l Wed Jun 11 10:40:15 1997 *************** *** 25,30 **** --- 25,34 ---- #include #include #include + #ifdef __FreeBSD__ + typedef char boolean_t; + #define strtoll strtol + #endif #include #include "y.tab.h" char* mprintf(char *format, ...); *** ./build/freebsd/java/net/GNUmakefile.orig Fri Feb 7 19:56:06 1997 --- ./build/freebsd/java/net/GNUmakefile Wed Jun 11 10:40:15 1997 *************** *** 3,9 **** TOPDIR = ../../../.. PACKAGE = java.net LIBRARY = net ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # --- 3,9 ---- TOPDIR = ../../../.. PACKAGE = java.net LIBRARY = net ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # *** ./build/freebsd/java/awt/GNUmakefile.orig Fri Feb 7 19:56:08 1997 --- ./build/freebsd/java/awt/GNUmakefile Wed Jun 11 10:40:15 1997 *************** *** 2,8 **** TOPDIR = ../../../.. PACKAGE = java.awt ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # --- 2,8 ---- TOPDIR = ../../../.. PACKAGE = java.awt ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # *** ./build/freebsd/java/applet/GNUmakefile.orig Fri Feb 7 19:56:08 1997 --- ./build/freebsd/java/applet/GNUmakefile Wed Jun 11 10:40:16 1997 *************** *** 2,8 **** TOPDIR = ../../../.. PACKAGE = java.applet ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk --- 2,8 ---- TOPDIR = ../../../.. PACKAGE = java.applet ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk *** ./build/freebsd/java/jio/GNUmakefile.orig Fri Feb 7 19:56:08 1997 --- ./build/freebsd/java/jio/GNUmakefile Wed Jun 11 10:40:16 1997 *************** *** 3,9 **** TOPDIR = ../../../.. PACKAGE = java.jio LIBRARY = jio ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # --- 3,9 ---- TOPDIR = ../../../.. PACKAGE = java.jio LIBRARY = jio ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # *** ./build/freebsd/java/security/GNUmakefile.orig Fri Feb 7 19:56:08 1997 --- ./build/freebsd/java/security/GNUmakefile Wed Jun 11 10:40:16 1997 *************** *** 2,8 **** TOPDIR = ../../../.. PACKAGE = java.security ! PLATFORM = solaris PRODUCT = java include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # --- 2,8 ---- TOPDIR = ../../../.. PACKAGE = java.security ! PLATFORM = freebsd PRODUCT = java include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # *** ./build/freebsd/java/rmi/GNUmakefile.orig Fri Feb 7 19:56:08 1997 --- ./build/freebsd/java/rmi/GNUmakefile Wed Jun 11 10:40:16 1997 *************** *** 5,11 **** # TOPDIR = ../../../.. PACKAGE = java.rmi ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk --- 5,11 ---- # TOPDIR = ../../../.. PACKAGE = java.rmi ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk *** ./build/freebsd/java/sql/GNUmakefile.orig Fri Feb 7 19:56:08 1997 --- ./build/freebsd/java/sql/GNUmakefile Wed Jun 11 10:40:16 1997 *************** *** 5,11 **** # TOPDIR = ../../../.. PACKAGE = java.sql ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk ABSTOP=$(shell cd $(TOPDIR);pwd) --- 5,11 ---- # TOPDIR = ../../../.. PACKAGE = java.sql ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk ABSTOP=$(shell cd $(TOPDIR);pwd) *** ./build/freebsd/java/text/GNUmakefile.orig Fri Feb 7 19:56:08 1997 --- ./build/freebsd/java/text/GNUmakefile Wed Jun 11 10:40:17 1997 *************** *** 2,8 **** TOPDIR = ../../../.. PACKAGE = java.text ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # --- 2,8 ---- TOPDIR = ../../../.. PACKAGE = java.text ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # *** ./build/freebsd/java/main/GNUmakefile.orig Fri Feb 7 19:56:08 1997 --- ./build/freebsd/java/main/GNUmakefile Wed Jun 11 10:40:17 1997 *************** *** 1,7 **** # @(#)GNUmakefile @(#)GNUmakefile 1.2 96/11/05 PROGRAM = java ! PLATFORM = solaris PRODUCT = java TOPDIR=../../../.. --- 1,7 ---- # @(#)GNUmakefile @(#)GNUmakefile 1.2 96/11/05 PROGRAM = java ! PLATFORM = freebsd PRODUCT = java TOPDIR=../../../.. *************** *** 14,26 **** # Files specific to the Solaris system # ! FILES.c += java.c FILES.s = include $(TOPDIR)/build/$(PLATFORM)/makefiles/Program.gmk ! LDLIBS_COMMON += -lX11 -lsocket -lnsl -lresolv LDLIBS_OPT += -ljava --- 14,27 ---- # Files specific to the Solaris system # ! FILES.c += java.c referenceX.c FILES.s = include $(TOPDIR)/build/$(PLATFORM)/makefiles/Program.gmk ! #LDLIBS_COMMON += -lX11 -lsocket -lnsl -lresolv ! LDLIBS_COMMON += -lm -L/usr/X11R6/lib -lXm -lXt -lXext -lX11 LDLIBS_OPT += -ljava *** ./build/freebsd/java/zip/GNUmakefile.orig Fri Feb 7 19:56:08 1997 --- ./build/freebsd/java/zip/GNUmakefile Wed Jun 11 10:40:17 1997 *************** *** 3,9 **** TOPDIR = ../../../.. PACKAGE = java.util.zip LIBRARY = zip ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk --- 3,9 ---- TOPDIR = ../../../.. PACKAGE = java.util.zip LIBRARY = zip ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk *** ./build/freebsd/java/math/GNUmakefile.orig Fri Feb 7 19:56:10 1997 --- ./build/freebsd/java/math/GNUmakefile Wed Jun 11 10:40:17 1997 *************** *** 3,9 **** TOPDIR = ../../../.. PACKAGE = java.math LIBRARY = math ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk --- 3,9 ---- TOPDIR = ../../../.. PACKAGE = java.math LIBRARY = math ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk *** ./build/freebsd/java/beans/GNUmakefile.orig Fri Feb 7 19:56:10 1997 --- ./build/freebsd/java/beans/GNUmakefile Wed Jun 11 10:40:17 1997 *************** *** 5,11 **** # TOPDIR = ../../../.. PACKAGE = java.beans ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk ABSTOP=$(shell cd $(TOPDIR);pwd) --- 5,11 ---- # TOPDIR = ../../../.. PACKAGE = java.beans ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk ABSTOP=$(shell cd $(TOPDIR);pwd) *** ./build/freebsd/java/GNUmakefile.orig Fri Feb 7 19:56:06 1997 --- ./build/freebsd/java/GNUmakefile Wed Jun 11 10:40:17 1997 *************** *** 5,16 **** # TOPDIR = ../../.. ! PLATFORM = solaris PRODUCT = java SUBDIRS = javah java math zip main javap javac text awt applet net security sql rmi zip beans ! RELEASE = $(shell echo `/usr/ucb/whoami`:`date '+%m/%d/%d-%H:%M'`) all optimized debug clean clobber :: @for i in $(SUBDIRS) ; do \ --- 5,16 ---- # TOPDIR = ../../.. ! PLATFORM = freebsd PRODUCT = java SUBDIRS = javah java math zip main javap javac text awt applet net security sql rmi zip beans ! RELEASE = $(shell echo jdk1.1-`whoami`:`date '+%Y/%m/%d-%H:%M'`) all optimized debug clean clobber :: @for i in $(SUBDIRS) ; do \ *** ./build/freebsd/sun/security/x509/GNUmakefile.orig Fri Feb 7 19:56:10 1997 --- ./build/freebsd/sun/security/x509/GNUmakefile Wed Jun 11 10:40:18 1997 *************** *** 2,8 **** TOPDIR = ../../../../.. PACKAGE = sun.security.x509 ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk --- 2,8 ---- TOPDIR = ../../../../.. PACKAGE = sun.security.x509 ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk *** ./build/freebsd/sun/security/acl/GNUmakefile.orig Fri Feb 7 19:56:10 1997 --- ./build/freebsd/sun/security/acl/GNUmakefile Wed Jun 11 10:40:18 1997 *************** *** 2,8 **** TOPDIR = ../../../../.. PACKAGE = sun.security.acl ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk --- 2,8 ---- TOPDIR = ../../../../.. PACKAGE = sun.security.acl ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk *** ./build/freebsd/sun/security/util/GNUmakefile.orig Fri Feb 7 19:56:10 1997 --- ./build/freebsd/sun/security/util/GNUmakefile Wed Jun 11 10:40:18 1997 *************** *** 2,8 **** TOPDIR = ../../../../.. PACKAGE = sun.security.util ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk --- 2,8 ---- TOPDIR = ../../../../.. PACKAGE = sun.security.util ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk *** ./build/freebsd/sun/security/pkcs/GNUmakefile.orig Fri Feb 7 19:56:10 1997 --- ./build/freebsd/sun/security/pkcs/GNUmakefile Wed Jun 11 10:40:18 1997 *************** *** 2,8 **** TOPDIR = ../../../../.. PACKAGE = sun.security.pkcs ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk --- 2,8 ---- TOPDIR = ../../../../.. PACKAGE = sun.security.pkcs ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk *** ./build/freebsd/sun/security/provider/GNUmakefile.orig Fri Feb 7 19:56:10 1997 --- ./build/freebsd/sun/security/provider/GNUmakefile Wed Jun 11 10:40:18 1997 *************** *** 2,8 **** TOPDIR = ../../../../.. PACKAGE = sun.security.provider ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk --- 2,8 ---- TOPDIR = ../../../../.. PACKAGE = sun.security.provider ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk *** ./build/freebsd/sun/security/GNUmakefile.orig Fri Feb 7 19:56:10 1997 --- ./build/freebsd/sun/security/GNUmakefile Wed Jun 11 10:40:19 1997 *************** *** 2,8 **** TOPDIR = ../../../.. PACKAGE = sun.security ! PLATFORM = solaris PRODUCT = sun SUBDIRS = acl util x509 pkcs provider --- 2,8 ---- TOPDIR = ../../../.. PACKAGE = sun.security ! PLATFORM = freebsd PRODUCT = sun SUBDIRS = acl util x509 pkcs provider *** ./build/freebsd/sun/applet/GNUmakefile.orig Fri Feb 7 19:56:10 1997 --- ./build/freebsd/sun/applet/GNUmakefile Wed Jun 11 10:40:19 1997 *************** *** 2,8 **** TOPDIR = ../../../.. PACKAGE = sun.applet ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk --- 2,8 ---- TOPDIR = ../../../.. PACKAGE = sun.applet ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk *** ./build/freebsd/sun/awt/GNUmakefile.orig Fri Feb 7 19:56:12 1997 --- ./build/freebsd/sun/awt/GNUmakefile Wed Jun 11 10:40:19 1997 *************** *** 4,10 **** TOPDIR = ../../../.. PACKAGE = sun.awt LIBRARY = awt ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # --- 4,10 ---- TOPDIR = ../../../.. PACKAGE = sun.awt LIBRARY = awt ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # *************** *** 138,147 **** motif: $(OBJDIR)/.library.dirs.$(ARCH) $(OBJDIR)/.library.motif.$(ARCH) ! $(OBJDIR)/.library.motif.$(ARCH): $(MOTIF_DIR)/lib/libXm.so.3 ! cp $(MOTIF_DIR)/lib/libXm.so.3 $(LIBDIR)/$(ARCH)/$(TSOBJDIR) cd $(LIBDIR)/$(ARCH)/$(TSOBJDIR); rm -f libXm.so; \ ! ln -s libXm.so.3 libXm.so @-touch $(OBJDIR)/.library.motif.$(ARCH) motif.clean : --- 138,147 ---- motif: $(OBJDIR)/.library.dirs.$(ARCH) $(OBJDIR)/.library.motif.$(ARCH) ! $(OBJDIR)/.library.motif.$(ARCH): $(MOTIF_DIR)/lib/libXm.so.1.2 ! cp $(MOTIF_DIR)/lib/libXm.so.1.2 $(LIBDIR)/$(ARCH)/$(TSOBJDIR) cd $(LIBDIR)/$(ARCH)/$(TSOBJDIR); rm -f libXm.so; \ ! ln -s libXm.so.1.2 libXm.so @-touch $(OBJDIR)/.library.motif.$(ARCH) motif.clean : *************** *** 178,185 **** -I$(SHARE_SRC)/sun/images \ $(EVENT_MODEL) ! LDFLAGS += -L$(LIBDIR)/$(ARCH)/$(TSOBJDIR) -L$(MOTIF_DIR)/lib \ ! -R$(MOTIF_DIR)/lib -lXm CLASSES.export += java.lang.String \ java.io.InputStream \ --- 178,186 ---- -I$(SHARE_SRC)/sun/images \ $(EVENT_MODEL) ! #LDFLAGS += -L$(LIBDIR)/$(ARCH)/$(TSOBJDIR) -L$(MOTIF_DIR)/lib \ ! # -R$(MOTIF_DIR)/lib -lXm ! #LDFLAGS += -L$(LIBDIR)/$(ARCH)/$(TSOBJDIR) -L$(MOTIF_DIR)/lib -lXm CLASSES.export += java.lang.String \ java.io.InputStream \ *** ./build/freebsd/sun/mmedia/GNUmakefile.orig Fri Feb 7 19:56:12 1997 --- ./build/freebsd/sun/mmedia/GNUmakefile Wed Jun 11 10:40:19 1997 *************** *** 3,9 **** TOPDIR = ../../../.. PACKAGE = sun.audio LIBRARY = mmedia ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # --- 3,9 ---- TOPDIR = ../../../.. PACKAGE = sun.audio LIBRARY = mmedia ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # *** ./build/freebsd/sun/net/GNUmakefile.orig Fri Feb 7 19:56:12 1997 --- ./build/freebsd/sun/net/GNUmakefile Wed Jun 11 10:40:19 1997 *************** *** 2,8 **** TOPDIR = ../../../.. PACKAGE = sun.net ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # --- 2,8 ---- TOPDIR = ../../../.. PACKAGE = sun.net ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # *** ./build/freebsd/sun/misc/GNUmakefile.orig Fri Feb 7 19:56:12 1997 --- ./build/freebsd/sun/misc/GNUmakefile Wed Jun 11 10:40:20 1997 *************** *** 2,8 **** TOPDIR = ../../../.. PACKAGE = sun.misc ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # --- 2,8 ---- TOPDIR = ../../../.. PACKAGE = sun.misc ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # *** ./build/freebsd/sun/jpeg/GNUmakefile.orig Fri Feb 7 19:56:12 1997 --- ./build/freebsd/sun/jpeg/GNUmakefile Wed Jun 11 10:40:20 1997 *************** *** 3,9 **** TOPDIR = ../../../.. PACKAGE = sun.awt LIBRARY = jpeg ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # --- 3,9 ---- TOPDIR = ../../../.. PACKAGE = sun.awt LIBRARY = jpeg ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # *** ./build/freebsd/sun/javac/GNUmakefile.orig Fri Feb 7 19:56:12 1997 --- ./build/freebsd/sun/javac/GNUmakefile Wed Jun 11 10:40:20 1997 *************** *** 6,12 **** PROGRAM = javac PACKAGE = sun.tools ! PLATFORM = solaris PRODUCT = sun TOPDIR = ../../../.. --- 6,12 ---- PROGRAM = javac PACKAGE = sun.tools ! PLATFORM = freebsd PRODUCT = sun TOPDIR = ../../../.. *************** *** 19,25 **** JAVAC = $(BINDIR)/$(ARCH)/$(TSOBJDIR)/javac SRCDIR = $(TOPDIR)/src/share/sun ! SOLDIR = $(TOPDIR)/src/solaris/java JAVASRCDIR = $(TOPDIR)/src/share/java PKGPATH = $(TOPDIR)/src/$(PLATFORM)/sun $(SRCDIR) $(JAVASRCDIR) $(SOLDIR) COMPCLASSFILES = $(CLASSFILES:%.java=$(CLASSBINDIR)/%.class) --- 19,25 ---- JAVAC = $(BINDIR)/$(ARCH)/$(TSOBJDIR)/javac SRCDIR = $(TOPDIR)/src/share/sun ! SOLDIR = $(TOPDIR)/src/freebsd/java JAVASRCDIR = $(TOPDIR)/src/share/java PKGPATH = $(TOPDIR)/src/$(PLATFORM)/sun $(SRCDIR) $(JAVASRCDIR) $(SOLDIR) COMPCLASSFILES = $(CLASSFILES:%.java=$(CLASSBINDIR)/%.class) *** ./build/freebsd/sun/debug/GNUmakefile.orig Fri Feb 7 19:56:12 1997 --- ./build/freebsd/sun/debug/GNUmakefile Wed Jun 11 10:40:20 1997 *************** *** 6,12 **** LIBRARY = agent PACKAGE = sun.tools ! PLATFORM = solaris PRODUCT = sun # --- 6,12 ---- LIBRARY = agent PACKAGE = sun.tools ! PLATFORM = freebsd PRODUCT = sun # *** ./build/freebsd/sun/javadoc/GNUmakefile.orig Fri Feb 7 19:56:12 1997 --- ./build/freebsd/sun/javadoc/GNUmakefile Wed Jun 11 10:40:20 1997 *************** *** 6,12 **** PROGRAM = javadoc PACKAGE = sun.tools ! PLATFORM = solaris PRODUCT = sun default: all --- 6,12 ---- PROGRAM = javadoc PACKAGE = sun.tools ! PLATFORM = freebsd PRODUCT = sun default: all *** ./build/freebsd/sun/tawt/GNUmakefile.orig Fri Feb 7 19:56:14 1997 --- ./build/freebsd/sun/tawt/GNUmakefile Wed Jun 11 10:40:21 1997 *************** *** 3,9 **** TOPDIR = ../../../.. PACKAGE = sun.awt LIBRARY = tawt ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk --- 3,9 ---- TOPDIR = ../../../.. PACKAGE = sun.awt LIBRARY = tawt ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk *************** *** 51,61 **** vpath %.c $(SHARE_SRC)/sun/gif vpath %.c $(SHARE_SRC)/sun/images ! CPPFLAGS += -I/usr/openwin/include \ -I$(SHARE_SRC)/sun/images \ -I$(JAVAHOME)/$(PLATFORM)/java/java/CClassHeaders ! LDFLAGS += -L$(LIBDIR)/$(ARCH) -lX CLASSES.export += java.lang.String \ java.io.InputStream \ --- 51,61 ---- vpath %.c $(SHARE_SRC)/sun/gif vpath %.c $(SHARE_SRC)/sun/images ! CPPFLAGS += -I/usr/X11R6/include \ -I$(SHARE_SRC)/sun/images \ -I$(JAVAHOME)/$(PLATFORM)/java/java/CClassHeaders ! #LDFLAGS += -L$(LIBDIR)/$(ARCH) -lX CLASSES.export += java.lang.String \ java.io.InputStream \ *** ./build/freebsd/sun/jar/GNUmakefile.orig Fri Feb 7 19:56:14 1997 --- ./build/freebsd/sun/jar/GNUmakefile Wed Jun 11 10:40:21 1997 *************** *** 6,12 **** PROGRAM = jar PACKAGE = sun.tools ! PLATFORM = solaris PRODUCT = sun default: all --- 6,12 ---- PROGRAM = jar PACKAGE = sun.tools ! PLATFORM = freebsd PRODUCT = sun default: all *** ./build/freebsd/sun/io/GNUmakefile.orig Fri Feb 7 19:56:14 1997 --- ./build/freebsd/sun/io/GNUmakefile Wed Jun 11 10:40:21 1997 *************** *** 2,8 **** TOPDIR = ../../../.. PACKAGE = sun.io ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # --- 2,8 ---- TOPDIR = ../../../.. PACKAGE = sun.io ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # *** ./build/freebsd/sun/native2ascii/GNUmakefile.orig Fri Feb 7 19:56:14 1997 --- ./build/freebsd/sun/native2ascii/GNUmakefile Wed Jun 11 10:40:21 1997 *************** *** 6,12 **** PROGRAM = native2ascii PACKAGE = sun.tools ! PLATFORM = solaris PRODUCT = sun # --- 6,12 ---- PROGRAM = native2ascii PACKAGE = sun.tools ! PLATFORM = freebsd PRODUCT = sun # *** ./build/freebsd/sun/jdbc/GNUmakefile.orig Fri Feb 7 19:56:14 1997 --- ./build/freebsd/sun/jdbc/GNUmakefile Wed Jun 11 10:40:21 1997 *************** *** 9,15 **** TOPDIR = ../../../.. PACKAGE = sun.jdbc.odbc LIBRARY = JdbcOdbc ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # --- 9,15 ---- TOPDIR = ../../../.. PACKAGE = sun.jdbc.odbc LIBRARY = JdbcOdbc ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # *** ./build/freebsd/sun/rmi/rmic/GNUmakefile.orig Fri Feb 7 19:56:14 1997 --- ./build/freebsd/sun/rmi/rmic/GNUmakefile Wed Jun 11 10:40:22 1997 *************** *** 5,11 **** # TOPDIR = ../../../../.. PACKAGE = sun.rmi.rmic ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk --- 5,11 ---- # TOPDIR = ../../../../.. PACKAGE = sun.rmi.rmic ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk *** ./build/freebsd/sun/rmi/registry/GNUmakefile.orig Fri Feb 7 19:56:14 1997 --- ./build/freebsd/sun/rmi/registry/GNUmakefile Wed Jun 11 10:40:22 1997 *************** *** 5,11 **** # TOPDIR = ../../../../.. PACKAGE = sun.rmi.registry ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk --- 5,11 ---- # TOPDIR = ../../../../.. PACKAGE = sun.rmi.registry ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk *** ./build/freebsd/sun/rmi/GNUmakefile.orig Fri Feb 7 19:56:14 1997 --- ./build/freebsd/sun/rmi/GNUmakefile Wed Jun 11 10:40:22 1997 *************** *** 5,11 **** # TOPDIR = ../../../.. PACKAGE = sun.rmi ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk --- 5,11 ---- # TOPDIR = ../../../.. PACKAGE = sun.rmi ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk *** ./build/freebsd/sun/serialver/GNUmakefile.orig Fri Feb 7 19:56:14 1997 --- ./build/freebsd/sun/serialver/GNUmakefile Wed Jun 11 10:40:22 1997 *************** *** 5,11 **** # TOPDIR = ../../../.. PACKAGE = sun.tools.serialver ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk --- 5,11 ---- # TOPDIR = ../../../.. PACKAGE = sun.tools.serialver ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk *** ./build/freebsd/sun/sysresource/GNUmakefile.orig Fri Feb 7 19:56:14 1997 --- ./build/freebsd/sun/sysresource/GNUmakefile Wed Jun 11 10:40:22 1997 *************** *** 3,9 **** TOPDIR = ../../../.. PACKAGE = sun.net.www.protocol.systemresource LIBRARY = sysresource ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # --- 3,9 ---- TOPDIR = ../../../.. PACKAGE = sun.net.www.protocol.systemresource LIBRARY = sysresource ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk # *** ./build/freebsd/sun/beans/GNUmakefile.orig Fri Feb 7 19:56:14 1997 --- ./build/freebsd/sun/beans/GNUmakefile Wed Jun 11 10:40:22 1997 *************** *** 5,11 **** # TOPDIR = ../../../.. PACKAGE = sun.beans ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk --- 5,11 ---- # TOPDIR = ../../../.. PACKAGE = sun.beans ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk *** ./build/freebsd/sun/GNUmakefile.orig Fri Feb 7 19:56:10 1997 --- ./build/freebsd/sun/GNUmakefile Wed Jun 11 10:40:23 1997 *************** *** 4,13 **** # Makefile for building all of sun tools # TOPDIR = ../.. ! PLATFORM = solaris PRODUCT = sun ! RELEASE = $(shell echo `/usr/ucb/whoami`:`date '+%m/%d/%d-%H:%M'`) SUBDIRS = jar javac io javadoc debug misc net mmedia awt tawt jpeg applet \ security native2ascii rmi serialver sysresource beans --- 4,13 ---- # Makefile for building all of sun tools # TOPDIR = ../.. ! PLATFORM = freebsd PRODUCT = sun ! RELEASE = $(shell echo jdk1.1-`whoami`:`date '+%Y/%m/%d-%H:%M'`) SUBDIRS = jar javac io javadoc debug misc net mmedia awt tawt jpeg applet \ security native2ascii rmi serialver sysresource beans *** ./build/freebsd/sunw/GNUmakefile.orig Fri Feb 7 19:56:16 1997 --- ./build/freebsd/sunw/GNUmakefile Wed Jun 11 10:40:23 1997 *************** *** 2,8 **** TOPDIR = ../../.. PACKAGE = sunw ! PLATFORM = solaris PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk --- 2,8 ---- TOPDIR = ../../.. PACKAGE = sunw ! PLATFORM = freebsd PRODUCT = sun include $(TOPDIR)/build/$(PLATFORM)/makefiles/Defs.gmk *** ./build/freebsd/GNUmakefile.orig Fri Feb 7 19:56:04 1997 --- ./build/freebsd/GNUmakefile Wed Jun 11 10:40:23 1997 *************** *** 4,15 **** # Makefile for building all of java # ! DEMODIR=/usr/green/src/applets TOPDIR = ../.. ! ZIP=/usr/dist/local/exe/zip JAVA = $(TOPDIR)/build/bin/java ! RELEASE = $(shell echo `/usr/ucb/whoami`:`date '+%m/%d/%y-%H:%M'`) PWD = $(shell echo `pwd`) DESTDIR = $(PWD)/$(TOPDIR)/buildbin --- 4,15 ---- # Makefile for building all of java # ! DEMODIR=/usr/local/java/jdk1.1/demo TOPDIR = ../.. ! ZIP=/usr/local/bin/zip JAVA = $(TOPDIR)/build/bin/java ! RELEASE = $(shell echo jdk1.1-`whoami`:`date '+%Y/%m/%d-%H:%M'`) PWD = $(shell echo `pwd`) DESTDIR = $(PWD)/$(TOPDIR)/buildbin *************** *** 29,59 **** echo "<< --- 24,31 ---- * Math library definitions for all the public functions implemented in libm.a. */ ! #ifndef _JMATH_H_ ! #define _JMATH_H_ #include *** ./src/share/java/include/oobj.h.orig Fri Feb 7 19:57:12 1997 --- ./src/share/java/include/oobj.h Wed Jun 11 10:40:24 1997 *************** *** 62,69 **** extern unicode *str2unicode(char *, unicode *, long); extern char *int642CString(int64_t number, char *buf, int buflen); ! #define ALIGN(n) (((n)+3)&~3) ! #define UCALIGN(n) ((unsigned char *)ALIGN((int)(n))) struct Hjava_lang_Class; /* forward reference for some compilers */ struct Classjava_lang_Class; /* forward reference for some compilers */ --- 62,69 ---- extern unicode *str2unicode(char *, unicode *, long); extern char *int642CString(int64_t number, char *buf, int buflen); ! #define JAVA_ALIGN(n) (((n)+3)&~3) ! #define UCALIGN(n) ((unsigned char *)JAVA_ALIGN((int)(n))) struct Hjava_lang_Class; /* forward reference for some compilers */ struct Classjava_lang_Class; /* forward reference for some compilers */ *** ./src/share/java/runtime/runtimeHelper_p5.c.orig Fri Feb 7 19:57:36 1997 --- ./src/share/java/runtime/runtimeHelper_p5.c Wed Jun 11 10:40:24 1997 *************** *** 484,486 **** --- 484,507 ---- HObject *object) { } #endif /* BREAKPTS */ + + #ifdef __FreeBSD__ + long long + _allmul(long long a, long long b) + { + return a * b; + } + #endif + + + #ifdef DEBUG + + /* we only need this if we're using the assembler version of ExecuteJava() + in debug mode */ + + unsigned char + get_breakpoint_opcode(unsigned char *pc, ExecEnv *ee) + { + return opc_breakpoint; /* we do nothing for now... */ + } + #endif *** ./src/freebsd/bin/java_wrapper.sh.orig Fri Feb 7 20:05:50 1997 --- ./src/freebsd/bin/java_wrapper.sh Wed Jun 11 10:40:24 1997 *************** *** 29,35 **** # e.g. the usage of the name "green_threads" here is dependent on the build # scripts which use the same name. Since this is somewhat analogous to the # wrapper already depending on the build scripts putting the executable in ! # a specific place (JAVA_HOME/bin/`uname -p`), the new dependency does not # seem all that bad. THREADS_TYPE=green_threads --- 29,35 ---- # e.g. the usage of the name "green_threads" here is dependent on the build # scripts which use the same name. Since this is somewhat analogous to the # wrapper already depending on the build scripts putting the executable in ! # a specific place (JAVA_HOME/bin/`uname -m`), the new dependency does not # seem all that bad. THREADS_TYPE=green_threads *************** *** 40,49 **** #echo "Using executables built for $THREADS_TYPE" export LD_LIBRARY_PATH ! LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$JAVA_HOME/lib/`uname -p`/$THREADS_TYPE" progname=`basename $0` ! prog=$JAVA_HOME/bin/`uname -p`/${THREADS_TYPE}/${progname} if [ -f $prog ] then --- 40,49 ---- #echo "Using executables built for $THREADS_TYPE" export LD_LIBRARY_PATH ! LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$JAVA_HOME/lib/`uname -m`/$THREADS_TYPE" progname=`basename $0` ! prog=$JAVA_HOME/bin/`uname -m`/${THREADS_TYPE}/${progname} if [ -f $prog ] then *** ./src/freebsd/bin/java_wrapper_local.sh.orig Fri Feb 7 20:05:50 1997 --- ./src/freebsd/bin/java_wrapper_local.sh Wed Jun 11 10:40:24 1997 *************** *** 30,36 **** if [[ $progname != $tprogname ]] ;\ then OBJDIR_NAME="$OBJDIR_NAME"_g;\ fi ! prog=${OBJDIR_NAME}/`uname -p`/${TSOBJDIR}/${progname} if [ -f $prog ] then --- 30,36 ---- if [[ $progname != $tprogname ]] ;\ then OBJDIR_NAME="$OBJDIR_NAME"_g;\ fi ! prog=${OBJDIR_NAME}/`uname -m`/${TSOBJDIR}/${progname} if [ -f $prog ] then *** ./src/freebsd/bin/appletviewer.sh.orig Fri Feb 7 20:05:50 1997 --- ./src/freebsd/bin/appletviewer.sh Thu Jun 26 13:50:23 1997 *************** *** 35,41 **** if [ ! -d "$HOME/.hotjava" ] ; then echo "Creating $HOME/.hotjava directory" ! /usr/bin/mkdir -p $HOME/.hotjava fi # --- 35,41 ---- if [ ! -d "$HOME/.hotjava" ] ; then echo "Creating $HOME/.hotjava directory" ! /bin/mkdir -p $HOME/.hotjava fi # *** ./src/freebsd/java/include/byteorder_md.h.orig Fri Feb 7 20:05:56 1997 --- ./src/freebsd/java/include/byteorder_md.h Wed Jun 11 10:40:25 1997 *************** *** 27,32 **** #ifndef _SOLARIS_BYTE_MD_H_ #define _SOLARIS_BYTE_MD_H_ - #include #endif /* !_SOLARIS_BYTE_MD_H_ */ --- 27,31 ---- *** ./src/freebsd/java/include/OSName_md.h.orig Fri Feb 7 20:05:54 1997 --- ./src/freebsd/java/include/OSName_md.h Wed Jun 11 10:40:25 1997 *************** *** 22,25 **** /* Define the name of the Operating System */ ! #define OSName_MD "Solaris" --- 22,25 ---- /* Define the name of the Operating System */ ! #define OSName_MD "FreeBSD" *** ./src/freebsd/java/include/typedefs_md.h.orig Fri Feb 7 20:05:56 1997 --- ./src/freebsd/java/include/typedefs_md.h Wed Jun 11 10:40:25 1997 *************** *** 40,52 **** typedef unsigned long long uint64_t; #define _UINT32_T typedef unsigned long uint32_t; #endif #ifndef _INT64_T #define _INT64_T typedef long long int64_t; #define _INT32_T ! typedef long int32_t; #endif #endif /* !defined(_ILP32) && !defined(_LP64) */ --- 40,61 ---- typedef unsigned long long uint64_t; #define _UINT32_T typedef unsigned long uint32_t; + typedef unsigned long uint_t; #endif + #if !(defined(__BIT_TYPES_DEFINED__) || defined(_MACHTYPES_H_)) + /* that should get Linux, at least */ #ifndef _INT64_T #define _INT64_T typedef long long int64_t; #define _INT32_T ! typedef long int_t; ! #endif ! #endif ! ! #if !(defined(_SSIZE_T) || defined(_SYS_TYPES_H_)) ! #define _SSIZE_T ! typedef int ssize_t; #endif #endif /* !defined(_ILP32) && !defined(_LP64) */ *************** *** 74,80 **** --- 83,93 ---- #define INT_OP(x,op,y) ((x) op (y)) #define NAN_CHECK(l,r,x) x + #ifdef __FreeBSD__ + #define IS_NAN(x) isnan(x) + #else #define IS_NAN(x) isnand(x) + #endif #define float2l(f) (f) #define double2l(f) (f) *** ./src/freebsd/java/include/prof_md.h.orig Fri Feb 7 20:05:56 1997 --- ./src/freebsd/java/include/prof_md.h Wed Jun 11 10:40:25 1997 *************** *** 27,32 **** --- 27,37 ---- #ifndef _SOLARIS_PROF_MD_H_ #define _SOLARIS_PROF_MD_H_ + #if defined(__linux__) || defined(__FreeBSD__) + #undef MARK(K) + #define MARK(K) {} + #else #include + #endif #endif /* !_SOLARIS_PROF_MD_H_ */ *** ./src/freebsd/java/include/jmath_md.h.orig Fri Feb 7 20:05:56 1997 --- ./src/freebsd/java/include/jmath_md.h Wed Jun 11 10:40:25 1997 *************** *** 20,26 **** --- 20,30 ---- * */ + #ifdef __FreeBSD__ + #include + #else #include + #endif #define DREM(a,b) fmod(a,b) #define IEEEREM(a,b) remainder(a,b) *** ./src/freebsd/java/runtime/linker_md.c.orig Fri Feb 7 20:05:58 1997 --- ./src/freebsd/java/runtime/linker_md.c Wed Jun 11 10:40:25 1997 *************** *** 37,42 **** --- 37,44 ---- static int linkerinitialized = 0; static int useddlsegments = 0; static int sizedlsegments = 0; + static char *wrap_dlopen(char *, int); + void out_of_memory(void); int jio_snprintf(char *str, size_t count, const char *fmt, ...); *************** *** 99,108 **** --- 101,114 ---- out_of_memory(); } dlsegment[useddlsegments].fname = "
"; + #ifndef __FreeBSD__ if ((dlsegment[useddlsegments].handle = dlopen(0, 1)) == 0) jio_fprintf(stderr, "Unable to dlopen main!\n"); else useddlsegments++; + #else + dlsegment[useddlsegments++].handle = 0; + #endif linkerinitialized = 1; return(ldpath); } *************** *** 163,169 **** } } ! if ((dlsegment[useddlsegments].handle = dlopen(fn, 1)) == 0) { char *err = (char *) dlerror(); if (err) { jio_fprintf(stderr, "%s (%s)\n", err, fn); --- 169,175 ---- } } ! if ((dlsegment[useddlsegments].handle = wrap_dlopen(fn, 1)) == 0) { char *err = (char *) dlerror(); if (err) { jio_fprintf(stderr, "%s (%s)\n", err, fn); *************** *** 184,189 **** --- 190,196 ---- sysDynamicLink(char *sym_p) { void *f = 0; + char buf[512]; int i; /* *************** *** 194,207 **** if (!linkerinitialized) { (void)sysInitializeLinker(); } ! ! if ((f = dlsym(RTLD_NEXT, sym_p)) == 0) { ! for (i = useddlsegments; --i >= 0;) { ! if ((f = dlsym(dlsegment[i].handle, sym_p))) { ! return((long)f); ! } } } return 0; } --- 201,270 ---- if (!linkerinitialized) { (void)sysInitializeLinker(); } ! ! #ifndef __linux__ ! #ifdef __FreeBSD__ ! strcpy(buf+1, sym_p); ! buf[0] = '_'; ! sym_p = buf; ! #endif ! for (i = useddlsegments; --i >= 0;) { ! if ((f = dlsym(dlsegment[i].handle, sym_p))) { ! return((long)f); } } return 0; + #else + if ((f = dlsym(RTLD_NEXT, sym_p)) == 0) { + for (i = useddlsegments; --i >= 0;) { + if ((f = dlsym(dlsegment[i].handle, sym_p))) { + return((long)f); + } + } + } + return f; + #endif + } + + static char * + wrap_dlopen(char *fn, int mode) + { + char *ldpath = getenv("LD_LIBRARY_PATH"); + char *dir; + char *handle; + char *curend; + char path[512]; + char file[512]; + + if (ldpath == NULL) { + ldpath = ""; + } + path[0] = '\0'; strncat(path, ldpath, sizeof(path)-1); + #if 0 + jio_fprintf(stderr, "Trying to dlopen(\"%s\", %d) on \"%s\"\n", fn, mode + , path); + #endif + curend = path; + do { + dir = curend; + if ((curend = index(dir, ':')) != NULL) { + *curend++ = '\0'; + } + else { + curend = dir + strlen(dir); + } + + file[0] = '\0'; + strncat(file, *dir ? dir : ".", sizeof(file)-1); + strncat(file, "/", sizeof(file)-1-strlen(file)-1); + strncat(file, fn, sizeof(file)-1-strlen(file)-strlen(fn)); + #if 0 + jio_fprintf(stderr, " Check file: %s\n", file); + #endif + if (handle=dlopen(file, mode)) { + break; + } + } while (*curend); + return handle; } *** ./src/freebsd/java/runtime/system_md.c.orig Fri Feb 7 20:05:58 1997 --- ./src/freebsd/java/runtime/system_md.c Wed Jun 11 10:40:26 1997 *************** *** 30,37 **** --- 30,39 ---- #include "finalize.h" #include "jni.h" + #if 0 /* Not in sys/time.h, for some reason */ int gettimeofday(struct timeval *, void *); + #endif long sysGetMilliTicks() *************** *** 62,89 **** * thread-safe (including Green thread-safe using our synch.c trick), * so we must use _r versions of those functions. In the native threads * system, _REENTRANT is defined. */ #include - #ifndef _REENTRANT - extern struct tm *gmtime_r(const time_t *, struct tm *); - extern struct tm *localtime_r(const time_t *, struct tm *); - #endif /* _REENTRANT */ struct tm * sysLocaltime(time_t *t, struct tm *tm) { ! return localtime_r(t, tm); } struct tm * sysGmtime(time_t *t, struct tm *tm) { ! return gmtime_r(t, tm); } void sysStrftime(char *buf, int buflen, char *fmt, struct tm *t) { strftime(buf, buflen, fmt, t); } --- 64,101 ---- * thread-safe (including Green thread-safe using our synch.c trick), * so we must use _r versions of those functions. In the native threads * system, _REENTRANT is defined. + * + * Unfortunately, there is no equivalent under SunOS. For now, lets just hope =) + * */ #include struct tm * sysLocaltime(time_t *t, struct tm *tm) { ! /*!*/ ! struct tm *ptm; ! ptm = localtime(t); ! *tm = *ptm; ! return tm; } struct tm * sysGmtime(time_t *t, struct tm *tm) { ! /*!*/ ! struct tm *ptm; ! ptm = gmtime(t); ! *tm = *ptm; ! return tm; } void sysStrftime(char *buf, int buflen, char *fmt, struct tm *t) { + #ifdef __FreeBSD__ + t->tm_zone=NULL; /* this field isn't used in Solaris */ + #endif strftime(buf, buflen, fmt, t); } *************** *** 131,137 **** } typedef void (*pProc)(void); ! static struct exit_proc { pProc proc; struct exit_proc *next; --- 143,149 ---- } typedef void (*pProc)(void); ! /* should be flag on memmove */ static struct exit_proc { pProc proc; struct exit_proc *next; *************** *** 211,214 **** --- 223,250 ---- abort_procs = pAbort; return 0; } + + #if defined(SUNOS4) + void memmove(void *dest, const void *src, size_t len) + { + bcopy( src, dest, len ); + } + #endif + + /* should be flag on atoll */ + #if !defined(SOLARIS) + long long atoll(const char *data) + { + return atol(data); + } + #endif + + /* bad thing.. what is using atexit() ? */ + /* looks like javai.c uses it for exiting stuff... need a way to do this =/ */ + #if defined(SUNOS4) + void atexit(void (*function)()) + { + } + #endif + *** ./src/freebsd/java/runtime/memory_md.c.orig Fri Feb 7 20:06:00 1997 --- ./src/freebsd/java/runtime/memory_md.c Wed Jun 11 10:40:26 1997 *************** *** 58,63 **** --- 58,67 ---- #endif /* !USE_MALLOC */ + #ifndef MAP_FAILED + #define MAP_FAILED ((caddr_t)-1) + #endif + static unsigned int memGrainSize; /* A page for Solaris */ /* *************** *** 93,103 **** * Set system-specific variables used by mem allocator */ if (memGrainSize == 0) { memGrainSize = sysconf(_SC_PAGESIZE); } #ifndef USE_MALLOC ! devZeroFD = open("/dev/zero", O_RDWR); if (devZeroFD == -1) { perror("devzero"); sysExit(1); --- 97,115 ---- * Set system-specific variables used by mem allocator */ if (memGrainSize == 0) { + #ifdef _SC_PAGESIZE memGrainSize = sysconf(_SC_PAGESIZE); + #elif defined(PAGESIZE) + memGrainSize = PAGESIZE; + #elif defined(__FreeBSD__) + memGrainSize = getpagesize(); + #else + memGrainSize = 8192; /* should be enough */ + #endif } #ifndef USE_MALLOC ! devZeroFD = open("/dev/zero", O_RDWR, 0); if (devZeroFD == -1) { perror("devzero"); sysExit(1); *** ./src/freebsd/java/runtime/properties_md.c.orig Fri Feb 7 20:05:58 1997 --- ./src/freebsd/java/runtime/properties_md.c Wed Jun 11 10:40:26 1997 *************** *** 26,32 **** --- 26,36 ---- #include #include #include + #ifdef __FreeBSD__ + #include + #else #include + #endif #include "timeval.h" #include "sys_api.h" *************** *** 62,67 **** --- 66,72 ---- char *lc; char *arch; int sizeOfArch=12; + struct utsname un; /* java properties */ PUTPROP(props, "java.version", RELEASE); *************** *** 78,86 **** PUTPROP(props, "java.class.path", v ? v : ""); /* os properties */ ! PUTPROP(props, "os.name", "Solaris"); ! PUTPROP(props, "os.version", "2.x"); ! arch = (char *) malloc(sizeOfArch); sysinfo(SI_ARCHITECTURE, arch, sizeOfArch); if (strcmp(arch,"sparc") == 0 ) { --- 83,95 ---- PUTPROP(props, "java.class.path", v ? v : ""); /* os properties */ ! uname(&un); ! PUTPROP(props, "os.name", un.sysname); ! PUTPROP(props, "os.version", un.release); ! ! #ifdef __FreeBSD__ ! PUTPROP(props, "os.arch", un.machine); ! #else arch = (char *) malloc(sizeOfArch); sysinfo(SI_ARCHITECTURE, arch, sizeOfArch); if (strcmp(arch,"sparc") == 0 ) { *************** *** 93,98 **** --- 102,108 ---- } else { PUTPROP(props, "os.arch", "Unknown"); } + #endif /* file system properties */ *************** *** 187,192 **** --- 197,203 ---- /* User TIMEZONE */ { struct tm *tmData; + extern char *tzname[2]; time_t clock = time(NULL); tzset(); tmData = localtime(&clock); *** ./src/freebsd/java/runtime/invokeNative_x86.s.orig Fri Feb 7 20:06:00 1997 --- ./src/freebsd/java/runtime/invokeNative_x86.s Wed Jun 11 10:40:26 1997 *************** *** 1,100 **** ! / ! / @(#)invokeNative_x86.s 1.1 96/09/19 ! / ! / Copyright (c) 1993-1996 Sun Microsystems, Inc. All Rights Reserved. ! / ! / Permission to use, copy, modify, and distribute this software ! / and its documentation for NON-COMMERCIAL purposes and without ! / fee is hereby granted provided that this copyright notice ! / appears in all copies. ! / ! / The Java source code is the confidential and proprietary information ! / of Sun Microsystems, Inc. ("Confidential Information"). You shall ! / not disclose such Confidential Information and shall use it only in ! / accordance with the terms of the license agreement you entered into ! / with Sun. ! / ! / SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF ! / THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED ! / TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A ! / PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ! / ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR ! / DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. ! / .file "invokeNative_x86.s" ! .section .text .align 4 ! .globl sysInvokeNative ! / This function translates the "Java" calling convention into the "C" ! / calling convention used in native methods. Java VM passes all the ! / arguments in the Java stack, and expects the results to be placed there ! / as well. We therefore have to copy the arguments into the C stack (or ! / registers), and place the return values back into the Java stack. ! / ! / With a small sacrifise in efficiency, this approach avoids having to ! / generate a stub function for every native methods. ! / ! / The x86 passes all arguments on stack, and returns floating pointer ! / results in ST0, 32-bit results in eax, and 64-bit results in eax and ! / edx. ! / ! / The first argument to sysInvokeNative is a pointer to the JNI ! / environment, which should be passed unmodified as the first argument ! / to the native method. ! / ! / The second argument is a pointer to the "real" native method function. ! / ! / The third argument (stk) is a pointer to the Java stack, where all ! / the arguments are stored (as stk[0], stk[1], etc.). ! / ! / The fourth argument is the signature of the native method. ! / ! / The fifth argument is the total size (in 32-bit words) of the ! / arguments on the Java stack. Note that the Java stack does not have ! / any alignment requirement, and stores all arguments consecutively in ! / words and double words. The argument size includes the "this" pointer ! / for non-static methods. ! / ! / The sixth argument is 0 for non-static methods, or a pointer to HClass ! / for static methods. Non-static native methods receive an object ! / pointer as the second argument (passed on the Java stack as ! / stk[0]). The "real" method arguments to non-static methods begin at ! / stk[1]. Static native methods receive a class pointer as the second ! / argument. ! / ! / The return value of the native method is placed at stk[0] for ! / word-sized results, or at stk[0] and stk[1] for ! / double-word-sized results. The return value of sysInvokeNative is ! / stk if the native method returns void, stk+1 if the native ! / method returns a word, or stk+2 if the native method returns a ! / double word. ! ! /_env$ = 8 ; JNI environment ! /_f$ = 12 ; native method function ! /_stk$ = 16 ; Java stack ! /_sig$ = 20 ; method signature ! /_sz$ = 24 ; total argument size ! /_cls$ = 28 ; class (if static) ! sysInvokeNative: push %ebp mov %esp, %ebp push %esi push %edi ! movl 16(%ebp), %esi / stk ! movl 24(%ebp), %edx / sz ! movl 28(%ebp), %ecx / cls subl $1, %edx jc push_class shll $2, %edx ! / Push the last argument first. args_loop: movl (%esi,%edx), %eax --- 1,100 ---- ! # ! # @(#)invokeNative_x86.s 1.1 96/09/19 ! # ! # Copyright (c) 1993-1996 Sun Microsystems, Inc. All Rights Reserved. ! # ! # Permission to use, copy, modify, and distribute this software ! # and its documentation for NON-COMMERCIAL purposes and without ! # fee is hereby granted provided that this copyright notice ! # appears in all copies. ! # ! # The Java source code is the confidential and proprietary information ! # of Sun Microsystems, Inc. ("Confidential Information"). You shall ! # not disclose such Confidential Information and shall use it only in ! # accordance with the terms of the license agreement you entered into ! # with Sun. ! # ! # SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF ! # THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED ! # TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A ! # PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ! # ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR ! # DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. ! # .file "invokeNative_x86.s" ! .text .align 4 ! .globl _sysInvokeNative ! # This function translates the "Java" calling convention into the "C" ! # calling convention used in native methods. Java VM passes all the ! # arguments in the Java stack, and expects the results to be placed there ! # as well. We therefore have to copy the arguments into the C stack (or ! # registers), and place the return values back into the Java stack. ! # ! # With a small sacrifise in efficiency, this approach avoids having to ! # generate a stub function for every native methods. ! # ! # The x86 passes all arguments on stack, and returns floating pointer ! # results in ST0, 32-bit results in eax, and 64-bit results in eax and ! # edx. ! # ! # The first argument to sysInvokeNative is a pointer to the JNI ! # environment, which should be passed unmodified as the first argument ! # to the native method. ! # ! # The second argument is a pointer to the "real" native method function. ! # ! # The third argument (stk) is a pointer to the Java stack, where all ! # the arguments are stored (as stk[0], stk[1], etc.). ! # ! # The fourth argument is the signature of the native method. ! # ! # The fifth argument is the total size (in 32-bit words) of the ! # arguments on the Java stack. Note that the Java stack does not have ! # any alignment requirement, and stores all arguments consecutively in ! # words and double words. The argument size includes the "this" pointer ! # for non-static methods. ! # ! # The sixth argument is 0 for non-static methods, or a pointer to HClass ! # for static methods. Non-static native methods receive an object ! # pointer as the second argument (passed on the Java stack as ! # stk[0]). The "real" method arguments to non-static methods begin at ! # stk[1]. Static native methods receive a class pointer as the second ! # argument. ! # ! # The return value of the native method is placed at stk[0] for ! # word-sized results, or at stk[0] and stk[1] for ! # double-word-sized results. The return value of sysInvokeNative is ! # stk if the native method returns void, stk+1 if the native ! # method returns a word, or stk+2 if the native method returns a ! # double word. ! ! #_env$ = 8 ; JNI environment ! #_f$ = 12 ; native method function ! #_stk$ = 16 ; Java stack ! #_sig$ = 20 ; method signature ! #_sz$ = 24 ; total argument size ! #_cls$ = 28 ; class (if static) ! _sysInvokeNative: push %ebp mov %esp, %ebp push %esi push %edi ! movl 16(%ebp), %esi # stk ! movl 24(%ebp), %edx # sz ! movl 28(%ebp), %ecx # cls subl $1, %edx jc push_class shll $2, %edx ! # Push the last argument first. args_loop: movl (%esi,%edx), %eax *************** *** 109,124 **** pushl %ecx push_env: ! pushl 8(%ebp) / env ! / Invoke the native method ! call *12(%ebp) / f ! / Clean up stack ! movl 24(%ebp), %ecx / sz ! movl 28(%ebp), %ebx /cls cmpl $0, %ebx jz non_static_method incl %ecx --- 109,124 ---- pushl %ecx push_env: ! pushl 8(%ebp) # env ! # Invoke the native method ! call *12(%ebp) # f ! # Clean up stack ! movl 24(%ebp), %ecx # sz ! movl 28(%ebp), %ebx #cls cmpl $0, %ebx jz non_static_method incl %ecx *************** *** 128,136 **** shll $2, %ecx addl %ecx, %esp ! / find out the return type ! movl 20(%ebp), %ebx / sig desc_loop: incl %ebx --- 128,136 ---- shll $2, %ecx addl %ecx, %esp ! # find out the return type ! movl 20(%ebp), %ebx # sig desc_loop: incl %ebx *************** *** 188,193 **** popl %ebp ret .align 4 ! .type sysInvokeNative,@function ! .size sysInvokeNative,.-sysInvokeNative --- 188,193 ---- popl %ebp ret .align 4 ! .type _sysInvokeNative,@function ! .size _sysInvokeNative,.-_sysInvokeNative *** ./src/freebsd/java/green_threads/include/internal_md.h.orig Fri Feb 7 20:06:06 1997 --- ./src/freebsd/java/green_threads/include/internal_md.h Wed Jun 11 10:40:27 1997 *************** *** 28,33 **** --- 28,34 ---- #define _SOLARIS_INTERNAL_MD_H_ #include + #include /* * Machine dependent info *** ./src/freebsd/java/green_threads/include/iomgr.h.orig Fri Feb 7 20:06:06 1997 --- ./src/freebsd/java/green_threads/include/iomgr.h Wed Jun 11 10:40:27 1997 *************** *** 28,33 **** --- 28,37 ---- #ifndef _GREEN_IOMGR_H_ #define _GREEN_IOMGR_H_ + #ifndef SOLARIS + #define FCNTL_HACK 1 + #endif /* not SOLARIS */ + #include "monitor.h" int nonblock_io(int,int); *************** *** 53,60 **** --- 57,69 ---- #define FD_NBINIT 0x1 #define FD_CLOSED 0x2 + #ifdef __linux__ + #define READ_TIMEOUT 20 + #define WRITE_TIMEOUT 20 + #else #define READ_TIMEOUT TIMEOUT_INFINITY #define WRITE_TIMEOUT TIMEOUT_INFINITY + #endif #define check_single_fd(fd) \ if ((fd_flags[fd] & FD_NBINIT) == 0) { \ *************** *** 87,92 **** --- 96,103 ---- #define SYS_FCNTL 10 #define SYS_DUP 11 #define SYS_CREAT 12 + #define SYS_ACCEPT 13 + #define SYS_SELECT 14 #define SYS_ACCEPT 13 #endif /* !_GREEN_IOMGR_H_ */ *** ./src/freebsd/java/green_threads/include/threads_md.h.orig Fri Feb 7 20:06:06 1997 --- ./src/freebsd/java/green_threads/include/threads_md.h Wed Jun 11 10:40:27 1997 *************** *** 119,130 **** --- 119,136 ---- extern sys_thread_t *_CurrentThread; extern void setCurrentThread(sys_thread_t *); + #if !defined(__FreeBSD__) + #include + #endif + #define greenThreadSelf() (_CurrentThread) extern void threadWakeup(sys_thread_t *); extern int threadSetSchedulingPriority(sys_thread_t *, int priority); + #ifndef MAX #define MAX(x, y) ((x) > (y) ? (x) : (y)) + #endif #define INVERSION_PRIORITY(tid) \ MAX((tid)->oldPriority, (tid)->inversion_queue->monitor_waitq->priority) *** ./src/freebsd/java/green_threads/include/context_md.h.orig Fri Feb 7 20:06:06 1997 --- ./src/freebsd/java/green_threads/include/context_md.h Wed Jun 11 10:40:27 1997 *************** *** 28,35 **** #define _SOLARIS_CONTEXT_MD_H_ #include ! #include ! #include /* * Routines that call getcontext have strange control flow graphs, --- 28,44 ---- #define _SOLARIS_CONTEXT_MD_H_ #include ! #include ! #include ! #include ! #include ! ! typedef struct lj_ucontext { ! sigjmp_buf jmpbuf; ! #if (defined(__linux__) && defined(__i386__)) || defined(__FreeBSD__) ! char floatbuf[108]; ! #endif ! } lj_ucontext_t; /* * Routines that call getcontext have strange control flow graphs, *************** *** 44,50 **** */ typedef struct { unsigned int unix_errno; ! ucontext_t ucontext; } context_t; /* Save state of the current content and call rescheduler */ --- 53,59 ---- */ typedef struct { unsigned int unix_errno; ! lj_ucontext_t lj_ucontext; } context_t; /* Save state of the current content and call rescheduler */ *************** *** 55,62 **** #define switchContext(contextp) { \ errno = (contextp)->unix_errno; \ ! ((contextp)->ucontext).uc_mcontext.gregs[EAX] = 1; \ ! setcontext(&((contextp)->ucontext)); \ } #elif defined(sparc) --- 64,70 ---- #define switchContext(contextp) { \ errno = (contextp)->unix_errno; \ ! lj_setcontext(&((contextp)->lj_ucontext)); \ } #elif defined(sparc) *************** *** 73,82 **** --- 81,103 ---- #endif + #if (defined(__linux__) && defined(__i386__)) || defined(__FreeBSD__) + #define yieldContext(contextp) \ + { \ + char * fdata = (char *)contextp->lj_ucontext.floatbuf; \ + __asm__ ("fsave %0"::"m" (*fdata)); \ + __asm__ ("fwait"); \ + if (!sigsetjmp(contextp->lj_ucontext.jmpbuf,-1)) { \ + (contextp)->unix_errno = errno; \ + reschedule(); \ + } \ + } + #else #define yieldContext(contextp) \ if (getcontext(&((contextp)->ucontext)) == 0) { \ (contextp)->unix_errno = errno; \ reschedule(); \ } + #endif #endif /* !_SOLARIS_CONTEXT_MD_H_ */ *** ./src/freebsd/java/green_threads/src/context.c.orig Fri Feb 7 20:06:10 1997 --- ./src/freebsd/java/green_threads/src/context.c Wed Jun 11 10:40:27 1997 *************** *** 26,31 **** --- 26,34 ---- #include #include + #ifndef PROT_NONE + #define PROT_NONE 0 + #endif #include #include #include *************** *** 36,46 **** #include "itimer_md.h" #include "sparc_md.h" #include "context.h" #include "log.h" #include "schedule.h" ! #include "sys_api.h" ! /* * The list on which we put freed thread stacks pending reclamation. */ --- 39,52 ---- #include "itimer_md.h" #include "sparc_md.h" #include "context.h" + #include "debug.h" #include "log.h" #include "schedule.h" ! #ifdef SUNOS4 ! #include ! #endif ! /* * The list on which we put freed thread stacks pending reclamation. */ *************** *** 100,107 **** stack->stack_size, stackFreeCount); /* Don't forget the redzone... */ size = stack->stack_size + redZoneSize; /* REMIND: Ignoring return value here... */ ! sysUnmapMem((char *)stack - redZoneSize, size, &junk); stack = next; } } --- 106,115 ---- stack->stack_size, stackFreeCount); /* Don't forget the redzone... */ size = stack->stack_size + redZoneSize; + /*stack -= redZoneSize;*/ /*!!! NO!! redZoneSize is in BYTES */ + /*!!! stack is not... bad pointer arith */ /* REMIND: Ignoring return value here... */ ! sysUnmapMem(((char *)stack)-redZoneSize, size, &junk); stack = next; } } *************** *** 152,158 **** } else { /* Didn't get one */ SCHED_UNLOCK(); /* Can't allocate with SCHED_LOCKED() */ if (redZoneSize == 0) { ! redZoneSize = sysconf(_SC_PAGESIZE); /* one page */ } size += redZoneSize; /* For redzone */ stack->base = (stackp_t) sysMapMem(size, &size); --- 160,172 ---- } else { /* Didn't get one */ SCHED_UNLOCK(); /* Can't allocate with SCHED_LOCKED() */ if (redZoneSize == 0) { ! #ifdef _SC_PAGESIZE ! redZoneSize = sysconf(_SC_PAGESIZE); ! #elif defined(PAGESIZE) ! redZoneSize = PAGESIZE; ! #else ! redZoneSize = 8192; /* should be enough */ ! #endif } size += redZoneSize; /* For redzone */ stack->base = (stackp_t) sysMapMem(size, &size); *************** *** 183,190 **** currentStackPointer(sys_thread_t *tp) { context_t *context = &tp->mdcontext; ! ucontext_t *uc = &(context->ucontext); ! #ifdef i386 return (void *) (uc->uc_mcontext.gregs[USP]); #elif sparc return (void *) (uc->uc_mcontext.gregs[REG_O6]); --- 197,206 ---- currentStackPointer(sys_thread_t *tp) { context_t *context = &tp->mdcontext; ! lj_ucontext_t *uc = &(context->lj_ucontext); ! #ifdef __FreeBSD__ ! return (void *)(uc->jmpbuf->_sjb[2]); ! #elif i386 return (void *) (uc->uc_mcontext.gregs[USP]); #elif sparc return (void *) (uc->uc_mcontext.gregs[REG_O6]); *************** *** 220,231 **** void (*death_func)(), unsigned int arg) { context_t *mdcontext = CONTEXT(tid); ! ucontext_t *uc = &(mdcontext->ucontext); machdep_t *machdepP = MACHDEP(tid); unsigned char *sp; int *p; - getcontext(uc); sp = (unsigned char *) tid->stack_base; /* Note: WINDOWSIZE stuff is for SPARC, not really needed for x86 */ sp -= (sizeof(sys_thread_t) + WINDOWSIZE + SA(MINFRAME)); --- 236,247 ---- void (*death_func)(), unsigned int arg) { context_t *mdcontext = CONTEXT(tid); ! lj_ucontext_t *uc = &(mdcontext->lj_ucontext); machdep_t *machdepP = MACHDEP(tid); unsigned char *sp; int *p; + char *fdata; sp = (unsigned char *) tid->stack_base; /* Note: WINDOWSIZE stuff is for SPARC, not really needed for x86 */ sp -= (sizeof(sys_thread_t) + WINDOWSIZE + SA(MINFRAME)); *************** *** 236,252 **** --- 252,285 ---- *p-- = (int ) pc; *p-- = (int ) arg; *p-- = (int ) 1; /* dummy arg - for compatibility with SPARC version */ + #if defined(__FreeBSD__) + *p-- = (int ) 0; + #endif + + #ifndef __FreeBSD__ uc->uc_stack.ss_sp = (char *) p; uc->uc_stack.ss_size = tid->stack_size; + #endif /* initialially all signals are enabled */ /* FIXME change to be initially disabled? */ + #ifdef __FreeBSD__ + memset(uc, 0, sizeof(lj_ucontext_t)); + fdata = (char *)uc->floatbuf; + __asm__ ("fsave %0"::"m" (*fdata)); + __asm__ ("fwait"); + uc->jmpbuf->_sjb[3] = (int)(char *)p; + uc->jmpbuf->_sjb[2] = (int)(char *)p; + uc->jmpbuf->_sjb[0] = (int)death_func; + uc->jmpbuf->_sjb[7] = 0x127f; /* FPU mask */ + #else memset((char *)&(uc->uc_sigmask), 0, sizeof(sigset_t)); machdepP->intrLockCount = 0; uc->uc_mcontext.gregs[USP] = (unsigned int) p; uc->uc_mcontext.gregs[PC] = (unsigned int) death_func; + #endif } #elif sparc *************** *** 410,416 **** * The normal case: queue the stack and the thread private data * to be freed when safe. */ ! sysAssert(0 <= tid->stack_size); /* Note that free stacks are pointed to *above* the redzone */ tmp = (free_stack_t *)((char *) tid->stack_base - tid->stack_size); tmp->stack_size = tid->stack_size; --- 443,449 ---- * The normal case: queue the stack and the thread private data * to be freed when safe. */ ! assert(0 <= tid->stack_size); /* Note that free stacks are pointed to *above* the redzone */ tmp = (free_stack_t *)((char *) tid->stack_base - tid->stack_size); tmp->stack_size = tid->stack_size; *************** *** 422,424 **** --- 455,491 ---- } return; } + + + #if 0 + #error THIS CANT BE IN A FUNCTION!!!! + int lj_getcontext(lj_ucontext_t *context) { + char * fdata = (char *)context->floatbuf; + __asm__ ("fsave %0"::"m" (*fdata)); + return sigsetjmp(context->jmpbuf,-1); + } + #endif + + int contextsaves=0; + int lj_setcontext(lj_ucontext_t *context) { + #if (defined(__linux__) && defined(__i386__)) + char * fdata; + contextsaves++; + fdata = (char *)context->floatbuf; + __asm__ ("frstor %0"::"m" (*fdata)); + siglongjmp(context->jmpbuf,1); + #elif defined(__FreeBSD__) + char * fdata; + contextsaves++; + fdata = (char *)context->floatbuf; + __asm__ ("frstor %0"::"m" (*fdata)); + __asm__ ("fwait"); + siglongjmp(context->jmpbuf,1); + #else + longjmp(context->jmpbuf,1); + #endif + return 0; + } + + + *** ./src/freebsd/java/green_threads/src/interrupt_md.c.orig Fri Feb 7 20:06:08 1997 --- ./src/freebsd/java/green_threads/src/interrupt_md.c Wed Jun 11 10:40:28 1997 *************** *** 30,42 **** */ #include #include - #include - #include #include #include "sys_api.h" #include "oobj.h" #include "interpreter.h" #include "interrupt.h" #include "itimer_md.h" #include "log.h" --- 30,41 ---- */ #include #include #include #include "sys_api.h" #include "oobj.h" #include "interpreter.h" + #include "debug.h" #include "interrupt.h" #include "itimer_md.h" #include "log.h" *************** *** 92,99 **** /* * Local routine prototypes. */ ! static void signalHandlerPanic(int, siginfo_t *, void *); ! static void signalHandlerDispatch(int, siginfo_t *, void *); /* * Exported routines. --- 91,98 ---- /* * Local routine prototypes. */ ! static void signalHandlerPanic(int); ! static void signalHandlerDispatch(int); /* * Exported routines. *************** *** 169,199 **** intrInitMD() { struct sigaction sigAct; /* * Install the panic handler for the signals that should cause us * to panic. */ ! sigAct.sa_handler = NULL; ! sigAct.sa_sigaction = signalHandlerPanic; sigemptyset(&(sigAct.sa_mask)); sigaddset(&sigAct.sa_mask, SIGPIPE); ! sigAct.sa_flags = SA_SIGINFO | SA_RESTART; ! sigaction(SIGABRT, &sigAct, (struct sigaction *)0); sigaction(SIGBUS, &sigAct, (struct sigaction *)0); sigaction(SIGILL, &sigAct, (struct sigaction *)0); sigaction(SIGIOT, &sigAct, (struct sigaction *)0); ! sigaction(SIGEMT, &sigAct, (struct sigaction *)0); sigaction(SIGFPE, &sigAct, (struct sigaction *)0); sigaction(SIGQUIT, &sigAct, (struct sigaction *)0); sigaction(SIGSEGV, &sigAct, (struct sigaction *)0); ! sigaction(SIGSYS, &sigAct, (struct sigaction *)0); sigaction(SIGTRAP, &sigAct, (struct sigaction *)0); sigaction(SIGXCPU, &sigAct, (struct sigaction *)0); sigaction(SIGXFSZ, &sigAct, (struct sigaction *)0); ! sigignore(SIGPIPE); if (sigprocmask(SIG_SETMASK, &(sigAct.sa_mask), NULL)) perror("intrinitMD - 2"); --- 168,213 ---- intrInitMD() { struct sigaction sigAct; + struct sigaction sigActOld; /* * Install the panic handler for the signals that should cause us * to panic. */ ! sigAct.sa_handler = signalHandlerPanic; sigemptyset(&(sigAct.sa_mask)); sigaddset(&sigAct.sa_mask, SIGPIPE); ! #ifdef SA_RESTART ! sigAct.sa_flags = SA_RESTART; ! #endif ! /* sigaction(SIGABRT, &sigAct, (struct sigaction *)0);*/ ! /* handling abort results in an endless loop =( */ sigaction(SIGBUS, &sigAct, (struct sigaction *)0); sigaction(SIGILL, &sigAct, (struct sigaction *)0); sigaction(SIGIOT, &sigAct, (struct sigaction *)0); ! /* sigaction(SIGEMT, &sigAct, (struct sigaction *)0);*/ sigaction(SIGFPE, &sigAct, (struct sigaction *)0); sigaction(SIGQUIT, &sigAct, (struct sigaction *)0); sigaction(SIGSEGV, &sigAct, (struct sigaction *)0); ! /* sigaction(SIGSYS, &sigAct, (struct sigaction *)0);*/ sigaction(SIGTRAP, &sigAct, (struct sigaction *)0); sigaction(SIGXCPU, &sigAct, (struct sigaction *)0); sigaction(SIGXFSZ, &sigAct, (struct sigaction *)0); ! /* now we get the SIGLARM, and change it to block SIGIO */ ! /* this might not be needed on systems other than linux, ! but lets be safe here --RC */ ! #ifdef __linux__ ! sigaction(SIGALRM, &sigAct, &sigActOld); ! /* sigaddset(sigActOld.sa_mask, SIGIO); */ ! sigaction(SIGALRM, &sigActOld, (struct sigaction *)0); ! #else ! sigaction(SIGALRM, &sigAct, (struct sigaction *)0); ! #endif ! ! ! signal(SIGPIPE, SIG_IGN); if (sigprocmask(SIG_SETMASK, &(sigAct.sa_mask), NULL)) perror("intrinitMD - 2"); *************** *** 227,235 **** */ sigfillset(&(sigAct.sa_mask)); ! sigAct.sa_handler = 0; ! sigAct.sa_sigaction = signalHandlerDispatch; ! sigAct.sa_flags = SA_SIGINFO | SA_RESTART; sigaction(interrupt, &sigAct, (struct sigaction *)0); } --- 241,250 ---- */ sigfillset(&(sigAct.sa_mask)); ! sigAct.sa_handler = signalHandlerDispatch; ! #ifdef SA_RESTART ! sigAct.sa_flags = SA_RESTART; ! #endif sigaction(interrupt, &sigAct, (struct sigaction *)0); } *************** *** 247,255 **** * Set to the panic handler in case we get one when we shouldn't */ sigfillset(&(sigAct.sa_mask)); ! sigAct.sa_handler = NULL; ! sigAct.sa_sigaction = signalHandlerPanic; ! sigAct.sa_flags = SA_SIGINFO; sigaction(interrupt, &sigAct, (struct sigaction *)0); } --- 262,269 ---- * Set to the panic handler in case we get one when we shouldn't */ sigfillset(&(sigAct.sa_mask)); ! sigAct.sa_handler = signalHandlerPanic; ! sigAct.sa_flags = 0; sigaction(interrupt, &sigAct, (struct sigaction *)0); } *************** *** 257,262 **** --- 271,277 ---- * Local routines. */ + #if 0 /* * Decode a siginfo_t structure, and print out something interesting * about it. Truncate and succeed if the buffer write overflows. It's *************** *** 373,378 **** --- 388,394 ---- return msg; } } + #endif /*- * signalHandlerPanic() -- Deal with unexpected signals by dumping *************** *** 380,406 **** * panicing. */ static void ! signalHandlerPanic(int sig, siginfo_t *info, void *uc) { extern void CompiledCodeSignalHandler(int sig, siginfo_t *info, void *uc); extern void DumpMonitors(); extern void DumpAlarmQ(); static int count = 0; if (sig != SIGQUIT && count > 0) { signal(SIGABRT, SIG_DFL); sysAbort(); } CompiledCodeSignalHandler(sig, info, uc); count += 1; if (sig > MAXSIG) { jio_fprintf(stderr, "Unknown signal: %d\n", sig); } else { jio_fprintf(stderr, "%s\n", signalNames[sig]); } if (info) { /* print out signal info */ if (info->si_code != SI_NOINFO) { --- 396,435 ---- * panicing. */ static void ! signalHandlerPanic(int sig) { + #ifndef __FreeBSD__ extern void CompiledCodeSignalHandler(int sig, siginfo_t *info, void *uc); + #endif extern void DumpMonitors(); extern void DumpAlarmQ(); static int count = 0; if (sig != SIGQUIT && count > 0) { + #ifdef __FreeBSD__ + /*abort();*/ + kill(getpid(),SIGKILL); + #else signal(SIGABRT, SIG_DFL); sysAbort(); + #endif } + #ifndef __FreeBSD__ CompiledCodeSignalHandler(sig, info, uc); + #endif count += 1; + #ifndef MAXSIG + #define MAXSIG NSIG + #endif if (sig > MAXSIG) { jio_fprintf(stderr, "Unknown signal: %d\n", sig); } else { jio_fprintf(stderr, "%s\n", signalNames[sig]); } + #ifndef __FreeBSD__ if (info) { /* print out signal info */ if (info->si_code != SI_NOINFO) { *************** *** 418,430 **** --- 447,464 ---- sysThreadStackPointer(greenThreadSelf())); } } + #endif DumpThreads(); DumpMonitors(); DumpAlarmQ(); if (sig != SIGQUIT) { + #ifdef __FreeBSD__ + abort(); + #else signal(SIGABRT, SIG_DFL); sysAbort(); + #endif } } *************** *** 432,448 **** * signalHandlerDispatch() -- Turn our signal into an intrDispatch(). */ static void ! signalHandlerDispatch(int sig, siginfo_t *info, void *uc) { int old_errno; if (sig == SIGSEGV) ! sysExit(1); Log1(1, "signalHandlerDispatch(sig=%d)\n", sig); old_errno = errno; ! intrDispatch(sig, (void *) info); errno = old_errno; --- 466,482 ---- * signalHandlerDispatch() -- Turn our signal into an intrDispatch(). */ static void ! signalHandlerDispatch(int sig) { int old_errno; if (sig == SIGSEGV) ! exit(1); Log1(1, "signalHandlerDispatch(sig=%d)\n", sig); old_errno = errno; ! intrDispatch(sig, (void *) NULL); errno = old_errno; *** ./src/freebsd/java/green_threads/src/io_md.c.orig Fri Feb 7 20:06:08 1997 --- ./src/freebsd/java/green_threads/src/io_md.c Wed Jun 11 10:40:28 1997 *************** *** 65,73 **** #include #include #include - #include #include ! #include #include "threads.h" #include "threads_md.h" --- 65,76 ---- #include #include #include #include ! #ifdef __linux__ ! #include ! #else ! #include ! #endif #include "threads.h" #include "threads_md.h" *************** *** 77,82 **** --- 80,91 ---- #include "log.h" #include "fd_md.h" + #ifndef __solaris__ + typedef unsigned boolean_t; + #define B_TRUE ((boolean_t)1) + #define B_FALSE ((boolean_t)0) + #endif + extern int pendingException(); extern boolean_t initialize_monitors(int); extern int system_close(int); *************** *** 201,213 **** FD_ZERO(&fds); FD_SET(fd, &fds); ! ret = _select(fdobj->fd, &fds, 0, 0, &zt); if (ret == 0) { /* we have to wait */ while (1) { sysMonitorWait(mon, timeout, FALSE); FD_SET(fd, &fds); ! ret = _select(fdobj->fd, &fds, 0, 0, &zt); if (ret) { break; } --- 210,222 ---- FD_ZERO(&fds); FD_SET(fd, &fds); ! ret = (*systable[SYS_SELECT].addr)(fdobj->fd, &fds, 0, 0, &zt); if (ret == 0) { /* we have to wait */ while (1) { sysMonitorWait(mon, timeout, FALSE); FD_SET(fd, &fds); ! ret = (*systable[SYS_SELECT].addr)(fdobj->fd, &fds, 0, 0, &zt); if (ret) { break; } *************** *** 503,508 **** --- 512,518 ---- sysAcceptFD(Classjava_io_FileDescriptor *fdobj, struct sockaddr *him, int *len) { int fd = fdobj->fd - 1; + int newfd; int ret = -1; sys_mon_t *mon; *************** *** 516,526 **** sysMonitorEnter(mon); fd = fdobj->fd - 1; ! if (fd >= 0) { ! ret = accept(fd, him, len); } sysMonitorExit(mon); ! return ret; } int --- 526,562 ---- sysMonitorEnter(mon); fd = fdobj->fd - 1; ! if (fd>=0) { ! fd_ref[fd]++; ! ! while(!pendingException() && !closed_fd(fd)) { ! ret = accept(fd, him, len); ! ! if ((ret != -1) || pendingException() || ! ((errno != EAGAIN) && (errno != EINTR))) ! break; ! if (errno == EAGAIN) ! sysMonitorWait(mon, READ_TIMEOUT, FALSE); ! } ! ! fd_ref[fd]--; ! /* If I am the last person to leave and fd has been closed ! call system close on the fd */ ! if (fd_ref[fd]==0 && closed_fd(fd)) system_close(fd); ! } sysMonitorExit(mon); ! ! newfd = ret; ! if (newfd != -1) { ! Log1(1, "Accepted fd: %d\n", newfd); ! ret = initialize_monitors(newfd); ! /* fdobj->fd = newfd+1;*/ ! } else { ! Log1(1, "accept error: %d\n", errno); ! } ! ! return newfd; } int *************** *** 553,563 **** result = connect(s, him, len); while (result < 0 && !pendingException()) { ! if (errno == EINPROGRESS) { ! int cnt = _select(s+1, 0, &write_fds, 0, &poll); FD_SET(s, &write_fds); if (cnt == 1) { int bytes; if (ioctl(s, FIONREAD, &bytes) == -1) { --- 589,607 ---- result = connect(s, him, len); while (result < 0 && !pendingException()) { ! if (errno == EINPROGRESS || errno == EAGAIN || errno == EINTR) { ! int cnt = (*systable[SYS_SELECT].addr)(s+1,0,&write_fds,0,&poll); FD_SET(s, &write_fds); if (cnt == 1) { + #ifdef __FreeBSD__ + struct sockaddr rconn; + int rconnlen = sizeof(struct sockaddr); + + if(!(getpeername(s, &rconn, &rconnlen))) { + errno = ECONNREFUSED; /* not necessarily, but likely */ + } + #else int bytes; if (ioctl(s, FIONREAD, &bytes) == -1) { *************** *** 572,577 **** --- 616,622 ---- sysAssert(result < 0); break; } + #endif result = 0; break; } *************** *** 682,687 **** --- 727,759 ---- sysRecvfromFD(Classjava_io_FileDescriptor * fdobj, char *buf, int nbytes, int flags, struct sockaddr *from, int *fromlen) { + #ifdef __FreeBSD__ + int fd = fdobj->fd-1; + register int nread = -1; + fd_set readset, writeset, exceptset; + int status; + + check_single_fd(fd); + + /* Since the recvfrom is not working in nonblocking manner, + we select on the fd until there is data. Poll succeeds + when client sends data. So then do a blocking recvfrom */ + + FD_ZERO(&readset); + FD_ZERO(&writeset); + FD_ZERO(&exceptset); + FD_SET(fd,&readset); + + Log1(1, "Going into recvfrom on fd %d\n", fd); + if ((status = select(fd+1, &readset, &writeset, &exceptset, NULL)) <=0) { + Log2(1, "polling before recvfrom failed with status %d, errno %d\n", + status, errno); /* this isnt what this does.... */ + } else { + nread = recvfrom(fd, buf, nbytes, flags, from, fromlen); + Log2(1, "Recvfrom for %d bytes finished on fd: %d\n", nread, fd); + } + return nread; + #else sys_mon_t *mon; register int nread = -1; struct pollfd polltbl[1]; *************** *** 733,736 **** --- 805,809 ---- close(fd); } return nread; + #endif } *** ./src/freebsd/java/green_threads/src/iomgr.c.orig Fri Feb 7 20:06:10 1997 --- ./src/freebsd/java/green_threads/src/iomgr.c Fri Jun 13 16:39:02 1997 *************** *** 37,43 **** #include #include #include - #include #include #include #include --- 37,42 ---- *************** *** 46,54 **** #include #include #include #include ! #include #include "threads.h" #include "threads_md.h" --- 45,54 ---- #include #include + #if !(defined(__linux__) || defined(__FreeBSD__)) #include #include ! #endif #include "threads.h" #include "threads_md.h" *************** *** 61,66 **** --- 61,70 ---- #include "log.h" #include "sys_api.h" + typedef unsigned boolean_t; + #define B_TRUE ((boolean_t)1) + #define B_FALSE ((boolean_t)0) + /* * Pavani's Async IO notes: * *************** *** 136,157 **** #endif #define IO_OPTIMIZE syscall_t systable[] = { ! { "write", 0 }, ! { "writev", 0 }, ! { "read", 0 }, ! { "readv", 0 }, ! { "getmsg", 0 }, ! { "putmsg", 0 }, ! { "poll", 0 }, ! { "open", 0 }, ! { "close", 0 }, ! { "pipe", 0 }, ! { "fcntl", 0}, ! { "dup", 0 }, ! { "creat", 0 }, ! { "accept", 0 }, { (char *) 0, 0 } }; --- 140,168 ---- #endif #define IO_OPTIMIZE + #ifdef __FreeBSD__ + #ifdef SYS_TIMEOUT_INFINITY + #undef SYS_TIMEOUT_INFINITY + #endif + #define SYS_TIMEOUT_INFINITY 10 + #endif /* __FreeBSD__ */ syscall_t systable[] = { ! { "_write", 0 }, ! { "_writev", 0 }, ! { "_read", 0 }, ! { "_readv", 0 }, ! { "_getmsg", 0 }, ! { "_putmsg", 0 }, ! { "_poll", 0 }, ! { "_open", 0 }, ! { "_close", 0 }, ! { "_pipe", 0 }, ! { "_fcntl", 0}, ! { "_dup", 0 }, ! { "_creat", 0 }, ! { "_accept", 0 }, ! { "_select", 0 }, { (char *) 0, 0 } }; *************** *** 173,184 **** initSyscalls() { syscall_t *tp = systable; ! ! while (tp->sym != (char *) 0) { ! tp->addr = (sysfunc_t) dlsym(RTLD_NEXT, tp->sym); ! tp++; } ! } /* * Returns non-zero if an exception is pending for this ee. --- 184,206 ---- initSyscalls() { syscall_t *tp = systable; ! #if defined(__FreeBSD__) ! #define LIBRARY "/usr/lib/libc.so.2.2" ! #endif ! ! #ifndef RTLD_NEXT ! void *dlMain = dlopen(LIBRARY, 1); ! #endif ! ! while (tp->sym != (char *) 0) { ! #ifdef RTLD_NEXT ! tp->addr = (sysfunc_t) dlsym(RTLD_NEXT, tp->sym); ! #else ! tp->addr = (sysfunc_t) dlsym(dlMain, tp->sym); ! #endif ! tp++; } ! } /* * Returns non-zero if an exception is pending for this ee. *************** *** 278,283 **** --- 300,306 ---- nonblock_io(int desc, int onoff) { long flgs; + pid_t pid; sysAssert(desc < max_files); sysAssert(fdmon[desc] != NULL); *************** *** 297,304 **** --- 320,343 ---- return -1; } + #ifdef SOLARIS fcntl(desc, F_SETFL, flgs | O_NONBLOCK); ioctl(desc, I_SETSIG, S_INPUT | S_OUTPUT); + #else /* not SOLARIS */ + #if defined(FNONBLOCK) + flgs |= FNONBLOCK|FASYNC; + #else + flgs |= O_NONBLOCK|FASYNC; + #endif + fcntl(desc, F_SETFL, flgs); + pid = getpid (); + #if defined(F_SETOWN) + fcntl(desc, F_SETOWN, pid); + #endif + #if defined(FIOSETOWN) + ioctl(desc, FIOSETOWN, &pid); + #endif + #endif asyncIOActivateFD(desc); fd_flags[desc] |= FD_NBINIT; *************** *** 317,323 **** } fcntl(desc, F_SETFL, flgs & ~O_NONBLOCK); ! ioctl(desc, I_SETSIG, 0); fd_flags[desc] &= ~FD_NBINIT; --- 356,363 ---- } fcntl(desc, F_SETFL, flgs & ~O_NONBLOCK); ! /*this is a major loss and takes changing blocking code elsewhere */ ! /*ioctl(desc, I_SETSIG, 1);*/ fd_flags[desc] &= ~FD_NBINIT; *************** *** 367,372 **** --- 407,418 ---- return ret; } + #ifdef __FreeBSD__ + if (fdmon == NULL) { + return (*systable[SYS_CLOSE].addr)(fd); + } + #endif + sysMonitorEnter(fdmon[fd]); if (fd_ref[fd] == 0) { *************** *** 419,432 **** } ssize_t ! recv(int fd, char *buf, int nbytes, int flags) { return read(fd, (void *) buf, (uint) nbytes); } - ssize_t ! send(int fd, const char *buf, int nbytes, int flags) { return write(fd, buf, (uint) nbytes); } --- 465,477 ---- } ssize_t ! recv(int fd, void *buf, size_t nbytes, int flags) { return read(fd, (void *) buf, (uint) nbytes); } ssize_t ! send(int fd, __const void *buf, size_t nbytes, int flags) { return write(fd, buf, (uint) nbytes); } *************** *** 463,468 **** --- 508,539 ---- sysrecvfrom(int fd, char *buf, int nbytes, int flags, struct sockaddr *from, int *fromlen) { + #if defined(__linux__) || defined(__FreeBSD__) + register int nread = -1; + fd_set readset, writeset, exceptset; + int status; + + check_single_fd(fd); + + /* Since the recvfrom is not working in nonblocking manner, + we select on the fd until there is data. Poll succeeds + when client sends data. So then do a blocking recvfrom */ + + FD_ZERO(&readset); + FD_ZERO(&writeset); + FD_ZERO(&exceptset); + FD_SET(fd,&readset); + + Log1(1, "Going into recvfrom on fd %d\n", fd); + if ((status = select(fd+1, &readset, &writeset, &exceptset, NULL)) <=0) { + Log2(1, "polling before recvfrom failed with status %d, errno %d\n", + status, errno); /* this isnt what this does.... */ + } else { + nread = recvfrom(fd, buf, nbytes, flags, from, fromlen); + Log2(1, "Recvfrom for %d bytes finished on fd: %d\n", nread, fd); + } + return nread; + #else register int nread = -1; struct pollfd polltbl[1]; int status; *************** *** 487,492 **** --- 558,564 ---- } return nread; + #endif } int *************** *** 585,591 **** --- 657,676 ---- register int nwrote; register caddr_t next = (caddr_t)buf; register int total_written = 0; + #ifdef __FreeBSD__ + sys_mon_t *mon; + + if ((fdmon == NULL) || (fd == 2)) { /* java not running yet? */ + if (!systable[SYS_WRITE].addr) { /* system calls not init + ialized */ + initSyscalls(); + } + return (*systable[SYS_WRITE].addr)(fd, buf, nbytes); + } + mon = fdmon[fd]; + #else sys_mon_t *mon = fdmon[fd]; + #endif sysAssert(mon != NULL); *************** *** 609,616 **** --- 694,705 ---- if ((nwrote != -1 && (total_written == nbytes)) || ((nwrote == -1) && (errno != EAGAIN && errno != EINTR)) || pendingException()) { + #if defined(__FreeBSD__) && defined(LOGGING) /* since Log*() calls write() we have a loop */ + if (strncmp((char *)buf, "Write for ", 10) == 0) /* NOTE: hanging if... */ + #else Log2(1, "Write for %d bytes finished (did not block) on fd: %d\n", \ nwrote, fd); + #endif return ((nwrote!=-1)?total_written:-1); } /* else take the slow path */ *************** *** 657,667 **** --- 746,761 ---- system_close(fd); } + #if defined(__FreeBSD__) && defined(LOGGING) /* since Log*() calls write() we have a loop */ + if (strncmp((char *)buf, "Write for ", 10) == 0) /* NOTE: hanging if... */ + #else Log2(1, "Write for %d bytes finished on fd: %d\n", nwrote, fd); + #endif sysMonitorExit(mon); return total_written; } + #ifndef __FreeBSD__00 int writev(int fd, const struct iovec *iovec, int iovcnt) { *************** *** 672,678 **** --- 766,774 ---- sysAssert(mon != NULL); + #ifndef __FreeBSD__0 check_single_fd(fd); + #endif sysMonitorEnter(mon); fd_ref[fd]++; *************** *** 683,689 **** nwrote = (*systable[SYS_WRITEV].addr)(fd, iov, iovcnt); while (nwrote == -1) { ! if (errno == EAGAIN) { /* TBD: WRITE_TIMEOUT should be replaced by SYS_TIMEOUT_INIFINITY */ sysMonitorWait(mon, WRITE_TIMEOUT, FALSE); --- 779,785 ---- nwrote = (*systable[SYS_WRITEV].addr)(fd, iov, iovcnt); while (nwrote == -1) { ! if (0 && errno == EAGAIN) { /* TBD: WRITE_TIMEOUT should be replaced by SYS_TIMEOUT_INIFINITY */ sysMonitorWait(mon, WRITE_TIMEOUT, FALSE); *************** *** 722,728 **** /* TBD: optimize like read routine - pavani */ /* signature changed on Solaris 2.6! -brown */ ! #if defined(_ILP32) || defined(_LP64) int readv(int fd, const struct iovec *iov, int iovcnt) #else --- 818,824 ---- /* TBD: optimize like read routine - pavani */ /* signature changed on Solaris 2.6! -brown */ ! #if defined(_ILP32) || defined(_LP64) || defined(__FreeBSD__) int readv(int fd, const struct iovec *iov, int iovcnt) #else *************** *** 736,742 **** --- 832,840 ---- sysAssert(mon != NULL); + #ifndef __FreeBSD__0 check_single_fd(fd); + #endif sysMonitorEnter(mon); fd_ref[fd]++; *************** *** 766,771 **** --- 864,871 ---- return nread; } + #endif __FreeBSD__ + /* we do not initialize the fd to be nonblocking for getmsg and putmsg i.e. no calls to check_single_fd - due to a bug *************** *** 873,879 **** int delay = 50; /* sleep 50 ms and try again */ fd_set write_fds; struct timeval poll; - extern int _select (int width, fd_set *, fd_set *, fd_set *, struct timeval *); FD_ZERO(&write_fds); FD_SET(s, &write_fds); --- 973,978 ---- *************** *** 883,892 **** --- 982,1004 ---- result = connect(s, him, len); while (result < 0 && !pendingException()) { if (errno == EINPROGRESS) { + #ifdef __FreeBSD__ + int cnt = (*systable[SYS_SELECT].addr)(s+1, 0, &write_fds, 0, &poll); + #else int cnt = _select(s+1, 0, &write_fds, 0, &poll); + #endif FD_SET(s, &write_fds); if (cnt == 1) { + #ifdef __FreeBSD__ + if (connect(s,him,len) == -1) { + if (errno == ENOTCONN) { + errno = ECONNREFUSED; + } + /* see comment above */ + break; + } + #else int bytes; if (ioctl(s, FIONREAD, &bytes) == -1) { *************** *** 901,906 **** --- 1013,1019 ---- sysAssert(result < 0); break; } + #endif result = 0; break; } *************** *** 914,919 **** --- 1027,1033 ---- } + #ifndef __FreeBSD__ /* Poll system call */ int *************** *** 998,1003 **** --- 1112,1118 ---- sysMonitorExit(asyncMon(SYS_ASYNC_MON_IO)); return retval; } + #endif /* * Select system call in a multi-threaded environment. *************** *** 1051,1057 **** timeval_t delay; int timeout = SYS_TIMEOUT_INFINITY; ! nfds = _select(width, readfds, writefds, exceptfds, &poll); if (nfds != 0) { break; --- 1166,1172 ---- timeval_t delay; int timeout = SYS_TIMEOUT_INFINITY; ! nfds = (*systable[SYS_SELECT].addr)(width, readfds, writefds, exceptfds, &poll); if (nfds != 0) { break; *************** *** 1130,1136 **** --- 1245,1255 ---- } if (fd != -1) { + #ifdef __FreeBSD__ + Log2(1, "Opened fd: %d (%s)\n", fd, fname); + #else Log1(1, "Opened fd: %d\n", fd); + #endif #ifndef GPROF ret = initialize_monitors(fd); #else *************** *** 1139,1145 **** --- 1258,1268 ---- } #endif } else { + #ifdef __FreeBSD__ + Log2(1, "open error: %d (%s)\n", errno, fname); + #else Log1(1, "open error: %d\n", errno); + #endif } IO_UNLOCK(); *************** *** 1283,1285 **** --- 1406,1482 ---- return fd; } + #ifdef __FreeBSD__ + + #include + + struct hostent * + gethostbyaddr_r(const char *addr, int length, int type, struct hostent *resp, char *buffer, int buflen, int *h_errnop) + { + struct hostent *result; + int old_h_errno; + char *filp = buffer; + char **aliasp, **out_aliasp; + char **addrp, **out_addrp; + unsigned k; + unsigned len; + + IO_LOCK(); + old_h_errno = h_errno; + result = gethostbyaddr (addr, length, type); + if (result != 0) + { + *resp = *result; + /* copy h_name */ + len = strlen (result->h_name)+1; + if (filp+len > buffer+buflen) + goto out_of_buffer_space; + memcpy (filp, result->h_name, len); + resp->h_name = filp; + filp += len; + /* copy h_aliases */ + resp->h_aliases = out_aliasp = (char **) filp; + len = sizeof (char *); + for (aliasp = result->h_aliases; *aliasp != 0; ++aliasp) + { + if (filp+len > buffer+buflen) + goto out_of_buffer_space; + filp += len; + } + for (aliasp = result->h_aliases; *aliasp != 0; ++aliasp) + { + len = strlen (*aliasp)+1; + if (filp+len > buffer+buflen) + goto out_of_buffer_space; + memcpy (filp, *aliasp, len); + *out_aliasp++ = filp; + filp += len; + } + /* copy h_addr_list */ + len = sizeof (char *); + resp->h_addr_list = out_addrp = (char **) filp; + for (addrp = result->h_addr_list; *addrp != 0; ++addrp) + { + if (filp+len > buffer+buflen) + goto out_of_buffer_space; + filp += len; + } + len = result->h_length; + for (addrp = result->h_addr_list; *addrp != 0; ++addrp) + { + if (filp+len > buffer+buflen) + goto out_of_buffer_space; + memcpy (filp, *addrp, len); + *out_addrp = filp; + filp += len; + } + } + *h_errnop = h_errno; + h_errno = old_h_errno; + IO_UNLOCK(); + return resp; + out_of_buffer_space: + *h_errnop = 42; /* out of buffer space */ + return 0; + } + #endif *** ./src/freebsd/java/green_threads/src/itimer.c.orig Fri Feb 7 20:06:10 1997 --- ./src/freebsd/java/green_threads/src/itimer.c Wed Jun 11 10:40:28 1997 *************** *** 32,38 **** --- 32,40 ---- #include "monitor_md.h" #include "itimer_md.h" + #ifdef __solaris__ extern int gettimeofday(struct timeval *, void *); + #endif /* * The minimum clock resolution in uSeconds. *** ./src/freebsd/java/green_threads/src/monitor_md.c.orig Fri Feb 7 20:06:08 1997 --- ./src/freebsd/java/green_threads/src/monitor_md.c Wed Jun 11 10:40:29 1997 *************** *** 477,482 **** --- 477,500 ---- !mid->suspend_waitq) { /* Nobody on queues, owner exiting, reinitialize sys_mon_t */ mid->monitor_owner = SYS_THREAD_NULL; + /* if the pendingq is set, remove us from it */ + sysAssert(!((mid->flags & SYS_MON_PENDING_NOTIFICATION) && mid->pendingq == SYS_MID_NULL)); + /* ugly. We will need to walk the pendingq and adjust whoever + points to us! */ + if (mid->pendingq) { + sys_mon_t **midq = &PendingNotifyQ; + while (*midq) { + if (*midq == mid) { + #ifdef DEBUG + fprintf(stderr, "removed us from someone's pendingq\n"); + #endif + *midq = mid->pendingq; + break; + } + midq = &((*midq)->pendingq); + } + mid->pendingq = SYS_MID_NULL; + } /* Clear all flags except SYS_MON_{IN_CACHE,HAS_HANDLER} */ mid->flags &= SYS_MON_HAS_HANDLER; } else if (queueSignal(mid, &mid->monitor_waitq)) { *** ./src/freebsd/java/green_threads/src/process_md.c.orig Fri Feb 7 20:06:10 1997 --- ./src/freebsd/java/green_threads/src/process_md.c Wed Jun 11 10:40:29 1997 *************** *** 24,30 **** #include #include #include ! #include #include #include --- 24,30 ---- #include #include #include ! #include #include #include *************** *** 63,72 **** --- 63,76 ---- */ void java_lang_UNIXProcess_run(Hjava_lang_UNIXProcess *this) { + #ifndef __FreeBSD__ siginfo_t info; + #endif sys_mon_t *mon = asyncMon(SYS_ASYNC_MON_CHILD); char *classname = JAVAPKG "UNIXProcess"; ClassClass *cb = FindClass(0, classname, TRUE); + pid_t pid; + int status; if (cb == NULL) { SignalError(0, JAVAPKG "NoClassDefFoundError", classname); *************** *** 75,80 **** --- 79,98 ---- while (1) { sysMonitorEnter(mon); + #ifdef __FreeBSD__ + while (1) { + pid = waitpid(0, &status, WNOHANG); + if (pid != 0 && pid != -1) { + break; + } + sysMonitorWait(mon, TIMEOUT_INFINITY, FALSE); + } + /* + * fprintf(stderr, "pid %d status %d\n", pid, status); + */ + execute_java_static_method(EE(), cb, "deadChild", "(II)V", + pid, status); + #else while (waitid(P_ALL, 0, &info, WEXITED|WNOHANG) != 0 || info.si_pid == 0) { sysMonitorWait(mon, TIMEOUT_INFINITY, FALSE); } *************** *** 82,87 **** --- 100,106 ---- execute_java_static_method(EE(), cb, "deadChild", "(II)V", info.si_pid, info.si_status); + #endif sysMonitorExit(mon); } } *** ./src/freebsd/java/green_threads/src/signals.c.orig Fri Feb 7 20:06:10 1997 --- ./src/freebsd/java/green_threads/src/signals.c Wed Jun 11 10:40:29 1997 *************** *** 1,3 **** --- 1,6 ---- + #if defined(__FreeBSD__) + #define NOPOLL + #endif /* * @(#)signals.c 1.45 97/01/23 * *************** *** 27,33 **** /* * Header files. */ - #include #include #include #include --- 30,35 ---- *************** *** 37,48 **** #include "threads_md.h" #include "monitor_md.h" #include "interrupt.h" ! #include "ucontext.h" #include "log.h" #include "itimer_md.h" #include "schedule.h" #include "monitor.h" /* For monitorRegister() */ #include "iomgr.h" /* For io lock */ void out_of_memory(void); --- 39,57 ---- #include "threads_md.h" #include "monitor_md.h" #include "interrupt.h" ! #include "debug.h" #include "log.h" #include "itimer_md.h" #include "schedule.h" #include "monitor.h" /* For monitorRegister() */ #include "iomgr.h" /* For io lock */ + #ifndef NOPOLL + #include + #endif + + #if defined(SOLARIS) && !defined(SIGHOLD) + #define SIGHOLD + #endif void out_of_memory(void); *************** *** 65,71 **** #include - #include /* The polling fd table. This table is contains all the file descriptors which are currently attempting i/o but have gotten --- 74,79 ---- *************** *** 81,92 **** This array is always packed. That is, there are no holes in it. The goal is to pass the minimum amount of fd's to the kernel for examination, and to only pass valid fds. Hopefully this isn't more ! work than it's worth. */ static struct pollfd *pollTable; /* This is the number of fds to examine in fdsToPoll */ - static int fdCount = -1; /* FdMap is indexed by file descriptor. It maps from a file descriptor to a position in the pollTable. A pollOffset of -1 --- 89,112 ---- This array is always packed. That is, there are no holes in it. The goal is to pass the minimum amount of fd's to the kernel for examination, and to only pass valid fds. Hopefully this isn't more ! work than it's worth. ! ! -- rc ! Note that on systems with NOPOLL, the select tables are NOT packed. ! -- rc ! */ ! ! static int fdCount = -1; ! ! #if defined(NOPOLL) ! static fd_set selectInTable; ! static fd_set selectOutTable; ! #else ! /* None of this is needed for select() based systems --rc */ static struct pollfd *pollTable; /* This is the number of fds to examine in fdsToPoll */ /* FdMap is indexed by file descriptor. It maps from a file descriptor to a position in the pollTable. A pollOffset of -1 *************** *** 96,101 **** --- 116,122 ---- short pollOffset; /* offset into the pollTable */ short flags; /* bits POLLIN and POLLOUT */ } *fdMap; + #endif /* * External routines. *************** *** 136,142 **** asyncIORegister(); ! if (fdCount == -1) { struct FdEntry *entry; int slot; --- 157,168 ---- asyncIORegister(); ! if (fdCount == -1) { ! #if defined(NOPOLL) ! FD_ZERO(&selectInTable); ! FD_ZERO(&selectOutTable); ! fdCount = 0; ! #else struct FdEntry *entry; int slot; *************** *** 155,160 **** --- 181,187 ---- if (pollTable == 0) { out_of_memory(); } + #endif } } *************** *** 196,202 **** * them. The notification is completely normal, except for the locking. * If a yield is necessary, it is done by the caller. */ ! sysAssert(PendingNotifyQ); midq = PendingNotifyQ; while (midq) { mid = midq; --- 223,229 ---- * them. The notification is completely normal, except for the locking. * If a yield is necessary, it is done by the caller. */ ! assert(PendingNotifyQ); midq = PendingNotifyQ; while (midq) { mid = midq; *************** *** 313,334 **** void asyncIOActivateFD(int fd) { struct FdEntry *entry; struct pollfd *pollfd; int slot; ! /* Here we need to mask SIGIO signal so that the signal handler does not run & use the poll table while we are constructing it. This is necessary as poll table is shared data structure and we cannot use the locks in the signal handler. NOTE: The assumption here is sighold and sigrelse apply process wide - TBD: Confirm this is true! If NOT then we need to grab the SCHED_LOCK so that thread cannot context switch here - ! Well just to be on safe side we grab SCHED_LOCK as well - pavani*/ SCHED_LOCK(); sighold(SIGIO); entry = &fdMap[fd]; if ((slot = entry->pollOffset) == -1) { entry->pollOffset = fdCount++; --- 340,372 ---- void asyncIOActivateFD(int fd) { + #if !defined(NOPOLL) struct FdEntry *entry; struct pollfd *pollfd; int slot; + #endif ! /* Here we need to mask SIGIO signal so that the signal handler does not run & use the poll table while we are constructing it. This is necessary as poll table is shared data structure and we cannot use the locks in the signal handler. NOTE: The assumption here is sighold and sigrelse apply process wide - TBD: Confirm this is true! If NOT then we need to grab the SCHED_LOCK so that thread cannot context switch here - ! Well just to be on safe side we grab SCHED_LOCK as well - pavani ! Which is needed for systems without sighold --rc */ SCHED_LOCK(); + #ifdef SIGHOLD sighold(SIGIO); + #endif + #if defined(NOPOLL) + FD_SET(fd, &selectInTable); + FD_SET(fd, &selectOutTable); + /*fprintf(stderr, "asking for io on fd %d\n", fd);*/ + fdCount++; + #else entry = &fdMap[fd]; if ((slot = entry->pollOffset) == -1) { entry->pollOffset = fdCount++; *************** *** 340,358 **** --- 378,411 ---- pollfd->fd = fd; /* may be redundant */ pollfd->events = entry->flags; Log2(1, "Activating fd=%d onto slot=%d\n", fd, slot); + #endif + + #ifdef SIGHOLD sigrelse(SIGIO); + #endif SCHED_UNLOCK(); } void asyncIODeactivateFD(int fd) { + #if !defined(NOPOLL) struct FdEntry *entry; int slot; + #endif SCHED_LOCK(); + #ifdef SIGHOLD sighold(SIGIO); + #endif + #if defined(NOPOLL) + FD_CLR(fd, &selectInTable); + FD_CLR(fd, &selectOutTable); + /*fprintf(stderr, "unasking for io on fd %d\n", fd);*/ + fdCount--; + sysAssert(fdCount >= 0); + #else entry = &fdMap[fd]; if ((slot = entry->pollOffset) != -1) { /* Now copy the highest slot in the poll array into this slot, *************** *** 376,382 **** --- 429,438 ---- pollTable[slot].events = entry->flags; } } + #endif + #ifdef SIGHOLD sigrelse(SIGIO); + #endif SCHED_UNLOCK(); } *************** *** 395,407 **** { int need_to_switch = 0; ! sysAssert(mid!=NULL); if (SCHED_LOCKED()) { /* * Queue this notification */ if ((mid->flags & SYS_MON_PENDING_NOTIFICATION) == 0) { ! sysAssert(mid->pendingq == SYS_MID_NULL); mid->pendingq = PendingNotifyQ; PendingNotifyQ = mid; } --- 451,463 ---- { int need_to_switch = 0; ! assert(mid!=NULL); if (SCHED_LOCKED()) { /* * Queue this notification */ if ((mid->flags & SYS_MON_PENDING_NOTIFICATION) == 0) { ! assert(mid->pendingq == SYS_MID_NULL); mid->pendingq = PendingNotifyQ; PendingNotifyQ = mid; } *************** *** 418,423 **** --- 474,514 ---- { extern sys_mon_t **fdmon; int resched = 0; + #if defined(NOPOLL) + int i, count; + fd_set tableIn, tableOut; + struct timeval timeout; + + tableIn = selectInTable; + tableOut = selectOutTable; + + /* Optimization: when there's only one fd to choose from it must have + been the one that delivered the sigio, right? */ + if (fdCount != 1) { + timeout.tv_sec = timeout.tv_usec = 0; + /* unfortunately, we don't know how to know what the maximum + fd in there is */ + count = (*systable[SYS_SELECT].addr)(sizeof(tableIn)*8, + &tableIn, &tableOut, + NULL, &timeout); + } else + count = 1; + + for (i = 0; i < sizeof(tableIn)*8 && count > 0; i++) { + if (FD_ISSET(i, &tableIn)) { + resched |= asyncEventNotify(fdmon[i]); + /*fprintf(stderr, "io(in) on fd %d\n", i);*/ + count--; + } + + if (FD_ISSET(i, &tableOut)) { + resched |= asyncEventNotify(fdmon[i]); + /*fprintf(stderr, "io(out) on fd %d\n", i);*/ + count--; + } + } + + #else int i, nfds, count; nfds = fdCount; *************** *** 440,445 **** --- 531,537 ---- } } } + #endif /* And for good measure... */ /* This monitor is the default io monitor mainly used for *************** *** 459,464 **** --- 551,559 ---- asyncIORegister() { intrRegister(SIGIO, sigioNotifier, 0); + #ifndef SIGCLD + #define SIGCLD SIGCHLD + #endif intrRegister(SIGCLD, sigioNotifier, 0); } *** ./src/freebsd/java/green_threads/src/synch.c.orig Fri Feb 7 20:06:10 1997 --- ./src/freebsd/java/green_threads/src/synch.c Wed Jun 11 10:40:29 1997 *************** *** 26,36 **** * instead of solaris threads, so we need a synchronization * mechanism that works with our thread package. */ ! #include "monitor.h" ! #include "synch.h" ! #include "schedule.h" ! #include "bool.h" ! #include "sys_api.h" extern bool_t monitorsInitialized; --- 26,34 ---- * instead of solaris threads, so we need a synchronization * mechanism that works with our thread package. */ ! #include ! #include ! #include extern bool_t monitorsInitialized; *************** *** 68,86 **** * scheduling locked. */ ! _mutex_lock(mutex_t *mp) { ! sysAssert(_scheduling_lock == 0); ! if (monitorsInitialized) { monitorEnter((int) mp); } return 0; } ! _mutex_unlock(mutex_t *mp) { ! sysAssert(_scheduling_lock == 0); if (monitorsInitialized) { monitorExit((int) mp); --- 66,91 ---- * scheduling locked. */ ! pthread_mutex_lock(void *mp) { ! #if 0 ! assert(_scheduling_lock == 0); ! #else ! if (_scheduling_lock == 0) ! #endif if (monitorsInitialized) { monitorEnter((int) mp); } return 0; } ! pthread_mutex_unlock(void *mp) { ! #if 0 ! assert(_scheduling_lock == 0); ! #else ! if (_scheduling_lock == 0) ! #endif if (monitorsInitialized) { monitorExit((int) mp); *************** *** 88,93 **** --- 93,99 ---- return 0; } + #ifndef __FreeBSD__ /* * SPECIAL CASE: In Solaris, malloc() calls sbrk() for more memory, * and both call _mutex_lock(), which we override to make them Green *************** *** 130,132 **** --- 136,141 ---- return ret; } #endif + #else /* __FreeBSD__ */ + void InitializeSbrk() {} + #endif /* __FreeBSD__ */ *** ./src/freebsd/java/green_threads/src/threads_md.c.orig Fri Feb 7 20:06:08 1997 --- ./src/freebsd/java/green_threads/src/threads_md.c Wed Jun 11 10:40:30 1997 *************** *** 225,231 **** } int ! sysThreadCreate(long stack_size, unsigned int flags, void *(*start)(void *), sys_thread_t **ptid, void *cookie) { sysAssert(cookie != 0); --- 225,231 ---- } int ! sysThreadCreate(long stack_size, uint_t flags, void *(*start)(void *), sys_thread_t **ptid, void *cookie) { sysAssert(cookie != 0); *** ./src/freebsd/sun/tiny_Toolkit.c.orig Fri Feb 7 20:06:38 1997 --- ./src/freebsd/sun/tiny_Toolkit.c Wed Jun 11 10:40:30 1997 *************** *** 22,28 **** --- 22,30 ---- #include #include + #ifndef __FreeBSD__ #include "thread.h" + #endif #include "tiny.h" #include "java_awt_Event.h" #include "sun_awt_tiny_TinyToolkit.h" *** ./src/freebsd/sun/awt_MToolkit.c.orig Fri Feb 7 20:06:34 1997 --- ./src/freebsd/sun/awt_MToolkit.c Wed Jun 11 10:40:31 1997 *************** *** 42,47 **** --- 42,51 ---- extern int awt_init_xt; #endif + #ifdef __FreeBSD__ + #include + #endif + #define bzero(a,b) memset(a, 0, b) void *awt_lock; *************** *** 207,213 **** NULL /* Must be NULL terminated */ }; ! #ifdef NETSCAPE sigset_t alarm_set, oldset; #endif --- 211,217 ---- NULL /* Must be NULL terminated */ }; ! #if defined(NETSCAPE) || defined(__FreeBSD__) sigset_t alarm_set, oldset; #endif *************** *** 232,238 **** #endif argv[0] = 0; ! #ifdef NETSCAPE /* Disable interrupts during XtOpenDisplay to avoid bugs in unix os select code: some unix systems don't implement SA_RESTART properly and because of this, select returns with EINTR. Most implementations of --- 236,242 ---- #endif argv[0] = 0; ! #if defined(NETSCAPE) || defined(__FreeBSD__) /* Disable interrupts during XtOpenDisplay to avoid bugs in unix os select code: some unix systems don't implement SA_RESTART properly and because of this, select returns with EINTR. Most implementations of *************** *** 253,259 **** 0, &argc, argv); ! #ifdef NETSCAPE sigprocmask(SIG_SETMASK, &oldset, 0); #endif --- 257,263 ---- 0, &argc, argv); ! #if defined(NETSCAPE) || defined(__FreeBSD__) sigprocmask(SIG_SETMASK, &oldset, 0); #endif *** ./src/freebsd/net/socket.c.orig Fri Feb 7 20:06:44 1997 --- ./src/freebsd/net/socket.c Wed Jun 11 10:40:32 1997 *************** *** 24,31 **** --- 24,33 ---- #include #include #include + #ifdef __solaris__ #include #include + #endif #ifndef TCP_NODELAY #include *************** *** 37,43 **** --- 39,47 ---- #include #include #include + #ifdef __solaris__ #include + #endif #include "java_net_Socket.h" #include "java_net_SocketImpl.h" *************** *** 211,217 **** */ addr = htonl(addr); ! hp = gethostbyaddr_r((char *)&addr, sizeof(addr), AF_INET, &hent, buf, sizeof(buf), &h_errno); if (hp == NULL) { NET_ERROR(0, JAVANETPKG "UnknownHostException", NULL); --- 215,221 ---- */ addr = htonl(addr); ! hp = (struct hostent *) gethostbyaddr_r((char *)&addr, sizeof(addr), AF_INET, &hent, buf, sizeof(buf), &h_errno); if (hp == NULL) { NET_ERROR(0, JAVANETPKG "UnknownHostException", NULL); *************** *** 290,295 **** --- 294,302 ---- him.sin_family = addrptr->family; if (sysConnectFD(fdptr, (struct sockaddr *) &him, sizeof(him)) < 0) { + #ifndef EPROTO + #define EPROTO ELAST+2 + #endif if (errno == EPROTO) { NET_ERROR(0, JAVANETPKG "ProtocolException", strerror(errno)); } else if (errno == ECONNREFUSED) { *** ./src/freebsd/net/multicast.c.orig Fri Feb 7 20:06:42 1997 --- ./src/freebsd/net/multicast.c Wed Jun 11 10:40:32 1997 *************** *** 24,30 **** --- 24,32 ---- #include #include #include + #ifdef __solaris__ #include + #endif #include #include #include *** ./src/freebsd/test/awt/drawsurface/GNUmakefile.orig Fri Feb 7 20:06:44 1997 --- ./src/freebsd/test/awt/drawsurface/GNUmakefile Wed Jun 11 10:40:32 1997 *************** *** 23,29 **** OW_INC = /usr/openwin/include J_INC = $(ROOT)/build/include ! INCLUDES = -I$(J_INC) -I$(J_INC)/solaris -I$(OW_INC) -I$(OW_INC)/X11 LIBS = -L/usr/openwin/lib -ldps -lX11 all: $(CLASSES) libdst.so --- 23,29 ---- OW_INC = /usr/openwin/include J_INC = $(ROOT)/build/include ! INCLUDES = -I$(J_INC) -I$(J_INC)/freebsd -I$(OW_INC) -I$(OW_INC)/X11 LIBS = -L/usr/openwin/lib -ldps -lX11 all: $(CLASSES) libdst.so *** /dev/null Thu Jun 26 12:08:49 1997 --- build/freebsd/makefiles/Defs-freebsd.gmk Wed Jun 11 10:40:32 1997 *************** *** 0 **** --- 1,122 ---- + # + # @(#)Defs-solaris.gmk 1.24 96/07/09 + # + # Makefile to specify compiler flags for programs and libraries + # targeted to Solaris. Should not contain any rules. + # + + ARCH = $(shell uname -m) + + # This default is redefined during a release build. + RELEASE = $(shell echo jdk1.1-`whoami`:`date '+%Y/%m/%d-%H:%M'`) + + # If -Xa is in CFLAGS_COMMON it will end up ahead of $(POPT) for the + # optimized build, and that ordering of the flags completely freaks + # out cc. Hence, -Xa is instead in each CFLAGS variant. + ifneq ($(CC_VERSION), gcc) + CFLAGS_COMMON = -v + CFLAGS_OPT = -Xa $(POPT) + CFLAGS_DBG = -Xa -g + else + CFLAGS_COMMON = + CFLAGS_OPT = $(POPT) + CFLAGS_DBG = -g + endif + + # + # Optional global flags with defaults: turn on from command line like + # + # % gnumake THREADS_FLAG=native + # + + # By default use green threads + THREADS_FLAG = green + + ifeq ($(THREADS_FLAG), native) + CFLAGS_COMMON += -D_REENTRANT -DNATIVE + endif + + # By default, gprof support is off + GPROF = false + + ifeq ($(GPROF), true) + CFLAGS_COMMON += -DGPROF -pg + endif + + # turn JCOV on + JCOV = true + + ifeq ($(JCOV), true) + ifeq ($(VARIANT), DBG) + CFLAGS_COMMON += -DJCOV + endif + endif + + # Java memory management is based on memory mapping by default, but a + # system only assuming malloc/free can be built by adding -DUSE_MALLOC + + ifneq ($(CC_VERSION), gcc) + CPPFLAGS_COMMON = -D$(ARCH) -DSOLARIS2 -DRELEASE='"$(RELEASE)"' + else + CPPFLAGS_COMMON = -D$(ARCH) -DHAVE_ALIGNED_LONGLONGS -DHAVE_ALIGNED_DOUBLES -DSOLARIS2 -DRELEASE='"$(RELEASE)"' + endif + CPPFLAGS_OPT = -DTRIMMED + CPPFLAGS_DBG = -DDEBUG -DTRACING -DBREAKPTS + + ASFLAGS_COMMON = + ASFLAGS_OPT = + ASFLAGS_DBG = + + LDFLAGS_COMMON = -L$(OPENWINHOME)/lib + LDFLAGS_OPT = + LDFLAGS_DBG = + + LDLIBS_COMMON = + LDLIBS_OPT = + LDLIBS_DBG = + + ifeq ($(THREADS_FLAG),native) + LDLIBS_COMMON += -lthread + endif + + ifeq ($(GPROF), true) + LDLIBS_COMMON += -pg + endif + + # + # Java variations + # + ifeq ($(PRODUCT), java) + # Java default optimization -x04 + ifneq ($(CC_VERSION), gcc) + _OPT = -xO4 + else + _OPT = -O3 + endif + CPPFLAGS_DBG += -DLOGGING -DDBINFO + ASFLAGS_COMMON += + ifeq ($(PROGRAM), java) + LDLIBS_COMMON += -lm + endif + endif + + + # + # Tools + # + ifneq ($(CC_VERSION), gcc) + CC = cc + CPP = cc -E + else + CC = gcc + CPP = gcc -E + endif + AS = as + LD = ld + AR = ar + RANLIB = ranlib + + OPENWINHOME = /usr/X11R6 + + LIBRARY_SUFFIX = so + *** /dev/null Thu Jun 26 12:08:49 1997 --- build/freebsd/java/java/README.AVL Wed Jun 11 10:40:32 1997 *************** *** 0 **** --- 1,191 ---- + Subject: tsearch(3) replacment with tseachAVL tree V1.2.2 + Followup-To: comp.unix.programmer + + Archive-name: tsearchAVL + Submitted-by: pbs@lmrln.demon.co.uk + + Copyright (c) 1992 Lomarline Ltd + @(#)avltree README 1.2.2 12/10/94 12:12:12 LMRN + _POSIX_SOURCE complient. + Compiler(s) : SunOS 4.1, System V Rel 3, OSF1, ULTRIX + + Permission to use, copy, modify, distribute, and sell this software and + its documentation for any purpose is hereby granted without fee, provided + that the above copyright notices and this permission notice appear in + all copies of the software and related documentation. + + THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + + IN NO EVENT SHALL LOMARLINE LTD BE LIABLE FOR ANY SPECIAL, INCIDENTAL, + INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER + RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE + POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR + IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + + + + The code is POSIX.1 complient so should compile on most machines. + + Replacement functions to perform tsearch etc, with a AVL balanced tree + structure. AVL balance is when the height of left and right subtree + from each node differ by one at most. + + void *tsearchAVL( void *key, void **rootp, int (*compar)() ); + void *tfindAVL( void *key, void **rootp, int (*compar)() ); + void *tdeleteAVL( void *key, void **rootp, int (*compar)() ); + void twalkAVL( void *root, void (*action)() ); + + See the manual entries for tsearch(3) for more details. + + How to use this code: + --------------------- + + The make files and the example programs sould be self explanitory. + + -DAVL is the *only* option which can be set at compile time. + + If you wish to use the avltree.c module as strait replacement for + the standard library calls compile the module with -DAVL. + + Add #include "avltree.h" to your source file and recomplie your + source with -DAVL and link in the avltree.o module. + + The header file "avltree.h" has in it #defines which replace + the standard tsearch() with tsearchAVL() etc if the AVL flag is set. + + + If you wish to take advantage of tdeleteAVL returning a pointer to + the information of the deleted node so that it can be freed then + compile the avltree.c module *without* the -DAVL. + + Add #include "avltree.h" to your source files, alter the tsearch() to + tsearchAVL() etc and then compile your source *without* the -DAVL flag + and link in the avltree.o module. + + WARNING: + -------- + + With reference to the above. + + There is one area where theses functions move away from the standard. + If the module avltree.c is compiled without the AVL flag set then + the tdelete function returns a pointer to the information containd in the + deleted node rather than the address of a pointer to the parent node + information. + + This is because the parent node is not of much use in an AVL tree. + The pointer to the information contained in the deleted not is of more + use because this information can then be freed by the user application + if necessary. + + What is the advantage of an AVL tree? + ------------------------------------- + + There are two fundemental problems with a B tree. + + The furthur away that the data is form random when placed into a btree + the greater the liklyhood of degeneration. In the worst case if the + data is sorted the the data will not be in a tree but a linked list. + + Over time as inserts and deletes are made a tree structure may + degenerate. + + AVL trees take care of both theses problems becase the software + automaticaly rebalances the tree so that it is never more than one level + away from balance. + + So the AVL tree will automate away the need to worry about the ordering + of data placed into a btree. + + Unless your data is close to random and you do not intend to delete + and insert more than you find then tsearchAVL will probably + be usefull for you. + + Credits + ------- + + This software was origenally written by Neil Barker for a project + which went belly up for lack of funds. + + I, Philip Shearer modified the source for clartity and so that the + returns were consistent with those of the standard library. + + To help find the bugs I looked at: + AVL Trees V2.0, 5-September-1993 Paul Vixie, a copy of which is kept on + gatekeeper.dec.com + 93.09.06 pub/usenet/comp.sources.unix/volume27/avl-subs/part01 + + (If we had known about an earlier version of this code back in 1990 we + would never have written our own!) + + Neil used the same book as Paul Vixie + + Algorithms & Data Structures + Niklaus Wirth, Prentice-Hall 1986, ISBN 0-13-022005-1. + + Which explains why the code looks some what similar. + While debugging the code I did not have A&DS to hand so I used one called: + + Data structures in ANSI C + S. Sengupta and P. Edwards, Academic Press 1991, ISBN 0-12-635655-1. + + + + + Additial Comments + ----------------- + + I think that the standard library tdelete function should contain another + argument, void (*del_fp)(const void *), so that a user defined function + could be supplied to delete the user supplied data. + + If you compile avltree without the AVL set then it is easy to implement + such a function. + + int deleteAVL( + const void *key, + void * const *rootp, + int (*compar) (const void *, const void *)), + int (*del_fp)(const void *) + ) + { + void *itm_p ; + int rtn; + + if( ( itm_p = tdeleteAVL( key, rootp, compar )) == NULL ) + return 0 ; + + rtn = del_fp(itm_p) ; + + return rtn; + } + Version Information: + ------------------- + + avltree.c 1.2 8/16/94 14:34:18 LMRN + + First published version. + + avltree.c 1.2.1 8/16/94 14:34:18 LMRN + + Fixed Trace so that the number increases from 0 up. The higher the + number the more debug is turned on. + + avltree.c 1.2.2 9/30/94 14:34:18 LMRN + + Moved the pointer to the information to the top of the structure used + to build the avl-btree. this has the advantage that like the version + of the btree used on an osf1 box, the pointer to the btree address also + holds a pointer to the first data item. This alows the root of the btree + to be examined with a cast to the user date structure without the user + needing to know anything about the avl-btree structure. + + To test this turn on the #define TREE_ROOT_HACK 1 in btest.c (it is + automaticaly turned on if you are useing the OSF1 C compiler). + + avltree.h 1.2.1 10/12/94 12:12:12 LMRN + + Sigh! Because ULTRIX does not include a macro to stop search.h + being included more than once, assume that the application includes it. *** /dev/null Thu Jun 26 12:08:49 1997 --- build/freebsd/java/java/avltree.h Wed Jun 11 10:40:33 1997 *************** *** 0 **** --- 1,134 ---- + #ifndef __AVLTREE_H + #define __AVLTREE_H + + /* + SCCS stuff + */ + + #ifndef SCCS /* only pick up one SCCS string per module */ + # define SCCS + # ifndef lint + static char e4d_sccs[] = "@(#)avltree.h 1.2.1 10/12/94 12:12:12 LMRN"; + # ifndef COPYRIGHT + # define COPYRIGHT + static char copyright[] = "@(#)Copyright (c) 1992 Lomarline " ; + # endif + # endif + #endif + /*------------------------------------------------------------------------------ + * Notice: + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that the above copyright notices and this permission notice appear in + * all copies of the software and related documentation. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL LOMARLINE LTD BE LIABLE FOR ANY SPECIAL, INCIDENTAL, + * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE + * POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR + * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + *------------------------------------------------------------------------------ + */ + + /* + * This is modle should complement the standard search.h functions. + * + * Sigh! Because ULTRIX does not include a macro to stop search.h + * being included more than one assume that the application includes it. + */ + + #if !(defined(__ultrix) || defined(__FreeBSD__)) + # include + #endif + + /*------------------------------------------------------------------ + *To relace the standard binary tree unix functions with the avl ones + *set AVL in the comple line to -DAVL + *----------------------------------*/ + #ifdef AVL + # define tsearch(kp,rpp,cfn) tsearchAVL(kp,rpp,cfn) + # define tfind(kp,rpp,cfn) tfindAVL(kp,rpp,cfn) + # define tdelete(kp,rpp,cfn) tdeleteAVL(kp,rpp,cfn) + # define twalk(rp,afn) twalkAVL(rp,afn) + #endif + /*------------------------------------------------------------------- + * if the std_header is included in the module + * then this VISIT enunerated type will already be defined so + * watch out for a clash. + *--------------------*/ + + + #ifdef USE_THIS_VISIT + #undef USE_THIS_VISIT + #endif + + #if defined(__osf__) || defined(__FreeBSD__) + #if ! defined ( _SEARCH_H_ ) || ! defined _XOPEN_SOURCE + # define USE_THIS_VISIT + # endif + #endif + + + #ifdef USE_THIS_VISIT + typedef enum { preorder, postorder, endorder, leaf } VISIT; + #endif + + /*------------------------------------------------------------------*/ + #if defined( __STDC__ ) && ! defined( NeedFunctionPrototypes ) + #define NeedFunctionPrototypes + #endif + + /*------------------------------------------------------------------*/ + #if defined ( __cplusplus ) && ! defined ( _BEGIN_CPLUSPLUS ) + # define _BEGIN_CPLUSPLUS extern "C" { + # define _END_CPLUSPLUS } + #else + # ifdef _BEGIN_CPLUSPLUS + # undef _BEGIN_CPLUSPLUS + # endif + # ifdef _END_CPLUSPLUS + # undef _END_CPLUSPLUS + # endif + # define _BEGIN_CPLUSPLUS + # define _END_CPLUSPLUS + #endif + + _BEGIN_CPLUSPLUS + + extern void *tsearchAVL( + #ifdef NeedFunctionPrototypes + const void *key, + void **rootp, + int (*compar)( const void *, const void * ) + #endif + ); + + extern void *tfindAVL( + #ifdef NeedFunctionPrototypes + const void *key, + void **rootp, + int (*compar)( const void *, const void * ) + #endif + ); + + extern void *tdeleteAVL( + #ifdef NeedFunctionPrototypes + const void *key, + void **rootp, + int (*compar)( const void *, const void * ) + #endif + ); + + extern void twalkAVL( + #ifdef NeedFunctionPrototypes + const void * root, + void (*action)(const void *, VISIT, int ) + #endif + ); + _END_CPLUSPLUS + + #endif /* __AVLTREE_H */ *** /dev/null Thu Jun 26 12:08:49 1997 --- build/freebsd/java/java/avltree.c Wed Jun 11 10:40:33 1997 *************** *** 0 **** --- 1,1085 ---- + #ifndef _POSIX_SOURCE + # define _POSIX_SOURCE 1 + #endif + + /* + SCCS stuff + */ + + #ifndef SCCS /* only pick up one SCCS string per module */ + # define SCCS + # ifndef lint + static char e4d_sccs[] = "@(#)avltree.c 1.2.2 9/30/94 14:34:18 LMRN"; + # ifndef COPYRIGHT + # define COPYRIGHT + static char copyright[] = "@(#)Copyright (c) 1992 Lomarline Ltd " ; + # endif + # endif + #endif + + /*----------------------------------------------------------------------------- + * Date : 25 February 1992 + * Version : 1.2 + * Last Update : 92/06/06 15:00:50 + * Author : Lomarline Ltd + * Compiler(s) : SunOS 4.1, System V Rel 3, OSF1 + * Module Name : avltree.c + * Description : + * Replacement functions to perform tsearch etc, with a AVL balanced tree + * structure. AVL balance is when the height of left and right subtree + * from each node differ by one at most. + * + * Global Functions: + * void *tsearchAVL( void *key, void **rootp, int (*compar)() ) + * void *tfindAVL( void *key, void **rootp, int (*compar)() ) + * void *tdeleteAVL( void *key, void **rootp, int (*compar)() ) + * void twalkAVL( void *root, void (*action)() ) + * + * Notice: + * Permission to use, copy, modify, distribute, and sell this software and + * its documentation for any purpose is hereby granted without fee, provided + * that the above copyright notices and this permission notice appear in + * all copies of the software and related documentation. + * + * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, + * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY + * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. + * + * IN NO EVENT SHALL LOMARLINE LTD BE LIABLE FOR ANY SPECIAL, INCIDENTAL, + * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER + * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE + * POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR + * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + *------------------------------------------------------------------------------ + */ + + #define global + + #include + #include + + #ifndef __FreeBSD__ + #include + #endif + #include "avltree.h" + + #ifndef TRUE + # define TRUE 1 + # define FALSE 0 + #endif + + struct Node + { + void *info; + struct Node *left; + struct Node *right; + /* + * height of left subtree - height of right subtree + */ + short balance; + }; + + + /*-------------------------------------------------------------------------- + * Debug and trace info + *--------------------------------------------------------------------------*/ + + /* + * If set to zero then All trace is not compiled in + * The maximum setting at the moment is 500 which will show everthing + * 200 will show only entry and exit to the top level functions, tsearch() etc. + */ + #define Avl_DEBUG 000 + + #if !defined ( Avl_DEBUG ) || ( Avl_DEBUG == 0 ) + # define Avl_Enter(level,name) + # define Avl_Trace(level,args) + # define Avl_Return return + #else + /* + * If you wish to view only one of the txxx functions and it's children then + * set one of the following to ( >200 * -1 ) and, above, Avl_DEBUG to 1. + * Or some combination of the two! + */ + # define Avl_ts (000 * -1) + # define Avl_td (000 * -1) + # define Avl_tw (000 * -1) + # define Avl_tf (000 * -1) + + static long avl_depth ; + static long avl_level ; + + # define Avl_Trace(level,args)\ + do\ + { if(( Avl_DEBUG >= (level) ) && ( avl_fname_p!= NULL))\ + { \ + printf("Avl_Trace:[%d]%s:",avl_depth,avl_fname_p );\ + printf args ;\ + printf("\n");\ + }\ + }while(0) + /* + * NB this must be placed after the initalization of local variables and + * before the first assignment statment + */ + # define Avl_Enter(level,name_p) \ + char *avl_fname_p ;\ + avl_level = (level) ;\ + avl_fname_p=name_p; \ + ++avl_depth ; \ + Avl_Trace((level),("Enter")) + + # define Avl_Return { Avl_Trace(avl_level,("Return")); --avl_depth; } ; return + + #endif + + + + /*------------------------------------------------------------------------------ + * Description: + * + * + * Notes: + * + * Parameters: + * nodeInfoPtr - Node to locate or insert. + * ptr - Current node in the tree. + * rb_flag - rebalance flag + * compar - Node contents comparison function. + * + * + * + * Returns: + * NULL - If node already exists. + * otherwise - Inserted Node. + * + *------------------------------------------------------------------------------ + */ + + #ifdef NeedFunctionPrototypes + static void * + search( + const void *key, + struct Node **rootp , + int *rb_flag , + int (*compar)(const void *, const void *) + ) + #else + static void * + search( key, rootp, rb_flag, compar ) + void *key; + struct Node **rootp; + int *rb_flag; + int (*compar)(); + #endif + { + struct Node *p1; + struct Node *p2; + void *keyInsert; + int direction; + + Avl_Enter(Avl_ts+300,"search") ; + + if ( *rootp == NULL ) + { + Avl_Trace(Avl_ts+310,("No tree create one")); + + if ( (*rootp = (struct Node *)malloc( sizeof( struct Node ) )) != NULL ) + { + *rb_flag = TRUE; + (*rootp)->info = (void *) key; + (*rootp)->left = NULL; + (*rootp)->right = NULL; + (*rootp)->balance = 0; + keyInsert = (void *) &((*rootp)->info); + } + else + keyInsert = NULL; + Avl_Return keyInsert; + } + + direction = compar( key, (*rootp)->info ) ; + + if ( direction < 0 ) + { + Avl_Trace(Avl_ts+320,("Move left")); + + keyInsert = search( key, &((*rootp)->left), rb_flag, compar ); + + if ( *rb_flag && (keyInsert != NULL) ) + { + + Avl_Trace(Avl_ts+330,("left branch has grown longer")); + + switch( (*rootp)->balance ) + { + case 1: + Avl_Trace(Avl_ts+340,("right branch was longer, now in balance")); + + (*rootp)->balance = 0; + *rb_flag = FALSE; + break; + + case 0: + Avl_Trace(Avl_ts+340, + ("was in balance, now the left branch is one longer")); + + (*rootp)->balance = -1; + break; + + case -1: + Avl_Trace(Avl_ts+340,("left is to long so rebalance")); + + p1 = (*rootp)->left; + + if ( p1->balance < 0 ) + { + Avl_Trace(Avl_ts+350,("single LL rotation")); + + (*rootp)->left = p1->right; + p1->right = *rootp; + (*rootp)->balance = 0; + *rootp = p1; + } + else + { + Avl_Trace(Avl_ts+350,("double LR rotation")); + + p2 = p1->right; + p1->right = p2->left; + p2->left = p1; + (*rootp)->left = p2->right; + p2->right = *rootp; + (*rootp)->balance = ( p2->balance < 0 ) ? 1 : 0; + p1->balance = ( p2->balance > 0 ) ? -1 : 0; + *rootp = p2 ; + } + + (*rootp)->balance = 0; + *rb_flag = FALSE; + + break; + + } /* switch */ + + } /* if */ + + } + else if ( direction > 0 ) + { + Avl_Trace(Avl_ts+320,("Move right")); + + keyInsert = search( key, &((*rootp)->right), rb_flag, compar ); + + if ( *rb_flag && (keyInsert != NULL) ) + { + Avl_Trace(Avl_ts+330,("right branch has grown longer")); + + switch( (*rootp)->balance ) + { + case -1: + Avl_Trace(Avl_ts+340,("left branch was longer, now in balance")); + (*rootp)->balance = 0; + *rb_flag = FALSE; + break; + + case 0: + Avl_Trace(Avl_ts+340,("was in balance, now the right branch is longer")); + (*rootp)->balance = 1; + break; + + case 1: + Avl_Trace(Avl_ts+340,("right is to long so rebalance")); + p1 = (*rootp)->right; + + if ( p1->balance > 0 ) + { + Avl_Trace(Avl_ts+350,("single RR rotation")); + + (*rootp)->right = p1->left; + p1->left = *rootp; + (*rootp)->balance = 0; + *rootp = p1; + } + else + { + Avl_Trace(Avl_ts+350,("double RL rotation")); + + p2 = p1->left; + p1->left = p2->right; + p2->right = p1; + (*rootp)->right = p2->left; + p2->left = *rootp; + (*rootp)->balance = ( p2->balance > 0 ) ? -1 : 0; + p1->balance = ( p2->balance < 0 ) ? 1 : 0; + *rootp = p2; + } + + (*rootp)->balance = 0; + *rb_flag = FALSE; + + break; + } + } /* if */ + } + else + { + Avl_Trace(Avl_ts+320,("direction == 0, got a match")); + *rb_flag = FALSE; + keyInsert = (void *) &((*rootp)->info); + } + + Avl_Return keyInsert; + } + + + /*------------------------------------------------------------------------------ + * Description: + * As per tsearch(3). + * + * Notes: + * + * Parameters: + * key - Node to locate or insert. + * rootp - Tree's root node. + * compar - Node contents comparison function. + * + * + * Returns: + * NULL - If node already exists. + * otherwise - Inserted Node. + * + *------------------------------------------------------------------------------ + */ + + #ifdef NeedFunctionPrototypes + global void * + tsearchAVL( + const void *key , + void **rootp , + int (*compar)(const void *, const void *) + ) + #else + global void * + tsearchAVL( key, rootp, compar ) + void *key; + void **rootp; + int (*compar)(); + #endif + { + void * rtn ; + int rb_flag = FALSE; + + Avl_Enter(Avl_ts+200,("tsearchAVL")) ; + + rtn = search( key, (struct Node **)rootp, &rb_flag, compar ); + Avl_Return rtn ; + } + + /*------------------------------------------------------------------------------ + * Description: + * As per tfind(3). + * + * tfind() searches for an entry in the binary tree, Avl_Returning a pointer to + * that entry when a match is found. However, when key is not matched, + * tfind() Avl_Returns a null pointer. + * + * Notes: + * + * Parameters: + * key - Node to locate. + * rootp - Tree's root node. + * compar - Node contents comparison function. + * + * + * Returns: + * NULL - + * otherwise - + * + *------------------------------------------------------------------------------ + */ + + #ifdef NeedFunctionPrototypes + global void * + tfindAVL( + const void *key, + void **rootp, + int (*compar)(const void *, const void *) + ) + #else + global void * + tfindAVL( key, rootp, compar ) + void *key; + void **rootp; + int (*compar)(); + #endif + { + int direction; + void * rtn ; + + Avl_Enter(Avl_tf+200,("tfindAVL")) ; + + if ( *rootp == NULL ) + { + Avl_Trace(Avl_tf+210,("rootp is Null")); + Avl_Return NULL; + } + + direction = compar( key, ((struct Node *)(*rootp))->info ); + + if ( direction < 0 ) + { + Avl_Trace(Avl_tf+210,("direction < 0, Going left")); + rtn = tfindAVL( + key, + (void **)&(((struct Node *)(*rootp))->left), + compar ); + } + else if ( direction > 0 ) + { + Avl_Trace(Avl_tf+210,("direction > 0, Going right")); + rtn = tfindAVL( + key, + (void **)&(((struct Node *)(*rootp))->right), + compar ); + } + else + { + Avl_Trace(Avl_tf+210,("direction == 0 , Got a match")); + rtn = &((struct Node *)(*rootp))->info; + } + + Avl_Return rtn ; + } + + + /*------------------------------------------------------------------------------ + * Description: + * Rebalance tree on the left + * + * + * Notes: + * + * Parameters: + * ptr - pointer to (sub) tree ; + * rb_flag - rebalance flag + * + * + * Returns: + * None + * + *------------------------------------------------------------------------------ + */ + + #ifdef NeedFunctionPrototypes + static void + bal_left( + struct Node **rootp , + int *rb_flag + ) + #else + static void + bal_left( rootp, rb_flag ) + struct Node **rootp; + int *rb_flag; + #endif + { + struct Node *p1; + struct Node *p2; + int b1; + int b2; + + Avl_Enter(Avl_td+400,("bal_left")) ; + + switch( (*rootp)->balance ) + { + case -1: + Avl_Trace(Avl_td+410,("was imbalanced, fixed implicitly")); + (*rootp)->balance = 0; + break; + + case 0: + Avl_Trace(Avl_td+410,("was okay, is now one out")); + (*rootp)->balance = 1; + *rb_flag = FALSE; + break; + + case 1: + Avl_Trace(Avl_td+410,("was alreay one out, so rebalance")); + p1 = (*rootp)->right; + b1 = p1->balance; + + if ( b1 >= 0 ) + { + Avl_Trace(Avl_td+410,("single RR rotation")); + + (*rootp)->right = p1->left; + p1->left = *rootp; + + if ( b1 == 0 ) + { + (*rootp)->balance = 1; + p1->balance = -1; + *rb_flag = FALSE; + } + else + { + (*rootp)->balance = 0; + p1->balance = 0; + } + + *rootp = p1; + } + else + { + Avl_Trace(Avl_td+410,("double RL rotation")); + + p2 = p1->left; + b2 = p2->balance; + p1->left = p2->right; + p2->right = p1; + (*rootp)->right = p2->left; + p2->left = *rootp; + + (*rootp)->balance = ( b2 == 1 ) ? -1 : 0; + p1->balance = ( b2 == -1 ) ? 1 : 0; + *rootp = p2; + p2->balance = 0; + } + break; + + } /* switch */ + + Avl_Return ; + } /* bal_left */ + + + /*------------------------------------------------------------------------------ + * Description: + * + * + * Notes: + * + * Parameters: + * rootp - pointer to (sub) tree + * rb_flag - repbalnce flag + * + * + * Returns: + * None + * + *------------------------------------------------------------------------------ + */ + + #ifdef NeedFunctionPrototypes + static void + bal_right( + struct Node **rootp, + int *rb_flag + ) + #else + static void + bal_right( rootp, rb_flag ) + struct Node **rootp; + int *rb_flag; + #endif + { + struct Node *p1; + struct Node *p2; + int b1; + int b2; + + Avl_Enter(Avl_td+400,("bal_right")) ; + + switch( (*rootp)->balance ) + { + case 1: + Avl_Trace(Avl_td+410,("was imbalanced, fixed implicitly")); + (*rootp)->balance = 0; + break; + + case 0: + Avl_Trace(Avl_td+410,("was okay, is now one out")); + (*rootp)->balance = -1; + *rb_flag = FALSE; + break; + + case -1: + Avl_Trace(Avl_td+410,("was already one out, so rebalance")); + p1 = (*rootp)->left; + b1 = p1->balance; + + if ( b1 <= 0 ) + { + Avl_Trace(Avl_td+410,("single LL rotation")); + + (*rootp)->left = p1->right; + p1->right = *rootp; + + if ( b1 == 0 ) + { + (*rootp)->balance = -1; + p1->balance = 1; + *rb_flag = FALSE; + } + else + { + (*rootp)->balance = 0; + p1->balance = 0; + } + + *rootp = p1; + } + else + { + Avl_Trace(Avl_td+410,("double LR rotation")); + + p2 = p1->right; + b2 = p2->balance; + p1->right = p2->left; + p2->left = p1; + (*rootp)->left = p2->right; + p2->right = *rootp; + + (*rootp)->balance = ( b2 == -1 ) ? 1 : 0; + p1->balance = ( b2 == 1 ) ? -1 : 0; + *rootp = p2; + p2->balance = 0; + } + break; + + } /* switch */ + + Avl_Return ; + } /* bal_right */ + + + /*------------------------------------------------------------------------------ + * Description: + * This is called initally from delete but it is recursive. + * It is responsible for removing a node when both + * subnodes contain data. + * + * Notes: + * + * Parameters: + * rootp - Node with two children + * q - + * rb_flag - rebalanc flag + * + * + * Returns: + * None + * + *------------------------------------------------------------------------------ + */ + + #ifdef NeedFunctionPrototypes + static void + del( + struct Node **rootp , + struct Node **q , + int *rb_flag + ) + #else + static void + del( rootp, q, rb_flag ) + struct Node **rootp; + struct Node **q ; + int *rb_flag; + #endif + { + Avl_Enter(Avl_td+400,("del")) ; + + if ( (*rootp)->right != NULL ) + { + Avl_Trace(Avl_td+410,("Moving right")); + del( &((*rootp)->right), q , rb_flag ); + + if ( *rb_flag ) + { + Avl_Trace(Avl_td+410,("Rebalancing right")); + bal_right( rootp, rb_flag ); + } + } + else + { + /* + * Delete is only called if both nodes exist + */ + Avl_Trace(Avl_td+410,("Moving to the left and repositioning data")); + (*q)->info = (*rootp)->info; + *q = *rootp ; + *rootp = (*rootp)->left; + *rb_flag = TRUE; + } + + Avl_Return ; + } /* del */ + + + /*------------------------------------------------------------------------------ + * Description: + * Deletes a node form the table and reblances the tree if + * required. + * + * Notes: + * It is not realy meaning full to Avl_Return a pointer to the + * parents address but this is done to comply with the UNIX + * man tsearch entrys. + * + * Parameters: + * key - + * ptr - pointer to (sub) tree + * rb_flag - rebalance flag + * compar - Node contents comparison function. + * + * + * Returns: + * parent - NULL if no matching node found + * or pointer to parent node + * if the parentNode parameter is not NUll + * otherwise Avl_Returns a pointer to the deleted nodes information + * + *------------------------------------------------------------------------------ + */ + + #ifdef NeedFunctionPrototypes + static void * + delete( + const void *key , + struct Node **rootp , + int *rb_flag , + int (*compar)(const void *, const void *), + struct Node **parentNode + ) + #else + static void * + delete( key, rootp, rb_flag, compar, parentNode ) + void *key; + struct Node **rootp; + int *rb_flag; + int (*compar)(); + struct Node **parentNode ; + #endif + { + int direction; + + void **infoPtr ; + + struct Node *q; + + Avl_Enter(Avl_td+300,("delete")) ; + + if ( *rootp == NULL ) + { + Avl_Trace(Avl_td+310,("No node maches key")); + *rb_flag = FALSE; + Avl_Return NULL ; + } + + + direction = compar( key, (*rootp)->info ) ; + + + if ( direction == 0 ) + { + Avl_Trace(Avl_td+310,("We have a match == We want to delete this node")); + /* + * if parentNode NULL then Avl_Return a pointer to the info + * else Avl_Return the address of a pointer to the parent node + */ + if ( parentNode == NULL ) + { + Avl_Trace(Avl_td+330,("Return (deleted node) info")); + infoPtr = (*rootp)->info ; + } + else + { + /* + * Then we were at the root node so we will + * have to return a new root node so set it + * to NULL here and test for it in the ("if" + * conditions below + */ + if ( parentNode == rootp ) + { + Avl_Trace(Avl_td+330,("Return infoPtr = rootp")); + infoPtr = NULL ; + } + else + { + Avl_Trace(Avl_td+330,("Return infoPtr = parentNode")); + infoPtr = &(*parentNode)->info ; + } + } + + q = *rootp; + + if ( q->right == NULL ) + { + Avl_Trace(Avl_td+340, + ("We have no right node so assign left node to rootp")); + *rootp = q->left; + *rb_flag = TRUE; + if( q->left == NULL ) + { + Avl_Trace(Avl_td+350,("We have no left node either")); + /*infoPtr = NULL ;*/ + } + else if ( infoPtr == NULL ) + infoPtr = &(*rootp)->info ; + } + else if ( q->left == NULL ) + { + Avl_Trace(Avl_td+340, + ("We have a right node but no left one so assign rightnode to pointer")); + + *rootp = q->right; + *rb_flag = TRUE; + if ( infoPtr == NULL ) + infoPtr = &(*rootp)->info ; + } + else + { + Avl_Trace(Avl_td+340, + ("We have both nodes but this one must go so delete this one and rebalance")); + del( &(q->left),&q, rb_flag ); + + if ( *rb_flag ) + bal_left( rootp, rb_flag ); + + if ( infoPtr == NULL ) + { + Avl_Trace(Avl_td+345, + ("We have both nodes infoPtr was NOT NULL")); + infoPtr = &(*rootp)->info ; + } + } + + free( (void *)q ); + q = NULL; + + Avl_Return infoPtr ; + } + + if( parentNode != NULL ) + { + Avl_Trace(Avl_td+320,("Parent node SET to root Node")); + parentNode = rootp ; + } + else + { + Avl_Trace(Avl_td+320,("Parent node NOT set to root Node")); + } + + if ( direction < 0 ) + { + Avl_Trace(Avl_td+350,("key is < node, Move down the left leaf")); + + infoPtr = delete( key, &((*rootp)->left), rb_flag, compar, parentNode ); + + if ( *rb_flag ) + { + Avl_Trace(Avl_td+350,("We found our target (direction < 0)")); + bal_left( rootp, rb_flag ); + } + } + else if ( direction > 0 ) + { + Avl_Trace(Avl_td+350,("key is > node, Move down the right leaf")); + + infoPtr = delete( key, &((*rootp)->right), rb_flag, compar, parentNode ); + + if ( *rb_flag ) + { + Avl_Trace(Avl_td+350,("We found our target (direction < 0)")); + bal_right( rootp, rb_flag ); + } + } + + Avl_Return infoPtr ; + } /* delete */ + + + /*------------------------------------------------------------------------------ + * Description: + * As per tdelete(3). + * The tdelete() function deletes a node from a binary search tree. Parameters + * for this function are used in the same way as for the tsearch() function. + * The variable pointed to by the rootp parameter is changed when the deleted + * node was the root of the binary tree. The tdelete() function Avl_Returns a + * pointer to the parent of the deleted node, or a null pointer if the node is + * not found. + * + * Notes: + * If this module is compiled with the AVL macro NOT set then + * the value Avl_Returned,(if not NULL), is a pointer to the + * information stored in the deleted node. + * This will be of more use in most applications because this + * memory will have to be freed by the calling application. + * Returning the address of the pointer to the parent of the deleted + * node is not of much use in an AVLtree. + * + * Parameters: + * key - Node to delete. + * rootp - Tree's root node. + * compar - Node contents comparison function. + * + * + * Returns: + * NULL - If node does not exist . + * otherwise - AVL == TRUE a pointer to the deleted nodes parent. + * or if the deleted node was root the new root. + * otherwise - AVL == FALSE a pointer to the information stored in the + * deleted node + * + *------------------------------------------------------------------------------ + */ + #ifdef NeedFunctionPrototypes + global void * + tdeleteAVL( + const void *key , + void **rootp , + int (*compar)(const void *, const void *) + ) + #else + global void * + tdeleteAVL( key, rootp, compar ) + void *key; + void **rootp; + int (*compar)(); + #endif + { + int rb_flag = FALSE; + void **parentNode ; + void *rtn ; + Avl_Enter(Avl_td+200,("tdeleteAVL")) ; + + #ifdef AVL + parentNode = rootp ; + #else + parentNode = NULL ; + #endif + + rtn = delete( + key, + (struct Node **)rootp, + &rb_flag, + compar, + (struct Node **) parentNode + ); + + Avl_Return rtn ; + + } /* tdeleteAVL */ + + /*------------------------------------------------------------------------------ + * Description: + * Test for a leaf node (node without any children). + * + * Notes: + * + * Parameters: + * nodePtr - Node. + * + * + * Returns: + * 0 - If nodePtr points to a non leaf node. + * 1 - If nodePtr points to a leaf node. + * + *------------------------------------------------------------------------------ + */ + + #ifdef NeedFunctionPrototypes + static int + leafNode( + struct Node *nodePtr + ) + #else + static int + leafNode( nodePtr ) + struct Node *nodePtr; + #endif + { + Avl_Enter(Avl_tw+300,("leafNode")) ; + Avl_Return (nodePtr->left == NULL) && (nodePtr->right == NULL); + } + + /*------------------------------------------------------------------------------ + * Description: + * As per twalk(3). + * + * The twalk() function traverses a binary search tree. The root parameter + * specifies the root of the binary tree to be traversed. Any node in a binary + * tree can be used as the root node for a walk below that node. The action + * parameter is the name of a routine to be invoked at each node. This action + * routine is called with three parameters. The first parameter specifies the + * address of the visited node. The second parameter specifies a value from + * an enum data type, which is defined in the search.h include file as fol- + * lows: + * typedef enum { preorder, postorder, endorder, leaf } VISIT + * + * The value of the second parameter in the action routine depends on whether + * this is the first (preorder), second (postorder), or third (endorder) time + * that the node has been visited during a depth-first, left-to-right traver- + * sal of the tree, or whether the node is a leaf. (A leaf is a node that is + * not the parent of another node). The third parameter in the action routine + * is the level of the node in the binary tree with the root being level 0 + * (zero). + * + * Notes: + * + * Parameters: + * root - Node to use as root for the walk. + * action - Function to be performed on each node. + * + * + * Returns: + * None + * + *----------------------------------------------------------------------------- + */ + + #ifdef NeedFunctionPrototypes + global void + twalkAVL( + const void *root , + void (*action)(const void *, VISIT, int ) + ) + #else + global void + twalkAVL( root, action ) + void *root; + void (*action)(); + #endif + { + static int level = -1; + + Avl_Enter(Avl_tw+200,("twalkAVL")) ; + + if ( root != NULL ) + { + level++; + + if ( leafNode( (struct Node *)root ) ) + { + action( &((struct Node *)root)->info, leaf, level); + } + else + { + action( &((struct Node *)root)->info, preorder, level); + twalkAVL( (void *)(((struct Node *)root)->left), action ); + action( &((struct Node *)root)->info, postorder, level); + twalkAVL( (void *)(((struct Node *)root)->right), action ); + action( &((struct Node *)root)->info, endorder, level); + } + + level--; + } + else + { + Avl_Trace(Avl_tw+210,("root != NULL")); + } + Avl_Return ; + } *** /dev/null Thu Jun 26 12:08:49 1997 --- build/freebsd/java/main/referenceX.c Wed Jun 11 10:40:33 1997 *************** *** 0 **** --- 1,12 ---- + #if defined(__FreeBSD__) + void referenceXstuff(void) { + /* this is never called, but is in here to get the loader to pull up + libXm, libXt, libXext, and libX11 */ + #ifdef USE_MOTIF + XmActivateProtocol(); + #endif + XtInitialize(); + XextFindDisplay(); + XServerVendor(); + } + #endif