@@ -65,64 +65,6 @@ _Py_ReachedRecursionLimitWithMargin(PyThreadState *tstate, int margin_count)
6565# define Py_C_STACK_SIZE 4000000
6666#endif
6767
68- #if defined(__EMSCRIPTEN__ )
69-
70- // Temporary workaround to make `pthread_getattr_np` work on Emscripten.
71- // Emscripten 4.0.6 will contain a fix:
72- // https://github.com/emscripten-core/emscripten/pull/23887
73-
74- #include "emscripten/stack.h"
75-
76- #define pthread_attr_t workaround_pthread_attr_t
77- #define pthread_getattr_np workaround_pthread_getattr_np
78- #define pthread_attr_getguardsize workaround_pthread_attr_getguardsize
79- #define pthread_attr_getstack workaround_pthread_attr_getstack
80- #define pthread_attr_destroy workaround_pthread_attr_destroy
81-
82- typedef struct {
83- void * _a_stackaddr ;
84- size_t _a_stacksize , _a_guardsize ;
85- } pthread_attr_t ;
86-
87- extern __attribute__((__visibility__ ("hidden" ))) unsigned __default_guardsize ;
88-
89- // Modified version of pthread_getattr_np from the upstream PR.
90-
91- int pthread_getattr_np (pthread_t thread , pthread_attr_t * attr ) {
92- attr -> _a_stackaddr = (void * )emscripten_stack_get_base ();
93- attr -> _a_stacksize = emscripten_stack_get_base () - emscripten_stack_get_end ();
94- attr -> _a_guardsize = __default_guardsize ;
95- return 0 ;
96- }
97-
98- // These three functions copied without any changes from Emscripten libc.
99-
100- int pthread_attr_getguardsize (const pthread_attr_t * restrict a , size_t * restrict size )
101- {
102- * size = a -> _a_guardsize ;
103- return 0 ;
104- }
105-
106- int pthread_attr_getstack (const pthread_attr_t * restrict a , void * * restrict addr , size_t * restrict size )
107- {
108- /// XXX musl is not standard-conforming? It should not report EINVAL if _a_stackaddr is zero, and it should
109- /// report EINVAL if a is null: http://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_attr_getstack.html
110- if (!a ) return EINVAL ;
111- // if (!a->_a_stackaddr)
112- // return EINVAL;
113-
114- * size = a -> _a_stacksize ;
115- * addr = (void * )(a -> _a_stackaddr - * size );
116- return 0 ;
117- }
118-
119- int pthread_attr_destroy (pthread_attr_t * a )
120- {
121- return 0 ;
122- }
123-
124- #endif
125-
12668static void
12769hardware_stack_limits (uintptr_t * base , uintptr_t * top , uintptr_t sp )
12870{
0 commit comments