1 // Copyright 2017 The Abseil Authors.
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 // This files is a forwarding header for other headers containing various
16 // portability macros and functions.
17 // This file is used for both C and C++!
18 // It also contains obsolete things that are pending cleanup but need to stay
19 // in Abseil for now.
20 
21 #ifndef S2_THIRD_PARTY_ABSL_BASE_PORT_H_
22 #define S2_THIRD_PARTY_ABSL_BASE_PORT_H_
23 
24 #include "s2/third_party/absl/base/attributes.h"
25 #include "s2/third_party/absl/base/config.h"
26 #include "s2/third_party/absl/base/optimization.h"
27 
28 #ifdef SWIG
29 %include "third_party/absl/base/attributes.h"
30 #endif
31 
32 // -----------------------------------------------------------------------------
33 // Obsolete (to be removed)
34 // -----------------------------------------------------------------------------
35 
36 // HAS_GLOBAL_STRING
37 // Some platforms have a ::string class that is different from ::std::string
38 // (although the interface is the same, of course).  On other platforms,
39 // ::string is the same as ::std::string.
40 #if defined(__cplusplus) && !defined(SWIG)
41 #include <string>
42 #ifndef HAS_GLOBAL_STRING
43 using std::basic_string;
44 using std::string;
45 // TODO(user): using std::wstring?
46 #endif  // HAS_GLOBAL_STRING
47 #endif  // SWIG, __cplusplus
48 
49 // NOTE: These live in Abseil purely as a short-term layering workaround to
50 // resolve a dependency chain between util/hash/hash, absl/strings, and //base:
51 // in order for //base to depend on absl/strings, the includes of hash need
52 // to be in absl, not //base.  string_view defines hashes.
53 //
54 // -----------------------------------------------------------------------------
55 // HASH_NAMESPACE, HASH_NAMESPACE_DECLARATION_START/END
56 // -----------------------------------------------------------------------------
57 
58 // Define the namespace for pre-C++11 functors for hash_map and hash_set.
59 // This is not the namespace for C++11 functors (that namespace is "std").
60 //
61 // We used to require that the build tool or Makefile provide this definition.
62 // Now we usually get it from testing target macros. If the testing target
63 // macros are different from an external definition, you will get a build
64 // error.
65 //
66 // TODO(user): always get HASH_NAMESPACE from testing target macros.
67 
68 #if defined(__GNUC__) && defined(GOOGLE_GLIBCXX_VERSION)
69 // Crosstool v17 or later.
70 #define HASH_NAMESPACE __gnu_cxx
71 #elif defined(_MSC_VER)
72 // MSVC.
73 // http://msdn.microsoft.com/en-us/library/6x7w9f6z(v=vs.100).aspx
74 #define HASH_NAMESPACE stdext
75 #elif defined(__APPLE__)
76 // Xcode.
77 #define HASH_NAMESPACE __gnu_cxx
78 #elif defined(__GNUC__)
79 // Some other version of gcc.
80 #define HASH_NAMESPACE __gnu_cxx
81 #else
82 // HASH_NAMESPACE defined externally.
83 // TODO(user): make this an error. Do not use external value of
84 // HASH_NAMESPACE.
85 #endif
86 
87 #ifndef HASH_NAMESPACE
88 // TODO(user): try to delete this.
89 // I think gcc 2.95.3 was the last toolchain to use this.
90 #define HASH_NAMESPACE_DECLARATION_START
91 #define HASH_NAMESPACE_DECLARATION_END
92 #else
93 #define HASH_NAMESPACE_DECLARATION_START namespace HASH_NAMESPACE {
94 #define HASH_NAMESPACE_DECLARATION_END }
95 #endif
96 
97 #endif  // S2_THIRD_PARTY_ABSL_BASE_PORT_H_
98