aboutsummaryrefslogtreecommitdiff
path: root/contrib/compiler-rt/lib/asan/asan_malloc_local.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-08-22 19:26:11 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-08-22 19:26:11 +0000
commit14a0b2859e9d76204ca897de961b36344ce1e775 (patch)
tree08901f9a2645ad5ec5813f4b15bdc92620e1f7e4 /contrib/compiler-rt/lib/asan/asan_malloc_local.h
parent580d4aa65a2dadf52a0abc9451ab25918cb25125 (diff)
parent8f3cadc28cb2bb9e8f9d69eeaaea1f57f2f7b2ab (diff)
downloadsrc-14a0b2859e9d76204ca897de961b36344ce1e775.tar.gz
src-14a0b2859e9d76204ca897de961b36344ce1e775.zip
Merge compiler-rt trunk r366426, resolve conflicts, and add
FREEBSD-Xlist.
Notes
Notes: svn path=/projects/clang900-import/; revision=351401
Diffstat (limited to 'contrib/compiler-rt/lib/asan/asan_malloc_local.h')
-rw-r--r--contrib/compiler-rt/lib/asan/asan_malloc_local.h32
1 files changed, 20 insertions, 12 deletions
diff --git a/contrib/compiler-rt/lib/asan/asan_malloc_local.h b/contrib/compiler-rt/lib/asan/asan_malloc_local.h
index 0e8de207d98d..3f784b90c739 100644
--- a/contrib/compiler-rt/lib/asan/asan_malloc_local.h
+++ b/contrib/compiler-rt/lib/asan/asan_malloc_local.h
@@ -1,9 +1,8 @@
//===-- asan_malloc_local.h -------------------------------------*- C++ -*-===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
+// 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
//
//===----------------------------------------------------------------------===//
//
@@ -18,25 +17,34 @@
#include "sanitizer_common/sanitizer_platform.h"
#include "asan_internal.h"
-// On RTEMS, we use the local pool to handle memory allocation when the ASan
-// run-time is not up.
static INLINE bool EarlyMalloc() {
- return SANITIZER_RTEMS && (!__asan::asan_inited ||
- __asan::asan_init_is_running);
+ return SANITIZER_RTEMS &&
+ (!__asan::asan_inited || __asan::asan_init_is_running);
}
-void* MemalignFromLocalPool(uptr alignment, uptr size);
-
#if SANITIZER_RTEMS
bool IsFromLocalPool(const void *ptr);
+void *MemalignFromLocalPool(uptr alignment, uptr size);
+
+// On RTEMS, we use the local pool to handle memory allocation when the ASan
+// run-time is not up. This macro is expanded in the context of the operator new
+// implementation.
+#define MAYBE_ALLOCATE_FROM_LOCAL_POOL(nothrow) \
+ do { \
+ if (UNLIKELY(EarlyMalloc())) { \
+ void *res = MemalignFromLocalPool(SHADOW_GRANULARITY, size); \
+ if (!nothrow) \
+ CHECK(res); \
+ return res; \
+ } \
+ } while (0)
-#define ALLOCATE_FROM_LOCAL_POOL UNLIKELY(EarlyMalloc())
#define IS_FROM_LOCAL_POOL(ptr) UNLIKELY(IsFromLocalPool(ptr))
#else // SANITIZER_RTEMS
-#define ALLOCATE_FROM_LOCAL_POOL 0
+#define MAYBE_ALLOCATE_FROM_LOCAL_POOL(nothrow)
#define IS_FROM_LOCAL_POOL(ptr) 0
#endif // SANITIZER_RTEMS