Automatic Differentiation
 
Loading...
Searching...
No Matches
compiler_attributes.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_META_COMPILER_ATTRIBUTES_HPP
2#define STAN_MATH_PRIM_META_COMPILER_ATTRIBUTES_HPP
3
4#ifdef __GNUC__
5
6#ifndef likely
7#define likely(x) __builtin_expect(!!(x), 1)
8#endif
9
10#ifndef unlikely
11#define unlikely(x) __builtin_expect(!!(x), 0)
12#endif
13
14#ifdef __has_attribute
15
16#if __has_attribute(noinline) && __has_attribute(cold)
17#ifndef STAN_COLD_PATH
23#define STAN_COLD_PATH __attribute__((noinline, cold))
24#endif
25#endif
26
27#if __has_attribute(always_inline)
28#ifndef STAN_STRONG_INLINE
34#define STAN_STRONG_INLINE __attribute__((always_inline)) inline
35#endif
36#endif
37
38#if __has_attribute(hot)
39#ifndef STAN_HOT_PATH
44#define STAN_HOT_PATH __attribute__((hot))
45#endif
46#endif
47
48#endif
49
50#ifndef STAN_DEPRECATED
51#if __has_attribute(deprecated)
52#define STAN_DEPRECATED __attribute__((deprecated))
53#else
54#define STAN_DEPRECATED
55#endif
56#endif
57
58#endif
59
60#ifndef likely
61#define likely(x) x
62#endif
63
64#ifndef unlikely
65#define unlikely(x) x
66#endif
67
68#ifndef STAN_COLD_PATH
69#define STAN_COLD_PATH
70#endif
71
72#ifndef STAN_STRONG_INLINE
73#define STAN_STRONG_INLINE inline
74#endif
75
76#ifndef STAN_HOT_PATH
77#define STAN_HOT_PATH
78#endif
79
80#ifndef STAN_DEPRECATED
81#define STAN_DEPRECATED
82#endif
86#ifndef STAN_NO_RANGE_CHECKS_RETURN
90#ifdef STAN_NO_RANGE_CHECKS
91#define STAN_NO_RANGE_CHECKS_RETURN return
92#endif
93#ifndef STAN_NO_RANGE_CHECKS_RETURN
94#define STAN_NO_RANGE_CHECKS_RETURN
95#endif
96#endif
97
98#endif