summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZachary Ware <zachary.ware@gmail.com>2014-11-22 05:35:12 (GMT)
committerZachary Ware <zachary.ware@gmail.com>2014-11-22 05:35:12 (GMT)
commitc4821d62b4f777a530f20aecd03fd819c4f4a009 (patch)
tree0732dcfe3066a90f9388f4d5a8e596cf8820d5d1
parent9b59dd4781c1fdcf79060f62e0e2f10f67a06c65 (diff)
downloadcpython-c4821d62b4f777a530f20aecd03fd819c4f4a009.zip
cpython-c4821d62b4f777a530f20aecd03fd819c4f4a009.tar.gz
cpython-c4821d62b4f777a530f20aecd03fd819c4f4a009.tar.bz2
Closes #22869: Move PyOS_CheckStack back to pythonrun.c
-rw-r--r--Python/pylifecycle.c38
-rw-r--r--Python/pythonrun.c37
2 files changed, 37 insertions, 38 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 077c013..25a4a60 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -1431,44 +1431,6 @@ Py_FdIsInteractive(FILE *fp, const char *filename)
}
-#if defined(USE_STACKCHECK)
-#if defined(WIN32) && defined(_MSC_VER)
-
-/* Stack checking for Microsoft C */
-
-#include <malloc.h>
-#include <excpt.h>
-
-/*
- * Return non-zero when we run out of memory on the stack; zero otherwise.
- */
-int
-PyOS_CheckStack(void)
-{
- __try {
- /* alloca throws a stack overflow exception if there's
- not enough space left on the stack */
- alloca(PYOS_STACK_MARGIN * sizeof(void*));
- return 0;
- } __except (GetExceptionCode() == STATUS_STACK_OVERFLOW ?
- EXCEPTION_EXECUTE_HANDLER :
- EXCEPTION_CONTINUE_SEARCH) {
- int errcode = _resetstkoflw();
- if (errcode == 0)
- {
- Py_FatalError("Could not reset the stack!");
- }
- }
- return 1;
-}
-
-#endif /* WIN32 && _MSC_VER */
-
-/* Alternate implementations can be added here... */
-
-#endif /* USE_STACKCHECK */
-
-
/* Wrappers around sigaction() or signal(). */
PyOS_sighandler_t
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index d435ef4..992a5a3 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1376,6 +1376,43 @@ cleanup:
}
+#if defined(USE_STACKCHECK)
+#if defined(WIN32) && defined(_MSC_VER)
+
+/* Stack checking for Microsoft C */
+
+#include <malloc.h>
+#include <excpt.h>
+
+/*
+ * Return non-zero when we run out of memory on the stack; zero otherwise.
+ */
+int
+PyOS_CheckStack(void)
+{
+ __try {
+ /* alloca throws a stack overflow exception if there's
+ not enough space left on the stack */
+ alloca(PYOS_STACK_MARGIN * sizeof(void*));
+ return 0;
+ } __except (GetExceptionCode() == STATUS_STACK_OVERFLOW ?
+ EXCEPTION_EXECUTE_HANDLER :
+ EXCEPTION_CONTINUE_SEARCH) {
+ int errcode = _resetstkoflw();
+ if (errcode == 0)
+ {
+ Py_FatalError("Could not reset the stack!");
+ }
+ }
+ return 1;
+}
+
+#endif /* WIN32 && _MSC_VER */
+
+/* Alternate implementations can be added here... */
+
+#endif /* USE_STACKCHECK */
+
/* Deprecated C API functions still provided for binary compatiblity */
#undef PyParser_SimpleParseFile