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

Function _write_r

components/libc/compilers/newlib/syscalls.c:292–325  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290}
291
292_ssize_t _write_r(struct _reent *ptr, int fd, const void *buf, size_t nbytes)
293{
294#ifdef DFS_USING_POSIX
295 _ssize_t rc;
296#endif /* DFS_USING_POSIX */
297
298 if (fd == STDOUT_FILENO || fd == STDERR_FILENO)
299 {
300#if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
301 rt_device_t console;
302
303 console = rt_console_get_device();
304 if (console)
305 return rt_device_write(console, -1, buf, nbytes);
306#else
307 ptr->_errno = ENOTSUP;
308 return -1;
309#endif /* defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) */
310 }
311 else if (fd == STDIN_FILENO)
312 {
313 ptr->_errno = ENOTSUP;
314 return -1;
315 }
316
317#ifdef DFS_USING_POSIX
318 rc = write(fd, buf, nbytes);
319 return rc;
320#else
321 LOG_W("%s: %s", __func__, _WARNING_WITHOUT_FS);
322 ptr->_errno = ENOTSUP;
323 return -1;
324#endif /* DFS_USING_POSIX */
325}
326
327/* for exit() and abort() */
328__attribute__ ((noreturn)) void _exit (int status)

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