From 5de854278915caa59b39ec2b91be3f140f73e77f Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Wed, 27 Oct 2004 22:07:00 +0000 Subject: [PATCH] Since the kernel links against libgcc.a and we use some C++ features that cause functions of libgcc.a to be included that use a couple of formerly undefined symbols (stderr, fprintf, abort, debugger) those had to be added to kernel_cpp.cpp. We don't build the kernel utils as static library anymore, since libgcc.a is listed at the end of the link command line and trying to change that would be a bit ugly. For C++ in the boot loader nothing changes. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9554 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/util/kernel_cpp.h | 7 ++++- src/kernel/Jamfile | 4 +-- src/kernel/core/util/Jamfile | 10 +++---- src/kernel/core/util/kernel_cpp.cpp | 38 +++++++++++++++++++++++- 4 files changed, 50 insertions(+), 9 deletions(-) diff --git a/headers/private/kernel/util/kernel_cpp.h b/headers/private/kernel/util/kernel_cpp.h index 4c59ebfb1e..eabc002fc3 100644 --- a/headers/private/kernel/util/kernel_cpp.h +++ b/headers/private/kernel/util/kernel_cpp.h @@ -71,10 +71,15 @@ operator delete[](void *ptr) throw () free(ptr); } -// we're using virtuals +// only needed in the boot loader +#ifndef _BOOT_MODE + extern "C" void __pure_virtual(); +#endif // #if _BOOT_MODE + #endif // #if _KERNEL_MODE + #endif // __cplusplus #endif /* KERNEL_CPP_H */ diff --git a/src/kernel/Jamfile b/src/kernel/Jamfile index a6116c3243..89e1020a92 100644 --- a/src/kernel/Jamfile +++ b/src/kernel/Jamfile @@ -54,11 +54,11 @@ KernelLd kernel : kernel_cache.o kernel_device_manager.o kernel_disk_device_manager.o + kernel_util.o libbus.a lib$(OBOS_ARCH).a libdrivers.a - libkernel_util.a linkhack.so @@ -83,11 +83,11 @@ KernelLd kernel.so : kernel_cache.o kernel_device_manager.o kernel_disk_device_manager.o + kernel_util.o libbus.a lib$(OBOS_ARCH).a libdrivers.a - libkernel_util.a linkhack.so diff --git a/src/kernel/core/util/Jamfile b/src/kernel/core/util/Jamfile index de910de520..2011fb05c8 100644 --- a/src/kernel/core/util/Jamfile +++ b/src/kernel/core/util/Jamfile @@ -1,8 +1,8 @@ SubDir OBOS_TOP src kernel core util ; -KernelStaticLibrary libkernel_util : - <$(SOURCE_GRIST)>list.c - <$(SOURCE_GRIST)>kernel_cpp.cpp - : - -fno-pic -Wno-unused -D_KERNEL_MODE +KernelMergeObject kernel_util.o : + list.c + kernel_cpp.cpp + + : -fno-pic -Wno-unused -D_KERNEL_MODE ; diff --git a/src/kernel/core/util/kernel_cpp.cpp b/src/kernel/core/util/kernel_cpp.cpp index 856a43b629..8d568c013a 100644 --- a/src/kernel/core/util/kernel_cpp.cpp +++ b/src/kernel/core/util/kernel_cpp.cpp @@ -4,7 +4,8 @@ ** This file may be used under the terms of the OpenBeOS License. */ -#if _KERNEL_MODE +// stripped down C++ support for the boot loader +#ifdef _BOOT_MODE #include "util/kernel_cpp.h" @@ -27,4 +28,39 @@ __cxa_pure_virtual() #endif + +// full C++ support in the kernel +#elif _KERNEL_MODE // #endif _BOOT_MODE + +#include + +#include + +#include "util/kernel_cpp.h" + +FILE *stderr = NULL; + +extern "C" +int +fprintf(FILE *f, const char *format, ...) +{ + // TODO: Introduce a vdprintf()... + dprintf("fprintf(`%s',...)\n", format); + return 0; +} + +extern "C" +void +abort() +{ + panic("abort() called!"); +} + +extern "C" +void +debugger(const char *message) +{ + kernel_debugger(message); +} + #endif // _#if KERNEL_MODE