Fix the fuzz failure reported (by me) in https://bugs.wireshark.org/bugzilla/show_bug...
[metze/wireshark/wip.git] / ws_symbol_export.h
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_NOEXTERN
38 #undef WS_DLL_PUBLIC_NOEXTERN
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 /* Originally copied from GCC Wiki at http://gcc.gnu.org/wiki/Visibility */
51 #if defined _WIN32 || defined __CYGWIN__
52   #ifdef WS_BUILD_DLL
53     #ifdef __GNUC__
54 #define WS_DLL_PUBLIC __attribute__ ((dllexport))
55     #else /* ! __GNUC__ */
56 #define WS_DLL_PUBLIC __declspec(dllexport) /* Note: actually gcc seems to also support this syntax. */
57     #endif /* __GNUC__ */
58   #else
59     #ifdef __GNUC__
60 #define WS_DLL_PUBLIC __attribute__ ((dllimport))
61     #elif ! (defined ENABLE_STATIC) /* ! __GNUC__ */
62 #define WS_DLL_PUBLIC __declspec(dllimport) /* Note: actually gcc seems to also support this syntax. */
63     #else /* ! __GNUC__  && ENABLE_STATIC */
64 #define WS_DLL_PUBLIC
65     #endif /* __GNUC__ */
66   #endif /* WS_BUILD_DLL */
67   #define WS_DLL_PUBLIC_NOEXTERN WS_DLL_PUBLIC
68   #define WS_DLL_LOCAL
69 #else
70   #if __GNUC__ >= 4
71 #define WS_DLL_PUBLIC __attribute__ ((visibility ("default"))) extern
72 #define WS_DLL_PUBLIC_NOEXTERN __attribute__ ((visibility ("default")))
73 #define WS_DLL_LOCAL  __attribute__ ((visibility ("hidden")))
74   #else /* ! __GNUC__ >= 4 */
75     #define WS_DLL_PUBLIC
76     #define WS_DLL_PUBLIC_NOEXTERN
77     #define WS_DLL_LOCAL extern
78   #endif /* __GNUC__ >= 4 */
79 #endif
80
81 #endif /* SYMBOL_EXPORT_H */