1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 07:58:11 +00:00

LibC: Avoid ninja-imports of system functions

This adds a new header <sys/internals.h>, which provides access to LibC internals.
This is in the interest of type-checking LibC itself, as well as enabling less-hacky
access for uses like LinkDemo.

And, of course, this progresses LibC towards building cleanly with -Wmissing-declarations.
This commit is contained in:
Ben Wiederhake 2020-08-12 01:58:50 +02:00 committed by Andreas Kling
parent 9221a25bbc
commit 9d2d97a059
6 changed files with 49 additions and 14 deletions

View file

@ -27,19 +27,17 @@
#include <AK/String.h>
#include <assert.h>
#include <stdio.h>
#include <sys/internals.h>
char* __static_environ[] = { nullptr }; // We don't get the environment without some libc workarounds..
// FIXME: Because we need to call printf, and we don't have access to the stout file descriptor
// from the main executable. We need to call __libc_init....
extern "C" void __libc_init();
extern "C" bool __environ_is_malloced;
class Global {
public:
Global(int i)
: m_i(i)
{
// FIXME: Because we need to call printf, and we don't have access to the stdout
// file descriptor from the main executable, we need to initialize LibC ourself.
__environ_is_malloced = false;
environ = __static_environ;
__libc_init();