File tree Expand file tree Collapse file tree 5 files changed +72
-93
lines changed
components/libc/compilers Expand file tree Collapse file tree 5 files changed +72
-93
lines changed Original file line number Diff line number Diff line change @@ -258,23 +258,9 @@ void _ttywrch(int ch)
258258
259259RT_WEAK void _sys_exit (int return_code )
260260{
261- rt_thread_t self = rt_thread_self ();
262-
263- #ifdef RT_USING_MODULE
264- if (dlmodule_self ())
265- {
266- dlmodule_exit (return_code );
267- }
268- #endif
269-
270- if (self != RT_NULL )
271- {
272- rt_kprintf ("thread:%-8.*s exit:%d!\n" , RT_NAME_MAX , self -> name , return_code );
273- rt_thread_suspend (self );
274- rt_schedule ();
275- }
276-
277- while (1 ); /* noreturn */
261+ extern void __rt_libc_exit (int status );
262+ __rt_libc_exit (return_code );
263+ while (1 );
278264}
279265
280266/**
@@ -320,8 +306,8 @@ int remove(const char *filename)
320306#else
321307int system (const char * string )
322308{
323- RT_ASSERT ( 0 );
324- for (;; );
309+ extern int __rt_libc_system ( const char * string );
310+ return __rt_libc_system ( string );
325311}
326312#endif
327313
Original file line number Diff line number Diff line change @@ -8,13 +8,13 @@ group = []
88CPPPATH = [cwd ]
99
1010if GetDepend ('RT_USING_LIBC' ):
11- src += Glob ('*.c' )
11+ src += Glob ('*.c' )
1212else :
13- if GetDepend ('RT_LIBC_USING_TIME' ) and not GetDepend ('RT_USING_MINILIBC' ):
14- src += ['time.c' ]
13+ if GetDepend ('RT_LIBC_USING_TIME' ) and not GetDepend ('RT_USING_MINILIBC' ):
14+ src += ['time.c' ]
1515
1616if GetDepend ('RT_USING_POSIX' ) == False :
17- SrcRemove (src , ['unistd.c' ])
17+ SrcRemove (src , ['unistd.c' ])
1818
1919if rtconfig .CROSS_TOOL == 'keil' :
2020 CPPDEFINES = ['__CLK_TCK=RT_TICK_PER_SECOND' ]
Original file line number Diff line number Diff line change 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+
11+ #include <rtthread.h>
12+ #include <stdlib.h>
13+
14+ void __rt_libc_exit (int status )
15+ {
16+ rt_thread_t self = rt_thread_self ();
17+
18+ #ifdef RT_USING_MODULE
19+ if (dlmodule_self ())
20+ {
21+ dlmodule_exit (status );
22+ }
23+ #endif
24+
25+ if (self != RT_NULL )
26+ {
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+ }
35+ rt_thread_suspend (self );
36+ rt_schedule ();
37+ }
38+ }
39+
40+ void __rt_libc_abort (void )
41+ {
42+ __rt_libc_exit (EXIT_FAILURE );
43+ }
44+
45+ int __rt_libc_system (const char * string )
46+ {
47+ /* TODO */
48+ return 0 ;
49+ }
Original file line number Diff line number Diff line change 1111
1212void exit (int status )
1313{
14- rt_thread_t self = rt_thread_self ();
15-
16- #ifdef RT_USING_MODULE
17- if (dlmodule_self ())
18- {
19- dlmodule_exit (status );
20- }
21- #endif
22-
23- if (self != RT_NULL )
24- {
25- rt_kprintf ("thread:%-8.*s exit:%d!\n" , RT_NAME_MAX , self -> name , status );
26- rt_thread_suspend (self );
27- rt_schedule ();
28- }
29-
30- while (1 ); /* noreturn */
14+ extern void __rt_libc_exit (int status );
15+ __rt_libc_exit (status );
16+ while (1 );
3117}
3218
3319void abort (void )
3420{
35- rt_thread_t self = rt_thread_self ();
36-
37- #ifdef RT_USING_MODULE
38- if (dlmodule_self ())
39- {
40- dlmodule_exit (-1 );
41- }
42- #endif
43-
44- if (self != RT_NULL )
45- {
46- rt_kprintf ("thread:%-8.*s abort!\n" , RT_NAME_MAX , self -> name );
47- rt_thread_suspend (self );
48- rt_schedule ();
49- }
50-
51- while (1 ); /* noreturn */
21+ extern void __rt_libc_abort (void );
22+ __rt_libc_abort ();
23+ while (1 );
5224}
Original file line number Diff line number Diff line change @@ -286,30 +286,16 @@ _free_r (struct _reent *ptr, void *addr)
286286void
287287exit (int status )
288288{
289- rt_thread_t self = rt_thread_self ();
290-
291- #ifdef RT_USING_MODULE
292- if (dlmodule_self ())
293- {
294- dlmodule_exit (status );
295- }
296- #endif
297-
298- if (self != RT_NULL )
299- {
300- rt_kprintf ("thread:%-8.*s exit:%d!\n" , RT_NAME_MAX , self -> name , status );
301- rt_thread_suspend (self );
302- rt_schedule ();
303- }
304-
305- while (1 ); /* noreturn */
289+ extern void __rt_libc_exit (int status );
290+ __rt_libc_exit (status );
291+ while (1 );
306292}
307293
308294void
309295_system (const char * s )
310296{
311- /* not support this call */
312- return ;
297+ extern int __rt_libc_system ( const char * string );
298+ __rt_libc_system ( s ) ;
313299}
314300
315301void __libc_init_array (void )
@@ -319,23 +305,9 @@ void __libc_init_array(void)
319305
320306void abort (void )
321307{
322- rt_thread_t self = rt_thread_self ();
323-
324- #ifdef RT_USING_MODULE
325- if (dlmodule_self ())
326- {
327- dlmodule_exit (-1 );
328- }
329- #endif
330-
331- if (self != RT_NULL )
332- {
333- rt_kprintf ("thread:%-8.*s abort!\n" , RT_NAME_MAX , self -> name );
334- rt_thread_suspend (self );
335- rt_schedule ();
336- }
337-
338- while (1 ); /* noreturn */
308+ extern void __rt_libc_abort (void );
309+ __rt_libc_abort ();
310+ while (1 );
339311}
340312
341313uid_t getuid (void )
You can’t perform that action at this time.
0 commit comments