Seastar
High performance C++ framework for concurrent servers
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
std-compat.hh
1/*
2 * This file is open source software, licensed to you under the terms
3 * of the Apache License, Version 2.0 (the "License"). See the NOTICE file
4 * distributed with this work for additional information regarding copyright
5 * ownership. You may not use this file except in compliance with the License.
6 *
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
16 * under the License.
17 */
18/*
19 * Copyright (C) 2018 ScyllaDB
20 */
21
22#pragma once
23
24#include <seastar/util/modules.hh>
25
26#ifndef SEASTAR_MODULE
27
28#if __has_include(<memory_resource>)
29#include <memory_resource>
30#else
31#include <experimental/memory_resource>
32namespace std::pmr {
33 using namespace std::experimental::pmr;
34}
35#endif
36
37// Defining SEASTAR_ASAN_ENABLED in here is a bit of a hack, but
38// convenient since it is build system independent and in practice
39// everything includes this header.
40
41#ifndef __has_feature
42#define __has_feature(x) 0
43#endif
44
45// clang uses __has_feature, gcc defines __SANITIZE_ADDRESS__
46#if __has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
47#define SEASTAR_ASAN_ENABLED
48#endif
49
50#if __has_include(<source_location>)
51#include <source_location>
52#endif
53
54#if defined(__cpp_lib_source_location) && !defined(SEASTAR_BROKEN_SOURCE_LOCATION)
55// good
56#elif __has_include(<experimental/source_location>) && !defined(SEASTAR_BROKEN_SOURCE_LOCATION)
57#include <experimental/source_location>
58#else
59#include <seastar/util/source_location-compat.hh>
60#endif
61
62#endif // !defined(SEASTAR_MODULE)
63
64namespace seastar::compat {
65SEASTAR_MODULE_EXPORT_BEGIN
66
67#if defined(__cpp_lib_source_location) && !defined(SEASTAR_BROKEN_SOURCE_LOCATION)
68using source_location = std::source_location;
69#elif __has_include(<experimental/source_location>) && !defined(SEASTAR_BROKEN_SOURCE_LOCATION)
70using source_location = std::experimental::source_location;
71#else
72using source_location = seastar::internal::source_location;
73#endif
74
75SEASTAR_MODULE_EXPORT_END
76}