]>
git.proxmox.com Git - mirror_zfs.git/blob - zfs/lib/libumem/misc.h
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 * Portions Copyright 2006 OmniTI, Inc.
33 /* #pragma ident "@(#)misc.h 1.6 05/06/08 SMI" */
36 #include <sys/types.h>
43 # include "sol_compat.h"
51 extern uint_t umem_abort
; /* abort when errors occur */
52 extern uint_t umem_output
; /* output error messages to stderr */
53 extern caddr_t umem_min_stack
; /* max stack address for audit log */
54 extern caddr_t umem_max_stack
; /* min stack address for audit log */
57 * various utility functions
58 * These are globally implemented.
62 #define offsetof(s, m) ((size_t)(&(((s *)0)->m)))
65 * a safe printf -- do not use for error messages.
67 void debug_printf(const char *format
, ...);
70 * adds a message to the log without writing it out.
72 void log_message(const char *format
, ...);
75 * returns the index of the (high/low) bit + 1
77 int highbit(ulong_t
) __attribute__ ((pure
));
78 int lowbit(ulong_t
) __attribute__ ((pure
));
79 /* #pragma no_side_effect(highbit, lowbit) */
82 * Converts a hrtime_t to a timestruc_t
84 void hrt2ts(hrtime_t hrt
, timestruc_t
*tsp
);
87 * tries to print out the symbol and offset of a pointer using umem_error_info
89 int print_sym(void *pointer
);
92 * Information about the current error. Can be called multiple times, should
93 * be followed eventually with a call to umem_err or umem_err_recoverable.
95 void umem_printf(const char *format
, ...);
96 void umem_vprintf(const char *format
, va_list);
98 void umem_printf_warn(void *ignored
, const char *format
, ...);
100 void umem_error_enter(const char *);
103 * prints error message and stack trace, then aborts. Cannot return.
105 void umem_panic(const char *format
, ...) __attribute__((noreturn
));
106 /* #pragma does_not_return(umem_panic) */
107 /* #pragma rarely_called(umem_panic) */
110 * like umem_err, but only aborts if umem_abort > 0
112 void umem_err_recoverable(const char *format
, ...);
115 * We define our own assertion handling since libc's assert() calls malloc()
118 #define ASSERT(assertion) (void)0
120 #define ASSERT(assertion) (void)((assertion) || \
121 __umem_assert_failed(#assertion, __FILE__, __LINE__))
124 int __umem_assert_failed(const char *assertion
, const char *file
, int line
) __attribute__ ((noreturn
));
125 /* #pragma does_not_return(__umem_assert_failed) */
126 /* #pragma rarely_called(__umem_assert_failed) */
128 * These have architecture-specific implementations.
132 * Returns the current function's frame pointer.
134 extern void *getfp(void);
137 * puts a pc-only stack trace of up to pcstack_limit frames into pcstack.
138 * Returns the number of stacks written.
140 * if check_sighandler != 0, and we are in a signal context, calls
141 * umem_err_recoverable.
143 extern int getpcstack(uintptr_t *pcstack
, int pcstack_limit
,
144 int check_sighandler
);