]>
git.proxmox.com Git - mirror_zfs-debian.git/blob - zfs/lib/libumem/include/misc.h
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #include <sys/types.h>
42 extern uint_t umem_abort
; /* abort when errors occur */
43 extern uint_t umem_output
; /* output error messages to stderr */
44 extern caddr_t umem_min_stack
; /* max stack address for audit log */
45 extern caddr_t umem_max_stack
; /* min stack address for audit log */
48 * various utility functions
49 * These are globally implemented.
53 #define offsetof(s, m) ((size_t)(&(((s *)0)->m)))
56 * a safe printf -- do not use for error messages.
58 void debug_printf(const char *format
, ...);
61 * adds a message to the log without writing it out.
63 void log_message(const char *format
, ...);
66 * returns the index of the (high/low) bit + 1
70 #pragma no_side_effect(highbit, lowbit)
73 * Converts a hrtime_t to a timestruc_t
75 void hrt2ts(hrtime_t hrt
, timestruc_t
*tsp
);
78 * tries to print out the symbol and offset of a pointer using umem_error_info
80 int print_sym(void *pointer
);
83 * Information about the current error. Can be called multiple times, should
84 * be followed eventually with a call to umem_err or umem_err_recoverable.
86 void umem_printf(const char *format
, ...);
87 void umem_vprintf(const char *format
, va_list);
89 void umem_printf_warn(void *ignored
, const char *format
, ...);
91 void umem_error_enter(const char *);
94 * prints error message and stack trace, then aborts. Cannot return.
96 void umem_panic(const char *format
, ...) __NORETURN
;
97 #pragma does_not_return(umem_panic)
98 #pragma rarely_called(umem_panic)
101 * like umem_err, but only aborts if umem_abort > 0
103 void umem_err_recoverable(const char *format
, ...);
106 * We define our own assertion handling since libc's assert() calls malloc()
109 #define ASSERT(assertion) (void)0
111 #define ASSERT(assertion) (void)((assertion) || \
112 __umem_assert_failed(#assertion, __FILE__, __LINE__))
115 int __umem_assert_failed(const char *assertion
, const char *file
, int line
);
116 #pragma does_not_return(__umem_assert_failed)
117 #pragma rarely_called(__umem_assert_failed)
119 * These have architecture-specific implementations.
123 * Returns the current function's frame pointer.
125 extern void *getfp(void);
128 * puts a pc-only stack trace of up to pcstack_limit frames into pcstack.
129 * Returns the number of stacks written.
131 * if check_sighandler != 0, and we are in a signal context, calls
132 * umem_err_recoverable.
134 extern int getpcstack(uintptr_t *pcstack
, int pcstack_limit
,
135 int check_sighandler
);