Hallo, dies ist ein Test.
PWD: /www/data-lst1/unixsoft/unixsoft/kaempfer/.public_html
Running in File Mode
Relative path: ./../../../../../../usr/include/sys/debug.h
Real path: /usr/include/sys/debug.h
Zurück
/* * Copyright (c) 1988, 2017, Oracle and/or its affiliates. All rights reserved. */ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ /* All Rights Reserved */ #ifndef _SYS_DEBUG_H #define _SYS_DEBUG_H #include <sys/isa_defs.h> #include <sys/types.h> #include <sys/note.h> #include <sys/static_assert.h> #ifdef __cplusplus extern "C" { #endif #ifndef _KERNEL #define assfail _assfail #define assfail3 _assfail3 #endif /* * ASSERT(ex) causes a panic or debugger entry if expression ex is not * true. ASSERT() is included only for debugging, and is a no-op in * production kernels. VERIFY(ex), on the other hand, behaves like * ASSERT and is evaluated on both debug and non-debug kernels. */ extern int assfail(const char *, const char *, int); #define __ASSERT_LINE_PREFIX "__assfailline__" #ifdef _KERNEL /* * __LINE__ uses cause ksplice to create splices for unmodified functions * when other functions earlier in the source file are modified. * * The following is here to prevent this. * * __LINE__ uses in the ASSERT family of macros are replaced by the use of a * special relocatable symbol of the template * __assfail_line__<linenumber> * where <linenumber> is the line number of the location of the use of the * macro. * * The ksplice generation mechanism ignores differences in object files due to * these special symbols. * * At module load time, the kernel runtime loader replaces uses of these * symbols with the corresponding line number. */ #define __ASSERT_LINE_CONCAT1(x, y) x ## y #define __ASSERT_LINE_CONCAT2(x, y) __ASSERT_LINE_CONCAT1(x, y) #define __ASSERT_LINE_VAR __ASSERT_LINE_CONCAT2(__assfailline__, \ __LINE__) #define __ASSERT_LINE_DECL extern char __ASSERT_LINE_VAR #define __ASSERT_LINE_SYMBOL (uint_t)(uintptr_t)&__ASSERT_LINE_VAR #define VERIFY(EX) \ do { \ __ASSERT_LINE_DECL; \ ((void)((EX) || assfail(#EX, __FILE__, __ASSERT_LINE_SYMBOL)));\ _NOTE(CONSTCOND) } while (0) #if DEBUG #define ASSERT(EX) \ do { \ __ASSERT_LINE_DECL; \ ((void)((EX) || assfail(#EX, __FILE__, __ASSERT_LINE_SYMBOL)));\ _NOTE(CONSTCOND) } while (0) #else #define ASSERT(x) ((void)0) #endif /* DEBUG */ #else /* _KERNEL */ #define VERIFY(EX) ((void)((EX) || assfail(#EX, __FILE__, __LINE__))) #if DEBUG #define ASSERT(EX) ((void)((EX) || assfail(#EX, __FILE__, __LINE__))) #else #define ASSERT(x) ((void)0) #endif /* DEBUG */ #endif /* _KERNEL */ /* * Assertion variants sensitive to the compilation data model */ #if defined(_LP64) #define ASSERT64(x) ASSERT(x) #define ASSERT32(x) #else #define ASSERT64(x) #define ASSERT32(x) ASSERT(x) #endif /* * These assertion are of the form: * * IMPLY(A, B) if (A) then (B) * (fails if A is true and B is not) * * EQUIV(A, B) if (A) then (B) *AND* if (B) then (A) * (fails if one is true and the other is false) * * ASSERT_JUST_ONE(A,B) if (A) then !(B) *AND* if !(B) then (A) * (fails if both are true or both are false) * * Like regular ASSERTs, these are only active in DEBUG builds. They all * evaluate A and B logically (0 is false, non-zero is true). EQUIV() and * ASSERT_JUST_ONE() will report the truth values of A and B in their assertion * message. */ #if DEBUG #ifdef _KERNEL #define IMPLY(A, B) do { \ __ASSERT_LINE_DECL; \ ((void)(((!(A)) || (B)) || \ assfail("(" #A ") implies (" #B ")", __FILE__, \ __ASSERT_LINE_SYMBOL))); \ _NOTE(CONSTCOND) } while (0) #define EQUIV(A, B) do { \ const uintmax_t __left = !!(uint64_t)(A); \ const uintmax_t __right = !!(uint64_t)(B); \ if (__left != __right) { \ __ASSERT_LINE_DECL; \ assfail3("(" #A ") is equivalent to (" #B ")", \ __left, "==", __right, \ __FILE__, __ASSERT_LINE_SYMBOL); \ } \ _NOTE(CONSTCOND) } while (0) #define ASSERT_JUST_ONE(A, B) do { \ const uintmax_t __left = !!(uint64_t)(A); \ const uintmax_t __right = !!(uint64_t)(B); \ if (__left == __right) { \ __ASSERT_LINE_DECL; \ assfail3("Just one of (" #A ") or (" #B ") must be true", \ __left, "!=", __right, \ __FILE__, __ASSERT_LINE_SYMBOL); \ } \ _NOTE(CONSTCOND) } while (0) #else /* _KERNEL */ #define IMPLY(A, B) \ ((void)(((!(A)) || (B)) || \ assfail("(" #A ") implies (" #B ")", __FILE__, __LINE__))) #define EQUIV(A, B) do {\ const uintmax_t __left = !!(uint64_t)(A); \ const uintmax_t __right = !!(uint64_t)(B); \ if (__left != __right) \ assfail3("(" #A ") is equivalent to (" #B ")",\ __left, "==", __right, \ __FILE__, __LINE__); \ _NOTE(CONSTCOND) } while (0) #define ASSERT_JUST_ONE(A, B) do { \ const uintmax_t __left = !!(uint64_t)(A); \ const uintmax_t __right = !!(uint64_t)(B); \ if (__left == __right) \ assfail3("Just one of (" #A ") or (" #B ") must be true", \ __left, "!=", __right, \ __FILE__, __LINE__); \ _NOTE(CONSTCOND) } while (0) #endif /* _KERNEL */ #else #define IMPLY(A, B) ((void)0) #define EQUIV(A, B) ((void)0) #define ASSERT_JUST_ONE(A, B) ((void)0) #endif /* * ASSERT3() behaves like ASSERT() except that it is an explicit conditional, * and prints out the values of the left and right hand expressions as part of * the panic message to ease debugging. The three variants imply the type * of their arguments. ASSERT3S() is for signed data types, ASSERT3U() is * for unsigned, and ASSERT3P() is for pointers. The VERIFY3*() macros * have the same relationship as above. */ extern void assfail3(const char *, uintmax_t, const char *, uintmax_t, const char *, int); #ifdef _KERNEL #define VERIFY3_IMPL(LEFT, SLEFT, OP, SOP, RIGHT, SRIGHT, TYPE) do { \ const TYPE __left = (TYPE)(LEFT); \ const TYPE __right = (TYPE)(RIGHT); \ if (!(__left OP __right)) { \ __ASSERT_LINE_DECL; \ assfail3(SLEFT " " SOP " " SRIGHT, \ (uintmax_t)__left, SOP, (uintmax_t)__right, \ __FILE__, __ASSERT_LINE_SYMBOL); \ } \ _NOTE(CONSTCOND) } while (0) #else /* _KERNEL */ #define VERIFY3_IMPL(LEFT, SLEFT, OP, SOP, RIGHT, SRIGHT, TYPE) do { \ const TYPE __left = (TYPE)(LEFT); \ const TYPE __right = (TYPE)(RIGHT); \ if (!(__left OP __right)) \ assfail3(SLEFT " " SOP " " SRIGHT, \ (uintmax_t)__left, SOP, (uintmax_t)__right, \ __FILE__, __LINE__); \ _NOTE(CONSTCOND) } while (0) #endif /* _KERNEL */ #define VERIFY3S(x, y, z) VERIFY3_IMPL(x, #x, y, #y, z, #z, int64_t) #define VERIFY3U(x, y, z) VERIFY3_IMPL(x, #x, y, #y, z, #z, uint64_t) #define VERIFY3P(x, y, z) VERIFY3_IMPL(x, #x, y, #y, z, #z, uintptr_t) #if DEBUG #define ASSERT3S(x, y, z) VERIFY3_IMPL(x, #x, y, #y, z, #z, int64_t) #define ASSERT3U(x, y, z) VERIFY3_IMPL(x, #x, y, #y, z, #z, uint64_t) #define ASSERT3P(x, y, z) VERIFY3_IMPL(x, #x, y, #y, z, #z, uintptr_t) #else #define ASSERT3S(x, y, z) ((void)0) #define ASSERT3U(x, y, z) ((void)0) #define ASSERT3P(x, y, z) ((void)0) #endif /* * Test that a pointer is valid (that is, it points to a valid, readable memory * location). */ #define VERIFY_PTR(p) ((void) ((volatile char *)p)[0]) #ifdef _KERNEL extern void abort_sequence_enter(char *); extern int abort_retry_required(void); extern void debug_enter(char *); #endif /* _KERNEL */ #if defined(DEBUG) && !defined(__sun) /* CSTYLED */ #define STATIC #else /* CSTYLED */ #define STATIC static #endif #ifdef __cplusplus } #endif #endif /* _SYS_DEBUG_H */