libc.c 745 B

12345678910111213141516171819202122232425262728293031323334
  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. void libc_system_init(const char* tty_name)
  8. {
  9. int fd;
  10. extern int pthread_system_init(void);
  11. #ifdef RT_USING_DFS
  12. #ifndef RT_USING_DFS_DEVFS
  13. #error Please enable devfs by defining RT_USING_DFS_DEVFS in rtconfig.h
  14. #endif
  15. /* init console device */
  16. rt_console_init(tty_name);
  17. /* open console as stdin/stdout/stderr */
  18. fd = open("/dev/console", O_RDONLY, 0); /* for stdin */
  19. fd = open("/dev/console", O_WRONLY, 0); /* for stdout */
  20. fd = open("/dev/console", O_WRONLY, 0); /* for stderr */
  21. #endif
  22. /* set PATH and HOME */
  23. putenv("PATH=/");
  24. putenv("HOME=/");
  25. #ifdef RT_USING_PTHREADS
  26. pthread_system_init();
  27. #endif
  28. }