From dd6f547c6615ea67db66ecdd97a0d18ae9432ba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 13 Jan 2003 10:50:14 +0000 Subject: [PATCH] Moved "__progname" from startup code to libroot_init.c (because BeOS start_dyn.o doesn't export it), initialization has also moved to initialize_before(). Added BeOS compatibility stubs to allow execution of BeOS native apps - added comments to every function; some of them might be removed later on again. Also moved "environ" to posix/stdlib/env.c for the same reason. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2446 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/libroot/libroot_init.c | 60 ++++++++++++++++++++++++--- src/kernel/libroot/os/image.c | 10 +++++ src/kernel/libroot/os/thread.c | 8 ++++ src/kernel/libroot/posix/stdlib/env.c | 3 ++ 4 files changed, 76 insertions(+), 5 deletions(-) diff --git a/src/kernel/libroot/libroot_init.c b/src/kernel/libroot/libroot_init.c index ed5bb9f125..fae0c1ec03 100644 --- a/src/kernel/libroot/libroot_init.c +++ b/src/kernel/libroot/libroot_init.c @@ -1,21 +1,71 @@ /* -** Copyright 2002, Manuel J. Petit. All rights reserved. -** Distributed under the terms of the NewOS License. +** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. */ + #include +#include -extern void __init__dlfcn(struct uspace_program_args const *args); extern void __init__image(struct uspace_program_args const *args); - +extern void __init__dlfcn(struct uspace_program_args const *args); void initialize_before(image_id imageID, struct uspace_program_args const *args); +char *__progname = NULL; + +thread_id __main_thread_id; +char **argv_save; + // needed for BeOS compatibility - they get set in the original + // BeOS startup code, but they won't be initialized when the + // OpenBeOS startup code is used. + + +// ToDo: these functions are defined in libgcc - this one is included in +// libroot.so in BeOS, but we probably don't want to do that. +// Since we don't yet have libgcc at all, it's defined here for now +// so that BeOS executables will find them. +// Remove them later! + + +void __deregister_frame_info(void); +void +__deregister_frame_info(void) +{ +} + + +void __register_frame_info(void); +void +__register_frame_info(void) +{ +} + + void initialize_before(image_id imageID, struct uspace_program_args const *args) { - __init__dlfcn(args); + char *programPath = args->argv[0]; + if (programPath) { + if ((__progname = strrchr(programPath, '/')) == NULL) + __progname = programPath; + else + __progname++; + } + __init__image(args); + __init__dlfcn(args); +} + + +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. } diff --git a/src/kernel/libroot/os/image.c b/src/kernel/libroot/os/image.c index a9d6bfd775..3768349b54 100644 --- a/src/kernel/libroot/os/image.c +++ b/src/kernel/libroot/os/image.c @@ -64,3 +64,13 @@ __init__image(struct uspace_program_args const *args) { gRuntimeLinker = args->rld_export; } + + +void _call_init_routines_(void); +void +_call_init_routines_(void) +{ + // This is called by the original BeOS startup code. + // We don't need it, because our loader already does the job, right? +} + diff --git a/src/kernel/libroot/os/thread.c b/src/kernel/libroot/os/thread.c index 58db0a2cb1..ae05f0408a 100644 --- a/src/kernel/libroot/os/thread.c +++ b/src/kernel/libroot/os/thread.c @@ -146,3 +146,11 @@ snooze_until(bigtime_t time, int timeBase) } +void _thread_do_exit_notification(void); +void +_thread_do_exit_notification(void) +{ + // this is called from the original BeOS startup code + // has probably to do with the on_exit stuff. +} + diff --git a/src/kernel/libroot/posix/stdlib/env.c b/src/kernel/libroot/posix/stdlib/env.c index d0b2de2564..f206b36beb 100644 --- a/src/kernel/libroot/posix/stdlib/env.c +++ b/src/kernel/libroot/posix/stdlib/env.c @@ -6,6 +6,9 @@ #include +char **environ = NULL; + + int setenv(const char *name, const char *value, int overwrite) { return sys_setenv(name, value, overwrite);