]> Zhao Yanbai Git Server - minix.git/commitdiff
intercept puts() in libsys, for gcc
authorDavid van Moolenbroek <david@minix3.org>
Fri, 23 Apr 2010 20:23:33 +0000 (20:23 +0000)
committerDavid van Moolenbroek <david@minix3.org>
Fri, 23 Apr 2010 20:23:33 +0000 (20:23 +0000)
lib/libsys/Makefile
lib/libsys/kputs.c [new file with mode: 0644]

index 126bdbca20c2410ca6d39b6b9ca532d5b6876d44..3ea87fc7ae9ed6db7b964c701d71b50fc832a709 100644 (file)
@@ -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 (file)
index 0000000..e05c9bf
--- /dev/null
@@ -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 <stdio.h>
+
+/* 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;
+}