From ba752d8b8e1a9125b3001ff6b2fb7135dff675b6 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Tue, 13 Jan 2015 17:18:17 +0100 Subject: [PATCH hurd 1/5] libshouldbeinlibc: provide `mach_print' XXX * libshouldbeinlibc/mach-print.c: New file. * libshouldbeinlibc/mach-print.h: Likewise. * libshouldbeinlibc/Makefile: Add `mach-print.{c,h}'. --- libshouldbeinlibc/Makefile | 2 ++ libshouldbeinlibc/mach-print.c | 28 ++++++++++++++++++++++++++++ libshouldbeinlibc/mach-print.h | 2 ++ 3 files changed, 32 insertions(+) create mode 100644 libshouldbeinlibc/mach-print.c create mode 100644 libshouldbeinlibc/mach-print.h diff --git a/libshouldbeinlibc/Makefile b/libshouldbeinlibc/Makefile index 633d60e..7a17d0e 100644 --- a/libshouldbeinlibc/Makefile +++ b/libshouldbeinlibc/Makefile @@ -29,10 +29,12 @@ SRCS = termsize.c timefmt.c exec-reauth.c maptime-funcs.c \ ugids-auth.c ugids-xinl.c ugids-merge.c ugids-imply.c ugids-posix.c \ ugids-verify-auth.c nullauth.c \ refcount.c \ + mach-print.c \ installhdrs = idvec.h timefmt.h maptime.h \ wire.h portinfo.h portxlate.h cacheq.h ugids.h nullauth.h \ refcount.h \ + mach-print.h \ installhdrsubdir = . diff --git a/libshouldbeinlibc/mach-print.c b/libshouldbeinlibc/mach-print.c new file mode 100644 index 0000000..b417d9d --- /dev/null +++ b/libshouldbeinlibc/mach-print.c @@ -0,0 +1,28 @@ +#include +#include + +#define BUFFER_SIZE 1024 + +asm (".global _mach_print;" + " _mach_print:;" + " mov $0xffffffe2, %eax;" + " lcall $0x7, $0x0;" + " ret;"); + +void +mach_print(const char *msg) +{ + _mach_print (msg); +} + +void +mach_printf (const char *format, ...) +{ + va_list ap; + char buf[BUFFER_SIZE]; + + va_start(ap, format); + vsnprintf(buf, sizeof(buf), format, ap); + mach_print(buf); + va_end(ap); +} diff --git a/libshouldbeinlibc/mach-print.h b/libshouldbeinlibc/mach-print.h new file mode 100644 index 0000000..a733939 --- /dev/null +++ b/libshouldbeinlibc/mach-print.h @@ -0,0 +1,2 @@ +void mach_print(const char *); +void mach_printf(const char *format, ...); // XXX attribute printf -- 2.1.4