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 // https://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 // absl:google3-begin(Internal-only note) 18 // It also contains obsolete things that are pending cleanup but need to stay 19 // in Abseil for now. 20 // absl:google3-end 21 22 #ifndef ABSL_BASE_PORT_H_ 23 #define ABSL_BASE_PORT_H_ 24 25 #include "third_party/abseil-cpp/absl/base/attributes.h" 26 #include "third_party/abseil-cpp/absl/base/config.h" 27 #include "third_party/abseil-cpp/absl/base/optimization.h" 28 29 // absl:google3-begin(Not shipping SWIG, global string, or hashing) 30 #ifdef SWIG 31 %include "third_party/absl/base/attributes.h" 32 #endif 33 34 // ----------------------------------------------------------------------------- 35 // Obsolete (to be removed) 36 // ----------------------------------------------------------------------------- 37 38 // NOTE: These live in Abseil purely as a short-term layering workaround to 39 // resolve a dependency chain between util/hash/hash, absl/strings, and //base: 40 // in order for //base to depend on absl/strings, the includes of hash need 41 // to be in absl, not //base. string_view defines hashes. 42 // 43 // ----------------------------------------------------------------------------- 44 // HASH_NAMESPACE, HASH_NAMESPACE_DECLARATION_START/END 45 // ----------------------------------------------------------------------------- 46 47 // Define the namespace for pre-C++11 functors for hash_map and hash_set. 48 // This is not the namespace for C++11 functors (that namespace is "std"). 49 // 50 // We used to require that the build tool or Makefile provide this definition. 51 // Now we usually get it from testing target macros. If the testing target 52 // macros are different from an external definition, you will get a build 53 // error. 54 // 55 // TODO(marmstrong): always get HASH_NAMESPACE from testing target macros. 56 57 #if defined(_MSC_VER) && !defined(_LIBCPP_VERSION) 58 // MSVC. 59 // http://msdn.microsoft.com/en-us/library/6x7w9f6z(v=vs.100).aspx 60 #define HASH_NAMESPACE stdext 61 #elif defined(__GNUC__) || defined(__APPLE__) || \ 62 (defined(_MSC_VER) && defined(_LIBCPP_VERSION)) 63 // Standard GCC-compatible compilation environment, or Xcode. 64 #define HASH_NAMESPACE __gnu_cxx 65 #else 66 // HASH_NAMESPACE defined externally. 67 // TODO(marmstrong): make this an error. Do not use external value of 68 // HASH_NAMESPACE. 69 #endif 70 71 #ifndef HASH_NAMESPACE 72 // TODO(marmstrong): try to delete this. 73 // I think gcc 2.95.3 was the last toolchain to use this. 74 #define HASH_NAMESPACE_DECLARATION_START 75 #define HASH_NAMESPACE_DECLARATION_END 76 #else 77 #define HASH_NAMESPACE_DECLARATION_START namespace HASH_NAMESPACE { 78 #define HASH_NAMESPACE_DECLARATION_END } 79 #endif 80 81 // Significant parts of //net/proto2, //util/hash, etc., assume that `hash` 82 // exists in the HASH_NAMESPACE. However, in MSVC runtime versions after VS 83 // 2015, Microsoft removed the directive: 84 // using _STD hash; 85 // from their stdext namespace, meaning that `hash` is no longer present. 86 // Since this is a change in layout, we temporarily restore this directive while 87 // we're working on removing this assumption. 88 // TODO(b/140888989): Remove this once the patch is no longer needed. 89 #if defined(_MSC_VER) && defined(__cplusplus) && !defined(_LIBCPP_VERSION) 90 #include <functional> 91 HASH_NAMESPACE_DECLARATION_START 92 using _STD hash; 93 HASH_NAMESPACE_DECLARATION_END 94 #endif 95 // absl:google3-end 96 97 #endif // THIRD_PARTY_ABSL_BASE_PORT_H_