syscalls.c 946 B

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