2020-01-18 05:38:21 -03:00
|
|
|
/*
|
2022-04-21 06:09:05 -03:00
|
|
|
* Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
|
2020-01-18 05:38:21 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 05:38:21 -03:00
|
|
|
*/
|
|
|
|
|
|
2020-01-09 04:36:32 -03:00
|
|
|
#include <AK/Types.h>
|
|
|
|
|
#include <assert.h>
|
2022-04-21 06:09:05 -03:00
|
|
|
#include <errno.h>
|
2020-08-11 20:58:50 -03:00
|
|
|
#include <sys/internals.h>
|
|
|
|
|
#include <unistd.h>
|
2020-01-09 04:36:32 -03:00
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
|
2020-10-10 11:48:27 -03:00
|
|
|
#ifdef NO_TLS
|
2022-04-21 06:09:05 -03:00
|
|
|
int errno_storage;
|
2020-10-10 11:48:27 -03:00
|
|
|
#else
|
2022-04-21 06:09:05 -03:00
|
|
|
__thread int errno_storage;
|
2020-10-10 11:48:27 -03:00
|
|
|
#endif
|
2020-01-09 04:36:32 -03:00
|
|
|
char** environ;
|
|
|
|
|
bool __environ_is_malloced;
|
2020-10-10 11:47:21 -03:00
|
|
|
bool __stdio_is_initialized;
|
2022-01-23 10:47:10 -03:00
|
|
|
bool s_global_initializers_ran;
|
2021-09-20 06:13:05 -03:00
|
|
|
void* __auxiliary_vector;
|
|
|
|
|
|
|
|
|
|
static void __auxiliary_vector_init();
|
2020-01-09 04:36:32 -03:00
|
|
|
|
2022-04-21 06:09:05 -03:00
|
|
|
int* __errno_location()
|
|
|
|
|
{
|
|
|
|
|
return &errno_storage;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-09 04:36:32 -03:00
|
|
|
void __libc_init()
|
|
|
|
|
{
|
2021-09-20 06:13:05 -03:00
|
|
|
__auxiliary_vector_init();
|
2020-01-09 04:36:32 -03:00
|
|
|
__malloc_init();
|
|
|
|
|
__stdio_init();
|
|
|
|
|
}
|
2021-09-20 06:13:05 -03:00
|
|
|
|
|
|
|
|
static void __auxiliary_vector_init()
|
|
|
|
|
{
|
|
|
|
|
char** env;
|
|
|
|
|
for (env = environ; *env; ++env) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
__auxiliary_vector = (void*)++env;
|
|
|
|
|
}
|
2020-01-09 04:36:32 -03:00
|
|
|
}
|