nexmon – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 /*
2 * Cross platform defines for exporting symbols from shared libraries
3 *
4 * Wireshark - Network traffic analyzer
5 * By Balint Reczey <balint@balintreczey.hu>
6 * Copyright 2013 Balint Reczey
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22  
23 /** Reset symbol export behavior.
24 * If you {un}define WS_BUILD_DLL on the fly you'll have to define this
25 * as well.
26 */
27 #ifdef RESET_SYMBOL_EXPORT
28  
29 #ifdef SYMBOL_EXPORT_H
30 #undef SYMBOL_EXPORT_H
31 #endif
32  
33 #ifdef WS_DLL_PUBLIC
34 #undef WS_DLL_PUBLIC
35 #endif
36  
37 #ifdef WS_DLL_PUBLIC_DEF
38 #undef WS_DLL_PUBLIC_DEF
39 #endif
40  
41 #ifdef WS_DLL_LOCAL
42 #undef WS_DLL_LOCAL
43 #endif
44  
45 #endif /* RESET_SYMBOL_EXPORT */
46  
47 #ifndef SYMBOL_EXPORT_H
48 #define SYMBOL_EXPORT_H
49  
50 /*
51 * NOTE: G_HAVE_GNUC_VISIBILITY is defined only if all of
52 *
53 * __attribute__ ((visibility ("hidden")))
54 *
55 * __attribute__ ((visibility ("internal")))
56 *
57 * __attribute__ ((visibility ("protected")))
58 *
59 * __attribute__ ((visibility ("default")))
60 *
61 * are supported, and at least some versions of GCC from Apple support
62 * "default" and "hidden" but not "internal" or "protected", so it
63 * shouldn't be used to determine whether "hidden" or "default" is
64 * supported.
65 *
66 * This also means that we shouldn't use G_GNUC_INTERNAL instead of
67 * WS_DLL_LOCAL, as GLib uses G_HAVE_GNUC_VISIBILITY to determine
68 * whether to use __attribute__ ((visibility ("hidden"))) for
69 * G_GNUC_INTERNAL, and that will not use it even with compilers
70 * that support it.
71 */
72  
73 /* Originally copied from GCC Wiki at http://gcc.gnu.org/wiki/Visibility */
74 #if defined _WIN32 || defined __CYGWIN__
75 /* Compiling for Windows, so we use the Windows DLL declarations. */
76 #ifdef WS_BUILD_DLL
77 /*
78 * Building a DLL; for all definitions, we want dllexport, and
79 * (presumably so source from DLL and source from a program using the
80 * DLL can both include a header that declares APIs and exported data
81 * for the DLL), for declarations, either dllexport or dllimport will
82 * work (they mean the same thing for a declaration when building a DLL).
83 */
84 #ifdef __GNUC__
85 /* GCC */
86 #define WS_DLL_PUBLIC_DEF __attribute__ ((dllexport))
87 #else /* ! __GNUC__ */
88 /*
89 * Presumably MSVC.
90 * Note: actually gcc seems to also support this syntax.
91 */
92 #define WS_DLL_PUBLIC_DEF __declspec(dllexport)
93 #endif /* __GNUC__ */
94 #else /* WS_BUILD_DLL */
95 /*
96 * Building a program; we should only see declarations, not definitions,
97 * with WS_DLL_PUBLIC, and they all represent APIs or data imported
98 * from a DLL, so use dllimport.
99 *
100 * For functions, export shouldn't be necessary; for data, it might
101 * be necessary, e.g. if what's declared is an array whose size is
102 * not given in the declaration.
103 */
104 #ifdef __GNUC__
105 /* GCC */
106 #define WS_DLL_PUBLIC_DEF __attribute__ ((dllimport))
107 #elif ! (defined ENABLE_STATIC) /* ! __GNUC__ */
108 /*
109 * Presumably MSVC, and we're not building all-static.
110 * Note: actually gcc seems to also support this syntax.
111 */
112 #define WS_DLL_PUBLIC_DEF __declspec(dllimport)
113 #else /* ! __GNUC__ && ENABLE_STATIC */
114 /*
115 * Presumably MSVC, and we're building all-static, so we're
116 * not building any DLLs.
117 */
118 #define WS_DLL_PUBLIC_DEF
119 #endif /* __GNUC__ */
120 #endif /* WS_BUILD_DLL */
121  
122 /*
123 * Symbols in a DLL are *not* exported unless they're specifically
124 * flagged as exported, so, for a non-static but non-exported
125 * symbol, we don't have to do anything.
126 */
127 #define WS_DLL_LOCAL
128 #else /* defined _WIN32 || defined __CYGWIN__ */
129 /*
130 * Compiling for UN*X, where the dllimport and dllexport stuff
131 * is neither necessary nor supported; just specify the
132 * visibility if we have a compiler that claims compatibility
133 * with GCC 4 or later.
134 */
135 #if __GNUC__ >= 4
136 /*
137 * Symbols exported from libraries.
138 */
139 #define WS_DLL_PUBLIC_DEF __attribute__ ((visibility ("default")))
140  
141 /*
142 * Non-static symbols *not* exported from libraries.
143 */
144 #define WS_DLL_LOCAL __attribute__ ((visibility ("hidden")))
145 #else /* ! __GNUC__ >= 4 */
146 /*
147 * We have no way to make stuff not explicitly marked as
148 * visible invisible outside a library, but we might have
149 * a way to make stuff explicitly marked as local invisible
150 * outside the library.
151 *
152 * This was lifted from GLib; see above for why we don't use
153 * G_GNUC_INTERNAL.
154 */
155 #if defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)
156 /* This supports GCC-style __attribute__ ((visibility (XXX))) */
157 #define WS_DLL_PUBLIC_DEF __attribute__ ((visibility ("default")))
158 #define WS_DLL_LOCAL __attribute__ ((visibility ("hidden")))
159 #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
160 /* This doesn't, but supports __global and __hidden */
161 #define WS_DLL_PUBLIC_DEF __global
162 #define WS_DLL_LOCAL __hidden
163 #else /* not Sun C with "hidden" support */
164 #define WS_DLL_PUBLIC_DEF
165 #define WS_DLL_LOCAL
166 #endif
167 #endif /* __GNUC__ >= 4 */
168 #endif
169  
170 /*
171 * You *must* use this for exported data *declarations*; if you use
172 * WS_DLL_PUBLIC_DEF, some compilers, such as MSVC++, will complain
173 * about array definitions with no size.
174 *
175 * You must *not* use this for exported data *definitions*, as that
176 * will, for some compilers, cause warnings about items being initialized
177 * and declared extern.
178 *
179 * Either can be used for exported *function* declarations and definitions.
180 */
181 #define WS_DLL_PUBLIC WS_DLL_PUBLIC_DEF extern
182  
183 #endif /* SYMBOL_EXPORT_H */
184  
185 /*
186 * Editor modelines - http://www.wireshark.org/tools/modelines.html
187 *
188 * Local Variables:
189 * c-basic-offset: 2
190 * tab-width: 8
191 * indent-tabs-mode: nil
192 * End:
193 *
194 * vi: set shiftwidth=2 tabstop=8 expandtab:
195 * :indentSize=2:tabSize=8:noTabs=true:
196 */