xref: /haiku/src/system/libroot/libroot_init.c (revision fef6144999c2fa611f59ee6ffe6dd7999501385c)
1 /*
2  * Copyright 2003-2005, 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 
11 #include <string.h>
12 
13 
14 void initialize_before(image_id imageID, struct uspace_program_args const *args);
15 
16 char *__progname = NULL;
17 int __libc_argc;
18 char **__libc_argv;
19 
20 char _single_threaded = true;
21 	// determines if I/O locking needed; needed for BeOS compatibility
22 
23 thread_id __main_thread_id;
24 char **argv_save;
25 	// needed for BeOS compatibility - they are set in the startup code
26 	// (have a look at the glue/ directory)
27 
28 int _data_offset_main_;
29 	// this is obviously needed for R4.5 compatiblity
30 
31 
32 void
33 initialize_before(image_id imageID, struct uspace_program_args const *args)
34 {
35 	char *programPath = args->argv[0];
36 	if (programPath) {
37 		if ((__progname = strrchr(programPath, '/')) == NULL)
38 			__progname = programPath;
39 		else
40 			__progname++;
41 	}
42 
43 	__libc_argc = args->argc;
44 	__libc_argv = args->argv;
45 
46 	__init_time();
47 	__init_image(args);
48 	__init_dlfcn(args);
49 	__init_fork();
50 	__init_heap();
51 	__init_env(args);
52 }
53 
54 
55 void _init_c_library_(void);
56 void
57 _init_c_library_(void)
58 {
59 	// This function is called from the BeOS start_dyn.o - so it's called once
60 	// for every application that was compiled under BeOS.
61 	// Our libroot functions are already initialized above, so we don't have to
62 	// do anything here.
63 }
64 
65