MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / __write

Function __write

components/libc/compilers/dlib/syscall_write.c:35–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33#pragma module_name = "?__write"
34
35size_t __write(int handle, const unsigned char *buf, size_t len)
36{
37#ifdef DFS_USING_POSIX
38 int size;
39#endif /* DFS_USING_POSIX */
40
41 if ((handle == _LLIO_STDOUT) || (handle == _LLIO_STDERR))
42 {
43#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
44 rt_device_t console_device;
45
46 console_device = rt_console_get_device();
47 if (console_device)
48 {
49 rt_device_write(console_device, 0, buf, len);
50 }
51
52 return len; /* return the length of the data written */
53#else
54 return _LLIO_ERROR;
55#endif /* defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) */
56 }
57 else if (handle == _LLIO_STDIN)
58 {
59 return _LLIO_ERROR;
60 }
61 else
62 {
63#ifdef DFS_USING_POSIX
64 size = write(handle, buf, len);
65 return size; /* return the length of the data written */
66#else
67 LOG_W(_WARNING_WITHOUT_FS);
68 return _LLIO_ERROR;
69#endif /* DFS_USING_POSIX */
70 }
71}

Callers

nothing calls this directly

Calls 3

rt_console_get_deviceFunction · 0.85
rt_device_writeFunction · 0.85
writeFunction · 0.50

Tested by

no test coverage detected