From c819b1e06a731b497ea9e0bfbb6b3b753306a190 Mon Sep 17 00:00:00 2001 From: johanknol Date: Sat, 30 Sep 2000 19:39:35 +0000 Subject: [PATCH] cleanup; moved extern's from .c to .h files for double check git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@429 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- src/Makefile.in | 5 +- src/SDCC.y | 1 - src/SDCCBBlock.c | 1 - src/SDCCast.c | 9 +-- src/SDCCast.h | 14 ++-- src/SDCCerr.c | 5 +- src/SDCCglobl.h | 3 + src/SDCCglue.c | 14 ++-- src/SDCCglue.h | 3 + src/SDCCicode.c | 2 - src/SDCCicode.h | 5 ++ src/SDCCmain.c | 159 +++++++++++++++++++++++----------------------- src/SDCCmem.c | 3 - src/SDCCmem.h | 4 ++ src/SDCCpeeph.awk | 14 ---- src/SDCCpeeph.h | 1 + src/SDCCsymt.c | 2 - src/asm.c | 4 +- src/clean.mk | 5 +- src/common.h | 7 +- src/port.h | 21 +++++- 21 files changed, 149 insertions(+), 133 deletions(-) delete mode 100644 src/SDCCpeeph.awk diff --git a/src/Makefile.in b/src/Makefile.in index f2661ed5..2a3f65e7 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -18,6 +18,8 @@ LIBDIRS = -L$(PRJDIR)/support/gc LIBGC = $(PRJDIR)/support/gc/libgc.a endif +#CFLAGS += -Werror + ifdef SDCC_SUB_VERSION CFLAGS += -DSDCC_SUB_VERSION_STR=\"$(SDCC_SUB_VERSION)\" endif @@ -63,7 +65,7 @@ install: all installdirs # -------------------------------- uninstall: rm -f $(bindir)/sdcc - + rm -f $(bindir)/packihx # Performing self-test # -------------------- @@ -99,7 +101,6 @@ $(TARGET): $(OBJECTS) $(PORT_LIBS) $(PACKIHX): packihx $(INSTALL) packihx $(PACKIHX) - .c.o: $(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ diff --git a/src/SDCC.y b/src/SDCC.y index 44b19d5f..1d8fb62e 100644 --- a/src/SDCC.y +++ b/src/SDCC.y @@ -34,7 +34,6 @@ extern int yyerror (char *); extern FILE *yyin; -extern char srcLstFname[]; int NestLevel = 0 ; /* current NestLevel */ int stackPtr = 1 ; /* stack pointer */ int xstackPtr = 0 ; /* xstack pointer */ diff --git a/src/SDCCBBlock.c b/src/SDCCBBlock.c index b759c3c9..4d40389c 100644 --- a/src/SDCCBBlock.c +++ b/src/SDCCBBlock.c @@ -27,7 +27,6 @@ int eBBNum = 0; set *graphEdges = NULL ; /* list of edges in this flow graph */ -extern int labelKey ; /*-----------------------------------------------------------------*/ /* printEntryLabel - prints entry label of a ebblock */ diff --git a/src/SDCCast.c b/src/SDCCast.c index cfa68e04..c64fcafb 100644 --- a/src/SDCCast.c +++ b/src/SDCCast.c @@ -27,7 +27,6 @@ int currLineno = 0; set *astList = NULL ; set *operKeyReset = NULL; -extern char *currFname ; ast *staticAutos = NULL; int labelKey = 1 ; @@ -50,12 +49,8 @@ char buffer[1024]; int noLineno = 0; int noAlloc = 0 ; symbol *currFunc ; -extern int fatalError ; -extern int lineno; -extern char *filename ; -extern set *publics; -extern ast *createIval (ast *, link *, initList *, ast *); -extern ast *createIvalCharPtr (ast *, link *, ast *); +ast *createIval (ast *, link *, initList *, ast *); +ast *createIvalCharPtr (ast *, link *, ast *); ast *optimizeRRCRLC ( ast * ); ast *optimizeGetHbit(ast *); ast *backPatchLabels (ast *,symbol *,symbol *); diff --git a/src/SDCCast.h b/src/SDCCast.h index df111185..58888c33 100644 --- a/src/SDCCast.h +++ b/src/SDCCast.h @@ -22,12 +22,13 @@ what you give them. Help stamp out software-hoarding! -------------------------------------------------------------------------*/ +#ifndef SDCCEXPR_H +#define SDCCEXPR_H + #include "SDCCglobl.h" #include "SDCCsymt.h" #include "SDCCval.h" - -#ifndef SDCCEXPR_H -#define SDCCEXPR_H +#include "SDCCset.h" #define EX_OP 0 #define EX_VALUE 1 @@ -149,8 +150,9 @@ typedef struct ast { x == AND_ASSIGN || x == OR_ASSIGN || x == INC_OP || x == DEC_OP) #define IS_DEREF_OP(x) (( x->opval.op == '*' && x->right == NULL) || x->opval.op == '.') -/* forward declrations for global variables */ +/* forward declarations for global variables */ extern ast *staticAutos ; +extern FILE *codeOutFile; /* forward definitions for functions */ ast *newAst (int , void * ); @@ -180,4 +182,8 @@ ast *initAggregates ( symbol *,initList *, ast *); bool hasSEFcalls ( ast *); void addSymToBlock (symbol *, ast *) ; +// exported variables +extern set *operKeyReset; +extern int noAlloc; + #endif diff --git a/src/SDCCerr.c b/src/SDCCerr.c index cdffcddb..be2946cf 100644 --- a/src/SDCCerr.c +++ b/src/SDCCerr.c @@ -12,10 +12,7 @@ #define ERROR 0 #define WARNING 1 -extern FILE *lstFile; -extern int fatalError ; -extern int lineno ; -extern char *filename; + struct { int errType ; char *errText ; diff --git a/src/SDCCglobl.h b/src/SDCCglobl.h index f0e2eb83..6cb18929 100644 --- a/src/SDCCglobl.h +++ b/src/SDCCglobl.h @@ -213,6 +213,9 @@ struct options { int c1mode : 1 ; /* Act like c1 - no pre-proc, asm or link */ char *peep_file ; /* additional rules for peep hole */ char *out_name ; /* Asm output name for c1 mode */ + int nostdlib : 1 ; /* Don't use standard lib files */ + int nostdinc : 1 ; /* Don't use standard include files */ + int verbose : 1 ; /* Show what the compiler is doing */ char *calleeSaves[128]; /* list of functions using callee save */ char *excludeRegs[32] ; /* registers excluded from saving */ diff --git a/src/SDCCglue.c b/src/SDCCglue.c index 1adc235f..a1ef56ae 100644 --- a/src/SDCCglue.c +++ b/src/SDCCglue.c @@ -26,20 +26,22 @@ #include "asm.h" #include +// This is a bit messy because we define link ourself +#define link NoLiNk +#include +#undef link + symbol *interrupts[256]; -/*extern char *aopLiteral (value *, int);*//* drdani Jan 30 2000 */ + void printIval (symbol *, link *, initList *, FILE *); -extern int noAlloc; set *publics = NULL; /* public variables */ set *externs = NULL; /* Varibles that are declared as extern */ /* TODO: this should be configurable (DS803C90 uses more than 6) */ int maxInterrupts = 6; int allocInfo = 1; -extern int maxRegBank ; symbol *mainf; -extern char *VersionString; -extern FILE *codeOutFile; +char *VersionString; set *tmpfileSet = NULL; /* set of tmp file created by the compiler */ set *tmpfileNameSet = NULL; /* All are unlinked at close. */ @@ -225,7 +227,7 @@ static void emitRegularMap (memmap * map, bool addPublics, bool arFlag) tfprintf(map->oFile, "\t!ds\n", (unsigned int)getSize (sym->type) & 0xffff); } - /* if it has a initial value then do it only if + /* if it has an initial value then do it only if it is a global variable */ if (sym->ival && sym->level == 0) { ast *ival = NULL; diff --git a/src/SDCCglue.h b/src/SDCCglue.h index 0205dd55..65c83be9 100644 --- a/src/SDCCglue.h +++ b/src/SDCCglue.h @@ -33,4 +33,7 @@ void glue(); char *aopLiteral (value *, int); void flushStatics(void); +extern symbol *interrupts[]; +extern set *publics; +extern set *tmpfileSet; #endif diff --git a/src/SDCCicode.c b/src/SDCCicode.c index 4c803639..802abd7b 100644 --- a/src/SDCCicode.c +++ b/src/SDCCicode.c @@ -38,8 +38,6 @@ int block; int scopeLevel; int lvaluereq; -extern int labelKey ; - symbol *returnLabel ; /* function return label */ symbol *entryLabel ; /* function entry label */ /*-----------------------------------------------------------------*/ diff --git a/src/SDCCicode.h b/src/SDCCicode.h index f5059169..3071d614 100644 --- a/src/SDCCicode.h +++ b/src/SDCCicode.h @@ -278,4 +278,9 @@ bool isOperandInFarSpace (operand *); operand *opFromOpWithDU (operand *,bitVect *,bitVect *); iCode *copyiCode (iCode *); operand *newiTempFromOp( operand *); +/*-----------------------------------------------------------------*/ +/* declaration of exported variables */ +/*-----------------------------------------------------------------*/ +extern char *filename; +int lineno; #endif diff --git a/src/SDCCmain.c b/src/SDCCmain.c index e68ce1a4..819633f9 100644 --- a/src/SDCCmain.c +++ b/src/SDCCmain.c @@ -31,25 +31,14 @@ #include "spawn.h" #endif -/* This is a bit messy. We cant include unistd.h as it defines - 'link' which we also use. -*/ -int access(const char *path, int mode); -#define X_OK 1 -int unlink(const char *path); - -extern void initSymt (); -extern void initMem (); -extern void initExpr (); -extern void initiCode (); -extern void initCSupport (); -extern void initPeepHole (); -extern void createObject (); -extern int yyparse (); -extern void glue (); -extern struct value *constVal(char *s); -extern double floatFromVal(struct value *); -extern int fatalError ; +// This is a bit messy because we define link ourself +#define link NoLiNk +#include +#undef link + +//REMOVE ME!!! +extern int yyparse(); + FILE *srcFile ;/* source file */ FILE *cdbFile = NULL ;/* debugger information output file */ char *fullSrcFileName ;/* full name for the source file */ @@ -71,7 +60,6 @@ int nlibPaths = 0; char *relFiles[128]; int nrelFiles = 0; bool verboseExec = FALSE; -//extern int wait (int *); char *preOutName; /* Far functions, far data */ @@ -126,29 +114,14 @@ char *preOutName; #define OPTION_HELP "-help" #define OPTION_CALLEE_SAVES "-callee-saves" #define OPTION_NOREGPARMS "-noregparms" - +#define OPTION_NOSTDLIB "-nostdlib" +#define OPTION_NOSTDINC "-nostdinc" +#define OPTION_VERBOSE "-verbose" static const char *_preCmd[] = { "sdcpp", "-Wall", "-lang-c++", "-DSDCC=1", "$l", "-I" SDCC_INCLUDE_DIR, "$1", "$2", NULL }; -#if !OPT_DISABLE_MCS51 -extern PORT mcs51_port; -#endif -#if !OPT_DISABLE_GBZ80 -extern PORT gbz80_port; -#endif -#if !OPT_DISABLE_Z80 -extern PORT z80_port; -#endif -#if !OPT_DISABLE_AVR -extern PORT avr_port; -#endif -#if !OPT_DISABLE_DS390 -extern PORT ds390_port; -#endif - - PORT *port; static PORT *_ports[] = { @@ -356,6 +329,9 @@ static void setDefaultOptions() options.genericPtr = 1; /* default on */ options.nopeep = 0; options.model = port->general.default_model; + options.nostdlib=0; + options.nostdinc=0; + options.verbose=0; /* now for the optimizations */ /* turn on the everything */ @@ -811,6 +787,21 @@ int parseCmdLine ( int argc, char **argv ) continue; } + if (strcmp(&argv[i][1],OPTION_NOSTDLIB) == 0) { + options.nostdlib=1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_NOSTDINC) == 0) { + options.nostdinc=1; + continue; + } + + if (strcmp(&argv[i][1],OPTION_VERBOSE) == 0) { + options.verbose=1; + continue; + } + if (!port->parseOption(&argc, argv, &i)) { werror(W_UNKNOWN_OPTION,argv[i]); @@ -968,13 +959,13 @@ int parseCmdLine ( int argc, char **argv ) noAssemble = 1; break; + case 'V': + verboseExec = TRUE; + break; + case 'v': -#if FEATURE_VERBOSE_EXEC - verboseExec = TRUE; -#else printVersionInfo(); exit(0); -#endif break; /* preprocessor options */ @@ -1087,16 +1078,17 @@ int my_system (const char *cmd, char **cmd_argv) free(dir); i++; } -#if FEATURE_VERBOSE_EXEC + if (verboseExec) { char **pCmd = cmd_argv; + printf ("+ "); while (*pCmd) { printf("%s ", *pCmd); pCmd++; } printf("\n"); } -#endif + if (got) i= spawnv(P_WAIT,got,cmd_argv) == -1; else @@ -1169,36 +1161,38 @@ static void linkEdit (char **envp) fprintf (lnkfile,"-k %s\n",libPaths[i]); /* standard library path */ - if (strcmp(port->target,"ds390")==0) { - c="ds390"; - } else { - switch(options.model) - { - case MODEL_SMALL: - c = "small"; - break; - case MODEL_LARGE: - c = "large"; - break; - case MODEL_FLAT24: - c = "flat24"; - break; - default: - werror(W_UNKNOWN_MODEL, __FILE__, __LINE__); - c = "unknown"; - break; - } - } - fprintf (lnkfile,"-k %s/%s\n",SDCC_LIB_DIR/*STD_LIB_PATH*/,c); - - /* standard library files */ - if (strcmp(port->target, "ds390")==0) { - fprintf (lnkfile,"-l %s\n",STD_DS390_LIB); + if (!options.nostdlib) { + if (IS_DS390_PORT) { + c="ds390"; + } else { + switch(options.model) + { + case MODEL_SMALL: + c = "small"; + break; + case MODEL_LARGE: + c = "large"; + break; + case MODEL_FLAT24: + c = "flat24"; + break; + default: + werror(W_UNKNOWN_MODEL, __FILE__, __LINE__); + c = "unknown"; + break; + } + } + fprintf (lnkfile,"-k %s/%s\n",SDCC_LIB_DIR/*STD_LIB_PATH*/,c); + + /* standard library files */ + if (strcmp(port->target, "ds390")==0) { + fprintf (lnkfile,"-l %s\n",STD_DS390_LIB); + } + fprintf (lnkfile,"-l %s\n",STD_LIB); + fprintf (lnkfile,"-l %s\n",STD_INT_LIB); + fprintf (lnkfile,"-l %s\n",STD_LONG_LIB); + fprintf (lnkfile,"-l %s\n",STD_FP_LIB); } - fprintf (lnkfile,"-l %s\n",STD_LIB); - fprintf (lnkfile,"-l %s\n",STD_INT_LIB); - fprintf (lnkfile,"-l %s\n",STD_LONG_LIB); - fprintf (lnkfile,"-l %s\n",STD_FP_LIB); /* additional libraries if any */ for (i = 0 ; i < nlibFiles; i++) @@ -1216,7 +1210,8 @@ static void linkEdit (char **envp) buildCmdLine(buffer, argv, port->linker.cmd, srcFileName, NULL, NULL, NULL); - /* call the linker */ + if (options.verbose) + printf ("sdcc: Calling linker...\n"); if (my_system(argv[0], argv)) { perror("Cannot exec linker"); exit(1); @@ -1305,6 +1300,9 @@ static int preProcess (char **envp) buildCmdLine(buffer, argv, _preCmd, fullSrcFileName, preOutName, srcFileName, preArgv); + if (options.verbose) + printf ("sdcc: Calling preprocessor...\n"); + if (my_system(argv[0], argv)) { unlink (preOutName); perror("Cannot exec Preprocessor"); @@ -1372,15 +1370,17 @@ int main ( int argc, char **argv , char **envp) exit(0); } - if (srcFileName) + if (srcFileName) { preProcess(envp) ; - if (srcFileName) - { initSymt(); initiCode(); initCSupport (); initPeepHole(); + + if (options.verbose) + printf ("sdcc: Generating code...\n"); + yyparse(); if (!fatalError) @@ -1392,6 +1392,9 @@ int main ( int argc, char **argv , char **envp) } if (!options.c1mode) { + if (options.verbose) + printf ("sdcc: Calling assembler...\n"); + assemble(envp); } } @@ -1413,7 +1416,7 @@ int main ( int argc, char **argv , char **envp) if (port->linker.do_link) port->linker.do_link(); else - linkEdit (envp); + linkEdit (envp); } if (yyin && yyin != stdin) diff --git a/src/SDCCmem.c b/src/SDCCmem.c index cb71eedb..9a9cc209 100644 --- a/src/SDCCmem.c +++ b/src/SDCCmem.c @@ -25,9 +25,6 @@ memmap *home =NULL; /* Unswitchable code bank */ symbols in a single overlay */ set *ovrSetSets = NULL; -extern set *operKeyReset ; -extern set *tmpfileSet ; -extern symbol *interrupts[]; int maxRegBank = 0; int fatalError = 0 ;/* fatal error flag */ diff --git a/src/SDCCmem.h b/src/SDCCmem.h index 1f4a54dc..ce734cf5 100644 --- a/src/SDCCmem.h +++ b/src/SDCCmem.h @@ -59,8 +59,12 @@ extern memmap *eeprom; /* eepromp space */ extern memmap *eeprom; /* eepromp space */ extern memmap *home; /* Non-banked home space */ +extern int fatalError; + extern struct set *ovrSetSets; +extern int maxRegBank; + /* easy access macros */ #define IN_BITSPACE(map) (map && map->bitsp) #define IN_STACK(x) (IS_SPEC(x) && (SPEC_OCLS(x) == xstack || SPEC_OCLS(x) == istack )) diff --git a/src/SDCCpeeph.awk b/src/SDCCpeeph.awk deleted file mode 100644 index 160e0694..00000000 --- a/src/SDCCpeeph.awk +++ /dev/null @@ -1,14 +0,0 @@ -BEGIN { - print "/* Generated file DO NOT Edit */" - print "/* To Make changes to rules */" - print "/* edit file SDCCpeeph.def */" -} - -/^\/\// { next} - -{ printf "\"" ; - printf "%s",$0; - print "\\n\""; -} - - diff --git a/src/SDCCpeeph.h b/src/SDCCpeeph.h index 23b4a451..a53adc21 100644 --- a/src/SDCCpeeph.h +++ b/src/SDCCpeeph.h @@ -51,6 +51,7 @@ typedef struct peepRule void printLine (lineNode *,FILE *); lineNode *newLineNode (char *); lineNode *connectLine (lineNode *,lineNode *); +void initPeepHole(void); void peepHole (lineNode **); #endif diff --git a/src/SDCCsymt.c b/src/SDCCsymt.c index 0879b882..0bd3032f 100644 --- a/src/SDCCsymt.c +++ b/src/SDCCsymt.c @@ -29,8 +29,6 @@ bucket *TypedefTab[256] ; /* the typedef table */ bucket *LabelTab [256] ; /* the Label table */ bucket *enumTab [256] ; /* enumerated table */ -extern struct set *publics; - /*------------------------------------------------------------------*/ /* initSymt () - initialises symbol table related stuff */ /*------------------------------------------------------------------*/ diff --git a/src/asm.c b/src/asm.c index 1e0dd64b..7455b69b 100644 --- a/src/asm.c +++ b/src/asm.c @@ -60,7 +60,7 @@ static va_list _iprintf(char *pInto, const char *sz, va_list ap) *p = '\0'; vsprintf(pInto, format, ap); /* PENDING: Assume that the arg length was an int */ - va_arg(ap, int); + (void)va_arg(ap, int); } } pInto = pStart + strlen(pStart); @@ -113,7 +113,7 @@ void tvsprintf(char *buffer, const char *sz, va_list ap) *p = '\0'; vsprintf(pInto, token, ap); pInto = buffer + strlen(buffer); - va_arg(ap, int); + (void)va_arg(ap, int); } else { *pInto++ = *sz++; diff --git a/src/clean.mk b/src/clean.mk index bc083764..b60ad6d7 100644 --- a/src/clean.mk +++ b/src/clean.mk @@ -2,7 +2,7 @@ # -------------------------------------------------- clean: rm -f *core *[%~] *.[oa] *.output - rm -f .[a-z]*~ + rm -f .[a-z]*~ \#* rm -f $(PRJDIR)/bin/sdcc sdcc for port in $(PORTS) ; do\ $(MAKE) -C $$port -f clean.mk clean ;\ @@ -18,6 +18,9 @@ distclean: clean # Like clean but some files may still exist # ----------------------------------------- mostlyclean: clean + rm -f SDCCy.c + rm -f SDCCy.h + rm -f SDCClex.c # Deleting everything that can reconstructed by this Makefile. It deletes diff --git a/src/common.h b/src/common.h index ced0a15a..3d257086 100644 --- a/src/common.h +++ b/src/common.h @@ -21,11 +21,8 @@ #include "SDCClrange.h" #include "SDCCptropt.h" #include "SDCCopt.h" +#include "SDCCglue.h" +#include "SDCCpeeph.h" #include "asm.h" #include "port.h" -#include "config.h" - -/* -#include "SDCCralloc.h" -*/ diff --git a/src/port.h b/src/port.h index f59c124a..2247a7e9 100644 --- a/src/port.h +++ b/src/port.h @@ -165,8 +165,27 @@ typedef struct { extern PORT *port; -/* Ugly test to see if we are current compiling in DS390 mode. */ +#if !OPT_DISABLE_MCS51 +extern PORT mcs51_port; +#endif +#if !OPT_DISABLE_GBZ80 +extern PORT gbz80_port; +#endif +#if !OPT_DISABLE_Z80 +extern PORT z80_port; +#endif +#if !OPT_DISABLE_AVR +extern PORT avr_port; +#endif +#if !OPT_DISABLE_DS390 extern PORT ds390_port; +#endif + +/* Test to see if we are current compiling in DS390 mode. */ +#define IS_MCS51_PORT (port == &mcs51_port) +#define IS_GBZ80_PORT (port == &gbz80_port) +#define IS_Z80_PORT (port == &z80_port) +#define IS_AVR_PORT (port == &avr_port) #define IS_DS390_PORT (port == &ds390_port) #endif -- 2.30.2