Skip to content

Commit d76b8d3

Browse files
committed
CXX-733: move INLINE macros to compiler.hpp
1 parent 1f5803b commit d76b8d3

File tree

6 files changed

+50
-16
lines changed

6 files changed

+50
-16
lines changed

src/bsoncxx/config/compiler.hpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2015 MongoDB Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#define BSONCXX_INLINE inline __attribute__((__visibility__("hidden"), __always_inline__))

src/bsoncxx/config/postlude.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
#undef BSONCXX_B64_ASSERT
1717
#pragma pop_macro("BSONCXX_B64_ASSERT")
1818

19+
// compiler.hpp
20+
#undef BSONCXX_INLINE
21+
#pragma pop_macro("BSONCXX_INLINE")
22+
1923
// src/bsoncxx/config/config.hpp.in
2024
#undef BSONCXX_INLINE_NAMESPACE_BEGIN
2125
#pragma pop_macro("BSONCXX_INLINE_NAMESPACE_BEGIN")
@@ -53,7 +57,5 @@
5357
#pragma pop_macro("BSONCXX_PRIVATE")
5458

5559
// prelude.hpp
56-
#undef BSONCXX_INLINE
57-
#pragma pop_macro("BSONCXX_INLINE")
5860
#undef BSONCXX_UNREACHABLE
5961
#pragma pop_macro("BSONCXX_UNREACHABLE")

src/bsoncxx/config/prelude.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
#pragma push_macro("BSONCXX_B64_ASSERT")
1717
#undef BSONCXX_B64_ASSERT
1818

19+
// compiler.hpp
20+
#pragma push_macro("BSONCXX_INLINE")
21+
#undef BSONCXX_INLINE
22+
1923
// src/bsoncxx/config/config.hpp.in
2024
#pragma push_macro("BSONCXX_INLINE_NAMESPACE_BEGIN")
2125
#undef BSONCXX_INLINE_NAMESPACE_BEGIN
@@ -52,15 +56,11 @@
5256
#pragma push_macro("BSONCXX_PRIVATE")
5357
#undef BSONCXX_PRIVATE
5458

59+
#include <bsoncxx/config/compiler.hpp>
5560
#include <bsoncxx/config/config.hpp>
5661
#include <bsoncxx/config/version.hpp>
5762
#include <bsoncxx/export.hpp>
5863

59-
// TODO to move this to a compiler.hpp header (CXX-733)
60-
#pragma push_macro("BSONCXX_INLINE")
61-
#undef BSONCXX_INLINE
62-
#define BSONCXX_INLINE inline __attribute__((__visibility__("hidden"), __always_inline__))
63-
6464
#pragma push_macro("BSONCXX_UNREACHABLE")
6565
#undef BSONCXX_UNREACHABLE
6666
#define BSONCXX_UNREACHABLE std::abort()

src/mongocxx/config/compiler.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2015 MongoDB Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
// TODO: DRY this definition with the one from bsoncxx/config/compiler.hpp per discussion
16+
// here - https://github.com/mongodb/mongo-cxx-driver/pull/374#issuecomment-158179295
17+
#define MONGOCXX_INLINE inline __attribute__((__visibility__("hidden"), __always_inline__))

src/mongocxx/config/postlude.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
// src/mongocxx/config/compiler.hpp
16+
#undef MONGOCXX_INLINE
17+
#pragma pop_macro("MONGOCXX_INLINE")
18+
1519
// src/mongocxx/config/config.hpp.in
1620
#undef MONGOCXX_INLINE_NAMESPACE_BEGIN
1721
#pragma pop_macro("MONGOCXX_INLINE_NAMESPACE_BEGIN")
@@ -45,7 +49,3 @@
4549
#pragma pop_macro("MONGOCXX_NO_DEPRECATED")
4650
#undef MONGOCXX_PRIVATE
4751
#pragma pop_macro("MONGOCXX_PRIVATE")
48-
49-
// prelude.hpp
50-
#undef MONGOCXX_INLINE
51-
#pragma pop_macro("MONGOCXX_INLINE")

src/mongocxx/config/prelude.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
// src/mongocxx/config/compiler.hpp
16+
#pragma push_macro("MONGOCXX_INLINE")
17+
#undef MONGOCXX_INLINE
18+
1519
// src/mongocxx/config/config.hpp.in
1620
#pragma push_macro("MONGOCXX_INLINE_NAMESPACE_BEGIN")
1721
#undef MONGOCXX_INLINE_NAMESPACE_BEGIN
@@ -46,11 +50,7 @@
4650
#pragma push_macro("MONGOCXX_PRIVATE")
4751
#undef MONGOCXX_PRIVATE
4852

53+
#include <mongocxx/config/compiler.hpp>
4954
#include <mongocxx/config/config.hpp>
5055
#include <mongocxx/config/version.hpp>
5156
#include <mongocxx/export.hpp>
52-
53-
// TODO to move this to a compiler.hpp header (CXX-733)
54-
#pragma push_macro("MONGOCXX_INLINE")
55-
#undef MONGOCXX_INLINE
56-
#define MONGOCXX_INLINE inline __attribute__ ((__visibility__("hidden"), __always_inline__))

0 commit comments

Comments
 (0)