xref: /nrf52832-nimble/rt-thread/components/libc/compilers/dlib/syscall_read.c (revision 042d53a763ad75cb1465103098bb88c245d95138)
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  * 2015-01-28     Bernard      first version
9  */
10 
11 #include <rtthread.h>
12 #ifdef RT_USING_DFS
13 #include <dfs_posix.h>
14 #endif
15 #include <yfuns.h>
16 #include "libc.h"
17 
18 #pragma module_name = "?__read"
19 size_t __read(int handle, unsigned char *buf, size_t len)
20 {
21 #ifdef RT_USING_DFS
22     int size;
23 #endif
24 
25     if (handle == _LLIO_STDIN)
26     {
27 #ifdef RT_USING_POSIX
28         return libc_stdio_read(buf, len);
29 #else
30         return _LLIO_ERROR;
31 #endif
32     }
33 
34     if ((handle == _LLIO_STDOUT) || (handle == _LLIO_STDERR))
35         return _LLIO_ERROR;
36 
37 #ifndef RT_USING_DFS
38     return _LLIO_ERROR;
39 #else
40     size = read(handle, buf, len);
41     return size;
42 #endif
43 }
44