summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2002-10-14 20:15:24 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2002-10-14 20:15:24 +0000
commit88520fa67dbed4d2d6f5e693ae304eed7d42954e (patch)
tree455ae009247481a2f998bc51848bd96ac713bd10 /sys
parent8968677b0a8e49f7b5bd4250a387dc45b227f25b (diff)
Stuff needed for gcc 3.X.
gcc has the nice feature of optimizing various common constructs into more optimal ones, inlining various calls, etc. The problem with that is that it assumes that we have a proper libc backing us. We really don't want to loose all those features by defining -ffreestanding and right now there is no way to just disable some of them, so we have to make the kernel more libc-like in some aspects to make it work with newer gcc. rename putchar to kputchar because it was nothing like libc putchar (and only internal to this function). Implement dummy putchar and puts (not prototyped outside this file).
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/subr_prf.c47
1 files changed, 38 insertions, 9 deletions
diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c
index cb4f83203ec..68d8f0b6bd6 100644
--- a/sys/kern/subr_prf.c
+++ b/sys/kern/subr_prf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_prf.c,v 1.44 2002/05/20 22:16:36 art Exp $ */
+/* $OpenBSD: subr_prf.c,v 1.45 2002/10/14 20:15:23 art Exp $ */
/* $NetBSD: subr_prf.c,v 1.45 1997/10/24 18:14:25 chuck Exp $ */
/*-
@@ -98,8 +98,7 @@ extern int uvm_doswapencrypt;
*/
int kprintf(const char *, int, void *, char *, va_list);
-void putchar(int, int, struct tty *);
-
+void kputchar(int, int, struct tty *);
/*
* globals
@@ -289,11 +288,11 @@ logpri(level)
char *p;
char snbuf[KPRINTF_BUFSIZE];
- putchar('<', TOLOG, NULL);
+ kputchar('<', TOLOG, NULL);
sprintf(snbuf, "%d", level);
for (p = snbuf ; *p ; p++)
- putchar(*p, TOLOG, NULL);
- putchar('>', TOLOG, NULL);
+ kputchar(*p, TOLOG, NULL);
+ kputchar('>', TOLOG, NULL);
}
/*
@@ -322,13 +321,13 @@ addlog(const char *fmt, ...)
/*
- * putchar: print a single character on console or user terminal.
+ * kputchar: print a single character on console or user terminal.
*
* => if console, then the last MSGBUFS chars are saved in msgbuf
* for inspection later (e.g. dmesg/syslog)
*/
void
-putchar(c, flags, tp)
+kputchar(c, flags, tp)
register int c;
int flags;
struct tty *tp;
@@ -704,7 +703,7 @@ vsnprintf(buf, size, fmt, ap)
} \
*sbuf++ = (C); \
} else { \
- putchar((C), oflags, (struct tty *)vp); \
+ kputchar((C), oflags, (struct tty *)vp); \
} \
}
@@ -1179,3 +1178,33 @@ overflow:
return (ret);
/* NOTREACHED */
}
+
+#if __GNUC_PREREQ__(2,96)
+/*
+ * XXX - these functions shouldn't be in the kernel, but gcc 3.X feels like
+ * translating some printf calls to puts and since it doesn't seem
+ * possible to just turn off parts of those optimizations (some of
+ * them are really useful, we have to provide a dummy puts and putchar
+ * that are wrappers around printf.
+ */
+int puts(const char *);
+int putchar(int c);
+
+int
+puts(const char *str)
+{
+ printf("%s\n", str);
+
+ return (0);
+}
+
+int
+putchar(int c)
+{
+ printf("%c", c);
+
+ return (c);
+}
+
+
+#endif