Print this page
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero


  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  24  * Copyright (c) 2012 by Delphix. All rights reserved.
  25  * Copyright (c) 2012, Joyent, Inc. All rights reserved.
  26  */
  27 
  28 #ifndef _SYS_ZFS_CONTEXT_H
  29 #define _SYS_ZFS_CONTEXT_H
  30 
  31 #ifdef  __cplusplus
  32 extern "C" {
  33 #endif
  34 
  35 #define _SYS_MUTEX_H
  36 #define _SYS_RWLOCK_H
  37 #define _SYS_CONDVAR_H
  38 #define _SYS_SYSTM_H
  39 #define _SYS_DEBUG_H
  40 #define _SYS_T_LOCK_H
  41 #define _SYS_VNODE_H
  42 #define _SYS_VFS_H
  43 #define _SYS_SUNDDI_H
  44 #define _SYS_CALLB_H
  45 
  46 #include <stdio.h>
  47 #include <stdlib.h>
  48 #include <stddef.h>
  49 #include <stdarg.h>
  50 #include <fcntl.h>
  51 #include <unistd.h>
  52 #include <errno.h>
  53 #include <string.h>
  54 #include <strings.h>
  55 #include <synch.h>
  56 #include <thread.h>
  57 #include <assert.h>
  58 #include <alloca.h>
  59 #include <umem.h>


  61 #include <atomic.h>
  62 #include <dirent.h>
  63 #include <time.h>
  64 #include <libsysevent.h>
  65 #include <sys/note.h>
  66 #include <sys/types.h>
  67 #include <sys/cred.h>
  68 #include <sys/sysmacros.h>
  69 #include <sys/bitmap.h>
  70 #include <sys/resource.h>
  71 #include <sys/byteorder.h>
  72 #include <sys/list.h>
  73 #include <sys/uio.h>
  74 #include <sys/zfs_debug.h>
  75 #include <sys/sdt.h>
  76 #include <sys/kstat.h>
  77 #include <sys/u8_textprep.h>
  78 #include <sys/sysevent/eventdefs.h>
  79 #include <sys/sysevent/dev.h>
  80 #include <sys/sunddi.h>

  81 
  82 /*
  83  * Debugging
  84  */
  85 
  86 /*
  87  * Note that we are not using the debugging levels.
  88  */
  89 
  90 #define CE_CONT         0       /* continuation         */
  91 #define CE_NOTE         1       /* notice               */
  92 #define CE_WARN         2       /* warning              */
  93 #define CE_PANIC        3       /* panic                */
  94 #define CE_IGNORE       4       /* print nothing        */
  95 
  96 /*
  97  * ZFS debugging
  98  */
  99 
 100 #ifdef ZFS_DEBUG
 101 extern void dprintf_setup(int *argc, char **argv);
 102 #endif /* ZFS_DEBUG */
 103 
 104 extern void cmn_err(int, const char *, ...);
 105 extern void vcmn_err(int, const char *, __va_list);
 106 extern void panic(const char *, ...);
 107 extern void vpanic(const char *, __va_list);
 108 
 109 #define fm_panic        panic
 110 
 111 extern int aok;
 112 
 113 /* This definition is copied from assert.h. */
 114 #if defined(__STDC__)
 115 #if __STDC_VERSION__ - 0 >= 199901L
 116 #define zverify(EX) (void)((EX) || (aok) || \
 117         (__assert_c99(#EX, __FILE__, __LINE__, __func__), 0))
 118 #else
 119 #define zverify(EX) (void)((EX) || (aok) || \
 120         (__assert(#EX, __FILE__, __LINE__), 0))
 121 #endif /* __STDC_VERSION__ - 0 >= 199901L */
 122 #else
 123 #define zverify(EX) (void)((EX) || (aok) || \
 124         (_assert("EX", __FILE__, __LINE__), 0))
 125 #endif  /* __STDC__ */
 126 
 127 
 128 #define VERIFY  zverify
 129 #define ASSERT  zverify
 130 #undef  assert
 131 #define assert  zverify
 132 
 133 extern void __assert(const char *, const char *, int);
 134 
 135 #ifdef lint
 136 #define VERIFY3_IMPL(x, y, z, t)        if (x == z) ((void)0)
 137 #else
 138 /* BEGIN CSTYLED */
 139 #define VERIFY3_IMPL(LEFT, OP, RIGHT, TYPE) do { \
 140         const TYPE __left = (TYPE)(LEFT); \
 141         const TYPE __right = (TYPE)(RIGHT); \
 142         if (!(__left OP __right) && (!aok)) { \
 143                 char *__buf = alloca(256); \
 144                 (void) snprintf(__buf, 256, "%s %s %s (0x%llx %s 0x%llx)", \
 145                         #LEFT, #OP, #RIGHT, \
 146                         (u_longlong_t)__left, #OP, (u_longlong_t)__right); \
 147                 __assert(__buf, __FILE__, __LINE__); \
 148         } \
 149 _NOTE(CONSTCOND) } while (0)
 150 /* END CSTYLED */
 151 #endif /* lint */
 152 
 153 #define VERIFY3S(x, y, z)       VERIFY3_IMPL(x, y, z, int64_t)
 154 #define VERIFY3U(x, y, z)       VERIFY3_IMPL(x, y, z, uint64_t)
 155 #define VERIFY3P(x, y, z)       VERIFY3_IMPL(x, y, z, uintptr_t)
 156 
 157 #ifdef NDEBUG
 158 #define ASSERT3S(x, y, z)       ((void)0)
 159 #define ASSERT3U(x, y, z)       ((void)0)
 160 #define ASSERT3P(x, y, z)       ((void)0)
 161 #else
 162 #define ASSERT3S(x, y, z)       VERIFY3S(x, y, z)
 163 #define ASSERT3U(x, y, z)       VERIFY3U(x, y, z)
 164 #define ASSERT3P(x, y, z)       VERIFY3P(x, y, z)
 165 #endif
 166 
 167 /*
 168  * DTrace SDT probes have different signatures in userland than they do in
 169  * kernel.  If they're being used in kernel code, re-define them out of
 170  * existence for their counterparts in libzpool.
 171  */
 172 
 173 #ifdef DTRACE_PROBE
 174 #undef  DTRACE_PROBE
 175 #define DTRACE_PROBE(a) ((void)0)
 176 #endif  /* DTRACE_PROBE */
 177 
 178 #ifdef DTRACE_PROBE1
 179 #undef  DTRACE_PROBE1
 180 #define DTRACE_PROBE1(a, b, c)  ((void)0)
 181 #endif  /* DTRACE_PROBE1 */
 182 
 183 #ifdef DTRACE_PROBE2
 184 #undef  DTRACE_PROBE2
 185 #define DTRACE_PROBE2(a, b, c, d, e)    ((void)0)
 186 #endif  /* DTRACE_PROBE2 */




  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  24  * Copyright (c) 2012 by Delphix. All rights reserved.
  25  * Copyright (c) 2012, Joyent, Inc. All rights reserved.
  26  */
  27 
  28 #ifndef _SYS_ZFS_CONTEXT_H
  29 #define _SYS_ZFS_CONTEXT_H
  30 
  31 #ifdef  __cplusplus
  32 extern "C" {
  33 #endif
  34 
  35 #define _SYS_MUTEX_H
  36 #define _SYS_RWLOCK_H
  37 #define _SYS_CONDVAR_H
  38 #define _SYS_SYSTM_H

  39 #define _SYS_T_LOCK_H
  40 #define _SYS_VNODE_H
  41 #define _SYS_VFS_H
  42 #define _SYS_SUNDDI_H
  43 #define _SYS_CALLB_H
  44 
  45 #include <stdio.h>
  46 #include <stdlib.h>
  47 #include <stddef.h>
  48 #include <stdarg.h>
  49 #include <fcntl.h>
  50 #include <unistd.h>
  51 #include <errno.h>
  52 #include <string.h>
  53 #include <strings.h>
  54 #include <synch.h>
  55 #include <thread.h>
  56 #include <assert.h>
  57 #include <alloca.h>
  58 #include <umem.h>


  60 #include <atomic.h>
  61 #include <dirent.h>
  62 #include <time.h>
  63 #include <libsysevent.h>
  64 #include <sys/note.h>
  65 #include <sys/types.h>
  66 #include <sys/cred.h>
  67 #include <sys/sysmacros.h>
  68 #include <sys/bitmap.h>
  69 #include <sys/resource.h>
  70 #include <sys/byteorder.h>
  71 #include <sys/list.h>
  72 #include <sys/uio.h>
  73 #include <sys/zfs_debug.h>
  74 #include <sys/sdt.h>
  75 #include <sys/kstat.h>
  76 #include <sys/u8_textprep.h>
  77 #include <sys/sysevent/eventdefs.h>
  78 #include <sys/sysevent/dev.h>
  79 #include <sys/sunddi.h>
  80 #include <sys/debug.h>
  81 
  82 /*
  83  * Debugging
  84  */
  85 
  86 /*
  87  * Note that we are not using the debugging levels.
  88  */
  89 
  90 #define CE_CONT         0       /* continuation         */
  91 #define CE_NOTE         1       /* notice               */
  92 #define CE_WARN         2       /* warning              */
  93 #define CE_PANIC        3       /* panic                */
  94 #define CE_IGNORE       4       /* print nothing        */
  95 
  96 /*
  97  * ZFS debugging
  98  */
  99 
 100 #ifdef ZFS_DEBUG
 101 extern void dprintf_setup(int *argc, char **argv);
 102 #endif /* ZFS_DEBUG */
 103 
 104 extern void cmn_err(int, const char *, ...);
 105 extern void vcmn_err(int, const char *, __va_list);
 106 extern void panic(const char *, ...);
 107 extern void vpanic(const char *, __va_list);
 108 
 109 #define fm_panic        panic
 110 
 111 extern int aok;
 112 






















































 113 /*
 114  * DTrace SDT probes have different signatures in userland than they do in
 115  * kernel.  If they're being used in kernel code, re-define them out of
 116  * existence for their counterparts in libzpool.
 117  */
 118 
 119 #ifdef DTRACE_PROBE
 120 #undef  DTRACE_PROBE
 121 #define DTRACE_PROBE(a) ((void)0)
 122 #endif  /* DTRACE_PROBE */
 123 
 124 #ifdef DTRACE_PROBE1
 125 #undef  DTRACE_PROBE1
 126 #define DTRACE_PROBE1(a, b, c)  ((void)0)
 127 #endif  /* DTRACE_PROBE1 */
 128 
 129 #ifdef DTRACE_PROBE2
 130 #undef  DTRACE_PROBE2
 131 #define DTRACE_PROBE2(a, b, c, d, e)    ((void)0)
 132 #endif  /* DTRACE_PROBE2 */