This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

move main from toplev.c to new file main.c


2001-01-08  Fergus Henderson  <fjh@cs.mu.oz.au>

	Put main() in a separate file, so that the language
	front-end can use a different main().

	* main.c: New.
	* toplev.c: (main): Rename as toplev_main.
	* toplev.h: Declare toplev_main.
	* Makefile.in (OBJS): add toplev.o.
	  (BACKEND): remove toplev.o, add main.o.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Makefile.in,v
retrieving revision 1.574
diff -u -d -c -p -5 -r1.574 Makefile.in
*** Makefile.in	2000/12/22 12:27:35	1.574
--- Makefile.in	2001/01/08 10:54:25
*************** OBJS = diagnostic.o version.o tree.o pri
*** 736,748 ****
   insn-opinit.o insn-recog.o insn-extract.o insn-output.o insn-emit.o lcm.o    \
   profile.o insn-attrtab.o $(out_object_file) $(EXTRA_OBJS) convert.o	      \
   mbchar.o splay-tree.o graph.o sbitmap.o resource.o hash.o predict.o	      \
   lists.o ggc-common.o $(GGC) stringpool.o simplify-rtx.o ssa.o bb-reorder.o   \
   sibcall.o conflict.o timevar.o ifcvt.o dominance.o dependence.o dce.o \
!  sched-vis.o sched-deps.o sched-rgn.o sched-ebb.o hashtab.o
  
! BACKEND = toplev.o libbackend.a
  
  # GEN files are listed separately, so they can be built before doing parallel
  #  makes for cc1 or cc1plus.  Otherwise sequent parallel make attempts to load
  #  them before rtl.o is compiled.
  GEN= genemit$(build_exeext) genoutput$(build_exeext) genrecog$(build_exeext) \
--- 736,748 ----
   insn-opinit.o insn-recog.o insn-extract.o insn-output.o insn-emit.o lcm.o    \
   profile.o insn-attrtab.o $(out_object_file) $(EXTRA_OBJS) convert.o	      \
   mbchar.o splay-tree.o graph.o sbitmap.o resource.o hash.o predict.o	      \
   lists.o ggc-common.o $(GGC) stringpool.o simplify-rtx.o ssa.o bb-reorder.o   \
   sibcall.o conflict.o timevar.o ifcvt.o dominance.o dependence.o dce.o \
!  sched-vis.o sched-deps.o sched-rgn.o sched-ebb.o hashtab.o toplev.o
  
! BACKEND = main.o libbackend.a
  
  # GEN files are listed separately, so they can be built before doing parallel
  #  makes for cc1 or cc1plus.  Otherwise sequent parallel make attempts to load
  #  them before rtl.o is compiled.
  GEN= genemit$(build_exeext) genoutput$(build_exeext) genrecog$(build_exeext) \
*************** toplev.o : toplev.c $(CONFIG_H) system.h
*** 1313,1322 ****
--- 1313,1323 ----
     dwarf2out.h sdbout.h dbxout.h $(EXPR_H) hard-reg-set.h $(BASIC_BLOCK_H) \
     graph.h $(LOOP_H) except.h $(REGS_H) $(TIMEVAR_H) $(lang_options_files) ssa.h
  	$(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(MAYBE_USE_COLLECT2) \
  	  -DTARGET_NAME=\"$(target_alias)\" \
  	  -c $(srcdir)/toplev.c
+ main.o : main.c toplev.h
  
  rtl.o : rtl.c $(GCONFIG_H) system.h $(RTL_H) bitmap.h $(GGC_H) toplev.h
  	$(CC) -c $(ALL_CFLAGS) -DGENERATOR_FILE $(ALL_CPPFLAGS) $(INCLUDES) $< $(OUTPUT_OPTION)
  
  print-rtl.o : print-rtl.c $(GCONFIG_H) system.h $(RTL_H) hard-reg-set.h \
Index: toplev.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.h,v
retrieving revision 1.47
diff -u -d -c -p -5 -r1.47 toplev.h
*** toplev.h	2000/12/29 01:45:53	1.47
--- toplev.h	2001/01/08 10:54:25
*************** struct rtx_def;
*** 29,38 ****
--- 29,39 ----
  /* If non-NULL, return one past-the-end of the matching SUBPART of
     the WHOLE string.  */
  #define skip_leading_substring(whole,  part) \
     (strncmp (whole, part, strlen (part)) ? NULL : whole + strlen (part))
  
+ extern int toplev_main			PARAMS ((int argc, char **argv));
  extern int read_integral_parameter	PARAMS ((const char *, const char *,
  						const int));
  extern int count_error			PARAMS ((int));
  extern void strip_off_ending		PARAMS ((char *, int));
  extern char *file_name_nondirectory	PARAMS ((const char *));
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/toplev.c,v
retrieving revision 1.408
diff -u -d -c -p -5 -r1.408 toplev.c
*** toplev.c	2000/12/29 13:09:35	1.408
--- toplev.c	2001/01/08 10:54:30
*************** static void print_switch_values PARAMS (
*** 190,200 ****
  
  /* Name of program invoked, sans directories.  */
  
  const char *progname;
  
! /* Copy of arguments to main.  */
  int save_argc;
  char **save_argv;
  
  /* Name of current original source file (what was input to cpp).
     This comes from each #-command in the actual input.  */
--- 190,200 ----
  
  /* Name of program invoked, sans directories.  */
  
  const char *progname;
  
! /* Copy of arguments to toplev_main.  */
  int save_argc;
  char **save_argv;
  
  /* Name of current original source file (what was input to cpp).
     This comes from each #-command in the actual input.  */
*************** independent_decode_option (argc, argv)
*** 4500,4517 ****
      }
  
    return 1;
  }
  
! /* Entry point of cc1/c++.  Decode command args, then call compile_file.
!    Exit code is 35 if can't open files, 34 if fatal error,
!    33 if had nonfatal errors, else success.  */
! 
! extern int main PARAMS ((int, char **));
  
  int
! main (argc, argv)
       int argc;
       char **argv;
  {
    register int i;
    char *p;
--- 4500,4518 ----
      }
  
    return 1;
  }
  
! /* Entry point of cc1, cc1plus, jc1, f771, etc.
!    Decode command args, then call compile_file.
!    Exit code is FATAL_EXIT_CODE if can't open files or if there were
!    any errors, or SUCCESS_EXIT_CODE if compilation succeeded.
!    
!    It is not safe to call this function more than once.  */
  
  int
! toplev_main (argc, argv)
       int argc;
       char **argv;
  {
    register int i;
    char *p;
Index: main.c
===================================================================
RCS file: main.c
diff -N main.c
*** /dev/null	Thu Mar 30 14:06:13 2000
--- main.c	Mon Jan  8 21:55:35 2001
***************
*** 0 ****
--- 1,35 ----
+ /* main.c: defines main() for cc1, cc1plus, etc.
+ 
+ This file is part of GNU CC.
+ 
+ GNU CC is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2, or (at your option)
+ any later version.
+ 
+ GNU CC is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+ 
+ You should have received a copy of the GNU General Public License
+ along with GNU CC; see the file COPYING.  If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.  */
+ 
+ #include "gansidecl.h"
+ #include "toplev.h"
+ 
+ int main PARAMS ((int argc, char **argv));
+ 
+ /* We define main() to call toplev_main(), which is defined in toplev.c.
+    We do this in a separate file in order to allow the language front-end
+    to define a different main(), if it so desires.  */
+ 
+ int
+ main (argc, argv)
+   int argc;
+   char **argv;
+ {
+   return toplev_main (argc, argv);
+ }

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]