17
17
18
18
#include <locale.h> // setlocale()
19
19
20
+ #if defined(__APPLE__ )
21
+ #include <mach-o/loader.h>
22
+ #endif
23
+
20
24
#ifdef HAVE_SIGNAL_H
21
25
# include <signal.h> // SIG_IGN
22
26
#endif
34
38
(PyObject_TypeCheck((op), &PyWindowsConsoleIO_Type))
35
39
#endif
36
40
37
-
38
41
#define PUTS (fd , str ) _Py_write_noraise(fd, str, (int)strlen(str))
39
42
40
43
@@ -59,7 +62,30 @@ static void wait_for_thread_shutdown(PyThreadState *tstate);
59
62
static void call_ll_exitfuncs (_PyRuntimeState * runtime );
60
63
61
64
int _Py_UnhandledKeyboardInterrupt = 0 ;
62
- _PyRuntimeState _PyRuntime = _PyRuntimeState_INIT ;
65
+
66
+ /* The following places the `_PyRuntime` structure in a location that can be
67
+ * found without any external information. This is meant to ease access to the
68
+ * interpreter state for various runtime debugging tools, but is *not* an
69
+ * officially supported feature */
70
+
71
+ #if defined(MS_WINDOWS )
72
+
73
+ #pragma section("PyRuntime", read, write)
74
+ __declspec(allocate ("PyRuntime" ))
75
+
76
+ #elif defined(__APPLE__ )
77
+
78
+ __attribute__((
79
+ section (SEG_DATA ",PyRuntime" )
80
+ ))
81
+
82
+ #endif
83
+
84
+ _PyRuntimeState _PyRuntime
85
+ #if defined(__linux__ ) && (defined(__GNUC__ ) || defined(__clang__ ))
86
+ __attribute__ ((section (".PyRuntime" )))
87
+ #endif
88
+ = _PyRuntimeState_INIT ;
63
89
static int runtime_initialized = 0 ;
64
90
65
91
PyStatus
0 commit comments