Skip to content

Commit

Permalink
lib: libc: Drop z_ prefix from stdio syscalls
Browse files Browse the repository at this point in the history
This commit removes the `z_` prefix from the stdio syscall functions
(`z_zephyr_write_stdout` and `z_zephyr_read_stdin`) since it is
redundant and does not align with the convention used by the equivalent
minimal libc syscall functions (e.g. `zephyr_fputc` and
`zephyr_fwrite`).

Signed-off-by: Stephanos Ioannidis <root@stephanos.io>
  • Loading branch information
stephanosio authored and cfriedt committed Sep 11, 2021
1 parent 86b8cf1 commit 92f0f70
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions include/sys/libc-hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
*/
#define _MLIBC_RESTRICT

__syscall int z_zephyr_read_stdin(char *buf, int nbytes);
__syscall int zephyr_read_stdin(char *buf, int nbytes);

__syscall int z_zephyr_write_stdout(const void *buf, int nbytes);
__syscall int zephyr_write_stdout(const void *buf, int nbytes);

#else
/* Minimal libc */
Expand Down
10 changes: 5 additions & 5 deletions lib/libc/arcmwdt/libc-hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ void __stdout_hook_install(int (*hook)(int))
_stdout_hook = hook;
}

int z_impl_z_zephyr_write_stdout(const void *buffer, int nbytes)
int z_impl_zephyr_write_stdout(const void *buffer, int nbytes)
{
const char *buf = buffer;
int i;
Expand All @@ -42,20 +42,20 @@ int z_impl_z_zephyr_write_stdout(const void *buffer, int nbytes)
}

#ifdef CONFIG_USERSPACE
static inline int z_vrfy_z_zephyr_write_stdout(const void *buf, int nbytes)
static inline int z_vrfy_zephyr_write_stdout(const void *buf, int nbytes)
{
Z_OOPS(Z_SYSCALL_MEMORY_READ(buf, nbytes));
return z_impl_z_zephyr_write_stdout(buf, nbytes);
return z_impl_zephyr_write_stdout(buf, nbytes);
}
#include <syscalls/z_zephyr_write_stdout_mrsh.c>
#include <syscalls/zephyr_write_stdout_mrsh.c>
#endif

#ifndef CONFIG_POSIX_API
int _write(int fd, const char *buf, unsigned int nbytes)
{
ARG_UNUSED(fd);

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

Expand Down
20 changes: 10 additions & 10 deletions lib/libc/newlib/libc-hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void __stdin_hook_install(unsigned char (*hook)(void))
_stdin_hook = hook;
}

int z_impl_z_zephyr_read_stdin(char *buf, int nbytes)
int z_impl_zephyr_read_stdin(char *buf, int nbytes)
{
int i = 0;

Expand All @@ -193,15 +193,15 @@ int z_impl_z_zephyr_read_stdin(char *buf, int nbytes)
}

#ifdef CONFIG_USERSPACE
static inline int z_vrfy_z_zephyr_read_stdin(char *buf, int nbytes)
static inline int z_vrfy_zephyr_read_stdin(char *buf, int nbytes)
{
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(buf, nbytes));
return z_impl_z_zephyr_read_stdin((char *)buf, nbytes);
return z_impl_zephyr_read_stdin((char *)buf, nbytes);
}
#include <syscalls/z_zephyr_read_stdin_mrsh.c>
#include <syscalls/zephyr_read_stdin_mrsh.c>
#endif

int z_impl_z_zephyr_write_stdout(const void *buffer, int nbytes)
int z_impl_zephyr_write_stdout(const void *buffer, int nbytes)
{
const char *buf = buffer;
int i;
Expand All @@ -216,28 +216,28 @@ int z_impl_z_zephyr_write_stdout(const void *buffer, int nbytes)
}

#ifdef CONFIG_USERSPACE
static inline int z_vrfy_z_zephyr_write_stdout(const void *buf, int nbytes)
static inline int z_vrfy_zephyr_write_stdout(const void *buf, int nbytes)
{
Z_OOPS(Z_SYSCALL_MEMORY_READ(buf, nbytes));
return z_impl_z_zephyr_write_stdout((const void *)buf, nbytes);
return z_impl_zephyr_write_stdout((const void *)buf, nbytes);
}
#include <syscalls/z_zephyr_write_stdout_mrsh.c>
#include <syscalls/zephyr_write_stdout_mrsh.c>
#endif

#ifndef CONFIG_POSIX_API
int _read(int fd, char *buf, int nbytes)
{
ARG_UNUSED(fd);

return z_zephyr_read_stdin(buf, nbytes);
return zephyr_read_stdin(buf, nbytes);
}
__weak FUNC_ALIAS(_read, read, int);

int _write(int fd, const void *buf, int nbytes)
{
ARG_UNUSED(fd);

return z_zephyr_write_stdout(buf, nbytes);
return zephyr_write_stdout(buf, nbytes);
}
__weak FUNC_ALIAS(_write, write, int);

Expand Down

0 comments on commit 92f0f70

Please sign in to comment.