| 1 |
/* go-main.c -- the main function for a Go program. |
| 2 |
|
| 3 |
Copyright 2009 The Go Authors. All rights reserved. |
| 4 |
Use of this source code is governed by a BSD-style |
| 5 |
license that can be found in the LICENSE file. */ |
| 6 |
|
| 7 |
#include "config.h" |
| 8 |
|
| 9 |
#include <stdlib.h> |
| 10 |
#include <time.h> |
| 11 |
#include <unistd.h> |
| 12 |
|
| 13 |
#ifdef HAVE_FPU_CONTROL_H |
| 14 |
#include <fpu_control.h> |
| 15 |
#endif |
| 16 |
|
| 17 |
#include "runtime.h" |
| 18 |
#include "array.h" |
| 19 |
#include "arch.h" |
| 20 |
|
| 21 |
#undef int |
| 22 |
#undef char |
| 23 |
#undef unsigned |
| 24 |
|
| 25 |
/* The main function for a Go program. This records the command line |
| 26 |
parameters, calls the real main function, and returns a zero status |
| 27 |
if the real main function returns. */ |
| 28 |
|
| 29 |
extern char **environ; |
| 30 |
|
| 31 |
/* A copy of _end that a shared library can reasonably refer to. */ |
| 32 |
uintptr __go_end; |
| 33 |
|
| 34 |
extern byte _end[]; |
| 35 |
|
| 36 |
/* The main function. */ |
| 37 |
|
| 38 |
int |
| 39 |
main (int argc, char **argv) |
| 40 |
{ |
| 41 |
runtime_isarchive = false; |
| 42 |
|
| 43 |
if (runtime_isstarted) |
| 44 |
return 0; |
| 45 |
runtime_isstarted = true; |
| 46 |
|
| 47 |
if (runtime_iscgo) |
| 48 |
setIsCgo (); |
| 49 |
|
| 50 |
__go_end = (uintptr)_end; |
| 51 |
runtime_ginit (); |
| 52 |
runtime_cpuinit (); |
| 53 |
runtime_check (); |
| 54 |
runtime_args (argc, (byte **) argv); |
| 55 |
runtime_osinit (); |
| 56 |
runtime_schedinit (); |
| 57 |
__go_go ((uintptr)(runtime_main), NULL); |
| 58 |
runtime_mstart (runtime_m ()); |
| 59 |
abort (); |
| 60 |
} |