mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-23 05:42:29 +00:00
Perform build and magnum tuning
Building o//third_party/python now takes 5 seconds on my PC This change works towards modifying Python to use runtime dispatching when appropriate. For example, when loading the magnums in the socket module, it's a good idea to check if the magnum is zero, because that means the local system platform doesn't support it.
This commit is contained in:
parent
ee7e296339
commit
d26d7ae0e4
1028 changed files with 6576 additions and 172777 deletions
7
third_party/python/Python/Python-ast.c
generated
vendored
7
third_party/python/Python/Python-ast.c
generated
vendored
|
@ -1,9 +1,8 @@
|
|||
/* clang-format off */
|
||||
/* File automatically generated by Parser/asdl_c.py. */
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#include "Python.h"
|
||||
#include "Python-ast.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/Python-ast.h"
|
||||
|
||||
static PyTypeObject AST_type;
|
||||
static PyTypeObject *mod_type;
|
||||
|
|
1
third_party/python/Python/README
vendored
1
third_party/python/Python/README
vendored
|
@ -1 +0,0 @@
|
|||
Miscellaneous source files for the main Python shared library
|
5
third_party/python/Python/_warnings.c
vendored
5
third_party/python/Python/_warnings.c
vendored
|
@ -1,5 +1,6 @@
|
|||
#include "Python.h"
|
||||
#include "frameobject.h"
|
||||
/* clang-format off */
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/frameobject.h"
|
||||
|
||||
#define MODULE_NAME "_warnings"
|
||||
|
||||
|
|
6
third_party/python/Python/asdl.c
vendored
6
third_party/python/Python/asdl.c
vendored
|
@ -1,5 +1,7 @@
|
|||
#include "Python.h"
|
||||
#include "asdl.h"
|
||||
/* clang-format off */
|
||||
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/asdl.h"
|
||||
|
||||
asdl_seq *
|
||||
_Py_asdl_seq_new(Py_ssize_t size, PyArena *arena)
|
||||
|
|
31
third_party/python/Python/ast.c
vendored
31
third_party/python/Python/ast.c
vendored
|
@ -1,16 +1,14 @@
|
|||
/*
|
||||
* This file includes functions to transform a concrete syntax tree (CST) to
|
||||
* an abstract syntax tree (AST). The main function is PyAST_FromNode().
|
||||
*
|
||||
*/
|
||||
#include "Python.h"
|
||||
#include "Python-ast.h"
|
||||
#include "node.h"
|
||||
#include "ast.h"
|
||||
#include "token.h"
|
||||
#include "pythonrun.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include "libc/assert.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
#include "third_party/python/Include/pyport.h"
|
||||
#include "third_party/python/Include/pythonrun.h"
|
||||
#include "third_party/python/Include/token.h"
|
||||
/**/
|
||||
#include "third_party/python/Include/Python-ast.h"
|
||||
/**/
|
||||
#include "third_party/python/Include/ast.h"
|
||||
/* clang-format off */
|
||||
|
||||
static int validate_stmts(asdl_seq *);
|
||||
static int validate_exprs(asdl_seq *, expr_context_ty, int);
|
||||
|
@ -580,9 +578,10 @@ PyAST_Validate(mod_ty mod)
|
|||
}
|
||||
|
||||
/* This is done here, so defines like "test" don't interfere with AST use above. */
|
||||
#include "grammar.h"
|
||||
#include "parsetok.h"
|
||||
#include "graminit.h"
|
||||
/* WHAT */
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
#include "third_party/python/Include/parsetok.h"
|
||||
#include "third_party/python/Include/graminit.h"
|
||||
|
||||
/* Data structure used internally */
|
||||
struct compiling {
|
||||
|
|
24
third_party/python/Python/bltinmodule.c
vendored
24
third_party/python/Python/bltinmodule.c
vendored
|
@ -1,19 +1,13 @@
|
|||
/* clang-format off */
|
||||
|
||||
/* Built-in functions */
|
||||
|
||||
#include "Python.h"
|
||||
#include "Python-ast.h"
|
||||
|
||||
#include "node.h"
|
||||
#include "code.h"
|
||||
|
||||
#include "asdl.h"
|
||||
#include "ast.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef HAVE_LANGINFO_H
|
||||
#include <langinfo.h> /* CODESET */
|
||||
#endif
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/Python-ast.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
#include "third_party/python/Include/code.h"
|
||||
#include "third_party/python/Include/asdl.h"
|
||||
#include "third_party/python/Include/ast.h"
|
||||
|
||||
/* The default encoding used by the platform file system APIs
|
||||
Can remain NULL for all platforms that don't have such a concept
|
||||
|
@ -48,7 +42,7 @@ _Py_IDENTIFIER(stdin);
|
|||
_Py_IDENTIFIER(stdout);
|
||||
_Py_IDENTIFIER(stderr);
|
||||
|
||||
#include "clinic/bltinmodule.c.h"
|
||||
#include "third_party/python/Python/clinic/bltinmodule.inc"
|
||||
|
||||
/* AC: cannot convert yet, waiting for *args support */
|
||||
static PyObject *
|
||||
|
|
27
third_party/python/Python/ceval.c
vendored
27
third_party/python/Python/ceval.c
vendored
|
@ -1,3 +1,4 @@
|
|||
/* clang-format off */
|
||||
|
||||
/* Execute compiled code */
|
||||
|
||||
|
@ -9,17 +10,14 @@
|
|||
/* enable more aggressive intra-module optimizations, where available */
|
||||
#define PY_LOCAL_AGGRESSIVE
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
#include "code.h"
|
||||
#include "dictobject.h"
|
||||
#include "frameobject.h"
|
||||
#include "opcode.h"
|
||||
#include "pydtrace.h"
|
||||
#include "setobject.h"
|
||||
#include "structmember.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/code.h"
|
||||
#include "third_party/python/Include/dictobject.h"
|
||||
#include "third_party/python/Include/frameobject.h"
|
||||
#include "third_party/python/Include/opcode.h"
|
||||
#include "third_party/python/Include/pydtrace.h"
|
||||
#include "third_party/python/Include/setobject.h"
|
||||
#include "third_party/python/Include/structmember.h"
|
||||
|
||||
/* Turn this on if your compiler chokes on the big switch: */
|
||||
/* #define CASE_TOO_BIG 1 */
|
||||
|
@ -210,16 +208,15 @@ static int pending_async_exc = 0;
|
|||
#ifdef WITH_THREAD
|
||||
|
||||
#ifdef HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#include "pythread.h"
|
||||
#include "third_party/python/Include/pythread.h"
|
||||
|
||||
static PyThread_type_lock pending_lock = 0; /* for pending calls */
|
||||
static long main_thread = 0;
|
||||
/* Request for dropping the GIL */
|
||||
static _Py_atomic_int gil_drop_request = {0};
|
||||
|
||||
#include "ceval_gil.h"
|
||||
#include "third_party/python/Include/ceval_gil.inc"
|
||||
|
||||
int
|
||||
PyEval_ThreadsInitialized(void)
|
||||
|
@ -845,7 +842,7 @@ _PyEval_EvalFrameDefault(PyFrameObject *f, int throwflag)
|
|||
|
||||
#if USE_COMPUTED_GOTOS
|
||||
/* Import the static jump table */
|
||||
#include "opcode_targets.h"
|
||||
#include "third_party/python/Python/opcode_targets.inc"
|
||||
|
||||
#define TARGET(op) \
|
||||
TARGET_##op: \
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
#include "third_party/python/Include/condvar.h"
|
||||
/* clang-format off */
|
||||
|
||||
/*
|
||||
* Implementation of the Global Interpreter Lock (GIL).
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
|
||||
|
||||
/* First some general settings */
|
||||
|
||||
/* microseconds (the Python API uses seconds, though) */
|
||||
|
@ -59,7 +58,6 @@ static unsigned long gil_interval = DEFAULT_INTERVAL;
|
|||
(Note: this mechanism is enabled with FORCE_SWITCHING above)
|
||||
*/
|
||||
|
||||
#include "condvar.h"
|
||||
#ifndef Py_HAVE_CONDVAR
|
||||
#error You need either a POSIX-compatible or a Windows system!
|
||||
#endif
|
7
third_party/python/Python/codecs.c
vendored
7
third_party/python/Python/codecs.c
vendored
|
@ -1,3 +1,5 @@
|
|||
/* clang-format off */
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
|
||||
Python Codec Registry and support functions
|
||||
|
@ -8,9 +10,8 @@ Copyright (c) Corporation for National Research Initiatives.
|
|||
|
||||
------------------------------------------------------------------------ */
|
||||
|
||||
#include "Python.h"
|
||||
#include "ucnhash.h"
|
||||
#include <ctype.h>
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/ucnhash.h"
|
||||
|
||||
const char *Py_hexdigits = "0123456789abcdef";
|
||||
|
||||
|
|
18
third_party/python/Python/compile.c
vendored
18
third_party/python/Python/compile.c
vendored
|
@ -1,3 +1,5 @@
|
|||
/* clang-format off */
|
||||
|
||||
/*
|
||||
* This file compiles an abstract syntax tree (AST) into Python bytecode.
|
||||
*
|
||||
|
@ -21,15 +23,15 @@
|
|||
* objects.
|
||||
*/
|
||||
|
||||
#include "Python.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
|
||||
#include "Python-ast.h"
|
||||
#include "node.h"
|
||||
#include "ast.h"
|
||||
#include "code.h"
|
||||
#include "symtable.h"
|
||||
#include "opcode.h"
|
||||
#include "wordcode_helpers.h"
|
||||
#include "third_party/python/Include/Python-ast.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
#include "third_party/python/Include/ast.h"
|
||||
#include "third_party/python/Include/code.h"
|
||||
#include "third_party/python/Include/symtable.h"
|
||||
#include "third_party/python/Include/opcode.h"
|
||||
#include "third_party/python/Python/wordcode_helpers.h"
|
||||
|
||||
#define DEFAULT_BLOCK_SIZE 16
|
||||
#define DEFAULT_BLOCKS 8
|
||||
|
|
25
third_party/python/Python/condvar.h
vendored
25
third_party/python/Python/condvar.h
vendored
|
@ -1,3 +1,8 @@
|
|||
#ifndef _CONDVAR_H_
|
||||
#define _CONDVAR_H_
|
||||
#include "third_party/python/Include/Python.h"
|
||||
/* clang-format off */
|
||||
|
||||
/*
|
||||
* Portable condition variable support for windows and pthreads.
|
||||
* Everything is inline, this header can be included where needed.
|
||||
|
@ -37,28 +42,12 @@
|
|||
* Condition Variable.
|
||||
*/
|
||||
|
||||
#ifndef _CONDVAR_H_
|
||||
#define _CONDVAR_H_
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
#ifndef _POSIX_THREADS
|
||||
/* This means pthreads are not implemented in libc headers, hence the macro
|
||||
not present in unistd.h. But they still can be implemented as an external
|
||||
library (e.g. gnu pth in pthread emulation) */
|
||||
# ifdef HAVE_PTHREAD_H
|
||||
# include <pthread.h> /* _POSIX_THREADS */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef _POSIX_THREADS
|
||||
/*
|
||||
* POSIX support
|
||||
*/
|
||||
#define Py_HAVE_CONDVAR
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#define PyCOND_ADD_MICROSECONDS(tv, interval) \
|
||||
do { /* TODO: add overflow and truncation checks */ \
|
||||
tv.tv_usec += (long) interval; \
|
||||
|
@ -121,7 +110,6 @@ PyCOND_TIMEDWAIT(PyCOND_T *cond, PyMUTEX_T *mut, long long us)
|
|||
|
||||
/* include windows if it hasn't been done before */
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
/* options */
|
||||
/* non-emulated condition variables are provided for those that want
|
||||
|
@ -382,9 +370,6 @@ PyCOND_BROADCAST(PyCOND_T *cv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif /* _PY_EMULATED_WIN_CV */
|
||||
|
||||
#endif /* _POSIX_THREADS, NT_THREADS */
|
||||
|
||||
#endif /* _CONDVAR_H_ */
|
||||
|
|
85
third_party/python/Python/dtoa.c
vendored
85
third_party/python/Python/dtoa.c
vendored
|
@ -1,3 +1,5 @@
|
|||
/* clang-format off */
|
||||
|
||||
/****************************************************************
|
||||
*
|
||||
* The author of this software is David M. Gay.
|
||||
|
@ -114,14 +116,13 @@
|
|||
|
||||
/* Linking of Python's #defines to Gay's #defines starts here. */
|
||||
|
||||
#include "Python.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "libc/math.h"
|
||||
|
||||
/* if PY_NO_SHORT_FLOAT_REPR is defined, then don't even try to compile
|
||||
the following code */
|
||||
#ifndef PY_NO_SHORT_FLOAT_REPR
|
||||
|
||||
#include "float.h"
|
||||
|
||||
#define MALLOC PyMem_Malloc
|
||||
#define FREE PyMem_Free
|
||||
|
||||
|
@ -172,10 +173,6 @@ typedef uint64_t ULLong;
|
|||
#define PRIVATE_mem ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double))
|
||||
static double private_mem[PRIVATE_mem], *pmem_next = private_mem;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef union { double d; ULong L[2]; } U;
|
||||
|
||||
#ifdef IEEE_8087
|
||||
|
@ -520,79 +517,26 @@ s2b(const char *s, int nd0, int nd, ULong y9)
|
|||
|
||||
/* count leading 0 bits in the 32-bit integer x. */
|
||||
|
||||
static int
|
||||
static inline int
|
||||
hi0bits(ULong x)
|
||||
{
|
||||
int k = 0;
|
||||
|
||||
if (!(x & 0xffff0000)) {
|
||||
k = 16;
|
||||
x <<= 16;
|
||||
}
|
||||
if (!(x & 0xff000000)) {
|
||||
k += 8;
|
||||
x <<= 8;
|
||||
}
|
||||
if (!(x & 0xf0000000)) {
|
||||
k += 4;
|
||||
x <<= 4;
|
||||
}
|
||||
if (!(x & 0xc0000000)) {
|
||||
k += 2;
|
||||
x <<= 2;
|
||||
}
|
||||
if (!(x & 0x80000000)) {
|
||||
k++;
|
||||
if (!(x & 0x40000000))
|
||||
return 32;
|
||||
}
|
||||
return k;
|
||||
return x ? __builtin_clz(x) : 32;
|
||||
}
|
||||
|
||||
/* count trailing 0 bits in the 32-bit integer y, and shift y right by that
|
||||
number of bits. */
|
||||
|
||||
static int
|
||||
static inline int
|
||||
lo0bits(ULong *y)
|
||||
{
|
||||
int k;
|
||||
ULong x = *y;
|
||||
|
||||
if (x & 7) {
|
||||
if (x & 1)
|
||||
return 0;
|
||||
if (x & 2) {
|
||||
*y = x >> 1;
|
||||
return 1;
|
||||
}
|
||||
*y = x >> 2;
|
||||
return 2;
|
||||
if (*y) {
|
||||
k = __builtin_ctz(*y);
|
||||
*y >>= k;
|
||||
return k;
|
||||
} else {
|
||||
return 32;
|
||||
}
|
||||
k = 0;
|
||||
if (!(x & 0xffff)) {
|
||||
k = 16;
|
||||
x >>= 16;
|
||||
}
|
||||
if (!(x & 0xff)) {
|
||||
k += 8;
|
||||
x >>= 8;
|
||||
}
|
||||
if (!(x & 0xf)) {
|
||||
k += 4;
|
||||
x >>= 4;
|
||||
}
|
||||
if (!(x & 0x3)) {
|
||||
k += 2;
|
||||
x >>= 2;
|
||||
}
|
||||
if (!(x & 1)) {
|
||||
k++;
|
||||
x >>= 1;
|
||||
if (!x)
|
||||
return 32;
|
||||
}
|
||||
*y = x;
|
||||
return k;
|
||||
}
|
||||
|
||||
/* convert a small nonnegative integer to a Bigint */
|
||||
|
@ -2869,8 +2813,5 @@ _Py_dg_dtoa(double dd, int mode, int ndigits,
|
|||
_Py_dg_freedtoa(s0);
|
||||
return NULL;
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PY_NO_SHORT_FLOAT_REPR */
|
||||
|
|
31
third_party/python/Python/dup2.c
vendored
31
third_party/python/Python/dup2.c
vendored
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
* Public domain dup2() lookalike
|
||||
* by Curtis Jackson @ AT&T Technologies, Burlington, NC
|
||||
* electronic address: burl!rcj
|
||||
*
|
||||
* dup2 performs the following functions:
|
||||
*
|
||||
* Check to make sure that fd1 is a valid open file descriptor.
|
||||
* Check to see if fd2 is already open; if so, close it.
|
||||
* Duplicate fd1 onto fd2; checking to make sure fd2 is a valid fd.
|
||||
* Return fd2 if all went well; return BADEXIT otherwise.
|
||||
*/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define BADEXIT -1
|
||||
|
||||
int
|
||||
dup2(int fd1, int fd2)
|
||||
{
|
||||
if (fd1 != fd2) {
|
||||
if (fcntl(fd1, F_GETFL) < 0)
|
||||
return BADEXIT;
|
||||
if (fcntl(fd2, F_GETFL) >= 0)
|
||||
close(fd2);
|
||||
if (fcntl(fd1, F_DUPFD, fd2) < 0)
|
||||
return BADEXIT;
|
||||
}
|
||||
return fd2;
|
||||
}
|
16
third_party/python/Python/dynamic_annotations.c
vendored
16
third_party/python/Python/dynamic_annotations.c
vendored
|
@ -1,3 +1,6 @@
|
|||
#include "third_party/python/Include/dynamic_annotations.h"
|
||||
/* clang-format off */
|
||||
|
||||
/* Copyright (c) 2008-2009, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
|
@ -27,19 +30,6 @@
|
|||
* Author: Kostya Serebryany
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
# error "This file should be built as pure C to avoid name mangling"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "dynamic_annotations.h"
|
||||
|
||||
/* Each function is empty and called (via a macro) only in debug mode.
|
||||
The arguments are captured by dynamic tools at runtime. */
|
||||
|
||||
|
|
7
third_party/python/Python/dynload_dl.c
vendored
7
third_party/python/Python/dynload_dl.c
vendored
|
@ -1,10 +1,9 @@
|
|||
/* clang-format off */
|
||||
|
||||
/* Support for dynamic loading of extension modules */
|
||||
|
||||
#include "dl.h"
|
||||
|
||||
#include "Python.h"
|
||||
#include "importdl.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/importdl.h"
|
||||
|
||||
|
||||
extern char *Py_GetProgramName(void);
|
||||
|
|
23
third_party/python/Python/dynload_shlib.c
vendored
23
third_party/python/Python/dynload_shlib.c
vendored
|
@ -1,24 +1,7 @@
|
|||
|
||||
/* Support for dynamic loading of extension modules */
|
||||
|
||||
#include "Python.h"
|
||||
#include "importdl.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if defined(__NetBSD__)
|
||||
#include <sys/param.h>
|
||||
#if (NetBSD < 199712)
|
||||
#include <nlist.h>
|
||||
#include <link.h>
|
||||
#define dlerror() "error in dynamic linking"
|
||||
#endif
|
||||
#endif /* NetBSD */
|
||||
|
||||
#ifdef HAVE_DLFCN_H
|
||||
#include "libc/runtime/dlfcn.h"
|
||||
#endif
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Python/importdl.h"
|
||||
/* clang-format off */
|
||||
|
||||
#if (defined(__OpenBSD__) || defined(__NetBSD__)) && !defined(__ELF__)
|
||||
#define LEAD_UNDERSCORE "_"
|
||||
|
|
7
third_party/python/Python/dynload_stub.c
vendored
7
third_party/python/Python/dynload_stub.c
vendored
|
@ -1,9 +1,8 @@
|
|||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/importdl.h"
|
||||
/* clang-format off */
|
||||
|
||||
/* This module provides the necessary stubs for when dynamic loading is
|
||||
not present. */
|
||||
|
||||
#include "Python.h"
|
||||
#include "importdl.h"
|
||||
|
||||
|
||||
const char *_PyImport_DynLoadFiletab[] = {NULL};
|
||||
|
|
17
third_party/python/Python/dynload_win.c
vendored
17
third_party/python/Python/dynload_win.c
vendored
|
@ -1,16 +1,7 @@
|
|||
|
||||
/* Support for dynamic loading of extension modules */
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
#ifdef HAVE_DIRECT_H
|
||||
#include <direct.h>
|
||||
#endif
|
||||
#include <ctype.h>
|
||||
|
||||
#include "importdl.h"
|
||||
#include "patchlevel.h"
|
||||
#include <windows.h>
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/importdl.h"
|
||||
#include "third_party/python/Include/patchlevel.h"
|
||||
/* clang-format off */
|
||||
|
||||
// "activation context" magic - see dl_nt.c...
|
||||
#if HAVE_SXS
|
||||
|
|
19
third_party/python/Python/errors.c
vendored
19
third_party/python/Python/errors.c
vendored
|
@ -1,20 +1,5 @@
|
|||
|
||||
/* Error handling */
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
#ifndef __STDC__
|
||||
#ifndef MS_WINDOWS
|
||||
extern char *strerror(int);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
#include <windows.h>
|
||||
#include <winbase.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include "third_party/python/Include/Python.h"
|
||||
/* clang-format off */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
25
third_party/python/Python/fileutils.c
vendored
25
third_party/python/Python/fileutils.c
vendored
|
@ -1,25 +1,10 @@
|
|||
#include "Python.h"
|
||||
#include "osdefs.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
# include <malloc.h>
|
||||
# include <windows.h>
|
||||
extern int winerror_to_errno(int);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LANGINFO_H
|
||||
#include <langinfo.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_SYS_IOCTL_H
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/sysv/consts/f.h"
|
||||
#include "libc/sysv/consts/fd.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif /* HAVE_FCNTL_H */
|
||||
#include "libc/unicode/locale.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/osdefs.h"
|
||||
/* clang-format off */
|
||||
|
||||
#if defined(__APPLE__) || defined(__ANDROID__)
|
||||
extern wchar_t* _Py_DecodeUTF8_surrogateescape(const char *s, Py_ssize_t size);
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
/* clang-format off */
|
||||
|
||||
/* implements the unicode (as opposed to string) version of the
|
||||
built-in formatters for string, int, float. that is, the versions
|
||||
of int.__float__, etc., that take and return unicode objects */
|
||||
|
||||
#include "Python.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
/* Raises an exception about an unknown presentation type for this
|
||||
|
|
8
third_party/python/Python/frozen.c
vendored
8
third_party/python/Python/frozen.c
vendored
|
@ -1,9 +1,9 @@
|
|||
|
||||
/* clang-format off */
|
||||
/* Dummy frozen modules initializer */
|
||||
|
||||
#include "Python.h"
|
||||
#include "importlib.h"
|
||||
#include "importlib_external.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Python/importlib.inc"
|
||||
#include "third_party/python/Python/importlib_external.inc"
|
||||
|
||||
/* In order to test the support for frozen modules, by default we
|
||||
define a single frozen module, __hello__. Loading it will print
|
||||
|
|
4
third_party/python/Python/frozenmain.c
vendored
4
third_party/python/Python/frozenmain.c
vendored
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* clang-format off */
|
||||
/* Python interpreter main program for frozen scripts */
|
||||
|
||||
#include "Python.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
|
|
16
third_party/python/Python/future.c
vendored
16
third_party/python/Python/future.c
vendored
|
@ -1,10 +1,12 @@
|
|||
#include "Python.h"
|
||||
#include "Python-ast.h"
|
||||
#include "node.h"
|
||||
#include "token.h"
|
||||
#include "graminit.h"
|
||||
#include "code.h"
|
||||
#include "symtable.h"
|
||||
/* clang-format off */
|
||||
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/Python-ast.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
#include "third_party/python/Include/token.h"
|
||||
#include "third_party/python/Include/graminit.h"
|
||||
#include "third_party/python/Include/code.h"
|
||||
#include "third_party/python/Include/symtable.h"
|
||||
|
||||
#define UNDEFINED_FUTURE_FEATURE "future feature %.100s is not defined"
|
||||
#define ERR_LATE_FUTURE \
|
||||
|
|
8
third_party/python/Python/getargs.c
vendored
8
third_party/python/Python/getargs.c
vendored
|
@ -1,11 +1,7 @@
|
|||
|
||||
/* clang-format off */
|
||||
/* New getargs implementation */
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <float.h>
|
||||
|
||||
#include "third_party/python/Include/Python.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
3
third_party/python/Python/getcompiler.c
vendored
3
third_party/python/Python/getcompiler.c
vendored
|
@ -1,7 +1,8 @@
|
|||
/* clang-format off */
|
||||
|
||||
/* Return the compiler identification, if possible. */
|
||||
|
||||
#include "Python.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
|
||||
#ifndef COMPILER
|
||||
|
||||
|
|
4
third_party/python/Python/getcopyright.c
vendored
4
third_party/python/Python/getcopyright.c
vendored
|
@ -1,6 +1,8 @@
|
|||
/* clang-format off */
|
||||
|
||||
/* Return the copyright string. This is updated manually. */
|
||||
|
||||
#include "Python.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
|
||||
static const char cprt[] =
|
||||
"\
|
||||
|
|
9
third_party/python/Python/getopt.c
vendored
9
third_party/python/Python/getopt.c
vendored
|
@ -1,3 +1,4 @@
|
|||
/* clang-format off */
|
||||
/*---------------------------------------------------------------------------*
|
||||
* <RCS keywords>
|
||||
*
|
||||
|
@ -27,11 +28,8 @@
|
|||
/* Modified to support --help and --version, as well as /? on Windows
|
||||
* by Georg Brandl. */
|
||||
|
||||
#include <Python.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <wchar.h>
|
||||
#include <pygetopt.h>
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/pygetopt.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -129,4 +127,3 @@ int _PyOS_GetOpt(int argc, wchar_t **argv, wchar_t *optstring)
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
4
third_party/python/Python/getplatform.c
vendored
4
third_party/python/Python/getplatform.c
vendored
|
@ -1,5 +1,5 @@
|
|||
|
||||
#include "Python.h"
|
||||
/* clang-format off */
|
||||
#include "third_party/python/Include/Python.h"
|
||||
|
||||
#ifndef PLATFORM
|
||||
#define PLATFORM "unknown"
|
||||
|
|
8
third_party/python/Python/getversion.c
vendored
8
third_party/python/Python/getversion.c
vendored
|
@ -1,9 +1,7 @@
|
|||
|
||||
/* clang-format off */
|
||||
/* Return the full version string. */
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
#include "patchlevel.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/patchlevel.h"
|
||||
|
||||
const char *
|
||||
Py_GetVersion(void)
|
||||
|
|
6
third_party/python/Python/graminit.c
vendored
6
third_party/python/Python/graminit.c
vendored
|
@ -1,7 +1,7 @@
|
|||
/* clang-format off */
|
||||
/* Generated by Parser/pgen */
|
||||
|
||||
#include "pgenheaders.h"
|
||||
#include "grammar.h"
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
PyAPI_DATA(grammar) _PyParser_Grammar;
|
||||
static arc arcs_0_0[3] = {
|
||||
{2, 1},
|
||||
|
|
38
third_party/python/Python/import.c
vendored
38
third_party/python/Python/import.c
vendored
|
@ -1,23 +1,14 @@
|
|||
|
||||
/* Module definition and import implementation */
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
#include "Python-ast.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
/**/
|
||||
#include "third_party/python/Include/Python-ast.h"
|
||||
#undef Yield /* undefine macro conflicting with winbase.h */
|
||||
#include "errcode.h"
|
||||
#include "marshal.h"
|
||||
#include "code.h"
|
||||
#include "frameobject.h"
|
||||
#include "osdefs.h"
|
||||
#include "importdl.h"
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include "third_party/python/Include/code.h"
|
||||
#include "third_party/python/Include/errcode.h"
|
||||
#include "third_party/python/Include/frameobject.h"
|
||||
#include "third_party/python/Include/marshal.h"
|
||||
#include "third_party/python/Include/osdefs.h"
|
||||
#include "third_party/python/Python/importdl.h"
|
||||
/* clang-format off */
|
||||
|
||||
#define CACHEDIR "__pycache__"
|
||||
|
||||
|
@ -36,7 +27,7 @@ module _imp
|
|||
[clinic start generated code]*/
|
||||
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=9c332475d8686284]*/
|
||||
|
||||
#include "clinic/import.c.h"
|
||||
#include "third_party/python/Python/clinic/import.inc"
|
||||
|
||||
/* Initialize things */
|
||||
|
||||
|
@ -143,8 +134,7 @@ _PyImportZip_Init(void)
|
|||
These calls are serialized by the global interpreter lock. */
|
||||
|
||||
#ifdef WITH_THREAD
|
||||
|
||||
#include "pythread.h"
|
||||
#include "third_party/python/Include/pythread.h"
|
||||
|
||||
static PyThread_type_lock import_lock = 0;
|
||||
static long import_lock_thread = -1;
|
||||
|
@ -2145,7 +2135,3 @@ PyImport_AppendInittab(const char *name, PyObject* (*initfunc)(void))
|
|||
|
||||
return PyImport_ExtendInittab(newtab);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
7
third_party/python/Python/importdl.c
vendored
7
third_party/python/Python/importdl.c
vendored
|
@ -1,7 +1,6 @@
|
|||
|
||||
/* clang-format off */
|
||||
/* Support for dynamic loading of extension modules */
|
||||
|
||||
#include "Python.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
|
||||
/* ./configure sets HAVE_DYNAMIC_LOADING if dynamic loading of modules is
|
||||
supported on this platform. configure will then compile and link in one
|
||||
|
@ -10,7 +9,7 @@
|
|||
*/
|
||||
#ifdef HAVE_DYNAMIC_LOADING
|
||||
|
||||
#include "importdl.h"
|
||||
#include "third_party/python/Python/importdl.h"
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
extern dl_funcptr _PyImport_FindSharedFuncptrWindows(const char *prefix,
|
||||
|
|
7
third_party/python/Python/importdl.h
vendored
7
third_party/python/Python/importdl.h
vendored
|
@ -5,7 +5,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
extern const char *_PyImport_DynLoadFiletab[];
|
||||
|
||||
extern PyObject *_PyImport_LoadDynamicModuleWithSpec(PyObject *spec, FILE *);
|
||||
|
@ -13,13 +12,7 @@ extern PyObject *_PyImport_LoadDynamicModuleWithSpec(PyObject *spec, FILE *);
|
|||
/* Max length of module suffix searched for -- accommodates "module.slb" */
|
||||
#define MAXSUFFIXSIZE 12
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
#include <windows.h>
|
||||
typedef FARPROC dl_funcptr;
|
||||
#else
|
||||
typedef void (*dl_funcptr)(void);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* clang-format off */
|
||||
/* Auto-generated by Programs/_freeze_importlib.c */
|
||||
const unsigned char _Py_M__importlib[] = {
|
||||
99,0,0,0,0,0,0,0,0,0,0,0,0,4,0,0,
|
|
@ -45,7 +45,7 @@ def main():
|
|||
if len(sys.argv) == 2:
|
||||
target = sys.argv[1]
|
||||
else:
|
||||
target = "Python/opcode_targets.h"
|
||||
target = "third_party/python/Python/opcode_targets.inc"
|
||||
with open(target, "w") as f:
|
||||
write_contents(f)
|
||||
print("Jump table written into %s" % target)
|
||||
|
|
12
third_party/python/Python/marshal.c
vendored
12
third_party/python/Python/marshal.c
vendored
|
@ -1,3 +1,5 @@
|
|||
/* clang-format off */
|
||||
|
||||
|
||||
/* Write Python objects to files and read them back.
|
||||
This is primarily intended for writing and reading compiled Python code,
|
||||
|
@ -8,11 +10,11 @@
|
|||
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
|
||||
#include "Python.h"
|
||||
#include "longintrepr.h"
|
||||
#include "code.h"
|
||||
#include "marshal.h"
|
||||
#include "../Modules/hashtable.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/longintrepr.h"
|
||||
#include "third_party/python/Include/code.h"
|
||||
#include "third_party/python/Include/marshal.h"
|
||||
#include "third_party/python/Modules/hashtable.h"
|
||||
|
||||
/* High water mark to determine when the marshalled object is dangerously deep
|
||||
* and risks coring the interpreter. When the object stack gets this deep,
|
||||
|
|
5
third_party/python/Python/modsupport.c
vendored
5
third_party/python/Python/modsupport.c
vendored
|
@ -1,7 +1,6 @@
|
|||
|
||||
/* clang-format off */
|
||||
/* Module support implementation */
|
||||
|
||||
#include "Python.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
|
||||
#define FLAG_SIZE_T 1
|
||||
typedef double va_double;
|
||||
|
|
4
third_party/python/Python/mysnprintf.c
vendored
4
third_party/python/Python/mysnprintf.c
vendored
|
@ -1,4 +1,6 @@
|
|||
#include "Python.h"
|
||||
/* clang-format off */
|
||||
|
||||
#include "third_party/python/Include/Python.h"
|
||||
|
||||
/* snprintf() wrappers. If the platform has vsnprintf, we use it, else we
|
||||
emulate it in a half-hearted way. Even if the platform has it, we wrap
|
||||
|
|
12
third_party/python/Python/mystrtoul.c
vendored
12
third_party/python/Python/mystrtoul.c
vendored
|
@ -1,18 +1,10 @@
|
|||
|
||||
#include "Python.h"
|
||||
/* clang-format off */
|
||||
#include "third_party/python/Include/Python.h"
|
||||
|
||||
#if defined(__sgi) && defined(WITH_THREAD) && !defined(_SGI_MP_SOURCE)
|
||||
#define _SGI_MP_SOURCE
|
||||
#endif
|
||||
|
||||
/* strtol and strtoul, renamed to avoid conflicts */
|
||||
|
||||
|
||||
#include <ctype.h>
|
||||
#ifdef HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
/* Static overflow check values for bases 2 through 36.
|
||||
* smallmax[base] is the largest unsigned long i such that
|
||||
* i * base doesn't overflow unsigned long.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* clang-format off */
|
||||
static void *opcode_targets[256] = {
|
||||
&&_unknown_opcode,
|
||||
&&TARGET_POP_TOP,
|
19
third_party/python/Python/peephole.c
vendored
19
third_party/python/Python/peephole.c
vendored
|
@ -1,14 +1,13 @@
|
|||
/* clang-format off */
|
||||
/* Peephole optimizations for bytecode compiler. */
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
#include "Python-ast.h"
|
||||
#include "node.h"
|
||||
#include "ast.h"
|
||||
#include "code.h"
|
||||
#include "symtable.h"
|
||||
#include "opcode.h"
|
||||
#include "wordcode_helpers.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/Python-ast.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
#include "third_party/python/Include/ast.h"
|
||||
#include "third_party/python/Include/code.h"
|
||||
#include "third_party/python/Include/symtable.h"
|
||||
#include "third_party/python/Include/opcode.h"
|
||||
#include "third_party/python/Python/wordcode_helpers.h"
|
||||
|
||||
#define UNCONDITIONAL_JUMP(op) (op==JUMP_ABSOLUTE || op==JUMP_FORWARD)
|
||||
#define CONDITIONAL_JUMP(op) (op==POP_JUMP_IF_FALSE || op==POP_JUMP_IF_TRUE \
|
||||
|
|
3
third_party/python/Python/pyarena.c
vendored
3
third_party/python/Python/pyarena.c
vendored
|
@ -1,4 +1,5 @@
|
|||
#include "Python.h"
|
||||
/* clang-format off */
|
||||
#include "third_party/python/Include/Python.h"
|
||||
|
||||
/* A simple arena block structure.
|
||||
|
||||
|
|
3
third_party/python/Python/pyctype.c
vendored
3
third_party/python/Python/pyctype.c
vendored
|
@ -1,4 +1,5 @@
|
|||
#include "Python.h"
|
||||
/* clang-format off */
|
||||
#include "third_party/python/Include/Python.h"
|
||||
|
||||
/* Our own locale-independent ctype.h-like macros */
|
||||
|
||||
|
|
5
third_party/python/Python/pyfpe.c
vendored
5
third_party/python/Python/pyfpe.c
vendored
|
@ -1,5 +1,6 @@
|
|||
#include "pyconfig.h"
|
||||
#include "pyfpe.h"
|
||||
/* clang-format off */
|
||||
#include "third_party/python/pyconfig.h"
|
||||
#include "third_party/python/Include/pyfpe.h"
|
||||
/*
|
||||
* The signal handler for SIGFPE is actually declared in an external
|
||||
* module fpectl, or as preferred by the user. These variable
|
||||
|
|
12
third_party/python/Python/pyhash.c
vendored
12
third_party/python/Python/pyhash.c
vendored
|
@ -1,17 +1,9 @@
|
|||
/* clang-format off */
|
||||
/* Set of hash utility functions to help maintaining the invariant that
|
||||
if a==b then hash(a)==hash(b)
|
||||
|
||||
All the utility functions (_Py_Hash*()) return "-1" to signify an error.
|
||||
*/
|
||||
#include "Python.h"
|
||||
|
||||
#ifdef __APPLE__
|
||||
# include <libkern/OSByteOrder.h>
|
||||
#elif defined(HAVE_LE64TOH) && defined(HAVE_ENDIAN_H)
|
||||
# include <endian.h>
|
||||
#elif defined(HAVE_LE64TOH) && defined(HAVE_SYS_ENDIAN_H)
|
||||
# include <sys/endian.h>
|
||||
#endif
|
||||
#include "third_party/python/Include/Python.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
57
third_party/python/Python/pylifecycle.c
vendored
57
third_party/python/Python/pylifecycle.c
vendored
|
@ -1,52 +1,27 @@
|
|||
/* clang-format off */
|
||||
/* Python interpreter top-level routines, including init/exit */
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
#include "Python-ast.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/Python-ast.h"
|
||||
#undef Yield /* undefine macro conflicting with winbase.h */
|
||||
#include "grammar.h"
|
||||
#include "node.h"
|
||||
#include "token.h"
|
||||
#include "parsetok.h"
|
||||
#include "errcode.h"
|
||||
#include "code.h"
|
||||
#include "symtable.h"
|
||||
#include "ast.h"
|
||||
#include "marshal.h"
|
||||
#include "osdefs.h"
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
#include "third_party/python/Include/token.h"
|
||||
#include "third_party/python/Include/parsetok.h"
|
||||
#include "third_party/python/Include/errcode.h"
|
||||
#include "third_party/python/Include/code.h"
|
||||
#include "third_party/python/Include/symtable.h"
|
||||
#include "third_party/python/Include/ast.h"
|
||||
#include "third_party/python/Include/marshal.h"
|
||||
#include "third_party/python/Include/osdefs.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
#include "libc/calls/sigbits.h"
|
||||
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
#include "malloc.h" /* for alloca */
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LANGINFO_H
|
||||
#include <langinfo.h>
|
||||
#endif
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
#undef BYTE
|
||||
#include "windows.h"
|
||||
|
||||
extern PyTypeObject PyWindowsConsoleIO_Type;
|
||||
#define PyWindowsConsoleIO_Check(op) (PyObject_TypeCheck((op), &PyWindowsConsoleIO_Type))
|
||||
#endif
|
||||
|
||||
_Py_IDENTIFIER(flush);
|
||||
_Py_IDENTIFIER(name);
|
||||
_Py_IDENTIFIER(stdin);
|
||||
_Py_IDENTIFIER(stdout);
|
||||
_Py_IDENTIFIER(stderr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern wchar_t *Py_GetPath(void);
|
||||
|
||||
extern grammar _PyParser_Grammar; /* From graminit.c */
|
||||
|
@ -1485,7 +1460,7 @@ exit:
|
|||
/* Clean up and exit */
|
||||
|
||||
#ifdef WITH_THREAD
|
||||
# include "pythread.h"
|
||||
#include "third_party/python/Include/pythread.h"
|
||||
#endif
|
||||
|
||||
static void (*pyexitfunc)(void) = NULL;
|
||||
|
@ -1690,7 +1665,3 @@ PyOS_setsig(int sig, PyOS_sighandler_t handler)
|
|||
return oldhandler;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
54
third_party/python/Python/pymath.c
vendored
54
third_party/python/Python/pymath.c
vendored
|
@ -1,4 +1,5 @@
|
|||
#include "Python.h"
|
||||
/* clang-format off */
|
||||
#include "third_party/python/Include/Python.h"
|
||||
|
||||
#ifdef X87_DOUBLE_ROUNDING
|
||||
/* On x86 platforms using an x87 FPU, this function is called from the
|
||||
|
@ -14,7 +15,6 @@ double _Py_force_double(double x)
|
|||
#endif
|
||||
|
||||
#ifdef HAVE_GCC_ASM_FOR_X87
|
||||
|
||||
/* inline assembly for getting and setting the 387 FPU control word on
|
||||
gcc/x86 */
|
||||
#ifdef _Py_MEMORY_SANITIZER
|
||||
|
@ -25,57 +25,7 @@ unsigned short _Py_get_387controlword(void) {
|
|||
__asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
|
||||
return cw;
|
||||
}
|
||||
|
||||
void _Py_set_387controlword(unsigned short cw) {
|
||||
__asm__ __volatile__ ("fldcw %0" : : "m" (cw));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAVE_HYPOT
|
||||
double hypot(double x, double y)
|
||||
{
|
||||
double yx;
|
||||
|
||||
x = fabs(x);
|
||||
y = fabs(y);
|
||||
if (x < y) {
|
||||
double temp = x;
|
||||
x = y;
|
||||
y = temp;
|
||||
}
|
||||
if (x == 0.)
|
||||
return 0.;
|
||||
else {
|
||||
yx = y/x;
|
||||
return x*sqrt(1.+yx*yx);
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_HYPOT */
|
||||
|
||||
#ifndef HAVE_COPYSIGN
|
||||
double
|
||||
copysign(double x, double y)
|
||||
{
|
||||
/* use atan2 to distinguish -0. from 0. */
|
||||
if (y > 0. || (y == 0. && atan2(y, -1.) > 0.)) {
|
||||
return fabs(x);
|
||||
} else {
|
||||
return -fabs(x);
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_COPYSIGN */
|
||||
|
||||
#ifndef HAVE_ROUND
|
||||
double
|
||||
round(double x)
|
||||
{
|
||||
double absx, y;
|
||||
absx = fabs(x);
|
||||
y = floor(absx);
|
||||
if (absx - y >= 0.5)
|
||||
y += 1.0;
|
||||
return copysign(y, x);
|
||||
}
|
||||
#endif /* HAVE_ROUND */
|
||||
|
|
128
third_party/python/Python/pystate.c
vendored
128
third_party/python/Python/pystate.c
vendored
|
@ -1,7 +1,10 @@
|
|||
|
||||
#include "libc/bits/pushpop.h"
|
||||
#include "libc/runtime/dlfcn.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
/* clang-format off */
|
||||
/* Thread and interpreter state structures and their interfaces */
|
||||
|
||||
#include "Python.h"
|
||||
#define ZERO(x) x = (typeof(x))pushpop(0L)
|
||||
|
||||
#define GET_TSTATE() \
|
||||
((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current))
|
||||
|
@ -10,7 +13,6 @@
|
|||
#define GET_INTERP_STATE() \
|
||||
(GET_TSTATE()->interp)
|
||||
|
||||
|
||||
/* --------------------------------------------------------------------------
|
||||
CAUTION
|
||||
|
||||
|
@ -21,23 +23,10 @@ debugging obmalloc functions. Those aren't thread-safe (they rely on the GIL
|
|||
to avoid the expense of doing their own locking).
|
||||
-------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef HAVE_DLOPEN
|
||||
#ifdef HAVE_DLFCN_H
|
||||
#include "libc/runtime/dlfcn.h"
|
||||
#endif
|
||||
#if !HAVE_DECL_RTLD_LAZY
|
||||
#define RTLD_LAZY 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int _PyGILState_check_enabled = 1;
|
||||
|
||||
#ifdef WITH_THREAD
|
||||
#include "pythread.h"
|
||||
#include "third_party/python/Include/pythread.h"
|
||||
static PyThread_type_lock head_mutex = NULL; /* Protects interp->tstate_head */
|
||||
#define HEAD_INIT() (void)(head_mutex || (head_mutex = PyThread_allocate_lock()))
|
||||
#define HEAD_LOCK() PyThread_acquire_lock(head_mutex, WAIT_LOCK)
|
||||
|
@ -73,33 +62,33 @@ PyInterpreterState_New(void)
|
|||
PyInterpreterState *interp = (PyInterpreterState *)
|
||||
PyMem_RawMalloc(sizeof(PyInterpreterState));
|
||||
|
||||
if (interp != NULL) {
|
||||
if (interp != 0) {
|
||||
__PyCodeExtraState* coextra = PyMem_RawMalloc(sizeof(__PyCodeExtraState));
|
||||
if (coextra == NULL) {
|
||||
if (coextra == 0) {
|
||||
PyMem_RawFree(interp);
|
||||
return NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
HEAD_INIT();
|
||||
#ifdef WITH_THREAD
|
||||
if (head_mutex == NULL)
|
||||
if (head_mutex == 0)
|
||||
Py_FatalError("Can't initialize threads for interpreter");
|
||||
#endif
|
||||
interp->modules = NULL;
|
||||
interp->modules_by_index = NULL;
|
||||
interp->sysdict = NULL;
|
||||
interp->builtins = NULL;
|
||||
interp->builtins_copy = NULL;
|
||||
interp->tstate_head = NULL;
|
||||
interp->codec_search_path = NULL;
|
||||
interp->codec_search_cache = NULL;
|
||||
interp->codec_error_registry = NULL;
|
||||
interp->codecs_initialized = 0;
|
||||
interp->fscodec_initialized = 0;
|
||||
interp->importlib = NULL;
|
||||
interp->import_func = NULL;
|
||||
ZERO(interp->modules);
|
||||
ZERO(interp->modules_by_index);
|
||||
ZERO(interp->sysdict);
|
||||
ZERO(interp->builtins);
|
||||
ZERO(interp->builtins_copy);
|
||||
ZERO(interp->tstate_head);
|
||||
ZERO(interp->codec_search_path);
|
||||
ZERO(interp->codec_search_cache);
|
||||
ZERO(interp->codec_error_registry);
|
||||
ZERO(interp->codecs_initialized);
|
||||
ZERO(interp->fscodec_initialized);
|
||||
ZERO(interp->importlib);
|
||||
ZERO(interp->import_func);
|
||||
interp->eval_frame = _PyEval_EvalFrameDefault;
|
||||
coextra->co_extra_user_count = 0;
|
||||
ZERO(coextra->co_extra_user_count);
|
||||
coextra->interp = interp;
|
||||
#ifdef HAVE_DLOPEN
|
||||
#if HAVE_DECL_RTLD_NOW
|
||||
|
@ -206,57 +195,58 @@ new_threadstate(PyInterpreterState *interp, int init)
|
|||
{
|
||||
PyThreadState *tstate = (PyThreadState *)PyMem_RawMalloc(sizeof(PyThreadState));
|
||||
|
||||
if (_PyThreadState_GetFrame == NULL)
|
||||
if (_PyThreadState_GetFrame == 0)
|
||||
_PyThreadState_GetFrame = threadstate_getframe;
|
||||
|
||||
if (tstate != NULL) {
|
||||
if (tstate != 0) {
|
||||
tstate->interp = interp;
|
||||
|
||||
tstate->frame = NULL;
|
||||
tstate->recursion_depth = 0;
|
||||
tstate->overflowed = 0;
|
||||
tstate->recursion_critical = 0;
|
||||
tstate->tracing = 0;
|
||||
tstate->use_tracing = 0;
|
||||
tstate->gilstate_counter = 0;
|
||||
tstate->async_exc = NULL;
|
||||
ZERO(tstate->frame);
|
||||
ZERO(tstate->recursion_depth);
|
||||
ZERO(tstate->overflowed);
|
||||
ZERO(tstate->recursion_critical);
|
||||
ZERO(tstate->tracing);
|
||||
ZERO(tstate->use_tracing);
|
||||
ZERO(tstate->gilstate_counter);
|
||||
ZERO(tstate->async_exc);
|
||||
#ifdef WITH_THREAD
|
||||
tstate->thread_id = PyThread_get_thread_ident();
|
||||
#else
|
||||
tstate->thread_id = 0;
|
||||
ZERO(tstate->thread_id);
|
||||
#endif
|
||||
|
||||
tstate->dict = NULL;
|
||||
ZERO(tstate->dict);
|
||||
|
||||
tstate->curexc_type = NULL;
|
||||
tstate->curexc_value = NULL;
|
||||
tstate->curexc_traceback = NULL;
|
||||
ZERO(tstate->curexc_type);
|
||||
ZERO(tstate->curexc_value);
|
||||
ZERO(tstate->curexc_traceback);
|
||||
|
||||
tstate->exc_type = NULL;
|
||||
tstate->exc_value = NULL;
|
||||
tstate->exc_traceback = NULL;
|
||||
ZERO(tstate->exc_type);
|
||||
ZERO(tstate->exc_value);
|
||||
ZERO(tstate->exc_traceback);
|
||||
|
||||
tstate->c_profilefunc = NULL;
|
||||
tstate->c_tracefunc = NULL;
|
||||
tstate->c_profileobj = NULL;
|
||||
tstate->c_traceobj = NULL;
|
||||
ZERO(tstate->c_profilefunc);
|
||||
ZERO(tstate->c_tracefunc);
|
||||
ZERO(tstate->c_profileobj);
|
||||
ZERO(tstate->c_traceobj);
|
||||
|
||||
tstate->trash_delete_nesting = 0;
|
||||
tstate->trash_delete_later = NULL;
|
||||
tstate->on_delete = NULL;
|
||||
tstate->on_delete_data = NULL;
|
||||
ZERO(tstate->trash_delete_nesting);
|
||||
ZERO(tstate->trash_delete_later);
|
||||
ZERO(tstate->on_delete);
|
||||
ZERO(tstate->on_delete_data);
|
||||
|
||||
tstate->coroutine_wrapper = NULL;
|
||||
tstate->in_coroutine_wrapper = 0;
|
||||
ZERO(tstate->coroutine_wrapper);
|
||||
ZERO(tstate->in_coroutine_wrapper);
|
||||
|
||||
tstate->async_gen_firstiter = NULL;
|
||||
tstate->async_gen_finalizer = NULL;
|
||||
ZERO(tstate->async_gen_firstiter);
|
||||
ZERO(tstate->async_gen_finalizer);
|
||||
|
||||
if (init)
|
||||
_PyThreadState_Init(tstate);
|
||||
|
||||
HEAD_LOCK();
|
||||
tstate->prev = NULL;
|
||||
ZERO(tstate->prev);
|
||||
|
||||
tstate->next = interp->tstate_head;
|
||||
if (tstate->next)
|
||||
tstate->next->prev = tstate;
|
||||
|
@ -951,9 +941,3 @@ PyGILState_Release(PyGILState_STATE oldstate)
|
|||
}
|
||||
|
||||
#endif /* WITH_THREAD */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
|
4
third_party/python/Python/pystrcmp.c
vendored
4
third_party/python/Python/pystrcmp.c
vendored
|
@ -1,7 +1,9 @@
|
|||
/* clang-format off */
|
||||
|
||||
/* Cross platform case insensitive string compare functions
|
||||
*/
|
||||
|
||||
#include "Python.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
|
||||
int
|
||||
PyOS_mystrnicmp(const char *s1, const char *s2, Py_ssize_t size)
|
||||
|
|
4
third_party/python/Python/pystrhex.c
vendored
4
third_party/python/Python/pystrhex.c
vendored
|
@ -1,6 +1,6 @@
|
|||
/* clang-format off */
|
||||
/* bytes to hex implementation */
|
||||
|
||||
#include "Python.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
|
||||
static PyObject *_Py_strhex_impl(const char* argbuf, const Py_ssize_t arglen,
|
||||
int return_bytes)
|
||||
|
|
4
third_party/python/Python/pystrtod.c
vendored
4
third_party/python/Python/pystrtod.c
vendored
|
@ -1,6 +1,6 @@
|
|||
/* clang-format off */
|
||||
/* -*- Mode: C; c-file-style: "python" -*- */
|
||||
|
||||
#include <Python.h>
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
/* Case-insensitive string match used for nan and inf detection; t should be
|
||||
|
|
56
third_party/python/Python/pythonrun.c
vendored
56
third_party/python/Python/pythonrun.c
vendored
|
@ -1,39 +1,20 @@
|
|||
|
||||
/* clang-format off */
|
||||
/* Python interpreter top-level routines, including init/exit */
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
#include "Python-ast.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/Python-ast.h"
|
||||
#undef Yield /* undefine macro conflicting with winbase.h */
|
||||
#include "grammar.h"
|
||||
#include "node.h"
|
||||
#include "token.h"
|
||||
#include "parsetok.h"
|
||||
#include "errcode.h"
|
||||
#include "code.h"
|
||||
#include "symtable.h"
|
||||
#include "ast.h"
|
||||
#include "marshal.h"
|
||||
#include "osdefs.h"
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
#include "third_party/python/Include/token.h"
|
||||
#include "third_party/python/Include/parsetok.h"
|
||||
#include "third_party/python/Include/errcode.h"
|
||||
#include "third_party/python/Include/code.h"
|
||||
#include "third_party/python/Include/symtable.h"
|
||||
#include "third_party/python/Include/ast.h"
|
||||
#include "third_party/python/Include/marshal.h"
|
||||
#include "third_party/python/Include/osdefs.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
#ifdef HAVE_SIGNAL_H
|
||||
#include <signal.h>
|
||||
#endif
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
#include "malloc.h" /* for alloca */
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LANGINFO_H
|
||||
#include <langinfo.h>
|
||||
#endif
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
#undef BYTE
|
||||
#include "windows.h"
|
||||
#endif
|
||||
|
||||
_Py_IDENTIFIER(builtins);
|
||||
_Py_IDENTIFIER(excepthook);
|
||||
_Py_IDENTIFIER(flush);
|
||||
|
@ -47,10 +28,6 @@ _Py_IDENTIFIER(stdout);
|
|||
_Py_IDENTIFIER(stderr);
|
||||
_Py_static_string(PyId_string, "<string>");
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern grammar _PyParser_Grammar; /* From graminit.c */
|
||||
|
||||
/* Forward */
|
||||
|
@ -1450,9 +1427,6 @@ cleanup:
|
|||
|
||||
/* Stack checking for Microsoft C */
|
||||
|
||||
#include <malloc.h>
|
||||
#include <excpt.h>
|
||||
|
||||
/*
|
||||
* Return non-zero when we run out of memory on the stack; zero otherwise.
|
||||
*/
|
||||
|
@ -1598,7 +1572,3 @@ PyRun_InteractiveLoop(FILE *f, const char *p)
|
|||
{
|
||||
return PyRun_InteractiveLoopFlags(f, p, NULL);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
10
third_party/python/Python/pytime.c
vendored
10
third_party/python/Python/pytime.c
vendored
|
@ -1,11 +1,5 @@
|
|||
#include "Python.h"
|
||||
#ifdef MS_WINDOWS
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <mach/mach_time.h> /* mach_absolute_time(), mach_timebase_info() */
|
||||
#endif
|
||||
/* clang-format off */
|
||||
#include "third_party/python/Include/Python.h"
|
||||
|
||||
#define _PyTime_check_mul_overflow(a, b) \
|
||||
(assert(b > 0), \
|
||||
|
|
166
third_party/python/Python/random.c
vendored
166
third_party/python/Python/random.c
vendored
|
@ -1,28 +1,6 @@
|
|||
#include "Python.h"
|
||||
#ifdef MS_WINDOWS
|
||||
# include <windows.h>
|
||||
/* All sample MSDN wincrypt programs include the header below. It is at least
|
||||
* required with Min GW. */
|
||||
# include <wincrypt.h>
|
||||
#else
|
||||
# include <fcntl.h>
|
||||
# ifdef HAVE_SYS_STAT_H
|
||||
# include <sys/stat.h>
|
||||
# endif
|
||||
# ifdef HAVE_LINUX_RANDOM_H
|
||||
# include <linux/random.h>
|
||||
# endif
|
||||
# if defined(HAVE_SYS_RANDOM_H) && (defined(HAVE_GETRANDOM) || defined(HAVE_GETENTROPY))
|
||||
# include <sys/random.h>
|
||||
# endif
|
||||
# if !defined(HAVE_GETRANDOM) && defined(HAVE_GETRANDOM_SYSCALL)
|
||||
# include <sys/syscall.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef _Py_MEMORY_SANITIZER
|
||||
# include <sanitizer/msan_interface.h>
|
||||
#endif
|
||||
/* clang-format off */
|
||||
#include "libc/sysv/consts/grnd.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
|
||||
#ifdef Py_DEBUG
|
||||
int _Py_HashSecret_Initialized = 0;
|
||||
|
@ -30,59 +8,6 @@ int _Py_HashSecret_Initialized = 0;
|
|||
static int _Py_HashSecret_Initialized = 0;
|
||||
#endif
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
static HCRYPTPROV hCryptProv = 0;
|
||||
|
||||
static int
|
||||
win32_urandom_init(int raise)
|
||||
{
|
||||
/* Acquire context */
|
||||
if (!CryptAcquireContext(&hCryptProv, NULL, NULL,
|
||||
PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
|
||||
goto error;
|
||||
|
||||
return 0;
|
||||
|
||||
error:
|
||||
if (raise) {
|
||||
PyErr_SetFromWindowsErr(0);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Fill buffer with size pseudo-random bytes generated by the Windows CryptoGen
|
||||
API. Return 0 on success, or raise an exception and return -1 on error. */
|
||||
static int
|
||||
win32_urandom(unsigned char *buffer, Py_ssize_t size, int raise)
|
||||
{
|
||||
Py_ssize_t chunk;
|
||||
|
||||
if (hCryptProv == 0)
|
||||
{
|
||||
if (win32_urandom_init(raise) == -1) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
while (size > 0)
|
||||
{
|
||||
chunk = size > INT_MAX ? INT_MAX : size;
|
||||
if (!CryptGenRandom(hCryptProv, (DWORD)chunk, buffer))
|
||||
{
|
||||
/* CryptGenRandom() failed */
|
||||
if (raise) {
|
||||
PyErr_SetFromWindowsErr(0);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
buffer += chunk;
|
||||
size -= chunk;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else /* !MS_WINDOWS */
|
||||
|
||||
#if defined(HAVE_GETRANDOM) || defined(HAVE_GETRANDOM_SYSCALL)
|
||||
#define PY_GETRANDOM 1
|
||||
|
||||
|
@ -195,80 +120,6 @@ py_getrandom(void *buffer, Py_ssize_t size, int blocking, int raise)
|
|||
return 1;
|
||||
}
|
||||
|
||||
#elif defined(HAVE_GETENTROPY)
|
||||
#define PY_GETENTROPY 1
|
||||
|
||||
/* Fill buffer with size pseudo-random bytes generated by getentropy():
|
||||
|
||||
- Return 1 on success
|
||||
- Return 0 if getentropy() syscall is not available (failed with ENOSYS or
|
||||
EPERM).
|
||||
- Raise an exception (if raise is non-zero) and return -1 on error:
|
||||
if getentropy() failed with EINTR, raise is non-zero and the Python signal
|
||||
handler raised an exception, or if getentropy() failed with a different
|
||||
error.
|
||||
|
||||
getentropy() is retried if it failed with EINTR: interrupted by a signal. */
|
||||
static int
|
||||
py_getentropy(char *buffer, Py_ssize_t size, int raise)
|
||||
{
|
||||
/* Is getentropy() supported by the running kernel? Set to 0 if
|
||||
getentropy() failed with ENOSYS or EPERM. */
|
||||
static int getentropy_works = 1;
|
||||
|
||||
if (!getentropy_works) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (size > 0) {
|
||||
/* getentropy() is limited to returning up to 256 bytes. Call it
|
||||
multiple times if more bytes are requested. */
|
||||
Py_ssize_t len = Py_MIN(size, 256);
|
||||
int res;
|
||||
|
||||
if (raise) {
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
res = getentropy(buffer, len);
|
||||
Py_END_ALLOW_THREADS
|
||||
}
|
||||
else {
|
||||
res = getentropy(buffer, len);
|
||||
}
|
||||
|
||||
if (res < 0) {
|
||||
/* ENOSYS: the syscall is not supported by the running kernel.
|
||||
EPERM: the syscall is blocked by a security policy (ex: SECCOMP)
|
||||
or something else. */
|
||||
if (errno == ENOSYS || errno == EPERM) {
|
||||
getentropy_works = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (errno == EINTR) {
|
||||
if (raise) {
|
||||
if (PyErr_CheckSignals()) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* retry getentropy() if it was interrupted by a signal */
|
||||
continue;
|
||||
}
|
||||
|
||||
if (raise) {
|
||||
PyErr_SetFromErrno(PyExc_OSError);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
buffer += len;
|
||||
size -= len;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif /* defined(HAVE_GETENTROPY) && !defined(sun) */
|
||||
|
||||
|
||||
static struct {
|
||||
int fd;
|
||||
dev_t st_dev;
|
||||
|
@ -437,12 +288,9 @@ lcg_urandom(unsigned int x0, unsigned char *buffer, size_t size)
|
|||
- Return 0 on success
|
||||
- Raise an exception (if raise is non-zero) and return -1 on error
|
||||
|
||||
Used sources of entropy ordered by preference, preferred source first:
|
||||
Used sources of entropy ordered by preference:
|
||||
|
||||
- CryptGenRandom() on Windows
|
||||
- getrandom() function (ex: Linux and Solaris): call py_getrandom()
|
||||
- getentropy() function (ex: OpenBSD): call py_getentropy()
|
||||
- /dev/urandom device
|
||||
- getrandom()
|
||||
|
||||
Read from the /dev/urandom device if getrandom() or getentropy() function
|
||||
is not available or does not work.
|
||||
|
@ -499,11 +347,7 @@ pyurandom(void *buffer, Py_ssize_t size, int blocking, int raise)
|
|||
#else
|
||||
|
||||
#if defined(PY_GETRANDOM) || defined(PY_GETENTROPY)
|
||||
#ifdef PY_GETRANDOM
|
||||
res = py_getrandom(buffer, size, blocking, raise);
|
||||
#else
|
||||
res = py_getentropy(buffer, size, raise);
|
||||
#endif
|
||||
if (res < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
|
3
third_party/python/Python/sigcheck.c
vendored
3
third_party/python/Python/sigcheck.c
vendored
|
@ -1,3 +1,4 @@
|
|||
#include "third_party/python/Include/Python.h"
|
||||
/* clang-format off */
|
||||
|
||||
/* Sigcheck is similar to intrcheck() but sets an exception when an
|
||||
|
@ -7,8 +8,6 @@
|
|||
overridden (at link time) by a more powerful version implemented in
|
||||
signalmodule.c. */
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
#pragma weak PyErr_CheckSignals
|
||||
|
||||
/* ARGSUSED */
|
||||
|
|
7
third_party/python/Python/structmember.c
vendored
7
third_party/python/Python/structmember.c
vendored
|
@ -1,10 +1,9 @@
|
|||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/structmember.h"
|
||||
/* clang-format off */
|
||||
|
||||
/* Map C struct members to Python object attributes */
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
#include "structmember.h"
|
||||
|
||||
PyObject *
|
||||
PyMember_GetOne(const char *addr, PyMemberDef *l)
|
||||
{
|
||||
|
|
12
third_party/python/Python/symtable.c
vendored
12
third_party/python/Python/symtable.c
vendored
|
@ -1,8 +1,10 @@
|
|||
#include "Python.h"
|
||||
#include "Python-ast.h"
|
||||
#include "code.h"
|
||||
#include "symtable.h"
|
||||
#include "structmember.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
/**/
|
||||
#include "third_party/python/Include/Python-ast.h"
|
||||
#include "third_party/python/Include/code.h"
|
||||
#include "third_party/python/Include/structmember.h"
|
||||
#include "third_party/python/Include/symtable.h"
|
||||
/* clang-format off */
|
||||
|
||||
/* error strings used for warnings */
|
||||
#define GLOBAL_AFTER_ASSIGN \
|
||||
|
|
28
third_party/python/Python/sysmodule.c
vendored
28
third_party/python/Python/sysmodule.c
vendored
|
@ -1,3 +1,4 @@
|
|||
/* clang-format off */
|
||||
|
||||
/* System module */
|
||||
|
||||
|
@ -14,29 +15,13 @@ Data members:
|
|||
- ps1, ps2: optional primary and secondary prompts (strings)
|
||||
*/
|
||||
|
||||
#include "Python.h"
|
||||
#include "code.h"
|
||||
#include "frameobject.h"
|
||||
#include "pythread.h"
|
||||
|
||||
#include "osdefs.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/code.h"
|
||||
#include "third_party/python/Include/frameobject.h"
|
||||
#include "third_party/python/Include/pythread.h"
|
||||
#include "third_party/python/Include/osdefs.h"
|
||||
#include "libc/unicode/locale.h"
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#endif /* MS_WINDOWS */
|
||||
|
||||
#ifdef MS_COREDLL
|
||||
extern void *PyWin_DLLhModule;
|
||||
/* A string loaded from the DLL at startup: */
|
||||
extern const char *PyWin_DLLVersionString;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LANGINFO_H
|
||||
#include <langinfo.h>
|
||||
#endif
|
||||
|
||||
_Py_IDENTIFIER(_);
|
||||
_Py_IDENTIFIER(__sizeof__);
|
||||
_Py_IDENTIFIER(buffer);
|
||||
|
@ -1065,7 +1050,6 @@ The flag constants are defined in the os module.");
|
|||
|
||||
#ifdef USE_MALLOPT
|
||||
/* Link with -lmalloc (or -lmpc) on an SGI */
|
||||
#include <malloc.h>
|
||||
|
||||
static PyObject *
|
||||
sys_mdebug(PyObject *self, PyObject *args)
|
||||
|
|
22
third_party/python/Python/thread.c
vendored
22
third_party/python/Python/thread.c
vendored
|
@ -1,28 +1,12 @@
|
|||
|
||||
/* clang-format off */
|
||||
/* Thread package.
|
||||
This is intended to be usable independently from Python.
|
||||
The implementation for system foobar is in a file thread_foobar.h
|
||||
which is included by this file dependent on config settings.
|
||||
Stuff shared by all thread_*.h files is collected here. */
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
#ifndef _POSIX_THREADS
|
||||
/* This means pthreads are not implemented in libc headers, hence the macro
|
||||
not present in unistd.h. But they still can be implemented as an external
|
||||
library (e.g. gnu pth in pthread emulation) */
|
||||
# ifdef HAVE_PTHREAD_H
|
||||
# include <pthread.h> /* _POSIX_THREADS */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef DONT_HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "pythread.h"
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/pythread.h"
|
||||
|
||||
#ifndef _POSIX_THREADS
|
||||
|
||||
|
|
9
third_party/python/Python/thread_nt.h
vendored
9
third_party/python/Python/thread_nt.h
vendored
|
@ -1,14 +1,9 @@
|
|||
/* clang-format off */
|
||||
|
||||
/* This code implemented by Dag.Gruneau@elsa.preseco.comm.se */
|
||||
/* Fast NonRecursiveMutex support by Yakov Markovitch, markovitch@iso.ru */
|
||||
/* Eliminated some memory leaks, gsw@agere.com */
|
||||
|
||||
#include <windows.h>
|
||||
#include <limits.h>
|
||||
#ifdef HAVE_PROCESS_H
|
||||
#include <process.h>
|
||||
#endif
|
||||
|
||||
/* options */
|
||||
#ifndef _PY_USE_CV_LOCKS
|
||||
#define _PY_USE_CV_LOCKS 1 /* use locks based on cond vars */
|
||||
|
@ -21,7 +16,7 @@
|
|||
|
||||
#if _PY_USE_CV_LOCKS
|
||||
|
||||
#include "condvar.h"
|
||||
#include "third_party/python/Include/condvar.h"
|
||||
|
||||
typedef struct _NRMUTEX
|
||||
{
|
||||
|
|
36
third_party/python/Python/thread_pthread.h
vendored
36
third_party/python/Python/thread_pthread.h
vendored
|
@ -1,17 +1,7 @@
|
|||
/* clang-format off */
|
||||
|
||||
/* Posix threads interface */
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#if defined(__APPLE__) || defined(HAVE_PTHREAD_DESTRUCTOR)
|
||||
#define destructor xxdestructor
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
#if defined(__APPLE__) || defined(HAVE_PTHREAD_DESTRUCTOR)
|
||||
#undef destructor
|
||||
#endif
|
||||
#include <signal.h>
|
||||
|
||||
/* The POSIX spec requires that use of pthread_attr_setstacksize
|
||||
be conditional on _POSIX_THREAD_ATTR_STACKSIZE being defined. */
|
||||
#ifdef _POSIX_THREAD_ATTR_STACKSIZE
|
||||
|
@ -42,30 +32,6 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
/* The POSIX spec says that implementations supporting the sem_*
|
||||
family of functions must indicate this by defining
|
||||
_POSIX_SEMAPHORES. */
|
||||
#ifdef _POSIX_SEMAPHORES
|
||||
/* On FreeBSD 4.x, _POSIX_SEMAPHORES is defined empty, so
|
||||
we need to add 0 to make it work there as well. */
|
||||
#if (_POSIX_SEMAPHORES+0) == -1
|
||||
#define HAVE_BROKEN_POSIX_SEMAPHORES
|
||||
#else
|
||||
#include <semaphore.h>
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Before FreeBSD 5.4, system scope threads was very limited resource
|
||||
in default setting. So the process scope is preferred to get
|
||||
enough number of threads to work. */
|
||||
#ifdef __FreeBSD__
|
||||
#include <osreldate.h>
|
||||
#if __FreeBSD_version >= 500000 && __FreeBSD_version < 504101
|
||||
#undef PTHREAD_SYSTEM_SCHED_SUPPORTED
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(pthread_attr_default)
|
||||
# define pthread_attr_default ((pthread_attr_t *)NULL)
|
||||
#endif
|
||||
|
|
18
third_party/python/Python/traceback.c
vendored
18
third_party/python/Python/traceback.c
vendored
|
@ -1,15 +1,9 @@
|
|||
|
||||
/* Traceback implementation */
|
||||
|
||||
#include "Python.h"
|
||||
|
||||
#include "code.h"
|
||||
#include "frameobject.h"
|
||||
#include "structmember.h"
|
||||
#include "osdefs.h"
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/code.h"
|
||||
#include "third_party/python/Include/frameobject.h"
|
||||
#include "third_party/python/Include/osdefs.h"
|
||||
#include "third_party/python/Include/structmember.h"
|
||||
/* clang-format off */
|
||||
|
||||
#define OFF(x) offsetof(PyTracebackObject, x)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue