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