# This tag requires that the tag ENABLE_PREPROCESSING is set to YES.
PREDEFINED = __attribute__(x)= \
+ __printf(x,y)= \
__noreturn \
--- /dev/null
+#include <xtf/types.h>
+#include <xtf/console.h>
+#include <xtf/lib.h>
+#include <xtf/libc.h>
+
+/*
+ * Output functions, registered if/when available.
+ * Possibilities:
+ */
+static cons_output_cb output_fns[1];
+static unsigned int nr_cons_cb;
+
+void register_console_callback(cons_output_cb fn)
+{
+ if ( nr_cons_cb < ARRAY_SIZE(output_fns) )
+ output_fns[nr_cons_cb++] = fn;
+}
+
+void printk(const char *fmt, ...)
+{
+ unsigned int i;
+
+ for ( i = 0; i < nr_cons_cb; ++i )
+ output_fns[i](fmt, strlen(fmt));
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--- /dev/null
+#include <string.h>
+
+size_t strlen(const char *str)
+{
+ const char *s = str;
+
+ while ( *s != '\0' )
+ ++s;
+
+ return s - str;
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
#include <xtf/hypercall.h>
#include <xtf/framework.h>
#include <xtf/test.h>
+#include <xtf/console.h>
/**
* Entry point into C.
{
arch_setup();
+ printk("--- Xen Test Framework ---\n");
+
test_main();
hypercall_shutdown(SHUTDOWN_poweroff);
# obj-perenv get get compiled once for each environment
# obj-$(env) are objects unique to a specific environment
+obj-perarch += $(ROOT)/common/console.o
+obj-perarch += $(ROOT)/common/libc/string.o
obj-perarch += $(ROOT)/common/setup.o
obj-perenv += $(ROOT)/arch/x86/setup.o
#define __noreturn __attribute__((noreturn))
#define unreachable() __builtin_unreachable()
+#define __printf(f, v) __attribute__((format(__printf__, f, v)))
+
#endif /* XTF_COMPILER_H */
/*
--- /dev/null
+#ifndef XTF_CONSOLE_H
+#define XTF_CONSOLE_H
+
+#include <xtf/compiler.h>
+
+/* Console output callback. */
+typedef void (*cons_output_cb)(const char *buf, size_t len);
+
+/*
+ * Register a console callback. Several callbacks can be registered for usful
+ * destinations of console text.
+ */
+void register_console_callback(cons_output_cb cb);
+
+void printk(const char *fmt, ...) __printf(1, 2);
+
+#endif /* XTF_CONSOLE_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--- /dev/null
+#ifndef XTF_LIB_H
+#define XTF_LIB_H
+
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*a))
+
+#endif /* XTF_LIB_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--- /dev/null
+#ifndef XTF_LIBC_H
+#define XTF_LIBC_H
+
+#include <xtf/types.h>
+
+/*
+ * Local declaration of bits of libc
+ *
+ * Use __builtin_???() wherever possible, to allow gcc to perform certain
+ * optimisations (e.g. constant folding) otherwise prevented by -fno-builtin.
+ *
+ * Where optimisations are not possible, the __builtin_???() varient will emit
+ * a call to ???(), which needs implementing in common/libc/
+ */
+
+#define strlen(s) __builtin_strlen(s)
+
+size_t strlen(const char *str);
+
+#endif /* XTF_LIBC_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */