]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Closes #22869: Move PyOS_CheckStack back to pythonrun.c
authorZachary Ware <zachary.ware@gmail.com>
Sat, 22 Nov 2014 05:35:12 +0000 (23:35 -0600)
committerZachary Ware <zachary.ware@gmail.com>
Sat, 22 Nov 2014 05:35:12 +0000 (23:35 -0600)
Python/pylifecycle.c
Python/pythonrun.c

index 077c013a917fe2305bc2375aab47877470fe193d..25a4a60f2ed2f31b76c8ac18f367b5b0d8426b97 100644 (file)
@@ -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
index d435ef40fc11a035c08b51b19a254d213adc1882..992a5a3ed09ca388de44d8d5c52062308ac5e1ea 100644 (file)
@@ -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