mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-01 03:53:33 +00:00
b420ed8248
This change gets the Python codebase into a state where it conforms to the conventions of this codebase. It's now possible to include headers from Python, without worrying about ordering. Python has traditionally solved that problem by "diamonding" everything in Python.h, but that's problematic since it means any change to any Python header invalidates all the build artifacts. Lastly it makes tooling not work. Since it is hard to explain to Emacs when I press C-c C-h to add an import line it shouldn't add the header that actually defines the symbol, and instead do follow the nonstandard Python convention. Progress has been made on letting Python load source code from the zip executable structure via the standard C library APIs. System calss now recognizes zip!FILENAME alternative URIs as equivalent to zip:FILENAME since Python uses colon as its delimiter. Some progress has been made on embedding the notice license terms into the Python object code. This is easier said than done since Python has an extremely complicated ownership story. - Some termios APIs have been added - Implement rewinddir() dirstream API - GetCpuCount() API added to Cosmopolitan Libc - More bugs in Cosmopolitan Libc have been fixed - zipobj.com now has flags for mangling the path - Fixed bug a priori with sendfile() on certain BSDs - Polyfill F_DUPFD and F_DUPFD_CLOEXEC across platforms - FIOCLEX / FIONCLEX now polyfilled for fast O_CLOEXEC changes - APE now supports a hybrid solution to no-self-modify for builds - Many BSD-only magnums added, e.g. O_SEARCH, O_SHLOCK, SF_NODISKIO
135 lines
2.3 KiB
C
135 lines
2.3 KiB
C
#include "libc/calls/calls.h"
|
|
/* clang-format off */
|
|
|
|
/*
|
|
* Initialization.
|
|
*/
|
|
static void
|
|
PyThread__init_thread(void)
|
|
{
|
|
}
|
|
|
|
/*
|
|
* Thread support.
|
|
*/
|
|
long
|
|
PyThread_start_new_thread(void (*func)(void *), void *arg)
|
|
{
|
|
int success = 0; /* init not needed when SOLARIS_THREADS and */
|
|
/* C_THREADS implemented properly */
|
|
|
|
dprintf(("PyThread_start_new_thread called\n"));
|
|
if (!initialized)
|
|
PyThread_init_thread();
|
|
return success < 0 ? -1 : 0;
|
|
}
|
|
|
|
long
|
|
PyThread_get_thread_ident(void)
|
|
{
|
|
if (!initialized)
|
|
PyThread_init_thread();
|
|
}
|
|
|
|
void
|
|
PyThread_exit_thread(void)
|
|
{
|
|
dprintf(("PyThread_exit_thread called\n"));
|
|
if (!initialized)
|
|
exit(0);
|
|
}
|
|
|
|
/*
|
|
* Lock support.
|
|
*/
|
|
PyThread_type_lock
|
|
PyThread_allocate_lock(void)
|
|
{
|
|
|
|
dprintf(("PyThread_allocate_lock called\n"));
|
|
if (!initialized)
|
|
PyThread_init_thread();
|
|
|
|
dprintf(("PyThread_allocate_lock() -> %p\n", lock));
|
|
return (PyThread_type_lock) lock;
|
|
}
|
|
|
|
void
|
|
PyThread_free_lock(PyThread_type_lock lock)
|
|
{
|
|
dprintf(("PyThread_free_lock(%p) called\n", lock));
|
|
}
|
|
|
|
int
|
|
PyThread_acquire_lock(PyThread_type_lock lock, int waitflag)
|
|
{
|
|
return PyThread_acquire_lock_timed(lock, waitflag ? -1 : 0, 0);
|
|
}
|
|
|
|
PyLockStatus
|
|
PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds,
|
|
int intr_flag)
|
|
{
|
|
int success;
|
|
|
|
dprintf(("PyThread_acquire_lock_timed(%p, %lld, %d) called\n", lock, microseconds, intr_flag));
|
|
dprintf(("PyThread_acquire_lock_timed(%p, %lld, %d) -> %d\n",
|
|
lock, microseconds, intr_flag, success));
|
|
return success;
|
|
}
|
|
|
|
void
|
|
PyThread_release_lock(PyThread_type_lock lock)
|
|
{
|
|
dprintf(("PyThread_release_lock(%p) called\n", lock));
|
|
}
|
|
|
|
/* The following are only needed if native TLS support exists */
|
|
#define Py_HAVE_NATIVE_TLS
|
|
|
|
#ifdef Py_HAVE_NATIVE_TLS
|
|
int
|
|
PyThread_create_key(void)
|
|
{
|
|
int result;
|
|
return result;
|
|
}
|
|
|
|
void
|
|
PyThread_delete_key(int key)
|
|
{
|
|
|
|
}
|
|
|
|
int
|
|
PyThread_set_key_value(int key, void *value)
|
|
{
|
|
int ok;
|
|
|
|
/* A failure in this case returns -1 */
|
|
if (!ok)
|
|
return -1;
|
|
return 0;
|
|
}
|
|
|
|
void *
|
|
PyThread_get_key_value(int key)
|
|
{
|
|
void *result;
|
|
|
|
return result;
|
|
}
|
|
|
|
void
|
|
PyThread_delete_key_value(int key)
|
|
{
|
|
|
|
}
|
|
|
|
void
|
|
PyThread_ReInitTLS(void)
|
|
{
|
|
|
|
}
|
|
|
|
#endif
|