diff -Nurd linux86.old/Libc_version linux86/Libc_version --- linux86.old/Libc_version Tue May 22 09:46:45 2001 +++ linux86/Libc_version Sat Jan 12 19:42:33 2002 @@ -1 +1 @@ -0.16.0 +0.16.1 diff -Nurd linux86.old/MAGIC linux86/MAGIC --- linux86.old/MAGIC Thu Nov 6 22:19:28 1997 +++ linux86/MAGIC Thu Jan 1 01:00:00 1970 @@ -1,23 +0,0 @@ -Useful bits for /etc/magic: - -#------------------------------------------------------------------------------ -# Localstuff: file(1) magic for locally observed files -# -# $Id: Localstuff,v 1.3 1995/01/21 21:09:00 christos Exp $ -# Add any locally observed files here. Remember: -# text if readable, executable if runnable binary, data if unreadable. -# -0 string \01\03\020\04 Linux-8086 impure executable ->28 long !0 not stripped -0 string \01\03\040\04 Linux-8086 executable ->28 long !0 not stripped -# -0 string \243\206\001\0 Linux-8086 object file -# There is _no_ difference between 16 and 32 bit .o files that file can see. -# -0 string \01\03\020\20 Minix-386 impure executable ->28 long !0 not stripped -0 string \01\03\040\20 Minix-386 executable ->28 long !0 not stripped -# -#------------------------------------------------------------------------------ diff -Nurd linux86.old/Mk_dist linux86/Mk_dist --- linux86.old/Mk_dist Mon May 21 15:15:45 2001 +++ linux86/Mk_dist Fri May 25 14:50:23 2001 @@ -13,9 +13,8 @@ ARCDIR="$DIR"/dev86arc SRCDIRS='bcc unproto as ar ld copt man elksemu dis88 tests libbsd bin86' -DISTFILES='Libc_version Makefile README COPYING MAGIC Changes Contributors - mkcompile mkcompile2 later.c GNUmakefile libcompat - ifdef.c makefile.in Mk_dist' +DISTFILES='Libc_version Makefile README COPYING Changes Contributors + mkcompile GNUmakefile libcompat ifdef.c makefile.in Mk_dist' TMPDIST=$TMPDIR/$TMPSRC rm -rf ${TMPDIR} diff -Nurd linux86.old/as/Makefile linux86/as/Makefile --- linux86.old/as/Makefile Sat Jan 6 09:52:28 2001 +++ linux86/as/Makefile Sat Jun 23 21:12:07 2001 @@ -4,10 +4,10 @@ LIBDIR=/usr/bin BINDIR=/usr/bin -OBJS =as.o assemble.o error.o express.o \ +OBJS =as.o assemble.o errors.o express.o \ genbin.o genlist.o genobj.o gensym.o \ keywords.o macro.o mops.o pops.o readsrc.o \ - scan.o table.o typeconv.o + scan.o table.o typeconv.o alloc.o all: as86 as86_encap diff -Nurd linux86.old/as/alloc.c linux86/as/alloc.c --- linux86.old/as/alloc.c Thu Jan 1 01:00:00 1970 +++ linux86/as/alloc.c Sat Jun 23 23:37:52 2001 @@ -0,0 +1,100 @@ + +#include "syshead.h" +#include "const.h" +#include "type.h" +#include "align.h" + +PRIVATE char NOMEMEORY[] = "Cannot allocate sufficient memory"; + +#ifdef USE_FIXED_HEAP +PRIVATE char *heapend; /* end of free space for symbol list */ +PRIVATE char *heapptr; /* next free space in symbol list */ +#endif + +#ifndef USE_FIXED_HEAP +PRIVATE char tempbuf[2048]; +#endif + +void +init_heap() +{ +#ifdef USE_FIXED_HEAP +#ifndef USERMEM +#define USERMEM (unsigned) 0xAC00U +#endif + +#ifdef __AS386_16__ + heapptr = sbrk(0); + heapend = ((char*)&argc) - STAKSIZ - 16; + brk(heapend); + if(sbrk(0) != heapend) + as_abort(NOMEMEORY); +#else +#ifdef SOS_EDOS + heapend = stackreg() - STAKSIZ; +#else + heapptr = malloc(USERMEM); + heapend = heapptr + USERMEM; + if (heapptr == 0) + as_abort(NOMEMEORY); +#endif +#endif +#endif +} + +void * temp_buf() +{ +#ifdef USE_FIXED_HEAP + return heapptr; +#else + return tempbuf; +#endif +} + +void * +asalloc(size) +unsigned int size; +{ + void * rv; +#ifdef USE_FIXED_HEAP + align(heapptr); + if (heapptr+size < heapend) + { + rv = heapptr; + heapptr += size; + } + else + rv = 0; +#else + rv = malloc(size); +#endif + + if (rv == 0) as_abort(NOMEMEORY); + return rv; +} + + +void * +asrealloc(oldptr, size) +void * oldptr; +unsigned int size; +{ + void * rv; +#ifdef USE_FIXED_HEAP + if (oldptr == 0) return asalloc(size); + + if ((char*)oldptr+size < heapend) + { + heapptr = oldptr + size; + rv = oldptr; + } + else + rv = 0; +#else + rv = realloc(oldptr, size); +#endif + + if (rv == 0) as_abort(NOMEMEORY); + return rv; +} + diff -Nurd linux86.old/as/as.c linux86/as/as.c --- linux86.old/as/as.c Tue Sep 26 21:08:13 2000 +++ linux86/as/as.c Sat Jun 23 20:01:12 2001 @@ -32,30 +32,11 @@ FORWARD void summ_number P((unsigned num)); FORWARD void usage P((void)); -#ifndef USERMEM -#define USERMEM (sizeof(int) <= 2 ? (unsigned) 0xAC00 : (unsigned) 0x28000L) -#endif - PUBLIC int main(argc, argv) int argc; char **argv; { -#ifdef __AS386_16__ - heapptr = sbrk(0); - heapend = ((char*)&argc) - STAKSIZ - 16; - brk(heapend); - if(sbrk(0) != heapend) - as_abort("Cannot allocate memory"); -#else -#ifdef SOS_EDOS - heapend = stackreg() - STAKSIZ; -#else - heapptr = malloc(USERMEM); - heapend = heapptr + USERMEM; - if (heapptr == 0) - as_abort("cannot allocate memory"); -#endif -#endif + init_heap(); initp1(); initp1p2(); inst_keywords(); @@ -321,9 +302,10 @@ PRIVATE void summ_number(num) unsigned num; { - /* format number like line numbers, build it at free spot heapptr */ - *build_number(num, LINUM_LEN, heapptr) = 0; - writes(heapptr); + /* format number like line numbers */ + char buf[16]; + *build_number(num, LINUM_LEN, buf) = 0; + writes(buf); } PRIVATE void usage() diff -Nurd linux86.old/as/assemble.c linux86/as/assemble.c --- linux86.old/as/assemble.c Fri Oct 27 09:02:12 2000 +++ linux86/as/assemble.c Sun Jun 24 08:19:37 2001 @@ -38,7 +38,9 @@ pfcb, pfcc, pfdb, +#if SIZEOF_OFFSET_T > 2 pfqb, +#endif pget, pglobl, pident, diff -Nurd linux86.old/as/const.h linux86/as/const.h --- linux86.old/as/const.h Thu Apr 24 21:25:29 1997 +++ linux86/as/const.h Wed Jun 27 16:38:16 2001 @@ -7,14 +7,14 @@ #define S_ALIGNMENT sizeof(long) #endif -#include "align.h" - /* const.h - constants for assembler */ /* major switches */ +/* #define MC6809 */ /* generate 6809 code */ +#ifndef MC6809 #define I80386 /* generate 80386 code */ -#undef MC6809 /* generate 6809 code */ +#endif #define MNSIZE /* allow byte size in mnemonic, e.g. "movb" */ #undef SOS_EDOS /* source OS is EDOS */ @@ -215,116 +215,6 @@ COLON }; -enum -{ -/* Error codes. */ - -/* Syntax errors. */ - COMEXP, - DELEXP, - FACEXP, - IREGEXP, - LABEXP, - LPEXP, - OPEXP, - RBEXP, - REGEXP, - RPEXP, - SPEXP, - -/* Expression errors. */ - ABSREQ, - NONIMPREQ, - RELBAD, - -/* Label errors. */ - ILLAB, - MACUID, - MISLAB, - MNUID, - REGUID, - RELAB, - UNBLAB, - UNLAB, - VARLAB, - -/* Addressing errors. */ - ABOUNDS, - DBOUNDS, - ILLMOD, - ILLREG, - -/* Control structure errors. */ - ELSEBAD, -#define ELSEIFBAD ELSEBAD - ENDBBAD, -#define ENDIFBAD ELSEBAD - EOFBLOCK, - EOFIF, - EOFLC, - EOFMAC, - FAILERR, - -/* Overflow errors. */ - BLOCKOV, - BWRAP, - COUNTOV, - COUNTUN, - GETOV, - IFOV, - - LINLONG, - MACOV, - OBJSYMOV, - OWRITE, - PAROV, - SYMOV, - SYMOUTOV, - -/* I/O errors. */ - OBJOUT, - -/* Miscellaneous errors. */ - AL_AX_EAX_EXP, - CTLINS, - FURTHER, - ILL_IMM_MODE, - ILL_IND_TO_IND, - ILL_IND, - ILL_IND_PTR, - ILL_SCALE, - ILL_SECTION, - ILL_SEG_REG, - ILL_SOURCE_EA, - ILL_SIZE, - IMM_REQ, - INDEX_REG_EXP, - IND_REQ, - MISMATCHED_SIZE, - NOIMPORT, - REENTER, - REL_REQ, - REPEATED_DISPL, - SEGREL, - SEG_REG_REQ, - SIZE_UNK, - UNKNOWN_ESCAPE_SEQUENCE, - - FP_REG_REQ, - FP_REG_NOT_ALLOWED, - ILL_FP_REG, - ILL_FP_REG_PAIR, - JUNK_AFTER_OPERANDS, - - ALREADY, - UNSTABLE_LABEL, - -/* Warnings. */ -#define MINWARN CPUCLASH - CPUCLASH, - SHORTB -}; - /* symbol table entry */ /* type entry contains following flags */ @@ -423,3 +313,6 @@ #define DPLOC 2 #define STRLOC 1 #define TEXTLOC 0 + +#include "errors.h" + diff -Nurd linux86.old/as/error.c linux86/as/error.c --- linux86.old/as/error.c Tue Sep 26 20:52:45 2000 +++ linux86/as/error.c Thu Jan 1 01:00:00 1970 @@ -1,102 +0,0 @@ -/* error.c - error routines for assembler */ - -#include "syshead.h" -#include "const.h" -#include "type.h" - -PRIVATE char *errormessage[] = -{ - "comma expected", - "delimiter expected", - "factor expected", - "index register expected", - "label expected", - "left parentheses expected", - "opcode expected", - "right bracket expected", - "register expected", - "right parentheses expected", - "space expected", - "absolute expression required", - "non-imported expression required", - "relocation impossible", - "illegal label", - "MACRO used as identifier", - "missing label", - "opcode used as identifier", - "register used as identifier", - "redefined label", - "unbound label", - "undefined label", - "variable used as label", - "address out of bounds", - "data out of bounds", - "illegal address mode", - "illegal register", - "no matching IF", - "no matching BLOCK", - "end of file in BLOCK", - "end of file in IF", - "location counter was undefined at end", - "end of file in MACRO", - "user-generated error", - "BLOCK stack overflow", - "binary file wrap-around", - "counter overflow", - "counter underflow", - "GET stack overflow", - "IF stack overflow", - "line too long", - "MACRO stack overflow", - "object symbol table overflow", - "program overwrite", - "parameter table overflow", - "symbol table overflow", - "output symbol table overflow", - "error writing object file", - "al, ax or eax expected", - "control character in string", - "futher errors suppressed", - "illegal immediate mode", - "illegal indirect to indirect", - "illegal indirection", - "illegal indirection from previous 'ptr'", - "illegal scale", - "illegal section", - "illegal segment register", - "illegal source effective address", - "illegal size", - "immediate expression expected", - "index register expected", - "indirect expression required", - "mismatched size", - "no imports with binary file output", - "multiple ENTER pseudo-ops", - "relative expression required", - "repeated displacement", - "segment or relocatability redefined", - "segment register required", - "size unknown", - "unknown escape sequence", - "FP register required", - "FP register not allowed", - "illegal FP register", - "illegal FP register pair", - "junk after operands", - "already defined", - "label moved in last pass, add -O?", - "instruction illegal for current cpu", - "short branch would do", - "unknown error", -}; - -/* build null-terminated error message for given error at given spot */ - -PUBLIC char *build_error_message(errnum, buf) -error_pt errnum; -char *buf; -{ - if (errnum >= sizeof errormessage / sizeof errormessage[0]) - errnum = sizeof errormessage / sizeof errormessage[0] - 1; - return strcpy(buf, errormessage[errnum]); -} diff -Nurd linux86.old/as/errors.c linux86/as/errors.c --- linux86.old/as/errors.c Thu Jan 1 01:00:00 1970 +++ linux86/as/errors.c Sun Jun 24 08:40:02 2001 @@ -0,0 +1,107 @@ + +#include "syshead.h" +#include "const.h" + +/* Error codes. */ + +/* Syntax errors. */ +PUBLIC char * COMEXP = "comma expected"; +PUBLIC char * DELEXP = "delimiter expected"; +PUBLIC char * FACEXP = "factor expected"; +PUBLIC char * IREGEXP = "index register expected"; +PUBLIC char * LABEXP = "label expected"; +PUBLIC char * LPEXP = "left parentheses expected"; +PUBLIC char * OPEXP = "opcode expected"; +PUBLIC char * RBEXP = "right bracket expected"; +PUBLIC char * REGEXP = "register expected"; +PUBLIC char * RPEXP = "right parentheses expected"; +PUBLIC char * SPEXP = "space expected"; + +/* Expression errors. */ +PUBLIC char * ABSREQ = "absolute expression required"; +PUBLIC char * NONIMPREQ = "non-imported expression required"; +PUBLIC char * RELBAD = "relocation impossible"; + +/* Label errors. */ +PUBLIC char * ILLAB = "illegal label"; +PUBLIC char * MACUID = "MACRO used as identifier"; +PUBLIC char * MISLAB = "missing label"; +PUBLIC char * MNUID = "opcode used as identifier"; +PUBLIC char * REGUID = "register used as identifier"; +PUBLIC char * RELAB = "redefined label"; +PUBLIC char * UNBLAB = "unbound label"; +PUBLIC char * UNLAB = "undefined label"; +PUBLIC char * VARLAB = "variable used as label"; + +/* Addressing errors. */ +PUBLIC char * ABOUNDS = "address out of bounds"; +PUBLIC char * DBOUNDS = "data out of bounds"; +PUBLIC char * ILLMOD = "illegal address mode"; +PUBLIC char * ILLREG = "illegal register"; + +/* Control structure errors. */ +PUBLIC char * ELSEBAD = "no matching IF"; +PUBLIC char * ENDBBAD = "no matching BLOCK"; +PUBLIC char * EOFBLOCK = "end of file in BLOCK"; +PUBLIC char * EOFIF = "end of file in IF"; +PUBLIC char * EOFLC = "location counter was undefined at end"; +PUBLIC char * EOFMAC = "end of file in MACRO"; +PUBLIC char * FAILERR = "user-generated error"; + +/* Overflow errors. */ +PUBLIC char * BLOCKOV = "BLOCK stack overflow"; +PUBLIC char * BWRAP = "binary file wrap-around"; +PUBLIC char * COUNTOV = "counter overflow"; +PUBLIC char * COUNTUN = "counter underflow"; +PUBLIC char * GETOV = "GET stack overflow"; +PUBLIC char * IFOV = "IF stack overflow"; + +PUBLIC char * LINLONG = "line too long"; +PUBLIC char * MACOV = "MACRO stack overflow"; +PUBLIC char * OBJSYMOV = "object symbol table overflow"; +PUBLIC char * OWRITE = "program overwrite"; +PUBLIC char * PAROV = "parameter table overflow"; +PUBLIC char * SYMOV = "symbol table overflow"; +PUBLIC char * SYMOUTOV = "output symbol table overflow"; + +/* I/O errors. */ +PUBLIC char * OBJOUT = "error writing object file"; + +/* Miscellaneous errors. */ +PUBLIC char * AL_AX_EAX_EXP = "al ax or eax expected"; +PUBLIC char * CTLINS = "control character in string"; +PUBLIC char * FURTHER = "futher errors suppressed"; +PUBLIC char * ILL_IMM_MODE = "illegal immediate mode"; +PUBLIC char * ILL_IND_TO_IND = "illegal indirect to indirect"; +PUBLIC char * ILL_IND = "illegal indirection"; +PUBLIC char * ILL_IND_PTR = "illegal indirection from previous 'ptr'"; +PUBLIC char * ILL_SCALE = "illegal scale"; +PUBLIC char * ILL_SECTION = "illegal section"; +PUBLIC char * ILL_SEG_REG = "illegal segment register"; +PUBLIC char * ILL_SOURCE_EA = "illegal source effective address"; +PUBLIC char * ILL_SIZE = "illegal size"; +PUBLIC char * IMM_REQ = "immediate expression expected"; +PUBLIC char * INDEX_REG_EXP = "index register expected"; +PUBLIC char * IND_REQ = "indirect expression required"; +PUBLIC char * MISMATCHED_SIZE = "mismatched size"; +PUBLIC char * NOIMPORT = "no imports with binary file output"; +PUBLIC char * REENTER = "multiple ENTER pseudo-ops"; +PUBLIC char * REL_REQ = "relative expression required"; +PUBLIC char * REPEATED_DISPL = "repeated displacement"; +PUBLIC char * SEGREL = "segment or relocatability redefined"; +PUBLIC char * SEG_REG_REQ = "segment register required"; +PUBLIC char * SIZE_UNK = "size unknown"; +PUBLIC char * UNKNOWN_ESCAPE_SEQUENCE = "unknown escape sequence"; + +PUBLIC char * FP_REG_REQ = "FP register required"; +PUBLIC char * FP_REG_NOT_ALLOWED = "FP register not allowed"; +PUBLIC char * ILL_FP_REG = "illegal FP register"; +PUBLIC char * ILL_FP_REG_PAIR = "illegal FP register pair"; +PUBLIC char * JUNK_AFTER_OPERANDS = "junk after operands"; + +PUBLIC char * ALREADY = "already defined"; +PUBLIC char * UNSTABLE_LABEL = "label moved in last pass add -O?"; + +/* Warnings. */ +PUBLIC char * CPUCLASH = "instruction illegal for current cpu"; +PUBLIC char * SHORTB = "short branch would do"; diff -Nurd linux86.old/as/errors.h linux86/as/errors.h --- linux86.old/as/errors.h Thu Jan 1 01:00:00 1970 +++ linux86/as/errors.h Sat Jun 23 20:58:50 2001 @@ -0,0 +1,105 @@ +/* Error codes. */ + +/* Syntax errors. */ +EXTERN char * COMEXP; /* "comma expected" */ +EXTERN char * DELEXP; /* "delimiter expected" */ +EXTERN char * FACEXP; /* "factor expected" */ +EXTERN char * IREGEXP; /* "index register expected" */ +EXTERN char * LABEXP; /* "label expected" */ +EXTERN char * LPEXP; /* "left parentheses expected" */ +EXTERN char * OPEXP; /* "opcode expected" */ +EXTERN char * RBEXP; /* "right bracket expected" */ +EXTERN char * REGEXP; /* "register expected" */ +EXTERN char * RPEXP; /* "right parentheses expected" */ +EXTERN char * SPEXP; /* "space expected" */ + +/* Expression errors. */ +EXTERN char * ABSREQ; /* "absolute expression required" */ +EXTERN char * NONIMPREQ; /* "non-imported expression required" */ +EXTERN char * RELBAD; /* "relocation impossible" */ + +/* Label errors. */ +EXTERN char * ILLAB; /* "illegal label" */ +EXTERN char * MACUID; /* "MACRO used as identifier" */ +EXTERN char * MISLAB; /* "missing label" */ +EXTERN char * MNUID; /* "opcode used as identifier" */ +EXTERN char * REGUID; /* "register used as identifier" */ +EXTERN char * RELAB; /* "redefined label" */ +EXTERN char * UNBLAB; /* "unbound label" */ +EXTERN char * UNLAB; /* "undefined label" */ +EXTERN char * VARLAB; /* "variable used as label" */ + +/* Addressing errors. */ +EXTERN char * ABOUNDS; /* "address out of bounds" */ +EXTERN char * DBOUNDS; /* "data out of bounds" */ +EXTERN char * ILLMOD; /* "illegal address mode" */ +EXTERN char * ILLREG; /* "illegal register" */ + +/* Control structure errors. */ +EXTERN char * ELSEBAD; /* "no matching IF" */ +#define ELSEIFBAD ELSEBAD +EXTERN char * ENDBBAD; /* "no matching BLOCK" */ +#define ENDIFBAD ELSEBAD +EXTERN char * EOFBLOCK; /* "end of file in BLOCK" */ +EXTERN char * EOFIF; /* "end of file in IF" */ +EXTERN char * EOFLC; /* "location counter was undefined at end" */ +EXTERN char * EOFMAC; /* "end of file in MACRO" */ +EXTERN char * FAILERR; /* "user-generated error" */ + +/* Overflow errors. */ +EXTERN char * BLOCKOV; /* "BLOCK stack overflow" */ +EXTERN char * BWRAP; /* "binary file wrap-around" */ +EXTERN char * COUNTOV; /* "counter overflow" */ +EXTERN char * COUNTUN; /* "counter underflow" */ +EXTERN char * GETOV; /* "GET stack overflow" */ +EXTERN char * IFOV; /* "IF stack overflow" */ + +EXTERN char * LINLONG; /* "line too long" */ +EXTERN char * MACOV; /* "MACRO stack overflow" */ +EXTERN char * OBJSYMOV; /* "object symbol table overflow" */ +EXTERN char * OWRITE; /* "program overwrite" */ +EXTERN char * PAROV; /* "parameter table overflow" */ +EXTERN char * SYMOV; /* "symbol table overflow" */ +EXTERN char * SYMOUTOV; /* "output symbol table overflow" */ + +/* I/O errors. */ +EXTERN char * OBJOUT; /* "error writing object file" */ + +/* Miscellaneous errors. */ +EXTERN char * AL_AX_EAX_EXP; /* "al ax or eax expected" */ +EXTERN char * CTLINS; /* "control character in string" */ +EXTERN char * FURTHER; /* "futher errors suppressed" */ +EXTERN char * ILL_IMM_MODE; /* "illegal immediate mode" */ +EXTERN char * ILL_IND_TO_IND; /* "illegal indirect to indirect" */ +EXTERN char * ILL_IND; /* "illegal indirection" */ +EXTERN char * ILL_IND_PTR; /* "illegal indirection from previous 'ptr'" */ +EXTERN char * ILL_SCALE; /* "illegal scale" */ +EXTERN char * ILL_SECTION; /* "illegal section" */ +EXTERN char * ILL_SEG_REG; /* "illegal segment register" */ +EXTERN char * ILL_SOURCE_EA; /* "illegal source effective address" */ +EXTERN char * ILL_SIZE; /* "illegal size" */ +EXTERN char * IMM_REQ; /* "immediate expression expected" */ +EXTERN char * INDEX_REG_EXP; /* "index register expected" */ +EXTERN char * IND_REQ; /* "indirect expression required" */ +EXTERN char * MISMATCHED_SIZE; /* "mismatched size" */ +EXTERN char * NOIMPORT; /* "no imports with binary file output" */ +EXTERN char * REENTER; /* "multiple ENTER pseudo-ops" */ +EXTERN char * REL_REQ; /* "relative expression required" */ +EXTERN char * REPEATED_DISPL; /* "repeated displacement" */ +EXTERN char * SEGREL; /* "segment or relocatability redefined" */ +EXTERN char * SEG_REG_REQ; /* "segment register required" */ +EXTERN char * SIZE_UNK; /* "size unknown" */ +EXTERN char * UNKNOWN_ESCAPE_SEQUENCE; /* "unknown escape sequence" */ + +EXTERN char * FP_REG_REQ; /* "FP register required" */ +EXTERN char * FP_REG_NOT_ALLOWED; /* "FP register not allowed" */ +EXTERN char * ILL_FP_REG; /* "illegal FP register" */ +EXTERN char * ILL_FP_REG_PAIR; /* "illegal FP register pair" */ +EXTERN char * JUNK_AFTER_OPERANDS; /* "junk after operands" */ + +EXTERN char * ALREADY; /* "already defined" */ +EXTERN char * UNSTABLE_LABEL; /* "label moved in last pass add -O?" */ + +/* Warnings. */ +EXTERN char * CPUCLASH; /* "instruction illegal for current cpu" */ +EXTERN char * SHORTB; /* "short branch would do" */ diff -Nurd linux86.old/as/express.c linux86/as/express.c --- linux86.old/as/express.c Mon Jul 26 11:23:39 1999 +++ linux86/as/express.c Sun Jun 24 08:09:40 2001 @@ -8,7 +8,7 @@ #include "scan.h" #include "source.h" -FORWARD void experror P((error_pt errnum)); +FORWARD void experror P((char * err_str)); FORWARD void expundefined P((void)); FORWARD void simple2 P((void)); FORWARD void simple P((void)); @@ -33,10 +33,10 @@ } } -PRIVATE void experror(errnum) -error_pt errnum; +PRIVATE void experror(err_str) +char * err_str; { - error(errnum); + error(err_str); expundefined(); } @@ -312,6 +312,7 @@ getsym(); return; } +#ifndef MC6809 case LBRACKET: if (!asld_compatible) break; /* error, LPAREN is the grouping symbol */ @@ -322,9 +323,12 @@ else getsym(); return; +#endif case LPAREN: +#ifndef MC6809 if (asld_compatible) break; /* error, LBRACKET is the grouping symbol */ +#endif getsym(); expres(); if (sym != RPAREN) diff -Nurd linux86.old/as/genbin.c linux86/as/genbin.c --- linux86.old/as/genbin.c Thu Jan 2 09:54:07 1997 +++ linux86/as/genbin.c Sat Jun 23 20:24:20 2001 @@ -7,9 +7,11 @@ #include "file.h" #include "globvar.h" +#ifdef USE_FIXED_HEAP PRIVATE char *asmbeg; /* beginning of assembler code */ /* for overwrite check */ /* bss-init to zero = NULL and not changed */ +#endif /* Sneaky stuff, the start of a binary file can be _negative_ for the I80386 assembler. The -ve addresses are ones over 2GB (or "org -32") */ @@ -234,17 +236,19 @@ } } } +#ifdef USE_FIXED_HEAP else if (binaryc && !(lcdata & UNDBIT)) /* memory output, and enabled */ { register char *bufptr; - if ((bufptr = (char *) binmbuf) >= asmbeg && bufptr < heapptr) + if ((bufptr = (char *) binmbuf) >= asmbeg && bufptr < temp_buf()) error(OWRITE); else *bufptr = ch; ++binmbuf; } +#endif } /* write sized offset to binary file or directly to memory */ diff -Nurd linux86.old/as/genlist.c linux86/as/genlist.c --- linux86.old/as/genlist.c Sat Jun 17 11:23:51 2000 +++ linux86/as/genlist.c Sat Jun 23 21:13:19 2001 @@ -17,7 +17,7 @@ struct error_s /* to record error info */ { - unsigned char errnum; + char * err_str; unsigned char position; }; @@ -131,36 +131,39 @@ /* record number and position of error (or error buffer overflow) */ -PUBLIC void error(errnum) -error_pt errnum; +PUBLIC void warning(err_str) +char * err_str; +{ + if (!as_warn.current) return; + ++totwarn; + --toterr; + error(err_str); +} + +PUBLIC void error(err_str) +char * err_str; { register struct error_s *errptr; register struct error_s *errptrlow; unsigned char position; - if ((unsigned) errnum < MINWARN || as_warn.current) + if (errcount >= MAXERR) + erroverflow = TRUE; + else { - if (errcount >= MAXERR) - erroverflow = TRUE; - else + position = symname - linebuf; + for (errptr = errbuf + errcount; + errptr > errbuf && errptr->position > position; + errptr = errptrlow) { - position = symname - linebuf; - for (errptr = errbuf + errcount; - errptr > errbuf && errptr->position > position; - errptr = errptrlow) - { - errptrlow = errptr - 1; - errptr->errnum = errptrlow->errnum; - errptr->position = errptrlow->position; - } - errptr->errnum = errnum; - errptr->position = position; - ++errcount; - if ((unsigned)errnum >= MINWARN) - ++totwarn; - else - ++toterr; + errptrlow = errptr - 1; + errptr->err_str = errptrlow->err_str; + errptr->position = errptrlow->position; } + errptr->err_str = err_str; + errptr->position = position; + ++errcount; + ++toterr; } } @@ -208,7 +211,7 @@ unsigned numlength; char *numptr; - listptr = (struct code_listing_s *) heapptr; + listptr = (struct code_listing_s *) temp_buf(); memset((char *) listptr, ' ', sizeof *listptr); listptr->nullterm = 0; if (macflag) @@ -354,7 +357,7 @@ { writenl(); paderrorline(1); } - writes(errmsg = build_error_message(errptr->errnum, heapptr)); + writes(errmsg = errptr->err_str); errcol = strlen(errmsg)+LINUM_LEN+1; column = 0; linep = linebuf; errcolw = CODE_LIST_LENGTH; @@ -390,7 +393,7 @@ paderrorline((unsigned) errcolw - LINUM_LEN); } writec('^'); - writes(errmsg = build_error_message(errptr->errnum, heapptr)); + writes(errmsg = errptr->err_str); errcol += strlen(errmsg); #endif ++errptr; @@ -404,7 +407,7 @@ #else paderrorline(CODE_LIST_LENGTH - LINUM_LEN); #endif - writesn(build_error_message(FURTHER, heapptr)); + writesn(FURTHER); } } diff -Nurd linux86.old/as/genobj.c linux86/as/genobj.c --- linux86.old/as/genobj.c Thu Mar 18 07:08:48 1999 +++ linux86/as/genobj.c Sat Jun 23 20:04:08 2001 @@ -345,6 +345,7 @@ unsigned symosiz; /* size of object symbol table */ register struct sym_s *symptr; u32_T textlength; + int symcount = 0; if ((objectc = objectg) == 0) return; @@ -362,9 +363,22 @@ if ((nameptr = strrchr(module_name, '.')) != NUL_PTR) *nameptr = 0; strsiz = strlen(module_name) + 1; - align(heapptr); - for (hashptr = spt, arrext = copyptr = (struct sym_s **) heapptr; - hashptr < spt_top;) + + for (hashptr = spt; hashptr < spt_top;) + if ((symptr = *hashptr++) != NUL_PTR) + do + { + if ((symptr->type & EXPBIT || symptr->data & IMPBIT) || + (!globals_only_in_obj && symptr->name[0] != '.' && + !(symptr->type & (MNREGBIT | MACBIT | VARBIT)))) + { + symcount ++; + } + } + while ((symptr = symptr->next) != NUL_PTR); + arrext = copyptr = asalloc( sizeof(struct sym_s *) * symcount); + + for (hashptr = spt; hashptr < spt_top;) if ((symptr = *hashptr++) != NUL_PTR) do { @@ -372,11 +386,6 @@ (!globals_only_in_obj && symptr->name[0] != '.' && !(symptr->type & (MNREGBIT | MACBIT | VARBIT)))) { - if (copyptr >= (struct sym_s **) heapend) - { - heapptr = (char *) copyptr; - fatalerror(OBJSYMOV); - } *copyptr++ = symptr; strsiz += symptr->length + 1; if (textseg>=0 && (symptr->data & SEGM) == textseg) @@ -399,7 +408,7 @@ } } while ((symptr = symptr->next) != NUL_PTR); - heapptr = (char *) (copytop = copyptr); + copytop = copyptr; /* calculate length of text, and number of seg size bytes in header */ diff -Nurd linux86.old/as/gensym.c linux86/as/gensym.c --- linux86.old/as/gensym.c Mon Jul 22 00:33:40 1996 +++ linux86/as/gensym.c Sat Jun 23 20:25:18 2001 @@ -29,35 +29,34 @@ #ifdef BINSYM unsigned label_stringptr; /* offset of label str from start of file */ #endif + int symcount = 0; labels_length = label_count = 0; /* make copy of all relavant symbol ptrs on heap */ /* original ptrs can now be modified, but need to be an array for sort */ - align(heapptr); - for (hashptr = spt, symlptr = copyptr = (struct sym_s **) heapptr; - hashptr < spt_top;) + for (hashptr = spt; hashptr < spt_top;) + if ((symptr = *hashptr++) != NUL_PTR) + do + if (!(symptr->type & (MACBIT | MNREGBIT | VARBIT))) + symcount++; + while ((symptr = symptr->next) != NUL_PTR); + symlptr = copyptr = asalloc( sizeof(struct sym_s *) * symcount); + + for (hashptr = spt; hashptr < spt_top;) if ((symptr = *hashptr++) != NUL_PTR) do if (!(symptr->type & (MACBIT | MNREGBIT | VARBIT))) { - if (copyptr >= (struct sym_s **) heapend) - { - heapptr = (char *) copyptr; - error(SYMOUTOV); /* avoid recursive fatalerror */ - listline(); /* the main job is OK if here */ - goto sort_symbols; - } *copyptr++ = symptr; ++label_count; labels_length += symptr->length + 3; /* 3 for type, value */ } while ((symptr = symptr->next) != NUL_PTR); -sort_symbols: sort(symlptr, copyptr, TRUE); /* sort on name */ - heapptr = (char *) (copytop = copyptr); + copytop = copyptr; if (list.global) { outfd = lstfil; @@ -147,7 +146,7 @@ char *outname; char *symname; - listptr = (struct sym_listing_s *) heapptr; + listptr = (struct sym_listing_s *) temp_buf(); memset((char *) listptr, ' ', SYMLIS_LEN); listptr->nullterm = 0; if ((length = symptr->length) > SYMLIS_NAMELEN) diff -Nurd linux86.old/as/globvar.h linux86/as/globvar.h --- linux86.old/as/globvar.h Wed Sep 27 20:03:50 2000 +++ linux86/as/globvar.h Sat Jun 23 21:18:19 2001 @@ -35,8 +35,6 @@ /* for symbol table routines */ -EXTERN char *heapend; /* end of free space for symbol list */ -EXTERN char *heapptr; /* next free space in symbol list */ EXTERN unsigned char inidata; /* init sym entry data governed by "u" flag */ EXTERN struct sym_s **spt; /* symbol pointer table */ EXTERN struct sym_s **spt_top; /* top of symbol ptr table */ @@ -112,7 +110,7 @@ #ifdef I80386 #ifndef __AS386_16__ #define iscpu(x) (cpuid>=(x)) -#define needcpu(x) do{ if(cpuid<(x)) {error(CPUCLASH); cpuid|=0x10;} }while(0) +#define needcpu(x) do{ if(cpuid<(x)) {warning(CPUCLASH); cpuid|=0x10;} }while(0) #define setcpu(x) (cpuid=(x)) #define cpuwarn() (cpuid&=0xF) #endif diff -Nurd linux86.old/as/keywords.c linux86/as/keywords.c --- linux86.old/as/keywords.c Mon Jul 22 00:33:42 1996 +++ linux86/as/keywords.c Wed Jun 27 17:08:22 2001 @@ -135,9 +135,13 @@ 5, '.', 'D', 'A', 'T', 'A', DATAOP, 0, 6, '.', 'D', 'A', 'T', 'A', '1', FCBOP, 0, 6, '.', 'D', 'A', 'T', 'A', '2', FDBOP, 0, +#if SIZEOF_OFFSET_T > 2 6, '.', 'D', 'A', 'T', 'A', '4', FQBOP, 0, +#endif 2, 'D', 'B', FCBOP, 0, +#if SIZEOF_OFFSET_T > 2 2, 'D', 'D', FQBOP, 0, +#endif 7, '.', 'D', 'E', 'F', 'I', 'N', 'E', EXPORTOP, 0, 2, 'D', 'W', FDBOP, 0, 3, 'E', 'N', 'D', PROCEOFOP, 0, @@ -165,7 +169,9 @@ 6, '.', 'L', 'C', 'O', 'M', 'M', LCOMMOP1, 0, 5, '.', 'L', 'I', 'S', 'T', LISTOP, 0, 3, 'L', 'O', 'C', LOCOP, 0, +#if SIZEOF_OFFSET_T > 2 5, '.', 'L', 'O', 'N', 'G', FQBOP, 0, +#endif 8, '.', 'M', 'A', 'C', 'L', 'I', 'S', 'T', MACLISTOP, 0, 5, 'M', 'A', 'C', 'R', 'O', MACROOP, 0, 4, '.', 'M', 'A', 'P', MAPOP, 0, @@ -180,8 +186,10 @@ 6, '.', 'S', 'H', 'O', 'R', 'T', FDBOP, 0, 6, '.', 'S', 'P', 'A', 'C', 'E', RMBOP, 0, 5, '.', 'T', 'E', 'X', 'T', TEXTOP, 0, +#ifndef MC6809 5, 'U', 'S', 'E', '1', '6', USE16OP, 0, 5, 'U', 'S', 'E', '3', '2', USE32OP, 0, +#endif 5, '.', 'W', 'A', 'R', 'N', WARNOP, 0, 5, '.', 'W', 'O', 'R', 'D', FDBOP, 0, 6, '.', 'Z', 'E', 'R', 'O', 'W', BLKWOP, 0, diff -Nurd linux86.old/as/macro.c linux86/as/macro.c --- linux86.old/as/macro.c Thu Jan 2 09:54:07 1997 +++ linux86/as/macro.c Sat Jun 23 22:54:14 2001 @@ -38,9 +38,12 @@ macpar = (struct schain_s *) (stringptr + 1); /* TODO: alignment */ getsym(); - if (sym != LPAREN) + if (sym == EOLSYM) return; /* no other params */ - reglineptr = lineptr; + if (sym != LPAREN) + reglineptr = symname; + else + reglineptr = lineptr; stringptr = macpar->string; while (TRUE) { @@ -51,10 +54,11 @@ return; } ch = *reglineptr++; - if (ch == '/') + if (ch == '\\') /* escaped means no special meaning for slash, comma, paren */ ch = *reglineptr++; - else if (ch == ',' || ch == ')') + else if (ch == ',' || ch == ')' || ch == '!' || ch == ';' + || ch == '\n' || ch == 0) { if (stringptr >= (char *) macptop) { @@ -69,7 +73,7 @@ macpar = (struct schain_s *) (stringptr + 1); /* but is finished OK - TODO align */ stringptr = macpar->string; - if (ch == ')') + if (ch != ',') return; continue; } @@ -90,6 +94,9 @@ bool_t saving; bool_t savingc; struct sym_s *symptr=0; + int maclen = 8; + int macoff = 0; + char * macbuf = asalloc(8); saving = /* prepare for bad macro */ savingc = FALSE; /* normally don't save comments */ @@ -114,9 +121,7 @@ else symptr->type |= MACBIT; symptr->data = UNDBIT; /* undefined till end */ - symptr->value_reg_or_op.value = (offset_t) heapptr; - /* beginning of store for macro */ - /* value s.b. (char *) */ + symptr->value_reg_or_op.value = (offset_t) macbuf; getsym_nolookup(); /* test for "C" */ if (sym == IDENT && lineptr == symname + 1 && *symname == 'C') savingc = TRUE; @@ -147,27 +152,24 @@ if (!saving) continue; { - register char *reglineptr; - register char *regheapptr; + char * p = strchr(linebuf, EOLCHAR); + int len = (p-linebuf+1); - reglineptr = linebuf; - regheapptr = heapptr; - do + if ( macoff + len > maclen-4 ) { - if (regheapptr >= heapend) - { - heapptr = regheapptr; - fatalerror(SYMOV); /* won't fit */ - } + maclen = maclen * 2 + len; + macbuf = asrealloc(macbuf, maclen); } - while ((*regheapptr++ = *reglineptr++) != EOLCHAR); - heapptr = regheapptr; + memcpy(macbuf+macoff, linebuf, len); + macoff += len; + } } macload = FALSE; if (saving) { - *heapptr++ = ETB; + macbuf[macoff] = ETB; + symptr->value_reg_or_op.value = (offset_t) macbuf; symptr->data = 0; } } diff -Nurd linux86.old/as/mops.c linux86/as/mops.c --- linux86.old/as/mops.c Wed Sep 27 21:15:14 2000 +++ linux86/as/mops.c Sun Jun 24 08:22:44 2001 @@ -409,7 +409,7 @@ FORWARD void getindirect P((struct ea_s *eap)); FORWARD void getshift P((struct ea_s *eap)); FORWARD reg_pt indregchk P((reg_pt matchreg)); -FORWARD void kgerror P((error_pt errnum)); +FORWARD void kgerror P((char * err_str)); FORWARD void lbranch P((int backamount)); FORWARD void notbytesize P((struct ea_s *eap)); FORWARD void notimmed P((struct ea_s *eap)); @@ -1050,10 +1050,10 @@ return reg; } -PRIVATE void kgerror(errnum) -error_pt errnum; +PRIVATE void kgerror(err_str) +char * err_str; { - error(errnum); + error(err_str); sprefix = oprefix = aprefix = mcount = 0x0; } @@ -1071,7 +1071,7 @@ if ( last_pass<2 && backamount != 0x0 && !(lastexp.data & IMPBIT) && lastexp.offset + backamount < 0x80 + backamount) - error(SHORTB); /* -0x8? to 0x7F, warning */ + warning(SHORTB); /* -0x8? to 0x7F, warning */ } } } @@ -2427,7 +2427,7 @@ FORWARD void do1altind P((void)); FORWARD void fixupind P((void)); FORWARD void getindexnopost P((void)); -FORWARD void inderror P((error_pt errnum)); +FORWARD void inderror P((char * err_str)); FORWARD reg_pt indreg P((reg_pt maxindex)); FORWARD void predec1 P((void)); FORWARD void sustack P((reg_pt stackreg)); @@ -2617,8 +2617,8 @@ inderror(ILLMOD); /* e.g. LEAX $10 */ else { - if (byteflag || !wordflag && !(lastexp.data & (FORBIT | RELBIT)) && - (lastexp.offset >> 0x8) == dirpag) + if (byteflag || (!wordflag && !(lastexp.data & (FORBIT | RELBIT)) && + (lastexp.offset >> 0x8) == dirpag)) { /* direct addressing */ if (opcode >= 0x80) opcode |= 0x10; @@ -2634,7 +2634,7 @@ !(lastexp.data & IMPBIT) && lastexp.offset + (0x81 - 0x3) < 0x101) /* JSR or JMP could be done with BSR or BRA */ - error(SHORTB); + warning(SHORTB); } } } @@ -2657,10 +2657,10 @@ fixupind(); } -PRIVATE void inderror(errnum) -error_pt errnum; +PRIVATE void inderror(err_str) +char * err_str; { - error(errnum); + error(err_str); if (postb & INDIRECTBIT) sym = RBRACKET; /* fake right bracket to kill further errors */ fixupind(); @@ -2754,7 +2754,7 @@ lastexp.offset = lastexp.offset - lc - lcjump; if ( last_pass<2 && !(lastexp.data & IMPBIT) && lastexp.offset + 0x81 < 0x101) - error(SHORTB); /* -0x81 to 0x7F, warning */ + warning(SHORTB); /* -0x81 to 0x7F, warning */ } } } diff -Nurd linux86.old/as/opcode.h linux86/as/opcode.h --- linux86.old/as/opcode.h Sat Jul 10 18:07:21 1993 +++ linux86/as/opcode.h Sun Jun 24 08:18:46 2001 @@ -31,7 +31,9 @@ FCBOP, FCCOP, FDBOP, +#if SIZEOF_OFFSET_T > 2 FQBOP, +#endif GETOP, GLOBLOP, IDENTOP, diff -Nurd linux86.old/as/pops.c linux86/as/pops.c --- linux86.old/as/pops.c Fri Oct 27 09:00:01 2000 +++ linux86/as/pops.c Sat Jun 23 21:03:47 2001 @@ -420,10 +420,10 @@ } } -PUBLIC void fatalerror(errnum) -error_pt errnum; +PUBLIC void fatalerror(err_str) +char * err_str; { - error(errnum); + error(err_str); skipline(); listline(); finishup(); @@ -432,8 +432,8 @@ /* swap position with label position, do error, put back posn */ /* also clear label ptr */ -PUBLIC void labelerror(errnum) -error_pt errnum; +PUBLIC void labelerror(err_str) +char * err_str; { struct sym_s *oldgsymptr; char *oldlineptr; @@ -447,7 +447,7 @@ lineptr = linebuf; getsym(); /* 1st symbol is label or symbol after * missing one */ - error(errnum); + error(err_str); gsymptr = oldgsymptr; lineptr = oldlineptr; sym = oldsym; diff -Nurd linux86.old/as/proto.h linux86/as/proto.h --- linux86.old/as/proto.h Thu Mar 18 07:06:04 1999 +++ linux86/as/proto.h Sun Jun 24 08:19:03 2001 @@ -10,9 +10,6 @@ /* assemble.c */ void assemble P((void)); -/* error.c */ -char *build_error_message P((error_pt errnum, char *buf)); - /* express.c */ void absexpres P((void)); void chkabs P((void)); @@ -34,7 +31,8 @@ /* genlist.c */ char *build_2hex_number P((unsigned num, char *where)); char *build_number P((unsigned num, unsigned width, char *where)); -void error P((error_pt errnum)); +void warning P((char * errorstr)); +void error P((char * errorstr)); void listline P((void)); void writec P((int ch)); void writenl P((void)); @@ -139,8 +137,8 @@ bool_pt checksegrel P((struct sym_s *symptr)); void checkdatabounds P((void)); void datatoobig P((void)); -void fatalerror P((error_pt errnum)); -void labelerror P((error_pt errnum)); +void fatalerror P((char * errorstr)); +void labelerror P((char * errorstr)); void palign P((void)); void pasciz P((void)); void pblkw P((void)); @@ -163,7 +161,9 @@ void pfcb P((void)); void pfcc P((void)); void pfdb P((void)); +#if SIZEOF_OFFSET_T > 2 void pfqb P((void)); +#endif void pglobl P((void)); void pident P((void)); void pif P((void)); @@ -216,3 +216,10 @@ void u2cn P((char *buf, u16_pt offset, unsigned count)); void u4cn P((char *buf, u32_T offset, unsigned count)); bool_pt typeconv_init P((bool_pt big_endian, bool_pt long_big_endian)); + +/* alloc.c */ +void * asalloc P((unsigned int size)); +void * asrealloc P((void * oldptr, unsigned int size)); +void * temp_buf P((void)); +void init_heap P((void)); + diff -Nurd linux86.old/as/readsrc.c linux86/as/readsrc.c --- linux86.old/as/readsrc.c Wed Sep 27 07:45:09 2000 +++ linux86/as/readsrc.c Sat Jun 23 23:41:14 2001 @@ -138,9 +138,12 @@ for(;;) { if( filelength >= memsize ) - mem_start = realloc(mem_start, (memsize+=16000)+4); - if(mem_start == 0) - as_abort("Cannot allocate memory for BIG buffer"); + { + if (memsize > 16000) + mem_start = asrealloc(mem_start, (memsize+=16384)+4); + else + mem_start = asrealloc(mem_start, (memsize+=memsize+32)+4); + } cc = read(fd, mem_start+filelength, (size_t)(memsize-filelength)); if( cc <= 0 ) break; diff -Nurd linux86.old/as/scan.c linux86/as/scan.c --- linux86.old/as/scan.c Sun Aug 4 19:45:42 1996 +++ linux86/as/scan.c Wed Jun 27 16:06:10 2001 @@ -233,6 +233,7 @@ PUBLIC void initscan() { +#ifndef MC6809 if (asld_compatible) { lindirect = LPAREN; @@ -241,8 +242,11 @@ } else { +#endif lindirect = LBRACKET; rindexp = RBEXP; rindirect = RBRACKET; +#ifndef MC6809 } +#endif } diff -Nurd linux86.old/as/scan.h linux86/as/scan.h --- linux86.old/as/scan.h Sat Jun 29 21:05:18 1996 +++ linux86/as/scan.h Sat Jun 23 21:14:28 2001 @@ -6,7 +6,7 @@ EXTERN char lindirect; /* left symbol for indirect addressing */ EXTERN char *lineptr; /* current line position */ EXTERN offset_t number; /* constant number */ -EXTERN int rindexp; /* error code for missing rindirect */ +EXTERN char * rindexp; /* error code for missing rindirect */ EXTERN char rindirect; /* right symbol for indirect addressing */ EXTERN char sym; /* current symbol */ EXTERN char *symname; /* current symbol name */ diff -Nurd linux86.old/as/table.c linux86/as/table.c --- linux86.old/as/table.c Sun Apr 13 12:53:11 1997 +++ linux86/as/table.c Wed Jun 27 16:31:42 2001 @@ -168,24 +168,18 @@ } if (!ifflag) return NUL_PTR; - align(heapptr); - if (heapptr >= heapend) - fatalerror(SYMOV); #ifdef DEBUG ++nsym; if (hashptr >= spt && hashptr < spt + SPTSIZ) ++nhash; #endif - *hashptr = symptr = (struct sym_s *) heapptr; + *hashptr = symptr = asalloc(sizeof(struct sym_s) + length); symptr->type = 0; symptr->data = inidata; symptr->length = length; symptr->value_reg_or_op.value = (offset_t) (symptr->next = NUL_PTR); - heapptr = symptr->name; - do - *heapptr++ = *nameptr++; - while (--length != 0); - *heapptr++ = 0; + memcpy(symptr->name, nameptr, length); + symptr->name[length] = 0; return symptr; } @@ -220,6 +214,6 @@ weight += nx[i] * i; } printf("\n"); - printf("weight = %d%d\n", w; + printf("weight = %d%d\n", w); #endif } diff -Nurd linux86.old/as/type.h linux86/as/type.h --- linux86.old/as/type.h Sat Jun 29 21:20:30 1996 +++ linux86/as/type.h Sat Jun 23 21:01:37 2001 @@ -22,7 +22,6 @@ typedef unsigned char bool_t; typedef int bool_pt; typedef unsigned count_t; -typedef int error_pt; typedef int fd_t; typedef unsigned char indcount_t; #ifdef I80386 diff -Nurd linux86.old/as/typeconv.c linux86/as/typeconv.c --- linux86.old/as/typeconv.c Sat Jun 7 08:38:46 1997 +++ linux86/as/typeconv.c Sat Jun 23 19:55:32 2001 @@ -15,8 +15,8 @@ static int no_swap = 1; -static long_off[4] = {0,1,2,3}; -static int_off[2] = {0,1}; +static int long_off[4] = {0,1,2,3}; +static int int_off[2] = {0,1}; PUBLIC bool_pt typeconv_init(big_endian, long_big_endian) bool_pt big_endian; diff -Nurd linux86.old/bcc/bcc.c linux86/bcc/bcc.c --- linux86.old/bcc/bcc.c Wed Sep 27 21:43:51 2000 +++ linux86/bcc/bcc.c Sat Jan 12 19:42:31 2002 @@ -1,26 +1,67 @@ -/* bcc.c - driver for Bruce's C compiler (bcc) and for CvW's C compiler */ - -/* Copyright (C) 1992 Bruce Evans */ - -#define _POSIX_SOURCE 1 - +/* + * bcc.c Version 2001.1 + * Complete rewrite because the old one was just too confusing! + * + * There are no significant compile time options (MC6809 and CCC + * just change defaults) but you should set LOCALPREFIX. + * + * Personality flags are: + * + * -Mn Normal ELKS + * -Md MSDOS + * -Ms PC Standalone. + * -Ml i386 Linux + * -M8 CvW's c386 + * -M9 MC6809 with bcc + */ +#include +#ifdef __STDC__ +#include +#include +#endif +#include +#include +#include +#include #include #include #ifndef MSDOS #include -#include -#endif #include -#include -#include -#include +#endif -#define FALSE 0 -#define FORWARD static -#define NUL_PTR ((void*)0) -#define PRIVATE static -#define PUBLIC -#define TRUE 1 +#ifdef MSDOS +#define LOCALPREFIX /linux86 +#define EXESUF ".exe" +#define R_OK 4 /* Test for read permission. */ +#define W_OK 2 /* Test for write permission. */ +#define X_OK 1 /* Test for execute permission. */ +#define F_OK 0 /* Test for existence. */ +#define L_TREE 1 /* Use different tree style */ +#define DEFARCH 0 /* Default to 8086 code */ +#else +#define EXESUF +#endif + +#define AS "as" EXESUF +#define LD "ld" EXESUF +#define CPP "cpp" EXESUF +#define CC1 "cc1" EXESUF +#define OPT "opt" EXESUF + +#define CC1C386 "c386" EXESUF + +#define AS09 "as09" EXESUF +#define LD09 "ld09" EXESUF + +#define CPPBCC "bcc-cc1" EXESUF +#define CC1BCC "bcc-cc1" EXESUF +#define AS86 "as86" EXESUF +#define LD86 "ld86" EXESUF + +#define GCC "gcc" +#define UNPROTO "unproto" EXESUF +#define OPTIM "copt" EXESUF #if __STDC__ == 1 #define P(x) x @@ -32,932 +73,951 @@ #define QUOT(x) "x" #endif +struct command { + char * cmd; + char * fullpath; + int numargs; + int maxargs; + char ** arglist; +} command = { 0,0,0,0,0 }; + +struct file_list { + struct file_list * next; + char * file; + char * oldfile; + char * name; + int filetype; /* Char, notional extention of file. */ +} * files; + +struct opt_list { + struct opt_list * next; + char * opt; + int opttype; /* Where the option should go */ +} * options; + +int opt_v, opt_V, opt_e, opt_x, opt_I, opt_L, opt_W, opt_i, + opt_O, opt_M; + +#ifdef DEFARCH +int opt_arch = (DEFARCH != 0); +#else +int opt_arch = sizeof (char *) >= 4; +#endif + +int do_preproc = 1; /* c -> i */ +int do_unproto = 0; /* i -> i */ +int do_compile = 1; /* i -> s */ +int do_optim = 0; /* s -> s */ +int do_as = 1; /* s -> o */ +int do_link = 1; /* o -> done */ +char * executable_name = 0; + +int file_count = 0; +int dyn_count = 0; +int error_count = 0; +char * progname = "C"; #ifdef MSDOS -#define LOCALPREFIX /linux86 -#define EXESUF ".exe" -#define R_OK 4 /* Test for read permission. */ -#define W_OK 2 /* Test for write permission. */ -#define X_OK 1 /* Test for execute permission. */ -#define F_OK 0 /* Test for existence. */ -#define L_TREE 1 /* Use different tree style */ -#define DEFARCH 0 /* Default to 8086 code */ +char * tmpdir = ""; #else -#define EXESUF +char * tmpdir = "/tmp/"; #endif -#if defined(__minix) || defined(__BCC__) -#define realpath(x,y) 0 +int main P((int argc, char **argv)); +void getargs P((int argc, char **argv)); +void add_prefix P((char * path)); +void run_aspreproc P((struct file_list * file)); +void run_preproc P((struct file_list * file)); +void run_unproto P((struct file_list * file)); +void run_compile P((struct file_list * file)); +void run_optim P((struct file_list * file)); +void run_as P((struct file_list * file)); +void run_link P((void)); +void command_reset P((void)); +void command_opt P((char * option)); +void command_arch P((void)); +void command_opts P((int opykey)); +void newfilename P((struct file_list * file, int last_stage, int new_extn, int use_o)); +void run_unlink P((void)); +void append_file P((char * filename, int ftype)); +void append_option P((char * option, int otype)); +char * expand_tilde P((char * str)); +void * xalloc P((int size)); +void Usage P((void)); +void fatal P((char * why)); +char * copystr P((char * str)); +char * catstr P((char * str, char * str2)); +#ifdef L_TREE +void reset_localprefix P((void)); #endif +void run_command P((struct file_list * file)); -#define BAS86 -#define BCC86 +#ifndef LOCALPREFIX +#define LOCALPREFIX /usr +#endif +char * localprefix = QUOT(LOCALPREFIX); +#ifndef L_TREE +char * default_include = "-I~/include"; +char * default_libdir0 = "-L~/lib/bcc/i86/"; +char * default_libdir3 = "-L~/lib/bcc/i386/"; +char * optim_rules = "-d~/lib/bcc/i86"; +#else +char * default_include = "-I~/include"; +char * default_libdir0 = "-L~/lib/"; +char * default_libdir3 = "-L~/lib/i386/"; +char * optim_rules = "-d~/lib"; +#endif -#define AS "as86" EXESUF -#define CC1 "bcc-cc1" EXESUF -#define CC1_MINUS_O_BROKEN FALSE -#define CPP "bcc-cc1" EXESUF -#define CPPFLAGS "-E" -#define GCC "gcc" -#define LD "ld86" EXESUF -#define UNPROTO "unproto" EXESUF -#define OPTIM "copt" EXESUF +char devnull[] = "/dev/null"; +char * exec_prefixs[] = { -#ifdef L_TREE -#define STANDARD_CRT0_0_PREFIX "~/lib/" -#define STANDARD_CRT0_3_PREFIX "~/lib/i386/" -#define STANDARD_EXEC_PREFIX "~/lib/" -#define STANDARD_EXEC_PREFIX_2 "~/bin/" -#define DEFAULT_INCLUDE "-I~/include" -#define DEFAULT_LIBDIR0 "-L~/lib/" -#define DEFAULT_LIBDIR3 "-L~/lib/i386/" -#define OPTIM_RULES "-d~/lib" -#else -#define STANDARD_CRT0_0_PREFIX "~/lib/bcc/i86/" -#define STANDARD_CRT0_3_PREFIX "~/lib/bcc/i386/" -#define STANDARD_EXEC_PREFIX "~/lib/bcc/" + /* Place fillers for dynamic fill */ + devnull, devnull, devnull, devnull, devnull, + + "~/lib/bcc/", #ifdef BINDIR -#define STANDARD_EXEC_PREFIX_2 QUOT(BINDIR) "/" -#else -#define STANDARD_EXEC_PREFIX_2 "/usr/bin/" + QUOT(BINDIR) "/", #endif -#define DEFAULT_INCLUDE "-I~/include" -#define DEFAULT_LIBDIR0 "-L~/lib/bcc/i86/" -#define DEFAULT_LIBDIR3 "-L~/lib/bcc/i386/" -#define OPTIM_RULES "-d~/lib/bcc/i86" + "~/lib/", + "~/bin/", + "/usr/bin/", + 0 +}; + +char * libc = "-lc"; + +int +main(argc, argv) +int argc; +char ** argv; +{ + struct file_list * next_file; + + progname = argv[0]; +#ifdef L_TREE + reset_localprefix(); #endif + getargs(argc, argv); -#ifdef CCC -#undef BCC86 -#undef CC1 -#define CC1 "c386" -#undef CC1_MINUS_O_BROKEN -#define CC1_MINUS_O_BROKEN TRUE -#undef STANDARD_CRT0_0_PREFIX -#undef STANDARD_CRT0_3_PREFIX -#define STANDARD_CRT0_PREFIX "~/lib/i386/" -#endif /* CCC */ + default_include = expand_tilde(default_include); + default_libdir0 = expand_tilde(default_libdir0); + default_libdir3 = expand_tilde(default_libdir3); + optim_rules = expand_tilde(optim_rules); -#ifdef MC6809 -#undef BAS86 -#undef BCC86 -#undef CRT0 -#undef GCC -#undef STANDARD_CRT0_0_PREFIX -#undef STANDARD_CRT0_3_PREFIX -#undef STANDARD_EXEC_PREFIX -#define STANDARD_EXEC_PREFIX "~/lib/bcc/m09/" -#endif /* MC6809 */ + if (opt_v>1) { command.cmd = ""; command_reset(); } + + for(next_file = files; next_file && !error_count; next_file = next_file->next) + { + if (next_file->filetype == 'o') continue; -#define ALLOC_UNIT 16 /* allocation unit for arg arrays */ -#define DIRCHAR '/' -#define START_ARGS 4 /* number of reserved args */ + if (opt_V) + fprintf(stderr, "%s:\n", next_file->file); -typedef unsigned char bool_T; /* boolean: TRUE if nonzero */ + /* Assembler that's not to be optimised. */ + if (do_preproc && next_file->filetype == 'S') run_aspreproc(next_file); + if (do_as && next_file->filetype == 's') run_as(next_file); -struct arg_s + /* C source */ + if (do_preproc && next_file->filetype == 'c') run_preproc(next_file); + if (do_unproto && next_file->filetype == 'i') run_unproto(next_file); + if (do_compile && next_file->filetype == 'i') run_compile(next_file); + if (do_optim && next_file->filetype == 's') run_optim(next_file); + if (do_as && next_file->filetype == 's') run_as(next_file); + + if (next_file->filetype == '~') error_count++; + } + + if (do_link && !error_count) + run_link(); + + run_unlink(); + exit(error_count>0); +} + +char * +copystr(str) +char * str; { - char *prog; - bool_T minus_O_broken; - int argc; - char **argv; - unsigned nr_allocated; -}; + return strcpy(xalloc(strlen(str)+1), str); +} -struct prefix_s +char * +catstr(str, str2) +char * str, * str2; { - char *name; - struct prefix_s *next; -}; + return strcat(strcpy(xalloc(strlen(str)+strlen(str2)+1), str), str2); +} -PRIVATE struct arg_s asargs = { AS, }; -PRIVATE struct arg_s ccargs = { CC1, CC1_MINUS_O_BROKEN, }; -PRIVATE struct arg_s cppargs = { CPP, }; -PRIVATE struct arg_s unprotoargs = { UNPROTO, TRUE }; -PRIVATE struct arg_s optargs = { OPTIM }; -PRIVATE struct prefix_s exec_prefix; -PRIVATE struct arg_s ldargs = { LD, }; -#ifdef BAS86 -PRIVATE struct arg_s ldrargs = { LD, }; +void +run_aspreproc(file) +struct file_list * file; +{ + if (opt_arch<5) command.cmd = CPPBCC; + else command.cmd = CPP; + command_reset(); + newfilename(file, !do_as, 's', (opt_arch<5)); + if (opt_arch<5) + command_opt("-E"); + command_opts('p'); + command_opt("-D__ASSEMBLER__"); +#if 0 + if (!opt_I) + command_opt(default_include); #endif -PRIVATE char *progname; -PRIVATE bool_T runerror; /* = FALSE */ -PRIVATE struct arg_s tmpargs; /* = empty */ -PRIVATE char *tmpdir; -PRIVATE unsigned verbosity; /* = 0 */ + command_arch(); + run_command(file); +} -PRIVATE char * localprefix = QUOT(LOCALPREFIX); +void +run_preproc(file) +struct file_list * file; +{ + int last_stage = 0;; -#ifdef REDECLARE_STDC_FUNCTIONS -void exit P((int status)); -char *getenv P((const char *name)); -void *malloc P((size_t size)); -void *realloc P((void *ptr, size_t size)); -void (*signal P((int sig, void (*func) P((int sig))))) P((int sig)); -char *strcpy P((char *dest, const char *src)); -size_t strlen P((const char *s)); -char *strrchr P((const char *s, int c)); -#endif + if (opt_arch<5) command.cmd = CPPBCC; + else command.cmd = CPP; + command_reset(); -#ifdef REDECLARE_POSIX_FUNCTIONS -int access P((const char *path, int amode)); -int execv P((const char *path, char * const *argv)); -int execve P((const char *path, char * const *argv, char * const envp)); -pid_t fork P((void)); -pid_t getpid P((void)); -int unlink P((const char *path)); -pid_t wait P((int *status)); -ssize_t write P((int fd, const void *buf, size_t nbytes)); -#endif + if (!opt_e && !do_optim && !do_as ) last_stage =1; + if (opt_e && !do_unproto && !do_compile ) last_stage =1; -int main P((int argc, char **argv)); + newfilename(file, last_stage, (opt_e?'i':'s'), (opt_arch<5)); -FORWARD void addarg P((struct arg_s *argp, char *arg)); -FORWARD void adddefine P((char *arg)); -FORWARD void addprefix P((struct prefix_s *prefix, char *name)); -FORWARD char *expand_tilde P((char * str, int canfree)); -FORWARD void fatal P((char *message)); -FORWARD char *fixpath P((char *path, struct prefix_s *prefix, int mode)); -FORWARD void killtemps P((void)); -FORWARD void *my_malloc P((unsigned size, char *where)); -FORWARD char *my_mktemp P((void)); -FORWARD void my_unlink P((char *name)); -FORWARD void outofmemory P((char *where)); -FORWARD int run P((char *in_name, char *out_name, struct arg_s *argp)); -#ifdef L_TREE -FORWARD void reset_localprefix P((void)); -#endif -FORWARD void set_trap P((void)); -FORWARD void show_who P((char *message)); -FORWARD void startarg P((struct arg_s *argp)); -FORWARD char *stralloc P((char *s)); -FORWARD char *stralloc2 P((char *s1, char *s2)); -FORWARD void trap P((int signum)); -FORWARD void writen P((void)); -FORWARD void writes P((char *s)); -FORWARD void writesn P((char *s)); -FORWARD void linux_patch P((char * fname)); + if (opt_e && opt_arch<5) command_opt("-E"); -#ifdef __BCC__ -char ** minienviron[] = { - "PATH=/bin:/usr/bin", - "SHELL=/bin/sh", - 0 -}; -#endif + command_opts('p'); + if (!opt_e) + { + command_opts('c'); + if (opt_arch<5 && !do_as) + command_opt("-t"); + } -PUBLIC int main(argc, argv) -int argc; -char **argv; + if (!opt_I) + command_opt(default_include); + + command_arch(); + + run_command(file); +} + +void +run_unproto(file) +struct file_list * file; { - char *arg; - int add_default_inc = 1; - int add_default_lib = 1; - int argcount = argc; - bool_T *argdone = my_malloc((unsigned) argc * sizeof *argdone, "argdone"); - bool_T as_only = FALSE; - char *basename; -#ifdef BCC86 -#ifdef DEFARCH - bool_T bits32 = (DEFARCH != 0); -#else - bool_T bits32 = sizeof (char *) >= 4; -#endif - char *bits_arg; -#endif - bool_T cc_only = FALSE; - bool_T ansi_pass = FALSE; -#ifdef CCC - bool_T cpp_pass = TRUE; -#else - bool_T cpp_pass = FALSE; -#endif - char *libc = "-lc"; -#ifdef MSDOS - char major_mode = 'd'; -#else - char major_mode = 0; -#endif - bool_T has_crt0 = TRUE; - bool_T debug = FALSE; - bool_T echo = FALSE; - unsigned errcount = 0; - char ext; - char *f_out = NUL_PTR; -#ifdef BAS86 - bool_T gnu_objects = FALSE; -#endif - bool_T aswarn = FALSE; - char *in_name; - int length; - unsigned ncisfiles = 0; - unsigned nifiles = 0; - unsigned npass_specs; - bool_T optimize = FALSE; - char *optflags = 0; - char *out_name; - bool_T profile = FALSE; - bool_T prep_only = FALSE; - bool_T prep_line_numbers = FALSE; - bool_T compiler_warnings = TRUE; - int status; - char *temp; - bool_T patch_exe = FALSE; /* Hackish patch to convert minix i386->OMAGIC */ + command.cmd = UNPROTO; + command_reset(); + newfilename(file, !do_compile, 'i', 0); + command_opts('u'); - progname = argv[0]; - addarg(&cppargs, CPPFLAGS); -#ifdef CCC - addarg(&asargs, "-j"); -#endif - addarg(&asargs, "-u"); -#ifdef BAS86 - addarg(&ldrargs, "-r"); - addarg(&ldrargs, "-N"); /* GCC uses native objects */ - /* GCC also uses 386 how to add -3 too ? */ - addarg(&optargs, "-c!"); - optflags = stralloc("start"); -#endif + run_command(file); +} -#ifdef L_TREE - reset_localprefix(); -#endif - /* Pass 1 over argv to gather compile options. */ - for (; --argc != 0;) - { - arg = *++argv; - *++argdone = TRUE; - if (arg[0] == '-' && arg[1] != 0 && arg[2] == 0) - switch (arg[1]) - { -#ifdef BCC86 - case '0': - bits32 = FALSE; - break; - case '3': - bits32 = TRUE; - break; -#endif - case 'E': - prep_only = prep_line_numbers = cpp_pass = TRUE; - break; -#ifdef BAS86 - case 'G': - gnu_objects = TRUE; - add_default_lib = 0; - break; -#endif - case 'P': - prep_only = cpp_pass = TRUE; - prep_line_numbers = FALSE; - break; - case 'O': - optimize = TRUE; - temp = optflags; - optflags=stralloc2(optflags,",86"); - free(temp); - break; - case 'S': - cc_only = TRUE; -#ifndef CCC - addarg(&ccargs, "-t"); -#endif - break; - case 'V': - echo = TRUE; - break; - case 'c': - as_only = TRUE; - break; - case 'e': - cpp_pass = TRUE; - break; - case 'g': - debug = TRUE; /* unsupported */ - break; - case 'o': - if (argc <= 1) - { - ++errcount; - show_who("output file missing after -o\n"); - } - else - { - argc--; - if (f_out != NUL_PTR) - show_who("more than one output file\n"); - f_out = *++argv; - *++argdone = TRUE; - } - break; - case 'p': - profile = TRUE; - break; - case 'v': - ++verbosity; - break; - case 'w': - compiler_warnings = FALSE; - aswarn = FALSE; - break; - case 'W': - aswarn = TRUE; - break; - case 'x': - has_crt0 = FALSE; - break; - case 'I': - add_default_inc = 0; - break; - case 'L': - add_default_lib = 0; - break; +void +run_compile(file) +struct file_list * file; +{ + if (opt_arch == 3) command.cmd = CC1C386; + else if (opt_arch<5) command.cmd = CC1BCC; + else command.cmd = CC1; + command_reset(); + newfilename(file, !(do_optim || do_as), 's', (opt_arch != 3 && opt_arch<5)); - default: - *argdone = FALSE; - break; - } - else if (arg[0] == '-') - switch (arg[1]) - { - case 'a': - if (!strcmp(arg, "-ansi")) - { - ansi_pass=TRUE; - cpp_pass=TRUE; - /* NOTE I'm setting this to zero, this isn't a _real_ STDC */ - adddefine("-D__STDC__=0"); - } - break; - case 't': - addarg(&asargs, "-t"); - addarg(&asargs, arg+2); - break; - case 'A': - addarg(&asargs, arg + 2); - break; - case 'B': - addprefix(&exec_prefix, arg + 2); - break; - case 'C': - addarg(&ccargs, arg + 2); - break; - case 'D': - case 'I': - case 'U': - adddefine(arg); - break; - case 'X': - addarg(&ldargs, arg + 2); - break; - case 'L': - addarg(&ldargs, arg); - break; - case 'M': - major_mode=arg[2]; - break; + command_opts('c'); - case 'O': - optimize = TRUE; - temp=optflags; optflags=stralloc2(optflags,","); free(temp); - temp=optflags; optflags=stralloc2(optflags,arg+2); free(temp); - if( arg[3] == 0 && ( arg[2] >= '1' && arg[2] <= '3' )) - { - temp=optflags; - optflags=stralloc2(optflags,"86,86"); - free(temp); - switch(arg[2]) - { - case '1': addarg(&optargs, "-huse16 186"); break; - case '2': addarg(&optargs, "-huse16 286"); break; - case '3': addarg(&optargs, "-huse16 386"); break; - } - } - break; - case 'P': - addarg(&cppargs, arg + 2); - break; - case 'Q': - addarg(&ccargs, arg); - break; - case 'T': - tmpdir = arg + 2; - break; - default: - *argdone = FALSE; - break; - } - else - { - ++nifiles; - *argdone = FALSE; - length = strlen(arg); - if (length >= 2 && arg[length - 2] == '.' - && ((ext = arg[length - 1]) == 'c' || ext == 'i' || ext == 'S' - || ext == 's')) - ++ncisfiles; - } - } - npass_specs = prep_only + cc_only + as_only; - if (npass_specs != 0) - { - if (npass_specs > 1) - { - ++errcount; - show_who("more than 1 option from -E -P -S -c\n"); - } - if (f_out != NUL_PTR && ncisfiles > 1) - { - ++errcount; - show_who("cannot have more than 1 input with non-linked output\n"); - } - } - if (nifiles == 0) - { - ++errcount; - show_who("no input files\n"); - } - if (errcount != 0) - exit(1); + command_arch(); -#ifdef BCC86 - if(!major_mode && !bits32) major_mode='n'; - switch(major_mode) - { - case 'd': /* DOS compile */ - bits32 = FALSE; - libc= "-ldos"; - adddefine("-D__MSDOS__"); - addarg(&ldargs, "-d"); - addarg(&ldargs, "-T100"); - break; + run_command(file); +} - case 'n': /* Normal Linux-86 */ - bits32 = FALSE; - libc= "-lc"; - adddefine("-D__ELKS__"); - adddefine("-D__unix__"); - break; +void +run_optim(file) +struct file_list * file; +{ + char buf[32]; + if (opt_arch<5) command.cmd = OPTIM; + else command.cmd = OPT; + command_reset(); + newfilename(file, !do_as, 's', 1); + command_opt("-c!"); + if (opt_O) + { + sprintf(buf, "-huse16 %c86", opt_O); + command_opt(buf); + } + command_opt(optim_rules); - case 'f': /* Caller saves+ax is first arg */ - bits32 = FALSE; - libc= "-lc_f"; - adddefine("-D__ELKS__"); - adddefine("-D__unix__"); - addarg(&ccargs, "-f"); - addarg(&ccargs, "-c"); - break; + command_opt("rules.start"); + command_opts('o'); + if (opt_O) + { + sprintf(buf, "rules.%c86", opt_O); + command_opt(buf); + } + command_opt("rules.86"); + command_opt("rules.end"); - case 'c': /* Just caller saves, normal C-lib is ok */ - bits32 = FALSE; - libc= "-lc"; - adddefine("-D__ELKS__"); - adddefine("-D__unix__"); - addarg(&ccargs, "-c"); - break; + run_command(file); +} - case 's': /* Standalone executable */ - bits32 = FALSE; - libc= "-lc_s"; - adddefine("-D__STANDALONE__"); - break; +void +run_as(file) +struct file_list * file; +{ + char * buf; + switch(opt_arch) + { + case 0: case 1: case 2: + command.cmd = AS86; break; + case 4: command.cmd = AS09; break; + default: command.cmd = AS; break; + } + command_reset(); + newfilename(file, (!do_link && opt_arch!=2), 'o', 1); + if (opt_arch==3) + command_opt("-j"); + if (opt_arch<5) + command_opt("-u"); + command_opts('a'); + if (opt_W) + command_opt("-w-"); + else + command_opt("-w"); + command_arch(); + command_opt("-n"); + buf = catstr(file->name, ".s"); + command_opt(buf); + free(buf); - case 'l': /* Large Linux compile */ - bits32 = TRUE; - libc= "-lc"; - adddefine("-D__linux__"); - adddefine("-D__unix__"); -#ifdef __linux__ - addarg(&ldargs, "-N"); /* Make OMAGIC */ -#else - patch_exe = TRUE; -#endif - break; + run_command(file); - case '?': - case 0: - break; + if (opt_arch == 2) + { + command.cmd = LD86; + command_reset(); + newfilename(file, !do_link, 'o', 1); + command_opt("-r"); + run_command(file); + } +} - default: - fatal("Fatal error: illegal -M option given"); - } -#endif +void +run_link() +{ + struct file_list * next_file; - if( aswarn ) - addarg(&asargs, "-w-"); - else - addarg(&asargs, "-w"); - if( patch_exe ) - addarg(&ldargs, "-s"); -#ifdef BCC86 - else if( !bits32 ) - addarg(&ldargs, "-i"); -#endif - if (verbosity > 2) - { - show_who("localprefix set to "); - writesn(localprefix); - } - if ((temp = getenv("BCC_EXEC_PREFIX")) != NUL_PTR) - addprefix(&exec_prefix, temp); - if( add_default_inc ) - adddefine(DEFAULT_INCLUDE); - if( add_default_lib ) - { -#ifdef BCC86 -#ifdef DEFAULT_LIBDIR3 - if( bits32 ) - addarg(&ldargs, DEFAULT_LIBDIR3); - else -#endif -#endif - addarg(&ldargs, DEFAULT_LIBDIR0); - } + switch(opt_arch) + { + case 0: case 1: + command.cmd = LD86; break; + case 2: command.cmd = GCC; break; + case 4: command.cmd = LD09; break; + default: command.cmd = LD; break; + } + command_reset(); + if (executable_name == 0) executable_name = "a.out"; - if (optimize) - addarg(&asargs, "-O"); - addarg(&optargs, OPTIM_RULES); - temp=optflags; optflags=stralloc2(optflags,",end"); free(temp); - for(temp=strtok(optflags,","); temp; temp=strtok((char*)0,",")) - { - temp = stralloc2("rules.", temp); - addarg(&optargs, temp); - } - addprefix(&exec_prefix, STANDARD_EXEC_PREFIX); - addprefix(&exec_prefix, STANDARD_EXEC_PREFIX_2); - cppargs.prog = fixpath(cppargs.prog, &exec_prefix, X_OK); - ccargs.prog = fixpath(ccargs.prog, &exec_prefix, X_OK); - asargs.prog = fixpath(asargs.prog, &exec_prefix, X_OK); - ldargs.prog = fixpath(ldargs.prog, &exec_prefix, X_OK); -#ifdef BAS86 - ldrargs.prog = fixpath(ldrargs.prog, &exec_prefix, X_OK); + command_opt("-o"); + command_opt(executable_name); + + command_opts('l'); + if (opt_arch != 2) + { + if (opt_arch == 0 && !opt_i) + command_opt("-i"); + + if (!opt_L) + { + if (opt_arch==1) command_opt(default_libdir3); + else command_opt(default_libdir0); + } + command_arch(); + + if (!opt_x) + command_opt("-C0"); + } + + for(next_file = files; next_file; next_file = next_file->next) + command_opt(next_file->file); + + if (opt_arch != 2) + command_opt(libc); + run_command(0); +} + +void +command_reset() +{ +#ifndef MAXPATHLEN +#define MAXPATHLEN 1024 #endif - unprotoargs.prog=fixpath(unprotoargs.prog, &exec_prefix, X_OK); - optargs.prog = fixpath(optargs.prog, &exec_prefix, X_OK); - if (tmpdir == NUL_PTR && (tmpdir = getenv("TMPDIR")) == NUL_PTR) + char buf[MAXPATHLEN]; + char ** prefix; + + if (command.arglist) + { + int i; + for(i=0; inext) + if (ol->opttype == optkey) + command_opt(ol->opt); +} + +void newfilename(file, last_stage, new_extn, use_o) +struct file_list * file; +int last_stage; +int new_extn; +int use_o; +{ + file->filetype = new_extn; + if (file->oldfile) free(file->oldfile); + file->oldfile = file->file; + file->file = 0; + + if (last_stage) { + if (executable_name) + file->file = copystr(executable_name); + else + { + char buf[4]; + buf[0] = '.'; + buf[1] = file->filetype; + buf[2] = 0; + file->file = catstr(file->name, buf); + } + } + else + { + char buf[16]; #ifdef MSDOS - tmpdir = "."; + sprintf(buf, "$$%05d$", dyn_count++); #else - tmpdir = "/tmp"; + sprintf(buf, "$$%04d%05d", dyn_count++, getpid()); #endif + file->file = catstr(tmpdir, buf); + } - if (prep_only && !prep_line_numbers) - addarg(&cppargs, "-P"); -#ifdef BCC86 -#ifdef STANDARD_CRT0_3_PREFIX - if (bits32) - bits_arg = "-3"; - else + command_opt(file->oldfile); + /* *.i files go to the stdout */ + if (last_stage && file->filetype == 'i') return; + if (use_o) command_opt("-o"); + command_opt(file->file); +} + +void +run_unlink() +{ + int i; + for(i=0; i1) + fprintf(stderr, "rm %s\n", p); + if (opt_v>2) + continue; + if (unlink(p) < 0) + { + if (error_count==0 || opt_v>1) + fprintf(stderr, "Error unlinking %s\n", p); + error_count++; + } + free(p); + } +} - /* Pass 2 over argv to compile and assemble .c, .i, .S and .s files and - * gather arguments for linker. - */ - for (argv -= (argc = argcount) - 1, argdone -= argcount - 1; --argc != 0;) - { - arg = *++argv; - if (!*++argdone) - { - length = strlen(arg); - if (length >= 2 && arg[length - 2] == '.' - && ((ext = arg[length - 1]) == 'c' || ext == 'i' || ext == 'S' - || ext == 's')) - { - if (echo || verbosity != 0) - { - writes(arg); - writesn(":"); - } - if ((basename = strrchr(arg, DIRCHAR)) == NUL_PTR) - basename = arg; - else - ++basename; - in_name = arg; - if (ext == 'c') - { - if (cpp_pass) - { - if (prep_only && !ansi_pass) - out_name = f_out; - else - out_name = my_mktemp(); - if (run(in_name, out_name, &cppargs) != 0) - continue; - in_name = out_name; - if (ansi_pass) - { - if (prep_only) - out_name = f_out; - else - out_name = my_mktemp(); +void +getargs(argc, argv) +int argc; +char ** argv; +{ + int ar; + char * pflag = 0; + int control_count = 0; + int exe_count = 0; - if (run(in_name, out_name, &unprotoargs) != 0) - continue; - in_name=out_name; - } - } - ext = 'i'; - } - if (ext == 'i') - { - if (prep_only) - continue; - if (cc_only && !optimize) - { - if (f_out != NUL_PTR) - out_name = f_out; - else - { - out_name = stralloc(basename); - out_name[strlen(out_name) - 1] = 's'; - } - } - else - out_name = my_mktemp(); - if (run(in_name, out_name, &ccargs) != 0) - continue; - in_name = out_name; - if( optimize ) - { - if (cc_only) - { - if (f_out != NUL_PTR) - out_name = f_out; - else - { - out_name = stralloc(basename); - out_name[strlen(out_name) - 1] = 's'; - } - } - else - out_name = my_mktemp(); + for(ar=1; ar= START_ARGS; --argc) - { - arg = ldargs.argv[argc]; - if (arg[0] == '-' && arg[1] == 'i' - && (arg[2] == 0 || (arg[2] == '-' && arg[3] == 0))) - { - --ldargs.argc; - memmove(ldargs.argv + argc, ldargs.argv + argc + 1, - (ldargs.argc - argc) * sizeof ldargs.argv[0]); - ldargs.argv[ldargs.argc] = NUL_PTR; - } - } + case 'Q': + append_option(argv[ar], 'c'); + break; - ldargs.prog = fixpath(GCC, &exec_prefix, X_OK); - link_st = run((char *) NUL_PTR, f_out, &ldargs); + case 'O': + do_optim=1; + if (!opt_arg[1] && ( opt_arg[0] >= '1' && opt_arg[0] <= '3' )) + opt_O = opt_arg[0]; + else + { + char * p = xalloc(strlen(opt_arg)+8); + strcpy(p, "rules."); + strcat(p, opt_arg); + append_option(p, 'o'); + free(p); + } + break; + + case 'o': + exe_count++; + executable_name = opt_arg; + break; + + case 'B': + add_prefix(opt_arg); + break; + + case 'I': + case 'D': + case 'U': + append_option(argv[ar], 'p'); + break; + + case 'T': + tmpdir = catstr(opt_arg, "/"); + break; + + case 'M': + if (opt_arg[1]) Usage(); + opt_M = *opt_arg; + break; + + default: + pflag = argv[ar]+1; + used_arg = 0; + break; + } + /* Singleton flags */ + if(pflag) switch(opt = *pflag++) + { + case 'P': + append_option("-P", 'p'); + /*FALLTHROUGH*/ + case 'E': + control_count++; + do_compile = do_link = do_as = 0; + opt_e = 1; + break; + case 'S': + control_count++; + do_as = do_link = 0; + break; + case 'c': + control_count++; + do_link = 0; + break; + case 'O': + do_optim=1; + break; + + case 'G': opt_M = 'G'; break; + + case 'v': opt_v++; break; + case 'V': opt_V++; break; + case 'e': opt_e++; break; + case 'x': opt_x++; break; + case 'I': opt_I++; break; + case 'L': opt_L++; break; + case 'i': opt_i++; break; + + case 'W': opt_W++; break; + + case '0': opt_arch=0; opt_M='x'; break; + case '3': opt_arch=1; opt_M='x'; break; + + case 'w': /*IGNORED*/ break; + case 'g': /*IGNORED*/ break; + case 'f': /*IGNORED*/ break; + case 'p': /*IGNORED*/ break; + + default: + if (pflag == argv[ar]+2) { + /* Special; unknown options saved as flags for the linker */ + append_file(argv[ar], 'o'); + pflag = 0; } else + Usage(); + } + if (!pflag || !*pflag) { ar++; pflag = 0; } + if (used_arg && inc_ar) ar++; + if (used_arg && inc_ar==2) + fatal("Last option requires an argument"); + } + + if (control_count>1) + fatal("only one option from -E -P -S -c allowed"); + if (exe_count>1) + fatal("only one -o option allowed"); + + if (file_count==0) Usage(); + + if (exe_count && file_count != 1 && !do_link) + fatal("only one input file for each non-linked output"); + + add_prefix(getenv("BCC_EXEC_PREFIX")); + +#ifdef MC6809 + if (opt_M==0) opt_M = '9'; #endif - { - addarg(&ldargs, libc); - link_st = run((char *) NUL_PTR, f_out, &ldargs); - } - if( patch_exe && link_st == 0 ) - linux_patch(f_out); - } - if( runerror && f_out != NUL_PTR ) - my_unlink(f_out); - killtemps(); - return runerror ? 1 : 0; +#ifdef CCC + if (opt_M==0) opt_M = '8'; +#endif +#ifdef MSDOS + if (opt_M==0) opt_M = 'd'; +#endif + if (opt_M==0) opt_M = (opt_arch==1 ?'l':'n'); + switch(opt_M) + { + case 'n': + append_option("-D__ELKS__", 'p'); + append_option("-D__unix__", 'p'); + libc="-lc"; + break; + case 'f': + append_option("-D__ELKS__", 'p'); + append_option("-D__unix__", 'p'); + append_option("-c", 'p'); + append_option("-f", 'p'); + libc="-lc_f"; + break; + case 'c': + append_option("-D__ELKS__", 'p'); + append_option("-D__unix__", 'p'); + append_option("-c", 'p'); + libc="-lc"; + break; + case 's': + append_option("-D__STANDALONE__", 'p'); + libc="-lc_s"; + break; + case 'd': + append_option("-D__MSDOS__", 'p'); + libc="-ldos"; + append_option("-d", 'l'); + append_option("-T100", 'l'); + break; + case 'l': + opt_arch=1; + append_option("-D__linux__", 'p'); + append_option("-D__unix__", 'p'); + libc="-lc"; + append_option("-N", 'l'); + break; + case 'G': + opt_arch = 2; + break; + case '8': + opt_arch = 3; + opt_e = 1; + break; + case '9': + opt_arch = 4; + default_libdir0 = "-L~/lib/bcc/m09/"; + optim_rules = "-d~/lib/bcc/m09"; + add_prefix("~/lib/bcc/m09/"); + break; + case '0': + opt_arch = 5; + opt_e = 1; + opt_I = 1; + opt_L = 1; + opt_x = 1; + append_option("/lib/crt0.o", 'l'); + break; + } + + if (do_optim) + { + if (opt_e) + append_option("-O", 'c'); + append_option("-O", 'p'); + append_option("-O", 'a'); + } } -PRIVATE void linux_patch(fname) -char * fname; +void +add_prefix(path) +char * path; { -/* OMAGIC */ - -#define AOUT_MAG "\x07\x01\x64\x00" /* 0x640107L */ -#define ELKS_MAG1 0x10 -#define ELKS_MAG2 0x11 /* -z */ -#define ELKS_MAG3 0x20 /* -i */ -#define ELKS_MAG4 0x21 /* -i -z */ - -static struct ELKS_exec { /* ELKS a.out header */ - char a_magic1; /* magic number */ - char a_magic2; /* magic number */ - char a_magic3; /* magic number */ - char a_magic4; /* magic number */ - char a_hdrlen; /* length, etc of header */ - char a_hdrlen3[3]; - long a_text; /* size of text segement in bytes */ - long a_data; /* size of data segment in bytes */ - long a_bss; /* size of bss segment in bytes */ - long a_entry; /* entry point */ - long a_total; /* total memory allocated */ - long a_syms; /* size of symbol table */ -} instr; + char ** p; + if (!path || !*path) return; + for(p=exec_prefixs; *p; p++) { + if( *p == devnull ) + { + *p = path; + break; + } + } + if (!*p) fatal("Too many -B options"); +} -static struct aout_exec { - char a_info[4]; /* Use macros N_MAGIC, etc for access */ - unsigned a_text; /* length of text, in bytes */ - unsigned a_data; /* length of data, in bytes */ - unsigned a_bss; /* length of uninitialized data area, in bytes */ - unsigned a_syms; /* length of symbol table data in file, in bytes */ - unsigned a_entry; /* start address */ - unsigned a_trsize; /* length of relocation info for text, in bytes */ - unsigned a_drsize; /* length of relocation info for data, in bytes */ -} outstr; +void append_file (filename, ftype) +char * filename; +int ftype; +{ + struct file_list * newfile = xalloc(sizeof(struct file_list)); + char * s; + char * name; - int fd; + newfile->file = copystr(filename); + name = copystr(filename); - fd = open(fname, O_RDWR); - if( fd<0 ) return; + s = strrchr(name, '.'); - if( read(fd, &instr, sizeof(instr)) != sizeof(instr) ) + if (ftype) { - writesn("Cannot re-read executable header"); - return; + newfile->name = copystr(name); + newfile->filetype = ftype; + } + else if (s && s == name + strlen(name) - 2) { + newfile->filetype = s[1]; + *s = 0; + newfile->name = copystr(name); } + else + newfile->name = copystr(name); + free(name); - if( instr.a_hdrlen != 0x20 || instr.a_magic1 != 0x01 || - instr.a_magic2 != 0x03 || instr.a_magic4 != 0x10 ) + if (newfile->filetype == 0) newfile->filetype = 'o'; /* Objects */ + + if (files==0) + files = newfile; + else { - writesn("Executable cannot be converted to OMAGIC - bad magics"); - return; + struct file_list * fptr; + for(fptr=files; fptr->next; fptr=fptr->next); + fptr->next = newfile; } +} - switch((int)(instr.a_magic3)) +void +append_option (option, otype) +char * option; +int otype; +{ + struct opt_list * newopt = xalloc(sizeof(struct opt_list)); + + newopt->opt = copystr(option); + newopt->opttype = otype; + + if (options==0) + options = newopt; + else { - case ELKS_MAG1: - break; - case ELKS_MAG2: - writesn("Executable cannot be converted to OMAGIC (compiled with -z)"); - return; - case ELKS_MAG3: - case ELKS_MAG4: - writesn("Executable file is split I/D, data overlaps text"); - return; - default: - writesn("Executable cannot be converted to OMAGIC (unknown type)"); - return; + struct opt_list * optr; + for(optr=options; optr->next; optr=optr->next); + optr->next = newopt; } +} - if( instr.a_syms != 0 ) - writesn("Warning: executable file isn't stripped"); +char * expand_tilde(str) +char * str; +{ + char * newstr; + char * ptr = strchr(str, '~'); + if( ptr == 0 ) return copystr(str); - memcpy(outstr.a_info, AOUT_MAG, 4); - outstr.a_text = instr.a_text; - outstr.a_data = instr.a_data; - outstr.a_bss = instr.a_bss; - outstr.a_entry= instr.a_entry; + newstr = xalloc(strlen(str)+strlen(localprefix)); + if( ptr!=str ) memcpy(newstr, str, ptr-str); + strcpy(newstr+(ptr-str), localprefix); + strcat(newstr, ptr+1); + return newstr; +} - lseek(fd, 0L, 0); +void * +xalloc (size) +int size; +{ + void * p = malloc(size); + if (!p) fatal("Out of memory"); + memset(p, '\0', size); + return p; +} - if( write(fd, &outstr, sizeof(outstr)) != sizeof(outstr) ) - { - writesn("Cannot re-write executable header"); - return; - } +void Usage() +{ + fatal("Usage: bcc [-ansi] [-options] [-o output] file [files]"); +} - close(fd); +void fatal(str) +char * str; +{ + fprintf(stderr, "%s: Fatal error: %s.\n", progname, str); + exit(1); } #ifdef L_TREE #ifdef MSDOS -PRIVATE void reset_localprefix() +void reset_localprefix() { char *ptr, *temp; - temp = stralloc(progname); + temp = copystr(progname); if( (ptr = strrchr(temp, '\\')) != 0 && temp 2) - { - show_who("localprefix is now "); - writesn(localprefix); - } } else free(temp); } #else -PRIVATE void reset_localprefix() +void reset_localprefix() { char *ptr, *temp; if( *progname == '/' ) - temp = stralloc(progname); + temp = copystr(progname); else { char * s, * d; ptr = getenv("PATH"); if( ptr==0 || *ptr == 0 ) return; - ptr = stralloc(ptr); - temp = stralloc(""); + ptr = copystr(ptr); + temp = copystr(""); for(d=s=ptr; d && *s; s=d) { @@ -970,14 +1030,14 @@ free(temp); d=strchr(s, ':'); if( d ) *d='\0'; - temp = my_malloc(strlen(progname)+strlen(s)+2, "prefixing"); + temp = xalloc(strlen(progname)+strlen(s)+2); strcpy(temp, s); strcat(temp, "/"); strcat(temp, progname); if( realpath(temp, buf) != 0 ) { free(temp); - temp = stralloc(buf); + temp = copystr(buf); } if( access(temp, X_OK) == 0 ) break; d++; @@ -985,7 +1045,7 @@ if( s == 0 ) { free(temp); - temp = stralloc(progname); + temp = copystr(progname); } free(ptr); } @@ -995,11 +1055,6 @@ { ptr[-4] = 0; localprefix = temp; - if (verbosity > 2) - { - show_who("localprefix is now "); - writesn(localprefix); - } } else free(temp); @@ -1007,355 +1062,71 @@ #endif #endif -PRIVATE char * expand_tilde(str, canfree) -char * str; -int canfree; -{ - char * newstr; - char * ptr = strchr(str, '~'); - if( ptr == 0 ) return str; - - newstr = my_malloc(strlen(str)+strlen(localprefix), "expand tilde"); - if( ptr!=str ) memcpy(newstr, str, ptr-str); - strcpy(newstr+(ptr-str), localprefix); - strcat(newstr, ptr+1); - if( canfree ) free(str); - return newstr; -} -PRIVATE void adddefine(arg) -char *arg; +void +run_command(file) +struct file_list * file; { -#ifndef CCC - addarg(&ccargs, arg); +#ifdef __BCC__ +static char ** minienviron[] = { + "PATH=/bin:/usr/bin", + "SHELL=/bin/sh", + 0 +}; #endif - addarg(&cppargs, arg); -} - -PRIVATE void addarg(argp, arg) -register struct arg_s *argp; -char *arg; -{ - int new_argc; - char **new_argv; - - if (argp->nr_allocated == 0) - startarg(argp); - new_argc = argp->argc + 1; - if (new_argc >= argp->nr_allocated) - { - argp->nr_allocated += ALLOC_UNIT; - new_argv = realloc(argp->argv, argp->nr_allocated * sizeof *argp->argv); - if (new_argv == NUL_PTR) - outofmemory("addarg"); - argp->argv = new_argv; - } - argp->argv[argp->argc] = expand_tilde(arg, 0); - argp->argv[argp->argc = new_argc] = NUL_PTR; -} - -PRIVATE void addprefix(prefix, name) -struct prefix_s *prefix; -char *name; -{ - struct prefix_s *new_prefix; - - if (prefix->name == NUL_PTR) - prefix->name = name; - else - { - new_prefix = my_malloc(sizeof *new_prefix, "addprefix"); - new_prefix->name = expand_tilde(name, 0); - new_prefix->next = NUL_PTR; - while (prefix->next != NUL_PTR) - prefix = prefix->next; - prefix->next = new_prefix; - } -} - -PRIVATE void fatal(message) -char *message; -{ - writesn(message); - killtemps(); - exit(1); -} - -PRIVATE char *fixpath(path, prefix, mode) -char *path; -struct prefix_s *prefix; -int mode; -{ - char *ppath; - - for (; prefix != NUL_PTR; prefix = prefix->next) - { - if (verbosity > 2) - { - show_who("searching for "); - if (mode == R_OK) - writes("readable file "); - else - writes("executable file "); - } - ppath = expand_tilde(stralloc2(prefix->name, path), 1); - if (verbosity > 2) - writes(ppath); - if (access(ppath, mode) == 0) - { - if (verbosity > 2) - writesn(" - found."); - return ppath; - } - if (verbosity > 2) - writesn(" - nope."); - free(ppath); - } - return path; -} - -PRIVATE void killtemps() -{ - while (tmpargs.argc > START_ARGS) - my_unlink(tmpargs.argv[--tmpargs.argc]); -} - -PRIVATE void *my_malloc(size, where) -unsigned size; -char *where; -{ - void *block; - - if ((block = malloc(size)) == NUL_PTR) - outofmemory(where); - return block; -} - -PRIVATE char *my_mktemp() -{ - char *p; - unsigned digit; - unsigned digits; - char *template; - static unsigned tmpnum; - -#ifdef MSDOS - digits = 42; - p = template = stralloc2(tmpdir, "/$$YYYYXX"); -#else - digits = getpid(); - p = template = stralloc2(tmpdir, "/bccYYYYXXXX"); + int i, status; +#ifndef MSDOS + void *oqsig, *oisig, *otsig, *ocsig; #endif - p += strlen(p); - while (*--p == 'X') - { - if ((digit = digits % 16) > 9) - digit += 'A' - ('9' + 1); - *p = digit + '0'; - digits /= 16; - } - digits = tmpnum; - while (*p == 'Y') - { - if ((digit = digits % 16) > 9) - digit += 'A' - ('9' + 1); - *p-- = digit + '0'; - digits /= 16; - } - ++tmpnum; - addarg(&tmpargs, template); - return template; -} -PRIVATE void my_unlink(name) -char *name; -{ - if (verbosity > 1) - { - show_who("unlinking "); - writesn(name); - } - if (verbosity > 4) return; - if (unlink(name) < 0) - { - if( !runerror || verbosity > 1) - { - show_who("error unlinking "); - writesn(name); - runerror = TRUE; - } - } -} - -PRIVATE void outofmemory(where) -char *where; -{ - show_who("out of memory in "); - fatal(where); -} - -PRIVATE int run(in_name, out_name, argp) -char *in_name; -char *out_name; -struct arg_s *argp; -{ - int arg0; - int i; - int status; + if (opt_v) + { + fprintf(stderr, "%s", command.fullpath); + for(i=1; command.arglist[i]; i++) + fprintf(stderr, " %s", command.arglist[i]); + fprintf(stderr, "\n"); + if (opt_v>2) return; + } - arg0 = 0; - if (in_name == NUL_PTR) - ++arg0; - if (out_name == NUL_PTR) - arg0 += 2; - else if (argp->minus_O_broken) - ++arg0; - if (argp->nr_allocated == 0) - startarg(argp); - argp->argv[arg0] = argp->prog; - i = arg0 + 1; - if (in_name != NUL_PTR) - argp->argv[i++] = in_name; - if (out_name != NUL_PTR) - { - if (!argp->minus_O_broken) - argp->argv[i++] = "-o"; - argp->argv[i++] = out_name; - } - if (verbosity != 0) - { - for (i = arg0; i < argp->argc; ++i) - { - writes(argp->argv[i]); - writes(" "); - } - writen(); - } - if (verbosity > 4 ) return 0; #ifdef MSDOS - status = spawnv(0, argp->prog, argp->argv+arg0); - if( status<0 ) - { - show_who("spawn of "); - writes(argp->prog); - writesn(" failed"); - } + status = spawnv(0, command.fullpath, command.arglist); + if (status<0) + { + fprintf(stderr, "Unable to execute %s\n", command.fullpath); + } #else - switch (fork()) - { - case -1: - show_who("fork failed"); - fatal(""); - case 0: + oqsig = signal(SIGQUIT, SIG_IGN); + oisig = signal(SIGINT, SIG_IGN); + otsig = signal(SIGTERM, SIG_IGN); + ocsig = signal(SIGCHLD, SIG_DFL); + + switch(fork()) + { + case -1: + fatal("Forking failure"); + case 0: #ifdef __BCC__ - execve(argp->prog, argp->argv + arg0, minienviron); + execve(command.fullpath, command.arglist, minienviron); #else - execv(argp->prog, argp->argv + arg0); -#endif - show_who("exec of "); - writes(argp->prog); - fatal(" failed"); - default: - wait(&status); - if (status & 0xFF) - { - writes(argp->prog); - writesn(": killed by fatal signal"); - } - } -#endif - for (i = tmpargs.argc - 1; i >= START_ARGS; --i) - if (in_name == tmpargs.argv[i]) - { - my_unlink(in_name); - --tmpargs.argc; - memmove(tmpargs.argv + i, tmpargs.argv + i + 1, - (tmpargs.argc - i) * sizeof tmpargs.argv[0]); - tmpargs.argv[tmpargs.argc] = NUL_PTR; - break; - } - if (status != 0) - { - runerror = TRUE; - killtemps(); - } - return status; -} - -PRIVATE void set_trap() -{ -#ifdef SIGINT - signal(SIGINT, trap); -#endif -#ifdef SIGQUIT - signal(SIGQUIT, trap); -#endif -#ifdef SIGTERM - signal(SIGTERM, trap); + execv(command.fullpath, command.arglist); #endif -} + fprintf(stderr, "Unable to execute %s.\n", command.fullpath); + exit(1); + default: + wait(&status); + if (status&0xFF) + { + fprintf(stderr, "%s: killed by signal %d\n", command.fullpath, (status&0xFF)); + } + } -PRIVATE void show_who(message) -char *message; -{ -#ifdef MSDOS - char * ptr; - ptr = strrchr(progname, '\\'); - if(ptr) ptr++; else ptr = progname; - writes(ptr); -#else - writes(progname); + (void) signal(SIGQUIT, oqsig); + (void) signal(SIGINT, oisig); + (void) signal(SIGTERM, otsig); + (void) signal(SIGCHLD, ocsig); #endif - writes(": "); - writes(message); -} - -PRIVATE void startarg(argp) -struct arg_s *argp; -{ - argp->argv = my_malloc((argp->nr_allocated = ALLOC_UNIT) - * sizeof *argp->argv, "startarg"); - argp->argc = START_ARGS; - argp->argv[START_ARGS] = NUL_PTR; -} - -PRIVATE char *stralloc(s) -char *s; -{ - return strcpy(my_malloc(strlen(s) + 1, "stralloc"), s); -} - -PRIVATE char *stralloc2(s1, s2) -char *s1; -char *s2; -{ - return strcat(strcpy(my_malloc( - strlen(s1) + strlen(s2) + 1, "stralloc2"), s1), s2); -} - -PRIVATE void trap(signum) -int signum; -{ - signal(signum, SIG_IGN); - show_who("caught signal"); - fatal(""); -} - -PRIVATE void writen() -{ - writes("\n"); -} - -PRIVATE void writes(s) -char *s; -{ - write(2, s, strlen(s)); + if (status) + file->filetype = '~'; } -PRIVATE void writesn(s) -char *s; -{ - writes(s); - writen(); -} diff -Nurd linux86.old/bcc/const.h linux86/bcc/const.h --- linux86.old/bcc/const.h Tue Sep 29 13:29:15 1998 +++ linux86/bcc/const.h Thu Jan 10 08:05:20 2002 @@ -25,6 +25,7 @@ #ifndef VERY_SMALL_MEMORY #define DEBUG /* generate compiler-debugging code */ +#define OPTIMISE /* include optimisation code */ #endif #ifdef I8088 diff -Nurd linux86.old/bcc/function.c linux86/bcc/function.c --- linux86.old/bcc/function.c Sat Jul 24 14:31:34 1999 +++ linux86/bcc/function.c Sat Jan 12 12:05:43 2002 @@ -270,7 +270,12 @@ PUBLIC void popframe() { +#ifdef STUPIDFRAME + poplist(callee1mask); /*XXX: Add if round this */ + poplist(FRAMEREG); +#else poplist(frame1list); +#endif } #endif @@ -308,7 +313,7 @@ pushreg(FRAMEREG); regtransfer(STACKREG, FRAMEREG); framep = sp; - pushlist(callee1mask); + pushlist(callee1mask); /*XXX: Add if round this */ # else /* not STUPIDFRAME */ # ifdef CANHANDLENOFRAME if (stackarg || softsp != -frameregsize) /* args or locals */ diff -Nurd linux86.old/bcc/gencode.h linux86/bcc/gencode.h --- linux86.old/bcc/gencode.h Sun Mar 15 10:16:31 1998 +++ linux86/bcc/gencode.h Thu Jan 10 07:43:56 2002 @@ -52,6 +52,7 @@ #endif EXTERN struct switchstruct *switchnow; /* currently active switch */ /* depends on NULL init */ +EXTERN bool_t optimise; /* nonzero to add optimisation code */ /* variables to be initialised to nonzero */ diff -Nurd linux86.old/bcc/idcc linux86/bcc/idcc --- linux86.old/bcc/idcc Sun Oct 13 22:04:52 1996 +++ linux86/bcc/idcc Thu Jan 1 01:00:00 1970 @@ -1,328 +0,0 @@ -#!/bin/ash -# -# This is a shell version of the bcc compiler driver. It's a little slower -# than a C version but overall seems to be a lot cleaner, perhaps a C version -# based on this might be a good idea ... -# -# The compiler works on a 'modal' basis certain flags given to it put the -# compiler into specific modes, it can only be in one mode for a run. -# -# The mode defines the basic passes and specific options that are available -# -# To define a mode see the functions 'run_0' and 'run_3' for examples. The -# variable assignments just above the definitions enable the functions. -# -# This script is specifically designed so the there is as little interaction -# between the modes as is possible. -# -# It's run using ash because this appears to be _much_ faster than bash, it's -# also reasonable with ksh. -# (On other interpreters I think perl would be too big, but awk might work...) -# - -TMPFIL="/tmp/cc$$" -trap "rm -f $TMPFIL.* ; exit 1" 1 2 3 15 -TMPCNT=0 - -FILES= -OPTS= -RESEXTN= -VERBOSE=no -MULTISRC=no - -LDOPTS= -DESTDEF=no -LDDEST=a.out -DEFMODE=0 - -ccmode= -LIBPATH="/lib:/usr/lib:/usr/bin" - -main() { - scanargs "$@" - - PATH="$LIBPATH:$PATH" - [ "$EXEC_PREFIX" != "" ] && PATH="$EXEC_PREFIX:$PATH" - - rv=0 - LDFILES= - [ "$MULTISRC" = yes -o "$RESEXTN" = "" ] && DESTDEF=no - - for FILE in $FILES - do - case "$FILE" in - *.c ) PASS=cpp ; BASE="`basename $FILE .c`" ;; - *.s ) PASS=as ; BASE="`basename $FILE .s`" ;; - * ) PASS=lnk ;; - esac - - NAME="`basename $FILE`" - DEST="`dirname $FILE`/" - [ "$DEST" = "./" ] && DEST= - DEST="$DEST$BASE.$RESEXTN" - [ "$DESTDEF" = yes ] && DEST="$LDDEST" - - STEMP=0 INTEMP=0 - [ "$PASS" = "cpp" ] && { compile $FILE || rv=$? ; } - [ "$PASS" = "as" ] && { assem $FILE || rv=$? ; } - if [ "$PASS" = "lnk" ] - then - LDFILES="$LDFILES $FILE" - else - # If there's a fail can't link - still assembling to temps tho. - [ "$RESEXTN" = "" ] && RESEXTN=O - fi - [ "$STEMP" = 1 ] && rm -f "$SFILE" - done - - [ "$RESEXTN" != "" ] && { - rm -f $TMPFIL.* - exit $rv - } - - [ "$VERBOSE" = yes ] && eval "echo \"$LINK\"" 1>&2 - eval "$LINK" - rv=$? - rm -f $TMPFIL.* - exit "$rv" -} - -scanargs() { - WILDOPT=no - - while [ "$#" -gt 0 ] - do - case "$1" in - -[DU]* ) CPPDEFS="$CPPDEFS $1" ;; - -B?* ) PATH="`echo '.$1:$PATH' | sed 's/...//'`" ;; - -I?* ) CPPFLAGS="$CPPFLAGS $1" ;; - -L?* ) LDOPTS="$LDOPTS $1" ;; - -o ) LDDEST="$2"; DESTDEF=yes ; shift ;; - -b ) . /usr/lib/idcc/opts_$2 || exit 1; shift ;; - -E ) RESEXTN=i ;; - -S ) RESEXTN=s ;; - -c ) RESEXTN=o ;; - -v ) VERBOSE=yes ;; - -l?* ) FILES="$FILES $1" ; MULTISRC=yes ;; - -* ) OPTS="$OPTS `echo .$1 | sed 's/..//'`" ;; - * ) [ "$FILES" != "" ] && MULTISRC=yes ; FILES="$FILES $1" ;; - esac - shift - done - - while [ "$OPTS" != "" -o "$DEFMODE" != "" ] - do - # So they can try again ... with DEFMODE if needed - MOPTS="$OPTS" - OPTS= - - for opt in $MOPTS - do - # Option can be defined only for specific mode so if we haven't seen - # the mode yet save the opt. If we have check for conflicts too. - [ "$ccmode" = "" -a "$DEFMODE" != "" ] && { - eval "[ \"\$opt_$opt\" = yes ]" || { OPTS="$OPTS $opt" ; opt= ; } - } - [ "$opt" != "" ] && { - [ "$ccmode" = "" ] || { - eval "[ \"\$mode_$opt\" = yes ]" && { - echo Option "-$opt incompatible with -$ccmode" 1>&2 - exit 2 - } - } - - eval "[ \"\$opt_$opt\" = yes ]" || { - { eval "[ \"$WILDOPT\" = yes ]" && wild_opt "-$opt" ; } || { - echo Option '-'$opt unknown for this mode 1>&2 - exit 3 - } - } - - eval "[ \"\$opt_$opt\" = yes ]" && run_$opt - eval "[ \"\$mode_$opt\" = yes ]" && ccmode="$opt" - } - done - [ "$ccmode" = "" -a "$DEFMODE" != "" ] && OPTS="$DEFMODE $OPTS" - DEFMODE= - done -} - -compile() { - [ -r "$FILE" ] || { echo "Cannot open $FILE" 1>&2 ; return 1 ; } - - # Loop for the pass list - # The CCX variables _are_ expanded again. - - ret=1 - for pass in $PASSLIST - do - for extn in '' res opt - do eval "CCX$extn=\"\$CC$pass$extn\"" - done - - [ "$CCX" = "" ] && continue; - - shuffel "$RESEXTN" $CCXres - [ "$VERBOSE" = yes ] && eval "echo \"$CCX\"" 1>&2 - eval "$CCX" || return 1 - ret=0 - [ "$CCXres" = "$RESEXTN" ] && break - done - [ "$ret" = 1 ] && { echo 'CC configuration error' 1>&2 ; return $ret ; } - - [ "$RESEXTN" != "$CCXres" ] && PASS=as - return 0 -} - -assem() { - [ -r "$FILE" ] || { echo "Cannot open $FILE" 1>&2 ; return 1 ; } - - shuffel "$RESEXTN" o - - n= - [ "$ASNAME" != "" ] && n="$ASNAME$NAME" - - [ "$VERBOSE" = yes ] && echo "$AS $ASFLAGS $n $SFILE -o $FILE" 1>&2 - $AS $ASFLAGS $n $SFILE -o $FILE || return - - [ "$RESEXTN" != "o" ] && PASS=lnk - return 0 -} - -if [ "2" = "$[1+1]" ] ; then inc_tmpcnt() { TMPCNT="$[$TMPCNT+1]" ; } -else inc_tmpcnt() { TMPCNT="`expr $TMPCNT + 1`" ; } -fi - -shuffel() { - [ "$STEMP" = 1 ] && rm -f "$SFILE" - - SFILE="$FILE" - STEMP="$INTEMP" - - if [ "$1" = "$2" ] - then - FILE="$DEST" - INTEMP=0 - else - inc_tmpcnt - FILE="$TMPFIL.$TMPCNT.$2" - INTEMP=1 - fi -} - -mode_0=yes opt_0=yes -run_0() -{ - SYSINC="-I/usr/bcc/include" - SYSLIB="-L/usr/bcc/lib/bcc/i86/" - LIBPATH="/usr/bcc/lib/bcc" - CRT0="-C0" - LIBS="-lc" - CGEN='-0' - DEFS= - - CPP="cpp" - - PASSLIST=2 - CC2='bcc-cc1 $SYSINC $DEFS $CPPDEFS $CPPFLAGS $CGEN $SFILE -o $FILE' - CC2res=s - AS="as86" ASFLAGS='-u -w -0' ASNAME='-n ' - LINK='ld86 $SYSLIB $LDOPTS $LDFLAGS -o $LDDEST $CRT0 $LDFILES $LIBS' - LDFLAGS='-i -0' - - [ "$RESEXTN" = "i" ] && { - PASSLIST="0" - CC0='bcc-cc1 $SYSINC $DEFS $CPPDEFS $CPPFLAGS $CGEN $SFILE -E' - CC0res=i - } - - opt_ansi=yes - run_ansi() - { - PASSLIST="0 1 2" - CC0='bcc-cc1 $SYSINC $DEFS $CPPDEFS $CPPFLAGS $CGEN $SFILE -o $FILE -E' - CC0res=k - CC1res=i CC1='unproto $SFILE $FILE' - CC2res=s CC2='bcc-cc1 $CGEN $SFILE -o $FILE' - DEFS='-D__STDC__=0' - } - opt_I=yes; run_I() { SYSINC= ; } - opt_L=yes; run_L() { SYSLIB= ; } - opt_O=yes; run_O() { echo Warning -O ignored 1>&2 ; } - opt_Mf=yes; run_Mf() { LIBS=-lc_f ; CGEN='-0 -f -c' ;} - opt_Md=yes; - run_Md() { LIBS=-ldos ; DEFS=$DEFS' -D__MSDOS__' LDFLAGS='-i -0 -d' ;} - - WILDOPT=yes - wild_opt() - { - case "$1" in - # For normal CC operation unknowns go to the linker. ie: - # * ) LDFLAGS="$LDFLAGS $1" ; return 0 ;; - # But do this instead. - -[dMizmts] ) LDFLAGS="$LDFLAGS $1" ; return 0 ;; - -[dMizmt]- ) LDFLAGS="$LDFLAGS $1" ; return 0 ;; - -T* ) LDFLAGS="$LDFLAGS $1" ; return 0 ;; - * ) return 1 ;; - esac - return 0 - } -} - -mode_3=yes opt_3=yes -run_3() -{ - SYSINC="-I/usr/bcc/include" - SYSLIB="-L/usr/bcc/lib/bcc/i386/" - LIBPATH="/usr/bcc/lib/bcc" - CRT0="-C0" - LIBS="-lc" - CGEN='-3' - DEFS= - - CPP="cpp" - - PASSLIST=2 - CC2='bcc-cc1 $SYSINC $DEFS $CPPDEFS $CPPFLAGS $CGEN $SFILE -o $FILE' - CC2res=s - AS="as86" ASFLAGS='-u -w -3' ASNAME='-n ' - LINK='ld86 $SYSLIB $LDOPTS $LDFLAGS -o $LDDEST $CRT0 $LDFILES $LIBS' - LDFLAGS='-3' - - [ "$RESEXTN" = "i" ] && { - PASSLIST="0" - CC0='bcc-cc1 $SYSINC $DEFS $CPPDEFS $CPPFLAGS $CGEN $SFILE -E' - CC0res=i - } - - opt_ansi=yes - run_ansi() - { - PASSLIST="0 1 2" - CC0='bcc-cc1 $SYSINC $DEFS $CPPDEFS $CPPFLAGS $CGEN $SFILE -o $FILE -E' - CC0res=k - CC1res=i CC1='unproto $SFILE $FILE' - CC2res=s CC2='bcc-cc1 $CGEN $SFILE -o $FILE' - DEFS='-D__STDC__=0' - } - opt_I=yes; run_I() { SYSINC= ; } - opt_L=yes; run_L() { SYSLIB= ; } - opt_O=yes; run_O() { echo Warning -O ignored 1>&2 ; } - - WILDOPT=yes - wild_opt() - { - case "$1" in - # For normal CC operation unknowns go to the linker. ie: - # * ) LDFLAGS="$LDFLAGS $1" ; return 0 ;; - # But do this instead. - -[dMizmts] ) LDFLAGS="$LDFLAGS $1" ; return 0 ;; - -[dMizmt]- ) LDFLAGS="$LDFLAGS $1" ; return 0 ;; - -T* ) LDFLAGS="$LDFLAGS $1" ; return 0 ;; - * ) return 1 ;; - esac - return 0 - } -} - -main "$@" diff -Nurd linux86.old/bcc/input.c linux86/bcc/input.c --- linux86.old/bcc/input.c Sat Feb 7 00:41:41 1998 +++ linux86/bcc/input.c Sat Jan 12 17:41:47 2002 @@ -509,6 +509,7 @@ #endif case 't': /* print source code in asm output */ case 'w': /* watch location counter */ + case 'O': /* Optimisation. */ if (arg[2] == 0) flag[(int)arg[1]] = TRUE; else if (arg[2] == '-' && arg[3] == 0) @@ -597,6 +598,11 @@ definestring("__POS_INDEPENDENT__"); } #endif + if (flag['O']) + { + optimise = TRUE; + definestring("__OPTIMISED__"); + } #ifdef NOFLOAT definestring("__HAS_NO_FLOATS__"); #endif diff -Nurd linux86.old/bcc/preproc.c linux86/bcc/preproc.c --- linux86.old/bcc/preproc.c Wed Dec 30 12:39:10 1998 +++ linux86/bcc/preproc.c Sat Jan 12 18:02:18 2002 @@ -68,8 +68,11 @@ #endif asmmode = TRUE; + if (expect_statement) + return; + if (orig_cppmode) - outstr("#asm\n"); + outnstr("#asm"); else { outnstr("!BCC_ASM"); @@ -126,9 +129,9 @@ } #endif if (orig_cppmode) - outstr("#endasm"); /* nl is done by skipeol */ + outnstr("#endasm"); else - outstr("!BCC_ENDASM\n"); + outnstr("!BCC_ENDASM"); } /* blanksident() - return nonzero if at blanks followed by an identifier */ @@ -158,6 +161,13 @@ char sname[NAMESIZE + 1]; sym_t ctlcase; struct symstruct *symptr; + if (ctext && asmmode) + { + comment(); + outudec(input.linenumber); + outbyte(' '); + outline(lineptr); + } sname[0] = '#'; /* prepare for bad control */ sname[1] = 0; @@ -188,7 +198,13 @@ switch (ctlcase) { case ASMCNTL: - asmcontrol(); + if (asmmode) + { + if (ifstate.ifflag) + error(" bad control"); + } + else + asmcontrol(); break; case DEFINECNTL: define(); @@ -197,6 +213,11 @@ elsecontrol(); break; case ENDASMCNTL: + if (!asmmode) + { + if (ifstate.ifflag) + error(" bad control"); + } asmmode = FALSE; break; case ENDIFCNTL: diff -Nurd linux86.old/bcc/scan.c linux86/bcc/scan.c --- linux86.old/bcc/scan.c Sat Feb 7 16:55:22 1998 +++ linux86/bcc/scan.c Sat Jan 12 17:44:28 2002 @@ -182,7 +182,10 @@ else { docontrol(); - break; +#ifndef ASM_BARE + virtual_nl = 1; +#endif + continue; } case SLASH: gch1(); @@ -431,7 +434,14 @@ static char lastch; register char *reglineptr; - while (TRUE) /* exit with short, fast returns */ + if (expect_statement && asmmode) + { + outnstr("!BCC_ASM"); + dumplocs(); + cppscan(1); + outnstr("!BCC_ENDASM"); + } + else while (TRUE) /* exit with short, fast returns */ { reglineptr = lineptr; while ((sym = SYMOFCHAR(*reglineptr)) == WHITESPACE) @@ -470,7 +480,13 @@ } else { + int old_asmmode = asmmode; docontrol(); + if (asmmode && !old_asmmode) + { + sym = SEMICOLON; + return; + } break; } case FLOATCONST: diff -Nurd linux86.old/bcc/scan.h linux86/bcc/scan.h --- linux86.old/bcc/scan.h Sat Jul 24 14:27:42 1999 +++ linux86/bcc/scan.h Sat Jan 12 17:10:33 2002 @@ -200,3 +200,6 @@ EXTERN bool_t incppexpr; /* nonzero while scanning cpp expression */ EXTERN sym_t sym; /* current symbol */ extern sym_t symofchar[]; /* table to convert chars to their symbols */ +EXTERN bool_t expect_statement; /* If set #asm needs to clear the recursive + * pending operations. ie: if stmts. */ + diff -Nurd linux86.old/bcc/state.c linux86/bcc/state.c --- linux86.old/bcc/state.c Sat Jul 24 12:14:36 1999 +++ linux86/bcc/state.c Sat Jan 12 17:47:49 2002 @@ -188,6 +188,7 @@ #endif spmark = sp; newlevel(); + expect_statement++; decllist(); softsp &= alignmask; if (sym != RBRACE) /* no need for locals if empty compound */ @@ -195,6 +196,7 @@ returnflag = FALSE; while (sym != RBRACE && sym != EOFSYM) statement(); + expect_statement--; oldlevel(); if (!returnflag) { @@ -233,17 +235,27 @@ PRIVATE void doasm() { - lparen(); + if (sym == LPAREN) nextsym(); if (sym!=STRINGCONST) error("string const expected"); else { - nextsym(); - constant.value.s[charptr-constant.value.s]='\0'; outnstr("!BCC_ASM"); - outbyte('\t'); - outnstr(constant.value.s); + for(;;) + { + constant.value.s[charptr-constant.value.s]='\0'; + outbyte('\t'); + outnstr(constant.value.s); + /* XXX: Need to investigate: wasting memory? + * + * charptr = constant.value.s; + */ + + nextsym(); + if (sym == COMMA) nextsym(); + if (sym!=STRINGCONST) break; + } outnstr("!BCC_ENDASM"); - rparen(); + if (sym == RPAREN) nextsym(); semicolon(); } } @@ -717,6 +729,10 @@ case IFSYM: nextsym(); doif(); + break; + case ELSESYM: + error("unexpected else"); + nextsym(); break; case WHILESYM: nextsym(); diff -Nurd linux86.old/bootblocks/Makefile linux86/bootblocks/Makefile --- linux86.old/bootblocks/Makefile Sat May 12 09:17:53 2001 +++ linux86/bootblocks/Makefile Mon Dec 3 22:39:25 2001 @@ -25,9 +25,9 @@ bootbin: $(SSRC:s=bin) $(CSRC:c=bin) minixhd.bin msdos16.bin minix_elks.bin MOBJ=monitor.o commands.o i86_funcs.o relocate.o help.o bzimage.o \ - trk_buf.o min_buf.o unix.o fs.o fs_tar.o fs_min.o fs_dos.o cprintf.o + trk_buf.o min_buf.o unix.o fs.o fs_tar.o fs_min.o fs_dos.o MSRC=monitor.c commands.c i86_funcs.c relocate.c help.c bzimage.c \ - trk_buf.c min_buf.c unix.c fs.c fs_tar.c fs_min.c fs_dos.c cprintf.c + trk_buf.c min_buf.c unix.c fs.c fs_tar.c fs_min.c fs_dos.c MINC=i86_funcs.h readfs.h monitor.h BOOTBLOCKS=sysboot.v noboot.v skip.v msdos.v msdos16.v \ @@ -46,19 +46,19 @@ bootfile.sys: $(MSRC) $(MINC) @rm -f $(MOBJ) - make 'CFLAGS=$(CFLAGS) -DDOSFLOPPY -i-' monitor.out + make 'CFLAGS=$(CFLAGS) -DDOSFLOPPY -i' monitor.out mv monitor.out bootfile.sys @rm -f $(MOBJ) boottar.sys: $(MSRC) $(MINC) tarboot.bin @rm -f $(MOBJ) - make 'CFLAGS=$(CFLAGS) -DTARFLOPPY -i-' monitor.out + make 'CFLAGS=$(CFLAGS) -DTARFLOPPY -i' monitor.out mv monitor.out boottar.sys @rm -f $(MOBJ) bootminix.sys: $(MSRC) $(MINC) tarboot.bin @rm -f $(MOBJ) - make 'CFLAGS=$(CFLAGS) -DMINFLOPPY -i-' monitor.out + make 'CFLAGS=$(CFLAGS) -DMINFLOPPY -i' monitor.out mv monitor.out bootminix.sys @rm -f $(MOBJ) diff -Nurd linux86.old/bootblocks/cprintf.c linux86/bootblocks/cprintf.c --- linux86.old/bootblocks/cprintf.c Sat Jan 29 15:23:44 2000 +++ linux86/bootblocks/cprintf.c Thu Jan 1 01:00:00 1970 @@ -1,150 +0,0 @@ - -#include - -static unsigned char * __numout(long i, int base); - -cputchar(ch) -int ch; -{ - if(ch == '\n') bios_putc('\r'); - return bios_putc(ch); -} - -cprintf(char * fmt, ...) -{ - register int c; - int count = 0; - int type, base; - long val; - char * cp; - char padch=' '; - int minsize, maxsize; - va_list ap; - - va_start(ap, fmt); - - while(c=*fmt++) - { - count++; - if(c!='%') - cputchar(c); - else - { - type=1; - padch = *fmt; - maxsize=minsize=0; - if(padch == '-') fmt++; - - for(;;) - { - c=*fmt++; - if( c<'0' || c>'9' ) break; - minsize*=10; minsize+=c-'0'; - } - - if( c == '.' ) - for(;;) - { - c=*fmt++; - if( c<'0' || c>'9' ) break; - maxsize*=10; maxsize+=c-'0'; - } - - if( padch == '-' ) minsize = -minsize; - else - if( padch == '0' ) padch='0'; else padch=' '; - - if( c == 0 ) break; - if(c=='h') - { - c=*fmt++; - type = 0; - } - else if(c=='l') - { - c=*fmt++; - type = 2; - } - - switch(c) - { - case 'x': base=16; type |= 4; if(0) { - case 'o': base= 8; type |= 4; } if(0) { - case 'u': base=10; type |= 4; } if(0) { - case 'd': base=10; } - switch(type) - { - case 0: val=va_arg(ap, short); break; - case 1: val=va_arg(ap, int); break; - case 2: val=va_arg(ap, long); break; - case 4: val=va_arg(ap, unsigned short); break; - case 5: val=va_arg(ap, unsigned int); break; - case 6: val=va_arg(ap, unsigned long); break; - default:val=0; break; - } - cp = __numout(val,base); - if(0) { - case 's': - cp=va_arg(ap, char *); - } - count--; - c = strlen(cp); - if( !maxsize ) maxsize = c; - if( minsize > 0 ) - { - minsize -= c; - while(minsize>0) { cputchar(padch); count++; minsize--; } - minsize=0; - } - if( minsize < 0 ) minsize= -minsize-c; - while(*cp && maxsize-->0 ) - { - cputchar(*cp++); - count++; - } - while(minsize>0) { cputchar(' '); count++; minsize--; } - break; - case 'c': - cputchar(va_arg(ap, int)); - break; - default: - cputchar(c); - break; - } - } - } - va_end(ap); - return count; -} - -static char nstring[]="0123456789ABCDEF"; - -static unsigned char * -__numout(long i, int base) -{ - static unsigned char out[16]; - int n; - int flg = 0; - unsigned long val; - - if (i<0 && base==10) - { - flg = 1; - i = -i; - } - val = i; - - for (n = 0; n < 15; n++) - out[n] = ' '; - out[15] = '\0'; - n = 14; - do - { - out[n] = nstring[val % base]; - n--; - val /= base; - } - while(val); - if(flg) out[n--] = '-'; - return &out[n+1]; -} diff -Nurd linux86.old/bootblocks/mbr.s linux86/bootblocks/mbr.s --- linux86.old/bootblocks/mbr.s Tue Sep 26 20:20:18 2000 +++ linux86/bootblocks/mbr.s Thu Sep 27 14:59:52 2001 @@ -16,7 +16,7 @@ ORGADDR=$0500 preboot=0 ! Include the pre-boot loader. mbrkey=0 ! Option to choose the boot record base on keystroke -message=0 ! Display boot message +message=1 ! Display boot message diskman=0 ! Disk manager partitions, allows 16 partitions but ! don't overwrite this with a LILO BB. diff -Nurd linux86.old/bootblocks/monitor.h linux86/bootblocks/monitor.h --- linux86.old/bootblocks/monitor.h Fri Jun 4 14:33:47 1999 +++ linux86/bootblocks/monitor.h Mon Dec 3 22:00:46 2001 @@ -59,7 +59,7 @@ #ifdef __STANDALONE__ #undef putchar -#define putchar cputchar +#define putchar putch #define printf cprintf #define fflush(x) #endif diff -Nurd linux86.old/bootblocks/tarboot.s linux86/bootblocks/tarboot.s --- linux86.old/bootblocks/tarboot.s Fri Jun 18 16:58:58 1999 +++ linux86/bootblocks/tarboot.s Fri Sep 28 19:32:46 2001 @@ -463,28 +463,20 @@ if DEBUG pboot: - mov si,#mesg + mov si,#blk_load nextc: lodsb call putc cmp al,#0 jnz nextc ret - -locn(512-16) -mesg: -.ascii "Tarboot loading " endif !-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- -! This isn't a hard disk boot sector so don't give it an HD magic -! locn(510) -! .word 0xAA55 -if DEBUG = 0 +! This isn't a hard disk boot sector but give it an HD magic anyway. locn(510) - .word 0 -endif + .word 0xAA55 ! From here down is where we load stuff. locn(512) diff -Nurd linux86.old/later.c linux86/later.c --- linux86.old/later.c Sun Dec 1 09:09:12 1996 +++ linux86/later.c Thu Jan 1 01:00:00 1970 @@ -1,38 +0,0 @@ - -#include -#include -#include - -main(argc, argv) -int argc; -char ** argv; -{ - struct stat st; - long exe_mtime = 0; - int verbose = 0; - int ar; - - if( strcmp(argv[1], "+") == 0 ) { verbose++; argc--; argv++; } - - if( stat(argv[1], &st) < 0 ) - { - if( verbose ) printf("%s not found\n", argv[1]); - exit(2); - } - exe_mtime = st.st_mtime; - - for(ar=2; ar -#define wchar(ch) putch(ch) - -cprintf(char * fmt, va_list ap) -{ - register int c; - int count = 0; - int type, base; - long val; - char * cp; - char padch=' '; - int minsize = 0; - - while(c=*fmt++) - { - if(c!='%') - { - wchar(c); - count++; - } - else - { - type=1; - do { c=*fmt++; } while( c>='0' && c<='9'); - - padch = *fmt; - minsize=0; - if(padch == '-') fmt++; - - for(;;) - { - c=*fmt++; - if( c<'0' || c>'9' ) break; - minsize*=10; minsize+=c-'0'; - } - - while( c=='.' || (c>='0' && c<='9')) { c=*fmt++; } - - if( padch == '-' ) minsize = -minsize; - else - if( padch == '0' ) padch='0'; else padch=' '; - - if( c == 0 ) break; - if(c=='h') - { - c=*fmt++; - type = 0; - } - else if(c=='l') - { - c=*fmt++; - type = 2; - } - - switch(c) - { - case 'x': base=16; type|=4; if(0) { - case 'o': base= 8; type|=4; } if(0) { - case 'u': base=10; type|=4; } if(0) { - case 'd': base=10; } - val=0; - switch(type) - { - case 0: val=va_arg(ap, short); break; - case 1: val=va_arg(ap, int); break; - case 2: val=va_arg(ap, long); break; - case 4: val=va_arg(ap, unsigned short); break; - case 5: val=va_arg(ap, unsigned int); break; - case 6: val=va_arg(ap, unsigned long); break; - } - cp = __numout(val,base); - if(0) { - case 's': - cp=va_arg(ap, char *); - } - if( minsize > 0 ) - { - minsize -= strlen(cp); - while(minsize>0) { wchar(padch); minsize--; } - minsize=0; - } - if( minsize < 0 ) minsize= -minsize-strlen(cp); - while(*cp) - wchar(*cp++); - while(minsize>0) { wchar(' '); minsize--; } - break; - case 'c': - wchar(va_arg(ap, int)); - break; - default: - wchar(c); - break; - } - } - } - return count; -} - - - -static char nstring[]="0123456789ABCDEF"; - -static unsigned char * -__numout(long i, int base) -{ - static unsigned char out[16]; - int n; - int flg = 0; - unsigned long val; - - if (i<0 && base==10) - { - flg = 1; - i = -i; - } - val = i; - - for (n = 0; n < 15; n++) - out[n] = ' '; - out[15] = '\0'; - n = 14; - do - { - out[n] = nstring[val % base]; - n--; - val /= base; - } - while(val); - if(flg) out[n--] = '-'; - return &out[n+1]; -} diff -Nurd linux86.old/libc/conio/Config linux86/libc/conio/Config --- linux86.old/libc/conio/Config Thu Jan 1 01:00:00 1970 +++ linux86/libc/conio/Config Mon Dec 3 21:05:14 2001 @@ -0,0 +1 @@ +conio: Console io functions for BIOS and DOS. diff -Nurd linux86.old/libc/conio/Makefile linux86/libc/conio/Makefile --- linux86.old/libc/conio/Makefile Thu Jan 1 01:00:00 1970 +++ linux86/libc/conio/Makefile Mon Dec 3 21:18:51 2001 @@ -0,0 +1,36 @@ +# Copyright (C) 1996 Robert de Bath +# This file is part of the Linux-8086 C library and is distributed +# under the GNU Library General Public License. + +ASRC=conio.c +AOBJ=getch.o getche.o kbhit.o putch.o cputs.o + +OBJ=$(AOBJ) cprintf.o + +CFLAGS=$(ARCH) $(CCFLAGS) $(DEFS) + +ifeq ($(LIB_CPU)-$(LIB_OS),i86-BIOS) +all: $(LIBC)($(OBJ)) + @$(RM) $(OBJ) +else +ifeq ($(LIB_CPU)-$(LIB_OS),i86-DOS) +all: $(LIBC)($(OBJ)) + @$(RM) $(OBJ) +else +all: + @: +endif +endif + +$(LIBC)($(AOBJ)): $(ASRC) + $(CC) $(CFLAGS) -DL_$* $< -c -o $*.o + $(AR) $(ARFLAGS) $@ $*.o + +$(LIBC)(cprintf.o): cprintf.c + $(CC) -c -ansi $(ARCH) $(CCFLAGS) $(DEFS) $*.c + $(AR) $(ARFLAGS) $@ $*.o + + + +clean: + rm -f *.o libc.a diff -Nurd linux86.old/libc/conio/conio.c linux86/libc/conio/conio.c --- linux86.old/libc/conio/conio.c Thu Jan 1 01:00:00 1970 +++ linux86/libc/conio/conio.c Mon Dec 3 22:26:06 2001 @@ -0,0 +1,101 @@ +/* Copyright (C) 1999 Robert de Bath + * This file is part of the Linux-8086 C library and is distributed + * under the GNU Library General Public License. + */ + +#include + +/* + * I'm not sure if these should be BIOS or dos calls, so I'll assume they're + * BIOS calls but I may have to do something about Ctrl-C. + * + * These functions are also compiled for __STANDALONE__ so if ^C or DOS + * versions are made this will have to be addressed. + */ + +#ifdef L_getch +getch() +{ +#asm + xor ax,ax + int $16 +#endasm +} +#endif + +#ifdef L_getche +getche() +{ + int i = getch(); + if( i & 0xFF ) putch(i); + return i; +} +#endif + +#ifdef L_kbhit +kbhit() +{ +#asm + mov ah,#1 + int $16 + jz nokey + cmp ax,#0 + jnz dort + mov ax,#3 +dort: + ret +nokey: + xor ax,ax +#endasm +} +#endif + +#ifdef L_putch +putch() +{ +#asm +#if !__FIRST_ARG_IN_AX__ + mov bx,sp + mov ax,[bx+2] +#endif + cmp al,#$0A + jne not_nl + mov ax,#$0E0D + mov bx,#7 + int $10 + mov al,#$0A +not_nl: + mov ah,#$0E + mov bx,#7 + int $10 +#endasm +} +#endif + +#ifdef L_cputs +cputs(str) +char * str; +{ + while(*str) putch(*str++); +} +#endif + +#if 0 + +cgets() +{ +} + +cscanf() +{ +} + +getpass() +{ +} + +gotoxy() +{ +} + +#endif diff -Nurd linux86.old/libc/conio/cprintf.c linux86/libc/conio/cprintf.c --- linux86.old/libc/conio/cprintf.c Thu Jan 1 01:00:00 1970 +++ linux86/libc/conio/cprintf.c Tue Dec 4 20:56:00 2001 @@ -0,0 +1,221 @@ +#include +#include + +static unsigned char * __numout(long i, int base); + +int cprintf(char * fmt, ...) +{ + register int c; + int count = 0; + int type, base; + long val; + char * cp; + char padch=' '; + int minsize, maxsize; + va_list ap; + + va_start(ap, fmt); + + while(c=*fmt++) + { + count++; + if(c!='%') + putch(c); + else + { + type=1; + padch = *fmt; + maxsize=minsize=0; + if(padch == '-') fmt++; + + for(;;) + { + c=*fmt++; + if( c<'0' || c>'9' ) break; + minsize*=10; minsize+=c-'0'; + } + + if( c == '.' ) + for(;;) + { + c=*fmt++; + if( c<'0' || c>'9' ) break; + maxsize*=10; maxsize+=c-'0'; + } + + if( padch == '-' ) minsize = -minsize; + else + if( padch != '0' ) padch=' '; + + if( c == 0 ) break; + if(c=='h') + { + c=*fmt++; + type = 0; + } + else if(c=='l') + { + c=*fmt++; + type = 2; + } + + switch(c) + { + case 'x': base=16; type |= 4; if(0) { + case 'o': base= 8; type |= 4; } if(0) { + case 'u': base=10; type |= 4; } if(0) { + case 'd': base=-10; } + switch(type) + { + case 0: val=va_arg(ap, short); break; + case 1: val=va_arg(ap, int); break; + case 2: val=va_arg(ap, long); break; + case 4: val=va_arg(ap, unsigned short); break; + case 5: val=va_arg(ap, unsigned int); break; + case 6: val=va_arg(ap, unsigned long); break; + default:val=0; break; + } + cp = __numout(val,base); + if(0) { + case 's': + cp=va_arg(ap, char *); + } + count--; + c = strlen(cp); + if( !maxsize ) maxsize = c; + if( minsize > 0 ) + { + minsize -= c; + while(minsize>0) { putch(padch); count++; minsize--; } + minsize=0; + } + if( minsize < 0 ) minsize= -minsize-c; + while(*cp && maxsize-->0 ) + { + putch(*cp++); + count++; + } + while(minsize>0) { putch(' '); count++; minsize--; } + break; + case 'c': + putch(va_arg(ap, int)); + break; + default: + putch(c); + break; + } + } + } + va_end(ap); + return count; +} + +static char nstring[]="0123456789ABCDEF"; + +#ifndef __AS386_16__ +#define NUMLTH 11 + +static unsigned char * +__numout(long i, int base) +{ + static unsigned char out[NUMLTH+1]; + int n; + int flg = 0; + unsigned long val; + + if (base<0) + { + base = -base; + if (i<0) + { + flg = 1; + i = -i; + } + } + val = i; + + out[NUMLTH] = '\0'; + n = NUMLTH-1; + do + { + out[n--] = nstring[val % base]; + val /= base; + } + while(val); + if(flg) out[n--] = '-'; + return &out[n+1]; +} + +#else + +#asm +! numout.s +! +.bss +___out lcomm $C + +.text +___numout: +push bp +mov bp,sp +push di +push si +add sp,*-4 +mov byte ptr -8[bp],*$0 ! flg = 0 +mov si,4[bp] ; i or val.lo +mov di,6[bp] ; i or val.hi +mov cx,8[bp] ; base +test cx,cx ! base < 0 ? +jge .3num +neg cx ! base = -base +or di,di ! i < 0 ? +jns .5num +mov byte ptr -8[bp],*1 ! flg = 1 +neg di ! i = -i +neg si +sbb di,0 +.5num: +.3num: +mov byte ptr [___out+$B],*$0 ! out[11] = nul +mov -6[bp],*$A ! n = 10 + +.9num: +!!! out[n--] = nstring[val % base]; +xor dx,dx +xchg ax,di +div cx +xchg ax,di +xchg ax,si +div cx +xchg ax,si ! val(new) = val / base + +mov bx,dx ! dx = val % base + +mov al,_nstring[bx] +mov bx,-6[bp] +dec word ptr -6[bp] +mov ___out[bx],al + +mov ax,si +or ax,di ! while (val) +jne .9num + +cmp byte ptr -8[bp],*$0 ! flg == 0 ? +je .Dnum + +mov bx,-6[bp] +dec word ptr -6[bp] +mov byte ptr ___out[bx],*$2D ! out[n--] = minus + +.Dnum: +mov ax,-6[bp] +add ax,#___out+1 + +add sp,*4 +pop si +pop di +pop bp +ret +#endasm + +#endif diff -Nurd linux86.old/libc/include/conio.h linux86/libc/include/conio.h --- linux86.old/libc/include/conio.h Thu Jan 1 01:00:00 1970 +++ linux86/libc/include/conio.h Mon Dec 3 22:23:56 2001 @@ -0,0 +1,26 @@ + +#ifndef __CONIO_H +#define __CONIO_H +#include + +int cprintf __P((char *, ...)); +int cputs __P((char *)); +int getch __P((void)); +int getche __P((void)); +int kbhit __P((void)); +int putch __P((int)); + +#if 0 /* Unimplemented as yet */ +char * cgets __P((char *)); +int ungetch __P((int)); +int cscanf __P((char *, ...)); +#endif + +#if 0 /* Hummm */ +unsigned outpw __P((unsigned int, unsigned int)); +unsigned inpw __P((unsigned int)); +int outp __P((unsigned int, int)); +int inp __P((unsigned int)); +#endif + +#endif diff -Nurd linux86.old/libc/msdos/conio.c linux86/libc/msdos/conio.c --- linux86.old/libc/msdos/conio.c Wed Mar 10 07:17:03 1999 +++ linux86/libc/msdos/conio.c Thu Jan 1 01:00:00 1970 @@ -1,83 +0,0 @@ -/* Copyright (C) 1999 Robert de Bath - * This file is part of the Linux-8086 C library and is distributed - * under the GNU Library General Public License. - */ - -/* - * I'm not sure if these should be BIOS or dos calls, so I'll assume they're - * BIOS calls but I may have to do something about Ctrl-C. - */ - -getch() -{ -#asm - xor ax,ax - int $16 -#endasm -} - -getche() -{ - int i = getch(); - if( i & 0xFF) putch(i); - return i; -} - -kbhit() -{ -#asm - mov ah,#1 - int $16 - jz nokey - cmp ax,#0 - jnz dort - mov ax,#3 -dort: - ret -nokey: - xor ax,ax -#endasm -} - -putch() -{ -#asm -#if !__FIRST_ARG_IN_AX__ - mov bx,sp - mov ax,[bx+2] -#endif - mov ah,#$0E - mov bx,#7 - int $10 -#endasm -} - -cputs(str) -char * str; -{ - while(*str) putch(*str++); -} - -#if 0 - -cgets() -{ -} - -cprintf() -{ -} - -cscanf() -{ -} - -getpass() -{ -} - -gotoxy() -{ -} - -#endif diff -Nurd linux86.old/libc/syscall/syscall.dev86 linux86/libc/syscall/syscall.dev86 --- linux86.old/libc/syscall/syscall.dev86 Sat Oct 18 15:28:19 1997 +++ linux86/libc/syscall/syscall.dev86 Fri May 25 14:57:42 2001 @@ -47,25 +47,25 @@ alarm 27 2 fstat +28 2 pause 29 0 -utime 30 2 +utime +30 2 chroot +31 1 -vfork 32 0 +vfork +32 0 access +33 2 nice 34 1 sleep 35 1 sync +36 0 -kill 37 2 +kill +37 2 rename +38 2 mkdir +39 2 rmdir +40 1 dup +41 1 . There is a fcntl lib function too. -pipe 42 1 +pipe +42 1 times 43 2 * 2nd arg is pointer for long ret val. profil 44 4 @ dup2 +45 2 setgid +46 1 getgid 47 1 * this gets both gid and egid -signal 48 2 * have put the despatch table in user space. +signal +48 2 * have put the despatch table in user space. getinfo 49 1 @ possible? gets pid,ppid,uid,euid etc fcntl +50 3 acct 51 1 @ Accounting to named file (off if null) @@ -78,11 +78,19 @@ symlink +58 2 readlink +59 3 umask +60 1 -settimeofday 61 2 -gettimeofday 62 2 -select 63 5 * +settimeofday +61 2 +gettimeofday +62 2 +select +63 5 . 5 paramaters is possible readdir +64 3 * - +insmod +65 1 +fchown +66 3 +dlload +67 2 +setsid +68 0 +socket +69 3 +bind +70 3 +listen +71 2 +accept +72 3 +connect +73 3 # # Name No Args Flag&comment # diff -Nurd linux86.old/libc/syscall/syscall.dev86.old linux86/libc/syscall/syscall.dev86.old --- linux86.old/libc/syscall/syscall.dev86.old Thu Jan 1 01:00:00 1970 +++ linux86/libc/syscall/syscall.dev86.old Sat Oct 18 15:28:19 1997 @@ -0,0 +1,160 @@ +# +# WARNING! +# This file is used to generate the system call lists for Dev86(elks) +# ELKSemu and elks itself. Changes to this may require changes in +# all three of those packages. +# +# . = Ok, with comment +# * = Needs libc code (Prefix __) +# - = Obsolete/not required +# @ = May be required later +# +# An initial plus on the call number specifies that this call is +# implemented in the kernel. +# +# Package versions are matched. +# Dev86/Elksemu version - 0.13.1 +# Elks version - 0.0.66 +# +# Name No Args Flag, comment +# +exit +1 1 * c exit does stdio, _exit in crt0 +fork +2 0 +read +3 3 +write +4 3 +open +5 3 +close +6 1 +wait4 +7 4 +creat 8 0 - Not needed alias for open +link +9 2 +unlink +10 1 +execve +11 3 * execve minix style +chdir +12 1 +time 13 1 - Use settimeofday +mknod +14 3 +chmod +15 2 +chown +16 3 +brk +17 1 * This is only to tell the system +stat +18 2 +lseek +19 3 * nb 2nd arg is an io ptr to long not a long. +getpid +20 1 * this gets both pid & ppid +mount +21 5 +umount +22 1 +setuid +23 1 +getuid +24 1 * this gets both uid and euid +stime 25 2 - this must not exist - even as a libc. +ptrace 26 4 @ adb/sdb/dbx need this. +alarm 27 2 +fstat +28 2 +pause 29 0 +utime 30 2 +chroot +31 1 +vfork 32 0 +access +33 2 +nice 34 1 +sleep 35 1 +sync +36 0 +kill 37 2 +rename +38 2 +mkdir +39 2 +rmdir +40 1 +dup +41 1 . There is a fcntl lib function too. +pipe 42 1 +times 43 2 * 2nd arg is pointer for long ret val. +profil 44 4 @ +dup2 +45 2 +setgid +46 1 +getgid 47 1 * this gets both gid and egid +signal 48 2 * have put the despatch table in user space. +getinfo 49 1 @ possible? gets pid,ppid,uid,euid etc +fcntl +50 3 +acct 51 1 @ Accounting to named file (off if null) +phys 52 3 - Replaced my mmap() +lock 53 1 @ Prevent swapping for this proc if flg!=0 +ioctl +54 3 . make this and fcntl the same ? +reboot +55 3 . the magic number is 0xfee1,0xdead,... +mpx 56 2 - Replaced by fifos and select. +lstat +57 2 +symlink +58 2 +readlink +59 3 +umask +60 1 +settimeofday 61 2 +gettimeofday 62 2 +select 63 5 * +readdir +64 3 * + +# +# Name No Args Flag&comment +# +# ( awk '{$2=NR+500;OFS="\t";print ;}'| expand -24,32,40 | unexpand ) <NUL/' - echo "cl $ARCH -o $BIN\\$PRG.exe $BOBJ doslib.lib $LDFLAGS" + sed "s/\(.*\)/lib %TMP%\\\\doslib.lib \1; /" | + sed 's/$/@if errorlevel 1 goto exit_now/' | + tr '@' '\012' + echo + echo "cl $ARCH -o $BIN\\$PRG.exe $BOBJ %TMP%\\doslib.lib $LDFLAGS" echo "if errorlevel 1 goto exit_now" - echo "if exist doslib.lib del doslib.lib" - echo "if exist doslib.bak del doslib.bak" - echo ":done_$PRG" fi echo -} - -check_time() { - TARG="$1" ; shift - - for i - do echo "$DIR/$i" - done | fmt -70 | \ - sed -e "s;\(.*\);later $TARG \1@if errorlevel 3 goto exit_now;" \ - -e '2,$s/^/if not errorlevel 1 /' | \ - tr '@' '\012' } main "$@" | sed 's/$/ /' > compile.bat diff -Nurd linux86.old/mkcompile2 linux86/mkcompile2 --- linux86.old/mkcompile2 Sun Mar 23 10:52:34 1997 +++ linux86/mkcompile2 Thu Jan 1 01:00:00 1970 @@ -1,103 +0,0 @@ -#!/bin/sh - -SRC_BCC='bcc.c' -SRC_CC1='bcc-cc1.c assign.c codefrag.c debug.c declare.c express.c exptree.c - floatop.c function.c gencode.c genloads.c glogcode.c hardop.c input.c - label.c loadexp.c longop.c output.c preproc.c preserve.c scan.c - softop.c state.c table.c type.c' -SRC_AS=' as.c assemble.c error.c express.c genbin.c genlist.c genobj.c gensym.c - keywords.c macro.c mops.c pops.c readsrc.c scan.c table.c typeconv.c' -SRC_LD=' ld.c dumps.c io.c linksyms.c readobj.c table.c typeconv.c - writebin.c writex86.c' - -HDR_BCC='' -HDR_CC1='align.h byteord.h condcode.h const.h gencode.h input.h label.h os.h - output.h parse.h proto.h reg.h sc.h scan.h sizes.h table.h type.h - types.h' -HDR_AS=' address.h byteord.h const.h file.h flag.h globvar.h macro.h opcode.h - proto.h scan.h source.h syshead.h type.h' -HDR_LD=' align.h ar.h bindef.h byteord.h config.h const.h globvar.h obj.h - syshead.h type.h x86_aout.h' - -main() { - echo '@echo off' - echo -n 'if not exist later.exe ' - echo 'bcc -O later.c' - echo - - CFLAGS='-O -D__STDC__=1 -DMSDOS' - LDFLAGS='' - ARCH= - build bcc bcc bin "$HDR_BCC" $SRC_BCC - - CFLAGS='-O -D__STDC__=1 -DMSDOS -DPOSIX_HEADERS_MISSING' - LDFLAGS= - ARCH=-ml - build bcc bcc-cc1 lib "$HDR_CC1" $SRC_CC1 - build as as86 bin "$HDR_AS" $SRC_AS - build ld ld86 bin "$HDR_LD" $SRC_LD - echo ":exit_now" -} - -build() { - DIR="$1" ; shift - PRG="$1" ; shift - BIN="$1" ; shift - HDR="$1" ; shift - OBJ= - BOBJ= - COBJ= - LOBJ= - SRC="$*" - - for i in $SRC - do - j=`basename $i .c` - check_time $DIR/$j.obj $i $HDR - echo -n "if errorlevel 1 " - - echo "bcc $ARCH $CFLAGS -c -I$DIR -o$DIR\\$j.obj $DIR\\$i" - if [ "$BOBJ" = "" ] - then BOBJ="$DIR\\$j.obj" - else LOBJ="$LOBJ +$DIR\\$j.obj" - fi - COBJ="$COBJ $DIR\\$j.obj" - OBJ="$OBJ $j.obj" - - echo "if errorlevel 1 goto exit_now" - done - - if [ `echo $COBJ | wc -c` -lt 50 ] - then - check_time $BIN/$PRG.exe $OBJ - echo -n "if errorlevel 1 " - echo "bcc $ARCH -e$BIN\\$PRG.exe$COBJ $LDFLAGS" - echo "if errorlevel 1 goto exit_now" - else - check_time $BIN/$PRG.exe $OBJ - echo "if not errorlevel 1 goto done_$PRG" - echo "if exist doslib.lib del doslib.lib" - echo $LOBJ | fmt -62 | \ - sed 's/\(.*\)/tlib doslib.lib \1/' - echo "bcc $ARCH -e$BIN\\$PRG.exe $BOBJ doslib.lib $LDFLAGS" - echo "if errorlevel 1 goto exit_now" - echo "if exist doslib.lib del doslib.lib" - echo "if exist doslib.bak del doslib.bak" - echo ":done_$PRG" - fi - echo -} - -check_time() { - TARG="$1" ; shift - - for i - do echo "$DIR/$i" - done | fmt -70 | \ - sed -e "s;\(.*\);later $TARG \1@if errorlevel 3 goto exit_now;" \ - -e '2,$s/^/if not errorlevel 1 /' | \ - tr '@' '\012' -} - -main "$@" | sed 's/$/ /' > compile.bat -