libc.c 733 B

1234567891011121314151617181920212223242526272829303132333435
  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 <rtthread.h>
  11. #include <fcntl.h>
  12. #include "libc.h"
  13. #ifdef RT_USING_PTHREADS
  14. #include <pthread.h>
  15. #endif
  16. int libc_system_init(void)
  17. {
  18. #ifdef RT_USING_POSIX
  19. rt_device_t dev_console;
  20. dev_console = rt_console_get_device();
  21. if (dev_console)
  22. {
  23. libc_stdio_set_console(dev_console->parent.name, O_RDWR);
  24. }
  25. #endif /* RT_USING_POSIX */
  26. #if defined RT_USING_PTHREADS && !defined RT_USING_COMPONENTS_INIT
  27. pthread_system_init();
  28. #endif
  29. return 0;
  30. }
  31. INIT_COMPONENT_EXPORT(libc_system_init);