From aacbfc41ccc009feabac4944fc4774f643e1f378 Mon Sep 17 00:00:00 2001 From: David van Moolenbroek Date: Fri, 23 Apr 2010 20:23:33 +0000 Subject: [PATCH] intercept puts() in libsys, for gcc --- lib/libsys/Makefile | 1 + lib/libsys/kputs.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 lib/libsys/kputs.c diff --git a/lib/libsys/Makefile b/lib/libsys/Makefile index 126bdbca2..3ea87fc7a 100644 --- a/lib/libsys/Makefile +++ b/lib/libsys/Makefile @@ -98,6 +98,7 @@ SRCS= \ asynsend.c \ kprintf.c \ kputc.c \ + kputs.c \ tickdelay.c \ get_randomness.c \ getidle.c \ diff --git a/lib/libsys/kputs.c b/lib/libsys/kputs.c new file mode 100644 index 000000000..e05c9bf45 --- /dev/null +++ b/lib/libsys/kputs.c @@ -0,0 +1,24 @@ +/* system services puts() + * + * This is here because gcc converts printf() calls without actual formatting + * in the format string, to puts() calls. While that "feature" can be disabled + * with the -fno-builtin-printf gcc flag, we still don't want the resulting + * mayhem to occur in system servers even when that flag is forgotten. + */ + +#include + +/* puts() uses kputc() to print characters. */ +void kputc(int c); + +int puts(const char *s) +{ + + for (; *s; s++) + kputc(*s); + + kputc('\n'); + kputc('\0'); + + return 0; +} -- 2.44.0