diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2010-12-03 04:34:57 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2010-12-03 04:34:57 +0000 |
commit | 7a9389330e91acc3ed05deac2d198af25d13cf3c (patch) | |
tree | 38fe54a4f38ede5d949c915d66191f24a6fe5153 /libgo/runtime/go-main.c | |
parent | 1aa6700378e5188a853c018256113ce6e1fb5c05 (diff) | |
download | gcc-7a9389330e91acc3ed05deac2d198af25d13cf3c.tar.gz |
Add Go frontend, libgo library, and Go testsuite.
gcc/:
* gcc.c (default_compilers): Add entry for ".go".
* common.opt: Add -static-libgo as a driver option.
* doc/install.texi (Configuration): Mention libgo as an option for
--enable-shared. Mention go as an option for --enable-languages.
* doc/invoke.texi (Overall Options): Mention .go as a file name
suffix. Mention go as a -x option.
* doc/frontends.texi (G++ and GCC): Mention Go as a supported
language.
* doc/sourcebuild.texi (Top Level): Mention libgo.
* doc/standards.texi (Standards): Add section on Go language.
Move references for other languages into their own section.
* doc/contrib.texi (Contributors): Mention that I contributed the
Go frontend.
gcc/testsuite/:
* lib/go.exp: New file.
* lib/go-dg.exp: New file.
* lib/go-torture.exp: New file.
* lib/target-supports.exp (check_compile): Match // Go.
From-SVN: r167407
Diffstat (limited to 'libgo/runtime/go-main.c')
-rw-r--r-- | libgo/runtime/go-main.c | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/libgo/runtime/go-main.c b/libgo/runtime/go-main.c new file mode 100644 index 00000000000..a6dbf347fb0 --- /dev/null +++ b/libgo/runtime/go-main.c @@ -0,0 +1,89 @@ +/* go-main.c -- the main function for a Go program. + + Copyright 2009 The Go Authors. All rights reserved. + Use of this source code is governed by a BSD-style + license that can be found in the LICENSE file. */ + +#include "config.h" + +#include <stdlib.h> +#include <time.h> + +#ifdef HAVE_FPU_CONTROL_H +#include <fpu_control.h> +#endif + +#include "go-alloc.h" +#include "array.h" +#include "go-signal.h" +#include "go-string.h" + +#include "runtime.h" +#include "malloc.h" + +#undef int +#undef char +#undef unsigned + +/* The main function for a Go program. This records the command line + parameters, calls the real main function, and returns a zero status + if the real main function returns. */ + +extern char **environ; + +extern struct __go_open_array Args asm ("libgo_os.os.Args"); + +extern struct __go_open_array Envs asm ("libgo_os.os.Envs"); + +/* These functions are created for the main package. */ +extern void __go_init_main (void); +extern void real_main (void) asm ("main.main"); + +/* The main function. */ + +int +main (int argc, char **argv) +{ + int i; + struct __go_string *values; + + runtime_mallocinit (); + __go_gc_goroutine_init (&argc); + + Args.__count = argc; + Args.__capacity = argc; + values = __go_alloc (argc * sizeof (struct __go_string)); + for (i = 0; i < argc; ++i) + { + values[i].__data = (unsigned char *) argv[i]; + values[i].__length = __builtin_strlen (argv[i]); + } + Args.__values = values; + + for (i = 0; environ[i] != NULL; ++i) + ; + Envs.__count = i; + Envs.__capacity = i; + values = __go_alloc (i * sizeof (struct __go_string)); + for (i = 0; environ[i] != NULL; ++i) + { + values[i].__data = (unsigned char *) environ[i]; + values[i].__length = __builtin_strlen (environ[i]); + } + Envs.__values = values; + + __initsig (); + +#if defined(HAVE_SRANDOM) + srandom ((unsigned int) time (NULL)); +#else + srand ((unsigned int) time (NULL)); +#endif + __go_init_main (); + + __go_enable_gc (); + + real_main (); + + return 0; +} |