1
0

libc.c 760 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include <rtthread.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <fcntl.h>
  5. #include <sys/time.h>
  6. #include "libc.h"
  7. #ifdef RT_USING_PTHREADS
  8. #include <pthread.h>
  9. #endif
  10. void libc_system_init(const char* tty_name)
  11. {
  12. #ifdef RT_USING_DFS
  13. int fd;
  14. #ifndef RT_USING_DFS_DEVFS
  15. #error Please enable devfs by defining RT_USING_DFS_DEVFS in rtconfig.h
  16. #endif
  17. /* init console device */
  18. rt_console_init(tty_name);
  19. /* open console as stdin/stdout/stderr */
  20. fd = open("/dev/console", O_RDONLY, 0); /* for stdin */
  21. fd = open("/dev/console", O_WRONLY, 0); /* for stdout */
  22. fd = open("/dev/console", O_WRONLY, 0); /* for stderr */
  23. #endif
  24. /* set PATH and HOME */
  25. putenv("PATH=/");
  26. putenv("HOME=/");
  27. #ifdef RT_USING_PTHREADS
  28. pthread_system_init();
  29. #endif
  30. }