4 * Copyright 2003,2004 Develer S.r.l. (http://www.develer.com/)
5 * Copyright 2000,2001,2002 Bernardo Innocenti <bernie@codewiz.org>
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.2 2004/05/23 18:21:53 bernie
20 * Trim CVS logs and cleanup header info.
22 * Revision 1.1 2004/05/23 18:10:11 bernie
23 * Import drv/ modules.
31 /* Avoid name clashes with Win32 headers */
38 void kdump(const void *buf, size_t len);
42 #include <avr/pgmspace.h>
43 void kputs_P(const char *PROGMEM str);
44 void kprintf_P(const char *PROGMEM fmt, ...) FORMAT(__printf__, 1, 2);
45 int __assert_P(const char *PROGMEM cond, const char *PROGMEM file, int line);
46 int __invalid_ptr_P(void *p, const char *PROGMEM name, const char *PROGMEM file, int line);
47 #define kputs(str) kputs_P(PSTR(str))
48 #define kprintf(fmt, ...) kprintf_P(PSTR(fmt) ,## __VA_ARGS__)
49 #define __assert(cond, file, line) __assert_P(PSTR(cond), PSTR(file), (line))
50 #define __invalid_ptr(p, name, file, line) __invalid_ptr_P((p), PSTR(name), PSTR(file), (line))
53 void kputs(const char *str);
54 void kprintf(const char * fmt, ...) FORMAT(__printf__, 1, 2);
55 int __assert(const char *cond, const char *file, int line);
56 int __invalid_ptr(void *p, const char *name, const char *file, int line);
59 void __init_wall(long *wall, int size);
60 int __check_wall(long *wall, int size, const char *name, const char *file, int line);
62 #define THIS_FILE __FILE__
63 #define ASSERT(x) ((x) ? 0 : __assert(#x, THIS_FILE, __LINE__))
64 #define ASSERT_VALID_PTR(p) ((p >= 0x200) ? 0 : __invalid_ptr(p, #p, THIS_FILE, __LINE__))
65 #define ASSERT_VALID_PTR_OR_NULL(p) (((p == NULL) || (p >= 0x200)) ? 0 : __invalid_ptr(p, #p, THIS_FILE, __LINE__))
66 #define TRACE kprintf("%s()\n", __FUNCTION__)
67 #define TRACEMSG(msg,...) kprintf("%s(): " msg "\n", __FUNCTION__, ## __VA_ARGS__)
70 /* Walls to detect data corruption */
72 #define WALL_VALUE (long)0xABADCAFEL
73 #define DECLARE_WALL(name,size) static long name[(size) / sizeof(long)];
74 #define INIT_WALL(name) __init_wall((name), countof(name))
75 #define CHECK_WALL(name) __check_wall((name), countof(name), #name, THIS_FILE, __LINE__)
80 #define ASSERT_VALID_PTR(p)
81 #define ASSERT_VALID_PTR_OR_NULL(p)
82 #define TRACE do {} while(0)
83 #define TRACEMSG(x,...) do {} while(0)
86 #define DECLARE_WALL(name, size)
87 #define INIT_WALL(name)
88 #define CHECK_WALL(name)