2015-12-11 02:17:01 +08:00
|
|
|
/*===- InstrProfilingPort.h- Support library for PGO instrumentation ------===*\
|
|
|
|
|*
|
|
|
|
|* The LLVM Compiler Infrastructure
|
|
|
|
|*
|
|
|
|
|* This file is distributed under the University of Illinois Open Source
|
|
|
|
|* License. See LICENSE.TXT for details.
|
|
|
|
|*
|
|
|
|
\*===----------------------------------------------------------------------===*/
|
|
|
|
|
|
|
|
#ifndef PROFILE_INSTRPROFILING_PORT_H_
|
|
|
|
#define PROFILE_INSTRPROFILING_PORT_H_
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
2015-12-18 07:37:30 +08:00
|
|
|
#define COMPILER_RT_ALIGNAS(x) __declspec(align(x))
|
2015-12-16 11:29:15 +08:00
|
|
|
#define COMPILER_RT_VISIBILITY
|
|
|
|
#define COMPILER_RT_WEAK __declspec(selectany)
|
2015-12-11 02:17:01 +08:00
|
|
|
#elif __GNUC__
|
2015-12-16 11:29:15 +08:00
|
|
|
#define COMPILER_RT_ALIGNAS(x) __attribute__((aligned(x)))
|
|
|
|
#define COMPILER_RT_VISIBILITY __attribute__((visibility("hidden")))
|
|
|
|
#define COMPILER_RT_WEAK __attribute__((weak))
|
2015-12-11 02:17:01 +08:00
|
|
|
#endif
|
|
|
|
|
2015-12-16 11:29:15 +08:00
|
|
|
#define COMPILER_RT_SECTION(Sect) __attribute__((section(Sect)))
|
2015-12-11 02:17:01 +08:00
|
|
|
|
2015-12-11 03:20:25 +08:00
|
|
|
#if COMPILER_RT_HAS_ATOMICS == 1
|
2015-12-21 03:11:44 +08:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
#include <windows.h>
|
2015-12-21 03:55:15 +08:00
|
|
|
#if defined(_WIN64)
|
2015-12-21 03:11:44 +08:00
|
|
|
#define COMPILER_RT_BOOL_CMPXCHG(Ptr, OldV, NewV) \
|
|
|
|
(InterlockedCompareExchange64((LONGLONG volatile *)Ptr, (LONGLONG)NewV, \
|
|
|
|
(LONGLONG)OldV) == (LONGLONG)OldV)
|
2015-12-21 03:55:15 +08:00
|
|
|
#else
|
|
|
|
#define COMPILER_RT_BOOL_CMPXCHG(Ptr, OldV, NewV) \
|
|
|
|
(InterlockedCompareExchange((LONG volatile *)Ptr, (LONG)NewV, (LONG)OldV) == \
|
|
|
|
(LONG)OldV)
|
2015-12-21 03:11:44 +08:00
|
|
|
#endif
|
|
|
|
#else
|
2015-12-16 11:29:15 +08:00
|
|
|
#define COMPILER_RT_BOOL_CMPXCHG(Ptr, OldV, NewV) \
|
2015-12-11 03:20:25 +08:00
|
|
|
__sync_bool_compare_and_swap(Ptr, OldV, NewV)
|
2015-12-21 03:11:44 +08:00
|
|
|
#endif
|
2015-12-11 03:20:25 +08:00
|
|
|
#else
|
2015-12-16 11:29:15 +08:00
|
|
|
#define COMPILER_RT_BOOL_CMPXCHG(Ptr, OldV, NewV) \
|
|
|
|
BoolCmpXchg((void **)Ptr, OldV, NewV)
|
2015-12-11 03:20:25 +08:00
|
|
|
#endif
|
|
|
|
|
2015-12-16 11:29:15 +08:00
|
|
|
#define PROF_ERR(Format, ...) \
|
|
|
|
if (GetEnvHook && GetEnvHook("LLVM_PROFILE_VERBOSE_ERRORS")) \
|
|
|
|
fprintf(stderr, Format, __VA_ARGS__);
|
|
|
|
|
2015-12-31 03:18:55 +08:00
|
|
|
#if defined(__FreeBSD__)
|
2015-12-11 02:17:01 +08:00
|
|
|
|
2015-12-31 03:18:55 +08:00
|
|
|
#include <inttypes.h>
|
|
|
|
#include <sys/types.h>
|
2015-12-11 02:17:01 +08:00
|
|
|
|
2015-12-31 03:18:55 +08:00
|
|
|
#else /* defined(__FreeBSD__) */
|
2015-12-11 02:17:01 +08:00
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#endif /* defined(__FreeBSD__) && defined(__i386__) */
|
|
|
|
|
|
|
|
#endif /* PROFILE_INSTRPROFILING_PORT_H_ */
|