1
0

stdlib.c 978 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #define ABORT_STATUS 2
  12. rt_inline void __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 == ABORT_STATUS) /* abort() */
  24. {
  25. rt_kprintf("thread:%s abort!\n", RT_NAME_MAX, self->name, status);
  26. }
  27. else /* exit() */
  28. {
  29. rt_kprintf("thread:%s exit:%d!\n", RT_NAME_MAX, self->name, status);
  30. }
  31. rt_thread_suspend(self);
  32. rt_schedule();
  33. }
  34. while(1); /* noreturn */
  35. }
  36. rt_inline void __abort__(void)
  37. {
  38. __exit__(ABORT_STATUS);
  39. }
  40. rt_inline int __system__(const char *string)
  41. {
  42. /* TODO */
  43. return 0;
  44. }