diff options
| author | [email protected] <[email protected]> | 2012-11-23 06:36:58 +0000 |
|---|---|---|
| committer | [email protected] <[email protected]> | 2012-11-23 06:36:58 +0000 |
| commit | 6698e69fc8a0d9c59cc6005251cd27eb09e623d2 (patch) | |
| tree | 1204eb3ee653c964f12621ae700e54a9d85e7705 /components/libc/newlib/syscalls.c | |
| parent | b820365317d382f34f4b9cef1ef3f8511e66a2bf (diff) | |
Add exit function when exit from a module.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2437 bbd45198-f89e-11dd-88c7-29a3b14d5316
Diffstat (limited to 'components/libc/newlib/syscalls.c')
| -rw-r--r-- | components/libc/newlib/syscalls.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/components/libc/newlib/syscalls.c b/components/libc/newlib/syscalls.c index 796c3159b7..7d3797948c 100644 --- a/components/libc/newlib/syscalls.c +++ b/components/libc/newlib/syscalls.c @@ -386,8 +386,51 @@ _free_r (struct _reent *ptr, void *addr) void _exit (int status) { +#ifdef RT_USING_MODULE + rt_module_t module; + + module = rt_module_self(); + if (module != RT_NULL) + { + struct rt_list_node *list; + struct rt_object *object; + + rt_enter_critical(); + + /* delete all threads in the module */ + list = &module->module_object[RT_Object_Class_Thread].object_list; + while (list->next != list) + { + object = rt_list_entry(list->next, struct rt_object, list); + if (rt_object_is_systemobject(object) == RT_TRUE) + { + /* detach static object */ + rt_thread_detach((rt_thread_t)object); + } + else + { + /* delete dynamic object */ + rt_thread_delete((rt_thread_t)object); + } + } + /* delete main thread */ + rt_thread_delete(module->module_thread); + rt_exit_critical(); + + /* re-schedule */ + rt_schedule(); + } +#endif + rt_kprintf("thread:%s exit with %d\n", rt_thread_self()->name, status); RT_ASSERT(0); while (1); } + +void +_system(const char *s) +{ + /* not support this call */ + return; +} |
