newlib.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include <sys/lock.h>
  8. #include <sys/reent.h>
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. /* Global variables used by newlib in ROM
  13. Note that any of these symbols which are used by both ROM & IDF will have duplicate copies
  14. in each "side" of the memory. However they're all pointers, and the pointers will be to the same
  15. thing, so it's not a big memory waste and functionality is the same.
  16. Some variables which look like they should be here, but aren't:
  17. - __sf_fake_stdin, __sf_fake_stdout, __sf_fake_stderr - These are defined in ROM because ROM includes findfp.c,
  18. but only used if _REENT_INIT or _REENT_INIT_PTR are ever called and ROM doesn't use these macros anywhere unless
  19. printf() or similar is called without initializing reent first. ESP-IDF sets up its own minimal reent structures.
  20. - __lock___sinit_recursive_mutex, etc. - these are combined into common_recursive_mutex & common_mutex to save space
  21. */
  22. typedef struct {
  23. _LOCK_T common_recursive_mutex;
  24. _LOCK_T common_mutex;
  25. struct _reent *global_reent;
  26. } esp_rom_newlib_global_data_t;
  27. /* Called from IDF newlib component setup
  28. to initialize common data shared between ROM and IDF
  29. */
  30. void esp_rom_newlib_init_global_data(const esp_rom_newlib_global_data_t *data);
  31. #ifdef __cplusplus
  32. }
  33. #endif