1 /* 2 * Copyright 2003-2006, Axel Dörfler, axeld@pinc-software.de. 3 * Distributed under the terms of the MIT License. 4 */ 5 6 7 #include <libroot_private.h> 8 #include <user_runtime.h> 9 #include <fork.h> 10 #include <image.h> 11 12 #include <string.h> 13 14 15 void initialize_before(image_id imageID); 16 17 struct rld_export *__gRuntimeLoader = NULL; 18 // This little bugger is set to something meaningful by the runtime loader 19 // Ugly, eh? 20 21 char *__progname = NULL; 22 int __libc_argc; 23 char **__libc_argv; 24 25 char _single_threaded = true; 26 // determines if I/O locking needed; needed for BeOS compatibility 27 28 thread_id __main_thread_id; 29 char **argv_save; 30 // needed for BeOS compatibility - they are set in the startup code 31 // (have a look at the glue/ directory) 32 33 int _data_offset_main_; 34 // this is obviously needed for R4.5 compatiblity 35 36 37 void 38 initialize_before(image_id imageID) 39 { 40 char *programPath = __gRuntimeLoader->program_args->argv[0]; 41 if (programPath) { 42 if ((__progname = strrchr(programPath, '/')) == NULL) 43 __progname = programPath; 44 else 45 __progname++; 46 } 47 48 __libc_argc = __gRuntimeLoader->program_args->argc; 49 __libc_argv = __gRuntimeLoader->program_args->argv; 50 51 __init_time(); 52 __init_fork(); 53 __init_heap(); 54 __init_env(__gRuntimeLoader->program_args); 55 } 56 57 58 void _init_c_library_(void); 59 void 60 _init_c_library_(void) 61 { 62 // This function is called from the BeOS start_dyn.o - so it's called once 63 // for every application that was compiled under BeOS. 64 // Our libroot functions are already initialized above, so we don't have to 65 // do anything here. 66 } 67 68