Put main() in a separate file, so that the language
authorFergus Henderson <fjh@cs.mu.oz.au>
Mon, 5 Mar 2001 12:17:45 +0000 (12:17 +0000)
committerFergus Henderson <fjh@gcc.gnu.org>
Mon, 5 Mar 2001 12:17:45 +0000 (12:17 +0000)
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.

From-SVN: r40247

gcc/ChangeLog
gcc/Makefile.in
gcc/main.c [new file with mode: 0644]
gcc/toplev.c
gcc/toplev.h

index 029af4bc803eb2f624afe9e0f4a4a7c490b89bb6..6946e61d116781f11a901c52e59f522681d1fd16 100644 (file)
@@ -1,3 +1,14 @@
+2001-03-05  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.
+
 2001-03-04  Neil Booth  <neil@daikokuya.demon.co.uk>
 
        * cppfiles.c (search_from): Special case the empty string.
index 9f48da4034d63c18ed2695881a98cf375cca2c73..365a6443140694cd78387539f82c91c3bbf24651 100644 (file)
@@ -746,11 +746,11 @@ OBJS =                                                                    \
  recog.o reg-stack.o regclass.o regmove.o regrename.o reload.o         \
  reload1.o reorg.o resource.o rtl.o rtlanal.o sbitmap.o sched-deps.o   \
  sched-ebb.o sched-rgn.o sched-vis.o sdbout.o sibcall.o simplify-rtx.o \
- splay-tree.o ssa.o stmt.o stor-layout.o stringpool.o timevar.o tree.o \
unroll.o varasm.o varray.o version.o xcoffout.o                       \
+ splay-tree.o ssa.o stmt.o stor-layout.o stringpool.o timevar.o                \
toplev.o tree.o unroll.o varasm.o varray.o version.o xcoffout.o       \
  $(GGC) $(out_object_file) $(EXTRA_OBJS)
 
-BACKEND = toplev.o libbackend.a
+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
@@ -1348,6 +1348,7 @@ toplev.o : toplev.c $(CONFIG_H) system.h $(TREE_H) $(RTL_H) function.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)
diff --git a/gcc/main.c b/gcc/main.c
new file mode 100644 (file)
index 0000000..34f7aa8
--- /dev/null
@@ -0,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);
+}
index 73f1b8fc517dc00770ea8ad5631747a2ad767e0d..dd1321c4f3186acc806bb2cc5ff57e2fabdbb944 100644 (file)
@@ -192,7 +192,7 @@ static void print_switch_values PARAMS ((FILE *, int, int, const char *,
 
 const char *progname;
 
-/* Copy of arguments to main.  */
+/* Copy of arguments to toplev_main.  */
 int save_argc;
 char **save_argv;
 \f
@@ -4582,14 +4582,15 @@ independent_decode_option (argc, argv)
   return 1;
 }
 \f
-/* 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 **));
+/* 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
-main (argc, argv)
+toplev_main (argc, argv)
      int argc;
      char **argv;
 {
index 44772f35a44bec7101f501e24858b67a4c5f9e45..08c6112d6b9f7d536ccd47a3a78321deacb681cf 100644 (file)
@@ -31,6 +31,7 @@ struct rtx_def;
 #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));