From: Ben Pfaff Date: Mon, 20 Sep 2004 04:27:43 +0000 (+0000) Subject: Add putbuf(). X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pintos-anon;a=commitdiff_plain;h=76f6e5dbcd612bbf79e0243bb8a0247b52043571 Add putbuf(). --- diff --git a/src/lib/kernel/console.c b/src/lib/kernel/console.c index 803b46b..149f29c 100644 --- a/src/lib/kernel/console.c +++ b/src/lib/kernel/console.c @@ -59,6 +59,20 @@ puts (const char *s) return 0; } +/* Writes the N characters in BUFFER to the console. */ +void +putbuf (const char *buffer, size_t n) +{ + if (!intr_context ()) + lock_acquire (&console_lock); + + while (n-- > 0) + putchar_unlocked (*buffer++); + + if (!intr_context ()) + lock_release (&console_lock); +} + /* Writes C to the vga display and serial port. */ int putchar (int c) diff --git a/src/lib/stdio.h b/src/lib/stdio.h index b351dd1..cf6c49e 100644 --- a/src/lib/stdio.h +++ b/src/lib/stdio.h @@ -19,7 +19,10 @@ int putchar (int); int puts (const char *); /* Nonstandard functions. */ -#ifndef KERNEL +#ifdef KERNEL +void putbuf (const char *, size_t); +#endif +#ifdef USER int hprintf (int, const char *, ...) PRINTF_FORMAT (2, 3); int vhprintf (int, const char *, va_list) PRINTF_FORMAT (2, 0); #endif