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