mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-12-26 17:18:24 +00:00
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user