Skip to content

Commit d47025b

Browse files
keith-packardcarlescufi
authored andcommitted
libc/picolibc: Remove unused read_stdin/write_stdout hooks
Picolibc doesn't need these two syscall implementations as it uses zephyr_fputc instead. Make sure that zephyr_putc is declared correctly. Signed-off-by: Keith Packard <[email protected]>
1 parent 66969fc commit d47025b

File tree

2 files changed

+7
-30
lines changed

2 files changed

+7
-30
lines changed

include/zephyr/sys/libc-hooks.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extern "C" {
2121
* that need to call into the kernel as system calls
2222
*/
2323

24-
#if defined(CONFIG_NEWLIB_LIBC) || defined(CONFIG_ARCMWDT_LIBC) || defined(CONFIG_PICOLIBC)
24+
#if defined(CONFIG_NEWLIB_LIBC) || defined(CONFIG_ARCMWDT_LIBC)
2525

2626
/* syscall generation ignores preprocessor, ensure this is defined to ensure
2727
* we don't have compile errors
@@ -31,12 +31,17 @@ __syscall int zephyr_read_stdin(char *buf, int nbytes);
3131
__syscall int zephyr_write_stdout(const void *buf, int nbytes);
3232

3333
#else
34-
/* Minimal libc */
34+
/* Minimal libc and picolibc */
3535

3636
__syscall int zephyr_fputc(int c, FILE * stream);
3737

38+
#ifdef CONFIG_MINIMAL_LIBC
39+
/* Minimal libc only */
40+
3841
__syscall size_t zephyr_fwrite(const void *ZRESTRICT ptr, size_t size,
3942
size_t nitems, FILE *ZRESTRICT stream);
43+
#endif
44+
4045
#endif /* CONFIG_NEWLIB_LIBC */
4146

4247
/* Handle deprecated malloc arena size configuration values */

lib/libc/picolibc/libc-hooks.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -73,34 +73,6 @@ void __stdin_hook_install(unsigned char (*hook)(void))
7373
__stdin.flags |= _FDEV_SETUP_READ;
7474
}
7575

76-
int z_impl_zephyr_read_stdin(char *buf, int nbytes)
77-
{
78-
int i = 0;
79-
80-
for (i = 0; i < nbytes; i++) {
81-
*(buf + i) = getchar();
82-
if ((*(buf + i) == '\n') || (*(buf + i) == '\r')) {
83-
i++;
84-
break;
85-
}
86-
}
87-
return i;
88-
}
89-
90-
int z_impl_zephyr_write_stdout(const void *buffer, int nbytes)
91-
{
92-
const char *buf = buffer;
93-
int i;
94-
95-
for (i = 0; i < nbytes; i++) {
96-
if (*(buf + i) == '\n') {
97-
putchar('\r');
98-
}
99-
putchar(*(buf + i));
100-
}
101-
return nbytes;
102-
}
103-
10476
#include <zephyr/sys/cbprintf.h>
10577

10678
struct cb_bits {

0 commit comments

Comments
 (0)