libc.c 750 B

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