]> git.proxmox.com Git - mirror_zfs.git/blobdiff - include/os/linux/spl/sys/debug.h
Add VERIFY0P() and ASSERT0P() macros.
[mirror_zfs.git] / include / os / linux / spl / sys / debug.h
index 9bcc2e1d19238c2cdeb2f45a09c76963fef3682d..288193ad21c50973223a5883bdd3bd68641b25b9 100644 (file)
  * ASSERT3U()  - Assert unsigned X OP Y is true, if not panic.
  * ASSERT3P()  - Assert pointer X OP Y is true, if not panic.
  * ASSERT0()   - Assert value is zero, if not panic.
+ * ASSERT0P()  - Assert pointer is null, if not panic.
  * VERIFY()    - Verify X is true, if not panic.
  * VERIFY3B()  - Verify boolean X OP Y is true, if not panic.
  * VERIFY3S()  - Verify signed X OP Y is true, if not panic.
  * VERIFY3U()  - Verify unsigned X OP Y is true, if not panic.
  * VERIFY3P()  - Verify pointer X OP Y is true, if not panic.
  * VERIFY0()   - Verify value is zero, if not panic.
+ * VERIFY0P()  - Verify pointer is null, if not panic.
  */
 
 #ifndef _SPL_DEBUG_H
@@ -139,6 +141,15 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
                    (long long)_verify0_right);                         \
        } while (0)
 
+#define        VERIFY0P(RIGHT) do {                                            \
+               const uintptr_t _verify0_right = (uintptr_t)(RIGHT);    \
+               if (unlikely(!(0 == _verify0_right)))                   \
+                   spl_panic(__FILE__, __FUNCTION__, __LINE__,         \
+                   "VERIFY0P(" #RIGHT ") "                             \
+                   "failed (NULL == %px)\n",                           \
+                   (void *)_verify0_right);                            \
+       } while (0)
+
 #define        VERIFY_IMPLY(A, B) \
        ((void)(likely((!(A)) || (B)) ||                                \
            spl_assert("(" #A ") implies (" #B ")",                     \
@@ -164,6 +175,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
 #define        ASSERT3P(x, y, z)                                               \
        ((void) sizeof ((uintptr_t)(x)), (void) sizeof ((uintptr_t)(z)))
 #define        ASSERT0(x)              ((void) sizeof ((uintptr_t)(x)))
+#define        ASSERT0P(x)             ((void) sizeof ((uintptr_t)(x)))
 #define        IMPLY(A, B)                                                     \
        ((void) sizeof ((uintptr_t)(A)), (void) sizeof ((uintptr_t)(B)))
 #define        EQUIV(A, B)             \
@@ -179,6 +191,7 @@ spl_assert(const char *buf, const char *file, const char *func, int line)
 #define        ASSERT3U        VERIFY3U
 #define        ASSERT3P        VERIFY3P
 #define        ASSERT0         VERIFY0
+#define        ASSERT0P        VERIFY0P
 #define        ASSERT          VERIFY
 #define        IMPLY           VERIFY_IMPLY
 #define        EQUIV           VERIFY_EQUIV