Print this page
3373 gcc >= 4.5 concerns about offsetof()
Portions contributed by: Igor Pashev <pashev.igor@gmail.com>
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 * Copyright 2014 PALO, Richard.
33 33 */
34 34
35 35 /*
36 36 * An application should not include this header directly. Instead it
37 37 * should be included only through the inclusion of other Sun headers.
38 38 *
39 39 * The contents of this header is limited to identifiers specified in the
40 40 * C Standard. Any new identifiers specified in future amendments to the
41 41 * C Standard must be placed in this header. If these new identifiers
42 42 * are required to also be in the C++ Standard "std" namespace, then for
43 43 * anything other than macro definitions, corresponding "using" directives
44 44 * must also be added to <stddef.h.h>.
45 45 */
46 46
47 47 #ifndef _ISO_STDDEF_ISO_H
48 48 #define _ISO_STDDEF_ISO_H
49 49
50 50 #include <sys/isa_defs.h>
51 51 #include <sys/null.h>
52 52
53 53 #ifdef __cplusplus
54 54 extern "C" {
55 55 #endif
56 56
57 57 #if __cplusplus >= 199711L
58 58 namespace std {
59 59 #endif
60 60
61 61 #if !defined(_PTRDIFF_T) || __cplusplus >= 199711L
62 62 #define _PTRDIFF_T
63 63 #if defined(_LP64) || defined(_I32LPx)
64 64 typedef long ptrdiff_t; /* pointer difference */
65 65 #else
66 66 typedef int ptrdiff_t; /* (historical version) */
67 67 #endif
68 68 #endif /* !_PTRDIFF_T */
69 69
70 70 #if !defined(_SIZE_T) || __cplusplus >= 199711L
71 71 #define _SIZE_T
72 72 #if defined(_LP64) || defined(_I32LPx)
↓ open down ↓ |
72 lines elided |
↑ open up ↑ |
73 73 typedef unsigned long size_t; /* size of something in bytes */
74 74 #else
75 75 typedef unsigned int size_t; /* (historical version) */
76 76 #endif
77 77 #endif /* !_SIZE_T */
78 78
79 79 #if __cplusplus >= 199711L
80 80 }
81 81 #endif /* end of namespace std */
82 82
83 +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
84 +#define offsetof(s, m) __builtin_offsetof(s, m)
85 +#else
83 86 #if __cplusplus >= 199711L
84 87 #define offsetof(s, m) (std::size_t)(&(((s *)0)->m))
85 88 #else
86 89 #define offsetof(s, m) (size_t)(&(((s *)0)->m))
87 90 #endif
91 +#endif /* GNUC, etc. */
88 92
89 93 #ifdef __cplusplus
90 94 }
91 95 #endif
92 96
93 97 #endif /* _ISO_STDDEF_ISO_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX