2 * Copyright 2003-2007, Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Axel Dörfler, axeld@pinc-software.de.
7 * Ingo Weinhold, bonefish@users.sf.net.
13 #include "util/kernel_cpp.h"
16 # include <boot/platform.h>
18 # include <KernelExport.h>
24 # define dprintf printf
25 # define kernel_debugger printf
29 // Always define the symbols needed when not linking against libgcc.a --
30 // we simply override them.
32 // ... it doesn't seem to work with this symbol at least.
35 const std::nothrow_t
std::nothrow
= {};
37 const nothrow_t
std::nothrow
= {};
41 const mynothrow_t mynothrow
= {};
48 panic("pure virtual function call\n");
56 panic("pure virtual function call\n");
61 __cxa_atexit(void (*hook
)(void*), void* data
, void* dsoHandle
)
68 __cxa_finalize(void* dsoHandle
)
74 // full C++ support in the kernel
75 #if (defined(_KERNEL_MODE) || defined(_LOADER_MODE))
77 operator new(size_t size
) throw (std::bad_alloc
)
79 // we don't actually throw any exceptions, but we have to
80 // keep the prototype as specified in <new>, or else GCC 3
87 operator new[](size_t size
) throw (std::bad_alloc
)
94 operator new(size_t size
, const std::nothrow_t
&) throw ()
101 operator new[](size_t size
, const std::nothrow_t
&) throw ()
108 operator new(size_t size
, const mynothrow_t
&) throw ()
115 operator new[](size_t size
, const mynothrow_t
&) throw ()
122 operator delete(void *ptr
) throw ()
129 operator delete[](void *ptr
) throw ()
140 fprintf(FILE *f
, const char *format
, ...)
142 // TODO: Introduce a vdprintf()...
143 dprintf("fprintf(`%s',...)\n", format
);
149 fwrite(const void *buffer
, size_t size
, size_t numItems
, FILE *stream
)
151 dprintf("%.*s", int(size
* numItems
), (char*)buffer
);
157 fputs(const char *string
, FILE *stream
)
159 dprintf("%s", string
);
165 fputc(int c
, FILE *stream
)
174 printf(const char *format
, ...)
176 // TODO: Introduce a vdprintf()...
177 dprintf("printf(`%s',...)\n", format
);
180 #endif // #ifndef _LOADER_MODE
184 puts(const char *string
)
186 return fputs(string
, NULL
);
189 #endif // #ifndef _BOOT_MODE
195 _Unwind_DeleteException()
197 panic("_Unwind_DeleteException");
204 panic("_Unwind_Find_FDE");
210 _Unwind_GetDataRelBase()
212 panic("_Unwind_GetDataRelBase");
219 panic("_Unwind_GetGR");
226 panic("_Unwind_GetIP");
233 panic("_Unwind_GetIPInfo");
238 _Unwind_GetLanguageSpecificData()
240 panic("_Unwind_GetLanguageSpecificData");
245 _Unwind_GetRegionStart()
247 panic("_Unwind_GetRegionStart");
252 _Unwind_GetTextRelBase()
254 panic("_Unwind_GetTextRelBase");
259 _Unwind_RaiseException()
261 panic("_Unwind_RaiseException");
268 panic("_Unwind_Resume");
273 _Unwind_Resume_or_Rethrow()
275 panic("_Unwind_Resume_or_Rethrow");
282 panic("_Unwind_SetGR");
289 panic("_Unwind_SetIP");
294 __deregister_frame_info()
296 panic("__deregister_frame_info");
301 __register_frame_info()
303 panic("__register_frame_info");
308 __aeabi_unwind_cpp_pr0(void)
310 panic("__aeabi_unwind_cpp_pr0");
314 __aeabi_unwind_cpp_pr1(void)
316 panic("__aeabi_unwind_cpp_pr1");
320 __aeabi_unwind_cpp_pr2(void)
322 panic("__aeabi_unwind_cpp_pr2");
326 _Unwind_Complete(void)
328 panic("_Unwind_Complete");
332 _Unwind_VRS_Set(void)
334 panic("_Unwind_VRS_Set");
338 _Unwind_VRS_Get(void)
340 panic("_Unwind_VRS_Get");
344 __gnu_unwind_frame(void)
346 panic("__gnu_unwind_frame");
349 #endif // __GNUC__ >= 4
355 panic("abort() called!");
363 debugger(const char *message
)
365 kernel_debugger(message
);
368 #endif // #ifndef _BOOT_MODE
370 #endif // #if (defined(_KERNEL_MODE) || defined(_LOADER_MODE))
377 panic("exit() called with status code = %d!", status
);