Commit 86b8cf1f authored by Stephanos Ioannidis's avatar Stephanos Ioannidis Committed by Christopher Friedt
Browse files

lib: libc: arcmwdt: Fix userspace write() and read() mishap



The newlib `write()` and `read()` functions must call the
`z_zephyr_write_stdout()` and `z_zephyr_read_stdin()` syscall functions
in order to function properly in a user mode context.

The existing incorrect implementation was copied off the newlib hooks
implementation, which was corrected in the previous commit.

Signed-off-by: default avatarStephanos Ioannidis <root@stephanos.io>
parent eab7ae92
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ void __stdout_hook_install(int (*hook)(int))
	_stdout_hook = hook;
}

int z_impl_zephyr_write_stdout(const void *buffer, int nbytes)
int z_impl_z_zephyr_write_stdout(const void *buffer, int nbytes)
{
	const char *buf = buffer;
	int i;
@@ -45,7 +45,7 @@ int z_impl_zephyr_write_stdout(const void *buffer, int nbytes)
static inline int z_vrfy_z_zephyr_write_stdout(const void *buf, int nbytes)
{
	Z_OOPS(Z_SYSCALL_MEMORY_READ(buf, nbytes));
	return z_impl_zephyr_write_stdout(buf, nbytes);
	return z_impl_z_zephyr_write_stdout(buf, nbytes);
}
#include <syscalls/z_zephyr_write_stdout_mrsh.c>
#endif
@@ -55,7 +55,7 @@ int _write(int fd, const char *buf, unsigned int nbytes)
{
	ARG_UNUSED(fd);

	return z_impl_zephyr_write_stdout(buf, nbytes);
	return z_zephyr_write_stdout(buf, nbytes);
}
#endif