• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2019 The libgav1 Authors
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef LIBGAV1_SRC_GAV1_SYMBOL_VISIBILITY_H_
18 #define LIBGAV1_SRC_GAV1_SYMBOL_VISIBILITY_H_
19 
20 // This module defines the LIBGAV1_PUBLIC macro. LIBGAV1_PUBLIC, when combined
21 // with the flags -fvisibility=hidden and -fvisibility-inlines-hidden, restricts
22 // symbol availability when users use the shared object form of libgav1. The
23 // intent is to prevent exposure of libgav1 internals to users of the library,
24 // and to avoid ABI compatibility problems that changes to libgav1 internals
25 // would cause for users of the libgav1 shared object.
26 //
27 // Examples:
28 //
29 // This form makes a class and all of its members part of the public API:
30 //
31 // class LIBGAV1_PUBLIC A {
32 //  public:
33 //   A();
34 //   ~A();
35 //   void Foo();
36 //   int Bar();
37 // };
38 //
39 // A::A(), A::~A(), A::Foo(), and A::Bar() are all available to code linking to
40 // the shared object when this form is used.
41 //
42 // This form exposes a single class method as part of the public API:
43 //
44 // class B {
45 //  public:
46 //   B();
47 //   ~B();
48 //   LIBGAV1_PUBLIC int Foo();
49 // };
50 //
51 // In this examples only B::Foo() is available to the user of the shared object.
52 //
53 // Non-class member functions can also be exposed individually:
54 //
55 // LIBGAV1_PUBLIC void Bar();
56 //
57 // In this example Bar() would be available to users of the shared object.
58 //
59 // Much of the above information and more can be found at
60 // https://gcc.gnu.org/wiki/Visibility
61 //
62 // NOTE: A third-party build system for libgav1 can add -DLIBGAV1_PUBLIC= to the
63 // compiler command line to override the definition of LIBGAV1_PUBLIC in this
64 // header. This can be used to create a libgav1 static library that will not
65 // export any symbols when it is linked into a shared library.
66 
67 #if !defined(LIBGAV1_PUBLIC)
68 #if defined(_WIN32)
69 #if defined(LIBGAV1_BUILDING_DLL) && LIBGAV1_BUILDING_DLL
70 #if defined(__GNUC__)
71 #define LIBGAV1_PUBLIC __attribute__((dllexport))
72 #else
73 #define LIBGAV1_PUBLIC __declspec(dllexport)
74 #endif  // defined(__GNUC__)
75 #elif defined(LIBGAV1_BUILDING_DLL)
76 #ifdef __GNUC__
77 #define LIBGAV1_PUBLIC __attribute__((dllimport))
78 #else
79 #define LIBGAV1_PUBLIC __declspec(dllimport)
80 #endif  // defined(__GNUC__)
81 #else
82 #define LIBGAV1_PUBLIC
83 #endif  // defined(LIBGAV1_BUILDING_DLL) && LIBGAV1_BUILDING_DLL
84 #else   // !defined(_WIN32)
85 #if defined(__GNUC__) && __GNUC__ >= 4
86 #define LIBGAV1_PUBLIC __attribute__((visibility("default")))
87 #else
88 #define LIBGAV1_PUBLIC
89 #endif
90 #endif  // defined(_WIN32)
91 #endif  // defined(LIBGAV1_PUBLIC)
92 
93 #endif  // LIBGAV1_SRC_GAV1_SYMBOL_VISIBILITY_H_
94