[compiler-rt] r367568 - compiler-rt: Rename .cc file in lib/scudo/standalone to .cpp
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 1 07:36:38 PDT 2019
Author: nico
Date: Thu Aug 1 07:36:38 2019
New Revision: 367568
URL: http://llvm.org/viewvc/llvm-project?rev=367568&view=rev
Log:
compiler-rt: Rename .cc file in lib/scudo/standalone to .cpp
Like r367463, but for scudo/standalone.
Added:
compiler-rt/trunk/lib/scudo/standalone/checksum.cpp
- copied, changed from r367567, compiler-rt/trunk/lib/scudo/standalone/checksum.cc
compiler-rt/trunk/lib/scudo/standalone/common.cpp
- copied, changed from r367567, compiler-rt/trunk/lib/scudo/standalone/common.cc
compiler-rt/trunk/lib/scudo/standalone/crc32_hw.cpp
- copied unchanged from r367567, compiler-rt/trunk/lib/scudo/standalone/crc32_hw.cc
compiler-rt/trunk/lib/scudo/standalone/flags.cpp
- copied, changed from r367567, compiler-rt/trunk/lib/scudo/standalone/flags.cc
compiler-rt/trunk/lib/scudo/standalone/flags_parser.cpp
- copied, changed from r367567, compiler-rt/trunk/lib/scudo/standalone/flags_parser.cc
compiler-rt/trunk/lib/scudo/standalone/fuchsia.cpp
- copied, changed from r367567, compiler-rt/trunk/lib/scudo/standalone/fuchsia.cc
compiler-rt/trunk/lib/scudo/standalone/linux.cpp
- copied, changed from r367567, compiler-rt/trunk/lib/scudo/standalone/linux.cc
compiler-rt/trunk/lib/scudo/standalone/report.cpp
- copied, changed from r367567, compiler-rt/trunk/lib/scudo/standalone/report.cc
compiler-rt/trunk/lib/scudo/standalone/secondary.cpp
- copied, changed from r367567, compiler-rt/trunk/lib/scudo/standalone/secondary.cc
compiler-rt/trunk/lib/scudo/standalone/string_utils.cpp
- copied, changed from r367567, compiler-rt/trunk/lib/scudo/standalone/string_utils.cc
compiler-rt/trunk/lib/scudo/standalone/wrappers_c.cpp
- copied, changed from r367567, compiler-rt/trunk/lib/scudo/standalone/wrappers_c.cc
compiler-rt/trunk/lib/scudo/standalone/wrappers_c_bionic.cpp
- copied, changed from r367567, compiler-rt/trunk/lib/scudo/standalone/wrappers_c_bionic.cc
compiler-rt/trunk/lib/scudo/standalone/wrappers_cpp.cpp
- copied, changed from r367567, compiler-rt/trunk/lib/scudo/standalone/wrappers_cpp.cc
Removed:
compiler-rt/trunk/lib/scudo/standalone/checksum.cc
compiler-rt/trunk/lib/scudo/standalone/common.cc
compiler-rt/trunk/lib/scudo/standalone/crc32_hw.cc
compiler-rt/trunk/lib/scudo/standalone/flags.cc
compiler-rt/trunk/lib/scudo/standalone/flags_parser.cc
compiler-rt/trunk/lib/scudo/standalone/fuchsia.cc
compiler-rt/trunk/lib/scudo/standalone/linux.cc
compiler-rt/trunk/lib/scudo/standalone/report.cc
compiler-rt/trunk/lib/scudo/standalone/secondary.cc
compiler-rt/trunk/lib/scudo/standalone/string_utils.cc
compiler-rt/trunk/lib/scudo/standalone/wrappers_c.cc
compiler-rt/trunk/lib/scudo/standalone/wrappers_c_bionic.cc
compiler-rt/trunk/lib/scudo/standalone/wrappers_cpp.cc
Modified:
compiler-rt/trunk/lib/scudo/standalone/CMakeLists.txt
compiler-rt/trunk/lib/scudo/standalone/chunk.h
Modified: compiler-rt/trunk/lib/scudo/standalone/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/CMakeLists.txt?rev=367568&r1=367567&r2=367568&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/CMakeLists.txt (original)
+++ compiler-rt/trunk/lib/scudo/standalone/CMakeLists.txt Thu Aug 1 07:36:38 2019
@@ -65,36 +65,40 @@ set(SCUDO_HEADERS
tsd_shared.h
vector.h
wrappers_c_checks.h
- wrappers_c.h)
+ wrappers_c.h
+ )
set(SCUDO_SOURCES
- checksum.cc
- crc32_hw.cc
- common.cc
- flags.cc
- flags_parser.cc
- fuchsia.cc
- linux.cc
- report.cc
- secondary.cc
- string_utils.cc)
+ checksum.cpp
+ crc32_hw.cpp
+ common.cpp
+ flags.cpp
+ flags_parser.cpp
+ fuchsia.cpp
+ linux.cpp
+ report.cpp
+ secondary.cpp
+ string_utils.cpp
+ )
-# Enable the SSE 4.2 instruction set for crc32_hw.cc, if available.
+# Enable the SSE 4.2 instruction set for crc32_hw.cpp, if available.
if (COMPILER_RT_HAS_MSSE4_2_FLAG)
- set_source_files_properties(crc32_hw.cc PROPERTIES COMPILE_FLAGS -msse4.2)
+ set_source_files_properties(crc32_hw.cpp PROPERTIES COMPILE_FLAGS -msse4.2)
endif()
-# Enable the AArch64 CRC32 feature for crc32_hw.cc, if available.
+# Enable the AArch64 CRC32 feature for crc32_hw.cpp, if available.
# Note that it is enabled by default starting with armv8.1-a.
if (COMPILER_RT_HAS_MCRC_FLAG)
- set_source_files_properties(crc32_hw.cc PROPERTIES COMPILE_FLAGS -mcrc)
+ set_source_files_properties(crc32_hw.cpp PROPERTIES COMPILE_FLAGS -mcrc)
endif()
set(SCUDO_SOURCES_C_WRAPPERS
- wrappers_c.cc)
+ wrappers_c.cpp
+ )
set(SCUDO_SOURCES_CXX_WRAPPERS
- wrappers_cpp.cc)
+ wrappers_cpp.cpp
+ )
if(COMPILER_RT_HAS_SCUDO_STANDALONE)
add_compiler_rt_object_libraries(RTScudoStandalone
Removed: compiler-rt/trunk/lib/scudo/standalone/checksum.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/checksum.cc?rev=367567&view=auto
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/checksum.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/checksum.cc (removed)
@@ -1,70 +0,0 @@
-//===-- checksum.cc ---------------------------------------------*- 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
-//
-//===----------------------------------------------------------------------===//
-
-#include "checksum.h"
-#include "atomic_helpers.h"
-
-#if defined(__x86_64__) || defined(__i386__)
-#include <cpuid.h>
-#elif defined(__arm__) || defined(__aarch64__)
-#if SCUDO_FUCHSIA
-#include <zircon/features.h>
-#include <zircon/syscalls.h>
-#else
-#include <sys/auxv.h>
-#endif
-#endif
-
-namespace scudo {
-
-Checksum HashAlgorithm = {Checksum::BSD};
-
-#if defined(__x86_64__) || defined(__i386__)
-// i386 and x86_64 specific code to detect CRC32 hardware support via CPUID.
-// CRC32 requires the SSE 4.2 instruction set.
-#ifndef bit_SSE4_2
-#define bit_SSE4_2 bit_SSE42 // clang and gcc have different defines.
-#endif
-
-bool hasHardwareCRC32() {
- u32 Eax, Ebx = 0, Ecx = 0, Edx = 0;
- __get_cpuid(0, &Eax, &Ebx, &Ecx, &Edx);
- const bool IsIntel = (Ebx == signature_INTEL_ebx) &&
- (Edx == signature_INTEL_edx) &&
- (Ecx == signature_INTEL_ecx);
- const bool IsAMD = (Ebx == signature_AMD_ebx) && (Edx == signature_AMD_edx) &&
- (Ecx == signature_AMD_ecx);
- if (!IsIntel && !IsAMD)
- return false;
- __get_cpuid(1, &Eax, &Ebx, &Ecx, &Edx);
- return !!(Ecx & bit_SSE4_2);
-}
-
-#elif defined(__arm__) || defined(__aarch64__)
-#ifndef AT_HWCAP
-#define AT_HWCAP 16
-#endif
-#ifndef HWCAP_CRC32
-#define HWCAP_CRC32 (1U << 7) // HWCAP_CRC32 is missing on older platforms.
-#endif
-
-bool hasHardwareCRC32() {
-#if SCUDO_FUCHSIA
- u32 HWCap;
- const zx_status_t Status =
- zx_system_get_features(ZX_FEATURE_KIND_CPU, &HWCap);
- if (Status != ZX_OK)
- return false;
- return !!(HWCap & ZX_ARM64_FEATURE_ISA_CRC32);
-#else
- return !!(getauxval(AT_HWCAP) & HWCAP_CRC32);
-#endif // SCUDO_FUCHSIA
-}
-#endif // defined(__x86_64__) || defined(__i386__)
-
-} // namespace scudo
Copied: compiler-rt/trunk/lib/scudo/standalone/checksum.cpp (from r367567, compiler-rt/trunk/lib/scudo/standalone/checksum.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/checksum.cpp?p2=compiler-rt/trunk/lib/scudo/standalone/checksum.cpp&p1=compiler-rt/trunk/lib/scudo/standalone/checksum.cc&r1=367567&r2=367568&rev=367568&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/checksum.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/checksum.cpp Thu Aug 1 07:36:38 2019
@@ -1,4 +1,4 @@
-//===-- checksum.cc ---------------------------------------------*- C++ -*-===//
+//===-- checksum.cpp --------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Modified: compiler-rt/trunk/lib/scudo/standalone/chunk.h
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/chunk.h?rev=367568&r1=367567&r2=367568&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/chunk.h (original)
+++ compiler-rt/trunk/lib/scudo/standalone/chunk.h Thu Aug 1 07:36:38 2019
@@ -22,9 +22,9 @@ extern Checksum HashAlgorithm;
INLINE u16 computeChecksum(u32 Seed, uptr Value, uptr *Array, uptr ArraySize) {
// If the hardware CRC32 feature is defined here, it was enabled everywhere,
- // as opposed to only for crc32_hw.cc. This means that other hardware specific
- // instructions were likely emitted at other places, and as a result there is
- // no reason to not use it here.
+ // as opposed to only for crc32_hw.cpp. This means that other hardware
+ // specific instructions were likely emitted at other places, and as a result
+ // there is no reason to not use it here.
#if defined(__SSE4_2__) || defined(__ARM_FEATURE_CRC32)
u32 Crc = static_cast<u32>(CRC32_INTRINSIC(Seed, Value));
for (uptr I = 0; I < ArraySize; I++)
Removed: compiler-rt/trunk/lib/scudo/standalone/common.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/common.cc?rev=367567&view=auto
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/common.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/common.cc (removed)
@@ -1,32 +0,0 @@
-//===-- common.cc -----------------------------------------------*- 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
-//
-//===----------------------------------------------------------------------===//
-
-#include "common.h"
-#include "atomic_helpers.h"
-
-namespace scudo {
-
-uptr PageSizeCached;
-uptr getPageSize();
-
-uptr getPageSizeSlow() {
- PageSizeCached = getPageSize();
- CHECK_NE(PageSizeCached, 0);
- return PageSizeCached;
-}
-
-// Fatal internal map() or unmap() error (potentially OOM related).
-void NORETURN dieOnMapUnmapError(bool OutOfMemory) {
- outputRaw("Scudo ERROR: internal map or unmap failure");
- if (OutOfMemory)
- outputRaw(" (OOM)");
- outputRaw("\n");
- die();
-}
-
-} // namespace scudo
Copied: compiler-rt/trunk/lib/scudo/standalone/common.cpp (from r367567, compiler-rt/trunk/lib/scudo/standalone/common.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/common.cpp?p2=compiler-rt/trunk/lib/scudo/standalone/common.cpp&p1=compiler-rt/trunk/lib/scudo/standalone/common.cc&r1=367567&r2=367568&rev=367568&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/common.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/common.cpp Thu Aug 1 07:36:38 2019
@@ -1,4 +1,4 @@
-//===-- common.cc -----------------------------------------------*- C++ -*-===//
+//===-- common.cpp ----------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Removed: compiler-rt/trunk/lib/scudo/standalone/crc32_hw.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/crc32_hw.cc?rev=367567&view=auto
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/crc32_hw.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/crc32_hw.cc (removed)
@@ -1,19 +0,0 @@
-//===-- crc32_hw.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
-//
-//===----------------------------------------------------------------------===//
-
-#include "checksum.h"
-
-namespace scudo {
-
-#if defined(__SSE4_2__) || defined(__ARM_FEATURE_CRC32)
-u32 computeHardwareCRC32(u32 Crc, uptr Data) {
- return static_cast<u32>(CRC32_INTRINSIC(Crc, Data));
-}
-#endif // defined(__SSE4_2__) || defined(__ARM_FEATURE_CRC32)
-
-} // namespace scudo
Removed: compiler-rt/trunk/lib/scudo/standalone/flags.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/flags.cc?rev=367567&view=auto
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/flags.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/flags.cc (removed)
@@ -1,57 +0,0 @@
-//===-- flags.cc ------------------------------------------------*- 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
-//
-//===----------------------------------------------------------------------===//
-
-#include "flags.h"
-#include "common.h"
-#include "flags_parser.h"
-#include "interface.h"
-
-namespace scudo {
-
-Flags *getFlags() {
- static Flags F;
- return &F;
-}
-
-void Flags::setDefaults() {
-#define SCUDO_FLAG(Type, Name, DefaultValue, Description) Name = DefaultValue;
-#include "flags.inc"
-#undef SCUDO_FLAG
-}
-
-void registerFlags(FlagParser *Parser, Flags *F) {
-#define SCUDO_FLAG(Type, Name, DefaultValue, Description) \
- Parser->registerFlag(#Name, Description, FlagType::FT_##Type, \
- reinterpret_cast<void *>(&F->Name));
-#include "flags.inc"
-#undef SCUDO_FLAG
-}
-
-static const char *getCompileDefinitionScudoDefaultOptions() {
-#ifdef SCUDO_DEFAULT_OPTIONS
- return STRINGIFY(SCUDO_DEFAULT_OPTIONS);
-#else
- return "";
-#endif
-}
-
-static const char *getScudoDefaultOptions() {
- return (&__scudo_default_options) ? __scudo_default_options() : "";
-}
-
-void initFlags() {
- Flags *F = getFlags();
- F->setDefaults();
- FlagParser Parser;
- registerFlags(&Parser, F);
- Parser.parseString(getCompileDefinitionScudoDefaultOptions());
- Parser.parseString(getScudoDefaultOptions());
- Parser.parseString(getEnv("SCUDO_OPTIONS"));
-}
-
-} // namespace scudo
Copied: compiler-rt/trunk/lib/scudo/standalone/flags.cpp (from r367567, compiler-rt/trunk/lib/scudo/standalone/flags.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/flags.cpp?p2=compiler-rt/trunk/lib/scudo/standalone/flags.cpp&p1=compiler-rt/trunk/lib/scudo/standalone/flags.cc&r1=367567&r2=367568&rev=367568&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/flags.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/flags.cpp Thu Aug 1 07:36:38 2019
@@ -1,4 +1,4 @@
-//===-- flags.cc ------------------------------------------------*- C++ -*-===//
+//===-- flags.cpp -----------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Removed: compiler-rt/trunk/lib/scudo/standalone/flags_parser.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/flags_parser.cc?rev=367567&view=auto
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/flags_parser.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/flags_parser.cc (removed)
@@ -1,164 +0,0 @@
-//===-- flags_parser.cc -----------------------------------------*- 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
-//
-//===----------------------------------------------------------------------===//
-
-#include "flags_parser.h"
-#include "common.h"
-#include "report.h"
-
-#include <stdlib.h>
-#include <string.h>
-
-namespace scudo {
-
-class UnknownFlagsRegistry {
- static const u32 MaxUnknownFlags = 16;
- const char *UnknownFlagsNames[MaxUnknownFlags];
- u32 NumberOfUnknownFlags;
-
-public:
- void add(const char *Name) {
- CHECK_LT(NumberOfUnknownFlags, MaxUnknownFlags);
- UnknownFlagsNames[NumberOfUnknownFlags++] = Name;
- }
-
- void report() {
- if (!NumberOfUnknownFlags)
- return;
- Printf("Scudo WARNING: found %d unrecognized flag(s):\n",
- NumberOfUnknownFlags);
- for (u32 I = 0; I < NumberOfUnknownFlags; ++I)
- Printf(" %s\n", UnknownFlagsNames[I]);
- NumberOfUnknownFlags = 0;
- }
-};
-static UnknownFlagsRegistry UnknownFlags;
-
-void reportUnrecognizedFlags() { UnknownFlags.report(); }
-
-void FlagParser::printFlagDescriptions() {
- Printf("Available flags for Scudo:\n");
- for (u32 I = 0; I < NumberOfFlags; ++I)
- Printf("\t%s\n\t\t- %s\n", Flags[I].Name, Flags[I].Desc);
-}
-
-static bool isSeparator(char C) {
- return C == ' ' || C == ',' || C == ':' || C == '\n' || C == '\t' ||
- C == '\r';
-}
-
-static bool isSeparatorOrNull(char C) { return !C || isSeparator(C); }
-
-void FlagParser::skipWhitespace() {
- while (isSeparator(Buffer[Pos]))
- ++Pos;
-}
-
-void FlagParser::parseFlag() {
- const uptr NameStart = Pos;
- while (Buffer[Pos] != '=' && !isSeparatorOrNull(Buffer[Pos]))
- ++Pos;
- if (Buffer[Pos] != '=')
- reportError("expected '='");
- const char *Name = Buffer + NameStart;
- const uptr ValueStart = ++Pos;
- const char *Value;
- if (Buffer[Pos] == '\'' || Buffer[Pos] == '"') {
- const char Quote = Buffer[Pos++];
- while (Buffer[Pos] != 0 && Buffer[Pos] != Quote)
- ++Pos;
- if (Buffer[Pos] == 0)
- reportError("unterminated string");
- Value = Buffer + ValueStart + 1;
- ++Pos; // consume the closing quote
- } else {
- while (!isSeparatorOrNull(Buffer[Pos]))
- ++Pos;
- Value = Buffer + ValueStart;
- }
- if (!runHandler(Name, Value))
- reportError("flag parsing failed.");
-}
-
-void FlagParser::parseFlags() {
- while (true) {
- skipWhitespace();
- if (Buffer[Pos] == 0)
- break;
- parseFlag();
- }
-}
-
-void FlagParser::parseString(const char *S) {
- if (!S)
- return;
- // Backup current parser state to allow nested parseString() calls.
- const char *OldBuffer = Buffer;
- const uptr OldPos = Pos;
- Buffer = S;
- Pos = 0;
-
- parseFlags();
-
- Buffer = OldBuffer;
- Pos = OldPos;
-}
-
-INLINE bool parseBool(const char *Value, bool *b) {
- if (strncmp(Value, "0", 1) == 0 || strncmp(Value, "no", 2) == 0 ||
- strncmp(Value, "false", 5) == 0) {
- *b = false;
- return true;
- }
- if (strncmp(Value, "1", 1) == 0 || strncmp(Value, "yes", 3) == 0 ||
- strncmp(Value, "true", 4) == 0) {
- *b = true;
- return true;
- }
- return false;
-}
-
-bool FlagParser::runHandler(const char *Name, const char *Value) {
- for (u32 I = 0; I < NumberOfFlags; ++I) {
- const uptr Len = strlen(Flags[I].Name);
- if (strncmp(Name, Flags[I].Name, Len) != 0 || Name[Len] != '=')
- continue;
- bool Ok = false;
- switch (Flags[I].Type) {
- case FlagType::FT_bool:
- Ok = parseBool(Value, reinterpret_cast<bool *>(Flags[I].Var));
- if (!Ok)
- reportInvalidFlag("bool", Value);
- break;
- case FlagType::FT_int:
- char *ValueEnd;
- *reinterpret_cast<int *>(Flags[I].Var) =
- static_cast<int>(strtol(Value, &ValueEnd, 10));
- Ok =
- *ValueEnd == '"' || *ValueEnd == '\'' || isSeparatorOrNull(*ValueEnd);
- if (!Ok)
- reportInvalidFlag("int", Value);
- break;
- }
- return Ok;
- }
- // Unrecognized flag. This is not a fatal error, we may print a warning later.
- UnknownFlags.add(Name);
- return true;
-}
-
-void FlagParser::registerFlag(const char *Name, const char *Desc, FlagType Type,
- void *Var) {
- CHECK_LT(NumberOfFlags, MaxFlags);
- Flags[NumberOfFlags].Name = Name;
- Flags[NumberOfFlags].Desc = Desc;
- Flags[NumberOfFlags].Type = Type;
- Flags[NumberOfFlags].Var = Var;
- ++NumberOfFlags;
-}
-
-} // namespace scudo
Copied: compiler-rt/trunk/lib/scudo/standalone/flags_parser.cpp (from r367567, compiler-rt/trunk/lib/scudo/standalone/flags_parser.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/flags_parser.cpp?p2=compiler-rt/trunk/lib/scudo/standalone/flags_parser.cpp&p1=compiler-rt/trunk/lib/scudo/standalone/flags_parser.cc&r1=367567&r2=367568&rev=367568&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/flags_parser.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/flags_parser.cpp Thu Aug 1 07:36:38 2019
@@ -1,4 +1,4 @@
-//===-- flags_parser.cc -----------------------------------------*- C++ -*-===//
+//===-- flags_parser.cpp ----------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Removed: compiler-rt/trunk/lib/scudo/standalone/fuchsia.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/fuchsia.cc?rev=367567&view=auto
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/fuchsia.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/fuchsia.cc (removed)
@@ -1,189 +0,0 @@
-//===-- fuchsia.cc ----------------------------------------------*- 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
-//
-//===----------------------------------------------------------------------===//
-
-#include "platform.h"
-
-#if SCUDO_FUCHSIA
-
-#include "common.h"
-#include "mutex.h"
-#include "string_utils.h"
-
-#include <lib/sync/mutex.h> // for sync_mutex_t
-#include <limits.h> // for PAGE_SIZE
-#include <stdlib.h> // for getenv()
-#include <zircon/compiler.h>
-#include <zircon/sanitizer.h>
-#include <zircon/syscalls.h>
-
-namespace scudo {
-
-uptr getPageSize() { return PAGE_SIZE; }
-
-void NORETURN die() { __builtin_trap(); }
-
-// We zero-initialize the Extra parameter of map(), make sure this is consistent
-// with ZX_HANDLE_INVALID.
-COMPILER_CHECK(ZX_HANDLE_INVALID == 0);
-
-static void *allocateVmar(uptr Size, MapPlatformData *Data, bool AllowNoMem) {
- // Only scenario so far.
- DCHECK(Data);
- DCHECK_EQ(Data->Vmar, ZX_HANDLE_INVALID);
-
- const zx_status_t Status = _zx_vmar_allocate(
- _zx_vmar_root_self(),
- ZX_VM_CAN_MAP_READ | ZX_VM_CAN_MAP_WRITE | ZX_VM_CAN_MAP_SPECIFIC, 0,
- Size, &Data->Vmar, &Data->VmarBase);
- if (UNLIKELY(Status != ZX_OK)) {
- if (Status != ZX_ERR_NO_MEMORY || !AllowNoMem)
- dieOnMapUnmapError(Status == ZX_ERR_NO_MEMORY);
- return nullptr;
- }
- return reinterpret_cast<void *>(Data->VmarBase);
-}
-
-void *map(void *Addr, uptr Size, const char *Name, uptr Flags,
- MapPlatformData *Data) {
- DCHECK_EQ(Size % PAGE_SIZE, 0);
- const bool AllowNoMem = !!(Flags & MAP_ALLOWNOMEM);
-
- // For MAP_NOACCESS, just allocate a Vmar and return.
- if (Flags & MAP_NOACCESS)
- return allocateVmar(Size, Data, AllowNoMem);
-
- const zx_handle_t Vmar = Data ? Data->Vmar : _zx_vmar_root_self();
- CHECK_NE(Vmar, ZX_HANDLE_INVALID);
-
- zx_status_t Status;
- zx_handle_t Vmo;
- uint64_t VmoSize = 0;
- if (Data && Data->Vmo != ZX_HANDLE_INVALID) {
- // If a Vmo was specified, it's a resize operation.
- CHECK(Addr);
- DCHECK(Flags & MAP_RESIZABLE);
- Vmo = Data->Vmo;
- VmoSize = Data->VmoSize;
- Status = _zx_vmo_set_size(Vmo, VmoSize + Size);
- if (Status != ZX_OK) {
- if (Status != ZX_ERR_NO_MEMORY || !AllowNoMem)
- dieOnMapUnmapError(Status == ZX_ERR_NO_MEMORY);
- return nullptr;
- }
- } else {
- // Otherwise, create a Vmo and set its name.
- Status = _zx_vmo_create(Size, ZX_VMO_RESIZABLE, &Vmo);
- if (UNLIKELY(Status != ZX_OK)) {
- if (Status != ZX_ERR_NO_MEMORY || !AllowNoMem)
- dieOnMapUnmapError(Status == ZX_ERR_NO_MEMORY);
- return nullptr;
- }
- _zx_object_set_property(Vmo, ZX_PROP_NAME, Name, strlen(Name));
- }
-
- uintptr_t P;
- zx_vm_option_t MapFlags =
- ZX_VM_PERM_READ | ZX_VM_PERM_WRITE | ZX_VM_ALLOW_FAULTS;
- const uint64_t Offset =
- Addr ? reinterpret_cast<uintptr_t>(Addr) - Data->VmarBase : 0;
- if (Offset)
- MapFlags |= ZX_VM_SPECIFIC;
- Status = _zx_vmar_map(Vmar, MapFlags, Offset, Vmo, VmoSize, Size, &P);
- // No need to track the Vmo if we don't intend on resizing it. Close it.
- if (Flags & MAP_RESIZABLE) {
- DCHECK(Data);
- DCHECK_EQ(Data->Vmo, ZX_HANDLE_INVALID);
- Data->Vmo = Vmo;
- } else {
- CHECK_EQ(_zx_handle_close(Vmo), ZX_OK);
- }
- if (UNLIKELY(Status != ZX_OK)) {
- if (Status != ZX_ERR_NO_MEMORY || !AllowNoMem)
- dieOnMapUnmapError(Status == ZX_ERR_NO_MEMORY);
- return nullptr;
- }
- if (Data)
- Data->VmoSize += Size;
-
- return reinterpret_cast<void *>(P);
-}
-
-void unmap(void *Addr, uptr Size, uptr Flags, MapPlatformData *Data) {
- if (Flags & UNMAP_ALL) {
- DCHECK_NE(Data, nullptr);
- const zx_handle_t Vmar = Data->Vmar;
- DCHECK_NE(Vmar, _zx_vmar_root_self());
- // Destroying the vmar effectively unmaps the whole mapping.
- CHECK_EQ(_zx_vmar_destroy(Vmar), ZX_OK);
- CHECK_EQ(_zx_handle_close(Vmar), ZX_OK);
- } else {
- const zx_handle_t Vmar = Data ? Data->Vmar : _zx_vmar_root_self();
- const zx_status_t Status =
- _zx_vmar_unmap(Vmar, reinterpret_cast<uintptr_t>(Addr), Size);
- if (UNLIKELY(Status != ZX_OK))
- dieOnMapUnmapError();
- }
- if (Data) {
- if (Data->Vmo != ZX_HANDLE_INVALID)
- CHECK_EQ(_zx_handle_close(Data->Vmo), ZX_OK);
- memset(Data, 0, sizeof(*Data));
- }
-}
-
-void releasePagesToOS(UNUSED uptr BaseAddress, uptr Offset, uptr Size,
- MapPlatformData *Data) {
- DCHECK(Data);
- DCHECK_NE(Data->Vmar, ZX_HANDLE_INVALID);
- DCHECK_NE(Data->Vmo, ZX_HANDLE_INVALID);
- const zx_status_t Status =
- _zx_vmo_op_range(Data->Vmo, ZX_VMO_OP_DECOMMIT, Offset, Size, NULL, 0);
- CHECK_EQ(Status, ZX_OK);
-}
-
-const char *getEnv(const char *Name) { return getenv(Name); }
-
-// Note: we need to flag these methods with __TA_NO_THREAD_SAFETY_ANALYSIS
-// because the Fuchsia implementation of sync_mutex_t has clang thread safety
-// annotations. Were we to apply proper capability annotations to the top level
-// HybridMutex class itself, they would not be needed. As it stands, the
-// thread analysis thinks that we are locking the mutex and accidentally leaving
-// it locked on the way out.
-bool HybridMutex::tryLock() __TA_NO_THREAD_SAFETY_ANALYSIS {
- // Size and alignment must be compatible between both types.
- return sync_mutex_trylock(&M) == ZX_OK;
-}
-
-void HybridMutex::lockSlow() __TA_NO_THREAD_SAFETY_ANALYSIS {
- sync_mutex_lock(&M);
-}
-
-void HybridMutex::unlock() __TA_NO_THREAD_SAFETY_ANALYSIS {
- sync_mutex_unlock(&M);
-}
-
-u64 getMonotonicTime() { return _zx_clock_get_monotonic(); }
-
-u32 getNumberOfCPUs() { return _zx_system_get_num_cpus(); }
-
-bool getRandom(void *Buffer, uptr Length, bool Blocking) {
- COMPILER_CHECK(MaxRandomLength <= ZX_CPRNG_DRAW_MAX_LEN);
- if (UNLIKELY(!Buffer || !Length || Length > MaxRandomLength))
- return false;
- _zx_cprng_draw(Buffer, Length);
- return true;
-}
-
-void outputRaw(const char *Buffer) {
- __sanitizer_log_write(Buffer, strlen(Buffer));
-}
-
-void setAbortMessage(const char *Message) {}
-
-} // namespace scudo
-
-#endif // SCUDO_FUCHSIA
Copied: compiler-rt/trunk/lib/scudo/standalone/fuchsia.cpp (from r367567, compiler-rt/trunk/lib/scudo/standalone/fuchsia.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/fuchsia.cpp?p2=compiler-rt/trunk/lib/scudo/standalone/fuchsia.cpp&p1=compiler-rt/trunk/lib/scudo/standalone/fuchsia.cc&r1=367567&r2=367568&rev=367568&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/fuchsia.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/fuchsia.cpp Thu Aug 1 07:36:38 2019
@@ -1,4 +1,4 @@
-//===-- fuchsia.cc ----------------------------------------------*- C++ -*-===//
+//===-- fuchsia.cpp ---------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Removed: compiler-rt/trunk/lib/scudo/standalone/linux.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/linux.cc?rev=367567&view=auto
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/linux.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/linux.cc (removed)
@@ -1,171 +0,0 @@
-//===-- linux.cc ------------------------------------------------*- 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
-//
-//===----------------------------------------------------------------------===//
-
-#include "platform.h"
-
-#if SCUDO_LINUX
-
-#include "common.h"
-#include "linux.h"
-#include "mutex.h"
-#include "string_utils.h"
-
-#include <errno.h>
-#include <fcntl.h>
-#include <linux/futex.h>
-#include <sched.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/mman.h>
-#include <sys/stat.h>
-#include <sys/syscall.h>
-#include <sys/time.h>
-#include <time.h>
-#include <unistd.h>
-
-#if SCUDO_ANDROID
-#include <sys/prctl.h>
-// Definitions of prctl arguments to set a vma name in Android kernels.
-#define ANDROID_PR_SET_VMA 0x53564d41
-#define ANDROID_PR_SET_VMA_ANON_NAME 0
-#endif
-
-namespace scudo {
-
-uptr getPageSize() { return static_cast<uptr>(sysconf(_SC_PAGESIZE)); }
-
-void NORETURN die() { abort(); }
-
-void *map(void *Addr, uptr Size, UNUSED const char *Name, uptr Flags,
- UNUSED MapPlatformData *Data) {
- int MmapFlags = MAP_PRIVATE | MAP_ANON;
- int MmapProt;
- if (Flags & MAP_NOACCESS) {
- MmapFlags |= MAP_NORESERVE;
- MmapProt = PROT_NONE;
- } else {
- MmapProt = PROT_READ | PROT_WRITE;
- }
- if (Addr) {
- // Currently no scenario for a noaccess mapping with a fixed address.
- DCHECK_EQ(Flags & MAP_NOACCESS, 0);
- MmapFlags |= MAP_FIXED;
- }
- void *P = mmap(Addr, Size, MmapProt, MmapFlags, -1, 0);
- if (P == MAP_FAILED) {
- if (!(Flags & MAP_ALLOWNOMEM) || errno != ENOMEM)
- dieOnMapUnmapError(errno == ENOMEM);
- return nullptr;
- }
-#if SCUDO_ANDROID
- if (!(Flags & MAP_NOACCESS))
- prctl(ANDROID_PR_SET_VMA, ANDROID_PR_SET_VMA_ANON_NAME, P, Size, Name);
-#endif
- return P;
-}
-
-void unmap(void *Addr, uptr Size, UNUSED uptr Flags,
- UNUSED MapPlatformData *Data) {
- if (munmap(Addr, Size) != 0)
- dieOnMapUnmapError();
-}
-
-void releasePagesToOS(uptr BaseAddress, uptr Offset, uptr Size,
- UNUSED MapPlatformData *Data) {
- void *Addr = reinterpret_cast<void *>(BaseAddress + Offset);
- while (madvise(Addr, Size, MADV_DONTNEED) == -1 && errno == EAGAIN) {
- }
-}
-
-// Calling getenv should be fine (c)(tm) at any time.
-const char *getEnv(const char *Name) { return getenv(Name); }
-
-namespace {
-enum State : u32 { Unlocked = 0, Locked = 1, Sleeping = 2 };
-}
-
-bool HybridMutex::tryLock() {
- return atomic_compare_exchange(&M, Unlocked, Locked) == Unlocked;
-}
-
-// The following is based on https://akkadia.org/drepper/futex.pdf.
-void HybridMutex::lockSlow() {
- u32 V = atomic_compare_exchange(&M, Unlocked, Locked);
- if (V == Unlocked)
- return;
- if (V != Sleeping)
- V = atomic_exchange(&M, Sleeping, memory_order_acquire);
- while (V != Unlocked) {
- syscall(SYS_futex, reinterpret_cast<uptr>(&M), FUTEX_WAIT_PRIVATE, Sleeping,
- nullptr, nullptr, 0);
- V = atomic_exchange(&M, Sleeping, memory_order_acquire);
- }
-}
-
-void HybridMutex::unlock() {
- if (atomic_fetch_sub(&M, 1U, memory_order_release) != Locked) {
- atomic_store(&M, Unlocked, memory_order_release);
- syscall(SYS_futex, reinterpret_cast<uptr>(&M), FUTEX_WAKE_PRIVATE, 1,
- nullptr, nullptr, 0);
- }
-}
-
-u64 getMonotonicTime() {
- timespec TS;
- clock_gettime(CLOCK_MONOTONIC, &TS);
- return static_cast<u64>(TS.tv_sec) * (1000ULL * 1000 * 1000) +
- static_cast<u64>(TS.tv_nsec);
-}
-
-u32 getNumberOfCPUs() {
- cpu_set_t CPUs;
- CHECK_EQ(sched_getaffinity(0, sizeof(cpu_set_t), &CPUs), 0);
- return static_cast<u32>(CPU_COUNT(&CPUs));
-}
-
-// Blocking is possibly unused if the getrandom block is not compiled in.
-bool getRandom(void *Buffer, uptr Length, UNUSED bool Blocking) {
- if (!Buffer || !Length || Length > MaxRandomLength)
- return false;
- ssize_t ReadBytes;
-#if defined(SYS_getrandom)
-#if !defined(GRND_NONBLOCK)
-#define GRND_NONBLOCK 1
-#endif
- // Up to 256 bytes, getrandom will not be interrupted.
- ReadBytes =
- syscall(SYS_getrandom, Buffer, Length, Blocking ? 0 : GRND_NONBLOCK);
- if (ReadBytes == static_cast<ssize_t>(Length))
- return true;
-#endif // defined(SYS_getrandom)
- // Up to 256 bytes, a read off /dev/urandom will not be interrupted.
- // Blocking is moot here, O_NONBLOCK has no effect when opening /dev/urandom.
- const int FileDesc = open("/dev/urandom", O_RDONLY);
- if (FileDesc == -1)
- return false;
- ReadBytes = read(FileDesc, Buffer, Length);
- close(FileDesc);
- return (ReadBytes == static_cast<ssize_t>(Length));
-}
-
-void outputRaw(const char *Buffer) {
- static HybridMutex Mutex;
- ScopedLock L(Mutex);
- write(2, Buffer, strlen(Buffer));
-}
-
-extern "C" WEAK void android_set_abort_message(const char *);
-
-void setAbortMessage(const char *Message) {
- if (&android_set_abort_message)
- android_set_abort_message(Message);
-}
-
-} // namespace scudo
-
-#endif // SCUDO_LINUX
Copied: compiler-rt/trunk/lib/scudo/standalone/linux.cpp (from r367567, compiler-rt/trunk/lib/scudo/standalone/linux.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/linux.cpp?p2=compiler-rt/trunk/lib/scudo/standalone/linux.cpp&p1=compiler-rt/trunk/lib/scudo/standalone/linux.cc&r1=367567&r2=367568&rev=367568&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/linux.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/linux.cpp Thu Aug 1 07:36:38 2019
@@ -1,4 +1,4 @@
-//===-- linux.cc ------------------------------------------------*- C++ -*-===//
+//===-- linux.cpp -----------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Removed: compiler-rt/trunk/lib/scudo/standalone/report.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/report.cc?rev=367567&view=auto
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/report.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/report.cc (removed)
@@ -1,192 +0,0 @@
-//===-- report.cc -----------------------------------------------*- 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
-//
-//===----------------------------------------------------------------------===//
-
-#include "report.h"
-
-#include "atomic_helpers.h"
-#include "string_utils.h"
-
-#include <stdarg.h>
-
-namespace scudo {
-
-class ScopedErrorReport {
-public:
- ScopedErrorReport() : Message(512) { Message.append("Scudo ERROR: "); }
- void append(const char *Format, ...) {
- va_list Args;
- va_start(Args, Format);
- Message.append(Format, Args);
- va_end(Args);
- }
- NORETURN ~ScopedErrorReport() {
- outputRaw(Message.data());
- setAbortMessage(Message.data());
- die();
- }
-
-private:
- ScopedString Message;
-};
-
-INLINE void NORETURN trap() { __builtin_trap(); }
-
-// This could potentially be called recursively if a CHECK fails in the reports.
-void NORETURN reportCheckFailed(const char *File, int Line,
- const char *Condition, u64 Value1, u64 Value2) {
- static atomic_u32 NumberOfCalls;
- if (atomic_fetch_add(&NumberOfCalls, 1, memory_order_relaxed) > 2) {
- // TODO(kostyak): maybe sleep here?
- trap();
- }
- ScopedErrorReport Report;
- Report.append("CHECK failed @ %s:%d %s (%llu, %llu)\n", File, Line, Condition,
- Value1, Value2);
-}
-
-// Generic string fatal error message.
-void NORETURN reportError(const char *Message) {
- ScopedErrorReport Report;
- Report.append("%s\n", Message);
-}
-
-void NORETURN reportInvalidFlag(const char *FlagType, const char *Value) {
- ScopedErrorReport Report;
- Report.append("invalid value for %s option: '%s'\n", FlagType, Value);
-}
-
-// The checksum of a chunk header is invalid. This could be caused by an
-// {over,under}write of the header, a pointer that is not an actual chunk.
-void NORETURN reportHeaderCorruption(void *Ptr) {
- ScopedErrorReport Report;
- Report.append("corrupted chunk header at address %p\n", Ptr);
-}
-
-// Two threads have attempted to modify a chunk header at the same time. This is
-// symptomatic of a race-condition in the application code, or general lack of
-// proper locking.
-void NORETURN reportHeaderRace(void *Ptr) {
- ScopedErrorReport Report;
- Report.append("race on chunk header at address %p\n", Ptr);
-}
-
-// The allocator was compiled with parameters that conflict with field size
-// requirements.
-void NORETURN reportSanityCheckError(const char *Field) {
- ScopedErrorReport Report;
- Report.append("maximum possible %s doesn't fit in header\n", Field);
-}
-
-// We enforce a maximum alignment, to keep fields smaller and generally prevent
-// integer overflows, or unexpected corner cases.
-void NORETURN reportAlignmentTooBig(uptr Alignment, uptr MaxAlignment) {
- ScopedErrorReport Report;
- Report.append("invalid allocation alignment: %zu exceeds maximum supported "
- "alignment of %zu\n",
- Alignment, MaxAlignment);
-}
-
-// See above, we also enforce a maximum size.
-void NORETURN reportAllocationSizeTooBig(uptr UserSize, uptr TotalSize,
- uptr MaxSize) {
- ScopedErrorReport Report;
- Report.append("requested allocation size %zu (%zu after adjustments) exceeds "
- "maximum supported size of %zu\n",
- UserSize, TotalSize, MaxSize);
-}
-
-void NORETURN reportOutOfMemory(uptr RequestedSize) {
- ScopedErrorReport Report;
- Report.append("out of memory trying to allocate %zu bytes\n", RequestedSize);
-}
-
-static const char *stringifyAction(AllocatorAction Action) {
- switch (Action) {
- case AllocatorAction::Recycling:
- return "recycling";
- case AllocatorAction::Deallocating:
- return "deallocating";
- case AllocatorAction::Reallocating:
- return "reallocating";
- case AllocatorAction::Sizing:
- return "sizing";
- }
- return "<invalid action>";
-}
-
-// The chunk is not in a state congruent with the operation we want to perform.
-// This is usually the case with a double-free, a realloc of a freed pointer.
-void NORETURN reportInvalidChunkState(AllocatorAction Action, void *Ptr) {
- ScopedErrorReport Report;
- Report.append("invalid chunk state when %s address %p\n",
- stringifyAction(Action), Ptr);
-}
-
-void NORETURN reportMisalignedPointer(AllocatorAction Action, void *Ptr) {
- ScopedErrorReport Report;
- Report.append("misaligned pointer when %s address %p\n",
- stringifyAction(Action), Ptr);
-}
-
-// The deallocation function used is at odds with the one used to allocate the
-// chunk (eg: new[]/delete or malloc/delete, and so on).
-void NORETURN reportDeallocTypeMismatch(AllocatorAction Action, void *Ptr,
- u8 TypeA, u8 TypeB) {
- ScopedErrorReport Report;
- Report.append("allocation type mismatch when %s address %p (%d vs %d)\n",
- stringifyAction(Action), Ptr, TypeA, TypeB);
-}
-
-// The size specified to the delete operator does not match the one that was
-// passed to new when allocating the chunk.
-void NORETURN reportDeleteSizeMismatch(void *Ptr, uptr Size,
- uptr ExpectedSize) {
- ScopedErrorReport Report;
- Report.append(
- "invalid sized delete when deallocating address %p (%zu vs %zu)\n", Ptr,
- Size, ExpectedSize);
-}
-
-void NORETURN reportAlignmentNotPowerOfTwo(uptr Alignment) {
- ScopedErrorReport Report;
- Report.append(
- "invalid allocation alignment: %zu, alignment must be a power of two\n",
- Alignment);
-}
-
-void NORETURN reportCallocOverflow(uptr Count, uptr Size) {
- ScopedErrorReport Report;
- Report.append("calloc parameters overflow: count * size (%zu * %zu) cannot "
- "be represented with type size_t\n",
- Count, Size);
-}
-
-void NORETURN reportInvalidPosixMemalignAlignment(uptr Alignment) {
- ScopedErrorReport Report;
- Report.append(
- "invalid alignment requested in posix_memalign: %zu, alignment must be a "
- "power of two and a multiple of sizeof(void *) == %zu\n",
- Alignment, sizeof(void *));
-}
-
-void NORETURN reportPvallocOverflow(uptr Size) {
- ScopedErrorReport Report;
- Report.append("pvalloc parameters overflow: size %zu rounded up to system "
- "page size %zu cannot be represented in type size_t\n",
- Size, getPageSizeCached());
-}
-
-void NORETURN reportInvalidAlignedAllocAlignment(uptr Alignment, uptr Size) {
- ScopedErrorReport Report;
- Report.append("invalid alignment requested in aligned_alloc: %zu, alignment "
- "must be a power of two and the requested size %zu must be a "
- "multiple of alignment\n",
- Alignment, Size);
-}
-
-} // namespace scudo
Copied: compiler-rt/trunk/lib/scudo/standalone/report.cpp (from r367567, compiler-rt/trunk/lib/scudo/standalone/report.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/report.cpp?p2=compiler-rt/trunk/lib/scudo/standalone/report.cpp&p1=compiler-rt/trunk/lib/scudo/standalone/report.cc&r1=367567&r2=367568&rev=367568&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/report.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/report.cpp Thu Aug 1 07:36:38 2019
@@ -1,4 +1,4 @@
-//===-- report.cc -----------------------------------------------*- C++ -*-===//
+//===-- report.cpp ----------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Removed: compiler-rt/trunk/lib/scudo/standalone/secondary.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/secondary.cc?rev=367567&view=auto
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/secondary.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/secondary.cc (removed)
@@ -1,134 +0,0 @@
-//===-- secondary.cc --------------------------------------------*- 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
-//
-//===----------------------------------------------------------------------===//
-
-#include "secondary.h"
-
-#include "string_utils.h"
-
-namespace scudo {
-
-// As with the Primary, the size passed to this function includes any desired
-// alignment, so that the frontend can align the user allocation. The hint
-// parameter allows us to unmap spurious memory when dealing with larger
-// (greater than a page) alignments on 32-bit platforms.
-// Due to the sparsity of address space available on those platforms, requesting
-// an allocation from the Secondary with a large alignment would end up wasting
-// VA space (even though we are not committing the whole thing), hence the need
-// to trim off some of the reserved space.
-// For allocations requested with an alignment greater than or equal to a page,
-// the committed memory will amount to something close to Size - AlignmentHint
-// (pending rounding and headers).
-void *MapAllocator::allocate(uptr Size, uptr AlignmentHint, uptr *BlockEnd) {
- DCHECK_GT(Size, AlignmentHint);
- const uptr PageSize = getPageSizeCached();
- const uptr MapSize =
- roundUpTo(Size + LargeBlock::getHeaderSize(), PageSize) + 2 * PageSize;
- MapPlatformData Data = {};
- uptr MapBase =
- reinterpret_cast<uptr>(map(nullptr, MapSize, "scudo:secondary",
- MAP_NOACCESS | MAP_ALLOWNOMEM, &Data));
- if (UNLIKELY(!MapBase))
- return nullptr;
- uptr CommitBase = MapBase + PageSize;
- uptr MapEnd = MapBase + MapSize;
-
- // In the unlikely event of alignments larger than a page, adjust the amount
- // of memory we want to commit, and trim the extra memory.
- if (UNLIKELY(AlignmentHint >= PageSize)) {
- // For alignments greater than or equal to a page, the user pointer (eg: the
- // pointer that is returned by the C or C++ allocation APIs) ends up on a
- // page boundary , and our headers will live in the preceding page.
- CommitBase = roundUpTo(MapBase + PageSize + 1, AlignmentHint) - PageSize;
- const uptr NewMapBase = CommitBase - PageSize;
- DCHECK_GE(NewMapBase, MapBase);
- // We only trim the extra memory on 32-bit platforms: 64-bit platforms
- // are less constrained memory wise, and that saves us two syscalls.
- if (SCUDO_WORDSIZE == 32U && NewMapBase != MapBase) {
- unmap(reinterpret_cast<void *>(MapBase), NewMapBase - MapBase, 0, &Data);
- MapBase = NewMapBase;
- }
- const uptr NewMapEnd = CommitBase + PageSize +
- roundUpTo((Size - AlignmentHint), PageSize) +
- PageSize;
- DCHECK_LE(NewMapEnd, MapEnd);
- if (SCUDO_WORDSIZE == 32U && NewMapEnd != MapEnd) {
- unmap(reinterpret_cast<void *>(NewMapEnd), MapEnd - NewMapEnd, 0, &Data);
- MapEnd = NewMapEnd;
- }
- }
-
- const uptr CommitSize = MapEnd - PageSize - CommitBase;
- const uptr Ptr =
- reinterpret_cast<uptr>(map(reinterpret_cast<void *>(CommitBase),
- CommitSize, "scudo:secondary", 0, &Data));
- LargeBlock::Header *H = reinterpret_cast<LargeBlock::Header *>(Ptr);
- H->MapBase = MapBase;
- H->MapSize = MapEnd - MapBase;
- H->BlockEnd = CommitBase + CommitSize;
- H->Data = Data;
- {
- ScopedLock L(Mutex);
- if (LIKELY(Tail)) {
- Tail->Next = H;
- H->Prev = Tail;
- }
- Tail = H;
- AllocatedBytes += CommitSize;
- if (LargestSize < CommitSize)
- LargestSize = CommitSize;
- NumberOfAllocs++;
- Stats.add(StatAllocated, CommitSize);
- Stats.add(StatMapped, H->MapSize);
- }
- if (BlockEnd)
- *BlockEnd = CommitBase + CommitSize;
- return reinterpret_cast<void *>(Ptr + LargeBlock::getHeaderSize());
-}
-
-void MapAllocator::deallocate(void *Ptr) {
- LargeBlock::Header *H = LargeBlock::getHeader(Ptr);
- {
- ScopedLock L(Mutex);
- LargeBlock::Header *Prev = H->Prev;
- LargeBlock::Header *Next = H->Next;
- if (Prev) {
- CHECK_EQ(Prev->Next, H);
- Prev->Next = Next;
- }
- if (Next) {
- CHECK_EQ(Next->Prev, H);
- Next->Prev = Prev;
- }
- if (UNLIKELY(Tail == H)) {
- CHECK(!Next);
- Tail = Prev;
- } else {
- CHECK(Next);
- }
- const uptr CommitSize = H->BlockEnd - reinterpret_cast<uptr>(H);
- FreedBytes += CommitSize;
- NumberOfFrees++;
- Stats.sub(StatAllocated, CommitSize);
- Stats.sub(StatMapped, H->MapSize);
- }
- void *Addr = reinterpret_cast<void *>(H->MapBase);
- const uptr Size = H->MapSize;
- MapPlatformData Data;
- Data = H->Data;
- unmap(Addr, Size, UNMAP_ALL, &Data);
-}
-
-void MapAllocator::printStats() const {
- Printf("Stats: MapAllocator: allocated %zd times (%zdK), freed %zd times "
- "(%zdK), remains %zd (%zdK) max %zdM\n",
- NumberOfAllocs, AllocatedBytes >> 10, NumberOfFrees, FreedBytes >> 10,
- NumberOfAllocs - NumberOfFrees, (AllocatedBytes - FreedBytes) >> 10,
- LargestSize >> 20);
-}
-
-} // namespace scudo
Copied: compiler-rt/trunk/lib/scudo/standalone/secondary.cpp (from r367567, compiler-rt/trunk/lib/scudo/standalone/secondary.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/secondary.cpp?p2=compiler-rt/trunk/lib/scudo/standalone/secondary.cpp&p1=compiler-rt/trunk/lib/scudo/standalone/secondary.cc&r1=367567&r2=367568&rev=367568&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/secondary.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/secondary.cpp Thu Aug 1 07:36:38 2019
@@ -1,4 +1,4 @@
-//===-- secondary.cc --------------------------------------------*- C++ -*-===//
+//===-- secondary.cpp -------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Removed: compiler-rt/trunk/lib/scudo/standalone/string_utils.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/string_utils.cc?rev=367567&view=auto
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/string_utils.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/string_utils.cc (removed)
@@ -1,235 +0,0 @@
-//===-- string_utils.cc -----------------------------------------*- 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
-//
-//===----------------------------------------------------------------------===//
-
-#include "string_utils.h"
-#include "common.h"
-
-#include <stdarg.h>
-#include <string.h>
-
-namespace scudo {
-
-static int appendChar(char **Buffer, const char *BufferEnd, char C) {
- if (*Buffer < BufferEnd) {
- **Buffer = C;
- (*Buffer)++;
- }
- return 1;
-}
-
-// Appends number in a given Base to buffer. If its length is less than
-// |MinNumberLength|, it is padded with leading zeroes or spaces, depending
-// on the value of |PadWithZero|.
-static int appendNumber(char **Buffer, const char *BufferEnd, u64 AbsoluteValue,
- u8 Base, u8 MinNumberLength, bool PadWithZero,
- bool Negative, bool Upper) {
- constexpr uptr MaxLen = 30;
- RAW_CHECK(Base == 10 || Base == 16);
- RAW_CHECK(Base == 10 || !Negative);
- RAW_CHECK(AbsoluteValue || !Negative);
- RAW_CHECK(MinNumberLength < MaxLen);
- int Res = 0;
- if (Negative && MinNumberLength)
- --MinNumberLength;
- if (Negative && PadWithZero)
- Res += appendChar(Buffer, BufferEnd, '-');
- uptr NumBuffer[MaxLen];
- int Pos = 0;
- do {
- RAW_CHECK_MSG(static_cast<uptr>(Pos) < MaxLen,
- "appendNumber buffer overflow");
- NumBuffer[Pos++] = static_cast<uptr>(AbsoluteValue % Base);
- AbsoluteValue /= Base;
- } while (AbsoluteValue > 0);
- if (Pos < MinNumberLength) {
- memset(&NumBuffer[Pos], 0,
- sizeof(NumBuffer[0]) * static_cast<uptr>(MinNumberLength - Pos));
- Pos = MinNumberLength;
- }
- RAW_CHECK(Pos > 0);
- Pos--;
- for (; Pos >= 0 && NumBuffer[Pos] == 0; Pos--) {
- char c = (PadWithZero || Pos == 0) ? '0' : ' ';
- Res += appendChar(Buffer, BufferEnd, c);
- }
- if (Negative && !PadWithZero)
- Res += appendChar(Buffer, BufferEnd, '-');
- for (; Pos >= 0; Pos--) {
- char Digit = static_cast<char>(NumBuffer[Pos]);
- Digit = static_cast<char>((Digit < 10) ? '0' + Digit
- : (Upper ? 'A' : 'a') + Digit - 10);
- Res += appendChar(Buffer, BufferEnd, Digit);
- }
- return Res;
-}
-
-static int appendUnsigned(char **Buffer, const char *BufferEnd, u64 Num,
- u8 Base, u8 MinNumberLength, bool PadWithZero,
- bool Upper) {
- return appendNumber(Buffer, BufferEnd, Num, Base, MinNumberLength,
- PadWithZero, /*Negative=*/false, Upper);
-}
-
-static int appendSignedDecimal(char **Buffer, const char *BufferEnd, s64 Num,
- u8 MinNumberLength, bool PadWithZero) {
- const bool Negative = (Num < 0);
- return appendNumber(Buffer, BufferEnd,
- static_cast<u64>(Negative ? -Num : Num), 10,
- MinNumberLength, PadWithZero, Negative,
- /*Upper=*/false);
-}
-
-// Use the fact that explicitly requesting 0 Width (%0s) results in UB and
-// interpret Width == 0 as "no Width requested":
-// Width == 0 - no Width requested
-// Width < 0 - left-justify S within and pad it to -Width chars, if necessary
-// Width > 0 - right-justify S, not implemented yet
-static int appendString(char **Buffer, const char *BufferEnd, int Width,
- int MaxChars, const char *S) {
- if (!S)
- S = "<null>";
- int Res = 0;
- for (; *S; S++) {
- if (MaxChars >= 0 && Res >= MaxChars)
- break;
- Res += appendChar(Buffer, BufferEnd, *S);
- }
- // Only the left justified strings are supported.
- while (Width < -Res)
- Res += appendChar(Buffer, BufferEnd, ' ');
- return Res;
-}
-
-static int appendPointer(char **Buffer, const char *BufferEnd, u64 ptr_value) {
- int Res = 0;
- Res += appendString(Buffer, BufferEnd, 0, -1, "0x");
- Res += appendUnsigned(Buffer, BufferEnd, ptr_value, 16,
- SCUDO_POINTER_FORMAT_LENGTH, /*PadWithZero=*/true,
- /*Upper=*/false);
- return Res;
-}
-
-int formatString(char *Buffer, uptr BufferLength, const char *Format,
- va_list Args) {
- static const char *PrintfFormatsHelp =
- "Supported formatString formats: %([0-9]*)?(z|ll)?{d,u,x,X}; %p; "
- "%[-]([0-9]*)?(\\.\\*)?s; %c\n";
- RAW_CHECK(Format);
- RAW_CHECK(BufferLength > 0);
- const char *BufferEnd = &Buffer[BufferLength - 1];
- const char *Cur = Format;
- int Res = 0;
- for (; *Cur; Cur++) {
- if (*Cur != '%') {
- Res += appendChar(&Buffer, BufferEnd, *Cur);
- continue;
- }
- Cur++;
- const bool LeftJustified = *Cur == '-';
- if (LeftJustified)
- Cur++;
- bool HaveWidth = (*Cur >= '0' && *Cur <= '9');
- const bool PadWithZero = (*Cur == '0');
- u8 Width = 0;
- if (HaveWidth) {
- while (*Cur >= '0' && *Cur <= '9')
- Width = static_cast<u8>(Width * 10 + *Cur++ - '0');
- }
- const bool HavePrecision = (Cur[0] == '.' && Cur[1] == '*');
- int Precision = -1;
- if (HavePrecision) {
- Cur += 2;
- Precision = va_arg(Args, int);
- }
- const bool HaveZ = (*Cur == 'z');
- Cur += HaveZ;
- const bool HaveLL = !HaveZ && (Cur[0] == 'l' && Cur[1] == 'l');
- Cur += HaveLL * 2;
- s64 DVal;
- u64 UVal;
- const bool HaveLength = HaveZ || HaveLL;
- const bool HaveFlags = HaveWidth || HaveLength;
- // At the moment only %s supports precision and left-justification.
- CHECK(!((Precision >= 0 || LeftJustified) && *Cur != 's'));
- switch (*Cur) {
- case 'd': {
- DVal = HaveLL ? va_arg(Args, s64)
- : HaveZ ? va_arg(Args, sptr) : va_arg(Args, int);
- Res += appendSignedDecimal(&Buffer, BufferEnd, DVal, Width, PadWithZero);
- break;
- }
- case 'u':
- case 'x':
- case 'X': {
- UVal = HaveLL ? va_arg(Args, u64)
- : HaveZ ? va_arg(Args, uptr) : va_arg(Args, unsigned);
- const bool Upper = (*Cur == 'X');
- Res += appendUnsigned(&Buffer, BufferEnd, UVal, (*Cur == 'u') ? 10 : 16,
- Width, PadWithZero, Upper);
- break;
- }
- case 'p': {
- RAW_CHECK_MSG(!HaveFlags, PrintfFormatsHelp);
- Res += appendPointer(&Buffer, BufferEnd, va_arg(Args, uptr));
- break;
- }
- case 's': {
- RAW_CHECK_MSG(!HaveLength, PrintfFormatsHelp);
- // Only left-justified Width is supported.
- CHECK(!HaveWidth || LeftJustified);
- Res += appendString(&Buffer, BufferEnd, LeftJustified ? -Width : Width,
- Precision, va_arg(Args, char *));
- break;
- }
- case 'c': {
- RAW_CHECK_MSG(!HaveFlags, PrintfFormatsHelp);
- Res +=
- appendChar(&Buffer, BufferEnd, static_cast<char>(va_arg(Args, int)));
- break;
- }
- case '%': {
- RAW_CHECK_MSG(!HaveFlags, PrintfFormatsHelp);
- Res += appendChar(&Buffer, BufferEnd, '%');
- break;
- }
- default: {
- RAW_CHECK_MSG(false, PrintfFormatsHelp);
- }
- }
- }
- RAW_CHECK(Buffer <= BufferEnd);
- appendChar(&Buffer, BufferEnd + 1, '\0');
- return Res;
-}
-
-void ScopedString::append(const char *Format, va_list Args) {
- CHECK_LT(Length, String.size());
- formatString(String.data() + Length, String.size() - Length, Format, Args);
- Length += strlen(String.data() + Length);
- CHECK_LT(Length, String.size());
-}
-
-FORMAT(2, 3)
-void ScopedString::append(const char *Format, ...) {
- va_list Args;
- va_start(Args, Format);
- append(Format, Args);
- va_end(Args);
-}
-
-FORMAT(1, 2)
-void Printf(const char *Format, ...) {
- va_list Args;
- va_start(Args, Format);
- ScopedString Msg(512);
- Msg.append(Format, Args);
- outputRaw(Msg.data());
- va_end(Args);
-}
-
-} // namespace scudo
Copied: compiler-rt/trunk/lib/scudo/standalone/string_utils.cpp (from r367567, compiler-rt/trunk/lib/scudo/standalone/string_utils.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/string_utils.cpp?p2=compiler-rt/trunk/lib/scudo/standalone/string_utils.cpp&p1=compiler-rt/trunk/lib/scudo/standalone/string_utils.cc&r1=367567&r2=367568&rev=367568&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/string_utils.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/string_utils.cpp Thu Aug 1 07:36:38 2019
@@ -1,4 +1,4 @@
-//===-- string_utils.cc -----------------------------------------*- C++ -*-===//
+//===-- string_utils.cpp ----------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Removed: compiler-rt/trunk/lib/scudo/standalone/wrappers_c.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/wrappers_c.cc?rev=367567&view=auto
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/wrappers_c.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/wrappers_c.cc (removed)
@@ -1,39 +0,0 @@
-//===-- wrappers_c.cc -------------------------------------------*- 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
-//
-//===----------------------------------------------------------------------===//
-
-#include "platform.h"
-
-// Skip this compilation unit if compiled as part of Bionic.
-#if !SCUDO_ANDROID || !_BIONIC
-
-#include "allocator_config.h"
-#include "wrappers_c.h"
-#include "wrappers_c_checks.h"
-
-#include <stdint.h>
-#include <stdio.h>
-
-static scudo::Allocator<scudo::Config> Allocator;
-// Pointer to the static allocator so that the C++ wrappers can access it.
-// Technically we could have a completely separated heap for C & C++ but in
-// reality the amount of cross pollination between the two is staggering.
-scudo::Allocator<scudo::Config> *AllocatorPtr = &Allocator;
-
-extern "C" {
-
-#define SCUDO_PREFIX(name) name
-#define SCUDO_ALLOCATOR Allocator
-#include "wrappers_c.inc"
-#undef SCUDO_ALLOCATOR
-#undef SCUDO_PREFIX
-
-INTERFACE void __scudo_print_stats(void) { Allocator.printStats(); }
-
-} // extern "C"
-
-#endif // !SCUDO_ANDROID || !_BIONIC
Copied: compiler-rt/trunk/lib/scudo/standalone/wrappers_c.cpp (from r367567, compiler-rt/trunk/lib/scudo/standalone/wrappers_c.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/wrappers_c.cpp?p2=compiler-rt/trunk/lib/scudo/standalone/wrappers_c.cpp&p1=compiler-rt/trunk/lib/scudo/standalone/wrappers_c.cc&r1=367567&r2=367568&rev=367568&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/wrappers_c.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/wrappers_c.cpp Thu Aug 1 07:36:38 2019
@@ -1,4 +1,4 @@
-//===-- wrappers_c.cc -------------------------------------------*- C++ -*-===//
+//===-- wrappers_c.cpp ------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Removed: compiler-rt/trunk/lib/scudo/standalone/wrappers_c_bionic.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/wrappers_c_bionic.cc?rev=367567&view=auto
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/wrappers_c_bionic.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/wrappers_c_bionic.cc (removed)
@@ -1,49 +0,0 @@
-//===-- wrappers_c_bionic.cc ------------------------------------*- 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
-//
-//===----------------------------------------------------------------------===//
-
-#include "platform.h"
-
-// This is only used when compiled as part of Bionic.
-#if SCUDO_ANDROID && _BIONIC
-
-#include "allocator_config.h"
-#include "wrappers_c.h"
-#include "wrappers_c_checks.h"
-
-#include <stdint.h>
-#include <stdio.h>
-
-static scudo::Allocator<scudo::AndroidConfig> Allocator;
-static scudo::Allocator<scudo::AndroidSvelteConfig> SvelteAllocator;
-
-extern "C" {
-
-// Regular MallocDispatch definitions.
-#define SCUDO_PREFIX(name) CONCATENATE(scudo_, name)
-#define SCUDO_ALLOCATOR Allocator
-#include "wrappers_c.inc"
-#undef SCUDO_ALLOCATOR
-#undef SCUDO_PREFIX
-
-// Svelte MallocDispatch definitions.
-#define SCUDO_PREFIX(name) CONCATENATE(scudo_svelte_, name)
-#define SCUDO_ALLOCATOR SvelteAllocator
-#include "wrappers_c.inc"
-#undef SCUDO_ALLOCATOR
-#undef SCUDO_PREFIX
-
-// The following is the only function that will end up initializing both
-// allocators, which will result in a slight increase in memory footprint.
-INTERFACE void __scudo_print_stats(void) {
- Allocator.printStats();
- SvelteAllocator.printStats();
-}
-
-} // extern "C"
-
-#endif // SCUDO_ANDROID && _BIONIC
Copied: compiler-rt/trunk/lib/scudo/standalone/wrappers_c_bionic.cpp (from r367567, compiler-rt/trunk/lib/scudo/standalone/wrappers_c_bionic.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/wrappers_c_bionic.cpp?p2=compiler-rt/trunk/lib/scudo/standalone/wrappers_c_bionic.cpp&p1=compiler-rt/trunk/lib/scudo/standalone/wrappers_c_bionic.cc&r1=367567&r2=367568&rev=367568&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/wrappers_c_bionic.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/wrappers_c_bionic.cpp Thu Aug 1 07:36:38 2019
@@ -1,4 +1,4 @@
-//===-- wrappers_c_bionic.cc ------------------------------------*- C++ -*-===//
+//===-- wrappers_c_bionic.cpp -----------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Removed: compiler-rt/trunk/lib/scudo/standalone/wrappers_cpp.cc
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/wrappers_cpp.cc?rev=367567&view=auto
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/wrappers_cpp.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/wrappers_cpp.cc (removed)
@@ -1,107 +0,0 @@
-//===-- wrappers_cpp.cc -----------------------------------------*- 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
-//
-//===----------------------------------------------------------------------===//
-
-#include "platform.h"
-
-// Skip this compilation unit if compiled as part of Bionic.
-#if !SCUDO_ANDROID || !_BIONIC
-
-#include "allocator_config.h"
-
-#include <stdint.h>
-
-extern scudo::Allocator<scudo::Config> *AllocatorPtr;
-
-namespace std {
-struct nothrow_t {};
-enum class align_val_t : size_t {};
-} // namespace std
-
-INTERFACE WEAK void *operator new(size_t size) {
- return AllocatorPtr->allocate(size, scudo::Chunk::Origin::New);
-}
-INTERFACE WEAK void *operator new[](size_t size) {
- return AllocatorPtr->allocate(size, scudo::Chunk::Origin::NewArray);
-}
-INTERFACE WEAK void *operator new(size_t size,
- std::nothrow_t const &) NOEXCEPT {
- return AllocatorPtr->allocate(size, scudo::Chunk::Origin::New);
-}
-INTERFACE WEAK void *operator new[](size_t size,
- std::nothrow_t const &) NOEXCEPT {
- return AllocatorPtr->allocate(size, scudo::Chunk::Origin::NewArray);
-}
-INTERFACE WEAK void *operator new(size_t size, std::align_val_t align) {
- return AllocatorPtr->allocate(size, scudo::Chunk::Origin::New,
- static_cast<scudo::uptr>(align));
-}
-INTERFACE WEAK void *operator new[](size_t size, std::align_val_t align) {
- return AllocatorPtr->allocate(size, scudo::Chunk::Origin::NewArray,
- static_cast<scudo::uptr>(align));
-}
-INTERFACE WEAK void *operator new(size_t size, std::align_val_t align,
- std::nothrow_t const &) NOEXCEPT {
- return AllocatorPtr->allocate(size, scudo::Chunk::Origin::New,
- static_cast<scudo::uptr>(align));
-}
-INTERFACE WEAK void *operator new[](size_t size, std::align_val_t align,
- std::nothrow_t const &) NOEXCEPT {
- return AllocatorPtr->allocate(size, scudo::Chunk::Origin::NewArray,
- static_cast<scudo::uptr>(align));
-}
-
-INTERFACE WEAK void operator delete(void *ptr)NOEXCEPT {
- AllocatorPtr->deallocate(ptr, scudo::Chunk::Origin::New);
-}
-INTERFACE WEAK void operator delete[](void *ptr) NOEXCEPT {
- AllocatorPtr->deallocate(ptr, scudo::Chunk::Origin::NewArray);
-}
-INTERFACE WEAK void operator delete(void *ptr, std::nothrow_t const &)NOEXCEPT {
- AllocatorPtr->deallocate(ptr, scudo::Chunk::Origin::New);
-}
-INTERFACE WEAK void operator delete[](void *ptr,
- std::nothrow_t const &) NOEXCEPT {
- AllocatorPtr->deallocate(ptr, scudo::Chunk::Origin::NewArray);
-}
-INTERFACE WEAK void operator delete(void *ptr, size_t size)NOEXCEPT {
- AllocatorPtr->deallocate(ptr, scudo::Chunk::Origin::New, size);
-}
-INTERFACE WEAK void operator delete[](void *ptr, size_t size) NOEXCEPT {
- AllocatorPtr->deallocate(ptr, scudo::Chunk::Origin::NewArray, size);
-}
-INTERFACE WEAK void operator delete(void *ptr, std::align_val_t align)NOEXCEPT {
- AllocatorPtr->deallocate(ptr, scudo::Chunk::Origin::New, 0,
- static_cast<scudo::uptr>(align));
-}
-INTERFACE WEAK void operator delete[](void *ptr,
- std::align_val_t align) NOEXCEPT {
- AllocatorPtr->deallocate(ptr, scudo::Chunk::Origin::NewArray, 0,
- static_cast<scudo::uptr>(align));
-}
-INTERFACE WEAK void operator delete(void *ptr, std::align_val_t align,
- std::nothrow_t const &)NOEXCEPT {
- AllocatorPtr->deallocate(ptr, scudo::Chunk::Origin::New, 0,
- static_cast<scudo::uptr>(align));
-}
-INTERFACE WEAK void operator delete[](void *ptr, std::align_val_t align,
- std::nothrow_t const &) NOEXCEPT {
- AllocatorPtr->deallocate(ptr, scudo::Chunk::Origin::NewArray, 0,
- static_cast<scudo::uptr>(align));
-}
-INTERFACE WEAK void operator delete(void *ptr, size_t size,
- std::align_val_t align)NOEXCEPT {
- AllocatorPtr->deallocate(ptr, scudo::Chunk::Origin::New, size,
- static_cast<scudo::uptr>(align));
-}
-INTERFACE WEAK void operator delete[](void *ptr, size_t size,
- std::align_val_t align) NOEXCEPT {
- AllocatorPtr->deallocate(ptr, scudo::Chunk::Origin::NewArray, size,
- static_cast<scudo::uptr>(align));
-}
-
-#endif // !SCUDO_ANDROID || !_BIONIC
Copied: compiler-rt/trunk/lib/scudo/standalone/wrappers_cpp.cpp (from r367567, compiler-rt/trunk/lib/scudo/standalone/wrappers_cpp.cc)
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/scudo/standalone/wrappers_cpp.cpp?p2=compiler-rt/trunk/lib/scudo/standalone/wrappers_cpp.cpp&p1=compiler-rt/trunk/lib/scudo/standalone/wrappers_cpp.cc&r1=367567&r2=367568&rev=367568&view=diff
==============================================================================
--- compiler-rt/trunk/lib/scudo/standalone/wrappers_cpp.cc (original)
+++ compiler-rt/trunk/lib/scudo/standalone/wrappers_cpp.cpp Thu Aug 1 07:36:38 2019
@@ -1,4 +1,4 @@
-//===-- wrappers_cpp.cc -----------------------------------------*- C++ -*-===//
+//===-- wrappers_cpp.cpp ----------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
More information about the llvm-commits
mailing list