2010-12-03 05:34:57 +01:00
|
|
|
/* 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>
|
2011-11-28 06:45:49 +01:00
|
|
|
#include <unistd.h>
|
2010-12-03 05:34:57 +01:00
|
|
|
|
|
|
|
#ifdef HAVE_FPU_CONTROL_H
|
|
|
|
#include <fpu_control.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "go-alloc.h"
|
|
|
|
#include "array.h"
|
|
|
|
#include "go-string.h"
|
|
|
|
|
|
|
|
#include "runtime.h"
|
2011-10-27 01:57:58 +02:00
|
|
|
#include "arch.h"
|
2010-12-03 05:34:57 +01:00
|
|
|
#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;
|
|
|
|
|
2011-12-02 20:34:41 +01:00
|
|
|
extern void runtime_main (void);
|
2011-11-28 06:45:49 +01:00
|
|
|
static void mainstart (void *);
|
|
|
|
|
2010-12-03 05:34:57 +01:00
|
|
|
/* The main function. */
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
2011-11-28 06:45:49 +01:00
|
|
|
runtime_initsig (0);
|
2011-11-14 23:26:45 +01:00
|
|
|
runtime_args (argc, (byte **) argv);
|
2011-11-28 06:45:49 +01:00
|
|
|
runtime_osinit ();
|
|
|
|
runtime_schedinit ();
|
|
|
|
__go_go (mainstart, NULL);
|
|
|
|
runtime_mstart (runtime_m ());
|
|
|
|
abort ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
mainstart (void *arg __attribute__ ((unused)))
|
|
|
|
{
|
2011-12-02 20:34:41 +01:00
|
|
|
runtime_main ();
|
2010-12-03 05:34:57 +01:00
|
|
|
}
|