1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28 /* All Rights Reserved */ 29 30 31 #ifndef _SYS_DEBUG_H 32 #define _SYS_DEBUG_H 33 34 #pragma ident "%Z%%M% %I% %E% SMI" 35 36 #include <sys/isa_defs.h> 37 38 #ifdef __cplusplus 39 extern "C" { 40 #endif 41 42 /* 43 * ASSERT(ex) causes a panic or debugger entry if expression ex is not 44 * true. ASSERT() is included only for debugging, and is a no-op in 45 * production kernels. VERIFY(ex), on the other hand, behaves like 46 * ASSERT on debug kernels but evaluates the expression on non-debug 47 * kernels. 48 */ 49 50 #ifdef _KERNEL 51 #if DEBUG 52 #define VERIFY(EX) ((void)((EX) || assfail(#EX, __FILE__, __LINE__))) 53 #else 54 #define VERIFY(EX) ((void)(EX)) 55 #endif 56 #endif 57 58 #if defined(__STDC__) 59 extern int assfail(const char *, const char *, int); 60 #if DEBUG 61 #define ASSERT(EX) ((void)((EX) || assfail(#EX, __FILE__, __LINE__))) 62 #else 63 #define ASSERT(x) ((void)0) 64 #endif 65 #else /* defined(__STDC__) */ 66 extern int assfail(); 67 #if DEBUG 68 #define ASSERT(EX) ((void)((EX) || assfail("EX", __FILE__, __LINE__))) 69 #else 70 #define ASSERT(x) ((void)0) 71 #endif 72 #endif /* defined(__STDC__) */ 73 74 /* 75 * Assertion variants sensitive to the compilation data model 76 */ 77 #if defined(_LP64) 78 #define ASSERT64(x) ASSERT(x) 79 #define ASSERT32(x) 80 #else 81 #define ASSERT64(x) 82 #define ASSERT32(x) ASSERT(x) 83 #endif 84 85 #ifdef _KERNEL 86 87 extern void abort_sequence_enter(char *); 88 extern void debug_enter(char *); 89 90 #endif /* _KERNEL */ 91 92 #ifdef MONITOR 93 #define MONITOR(id, w1, w2, w3, w4) monitor(id, w1, w2, w3, w4) 94 #else 95 #define MONITOR(id, w1, w2, w3, w4) 96 #endif 97 98 #if defined(DEBUG) && !defined(__sun) 99 /* CSTYLED */ 100 #define STATIC 101 #else 102 /* CSTYLED */ 103 #define STATIC static 104 #endif 105 106 #ifdef __cplusplus 107 } 108 #endif 109 110 #endif /* _SYS_DEBUG_H */ 111