2004-11-18 06:08:36 +03:00
|
|
|
/*
|
2009-11-26 20:00:09 +03:00
|
|
|
* Copyright 2003-2009, Axel Dörfler, axeld@pinc-software.de.
|
2004-11-18 06:08:36 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
2002-10-05 21:04:37 +04:00
|
|
|
|
2009-11-26 20:00:09 +03:00
|
|
|
|
2011-06-12 04:00:23 +04:00
|
|
|
#include <pthread.h>
|
2008-11-02 06:43:01 +03:00
|
|
|
#include <string.h>
|
2003-01-13 13:50:14 +03:00
|
|
|
|
2006-01-06 06:48:11 +03:00
|
|
|
#include <image.h>
|
2011-06-12 04:00:23 +04:00
|
|
|
|
2008-11-02 06:43:01 +03:00
|
|
|
#include <user_runtime.h>
|
2002-10-05 21:04:37 +04:00
|
|
|
|
2011-06-12 04:00:23 +04:00
|
|
|
#include <runtime_loader.h>
|
|
|
|
|
|
|
|
#include <fork.h>
|
|
|
|
#include <libroot_private.h>
|
|
|
|
#include <pthread_private.h>
|
|
|
|
|
2002-10-05 21:04:37 +04:00
|
|
|
|
2006-01-06 06:48:11 +03:00
|
|
|
void initialize_before(image_id imageID);
|
|
|
|
|
|
|
|
struct rld_export *__gRuntimeLoader = NULL;
|
|
|
|
// This little bugger is set to something meaningful by the runtime loader
|
|
|
|
// Ugly, eh?
|
2003-01-12 20:13:32 +03:00
|
|
|
|
2003-01-13 13:50:14 +03:00
|
|
|
char *__progname = NULL;
|
2005-02-02 07:36:16 +03:00
|
|
|
int __libc_argc;
|
|
|
|
char **__libc_argv;
|
2003-01-13 13:50:14 +03:00
|
|
|
|
2003-02-11 22:51:49 +03:00
|
|
|
char _single_threaded = true;
|
|
|
|
// determines if I/O locking needed; needed for BeOS compatibility
|
2004-07-05 22:47:54 +04:00
|
|
|
|
2003-01-13 13:50:14 +03:00
|
|
|
thread_id __main_thread_id;
|
|
|
|
char **argv_save;
|
2004-07-05 22:47:54 +04:00
|
|
|
// needed for BeOS compatibility - they are set in the startup code
|
|
|
|
// (have a look at the glue/ directory)
|
2003-01-13 13:50:14 +03:00
|
|
|
|
2005-03-23 16:22:42 +03:00
|
|
|
int _data_offset_main_;
|
|
|
|
// this is obviously needed for R4.5 compatiblity
|
|
|
|
|
2003-01-13 13:50:14 +03:00
|
|
|
|
2002-10-05 21:04:37 +04:00
|
|
|
void
|
2006-01-06 06:48:11 +03:00
|
|
|
initialize_before(image_id imageID)
|
2002-10-05 21:04:37 +04:00
|
|
|
{
|
2007-07-27 06:32:19 +04:00
|
|
|
char *programPath = __gRuntimeLoader->program_args->args[0];
|
2003-01-13 13:50:14 +03:00
|
|
|
if (programPath) {
|
|
|
|
if ((__progname = strrchr(programPath, '/')) == NULL)
|
|
|
|
__progname = programPath;
|
|
|
|
else
|
|
|
|
__progname++;
|
|
|
|
}
|
|
|
|
|
2007-07-27 06:32:19 +04:00
|
|
|
__libc_argc = __gRuntimeLoader->program_args->arg_count;
|
|
|
|
__libc_argv = __gRuntimeLoader->program_args->args;
|
2005-02-02 07:36:16 +03:00
|
|
|
|
2008-01-13 15:08:34 +03:00
|
|
|
__gRuntimeLoader->call_atexit_hooks_for_range
|
|
|
|
= _call_atexit_hooks_for_range;
|
|
|
|
|
2011-01-02 22:12:19 +03:00
|
|
|
if (__gRuntimeLoader->program_args->umask != (mode_t)-1)
|
|
|
|
umask(__gRuntimeLoader->program_args->umask);
|
|
|
|
|
2011-06-12 04:00:23 +04:00
|
|
|
pthread_self()->id = find_thread(NULL);
|
|
|
|
|
2004-11-18 06:08:36 +03:00
|
|
|
__init_time();
|
2005-03-23 04:47:21 +03:00
|
|
|
__init_heap();
|
2006-01-06 06:48:11 +03:00
|
|
|
__init_env(__gRuntimeLoader->program_args);
|
2011-02-15 20:54:24 +03:00
|
|
|
__init_heap_post_env();
|
2008-01-14 05:03:34 +03:00
|
|
|
__init_pwd_backend();
|
2005-03-11 01:54:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-01-13 13:50:14 +03:00
|
|
|
void _init_c_library_(void);
|
|
|
|
void
|
|
|
|
_init_c_library_(void)
|
|
|
|
{
|
|
|
|
// This function is called from the BeOS start_dyn.o - so it's called once
|
|
|
|
// for every application that was compiled under BeOS.
|
|
|
|
// Our libroot functions are already initialized above, so we don't have to
|
|
|
|
// do anything here.
|
2002-10-05 21:04:37 +04:00
|
|
|
}
|
|
|
|
|