libcopp 2.3.1
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
features.h
Go to the documentation of this file.
1// cmake template file
2
3#ifndef LIBCOPP_UTILS_FEATURES_H
4#define LIBCOPP_UTILS_FEATURES_H
5
6#pragma once
7
8// ================ build options ================
9#include <libcopp/utils/config/libcopp_build_features.h>
10// ---------------- build options ----------------
11
12// ================ select compiler ================
13#if defined(__GCCXML__)
14# define LIBCOPP_MACRO_COMPILER_GCCXML 1
15#elif defined(__clang__)
16# define LIBCOPP_MACRO_COMPILER_CLANG 1
17#elif defined(_MSC_VER)
18# define LIBCOPP_MACRO_COMPILER_MSVC 1
19#elif defined(__INTEL_COMPILER) || defined(__ICL) || defined(__ICC) || defined(__ECC)
20# define LIBCOPP_MACRO_COMPILER_INTELC 1
21#elif defined(__GNUC__)
22# define LIBCOPP_MACRO_COMPILER_GCC 1
23#elif defined(__BORLANDC__)
24# define LIBCOPP_MACRO_COMPILER_BORLANDC 1
25#endif
26// ---------------- select compiler ----------------
27
28// ================ select platform ================
29#if (defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__)) && \
30 !defined(_CRAYC)
31# define LIBCOPP_MACRO_PLATFORM_LINUX
32#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
33# define LIBCOPP_MACRO_PLATFORM_BSD
34#elif defined(sun) || defined(__sun)
35# define LIBCOPP_MACRO_PLATFORM_SOLARIS
36#elif defined(__sgi)
37# define LIBCOPP_MACRO_PLATFORM_SGI
38#elif defined(__hpux)
39# define LIBCOPP_MACRO_PLATFORM_HPUNIX
40#elif defined(__CYGWIN__)
41# define LIBCOPP_MACRO_PLATFORM_CYGWIN
42#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
43# define LIBCOPP_MACRO_PLATFORM_WIN32
44#else
45# if defined(unix) || defined(__unix) || defined(_XOPEN_SOURCE) || defined(_POSIX_SOURCE)
46# define LIBCOPP_MACRO_PLATFORM_UNIX
47# endif
48#endif
49// ---------------- select platform ----------------
50
51// ---------------- c extern ----------------
52
53// ================ compiler abi headers ================
54#if defined(LIBCOPP_MACRO_COMPILER_MSVC)
55# define LIBCOPP_HAS_ABI_HEADERS 1
56# define LIBCOPP_ABI_PREFIX "libcopp/utils/abi/msvc_prefix.hpp"
57# define LIBCOPP_ABI_SUFFIX "libcopp/utils/abi/msvc_suffix.hpp"
58#elif defined LIBCOPP_MACRO_COMPILER_BORLANDC
59# define LIBCOPP_HAS_ABI_HEADERS 1
60# define LIBCOPP_ABI_PREFIX "libcopp/utils/abi/borland_prefix.hpp"
61# define LIBCOPP_ABI_SUFFIX "libcopp/utils/abi/borland_suffix.hpp"
62#endif
63// ---------------- compiler abi headers ----------------
64
65// ================ function flags ================
66
67#if defined(LIBCOPP_MACRO_USE_SEGMENTED_STACKS)
68# if !((defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ > 3 && __GNUC_MINOR__ > 6))) || \
69 (defined(__clang__) && __clang_major__ > 2 && __clang_minor__ > 3))
70# error "compiler does not support segmented_stack stacks"
71# endif
72# define LIBCOPP_MACRO_SEGMENTED_STACK_NUMBER 10
73#endif
74
75#ifndef LIBCOPP_MACRO_CPP_STD
76# if defined(__cplusplus) && __cplusplus >= 201103L
77# define LIBCOPP_MACRO_CPP_STD 201103L
78# define LIBCOPP_MACRO_ENABLE_SMART_PTR 1
79# else
80# define LIBCOPP_MACRO_CPP_STD 199711L
81# endif
82#endif
83
84// ---------------- function flags ----------------
85
86// ---------------- branch prediction information ----------------
87
88#include "errno.h"
89
90// Deprecated macro for old toolchain
91#if !defined(COPP_MACRO_RV_REF)
92# define COPP_MACRO_RV_REF &&
93#endif
94
95// Deprecated macro for old toolchain
96#if !defined(COPP_MACRO_STD_MOVE)
97# define COPP_MACRO_STD_MOVE(x) std::move(x)
98#endif
99
100// Deprecated macro for old toolchain
101#if !defined(COPP_MACRO_STD_FORWARD)
102# define COPP_MACRO_STD_FORWARD(t, x) std::forward<t>(x)
103#endif
104
105// ================ branch prediction information ================
106#if defined(LIBCOPP_MACRO_COMPILER_GCC)
107# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L
108# define LIBCOPP_MACRO_COMPILER_CXX_THREAD_LOCAL 1
109# else
110# define LIBCOPP_MACRO_COMPILER_CXX_THREAD_LOCAL 0
111# endif
112#elif defined(LIBCOPP_MACRO_COMPILER_CLANG)
113# if __has_feature(cxx_thread_local)
114# define LIBCOPP_MACRO_COMPILER_CXX_THREAD_LOCAL 1
115# else
116# define LIBCOPP_MACRO_COMPILER_CXX_THREAD_LOCAL 0
117# endif
118#elif defined(_MSC_VER)
119# if _MSC_VER >= 1900
120# define LIBCOPP_MACRO_COMPILER_CXX_THREAD_LOCAL 1
121# else
122# define LIBCOPP_MACRO_COMPILER_CXX_THREAD_LOCAL 0
123# endif
124#endif
125
126// iOS may not link STL with thread_local
127#if defined(__APPLE__)
128# include <TargetConditionals.h>
129
130# if TARGET_OS_IPHONE || TARGET_OS_EMBEDDED || TARGET_IPHONE_SIMULATOR
131# define LIBCOPP_MACRO_DISABLE_THREAD_LOCAL_KEYWORK
132# endif
133#endif
134
135// android may not link STL with thread_local
136#if defined(__ANDROID__)
137# define LIBCOPP_MACRO_DISABLE_THREAD_LOCAL_KEYWORK
138#endif
139
140#if !defined(LIBCOPP_MACRO_DISABLE_THREAD_LOCAL_KEYWORK)
141# if defined(LIBCOPP_MACRO_COMPILER_CXX_THREAD_LOCAL) && LIBCOPP_MACRO_COMPILER_CXX_THREAD_LOCAL
142# define LIBCOPP_MACRO_THREAD_LOCAL thread_local
143# elif defined(LIBCOPP_MACRO_COMPILER_GCC) || defined(LIBCOPP_MACRO_COMPILER_CLANG)
144# define LIBCOPP_MACRO_THREAD_LOCAL __thread
145# elif defined(_MSC_VER)
146# define LIBCOPP_MACRO_THREAD_LOCAL __declspec(thread)
147# else
148// LIBCOPP_MACRO_THREAD_LOCAL not defined for this configuration.
149# endif
150#endif
151// ---------------- branch prediction information ----------------
152
153#endif