X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Futils%2Fmono-compiler.h;h=f8481d004d10e34da4cf629fef17b4bf38190137;hb=4058c2be43ec605cdcc57e9d678251339349cb5f;hp=2a7849f101afb6bea053aa99b3715755987ab662;hpb=7f76306f79a62af3b6466c43558ff2de448d815c;p=mono.git diff --git a/mono/utils/mono-compiler.h b/mono/utils/mono-compiler.h index 2a7849f101a..f8481d004d1 100644 --- a/mono/utils/mono-compiler.h +++ b/mono/utils/mono-compiler.h @@ -1,3 +1,7 @@ +/** + * \file + */ + #ifndef __UTILS_MONO_COMPILER_H__ #define __UTILS_MONO_COMPILER_H__ @@ -6,15 +10,18 @@ * compiler behaviours. */ #include +#if defined(HAVE_UNISTD_H) +#include +#endif #ifdef __GNUC__ -#define MONO_ATTR_USED __attribute__ ((used)) +#define MONO_ATTR_USED __attribute__ ((__used__)) #else #define MONO_ATTR_USED #endif #ifdef __GNUC__ -#define MONO_ATTR_FORMAT_PRINTF(fmt_pos,arg_pos) __attribute__((format(printf,fmt_pos,arg_pos))) +#define MONO_ATTR_FORMAT_PRINTF(fmt_pos,arg_pos) __attribute__ ((__format__(__printf__,fmt_pos,arg_pos))) #else #define MONO_ATTR_FORMAT_PRINTF(fmt_pos,arg_pos) #endif @@ -70,7 +77,7 @@ typedef SSIZE_T ssize_t; #define MONO_EMPTY_SOURCE_FILE(x) #endif -#if !defined(_MSC_VER) && !defined(PLATFORM_SOLARIS) && !defined(_WIN32) && !defined(__CYGWIN__) && !defined(MONOTOUCH) && HAVE_VISIBILITY_HIDDEN +#if !defined(_MSC_VER) && !defined(HOST_SOLARIS) && !defined(_WIN32) && !defined(__CYGWIN__) && !defined(MONOTOUCH) && HAVE_VISIBILITY_HIDDEN #if MONO_LLVM_LOADED #define MONO_LLVM_INTERNAL MONO_API #else @@ -80,8 +87,11 @@ typedef SSIZE_T ssize_t; #define MONO_LLVM_INTERNAL #endif +/* Used to mark internal functions used by the profiler modules */ +#define MONO_PROFILER_API MONO_API + #ifdef __GNUC__ -#define MONO_ALWAYS_INLINE __attribute__((always_inline)) +#define MONO_ALWAYS_INLINE __attribute__ ((__always_inline__)) #elif defined(_MSC_VER) #define MONO_ALWAYS_INLINE __forceinline #else @@ -89,7 +99,7 @@ typedef SSIZE_T ssize_t; #endif #ifdef __GNUC__ -#define MONO_NEVER_INLINE __attribute__((noinline)) +#define MONO_NEVER_INLINE __attribute__ ((__noinline__)) #elif defined(_MSC_VER) #define MONO_NEVER_INLINE __declspec(noinline) #else @@ -97,7 +107,7 @@ typedef SSIZE_T ssize_t; #endif #ifdef __GNUC__ -#define MONO_COLD __attribute__((cold)) +#define MONO_COLD __attribute__ ((__cold__)) #else #define MONO_COLD #endif @@ -106,5 +116,54 @@ typedef SSIZE_T ssize_t; #define MONO_GNUC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) #endif +#if defined(__has_feature) +#if __has_feature(thread_sanitizer) +#define MONO_HAS_CLANG_THREAD_SANITIZER 1 +#else +#define MONO_HAS_CLANG_THREAD_SANITIZER 0 +#endif +#else +#define MONO_HAS_CLANG_THREAD_SANITIZER 0 +#endif + +/* Used to tell Clang's ThreadSanitizer to not report data races that occur within a certain function */ +#if MONO_HAS_CLANG_THREAD_SANITIZER +#define MONO_NO_SANITIZE_THREAD __attribute__ ((no_sanitize("thread"))) +#else +#define MONO_NO_SANITIZE_THREAD +#endif + +/* Used when building with Android NDK's unified headers */ +#if defined(HOST_ANDROID) && defined (ANDROID_UNIFIED_HEADERS) +#if __ANDROID_API__ < 21 + +typedef int32_t __mono_off32_t; + +#ifdef HAVE_SYS_MMAN_H +#include +#endif + +#if !defined(mmap) +/* Unified headers before API 21 do not declare mmap when LARGE_FILES are used (via -D_FILE_OFFSET_BITS=64) + * which is always the case when Mono build targets Android. The problem here is that the unified headers + * map `mmap` to `mmap64` if large files are enabled but this api exists only in API21 onwards. Therefore + * we must carefully declare the 32-bit mmap here without changing the ABI along the way. Carefully because + * in this instance off_t is redeclared to be 64-bit and that's not what we want. + */ +void* mmap (void*, size_t, int, int, int, __mono_off32_t); +#endif /* !mmap */ + +#ifdef HAVE_SYS_SENDFILE_H +#include +#endif + +#if !defined(sendfile) +/* The same thing as with mmap happens with sendfile */ +ssize_t sendfile (int out_fd, int in_fd, __mono_off32_t* offset, size_t count); +#endif /* !sendfile */ + +#endif /* __ANDROID_API__ < 21 */ +#endif /* HOST_ANDROID && ANDROID_UNIFIED_HEADERS */ + #endif /* __UTILS_MONO_COMPILER_H__*/