libcinit.cpp 783 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright (c) 2018-2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <AK/Types.h>
  7. #include <assert.h>
  8. #include <errno.h>
  9. #include <sys/internals.h>
  10. #include <unistd.h>
  11. extern "C" {
  12. #ifdef NO_TLS
  13. int errno_storage;
  14. #else
  15. __thread int errno_storage;
  16. #endif
  17. char** environ;
  18. bool __environ_is_malloced;
  19. bool __stdio_is_initialized;
  20. bool s_global_initializers_ran;
  21. void* __auxiliary_vector;
  22. static void __auxiliary_vector_init();
  23. int* __errno_location()
  24. {
  25. return &errno_storage;
  26. }
  27. void __libc_init()
  28. {
  29. __auxiliary_vector_init();
  30. __malloc_init();
  31. __stdio_init();
  32. }
  33. static void __auxiliary_vector_init()
  34. {
  35. char** env;
  36. for (env = environ; *env; ++env) {
  37. }
  38. __auxiliary_vector = (void*)++env;
  39. }
  40. }