xref: /freebsd/contrib/llvm-project/llvm/include/llvm-c/Visibility.h (revision 700637cbb5e582861067a11aaca4d053546871d2)
1 /*===-- llvm-c/Visibility.h - Visibility macros for llvm-c ------*- C++ -*-===*\
2 |*                                                                            *|
3 |* Part of the LLVM Project, under the Apache License v2.0 with LLVM          *|
4 |* Exceptions.                                                                *|
5 |* See https://llvm.org/LICENSE.txt for license information.                  *|
6 |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception                    *|
7 |*                                                                            *|
8 |*===----------------------------------------------------------------------===*|
9 |*                                                                            *|
10 |* This header defines visibility macros used for the LLVM C interface. These *|
11 |* macros are used to annotate C functions that should be exported as part of *|
12 |* a shared library or DLL.                                                   *|
13 |*                                                                            *|
14 \*===----------------------------------------------------------------------===*/
15 
16 #ifndef LLVM_C_VISIBILITY_H
17 #define LLVM_C_VISIBILITY_H
18 
19 #include "llvm/Config/llvm-config.h"
20 
21 /// LLVM_C_ABI is the export/visibility macro used to mark symbols declared in
22 /// llvm-c as exported when built as a shared library.
23 
24 #if !defined(LLVM_ABI_GENERATING_ANNOTATIONS)
25 // TODO(https://github.com/llvm/llvm-project/issues/145406): eliminate need for
26 // two preprocessor definitions to gate LLVM_ABI macro definitions.
27 #if defined(LLVM_ENABLE_LLVM_C_EXPORT_ANNOTATIONS) &&                          \
28     !defined(LLVM_BUILD_STATIC)
29 #if defined(_WIN32) && !defined(__MINGW32__)
30 #if defined(LLVM_EXPORTS)
31 #define LLVM_C_ABI __declspec(dllexport)
32 #else
33 #define LLVM_C_ABI __declspec(dllimport)
34 #endif
35 #elif defined(__has_attribute) && __has_attribute(visibility)
36 #define LLVM_C_ABI __attribute__((visibility("default")))
37 #endif
38 #endif
39 #if !defined(LLVM_C_ABI)
40 #define LLVM_C_ABI
41 #endif
42 #endif
43 
44 #endif
45