summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/sanitizer_common/sanitizer_allocator_checks.h
diff options
context:
space:
mode:
authorKostya Kortchinsky <kostyak@google.com>2017-10-11 21:20:04 +0000
committerKostya Kortchinsky <kostyak@google.com>2017-10-11 21:20:04 +0000
commit6a45f9ce82b5eb969fd30ec48ded1e8a6e6a183a (patch)
treec8890830266033a9c49e4bb7b9cb70a4f617f871 /compiler-rt/lib/sanitizer_common/sanitizer_allocator_checks.h
parentc928e1f5958a3bd748337cfd95d334202a0a9557 (diff)
downloadbcm5719-llvm-6a45f9ce82b5eb969fd30ec48ded1e8a6e6a183a.tar.gz
bcm5719-llvm-6a45f9ce82b5eb969fd30ec48ded1e8a6e6a183a.zip
[sanitizer] Move the errno/ENOMEM allocator checks logic to separate .cc
Summary: This is a new attempt at D38706, which had 2 issues. The first one was that it broke TSan, because `sanitizer_errno.h` was not directly included in `tsan_mman.cc`. This fixes the include. The second one was that it broke the nolibc build, because `__errno_location` couldn't be found. This adds the new .cc to the libcdep list instead of the base one. Reviewers: alekseyshl Reviewed By: alekseyshl Subscribers: kubamracek, mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D38743 llvm-svn: 315509
Diffstat (limited to 'compiler-rt/lib/sanitizer_common/sanitizer_allocator_checks.h')
-rw-r--r--compiler-rt/lib/sanitizer_common/sanitizer_allocator_checks.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_checks.h b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_checks.h
index b72f541a494..b61a8b2eb3b 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_allocator_checks.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_allocator_checks.h
@@ -15,17 +15,22 @@
#ifndef SANITIZER_ALLOCATOR_CHECKS_H
#define SANITIZER_ALLOCATOR_CHECKS_H
-#include "sanitizer_errno.h"
#include "sanitizer_internal_defs.h"
#include "sanitizer_common.h"
#include "sanitizer_platform.h"
namespace __sanitizer {
+// The following is defined in a separate compilation unit to avoid pulling in
+// sanitizer_errno.h in this header, which leads to conflicts when other system
+// headers include errno.h. This is usually the result of an unlikely event,
+// and as such we do not care as much about having it inlined.
+void SetErrnoToENOMEM();
+
// A common errno setting logic shared by almost all sanitizer allocator APIs.
INLINE void *SetErrnoOnNull(void *ptr) {
if (UNLIKELY(!ptr))
- errno = errno_ENOMEM;
+ SetErrnoToENOMEM();
return ptr;
}
OpenPOWER on IntegriCloud