libcinit.cpp 751 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. void* __auxiliary_vector;
  21. static void __auxiliary_vector_init();
  22. int* __errno_location()
  23. {
  24. return &errno_storage;
  25. }
  26. void __libc_init()
  27. {
  28. __auxiliary_vector_init();
  29. __malloc_init();
  30. __stdio_init();
  31. }
  32. static void __auxiliary_vector_init()
  33. {
  34. char** env;
  35. for (env = environ; *env; ++env) {
  36. }
  37. __auxiliary_vector = (void*)++env;
  38. }
  39. }