*** scrt/cio.c.ORIG Tue Feb 23 18:26:41 1993 --- scrt/cio.c Tue Jun 28 14:33:50 1994 *************** *** 143,148 **** --- 143,152 ---- #define HAVE_RUSAGE #endif + #ifdef FREEBSD + #define HAVE_RUSAGE + #endif + #ifdef SYSV #define HAVE_TIMES #else *************** *** 467,473 **** --- 471,481 ---- struct timeval timeout; stream = (FILE*)TSCP_POINTER( file ); + #ifdef FREEBSD + if (((stream)->_r) <= 0) { + #else if (((stream)->_cnt) <= 0) { + #endif FD_ZERO( &readfds ); FD_SET( fileno( stream ), &readfds ); timeout.tv_sec = 0; *************** *** 549,555 **** break; case 3: ! #ifdef MAC sprintf( format, "%%.%lilg", (long)TSCP_S2CINT( length ) ); sprintf( buffer, format, TSCP_DOUBLE( number ) ); #else --- 557,563 ---- break; case 3: ! #if defined(MAC) || defined(FREEBSD) sprintf( format, "%%.%lilg", (long)TSCP_S2CINT( length ) ); sprintf( buffer, format, TSCP_DOUBLE( number ) ); #else *** scrt/heap.c.ORIG Mon Feb 22 11:11:16 1993 --- scrt/heap.c Mon Jun 27 23:26:15 1994 *************** *** 66,71 **** --- 66,74 ---- #ifdef VAX extern sc_r2tor11( ); #endif + #ifdef FREEBSD + extern sc_geti386regs( S2CINT* a ); + #endif /* Forward declarations */ *************** *** 368,373 **** --- 371,401 ---- S2CINT r2tor11[10], *pp; sc_r2tor11( r2tor11 ); + STACKPTR( pp ); + while (pp != sc_stackbase) move_continuation_ptr( ((SCP)*pp++) ); + } + #endif + + #ifdef FREEBSD + /* The following code is used to read the stack pointer. The register + number is passed in to force an argument to be on the stack, which in + turn can be used to find the address of the top of stack. + */ + + S2CINT *sc_processor_register( S2CINT reg ) + { + return( ® ); + } + + /* All processor registers which might contain pointers are traced by the + following procedure. + */ + + static trace_stack_and_registers() + { + S2CINT i386regs[6], *pp; + + sc_geti386regs( i386regs ); STACKPTR( pp ); while (pp != sc_stackbase) move_continuation_ptr( ((SCP)*pp++) ); } *** scrt/options.h.ORIG Mon Feb 22 11:14:23 1993 --- scrt/options.h Tue Jun 28 15:25:37 1994 *************** *** 71,76 **** --- 71,77 ---- MC680X0 HP 9000/300, Sun 3, Next MIPS DECstation, SGI, Sony News VAX Vax ULTRIX + FREEBSD x86 FreeBSD WIN16 Microsoft Windows 3.1 */ *************** *** 80,85 **** --- 81,87 ---- #define MC680X0 1 #define MIPS 1 #define VAX 1 + #define FREEBSD 1 #define WIN16 1 /* Attributes of the selected architecture: *************** *** 369,374 **** --- 371,404 ---- */ #define STACKPTR( x ) x = sc_processor_register( 14 ) + #endif + + /***************/ + /* FREEBSD */ + /***************/ + + #ifdef FREEBSD + #define IMPLEMENTATION_MACHINE "Generic PC" + #define IMPLEMENTATION_CPU "Intelx86" + #define IMPLEMENTATION_OS "FreeBSD" + #undef IMPLEMENTATION_FS + + typedef int S2CINT; /* Signed pointer size integer */ + typedef unsigned S2CUINT; /* Unsigned pointer size interger */ + + typedef int PAGELINK; /* 32-bit sc_pagelink values */ + #define MAXS2CINT 0x7fffffff /* Maximum value of an S2CINT */ + #define MSBS2CUINT 0x80000000 /* S2CUINT with 1 in the MSB */ + + #define STACKPTR( x ) x = sc_processor_register( 0 ) + + #include + typedef jmp_buf sc_jmp_buf; + + /* Horrid kludge. See callcc.c for the full story: */ + #define LAZY_STACK_POP 1 + #define LAZY_STACK_INCREMENT 4 + #endif /***************/ *** scrt/callcc.c.ORIG Tue Feb 23 18:25:24 1993 --- scrt/callcc.c Tue Jun 28 03:25:04 1994 *************** *** 91,96 **** --- 91,101 ---- #define SETJMP( x ) sc_setjmp( x ) #endif + #ifdef FREEBSD + #define LONGJMP( x, y ) longjmp( x, y ) + #define SETJMP( x ) setjmp( x ) + #endif + TSCP sc_clink; /* Pointer to inner most continuation on stack. */ /* Static declarations for data structures internal to the module. These *************** *** 192,197 **** --- 197,213 ---- STACKPTR( tos ); count = (((STACK_BYTES (bfp, tos)) + ((sizeof (S2CINT)) - 1)) / (sizeof (S2CINT))); + #ifdef LAZY_STACK_POP + /* NOTE WELL! + * For machines that must pop arguments after a function call, + * the compiler may let arguments accumulate on the stack for several + * function calls and pop them all at once. + * If your compiler uses this optimization, 'count' must be incremented + * by the number of S2CINTs pushed as arguments between this point and + * the point where 'bcount' is computed. + */ + count += LAZY_STACK_INCREMENT; + #endif save_fp = (S2CINT*)bfp; cp = sc_allocateheap( NULLCONTINUATIONSIZE+count+2+sc_maxdisplay, CONTINUATIONTAG, *************** *** 199,204 **** --- 215,227 ---- STACKPTR( tos ); fp = save_fp; bcount = (STACK_BYTES (fp, tos)); + if (bcount > count*sizeof(S2CINT)) + /* If you get this error, look above at LAZY_STACK_POP */ + sc_error( "CALL-WITH-CURRENT-CONTINUATION", + "internal error: want to write ~s bytes of stack, " + "but only ~s bytes allocated.", + LIST2( C_FIXED( bcount ), + C_FIXED( count*sizeof(S2CINT) ) ) ); cp->continuation.continuation = sc_clink; cp->continuation.stackbytes = bcount; cp->continuation.stacktrace = sc_stacktrace; *** makefile.ORIG Tue Feb 16 14:19:52 1993 --- makefile Mon Jun 27 22:52:48 1994 *************** *** 92,97 **** --- 92,104 ---- cp ports/VAX/vax.s VAX/server cp ports/VAX/options-server.h VAX/server/options.h + forFREEBSD: + make "CPU=FREEBSD" forANY + cp ports/FREEBSD/x86.s FREEBSD/scrt + cp ports/FREEBSD/options.h FREEBSD/scrt + cp ports/FREEBSD/x86.s FREEBSD/server + cp ports/FREEBSD/options-server.h FREEBSD/server/options.h + forWIN16: make "CPU=WIN16" forANY rm -r WIN16/scsc