klee/0004-Provide-errno-independent-of-CTYPE_EXTERNALS-being-d.patch

44 lines
1.3 KiB
Diff

From: Martin Nowack <martin@se.inf.tu-dresden.de>
Date: Tue, 25 Jul 2017 18:04:06 +0200
Subject: Provide errno independent of CTYPE_EXTERNALS being defined
Patch-mainline: no
Add support for `errno()` for Darwin as well.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
lib/Core/Executor.cpp | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
index dcb8d30e0ffa..dd3af9836187 100644
--- a/lib/Core/Executor.cpp
+++ b/lib/Core/Executor.cpp
@@ -524,14 +524,20 @@ void Executor::initializeGlobals(ExecutionState &state) {
globalAddresses.insert(std::make_pair(f, addr));
}
- // Disabled, we don't want to promote use of live externals.
-#ifdef HAVE_CTYPE_EXTERNALS
#ifndef WINDOWS
-#ifndef DARWIN
+#ifndef __APPLE__
/* From /usr/include/errno.h: it [errno] is a per-thread variable. */
int *errno_addr = __errno_location();
+#else
+ int *errno_addr = __error();
+#endif
addExternalObject(state, (void *)errno_addr, sizeof *errno_addr, false);
+#endif
+ // Disabled, we don't want to promote use of live externals.
+#ifdef HAVE_CTYPE_EXTERNALS
+#ifndef WINDOWS
+#ifndef DARWIN
/* from /usr/include/ctype.h:
These point into arrays of 384, so they can be indexed by any `unsigned
char' value [0,255]; by EOF (-1); or by any `signed char' value
--
2.15.0