libc.c 885 字节
Newer Older
1 2 3 4 5 6 7
#include <rtthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/time.h>
#include "libc.h"

U
user 已提交
8 9 10 11
#ifdef RT_USING_PTHREADS
#include <pthread.h>
#endif

B
Bernard Xiong 已提交
12 13 14 15 16 17 18 19 20
#ifdef RT_USING_DFS
#include <dfs_posix.h>

#ifdef RT_USING_DFS_DEVFS
#include <devfs.h>
#endif

#endif

21
int libc_system_init(void)
22
{
U
user 已提交
23
#ifdef RT_USING_DFS
24
    struct rt_device *console_dev;
25 26 27 28 29

#ifndef RT_USING_DFS_DEVFS
#error Please enable devfs by defining RT_USING_DFS_DEVFS in rtconfig.h
#endif

30 31 32 33 34 35
    console_dev = rt_console_get_device();
    if (console_dev)
    {
        /* initialize console device */
        rt_console_init(console_dev->parent.name);
    }
36
#endif
37

38 39 40
    /* set PATH and HOME */
    putenv("PATH=/bin");
    putenv("HOME=/home");
41
#if defined RT_USING_PTHREADS && !defined RT_USING_COMPONENTS_INIT
42
    pthread_system_init();
43
#endif
44 45

    return 0;
46
}
47
INIT_COMPONENT_EXPORT(libc_system_init);