1
0

libc.c 903 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. #ifdef RT_USING_DFS
  11. #include <dfs_posix.h>
  12. #ifdef RT_USING_DFS_DEVFS
  13. #include <devfs.h>
  14. #endif
  15. #endif
  16. void libc_system_init(const char* tty_name)
  17. {
  18. #ifdef RT_USING_DFS
  19. int fd;
  20. #ifndef RT_USING_DFS_DEVFS
  21. #error Please enable devfs by defining RT_USING_DFS_DEVFS in rtconfig.h
  22. #endif
  23. /* initialize console device */
  24. rt_console_init(tty_name);
  25. /* open console as stdin/stdout/stderr */
  26. fd = open("/dev/console", O_RDONLY, 0); /* for stdin */
  27. fd = open("/dev/console", O_WRONLY, 0); /* for stdout */
  28. fd = open("/dev/console", O_WRONLY, 0); /* for stderr */
  29. /* skip warning */
  30. fd = fd;
  31. #endif
  32. /* set PATH and HOME */
  33. putenv("PATH=/");
  34. putenv("HOME=/");
  35. #ifdef RT_USING_PTHREADS
  36. pthread_system_init();
  37. #endif
  38. }