stdlib.c 901 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (c) 2006-2018, 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. #include <stdlib.h>
  12. void __rt_libc_exit(int status)
  13. {
  14. rt_thread_t self = rt_thread_self();
  15. #ifdef RT_USING_MODULE
  16. if (dlmodule_self())
  17. {
  18. dlmodule_exit(status);
  19. }
  20. #endif
  21. if (self != RT_NULL)
  22. {
  23. if(status == EXIT_FAILURE) /* abort() */
  24. {
  25. rt_kprintf("thread:%s abort!\n", self->name);
  26. }
  27. else /* exit() */
  28. {
  29. rt_kprintf("thread:%s exit:%d!\n", self->name, status);
  30. }
  31. rt_thread_suspend(self);
  32. rt_schedule();
  33. }
  34. }
  35. void __rt_libc_abort(void)
  36. {
  37. __rt_libc_exit(EXIT_FAILURE);
  38. }
  39. int __rt_libc_system(const char *string)
  40. {
  41. /* TODO */
  42. return 0;
  43. }