9075 Improve ZFS pool import/load process and corrupted pool recovery
[unleashed.git] / usr / src / uts / common / io / sfxge / sfxge_debug.h
blobb8a4a65c00be835ae24bf3aed1da9d0cbe83cef0
1 /*
2 * Copyright (c) 2008-2016 Solarflare Communications Inc.
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 * The views and conclusions contained in the software and documentation are
27 * those of the authors and should not be interpreted as representing official
28 * policies, either expressed or implied, of the FreeBSD Project.
31 #ifndef _SYS_SFXGE_DEBUG_H
32 #define _SYS_SFXGE_DEBUG_H
34 #include <sys/types.h>
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
40 #ifdef DEBUG
42 extern boolean_t sfxge_aask;
44 #define SFXGE_OBJ_CHECK(_objp, _type) \
45 do { \
46 uint8_t *p = (uint8_t *)(_objp); \
47 size_t off; \
49 for (off = 0; off < sizeof (_type); off++) { \
50 char buf[MAXNAMELEN]; \
52 if (*p++ == 0) \
53 continue; \
55 (void) snprintf(buf, MAXNAMELEN - 1, \
56 "%s[%d]: non-zero byte found in %s " \
57 "at 0x%p+%lx", __FILE__, __LINE__, #_type, \
58 (void *)(_objp), off); \
60 if (sfxge_aask) \
61 debug_enter(buf); \
62 break; \
63 } \
64 _NOTE(CONSTANTCONDITION) \
65 } while (B_FALSE)
67 /* Log cmn_err(9F) messages to console and system log */
68 #define SFXGE_CMN_ERR ""
70 #else /* DEBUG */
72 #define SFXGE_OBJ_CHECK(_objp, _type)
74 /* Log cmn_err(9F) messages to system log only */
75 #define SFXGE_CMN_ERR "!"
77 #endif /* DEBUG */
79 #ifdef __cplusplus
81 #endif
83 #endif /* _SYS_SFXGE_DEBUG_H */