libc.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 _EXFUN(putenv,(char *__string));
  20. int libc_system_init(void)
  21. {
  22. #if defined(RT_USING_DFS) & defined(RT_USING_DFS_DEVFS) & defined(RT_USING_CONSOLE)
  23. rt_device_t dev_console;
  24. dev_console = rt_console_get_device();
  25. if (dev_console)
  26. {
  27. #if defined(RT_USING_POSIX)
  28. libc_stdio_set_console(dev_console->parent.name, O_RDWR);
  29. #else
  30. libc_stdio_set_console(dev_console->parent.name, O_WRONLY);
  31. #endif
  32. }
  33. /* set PATH and HOME */
  34. putenv("PATH=/bin");
  35. putenv("HOME=/home");
  36. #endif
  37. #if defined RT_USING_PTHREADS && !defined RT_USING_COMPONENTS_INIT
  38. pthread_system_init();
  39. #endif
  40. return 0;
  41. }
  42. INIT_COMPONENT_EXPORT(libc_system_init);