visibility.h
1 /* visibility.h
2  *
3  * Copyright (C) 2006-2020 wolfSSL Inc.
4  *
5  * This file is part of wolfSSL.
6  *
7  * wolfSSL is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * wolfSSL is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20  */
21 
22 
23 /* Visibility control macros */
24 
25 #ifndef WOLF_CRYPT_VISIBILITY_H
26 #define WOLF_CRYPT_VISIBILITY_H
27 
28 
29 /* for compatibility and so that fips is using same name of macro @wc_fips */
30 /* The following visibility wrappers are for old FIPS. New FIPS should use
31  * the same as a non-FIPS build. */
32 #if defined(HAVE_FIPS) && \
33  (!defined(HAVE_FIPS_VERSION) || (HAVE_FIPS_VERSION < 2))
34  #include <cyassl/ctaocrypt/visibility.h>
35  #define WOLFSSL_API CYASSL_API
36  #define WOLFSSL_LOCAL CYASSL_LOCAL
37 #else
38 
39 /* WOLFSSL_API is used for the public API symbols.
40  It either imports or exports (or does nothing for static builds)
41 
42  WOLFSSL_LOCAL is used for non-API symbols (private).
43 */
44 
45 #if defined(BUILDING_WOLFSSL)
46  #if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__)
47  #if defined(WOLFSSL_DLL)
48  #define WOLFSSL_API __declspec(dllexport)
49  #else
50  #define WOLFSSL_API
51  #endif
52  #define WOLFSSL_LOCAL
53  #elif defined(HAVE_VISIBILITY) && HAVE_VISIBILITY
54  #define WOLFSSL_API __attribute__ ((visibility("default")))
55  #define WOLFSSL_LOCAL __attribute__ ((visibility("hidden")))
56  #elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x550)
57  #define WOLFSSL_API __global
58  #define WOLFSSL_LOCAL __hidden
59  #else
60  #define WOLFSSL_API
61  #define WOLFSSL_LOCAL
62  #endif /* HAVE_VISIBILITY */
63 #else /* BUILDING_WOLFSSL */
64  #if defined(_MSC_VER) || defined(__MINGW32__) || defined(__CYGWIN__)
65  #if defined(WOLFSSL_DLL)
66  #define WOLFSSL_API __declspec(dllimport)
67  #else
68  #define WOLFSSL_API
69  #endif
70  #define WOLFSSL_LOCAL
71  #else
72  #define WOLFSSL_API
73  #define WOLFSSL_LOCAL
74  #endif
75 #endif /* BUILDING_WOLFSSL */
76 
77 #endif /* HAVE_FIPS */
78 #endif /* WOLF_CRYPT_VISIBILITY_H */
79