diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-10-18 08:53:40 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-10-18 08:53:40 +0000 |
commit | d6583bb2a13f329cf0332ef2570eb8bb8fc0e39c (patch) | |
tree | ece253b876159b39c620e62b6c9b1174642e070e /sys/arch/mac68k/dev/bounds.h |
initial import of NetBSD tree
Diffstat (limited to 'sys/arch/mac68k/dev/bounds.h')
-rw-r--r-- | sys/arch/mac68k/dev/bounds.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/sys/arch/mac68k/dev/bounds.h b/sys/arch/mac68k/dev/bounds.h new file mode 100644 index 00000000000..8aa02671763 --- /dev/null +++ b/sys/arch/mac68k/dev/bounds.h @@ -0,0 +1,34 @@ +/* $NetBSD: bounds.h,v 1.3 1995/04/21 02:47:47 briggs Exp $ */ + +#if defined(CHECKBOUNDS) + +#undef CHECKBOUNDS + +/* This requires ANSI C stringification. */ +#define CHECKBOUNDS(a, i) { \ + if ( (((a) + (i)) < (a)) || \ + (((a) + (i)) >= ((a) + (sizeof(a) / sizeof(*(a))))) ) { \ + printf("index " #i " (%d) exceeded bounds of " #a \ + ", '%s' line %d.\n", (i), __FILE__, __LINE__); \ + printf("halting...\n"); \ + /*asm(" stop #0x2700");*/ \ + } \ +} + +#define CHECKPOINTER(a, p) { \ + if ( ((p) < (a)) || \ + ((p) >= ((a) + (sizeof(a) / sizeof(*(a))))) ) { \ + printf("pointer " #p " (0x%X) exceeded bounds of " #a \ + " (0x%X), '%s' line %d.\n", \ + (p), (a), __FILE__, __LINE__); \ + printf("halting...\n"); \ + /*asm(" stop #0x2700");*/ \ + } \ +} + +#else /* !defined(CHECKBOUNDS) */ + +#define CHECKBOUNDS(a, i) +#define CHECKPOINTER(a, p) + +#endif /* defined(CHECKBOUNDS) */ |