re-establish kernel assert()s.
[minix.git] / lib / libsys / kputc.c
blob1895f26a2ab721ae3a057a6fc3585e61a6a4963e
1 /* A server must occasionally print some message. It uses a simple version of
2 * printf() found in the system lib that calls kputc() to output characters.
3 * Printing is done with a call to the kernel, and not by going through FS.
5 * This routine can only be used by servers and device drivers. The kernel
6 * must define its own kputc(). Note that the log driver also defines its own
7 * kputc() to directly call the TTY instead of going through this library.
8 */
10 #include "sysutil.h"
12 static char print_buf[DIAG_BUFSIZE]; /* output is buffered here */
14 /*===========================================================================*
15 * kputc *
16 *===========================================================================*/
17 void kputc(c)
18 int c;
20 /* Accumulate another character. If 0 or buffer full, print it. */
21 static int buf_count; /* # characters in the buffer */
22 message m;
24 if ((c == 0 && buf_count > 0) || buf_count == sizeof(print_buf)) {
25 sys_sysctl(SYSCTL_CODE_DIAG, print_buf, buf_count);
26 buf_count = 0;
28 if (c != 0) {
30 /* Append a single character to the output buffer. */
31 print_buf[buf_count++] = c;