stdlib.c 921 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2021-02-15 Meco Man first version
  9. */
  10. #include <rtthread.h>
  11. #define DBG_TAG "stdlib"
  12. #define DBG_LVL DBG_INFO
  13. #include <rtdbg.h>
  14. void __rt_libc_exit(int status)
  15. {
  16. rt_thread_t self = rt_thread_self();
  17. if (self != RT_NULL)
  18. {
  19. #ifdef RT_USING_PTHREADS
  20. extern void pthread_exit(void *value);
  21. pthread_exit((void *)status);
  22. #else
  23. LOG_E("thread:%s exit:%d!", self->name, status);
  24. rt_thread_control(self, RT_THREAD_CTRL_CLOSE, RT_NULL);
  25. #endif
  26. }
  27. }
  28. #ifdef RT_USING_MSH
  29. int system(const char *command)
  30. {
  31. extern int msh_exec(char *cmd, rt_size_t length);
  32. if (command)
  33. {
  34. msh_exec((char *)command, rt_strlen(command));
  35. }
  36. return 0;
  37. }
  38. RTM_EXPORT(system);
  39. #endif /* RT_USING_MSH */