libc.c 890 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2006-2018, 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 <stdio.h>
  11. #include <stdlib.h>
  12. #include <rtthread.h>
  13. #include "libc.h"
  14. #ifdef RT_USING_PTHREADS
  15. #include <pthread.h>
  16. #endif
  17. int libc_system_init(void)
  18. {
  19. #if defined(RT_USING_DFS) & defined(RT_USING_DFS_DEVFS)
  20. rt_device_t dev_console;
  21. dev_console = rt_console_get_device();
  22. if (dev_console)
  23. {
  24. #if defined(RT_USING_POSIX)
  25. libc_stdio_set_console(dev_console->parent.name, O_RDWR);
  26. #else
  27. libc_stdio_set_console(dev_console->parent.name, O_WRONLY);
  28. #endif
  29. }
  30. #endif
  31. #if defined RT_USING_PTHREADS && !defined RT_USING_COMPONENTS_INIT
  32. pthread_system_init();
  33. #endif
  34. return 0;
  35. }
  36. INIT_COMPONENT_EXPORT(libc_system_init);