From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- libgo/runtime/go-main.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 libgo/runtime/go-main.c (limited to 'libgo/runtime/go-main.c') diff --git a/libgo/runtime/go-main.c b/libgo/runtime/go-main.c new file mode 100644 index 000000000..a6dbf347f --- /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 +#include + +#ifdef HAVE_FPU_CONTROL_H +#include +#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; +} -- cgit v1.2.3