Print this page
3373 gcc >= 4.5 concerns about offsetof()
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/head/iso/stddef_iso.h
+++ new/usr/src/head/iso/stddef_iso.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, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22 /* Copyright (c) 1988 AT&T */
23 23 /* All Rights Reserved */
24 24
25 25
26 26 /*
27 27 * Copyright 1999-2003 Sun Microsystems, Inc. All rights reserved.
28 28 * Use is subject to license terms.
29 29 */
30 30
31 31 /*
32 32 * An application should not include this header directly. Instead it
33 33 * should be included only through the inclusion of other Sun headers.
34 34 *
35 35 * The contents of this header is limited to identifiers specified in the
↓ open down ↓ |
35 lines elided |
↑ open up ↑ |
36 36 * C Standard. Any new identifiers specified in future amendments to the
37 37 * C Standard must be placed in this header. If these new identifiers
38 38 * are required to also be in the C++ Standard "std" namespace, then for
39 39 * anything other than macro definitions, corresponding "using" directives
40 40 * must also be added to <stddef.h.h>.
41 41 */
42 42
43 43 #ifndef _ISO_STDDEF_ISO_H
44 44 #define _ISO_STDDEF_ISO_H
45 45
46 -#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.5 */
47 -
48 46 #include <sys/isa_defs.h>
49 47
50 48 #ifdef __cplusplus
51 49 extern "C" {
52 50 #endif
53 51
54 52 #if __cplusplus >= 199711L
55 53 namespace std {
56 54 #endif
57 55
58 56 #ifndef NULL
59 57 #if defined(_LP64)
60 58 #define NULL 0L
61 59 #else
62 60 #define NULL 0
63 61 #endif
64 62 #endif
65 63
66 64 #if !defined(_PTRDIFF_T) || __cplusplus >= 199711L
67 65 #define _PTRDIFF_T
68 66 #if defined(_LP64) || defined(_I32LPx)
69 67 typedef long ptrdiff_t; /* pointer difference */
70 68 #else
71 69 typedef int ptrdiff_t; /* (historical version) */
72 70 #endif
73 71 #endif /* !_PTRDIFF_T */
74 72
75 73 #if !defined(_SIZE_T) || __cplusplus >= 199711L
76 74 #define _SIZE_T
77 75 #if defined(_LP64) || defined(_I32LPx)
78 76 typedef unsigned long size_t; /* size of something in bytes */
79 77 #else
80 78 typedef unsigned int size_t; /* (historical version) */
↓ open down ↓ |
23 lines elided |
↑ open up ↑ |
81 79 #endif
82 80 #endif /* !_SIZE_T */
83 81
84 82 #if __cplusplus >= 199711L
85 83 }
86 84 #endif /* end of namespace std */
87 85
88 86 #if __cplusplus >= 199711L
89 87 #define offsetof(s, m) (std::size_t)(&(((s *)0)->m))
90 88 #else
91 -#define offsetof(s, m) (size_t)(&(((s *)0)->m))
89 +#if defined(__GNUC__)
90 +#define offsetof(s, m) __builtin_offsetof(s, m)
91 +#else
92 +#define offsetof(s, m) ((size_t)(&(((s *)0)->m)))
93 +#endif
92 94 #endif
93 95
94 96 #ifdef __cplusplus
95 97 }
96 98 #endif
97 99
98 100 #endif /* _ISO_STDDEF_ISO_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX