| 1 | // Copyright 2016 Google Inc. All Rights Reserved. |
| 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 | #include "absl/time/internal/cctz/include/cctz/zone_info_source.h" |
| 16 | |
| 17 | namespace absl { |
| 18 | namespace time_internal { |
| 19 | namespace cctz { |
| 20 | |
| 21 | // Defined out-of-line to avoid emitting a weak vtable in all TUs. |
| 22 | ZoneInfoSource::~ZoneInfoSource() {} |
| 23 | std::string ZoneInfoSource::Version() const { return std::string(); } |
| 24 | |
| 25 | } // namespace cctz |
| 26 | } // namespace time_internal |
| 27 | } // namespace absl |
| 28 | |
| 29 | namespace absl { |
| 30 | namespace time_internal { |
| 31 | namespace cctz_extension { |
| 32 | |
| 33 | namespace { |
| 34 | |
| 35 | // A default for cctz_extension::zone_info_source_factory, which simply |
| 36 | // defers to the fallback factory. |
| 37 | std::unique_ptr<absl::time_internal::cctz::ZoneInfoSource> DefaultFactory( |
| 38 | const std::string& name, |
| 39 | const std::function<std::unique_ptr<absl::time_internal::cctz::ZoneInfoSource>( |
| 40 | const std::string& name)>& fallback_factory) { |
| 41 | return fallback_factory(name); |
| 42 | } |
| 43 | |
| 44 | } // namespace |
| 45 | |
| 46 | // A "weak" definition for cctz_extension::zone_info_source_factory. |
| 47 | // The user may override this with their own "strong" definition (see |
| 48 | // zone_info_source.h). |
| 49 | #if !defined(__has_attribute) |
| 50 | #define __has_attribute(x) 0 |
| 51 | #endif |
| 52 | #if __has_attribute(weak) || defined(__GNUC__) |
| 53 | ZoneInfoSourceFactory zone_info_source_factory |
| 54 | __attribute__((weak)) = DefaultFactory; |
| 55 | #elif defined(_MSC_VER) && !defined(_LIBCPP_VERSION) |
| 56 | extern ZoneInfoSourceFactory zone_info_source_factory; |
| 57 | extern ZoneInfoSourceFactory default_factory; |
| 58 | ZoneInfoSourceFactory default_factory = DefaultFactory; |
| 59 | #if defined(_M_IX86) |
| 60 | #pragma comment( \ |
| 61 | linker, \ |
| 62 | "/alternatename:?zone_info_source_factory@cctz_extension@time_internal@absl@@3P6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@absl@@U?$default_delete@VZoneInfoSource@cctz@time_internal@absl@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@ABV?$function@$$A6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@absl@@U?$default_delete@VZoneInfoSource@cctz@time_internal@absl@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z@5@@ZA=?default_factory@cctz_extension@time_internal@absl@@3P6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@absl@@U?$default_delete@VZoneInfoSource@cctz@time_internal@absl@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@ABV?$function@$$A6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@absl@@U?$default_delete@VZoneInfoSource@cctz@time_internal@absl@@@std@@@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z@5@@ZA") |
| 63 | #elif defined(_M_IA_64) || defined(_M_AMD64) || defined(_M_ARM64) |
| 64 | #pragma comment( \ |
| 65 | linker, \ |
| 66 | "/alternatename:?zone_info_source_factory@cctz_extension@time_internal@absl@@3P6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@absl@@U?$default_delete@VZoneInfoSource@cctz@time_internal@absl@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@AEBV?$function@$$A6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@absl@@U?$default_delete@VZoneInfoSource@cctz@time_internal@absl@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z@5@@ZEA=?default_factory@cctz_extension@time_internal@absl@@3P6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@absl@@U?$default_delete@VZoneInfoSource@cctz@time_internal@absl@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@AEBV?$function@$$A6A?AV?$unique_ptr@VZoneInfoSource@cctz@time_internal@absl@@U?$default_delete@VZoneInfoSource@cctz@time_internal@absl@@@std@@@std@@AEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z@5@@ZEA") |
| 67 | #else |
| 68 | #error Unsupported MSVC platform |
| 69 | #endif // _M_<PLATFORM> |
| 70 | #else |
| 71 | // Make it a "strong" definition if we have no other choice. |
| 72 | ZoneInfoSourceFactory zone_info_source_factory = DefaultFactory; |
| 73 | #endif |
| 74 | |
| 75 | } // namespace cctz_extension |
| 76 | } // namespace time_internal |
| 77 | } // namespace absl |
| 78 | |