libc.c 885 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. int libc_system_init(void)
  17. {
  18. #ifdef RT_USING_DFS
  19. struct rt_device *console_dev;
  20. #ifndef RT_USING_DFS_DEVFS
  21. #error Please enable devfs by defining RT_USING_DFS_DEVFS in rtconfig.h
  22. #endif
  23. console_dev = rt_console_get_device();
  24. if (console_dev)
  25. {
  26. /* initialize console device */
  27. rt_console_init(console_dev->parent.name);
  28. }
  29. #endif
  30. /* set PATH and HOME */
  31. putenv("PATH=/bin");
  32. putenv("HOME=/home");
  33. #if defined RT_USING_PTHREADS && !defined RT_USING_COMPONENTS_INIT
  34. pthread_system_init();
  35. #endif
  36. return 0;
  37. }
  38. INIT_COMPONENT_EXPORT(libc_system_init);