mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
quick addition of cosmo pthreads to python.com
- enable WITH_THREAD and _POSIX_THREADS - add headers everywhere - breaks only two tests (faulthandler and signal) - disabled terminal completion because it causes segfaults for some reason (probably could not get the current thread)
This commit is contained in:
parent
a808b3e738
commit
60eb34509b
16 changed files with 166 additions and 34 deletions
1
third_party/python/Python/ceval.c
vendored
1
third_party/python/Python/ceval.c
vendored
|
@ -5,6 +5,7 @@
|
|||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#define PY_LOCAL_AGGRESSIVE
|
||||
#include "libc/errno.h"
|
||||
#include "libc/intrin/likely.h"
|
||||
#include "third_party/python/Include/abstract.h"
|
||||
#include "third_party/python/Include/boolobject.h"
|
||||
|
|
4
third_party/python/Python/ceval_gil.inc
vendored
4
third_party/python/Python/ceval_gil.inc
vendored
|
@ -4,6 +4,10 @@
|
|||
│ Python 3 │
|
||||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/thread/thread2.h"
|
||||
#include "third_party/python/Include/pylifecycle.h"
|
||||
#include "third_party/python/Python/condvar.h"
|
||||
/* clang-format off */
|
||||
|
||||
|
|
6
third_party/python/Python/finalize.c
vendored
6
third_party/python/Python/finalize.c
vendored
|
@ -32,6 +32,12 @@
|
|||
Locking: as above.
|
||||
*/
|
||||
|
||||
#ifdef WITH_THREAD
|
||||
extern void wait_for_thread_shutdown(void);
|
||||
extern void _PyGILState_Init(PyInterpreterState *, PyThreadState *);
|
||||
extern void _PyGILState_Fini(void);
|
||||
#endif /* WITH_THREAD */
|
||||
|
||||
int
|
||||
Py_FinalizeEx(void)
|
||||
{
|
||||
|
|
5
third_party/python/Python/pylifecycle.c
vendored
5
third_party/python/Python/pylifecycle.c
vendored
|
@ -19,6 +19,7 @@
|
|||
#include "third_party/python/Include/abstract.h"
|
||||
#include "third_party/python/Include/ast.h"
|
||||
#include "third_party/python/Include/boolobject.h"
|
||||
#include "third_party/python/Include/ceval.h"
|
||||
#include "third_party/python/Include/code.h"
|
||||
#include "third_party/python/Include/codecs.h"
|
||||
#include "third_party/python/Include/cosmo.h"
|
||||
|
@ -58,7 +59,7 @@ _Py_IDENTIFIER(stdout);
|
|||
_Py_IDENTIFIER(stderr);
|
||||
|
||||
/* Forward */
|
||||
static void wait_for_thread_shutdown(void);
|
||||
void wait_for_thread_shutdown(void);
|
||||
#ifdef WITH_THREAD
|
||||
extern void _PyGILState_Init(PyInterpreterState *, PyThreadState *);
|
||||
extern void _PyGILState_Fini(void);
|
||||
|
@ -470,7 +471,7 @@ Py_EndInterpreter(PyThreadState *tstate)
|
|||
the threading module was imported in the first place.
|
||||
The shutdown routine will wait until all non-daemon
|
||||
"threading" threads have completed. */
|
||||
static void
|
||||
void
|
||||
wait_for_thread_shutdown(void)
|
||||
{
|
||||
#ifdef WITH_THREAD
|
||||
|
|
11
third_party/python/Python/thread.c
vendored
11
third_party/python/Python/thread.c
vendored
|
@ -5,6 +5,11 @@
|
|||
│ https://docs.python.org/3/license.html │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/thread/thread2.h"
|
||||
#include "third_party/python/Include/dynamic_annotations.h"
|
||||
#include "third_party/python/Include/pyerrors.h"
|
||||
#include "third_party/python/Include/pymacro.h"
|
||||
#include "third_party/python/Include/pymem.h"
|
||||
|
@ -77,18 +82,18 @@ static size_t _pythread_stacksize = 0;
|
|||
|
||||
#ifdef _POSIX_THREADS
|
||||
#define PYTHREAD_NAME "pthread"
|
||||
#include "thread_pthread.inc"
|
||||
#include "third_party/python/Python/thread_pthread.inc"
|
||||
#endif
|
||||
|
||||
#ifdef NT_THREADS
|
||||
#define PYTHREAD_NAME "nt"
|
||||
#include "thread_nt.inc"
|
||||
// #include "thread_nt.inc"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
#ifdef FOOBAR_THREADS
|
||||
#include "thread_foobar.inc"
|
||||
// #include "thread_foobar.inc"
|
||||
#endif
|
||||
*/
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue