summaryrefslogtreecommitdiff
path: root/hurd/stddef.h
diff options
context:
space:
mode:
authorneal <neal>2008-01-23 23:12:39 +0000
committerneal <neal>2008-01-23 23:12:39 +0000
commit53119ad6d5042194c4653bc718799a8bc653a7da (patch)
tree352fb1b5551144f58619140a674a9bffcc8e39a8 /hurd/stddef.h
parentb962fefe8733a2fd7911090b3e8565eff3469048 (diff)
hurd/
2008-01-23 Neal H. Walfield <neal@gnu.org> * stddef.h (S_PRINTF): New macro. (debug): Use S_PRINTF rather than printf. * Makefile.am (t_addr_CPPFLAGS): Add -DS_PRINTF=printf. (t_addr_trans_CPPFLAGS): Likewise. (t_rpc_CPPFLAGS): Likewise. libc-parts/ 2008-01-24 Neal H. Walfield <neal@gnu.org> * assert.h: Include <hurd/stddef.h>. (assertx): Use S_PRINTF rather than printf. libhurd-btree/ 2008-01-24 Neal H. Walfield <neal@gnu.org> * Makefile.am (btree_test_CPPFLAGS): New variable. (btree_test_LDADD): Remove. (btree_test_SOURCES): Add btree.c. * btree.c (node_t): Include <stdio.h>. libhurd-ihash/ 2008-01-24 Neal H. Walfield <neal@gnu.org> * Makefile.am (t_ihash_SOURCES): Add ihash.c. (t_ihash_CPPFLAGS): New variable. * t-ihash.c: Include <stdio.h>. libhurd-mm/ 2008-01-24 Neal H. Walfield <neal@gnu.org> * as.c (as_alloced_dump): Use s_printf rather than printf. (as_walk): Likewise. laden/ 2008-01-23 Neal H. Walfield <neal@gnu.org> * Makefile.am (laden_CPPFLAGS): Add -DS_PRINTF=printf. ruth/ 2008-01-24 Neal H. Walfield <neal@gnu.org> * output.h (putchar): Rename from this... (s_putchar): ... to this. (puts): Rename from this... (s_puts): ... to this. (vprintf): Rename from this... (s_vprintf): ... to this. (printf): Rename from this... (s_printf): ... to this. * output.c (putchar): Rename from this... (s_putchar): ... to this. Update users. (puts): Rename from this... (s_puts): ... to this. Update users. (vprintf): Rename from this... (s_vprintf): ... to this. Update users. (printf): Rename from this... (s_printf): ... to this. * Makefile.am (ruth_SOURCES): Add object.h and object.c. * ia32-cmain.c: Include <stddef.h>. (cmain): Use s_printf rather than printf. * panic.c (panic_): Use s_printf and s_vprintf rather than printf and vprintf.
Diffstat (limited to 'hurd/stddef.h')
-rw-r--r--hurd/stddef.h33
1 files changed, 23 insertions, 10 deletions
diff --git a/hurd/stddef.h b/hurd/stddef.h
index 31f9828..28e8d86 100644
--- a/hurd/stddef.h
+++ b/hurd/stddef.h
@@ -24,6 +24,19 @@
#include <l4/types.h>
#include <assert.h>
+/* A safe-printf routine. In particular, it doesn't call malloc and
+ works in place. This makes it appropriate for situations in which
+ malloc is not yet working and when the state is suspected to be
+ compromised (e.g., assert or panic). */
+#ifndef S_PRINTF
+# if defined(RM_INTERN) || defined(_L4_TEST_ENVIRONMENT)
+# define S_PRINTF printf
+# else
+# define S_PRINTF s_printf
+# endif
+#endif
+extern int S_PRINTF (const char *fmt, ...);
+
/* Convenient debugging macros. */
#ifdef DEBUG_ELIDE
@@ -44,16 +57,16 @@ extern int output_debug;
#include <l4/thread.h>
/* Print a debug message if DEBUG_COND is true. */
-#define debug(level, fmt, ...) \
- do \
- { \
- extern const char program_name[]; \
- extern int printf (const char *, ...); \
- do_debug (level) \
- printf ("%s (%x):%s:%d: " fmt "\n", \
- program_name, l4_myself (), __func__, __LINE__, \
- ##__VA_ARGS__); \
- } \
+#define debug(level, fmt, ...) \
+ do \
+ { \
+ extern const char program_name[]; \
+ extern int S_PRINTF (const char *, ...); \
+ do_debug (level) \
+ S_PRINTF ("%s (%x):%s:%d: " fmt "\n", \
+ program_name, l4_myself (), __func__, __LINE__, \
+ ##__VA_ARGS__); \
+ } \
while (0)
/* Print an error message and fail. This function must be provided by