5 #ifndef __UTILS_MONO_COMPILER_H__
6 #define __UTILS_MONO_COMPILER_H__
9 * This file includes macros used in the runtime to encapsulate different
10 * compiler behaviours.
15 #define MONO_ATTR_USED __attribute__ ((__used__))
17 #define MONO_ATTR_USED
21 #define MONO_ATTR_FORMAT_PRINTF(fmt_pos,arg_pos) __attribute__ ((__format__(__printf__,fmt_pos,arg_pos)))
23 #define MONO_ATTR_FORMAT_PRINTF(fmt_pos,arg_pos)
26 /* Deal with Microsoft C compiler differences */
31 #if _MSC_VER < 1800 /* VS 2013 */
32 #define strtoull _strtoui64
36 #define trunc(x) (((x) < 0) ? ceil((x)) : floor((x)))
37 #if _MSC_VER < 1800 /* VS 2013 */
38 #define isnan(x) _isnan(x)
39 #define isinf(x) (_isnan(x) ? 0 : (_fpclass(x) == _FPCLASS_NINF) ? -1 : (_fpclass(x) == _FPCLASS_PINF) ? 1 : 0)
40 #define isnormal(x) _finite(x)
44 #define pclose _pclose
47 #define mkdir(x) _mkdir(x)
49 #define __func__ __FUNCTION__
52 typedef SSIZE_T ssize_t;
55 * SSIZE_MAX is not defined in MSVC, so define it here.
57 * These values come from MinGW64, and are public domain.
62 #define SSIZE_MAX _I64_MAX
64 #define SSIZE_MAX INT_MAX
71 // Quiet Visual Studio linker warning, LNK4221, in cases when this source file intentional ends up empty.
72 #define MONO_EMPTY_SOURCE_FILE(x) void __mono_win32_ ## x ## _quiet_lnk4221 (void) {}
74 #define MONO_EMPTY_SOURCE_FILE(x)
77 #if !defined(_MSC_VER) && !defined(HOST_SOLARIS) && !defined(_WIN32) && !defined(__CYGWIN__) && !defined(MONOTOUCH) && HAVE_VISIBILITY_HIDDEN
79 #define MONO_LLVM_INTERNAL MONO_API
81 #define MONO_LLVM_INTERNAL
84 #define MONO_LLVM_INTERNAL
87 /* Used to mark internal functions used by the profiler modules */
88 #define MONO_PROFILER_API MONO_API
91 #define MONO_ALWAYS_INLINE __attribute__ ((__always_inline__))
92 #elif defined(_MSC_VER)
93 #define MONO_ALWAYS_INLINE __forceinline
95 #define MONO_ALWAYS_INLINE
99 #define MONO_NEVER_INLINE __attribute__ ((__noinline__))
100 #elif defined(_MSC_VER)
101 #define MONO_NEVER_INLINE __declspec(noinline)
103 #define MONO_NEVER_INLINE
107 #define MONO_COLD __attribute__ ((__cold__))
112 #if defined (__GNUC__) && defined (__GNUC_MINOR__) && defined (__GNUC_PATCHLEVEL__)
113 #define MONO_GNUC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
116 #if defined(__has_feature)
117 #if __has_feature(thread_sanitizer)
118 #define MONO_HAS_CLANG_THREAD_SANITIZER 1
120 #define MONO_HAS_CLANG_THREAD_SANITIZER 0
123 #define MONO_HAS_CLANG_THREAD_SANITIZER 0
126 /* Used to tell Clang's ThreadSanitizer to not report data races that occur within a certain function */
127 #if MONO_HAS_CLANG_THREAD_SANITIZER
128 #define MONO_NO_SANITIZE_THREAD __attribute__ ((no_sanitize("thread")))
130 #define MONO_NO_SANITIZE_THREAD
133 #endif /* __UTILS_MONO_COMPILER_H__*/