1 /*
2  * %CopyrightBegin%
3  *
4  * Copyright Ericsson AB 2004-2020. All Rights Reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *     http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * %CopyrightEnd%
19  */
20 
21 #ifndef ETHREAD_INLINE_H__
22 #define ETHREAD_INLINE_H__
23 
24 #define ETHR_GCC_COMPILER_FALSE 0 /* Not a gcc compatible compiler */
25 #define ETHR_GCC_COMPILER_TRUE 1 /* The GNU gcc compiler */
26 /* Negative integers for gcc compatible compilers */
27 #define ETHR_GCC_COMPILER_CLANG -1 /* The Clang gcc compatible compiler */
28 #define ETHR_GCC_COMPILER_ICC -2 /* The Intel gcc compatible compiler */
29 /* Line them up... */
30 
31 /*
32  * Unfortunately there is no easy and certain way of
33  * detecting a true gcc compiler, since the compatible
34  * ones all define the same defines as the true gnu-gcc...
35  */
36 #if !defined(__GNUC__) && !defined(__GNUG__)
37 #  define ETHR_GCC_COMPILER ETHR_GCC_COMPILER_FALSE
38 #elif defined(__clang__)
39 #  define ETHR_GCC_COMPILER ETHR_GCC_COMPILER_CLANG
40 #elif defined(__ICC) || defined(__INTEL_COMPILER)
41 #  define ETHR_GCC_COMPILER ETHR_GCC_COMPILER_ICC
42 #else
43 /* Seems to be the true gnu-gcc... */
44 #  define ETHR_GCC_COMPILER ETHR_GCC_COMPILER_TRUE
45 #endif
46 
47 #if !defined(__GNUC__)
48 #  define ETHR_AT_LEAST_GCC_VSN__(MAJ, MIN, PL) 0
49 #elif !defined(__GNUC_MINOR__)
50 #  define ETHR_AT_LEAST_GCC_VSN__(MAJ, MIN, PL) \
51   ((__GNUC__ << 24) >= (((MAJ) << 24) | ((MIN) << 12) | (PL)))
52 #elif !defined(__GNUC_PATCHLEVEL__)
53 #  define ETHR_AT_LEAST_GCC_VSN__(MAJ, MIN, PL) \
54   (((__GNUC__ << 24) | (__GNUC_MINOR__ << 12)) >= (((MAJ) << 24) | ((MIN) << 12) | (PL)))
55 #else
56 #  define ETHR_AT_LEAST_GCC_VSN__(MAJ, MIN, PL) \
57   (((__GNUC__ << 24) | (__GNUC_MINOR__ << 12) | __GNUC_PATCHLEVEL__) >= (((MAJ) << 24) | ((MIN) << 12) | (PL)))
58 #endif
59 
60 #undef ETHR_INLINE
61 #if defined(__GNUC__)
62 #  define ETHR_INLINE __inline__
63 #  if ETHR_AT_LEAST_GCC_VSN__(3, 1, 1)
64 #    define ETHR_FORCE_INLINE __inline__ __attribute__((__always_inline__))
65 #    define ETHR_NOINLINE __attribute__((__noinline__))
66 #  else
67 #    define ETHR_FORCE_INLINE __inline__
68 #    define ETHR_NOINLINE
69 #  endif
70 #elif defined(__WIN32__)
71 #  define ETHR_INLINE __forceinline
72 #  define ETHR_FORCE_INLINE __forceinline
73 #  define ETHR_NOINLINE
74 #endif
75 
76 #endif /* #ifndef ETHREAD_INLINE_H__ */
77