cleanup; moved extern's from .c to .h files for double check
authorjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 30 Sep 2000 19:39:35 +0000 (19:39 +0000)
committerjohanknol <johanknol@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Sat, 30 Sep 2000 19:39:35 +0000 (19:39 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@429 4a8a32a2-be11-0410-ad9d-d568d2c75423

21 files changed:
src/Makefile.in
src/SDCC.y
src/SDCCBBlock.c
src/SDCCast.c
src/SDCCast.h
src/SDCCerr.c
src/SDCCglobl.h
src/SDCCglue.c
src/SDCCglue.h
src/SDCCicode.c
src/SDCCicode.h
src/SDCCmain.c
src/SDCCmem.c
src/SDCCmem.h
src/SDCCpeeph.awk [deleted file]
src/SDCCpeeph.h
src/SDCCsymt.c
src/asm.c
src/clean.mk
src/common.h
src/port.h

index f2661ed574dd3493c1585192962f80df23241c41..2a3f65e79636c6cd5dd6dfe28adecfd94e8862da 100644 (file)
@@ -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 $@
index 44b19d5ffcbef959e58258443429802acb9fe562..1d8fb62ed1ecbc74f708b3ef41093266d38b17a5 100644 (file)
@@ -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          */
index b759c3c93daf89b03464b0708b83bf45d3dab7bc..4d40389cd3ba9f6231c849605335894d55292157 100644 (file)
@@ -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               */
index cfa68e040219774a5e2e6f8444d669321787e816..c64fcafbfd2f9889d82678edcc6297c15c2f3d02 100644 (file)
@@ -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 *);
index df1111852735ce27aa620325dbe09d48929970b3..58888c33cec3d905a0a78054e3fecd7f70ca06dc 100644 (file)
    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 
index cdffcddb27ac68424c7e93bf9fb88c2f024d27f7..be2946cfe74c8d23f5b994ba8f31a4f52f85a69e 100644 (file)
 
 #define ERROR          0
 #define WARNING                1
-extern FILE *lstFile;
-extern int fatalError ;
-extern int lineno ;
-extern char *filename;
+
 struct  {
        int             errType ;
        char    *errText ;
index f0e2eb83f76538bb3957131c294a51a65b17592f..6cb18929baccb501402e1c8010b457401bffa52d 100644 (file)
@@ -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 */
index 1adc235fa1d554e26505b000f9ae0870c0a9c4bf..a1ef56ae7b115330a1d99844403fe168861923af 100644 (file)
 #include "asm.h"
 #include <time.h>
 
+// This is a bit messy because we define link ourself
+#define link NoLiNk
+#include <unistd.h>
+#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;
index 0205dd55a59ca48825814f7a31ea313267af43ba..65c83be9d8f1d7ce90c175b4523c968eb543e4c0 100644 (file)
@@ -33,4 +33,7 @@ void glue();
 char *aopLiteral (value *, int);
 void flushStatics(void);
 
+extern symbol *interrupts[];
+extern set *publics;
+extern set *tmpfileSet;
 #endif
index 4c803639ad654e51cc93940391deeb38f2f8f1a1..802abd7b4ee07e56c9fac0e5ce8ecb71f544d1cf 100644 (file)
@@ -38,8 +38,6 @@ int block;
 int scopeLevel;
 int lvaluereq;
 
-extern int labelKey ;
-
 symbol *returnLabel ; /* function return label */
 symbol *entryLabel  ; /* function entry  label */
 /*-----------------------------------------------------------------*/
index f5059169016bae499fa2ccbd72191c6e0e4dba1f..3071d614fe415c975a97584d46af32bacc12b0ca 100644 (file)
@@ -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
index e68ce1a419692262692dc4675ec02432ffba80e1..819633f99482aee6c9046190aefd20ee836ef4e3 100644 (file)
 #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 <unistd.h>
+#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)
index cb71eedb3e88f95385bf16e1afce24fab2a69c80..9a9cc20922de7d9225f4fb2711e293e2ea69e056 100644 (file)
@@ -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                   */
 
index 1f4a54dcb190d40786946452262fd820e30b7128..ce734cf58f1f2c6763414b14947ce61292559843 100644 (file)
@@ -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 (file)
index 160e069..0000000
+++ /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\""; 
-}
-
-
index 23b4a45196dd178b010da7387fa7ce5a4745c7fa..a53adc21c768302c3a8e483aa8c747bceb5cacbb 100644 (file)
@@ -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
index 0879b882e71070e4d360265052aaaab4d75f85a4..0bd3032f6bf786d6f7c6c96f36186bd3b6f9c719 100644 (file)
@@ -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             */
 /*------------------------------------------------------------------*/
index 1e0dd64b445295ad9ddd29e3a5c51c747ca5c151..7455b69b3e6f91b7713eed8c39b0a69e6c6f7275 100644 (file)
--- 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++;
index bc083764424a77ed7bc71d5c02c50aef037e1de8..b60ad6d7874bb653ed510fe58abad59afaec146d 100644 (file)
@@ -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
index ced0a15a2ebb5caadb8bc707f568cb2a1b1e49ce..3d257086a8b89faa8c1dc4560ed32ea16370fb0c 100644 (file)
 #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"
-*/
index f59c124a14b8666e31ad7d46509bc2307e023534..2247a7e9d02ebeab1db097ef69269f848b80c954 100644 (file)
@@ -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