syscalls.c 968 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-13 Meco Man implement exit() and abort()
  9. */
  10. #include <rtthread.h>
  11. void exit (int status)
  12. {
  13. rt_thread_t self = rt_thread_self();
  14. #ifdef RT_USING_MODULE
  15. if (dlmodule_self())
  16. {
  17. dlmodule_exit(status);
  18. }
  19. #endif
  20. if (self != RT_NULL)
  21. {
  22. rt_kprintf("thread:%-8.*s exit:%d!\n", RT_NAME_MAX, self->name, status);
  23. rt_thread_suspend(self);
  24. rt_schedule();
  25. }
  26. while(1); /* noreturn */
  27. }
  28. void abort(void)
  29. {
  30. rt_thread_t self = rt_thread_self();
  31. #ifdef RT_USING_MODULE
  32. if (dlmodule_self())
  33. {
  34. dlmodule_exit(-1);
  35. }
  36. #endif
  37. if (self != RT_NULL)
  38. {
  39. rt_kprintf("thread:%-8.*s abort!\n", RT_NAME_MAX, self->name);
  40. rt_thread_suspend(self);
  41. rt_schedule();
  42. }
  43. while(1); /* noreturn */
  44. }