未验证 提交 4094b0e3 编写于 作者: B Bernard Xiong 提交者: GitHub

Merge pull request #4358 from mysterywolf/master

[libc] 优化abort函数
......@@ -256,6 +256,7 @@ void _ttywrch(int ch)
#endif
}
/* for exit() and abort() */
RT_WEAK void _sys_exit(int return_code)
{
extern void __rt_libc_exit(int status);
......
......@@ -9,7 +9,6 @@
*/
#include <rtthread.h>
#include <stdlib.h>
void __rt_libc_exit(int status)
{
......@@ -24,24 +23,12 @@ void __rt_libc_exit(int status)
if (self != RT_NULL)
{
if(status == EXIT_FAILURE) /* abort() */
{
rt_kprintf("thread:%s abort!\n", self->name);
}
else /* exit() */
{
rt_kprintf("thread:%s exit:%d!\n", self->name, status);
}
rt_kprintf("thread:%s exit:%d!\n", self->name, status);
rt_thread_suspend(self);
rt_schedule();
}
}
void __rt_libc_abort(void)
{
__rt_libc_exit(EXIT_FAILURE);
}
int __rt_libc_system(const char *string)
{
/* TODO */
......
......@@ -6,19 +6,20 @@
* Change Logs:
* Date Author Notes
* 2021-02-13 Meco Man implement exit() and abort()
* 2021-02-20 Meco Man add system()
*/
#include <rtthread.h>
void exit (int status)
/* for exit() and abort() */
void __exit (int status)
{
extern void __rt_libc_exit(int status);
__rt_libc_exit(status);
while(1);
}
void abort(void)
int system(const char * string)
{
extern void __rt_libc_abort(void);
__rt_libc_abort();
while(1);
extern int __rt_libc_system(const char *string);
return __rt_libc_system(string);
}
......@@ -283,8 +283,9 @@ _free_r (struct _reent *ptr, void *addr)
rt_free (addr);
}
void
exit (int status)
/* for exit() and abort() */
__attribute__ ((noreturn)) void
_exit (int status)
{
extern void __rt_libc_exit(int status);
__rt_libc_exit(status);
......@@ -303,13 +304,6 @@ void __libc_init_array(void)
/* we not use __libc init_aray to initialize C++ objects */
}
void abort(void)
{
extern void __rt_libc_abort(void);
__rt_libc_abort();
while(1);
}
uid_t getuid(void)
{
return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册