2012-06-05 22:25:27 +08:00
|
|
|
//===-- sanitizer_internal_defs.h -------------------------------*- C++ -*-===//
|
2012-05-31 22:11:07 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file is shared between AddressSanitizer and ThreadSanitizer.
|
2012-06-05 21:50:57 +08:00
|
|
|
// It contains macro used in run-time libraries code.
|
2012-05-31 22:11:07 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef SANITIZER_DEFS_H
|
|
|
|
#define SANITIZER_DEFS_H
|
|
|
|
|
2013-03-19 22:33:38 +08:00
|
|
|
#include "sanitizer_platform.h"
|
2013-03-19 21:54:41 +08:00
|
|
|
|
2013-08-13 19:42:45 +08:00
|
|
|
// Only use SANITIZER_*ATTRIBUTE* before the function return type!
|
2013-03-19 22:54:17 +08:00
|
|
|
#if SANITIZER_WINDOWS
|
2014-07-15 16:16:04 +08:00
|
|
|
# define SANITIZER_INTERFACE_ATTRIBUTE __declspec(dllexport)
|
2013-08-13 19:42:45 +08:00
|
|
|
// FIXME find out what we need on Windows, if anything.
|
2013-01-30 21:12:08 +08:00
|
|
|
# define SANITIZER_WEAK_ATTRIBUTE
|
|
|
|
#elif defined(SANITIZER_GO)
|
|
|
|
# define SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
# define SANITIZER_WEAK_ATTRIBUTE
|
|
|
|
#else
|
|
|
|
# define SANITIZER_INTERFACE_ATTRIBUTE __attribute__((visibility("default")))
|
|
|
|
# define SANITIZER_WEAK_ATTRIBUTE __attribute__((weak))
|
|
|
|
#endif
|
|
|
|
|
2013-04-03 21:22:54 +08:00
|
|
|
#if SANITIZER_LINUX && !defined(SANITIZER_GO)
|
2013-01-30 21:12:08 +08:00
|
|
|
# define SANITIZER_SUPPORTS_WEAK_HOOKS 1
|
|
|
|
#else
|
|
|
|
# define SANITIZER_SUPPORTS_WEAK_HOOKS 0
|
|
|
|
#endif
|
|
|
|
|
2014-07-26 06:05:02 +08:00
|
|
|
// We can use .preinit_array section on Linux to call sanitizer initialization
|
|
|
|
// functions very early in the process startup (unless PIC macro is defined).
|
|
|
|
// FIXME: do we have anything like this on Mac?
|
|
|
|
#if SANITIZER_LINUX && !SANITIZER_ANDROID && !defined(PIC)
|
|
|
|
# define SANITIZER_CAN_USE_PREINIT_ARRAY 1
|
|
|
|
#else
|
|
|
|
# define SANITIZER_CAN_USE_PREINIT_ARRAY 0
|
|
|
|
#endif
|
|
|
|
|
[asan] make asan work with 7fff8000 offset and prelink
When prelink is installed in the system, prelink-ed
libraries map between 0x003000000000 and 0x004000000000 thus occupying the shadow Gap,
so we need so split the address space even further, like this:
|| [0x10007fff8000, 0x7fffffffffff] || HighMem ||
|| [0x02008fff7000, 0x10007fff7fff] || HighShadow ||
|| [0x004000000000, 0x02008fff6fff] || ShadowGap3 ||
|| [0x003000000000, 0x003fffffffff] || MidMem ||
|| [0x00087fff8000, 0x002fffffffff] || ShadowGap2 ||
|| [0x00067fff8000, 0x00087fff7fff] || MidShadow ||
|| [0x00008fff7000, 0x00067fff7fff] || ShadowGap ||
|| [0x00007fff8000, 0x00008fff6fff] || LowShadow ||
|| [0x000000000000, 0x00007fff7fff] || LowMem ||
Do it only if necessary.
Also added a bit of profiling code to make sure that the
mapping code is efficient.
Added a lit test to simulate prelink-ed libraries.
Unfortunately, this test does not work with binutils-gold linker.
If gold is the default linker the test silently passes.
Also replaced
__has_feature(address_sanitizer)
with
__has_feature(address_sanitizer) || defined(__SANITIZE_ADDRESS__)
in two places.
Patch partially by Jakub Jelinek.
llvm-svn: 175263
2013-02-15 20:00:24 +08:00
|
|
|
// GCC does not understand __has_feature
|
2013-01-30 21:12:08 +08:00
|
|
|
#if !defined(__has_feature)
|
|
|
|
# define __has_feature(x) 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// For portability reasons we do not include stddef.h, stdint.h or any other
|
|
|
|
// system header, but we do need some basic types that are not defined
|
|
|
|
// in a portable way by the language itself.
|
|
|
|
namespace __sanitizer {
|
|
|
|
|
|
|
|
#if defined(_WIN64)
|
|
|
|
// 64-bit Windows uses LLP64 data model.
|
|
|
|
typedef unsigned long long uptr; // NOLINT
|
|
|
|
typedef signed long long sptr; // NOLINT
|
|
|
|
#else
|
|
|
|
typedef unsigned long uptr; // NOLINT
|
|
|
|
typedef signed long sptr; // NOLINT
|
|
|
|
#endif // defined(_WIN64)
|
2014-05-21 15:34:03 +08:00
|
|
|
#if defined(__x86_64__)
|
|
|
|
// Since x32 uses ILP32 data model in 64-bit hardware mode, we must use
|
|
|
|
// 64-bit pointer to unwind stack frame.
|
|
|
|
typedef unsigned long long uhwptr; // NOLINT
|
|
|
|
#else
|
|
|
|
typedef uptr uhwptr; // NOLINT
|
|
|
|
#endif
|
2013-01-30 21:12:08 +08:00
|
|
|
typedef unsigned char u8;
|
|
|
|
typedef unsigned short u16; // NOLINT
|
|
|
|
typedef unsigned int u32;
|
|
|
|
typedef unsigned long long u64; // NOLINT
|
|
|
|
typedef signed char s8;
|
|
|
|
typedef signed short s16; // NOLINT
|
|
|
|
typedef signed int s32;
|
|
|
|
typedef signed long long s64; // NOLINT
|
2013-02-01 23:58:46 +08:00
|
|
|
typedef int fd_t;
|
2013-01-30 21:12:08 +08:00
|
|
|
|
2013-02-27 19:22:40 +08:00
|
|
|
// WARNING: OFF_T may be different from OS type off_t, depending on the value of
|
|
|
|
// _FILE_OFFSET_BITS. This definition of OFF_T matches the ABI of system calls
|
|
|
|
// like pread and mmap, as opposed to pread64 and mmap64.
|
|
|
|
// Mac and Linux/x86-64 are special.
|
2013-03-19 22:54:17 +08:00
|
|
|
#if SANITIZER_MAC || (SANITIZER_LINUX && defined(__x86_64__))
|
2013-02-27 19:22:40 +08:00
|
|
|
typedef u64 OFF_T;
|
|
|
|
#else
|
|
|
|
typedef uptr OFF_T;
|
|
|
|
#endif
|
|
|
|
typedef u64 OFF64_T;
|
2013-10-24 14:23:39 +08:00
|
|
|
|
|
|
|
#if (SANITIZER_WORDSIZE == 64) || SANITIZER_MAC
|
|
|
|
typedef uptr operator_new_size_type;
|
|
|
|
#else
|
|
|
|
typedef u32 operator_new_size_type;
|
|
|
|
#endif
|
2013-01-30 21:12:08 +08:00
|
|
|
} // namespace __sanitizer
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
// Tell the tools to write their reports to "path.<pid>" instead of stderr.
|
2013-10-15 20:25:29 +08:00
|
|
|
// The special values are "stdout" and "stderr".
|
2013-08-13 19:42:45 +08:00
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
void __sanitizer_set_report_path(const char *path);
|
2013-01-30 21:12:08 +08:00
|
|
|
|
2014-05-19 20:53:03 +08:00
|
|
|
typedef struct {
|
|
|
|
int coverage_sandboxed;
|
|
|
|
__sanitizer::sptr coverage_fd;
|
|
|
|
unsigned int coverage_max_block_size;
|
|
|
|
} __sanitizer_sandbox_arguments;
|
|
|
|
|
|
|
|
// Notify the tools that the sandbox is going to be turned on.
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE void
|
|
|
|
__sanitizer_sandbox_on_notify(__sanitizer_sandbox_arguments *args);
|
2013-02-06 20:36:49 +08:00
|
|
|
|
|
|
|
// This function is called by the tool when it has just finished reporting
|
|
|
|
// an error. 'error_summary' is a one-line string that summarizes
|
|
|
|
// the error message. This function can be overridden by the client.
|
2013-08-13 19:42:45 +08:00
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE SANITIZER_WEAK_ATTRIBUTE
|
|
|
|
void __sanitizer_report_error_summary(const char *error_summary);
|
2013-11-15 15:18:15 +08:00
|
|
|
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov_dump();
|
2014-04-30 18:40:48 +08:00
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov_init();
|
[asan] extend asan-coverage (still experimental).
- add a mode for collecting per-block coverage (-asan-coverage=2).
So far the implementation is naive (all blocks are instrumented),
the performance overhead on top of asan could be as high as 30%.
- Make sure the one-time calls to __sanitizer_cov are moved to function buttom,
which in turn required to copy the original debug info into the call insn.
Here is the performance data on SPEC 2006
(train data, comparing asan with asan-coverage={0,1,2}):
asan+cov0 asan+cov1 diff 0-1 asan+cov2 diff 0-2 diff 1-2
400.perlbench, 65.60, 65.80, 1.00, 76.20, 1.16, 1.16
401.bzip2, 65.10, 65.50, 1.01, 75.90, 1.17, 1.16
403.gcc, 1.64, 1.69, 1.03, 2.04, 1.24, 1.21
429.mcf, 21.90, 22.60, 1.03, 23.20, 1.06, 1.03
445.gobmk, 166.00, 169.00, 1.02, 205.00, 1.23, 1.21
456.hmmer, 88.30, 87.90, 1.00, 91.00, 1.03, 1.04
458.sjeng, 210.00, 222.00, 1.06, 258.00, 1.23, 1.16
462.libquantum, 1.73, 1.75, 1.01, 2.11, 1.22, 1.21
464.h264ref, 147.00, 152.00, 1.03, 160.00, 1.09, 1.05
471.omnetpp, 115.00, 116.00, 1.01, 140.00, 1.22, 1.21
473.astar, 133.00, 131.00, 0.98, 142.00, 1.07, 1.08
483.xalancbmk, 118.00, 120.00, 1.02, 154.00, 1.31, 1.28
433.milc, 19.80, 20.00, 1.01, 20.10, 1.02, 1.01
444.namd, 16.20, 16.20, 1.00, 17.60, 1.09, 1.09
447.dealII, 41.80, 42.20, 1.01, 43.50, 1.04, 1.03
450.soplex, 7.51, 7.82, 1.04, 8.25, 1.10, 1.05
453.povray, 14.00, 14.40, 1.03, 15.80, 1.13, 1.10
470.lbm, 33.30, 34.10, 1.02, 34.10, 1.02, 1.00
482.sphinx3, 12.40, 12.30, 0.99, 13.00, 1.05, 1.06
llvm-svn: 199488
2014-01-17 19:00:30 +08:00
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov();
|
2013-11-18 22:02:05 +08:00
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
2013-11-19 16:40:07 +08:00
|
|
|
void __sanitizer_annotate_contiguous_container(const void *beg,
|
|
|
|
const void *end,
|
|
|
|
const void *old_mid,
|
|
|
|
const void *new_mid);
|
2014-05-06 22:41:01 +08:00
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
int __sanitizer_verify_contiguous_container(const void *beg, const void *mid,
|
|
|
|
const void *end);
|
2013-01-30 21:12:08 +08:00
|
|
|
} // extern "C"
|
|
|
|
|
|
|
|
|
2012-06-05 21:50:57 +08:00
|
|
|
using namespace __sanitizer; // NOLINT
|
2012-05-31 22:11:07 +08:00
|
|
|
// ----------- ATTENTION -------------
|
|
|
|
// This header should NOT include any other headers to avoid portability issues.
|
|
|
|
|
2012-06-05 21:50:57 +08:00
|
|
|
// Common defs.
|
2013-04-12 17:37:20 +08:00
|
|
|
#define INLINE inline
|
2012-06-05 21:50:57 +08:00
|
|
|
#define INTERFACE_ATTRIBUTE SANITIZER_INTERFACE_ATTRIBUTE
|
|
|
|
#define WEAK SANITIZER_WEAK_ATTRIBUTE
|
|
|
|
|
|
|
|
// Platform-specific defs.
|
2012-11-06 20:47:42 +08:00
|
|
|
#if defined(_MSC_VER)
|
2013-04-12 17:37:20 +08:00
|
|
|
# define ALWAYS_INLINE __forceinline
|
2012-06-05 21:50:57 +08:00
|
|
|
// FIXME(timurrrr): do we need this on Windows?
|
|
|
|
# define ALIAS(x)
|
|
|
|
# define ALIGNED(x) __declspec(align(x))
|
2012-06-06 21:37:02 +08:00
|
|
|
# define FORMAT(f, a)
|
2012-06-05 21:50:57 +08:00
|
|
|
# define NOINLINE __declspec(noinline)
|
|
|
|
# define NORETURN __declspec(noreturn)
|
|
|
|
# define THREADLOCAL __declspec(thread)
|
2012-06-28 05:00:23 +08:00
|
|
|
# define NOTHROW
|
2012-11-06 20:54:16 +08:00
|
|
|
# define LIKELY(x) (x)
|
|
|
|
# define UNLIKELY(x) (x)
|
2013-01-12 00:40:24 +08:00
|
|
|
# define PREFETCH(x) /* _mm_prefetch(x, _MM_HINT_NTA) */
|
2012-11-06 20:47:42 +08:00
|
|
|
#else // _MSC_VER
|
2013-03-29 17:44:16 +08:00
|
|
|
# define ALWAYS_INLINE inline __attribute__((always_inline))
|
2012-06-05 21:50:57 +08:00
|
|
|
# define ALIAS(x) __attribute__((alias(x)))
|
2013-06-04 16:25:17 +08:00
|
|
|
// Please only use the ALIGNED macro before the type.
|
|
|
|
// Using ALIGNED after the variable declaration is not portable!
|
2012-06-05 21:50:57 +08:00
|
|
|
# define ALIGNED(x) __attribute__((aligned(x)))
|
2012-06-06 21:37:02 +08:00
|
|
|
# define FORMAT(f, a) __attribute__((format(printf, f, a)))
|
2012-06-05 21:50:57 +08:00
|
|
|
# define NOINLINE __attribute__((noinline))
|
|
|
|
# define NORETURN __attribute__((noreturn))
|
|
|
|
# define THREADLOCAL __thread
|
2012-11-06 20:49:22 +08:00
|
|
|
# define NOTHROW throw()
|
2012-06-05 21:50:57 +08:00
|
|
|
# define LIKELY(x) __builtin_expect(!!(x), 1)
|
|
|
|
# define UNLIKELY(x) __builtin_expect(!!(x), 0)
|
2013-01-16 22:35:13 +08:00
|
|
|
# if defined(__i386__) || defined(__x86_64__)
|
|
|
|
// __builtin_prefetch(x) generates prefetchnt0 on x86
|
|
|
|
# define PREFETCH(x) __asm__("prefetchnta (%0)" : : "r" (x))
|
|
|
|
# else
|
|
|
|
# define PREFETCH(x) __builtin_prefetch(x)
|
|
|
|
# endif
|
2012-11-06 20:54:16 +08:00
|
|
|
#endif // _MSC_VER
|
2012-05-31 22:11:07 +08:00
|
|
|
|
2014-05-12 22:44:29 +08:00
|
|
|
#if !defined(_MSC_VER) || defined(__clang__)
|
|
|
|
# define UNUSED __attribute__((unused))
|
|
|
|
# define USED __attribute__((used))
|
|
|
|
#else
|
|
|
|
# define UNUSED
|
|
|
|
# define USED
|
|
|
|
#endif
|
|
|
|
|
2013-06-04 22:06:16 +08:00
|
|
|
// Unaligned versions of basic types.
|
|
|
|
typedef ALIGNED(1) u16 uu16;
|
|
|
|
typedef ALIGNED(1) u32 uu32;
|
|
|
|
typedef ALIGNED(1) u64 uu64;
|
|
|
|
typedef ALIGNED(1) s16 us16;
|
|
|
|
typedef ALIGNED(1) s32 us32;
|
|
|
|
typedef ALIGNED(1) s64 us64;
|
|
|
|
|
2013-03-19 22:54:17 +08:00
|
|
|
#if SANITIZER_WINDOWS
|
2012-11-06 20:50:13 +08:00
|
|
|
typedef unsigned long DWORD; // NOLINT
|
2012-06-15 15:29:14 +08:00
|
|
|
typedef DWORD thread_return_t;
|
|
|
|
# define THREAD_CALLING_CONV __stdcall
|
|
|
|
#else // _WIN32
|
|
|
|
typedef void* thread_return_t;
|
|
|
|
# define THREAD_CALLING_CONV
|
|
|
|
#endif // _WIN32
|
|
|
|
typedef thread_return_t (THREAD_CALLING_CONV *thread_callback_t)(void* arg);
|
|
|
|
|
2012-06-06 23:22:20 +08:00
|
|
|
// NOTE: Functions below must be defined in each run-time.
|
|
|
|
namespace __sanitizer {
|
|
|
|
void NORETURN Die();
|
2013-08-13 20:03:51 +08:00
|
|
|
|
|
|
|
// FIXME: No, this shouldn't be in the sanitizer interface.
|
|
|
|
SANITIZER_INTERFACE_ATTRIBUTE
|
2012-06-06 23:22:20 +08:00
|
|
|
void NORETURN CheckFailed(const char *file, int line, const char *cond,
|
|
|
|
u64 v1, u64 v2);
|
|
|
|
} // namespace __sanitizer
|
|
|
|
|
|
|
|
// Check macro
|
2012-06-06 17:26:25 +08:00
|
|
|
#define RAW_CHECK_MSG(expr, msg) do { \
|
2014-05-14 22:03:31 +08:00
|
|
|
if (UNLIKELY(!(expr))) { \
|
2012-06-06 17:26:25 +08:00
|
|
|
RawWrite(msg); \
|
|
|
|
Die(); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define RAW_CHECK(expr) RAW_CHECK_MSG(expr, #expr)
|
|
|
|
|
2012-06-06 23:22:20 +08:00
|
|
|
#define CHECK_IMPL(c1, op, c2) \
|
|
|
|
do { \
|
|
|
|
__sanitizer::u64 v1 = (u64)(c1); \
|
|
|
|
__sanitizer::u64 v2 = (u64)(c2); \
|
2014-05-14 22:03:31 +08:00
|
|
|
if (UNLIKELY(!(v1 op v2))) \
|
2012-06-06 23:22:20 +08:00
|
|
|
__sanitizer::CheckFailed(__FILE__, __LINE__, \
|
|
|
|
"(" #c1 ") " #op " (" #c2 ")", v1, v2); \
|
|
|
|
} while (false) \
|
|
|
|
/**/
|
|
|
|
|
|
|
|
#define CHECK(a) CHECK_IMPL((a), !=, 0)
|
|
|
|
#define CHECK_EQ(a, b) CHECK_IMPL((a), ==, (b))
|
|
|
|
#define CHECK_NE(a, b) CHECK_IMPL((a), !=, (b))
|
|
|
|
#define CHECK_LT(a, b) CHECK_IMPL((a), <, (b))
|
|
|
|
#define CHECK_LE(a, b) CHECK_IMPL((a), <=, (b))
|
|
|
|
#define CHECK_GT(a, b) CHECK_IMPL((a), >, (b))
|
|
|
|
#define CHECK_GE(a, b) CHECK_IMPL((a), >=, (b))
|
|
|
|
|
2012-06-30 00:58:33 +08:00
|
|
|
#if TSAN_DEBUG
|
|
|
|
#define DCHECK(a) CHECK(a)
|
|
|
|
#define DCHECK_EQ(a, b) CHECK_EQ(a, b)
|
|
|
|
#define DCHECK_NE(a, b) CHECK_NE(a, b)
|
|
|
|
#define DCHECK_LT(a, b) CHECK_LT(a, b)
|
|
|
|
#define DCHECK_LE(a, b) CHECK_LE(a, b)
|
|
|
|
#define DCHECK_GT(a, b) CHECK_GT(a, b)
|
|
|
|
#define DCHECK_GE(a, b) CHECK_GE(a, b)
|
|
|
|
#else
|
|
|
|
#define DCHECK(a)
|
|
|
|
#define DCHECK_EQ(a, b)
|
|
|
|
#define DCHECK_NE(a, b)
|
|
|
|
#define DCHECK_LT(a, b)
|
|
|
|
#define DCHECK_LE(a, b)
|
|
|
|
#define DCHECK_GT(a, b)
|
|
|
|
#define DCHECK_GE(a, b)
|
|
|
|
#endif
|
|
|
|
|
2012-10-09 16:42:07 +08:00
|
|
|
#define UNREACHABLE(msg) do { \
|
|
|
|
CHECK(0 && msg); \
|
|
|
|
Die(); \
|
2012-10-16 12:50:32 +08:00
|
|
|
} while (0)
|
2012-10-09 16:42:07 +08:00
|
|
|
|
|
|
|
#define UNIMPLEMENTED() UNREACHABLE("unimplemented")
|
2012-06-06 23:47:40 +08:00
|
|
|
|
2012-06-21 18:04:36 +08:00
|
|
|
#define COMPILER_CHECK(pred) IMPL_COMPILER_ASSERT(pred, __LINE__)
|
|
|
|
|
2012-08-28 19:54:51 +08:00
|
|
|
#define ARRAY_SIZE(a) (sizeof(a)/sizeof((a)[0]))
|
|
|
|
|
2012-06-21 18:04:36 +08:00
|
|
|
#define IMPL_PASTE(a, b) a##b
|
|
|
|
#define IMPL_COMPILER_ASSERT(pred, line) \
|
2012-09-11 18:31:28 +08:00
|
|
|
typedef char IMPL_PASTE(assertion_failed_##_, line)[2*(int)(pred)-1]
|
2012-06-21 18:04:36 +08:00
|
|
|
|
2012-06-15 21:09:52 +08:00
|
|
|
// Limits for integral types. We have to redefine it in case we don't
|
|
|
|
// have stdint.h (like in Visual Studio 9).
|
2012-09-24 19:43:40 +08:00
|
|
|
#undef __INT64_C
|
|
|
|
#undef __UINT64_C
|
2012-11-21 20:38:58 +08:00
|
|
|
#if SANITIZER_WORDSIZE == 64
|
2012-06-15 21:09:52 +08:00
|
|
|
# define __INT64_C(c) c ## L
|
|
|
|
# define __UINT64_C(c) c ## UL
|
|
|
|
#else
|
|
|
|
# define __INT64_C(c) c ## LL
|
|
|
|
# define __UINT64_C(c) c ## ULL
|
2012-11-21 20:38:58 +08:00
|
|
|
#endif // SANITIZER_WORDSIZE == 64
|
2012-06-15 21:09:52 +08:00
|
|
|
#undef INT32_MIN
|
|
|
|
#define INT32_MIN (-2147483647-1)
|
|
|
|
#undef INT32_MAX
|
|
|
|
#define INT32_MAX (2147483647)
|
|
|
|
#undef UINT32_MAX
|
|
|
|
#define UINT32_MAX (4294967295U)
|
|
|
|
#undef INT64_MIN
|
|
|
|
#define INT64_MIN (-__INT64_C(9223372036854775807)-1)
|
|
|
|
#undef INT64_MAX
|
|
|
|
#define INT64_MAX (__INT64_C(9223372036854775807))
|
|
|
|
#undef UINT64_MAX
|
|
|
|
#define UINT64_MAX (__UINT64_C(18446744073709551615))
|
|
|
|
|
2012-08-27 17:30:58 +08:00
|
|
|
enum LinkerInitialized { LINKER_INITIALIZED = 0 };
|
|
|
|
|
2012-09-24 19:43:40 +08:00
|
|
|
#if !defined(_MSC_VER) || defined(__clang__)
|
2012-08-28 22:11:57 +08:00
|
|
|
# define GET_CALLER_PC() (uptr)__builtin_return_address(0)
|
|
|
|
# define GET_CURRENT_FRAME() (uptr)__builtin_frame_address(0)
|
|
|
|
#else
|
2012-08-28 23:25:07 +08:00
|
|
|
extern "C" void* _ReturnAddress(void);
|
|
|
|
# pragma intrinsic(_ReturnAddress)
|
2012-08-28 22:11:57 +08:00
|
|
|
# define GET_CALLER_PC() (uptr)_ReturnAddress()
|
|
|
|
// CaptureStackBackTrace doesn't need to know BP on Windows.
|
|
|
|
// FIXME: This macro is still used when printing error reports though it's not
|
|
|
|
// clear if the BP value is needed in the ASan reports on Windows.
|
|
|
|
# define GET_CURRENT_FRAME() (uptr)0xDEADBEEF
|
|
|
|
#endif
|
|
|
|
|
2013-05-08 22:43:49 +08:00
|
|
|
#define HANDLE_EINTR(res, f) \
|
|
|
|
{ \
|
|
|
|
int rverrno; \
|
|
|
|
do { \
|
|
|
|
res = (f); \
|
|
|
|
} while (internal_iserror(res, &rverrno) && rverrno == EINTR); \
|
2012-10-02 21:41:40 +08:00
|
|
|
}
|
|
|
|
|
2012-05-31 22:11:07 +08:00
|
|
|
#endif // SANITIZER_DEFS_H
|