Source changes for compilation

These are the commits from
https://github.com/ahgamut/cpython/tree/cosmo_py36 squashed for
simplicity.

Also included is the pyconfig.h used for compilation. The pyconfig.h has
to be changed manually in case Cosmopolitan gets new features.
This commit is contained in:
ahgamut 2021-08-08 19:22:49 +05:30 committed by Justine Tunney
parent 0c4c56ff39
commit 5ef64dbcdb
82 changed files with 2009 additions and 424 deletions

View file

@ -14,6 +14,7 @@
# include <sys/resource.h>
#endif
#include <assert.h>
/* Allocate at maximum 100 MB of the stack to raise the stack overflow */
#define STACK_OVERFLOW_MAX_SIZE (100*1024*1024)
@ -109,22 +110,30 @@ static void faulthandler_user(int signum);
#endif /* FAULTHANDLER_USER */
static fault_handler_t faulthandler_handlers[] = {
#ifdef SIGBUS
{SIGBUS, 0, "Bus error", },
#endif
#ifdef SIGILL
{SIGILL, 0, "Illegal instruction", },
#endif
{SIGFPE, 0, "Floating point exception", },
{SIGABRT, 0, "Aborted", },
/* define SIGSEGV at the end to make it the default choice if searching the
handler fails in faulthandler_fatal_error() */
{SIGSEGV, 0, "Segmentation fault", }
};
static fault_handler_t faulthandler_handlers[5];
static const size_t faulthandler_nsignals = \
Py_ARRAY_LENGTH(faulthandler_handlers);
static void faulthandler_handlers_init()
{
fault_handler_t local_handlers[] = {
#ifdef SIGBUS
{SIGBUS, 0, "Bus error", },
#endif
#ifdef SIGILL
{SIGILL, 0, "Illegal instruction", },
#endif
{SIGFPE, 0, "Floating point exception", },
{SIGABRT, 0, "Aborted", },
/* define SIGSEGV at the end to make it the default choice if searching the
handler fails in faulthandler_fatal_error() */
{SIGSEGV, 0, "Segmentation fault", }
};
_Static_assert(sizeof(faulthandler_handlers) == sizeof(local_handlers), "handler alloc error");
memcpy(faulthandler_handlers, local_handlers, sizeof(local_handlers));
}
#ifdef HAVE_SIGALTSTACK
static stack_t stack;
static stack_t old_stack;
@ -1355,6 +1364,7 @@ int _PyFaulthandler_Init(void)
PyThread_acquire_lock(thread.cancel_event, 1);
#endif
faulthandler_handlers_init();
return faulthandler_env_options();
}