xref: /nrf52832-nimble/rt-thread/components/libc/compilers/dlib/libc.c (revision 167494296f0543431a51b6b1b83e957045294e05)
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  * 2017/10/15     bernard      the first version
9  */
10 #include <stdio.h>
11 #include <stdlib.h>
12 
13 #include <rtthread.h>
14 
15 #include "libc.h"
16 
17 #ifdef RT_USING_PTHREADS
18 #include <pthread.h>
19 #endif
20 
21 int libc_system_init(void)
22 {
23 #if defined(RT_USING_DFS) && defined(RT_USING_DFS_DEVFS)
24     rt_device_t dev_console;
25 
26     dev_console = rt_console_get_device();
27     if (dev_console)
28     {
29     #if defined(RT_USING_POSIX)
30         libc_stdio_set_console(dev_console->parent.name, O_RDWR);
31     #else
32         libc_stdio_set_console(dev_console->parent.name, O_WRONLY);
33     #endif
34     }
35 #endif
36 
37 #if defined (RT_USING_PTHREADS) && !defined (RT_USING_COMPONENTS_INIT)
38     pthread_system_init();
39 #endif
40 
41     return 0;
42 }
43 INIT_COMPONENT_EXPORT(libc_system_init);
44 
45