ATLAS Offline Software
features.h
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 /*
3  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
4 */
12 #ifndef CXXUTILS_FEATURES_H
13 #define CXXUTILS_FEATURES_H
14 
15 // cppcheck-suppress preprocessorErrorDirective
16 #if __has_include( <features.h> )
17 # include <features.h>
18 #endif
19 // cppcheck-suppress preprocessorErrorDirective
20 #if __has_include( <version> )
21 # include <version>
22 #endif
23 
24 // If we're using glibc, this should have been defined by features.h.
25 // Otherwise, define a dummy.
26 #ifndef __GLIBC_PREREQ
27 # define __GLIBC_PREREQ(MAJOR, MINOR) 0
28 #endif
29 
32 #if (defined(__GNUC__) || defined(__clang__)) && \
33  !(defined(__ICC) || defined(__COVERITY__) || \
34  defined(__CUDACC__) || defined(__CLING__))
35 # define HAVE_GCC_CLANG_EXTENSIONS 1
36 #else
37 # define HAVE_GCC_CLANG_EXTENSIONS 0
38 #endif
39 
42 #if HAVE_GCC_CLANG_EXTENSIONS && \
43  (defined(__i386__) || defined(__x86_64__)) && defined(__ELF__) && \
44  !defined(__HIP__) && !defined(CL_SYCL_LANGUAGE_VERSION) && \
45  !defined(SYCL_LANGUAGE_VERSION)
46 #define HAVE_FUNCTION_MULTIVERSIONING 1
47 #else
48 # define HAVE_FUNCTION_MULTIVERSIONING 0
49 #endif
50 
56 #if HAVE_FUNCTION_MULTIVERSIONING && !(defined(__clang__) && __clang_major__ < 14)
57 # define HAVE_TARGET_CLONES 1
58 #else
59 # define HAVE_TARGET_CLONES 0
60 #endif
61 
63 #if HAVE_GCC_CLANG_EXTENSIONS && !defined(__clang__)
64 # define HAVE_GCC_INTRINSICS 1
65 #else
66 # define HAVE_GCC_INTRINSICS 0
67 #endif
68 
70 // __builtin_ctz
71 // __builtin_ctzl
72 // __builtin_ctzll
73 // __builtin_clz
74 // __builtin_clzl
75 // __builtin_clzll
76 // __builtin_popcount
77 // __builtin_popcountl
78 // __builtin_popcountll
79 #if HAVE_GCC_CLANG_EXTENSIONS
80 # define HAVE_BITCOUNT_INTRINSICS 1
81 #else
82 # define HAVE_BITCOUNT_INTRINSICS 0
83 #endif
84 
85 // Do we have the vector_size attribute for writing explicitly
86 // vectorized code?
87 #if HAVE_GCC_CLANG_EXTENSIONS
88 # define HAVE_VECTOR_SIZE_ATTRIBUTE 1
89 #else
90 # define HAVE_VECTOR_SIZE_ATTRIBUTE 0
91 #endif
92 
93 // Do we additionally support the clang
94 // __builtin_convertvector
95 // GCC>=9 does
96 #if HAVE_VECTOR_SIZE_ATTRIBUTE && (defined(__clang__) || (__GNUC__ >= 9))
97 # define HAVE_CONVERT_VECTOR 1
98 #else
99 # define HAVE_CONVERT_VECTOR 0
100 #endif
101 
102 // Do we have mallinfo2? Present in glibc 2.33,
103 // in which mallinfo is deprecated.
104 # if __GLIBC_PREREQ(2, 33)
105 # define HAVE_MALLINFO2 1
106 #else
107 # define HAVE_MALLINFO2 0
108 #endif
109 
110 
111 // Do we have malloc hooks? They were removed in glibc 2.34.
112 #if !__GLIBC_PREREQ(2, 34)
113 # define HAVE_MALLOC_HOOKS 1
114 #else
115 # define HAVE_MALLOC_HOOKS 0
116 #endif
117 
118 // Do we have feenableexcept/fedisableexcept
119 #if defined(__GLIBC__)
120 # define HAVE_FEENABLEEXCEPT 1
121 #else
122 # define HAVE_FEENABLEEXCEPT 0
123 #endif
124 
125 // Do we have C++20 ranges?
126 #if __cpp_lib_ranges
127 # define HAVE_STD_RANGES 1
128 #else
129 # define HAVE_STD_RANGES 0
130 #endif
131 
132 
133 #endif // not CXXUTILS_FEATURES_H
features.h
Some additional feature test macros.