libc.c 807 B

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