summaryrefslogtreecommitdiff
path: root/boot
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1996-04-29 03:54:24 +0000
committerMiles Bader <miles@gnu.org>1996-04-29 03:54:24 +0000
commit032a0f7edb638b72d70de98eace700d8442d9ba4 (patch)
tree3c9571233fc9ea7a6cfb62be9f33c3c5a2512f91 /boot
parent125f0f8aabff591e8314ea9ca105a9b3ae2e935c (diff)
(printf): Add %d.
Diffstat (limited to 'boot')
-rw-r--r--boot/ux.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/boot/ux.c b/boot/ux.c
index 0a34b25f..b532f19e 100644
--- a/boot/ux.c
+++ b/boot/ux.c
@@ -28,6 +28,21 @@
#include "ux.h"
+#if 0
+static int (* const _sc)(int, ...) = &syscall;
+int _sc_print = 1;
+
+#define syscall(num, args...) \
+ ({ int _rv, _num = (num), _pr = _sc_print; \
+ _sc_print = 0; \
+ if (_pr) printf ("syscall (%d) start\r\n", _num); \
+ _rv = (*_sc) (_num , ##args); \
+ if (_pr) printf ("syscall (%d) end\r\n", _num); \
+ _sc_print = _pr; \
+ _rv; \
+ })
+#endif
+
extern void __mach_init ();
void (*mach_init_routine)() = __mach_init;
@@ -211,7 +226,7 @@ void get_privileged_ports (mach_port_t *host_port, mach_port_t *device_port)
*device_port = task_by_pid (-2);
}
-/* A *really* stupid printf that only understands %s. */
+/* A *really* stupid printf that only understands %s & %d. */
int
printf (const char *fmt, ...)
{
@@ -233,6 +248,23 @@ printf (const char *fmt, ...)
flush (p + 2);
write (1, str, strlen (str));
}
+ else if (*p == '%' && p[1] == 'd')
+ {
+ int i = va_arg (ap, int);
+ char rbuf[20], *e = rbuf + sizeof (rbuf), *b = e;
+
+ if (i == 0)
+ *--b = '0';
+ else
+ while (i)
+ {
+ *--b = i % 10 + '0';
+ i /= 10;
+ }
+
+ flush (p + 2);
+ write (1, b, e - b);
+ }
else
p++;
va_end (ap);