4 * Copyright 2003,2004 Develer S.r.l. (http://www.develer.com/)
5 * Copyright 2000,2001,2002 Bernardo Innocenti <bernie@codewiz.org>
6 * This file is part of DevLib - See devlib/README for information.
9 * \brief Definition of handy debug macros. These macros are no-ops
10 * when the preprocessor symbol _DEBUG isn't defined.
14 * \author Bernardo Innocenti <bernie@develer.com>
19 * Revision 1.3 2004/06/03 11:27:09 bernie
20 * Add dual-license information.
22 * Revision 1.2 2004/05/23 18:21:53 bernie
23 * Trim CVS logs and cleanup header info.
25 * Revision 1.1 2004/05/23 18:10:11 bernie
26 * Import drv/ modules.
34 /* Avoid name clashes with Win32 headers */
41 void kdump(const void *buf, size_t len);
45 #include <avr/pgmspace.h>
46 void kputs_P(const char *PROGMEM str);
47 void kprintf_P(const char *PROGMEM fmt, ...) FORMAT(__printf__, 1, 2);
48 int __assert_P(const char *PROGMEM cond, const char *PROGMEM file, int line);
49 int __invalid_ptr_P(void *p, const char *PROGMEM name, const char *PROGMEM file, int line);
50 #define kputs(str) kputs_P(PSTR(str))
51 #define kprintf(fmt, ...) kprintf_P(PSTR(fmt) ,## __VA_ARGS__)
52 #define __assert(cond, file, line) __assert_P(PSTR(cond), PSTR(file), (line))
53 #define __invalid_ptr(p, name, file, line) __invalid_ptr_P((p), PSTR(name), PSTR(file), (line))
56 void kputs(const char *str);
57 void kprintf(const char * fmt, ...) FORMAT(__printf__, 1, 2);
58 int __assert(const char *cond, const char *file, int line);
59 int __invalid_ptr(void *p, const char *name, const char *file, int line);
62 void __init_wall(long *wall, int size);
63 int __check_wall(long *wall, int size, const char *name, const char *file, int line);
65 #define THIS_FILE __FILE__
66 #define ASSERT(x) ((x) ? 0 : __assert(#x, THIS_FILE, __LINE__))
67 #define ASSERT_VALID_PTR(p) ((p >= 0x200) ? 0 : __invalid_ptr(p, #p, THIS_FILE, __LINE__))
68 #define ASSERT_VALID_PTR_OR_NULL(p) (((p == NULL) || (p >= 0x200)) ? 0 : __invalid_ptr(p, #p, THIS_FILE, __LINE__))
69 #define TRACE kprintf("%s()\n", __FUNCTION__)
70 #define TRACEMSG(msg,...) kprintf("%s(): " msg "\n", __FUNCTION__, ## __VA_ARGS__)
73 /* Walls to detect data corruption */
75 #define WALL_VALUE (long)0xABADCAFEL
76 #define DECLARE_WALL(name,size) static long name[(size) / sizeof(long)];
77 #define INIT_WALL(name) __init_wall((name), countof(name))
78 #define CHECK_WALL(name) __check_wall((name), countof(name), #name, THIS_FILE, __LINE__)
83 #define ASSERT_VALID_PTR(p)
84 #define ASSERT_VALID_PTR_OR_NULL(p)
85 #define TRACE do {} while(0)
86 #define TRACEMSG(x,...) do {} while(0)
89 #define DECLARE_WALL(name, size)
90 #define INIT_WALL(name)
91 #define CHECK_WALL(name)