Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ _Py_ReachedRecursionLimitWithMargin(PyThreadState *tstate, int margin_count)
#include "emscripten/stack.h"

#define pthread_attr_t workaround_pthread_attr_t
#define pthread_attr_init workaround_pthread_attr_init
#define pthread_getattr_np workaround_pthread_getattr_np
#define pthread_attr_getguardsize workaround_pthread_attr_getguardsize
#define pthread_attr_getstack workaround_pthread_attr_getstack
Expand All @@ -91,6 +92,11 @@ typedef struct {

extern __attribute__((__visibility__("hidden"))) unsigned __default_guardsize;

int pthread_attr_init(pthread_attr_t *a)
{
return 0;
}

// Modified version of pthread_getattr_np from the upstream PR.

int pthread_getattr_np(pthread_t thread, pthread_attr_t *attr) {
Expand Down Expand Up @@ -158,11 +164,12 @@ hardware_stack_limits(uintptr_t *base, uintptr_t *top, uintptr_t sp)
size_t stack_size, guard_size;
void *stack_addr;
pthread_attr_t attr;
#ifdef _Py_HAVE_PTHREAD_ATTR_GET_NP

int err = pthread_attr_init(&attr);
#ifdef _Py_HAVE_PTHREAD_ATTR_GET_NP
err |= pthread_attr_get_np(pthread_self(), &attr);
#else
int err = pthread_getattr_np(pthread_self(), &attr);
err |= pthread_getattr_np(pthread_self(), &attr);
#endif
if (err == 0) {
err = pthread_attr_getguardsize(&attr, &guard_size);
Expand All @@ -175,6 +182,7 @@ hardware_stack_limits(uintptr_t *base, uintptr_t *top, uintptr_t sp)
return;
}
# endif

// Add some space for caller function then round to minimum page size
// This is a guess at the top of the stack, but should be a reasonably
// good guess if called from _PyThreadState_Attach when creating a thread.
Expand Down
Loading