stdlib.c 910 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. 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);
  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. }
  35. void __abort__(void)
  36. {
  37. __exit__(ABORT_STATUS);
  38. }
  39. int __system__(const char *string)
  40. {
  41. /* TODO */
  42. return 0;
  43. }