features.h 2.45 KB
Newer Older
1
2
// This file's extension implies that it's C, but it's really -*- C++ -*-.
/*
3
  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
4
*/
5
6
7
8
9
10
11
12
/**
 * @file CxxUtils/features.h
 * @author scott snyder <snyder@bnl.gov>
 * @date May, 2018
 * @brief Some additional feature test macros.
 */

#ifndef CXXUTILS_FEATURES_H
13
#define CXXUTILS_FEATURES_H
14

scott snyder's avatar
scott snyder committed
15
16
#include <features.h>

17
18
/// Do we have function multiversioning?  GCC and clang > 7 support
/// the target attribute
19
20
#if ( defined(__i386__) || defined(__x86_64__) ) &&                            \
  defined(__ELF__) && defined(__GNUC__) && !defined(__CLING__) &&              \
21
  !defined(__ICC) && !defined(__COVERITY__) && !defined(__CUDACC__) &&         \
22
23
  !defined(CL_SYCL_LANGUAGE_VERSION) && !defined(SYCL_LANGUAGE_VERSION) &&     \
  !defined(__HIP__)
24
# define HAVE_FUNCTION_MULTIVERSIONING 1
25
#else
26
# define HAVE_FUNCTION_MULTIVERSIONING 0
27
28
#endif

29
/// Do we have the target_clones attribute?  clang  does not support it
30
31
32
#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) &&             \
  !defined(__COVERITY__) && !defined(__CUDACC__)
# define HAVE_TARGET_CLONES 1
33
#else
34
# define HAVE_TARGET_CLONES 0
35
36
#endif

37
/// Do we have support for all GCC intrinsics?
38
39
40
#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) &&             \
  !defined(__COVERITY__) && !defined(__CUDACC__)
# define HAVE_GCC_INTRINSICS 1
41
#else
42
# define HAVE_GCC_INTRINSICS 0
43
44
#endif

45
46
47
48
49
50
51
52
53
54
55
/// Do we have the bit-counting intrinsics?
// __builtin_ctz
// __builtin_ctzl
// __builtin_ctzll
// __builtin_clz
// __builtin_clzl
// __builtin_clzll
// __builtin_popcount
// __builtin_popcountl
// __builtin_popcountll
#if defined(__GNUC__) || defined(__clang__)
56
# define HAVE_BITCOUNT_INTRINSICS 1
57
#else
58
# define HAVE_BITCOUNT_INTRINSICS 0
59
60
#endif

scott snyder's avatar
scott snyder committed
61
62
// Do we have the vector_size attribute for writing explicitly
// vectorized code?
63
64
65
#if (defined(__GNUC__) || defined(__clang__)) && !defined(__CLING__) &&        \
  !defined(__ICC) && !defined(__COVERITY__) && !defined(__CUDACC__)
#define HAVE_VECTOR_SIZE_ATTRIBUTE 1
scott snyder's avatar
scott snyder committed
66
#else
67
# define HAVE_VECTOR_SIZE_ATTRIBUTE 0
scott snyder's avatar
scott snyder committed
68
69
#endif

70
71
// Do we additionally support the clang
// __builtin_convertvector
72
73
// GCC>=9 does
#if HAVE_VECTOR_SIZE_ATTRIBUTE && (defined(__clang__) || (__GNUC__ >= 9))
74
75
76
77
78
#define HAVE_CONVERT_VECTOR 1
#else
#define HAVE_CONVERT_VECTOR 0
#endif

scott snyder's avatar
scott snyder committed
79
80
81
82
83
// Do we have mallinfo2?  Present in glibc 2.33,
// in which mallinfo is deprecated.
#define HAVE_MALLINFO2 (__GLIBC_PREREQ(2, 33))


84
#endif // not CXXUTILS_FEATURES_H