mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:07:35 +00:00
LibC: Make it possible to use ASSERTs without initializing stdio
This commit is contained in:
parent
b1c1d7661f
commit
65ee2f07b7
4 changed files with 7 additions and 1 deletions
|
@ -27,15 +27,18 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <sys/internals.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
|
extern bool __stdio_is_initialized;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
void __assertion_failed(const char* msg)
|
void __assertion_failed(const char* msg)
|
||||||
{
|
{
|
||||||
dbgprintf("USERSPACE(%d) ASSERTION FAILED: %s\n", getpid(), msg);
|
dbgprintf("USERSPACE(%d) ASSERTION FAILED: %s\n", getpid(), msg);
|
||||||
fprintf(stderr, "ASSERTION FAILED: %s\n", msg);
|
if (__stdio_is_initialized)
|
||||||
|
fprintf(stderr, "ASSERTION FAILED: %s\n", msg);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -34,6 +34,7 @@ extern "C" {
|
||||||
__thread int errno;
|
__thread int errno;
|
||||||
char** environ;
|
char** environ;
|
||||||
bool __environ_is_malloced;
|
bool __environ_is_malloced;
|
||||||
|
bool __stdio_is_initialized;
|
||||||
|
|
||||||
void __libc_init()
|
void __libc_init()
|
||||||
{
|
{
|
||||||
|
|
|
@ -585,6 +585,7 @@ void __stdio_init()
|
||||||
new (stdout) FILE(1, O_WRONLY);
|
new (stdout) FILE(1, O_WRONLY);
|
||||||
new (stderr) FILE(2, O_WRONLY);
|
new (stderr) FILE(2, O_WRONLY);
|
||||||
stderr->setbuf(nullptr, _IONBF, 0);
|
stderr->setbuf(nullptr, _IONBF, 0);
|
||||||
|
__stdio_is_initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int setvbuf(FILE* stream, char* buf, int mode, size_t size)
|
int setvbuf(FILE* stream, char* buf, int mode, size_t size)
|
||||||
|
|
|
@ -37,6 +37,7 @@ extern void __malloc_init();
|
||||||
extern void __stdio_init();
|
extern void __stdio_init();
|
||||||
extern void _init();
|
extern void _init();
|
||||||
extern bool __environ_is_malloced;
|
extern bool __environ_is_malloced;
|
||||||
|
extern bool __stdio_is_initialized;
|
||||||
|
|
||||||
int __cxa_atexit(AtExitFunction exit_function, void* parameter, void* dso_handle);
|
int __cxa_atexit(AtExitFunction exit_function, void* parameter, void* dso_handle);
|
||||||
void __cxa_finalize(void* dso_handle);
|
void __cxa_finalize(void* dso_handle);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue