#include "common_header.h" #ifdef PYPY_STANDALONE #include "structdef.h" #include "forwarddecl.h" #include "preimpl.h" #include #include #include #include #include #include #include #include #include #include #if defined(MS_WINDOWS) # include # include # include # include typedef unsigned short ARGV_T; #else typedef char ARGV_T; #endif #ifdef RPY_WITH_GIL # include # include #endif #ifdef RPY_REVERSE_DEBUGGER # include #endif static char already_initialized_non_threadsafe; static void mark_initialized_now() { already_initialized_non_threadsafe = 1; } RPY_EXPORTED int rpython_startup_code(void) { if (already_initialized_non_threadsafe) return 67; #ifdef RPY_WITH_GIL RPython_ThreadLocals_ProgramInit(); RPyGilAcquire(); #endif RPython_StartupCode(); mark_initialized_now(); #ifdef RPY_WITH_GIL RPyGilRelease(); #endif return 0; } RPY_EXTERN int pypy_main_function(int argc, ARGV_T *argv[]) { char *errmsg; int i, exitcode; #ifdef MS_WINDOWS _setmode(0, _O_BINARY); _setmode(1, _O_BINARY); _setmode(2, _O_BINARY); #endif #ifdef RPY_WITH_GIL /* Note that the GIL's mutexes are not automatically made; if the program starts threads, it needs to call rgil.gil_allocate(). RPyGilAcquire() still works without that, but crash if it finds that it really needs to wait on a mutex. */ RPython_ThreadLocals_ProgramInit(); RPyGilAcquire(); #endif instrument_setup(); #ifdef RPY_REVERSE_DEBUGGER #ifdef MS_WINDOWS errmsg = "revdb not supported on windows" goto error; #endif rpy_reverse_db_setup(&argc, &argv); #endif #ifdef MS_WINDOWS /* Convert wchar_t argv into char */ char **converted_argv = malloc(sizeof(char*) * (argc + 1)); converted_argv[argc] = NULL; for (int i=0; i