libc.c 868 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2017/10/15 bernard the first version
  9. */
  10. #include <fcntl.h>
  11. #include <rtthread.h>
  12. #include "libc.h"
  13. #ifdef RT_USING_PTHREADS
  14. #include <pthread.h>
  15. #endif
  16. int libc_system_init(void)
  17. {
  18. #if defined(RT_USING_DFS) & defined(RT_USING_DFS_DEVFS)
  19. rt_device_t dev_console;
  20. dev_console = rt_console_get_device();
  21. if (dev_console)
  22. {
  23. #if defined(RT_USING_POSIX)
  24. libc_stdio_set_console(dev_console->parent.name, O_RDWR);
  25. #else
  26. libc_stdio_set_console(dev_console->parent.name, O_WRONLY);
  27. #endif
  28. }
  29. #endif
  30. #if defined RT_USING_PTHREADS && !defined RT_USING_COMPONENTS_INIT
  31. pthread_system_init();
  32. #endif
  33. return 0;
  34. }
  35. INIT_COMPONENT_EXPORT(libc_system_init);