diff options
Diffstat (limited to 'runtime/Sanitizer/sanitizer_common')
3 files changed, 92 insertions, 0 deletions
diff --git a/runtime/Sanitizer/sanitizer_common/sanitizer_common.h b/runtime/Sanitizer/sanitizer_common/sanitizer_common.h new file mode 100644 index 00000000..ebb88600 --- /dev/null +++ b/runtime/Sanitizer/sanitizer_common/sanitizer_common.h @@ -0,0 +1,20 @@ +//===-- sanitizer_common.h --------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file is shared between run-time libraries of sanitizers. +// +// It declares common functions and classes that are used in both runtimes. +// Implementation of some functions are provided in sanitizer_common, while +// others must be defined by run-time library itself. +//===----------------------------------------------------------------------===// +#ifndef SANITIZER_COMMON_H +#define SANITIZER_COMMON_H + +#include "sanitizer_internal_defs.h" + +#endif // SANITIZER_COMMON_H diff --git a/runtime/Sanitizer/sanitizer_common/sanitizer_internal_defs.h b/runtime/Sanitizer/sanitizer_common/sanitizer_internal_defs.h new file mode 100644 index 00000000..d0817abe --- /dev/null +++ b/runtime/Sanitizer/sanitizer_common/sanitizer_internal_defs.h @@ -0,0 +1,51 @@ +//===-- sanitizer_internal_defs.h -------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file is shared between AddressSanitizer and ThreadSanitizer. +// It contains macro used in run-time libraries code. +//===----------------------------------------------------------------------===// +#ifndef SANITIZER_DEFS_H +#define SANITIZER_DEFS_H + +#include "sanitizer_platform.h" + +// 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; +typedef signed long long sptr; +#else +#if (SANITIZER_WORDSIZE == 64) || defined(__APPLE__) || defined(_WIN32) +typedef unsigned long uptr; +typedef signed long sptr; +#else +typedef unsigned int uptr; +typedef signed int sptr; +#endif +#endif // defined(_WIN64) + +typedef unsigned char u8; +typedef unsigned short u16; +typedef unsigned int u32; +typedef unsigned long long u64; +typedef signed char s8; +typedef signed short s16; +typedef signed int s32; +typedef signed long long s64; + +} // namespace __sanitizer + +namespace __ubsan { +using namespace __sanitizer; +} + +#endif // SANITIZER_DEFS_H diff --git a/runtime/Sanitizer/sanitizer_common/sanitizer_platform.h b/runtime/Sanitizer/sanitizer_common/sanitizer_platform.h new file mode 100644 index 00000000..074d2b74 --- /dev/null +++ b/runtime/Sanitizer/sanitizer_common/sanitizer_platform.h @@ -0,0 +1,21 @@ +//===-- sanitizer_platform.h ------------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// Common platform macros. +//===----------------------------------------------------------------------===// + +#ifndef SANITIZER_PLATFORM_H +#define SANITIZER_PLATFORM_H + +#if __LP64__ || defined(_WIN64) +#define SANITIZER_WORDSIZE 64 +#else +#define SANITIZER_WORDSIZE 32 +#endif + +#endif // SANITIZER_PLATFORM_H |