Print this page
3373 gcc >= 4.5 concerns about offsetof()
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libumem/common/misc.h
+++ new/usr/src/lib/libumem/common/misc.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
20 20 */
21 21
22 22 /*
23 23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 27 #ifndef _MISC_H
28 28 #define _MISC_H
29 29
30 -#pragma ident "%Z%%M% %I% %E% SMI"
31 -
32 30 #include <sys/types.h>
33 31 #include <sys/time.h>
34 32 #include <thread.h>
35 33 #include <pthread.h>
36 34 #include <stdarg.h>
37 35
38 36 #ifdef __cplusplus
39 37 extern "C" {
40 38 #endif
41 39
42 40 extern uint_t umem_abort; /* abort when errors occur */
↓ open down ↓ |
1 lines elided |
↑ open up ↑ |
43 41 extern uint_t umem_output; /* output error messages to stderr */
44 42 extern caddr_t umem_min_stack; /* max stack address for audit log */
45 43 extern caddr_t umem_max_stack; /* min stack address for audit log */
46 44
47 45 /*
48 46 * various utility functions
49 47 * These are globally implemented.
50 48 */
51 49
52 50 #undef offsetof
51 +#if defined(__GNUC__)
52 +#define offsetof(s, m) __builtin_offsetof(s, m)
53 +#else
53 54 #define offsetof(s, m) ((size_t)(&(((s *)0)->m)))
55 +#endif
54 56
55 57 /*
56 58 * a safe printf -- do not use for error messages.
57 59 */
58 60 void debug_printf(const char *format, ...);
59 61
60 62 /*
61 63 * adds a message to the log without writing it out.
62 64 */
63 65 void log_message(const char *format, ...);
64 66
65 67 /*
66 68 * returns the index of the (high/low) bit + 1
67 69 */
68 70 int highbit(ulong_t);
69 71 int lowbit(ulong_t);
70 72 #pragma no_side_effect(highbit, lowbit)
71 73
72 74 /*
73 75 * Converts a hrtime_t to a timestruc_t
74 76 */
75 77 void hrt2ts(hrtime_t hrt, timestruc_t *tsp);
76 78
77 79 /*
78 80 * tries to print out the symbol and offset of a pointer using umem_error_info
79 81 */
80 82 int print_sym(void *pointer);
81 83
82 84 /*
83 85 * Information about the current error. Can be called multiple times, should
84 86 * be followed eventually with a call to umem_err or umem_err_recoverable.
85 87 */
86 88 void umem_printf(const char *format, ...);
87 89 void umem_vprintf(const char *format, va_list);
88 90
89 91 void umem_printf_warn(void *ignored, const char *format, ...);
90 92
91 93 void umem_error_enter(const char *);
92 94
93 95 /*
94 96 * prints error message and stack trace, then aborts. Cannot return.
95 97 */
96 98 void umem_panic(const char *format, ...) __NORETURN;
97 99 #pragma does_not_return(umem_panic)
98 100 #pragma rarely_called(umem_panic)
99 101
100 102 /*
101 103 * like umem_err, but only aborts if umem_abort > 0
102 104 */
103 105 void umem_err_recoverable(const char *format, ...);
104 106
105 107 /*
106 108 * We define our own assertion handling since libc's assert() calls malloc()
107 109 */
108 110 #ifdef NDEBUG
109 111 #define ASSERT(assertion) (void)0
110 112 #else
111 113 #define ASSERT(assertion) (void)((assertion) || \
112 114 __umem_assert_failed(#assertion, __FILE__, __LINE__))
113 115 #endif
114 116
115 117 int __umem_assert_failed(const char *assertion, const char *file, int line);
116 118 #pragma does_not_return(__umem_assert_failed)
117 119 #pragma rarely_called(__umem_assert_failed)
118 120 /*
119 121 * These have architecture-specific implementations.
120 122 */
121 123
122 124 /*
123 125 * Returns the current function's frame pointer.
124 126 */
125 127 extern void *getfp(void);
126 128
127 129 /*
128 130 * puts a pc-only stack trace of up to pcstack_limit frames into pcstack.
129 131 * Returns the number of stacks written.
130 132 *
131 133 * if check_sighandler != 0, and we are in a signal context, calls
132 134 * umem_err_recoverable.
133 135 */
134 136 extern int getpcstack(uintptr_t *pcstack, int pcstack_limit,
135 137 int check_sighandler);
136 138
137 139 #ifdef __cplusplus
138 140 }
139 141 #endif
140 142
141 143 #endif /* _MISC_H */
↓ open down ↓ |
78 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX