File tree Expand file tree Collapse file tree 4 files changed +11
-28
lines changed
components/libc/compilers Expand file tree Collapse file tree 4 files changed +11
-28
lines changed Original file line number Diff line number Diff line change @@ -256,6 +256,7 @@ void _ttywrch(int ch)
256256#endif
257257}
258258
259+ /* for exit() and abort() */
259260RT_WEAK void _sys_exit (int return_code )
260261{
261262 extern void __rt_libc_exit (int status );
Original file line number Diff line number Diff line change 99 */
1010
1111#include <rtthread.h>
12- #include <stdlib.h>
1312
1413void __rt_libc_exit (int status )
1514{
@@ -24,24 +23,12 @@ void __rt_libc_exit(int status)
2423
2524 if (self != RT_NULL )
2625 {
27- if (status == EXIT_FAILURE ) /* abort() */
28- {
29- rt_kprintf ("thread:%s abort!\n" , self -> name );
30- }
31- else /* exit() */
32- {
33- rt_kprintf ("thread:%s exit:%d!\n" , self -> name , status );
34- }
26+ rt_kprintf ("thread:%s exit:%d!\n" , self -> name , status );
3527 rt_thread_suspend (self );
3628 rt_schedule ();
3729 }
3830}
3931
40- void __rt_libc_abort (void )
41- {
42- __rt_libc_exit (EXIT_FAILURE );
43- }
44-
4532int __rt_libc_system (const char * string )
4633{
4734 /* TODO */
Original file line number Diff line number Diff line change 66 * Change Logs:
77 * Date Author Notes
88 * 2021-02-13 Meco Man implement exit() and abort()
9+ * 2021-02-20 Meco Man add system()
910 */
1011#include <rtthread.h>
1112
12- void exit (int status )
13+ /* for exit() and abort() */
14+ void __exit (int status )
1315{
1416 extern void __rt_libc_exit (int status );
1517 __rt_libc_exit (status );
1618 while (1 );
1719}
1820
19- void abort ( void )
21+ int system ( const char * string )
2022{
21- extern void __rt_libc_abort (void );
22- __rt_libc_abort ();
23- while (1 );
23+ extern int __rt_libc_system (const char * string );
24+ return __rt_libc_system (string );
2425}
Original file line number Diff line number Diff line change @@ -283,8 +283,9 @@ _free_r (struct _reent *ptr, void *addr)
283283 rt_free (addr );
284284}
285285
286- void
287- exit (int status )
286+ /* for exit() and abort() */
287+ __attribute__ ((noreturn )) void
288+ _exit (int status )
288289{
289290 extern void __rt_libc_exit (int status );
290291 __rt_libc_exit (status );
@@ -303,13 +304,6 @@ void __libc_init_array(void)
303304 /* we not use __libc init_aray to initialize C++ objects */
304305}
305306
306- void abort (void )
307- {
308- extern void __rt_libc_abort (void );
309- __rt_libc_abort ();
310- while (1 );
311- }
312-
313307uid_t getuid (void )
314308{
315309 return 0 ;
You can’t perform that action at this time.
0 commit comments