mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-05-22 21:32:31 +00:00
Undiamond Python headers
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
This commit is contained in:
parent
20bb8db9f8
commit
b420ed8248
762 changed files with 18410 additions and 53772 deletions
13
third_party/python/Include/Python-ast.h
generated
vendored
13
third_party/python/Include/Python-ast.h
generated
vendored
|
@ -1,7 +1,12 @@
|
|||
#ifndef COSMOPOLITAN_THIRD_PARTY_PYTHON_INCLUDE_PYTHON_AST_H_
|
||||
#define COSMOPOLITAN_THIRD_PARTY_PYTHON_INCLUDE_PYTHON_AST_H_
|
||||
#include "third_party/python/Include/asdl.h"
|
||||
#include "third_party/python/Include/object.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
/* File automatically generated by Parser/asdl_c.py. */
|
||||
|
||||
#include "asdl.h"
|
||||
|
||||
typedef struct _mod *mod_ty;
|
||||
|
||||
typedef struct _stmt *stmt_ty;
|
||||
|
@ -635,3 +640,7 @@ withitem_ty _Py_withitem(expr_ty context_expr, expr_ty optional_vars, PyArena
|
|||
PyObject* PyAST_mod2obj(mod_ty t);
|
||||
mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode);
|
||||
int PyAST_Check(PyObject* obj);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_THIRD_PARTY_PYTHON_INCLUDE_PYTHON_AST_H_ */
|
||||
|
|
68
third_party/python/Include/Python.h
vendored
68
third_party/python/Include/Python.h
vendored
|
@ -1,62 +1,36 @@
|
|||
#ifndef Py_PYTHON_H
|
||||
#define Py_PYTHON_H
|
||||
#include "libc/assert.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/conv.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/log/log.h"
|
||||
#include "libc/mem/mem.h"
|
||||
#include "libc/rand/rand.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/stdio/temp.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/exit.h"
|
||||
#include "libc/sysv/consts/fileno.h"
|
||||
#include "libc/sysv/consts/o.h"
|
||||
#include "third_party/python/Include/patchlevel.h"
|
||||
#include "third_party/python/Include/pymacconfig.h"
|
||||
#include "third_party/python/pyconfig.h"
|
||||
/* clang-format off */
|
||||
|
||||
/*
|
||||
* PYTHON DIAMOND DEPENDENCY HEADER
|
||||
*
|
||||
* If your editor isn't able to automatically insert #include lines,
|
||||
* then this header can make development easier. It's also great for
|
||||
* making beginner's tutorials simpler and more attractive.
|
||||
*
|
||||
* However it's sloppy to use something like this in the long term since
|
||||
* it's not a scalable dependency model. It makes builds slower, because
|
||||
* changing any single header will invalidate all the build artifacts.
|
||||
*
|
||||
* So please consider doing the conscientious thing and avoid using it!
|
||||
*/
|
||||
|
||||
#include "libc/errno.h"
|
||||
#include "third_party/python/pyconfig.h"
|
||||
#include "third_party/python/Include/patchlevel.h"
|
||||
#include "third_party/python/pyconfig.h"
|
||||
#include "third_party/python/Include/pyport.h"
|
||||
#include "third_party/python/Include/pymacro.h"
|
||||
|
||||
/* A convenient way for code to know if clang's memory sanitizer is enabled. */
|
||||
#if defined(__has_feature)
|
||||
# if __has_feature(memory_sanitizer)
|
||||
# if !defined(_Py_MEMORY_SANITIZER)
|
||||
# define _Py_MEMORY_SANITIZER
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include "third_party/python/Include/pyatomic.h"
|
||||
|
||||
/* Debug-mode build with pymalloc implies PYMALLOC_DEBUG.
|
||||
* PYMALLOC_DEBUG is in error if pymalloc is not in use.
|
||||
*/
|
||||
#if defined(Py_DEBUG) && defined(WITH_PYMALLOC) && !defined(PYMALLOC_DEBUG)
|
||||
#define PYMALLOC_DEBUG
|
||||
#endif
|
||||
#if defined(PYMALLOC_DEBUG) && !defined(WITH_PYMALLOC)
|
||||
#error "PYMALLOC_DEBUG requires WITH_PYMALLOC"
|
||||
#endif
|
||||
|
||||
#include "third_party/python/Include/pymath.h"
|
||||
#include "third_party/python/Include/pytime.h"
|
||||
#include "third_party/python/Include/pymem.h"
|
||||
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/objimpl.h"
|
||||
#include "third_party/python/Include/typeslots.h"
|
||||
#include "third_party/python/Include/pyhash.h"
|
||||
|
||||
#include "third_party/python/Include/pydebug.h"
|
||||
|
||||
#include "third_party/python/Include/bytearrayobject.h"
|
||||
#include "third_party/python/Include/bytesobject.h"
|
||||
#include "third_party/python/Include/unicodeobject.h"
|
||||
|
@ -89,12 +63,9 @@
|
|||
#include "third_party/python/Include/weakrefobject.h"
|
||||
#include "third_party/python/Include/structseq.h"
|
||||
#include "third_party/python/Include/namespaceobject.h"
|
||||
|
||||
#include "third_party/python/Include/codecs.h"
|
||||
#include "third_party/python/Include/pyerrors.h"
|
||||
|
||||
#include "third_party/python/Include/pystate.h"
|
||||
|
||||
#include "third_party/python/Include/pyarena.h"
|
||||
#include "third_party/python/Include/modsupport.h"
|
||||
#include "third_party/python/Include/pythonrun.h"
|
||||
|
@ -104,13 +75,10 @@
|
|||
#include "third_party/python/Include/osmodule.h"
|
||||
#include "third_party/python/Include/intrcheck.h"
|
||||
#include "third_party/python/Include/import.h"
|
||||
|
||||
#include "third_party/python/Include/abstract.h"
|
||||
#include "third_party/python/Include/bltinmodule.h"
|
||||
|
||||
#include "third_party/python/Include/compile.h"
|
||||
#include "third_party/python/Include/eval.h"
|
||||
|
||||
#include "third_party/python/Include/pyctype.h"
|
||||
#include "third_party/python/Include/pystrtod.h"
|
||||
#include "third_party/python/Include/pystrcmp.h"
|
||||
|
|
1831
third_party/python/Include/abstract.h
vendored
1831
third_party/python/Include/abstract.h
vendored
File diff suppressed because it is too large
Load diff
11
third_party/python/Include/accu.h
vendored
11
third_party/python/Include/accu.h
vendored
|
@ -1,6 +1,7 @@
|
|||
#ifndef Py_LIMITED_API
|
||||
#ifndef Py_ACCU_H
|
||||
#define Py_ACCU_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -11,11 +12,11 @@ typedef struct {
|
|||
PyObject *small; /* Pending small strings */
|
||||
} _PyAccu;
|
||||
|
||||
PyAPI_FUNC(int) _PyAccu_Init(_PyAccu *acc);
|
||||
PyAPI_FUNC(int) _PyAccu_Accumulate(_PyAccu *acc, PyObject *unicode);
|
||||
PyAPI_FUNC(PyObject *) _PyAccu_FinishAsList(_PyAccu *acc);
|
||||
PyAPI_FUNC(PyObject *) _PyAccu_Finish(_PyAccu *acc);
|
||||
PyAPI_FUNC(void) _PyAccu_Destroy(_PyAccu *acc);
|
||||
int _PyAccu_Init(_PyAccu *acc);
|
||||
int _PyAccu_Accumulate(_PyAccu *acc, PyObject *unicode);
|
||||
PyObject * _PyAccu_FinishAsList(_PyAccu *acc);
|
||||
PyObject * _PyAccu_Finish(_PyAccu *acc);
|
||||
void _PyAccu_Destroy(_PyAccu *acc);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* Py_ACCU_H */
|
||||
|
|
2
third_party/python/Include/asdl.h
vendored
2
third_party/python/Include/asdl.h
vendored
|
@ -1,5 +1,7 @@
|
|||
#ifndef Py_ASDL_H
|
||||
#define Py_ASDL_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/pyarena.h"
|
||||
/* clang-format off */
|
||||
|
||||
typedef PyObject * identifier;
|
||||
|
|
9
third_party/python/Include/ast.h
vendored
9
third_party/python/Include/ast.h
vendored
|
@ -1,16 +1,19 @@
|
|||
#ifndef Py_AST_H
|
||||
#define Py_AST_H
|
||||
#include "third_party/python/Include/Python-ast.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
#include "third_party/python/Include/pythonrun.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
extern int foo;
|
||||
PyAPI_FUNC(int) PyAST_Validate(mod_ty);
|
||||
PyAPI_FUNC(mod_ty) PyAST_FromNode(
|
||||
int PyAST_Validate(mod_ty);
|
||||
mod_ty PyAST_FromNode(
|
||||
const node *n,
|
||||
PyCompilerFlags *flags,
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
PyArena *arena);
|
||||
PyAPI_FUNC(mod_ty) PyAST_FromNodeObject(
|
||||
mod_ty PyAST_FromNodeObject(
|
||||
const node *n,
|
||||
PyCompilerFlags *flags,
|
||||
PyObject *filename,
|
||||
|
|
1
third_party/python/Include/bitset.h
vendored
1
third_party/python/Include/bitset.h
vendored
|
@ -1,5 +1,6 @@
|
|||
#ifndef Py_BITSET_H
|
||||
#define Py_BITSET_H
|
||||
#include "third_party/python/Include/pgenheaders.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
|
7
third_party/python/Include/bltinmodule.h
vendored
7
third_party/python/Include/bltinmodule.h
vendored
|
@ -1,11 +1,12 @@
|
|||
#ifndef Py_BLTINMODULE_H
|
||||
#define Py_BLTINMODULE_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyFilter_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyMap_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyZip_Type;
|
||||
extern PyTypeObject PyFilter_Type;
|
||||
extern PyTypeObject PyMap_Type;
|
||||
extern PyTypeObject PyZip_Type;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !Py_BLTINMODULE_H */
|
||||
|
|
7
third_party/python/Include/boolobject.h
vendored
7
third_party/python/Include/boolobject.h
vendored
|
@ -1,9 +1,10 @@
|
|||
#ifndef Py_BOOLOBJECT_H
|
||||
#define Py_BOOLOBJECT_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyBool_Type;
|
||||
extern PyTypeObject PyBool_Type;
|
||||
|
||||
#define PyBool_Check(x) (Py_TYPE(x) == &PyBool_Type)
|
||||
|
||||
|
@ -11,7 +12,7 @@ PyAPI_DATA(PyTypeObject) PyBool_Type;
|
|||
Don't forget to apply Py_INCREF() when returning either!!! */
|
||||
|
||||
/* Don't use these directly */
|
||||
PyAPI_DATA(struct _longobject) _Py_FalseStruct, _Py_TrueStruct;
|
||||
extern struct _longobject _Py_FalseStruct, _Py_TrueStruct;
|
||||
|
||||
/* Use these macros */
|
||||
#define Py_False ((PyObject *)&_Py_FalseStruct)
|
||||
|
@ -22,7 +23,7 @@ PyAPI_DATA(struct _longobject) _Py_FalseStruct, _Py_TrueStruct;
|
|||
#define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False
|
||||
|
||||
/* Function to return a bool from a C long */
|
||||
PyAPI_FUNC(PyObject *) PyBool_FromLong(long);
|
||||
PyObject * PyBool_FromLong(long);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !Py_BOOLOBJECT_H */
|
||||
|
|
20
third_party/python/Include/bytearrayobject.h
vendored
20
third_party/python/Include/bytearrayobject.h
vendored
|
@ -1,5 +1,7 @@
|
|||
#ifndef Py_BYTEARRAYOBJECT_H
|
||||
#define Py_BYTEARRAYOBJECT_H
|
||||
#include "libc/assert.h"
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -26,20 +28,20 @@ typedef struct {
|
|||
#endif
|
||||
|
||||
/* Type object */
|
||||
PyAPI_DATA(PyTypeObject) PyByteArray_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyByteArrayIter_Type;
|
||||
extern PyTypeObject PyByteArray_Type;
|
||||
extern PyTypeObject PyByteArrayIter_Type;
|
||||
|
||||
/* Type check macros */
|
||||
#define PyByteArray_Check(self) PyObject_TypeCheck(self, &PyByteArray_Type)
|
||||
#define PyByteArray_CheckExact(self) (Py_TYPE(self) == &PyByteArray_Type)
|
||||
|
||||
/* Direct API functions */
|
||||
PyAPI_FUNC(PyObject *) PyByteArray_FromObject(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyByteArray_Concat(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyByteArray_FromStringAndSize(const char *, Py_ssize_t);
|
||||
PyAPI_FUNC(Py_ssize_t) PyByteArray_Size(PyObject *);
|
||||
PyAPI_FUNC(char *) PyByteArray_AsString(PyObject *);
|
||||
PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t);
|
||||
PyObject * PyByteArray_FromObject(PyObject *);
|
||||
PyObject * PyByteArray_Concat(PyObject *, PyObject *);
|
||||
PyObject * PyByteArray_FromStringAndSize(const char *, Py_ssize_t);
|
||||
Py_ssize_t PyByteArray_Size(PyObject *);
|
||||
char * PyByteArray_AsString(PyObject *);
|
||||
int PyByteArray_Resize(PyObject *, Py_ssize_t);
|
||||
|
||||
/* Macros, trading safety for speed */
|
||||
#ifndef Py_LIMITED_API
|
||||
|
@ -48,7 +50,7 @@ PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t);
|
|||
Py_SIZE(self) ? ((PyByteArrayObject *)(self))->ob_start : _PyByteArray_empty_string)
|
||||
#define PyByteArray_GET_SIZE(self) (assert(PyByteArray_Check(self)), Py_SIZE(self))
|
||||
|
||||
PyAPI_DATA(char) _PyByteArray_empty_string[];
|
||||
extern char _PyByteArray_empty_string[];
|
||||
#endif
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
2
third_party/python/Include/bytes_methods.h
vendored
2
third_party/python/Include/bytes_methods.h
vendored
|
@ -1,6 +1,8 @@
|
|||
#ifndef Py_LIMITED_API
|
||||
#ifndef Py_BYTES_CTYPE_H
|
||||
#define Py_BYTES_CTYPE_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/pymacro.h"
|
||||
/* clang-format off */
|
||||
|
||||
/*
|
||||
|
|
57
third_party/python/Include/bytesobject.h
vendored
57
third_party/python/Include/bytesobject.h
vendored
|
@ -1,5 +1,6 @@
|
|||
#ifndef Py_BYTESOBJECT_H
|
||||
#define Py_BYTESOBJECT_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -35,42 +36,42 @@ typedef struct {
|
|||
} PyBytesObject;
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyBytes_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyBytesIter_Type;
|
||||
extern PyTypeObject PyBytes_Type;
|
||||
extern PyTypeObject PyBytesIter_Type;
|
||||
|
||||
#define PyBytes_Check(op) \
|
||||
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_BYTES_SUBCLASS)
|
||||
#define PyBytes_CheckExact(op) (Py_TYPE(op) == &PyBytes_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyBytes_FromStringAndSize(const char *, Py_ssize_t);
|
||||
PyAPI_FUNC(PyObject *) PyBytes_FromString(const char *);
|
||||
PyAPI_FUNC(PyObject *) PyBytes_FromObject(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyBytes_FromFormatV(const char*, va_list)
|
||||
PyObject * PyBytes_FromStringAndSize(const char *, Py_ssize_t);
|
||||
PyObject * PyBytes_FromString(const char *);
|
||||
PyObject * PyBytes_FromObject(PyObject *);
|
||||
PyObject * PyBytes_FromFormatV(const char*, va_list)
|
||||
Py_GCC_ATTRIBUTE((format(printf, 1, 0)));
|
||||
PyAPI_FUNC(PyObject *) PyBytes_FromFormat(const char*, ...)
|
||||
PyObject * PyBytes_FromFormat(const char*, ...)
|
||||
Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
|
||||
PyAPI_FUNC(Py_ssize_t) PyBytes_Size(PyObject *);
|
||||
PyAPI_FUNC(char *) PyBytes_AsString(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyBytes_Repr(PyObject *, int);
|
||||
PyAPI_FUNC(void) PyBytes_Concat(PyObject **, PyObject *);
|
||||
PyAPI_FUNC(void) PyBytes_ConcatAndDel(PyObject **, PyObject *);
|
||||
Py_ssize_t PyBytes_Size(PyObject *);
|
||||
char * PyBytes_AsString(PyObject *);
|
||||
PyObject * PyBytes_Repr(PyObject *, int);
|
||||
void PyBytes_Concat(PyObject **, PyObject *);
|
||||
void PyBytes_ConcatAndDel(PyObject **, PyObject *);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, Py_ssize_t);
|
||||
PyAPI_FUNC(PyObject*) _PyBytes_FormatEx(
|
||||
int _PyBytes_Resize(PyObject **, Py_ssize_t);
|
||||
PyObject* _PyBytes_FormatEx(
|
||||
const char *format,
|
||||
Py_ssize_t format_len,
|
||||
PyObject *args,
|
||||
int use_bytearray);
|
||||
PyAPI_FUNC(PyObject*) _PyBytes_FromHex(
|
||||
PyObject* _PyBytes_FromHex(
|
||||
PyObject *string,
|
||||
int use_bytearray);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyBytes_DecodeEscape(const char *, Py_ssize_t,
|
||||
PyObject * PyBytes_DecodeEscape(const char *, Py_ssize_t,
|
||||
const char *, Py_ssize_t,
|
||||
const char *);
|
||||
#ifndef Py_LIMITED_API
|
||||
/* Helper for PyBytes_DecodeEscape that detects invalid escape chars. */
|
||||
PyAPI_FUNC(PyObject *) _PyBytes_DecodeEscape(const char *, Py_ssize_t,
|
||||
PyObject * _PyBytes_DecodeEscape(const char *, Py_ssize_t,
|
||||
const char *, Py_ssize_t,
|
||||
const char *,
|
||||
const char **);
|
||||
|
@ -86,7 +87,7 @@ PyAPI_FUNC(PyObject *) _PyBytes_DecodeEscape(const char *, Py_ssize_t,
|
|||
/* _PyBytes_Join(sep, x) is like sep.join(x). sep must be PyBytesObject*,
|
||||
x must be an iterable object. */
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) _PyBytes_Join(PyObject *sep, PyObject *x);
|
||||
PyObject * _PyBytes_Join(PyObject *sep, PyObject *x);
|
||||
#endif
|
||||
|
||||
/* Provides access to the internal data buffer and size of a string
|
||||
|
@ -94,7 +95,7 @@ PyAPI_FUNC(PyObject *) _PyBytes_Join(PyObject *sep, PyObject *x);
|
|||
NULL as *len parameter will force the string buffer to be
|
||||
0-terminated (passing a string with embedded NULL characters will
|
||||
cause an exception). */
|
||||
PyAPI_FUNC(int) PyBytes_AsStringAndSize(
|
||||
int PyBytes_AsStringAndSize(
|
||||
PyObject *obj, /* string or Unicode object */
|
||||
char **s, /* pointer to buffer variable */
|
||||
Py_ssize_t *len /* pointer to length variable or NULL
|
||||
|
@ -106,7 +107,7 @@ PyAPI_FUNC(int) PyBytes_AsStringAndSize(
|
|||
into the string pointed to by buffer. For the argument descriptions,
|
||||
see Objects/stringlib/localeutil.h */
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(Py_ssize_t) _PyBytes_InsertThousandsGroupingLocale(char *buffer,
|
||||
Py_ssize_t _PyBytes_InsertThousandsGroupingLocale(char *buffer,
|
||||
Py_ssize_t n_buffer,
|
||||
char *digits,
|
||||
Py_ssize_t n_digits,
|
||||
|
@ -115,7 +116,7 @@ PyAPI_FUNC(Py_ssize_t) _PyBytes_InsertThousandsGroupingLocale(char *buffer,
|
|||
/* Using explicit passed-in values, insert the thousands grouping
|
||||
into the string pointed to by buffer. For the argument descriptions,
|
||||
see Objects/stringlib/localeutil.h */
|
||||
PyAPI_FUNC(Py_ssize_t) _PyBytes_InsertThousandsGrouping(char *buffer,
|
||||
Py_ssize_t _PyBytes_InsertThousandsGrouping(char *buffer,
|
||||
Py_ssize_t n_buffer,
|
||||
char *digits,
|
||||
Py_ssize_t n_digits,
|
||||
|
@ -162,21 +163,21 @@ typedef struct {
|
|||
|
||||
By default, the overallocation is disabled. Set the overallocate attribute
|
||||
to control the allocation of the buffer. */
|
||||
PyAPI_FUNC(void) _PyBytesWriter_Init(_PyBytesWriter *writer);
|
||||
void _PyBytesWriter_Init(_PyBytesWriter *writer);
|
||||
|
||||
/* Get the buffer content and reset the writer.
|
||||
Return a bytes object, or a bytearray object if use_bytearray is non-zero.
|
||||
Raise an exception and return NULL on error. */
|
||||
PyAPI_FUNC(PyObject *) _PyBytesWriter_Finish(_PyBytesWriter *writer,
|
||||
PyObject * _PyBytesWriter_Finish(_PyBytesWriter *writer,
|
||||
void *str);
|
||||
|
||||
/* Deallocate memory of a writer (clear its internal buffer). */
|
||||
PyAPI_FUNC(void) _PyBytesWriter_Dealloc(_PyBytesWriter *writer);
|
||||
void _PyBytesWriter_Dealloc(_PyBytesWriter *writer);
|
||||
|
||||
/* Allocate the buffer to write size bytes.
|
||||
Return the pointer to the beginning of buffer data.
|
||||
Raise an exception and return NULL on error. */
|
||||
PyAPI_FUNC(void*) _PyBytesWriter_Alloc(_PyBytesWriter *writer,
|
||||
void* _PyBytesWriter_Alloc(_PyBytesWriter *writer,
|
||||
Py_ssize_t size);
|
||||
|
||||
/* Ensure that the buffer is large enough to write *size* bytes.
|
||||
|
@ -185,7 +186,7 @@ PyAPI_FUNC(void*) _PyBytesWriter_Alloc(_PyBytesWriter *writer,
|
|||
str is the current pointer inside the buffer.
|
||||
Return the updated current pointer inside the buffer.
|
||||
Raise an exception and return NULL on error. */
|
||||
PyAPI_FUNC(void*) _PyBytesWriter_Prepare(_PyBytesWriter *writer,
|
||||
void* _PyBytesWriter_Prepare(_PyBytesWriter *writer,
|
||||
void *str,
|
||||
Py_ssize_t size);
|
||||
|
||||
|
@ -200,13 +201,13 @@ PyAPI_FUNC(void*) _PyBytesWriter_Prepare(_PyBytesWriter *writer,
|
|||
|
||||
See also _PyBytesWriter_Prepare().
|
||||
*/
|
||||
PyAPI_FUNC(void*) _PyBytesWriter_Resize(_PyBytesWriter *writer,
|
||||
void* _PyBytesWriter_Resize(_PyBytesWriter *writer,
|
||||
void *str,
|
||||
Py_ssize_t size);
|
||||
|
||||
/* Write bytes.
|
||||
Raise an exception and return NULL on error. */
|
||||
PyAPI_FUNC(void*) _PyBytesWriter_WriteBytes(_PyBytesWriter *writer,
|
||||
void* _PyBytesWriter_WriteBytes(_PyBytesWriter *writer,
|
||||
void *str,
|
||||
const void *bytes,
|
||||
Py_ssize_t size);
|
||||
|
|
9
third_party/python/Include/cellobject.h
vendored
9
third_party/python/Include/cellobject.h
vendored
|
@ -1,6 +1,7 @@
|
|||
#ifndef Py_LIMITED_API
|
||||
#ifndef Py_CELLOBJECT_H
|
||||
#define Py_CELLOBJECT_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -9,13 +10,13 @@ typedef struct {
|
|||
PyObject *ob_ref; /* Content of the cell or NULL when empty */
|
||||
} PyCellObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyCell_Type;
|
||||
extern PyTypeObject PyCell_Type;
|
||||
|
||||
#define PyCell_Check(op) (Py_TYPE(op) == &PyCell_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCell_New(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *);
|
||||
PyAPI_FUNC(int) PyCell_Set(PyObject *, PyObject *);
|
||||
PyObject * PyCell_New(PyObject *);
|
||||
PyObject * PyCell_Get(PyObject *);
|
||||
int PyCell_Set(PyObject *, PyObject *);
|
||||
|
||||
#define PyCell_GET(op) (((PyCellObject *)(op))->ob_ref)
|
||||
#define PyCell_SET(op, v) (((PyCellObject *)(op))->ob_ref = v)
|
||||
|
|
98
third_party/python/Include/ceval.h
vendored
98
third_party/python/Include/ceval.h
vendored
|
@ -1,53 +1,53 @@
|
|||
#ifndef Py_CEVAL_H
|
||||
#define Py_CEVAL_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/pystate.h"
|
||||
#include "third_party/python/Include/pythonrun.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
/* Interface to random parts in ceval.c */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
|
||||
PyObject * PyEval_CallObjectWithKeywords(
|
||||
PyObject *func, PyObject *args, PyObject *kwargs);
|
||||
|
||||
/* Inline this */
|
||||
#define PyEval_CallObject(func,arg) \
|
||||
PyEval_CallObjectWithKeywords(func, arg, (PyObject *)NULL)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyEval_CallFunction(PyObject *obj,
|
||||
const char *format, ...);
|
||||
PyAPI_FUNC(PyObject *) PyEval_CallMethod(PyObject *obj,
|
||||
const char *methodname,
|
||||
const char *format, ...);
|
||||
PyObject * PyEval_CallFunction(PyObject *, const char *, ...);
|
||||
PyObject * PyEval_CallMethod(PyObject *, const char *, const char *, ...);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
|
||||
PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
|
||||
PyAPI_FUNC(void) _PyEval_SetCoroutineWrapper(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) _PyEval_GetCoroutineWrapper(void);
|
||||
PyAPI_FUNC(void) _PyEval_SetAsyncGenFirstiter(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) _PyEval_GetAsyncGenFirstiter(void);
|
||||
PyAPI_FUNC(void) _PyEval_SetAsyncGenFinalizer(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) _PyEval_GetAsyncGenFinalizer(void);
|
||||
void PyEval_SetProfile(Py_tracefunc, PyObject *);
|
||||
void PyEval_SetTrace(Py_tracefunc, PyObject *);
|
||||
void _PyEval_SetCoroutineWrapper(PyObject *);
|
||||
PyObject * _PyEval_GetCoroutineWrapper(void);
|
||||
void _PyEval_SetAsyncGenFirstiter(PyObject *);
|
||||
PyObject * _PyEval_GetAsyncGenFirstiter(void);
|
||||
void _PyEval_SetAsyncGenFinalizer(PyObject *);
|
||||
PyObject * _PyEval_GetAsyncGenFinalizer(void);
|
||||
#endif
|
||||
|
||||
struct _frame; /* Avoid including frameobject.h */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void);
|
||||
PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void);
|
||||
PyAPI_FUNC(PyObject *) PyEval_GetLocals(void);
|
||||
PyAPI_FUNC(struct _frame *) PyEval_GetFrame(void);
|
||||
PyObject * PyEval_GetBuiltins(void);
|
||||
PyObject * PyEval_GetGlobals(void);
|
||||
PyObject * PyEval_GetLocals(void);
|
||||
struct _frame * PyEval_GetFrame(void);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
/* Helper to look up a builtin object */
|
||||
PyAPI_FUNC(PyObject *) _PyEval_GetBuiltinId(_Py_Identifier *);
|
||||
PyObject * _PyEval_GetBuiltinId(_Py_Identifier *);
|
||||
/* Look at the current frame's (if any) code's co_flags, and turn on
|
||||
the corresponding compiler flags in cf->cf_flags. Return 1 if any
|
||||
flag was set, else return 0. */
|
||||
PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf);
|
||||
int PyEval_MergeCompilerFlags(PyCompilerFlags *cf);
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg);
|
||||
PyAPI_FUNC(void) _PyEval_SignalReceived(void);
|
||||
PyAPI_FUNC(int) Py_MakePendingCalls(void);
|
||||
int Py_AddPendingCall(int (*func)(void *), void *arg);
|
||||
void _PyEval_SignalReceived(void);
|
||||
int Py_MakePendingCalls(void);
|
||||
|
||||
/* Protection against deeply nested recursive calls
|
||||
|
||||
|
@ -74,8 +74,8 @@ PyAPI_FUNC(int) Py_MakePendingCalls(void);
|
|||
http://mail.python.org/pipermail/python-dev/2008-August/082106.html
|
||||
for some observations.
|
||||
*/
|
||||
PyAPI_FUNC(void) Py_SetRecursionLimit(int);
|
||||
PyAPI_FUNC(int) Py_GetRecursionLimit(void);
|
||||
void Py_SetRecursionLimit(int);
|
||||
int Py_GetRecursionLimit(void);
|
||||
|
||||
#define Py_EnterRecursiveCall(where) \
|
||||
(_Py_MakeRecCheck(PyThreadState_GET()->recursion_depth) && \
|
||||
|
@ -84,8 +84,8 @@ PyAPI_FUNC(int) Py_GetRecursionLimit(void);
|
|||
do{ if(_Py_MakeEndRecCheck(PyThreadState_GET()->recursion_depth)) \
|
||||
PyThreadState_GET()->overflowed = 0; \
|
||||
} while(0)
|
||||
PyAPI_FUNC(int) _Py_CheckRecursiveCall(const char *where);
|
||||
PyAPI_DATA(int) _Py_CheckRecursionLimit;
|
||||
int _Py_CheckRecursiveCall(const char *where);
|
||||
extern int _Py_CheckRecursionLimit;
|
||||
|
||||
#ifdef USE_STACKCHECK
|
||||
/* With USE_STACKCHECK, we artificially decrement the recursion limit in order
|
||||
|
@ -118,14 +118,14 @@ PyAPI_DATA(int) _Py_CheckRecursionLimit;
|
|||
PyThreadState_GET()->recursion_critical = _old; \
|
||||
} while(0);
|
||||
|
||||
PyAPI_FUNC(const char *) PyEval_GetFuncName(PyObject *);
|
||||
PyAPI_FUNC(const char *) PyEval_GetFuncDesc(PyObject *);
|
||||
const char * PyEval_GetFuncName(PyObject *);
|
||||
const char * PyEval_GetFuncDesc(PyObject *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyEval_GetCallStats(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyEval_EvalFrame(struct _frame *);
|
||||
PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(struct _frame *f, int exc);
|
||||
PyObject * PyEval_GetCallStats(PyObject *);
|
||||
PyObject * PyEval_EvalFrame(struct _frame *);
|
||||
PyObject * PyEval_EvalFrameEx(struct _frame *f, int exc);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) _PyEval_EvalFrameDefault(struct _frame *f, int exc);
|
||||
PyObject * _PyEval_EvalFrameDefault(struct _frame *f, int exc);
|
||||
#endif
|
||||
|
||||
/* Interface for threads.
|
||||
|
@ -173,29 +173,29 @@ PyAPI_FUNC(PyObject *) _PyEval_EvalFrameDefault(struct _frame *f, int exc);
|
|||
mechanism!
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(PyThreadState *) PyEval_SaveThread(void);
|
||||
PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *);
|
||||
PyThreadState * PyEval_SaveThread(void);
|
||||
void PyEval_RestoreThread(PyThreadState *);
|
||||
|
||||
#ifdef WITH_THREAD
|
||||
|
||||
PyAPI_FUNC(int) PyEval_ThreadsInitialized(void);
|
||||
PyAPI_FUNC(void) PyEval_InitThreads(void);
|
||||
int PyEval_ThreadsInitialized(void);
|
||||
void PyEval_InitThreads(void);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) _PyEval_FiniThreads(void);
|
||||
void _PyEval_FiniThreads(void);
|
||||
#endif /* !Py_LIMITED_API */
|
||||
PyAPI_FUNC(void) PyEval_AcquireLock(void);
|
||||
PyAPI_FUNC(void) PyEval_ReleaseLock(void);
|
||||
PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate);
|
||||
PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);
|
||||
PyAPI_FUNC(void) PyEval_ReInitThreads(void);
|
||||
void PyEval_AcquireLock(void);
|
||||
void PyEval_ReleaseLock(void);
|
||||
void PyEval_AcquireThread(PyThreadState *tstate);
|
||||
void PyEval_ReleaseThread(PyThreadState *tstate);
|
||||
void PyEval_ReInitThreads(void);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) _PyEval_SetSwitchInterval(unsigned long microseconds);
|
||||
PyAPI_FUNC(unsigned long) _PyEval_GetSwitchInterval(void);
|
||||
void _PyEval_SetSwitchInterval(unsigned long microseconds);
|
||||
unsigned long _PyEval_GetSwitchInterval(void);
|
||||
#endif
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(Py_ssize_t) _PyEval_RequestCodeExtraIndex(freefunc);
|
||||
Py_ssize_t _PyEval_RequestCodeExtraIndex(freefunc);
|
||||
#endif
|
||||
|
||||
#define Py_BEGIN_ALLOW_THREADS { \
|
||||
|
@ -216,9 +216,9 @@ PyAPI_FUNC(Py_ssize_t) _PyEval_RequestCodeExtraIndex(freefunc);
|
|||
#endif /* !WITH_THREAD */
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *);
|
||||
PyAPI_FUNC(int) _PyEval_SliceIndexNotNone(PyObject *, Py_ssize_t *);
|
||||
PyAPI_FUNC(void) _PyEval_SignalAsyncExc(void);
|
||||
int _PyEval_SliceIndex(PyObject *, Py_ssize_t *);
|
||||
int _PyEval_SliceIndexNotNone(PyObject *, Py_ssize_t *);
|
||||
void _PyEval_SignalAsyncExc(void);
|
||||
#endif
|
||||
|
||||
/* Masks and values used by FORMAT_VALUE opcode. */
|
||||
|
|
17
third_party/python/Include/classobject.h
vendored
17
third_party/python/Include/classobject.h
vendored
|
@ -1,6 +1,7 @@
|
|||
#ifndef Py_LIMITED_API
|
||||
#ifndef Py_CLASSOBJECT_H
|
||||
#define Py_CLASSOBJECT_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -11,14 +12,14 @@ typedef struct {
|
|||
PyObject *im_weakreflist; /* List of weak references */
|
||||
} PyMethodObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyMethod_Type;
|
||||
extern PyTypeObject PyMethod_Type;
|
||||
|
||||
#define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *);
|
||||
PyObject * PyMethod_New(PyObject *, PyObject *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *);
|
||||
PyObject * PyMethod_Function(PyObject *);
|
||||
PyObject * PyMethod_Self(PyObject *);
|
||||
|
||||
/* Macros for direct access to these values. Type checks are *not*
|
||||
done, so use with care. */
|
||||
|
@ -27,19 +28,19 @@ PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *);
|
|||
#define PyMethod_GET_SELF(meth) \
|
||||
(((PyMethodObject *)meth) -> im_self)
|
||||
|
||||
PyAPI_FUNC(int) PyMethod_ClearFreeList(void);
|
||||
int PyMethod_ClearFreeList(void);
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyObject *func;
|
||||
} PyInstanceMethodObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyInstanceMethod_Type;
|
||||
extern PyTypeObject PyInstanceMethod_Type;
|
||||
|
||||
#define PyInstanceMethod_Check(op) ((op)->ob_type == &PyInstanceMethod_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyInstanceMethod_New(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *);
|
||||
PyObject * PyInstanceMethod_New(PyObject *);
|
||||
PyObject * PyInstanceMethod_Function(PyObject *);
|
||||
|
||||
/* Macros for direct access to these values. Type checks are *not*
|
||||
done, so use with care. */
|
||||
|
|
142
third_party/python/Include/code.h
vendored
142
third_party/python/Include/code.h
vendored
|
@ -1,84 +1,83 @@
|
|||
#ifndef Py_LIMITED_API
|
||||
#ifndef Py_CODE_H
|
||||
#define Py_CODE_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
typedef uint16_t _Py_CODEUNIT;
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
# define _Py_OPCODE(word) ((word) >> 8)
|
||||
# define _Py_OPARG(word) ((word) & 255)
|
||||
#define _Py_OPCODE(word) ((word) >> 8)
|
||||
#define _Py_OPARG(word) ((word)&255)
|
||||
#else
|
||||
# define _Py_OPCODE(word) ((word) & 255)
|
||||
# define _Py_OPARG(word) ((word) >> 8)
|
||||
#define _Py_OPCODE(word) ((word)&255)
|
||||
#define _Py_OPARG(word) ((word) >> 8)
|
||||
#endif
|
||||
|
||||
/* Bytecode object */
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
int co_argcount; /* #arguments, except *args */
|
||||
int co_kwonlyargcount; /* #keyword only arguments */
|
||||
int co_nlocals; /* #local variables */
|
||||
int co_stacksize; /* #entries needed for evaluation stack */
|
||||
int co_flags; /* CO_..., see below */
|
||||
int co_firstlineno; /* first source line number */
|
||||
PyObject *co_code; /* instruction opcodes */
|
||||
PyObject *co_consts; /* list (constants used) */
|
||||
PyObject *co_names; /* list of strings (names used) */
|
||||
PyObject *co_varnames; /* tuple of strings (local variable names) */
|
||||
PyObject *co_freevars; /* tuple of strings (free variable names) */
|
||||
PyObject *co_cellvars; /* tuple of strings (cell variable names) */
|
||||
/* The rest aren't used in either hash or comparisons, except for co_name,
|
||||
used in both. This is done to preserve the name and line number
|
||||
for tracebacks and debuggers; otherwise, constant de-duplication
|
||||
would collapse identical functions/lambdas defined on different lines.
|
||||
*/
|
||||
unsigned char *co_cell2arg; /* Maps cell vars which are arguments. */
|
||||
PyObject *co_filename; /* unicode (where it was loaded from) */
|
||||
PyObject *co_name; /* unicode (name, for reference) */
|
||||
PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) See
|
||||
Objects/lnotab_notes.txt for details. */
|
||||
void *co_zombieframe; /* for optimization only (see frameobject.c) */
|
||||
PyObject *co_weakreflist; /* to support weakrefs to code objects */
|
||||
/* Scratch space for extra data relating to the code object.
|
||||
Type is a void* to keep the format private in codeobject.c to force
|
||||
people to go through the proper APIs. */
|
||||
void *co_extra;
|
||||
PyObject_HEAD int co_argcount; /* #arguments, except *args */
|
||||
int co_kwonlyargcount; /* #keyword only arguments */
|
||||
int co_nlocals; /* #local variables */
|
||||
int co_stacksize; /* #entries needed for evaluation stack */
|
||||
int co_flags; /* CO_..., see below */
|
||||
int co_firstlineno; /* first source line number */
|
||||
PyObject *co_code; /* instruction opcodes */
|
||||
PyObject *co_consts; /* list (constants used) */
|
||||
PyObject *co_names; /* list of strings (names used) */
|
||||
PyObject *co_varnames; /* tuple of strings (local variable names) */
|
||||
PyObject *co_freevars; /* tuple of strings (free variable names) */
|
||||
PyObject *co_cellvars; /* tuple of strings (cell variable names) */
|
||||
/* The rest aren't used in either hash or comparisons, except for co_name,
|
||||
used in both. This is done to preserve the name and line number
|
||||
for tracebacks and debuggers; otherwise, constant de-duplication
|
||||
would collapse identical functions/lambdas defined on different lines.
|
||||
*/
|
||||
unsigned char *co_cell2arg; /* Maps cell vars which are arguments. */
|
||||
PyObject *co_filename; /* unicode (where it was loaded from) */
|
||||
PyObject *co_name; /* unicode (name, for reference) */
|
||||
PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) See
|
||||
Objects/lnotab_notes.txt for details. */
|
||||
void *co_zombieframe; /* for optimization only (see frameobject.c) */
|
||||
PyObject *co_weakreflist; /* to support weakrefs to code objects */
|
||||
/* Scratch space for extra data relating to the code object.
|
||||
Type is a void* to keep the format private in codeobject.c to force
|
||||
people to go through the proper APIs. */
|
||||
void *co_extra;
|
||||
} PyCodeObject;
|
||||
|
||||
/* Masks for co_flags above */
|
||||
#define CO_OPTIMIZED 0x0001
|
||||
#define CO_NEWLOCALS 0x0002
|
||||
#define CO_VARARGS 0x0004
|
||||
#define CO_VARKEYWORDS 0x0008
|
||||
#define CO_NESTED 0x0010
|
||||
#define CO_GENERATOR 0x0020
|
||||
#define CO_OPTIMIZED 0x0001
|
||||
#define CO_NEWLOCALS 0x0002
|
||||
#define CO_VARARGS 0x0004
|
||||
#define CO_VARKEYWORDS 0x0008
|
||||
#define CO_NESTED 0x0010
|
||||
#define CO_GENERATOR 0x0020
|
||||
/* The CO_NOFREE flag is set if there are no free or cell variables.
|
||||
This information is redundant, but it allows a single flag test
|
||||
to determine whether there is any extra work to be done when the
|
||||
call frame it setup.
|
||||
*/
|
||||
#define CO_NOFREE 0x0040
|
||||
#define CO_NOFREE 0x0040
|
||||
|
||||
/* The CO_COROUTINE flag is set for coroutine functions (defined with
|
||||
``async def`` keywords) */
|
||||
#define CO_COROUTINE 0x0080
|
||||
#define CO_ITERABLE_COROUTINE 0x0100
|
||||
#define CO_ASYNC_GENERATOR 0x0200
|
||||
#define CO_COROUTINE 0x0080
|
||||
#define CO_ITERABLE_COROUTINE 0x0100
|
||||
#define CO_ASYNC_GENERATOR 0x0200
|
||||
|
||||
/* These are no longer used. */
|
||||
#if 0
|
||||
#define CO_GENERATOR_ALLOWED 0x1000
|
||||
#define CO_GENERATOR_ALLOWED 0x1000
|
||||
#endif
|
||||
#define CO_FUTURE_DIVISION 0x2000
|
||||
#define CO_FUTURE_ABSOLUTE_IMPORT 0x4000 /* do absolute imports by default */
|
||||
#define CO_FUTURE_WITH_STATEMENT 0x8000
|
||||
#define CO_FUTURE_PRINT_FUNCTION 0x10000
|
||||
#define CO_FUTURE_DIVISION 0x2000
|
||||
#define CO_FUTURE_ABSOLUTE_IMPORT 0x4000 /* do absolute imports by default */
|
||||
#define CO_FUTURE_WITH_STATEMENT 0x8000
|
||||
#define CO_FUTURE_PRINT_FUNCTION 0x10000
|
||||
#define CO_FUTURE_UNICODE_LITERALS 0x20000
|
||||
|
||||
#define CO_FUTURE_BARRY_AS_BDFL 0x40000
|
||||
#define CO_FUTURE_GENERATOR_STOP 0x80000
|
||||
#define CO_FUTURE_GENERATOR_STOP 0x80000
|
||||
|
||||
/* This value is found in the co_cell2arg array when the associated cell
|
||||
variable does not correspond to an argument. The maximum number of
|
||||
|
@ -92,39 +91,37 @@ typedef struct {
|
|||
|
||||
#define CO_MAXBLOCKS 20 /* Max static block nesting within a function */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyCode_Type;
|
||||
extern PyTypeObject PyCode_Type;
|
||||
|
||||
#define PyCode_Check(op) (Py_TYPE(op) == &PyCode_Type)
|
||||
#define PyCode_Check(op) (Py_TYPE(op) == &PyCode_Type)
|
||||
#define PyCode_GetNumFree(op) (PyTuple_GET_SIZE((op)->co_freevars))
|
||||
|
||||
/* Public interface */
|
||||
PyAPI_FUNC(PyCodeObject *) PyCode_New(
|
||||
int, int, int, int, int, PyObject *, PyObject *,
|
||||
PyObject *, PyObject *, PyObject *, PyObject *,
|
||||
PyObject *, PyObject *, int, PyObject *);
|
||||
/* same as struct above */
|
||||
PyCodeObject *PyCode_New(int, int, int, int, int, PyObject *, PyObject *,
|
||||
PyObject *, PyObject *, PyObject *, PyObject *,
|
||||
PyObject *, PyObject *, int, PyObject *);
|
||||
/* same as struct above */
|
||||
|
||||
/* Creates a new empty code object with the specified source location. */
|
||||
PyAPI_FUNC(PyCodeObject *)
|
||||
PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno);
|
||||
PyCodeObject *PyCode_NewEmpty(const char *filename, const char *funcname,
|
||||
int firstlineno);
|
||||
|
||||
/* Return the line number associated with the specified bytecode index
|
||||
in this code object. If you just need the line number of a frame,
|
||||
use PyFrame_GetLineNumber() instead. */
|
||||
PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int);
|
||||
int PyCode_Addr2Line(PyCodeObject *, int);
|
||||
|
||||
/* for internal use only */
|
||||
typedef struct _addr_pair {
|
||||
int ap_lower;
|
||||
int ap_upper;
|
||||
int ap_lower;
|
||||
int ap_upper;
|
||||
} PyAddrPair;
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
/* Update *bounds to describe the first and one-past-the-last instructions in the
|
||||
same line as lasti. Return the number of that line.
|
||||
/* Update *bounds to describe the first and one-past-the-last instructions in
|
||||
the same line as lasti. Return the number of that line.
|
||||
*/
|
||||
PyAPI_FUNC(int) _PyCode_CheckLineNumber(PyCodeObject* co,
|
||||
int lasti, PyAddrPair *bounds);
|
||||
int _PyCode_CheckLineNumber(PyCodeObject *co, int lasti, PyAddrPair *bounds);
|
||||
|
||||
/* Create a comparable key used to compare constants taking in account the
|
||||
* object type. It is used to make sure types are not coerced (e.g., float and
|
||||
|
@ -133,18 +130,15 @@ PyAPI_FUNC(int) _PyCode_CheckLineNumber(PyCodeObject* co,
|
|||
* Return (type(obj), obj, ...): a tuple with variable size (at least 2 items)
|
||||
* depending on the type and the value. The type is the first item to not
|
||||
* compare bytes and str which can raise a BytesWarning exception. */
|
||||
PyAPI_FUNC(PyObject*) _PyCode_ConstantKey(PyObject *obj);
|
||||
PyObject *_PyCode_ConstantKey(PyObject *obj);
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(PyObject*) PyCode_Optimize(PyObject *code, PyObject* consts,
|
||||
PyObject *names, PyObject *lnotab);
|
||||
|
||||
PyObject *PyCode_Optimize(PyObject *code, PyObject *consts, PyObject *names,
|
||||
PyObject *lnotab);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(int) _PyCode_GetExtra(PyObject *code, Py_ssize_t index,
|
||||
void **extra);
|
||||
PyAPI_FUNC(int) _PyCode_SetExtra(PyObject *code, Py_ssize_t index,
|
||||
void *extra);
|
||||
int _PyCode_GetExtra(PyObject *code, Py_ssize_t index, void **extra);
|
||||
int _PyCode_SetExtra(PyObject *code, Py_ssize_t index, void *extra);
|
||||
#endif
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
53
third_party/python/Include/codecs.h
vendored
53
third_party/python/Include/codecs.h
vendored
|
@ -1,5 +1,6 @@
|
|||
#ifndef Py_CODECREGISTRY_H
|
||||
#define Py_CODECREGISTRY_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -22,7 +23,7 @@ Copyright (c) Corporation for National Research Initiatives.
|
|||
|
||||
The search_function's refcount is incremented by this function. */
|
||||
|
||||
PyAPI_FUNC(int) PyCodec_Register(
|
||||
int PyCodec_Register(
|
||||
PyObject *search_function
|
||||
);
|
||||
|
||||
|
@ -45,11 +46,11 @@ PyAPI_FUNC(int) PyCodec_Register(
|
|||
*/
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) _PyCodec_Lookup(
|
||||
PyObject * _PyCodec_Lookup(
|
||||
const char *encoding
|
||||
);
|
||||
|
||||
PyAPI_FUNC(int) _PyCodec_Forget(
|
||||
int _PyCodec_Forget(
|
||||
const char *encoding
|
||||
);
|
||||
#endif
|
||||
|
@ -61,7 +62,7 @@ PyAPI_FUNC(int) _PyCodec_Forget(
|
|||
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(int) PyCodec_KnownEncoding(
|
||||
int PyCodec_KnownEncoding(
|
||||
const char *encoding
|
||||
);
|
||||
|
||||
|
@ -75,7 +76,7 @@ PyAPI_FUNC(int) PyCodec_KnownEncoding(
|
|||
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_Encode(
|
||||
PyObject * PyCodec_Encode(
|
||||
PyObject *object,
|
||||
const char *encoding,
|
||||
const char *errors
|
||||
|
@ -91,7 +92,7 @@ PyAPI_FUNC(PyObject *) PyCodec_Encode(
|
|||
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_Decode(
|
||||
PyObject * PyCodec_Decode(
|
||||
PyObject *object,
|
||||
const char *encoding,
|
||||
const char *errors
|
||||
|
@ -111,18 +112,18 @@ PyAPI_FUNC(PyObject *) PyCodec_Decode(
|
|||
in Python 3.5+?
|
||||
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) _PyCodec_LookupTextEncoding(
|
||||
PyObject * _PyCodec_LookupTextEncoding(
|
||||
const char *encoding,
|
||||
const char *alternate_command
|
||||
);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyCodec_EncodeText(
|
||||
PyObject * _PyCodec_EncodeText(
|
||||
PyObject *object,
|
||||
const char *encoding,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyCodec_DecodeText(
|
||||
PyObject * _PyCodec_DecodeText(
|
||||
PyObject *object,
|
||||
const char *encoding,
|
||||
const char *errors
|
||||
|
@ -131,12 +132,12 @@ PyAPI_FUNC(PyObject *) _PyCodec_DecodeText(
|
|||
/* These two aren't actually text encoding specific, but _io.TextIOWrapper
|
||||
* is the only current API consumer.
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) _PyCodecInfo_GetIncrementalDecoder(
|
||||
PyObject * _PyCodecInfo_GetIncrementalDecoder(
|
||||
PyObject *codec_info,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyCodecInfo_GetIncrementalEncoder(
|
||||
PyObject * _PyCodecInfo_GetIncrementalEncoder(
|
||||
PyObject *codec_info,
|
||||
const char *errors
|
||||
);
|
||||
|
@ -154,33 +155,33 @@ PyAPI_FUNC(PyObject *) _PyCodecInfo_GetIncrementalEncoder(
|
|||
|
||||
/* Get an encoder function for the given encoding. */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_Encoder(
|
||||
PyObject * PyCodec_Encoder(
|
||||
const char *encoding
|
||||
);
|
||||
|
||||
/* Get a decoder function for the given encoding. */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_Decoder(
|
||||
PyObject * PyCodec_Decoder(
|
||||
const char *encoding
|
||||
);
|
||||
|
||||
/* Get an IncrementalEncoder object for the given encoding. */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_IncrementalEncoder(
|
||||
PyObject * PyCodec_IncrementalEncoder(
|
||||
const char *encoding,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
/* Get an IncrementalDecoder object function for the given encoding. */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_IncrementalDecoder(
|
||||
PyObject * PyCodec_IncrementalDecoder(
|
||||
const char *encoding,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
/* Get a StreamReader factory function for the given encoding. */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_StreamReader(
|
||||
PyObject * PyCodec_StreamReader(
|
||||
const char *encoding,
|
||||
PyObject *stream,
|
||||
const char *errors
|
||||
|
@ -188,7 +189,7 @@ PyAPI_FUNC(PyObject *) PyCodec_StreamReader(
|
|||
|
||||
/* Get a StreamWriter factory function for the given encoding. */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_StreamWriter(
|
||||
PyObject * PyCodec_StreamWriter(
|
||||
const char *encoding,
|
||||
PyObject *stream,
|
||||
const char *errors
|
||||
|
@ -202,35 +203,35 @@ PyAPI_FUNC(PyObject *) PyCodec_StreamWriter(
|
|||
callback name, when name is specified as the error parameter
|
||||
in the call to the encode/decode function.
|
||||
Return 0 on success, -1 on error */
|
||||
PyAPI_FUNC(int) PyCodec_RegisterError(const char *name, PyObject *error);
|
||||
int PyCodec_RegisterError(const char *name, PyObject *error);
|
||||
|
||||
/* Lookup the error handling callback function registered under the given
|
||||
name. As a special case NULL can be passed, in which case
|
||||
the error handling callback for "strict" will be returned. */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_LookupError(const char *name);
|
||||
PyObject * PyCodec_LookupError(const char *name);
|
||||
|
||||
/* raise exc as an exception */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_StrictErrors(PyObject *exc);
|
||||
PyObject * PyCodec_StrictErrors(PyObject *exc);
|
||||
|
||||
/* ignore the unicode error, skipping the faulty input */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_IgnoreErrors(PyObject *exc);
|
||||
PyObject * PyCodec_IgnoreErrors(PyObject *exc);
|
||||
|
||||
/* replace the unicode encode error with ? or U+FFFD */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_ReplaceErrors(PyObject *exc);
|
||||
PyObject * PyCodec_ReplaceErrors(PyObject *exc);
|
||||
|
||||
/* replace the unicode encode error with XML character references */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_XMLCharRefReplaceErrors(PyObject *exc);
|
||||
PyObject * PyCodec_XMLCharRefReplaceErrors(PyObject *exc);
|
||||
|
||||
/* replace the unicode encode error with backslash escapes (\x, \u and \U) */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_BackslashReplaceErrors(PyObject *exc);
|
||||
PyObject * PyCodec_BackslashReplaceErrors(PyObject *exc);
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||
/* replace the unicode encode error with backslash escapes (\N, \x, \u and \U) */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_NameReplaceErrors(PyObject *exc);
|
||||
PyObject * PyCodec_NameReplaceErrors(PyObject *exc);
|
||||
#endif
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_DATA(const char *) Py_hexdigits;
|
||||
extern const char * Py_hexdigits;
|
||||
#endif
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
16
third_party/python/Include/compile.h
vendored
16
third_party/python/Include/compile.h
vendored
|
@ -1,6 +1,8 @@
|
|||
#ifndef Py_COMPILE_H
|
||||
#define Py_COMPILE_H
|
||||
#include "third_party/python/Include/code.h"
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/pythonrun.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
#define Py_single_input 256
|
||||
|
@ -12,7 +14,7 @@ COSMOPOLITAN_C_START_
|
|||
|
||||
/* Public interface */
|
||||
struct _node; /* Declare the existence of this type */
|
||||
PyAPI_FUNC(PyCodeObject *) PyNode_Compile(struct _node *, const char *);
|
||||
PyCodeObject * PyNode_Compile(struct _node *, const char *);
|
||||
|
||||
/* Future feature support */
|
||||
|
||||
|
@ -33,32 +35,32 @@ typedef struct {
|
|||
|
||||
struct _mod; /* Declare the existence of this type */
|
||||
#define PyAST_Compile(mod, s, f, ar) PyAST_CompileEx(mod, s, f, -1, ar)
|
||||
PyAPI_FUNC(PyCodeObject *) PyAST_CompileEx(
|
||||
PyCodeObject * PyAST_CompileEx(
|
||||
struct _mod *mod,
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
PyCompilerFlags *flags,
|
||||
int optimize,
|
||||
PyArena *arena);
|
||||
PyAPI_FUNC(PyCodeObject *) PyAST_CompileObject(
|
||||
PyCodeObject * PyAST_CompileObject(
|
||||
struct _mod *mod,
|
||||
PyObject *filename,
|
||||
PyCompilerFlags *flags,
|
||||
int optimize,
|
||||
PyArena *arena);
|
||||
PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromAST(
|
||||
PyFutureFeatures * PyFuture_FromAST(
|
||||
struct _mod * mod,
|
||||
const char *filename /* decoded from the filesystem encoding */
|
||||
);
|
||||
PyAPI_FUNC(PyFutureFeatures *) PyFuture_FromASTObject(
|
||||
PyFutureFeatures * PyFuture_FromASTObject(
|
||||
struct _mod * mod,
|
||||
PyObject *filename
|
||||
);
|
||||
|
||||
/* _Py_Mangle is defined in compile.c */
|
||||
PyAPI_FUNC(PyObject*) _Py_Mangle(PyObject *p, PyObject *name);
|
||||
PyObject* _Py_Mangle(PyObject *p, PyObject *name);
|
||||
|
||||
#define PY_INVALID_STACK_EFFECT INT_MAX
|
||||
PyAPI_FUNC(int) PyCompile_OpcodeStackEffect(int opcode, int oparg);
|
||||
int PyCompile_OpcodeStackEffect(int opcode, int oparg);
|
||||
|
||||
#endif /* !Py_LIMITED_API */
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
30
third_party/python/Include/complexobject.h
vendored
30
third_party/python/Include/complexobject.h
vendored
|
@ -1,5 +1,7 @@
|
|||
#ifndef Py_COMPLEXOBJECT_H
|
||||
#define Py_COMPLEXOBJECT_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/unicodeobject.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -11,13 +13,13 @@ typedef struct {
|
|||
|
||||
/* Operations on complex numbers from complexmodule.c */
|
||||
|
||||
PyAPI_FUNC(Py_complex) _Py_c_sum(Py_complex, Py_complex);
|
||||
PyAPI_FUNC(Py_complex) _Py_c_diff(Py_complex, Py_complex);
|
||||
PyAPI_FUNC(Py_complex) _Py_c_neg(Py_complex);
|
||||
PyAPI_FUNC(Py_complex) _Py_c_prod(Py_complex, Py_complex);
|
||||
PyAPI_FUNC(Py_complex) _Py_c_quot(Py_complex, Py_complex);
|
||||
PyAPI_FUNC(Py_complex) _Py_c_pow(Py_complex, Py_complex);
|
||||
PyAPI_FUNC(double) _Py_c_abs(Py_complex);
|
||||
Py_complex _Py_c_sum(Py_complex, Py_complex);
|
||||
Py_complex _Py_c_diff(Py_complex, Py_complex);
|
||||
Py_complex _Py_c_neg(Py_complex);
|
||||
Py_complex _Py_c_prod(Py_complex, Py_complex);
|
||||
Py_complex _Py_c_quot(Py_complex, Py_complex);
|
||||
Py_complex _Py_c_pow(Py_complex, Py_complex);
|
||||
double _Py_c_abs(Py_complex);
|
||||
#endif
|
||||
|
||||
/* Complex object interface */
|
||||
|
@ -33,26 +35,26 @@ typedef struct {
|
|||
} PyComplexObject;
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyComplex_Type;
|
||||
extern PyTypeObject PyComplex_Type;
|
||||
|
||||
#define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
|
||||
#define PyComplex_CheckExact(op) (Py_TYPE(op) == &PyComplex_Type)
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
|
||||
PyObject * PyComplex_FromCComplex(Py_complex);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag);
|
||||
PyObject * PyComplex_FromDoubles(double real, double imag);
|
||||
|
||||
PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op);
|
||||
PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op);
|
||||
double PyComplex_RealAsDouble(PyObject *op);
|
||||
double PyComplex_ImagAsDouble(PyObject *op);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op);
|
||||
Py_complex PyComplex_AsCComplex(PyObject *op);
|
||||
#endif
|
||||
|
||||
/* Format the object based on the format_spec, as defined in PEP 3101
|
||||
(Advanced String Formatting). */
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(int) _PyComplex_FormatAdvancedWriter(
|
||||
int _PyComplex_FormatAdvancedWriter(
|
||||
_PyUnicodeWriter *writer,
|
||||
PyObject *obj,
|
||||
PyObject *format_spec,
|
||||
|
|
1
third_party/python/Include/datetime.h
vendored
1
third_party/python/Include/datetime.h
vendored
|
@ -1,6 +1,7 @@
|
|||
#ifndef Py_LIMITED_API
|
||||
#ifndef DATETIME_H
|
||||
#define DATETIME_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
|
33
third_party/python/Include/descrobject.h
vendored
33
third_party/python/Include/descrobject.h
vendored
|
@ -1,5 +1,8 @@
|
|||
#ifndef Py_DESCROBJECT_H
|
||||
#define Py_DESCROBJECT_H
|
||||
#include "third_party/python/Include/methodobject.h"
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/pyport.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -70,34 +73,34 @@ typedef struct {
|
|||
} PyWrapperDescrObject;
|
||||
#endif /* Py_LIMITED_API */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyClassMethodDescr_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyMemberDescr_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyMethodDescr_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
|
||||
extern PyTypeObject PyClassMethodDescr_Type;
|
||||
extern PyTypeObject PyGetSetDescr_Type;
|
||||
extern PyTypeObject PyMemberDescr_Type;
|
||||
extern PyTypeObject PyMethodDescr_Type;
|
||||
extern PyTypeObject PyWrapperDescr_Type;
|
||||
extern PyTypeObject PyDictProxy_Type;
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_DATA(PyTypeObject) _PyMethodWrapper_Type;
|
||||
extern PyTypeObject _PyMethodWrapper_Type;
|
||||
#endif /* Py_LIMITED_API */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
|
||||
PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);
|
||||
PyObject * PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
|
||||
PyObject * PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);
|
||||
struct PyMemberDef; /* forward declaration for following prototype */
|
||||
PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *,
|
||||
PyObject * PyDescr_NewMember(PyTypeObject *,
|
||||
struct PyMemberDef *);
|
||||
PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *,
|
||||
PyObject * PyDescr_NewGetSet(PyTypeObject *,
|
||||
struct PyGetSetDef *);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
|
||||
PyObject * PyDescr_NewWrapper(PyTypeObject *,
|
||||
struct wrapperbase *, void *);
|
||||
#define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL)
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *);
|
||||
PyObject * PyDictProxy_New(PyObject *);
|
||||
PyObject * PyWrapper_New(PyObject *, PyObject *);
|
||||
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyProperty_Type;
|
||||
extern PyTypeObject PyProperty_Type;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !Py_DESCROBJECT_H */
|
||||
|
|
93
third_party/python/Include/dictobject.h
vendored
93
third_party/python/Include/dictobject.h
vendored
|
@ -1,5 +1,6 @@
|
|||
#ifndef Py_DICTOBJECT_H
|
||||
#define Py_DICTOBJECT_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -45,13 +46,13 @@ typedef struct {
|
|||
|
||||
#endif /* Py_LIMITED_API */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyDict_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictIterKey_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictIterValue_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictIterItem_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictKeys_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictItems_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictValues_Type;
|
||||
extern PyTypeObject PyDict_Type;
|
||||
extern PyTypeObject PyDictIterKey_Type;
|
||||
extern PyTypeObject PyDictIterValue_Type;
|
||||
extern PyTypeObject PyDictIterItem_Type;
|
||||
extern PyTypeObject PyDictKeys_Type;
|
||||
extern PyTypeObject PyDictItems_Type;
|
||||
extern PyTypeObject PyDictValues_Type;
|
||||
|
||||
#define PyDict_Check(op) \
|
||||
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS)
|
||||
|
@ -64,71 +65,71 @@ PyAPI_DATA(PyTypeObject) PyDictValues_Type;
|
|||
(PyDictKeys_Check(op) || PyDictItems_Check(op))
|
||||
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyDict_New(void);
|
||||
PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key);
|
||||
PyObject * PyDict_New(void);
|
||||
PyObject * PyDict_GetItem(PyObject *mp, PyObject *key);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) _PyDict_GetItem_KnownHash(PyObject *mp, PyObject *key,
|
||||
PyObject * _PyDict_GetItem_KnownHash(PyObject *mp, PyObject *key,
|
||||
Py_hash_t hash);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyDict_GetItemWithError(PyObject *mp, PyObject *key);
|
||||
PyObject * PyDict_GetItemWithError(PyObject *mp, PyObject *key);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) _PyDict_GetItemIdWithError(PyObject *dp,
|
||||
PyObject * _PyDict_GetItemIdWithError(PyObject *dp,
|
||||
struct _Py_Identifier *key);
|
||||
PyAPI_FUNC(PyObject *) PyDict_SetDefault(
|
||||
PyObject * PyDict_SetDefault(
|
||||
PyObject *mp, PyObject *key, PyObject *defaultobj);
|
||||
#endif
|
||||
PyAPI_FUNC(int) PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item);
|
||||
int PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(int) _PyDict_SetItem_KnownHash(PyObject *mp, PyObject *key,
|
||||
int _PyDict_SetItem_KnownHash(PyObject *mp, PyObject *key,
|
||||
PyObject *item, Py_hash_t hash);
|
||||
#endif
|
||||
PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key);
|
||||
int PyDict_DelItem(PyObject *mp, PyObject *key);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(int) _PyDict_DelItem_KnownHash(PyObject *mp, PyObject *key,
|
||||
int _PyDict_DelItem_KnownHash(PyObject *mp, PyObject *key,
|
||||
Py_hash_t hash);
|
||||
PyAPI_FUNC(int) _PyDict_DelItemIf(PyObject *mp, PyObject *key,
|
||||
int _PyDict_DelItemIf(PyObject *mp, PyObject *key,
|
||||
int (*predicate)(PyObject *value));
|
||||
#endif
|
||||
PyAPI_FUNC(void) PyDict_Clear(PyObject *mp);
|
||||
PyAPI_FUNC(int) PyDict_Next(
|
||||
void PyDict_Clear(PyObject *mp);
|
||||
int PyDict_Next(
|
||||
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyDictKeysObject *_PyDict_NewKeysForClass(void);
|
||||
PyAPI_FUNC(PyObject *) PyObject_GenericGetDict(PyObject *, void *);
|
||||
PyAPI_FUNC(int) _PyDict_Next(
|
||||
PyObject * PyObject_GenericGetDict(PyObject *, void *);
|
||||
int _PyDict_Next(
|
||||
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, Py_hash_t *hash);
|
||||
PyObject *_PyDictView_New(PyObject *, PyTypeObject *);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp);
|
||||
PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp);
|
||||
PyAPI_FUNC(PyObject *) PyDict_Items(PyObject *mp);
|
||||
PyAPI_FUNC(Py_ssize_t) PyDict_Size(PyObject *mp);
|
||||
PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp);
|
||||
PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key);
|
||||
PyObject * PyDict_Keys(PyObject *mp);
|
||||
PyObject * PyDict_Values(PyObject *mp);
|
||||
PyObject * PyDict_Items(PyObject *mp);
|
||||
Py_ssize_t PyDict_Size(PyObject *mp);
|
||||
PyObject * PyDict_Copy(PyObject *mp);
|
||||
int PyDict_Contains(PyObject *mp, PyObject *key);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(int) _PyDict_Contains(PyObject *mp, PyObject *key, Py_hash_t hash);
|
||||
PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused);
|
||||
PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp);
|
||||
PyAPI_FUNC(int) _PyDict_HasOnlyStringKeys(PyObject *mp);
|
||||
int _PyDict_Contains(PyObject *mp, PyObject *key, Py_hash_t hash);
|
||||
PyObject * _PyDict_NewPresized(Py_ssize_t minused);
|
||||
void _PyDict_MaybeUntrack(PyObject *mp);
|
||||
int _PyDict_HasOnlyStringKeys(PyObject *mp);
|
||||
Py_ssize_t _PyDict_KeysSize(PyDictKeysObject *keys);
|
||||
Py_ssize_t _PyDict_SizeOf(PyDictObject *);
|
||||
PyAPI_FUNC(PyObject *) _PyDict_Pop(PyObject *, PyObject *, PyObject *);
|
||||
PyObject * _PyDict_Pop(PyObject *, PyObject *, PyObject *);
|
||||
PyObject *_PyDict_Pop_KnownHash(PyObject *, PyObject *, Py_hash_t, PyObject *);
|
||||
PyObject *_PyDict_FromKeys(PyObject *, PyObject *, PyObject *);
|
||||
#define _PyDict_HasSplitTable(d) ((d)->ma_values != NULL)
|
||||
|
||||
PyAPI_FUNC(int) PyDict_ClearFreeList(void);
|
||||
int PyDict_ClearFreeList(void);
|
||||
#endif
|
||||
|
||||
/* PyDict_Update(mp, other) is equivalent to PyDict_Merge(mp, other, 1). */
|
||||
PyAPI_FUNC(int) PyDict_Update(PyObject *mp, PyObject *other);
|
||||
int PyDict_Update(PyObject *mp, PyObject *other);
|
||||
|
||||
/* PyDict_Merge updates/merges from a mapping object (an object that
|
||||
supports PyMapping_Keys() and PyObject_GetItem()). If override is true,
|
||||
the last occurrence of a key wins, else the first. The Python
|
||||
dict.update(other) is equivalent to PyDict_Merge(dict, other, 1).
|
||||
*/
|
||||
PyAPI_FUNC(int) PyDict_Merge(PyObject *mp,
|
||||
int PyDict_Merge(PyObject *mp,
|
||||
PyObject *other,
|
||||
int override);
|
||||
|
||||
|
@ -138,8 +139,8 @@ PyAPI_FUNC(int) PyDict_Merge(PyObject *mp,
|
|||
of a key wins, if override is 2, a KeyError with conflicting key as
|
||||
argument is raised.
|
||||
*/
|
||||
PyAPI_FUNC(int) _PyDict_MergeEx(PyObject *mp, PyObject *other, int override);
|
||||
PyAPI_FUNC(PyObject *) _PyDictView_Intersect(PyObject* self, PyObject *other);
|
||||
int _PyDict_MergeEx(PyObject *mp, PyObject *other, int override);
|
||||
PyObject * _PyDictView_Intersect(PyObject* self, PyObject *other);
|
||||
#endif
|
||||
|
||||
/* PyDict_MergeFromSeq2 updates/merges from an iterable object producing
|
||||
|
@ -147,23 +148,23 @@ PyAPI_FUNC(PyObject *) _PyDictView_Intersect(PyObject* self, PyObject *other);
|
|||
of a key wins, else the first. The Python dict constructor dict(seq2)
|
||||
is equivalent to dict={}; PyDict_MergeFromSeq(dict, seq2, 1).
|
||||
*/
|
||||
PyAPI_FUNC(int) PyDict_MergeFromSeq2(PyObject *d,
|
||||
int PyDict_MergeFromSeq2(PyObject *d,
|
||||
PyObject *seq2,
|
||||
int override);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyDict_GetItemString(PyObject *dp, const char *key);
|
||||
PyObject * PyDict_GetItemString(PyObject *dp, const char *key);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) _PyDict_GetItemId(PyObject *dp, struct _Py_Identifier *key);
|
||||
PyObject * _PyDict_GetItemId(PyObject *dp, struct _Py_Identifier *key);
|
||||
#endif /* !Py_LIMITED_API */
|
||||
PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item);
|
||||
int PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(int) _PyDict_SetItemId(PyObject *dp, struct _Py_Identifier *key, PyObject *item);
|
||||
int _PyDict_SetItemId(PyObject *dp, struct _Py_Identifier *key, PyObject *item);
|
||||
#endif /* !Py_LIMITED_API */
|
||||
PyAPI_FUNC(int) PyDict_DelItemString(PyObject *dp, const char *key);
|
||||
int PyDict_DelItemString(PyObject *dp, const char *key);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(int) _PyDict_DelItemId(PyObject *mp, struct _Py_Identifier *key);
|
||||
PyAPI_FUNC(void) _PyDict_DebugMallocStats(FILE *out);
|
||||
int _PyDict_DelItemId(PyObject *mp, struct _Py_Identifier *key);
|
||||
void _PyDict_DebugMallocStats(FILE *out);
|
||||
|
||||
int _PyObjectDict_SetItem(PyTypeObject *tp, PyObject **dictptr, PyObject *name, PyObject *value);
|
||||
PyObject *_PyDict_LoadGlobal(PyDictObject *, PyDictObject *, PyObject *);
|
||||
|
|
10
third_party/python/Include/dtoa.h
vendored
10
third_party/python/Include/dtoa.h
vendored
|
@ -3,12 +3,12 @@
|
|||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
PyAPI_FUNC(double) _Py_dg_strtod(const char *str, char **ptr);
|
||||
PyAPI_FUNC(char *) _Py_dg_dtoa(double d, int mode, int ndigits,
|
||||
double _Py_dg_strtod(const char *str, char **ptr);
|
||||
char * _Py_dg_dtoa(double d, int mode, int ndigits,
|
||||
int *decpt, int *sign, char **rve);
|
||||
PyAPI_FUNC(void) _Py_dg_freedtoa(char *s);
|
||||
PyAPI_FUNC(double) _Py_dg_stdnan(int sign);
|
||||
PyAPI_FUNC(double) _Py_dg_infinity(int sign);
|
||||
void _Py_dg_freedtoa(char *s);
|
||||
double _Py_dg_stdnan(int sign);
|
||||
double _Py_dg_infinity(int sign);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif
|
||||
|
|
146
third_party/python/Include/dynamic_annotations.h
vendored
146
third_party/python/Include/dynamic_annotations.h
vendored
|
@ -1,3 +1,9 @@
|
|||
#ifndef __DYNAMIC_ANNOTATIONS_H__
|
||||
#define __DYNAMIC_ANNOTATIONS_H__
|
||||
#ifndef DYNAMIC_ANNOTATIONS_ENABLED
|
||||
#define DYNAMIC_ANNOTATIONS_ENABLED 0
|
||||
#endif
|
||||
#if DYNAMIC_ANNOTATIONS_ENABLED != 0
|
||||
/* clang-format off */
|
||||
|
||||
/* Copyright (c) 2008-2009, Google Inc.
|
||||
|
@ -55,15 +61,6 @@
|
|||
Macros are defined as calls to non-inlinable empty functions
|
||||
that are intercepted by Valgrind. */
|
||||
|
||||
#ifndef __DYNAMIC_ANNOTATIONS_H__
|
||||
#define __DYNAMIC_ANNOTATIONS_H__
|
||||
|
||||
#ifndef DYNAMIC_ANNOTATIONS_ENABLED
|
||||
# define DYNAMIC_ANNOTATIONS_ENABLED 0
|
||||
#endif
|
||||
|
||||
#if DYNAMIC_ANNOTATIONS_ENABLED != 0
|
||||
|
||||
/* -------------------------------------------------------------
|
||||
Annotations useful when implementing condition variables such as CondVar,
|
||||
using conditional critical sections (Await/LockWhen) and when constructing
|
||||
|
@ -324,54 +321,8 @@
|
|||
#define _Py_ANNOTATE_FLUSH_STATE() \
|
||||
AnnotateFlushState(__FILE__, __LINE__)
|
||||
|
||||
|
||||
#else /* DYNAMIC_ANNOTATIONS_ENABLED == 0 */
|
||||
|
||||
#define _Py_ANNOTATE_RWLOCK_CREATE(lock) /* empty */
|
||||
#define _Py_ANNOTATE_RWLOCK_DESTROY(lock) /* empty */
|
||||
#define _Py_ANNOTATE_RWLOCK_ACQUIRED(lock, is_w) /* empty */
|
||||
#define _Py_ANNOTATE_RWLOCK_RELEASED(lock, is_w) /* empty */
|
||||
#define _Py_ANNOTATE_BARRIER_INIT(barrier, count, reinitialization_allowed) /* */
|
||||
#define _Py_ANNOTATE_BARRIER_WAIT_BEFORE(barrier) /* empty */
|
||||
#define _Py_ANNOTATE_BARRIER_WAIT_AFTER(barrier) /* empty */
|
||||
#define _Py_ANNOTATE_BARRIER_DESTROY(barrier) /* empty */
|
||||
#define _Py_ANNOTATE_CONDVAR_LOCK_WAIT(cv, lock) /* empty */
|
||||
#define _Py_ANNOTATE_CONDVAR_WAIT(cv) /* empty */
|
||||
#define _Py_ANNOTATE_CONDVAR_SIGNAL(cv) /* empty */
|
||||
#define _Py_ANNOTATE_CONDVAR_SIGNAL_ALL(cv) /* empty */
|
||||
#define _Py_ANNOTATE_HAPPENS_BEFORE(obj) /* empty */
|
||||
#define _Py_ANNOTATE_HAPPENS_AFTER(obj) /* empty */
|
||||
#define _Py_ANNOTATE_PUBLISH_MEMORY_RANGE(address, size) /* empty */
|
||||
#define _Py_ANNOTATE_UNPUBLISH_MEMORY_RANGE(address, size) /* empty */
|
||||
#define _Py_ANNOTATE_SWAP_MEMORY_RANGE(address, size) /* empty */
|
||||
#define _Py_ANNOTATE_PCQ_CREATE(pcq) /* empty */
|
||||
#define _Py_ANNOTATE_PCQ_DESTROY(pcq) /* empty */
|
||||
#define _Py_ANNOTATE_PCQ_PUT(pcq) /* empty */
|
||||
#define _Py_ANNOTATE_PCQ_GET(pcq) /* empty */
|
||||
#define _Py_ANNOTATE_NEW_MEMORY(address, size) /* empty */
|
||||
#define _Py_ANNOTATE_EXPECT_RACE(address, description) /* empty */
|
||||
#define _Py_ANNOTATE_BENIGN_RACE(address, description) /* empty */
|
||||
#define _Py_ANNOTATE_BENIGN_RACE_SIZED(address, size, description) /* empty */
|
||||
#define _Py_ANNOTATE_PURE_HAPPENS_BEFORE_MUTEX(mu) /* empty */
|
||||
#define _Py_ANNOTATE_MUTEX_IS_USED_AS_CONDVAR(mu) /* empty */
|
||||
#define _Py_ANNOTATE_TRACE_MEMORY(arg) /* empty */
|
||||
#define _Py_ANNOTATE_THREAD_NAME(name) /* empty */
|
||||
#define _Py_ANNOTATE_IGNORE_READS_BEGIN() /* empty */
|
||||
#define _Py_ANNOTATE_IGNORE_READS_END() /* empty */
|
||||
#define _Py_ANNOTATE_IGNORE_WRITES_BEGIN() /* empty */
|
||||
#define _Py_ANNOTATE_IGNORE_WRITES_END() /* empty */
|
||||
#define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN() /* empty */
|
||||
#define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_END() /* empty */
|
||||
#define _Py_ANNOTATE_IGNORE_SYNC_BEGIN() /* empty */
|
||||
#define _Py_ANNOTATE_IGNORE_SYNC_END() /* empty */
|
||||
#define _Py_ANNOTATE_ENABLE_RACE_DETECTION(enable) /* empty */
|
||||
#define _Py_ANNOTATE_NO_OP(arg) /* empty */
|
||||
#define _Py_ANNOTATE_FLUSH_STATE() /* empty */
|
||||
|
||||
#endif /* DYNAMIC_ANNOTATIONS_ENABLED */
|
||||
|
||||
/* Use the macros above rather than using these functions directly. */
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
void AnnotateRWLockCreate(const char *file, int line,
|
||||
const volatile void *lock);
|
||||
void AnnotateRWLockDestroy(const char *file, int line,
|
||||
|
@ -457,24 +408,22 @@ int RunningOnValgrind(void);
|
|||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
||||
#if DYNAMIC_ANNOTATIONS_ENABLED != 0 && defined(__cplusplus)
|
||||
|
||||
/* _Py_ANNOTATE_UNPROTECTED_READ is the preferred way to annotate racey reads.
|
||||
|
||||
Instead of doing
|
||||
_Py_ANNOTATE_IGNORE_READS_BEGIN();
|
||||
... = x;
|
||||
_Py_ANNOTATE_IGNORE_READS_END();
|
||||
one can use
|
||||
... = _Py_ANNOTATE_UNPROTECTED_READ(x); */
|
||||
template <class T>
|
||||
inline T _Py_ANNOTATE_UNPROTECTED_READ(const volatile T &x) {
|
||||
_Py_ANNOTATE_IGNORE_READS_BEGIN();
|
||||
T res = x;
|
||||
_Py_ANNOTATE_IGNORE_READS_END();
|
||||
return res;
|
||||
}
|
||||
/* Apply _Py_ANNOTATE_BENIGN_RACE_SIZED to a static variable. */
|
||||
#ifdef __cplusplus
|
||||
/* _Py_ANNOTATE_UNPROTECTED_READ is the preferred way to annotate racey reads.
|
||||
Instead of doing
|
||||
_Py_ANNOTATE_IGNORE_READS_BEGIN();
|
||||
... = x;
|
||||
_Py_ANNOTATE_IGNORE_READS_END();
|
||||
one can use
|
||||
... = _Py_ANNOTATE_UNPROTECTED_READ(x); */
|
||||
template <class T>
|
||||
inline T _Py_ANNOTATE_UNPROTECTED_READ(const volatile T &x) {
|
||||
_Py_ANNOTATE_IGNORE_READS_BEGIN();
|
||||
T res = x;
|
||||
_Py_ANNOTATE_IGNORE_READS_END();
|
||||
return res;
|
||||
}
|
||||
/* Apply _Py_ANNOTATE_BENIGN_RACE_SIZED to a static variable. */
|
||||
#define _Py_ANNOTATE_BENIGN_RACE_STATIC(static_var, description) \
|
||||
namespace { \
|
||||
class static_var ## _annotator { \
|
||||
|
@ -487,11 +436,50 @@ COSMOPOLITAN_C_END_
|
|||
}; \
|
||||
static static_var ## _annotator the ## static_var ## _annotator;\
|
||||
}
|
||||
#else /* DYNAMIC_ANNOTATIONS_ENABLED == 0 */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#else /* DYNAMIC_ANNOTATIONS_ENABLED == 0 */
|
||||
#define _Py_ANNOTATE_RWLOCK_CREATE(lock)
|
||||
#define _Py_ANNOTATE_RWLOCK_DESTROY(lock)
|
||||
#define _Py_ANNOTATE_RWLOCK_ACQUIRED(lock, is_w)
|
||||
#define _Py_ANNOTATE_RWLOCK_RELEASED(lock, is_w)
|
||||
#define _Py_ANNOTATE_BARRIER_INIT(barrier, count, reinitialization_allowed) /* */
|
||||
#define _Py_ANNOTATE_BARRIER_WAIT_BEFORE(barrier)
|
||||
#define _Py_ANNOTATE_BARRIER_WAIT_AFTER(barrier)
|
||||
#define _Py_ANNOTATE_BARRIER_DESTROY(barrier)
|
||||
#define _Py_ANNOTATE_CONDVAR_LOCK_WAIT(cv, lock)
|
||||
#define _Py_ANNOTATE_CONDVAR_WAIT(cv)
|
||||
#define _Py_ANNOTATE_CONDVAR_SIGNAL(cv)
|
||||
#define _Py_ANNOTATE_CONDVAR_SIGNAL_ALL(cv)
|
||||
#define _Py_ANNOTATE_HAPPENS_BEFORE(obj)
|
||||
#define _Py_ANNOTATE_HAPPENS_AFTER(obj)
|
||||
#define _Py_ANNOTATE_PUBLISH_MEMORY_RANGE(address, size)
|
||||
#define _Py_ANNOTATE_UNPUBLISH_MEMORY_RANGE(address, size)
|
||||
#define _Py_ANNOTATE_SWAP_MEMORY_RANGE(address, size)
|
||||
#define _Py_ANNOTATE_PCQ_CREATE(pcq)
|
||||
#define _Py_ANNOTATE_PCQ_DESTROY(pcq)
|
||||
#define _Py_ANNOTATE_PCQ_PUT(pcq)
|
||||
#define _Py_ANNOTATE_PCQ_GET(pcq)
|
||||
#define _Py_ANNOTATE_NEW_MEMORY(address, size)
|
||||
#define _Py_ANNOTATE_EXPECT_RACE(address, description)
|
||||
#define _Py_ANNOTATE_BENIGN_RACE(address, description)
|
||||
#define _Py_ANNOTATE_BENIGN_RACE_SIZED(address, size, description)
|
||||
#define _Py_ANNOTATE_PURE_HAPPENS_BEFORE_MUTEX(mu)
|
||||
#define _Py_ANNOTATE_MUTEX_IS_USED_AS_CONDVAR(mu)
|
||||
#define _Py_ANNOTATE_TRACE_MEMORY(arg)
|
||||
#define _Py_ANNOTATE_THREAD_NAME(name)
|
||||
#define _Py_ANNOTATE_IGNORE_READS_BEGIN()
|
||||
#define _Py_ANNOTATE_IGNORE_READS_END()
|
||||
#define _Py_ANNOTATE_IGNORE_WRITES_BEGIN()
|
||||
#define _Py_ANNOTATE_IGNORE_WRITES_END()
|
||||
#define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN()
|
||||
#define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_END()
|
||||
#define _Py_ANNOTATE_IGNORE_SYNC_BEGIN()
|
||||
#define _Py_ANNOTATE_IGNORE_SYNC_END()
|
||||
#define _Py_ANNOTATE_ENABLE_RACE_DETECTION(enable)
|
||||
#define _Py_ANNOTATE_NO_OP(arg)
|
||||
#define _Py_ANNOTATE_FLUSH_STATE()
|
||||
#define _Py_ANNOTATE_UNPROTECTED_READ(x) (x)
|
||||
#define _Py_ANNOTATE_BENIGN_RACE_STATIC(static_var, description) /* empty */
|
||||
|
||||
#endif /* DYNAMIC_ANNOTATIONS_ENABLED */
|
||||
|
||||
#define _Py_ANNOTATE_BENIGN_RACE_STATIC(static_var, description)
|
||||
#endif /* DYNAMIC_ANNOTATIONS_ENABLED */
|
||||
#endif /* __DYNAMIC_ANNOTATIONS_H__ */
|
||||
|
|
5
third_party/python/Include/enumobject.h
vendored
5
third_party/python/Include/enumobject.h
vendored
|
@ -1,10 +1,11 @@
|
|||
#ifndef Py_ENUMOBJECT_H
|
||||
#define Py_ENUMOBJECT_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyEnum_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyReversed_Type;
|
||||
extern PyTypeObject PyEnum_Type;
|
||||
extern PyTypeObject PyReversed_Type;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !Py_ENUMOBJECT_H */
|
||||
|
|
7
third_party/python/Include/eval.h
vendored
7
third_party/python/Include/eval.h
vendored
|
@ -1,11 +1,12 @@
|
|||
#ifndef Py_EVAL_H
|
||||
#define Py_EVAL_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyEval_EvalCode(PyObject *, PyObject *, PyObject *);
|
||||
PyObject * PyEval_EvalCode(PyObject *, PyObject *, PyObject *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyObject *co,
|
||||
PyObject * PyEval_EvalCodeEx(PyObject *co,
|
||||
PyObject *globals,
|
||||
PyObject *locals,
|
||||
PyObject **args, int argc,
|
||||
|
@ -14,7 +15,7 @@ PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyObject *co,
|
|||
PyObject *kwdefs, PyObject *closure);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) _PyEval_CallTracing(PyObject *func, PyObject *args);
|
||||
PyObject * _PyEval_CallTracing(PyObject *func, PyObject *args);
|
||||
#endif
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
23
third_party/python/Include/fileobject.h
vendored
23
third_party/python/Include/fileobject.h
vendored
|
@ -1,37 +1,38 @@
|
|||
#ifndef Py_FILEOBJECT_H
|
||||
#define Py_FILEOBJECT_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
#define PY_STDIOTEXTMODE "b"
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyFile_FromFd(int, const char *, const char *, int,
|
||||
PyObject * PyFile_FromFd(int, const char *, const char *, int,
|
||||
const char *, const char *,
|
||||
const char *, int);
|
||||
PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int);
|
||||
PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int);
|
||||
PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *);
|
||||
PyObject * PyFile_GetLine(PyObject *, int);
|
||||
int PyFile_WriteObject(PyObject *, PyObject *, int);
|
||||
int PyFile_WriteString(const char *, PyObject *);
|
||||
int PyObject_AsFileDescriptor(PyObject *);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(char *) Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *);
|
||||
char * Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *);
|
||||
#endif
|
||||
|
||||
/* The default encoding used by the platform file system APIs
|
||||
If non-NULL, this is different than the default encoding for strings
|
||||
*/
|
||||
PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding;
|
||||
extern const char * Py_FileSystemDefaultEncoding;
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000
|
||||
PyAPI_DATA(const char *) Py_FileSystemDefaultEncodeErrors;
|
||||
extern const char * Py_FileSystemDefaultEncodeErrors;
|
||||
#endif
|
||||
PyAPI_DATA(int) Py_HasFileSystemDefaultEncoding;
|
||||
extern int Py_HasFileSystemDefaultEncoding;
|
||||
|
||||
/* Internal API
|
||||
|
||||
The std printer acts as a preliminary sys.stderr until the new io
|
||||
infrastructure is in place. */
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) PyFile_NewStdPrinter(int);
|
||||
PyAPI_DATA(PyTypeObject) PyStdPrinter_Type;
|
||||
PyObject * PyFile_NewStdPrinter(int);
|
||||
extern PyTypeObject PyStdPrinter_Type;
|
||||
#endif /* Py_LIMITED_API */
|
||||
|
||||
/* A routine to check if a file descriptor can be select()-ed. */
|
||||
|
|
54
third_party/python/Include/fileutils.h
vendored
54
third_party/python/Include/fileutils.h
vendored
|
@ -1,31 +1,33 @@
|
|||
#ifndef Py_FILEUTILS_H
|
||||
#define Py_FILEUTILS_H
|
||||
#include "libc/calls/struct/stat.h"
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||
PyAPI_FUNC(wchar_t *) Py_DecodeLocale(
|
||||
wchar_t * Py_DecodeLocale(
|
||||
const char *arg,
|
||||
size_t *size);
|
||||
|
||||
PyAPI_FUNC(char*) Py_EncodeLocale(
|
||||
char* Py_EncodeLocale(
|
||||
const wchar_t *text,
|
||||
size_t *error_pos);
|
||||
#endif
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
|
||||
PyAPI_FUNC(wchar_t *) _Py_DecodeLocaleEx(
|
||||
wchar_t * _Py_DecodeLocaleEx(
|
||||
const char *arg,
|
||||
size_t *size,
|
||||
int current_locale);
|
||||
|
||||
PyAPI_FUNC(char*) _Py_EncodeLocaleEx(
|
||||
char* _Py_EncodeLocaleEx(
|
||||
const wchar_t *text,
|
||||
size_t *error_pos,
|
||||
int current_locale);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _Py_device_encoding(int);
|
||||
PyObject * _Py_device_encoding(int);
|
||||
|
||||
#if defined(MS_WINDOWS) || defined(__APPLE__)
|
||||
/* On Windows, the count parameter of read() is an int (bpo-9015, bpo-9611).
|
||||
|
@ -62,88 +64,88 @@ struct _Py_stat_struct {
|
|||
# define _Py_stat_struct stat
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(int) _Py_fstat(
|
||||
int _Py_fstat(
|
||||
int fd,
|
||||
struct _Py_stat_struct *status);
|
||||
|
||||
PyAPI_FUNC(int) _Py_fstat_noraise(
|
||||
int _Py_fstat_noraise(
|
||||
int fd,
|
||||
struct _Py_stat_struct *status);
|
||||
|
||||
PyAPI_FUNC(int) _Py_stat(
|
||||
int _Py_stat(
|
||||
PyObject *path,
|
||||
struct stat *status);
|
||||
|
||||
PyAPI_FUNC(int) _Py_open(
|
||||
int _Py_open(
|
||||
const char *pathname,
|
||||
int flags);
|
||||
|
||||
PyAPI_FUNC(int) _Py_open_noraise(
|
||||
int _Py_open_noraise(
|
||||
const char *pathname,
|
||||
int flags);
|
||||
|
||||
PyAPI_FUNC(FILE *) _Py_wfopen(
|
||||
FILE * _Py_wfopen(
|
||||
const wchar_t *path,
|
||||
const wchar_t *mode);
|
||||
|
||||
PyAPI_FUNC(FILE*) _Py_fopen(
|
||||
FILE* _Py_fopen(
|
||||
const char *pathname,
|
||||
const char *mode);
|
||||
|
||||
PyAPI_FUNC(FILE*) _Py_fopen_obj(
|
||||
FILE* _Py_fopen_obj(
|
||||
PyObject *path,
|
||||
const char *mode);
|
||||
|
||||
PyAPI_FUNC(Py_ssize_t) _Py_read(
|
||||
Py_ssize_t _Py_read(
|
||||
int fd,
|
||||
void *buf,
|
||||
size_t count);
|
||||
|
||||
PyAPI_FUNC(Py_ssize_t) _Py_write(
|
||||
Py_ssize_t _Py_write(
|
||||
int fd,
|
||||
const void *buf,
|
||||
size_t count);
|
||||
|
||||
PyAPI_FUNC(Py_ssize_t) _Py_write_noraise(
|
||||
Py_ssize_t _Py_write_noraise(
|
||||
int fd,
|
||||
const void *buf,
|
||||
size_t count);
|
||||
|
||||
#ifdef HAVE_READLINK
|
||||
PyAPI_FUNC(int) _Py_wreadlink(
|
||||
int _Py_wreadlink(
|
||||
const wchar_t *path,
|
||||
wchar_t *buf,
|
||||
size_t bufsiz);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_REALPATH
|
||||
PyAPI_FUNC(wchar_t*) _Py_wrealpath(
|
||||
wchar_t* _Py_wrealpath(
|
||||
const wchar_t *path,
|
||||
wchar_t *resolved_path,
|
||||
size_t resolved_path_size);
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(wchar_t*) _Py_wgetcwd(
|
||||
wchar_t* _Py_wgetcwd(
|
||||
wchar_t *buf,
|
||||
size_t size);
|
||||
|
||||
PyAPI_FUNC(int) _Py_get_inheritable(int fd);
|
||||
int _Py_get_inheritable(int fd);
|
||||
|
||||
PyAPI_FUNC(int) _Py_set_inheritable(int fd, int inheritable,
|
||||
int _Py_set_inheritable(int fd, int inheritable,
|
||||
int *atomic_flag_works);
|
||||
|
||||
PyAPI_FUNC(int) _Py_set_inheritable_async_safe(int fd, int inheritable,
|
||||
int _Py_set_inheritable_async_safe(int fd, int inheritable,
|
||||
int *atomic_flag_works);
|
||||
|
||||
PyAPI_FUNC(int) _Py_dup(int fd);
|
||||
int _Py_dup(int fd);
|
||||
|
||||
#ifndef MS_WINDOWS
|
||||
PyAPI_FUNC(int) _Py_get_blocking(int fd);
|
||||
int _Py_get_blocking(int fd);
|
||||
|
||||
PyAPI_FUNC(int) _Py_set_blocking(int fd, int blocking);
|
||||
int _Py_set_blocking(int fd, int blocking);
|
||||
#endif /* !MS_WINDOWS */
|
||||
|
||||
PyAPI_FUNC(int) _Py_GetLocaleconvNumeric(
|
||||
int _Py_GetLocaleconvNumeric(
|
||||
PyObject **decimal_point,
|
||||
PyObject **thousands_sep,
|
||||
const char **grouping);
|
||||
|
|
40
third_party/python/Include/floatobject.h
vendored
40
third_party/python/Include/floatobject.h
vendored
|
@ -1,5 +1,7 @@
|
|||
#ifndef Py_FLOATOBJECT_H
|
||||
#define Py_FLOATOBJECT_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/unicodeobject.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -10,7 +12,7 @@ typedef struct {
|
|||
} PyFloatObject;
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyFloat_Type;
|
||||
extern PyTypeObject PyFloat_Type;
|
||||
|
||||
#define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type)
|
||||
#define PyFloat_CheckExact(op) (Py_TYPE(op) == &PyFloat_Type)
|
||||
|
@ -26,19 +28,19 @@ PyAPI_DATA(PyTypeObject) PyFloat_Type;
|
|||
return PyFloat_FromDouble(-Py_HUGE_VAL); \
|
||||
} while(0)
|
||||
|
||||
PyAPI_FUNC(double) PyFloat_GetMax(void);
|
||||
PyAPI_FUNC(double) PyFloat_GetMin(void);
|
||||
PyAPI_FUNC(PyObject *) PyFloat_GetInfo(void);
|
||||
double PyFloat_GetMax(void);
|
||||
double PyFloat_GetMin(void);
|
||||
PyObject * PyFloat_GetInfo(void);
|
||||
|
||||
/* Return Python float from string PyObject. */
|
||||
PyAPI_FUNC(PyObject *) PyFloat_FromString(PyObject*);
|
||||
PyObject * PyFloat_FromString(PyObject*);
|
||||
|
||||
/* Return Python float from C double. */
|
||||
PyAPI_FUNC(PyObject *) PyFloat_FromDouble(double);
|
||||
PyObject * PyFloat_FromDouble(double);
|
||||
|
||||
/* Extract C double from Python float. The macro version trades safety for
|
||||
speed. */
|
||||
PyAPI_FUNC(double) PyFloat_AsDouble(PyObject *);
|
||||
double PyFloat_AsDouble(PyObject *);
|
||||
#ifndef Py_LIMITED_API
|
||||
#define PyFloat_AS_DOUBLE(op) (((PyFloatObject *)(op))->ob_fval)
|
||||
#endif
|
||||
|
@ -76,18 +78,18 @@ PyAPI_FUNC(double) PyFloat_AsDouble(PyObject *);
|
|||
* 1): What this does is undefined if x is a NaN or infinity.
|
||||
* 2): -0.0 and +0.0 produce the same string.
|
||||
*/
|
||||
PyAPI_FUNC(int) _PyFloat_Pack2(double x, unsigned char *p, int le);
|
||||
PyAPI_FUNC(int) _PyFloat_Pack4(double x, unsigned char *p, int le);
|
||||
PyAPI_FUNC(int) _PyFloat_Pack8(double x, unsigned char *p, int le);
|
||||
int _PyFloat_Pack2(double x, unsigned char *p, int le);
|
||||
int _PyFloat_Pack4(double x, unsigned char *p, int le);
|
||||
int _PyFloat_Pack8(double x, unsigned char *p, int le);
|
||||
|
||||
/* Needed for the old way for marshal to store a floating point number.
|
||||
Returns the string length copied into p, -1 on error.
|
||||
*/
|
||||
PyAPI_FUNC(int) _PyFloat_Repr(double x, char *p, size_t len);
|
||||
int _PyFloat_Repr(double x, char *p, size_t len);
|
||||
|
||||
/* Used to get the important decimal digits of a double */
|
||||
PyAPI_FUNC(int) _PyFloat_Digits(char *buf, double v, int *signum);
|
||||
PyAPI_FUNC(void) _PyFloat_DigitsInit(void);
|
||||
int _PyFloat_Digits(char *buf, double v, int *signum);
|
||||
void _PyFloat_DigitsInit(void);
|
||||
|
||||
/* The unpack routines read 2, 4 or 8 bytes, starting at p. le is a bool
|
||||
* argument, true if the string is in little-endian format (exponent
|
||||
|
@ -97,18 +99,18 @@ PyAPI_FUNC(void) _PyFloat_DigitsInit(void);
|
|||
* OverflowError). Note that on a non-IEEE platform this will refuse
|
||||
* to unpack a string that represents a NaN or infinity.
|
||||
*/
|
||||
PyAPI_FUNC(double) _PyFloat_Unpack2(const unsigned char *p, int le);
|
||||
PyAPI_FUNC(double) _PyFloat_Unpack4(const unsigned char *p, int le);
|
||||
PyAPI_FUNC(double) _PyFloat_Unpack8(const unsigned char *p, int le);
|
||||
double _PyFloat_Unpack2(const unsigned char *p, int le);
|
||||
double _PyFloat_Unpack4(const unsigned char *p, int le);
|
||||
double _PyFloat_Unpack8(const unsigned char *p, int le);
|
||||
|
||||
/* free list api */
|
||||
PyAPI_FUNC(int) PyFloat_ClearFreeList(void);
|
||||
int PyFloat_ClearFreeList(void);
|
||||
|
||||
PyAPI_FUNC(void) _PyFloat_DebugMallocStats(FILE* out);
|
||||
void _PyFloat_DebugMallocStats(FILE* out);
|
||||
|
||||
/* Format the object based on the format_spec, as defined in PEP 3101
|
||||
(Advanced String Formatting). */
|
||||
PyAPI_FUNC(int) _PyFloat_FormatAdvancedWriter(
|
||||
int _PyFloat_FormatAdvancedWriter(
|
||||
_PyUnicodeWriter *writer,
|
||||
PyObject *obj,
|
||||
PyObject *format_spec,
|
||||
|
|
27
third_party/python/Include/frameobject.h
vendored
27
third_party/python/Include/frameobject.h
vendored
|
@ -1,6 +1,9 @@
|
|||
#ifndef Py_LIMITED_API
|
||||
#ifndef Py_FRAMEOBJECT_H
|
||||
#define Py_FRAMEOBJECT_H
|
||||
#include "third_party/python/Include/code.h"
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/pystate.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -51,38 +54,38 @@ typedef struct _frame {
|
|||
|
||||
/* Standard object interface */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyFrame_Type;
|
||||
extern PyTypeObject PyFrame_Type;
|
||||
|
||||
#define PyFrame_Check(op) (Py_TYPE(op) == &PyFrame_Type)
|
||||
|
||||
PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *,
|
||||
PyObject *, PyObject *);
|
||||
PyFrameObject * PyFrame_New(PyThreadState *, PyCodeObject *,
|
||||
PyObject *, PyObject *);
|
||||
|
||||
|
||||
/* The rest of the interface is specific for frame objects */
|
||||
|
||||
/* Block management functions */
|
||||
|
||||
PyAPI_FUNC(void) PyFrame_BlockSetup(PyFrameObject *, int, int, int);
|
||||
PyAPI_FUNC(PyTryBlock *) PyFrame_BlockPop(PyFrameObject *);
|
||||
void PyFrame_BlockSetup(PyFrameObject *, int, int, int);
|
||||
PyTryBlock * PyFrame_BlockPop(PyFrameObject *);
|
||||
|
||||
/* Extend the value stack */
|
||||
|
||||
PyAPI_FUNC(PyObject **) PyFrame_ExtendStack(PyFrameObject *, int, int);
|
||||
PyObject ** PyFrame_ExtendStack(PyFrameObject *, int, int);
|
||||
|
||||
/* Conversions between "fast locals" and locals in dictionary */
|
||||
|
||||
PyAPI_FUNC(void) PyFrame_LocalsToFast(PyFrameObject *, int);
|
||||
void PyFrame_LocalsToFast(PyFrameObject *, int);
|
||||
|
||||
PyAPI_FUNC(int) PyFrame_FastToLocalsWithError(PyFrameObject *f);
|
||||
PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *);
|
||||
int PyFrame_FastToLocalsWithError(PyFrameObject *f);
|
||||
void PyFrame_FastToLocals(PyFrameObject *);
|
||||
|
||||
PyAPI_FUNC(int) PyFrame_ClearFreeList(void);
|
||||
int PyFrame_ClearFreeList(void);
|
||||
|
||||
PyAPI_FUNC(void) _PyFrame_DebugMallocStats(FILE *out);
|
||||
void _PyFrame_DebugMallocStats(FILE *out);
|
||||
|
||||
/* Return the line of code the frame is currently executing. */
|
||||
PyAPI_FUNC(int) PyFrame_GetLineNumber(PyFrameObject *);
|
||||
int PyFrame_GetLineNumber(PyFrameObject *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !Py_FRAMEOBJECT_H */
|
||||
|
|
41
third_party/python/Include/funcobject.h
vendored
41
third_party/python/Include/funcobject.h
vendored
|
@ -1,6 +1,7 @@
|
|||
#ifndef Py_LIMITED_API
|
||||
#ifndef Py_FUNCOBJECT_H
|
||||
#define Py_FUNCOBJECT_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -37,32 +38,32 @@ typedef struct {
|
|||
*/
|
||||
} PyFunctionObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyFunction_Type;
|
||||
extern PyTypeObject PyFunction_Type;
|
||||
|
||||
#define PyFunction_Check(op) (Py_TYPE(op) == &PyFunction_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_NewWithQualName(PyObject *, PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetGlobals(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetModule(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetDefaults(PyObject *);
|
||||
PyAPI_FUNC(int) PyFunction_SetDefaults(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetKwDefaults(PyObject *);
|
||||
PyAPI_FUNC(int) PyFunction_SetKwDefaults(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetClosure(PyObject *);
|
||||
PyAPI_FUNC(int) PyFunction_SetClosure(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetAnnotations(PyObject *);
|
||||
PyAPI_FUNC(int) PyFunction_SetAnnotations(PyObject *, PyObject *);
|
||||
PyObject * PyFunction_New(PyObject *, PyObject *);
|
||||
PyObject * PyFunction_NewWithQualName(PyObject *, PyObject *, PyObject *);
|
||||
PyObject * PyFunction_GetCode(PyObject *);
|
||||
PyObject * PyFunction_GetGlobals(PyObject *);
|
||||
PyObject * PyFunction_GetModule(PyObject *);
|
||||
PyObject * PyFunction_GetDefaults(PyObject *);
|
||||
int PyFunction_SetDefaults(PyObject *, PyObject *);
|
||||
PyObject * PyFunction_GetKwDefaults(PyObject *);
|
||||
int PyFunction_SetKwDefaults(PyObject *, PyObject *);
|
||||
PyObject * PyFunction_GetClosure(PyObject *);
|
||||
int PyFunction_SetClosure(PyObject *, PyObject *);
|
||||
PyObject * PyFunction_GetAnnotations(PyObject *);
|
||||
int PyFunction_SetAnnotations(PyObject *, PyObject *);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) _PyFunction_FastCallDict(
|
||||
PyObject * _PyFunction_FastCallDict(
|
||||
PyObject *func,
|
||||
PyObject **args,
|
||||
Py_ssize_t nargs,
|
||||
PyObject *kwargs);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyFunction_FastCallKeywords(
|
||||
PyObject * _PyFunction_FastCallKeywords(
|
||||
PyObject *func,
|
||||
PyObject **stack,
|
||||
Py_ssize_t nargs,
|
||||
|
@ -87,11 +88,11 @@ PyAPI_FUNC(PyObject *) _PyFunction_FastCallKeywords(
|
|||
(((PyFunctionObject *)func) -> func_annotations)
|
||||
|
||||
/* The classmethod and staticmethod types lives here, too */
|
||||
PyAPI_DATA(PyTypeObject) PyClassMethod_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyStaticMethod_Type;
|
||||
extern PyTypeObject PyClassMethod_Type;
|
||||
extern PyTypeObject PyStaticMethod_Type;
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyClassMethod_New(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyStaticMethod_New(PyObject *);
|
||||
PyObject * PyClassMethod_New(PyObject *);
|
||||
PyObject * PyStaticMethod_New(PyObject *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !Py_FUNCOBJECT_H */
|
||||
|
|
35
third_party/python/Include/genobject.h
vendored
35
third_party/python/Include/genobject.h
vendored
|
@ -1,6 +1,7 @@
|
|||
#ifndef Py_LIMITED_API
|
||||
#ifndef Py_GENOBJECT_H
|
||||
#define Py_GENOBJECT_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -28,35 +29,35 @@ typedef struct {
|
|||
_PyGenObject_HEAD(gi)
|
||||
} PyGenObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyGen_Type;
|
||||
extern PyTypeObject PyGen_Type;
|
||||
|
||||
#define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type)
|
||||
#define PyGen_CheckExact(op) (Py_TYPE(op) == &PyGen_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyGen_New(struct _frame *);
|
||||
PyAPI_FUNC(PyObject *) PyGen_NewWithQualName(struct _frame *,
|
||||
PyObject * PyGen_New(struct _frame *);
|
||||
PyObject * PyGen_NewWithQualName(struct _frame *,
|
||||
PyObject *name, PyObject *qualname);
|
||||
PyAPI_FUNC(int) PyGen_NeedsFinalizing(PyGenObject *);
|
||||
PyAPI_FUNC(int) _PyGen_SetStopIterationValue(PyObject *);
|
||||
PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **);
|
||||
PyAPI_FUNC(PyObject *) _PyGen_Send(PyGenObject *, PyObject *);
|
||||
int PyGen_NeedsFinalizing(PyGenObject *);
|
||||
int _PyGen_SetStopIterationValue(PyObject *);
|
||||
int _PyGen_FetchStopIterationValue(PyObject **);
|
||||
PyObject * _PyGen_Send(PyGenObject *, PyObject *);
|
||||
PyObject *_PyGen_yf(PyGenObject *);
|
||||
PyAPI_FUNC(void) _PyGen_Finalize(PyObject *self);
|
||||
void _PyGen_Finalize(PyObject *self);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
typedef struct {
|
||||
_PyGenObject_HEAD(cr)
|
||||
} PyCoroObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyCoro_Type;
|
||||
PyAPI_DATA(PyTypeObject) _PyCoroWrapper_Type;
|
||||
extern PyTypeObject PyCoro_Type;
|
||||
extern PyTypeObject _PyCoroWrapper_Type;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) _PyAIterWrapper_Type;
|
||||
extern PyTypeObject _PyAIterWrapper_Type;
|
||||
PyObject *_PyAIterWrapper_New(PyObject *aiter);
|
||||
|
||||
#define PyCoro_CheckExact(op) (Py_TYPE(op) == &PyCoro_Type)
|
||||
PyObject *_PyCoro_GetAwaitableIter(PyObject *o);
|
||||
PyAPI_FUNC(PyObject *) PyCoro_New(struct _frame *,
|
||||
PyObject * PyCoro_New(struct _frame *,
|
||||
PyObject *name, PyObject *qualname);
|
||||
|
||||
/* Asynchronous Generators */
|
||||
|
@ -75,12 +76,12 @@ typedef struct {
|
|||
int ag_closed;
|
||||
} PyAsyncGenObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyAsyncGen_Type;
|
||||
PyAPI_DATA(PyTypeObject) _PyAsyncGenASend_Type;
|
||||
PyAPI_DATA(PyTypeObject) _PyAsyncGenWrappedValue_Type;
|
||||
PyAPI_DATA(PyTypeObject) _PyAsyncGenAThrow_Type;
|
||||
extern PyTypeObject PyAsyncGen_Type;
|
||||
extern PyTypeObject _PyAsyncGenASend_Type;
|
||||
extern PyTypeObject _PyAsyncGenWrappedValue_Type;
|
||||
extern PyTypeObject _PyAsyncGenAThrow_Type;
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyAsyncGen_New(struct _frame *,
|
||||
PyObject * PyAsyncGen_New(struct _frame *,
|
||||
PyObject *name, PyObject *qualname);
|
||||
|
||||
#define PyAsyncGen_CheckExact(op) (Py_TYPE(op) == &PyAsyncGen_Type)
|
||||
|
|
1
third_party/python/Include/grammar.h
vendored
1
third_party/python/Include/grammar.h
vendored
|
@ -1,5 +1,6 @@
|
|||
#ifndef Py_GRAMMAR_H
|
||||
#define Py_GRAMMAR_H
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "third_party/python/Include/bitset.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
|
65
third_party/python/Include/import.h
vendored
65
third_party/python/Include/import.h
vendored
|
@ -1,54 +1,55 @@
|
|||
#ifndef Py_IMPORT_H
|
||||
#define Py_IMPORT_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) _PyImportZip_Init(void);
|
||||
void _PyImportZip_Init(void);
|
||||
|
||||
PyMODINIT_FUNC PyInit_imp(void);
|
||||
#endif /* !Py_LIMITED_API */
|
||||
PyAPI_FUNC(long) PyImport_GetMagicNumber(void);
|
||||
PyAPI_FUNC(const char *) PyImport_GetMagicTag(void);
|
||||
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModule(
|
||||
long PyImport_GetMagicNumber(void);
|
||||
const char * PyImport_GetMagicTag(void);
|
||||
PyObject * PyImport_ExecCodeModule(
|
||||
const char *name, /* UTF-8 encoded string */
|
||||
PyObject *co
|
||||
);
|
||||
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx(
|
||||
PyObject * PyImport_ExecCodeModuleEx(
|
||||
const char *name, /* UTF-8 encoded string */
|
||||
PyObject *co,
|
||||
const char *pathname /* decoded from the filesystem encoding */
|
||||
);
|
||||
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleWithPathnames(
|
||||
PyObject * PyImport_ExecCodeModuleWithPathnames(
|
||||
const char *name, /* UTF-8 encoded string */
|
||||
PyObject *co,
|
||||
const char *pathname, /* decoded from the filesystem encoding */
|
||||
const char *cpathname /* decoded from the filesystem encoding */
|
||||
);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleObject(
|
||||
PyObject * PyImport_ExecCodeModuleObject(
|
||||
PyObject *name,
|
||||
PyObject *co,
|
||||
PyObject *pathname,
|
||||
PyObject *cpathname
|
||||
);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void);
|
||||
PyObject * PyImport_GetModuleDict(void);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_FUNC(PyObject *) PyImport_AddModuleObject(
|
||||
PyObject * PyImport_AddModuleObject(
|
||||
PyObject *name
|
||||
);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyImport_AddModule(
|
||||
PyObject * PyImport_AddModule(
|
||||
const char *name /* UTF-8 encoded string */
|
||||
);
|
||||
PyAPI_FUNC(PyObject *) PyImport_ImportModule(
|
||||
PyObject * PyImport_ImportModule(
|
||||
const char *name /* UTF-8 encoded string */
|
||||
);
|
||||
PyAPI_FUNC(PyObject *) PyImport_ImportModuleNoBlock(
|
||||
PyObject * PyImport_ImportModuleNoBlock(
|
||||
const char *name /* UTF-8 encoded string */
|
||||
);
|
||||
PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel(
|
||||
PyObject * PyImport_ImportModuleLevel(
|
||||
const char *name, /* UTF-8 encoded string */
|
||||
PyObject *globals,
|
||||
PyObject *locals,
|
||||
|
@ -56,7 +57,7 @@ PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel(
|
|||
int level
|
||||
);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||
PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevelObject(
|
||||
PyObject * PyImport_ImportModuleLevelObject(
|
||||
PyObject *name,
|
||||
PyObject *globals,
|
||||
PyObject *locals,
|
||||
|
@ -68,51 +69,51 @@ PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevelObject(
|
|||
#define PyImport_ImportModuleEx(n, g, l, f) \
|
||||
PyImport_ImportModuleLevel(n, g, l, f, 0)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyImport_GetImporter(PyObject *path);
|
||||
PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name);
|
||||
PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m);
|
||||
PyAPI_FUNC(void) PyImport_Cleanup(void);
|
||||
PyObject * PyImport_GetImporter(PyObject *path);
|
||||
PyObject * PyImport_Import(PyObject *name);
|
||||
PyObject * PyImport_ReloadModule(PyObject *m);
|
||||
void PyImport_Cleanup(void);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_FUNC(int) PyImport_ImportFrozenModuleObject(
|
||||
int PyImport_ImportFrozenModuleObject(
|
||||
PyObject *name
|
||||
);
|
||||
#endif
|
||||
PyAPI_FUNC(int) PyImport_ImportFrozenModule(
|
||||
int PyImport_ImportFrozenModule(
|
||||
const char *name /* UTF-8 encoded string */
|
||||
);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
#ifdef WITH_THREAD
|
||||
PyAPI_FUNC(void) _PyImport_AcquireLock(void);
|
||||
PyAPI_FUNC(int) _PyImport_ReleaseLock(void);
|
||||
void _PyImport_AcquireLock(void);
|
||||
int _PyImport_ReleaseLock(void);
|
||||
#else
|
||||
#define _PyImport_AcquireLock()
|
||||
#define _PyImport_ReleaseLock() 1
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(void) _PyImport_ReInitLock(void);
|
||||
void _PyImport_ReInitLock(void);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyImport_FindBuiltin(
|
||||
PyObject * _PyImport_FindBuiltin(
|
||||
const char *name /* UTF-8 encoded string */
|
||||
);
|
||||
PyAPI_FUNC(PyObject *) _PyImport_FindExtensionObject(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(int) _PyImport_FixupBuiltin(
|
||||
PyObject * _PyImport_FindExtensionObject(PyObject *, PyObject *);
|
||||
int _PyImport_FixupBuiltin(
|
||||
PyObject *mod,
|
||||
const char *name /* UTF-8 encoded string */
|
||||
);
|
||||
PyAPI_FUNC(int) _PyImport_FixupExtensionObject(PyObject*, PyObject *, PyObject *);
|
||||
int _PyImport_FixupExtensionObject(PyObject*, PyObject *, PyObject *);
|
||||
|
||||
struct _inittab {
|
||||
const char *name; /* ASCII encoded string */
|
||||
PyObject* (*initfunc)(void);
|
||||
};
|
||||
PyAPI_DATA(struct _inittab *) PyImport_Inittab;
|
||||
PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab);
|
||||
extern struct _inittab * PyImport_Inittab;
|
||||
int PyImport_ExtendInittab(struct _inittab *newtab);
|
||||
#endif /* Py_LIMITED_API */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyNullImporter_Type;
|
||||
extern PyTypeObject PyNullImporter_Type;
|
||||
|
||||
PyAPI_FUNC(int) PyImport_AppendInittab(
|
||||
int PyImport_AppendInittab(
|
||||
const char *name, /* ASCII encoded string */
|
||||
PyObject* (*initfunc)(void)
|
||||
);
|
||||
|
@ -127,7 +128,7 @@ struct _frozen {
|
|||
/* Embedding apps may change this pointer to point to their favorite
|
||||
collection of frozen modules: */
|
||||
|
||||
PyAPI_DATA(const struct _frozen *) PyImport_FrozenModules;
|
||||
extern const struct _frozen * PyImport_FrozenModules;
|
||||
#endif
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
10
third_party/python/Include/intrcheck.h
vendored
10
third_party/python/Include/intrcheck.h
vendored
|
@ -3,16 +3,16 @@
|
|||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
PyAPI_FUNC(int) PyOS_InterruptOccurred(void);
|
||||
PyAPI_FUNC(void) PyOS_InitInterrupts(void);
|
||||
PyAPI_FUNC(void) PyOS_AfterFork(void);
|
||||
int PyOS_InterruptOccurred(void);
|
||||
void PyOS_InitInterrupts(void);
|
||||
void PyOS_AfterFork(void);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(int) _PyOS_IsMainThread(void);
|
||||
int _PyOS_IsMainThread(void);
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
/* windows.h is not included by Python.h so use void* instead of HANDLE */
|
||||
PyAPI_FUNC(void*) _PyOS_SigintEvent(void);
|
||||
void* _PyOS_SigintEvent(void);
|
||||
#endif
|
||||
#endif /* !Py_LIMITED_API */
|
||||
|
||||
|
|
11
third_party/python/Include/iterobject.h
vendored
11
third_party/python/Include/iterobject.h
vendored
|
@ -1,20 +1,21 @@
|
|||
#ifndef Py_ITEROBJECT_H
|
||||
#define Py_ITEROBJECT_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PySeqIter_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyCallIter_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyCmpWrapper_Type;
|
||||
extern PyTypeObject PySeqIter_Type;
|
||||
extern PyTypeObject PyCallIter_Type;
|
||||
extern PyTypeObject PyCmpWrapper_Type;
|
||||
|
||||
#define PySeqIter_Check(op) (Py_TYPE(op) == &PySeqIter_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PySeqIter_New(PyObject *);
|
||||
PyObject * PySeqIter_New(PyObject *);
|
||||
|
||||
|
||||
#define PyCallIter_Check(op) (Py_TYPE(op) == &PyCallIter_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCallIter_New(PyObject *, PyObject *);
|
||||
PyObject * PyCallIter_New(PyObject *, PyObject *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !Py_ITEROBJECT_H */
|
||||
|
|
37
third_party/python/Include/listobject.h
vendored
37
third_party/python/Include/listobject.h
vendored
|
@ -1,5 +1,6 @@
|
|||
#ifndef Py_LISTOBJECT_H
|
||||
#define Py_LISTOBJECT_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -38,31 +39,31 @@ typedef struct {
|
|||
} PyListObject;
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyList_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyListIter_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyListRevIter_Type;
|
||||
PyAPI_DATA(PyTypeObject) PySortWrapper_Type;
|
||||
extern PyTypeObject PyList_Type;
|
||||
extern PyTypeObject PyListIter_Type;
|
||||
extern PyTypeObject PyListRevIter_Type;
|
||||
extern PyTypeObject PySortWrapper_Type;
|
||||
|
||||
#define PyList_Check(op) \
|
||||
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LIST_SUBCLASS)
|
||||
#define PyList_CheckExact(op) (Py_TYPE(op) == &PyList_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyList_New(Py_ssize_t size);
|
||||
PyAPI_FUNC(Py_ssize_t) PyList_Size(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyList_GetItem(PyObject *, Py_ssize_t);
|
||||
PyAPI_FUNC(int) PyList_SetItem(PyObject *, Py_ssize_t, PyObject *);
|
||||
PyAPI_FUNC(int) PyList_Insert(PyObject *, Py_ssize_t, PyObject *);
|
||||
PyAPI_FUNC(int) PyList_Append(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyList_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t);
|
||||
PyAPI_FUNC(int) PyList_SetSlice(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *);
|
||||
PyAPI_FUNC(int) PyList_Sort(PyObject *);
|
||||
PyAPI_FUNC(int) PyList_Reverse(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyList_AsTuple(PyObject *);
|
||||
PyObject * PyList_New(Py_ssize_t size);
|
||||
Py_ssize_t PyList_Size(PyObject *);
|
||||
PyObject * PyList_GetItem(PyObject *, Py_ssize_t);
|
||||
int PyList_SetItem(PyObject *, Py_ssize_t, PyObject *);
|
||||
int PyList_Insert(PyObject *, Py_ssize_t, PyObject *);
|
||||
int PyList_Append(PyObject *, PyObject *);
|
||||
PyObject * PyList_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t);
|
||||
int PyList_SetSlice(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *);
|
||||
int PyList_Sort(PyObject *);
|
||||
int PyList_Reverse(PyObject *);
|
||||
PyObject * PyList_AsTuple(PyObject *);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) _PyList_Extend(PyListObject *, PyObject *);
|
||||
PyObject * _PyList_Extend(PyListObject *, PyObject *);
|
||||
|
||||
PyAPI_FUNC(int) PyList_ClearFreeList(void);
|
||||
PyAPI_FUNC(void) _PyList_DebugMallocStats(FILE *out);
|
||||
int PyList_ClearFreeList(void);
|
||||
void _PyList_DebugMallocStats(FILE *out);
|
||||
#endif
|
||||
|
||||
/* Macro, trading safety for speed */
|
||||
|
|
7
third_party/python/Include/longintrepr.h
vendored
7
third_party/python/Include/longintrepr.h
vendored
|
@ -1,7 +1,8 @@
|
|||
#ifndef Py_LIMITED_API
|
||||
#ifndef Py_LONGINTREPR_H
|
||||
#define Py_LONGINTREPR_H
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/longobject.h"
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/pyport.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
@ -87,10 +88,10 @@ struct _longobject {
|
|||
digit ob_digit[1];
|
||||
};
|
||||
|
||||
PyAPI_FUNC(PyLongObject *) _PyLong_New(Py_ssize_t);
|
||||
PyLongObject * _PyLong_New(Py_ssize_t);
|
||||
|
||||
/* Return a copy of src. */
|
||||
PyAPI_FUNC(PyObject *) _PyLong_Copy(PyLongObject *src);
|
||||
PyObject * _PyLong_Copy(PyLongObject *src);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !Py_LONGINTREPR_H */
|
||||
|
|
87
third_party/python/Include/longobject.h
vendored
87
third_party/python/Include/longobject.h
vendored
|
@ -1,5 +1,8 @@
|
|||
#ifndef Py_LONGOBJECT_H
|
||||
#define Py_LONGOBJECT_H
|
||||
#include "third_party/python/Include/bytesobject.h"
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/unicodeobject.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -7,27 +10,27 @@ COSMOPOLITAN_C_START_
|
|||
|
||||
typedef struct _longobject PyLongObject; /* Revealed in longintrepr.h */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyLong_Type;
|
||||
extern PyTypeObject PyLong_Type;
|
||||
|
||||
#define PyLong_Check(op) \
|
||||
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS)
|
||||
#define PyLong_CheckExact(op) (Py_TYPE(op) == &PyLong_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromLong(long);
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long);
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromSize_t(size_t);
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromSsize_t(Py_ssize_t);
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromDouble(double);
|
||||
PyAPI_FUNC(long) PyLong_AsLong(PyObject *);
|
||||
PyAPI_FUNC(long) PyLong_AsLongAndOverflow(PyObject *, int *);
|
||||
PyAPI_FUNC(Py_ssize_t) PyLong_AsSsize_t(PyObject *);
|
||||
PyAPI_FUNC(size_t) PyLong_AsSize_t(PyObject *);
|
||||
PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *);
|
||||
PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *);
|
||||
PyObject * PyLong_FromLong(long);
|
||||
PyObject * PyLong_FromUnsignedLong(unsigned long);
|
||||
PyObject * PyLong_FromSize_t(size_t);
|
||||
PyObject * PyLong_FromSsize_t(Py_ssize_t);
|
||||
PyObject * PyLong_FromDouble(double);
|
||||
long PyLong_AsLong(PyObject *);
|
||||
long PyLong_AsLongAndOverflow(PyObject *, int *);
|
||||
Py_ssize_t PyLong_AsSsize_t(PyObject *);
|
||||
size_t PyLong_AsSize_t(PyObject *);
|
||||
unsigned long PyLong_AsUnsignedLong(PyObject *);
|
||||
unsigned long PyLong_AsUnsignedLongMask(PyObject *);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(int) _PyLong_AsInt(PyObject *);
|
||||
int _PyLong_AsInt(PyObject *);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyLong_GetInfo(void);
|
||||
PyObject * PyLong_GetInfo(void);
|
||||
|
||||
/* It may be useful in the future. I've added it in the PyInt -> PyLong
|
||||
cleanup to keep the extra information. [CH] */
|
||||
|
@ -66,7 +69,7 @@ PyAPI_FUNC(PyObject *) PyLong_GetInfo(void);
|
|||
/* Used by Python/mystrtoul.c, _PyBytes_FromHex(),
|
||||
_PyBytes_DecodeEscapeRecode(), etc. */
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_DATA(unsigned char) _PyLong_DigitValue[256];
|
||||
extern unsigned char _PyLong_DigitValue[256];
|
||||
#endif
|
||||
|
||||
/* _PyLong_Frexp returns a double x and an exponent e such that the
|
||||
|
@ -76,25 +79,25 @@ PyAPI_DATA(unsigned char) _PyLong_DigitValue[256];
|
|||
possible if the number of bits doesn't fit into a Py_ssize_t, sets
|
||||
OverflowError and returns -1.0 for x, 0 for e. */
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(double) _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e);
|
||||
double _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e);
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(double) PyLong_AsDouble(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromVoidPtr(void *);
|
||||
PyAPI_FUNC(void *) PyLong_AsVoidPtr(PyObject *);
|
||||
double PyLong_AsDouble(PyObject *);
|
||||
PyObject * PyLong_FromVoidPtr(void *);
|
||||
void * PyLong_AsVoidPtr(PyObject *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromLongLong(long long);
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLongLong(unsigned long long);
|
||||
PyAPI_FUNC(long long) PyLong_AsLongLong(PyObject *);
|
||||
PyAPI_FUNC(unsigned long long) PyLong_AsUnsignedLongLong(PyObject *);
|
||||
PyAPI_FUNC(unsigned long long) PyLong_AsUnsignedLongLongMask(PyObject *);
|
||||
PyAPI_FUNC(long long) PyLong_AsLongLongAndOverflow(PyObject *, int *);
|
||||
PyObject * PyLong_FromLongLong(long long);
|
||||
PyObject * PyLong_FromUnsignedLongLong(unsigned long long);
|
||||
long long PyLong_AsLongLong(PyObject *);
|
||||
unsigned long long PyLong_AsUnsignedLongLong(PyObject *);
|
||||
unsigned long long PyLong_AsUnsignedLongLongMask(PyObject *);
|
||||
long long PyLong_AsLongLongAndOverflow(PyObject *, int *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromString(const char *, char **, int);
|
||||
PyObject * PyLong_FromString(const char *, char **, int);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int);
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromUnicodeObject(PyObject *u, int base);
|
||||
PyAPI_FUNC(PyObject *) _PyLong_FromBytes(const char *, Py_ssize_t, int);
|
||||
PyObject * PyLong_FromUnicode(Py_UNICODE*, Py_ssize_t, int);
|
||||
PyObject * PyLong_FromUnicodeObject(PyObject *u, int base);
|
||||
PyObject * _PyLong_FromBytes(const char *, Py_ssize_t, int);
|
||||
#endif
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
|
@ -102,7 +105,7 @@ PyAPI_FUNC(PyObject *) _PyLong_FromBytes(const char *, Py_ssize_t, int);
|
|||
v must not be NULL, and must be a normalized long.
|
||||
There are no error cases.
|
||||
*/
|
||||
PyAPI_FUNC(int) _PyLong_Sign(PyObject *v);
|
||||
int _PyLong_Sign(PyObject *v);
|
||||
|
||||
|
||||
/* _PyLong_NumBits. Return the number of bits needed to represent the
|
||||
|
@ -112,7 +115,7 @@ PyAPI_FUNC(int) _PyLong_Sign(PyObject *v);
|
|||
(size_t)-1 is returned and OverflowError set if the true result doesn't
|
||||
fit in a size_t.
|
||||
*/
|
||||
PyAPI_FUNC(size_t) _PyLong_NumBits(PyObject *v);
|
||||
size_t _PyLong_NumBits(PyObject *v);
|
||||
|
||||
/* _PyLong_DivmodNear. Given integers a and b, compute the nearest
|
||||
integer q to the exact quotient a / b, rounding to the nearest even integer
|
||||
|
@ -120,7 +123,7 @@ PyAPI_FUNC(size_t) _PyLong_NumBits(PyObject *v);
|
|||
will satisfy abs(r) <= abs(b)/2, with equality possible only if q is
|
||||
even.
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) _PyLong_DivmodNear(PyObject *, PyObject *);
|
||||
PyObject * _PyLong_DivmodNear(PyObject *, PyObject *);
|
||||
|
||||
/* _PyLong_FromByteArray: View the n unsigned bytes as a binary integer in
|
||||
base 256, and return a Python int with the same numeric value.
|
||||
|
@ -135,7 +138,7 @@ PyAPI_FUNC(PyObject *) _PyLong_DivmodNear(PyObject *, PyObject *);
|
|||
+ Return NULL with the appropriate exception set if there's not
|
||||
enough memory to create the Python int.
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) _PyLong_FromByteArray(
|
||||
PyObject * _PyLong_FromByteArray(
|
||||
const unsigned char* bytes, size_t n,
|
||||
int little_endian, int is_signed);
|
||||
|
||||
|
@ -158,7 +161,7 @@ PyAPI_FUNC(PyObject *) _PyLong_FromByteArray(
|
|||
being large enough to hold a sign bit. OverflowError is set in this
|
||||
case, but bytes holds the least-significant n bytes of the true value.
|
||||
*/
|
||||
PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v,
|
||||
int _PyLong_AsByteArray(PyLongObject* v,
|
||||
unsigned char* bytes, size_t n,
|
||||
int little_endian, int is_signed);
|
||||
|
||||
|
@ -167,19 +170,19 @@ PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v,
|
|||
nb_int slot is not available or the result of the call to nb_int
|
||||
returns something not of type int.
|
||||
*/
|
||||
PyAPI_FUNC(PyLongObject *)_PyLong_FromNbInt(PyObject *);
|
||||
PyLongObject *_PyLong_FromNbInt(PyObject *);
|
||||
|
||||
/* _PyLong_Format: Convert the long to a string object with given base,
|
||||
appending a base prefix of 0[box] if base is 2, 8 or 16. */
|
||||
PyAPI_FUNC(PyObject *) _PyLong_Format(PyObject *obj, int base);
|
||||
PyObject * _PyLong_Format(PyObject *obj, int base);
|
||||
|
||||
PyAPI_FUNC(int) _PyLong_FormatWriter(
|
||||
int _PyLong_FormatWriter(
|
||||
_PyUnicodeWriter *writer,
|
||||
PyObject *obj,
|
||||
int base,
|
||||
int alternate);
|
||||
|
||||
PyAPI_FUNC(char*) _PyLong_FormatBytesWriter(
|
||||
char* _PyLong_FormatBytesWriter(
|
||||
_PyBytesWriter *writer,
|
||||
char *str,
|
||||
PyObject *obj,
|
||||
|
@ -188,7 +191,7 @@ PyAPI_FUNC(char*) _PyLong_FormatBytesWriter(
|
|||
|
||||
/* Format the object based on the format_spec, as defined in PEP 3101
|
||||
(Advanced String Formatting). */
|
||||
PyAPI_FUNC(int) _PyLong_FormatAdvancedWriter(
|
||||
int _PyLong_FormatAdvancedWriter(
|
||||
_PyUnicodeWriter *writer,
|
||||
PyObject *obj,
|
||||
PyObject *format_spec,
|
||||
|
@ -199,12 +202,12 @@ PyAPI_FUNC(int) _PyLong_FormatAdvancedWriter(
|
|||
/* These aren't really part of the int object, but they're handy. The
|
||||
functions are in Python/mystrtoul.c.
|
||||
*/
|
||||
PyAPI_FUNC(unsigned long) PyOS_strtoul(const char *, char **, int);
|
||||
PyAPI_FUNC(long) PyOS_strtol(const char *, char **, int);
|
||||
unsigned long PyOS_strtoul(const char *, char **, int);
|
||||
long PyOS_strtol(const char *, char **, int);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
/* For use by the gcd function in mathmodule.c */
|
||||
PyAPI_FUNC(PyObject *) _PyLong_GCD(PyObject *, PyObject *);
|
||||
PyObject * _PyLong_GCD(PyObject *, PyObject *);
|
||||
#endif /* !Py_LIMITED_API */
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
17
third_party/python/Include/marshal.h
vendored
17
third_party/python/Include/marshal.h
vendored
|
@ -1,21 +1,22 @@
|
|||
#ifndef Py_MARSHAL_H
|
||||
#define Py_MARSHAL_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
#define Py_MARSHAL_VERSION 4
|
||||
|
||||
PyAPI_FUNC(void) PyMarshal_WriteLongToFile(long, FILE *, int);
|
||||
PyAPI_FUNC(void) PyMarshal_WriteObjectToFile(PyObject *, FILE *, int);
|
||||
PyAPI_FUNC(PyObject *) PyMarshal_WriteObjectToString(PyObject *, int);
|
||||
void PyMarshal_WriteLongToFile(long, FILE *, int);
|
||||
void PyMarshal_WriteObjectToFile(PyObject *, FILE *, int);
|
||||
PyObject * PyMarshal_WriteObjectToString(PyObject *, int);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(long) PyMarshal_ReadLongFromFile(FILE *);
|
||||
PyAPI_FUNC(int) PyMarshal_ReadShortFromFile(FILE *);
|
||||
PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromFile(FILE *);
|
||||
PyAPI_FUNC(PyObject *) PyMarshal_ReadLastObjectFromFile(FILE *);
|
||||
long PyMarshal_ReadLongFromFile(FILE *);
|
||||
int PyMarshal_ReadShortFromFile(FILE *);
|
||||
PyObject * PyMarshal_ReadObjectFromFile(FILE *);
|
||||
PyObject * PyMarshal_ReadLastObjectFromFile(FILE *);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(const char *, Py_ssize_t);
|
||||
PyObject * PyMarshal_ReadObjectFromString(const char *, Py_ssize_t);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !Py_MARSHAL_H */
|
||||
|
|
13
third_party/python/Include/memoryobject.h
vendored
13
third_party/python/Include/memoryobject.h
vendored
|
@ -1,12 +1,13 @@
|
|||
#ifndef Py_MEMORYOBJECT_H
|
||||
#define Py_MEMORYOBJECT_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_DATA(PyTypeObject) _PyManagedBuffer_Type;
|
||||
extern PyTypeObject _PyManagedBuffer_Type;
|
||||
#endif
|
||||
PyAPI_DATA(PyTypeObject) PyMemoryView_Type;
|
||||
extern PyTypeObject PyMemoryView_Type;
|
||||
|
||||
#define PyMemoryView_Check(op) (Py_TYPE(op) == &PyMemoryView_Type)
|
||||
|
||||
|
@ -17,15 +18,15 @@ PyAPI_DATA(PyTypeObject) PyMemoryView_Type;
|
|||
#define PyMemoryView_GET_BASE(op) (((PyMemoryViewObject *)(op))->view.obj)
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyMemoryView_FromObject(PyObject *base);
|
||||
PyObject * PyMemoryView_FromObject(PyObject *base);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_FUNC(PyObject *) PyMemoryView_FromMemory(char *mem, Py_ssize_t size,
|
||||
PyObject * PyMemoryView_FromMemory(char *mem, Py_ssize_t size,
|
||||
int flags);
|
||||
#endif
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) PyMemoryView_FromBuffer(Py_buffer *info);
|
||||
PyObject * PyMemoryView_FromBuffer(Py_buffer *info);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyMemoryView_GetContiguous(PyObject *base,
|
||||
PyObject * PyMemoryView_GetContiguous(PyObject *base,
|
||||
int buffertype,
|
||||
char order);
|
||||
|
||||
|
|
24
third_party/python/Include/methodobject.h
vendored
24
third_party/python/Include/methodobject.h
vendored
|
@ -1,5 +1,7 @@
|
|||
#ifndef Py_METHODOBJECT_H
|
||||
#define Py_METHODOBJECT_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/pyport.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -7,7 +9,7 @@ COSMOPOLITAN_C_START_
|
|||
not Python methods in user-defined classes. See classobject.h
|
||||
for the latter. */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyCFunction_Type;
|
||||
extern PyTypeObject PyCFunction_Type;
|
||||
|
||||
#define PyCFunction_Check(op) (Py_TYPE(op) == &PyCFunction_Type)
|
||||
|
||||
|
@ -18,9 +20,9 @@ typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *,
|
|||
PyObject *);
|
||||
typedef PyObject *(*PyNoArgsFunction)(PyObject *);
|
||||
|
||||
PyAPI_FUNC(PyCFunction) PyCFunction_GetFunction(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyCFunction_GetSelf(PyObject *);
|
||||
PyAPI_FUNC(int) PyCFunction_GetFlags(PyObject *);
|
||||
PyCFunction PyCFunction_GetFunction(PyObject *);
|
||||
PyObject * PyCFunction_GetSelf(PyObject *);
|
||||
int PyCFunction_GetFlags(PyObject *);
|
||||
|
||||
/* Macros for direct access to these values. Type checks are *not*
|
||||
done, so use with care. */
|
||||
|
@ -33,15 +35,15 @@ PyAPI_FUNC(int) PyCFunction_GetFlags(PyObject *);
|
|||
#define PyCFunction_GET_FLAGS(func) \
|
||||
(((PyCFunctionObject *)func) -> m_ml -> ml_flags)
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *);
|
||||
PyObject * PyCFunction_Call(PyObject *, PyObject *, PyObject *);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) _PyCFunction_FastCallDict(PyObject *func,
|
||||
PyObject * _PyCFunction_FastCallDict(PyObject *func,
|
||||
PyObject **args,
|
||||
Py_ssize_t nargs,
|
||||
PyObject *kwargs);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyCFunction_FastCallKeywords(PyObject *func,
|
||||
PyObject * _PyCFunction_FastCallKeywords(PyObject *func,
|
||||
PyObject **stack,
|
||||
Py_ssize_t nargs,
|
||||
PyObject *kwnames);
|
||||
|
@ -57,7 +59,7 @@ struct PyMethodDef {
|
|||
typedef struct PyMethodDef PyMethodDef;
|
||||
|
||||
#define PyCFunction_New(ML, SELF) PyCFunction_NewEx((ML), (SELF), NULL)
|
||||
PyAPI_FUNC(PyObject *) PyCFunction_NewEx(PyMethodDef *, PyObject *,
|
||||
PyObject * PyCFunction_NewEx(PyMethodDef *, PyObject *,
|
||||
PyObject *);
|
||||
|
||||
/* Flag passed to newmethodobject */
|
||||
|
@ -93,11 +95,11 @@ typedef struct {
|
|||
} PyCFunctionObject;
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(int) PyCFunction_ClearFreeList(void);
|
||||
int PyCFunction_ClearFreeList(void);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) _PyCFunction_DebugMallocStats(FILE *out);
|
||||
PyAPI_FUNC(void) _PyMethod_DebugMallocStats(FILE *out);
|
||||
void _PyCFunction_DebugMallocStats(FILE *out);
|
||||
void _PyMethod_DebugMallocStats(FILE *out);
|
||||
#endif
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
53
third_party/python/Include/modsupport.h
vendored
53
third_party/python/Include/modsupport.h
vendored
|
@ -1,5 +1,8 @@
|
|||
#ifndef Py_MODSUPPORT_H
|
||||
#define Py_MODSUPPORT_H
|
||||
#include "third_party/python/Include/methodobject.h"
|
||||
#include "third_party/python/Include/moduleobject.h"
|
||||
#include "third_party/python/Include/object.h"
|
||||
#pragma GCC diagnostic ignored "-Wredundant-decls"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
@ -16,30 +19,30 @@ COSMOPOLITAN_C_START_
|
|||
#define Py_VaBuildValue _Py_VaBuildValue_SizeT
|
||||
#else
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) _Py_VaBuildValue_SizeT(const char *, va_list);
|
||||
PyObject * _Py_VaBuildValue_SizeT(const char *, va_list);
|
||||
#endif /* !Py_LIMITED_API */
|
||||
#endif
|
||||
|
||||
/* Due to a glitch in 3.2, the _SizeT versions weren't exported from the DLL. */
|
||||
#if !defined(PY_SSIZE_T_CLEAN) || !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...);
|
||||
PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...);
|
||||
PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *,
|
||||
int PyArg_Parse(PyObject *, const char *, ...);
|
||||
int PyArg_ParseTuple(PyObject *, const char *, ...);
|
||||
int PyArg_ParseTupleAndKeywords(PyObject *, PyObject *,
|
||||
const char *, char **, ...);
|
||||
PyAPI_FUNC(int) PyArg_VaParse(PyObject *, const char *, va_list);
|
||||
PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *,
|
||||
int PyArg_VaParse(PyObject *, const char *, va_list);
|
||||
int PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *,
|
||||
const char *, char **, va_list);
|
||||
#endif
|
||||
PyAPI_FUNC(int) PyArg_ValidateKeywordArguments(PyObject *);
|
||||
PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *, Py_ssize_t, Py_ssize_t, ...);
|
||||
PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...);
|
||||
PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...);
|
||||
int PyArg_ValidateKeywordArguments(PyObject *);
|
||||
int PyArg_UnpackTuple(PyObject *, const char *, Py_ssize_t, Py_ssize_t, ...);
|
||||
PyObject * Py_BuildValue(const char *, ...);
|
||||
PyObject * _Py_BuildValue_SizeT(const char *, ...);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(int) _PyArg_NoKeywords(const char *funcname, PyObject *kw);
|
||||
PyAPI_FUNC(int) _PyArg_NoPositional(const char *funcname, PyObject *args);
|
||||
int _PyArg_NoKeywords(const char *funcname, PyObject *kw);
|
||||
int _PyArg_NoPositional(const char *funcname, PyObject *args);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list);
|
||||
PyObject * Py_VaBuildValue(const char *, va_list);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
typedef struct _PyArg_Parser {
|
||||
|
@ -58,26 +61,26 @@ typedef struct _PyArg_Parser {
|
|||
#define _PyArg_ParseStack _PyArg_ParseStack_SizeT
|
||||
#define _PyArg_VaParseTupleAndKeywordsFast _PyArg_VaParseTupleAndKeywordsFast_SizeT
|
||||
#endif
|
||||
PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywordsFast(PyObject *, PyObject *,
|
||||
int _PyArg_ParseTupleAndKeywordsFast(PyObject *, PyObject *,
|
||||
struct _PyArg_Parser *, ...);
|
||||
PyAPI_FUNC(int) _PyArg_ParseStack(PyObject **args, Py_ssize_t nargs, PyObject *kwnames,
|
||||
int _PyArg_ParseStack(PyObject **args, Py_ssize_t nargs, PyObject *kwnames,
|
||||
struct _PyArg_Parser *, ...);
|
||||
PyAPI_FUNC(int) _PyArg_VaParseTupleAndKeywordsFast(PyObject *, PyObject *,
|
||||
int _PyArg_VaParseTupleAndKeywordsFast(PyObject *, PyObject *,
|
||||
struct _PyArg_Parser *, va_list);
|
||||
void _PyArg_Fini(void);
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(int) PyModule_AddObject(PyObject *, const char *, PyObject *);
|
||||
PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, const char *, long);
|
||||
PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char *);
|
||||
int PyModule_AddObject(PyObject *, const char *, PyObject *);
|
||||
int PyModule_AddIntConstant(PyObject *, const char *, long);
|
||||
int PyModule_AddStringConstant(PyObject *, const char *, const char *);
|
||||
#define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant(m, #c, c)
|
||||
#define PyModule_AddStringMacro(m, c) PyModule_AddStringConstant(m, #c, c)
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||
/* New in 3.5 */
|
||||
PyAPI_FUNC(int) PyModule_SetDocString(PyObject *, const char *);
|
||||
PyAPI_FUNC(int) PyModule_AddFunctions(PyObject *, PyMethodDef *);
|
||||
PyAPI_FUNC(int) PyModule_ExecDef(PyObject *module, PyModuleDef *def);
|
||||
int PyModule_SetDocString(PyObject *, const char *);
|
||||
int PyModule_AddFunctions(PyObject *, PyMethodDef *);
|
||||
int PyModule_ExecDef(PyObject *module, PyModuleDef *def);
|
||||
#endif
|
||||
|
||||
#define Py_CLEANUP_SUPPORTED 0x20000
|
||||
|
@ -142,7 +145,7 @@ PyAPI_FUNC(int) PyModule_ExecDef(PyObject *module, PyModuleDef *def);
|
|||
#define PyModule_FromDefAndSpec2 PyModule_FromDefAndSpec2TraceRefs
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyModule_Create2(struct PyModuleDef*,
|
||||
PyObject * PyModule_Create2(struct PyModuleDef*,
|
||||
int apiver);
|
||||
|
||||
#ifdef Py_LIMITED_API
|
||||
|
@ -155,7 +158,7 @@ PyAPI_FUNC(PyObject *) PyModule_Create2(struct PyModuleDef*,
|
|||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||
/* New in 3.5 */
|
||||
PyAPI_FUNC(PyObject *) PyModule_FromDefAndSpec2(PyModuleDef *def,
|
||||
PyObject * PyModule_FromDefAndSpec2(PyModuleDef *def,
|
||||
PyObject *spec,
|
||||
int module_api_version);
|
||||
|
||||
|
@ -169,7 +172,7 @@ PyAPI_FUNC(PyObject *) PyModule_FromDefAndSpec2(PyModuleDef *def,
|
|||
#endif /* New in 3.5 */
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_DATA(char *) _Py_PackageContext;
|
||||
extern char * _Py_PackageContext;
|
||||
#endif
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
30
third_party/python/Include/moduleobject.h
vendored
30
third_party/python/Include/moduleobject.h
vendored
|
@ -1,39 +1,41 @@
|
|||
#ifndef Py_MODULEOBJECT_H
|
||||
#define Py_MODULEOBJECT_H
|
||||
#include "third_party/python/Include/methodobject.h"
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyModule_Type;
|
||||
extern PyTypeObject PyModule_Type;
|
||||
|
||||
#define PyModule_Check(op) PyObject_TypeCheck(op, &PyModule_Type)
|
||||
#define PyModule_CheckExact(op) (Py_TYPE(op) == &PyModule_Type)
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_FUNC(PyObject *) PyModule_NewObject(
|
||||
PyObject * PyModule_NewObject(
|
||||
PyObject *name
|
||||
);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyModule_New(
|
||||
PyObject * PyModule_New(
|
||||
const char *name /* UTF-8 encoded string */
|
||||
);
|
||||
PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *);
|
||||
PyObject * PyModule_GetDict(PyObject *);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_FUNC(PyObject *) PyModule_GetNameObject(PyObject *);
|
||||
PyObject * PyModule_GetNameObject(PyObject *);
|
||||
#endif
|
||||
PyAPI_FUNC(const char *) PyModule_GetName(PyObject *);
|
||||
PyAPI_FUNC(const char *) PyModule_GetFilename(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyModule_GetFilenameObject(PyObject *);
|
||||
const char * PyModule_GetName(PyObject *);
|
||||
const char * PyModule_GetFilename(PyObject *);
|
||||
PyObject * PyModule_GetFilenameObject(PyObject *);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) _PyModule_Clear(PyObject *);
|
||||
PyAPI_FUNC(void) _PyModule_ClearDict(PyObject *);
|
||||
void _PyModule_Clear(PyObject *);
|
||||
void _PyModule_ClearDict(PyObject *);
|
||||
#endif
|
||||
PyAPI_FUNC(struct PyModuleDef*) PyModule_GetDef(PyObject*);
|
||||
PyAPI_FUNC(void*) PyModule_GetState(PyObject*);
|
||||
struct PyModuleDef* PyModule_GetDef(PyObject*);
|
||||
void* PyModule_GetState(PyObject*);
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||
/* New in 3.5 */
|
||||
PyAPI_FUNC(PyObject *) PyModuleDef_Init(struct PyModuleDef*);
|
||||
PyAPI_DATA(PyTypeObject) PyModuleDef_Type;
|
||||
PyObject * PyModuleDef_Init(struct PyModuleDef*);
|
||||
extern PyTypeObject PyModuleDef_Type;
|
||||
#endif
|
||||
|
||||
typedef struct PyModuleDef_Base {
|
||||
|
|
5
third_party/python/Include/namespaceobject.h
vendored
5
third_party/python/Include/namespaceobject.h
vendored
|
@ -1,12 +1,13 @@
|
|||
#ifndef NAMESPACEOBJECT_H
|
||||
#define NAMESPACEOBJECT_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_DATA(PyTypeObject) _PyNamespace_Type;
|
||||
extern PyTypeObject _PyNamespace_Type;
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyNamespace_New(PyObject *kwds);
|
||||
PyObject * _PyNamespace_New(PyObject *kwds);
|
||||
#endif /* !Py_LIMITED_API */
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
11
third_party/python/Include/node.h
vendored
11
third_party/python/Include/node.h
vendored
|
@ -1,5 +1,6 @@
|
|||
#ifndef Py_NODE_H
|
||||
#define Py_NODE_H
|
||||
#include "third_party/python/Include/pyport.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -12,12 +13,12 @@ typedef struct _node {
|
|||
struct _node *n_child;
|
||||
} node;
|
||||
|
||||
PyAPI_FUNC(node *) PyNode_New(int type);
|
||||
PyAPI_FUNC(int) PyNode_AddChild(node *n, int type,
|
||||
node * PyNode_New(int type);
|
||||
int PyNode_AddChild(node *n, int type,
|
||||
char *str, int lineno, int col_offset);
|
||||
PyAPI_FUNC(void) PyNode_Free(node *n);
|
||||
void PyNode_Free(node *n);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(Py_ssize_t) _PyNode_SizeOf(node *n);
|
||||
Py_ssize_t _PyNode_SizeOf(node *n);
|
||||
#endif
|
||||
|
||||
/* Node access functions */
|
||||
|
@ -32,7 +33,7 @@ PyAPI_FUNC(Py_ssize_t) _PyNode_SizeOf(node *n);
|
|||
/* Assert that the type of a node is what we expect */
|
||||
#define REQ(n, type) assert(TYPE(n) == (type))
|
||||
|
||||
PyAPI_FUNC(void) PyNode_ListTree(node *);
|
||||
void PyNode_ListTree(node *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !Py_NODE_H */
|
||||
|
|
187
third_party/python/Include/object.h
vendored
187
third_party/python/Include/object.h
vendored
|
@ -1,5 +1,8 @@
|
|||
#ifndef Py_OBJECT_H
|
||||
#define Py_OBJECT_H
|
||||
#define Py_OBJECT_H /* DO NOT INCLUDE pystate.h */
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "third_party/python/Include/op.h"
|
||||
#include "third_party/python/Include/pyport.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -446,12 +449,12 @@ typedef struct{
|
|||
PyType_Slot *slots; /* terminated by slot==0. */
|
||||
} PyType_Spec;
|
||||
|
||||
PyAPI_FUNC(PyObject*) PyType_FromSpec(PyType_Spec*);
|
||||
PyObject* PyType_FromSpec(PyType_Spec*);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_FUNC(PyObject*) PyType_FromSpecWithBases(PyType_Spec*, PyObject*);
|
||||
PyObject* PyType_FromSpecWithBases(PyType_Spec*, PyObject*);
|
||||
#endif
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03040000
|
||||
PyAPI_FUNC(void*) PyType_GetSlot(PyTypeObject*, int);
|
||||
void* PyType_GetSlot(PyTypeObject*, int);
|
||||
#endif
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
|
@ -480,100 +483,100 @@ typedef struct _heaptypeobject {
|
|||
#endif
|
||||
|
||||
/* Generic type check */
|
||||
PyAPI_FUNC(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *);
|
||||
int PyType_IsSubtype(PyTypeObject *, PyTypeObject *);
|
||||
#define PyObject_TypeCheck(ob, tp) \
|
||||
(Py_TYPE(ob) == (tp) || PyType_IsSubtype(Py_TYPE(ob), (tp)))
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyType_Type; /* built-in 'type' */
|
||||
PyAPI_DATA(PyTypeObject) PyBaseObject_Type; /* built-in 'object' */
|
||||
PyAPI_DATA(PyTypeObject) PySuper_Type; /* built-in 'super' */
|
||||
extern PyTypeObject PyType_Type; /* built-in 'type' */
|
||||
extern PyTypeObject PyBaseObject_Type; /* built-in 'object' */
|
||||
extern PyTypeObject PySuper_Type; /* built-in 'super' */
|
||||
|
||||
PyAPI_FUNC(unsigned long) PyType_GetFlags(PyTypeObject*);
|
||||
unsigned long PyType_GetFlags(PyTypeObject*);
|
||||
|
||||
#define PyType_Check(op) \
|
||||
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TYPE_SUBCLASS)
|
||||
#define PyType_CheckExact(op) (Py_TYPE(op) == &PyType_Type)
|
||||
|
||||
PyAPI_FUNC(int) PyType_Ready(PyTypeObject *);
|
||||
PyAPI_FUNC(PyObject *) PyType_GenericAlloc(PyTypeObject *, Py_ssize_t);
|
||||
PyAPI_FUNC(PyObject *) PyType_GenericNew(PyTypeObject *,
|
||||
int PyType_Ready(PyTypeObject *);
|
||||
PyObject * PyType_GenericAlloc(PyTypeObject *, Py_ssize_t);
|
||||
PyObject * PyType_GenericNew(PyTypeObject *,
|
||||
PyObject *, PyObject *);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) _PyType_Lookup(PyTypeObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) _PyType_LookupId(PyTypeObject *, _Py_Identifier *);
|
||||
PyAPI_FUNC(PyObject *) _PyObject_LookupSpecial(PyObject *, _Py_Identifier *);
|
||||
PyAPI_FUNC(PyTypeObject *) _PyType_CalculateMetaclass(PyTypeObject *, PyObject *);
|
||||
PyObject * _PyType_Lookup(PyTypeObject *, PyObject *);
|
||||
PyObject * _PyType_LookupId(PyTypeObject *, _Py_Identifier *);
|
||||
PyObject * _PyObject_LookupSpecial(PyObject *, _Py_Identifier *);
|
||||
PyTypeObject * _PyType_CalculateMetaclass(PyTypeObject *, PyObject *);
|
||||
#endif
|
||||
PyAPI_FUNC(unsigned int) PyType_ClearCache(void);
|
||||
PyAPI_FUNC(void) PyType_Modified(PyTypeObject *);
|
||||
unsigned int PyType_ClearCache(void);
|
||||
void PyType_Modified(PyTypeObject *);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) _PyType_GetDocFromInternalDoc(const char *, const char *);
|
||||
PyAPI_FUNC(PyObject *) _PyType_GetTextSignatureFromInternalDoc(const char *, const char *);
|
||||
PyObject * _PyType_GetDocFromInternalDoc(const char *, const char *);
|
||||
PyObject * _PyType_GetTextSignatureFromInternalDoc(const char *, const char *);
|
||||
#endif
|
||||
|
||||
/* Generic operations on objects */
|
||||
#ifndef Py_LIMITED_API
|
||||
struct _Py_Identifier;
|
||||
PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int);
|
||||
PyAPI_FUNC(void) _Py_BreakPoint(void);
|
||||
PyAPI_FUNC(void) _PyObject_Dump(PyObject *);
|
||||
PyAPI_FUNC(int) _PyObject_IsFreed(PyObject *);
|
||||
int PyObject_Print(PyObject *, FILE *, int);
|
||||
void _Py_BreakPoint(void);
|
||||
void _PyObject_Dump(PyObject *);
|
||||
int _PyObject_IsFreed(PyObject *);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyObject_Str(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyObject_ASCII(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyObject_Bytes(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyObject_RichCompare(PyObject *, PyObject *, int);
|
||||
PyAPI_FUNC(int) PyObject_RichCompareBool(PyObject *, PyObject *, int);
|
||||
PyAPI_FUNC(PyObject *) PyObject_GetAttrString(PyObject *, const char *);
|
||||
PyAPI_FUNC(int) PyObject_SetAttrString(PyObject *, const char *, PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_HasAttrString(PyObject *, const char *);
|
||||
PyAPI_FUNC(PyObject *) PyObject_GetAttr(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_SetAttr(PyObject *, PyObject *, PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_HasAttr(PyObject *, PyObject *);
|
||||
PyObject * PyObject_Repr(PyObject *);
|
||||
PyObject * PyObject_Str(PyObject *);
|
||||
PyObject * PyObject_ASCII(PyObject *);
|
||||
PyObject * PyObject_Bytes(PyObject *);
|
||||
PyObject * PyObject_RichCompare(PyObject *, PyObject *, int);
|
||||
int PyObject_RichCompareBool(PyObject *, PyObject *, int);
|
||||
PyObject * PyObject_GetAttrString(PyObject *, const char *);
|
||||
int PyObject_SetAttrString(PyObject *, const char *, PyObject *);
|
||||
int PyObject_HasAttrString(PyObject *, const char *);
|
||||
PyObject * PyObject_GetAttr(PyObject *, PyObject *);
|
||||
int PyObject_SetAttr(PyObject *, PyObject *, PyObject *);
|
||||
int PyObject_HasAttr(PyObject *, PyObject *);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(int) _PyObject_IsAbstract(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) _PyObject_GetAttrId(PyObject *, struct _Py_Identifier *);
|
||||
PyAPI_FUNC(int) _PyObject_SetAttrId(PyObject *, struct _Py_Identifier *, PyObject *);
|
||||
PyAPI_FUNC(int) _PyObject_HasAttrId(PyObject *, struct _Py_Identifier *);
|
||||
PyAPI_FUNC(PyObject **) _PyObject_GetDictPtr(PyObject *);
|
||||
int _PyObject_IsAbstract(PyObject *);
|
||||
PyObject * _PyObject_GetAttrId(PyObject *, struct _Py_Identifier *);
|
||||
int _PyObject_SetAttrId(PyObject *, struct _Py_Identifier *, PyObject *);
|
||||
int _PyObject_HasAttrId(PyObject *, struct _Py_Identifier *);
|
||||
PyObject ** _PyObject_GetDictPtr(PyObject *);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyObject_SelfIter(PyObject *);
|
||||
PyObject * PyObject_SelfIter(PyObject *);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) _PyObject_NextNotImplemented(PyObject *);
|
||||
PyObject * _PyObject_NextNotImplemented(PyObject *);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyObject_GenericGetAttr(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_GenericSetAttr(PyObject *,
|
||||
PyObject * PyObject_GenericGetAttr(PyObject *, PyObject *);
|
||||
int PyObject_GenericSetAttr(PyObject *,
|
||||
PyObject *, PyObject *);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_FUNC(int) PyObject_GenericSetDict(PyObject *, PyObject *, void *);
|
||||
int PyObject_GenericSetDict(PyObject *, PyObject *, void *);
|
||||
#endif
|
||||
PyAPI_FUNC(Py_hash_t) PyObject_Hash(PyObject *);
|
||||
PyAPI_FUNC(Py_hash_t) PyObject_HashNotImplemented(PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_IsTrue(PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_Not(PyObject *);
|
||||
PyAPI_FUNC(int) PyCallable_Check(PyObject *);
|
||||
Py_hash_t PyObject_Hash(PyObject *);
|
||||
Py_hash_t PyObject_HashNotImplemented(PyObject *);
|
||||
int PyObject_IsTrue(PyObject *);
|
||||
int PyObject_Not(PyObject *);
|
||||
int PyCallable_Check(PyObject *);
|
||||
|
||||
PyAPI_FUNC(void) PyObject_ClearWeakRefs(PyObject *);
|
||||
void PyObject_ClearWeakRefs(PyObject *);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) PyObject_CallFinalizer(PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_CallFinalizerFromDealloc(PyObject *);
|
||||
void PyObject_CallFinalizer(PyObject *);
|
||||
int PyObject_CallFinalizerFromDealloc(PyObject *);
|
||||
#endif
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
/* Same as PyObject_Generic{Get,Set}Attr, but passing the attributes
|
||||
dict as the last parameter. */
|
||||
PyAPI_FUNC(PyObject *)
|
||||
PyObject *
|
||||
_PyObject_GenericGetAttrWithDict(PyObject *, PyObject *, PyObject *);
|
||||
PyAPI_FUNC(int)
|
||||
int
|
||||
_PyObject_GenericSetAttrWithDict(PyObject *, PyObject *,
|
||||
PyObject *, PyObject *);
|
||||
#endif /* !Py_LIMITED_API */
|
||||
|
||||
/* Helper to look up a builtin object */
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *)
|
||||
PyObject *
|
||||
_PyObject_GetBuiltin(const char *name);
|
||||
#endif
|
||||
|
||||
|
@ -582,12 +585,12 @@ _PyObject_GetBuiltin(const char *name);
|
|||
returning the names of the current locals. In this case, if there are
|
||||
no current locals, NULL is returned, and PyErr_Occurred() is false.
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) PyObject_Dir(PyObject *);
|
||||
PyObject * PyObject_Dir(PyObject *);
|
||||
|
||||
|
||||
/* Helpers for printing recursive container types */
|
||||
PyAPI_FUNC(int) Py_ReprEnter(PyObject *);
|
||||
PyAPI_FUNC(void) Py_ReprLeave(PyObject *);
|
||||
int Py_ReprEnter(PyObject *);
|
||||
void Py_ReprLeave(PyObject *);
|
||||
|
||||
/* Flag bits for printing: */
|
||||
#define Py_PRINT_RAW 1 /* No string quotes etc. */
|
||||
|
@ -711,10 +714,10 @@ you can count such references to the type object.)
|
|||
* #ifdefs (we used to do that -- it was impenetrable).
|
||||
*/
|
||||
#ifdef Py_REF_DEBUG
|
||||
PyAPI_DATA(Py_ssize_t) _Py_RefTotal;
|
||||
PyAPI_FUNC(void) _Py_NegativeRefcount(const char *fname,
|
||||
extern Py_ssize_t _Py_RefTotal;
|
||||
void _Py_NegativeRefcount(const char *fname,
|
||||
int lineno, PyObject *op);
|
||||
PyAPI_FUNC(Py_ssize_t) _Py_GetRefTotal(void);
|
||||
Py_ssize_t _Py_GetRefTotal(void);
|
||||
#define _Py_INC_REFTOTAL _Py_RefTotal++
|
||||
#define _Py_DEC_REFTOTAL _Py_RefTotal--
|
||||
#define _Py_REF_DEBUG_COMMA ,
|
||||
|
@ -726,7 +729,7 @@ PyAPI_FUNC(Py_ssize_t) _Py_GetRefTotal(void);
|
|||
/* Py_REF_DEBUG also controls the display of refcounts and memory block
|
||||
* allocations at the interactive prompt and at interpreter shutdown
|
||||
*/
|
||||
PyAPI_FUNC(void) _PyDebug_PrintTotalRefs(void);
|
||||
void _PyDebug_PrintTotalRefs(void);
|
||||
#define _PY_DEBUG_PRINT_TOTAL_REFS() _PyDebug_PrintTotalRefs()
|
||||
#else
|
||||
#define _Py_INC_REFTOTAL
|
||||
|
@ -737,8 +740,8 @@ PyAPI_FUNC(void) _PyDebug_PrintTotalRefs(void);
|
|||
#endif /* Py_REF_DEBUG */
|
||||
|
||||
#ifdef COUNT_ALLOCS
|
||||
PyAPI_FUNC(void) inc_count(PyTypeObject *);
|
||||
PyAPI_FUNC(void) dec_count(PyTypeObject *);
|
||||
void inc_count(PyTypeObject *);
|
||||
void dec_count(PyTypeObject *);
|
||||
#define _Py_INC_TPALLOCS(OP) inc_count(Py_TYPE(OP))
|
||||
#define _Py_INC_TPFREES(OP) dec_count(Py_TYPE(OP))
|
||||
#define _Py_DEC_TPFREES(OP) Py_TYPE(OP)->tp_frees--
|
||||
|
@ -752,12 +755,12 @@ PyAPI_FUNC(void) dec_count(PyTypeObject *);
|
|||
|
||||
#ifdef Py_TRACE_REFS
|
||||
/* Py_TRACE_REFS is such major surgery that we call external routines. */
|
||||
PyAPI_FUNC(void) _Py_NewReference(PyObject *);
|
||||
PyAPI_FUNC(void) _Py_ForgetReference(PyObject *);
|
||||
PyAPI_FUNC(void) _Py_Dealloc(PyObject *);
|
||||
PyAPI_FUNC(void) _Py_PrintReferences(FILE *);
|
||||
PyAPI_FUNC(void) _Py_PrintReferenceAddresses(FILE *);
|
||||
PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force);
|
||||
void _Py_NewReference(PyObject *);
|
||||
void _Py_ForgetReference(PyObject *);
|
||||
void _Py_Dealloc(PyObject *);
|
||||
void _Py_PrintReferences(FILE *);
|
||||
void _Py_PrintReferenceAddresses(FILE *);
|
||||
void _Py_AddToAllObjects(PyObject *, int force);
|
||||
|
||||
#else
|
||||
/* Without Py_TRACE_REFS, there's little enough to do that we expand code
|
||||
|
@ -771,7 +774,7 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force);
|
|||
#define _Py_ForgetReference(op) _Py_INC_TPFREES(op)
|
||||
|
||||
#ifdef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) _Py_Dealloc(PyObject *);
|
||||
void _Py_Dealloc(PyObject *);
|
||||
#else
|
||||
#define _Py_Dealloc(op) ( \
|
||||
_Py_INC_TPFREES(op) _Py_COUNT_ALLOCS_COMMA \
|
||||
|
@ -891,12 +894,12 @@ PyAPI_FUNC(void) _Py_Dealloc(PyObject *);
|
|||
These are provided as conveniences to Python runtime embedders, so that
|
||||
they can have object code that is not dependent on Python compilation flags.
|
||||
*/
|
||||
PyAPI_FUNC(void) Py_IncRef(PyObject *);
|
||||
PyAPI_FUNC(void) Py_DecRef(PyObject *);
|
||||
void Py_IncRef(PyObject *);
|
||||
void Py_DecRef(PyObject *);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_DATA(PyTypeObject) _PyNone_Type;
|
||||
PyAPI_DATA(PyTypeObject) _PyNotImplemented_Type;
|
||||
extern PyTypeObject _PyNone_Type;
|
||||
extern PyTypeObject _PyNotImplemented_Type;
|
||||
#endif /* !Py_LIMITED_API */
|
||||
|
||||
/*
|
||||
|
@ -905,7 +908,7 @@ where NULL (nil) is not suitable (since NULL often means 'error').
|
|||
|
||||
Don't forget to apply Py_INCREF() when returning this value!!!
|
||||
*/
|
||||
PyAPI_DATA(PyObject) _Py_NoneStruct; /* Don't use this directly */
|
||||
extern PyObject _Py_NoneStruct; /* Don't use this directly */
|
||||
#define Py_None (&_Py_NoneStruct)
|
||||
|
||||
/* Macro for returning Py_None from a function */
|
||||
|
@ -915,26 +918,18 @@ PyAPI_DATA(PyObject) _Py_NoneStruct; /* Don't use this directly */
|
|||
Py_NotImplemented is a singleton used to signal that an operation is
|
||||
not implemented for a given type combination.
|
||||
*/
|
||||
PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */
|
||||
extern PyObject _Py_NotImplementedStruct; /* Don't use this directly */
|
||||
#define Py_NotImplemented (&_Py_NotImplementedStruct)
|
||||
|
||||
/* Macro for returning Py_NotImplemented from a function */
|
||||
#define Py_RETURN_NOTIMPLEMENTED \
|
||||
return Py_INCREF(Py_NotImplemented), Py_NotImplemented
|
||||
|
||||
/* Rich comparison opcodes */
|
||||
#define Py_LT 0
|
||||
#define Py_LE 1
|
||||
#define Py_EQ 2
|
||||
#define Py_NE 3
|
||||
#define Py_GT 4
|
||||
#define Py_GE 5
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
/* Maps Py_LT to Py_GT, ..., Py_GE to Py_LE.
|
||||
* Defined in object.c.
|
||||
*/
|
||||
PyAPI_DATA(int) _Py_SwappedOp[];
|
||||
extern int _Py_SwappedOp[];
|
||||
#endif /* !Py_LIMITED_API */
|
||||
|
||||
|
||||
|
@ -1035,15 +1030,15 @@ with the call stack never exceeding a depth of PyTrash_UNWIND_LEVEL.
|
|||
#ifndef Py_LIMITED_API
|
||||
/* This is the old private API, invoked by the macros before 3.2.4.
|
||||
Kept for binary compatibility of extensions using the stable ABI. */
|
||||
PyAPI_FUNC(void) _PyTrash_deposit_object(PyObject*);
|
||||
PyAPI_FUNC(void) _PyTrash_destroy_chain(void);
|
||||
PyAPI_DATA(int) _PyTrash_delete_nesting;
|
||||
PyAPI_DATA(PyObject *) _PyTrash_delete_later;
|
||||
void _PyTrash_deposit_object(PyObject*);
|
||||
void _PyTrash_destroy_chain(void);
|
||||
extern int _PyTrash_delete_nesting;
|
||||
extern PyObject * _PyTrash_delete_later;
|
||||
#endif /* !Py_LIMITED_API */
|
||||
|
||||
/* The new thread-safe private API, invoked by the macros below. */
|
||||
PyAPI_FUNC(void) _PyTrash_thread_deposit_object(PyObject*);
|
||||
PyAPI_FUNC(void) _PyTrash_thread_destroy_chain(void);
|
||||
void _PyTrash_thread_deposit_object(PyObject*);
|
||||
void _PyTrash_thread_destroy_chain(void);
|
||||
|
||||
#define PyTrash_UNWIND_LEVEL 50
|
||||
|
||||
|
@ -1063,10 +1058,10 @@ PyAPI_FUNC(void) _PyTrash_thread_destroy_chain(void);
|
|||
} while (0);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void)
|
||||
void
|
||||
_PyDebugAllocatorStats(FILE *out, const char *block_name, int num_blocks,
|
||||
size_t sizeof_block);
|
||||
PyAPI_FUNC(void)
|
||||
void
|
||||
_PyObject_DebugTypeStats(FILE *out);
|
||||
#endif /* ifndef Py_LIMITED_API */
|
||||
|
||||
|
|
134
third_party/python/Include/objimpl.h
vendored
134
third_party/python/Include/objimpl.h
vendored
|
@ -1,108 +1,30 @@
|
|||
#ifndef Py_OBJIMPL_H
|
||||
#define Py_OBJIMPL_H
|
||||
#include "libc/assert.h"
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/pyerrors.h"
|
||||
#include "third_party/python/Include/pymacro.h"
|
||||
#include "third_party/python/Include/pymem.h"
|
||||
#include "third_party/python/Include/tupleobject.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
/* BEWARE:
|
||||
|
||||
Each interface exports both functions and macros. Extension modules should
|
||||
use the functions, to ensure binary compatibility across Python versions.
|
||||
Because the Python implementation is free to change internal details, and
|
||||
the macros may (or may not) expose details for speed, if you do use the
|
||||
macros you must recompile your extensions with each Python release.
|
||||
|
||||
Never mix calls to PyObject_ memory functions with calls to the platform
|
||||
malloc/realloc/ calloc/free, or with calls to PyMem_.
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions and macros for modules that implement new object types.
|
||||
|
||||
- PyObject_New(type, typeobj) allocates memory for a new object of the given
|
||||
type, and initializes part of it. 'type' must be the C structure type used
|
||||
to represent the object, and 'typeobj' the address of the corresponding
|
||||
type object. Reference count and type pointer are filled in; the rest of
|
||||
the bytes of the object are *undefined*! The resulting expression type is
|
||||
'type *'. The size of the object is determined by the tp_basicsize field
|
||||
of the type object.
|
||||
|
||||
- PyObject_NewVar(type, typeobj, n) is similar but allocates a variable-size
|
||||
object with room for n items. In addition to the refcount and type pointer
|
||||
fields, this also fills in the ob_size field.
|
||||
|
||||
- PyObject_Del(op) releases the memory allocated for an object. It does not
|
||||
run a destructor -- it only frees the memory. PyObject_Free is identical.
|
||||
|
||||
- PyObject_Init(op, typeobj) and PyObject_InitVar(op, typeobj, n) don't
|
||||
allocate memory. Instead of a 'type' parameter, they take a pointer to a
|
||||
new object (allocated by an arbitrary allocator), and initialize its object
|
||||
header fields.
|
||||
|
||||
Note that objects created with PyObject_{New, NewVar} are allocated using the
|
||||
specialized Python allocator (implemented in obmalloc.c), if WITH_PYMALLOC is
|
||||
enabled. In addition, a special debugging allocator is used if PYMALLOC_DEBUG
|
||||
is also #defined.
|
||||
|
||||
In case a specific form of memory management is needed (for example, if you
|
||||
must use the platform malloc heap(s), or shared memory, or C++ local storage or
|
||||
operator new), you must first allocate the object with your custom allocator,
|
||||
then pass its pointer to PyObject_{Init, InitVar} for filling in its Python-
|
||||
specific fields: reference count, type pointer, possibly others. You should
|
||||
be aware that Python has no control over these objects because they don't
|
||||
cooperate with the Python memory manager. Such objects may not be eligible
|
||||
for automatic garbage collection and you have to make sure that they are
|
||||
released accordingly whenever their destructor gets called (cf. the specific
|
||||
form of memory management you're using).
|
||||
|
||||
Unless you have specific memory management requirements, use
|
||||
PyObject_{New, NewVar, Del}.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Raw object memory interface
|
||||
* ===========================
|
||||
*/
|
||||
|
||||
/* Functions to call the same malloc/realloc/free as used by Python's
|
||||
object allocator. If WITH_PYMALLOC is enabled, these may differ from
|
||||
the platform malloc/realloc/free. The Python object allocator is
|
||||
designed for fast, cache-conscious allocation of many "small" objects,
|
||||
and with low hidden memory overhead.
|
||||
|
||||
PyObject_Malloc(0) returns a unique non-NULL pointer if possible.
|
||||
|
||||
PyObject_Realloc(NULL, n) acts like PyObject_Malloc(n).
|
||||
PyObject_Realloc(p != NULL, 0) does not return NULL, or free the memory
|
||||
at p.
|
||||
|
||||
Returned pointers must be checked for NULL explicitly; no action is
|
||||
performed on failure other than to return NULL (no warning it printed, no
|
||||
exception is set, etc).
|
||||
|
||||
For allocating objects, use PyObject_{New, NewVar} instead whenever
|
||||
possible. The PyObject_{Malloc, Realloc, Free} family is exposed
|
||||
so that you can exploit Python's small-block allocator for non-object
|
||||
uses. If you must use these routines to allocate object memory, make sure
|
||||
the object gets initialized via PyObject_{Init, InitVar} after obtaining
|
||||
the raw memory.
|
||||
*/
|
||||
PyAPI_FUNC(void *) PyObject_Malloc(size_t size);
|
||||
void * PyObject_Malloc(size_t size);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||
PyAPI_FUNC(void *) PyObject_Calloc(size_t nelem, size_t elsize);
|
||||
void * PyObject_Calloc(size_t nelem, size_t elsize);
|
||||
#endif
|
||||
PyAPI_FUNC(void *) PyObject_Realloc(void *ptr, size_t new_size);
|
||||
PyAPI_FUNC(void) PyObject_Free(void *ptr);
|
||||
void * PyObject_Realloc(void *ptr, size_t new_size);
|
||||
void PyObject_Free(void *ptr);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
/* This function returns the number of allocated memory blocks, regardless of size */
|
||||
PyAPI_FUNC(Py_ssize_t) _Py_GetAllocatedBlocks(void);
|
||||
Py_ssize_t _Py_GetAllocatedBlocks(void);
|
||||
#endif /* !Py_LIMITED_API */
|
||||
|
||||
/* Macros */
|
||||
#ifdef WITH_PYMALLOC
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) _PyObject_DebugMallocStats(FILE *out);
|
||||
void _PyObject_DebugMallocStats(FILE *out);
|
||||
#endif /* #ifndef Py_LIMITED_API */
|
||||
#endif
|
||||
|
||||
|
@ -120,11 +42,11 @@ PyAPI_FUNC(void) _PyObject_DebugMallocStats(FILE *out);
|
|||
*/
|
||||
|
||||
/* Functions */
|
||||
PyAPI_FUNC(PyObject *) PyObject_Init(PyObject *, PyTypeObject *);
|
||||
PyAPI_FUNC(PyVarObject *) PyObject_InitVar(PyVarObject *,
|
||||
PyObject * PyObject_Init(PyObject *, PyTypeObject *);
|
||||
PyVarObject * PyObject_InitVar(PyVarObject *,
|
||||
PyTypeObject *, Py_ssize_t);
|
||||
PyAPI_FUNC(PyObject *) _PyObject_New(PyTypeObject *);
|
||||
PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t);
|
||||
PyObject * _PyObject_New(PyTypeObject *);
|
||||
PyVarObject * _PyObject_NewVar(PyTypeObject *, Py_ssize_t);
|
||||
|
||||
#define PyObject_New(type, typeobj) \
|
||||
( (type *) _PyObject_New(typeobj) )
|
||||
|
@ -209,10 +131,10 @@ typedef struct {
|
|||
} PyObjectArenaAllocator;
|
||||
|
||||
/* Get the arena allocator. */
|
||||
PyAPI_FUNC(void) PyObject_GetArenaAllocator(PyObjectArenaAllocator *allocator);
|
||||
void PyObject_GetArenaAllocator(PyObjectArenaAllocator *allocator);
|
||||
|
||||
/* Set the arena allocator. */
|
||||
PyAPI_FUNC(void) PyObject_SetArenaAllocator(PyObjectArenaAllocator *allocator);
|
||||
void PyObject_SetArenaAllocator(PyObjectArenaAllocator *allocator);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -222,11 +144,11 @@ PyAPI_FUNC(void) PyObject_SetArenaAllocator(PyObjectArenaAllocator *allocator);
|
|||
*/
|
||||
|
||||
/* C equivalent of gc.collect() which ignores the state of gc.enabled. */
|
||||
PyAPI_FUNC(Py_ssize_t) PyGC_Collect(void);
|
||||
Py_ssize_t PyGC_Collect(void);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(Py_ssize_t) _PyGC_CollectNoFail(void);
|
||||
PyAPI_FUNC(Py_ssize_t) _PyGC_CollectIfEnabled(void);
|
||||
Py_ssize_t _PyGC_CollectNoFail(void);
|
||||
Py_ssize_t _PyGC_CollectIfEnabled(void);
|
||||
#endif
|
||||
|
||||
/* Test if a type has a GC head */
|
||||
|
@ -236,7 +158,7 @@ PyAPI_FUNC(Py_ssize_t) _PyGC_CollectIfEnabled(void);
|
|||
#define PyObject_IS_GC(o) (PyType_IS_GC(Py_TYPE(o)) && \
|
||||
(Py_TYPE(o)->tp_is_gc == NULL || Py_TYPE(o)->tp_is_gc(o)))
|
||||
|
||||
PyAPI_FUNC(PyVarObject *) _PyObject_GC_Resize(PyVarObject *, Py_ssize_t);
|
||||
PyVarObject * _PyObject_GC_Resize(PyVarObject *, Py_ssize_t);
|
||||
#define PyObject_GC_Resize(type, op, n) \
|
||||
( (type *) _PyObject_GC_Resize((PyVarObject *)(op), (n)) )
|
||||
|
||||
|
@ -321,14 +243,14 @@ extern PyGC_Head *_PyGC_generation0;
|
|||
#endif /* Py_LIMITED_API */
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) _PyObject_GC_Malloc(size_t size);
|
||||
PyAPI_FUNC(PyObject *) _PyObject_GC_Calloc(size_t size);
|
||||
PyObject * _PyObject_GC_Malloc(size_t size);
|
||||
PyObject * _PyObject_GC_Calloc(size_t size);
|
||||
#endif /* !Py_LIMITED_API */
|
||||
PyAPI_FUNC(PyObject *) _PyObject_GC_New(PyTypeObject *);
|
||||
PyAPI_FUNC(PyVarObject *) _PyObject_GC_NewVar(PyTypeObject *, Py_ssize_t);
|
||||
PyAPI_FUNC(void) PyObject_GC_Track(void *);
|
||||
PyAPI_FUNC(void) PyObject_GC_UnTrack(void *);
|
||||
PyAPI_FUNC(void) PyObject_GC_Del(void *);
|
||||
PyObject * _PyObject_GC_New(PyTypeObject *);
|
||||
PyVarObject * _PyObject_GC_NewVar(PyTypeObject *, Py_ssize_t);
|
||||
void PyObject_GC_Track(void *);
|
||||
void PyObject_GC_UnTrack(void *);
|
||||
void PyObject_GC_Del(void *);
|
||||
|
||||
#define PyObject_GC_New(type, typeobj) \
|
||||
( (type *) _PyObject_GC_New(typeobj) )
|
||||
|
|
17
third_party/python/Include/odictobject.h
vendored
17
third_party/python/Include/odictobject.h
vendored
|
@ -1,5 +1,6 @@
|
|||
#ifndef Py_ODICTOBJECT_H
|
||||
#define Py_ODICTOBJECT_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -10,19 +11,19 @@ COSMOPOLITAN_C_START_
|
|||
|
||||
typedef struct _odictobject PyODictObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyODict_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyODictIter_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyODictKeys_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyODictItems_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyODictValues_Type;
|
||||
extern PyTypeObject PyODict_Type;
|
||||
extern PyTypeObject PyODictIter_Type;
|
||||
extern PyTypeObject PyODictKeys_Type;
|
||||
extern PyTypeObject PyODictItems_Type;
|
||||
extern PyTypeObject PyODictValues_Type;
|
||||
|
||||
#define PyODict_Check(op) PyObject_TypeCheck(op, &PyODict_Type)
|
||||
#define PyODict_CheckExact(op) (Py_TYPE(op) == &PyODict_Type)
|
||||
#define PyODict_SIZE(op) ((PyDictObject *)op)->ma_used
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyODict_New(void);
|
||||
PyAPI_FUNC(int) PyODict_SetItem(PyObject *od, PyObject *key, PyObject *item);
|
||||
PyAPI_FUNC(int) PyODict_DelItem(PyObject *od, PyObject *key);
|
||||
PyObject * PyODict_New(void);
|
||||
int PyODict_SetItem(PyObject *od, PyObject *key, PyObject *item);
|
||||
int PyODict_DelItem(PyObject *od, PyObject *key);
|
||||
|
||||
/* wrappers around PyDict* functions */
|
||||
#define PyODict_GetItem(od, key) PyDict_GetItem((PyObject *)od, key)
|
||||
|
|
12
third_party/python/Include/op.h
vendored
Normal file
12
third_party/python/Include/op.h
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
#ifndef COSMOPOLITAN_THIRD_PARTY_PYTHON_INCLUDE_OP_H_
|
||||
#define COSMOPOLITAN_THIRD_PARTY_PYTHON_INCLUDE_OP_H_
|
||||
|
||||
/* Rich comparison opcodes */
|
||||
#define Py_LT 0
|
||||
#define Py_LE 1
|
||||
#define Py_EQ 2
|
||||
#define Py_NE 3
|
||||
#define Py_GT 4
|
||||
#define Py_GE 5
|
||||
|
||||
#endif /* COSMOPOLITAN_THIRD_PARTY_PYTHON_INCLUDE_OP_H_ */
|
2
third_party/python/Include/opcode.h
generated
vendored
2
third_party/python/Include/opcode.h
generated
vendored
|
@ -1,5 +1,6 @@
|
|||
#ifndef Py_OPCODE_H
|
||||
#define Py_OPCODE_H
|
||||
#include "third_party/python/Include/op.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
/* Auto-generated by Tools/scripts/generate_opcode_h.py */
|
||||
|
@ -131,7 +132,6 @@ COSMOPOLITAN_C_START_
|
|||
remaining private.*/
|
||||
#define EXCEPT_HANDLER 257
|
||||
|
||||
|
||||
enum cmp_op {PyCmp_LT=Py_LT, PyCmp_LE=Py_LE, PyCmp_EQ=Py_EQ, PyCmp_NE=Py_NE,
|
||||
PyCmp_GT=Py_GT, PyCmp_GE=Py_GE, PyCmp_IN, PyCmp_NOT_IN,
|
||||
PyCmp_IS, PyCmp_IS_NOT, PyCmp_EXC_MATCH, PyCmp_BAD};
|
||||
|
|
3
third_party/python/Include/osmodule.h
vendored
3
third_party/python/Include/osmodule.h
vendored
|
@ -1,10 +1,11 @@
|
|||
#ifndef Py_OSMODULE_H
|
||||
#define Py_OSMODULE_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000
|
||||
PyAPI_FUNC(PyObject *) PyOS_FSPath(PyObject *path);
|
||||
PyObject * PyOS_FSPath(PyObject *path);
|
||||
#endif
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
25
third_party/python/Include/parsetok.h
vendored
25
third_party/python/Include/parsetok.h
vendored
|
@ -1,6 +1,9 @@
|
|||
#ifndef Py_LIMITED_API
|
||||
#ifndef Py_PARSETOK_H
|
||||
#define Py_PARSETOK_H
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
#include "third_party/python/Include/node.h"
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -32,15 +35,15 @@ typedef struct {
|
|||
#define PyPARSE_IGNORE_COOKIE 0x0010
|
||||
#define PyPARSE_BARRY_AS_BDFL 0x0020
|
||||
|
||||
PyAPI_FUNC(node *) PyParser_ParseString(const char *, grammar *, int,
|
||||
node * PyParser_ParseString(const char *, grammar *, int,
|
||||
perrdetail *);
|
||||
PyAPI_FUNC(node *) PyParser_ParseFile (FILE *, const char *, grammar *, int,
|
||||
node * PyParser_ParseFile (FILE *, const char *, grammar *, int,
|
||||
const char *, const char *,
|
||||
perrdetail *);
|
||||
|
||||
PyAPI_FUNC(node *) PyParser_ParseStringFlags(const char *, grammar *, int,
|
||||
node * PyParser_ParseStringFlags(const char *, grammar *, int,
|
||||
perrdetail *, int);
|
||||
PyAPI_FUNC(node *) PyParser_ParseFileFlags(
|
||||
node * PyParser_ParseFileFlags(
|
||||
FILE *fp,
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
const char *enc,
|
||||
|
@ -50,7 +53,7 @@ PyAPI_FUNC(node *) PyParser_ParseFileFlags(
|
|||
const char *ps2,
|
||||
perrdetail *err_ret,
|
||||
int flags);
|
||||
PyAPI_FUNC(node *) PyParser_ParseFileFlagsEx(
|
||||
node * PyParser_ParseFileFlagsEx(
|
||||
FILE *fp,
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
const char *enc,
|
||||
|
@ -60,7 +63,7 @@ PyAPI_FUNC(node *) PyParser_ParseFileFlagsEx(
|
|||
const char *ps2,
|
||||
perrdetail *err_ret,
|
||||
int *flags);
|
||||
PyAPI_FUNC(node *) PyParser_ParseFileObject(
|
||||
node * PyParser_ParseFileObject(
|
||||
FILE *fp,
|
||||
PyObject *filename,
|
||||
const char *enc,
|
||||
|
@ -71,21 +74,21 @@ PyAPI_FUNC(node *) PyParser_ParseFileObject(
|
|||
perrdetail *err_ret,
|
||||
int *flags);
|
||||
|
||||
PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilename(
|
||||
node * PyParser_ParseStringFlagsFilename(
|
||||
const char *s,
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
grammar *g,
|
||||
int start,
|
||||
perrdetail *err_ret,
|
||||
int flags);
|
||||
PyAPI_FUNC(node *) PyParser_ParseStringFlagsFilenameEx(
|
||||
node * PyParser_ParseStringFlagsFilenameEx(
|
||||
const char *s,
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
grammar *g,
|
||||
int start,
|
||||
perrdetail *err_ret,
|
||||
int *flags);
|
||||
PyAPI_FUNC(node *) PyParser_ParseStringObject(
|
||||
node * PyParser_ParseStringObject(
|
||||
const char *s,
|
||||
PyObject *filename,
|
||||
grammar *g,
|
||||
|
@ -95,8 +98,8 @@ PyAPI_FUNC(node *) PyParser_ParseStringObject(
|
|||
|
||||
/* Note that the following functions are defined in pythonrun.c,
|
||||
not in parsetok.c */
|
||||
PyAPI_FUNC(void) PyParser_SetError(perrdetail *);
|
||||
PyAPI_FUNC(void) PyParser_ClearError(perrdetail *);
|
||||
void PyParser_SetError(perrdetail *);
|
||||
void PyParser_ClearError(perrdetail *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !Py_PARSETOK_H */
|
||||
|
|
1
third_party/python/Include/pgen.h
vendored
1
third_party/python/Include/pgen.h
vendored
|
@ -1,5 +1,6 @@
|
|||
#ifndef Py_PGEN_H
|
||||
#define Py_PGEN_H
|
||||
#include "third_party/python/Include/grammar.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
|
6
third_party/python/Include/pgenheaders.h
vendored
6
third_party/python/Include/pgenheaders.h
vendored
|
@ -1,12 +1,12 @@
|
|||
#ifndef Py_PGENHEADERS_H
|
||||
#define Py_PGENHEADERS_H
|
||||
#include "third_party/python/Include/Python.h"
|
||||
#include "third_party/python/Include/pyport.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...)
|
||||
void PySys_WriteStdout(const char *format, ...)
|
||||
Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
|
||||
PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...)
|
||||
void PySys_WriteStderr(const char *format, ...)
|
||||
Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
|
||||
|
||||
#define addarc _Py_addarc
|
||||
|
|
1
third_party/python/Include/py_curses.h
vendored
1
third_party/python/Include/py_curses.h
vendored
|
@ -1,5 +1,6 @@
|
|||
#ifndef Py_CURSES_H
|
||||
#define Py_CURSES_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
/* clang-format off */
|
||||
|
||||
#if !defined(HAVE_CURSES_IS_PAD) && defined(WINDOW_HAS_FLAGS)
|
||||
|
|
9
third_party/python/Include/pyarena.h
vendored
9
third_party/python/Include/pyarena.h
vendored
|
@ -1,6 +1,7 @@
|
|||
#ifndef Py_LIMITED_API
|
||||
#ifndef Py_PYARENA_H
|
||||
#define Py_PYARENA_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -28,8 +29,8 @@ typedef struct _arena PyArena;
|
|||
XXX block_new(DEFAULT_BLOCK_SIZE) returns NULL, that's passed on but
|
||||
XXX an exception is not set in that case).
|
||||
*/
|
||||
PyAPI_FUNC(PyArena *) PyArena_New(void);
|
||||
PyAPI_FUNC(void) PyArena_Free(PyArena *);
|
||||
PyArena * PyArena_New(void);
|
||||
void PyArena_Free(PyArena *);
|
||||
|
||||
/* Mostly like malloc(), return the address of a block of memory spanning
|
||||
* `size` bytes, or return NULL (without setting an exception) if enough
|
||||
|
@ -43,13 +44,13 @@ PyAPI_FUNC(void) PyArena_Free(PyArena *);
|
|||
* until PyArena_Free(ar) is called, at which point all pointers obtained
|
||||
* from the arena `ar` become invalid simultaneously.
|
||||
*/
|
||||
PyAPI_FUNC(void *) PyArena_Malloc(PyArena *, size_t size);
|
||||
void * PyArena_Malloc(PyArena *, size_t size);
|
||||
|
||||
/* This routine isn't a proper arena allocation routine. It takes
|
||||
* a PyObject* and records it so that it can be DECREFed when the
|
||||
* arena is freed.
|
||||
*/
|
||||
PyAPI_FUNC(int) PyArena_AddPyObject(PyArena *, PyObject *);
|
||||
int PyArena_AddPyObject(PyArena *, PyObject *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !Py_PYARENA_H */
|
||||
|
|
1
third_party/python/Include/pyatomic.h
vendored
1
third_party/python/Include/pyatomic.h
vendored
|
@ -1,6 +1,7 @@
|
|||
#ifndef Py_ATOMIC_H
|
||||
#define Py_ATOMIC_H
|
||||
#ifdef Py_BUILD_CORE
|
||||
#include "libc/assert.h"
|
||||
#include "third_party/python/Include/dynamic_annotations.h"
|
||||
#include "third_party/python/pyconfig.h"
|
||||
/* clang-format off */
|
||||
|
|
25
third_party/python/Include/pycapsule.h
vendored
25
third_party/python/Include/pycapsule.h
vendored
|
@ -1,5 +1,6 @@
|
|||
#ifndef Py_CAPSULE_H
|
||||
#define Py_CAPSULE_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -16,37 +17,37 @@ COSMOPOLITAN_C_START_
|
|||
documentation.
|
||||
*/
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyCapsule_Type;
|
||||
extern PyTypeObject PyCapsule_Type;
|
||||
|
||||
typedef void (*PyCapsule_Destructor)(PyObject *);
|
||||
|
||||
#define PyCapsule_CheckExact(op) (Py_TYPE(op) == &PyCapsule_Type)
|
||||
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCapsule_New(
|
||||
PyObject * PyCapsule_New(
|
||||
void *pointer,
|
||||
const char *name,
|
||||
PyCapsule_Destructor destructor);
|
||||
|
||||
PyAPI_FUNC(void *) PyCapsule_GetPointer(PyObject *capsule, const char *name);
|
||||
void * PyCapsule_GetPointer(PyObject *capsule, const char *name);
|
||||
|
||||
PyAPI_FUNC(PyCapsule_Destructor) PyCapsule_GetDestructor(PyObject *capsule);
|
||||
PyCapsule_Destructor PyCapsule_GetDestructor(PyObject *capsule);
|
||||
|
||||
PyAPI_FUNC(const char *) PyCapsule_GetName(PyObject *capsule);
|
||||
const char * PyCapsule_GetName(PyObject *capsule);
|
||||
|
||||
PyAPI_FUNC(void *) PyCapsule_GetContext(PyObject *capsule);
|
||||
void * PyCapsule_GetContext(PyObject *capsule);
|
||||
|
||||
PyAPI_FUNC(int) PyCapsule_IsValid(PyObject *capsule, const char *name);
|
||||
int PyCapsule_IsValid(PyObject *capsule, const char *name);
|
||||
|
||||
PyAPI_FUNC(int) PyCapsule_SetPointer(PyObject *capsule, void *pointer);
|
||||
int PyCapsule_SetPointer(PyObject *capsule, void *pointer);
|
||||
|
||||
PyAPI_FUNC(int) PyCapsule_SetDestructor(PyObject *capsule, PyCapsule_Destructor destructor);
|
||||
int PyCapsule_SetDestructor(PyObject *capsule, PyCapsule_Destructor destructor);
|
||||
|
||||
PyAPI_FUNC(int) PyCapsule_SetName(PyObject *capsule, const char *name);
|
||||
int PyCapsule_SetName(PyObject *capsule, const char *name);
|
||||
|
||||
PyAPI_FUNC(int) PyCapsule_SetContext(PyObject *capsule, void *context);
|
||||
int PyCapsule_SetContext(PyObject *capsule, void *context);
|
||||
|
||||
PyAPI_FUNC(void *) PyCapsule_Import(
|
||||
void * PyCapsule_Import(
|
||||
const char *name, /* UTF-8 encoded string */
|
||||
int no_block);
|
||||
|
||||
|
|
53
third_party/python/Include/pyctype.h
vendored
53
third_party/python/Include/pyctype.h
vendored
|
@ -1,34 +1,41 @@
|
|||
#ifndef Py_LIMITED_API
|
||||
#ifndef PYCTYPE_H
|
||||
#define PYCTYPE_H
|
||||
/* clang-format off */
|
||||
#include "libc/str/str.h"
|
||||
|
||||
#define PY_CTF_LOWER 0x01
|
||||
#define PY_CTF_UPPER 0x02
|
||||
#define PY_CTF_ALPHA (PY_CTF_LOWER|PY_CTF_UPPER)
|
||||
#define PY_CTF_DIGIT 0x04
|
||||
#define PY_CTF_ALNUM (PY_CTF_ALPHA|PY_CTF_DIGIT)
|
||||
#define PY_CTF_SPACE 0x08
|
||||
#define PY_CTF_XDIGIT 0x10
|
||||
#define Py_TOLOWER(c) kToLower[255 & (c)]
|
||||
#define Py_TOUPPER(c) kToUpper[255 & (c)]
|
||||
|
||||
PyAPI_DATA(const unsigned int) _Py_ctype_table[256];
|
||||
forceinline bool Py_ISDIGIT(unsigned char c) {
|
||||
return '0' <= c && c <= '9';
|
||||
}
|
||||
|
||||
/* Unlike their C counterparts, the following macros are not meant to
|
||||
* handle an int with any of the values [EOF, 0-UCHAR_MAX]. The argument
|
||||
* must be a signed/unsigned char. */
|
||||
#define Py_ISLOWER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_LOWER)
|
||||
#define Py_ISUPPER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_UPPER)
|
||||
#define Py_ISALPHA(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALPHA)
|
||||
#define Py_ISDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_DIGIT)
|
||||
#define Py_ISXDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_XDIGIT)
|
||||
#define Py_ISALNUM(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALNUM)
|
||||
#define Py_ISSPACE(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_SPACE)
|
||||
forceinline bool Py_ISLOWER(unsigned char c) {
|
||||
return 'a' <= c && c <= 'z';
|
||||
}
|
||||
|
||||
PyAPI_DATA(const unsigned char) _Py_ctype_tolower[256];
|
||||
PyAPI_DATA(const unsigned char) _Py_ctype_toupper[256];
|
||||
forceinline bool Py_ISUPPER(unsigned char c) {
|
||||
return 'A' <= c && c <= 'Z';
|
||||
}
|
||||
|
||||
#define Py_TOLOWER(c) (_Py_ctype_tolower[Py_CHARMASK(c)])
|
||||
#define Py_TOUPPER(c) (_Py_ctype_toupper[Py_CHARMASK(c)])
|
||||
forceinline bool Py_ISALPHA(unsigned char c) {
|
||||
return ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z');
|
||||
}
|
||||
|
||||
forceinline bool Py_ISALNUM(unsigned char c) {
|
||||
return ('0' <= c && c <= '9') || ('A' <= c && c <= 'Z') ||
|
||||
('a' <= c && c <= 'z');
|
||||
}
|
||||
|
||||
forceinline bool Py_ISSPACE(unsigned char c) {
|
||||
return c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\f' ||
|
||||
c == '\v';
|
||||
}
|
||||
|
||||
forceinline bool Py_ISXDIGIT(unsigned char c) {
|
||||
return ('0' <= c && c <= '9') || ('A' <= c && c <= 'F') ||
|
||||
('a' <= c && c <= 'f');
|
||||
}
|
||||
|
||||
#endif /* !PYCTYPE_H */
|
||||
#endif /* !Py_LIMITED_API */
|
||||
|
|
34
third_party/python/Include/pydebug.h
vendored
34
third_party/python/Include/pydebug.h
vendored
|
@ -6,25 +6,25 @@ COSMOPOLITAN_C_START_
|
|||
|
||||
/* These global variable are defined in pylifecycle.c */
|
||||
/* XXX (ncoghlan): move these declarations to pylifecycle.h? */
|
||||
PyAPI_DATA(int) Py_DebugFlag;
|
||||
PyAPI_DATA(int) Py_VerboseFlag;
|
||||
PyAPI_DATA(int) Py_QuietFlag;
|
||||
PyAPI_DATA(int) Py_InteractiveFlag;
|
||||
PyAPI_DATA(int) Py_InspectFlag;
|
||||
PyAPI_DATA(int) Py_OptimizeFlag;
|
||||
PyAPI_DATA(int) Py_NoSiteFlag;
|
||||
PyAPI_DATA(int) Py_BytesWarningFlag;
|
||||
PyAPI_DATA(int) Py_UseClassExceptionsFlag;
|
||||
PyAPI_DATA(int) Py_FrozenFlag;
|
||||
PyAPI_DATA(int) Py_IgnoreEnvironmentFlag;
|
||||
PyAPI_DATA(int) Py_DontWriteBytecodeFlag;
|
||||
PyAPI_DATA(int) Py_NoUserSiteDirectory;
|
||||
PyAPI_DATA(int) Py_UnbufferedStdioFlag;
|
||||
PyAPI_DATA(int) Py_HashRandomizationFlag;
|
||||
PyAPI_DATA(int) Py_IsolatedFlag;
|
||||
extern int Py_DebugFlag;
|
||||
extern int Py_VerboseFlag;
|
||||
extern int Py_QuietFlag;
|
||||
extern int Py_InteractiveFlag;
|
||||
extern int Py_InspectFlag;
|
||||
extern int Py_OptimizeFlag;
|
||||
extern int Py_NoSiteFlag;
|
||||
extern int Py_BytesWarningFlag;
|
||||
extern int Py_UseClassExceptionsFlag;
|
||||
extern int Py_FrozenFlag;
|
||||
extern int Py_IgnoreEnvironmentFlag;
|
||||
extern int Py_DontWriteBytecodeFlag;
|
||||
extern int Py_NoUserSiteDirectory;
|
||||
extern int Py_UnbufferedStdioFlag;
|
||||
extern int Py_HashRandomizationFlag;
|
||||
extern int Py_IsolatedFlag;
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
PyAPI_DATA(int) Py_LegacyWindowsStdioFlag;
|
||||
extern int Py_LegacyWindowsStdioFlag;
|
||||
#endif
|
||||
|
||||
/* this is a wrapper around getenv() that pays attention to
|
||||
|
|
85
third_party/python/Include/pydtrace.h
vendored
85
third_party/python/Include/pydtrace.h
vendored
|
@ -2,74 +2,25 @@
|
|||
#define Py_DTRACE_H
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
#ifdef WITH_DTRACE
|
||||
#include "pydtrace_probes.h"
|
||||
#define PyDTrace_LINE(arg0, arg1, arg2)
|
||||
#define PyDTrace_FUNCTION_ENTRY(arg0, arg1, arg2)
|
||||
#define PyDTrace_FUNCTION_RETURN(arg0, arg1, arg2)
|
||||
#define PyDTrace_GC_START(arg0)
|
||||
#define PyDTrace_GC_DONE(arg0)
|
||||
#define PyDTrace_INSTANCE_NEW_START(arg0)
|
||||
#define PyDTrace_INSTANCE_NEW_DONE(arg0)
|
||||
#define PyDTrace_INSTANCE_DELETE_START(arg0)
|
||||
#define PyDTrace_INSTANCE_DELETE_DONE(arg0)
|
||||
|
||||
/* pydtrace_probes.h, on systems with DTrace, is auto-generated to include
|
||||
`PyDTrace_{PROBE}` and `PyDTrace_{PROBE}_ENABLED()` macros for every probe
|
||||
defined in pydtrace_provider.d.
|
||||
|
||||
Calling these functions must be guarded by a `PyDTrace_{PROBE}_ENABLED()`
|
||||
check to minimize performance impact when probing is off. For example:
|
||||
|
||||
if (PyDTrace_FUNCTION_ENTRY_ENABLED())
|
||||
PyDTrace_FUNCTION_ENTRY(f);
|
||||
*/
|
||||
|
||||
#else
|
||||
|
||||
/* Without DTrace, compile to nothing. */
|
||||
|
||||
static inline void PyDTrace_LINE(const char *arg0, const char *arg1, int arg2) {
|
||||
}
|
||||
static inline void PyDTrace_FUNCTION_ENTRY(const char *arg0, const char *arg1,
|
||||
int arg2) {
|
||||
}
|
||||
static inline void PyDTrace_FUNCTION_RETURN(const char *arg0, const char *arg1,
|
||||
int arg2) {
|
||||
}
|
||||
static inline void PyDTrace_GC_START(int arg0) {
|
||||
}
|
||||
static inline void PyDTrace_GC_DONE(int arg0) {
|
||||
}
|
||||
static inline void PyDTrace_INSTANCE_NEW_START(int arg0) {
|
||||
}
|
||||
static inline void PyDTrace_INSTANCE_NEW_DONE(int arg0) {
|
||||
}
|
||||
static inline void PyDTrace_INSTANCE_DELETE_START(int arg0) {
|
||||
}
|
||||
static inline void PyDTrace_INSTANCE_DELETE_DONE(int arg0) {
|
||||
}
|
||||
|
||||
static inline int PyDTrace_LINE_ENABLED(void) {
|
||||
return 0;
|
||||
}
|
||||
static inline int PyDTrace_FUNCTION_ENTRY_ENABLED(void) {
|
||||
return 0;
|
||||
}
|
||||
static inline int PyDTrace_FUNCTION_RETURN_ENABLED(void) {
|
||||
return 0;
|
||||
}
|
||||
static inline int PyDTrace_GC_START_ENABLED(void) {
|
||||
return 0;
|
||||
}
|
||||
static inline int PyDTrace_GC_DONE_ENABLED(void) {
|
||||
return 0;
|
||||
}
|
||||
static inline int PyDTrace_INSTANCE_NEW_START_ENABLED(void) {
|
||||
return 0;
|
||||
}
|
||||
static inline int PyDTrace_INSTANCE_NEW_DONE_ENABLED(void) {
|
||||
return 0;
|
||||
}
|
||||
static inline int PyDTrace_INSTANCE_DELETE_START_ENABLED(void) {
|
||||
return 0;
|
||||
}
|
||||
static inline int PyDTrace_INSTANCE_DELETE_DONE_ENABLED(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* !WITH_DTRACE */
|
||||
#define PyDTrace_LINE_ENABLED() 0
|
||||
#define PyDTrace_FUNCTION_ENTRY_ENABLED() 0
|
||||
#define PyDTrace_FUNCTION_RETURN_ENABLED() 0
|
||||
#define PyDTrace_GC_START_ENABLED() 0
|
||||
#define PyDTrace_GC_DONE_ENABLED() 0
|
||||
#define PyDTrace_INSTANCE_NEW_START_ENABLED() 0
|
||||
#define PyDTrace_INSTANCE_NEW_DONE_ENABLED() 0
|
||||
#define PyDTrace_INSTANCE_DELETE_START_ENABLED() 0
|
||||
#define PyDTrace_INSTANCE_DELETE_DONE_ENABLED() 0
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !Py_DTRACE_H */
|
||||
|
|
302
third_party/python/Include/pyerrors.h
vendored
302
third_party/python/Include/pyerrors.h
vendored
|
@ -1,5 +1,7 @@
|
|||
#ifndef Py_ERRORS_H
|
||||
#define Py_ERRORS_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/unicodeobject.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -71,22 +73,22 @@ typedef PyOSErrorObject PyWindowsErrorObject;
|
|||
|
||||
/* Error handling definitions */
|
||||
|
||||
PyAPI_FUNC(void) PyErr_SetNone(PyObject *);
|
||||
PyAPI_FUNC(void) PyErr_SetObject(PyObject *, PyObject *);
|
||||
void PyErr_SetNone(PyObject *);
|
||||
void PyErr_SetObject(PyObject *, PyObject *);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) _PyErr_SetKeyError(PyObject *);
|
||||
void _PyErr_SetKeyError(PyObject *);
|
||||
#endif
|
||||
PyAPI_FUNC(void) PyErr_SetString(
|
||||
void PyErr_SetString(
|
||||
PyObject *exception,
|
||||
const char *string /* decoded from utf-8 */
|
||||
);
|
||||
PyAPI_FUNC(PyObject *) PyErr_Occurred(void);
|
||||
PyAPI_FUNC(void) PyErr_Clear(void);
|
||||
PyAPI_FUNC(void) PyErr_Fetch(PyObject **, PyObject **, PyObject **);
|
||||
PyAPI_FUNC(void) PyErr_Restore(PyObject *, PyObject *, PyObject *);
|
||||
PyObject * PyErr_Occurred(void);
|
||||
void PyErr_Clear(void);
|
||||
void PyErr_Fetch(PyObject **, PyObject **, PyObject **);
|
||||
void PyErr_Restore(PyObject *, PyObject *, PyObject *);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_FUNC(void) PyErr_GetExcInfo(PyObject **, PyObject **, PyObject **);
|
||||
PyAPI_FUNC(void) PyErr_SetExcInfo(PyObject *, PyObject *, PyObject *);
|
||||
void PyErr_GetExcInfo(PyObject **, PyObject **, PyObject **);
|
||||
void PyErr_SetExcInfo(PyObject *, PyObject *, PyObject *);
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) || \
|
||||
|
@ -99,7 +101,7 @@ PyAPI_FUNC(void) PyErr_SetExcInfo(PyObject *, PyObject *, PyObject *);
|
|||
#endif
|
||||
|
||||
/* Defined in Python/pylifecycle.c */
|
||||
PyAPI_FUNC(void) Py_FatalError(const char *message) _Py_NO_RETURN;
|
||||
void Py_FatalError(const char *message) _Py_NO_RETURN;
|
||||
|
||||
#if defined(Py_DEBUG) || defined(Py_LIMITED_API)
|
||||
#define _PyErr_OCCURRED() PyErr_Occurred()
|
||||
|
@ -108,23 +110,23 @@ PyAPI_FUNC(void) Py_FatalError(const char *message) _Py_NO_RETURN;
|
|||
#endif
|
||||
|
||||
/* Error testing and normalization */
|
||||
PyAPI_FUNC(int) PyErr_GivenExceptionMatches(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(int) PyErr_ExceptionMatches(PyObject *);
|
||||
PyAPI_FUNC(void) PyErr_NormalizeException(PyObject**, PyObject**, PyObject**);
|
||||
int PyErr_GivenExceptionMatches(PyObject *, PyObject *);
|
||||
int PyErr_ExceptionMatches(PyObject *);
|
||||
void PyErr_NormalizeException(PyObject**, PyObject**, PyObject**);
|
||||
|
||||
/* Traceback manipulation (PEP 3134) */
|
||||
PyAPI_FUNC(int) PyException_SetTraceback(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyException_GetTraceback(PyObject *);
|
||||
int PyException_SetTraceback(PyObject *, PyObject *);
|
||||
PyObject * PyException_GetTraceback(PyObject *);
|
||||
|
||||
/* Cause manipulation (PEP 3134) */
|
||||
PyAPI_FUNC(PyObject *) PyException_GetCause(PyObject *);
|
||||
PyAPI_FUNC(void) PyException_SetCause(PyObject *, PyObject *);
|
||||
PyObject * PyException_GetCause(PyObject *);
|
||||
void PyException_SetCause(PyObject *, PyObject *);
|
||||
|
||||
/* Context manipulation (PEP 3134) */
|
||||
PyAPI_FUNC(PyObject *) PyException_GetContext(PyObject *);
|
||||
PyAPI_FUNC(void) PyException_SetContext(PyObject *, PyObject *);
|
||||
PyObject * PyException_GetContext(PyObject *);
|
||||
void PyException_SetContext(PyObject *, PyObject *);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) _PyErr_ChainExceptions(PyObject *, PyObject *, PyObject *);
|
||||
void _PyErr_ChainExceptions(PyObject *, PyObject *, PyObject *);
|
||||
#endif
|
||||
|
||||
/* */
|
||||
|
@ -144,119 +146,119 @@ PyAPI_FUNC(void) _PyErr_ChainExceptions(PyObject *, PyObject *, PyObject *);
|
|||
|
||||
/* Predefined exceptions */
|
||||
|
||||
PyAPI_DATA(PyObject *) PyExc_BaseException;
|
||||
PyAPI_DATA(PyObject *) PyExc_Exception;
|
||||
extern PyObject * PyExc_BaseException;
|
||||
extern PyObject * PyExc_Exception;
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||
PyAPI_DATA(PyObject *) PyExc_StopAsyncIteration;
|
||||
extern PyObject * PyExc_StopAsyncIteration;
|
||||
#endif
|
||||
PyAPI_DATA(PyObject *) PyExc_StopIteration;
|
||||
PyAPI_DATA(PyObject *) PyExc_GeneratorExit;
|
||||
PyAPI_DATA(PyObject *) PyExc_ArithmeticError;
|
||||
PyAPI_DATA(PyObject *) PyExc_LookupError;
|
||||
extern PyObject * PyExc_StopIteration;
|
||||
extern PyObject * PyExc_GeneratorExit;
|
||||
extern PyObject * PyExc_ArithmeticError;
|
||||
extern PyObject * PyExc_LookupError;
|
||||
|
||||
PyAPI_DATA(PyObject *) PyExc_AssertionError;
|
||||
PyAPI_DATA(PyObject *) PyExc_AttributeError;
|
||||
PyAPI_DATA(PyObject *) PyExc_BufferError;
|
||||
PyAPI_DATA(PyObject *) PyExc_EOFError;
|
||||
PyAPI_DATA(PyObject *) PyExc_FloatingPointError;
|
||||
PyAPI_DATA(PyObject *) PyExc_OSError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ImportError;
|
||||
extern PyObject * PyExc_AssertionError;
|
||||
extern PyObject * PyExc_AttributeError;
|
||||
extern PyObject * PyExc_BufferError;
|
||||
extern PyObject * PyExc_EOFError;
|
||||
extern PyObject * PyExc_FloatingPointError;
|
||||
extern PyObject * PyExc_OSError;
|
||||
extern PyObject * PyExc_ImportError;
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000
|
||||
PyAPI_DATA(PyObject *) PyExc_ModuleNotFoundError;
|
||||
extern PyObject * PyExc_ModuleNotFoundError;
|
||||
#endif
|
||||
PyAPI_DATA(PyObject *) PyExc_IndexError;
|
||||
PyAPI_DATA(PyObject *) PyExc_KeyError;
|
||||
PyAPI_DATA(PyObject *) PyExc_KeyboardInterrupt;
|
||||
PyAPI_DATA(PyObject *) PyExc_MemoryError;
|
||||
PyAPI_DATA(PyObject *) PyExc_NameError;
|
||||
PyAPI_DATA(PyObject *) PyExc_OverflowError;
|
||||
PyAPI_DATA(PyObject *) PyExc_RuntimeError;
|
||||
extern PyObject * PyExc_IndexError;
|
||||
extern PyObject * PyExc_KeyError;
|
||||
extern PyObject * PyExc_KeyboardInterrupt;
|
||||
extern PyObject * PyExc_MemoryError;
|
||||
extern PyObject * PyExc_NameError;
|
||||
extern PyObject * PyExc_OverflowError;
|
||||
extern PyObject * PyExc_RuntimeError;
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||
PyAPI_DATA(PyObject *) PyExc_RecursionError;
|
||||
extern PyObject * PyExc_RecursionError;
|
||||
#endif
|
||||
PyAPI_DATA(PyObject *) PyExc_NotImplementedError;
|
||||
PyAPI_DATA(PyObject *) PyExc_SyntaxError;
|
||||
PyAPI_DATA(PyObject *) PyExc_IndentationError;
|
||||
PyAPI_DATA(PyObject *) PyExc_TabError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ReferenceError;
|
||||
PyAPI_DATA(PyObject *) PyExc_SystemError;
|
||||
PyAPI_DATA(PyObject *) PyExc_SystemExit;
|
||||
PyAPI_DATA(PyObject *) PyExc_TypeError;
|
||||
PyAPI_DATA(PyObject *) PyExc_UnboundLocalError;
|
||||
PyAPI_DATA(PyObject *) PyExc_UnicodeError;
|
||||
PyAPI_DATA(PyObject *) PyExc_UnicodeEncodeError;
|
||||
PyAPI_DATA(PyObject *) PyExc_UnicodeDecodeError;
|
||||
PyAPI_DATA(PyObject *) PyExc_UnicodeTranslateError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ValueError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ZeroDivisionError;
|
||||
extern PyObject * PyExc_NotImplementedError;
|
||||
extern PyObject * PyExc_SyntaxError;
|
||||
extern PyObject * PyExc_IndentationError;
|
||||
extern PyObject * PyExc_TabError;
|
||||
extern PyObject * PyExc_ReferenceError;
|
||||
extern PyObject * PyExc_SystemError;
|
||||
extern PyObject * PyExc_SystemExit;
|
||||
extern PyObject * PyExc_TypeError;
|
||||
extern PyObject * PyExc_UnboundLocalError;
|
||||
extern PyObject * PyExc_UnicodeError;
|
||||
extern PyObject * PyExc_UnicodeEncodeError;
|
||||
extern PyObject * PyExc_UnicodeDecodeError;
|
||||
extern PyObject * PyExc_UnicodeTranslateError;
|
||||
extern PyObject * PyExc_ValueError;
|
||||
extern PyObject * PyExc_ZeroDivisionError;
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_DATA(PyObject *) PyExc_BlockingIOError;
|
||||
PyAPI_DATA(PyObject *) PyExc_BrokenPipeError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ChildProcessError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ConnectionError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ConnectionAbortedError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ConnectionRefusedError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ConnectionResetError;
|
||||
PyAPI_DATA(PyObject *) PyExc_FileExistsError;
|
||||
PyAPI_DATA(PyObject *) PyExc_FileNotFoundError;
|
||||
PyAPI_DATA(PyObject *) PyExc_InterruptedError;
|
||||
PyAPI_DATA(PyObject *) PyExc_IsADirectoryError;
|
||||
PyAPI_DATA(PyObject *) PyExc_NotADirectoryError;
|
||||
PyAPI_DATA(PyObject *) PyExc_PermissionError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ProcessLookupError;
|
||||
PyAPI_DATA(PyObject *) PyExc_TimeoutError;
|
||||
extern PyObject * PyExc_BlockingIOError;
|
||||
extern PyObject * PyExc_BrokenPipeError;
|
||||
extern PyObject * PyExc_ChildProcessError;
|
||||
extern PyObject * PyExc_ConnectionError;
|
||||
extern PyObject * PyExc_ConnectionAbortedError;
|
||||
extern PyObject * PyExc_ConnectionRefusedError;
|
||||
extern PyObject * PyExc_ConnectionResetError;
|
||||
extern PyObject * PyExc_FileExistsError;
|
||||
extern PyObject * PyExc_FileNotFoundError;
|
||||
extern PyObject * PyExc_InterruptedError;
|
||||
extern PyObject * PyExc_IsADirectoryError;
|
||||
extern PyObject * PyExc_NotADirectoryError;
|
||||
extern PyObject * PyExc_PermissionError;
|
||||
extern PyObject * PyExc_ProcessLookupError;
|
||||
extern PyObject * PyExc_TimeoutError;
|
||||
#endif
|
||||
|
||||
|
||||
/* Compatibility aliases */
|
||||
PyAPI_DATA(PyObject *) PyExc_EnvironmentError;
|
||||
PyAPI_DATA(PyObject *) PyExc_IOError;
|
||||
extern PyObject * PyExc_EnvironmentError;
|
||||
extern PyObject * PyExc_IOError;
|
||||
#ifdef MS_WINDOWS
|
||||
PyAPI_DATA(PyObject *) PyExc_WindowsError;
|
||||
extern PyObject * PyExc_WindowsError;
|
||||
#endif
|
||||
|
||||
/* Predefined warning categories */
|
||||
PyAPI_DATA(PyObject *) PyExc_Warning;
|
||||
PyAPI_DATA(PyObject *) PyExc_UserWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_DeprecationWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_PendingDeprecationWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_SyntaxWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_RuntimeWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_FutureWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_ImportWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_UnicodeWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_BytesWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_ResourceWarning;
|
||||
extern PyObject * PyExc_Warning;
|
||||
extern PyObject * PyExc_UserWarning;
|
||||
extern PyObject * PyExc_DeprecationWarning;
|
||||
extern PyObject * PyExc_PendingDeprecationWarning;
|
||||
extern PyObject * PyExc_SyntaxWarning;
|
||||
extern PyObject * PyExc_RuntimeWarning;
|
||||
extern PyObject * PyExc_FutureWarning;
|
||||
extern PyObject * PyExc_ImportWarning;
|
||||
extern PyObject * PyExc_UnicodeWarning;
|
||||
extern PyObject * PyExc_BytesWarning;
|
||||
extern PyObject * PyExc_ResourceWarning;
|
||||
|
||||
|
||||
/* Convenience functions */
|
||||
|
||||
PyAPI_FUNC(int) PyErr_BadArgument(void);
|
||||
PyAPI_FUNC(PyObject *) PyErr_NoMemory(void);
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetFromErrno(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilenameObject(
|
||||
int PyErr_BadArgument(void);
|
||||
PyObject * PyErr_NoMemory(void);
|
||||
PyObject * PyErr_SetFromErrno(PyObject *);
|
||||
PyObject * PyErr_SetFromErrnoWithFilenameObject(
|
||||
PyObject *, PyObject *);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03040000
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilenameObjects(
|
||||
PyObject * PyErr_SetFromErrnoWithFilenameObjects(
|
||||
PyObject *, PyObject *, PyObject *);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilename(
|
||||
PyObject * PyErr_SetFromErrnoWithFilename(
|
||||
PyObject *exc,
|
||||
const char *filename /* decoded from the filesystem encoding */
|
||||
);
|
||||
#if defined(MS_WINDOWS) && !defined(Py_LIMITED_API)
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename(
|
||||
PyObject * PyErr_SetFromErrnoWithUnicodeFilename(
|
||||
PyObject *, const Py_UNICODE *);
|
||||
#endif /* MS_WINDOWS */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyErr_Format(
|
||||
PyObject * PyErr_Format(
|
||||
PyObject *exception,
|
||||
const char *format, /* ASCII-encoded string */
|
||||
...
|
||||
);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||
PyAPI_FUNC(PyObject *) PyErr_FormatV(
|
||||
PyObject * PyErr_FormatV(
|
||||
PyObject *exception,
|
||||
const char *format,
|
||||
va_list vargs);
|
||||
|
@ -266,7 +268,7 @@ PyAPI_FUNC(PyObject *) PyErr_FormatV(
|
|||
/* Like PyErr_Format(), but saves current exception as __context__ and
|
||||
__cause__.
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) _PyErr_FormatFromCause(
|
||||
PyObject * _PyErr_FormatFromCause(
|
||||
PyObject *exception,
|
||||
const char *format, /* ASCII-encoded string */
|
||||
...
|
||||
|
@ -274,56 +276,56 @@ PyAPI_FUNC(PyObject *) _PyErr_FormatFromCause(
|
|||
#endif
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename(
|
||||
PyObject * PyErr_SetFromWindowsErrWithFilename(
|
||||
int ierr,
|
||||
const char *filename /* decoded from the filesystem encoding */
|
||||
);
|
||||
#ifndef Py_LIMITED_API
|
||||
/* XXX redeclare to use WSTRING */
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename(
|
||||
PyObject * PyErr_SetFromWindowsErrWithUnicodeFilename(
|
||||
int, const Py_UNICODE *);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(int);
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObject(
|
||||
PyObject * PyErr_SetFromWindowsErr(int);
|
||||
PyObject * PyErr_SetExcFromWindowsErrWithFilenameObject(
|
||||
PyObject *,int, PyObject *);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03040000
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObjects(
|
||||
PyObject * PyErr_SetExcFromWindowsErrWithFilenameObjects(
|
||||
PyObject *,int, PyObject *, PyObject *);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilename(
|
||||
PyObject * PyErr_SetExcFromWindowsErrWithFilename(
|
||||
PyObject *exc,
|
||||
int ierr,
|
||||
const char *filename /* decoded from the filesystem encoding */
|
||||
);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename(
|
||||
PyObject * PyErr_SetExcFromWindowsErrWithUnicodeFilename(
|
||||
PyObject *,int, const Py_UNICODE *);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int);
|
||||
PyObject * PyErr_SetExcFromWindowsErr(PyObject *, int);
|
||||
#endif /* MS_WINDOWS */
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetImportErrorSubclass(PyObject *, PyObject *,
|
||||
PyObject * PyErr_SetImportErrorSubclass(PyObject *, PyObject *,
|
||||
PyObject *, PyObject *);
|
||||
#endif
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetImportError(PyObject *, PyObject *,
|
||||
PyObject * PyErr_SetImportError(PyObject *, PyObject *,
|
||||
PyObject *);
|
||||
#endif
|
||||
|
||||
/* Export the old function so that the existing API remains available: */
|
||||
PyAPI_FUNC(void) PyErr_BadInternalCall(void);
|
||||
PyAPI_FUNC(void) _PyErr_BadInternalCall(const char *filename, int lineno);
|
||||
void PyErr_BadInternalCall(void);
|
||||
void _PyErr_BadInternalCall(const char *filename, int lineno);
|
||||
/* Mask the old API with a call to the new API for code compiled under
|
||||
Python 2.0: */
|
||||
#define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__)
|
||||
|
||||
/* Function to create a new exception */
|
||||
PyAPI_FUNC(PyObject *) PyErr_NewException(
|
||||
PyObject * PyErr_NewException(
|
||||
const char *name, PyObject *base, PyObject *dict);
|
||||
PyAPI_FUNC(PyObject *) PyErr_NewExceptionWithDoc(
|
||||
PyObject * PyErr_NewExceptionWithDoc(
|
||||
const char *name, const char *doc, PyObject *base, PyObject *dict);
|
||||
PyAPI_FUNC(void) PyErr_WriteUnraisable(PyObject *);
|
||||
void PyErr_WriteUnraisable(PyObject *);
|
||||
|
||||
/* In exceptions.c */
|
||||
#ifndef Py_LIMITED_API
|
||||
|
@ -340,7 +342,7 @@ PyAPI_FUNC(void) PyErr_WriteUnraisable(PyObject *);
|
|||
* Returns a borrowed reference to the new exception (if any), NULL if the
|
||||
* existing exception was left in place.
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) _PyErr_TrySetFromCause(
|
||||
PyObject * _PyErr_TrySetFromCause(
|
||||
const char *prefix_format, /* ASCII-encoded string */
|
||||
...
|
||||
);
|
||||
|
@ -348,8 +350,8 @@ PyAPI_FUNC(PyObject *) _PyErr_TrySetFromCause(
|
|||
|
||||
|
||||
/* In sigcheck.c or signalmodule.c */
|
||||
PyAPI_FUNC(int) PyErr_CheckSignals(void);
|
||||
PyAPI_FUNC(void) PyErr_SetInterrupt(void);
|
||||
int PyErr_CheckSignals(void);
|
||||
void PyErr_SetInterrupt(void);
|
||||
|
||||
/* In signalmodule.c */
|
||||
#ifndef Py_LIMITED_API
|
||||
|
@ -357,24 +359,24 @@ int PySignal_SetWakeupFd(int fd);
|
|||
#endif
|
||||
|
||||
/* Support for adding program text to SyntaxErrors */
|
||||
PyAPI_FUNC(void) PyErr_SyntaxLocation(
|
||||
void PyErr_SyntaxLocation(
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
int lineno);
|
||||
PyAPI_FUNC(void) PyErr_SyntaxLocationEx(
|
||||
void PyErr_SyntaxLocationEx(
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
int lineno,
|
||||
int col_offset);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) PyErr_SyntaxLocationObject(
|
||||
void PyErr_SyntaxLocationObject(
|
||||
PyObject *filename,
|
||||
int lineno,
|
||||
int col_offset);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyErr_ProgramText(
|
||||
PyObject * PyErr_ProgramText(
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
int lineno);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) PyErr_ProgramTextObject(
|
||||
PyObject * PyErr_ProgramTextObject(
|
||||
PyObject *filename,
|
||||
int lineno);
|
||||
#endif
|
||||
|
@ -383,7 +385,7 @@ PyAPI_FUNC(PyObject *) PyErr_ProgramTextObject(
|
|||
exceptions from C */
|
||||
|
||||
/* create a UnicodeDecodeError object */
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_Create(
|
||||
PyObject * PyUnicodeDecodeError_Create(
|
||||
const char *encoding, /* UTF-8 encoded string */
|
||||
const char *object,
|
||||
Py_ssize_t length,
|
||||
|
@ -394,7 +396,7 @@ PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_Create(
|
|||
|
||||
/* create a UnicodeEncodeError object */
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create(
|
||||
PyObject * PyUnicodeEncodeError_Create(
|
||||
const char *encoding, /* UTF-8 encoded string */
|
||||
const Py_UNICODE *object,
|
||||
Py_ssize_t length,
|
||||
|
@ -406,14 +408,14 @@ PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create(
|
|||
|
||||
/* create a UnicodeTranslateError object */
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
|
||||
PyObject * PyUnicodeTranslateError_Create(
|
||||
const Py_UNICODE *object,
|
||||
Py_ssize_t length,
|
||||
Py_ssize_t start,
|
||||
Py_ssize_t end,
|
||||
const char *reason /* UTF-8 encoded string */
|
||||
);
|
||||
PyAPI_FUNC(PyObject *) _PyUnicodeTranslateError_Create(
|
||||
PyObject * _PyUnicodeTranslateError_Create(
|
||||
PyObject *object,
|
||||
Py_ssize_t start,
|
||||
Py_ssize_t end,
|
||||
|
@ -422,54 +424,54 @@ PyAPI_FUNC(PyObject *) _PyUnicodeTranslateError_Create(
|
|||
#endif
|
||||
|
||||
/* get the encoding attribute */
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetEncoding(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetEncoding(PyObject *);
|
||||
PyObject * PyUnicodeEncodeError_GetEncoding(PyObject *);
|
||||
PyObject * PyUnicodeDecodeError_GetEncoding(PyObject *);
|
||||
|
||||
/* get the object attribute */
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetObject(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetObject(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetObject(PyObject *);
|
||||
PyObject * PyUnicodeEncodeError_GetObject(PyObject *);
|
||||
PyObject * PyUnicodeDecodeError_GetObject(PyObject *);
|
||||
PyObject * PyUnicodeTranslateError_GetObject(PyObject *);
|
||||
|
||||
/* get the value of the start attribute (the int * may not be NULL)
|
||||
return 0 on success, -1 on failure */
|
||||
PyAPI_FUNC(int) PyUnicodeEncodeError_GetStart(PyObject *, Py_ssize_t *);
|
||||
PyAPI_FUNC(int) PyUnicodeDecodeError_GetStart(PyObject *, Py_ssize_t *);
|
||||
PyAPI_FUNC(int) PyUnicodeTranslateError_GetStart(PyObject *, Py_ssize_t *);
|
||||
int PyUnicodeEncodeError_GetStart(PyObject *, Py_ssize_t *);
|
||||
int PyUnicodeDecodeError_GetStart(PyObject *, Py_ssize_t *);
|
||||
int PyUnicodeTranslateError_GetStart(PyObject *, Py_ssize_t *);
|
||||
|
||||
/* assign a new value to the start attribute
|
||||
return 0 on success, -1 on failure */
|
||||
PyAPI_FUNC(int) PyUnicodeEncodeError_SetStart(PyObject *, Py_ssize_t);
|
||||
PyAPI_FUNC(int) PyUnicodeDecodeError_SetStart(PyObject *, Py_ssize_t);
|
||||
PyAPI_FUNC(int) PyUnicodeTranslateError_SetStart(PyObject *, Py_ssize_t);
|
||||
int PyUnicodeEncodeError_SetStart(PyObject *, Py_ssize_t);
|
||||
int PyUnicodeDecodeError_SetStart(PyObject *, Py_ssize_t);
|
||||
int PyUnicodeTranslateError_SetStart(PyObject *, Py_ssize_t);
|
||||
|
||||
/* get the value of the end attribute (the int *may not be NULL)
|
||||
return 0 on success, -1 on failure */
|
||||
PyAPI_FUNC(int) PyUnicodeEncodeError_GetEnd(PyObject *, Py_ssize_t *);
|
||||
PyAPI_FUNC(int) PyUnicodeDecodeError_GetEnd(PyObject *, Py_ssize_t *);
|
||||
PyAPI_FUNC(int) PyUnicodeTranslateError_GetEnd(PyObject *, Py_ssize_t *);
|
||||
int PyUnicodeEncodeError_GetEnd(PyObject *, Py_ssize_t *);
|
||||
int PyUnicodeDecodeError_GetEnd(PyObject *, Py_ssize_t *);
|
||||
int PyUnicodeTranslateError_GetEnd(PyObject *, Py_ssize_t *);
|
||||
|
||||
/* assign a new value to the end attribute
|
||||
return 0 on success, -1 on failure */
|
||||
PyAPI_FUNC(int) PyUnicodeEncodeError_SetEnd(PyObject *, Py_ssize_t);
|
||||
PyAPI_FUNC(int) PyUnicodeDecodeError_SetEnd(PyObject *, Py_ssize_t);
|
||||
PyAPI_FUNC(int) PyUnicodeTranslateError_SetEnd(PyObject *, Py_ssize_t);
|
||||
int PyUnicodeEncodeError_SetEnd(PyObject *, Py_ssize_t);
|
||||
int PyUnicodeDecodeError_SetEnd(PyObject *, Py_ssize_t);
|
||||
int PyUnicodeTranslateError_SetEnd(PyObject *, Py_ssize_t);
|
||||
|
||||
/* get the value of the reason attribute */
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetReason(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetReason(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetReason(PyObject *);
|
||||
PyObject * PyUnicodeEncodeError_GetReason(PyObject *);
|
||||
PyObject * PyUnicodeDecodeError_GetReason(PyObject *);
|
||||
PyObject * PyUnicodeTranslateError_GetReason(PyObject *);
|
||||
|
||||
/* assign a new value to the reason attribute
|
||||
return 0 on success, -1 on failure */
|
||||
PyAPI_FUNC(int) PyUnicodeEncodeError_SetReason(
|
||||
int PyUnicodeEncodeError_SetReason(
|
||||
PyObject *exc,
|
||||
const char *reason /* UTF-8 encoded string */
|
||||
);
|
||||
PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason(
|
||||
int PyUnicodeDecodeError_SetReason(
|
||||
PyObject *exc,
|
||||
const char *reason /* UTF-8 encoded string */
|
||||
);
|
||||
PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason(
|
||||
int PyUnicodeTranslateError_SetReason(
|
||||
PyObject *exc,
|
||||
const char *reason /* UTF-8 encoded string */
|
||||
);
|
||||
|
@ -488,9 +490,9 @@ PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason(
|
|||
# define vsnprintf _vsnprintf
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(int) PyOS_snprintf(char *str, size_t size, const char *format, ...)
|
||||
int PyOS_snprintf(char *str, size_t size, const char *format, ...)
|
||||
Py_GCC_ATTRIBUTE((format(printf, 3, 4)));
|
||||
PyAPI_FUNC(int) PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va)
|
||||
int PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va)
|
||||
Py_GCC_ATTRIBUTE((format(printf, 3, 0)));
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
14
third_party/python/Include/pyexpat.h
vendored
14
third_party/python/Include/pyexpat.h
vendored
|
@ -1,8 +1,10 @@
|
|||
#ifndef COSMOPOLITAN_THIRD_PARTY_PYTHON_INCLUDE_PYEXPAT_H_
|
||||
#define COSMOPOLITAN_THIRD_PARTY_PYTHON_INCLUDE_PYEXPAT_H_
|
||||
#include "third_party/python/Modules/expat/expat.h"
|
||||
#include "third_party/python/Modules/expat/expat_external.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
/* Stuff to export relevant 'expat' entry points from pyexpat to other
|
||||
* parser modules, such as cElementTree. */
|
||||
|
||||
/* note: you must import expat.h before importing this module! */
|
||||
|
||||
#define PyExpat_CAPI_MAGIC "pyexpat.expat_CAPI 1.1"
|
||||
#define PyExpat_CAPSULE_NAME "pyexpat.expat_CAPI"
|
||||
|
@ -54,3 +56,7 @@ struct PyExpat_CAPI
|
|||
/* always add new stuff to the end! */
|
||||
};
|
||||
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_THIRD_PARTY_PYTHON_INCLUDE_PYEXPAT_H_ */
|
||||
|
|
10
third_party/python/Include/pygetopt.h
vendored
10
third_party/python/Include/pygetopt.h
vendored
|
@ -4,13 +4,13 @@ COSMOPOLITAN_C_START_
|
|||
/* clang-format off */
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_DATA(int) _PyOS_opterr;
|
||||
PyAPI_DATA(int) _PyOS_optind;
|
||||
PyAPI_DATA(wchar_t *) _PyOS_optarg;
|
||||
extern int _PyOS_opterr;
|
||||
extern int _PyOS_optind;
|
||||
extern wchar_t * _PyOS_optarg;
|
||||
|
||||
PyAPI_FUNC(void) _PyOS_ResetGetOpt(void);
|
||||
void _PyOS_ResetGetOpt(void);
|
||||
|
||||
PyAPI_FUNC(int) _PyOS_GetOpt(int argc, wchar_t **argv, wchar_t *optstring);
|
||||
int _PyOS_GetOpt(int argc, wchar_t **argv, wchar_t *optstring);
|
||||
#endif /* !Py_LIMITED_API */
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
13
third_party/python/Include/pyhash.h
vendored
13
third_party/python/Include/pyhash.h
vendored
|
@ -1,13 +1,14 @@
|
|||
#ifndef Py_HASH_H
|
||||
#define Py_HASH_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
/* Helpers for hash functions */
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(Py_hash_t) _Py_HashDouble(double);
|
||||
PyAPI_FUNC(Py_hash_t) _Py_HashPointer(void*);
|
||||
PyAPI_FUNC(Py_hash_t) _Py_HashBytes(const void*, Py_ssize_t);
|
||||
Py_hash_t _Py_HashDouble(double);
|
||||
Py_hash_t _Py_HashPointer(void*);
|
||||
Py_hash_t _Py_HashBytes(const void*, Py_ssize_t);
|
||||
#endif
|
||||
|
||||
/* Prime multiplier used in string and various other hashes. */
|
||||
|
@ -72,11 +73,11 @@ typedef union {
|
|||
Py_hash_t hashsalt;
|
||||
} expat;
|
||||
} _Py_HashSecret_t;
|
||||
PyAPI_DATA(_Py_HashSecret_t) _Py_HashSecret;
|
||||
extern _Py_HashSecret_t _Py_HashSecret;
|
||||
#endif
|
||||
|
||||
#ifdef Py_DEBUG
|
||||
PyAPI_DATA(int) _Py_HashSecret_Initialized;
|
||||
extern int _Py_HashSecret_Initialized;
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -89,7 +90,7 @@ typedef struct {
|
|||
const int seed_bits;
|
||||
} PyHash_FuncDef;
|
||||
|
||||
PyAPI_FUNC(PyHash_FuncDef*) PyHash_GetFuncDef(void);
|
||||
PyHash_FuncDef* PyHash_GetFuncDef(void);
|
||||
#endif
|
||||
|
||||
|
||||
|
|
130
third_party/python/Include/pylifecycle.h
vendored
130
third_party/python/Include/pylifecycle.h
vendored
|
@ -1,124 +1,126 @@
|
|||
#ifndef Py_PYLIFECYCLE_H
|
||||
#define Py_PYLIFECYCLE_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/pystate.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
PyAPI_FUNC(void) Py_SetProgramName(wchar_t *);
|
||||
PyAPI_FUNC(wchar_t *) Py_GetProgramName(void);
|
||||
void Py_SetProgramName(wchar_t *);
|
||||
wchar_t * Py_GetProgramName(void);
|
||||
|
||||
PyAPI_FUNC(void) Py_SetPythonHome(wchar_t *);
|
||||
PyAPI_FUNC(wchar_t *) Py_GetPythonHome(void);
|
||||
void Py_SetPythonHome(wchar_t *);
|
||||
wchar_t * Py_GetPythonHome(void);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
/* Only used by applications that embed the interpreter and need to
|
||||
* override the standard encoding determination mechanism
|
||||
*/
|
||||
PyAPI_FUNC(int) Py_SetStandardStreamEncoding(const char *encoding,
|
||||
int Py_SetStandardStreamEncoding(const char *encoding,
|
||||
const char *errors);
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(void) Py_Initialize(void);
|
||||
PyAPI_FUNC(void) Py_InitializeEx(int);
|
||||
void Py_Initialize(void);
|
||||
void Py_InitializeEx(int);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) _Py_InitializeEx_Private(int, int);
|
||||
void _Py_InitializeEx_Private(int, int);
|
||||
#endif
|
||||
PyAPI_FUNC(void) Py_Finalize(void);
|
||||
void Py_Finalize(void);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000
|
||||
PyAPI_FUNC(int) Py_FinalizeEx(void);
|
||||
int Py_FinalizeEx(void);
|
||||
#endif
|
||||
PyAPI_FUNC(int) Py_IsInitialized(void);
|
||||
PyAPI_FUNC(PyThreadState *) Py_NewInterpreter(void);
|
||||
PyAPI_FUNC(void) Py_EndInterpreter(PyThreadState *);
|
||||
int Py_IsInitialized(void);
|
||||
PyThreadState * Py_NewInterpreter(void);
|
||||
void Py_EndInterpreter(PyThreadState *);
|
||||
|
||||
|
||||
/* Py_PyAtExit is for the atexit module, Py_AtExit is for low-level
|
||||
* exit functions.
|
||||
*/
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) _Py_PyAtExit(void (*func)(void));
|
||||
void _Py_PyAtExit(void (*func)(void));
|
||||
#endif
|
||||
PyAPI_FUNC(int) Py_AtExit(void (*func)(void));
|
||||
int Py_AtExit(void (*func)(void));
|
||||
|
||||
PyAPI_FUNC(void) Py_Exit(int);
|
||||
void Py_Exit(int);
|
||||
|
||||
/* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. */
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) _Py_RestoreSignals(void);
|
||||
void _Py_RestoreSignals(void);
|
||||
|
||||
PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *);
|
||||
int Py_FdIsInteractive(FILE *, const char *);
|
||||
#endif
|
||||
|
||||
/* Bootstrap __main__ (defined in Modules/main.c) */
|
||||
PyAPI_FUNC(int) Py_Main(int argc, wchar_t **argv);
|
||||
int Py_Main(int argc, wchar_t **argv);
|
||||
|
||||
/* In getpath.c */
|
||||
PyAPI_FUNC(wchar_t *) Py_GetProgramFullPath(void);
|
||||
PyAPI_FUNC(wchar_t *) Py_GetPrefix(void);
|
||||
PyAPI_FUNC(wchar_t *) Py_GetExecPrefix(void);
|
||||
PyAPI_FUNC(wchar_t *) Py_GetPath(void);
|
||||
PyAPI_FUNC(void) Py_SetPath(const wchar_t *);
|
||||
wchar_t * Py_GetProgramFullPath(void);
|
||||
wchar_t * Py_GetPrefix(void);
|
||||
wchar_t * Py_GetExecPrefix(void);
|
||||
wchar_t * Py_GetPath(void);
|
||||
void Py_SetPath(const wchar_t *);
|
||||
#ifdef MS_WINDOWS
|
||||
int _Py_CheckPython3();
|
||||
#endif
|
||||
|
||||
/* In their own files */
|
||||
PyAPI_FUNC(const char *) Py_GetVersion(void);
|
||||
PyAPI_FUNC(const char *) Py_GetPlatform(void);
|
||||
PyAPI_FUNC(const char *) Py_GetCopyright(void);
|
||||
PyAPI_FUNC(const char *) Py_GetCompiler(void);
|
||||
PyAPI_FUNC(const char *) Py_GetBuildInfo(void);
|
||||
const char * Py_GetVersion(void);
|
||||
const char * Py_GetPlatform(void);
|
||||
const char * Py_GetCopyright(void);
|
||||
const char * Py_GetCompiler(void);
|
||||
const char * Py_GetBuildInfo(void);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(const char *) _Py_gitidentifier(void);
|
||||
PyAPI_FUNC(const char *) _Py_gitversion(void);
|
||||
const char * _Py_gitidentifier(void);
|
||||
const char * _Py_gitversion(void);
|
||||
#endif
|
||||
|
||||
/* Internal -- various one-time initializations */
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) _PyBuiltin_Init(void);
|
||||
PyAPI_FUNC(PyObject *) _PySys_Init(void);
|
||||
PyAPI_FUNC(void) _PyImport_Init(void);
|
||||
PyAPI_FUNC(void) _PyExc_Init(PyObject * bltinmod);
|
||||
PyAPI_FUNC(void) _PyImportHooks_Init(void);
|
||||
PyAPI_FUNC(int) _PyFrame_Init(void);
|
||||
PyAPI_FUNC(int) _PyFloat_Init(void);
|
||||
PyAPI_FUNC(int) PyByteArray_Init(void);
|
||||
PyAPI_FUNC(void) _PyRandom_Init(void);
|
||||
PyObject * _PyBuiltin_Init(void);
|
||||
PyObject * _PySys_Init(void);
|
||||
void _PyImport_Init(void);
|
||||
void _PyExc_Init(PyObject * bltinmod);
|
||||
void _PyImportHooks_Init(void);
|
||||
int _PyFrame_Init(void);
|
||||
int _PyFloat_Init(void);
|
||||
int PyByteArray_Init(void);
|
||||
void _PyRandom_Init(void);
|
||||
#endif
|
||||
|
||||
/* Various internal finalizers */
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) _PyExc_Fini(void);
|
||||
PyAPI_FUNC(void) _PyImport_Fini(void);
|
||||
PyAPI_FUNC(void) PyMethod_Fini(void);
|
||||
PyAPI_FUNC(void) PyFrame_Fini(void);
|
||||
PyAPI_FUNC(void) PyCFunction_Fini(void);
|
||||
PyAPI_FUNC(void) PyDict_Fini(void);
|
||||
PyAPI_FUNC(void) PyTuple_Fini(void);
|
||||
PyAPI_FUNC(void) PyList_Fini(void);
|
||||
PyAPI_FUNC(void) PySet_Fini(void);
|
||||
PyAPI_FUNC(void) PyBytes_Fini(void);
|
||||
PyAPI_FUNC(void) PyByteArray_Fini(void);
|
||||
PyAPI_FUNC(void) PyFloat_Fini(void);
|
||||
PyAPI_FUNC(void) PyOS_FiniInterrupts(void);
|
||||
PyAPI_FUNC(void) _PyGC_DumpShutdownStats(void);
|
||||
PyAPI_FUNC(void) _PyGC_Fini(void);
|
||||
PyAPI_FUNC(void) PySlice_Fini(void);
|
||||
PyAPI_FUNC(void) _PyType_Fini(void);
|
||||
PyAPI_FUNC(void) _PyRandom_Fini(void);
|
||||
PyAPI_FUNC(void) PyAsyncGen_Fini(void);
|
||||
void _PyExc_Fini(void);
|
||||
void _PyImport_Fini(void);
|
||||
void PyMethod_Fini(void);
|
||||
void PyFrame_Fini(void);
|
||||
void PyCFunction_Fini(void);
|
||||
void PyDict_Fini(void);
|
||||
void PyTuple_Fini(void);
|
||||
void PyList_Fini(void);
|
||||
void PySet_Fini(void);
|
||||
void PyBytes_Fini(void);
|
||||
void PyByteArray_Fini(void);
|
||||
void PyFloat_Fini(void);
|
||||
void PyOS_FiniInterrupts(void);
|
||||
void _PyGC_DumpShutdownStats(void);
|
||||
void _PyGC_Fini(void);
|
||||
void PySlice_Fini(void);
|
||||
void _PyType_Fini(void);
|
||||
void _PyRandom_Fini(void);
|
||||
void PyAsyncGen_Fini(void);
|
||||
|
||||
PyAPI_DATA(PyThreadState *) _Py_Finalizing;
|
||||
extern PyThreadState * _Py_Finalizing;
|
||||
#endif
|
||||
|
||||
/* Signals */
|
||||
typedef void (*PyOS_sighandler_t)(int);
|
||||
PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int);
|
||||
PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t);
|
||||
PyOS_sighandler_t PyOS_getsig(int);
|
||||
PyOS_sighandler_t PyOS_setsig(int, PyOS_sighandler_t);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
/* Random */
|
||||
PyAPI_FUNC(int) _PyOS_URandom(void *buffer, Py_ssize_t size);
|
||||
PyAPI_FUNC(int) _PyOS_URandomNonblock(void *buffer, Py_ssize_t size);
|
||||
int _PyOS_URandom(void *buffer, Py_ssize_t size);
|
||||
int _PyOS_URandomNonblock(void *buffer, Py_ssize_t size);
|
||||
#endif /* !Py_LIMITED_API */
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
104
third_party/python/Include/pymacconfig.h
vendored
104
third_party/python/Include/pymacconfig.h
vendored
|
@ -1,104 +0,0 @@
|
|||
#ifndef PYMACCONFIG_H
|
||||
#define PYMACCONFIG_H
|
||||
/* clang-format off */
|
||||
|
||||
/*
|
||||
* This file moves some of the autoconf magic to compile-time
|
||||
* when building on MacOSX. This is needed for building 4-way
|
||||
* universal binaries and for 64-bit universal binaries because
|
||||
* the values redefined below aren't configure-time constant but
|
||||
* only compile-time constant in these scenarios.
|
||||
*/
|
||||
|
||||
#if defined(__APPLE__)
|
||||
|
||||
# undef SIZEOF_LONG
|
||||
# undef SIZEOF_PTHREAD_T
|
||||
# undef SIZEOF_SIZE_T
|
||||
# undef SIZEOF_TIME_T
|
||||
# undef SIZEOF_VOID_P
|
||||
# undef SIZEOF__BOOL
|
||||
# undef SIZEOF_UINTPTR_T
|
||||
# undef SIZEOF_PTHREAD_T
|
||||
# undef WORDS_BIGENDIAN
|
||||
# undef DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754
|
||||
# undef DOUBLE_IS_BIG_ENDIAN_IEEE754
|
||||
# undef DOUBLE_IS_LITTLE_ENDIAN_IEEE754
|
||||
# undef HAVE_GCC_ASM_FOR_X87
|
||||
|
||||
# undef VA_LIST_IS_ARRAY
|
||||
# if defined(__LP64__) && defined(__x86_64__)
|
||||
# define VA_LIST_IS_ARRAY 1
|
||||
# endif
|
||||
|
||||
# undef HAVE_LARGEFILE_SUPPORT
|
||||
# ifndef __LP64__
|
||||
# define HAVE_LARGEFILE_SUPPORT 1
|
||||
# endif
|
||||
|
||||
# undef SIZEOF_LONG
|
||||
# ifdef __LP64__
|
||||
# define SIZEOF__BOOL 1
|
||||
# define SIZEOF__BOOL 1
|
||||
# define SIZEOF_LONG 8
|
||||
# define SIZEOF_PTHREAD_T 8
|
||||
# define SIZEOF_SIZE_T 8
|
||||
# define SIZEOF_TIME_T 8
|
||||
# define SIZEOF_VOID_P 8
|
||||
# define SIZEOF_UINTPTR_T 8
|
||||
# define SIZEOF_PTHREAD_T 8
|
||||
# else
|
||||
# ifdef __ppc__
|
||||
# define SIZEOF__BOOL 4
|
||||
# else
|
||||
# define SIZEOF__BOOL 1
|
||||
# endif
|
||||
# define SIZEOF_LONG 4
|
||||
# define SIZEOF_PTHREAD_T 4
|
||||
# define SIZEOF_SIZE_T 4
|
||||
# define SIZEOF_TIME_T 4
|
||||
# define SIZEOF_VOID_P 4
|
||||
# define SIZEOF_UINTPTR_T 4
|
||||
# define SIZEOF_PTHREAD_T 4
|
||||
# endif
|
||||
|
||||
# if defined(__LP64__)
|
||||
/* MacOSX 10.4 (the first release to support 64-bit code
|
||||
* at all) only supports 64-bit in the UNIX layer.
|
||||
* Therefore suppress the toolbox-glue in 64-bit mode.
|
||||
*/
|
||||
|
||||
/* In 64-bit mode setpgrp always has no arguments, in 32-bit
|
||||
* mode that depends on the compilation environment
|
||||
*/
|
||||
# undef SETPGRP_HAVE_ARG
|
||||
|
||||
# endif
|
||||
|
||||
#ifdef __BIG_ENDIAN__
|
||||
#define WORDS_BIGENDIAN 1
|
||||
#define DOUBLE_IS_BIG_ENDIAN_IEEE754
|
||||
#else
|
||||
#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754
|
||||
#endif /* __BIG_ENDIAN */
|
||||
|
||||
#ifdef __i386__
|
||||
# define HAVE_GCC_ASM_FOR_X87
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The definition in pyconfig.h is only valid on the OS release
|
||||
* where configure ran on and not necessarily for all systems where
|
||||
* the executable can be used on.
|
||||
*
|
||||
* Specifically: OSX 10.4 has limited supported for '%zd', while
|
||||
* 10.5 has full support for '%zd'. A binary built on 10.5 won't
|
||||
* work properly on 10.4 unless we suppress the definition
|
||||
* of PY_FORMAT_SIZE_T
|
||||
*/
|
||||
#undef PY_FORMAT_SIZE_T
|
||||
|
||||
|
||||
#endif /* defined(_APPLE__) */
|
||||
|
||||
#endif /* PYMACCONFIG_H */
|
7
third_party/python/Include/pymath.h
vendored
7
third_party/python/Include/pymath.h
vendored
|
@ -1,5 +1,6 @@
|
|||
#ifndef Py_PYMATH_H
|
||||
#define Py_PYMATH_H
|
||||
#include "libc/math.h"
|
||||
#include "third_party/python/pyconfig.h"
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -69,7 +70,7 @@ extern double pow(double, double);
|
|||
#ifndef Py_LIMITED_API
|
||||
#ifndef Py_FORCE_DOUBLE
|
||||
#ifdef X87_DOUBLE_ROUNDING
|
||||
PyAPI_FUNC(double) _Py_force_double(double);
|
||||
double _Py_force_double(double);
|
||||
#define Py_FORCE_DOUBLE(X) (_Py_force_double(X))
|
||||
#else
|
||||
#define Py_FORCE_DOUBLE(X) (X)
|
||||
|
@ -79,8 +80,8 @@ PyAPI_FUNC(double) _Py_force_double(double);
|
|||
|
||||
#ifndef Py_LIMITED_API
|
||||
#ifdef HAVE_GCC_ASM_FOR_X87
|
||||
PyAPI_FUNC(unsigned short) _Py_get_387controlword(void);
|
||||
PyAPI_FUNC(void) _Py_set_387controlword(unsigned short);
|
||||
unsigned short _Py_get_387controlword(void);
|
||||
void _Py_set_387controlword(unsigned short);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
49
third_party/python/Include/pymem.h
vendored
49
third_party/python/Include/pymem.h
vendored
|
@ -1,21 +1,32 @@
|
|||
#ifndef Py_PYMEM_H
|
||||
#define Py_PYMEM_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/pyport.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
/* Debug-mode build with pymalloc implies PYMALLOC_DEBUG.
|
||||
* PYMALLOC_DEBUG is in error if pymalloc is not in use.
|
||||
*/
|
||||
#if defined(Py_DEBUG) && defined(WITH_PYMALLOC) && !defined(PYMALLOC_DEBUG)
|
||||
#define PYMALLOC_DEBUG
|
||||
#endif
|
||||
#if defined(PYMALLOC_DEBUG) && !defined(WITH_PYMALLOC)
|
||||
#error "PYMALLOC_DEBUG requires WITH_PYMALLOC"
|
||||
#endif
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void *) PyMem_RawMalloc(size_t size);
|
||||
PyAPI_FUNC(void *) PyMem_RawCalloc(size_t nelem, size_t elsize);
|
||||
PyAPI_FUNC(void *) PyMem_RawRealloc(void *ptr, size_t new_size);
|
||||
PyAPI_FUNC(void) PyMem_RawFree(void *ptr);
|
||||
void * PyMem_RawMalloc(size_t size);
|
||||
void * PyMem_RawCalloc(size_t nelem, size_t elsize);
|
||||
void * PyMem_RawRealloc(void *ptr, size_t new_size);
|
||||
void PyMem_RawFree(void *ptr);
|
||||
|
||||
/* Configure the Python memory allocators. Pass NULL to use default
|
||||
allocators. */
|
||||
PyAPI_FUNC(int) _PyMem_SetupAllocators(const char *opt);
|
||||
int _PyMem_SetupAllocators(const char *opt);
|
||||
|
||||
#ifdef WITH_PYMALLOC
|
||||
PyAPI_FUNC(int) _PyMem_PymallocEnabled(void);
|
||||
int _PyMem_PymallocEnabled(void);
|
||||
#endif
|
||||
|
||||
/* Identifier of an address space (domain) in tracemalloc */
|
||||
|
@ -28,7 +39,7 @@ typedef unsigned int _PyTraceMalloc_domain_t;
|
|||
Return -2 if tracemalloc is disabled.
|
||||
|
||||
If memory block is already tracked, update the existing trace. */
|
||||
PyAPI_FUNC(int) _PyTraceMalloc_Track(
|
||||
int _PyTraceMalloc_Track(
|
||||
_PyTraceMalloc_domain_t domain,
|
||||
uintptr_t ptr,
|
||||
size_t size);
|
||||
|
@ -37,7 +48,7 @@ PyAPI_FUNC(int) _PyTraceMalloc_Track(
|
|||
Do nothing if the block was not tracked.
|
||||
|
||||
Return -2 if tracemalloc is disabled, otherwise return 0. */
|
||||
PyAPI_FUNC(int) _PyTraceMalloc_Untrack(
|
||||
int _PyTraceMalloc_Untrack(
|
||||
_PyTraceMalloc_domain_t domain,
|
||||
uintptr_t ptr);
|
||||
|
||||
|
@ -49,11 +60,11 @@ PyAPI_FUNC(int) _PyTraceMalloc_Untrack(
|
|||
is not tracked by tracemalloc.
|
||||
|
||||
Raise an exception and return NULL on error. */
|
||||
PyAPI_FUNC(PyObject*) _PyTraceMalloc_GetTraceback(
|
||||
PyObject* _PyTraceMalloc_GetTraceback(
|
||||
_PyTraceMalloc_domain_t domain,
|
||||
uintptr_t ptr);
|
||||
|
||||
PyAPI_FUNC(int) _PyMem_IsFreed(void *ptr, size_t size);
|
||||
int _PyMem_IsFreed(void *ptr, size_t size);
|
||||
#endif /* !defined(Py_LIMITED_API) */
|
||||
|
||||
|
||||
|
@ -95,16 +106,16 @@ PyAPI_FUNC(int) _PyMem_IsFreed(void *ptr, size_t size);
|
|||
performed on failure (no exception is set, no warning is printed, etc).
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(void *) PyMem_Malloc(size_t size);
|
||||
void * PyMem_Malloc(size_t size);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||
PyAPI_FUNC(void *) PyMem_Calloc(size_t nelem, size_t elsize);
|
||||
void * PyMem_Calloc(size_t nelem, size_t elsize);
|
||||
#endif
|
||||
PyAPI_FUNC(void *) PyMem_Realloc(void *ptr, size_t new_size);
|
||||
PyAPI_FUNC(void) PyMem_Free(void *ptr);
|
||||
void * PyMem_Realloc(void *ptr, size_t new_size);
|
||||
void PyMem_Free(void *ptr);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(char *) _PyMem_RawStrdup(const char *str);
|
||||
PyAPI_FUNC(char *) _PyMem_Strdup(const char *str);
|
||||
char * _PyMem_RawStrdup(const char *str);
|
||||
char * _PyMem_Strdup(const char *str);
|
||||
#endif
|
||||
|
||||
/* Macros. */
|
||||
|
@ -185,7 +196,7 @@ typedef struct {
|
|||
} PyMemAllocatorEx;
|
||||
|
||||
/* Get the memory block allocator of the specified domain. */
|
||||
PyAPI_FUNC(void) PyMem_GetAllocator(PyMemAllocatorDomain domain,
|
||||
void PyMem_GetAllocator(PyMemAllocatorDomain domain,
|
||||
PyMemAllocatorEx *allocator);
|
||||
|
||||
/* Set the memory block allocator of the specified domain.
|
||||
|
@ -199,7 +210,7 @@ PyAPI_FUNC(void) PyMem_GetAllocator(PyMemAllocatorDomain domain,
|
|||
If the new allocator is not a hook (don't call the previous allocator), the
|
||||
PyMem_SetupDebugHooks() function must be called to reinstall the debug hooks
|
||||
on top on the new allocator. */
|
||||
PyAPI_FUNC(void) PyMem_SetAllocator(PyMemAllocatorDomain domain,
|
||||
void PyMem_SetAllocator(PyMemAllocatorDomain domain,
|
||||
PyMemAllocatorEx *allocator);
|
||||
|
||||
/* Setup hooks to detect bugs in the following Python memory allocator
|
||||
|
@ -218,7 +229,7 @@ PyAPI_FUNC(void) PyMem_SetAllocator(PyMemAllocatorDomain domain,
|
|||
- detect write after the end of the buffer (buffer overflow)
|
||||
|
||||
The function does nothing if Python is not compiled is debug mode. */
|
||||
PyAPI_FUNC(void) PyMem_SetupDebugHooks(void);
|
||||
void PyMem_SetupDebugHooks(void);
|
||||
#endif
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
236
third_party/python/Include/pyport.h
vendored
236
third_party/python/Include/pyport.h
vendored
|
@ -1,63 +1,15 @@
|
|||
#ifndef Py_PYPORT_H
|
||||
#define Py_PYPORT_H
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/termios.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/limits.h"
|
||||
#include "libc/math.h"
|
||||
#include "libc/str/str.h"
|
||||
#include "libc/sysv/consts/clock.h"
|
||||
#include "libc/sysv/consts/itimer.h"
|
||||
#include "libc/sysv/consts/s.h"
|
||||
#include "libc/sysv/consts/sched.h"
|
||||
#include "libc/sysv/consts/termios.h"
|
||||
#include "libc/time/time.h"
|
||||
#include "third_party/python/Include/pymath.h"
|
||||
#include "third_party/python/pyconfig.h"
|
||||
/* clang-format off */
|
||||
|
||||
/**************************************************************************
|
||||
Symbols and macros to supply platform-independent interfaces to basic
|
||||
C language & library operations whose spellings vary across platforms.
|
||||
|
||||
Please try to make documentation here as clear as possible: by definition,
|
||||
the stuff here is trying to illuminate C's darkest corners.
|
||||
|
||||
Config #defines referenced here:
|
||||
|
||||
SIGNED_RIGHT_SHIFT_ZERO_FILLS
|
||||
Meaning: To be defined iff i>>j does not extend the sign bit when i is a
|
||||
signed integral type and i < 0.
|
||||
Used in: Py_ARITHMETIC_RIGHT_SHIFT
|
||||
|
||||
Py_DEBUG
|
||||
Meaning: Extra checks compiled in for debug mode.
|
||||
Used in: Py_SAFE_DOWNCAST
|
||||
|
||||
**************************************************************************/
|
||||
|
||||
/* typedefs for some C9X-defined synonyms for integral types.
|
||||
*
|
||||
* The names in Python are exactly the same as the C9X names, except with a
|
||||
* Py_ prefix. Until C9X is universally implemented, this is the only way
|
||||
* to ensure that Python gets reliable names that don't conflict with names
|
||||
* in non-Python code that are playing their own tricks to define the C9X
|
||||
* names.
|
||||
*
|
||||
* NOTE: don't go nuts here! Python has no use for *most* of the C9X
|
||||
* integral synonyms. Only define the ones we actually need.
|
||||
*/
|
||||
|
||||
/* long long is required. Ensure HAVE_LONG_LONG is defined for compatibility. */
|
||||
#ifndef HAVE_LONG_LONG
|
||||
#define HAVE_LONG_LONG 1
|
||||
#endif
|
||||
#ifndef PY_LONG_LONG
|
||||
#define PY_LONG_LONG long long
|
||||
/* If LLONG_MAX is defined in limits.h, use that. */
|
||||
#define PY_LLONG_MIN LLONG_MIN
|
||||
#define PY_LLONG_MAX LLONG_MAX
|
||||
#define PY_ULLONG_MAX ULLONG_MAX
|
||||
#endif
|
||||
|
||||
#define PY_UINT32_T uint32_t
|
||||
#define PY_UINT64_T uint64_t
|
||||
|
@ -112,78 +64,11 @@ typedef Py_ssize_t Py_ssize_clean_t;
|
|||
typedef int Py_ssize_clean_t;
|
||||
#endif
|
||||
|
||||
/* Largest possible value of size_t. */
|
||||
#define PY_SIZE_MAX SIZE_MAX
|
||||
|
||||
/* Largest positive value of type Py_ssize_t. */
|
||||
#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1) >> 1))
|
||||
/* Smallest negative value of type Py_ssize_t. */
|
||||
#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX - 1)
|
||||
|
||||
/* PY_FORMAT_SIZE_T is a platform-specific modifier for use in a printf
|
||||
* format to convert an argument with the width of a size_t or Py_ssize_t.
|
||||
* C99 introduced "z" for this purpose, but not all platforms support that;
|
||||
* e.g., MS compilers use "I" instead.
|
||||
*
|
||||
* These "high level" Python format functions interpret "z" correctly on
|
||||
* all platforms (Python interprets the format string itself, and does whatever
|
||||
* the platform C requires to convert a size_t/Py_ssize_t argument):
|
||||
*
|
||||
* PyBytes_FromFormat
|
||||
* PyErr_Format
|
||||
* PyBytes_FromFormatV
|
||||
* PyUnicode_FromFormatV
|
||||
*
|
||||
* Lower-level uses require that you interpolate the correct format modifier
|
||||
* yourself (e.g., calling printf, fprintf, sprintf, PyOS_snprintf); for
|
||||
* example,
|
||||
*
|
||||
* Py_ssize_t index;
|
||||
* fprintf(stderr, "index %" PY_FORMAT_SIZE_T "d sucks\n", index);
|
||||
*
|
||||
* That will expand to %ld, or %Id, or to something else correct for a
|
||||
* Py_ssize_t on the platform.
|
||||
*/
|
||||
#ifndef PY_FORMAT_SIZE_T
|
||||
#if SIZEOF_SIZE_T == SIZEOF_INT && !defined(__APPLE__)
|
||||
#define PY_FORMAT_SIZE_T ""
|
||||
#elif SIZEOF_SIZE_T == SIZEOF_LONG
|
||||
#define PY_FORMAT_SIZE_T "l"
|
||||
#elif defined(MS_WINDOWS)
|
||||
#define PY_FORMAT_SIZE_T "I"
|
||||
#else
|
||||
#error "This platform's pyconfig.h needs to define PY_FORMAT_SIZE_T"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Py_LOCAL can be used instead of static to get the fastest possible calling
|
||||
* convention for functions that are local to a given module.
|
||||
*
|
||||
* Py_LOCAL_INLINE does the same thing, and also explicitly requests inlining,
|
||||
* for platforms that support that.
|
||||
*
|
||||
* If PY_LOCAL_AGGRESSIVE is defined before python.h is included, more
|
||||
* "aggressive" inlining/optimization is enabled for the entire module. This
|
||||
* may lead to code bloat, and may slow things down for those reasons. It may
|
||||
* also lead to errors, if the code relies on pointer aliasing. Use with
|
||||
* care.
|
||||
*
|
||||
* NOTE: You can only use this for functions that are entirely local to a
|
||||
* module; functions that are exported via method tables, callbacks, etc,
|
||||
* should keep using static.
|
||||
*/
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(PY_LOCAL_AGGRESSIVE)
|
||||
/* enable more aggressive optimization for visual studio */
|
||||
#pragma optimize("agtw", on)
|
||||
#endif
|
||||
/* ignore warnings if the compiler decides not to inline a function */
|
||||
#pragma warning(disable : 4710)
|
||||
/* fastest possible local call under MSVC */
|
||||
#define Py_LOCAL(type) static type __fastcall
|
||||
#define Py_LOCAL_INLINE(type) static __inline type __fastcall
|
||||
#elif defined(USE_INLINE)
|
||||
#ifdef USE_INLINE
|
||||
#define Py_LOCAL(type) static type
|
||||
#define Py_LOCAL_INLINE(type) static inline type
|
||||
#else
|
||||
|
@ -191,36 +76,7 @@ typedef int Py_ssize_clean_t;
|
|||
#define Py_LOCAL_INLINE(type) static type
|
||||
#endif
|
||||
|
||||
/* Py_MEMCPY is kept for backwards compatibility,
|
||||
* see https://bugs.python.org/issue28126 */
|
||||
#define Py_MEMCPY memcpy
|
||||
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
/* Py_ARITHMETIC_RIGHT_SHIFT
|
||||
* C doesn't define whether a right-shift of a signed integer sign-extends
|
||||
* or zero-fills. Here a macro to force sign extension:
|
||||
* Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J)
|
||||
* Return I >> J, forcing sign extension. Arithmetically, return the
|
||||
* floor of I/2**J.
|
||||
* Requirements:
|
||||
* I should have signed integer type. In the terminology of C99, this can
|
||||
* be either one of the five standard signed integer types (signed char,
|
||||
* short, int, long, long long) or an extended signed integer type.
|
||||
* J is an integer >= 0 and strictly less than the number of bits in the
|
||||
* type of I (because C doesn't define what happens for J outside that
|
||||
* range either).
|
||||
* TYPE used to specify the type of I, but is now ignored. It's been left
|
||||
* in for backwards compatibility with versions <= 2.6 or 3.0.
|
||||
* Caution:
|
||||
* I may be evaluated more than once.
|
||||
*/
|
||||
#ifdef SIGNED_RIGHT_SHIFT_ZERO_FILLS
|
||||
#define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) \
|
||||
((I) < 0 ? -1 - ((-1 - (I)) >> (J)) : (I) >> (J))
|
||||
#else
|
||||
#define Py_ARITHMETIC_RIGHT_SHIFT(TYPE, I, J) ((I) >> (J))
|
||||
#endif
|
||||
|
||||
/* Py_FORCE_EXPANSION(X)
|
||||
* "Simply" returns its argument. However, macro expansions within the
|
||||
|
@ -345,8 +201,6 @@ COSMOPOLITAN_C_START_
|
|||
_Py_set_387controlword(old_387controlword)
|
||||
#endif
|
||||
|
||||
/* get and set x87 control word for VisualStudio/x86 */
|
||||
|
||||
/* default definitions are empty */
|
||||
#ifndef HAVE_PY_SET_53BIT_PRECISION
|
||||
#define _Py_SET_53BIT_PRECISION_HEADER
|
||||
|
@ -354,18 +208,6 @@ COSMOPOLITAN_C_START_
|
|||
#define _Py_SET_53BIT_PRECISION_END
|
||||
#endif
|
||||
|
||||
/* If we can't guarantee 53-bit precision, don't use the code
|
||||
in Python/dtoa.c, but fall back to standard code. This
|
||||
means that repr of a float will be long (17 sig digits).
|
||||
|
||||
Realistically, there are two things that could go wrong:
|
||||
|
||||
(1) doubles aren't IEEE 754 doubles, or
|
||||
(2) we're on x86 with the rounding precision set to 64-bits
|
||||
(extended precision), and we don't know how to change
|
||||
the rounding precision.
|
||||
*/
|
||||
|
||||
#if !defined(DOUBLE_IS_LITTLE_ENDIAN_IEEE754) && \
|
||||
!defined(DOUBLE_IS_BIG_ENDIAN_IEEE754) && \
|
||||
!defined(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754)
|
||||
|
@ -393,73 +235,21 @@ COSMOPOLITAN_C_START_
|
|||
#define Py_DEPRECATED(VERSION_UNUSED)
|
||||
#endif
|
||||
|
||||
/**************************************************************************
|
||||
Prototypes that are missing from the standard include files on some systems
|
||||
(and possibly only some versions of such systems.)
|
||||
|
||||
Please be conservative with adding new ones, document them and enclose them
|
||||
in platform-specific #ifdefs.
|
||||
**************************************************************************/
|
||||
|
||||
#ifdef SOLARIS
|
||||
/* Unchecked */
|
||||
extern int gethostname(char *, int);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE__GETPTY
|
||||
extern char *_getpty(int *, int, mode_t, int);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY)
|
||||
#if !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H)
|
||||
/* BSDI does not supply a prototype for the 'openpty' and 'forkpty'
|
||||
functions, even though they are included in libutil. */
|
||||
extern int openpty(int *, int *, char *, struct termios *, struct winsize *);
|
||||
extern pid_t forkpty(int *, char *, struct termios *, struct winsize *);
|
||||
#endif /* !defined(HAVE_PTY_H) && !defined(HAVE_LIBUTIL_H) */
|
||||
#endif /* defined(HAVE_OPENPTY) || defined(HAVE_FORKPTY) */
|
||||
|
||||
/* Declarations for symbol visibility.
|
||||
|
||||
PyAPI_FUNC(type): Declares a public Python API function and return type
|
||||
PyAPI_DATA(type): Declares public Python data and its type
|
||||
PyMODINIT_FUNC: A Python module init function. If these functions are
|
||||
inside the Python core, they are private to the core.
|
||||
If in an extension module, it may be declared with
|
||||
external linkage depending on the platform.
|
||||
|
||||
As a number of platforms support/require "__declspec(dllimport/dllexport)",
|
||||
we support a HAVE_DECLSPEC_DLL macro to save duplication.
|
||||
*/
|
||||
|
||||
#define PyAPI_FUNC(RTYPE) RTYPE
|
||||
#define PyAPI_DATA(RTYPE) extern RTYPE
|
||||
#define RTYPE RTYPE
|
||||
#ifdef __cplusplus
|
||||
#define PyMODINIT_FUNC extern "C" PyObject *
|
||||
#else
|
||||
#define PyMODINIT_FUNC PyObject *
|
||||
#endif
|
||||
|
||||
/* limits.h constants that may be missing */
|
||||
|
||||
#ifndef LONG_BIT
|
||||
#define LONG_BIT (8 * SIZEOF_LONG)
|
||||
#endif
|
||||
|
||||
#if LONG_BIT != 8 * SIZEOF_LONG
|
||||
/* 04-Oct-2000 LONG_BIT is apparently (mis)defined as 64 on some recent
|
||||
* 32-bit platforms using gcc. We try to catch that here at compile-time
|
||||
* rather than waiting for integer multiplication to trigger bogus
|
||||
* overflows.
|
||||
*/
|
||||
#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."
|
||||
#error "LONG_BIT wrong"
|
||||
#endif
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
||||
/*
|
||||
* Hide GCC attributes from compilers that don't support them.
|
||||
*/
|
||||
#if (!defined(__GNUC__) || __GNUC__ < 2 || \
|
||||
(__GNUC__ == 2 && __GNUC_MINOR__ < 7))
|
||||
#define Py_GCC_ATTRIBUTE(x)
|
||||
|
@ -467,22 +257,12 @@ COSMOPOLITAN_C_END_
|
|||
#define Py_GCC_ATTRIBUTE(x) __attribute__(x)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Specify alignment on compilers that support it.
|
||||
*/
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
#define Py_ALIGNED(x) __attribute__((aligned(x)))
|
||||
#define Py_ALIGNED(x) __attribute__((__aligned__(x)))
|
||||
#else
|
||||
#define Py_ALIGNED(x)
|
||||
#endif
|
||||
|
||||
/* Eliminate end-of-loop code not reached warnings from SunPro C
|
||||
* when using do{...}while(0) macros
|
||||
*/
|
||||
#ifdef __SUNPRO_C
|
||||
#pragma error_messages(off, E_END_OF_LOOP_CODE_NOT_REACHED)
|
||||
#endif
|
||||
|
||||
#ifndef Py_LL
|
||||
#define Py_LL(x) x##LL
|
||||
#endif
|
||||
|
@ -493,12 +273,6 @@ COSMOPOLITAN_C_END_
|
|||
|
||||
#define Py_VA_COPY va_copy
|
||||
|
||||
/*
|
||||
* Convenient macros to deal with endianness of the platform. WORDS_BIGENDIAN is
|
||||
* detected by configure and defined in pyconfig.h. The code in pyconfig.h
|
||||
* also takes care of Apple's universal builds.
|
||||
*/
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
#define PY_BIG_ENDIAN 1
|
||||
#define PY_LITTLE_ENDIAN 0
|
||||
|
|
71
third_party/python/Include/pystate.h
vendored
71
third_party/python/Include/pystate.h
vendored
|
@ -1,5 +1,8 @@
|
|||
#ifndef Py_PYSTATE_H
|
||||
#define Py_PYSTATE_H
|
||||
#include "third_party/python/Include/moduleobject.h"
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/pyatomic.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -161,53 +164,53 @@ typedef struct _ts {
|
|||
#endif
|
||||
|
||||
|
||||
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_New(void);
|
||||
PyAPI_FUNC(void) PyInterpreterState_Clear(PyInterpreterState *);
|
||||
PyAPI_FUNC(void) PyInterpreterState_Delete(PyInterpreterState *);
|
||||
PyInterpreterState * PyInterpreterState_New(void);
|
||||
void PyInterpreterState_Clear(PyInterpreterState *);
|
||||
void PyInterpreterState_Delete(PyInterpreterState *);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(int) _PyState_AddModule(PyObject*, struct PyModuleDef*);
|
||||
int _PyState_AddModule(PyObject*, struct PyModuleDef*);
|
||||
#endif /* !Py_LIMITED_API */
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
/* New in 3.3 */
|
||||
PyAPI_FUNC(int) PyState_AddModule(PyObject*, struct PyModuleDef*);
|
||||
PyAPI_FUNC(int) PyState_RemoveModule(struct PyModuleDef*);
|
||||
int PyState_AddModule(PyObject*, struct PyModuleDef*);
|
||||
int PyState_RemoveModule(struct PyModuleDef*);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject*) PyState_FindModule(struct PyModuleDef*);
|
||||
PyObject* PyState_FindModule(struct PyModuleDef*);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) _PyState_ClearModules(void);
|
||||
void _PyState_ClearModules(void);
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(PyThreadState *) PyThreadState_New(PyInterpreterState *);
|
||||
PyThreadState * PyThreadState_New(PyInterpreterState *);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyThreadState *) _PyThreadState_Prealloc(PyInterpreterState *);
|
||||
PyAPI_FUNC(void) _PyThreadState_Init(PyThreadState *);
|
||||
PyThreadState * _PyThreadState_Prealloc(PyInterpreterState *);
|
||||
void _PyThreadState_Init(PyThreadState *);
|
||||
#endif /* !Py_LIMITED_API */
|
||||
PyAPI_FUNC(void) PyThreadState_Clear(PyThreadState *);
|
||||
PyAPI_FUNC(void) PyThreadState_Delete(PyThreadState *);
|
||||
void PyThreadState_Clear(PyThreadState *);
|
||||
void PyThreadState_Delete(PyThreadState *);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) _PyThreadState_DeleteExcept(PyThreadState *tstate);
|
||||
void _PyThreadState_DeleteExcept(PyThreadState *tstate);
|
||||
#endif /* !Py_LIMITED_API */
|
||||
#ifdef WITH_THREAD
|
||||
PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);
|
||||
void PyThreadState_DeleteCurrent(void);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) _PyGILState_Reinit(void);
|
||||
void _PyGILState_Reinit(void);
|
||||
#endif /* !Py_LIMITED_API */
|
||||
#endif
|
||||
|
||||
/* Return the current thread state. The global interpreter lock must be held.
|
||||
* When the current thread state is NULL, this issues a fatal error (so that
|
||||
* the caller needn't check for NULL). */
|
||||
PyAPI_FUNC(PyThreadState *) PyThreadState_Get(void);
|
||||
PyThreadState * PyThreadState_Get(void);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
/* Similar to PyThreadState_Get(), but don't issue a fatal error
|
||||
* if it is NULL. */
|
||||
PyAPI_FUNC(PyThreadState *) _PyThreadState_UncheckedGet(void);
|
||||
PyThreadState * _PyThreadState_UncheckedGet(void);
|
||||
#endif /* !Py_LIMITED_API */
|
||||
|
||||
PyAPI_FUNC(PyThreadState *) PyThreadState_Swap(PyThreadState *);
|
||||
PyAPI_FUNC(PyObject *) PyThreadState_GetDict(void);
|
||||
PyAPI_FUNC(int) PyThreadState_SetAsyncExc(long, PyObject *);
|
||||
PyThreadState * PyThreadState_Swap(PyThreadState *);
|
||||
PyObject * PyThreadState_GetDict(void);
|
||||
int PyThreadState_SetAsyncExc(long, PyObject *);
|
||||
|
||||
|
||||
/* Variable and macro for in-line access to current thread state */
|
||||
|
@ -215,7 +218,7 @@ PyAPI_FUNC(int) PyThreadState_SetAsyncExc(long, PyObject *);
|
|||
/* Assuming the current thread holds the GIL, this is the
|
||||
PyThreadState for the current thread. */
|
||||
#ifdef Py_BUILD_CORE
|
||||
PyAPI_DATA(_Py_atomic_address) _PyThreadState_Current;
|
||||
extern _Py_atomic_address _PyThreadState_Current;
|
||||
# define PyThreadState_GET() \
|
||||
((PyThreadState*)_Py_atomic_load_relaxed(&_PyThreadState_Current))
|
||||
#else
|
||||
|
@ -249,7 +252,7 @@ typedef
|
|||
|
||||
Failure is a fatal error.
|
||||
*/
|
||||
PyAPI_FUNC(PyGILState_STATE) PyGILState_Ensure(void);
|
||||
PyGILState_STATE PyGILState_Ensure(void);
|
||||
|
||||
/* Release any resources previously acquired. After this call, Python's
|
||||
state will be the same as it was prior to the corresponding
|
||||
|
@ -259,7 +262,7 @@ PyAPI_FUNC(PyGILState_STATE) PyGILState_Ensure(void);
|
|||
Every call to PyGILState_Ensure must be matched by a call to
|
||||
PyGILState_Release on the same thread.
|
||||
*/
|
||||
PyAPI_FUNC(void) PyGILState_Release(PyGILState_STATE);
|
||||
void PyGILState_Release(PyGILState_STATE);
|
||||
|
||||
/* Helper/diagnostic function - get the current thread state for
|
||||
this thread. May return NULL if no GILState API has been used
|
||||
|
@ -267,25 +270,25 @@ PyAPI_FUNC(void) PyGILState_Release(PyGILState_STATE);
|
|||
thread-state, even if no auto-thread-state call has been made
|
||||
on the main thread.
|
||||
*/
|
||||
PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadState(void);
|
||||
PyThreadState * PyGILState_GetThisThreadState(void);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
/* Issue #26558: Flag to disable PyGILState_Check().
|
||||
If set to non-zero, PyGILState_Check() always return 1. */
|
||||
PyAPI_DATA(int) _PyGILState_check_enabled;
|
||||
extern int _PyGILState_check_enabled;
|
||||
|
||||
/* Helper/diagnostic function - return 1 if the current thread
|
||||
currently holds the GIL, 0 otherwise.
|
||||
|
||||
The function returns 1 if _PyGILState_check_enabled is non-zero. */
|
||||
PyAPI_FUNC(int) PyGILState_Check(void);
|
||||
int PyGILState_Check(void);
|
||||
|
||||
/* Unsafe function to get the single PyInterpreterState used by this process'
|
||||
GILState implementation.
|
||||
|
||||
Return NULL before _PyGILState_Init() is called and after _PyGILState_Fini()
|
||||
is called. */
|
||||
PyAPI_FUNC(PyInterpreterState *) _PyGILState_GetInterpreterStateUnsafe(void);
|
||||
PyInterpreterState * _PyGILState_GetInterpreterStateUnsafe(void);
|
||||
#endif
|
||||
|
||||
#endif /* #ifdef WITH_THREAD */
|
||||
|
@ -294,23 +297,23 @@ PyAPI_FUNC(PyInterpreterState *) _PyGILState_GetInterpreterStateUnsafe(void);
|
|||
thread id to that thread's current frame.
|
||||
*/
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) _PyThread_CurrentFrames(void);
|
||||
PyObject * _PyThread_CurrentFrames(void);
|
||||
#endif
|
||||
|
||||
/* Routines for advanced debuggers, requested by David Beazley.
|
||||
Don't use unless you know what you are doing! */
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void);
|
||||
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *);
|
||||
PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);
|
||||
PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *);
|
||||
PyInterpreterState * PyInterpreterState_Head(void);
|
||||
PyInterpreterState * PyInterpreterState_Next(PyInterpreterState *);
|
||||
PyThreadState * PyInterpreterState_ThreadHead(PyInterpreterState *);
|
||||
PyThreadState * PyThreadState_Next(PyThreadState *);
|
||||
|
||||
typedef struct _frame *(*PyThreadFrameGetter)(PyThreadState *self_);
|
||||
#endif
|
||||
|
||||
/* hook for PyEval_GetFrame(), requested for Psyco */
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_DATA(PyThreadFrameGetter) _PyThreadState_GetFrame;
|
||||
extern PyThreadFrameGetter _PyThreadState_GetFrame;
|
||||
#endif
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
5
third_party/python/Include/pystrcmp.h
vendored
5
third_party/python/Include/pystrcmp.h
vendored
|
@ -1,10 +1,11 @@
|
|||
#ifndef Py_STRCMP_H
|
||||
#define Py_STRCMP_H
|
||||
#include "third_party/python/Include/pyport.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
PyAPI_FUNC(int) PyOS_mystrnicmp(const char *, const char *, Py_ssize_t);
|
||||
PyAPI_FUNC(int) PyOS_mystricmp(const char *, const char *);
|
||||
int PyOS_mystrnicmp(const char *, const char *, Py_ssize_t);
|
||||
int PyOS_mystricmp(const char *, const char *);
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
#define PyOS_strnicmp strnicmp
|
||||
|
|
5
third_party/python/Include/pystrhex.h
vendored
5
third_party/python/Include/pystrhex.h
vendored
|
@ -1,13 +1,14 @@
|
|||
#ifndef Py_STRHEX_H
|
||||
#define Py_STRHEX_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
/* Returns a str() containing the hex representation of argbuf. */
|
||||
PyAPI_FUNC(PyObject*) _Py_strhex(const char* argbuf, const Py_ssize_t arglen);
|
||||
PyObject* _Py_strhex(const char* argbuf, const Py_ssize_t arglen);
|
||||
/* Returns a bytes() containing the ASCII hex representation of argbuf. */
|
||||
PyAPI_FUNC(PyObject*) _Py_strhex_bytes(const char* argbuf, const Py_ssize_t arglen);
|
||||
PyObject* _Py_strhex_bytes(const char* argbuf, const Py_ssize_t arglen);
|
||||
#endif /* !Py_LIMITED_API */
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
9
third_party/python/Include/pystrtod.h
vendored
9
third_party/python/Include/pystrtod.h
vendored
|
@ -1,26 +1,27 @@
|
|||
#ifndef Py_STRTOD_H
|
||||
#define Py_STRTOD_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
PyAPI_FUNC(double) PyOS_string_to_double(const char *str,
|
||||
double PyOS_string_to_double(const char *str,
|
||||
char **endptr,
|
||||
PyObject *overflow_exception);
|
||||
|
||||
/* The caller is responsible for calling PyMem_Free to free the buffer
|
||||
that's is returned. */
|
||||
PyAPI_FUNC(char *) PyOS_double_to_string(double val,
|
||||
char * PyOS_double_to_string(double val,
|
||||
char format_code,
|
||||
int precision,
|
||||
int flags,
|
||||
int *type);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) _Py_string_to_number_with_underscores(
|
||||
PyObject * _Py_string_to_number_with_underscores(
|
||||
const char *str, Py_ssize_t len, const char *what, PyObject *obj, void *arg,
|
||||
PyObject *(*innerfunc)(const char *, Py_ssize_t, void *));
|
||||
|
||||
PyAPI_FUNC(double) _Py_parse_inf_or_nan(const char *p, char **endptr);
|
||||
double _Py_parse_inf_or_nan(const char *p, char **endptr);
|
||||
#endif
|
||||
|
||||
|
||||
|
|
61
third_party/python/Include/pythonrun.h
vendored
61
third_party/python/Include/pythonrun.h
vendored
|
@ -1,5 +1,8 @@
|
|||
#ifndef Py_PYTHONRUN_H
|
||||
#define Py_PYTHONRUN_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/pyarena.h"
|
||||
#include "third_party/python/Include/pystate.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -20,44 +23,44 @@ typedef struct {
|
|||
#endif
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
|
||||
PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
|
||||
PyAPI_FUNC(int) PyRun_AnyFileExFlags(
|
||||
int PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
|
||||
int PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
|
||||
int PyRun_AnyFileExFlags(
|
||||
FILE *fp,
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
int closeit,
|
||||
PyCompilerFlags *flags);
|
||||
PyAPI_FUNC(int) PyRun_SimpleFileExFlags(
|
||||
int PyRun_SimpleFileExFlags(
|
||||
FILE *fp,
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
int closeit,
|
||||
PyCompilerFlags *flags);
|
||||
PyAPI_FUNC(int) PyRun_InteractiveOneFlags(
|
||||
int PyRun_InteractiveOneFlags(
|
||||
FILE *fp,
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
PyCompilerFlags *flags);
|
||||
PyAPI_FUNC(int) PyRun_InteractiveOneObject(
|
||||
int PyRun_InteractiveOneObject(
|
||||
FILE *fp,
|
||||
PyObject *filename,
|
||||
PyCompilerFlags *flags);
|
||||
PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(
|
||||
int PyRun_InteractiveLoopFlags(
|
||||
FILE *fp,
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
PyCompilerFlags *flags);
|
||||
|
||||
PyAPI_FUNC(struct _mod *) PyParser_ASTFromString(
|
||||
struct _mod * PyParser_ASTFromString(
|
||||
const char *s,
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
int start,
|
||||
PyCompilerFlags *flags,
|
||||
PyArena *arena);
|
||||
PyAPI_FUNC(struct _mod *) PyParser_ASTFromStringObject(
|
||||
struct _mod * PyParser_ASTFromStringObject(
|
||||
const char *s,
|
||||
PyObject *filename,
|
||||
int start,
|
||||
PyCompilerFlags *flags,
|
||||
PyArena *arena);
|
||||
PyAPI_FUNC(struct _mod *) PyParser_ASTFromFile(
|
||||
struct _mod * PyParser_ASTFromFile(
|
||||
FILE *fp,
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
const char* enc,
|
||||
|
@ -67,7 +70,7 @@ PyAPI_FUNC(struct _mod *) PyParser_ASTFromFile(
|
|||
PyCompilerFlags *flags,
|
||||
int *errcode,
|
||||
PyArena *arena);
|
||||
PyAPI_FUNC(struct _mod *) PyParser_ASTFromFileObject(
|
||||
struct _mod * PyParser_ASTFromFileObject(
|
||||
FILE *fp,
|
||||
PyObject *filename,
|
||||
const char* enc,
|
||||
|
@ -85,21 +88,21 @@ PyAPI_FUNC(struct _mod *) PyParser_ASTFromFileObject(
|
|||
#define PyParser_SimpleParseFile(FP, S, B) \
|
||||
PyParser_SimpleParseFileFlags(FP, S, B, 0)
|
||||
#endif
|
||||
PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlags(const char *, int,
|
||||
struct _node * PyParser_SimpleParseStringFlags(const char *, int,
|
||||
int);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_FUNC(struct _node *) PyParser_SimpleParseStringFlagsFilename(const char *,
|
||||
struct _node * PyParser_SimpleParseStringFlagsFilename(const char *,
|
||||
const char *,
|
||||
int, int);
|
||||
#endif
|
||||
PyAPI_FUNC(struct _node *) PyParser_SimpleParseFileFlags(FILE *, const char *,
|
||||
struct _node * PyParser_SimpleParseFileFlags(FILE *, const char *,
|
||||
int, int);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *,
|
||||
PyObject * PyRun_StringFlags(const char *, int, PyObject *,
|
||||
PyObject *, PyCompilerFlags *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyRun_FileExFlags(
|
||||
PyObject * PyRun_FileExFlags(
|
||||
FILE *fp,
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
int start,
|
||||
|
@ -110,36 +113,36 @@ PyAPI_FUNC(PyObject *) PyRun_FileExFlags(
|
|||
#endif
|
||||
|
||||
#ifdef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) Py_CompileString(const char *, const char *, int);
|
||||
PyObject * Py_CompileString(const char *, const char *, int);
|
||||
#else
|
||||
#define Py_CompileString(str, p, s) Py_CompileStringExFlags(str, p, s, NULL, -1)
|
||||
#define Py_CompileStringFlags(str, p, s, f) Py_CompileStringExFlags(str, p, s, f, -1)
|
||||
PyAPI_FUNC(PyObject *) Py_CompileStringExFlags(
|
||||
PyObject * Py_CompileStringExFlags(
|
||||
const char *str,
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
int start,
|
||||
PyCompilerFlags *flags,
|
||||
int optimize);
|
||||
PyAPI_FUNC(PyObject *) Py_CompileStringObject(
|
||||
PyObject * Py_CompileStringObject(
|
||||
const char *str,
|
||||
PyObject *filename, int start,
|
||||
PyCompilerFlags *flags,
|
||||
int optimize);
|
||||
#endif
|
||||
PyAPI_FUNC(struct symtable *) Py_SymtableString(
|
||||
struct symtable * Py_SymtableString(
|
||||
const char *str,
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
int start);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(struct symtable *) Py_SymtableStringObject(
|
||||
struct symtable * Py_SymtableStringObject(
|
||||
const char *str,
|
||||
PyObject *filename,
|
||||
int start);
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(void) PyErr_Print(void);
|
||||
PyAPI_FUNC(void) PyErr_PrintEx(int);
|
||||
PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *);
|
||||
void PyErr_Print(void);
|
||||
void PyErr_PrintEx(int);
|
||||
void PyErr_Display(PyObject *, PyObject *, PyObject *);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
/* Use macros for a bunch of old variants */
|
||||
|
@ -164,12 +167,12 @@ PyAPI_FUNC(void) PyErr_Display(PyObject *, PyObject *, PyObject *);
|
|||
|
||||
/* Stuff with no proper home (yet) */
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, const char *);
|
||||
char * PyOS_Readline(FILE *, FILE *, const char *);
|
||||
#endif
|
||||
PyAPI_DATA(int) (*PyOS_InputHook)(void);
|
||||
PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *);
|
||||
extern int (*PyOS_InputHook)(void);
|
||||
extern char *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;
|
||||
extern PyThreadState* _PyOS_ReadlineTState;
|
||||
#endif
|
||||
|
||||
/* Stack size, in "pointers" (so we get extra safety margins
|
||||
|
@ -184,7 +187,7 @@ PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;
|
|||
|
||||
#ifdef USE_STACKCHECK
|
||||
/* Check that we aren't overflowing our stack */
|
||||
PyAPI_FUNC(int) PyOS_CheckStack(void);
|
||||
int PyOS_CheckStack(void);
|
||||
#endif
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
37
third_party/python/Include/pythread.h
vendored
37
third_party/python/Include/pythread.h
vendored
|
@ -1,5 +1,6 @@
|
|||
#ifndef Py_PYTHREAD_H
|
||||
#define Py_PYTHREAD_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -14,14 +15,14 @@ typedef enum PyLockStatus {
|
|||
PY_LOCK_INTR
|
||||
} PyLockStatus;
|
||||
|
||||
PyAPI_FUNC(void) PyThread_init_thread(void);
|
||||
PyAPI_FUNC(long) PyThread_start_new_thread(void (*)(void *), void *);
|
||||
PyAPI_FUNC(void) PyThread_exit_thread(void);
|
||||
PyAPI_FUNC(long) PyThread_get_thread_ident(void);
|
||||
void PyThread_init_thread(void);
|
||||
long PyThread_start_new_thread(void (*)(void *), void *);
|
||||
void PyThread_exit_thread(void);
|
||||
long PyThread_get_thread_ident(void);
|
||||
|
||||
PyAPI_FUNC(PyThread_type_lock) PyThread_allocate_lock(void);
|
||||
PyAPI_FUNC(void) PyThread_free_lock(PyThread_type_lock);
|
||||
PyAPI_FUNC(int) PyThread_acquire_lock(PyThread_type_lock, int);
|
||||
PyThread_type_lock PyThread_allocate_lock(void);
|
||||
void PyThread_free_lock(PyThread_type_lock);
|
||||
int PyThread_acquire_lock(PyThread_type_lock, int);
|
||||
#define WAIT_LOCK 1
|
||||
#define NOWAIT_LOCK 0
|
||||
|
||||
|
@ -57,28 +58,28 @@ PyAPI_FUNC(int) PyThread_acquire_lock(PyThread_type_lock, int);
|
|||
call will return PY_LOCK_INTR. The caller may reattempt to acquire the
|
||||
lock.
|
||||
*/
|
||||
PyAPI_FUNC(PyLockStatus) PyThread_acquire_lock_timed(PyThread_type_lock,
|
||||
PyLockStatus PyThread_acquire_lock_timed(PyThread_type_lock,
|
||||
PY_TIMEOUT_T microseconds,
|
||||
int intr_flag);
|
||||
|
||||
PyAPI_FUNC(void) PyThread_release_lock(PyThread_type_lock);
|
||||
void PyThread_release_lock(PyThread_type_lock);
|
||||
|
||||
PyAPI_FUNC(size_t) PyThread_get_stacksize(void);
|
||||
PyAPI_FUNC(int) PyThread_set_stacksize(size_t);
|
||||
size_t PyThread_get_stacksize(void);
|
||||
int PyThread_set_stacksize(size_t);
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_FUNC(PyObject*) PyThread_GetInfo(void);
|
||||
PyObject* PyThread_GetInfo(void);
|
||||
#endif
|
||||
|
||||
/* Thread Local Storage (TLS) API */
|
||||
PyAPI_FUNC(int) PyThread_create_key(void);
|
||||
PyAPI_FUNC(void) PyThread_delete_key(int);
|
||||
PyAPI_FUNC(int) PyThread_set_key_value(int, void *);
|
||||
PyAPI_FUNC(void *) PyThread_get_key_value(int);
|
||||
PyAPI_FUNC(void) PyThread_delete_key_value(int key);
|
||||
int PyThread_create_key(void);
|
||||
void PyThread_delete_key(int);
|
||||
int PyThread_set_key_value(int, void *);
|
||||
void * PyThread_get_key_value(int);
|
||||
void PyThread_delete_key_value(int key);
|
||||
|
||||
/* Cleanup after a fork */
|
||||
PyAPI_FUNC(void) PyThread_ReInitTLS(void);
|
||||
void PyThread_ReInitTLS(void);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !Py_PYTHREAD_H */
|
||||
|
|
218
third_party/python/Include/pytime.h
vendored
218
third_party/python/Include/pytime.h
vendored
|
@ -1,205 +1,63 @@
|
|||
#ifndef Py_LIMITED_API
|
||||
#ifndef Py_PYTIME_H
|
||||
#define Py_PYTIME_H
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/time/struct/tm.h"
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/pyconfig.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
/**************************************************************************
|
||||
Symbols and macros to supply platform-independent interfaces to time related
|
||||
functions and constants
|
||||
**************************************************************************/
|
||||
|
||||
/* _PyTime_t: Python timestamp with subsecond precision. It can be used to
|
||||
store a duration, and so indirectly a date (related to another date, like
|
||||
UNIX epoch). */
|
||||
typedef int64_t _PyTime_t;
|
||||
#define _PyTime_MIN PY_LLONG_MIN
|
||||
#define _PyTime_MAX PY_LLONG_MAX
|
||||
|
||||
typedef enum {
|
||||
/* Round towards minus infinity (-inf).
|
||||
For example, used to read a clock. */
|
||||
_PyTime_ROUND_FLOOR=0,
|
||||
/* Round towards infinity (+inf).
|
||||
For example, used for timeout to wait "at least" N seconds. */
|
||||
_PyTime_ROUND_CEILING=1,
|
||||
/* Round to nearest with ties going to nearest even integer.
|
||||
For example, used to round from a Python float. */
|
||||
_PyTime_ROUND_HALF_EVEN=2,
|
||||
/* Round away from zero
|
||||
For example, used for timeout. _PyTime_ROUND_CEILING rounds
|
||||
-1e-9 to 0 milliseconds which causes bpo-31786 issue.
|
||||
_PyTime_ROUND_UP rounds -1e-9 to -1 millisecond which keeps
|
||||
the timeout sign as expected. select.poll(timeout) must block
|
||||
for negative values." */
|
||||
_PyTime_ROUND_UP=3,
|
||||
/* _PyTime_ROUND_TIMEOUT (an alias for _PyTime_ROUND_UP) should be
|
||||
used for timeouts. */
|
||||
_PyTime_ROUND_TIMEOUT = _PyTime_ROUND_UP
|
||||
_PyTime_ROUND_FLOOR = 0,
|
||||
_PyTime_ROUND_CEILING = 1,
|
||||
_PyTime_ROUND_HALF_EVEN = 2,
|
||||
_PyTime_ROUND_UP = 3,
|
||||
_PyTime_ROUND_TIMEOUT = _PyTime_ROUND_UP
|
||||
} _PyTime_round_t;
|
||||
|
||||
PyObject *_PyLong_FromTime_t(time_t);
|
||||
time_t _PyLong_AsTime_t(PyObject *);
|
||||
int _PyTime_ObjectToTime_t(PyObject *, time_t *, _PyTime_round_t);
|
||||
int _PyTime_ObjectToTimeval(PyObject *, time_t *, long *, _PyTime_round_t);
|
||||
int _PyTime_ObjectToTimespec(PyObject *, time_t *, long *, _PyTime_round_t);
|
||||
|
||||
/* Convert a time_t to a PyLong. */
|
||||
PyAPI_FUNC(PyObject *) _PyLong_FromTime_t(
|
||||
time_t sec);
|
||||
_PyTime_t _PyTime_FromSeconds(int);
|
||||
|
||||
/* Convert a PyLong to a time_t. */
|
||||
PyAPI_FUNC(time_t) _PyLong_AsTime_t(
|
||||
PyObject *obj);
|
||||
|
||||
/* Convert a number of seconds, int or float, to time_t. */
|
||||
PyAPI_FUNC(int) _PyTime_ObjectToTime_t(
|
||||
PyObject *obj,
|
||||
time_t *sec,
|
||||
_PyTime_round_t);
|
||||
|
||||
/* Convert a number of seconds, int or float, to a timeval structure.
|
||||
usec is in the range [0; 999999] and rounded towards zero.
|
||||
For example, -1.2 is converted to (-2, 800000). */
|
||||
PyAPI_FUNC(int) _PyTime_ObjectToTimeval(
|
||||
PyObject *obj,
|
||||
time_t *sec,
|
||||
long *usec,
|
||||
_PyTime_round_t);
|
||||
|
||||
/* Convert a number of seconds, int or float, to a timespec structure.
|
||||
nsec is in the range [0; 999999999] and rounded towards zero.
|
||||
For example, -1.2 is converted to (-2, 800000000). */
|
||||
PyAPI_FUNC(int) _PyTime_ObjectToTimespec(
|
||||
PyObject *obj,
|
||||
time_t *sec,
|
||||
long *nsec,
|
||||
_PyTime_round_t);
|
||||
|
||||
|
||||
/* Create a timestamp from a number of seconds. */
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_FromSeconds(int seconds);
|
||||
|
||||
/* Macro to create a timestamp from a number of seconds, no integer overflow.
|
||||
Only use the macro for small values, prefer _PyTime_FromSeconds(). */
|
||||
#define _PYTIME_FROMSECONDS(seconds) \
|
||||
((_PyTime_t)(seconds) * (1000 * 1000 * 1000))
|
||||
((_PyTime_t)(seconds) * (1000 * 1000 * 1000))
|
||||
|
||||
/* Create a timestamp from a number of nanoseconds. */
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_FromNanoseconds(long long ns);
|
||||
_PyTime_t _PyTime_FromNanoseconds(long long);
|
||||
int _PyTime_FromSecondsObject(_PyTime_t *, PyObject *, _PyTime_round_t);
|
||||
int _PyTime_FromMillisecondsObject(_PyTime_t *, PyObject *, _PyTime_round_t);
|
||||
double _PyTime_AsSecondsDouble(_PyTime_t);
|
||||
_PyTime_t _PyTime_AsMilliseconds(_PyTime_t, _PyTime_round_t);
|
||||
_PyTime_t _PyTime_AsMicroseconds(_PyTime_t, _PyTime_round_t);
|
||||
PyObject *_PyTime_AsNanosecondsObject(_PyTime_t);
|
||||
int _PyTime_AsTimeval(_PyTime_t, struct timeval *, _PyTime_round_t);
|
||||
int _PyTime_AsTimeval_noraise(_PyTime_t, struct timeval *, _PyTime_round_t);
|
||||
int _PyTime_AsTimevalTime_t(_PyTime_t, time_t *, int *, _PyTime_round_t);
|
||||
int _PyTime_AsTimespec(_PyTime_t, struct timespec *);
|
||||
_PyTime_t _PyTime_GetSystemClock(void);
|
||||
_PyTime_t _PyTime_GetMonotonicClock(void);
|
||||
|
||||
/* Convert a number of seconds (Python float or int) to a timetamp.
|
||||
Raise an exception and return -1 on error, return 0 on success. */
|
||||
PyAPI_FUNC(int) _PyTime_FromSecondsObject(_PyTime_t *t,
|
||||
PyObject *obj,
|
||||
_PyTime_round_t round);
|
||||
|
||||
/* Convert a number of milliseconds (Python float or int, 10^-3) to a timetamp.
|
||||
Raise an exception and return -1 on error, return 0 on success. */
|
||||
PyAPI_FUNC(int) _PyTime_FromMillisecondsObject(_PyTime_t *t,
|
||||
PyObject *obj,
|
||||
_PyTime_round_t round);
|
||||
|
||||
/* Convert a timestamp to a number of seconds as a C double. */
|
||||
PyAPI_FUNC(double) _PyTime_AsSecondsDouble(_PyTime_t t);
|
||||
|
||||
/* Convert timestamp to a number of milliseconds (10^-3 seconds). */
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_AsMilliseconds(_PyTime_t t,
|
||||
_PyTime_round_t round);
|
||||
|
||||
/* Convert timestamp to a number of microseconds (10^-6 seconds). */
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_AsMicroseconds(_PyTime_t t,
|
||||
_PyTime_round_t round);
|
||||
|
||||
/* Convert timestamp to a number of nanoseconds (10^-9 seconds) as a Python int
|
||||
object. */
|
||||
PyAPI_FUNC(PyObject *) _PyTime_AsNanosecondsObject(_PyTime_t t);
|
||||
|
||||
/* Convert a timestamp to a timeval structure (microsecond resolution).
|
||||
tv_usec is always positive.
|
||||
Raise an exception and return -1 if the conversion overflowed,
|
||||
return 0 on success. */
|
||||
PyAPI_FUNC(int) _PyTime_AsTimeval(_PyTime_t t,
|
||||
struct timeval *tv,
|
||||
_PyTime_round_t round);
|
||||
|
||||
/* Similar to _PyTime_AsTimeval(), but don't raise an exception on error. */
|
||||
PyAPI_FUNC(int) _PyTime_AsTimeval_noraise(_PyTime_t t,
|
||||
struct timeval *tv,
|
||||
_PyTime_round_t round);
|
||||
|
||||
/* Convert a timestamp to a number of seconds (secs) and microseconds (us).
|
||||
us is always positive. This function is similar to _PyTime_AsTimeval()
|
||||
except that secs is always a time_t type, whereas the timeval structure
|
||||
uses a C long for tv_sec on Windows.
|
||||
Raise an exception and return -1 if the conversion overflowed,
|
||||
return 0 on success. */
|
||||
PyAPI_FUNC(int) _PyTime_AsTimevalTime_t(
|
||||
_PyTime_t t,
|
||||
time_t *secs,
|
||||
int *us,
|
||||
_PyTime_round_t round);
|
||||
|
||||
#if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_KQUEUE)
|
||||
/* Convert a timestamp to a timespec structure (nanosecond resolution).
|
||||
tv_nsec is always positive.
|
||||
Raise an exception and return -1 on error, return 0 on success. */
|
||||
PyAPI_FUNC(int) _PyTime_AsTimespec(_PyTime_t t, struct timespec *ts);
|
||||
#endif
|
||||
|
||||
/* Get the current time from the system clock.
|
||||
|
||||
The function cannot fail. _PyTime_Init() ensures that the system clock
|
||||
works. */
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_GetSystemClock(void);
|
||||
|
||||
/* Get the time of a monotonic clock, i.e. a clock that cannot go backwards.
|
||||
The clock is not affected by system clock updates. The reference point of
|
||||
the returned value is undefined, so that only the difference between the
|
||||
results of consecutive calls is valid.
|
||||
|
||||
The function cannot fail. _PyTime_Init() ensures that a monotonic clock
|
||||
is available and works. */
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_GetMonotonicClock(void);
|
||||
|
||||
|
||||
/* Structure used by time.get_clock_info() */
|
||||
typedef struct {
|
||||
const char *implementation;
|
||||
int monotonic;
|
||||
int adjustable;
|
||||
double resolution;
|
||||
const char *implementation;
|
||||
int monotonic;
|
||||
int adjustable;
|
||||
double resolution;
|
||||
} _Py_clock_info_t;
|
||||
|
||||
/* Get the current time from the system clock.
|
||||
* Fill clock information if info is not NULL.
|
||||
* Raise an exception and return -1 on error, return 0 on success.
|
||||
*/
|
||||
PyAPI_FUNC(int) _PyTime_GetSystemClockWithInfo(
|
||||
_PyTime_t *t,
|
||||
_Py_clock_info_t *info);
|
||||
|
||||
/* Get the time of a monotonic clock, i.e. a clock that cannot go backwards.
|
||||
The clock is not affected by system clock updates. The reference point of
|
||||
the returned value is undefined, so that only the difference between the
|
||||
results of consecutive calls is valid.
|
||||
|
||||
Fill info (if set) with information of the function used to get the time.
|
||||
|
||||
Return 0 on success, raise an exception and return -1 on error. */
|
||||
PyAPI_FUNC(int) _PyTime_GetMonotonicClockWithInfo(
|
||||
_PyTime_t *t,
|
||||
_Py_clock_info_t *info);
|
||||
|
||||
|
||||
/* Initialize time.
|
||||
Return 0 on success, raise an exception and return -1 on error. */
|
||||
PyAPI_FUNC(int) _PyTime_Init(void);
|
||||
|
||||
/* Converts a timestamp to the Gregorian time, using the local time zone.
|
||||
Return 0 on success, raise an exception and return -1 on error. */
|
||||
PyAPI_FUNC(int) _PyTime_localtime(time_t t, struct tm *tm);
|
||||
|
||||
/* Converts a timestamp to the Gregorian time, assuming UTC.
|
||||
Return 0 on success, raise an exception and return -1 on error. */
|
||||
PyAPI_FUNC(int) _PyTime_gmtime(time_t t, struct tm *tm);
|
||||
int _PyTime_GetSystemClockWithInfo(_PyTime_t *, _Py_clock_info_t *);
|
||||
int _PyTime_GetMonotonicClockWithInfo(_PyTime_t *, _Py_clock_info_t *);
|
||||
int _PyTime_Init(void);
|
||||
int _PyTime_localtime(time_t, struct tm *);
|
||||
int _PyTime_gmtime(time_t, struct tm *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* Py_PYTIME_H */
|
||||
|
|
7
third_party/python/Include/rangeobject.h
vendored
7
third_party/python/Include/rangeobject.h
vendored
|
@ -1,5 +1,6 @@
|
|||
#ifndef Py_RANGEOBJECT_H
|
||||
#define Py_RANGEOBJECT_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -11,9 +12,9 @@ Range objects behave like the corresponding tuple objects except that
|
|||
they are represented by a start, stop, and step datamembers.
|
||||
*/
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyRange_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyRangeIter_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyLongRangeIter_Type;
|
||||
extern PyTypeObject PyRange_Type;
|
||||
extern PyTypeObject PyRangeIter_Type;
|
||||
extern PyTypeObject PyLongRangeIter_Type;
|
||||
|
||||
#define PyRange_Check(op) (Py_TYPE(op) == &PyRange_Type)
|
||||
|
||||
|
|
31
third_party/python/Include/setobject.h
vendored
31
third_party/python/Include/setobject.h
vendored
|
@ -1,5 +1,6 @@
|
|||
#ifndef Py_SETOBJECT_H
|
||||
#define Py_SETOBJECT_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -63,27 +64,27 @@ typedef struct {
|
|||
|
||||
#define PySet_GET_SIZE(so) (((PySetObject *)(so))->used)
|
||||
|
||||
PyAPI_DATA(PyObject *) _PySet_Dummy;
|
||||
extern PyObject * _PySet_Dummy;
|
||||
|
||||
PyAPI_FUNC(int) _PySet_NextEntry(PyObject *set, Py_ssize_t *pos, PyObject **key, Py_hash_t *hash);
|
||||
PyAPI_FUNC(int) _PySet_Update(PyObject *set, PyObject *iterable);
|
||||
PyAPI_FUNC(int) PySet_ClearFreeList(void);
|
||||
int _PySet_NextEntry(PyObject *set, Py_ssize_t *pos, PyObject **key, Py_hash_t *hash);
|
||||
int _PySet_Update(PyObject *set, PyObject *iterable);
|
||||
int PySet_ClearFreeList(void);
|
||||
|
||||
#endif /* Section excluded by Py_LIMITED_API */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PySet_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyFrozenSet_Type;
|
||||
PyAPI_DATA(PyTypeObject) PySetIter_Type;
|
||||
extern PyTypeObject PySet_Type;
|
||||
extern PyTypeObject PyFrozenSet_Type;
|
||||
extern PyTypeObject PySetIter_Type;
|
||||
|
||||
PyAPI_FUNC(PyObject *) PySet_New(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFrozenSet_New(PyObject *);
|
||||
PyObject * PySet_New(PyObject *);
|
||||
PyObject * PyFrozenSet_New(PyObject *);
|
||||
|
||||
PyAPI_FUNC(int) PySet_Add(PyObject *set, PyObject *key);
|
||||
PyAPI_FUNC(int) PySet_Clear(PyObject *set);
|
||||
PyAPI_FUNC(int) PySet_Contains(PyObject *anyset, PyObject *key);
|
||||
PyAPI_FUNC(int) PySet_Discard(PyObject *set, PyObject *key);
|
||||
PyAPI_FUNC(PyObject *) PySet_Pop(PyObject *set);
|
||||
PyAPI_FUNC(Py_ssize_t) PySet_Size(PyObject *anyset);
|
||||
int PySet_Add(PyObject *set, PyObject *key);
|
||||
int PySet_Clear(PyObject *set);
|
||||
int PySet_Contains(PyObject *anyset, PyObject *key);
|
||||
int PySet_Discard(PyObject *set, PyObject *key);
|
||||
PyObject * PySet_Pop(PyObject *set);
|
||||
Py_ssize_t PySet_Size(PyObject *anyset);
|
||||
|
||||
#define PyFrozenSet_CheckExact(ob) (Py_TYPE(ob) == &PyFrozenSet_Type)
|
||||
#define PyAnySet_CheckExact(ob) \
|
||||
|
|
21
third_party/python/Include/sliceobject.h
vendored
21
third_party/python/Include/sliceobject.h
vendored
|
@ -1,11 +1,12 @@
|
|||
#ifndef Py_SLICEOBJECT_H
|
||||
#define Py_SLICEOBJECT_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
/* The unique ellipsis object "..." */
|
||||
|
||||
PyAPI_DATA(PyObject) _Py_EllipsisObject; /* Don't use this directly */
|
||||
extern PyObject _Py_EllipsisObject; /* Don't use this directly */
|
||||
|
||||
#define Py_Ellipsis (&_Py_EllipsisObject)
|
||||
|
||||
|
@ -24,22 +25,22 @@ typedef struct {
|
|||
} PySliceObject;
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PySlice_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyEllipsis_Type;
|
||||
extern PyTypeObject PySlice_Type;
|
||||
extern PyTypeObject PyEllipsis_Type;
|
||||
|
||||
#define PySlice_Check(op) (Py_TYPE(op) == &PySlice_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop,
|
||||
PyObject * PySlice_New(PyObject* start, PyObject* stop,
|
||||
PyObject* step);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) _PySlice_FromIndices(Py_ssize_t start, Py_ssize_t stop);
|
||||
PyAPI_FUNC(int) _PySlice_GetLongIndices(PySliceObject *self, PyObject *length,
|
||||
PyObject * _PySlice_FromIndices(Py_ssize_t start, Py_ssize_t stop);
|
||||
int _PySlice_GetLongIndices(PySliceObject *self, PyObject *length,
|
||||
PyObject **start_ptr, PyObject **stop_ptr,
|
||||
PyObject **step_ptr);
|
||||
#endif
|
||||
PyAPI_FUNC(int) PySlice_GetIndices(PyObject *r, Py_ssize_t length,
|
||||
int PySlice_GetIndices(PyObject *r, Py_ssize_t length,
|
||||
Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step);
|
||||
PyAPI_FUNC(int) PySlice_GetIndicesEx(PyObject *r, Py_ssize_t length,
|
||||
int PySlice_GetIndicesEx(PyObject *r, Py_ssize_t length,
|
||||
Py_ssize_t *start, Py_ssize_t *stop,
|
||||
Py_ssize_t *step, Py_ssize_t *slicelength);
|
||||
|
||||
|
@ -51,9 +52,9 @@ PyAPI_FUNC(int) PySlice_GetIndicesEx(PyObject *r, Py_ssize_t length,
|
|||
((*(slicelen) = PySlice_AdjustIndices((length), (start), (stop), *(step))), \
|
||||
0))
|
||||
#endif
|
||||
PyAPI_FUNC(int) PySlice_Unpack(PyObject *slice,
|
||||
int PySlice_Unpack(PyObject *slice,
|
||||
Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step);
|
||||
PyAPI_FUNC(Py_ssize_t) PySlice_AdjustIndices(Py_ssize_t length,
|
||||
Py_ssize_t PySlice_AdjustIndices(Py_ssize_t length,
|
||||
Py_ssize_t *start, Py_ssize_t *stop,
|
||||
Py_ssize_t step);
|
||||
#endif
|
||||
|
|
5
third_party/python/Include/structmember.h
vendored
5
third_party/python/Include/structmember.h
vendored
|
@ -1,5 +1,6 @@
|
|||
#ifndef Py_STRUCTMEMBER_H
|
||||
#define Py_STRUCTMEMBER_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -59,8 +60,8 @@ typedef struct PyMemberDef {
|
|||
|
||||
|
||||
/* Current API, use this */
|
||||
PyAPI_FUNC(PyObject *) PyMember_GetOne(const char *, struct PyMemberDef *);
|
||||
PyAPI_FUNC(int) PyMember_SetOne(char *, struct PyMemberDef *, PyObject *);
|
||||
PyObject * PyMember_GetOne(const char *, struct PyMemberDef *);
|
||||
int PyMember_SetOne(char *, struct PyMemberDef *, PyObject *);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !Py_STRUCTMEMBER_H */
|
||||
|
|
14
third_party/python/Include/structseq.h
vendored
14
third_party/python/Include/structseq.h
vendored
|
@ -1,5 +1,7 @@
|
|||
#ifndef Py_STRUCTSEQ_H
|
||||
#define Py_STRUCTSEQ_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/tupleobject.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -18,14 +20,14 @@ typedef struct PyStructSequence_Desc {
|
|||
extern char* PyStructSequence_UnnamedField;
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type,
|
||||
void PyStructSequence_InitType(PyTypeObject *type,
|
||||
PyStructSequence_Desc *desc);
|
||||
PyAPI_FUNC(int) PyStructSequence_InitType2(PyTypeObject *type,
|
||||
int PyStructSequence_InitType2(PyTypeObject *type,
|
||||
PyStructSequence_Desc *desc);
|
||||
#endif
|
||||
PyAPI_FUNC(PyTypeObject*) PyStructSequence_NewType(PyStructSequence_Desc *desc);
|
||||
PyTypeObject* PyStructSequence_NewType(PyStructSequence_Desc *desc);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type);
|
||||
PyObject * PyStructSequence_New(PyTypeObject* type);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
typedef PyTupleObject PyStructSequence;
|
||||
|
@ -36,8 +38,8 @@ typedef PyTupleObject PyStructSequence;
|
|||
#define PyStructSequence_GET_ITEM(op, i) PyTuple_GET_ITEM(op, i)
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(void) PyStructSequence_SetItem(PyObject*, Py_ssize_t, PyObject*);
|
||||
PyAPI_FUNC(PyObject*) PyStructSequence_GetItem(PyObject*, Py_ssize_t);
|
||||
void PyStructSequence_SetItem(PyObject*, Py_ssize_t, PyObject*);
|
||||
PyObject* PyStructSequence_GetItem(PyObject*, Py_ssize_t);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !Py_STRUCTSEQ_H */
|
||||
|
|
15
third_party/python/Include/symtable.h
vendored
15
third_party/python/Include/symtable.h
vendored
|
@ -1,6 +1,9 @@
|
|||
#ifndef Py_LIMITED_API
|
||||
#ifndef Py_SYMTABLE_H
|
||||
#define Py_SYMTABLE_H
|
||||
#include "third_party/python/Include/Python-ast.h"
|
||||
#include "third_party/python/Include/compile.h"
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -58,23 +61,23 @@ typedef struct _symtable_entry {
|
|||
struct symtable *ste_table;
|
||||
} PySTEntryObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PySTEntry_Type;
|
||||
extern PyTypeObject PySTEntry_Type;
|
||||
|
||||
#define PySTEntry_Check(op) (Py_TYPE(op) == &PySTEntry_Type)
|
||||
|
||||
PyAPI_FUNC(int) PyST_GetScope(PySTEntryObject *, PyObject *);
|
||||
int PyST_GetScope(PySTEntryObject *, PyObject *);
|
||||
|
||||
PyAPI_FUNC(struct symtable *) PySymtable_Build(
|
||||
struct symtable * PySymtable_Build(
|
||||
mod_ty mod,
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
PyFutureFeatures *future);
|
||||
PyAPI_FUNC(struct symtable *) PySymtable_BuildObject(
|
||||
struct symtable * PySymtable_BuildObject(
|
||||
mod_ty mod,
|
||||
PyObject *filename,
|
||||
PyFutureFeatures *future);
|
||||
PyAPI_FUNC(PySTEntryObject *) PySymtable_Lookup(struct symtable *, void *);
|
||||
PySTEntryObject * PySymtable_Lookup(struct symtable *, void *);
|
||||
|
||||
PyAPI_FUNC(void) PySymtable_Free(struct symtable *);
|
||||
void PySymtable_Free(struct symtable *);
|
||||
|
||||
/* Flags for def-use information */
|
||||
|
||||
|
|
41
third_party/python/Include/sysmodule.h
vendored
41
third_party/python/Include/sysmodule.h
vendored
|
@ -1,36 +1,31 @@
|
|||
#ifndef Py_SYSMODULE_H
|
||||
#define Py_SYSMODULE_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/pyport.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PySys_GetObject(const char *);
|
||||
PyAPI_FUNC(int) PySys_SetObject(const char *, PyObject *);
|
||||
PyObject * PySys_GetObject(const char *);
|
||||
int PySys_SetObject(const char *, PyObject *);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) _PySys_GetObjectId(_Py_Identifier *key);
|
||||
PyAPI_FUNC(int) _PySys_SetObjectId(_Py_Identifier *key, PyObject *);
|
||||
PyObject * _PySys_GetObjectId(_Py_Identifier *key);
|
||||
int _PySys_SetObjectId(_Py_Identifier *key, PyObject *);
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(void) PySys_SetArgv(int, wchar_t **);
|
||||
PyAPI_FUNC(void) PySys_SetArgvEx(int, wchar_t **, int);
|
||||
PyAPI_FUNC(void) PySys_SetPath(const wchar_t *);
|
||||
|
||||
PyAPI_FUNC(void) PySys_WriteStdout(const char *format, ...)
|
||||
Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
|
||||
PyAPI_FUNC(void) PySys_WriteStderr(const char *format, ...)
|
||||
Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
|
||||
PyAPI_FUNC(void) PySys_FormatStdout(const char *format, ...);
|
||||
PyAPI_FUNC(void) PySys_FormatStderr(const char *format, ...);
|
||||
|
||||
PyAPI_FUNC(void) PySys_ResetWarnOptions(void);
|
||||
PyAPI_FUNC(void) PySys_AddWarnOption(const wchar_t *);
|
||||
PyAPI_FUNC(void) PySys_AddWarnOptionUnicode(PyObject *);
|
||||
PyAPI_FUNC(int) PySys_HasWarnOptions(void);
|
||||
|
||||
PyAPI_FUNC(void) PySys_AddXOption(const wchar_t *);
|
||||
PyAPI_FUNC(PyObject *) PySys_GetXOptions(void);
|
||||
void PySys_SetArgv(int, wchar_t **);
|
||||
void PySys_SetArgvEx(int, wchar_t **, int);
|
||||
void PySys_SetPath(const wchar_t *);
|
||||
void PySys_FormatStdout(const char *, ...);
|
||||
void PySys_FormatStderr(const char *, ...);
|
||||
void PySys_ResetWarnOptions(void);
|
||||
void PySys_AddWarnOption(const wchar_t *);
|
||||
void PySys_AddWarnOptionUnicode(PyObject *);
|
||||
int PySys_HasWarnOptions(void);
|
||||
void PySys_AddXOption(const wchar_t *);
|
||||
PyObject * PySys_GetXOptions(void);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(size_t) _PySys_GetSizeOf(PyObject *);
|
||||
size_t _PySys_GetSizeOf(PyObject *);
|
||||
#endif
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
8
third_party/python/Include/token.h
vendored
8
third_party/python/Include/token.h
vendored
|
@ -75,10 +75,10 @@ COSMOPOLITAN_C_START_
|
|||
#define ISEOF(x) ((x) == ENDMARKER)
|
||||
|
||||
|
||||
PyAPI_DATA(const char *) _PyParser_TokenNames[]; /* Token names */
|
||||
PyAPI_FUNC(int) PyToken_OneChar(int);
|
||||
PyAPI_FUNC(int) PyToken_TwoChars(int, int);
|
||||
PyAPI_FUNC(int) PyToken_ThreeChars(int, int, int);
|
||||
extern const char * _PyParser_TokenNames[]; /* Token names */
|
||||
int PyToken_OneChar(int);
|
||||
int PyToken_TwoChars(int, int);
|
||||
int PyToken_ThreeChars(int, int, int);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !Py_TOKEN_H */
|
||||
|
|
21
third_party/python/Include/traceback.h
vendored
21
third_party/python/Include/traceback.h
vendored
|
@ -1,5 +1,6 @@
|
|||
#ifndef Py_TRACEBACK_H
|
||||
#define Py_TRACEBACK_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/pystate.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
@ -17,15 +18,15 @@ typedef struct _traceback {
|
|||
} PyTracebackObject;
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(int) PyTraceBack_Here(struct _frame *);
|
||||
PyAPI_FUNC(int) PyTraceBack_Print(PyObject *, PyObject *);
|
||||
int PyTraceBack_Here(struct _frame *);
|
||||
int PyTraceBack_Print(PyObject *, PyObject *);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, PyObject *, int, int);
|
||||
PyAPI_FUNC(void) _PyTraceback_Add(const char *, const char *, int);
|
||||
int _Py_DisplaySourceLine(PyObject *, PyObject *, int, int);
|
||||
void _PyTraceback_Add(const char *, const char *, int);
|
||||
#endif
|
||||
|
||||
/* Reveal traceback type so we can typecheck traceback objects */
|
||||
PyAPI_DATA(PyTypeObject) PyTraceBack_Type;
|
||||
extern PyTypeObject PyTraceBack_Type;
|
||||
#define PyTraceBack_Check(v) (Py_TYPE(v) == &PyTraceBack_Type)
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
|
@ -46,7 +47,7 @@ PyAPI_DATA(PyTypeObject) PyTraceBack_Type;
|
|||
|
||||
This function is signal safe. */
|
||||
|
||||
PyAPI_FUNC(void) _Py_DumpTraceback(
|
||||
void _Py_DumpTraceback(
|
||||
int fd,
|
||||
PyThreadState *tstate);
|
||||
|
||||
|
@ -73,7 +74,7 @@ PyAPI_FUNC(void) _Py_DumpTraceback(
|
|||
|
||||
This function is signal safe. */
|
||||
|
||||
PyAPI_FUNC(const char*) _Py_DumpTracebackThreads(
|
||||
const char* _Py_DumpTracebackThreads(
|
||||
int fd,
|
||||
PyInterpreterState *interp,
|
||||
PyThreadState *current_tstate);
|
||||
|
@ -88,12 +89,12 @@ PyAPI_FUNC(const char*) _Py_DumpTracebackThreads(
|
|||
string which is not ready (PyUnicode_WCHAR_KIND).
|
||||
|
||||
This function is signal safe. */
|
||||
PyAPI_FUNC(void) _Py_DumpASCII(int fd, PyObject *text);
|
||||
void _Py_DumpASCII(int fd, PyObject *text);
|
||||
|
||||
/* Format an integer as decimal into the file descriptor fd.
|
||||
|
||||
This function is signal safe. */
|
||||
PyAPI_FUNC(void) _Py_DumpDecimal(
|
||||
void _Py_DumpDecimal(
|
||||
int fd,
|
||||
unsigned long value);
|
||||
|
||||
|
@ -103,7 +104,7 @@ PyAPI_FUNC(void) _Py_DumpDecimal(
|
|||
The maximum width is sizeof(unsigned long)*2 digits.
|
||||
|
||||
This function is signal safe. */
|
||||
PyAPI_FUNC(void) _Py_DumpHexadecimal(
|
||||
void _Py_DumpHexadecimal(
|
||||
int fd,
|
||||
unsigned long value,
|
||||
Py_ssize_t width);
|
||||
|
|
25
third_party/python/Include/tupleobject.h
vendored
25
third_party/python/Include/tupleobject.h
vendored
|
@ -1,5 +1,6 @@
|
|||
#ifndef Py_TUPLEOBJECT_H
|
||||
#define Py_TUPLEOBJECT_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -29,24 +30,24 @@ typedef struct {
|
|||
} PyTupleObject;
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyTuple_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyTupleIter_Type;
|
||||
extern PyTypeObject PyTuple_Type;
|
||||
extern PyTypeObject PyTupleIter_Type;
|
||||
|
||||
#define PyTuple_Check(op) \
|
||||
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TUPLE_SUBCLASS)
|
||||
#define PyTuple_CheckExact(op) (Py_TYPE(op) == &PyTuple_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyTuple_New(Py_ssize_t size);
|
||||
PyAPI_FUNC(Py_ssize_t) PyTuple_Size(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyTuple_GetItem(PyObject *, Py_ssize_t);
|
||||
PyAPI_FUNC(int) PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyTuple_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t);
|
||||
PyObject * PyTuple_New(Py_ssize_t size);
|
||||
Py_ssize_t PyTuple_Size(PyObject *);
|
||||
PyObject * PyTuple_GetItem(PyObject *, Py_ssize_t);
|
||||
int PyTuple_SetItem(PyObject *, Py_ssize_t, PyObject *);
|
||||
PyObject * PyTuple_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(int) _PyTuple_Resize(PyObject **, Py_ssize_t);
|
||||
int _PyTuple_Resize(PyObject **, Py_ssize_t);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyTuple_Pack(Py_ssize_t, ...);
|
||||
PyObject * PyTuple_Pack(Py_ssize_t, ...);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *);
|
||||
void _PyTuple_MaybeUntrack(PyObject *);
|
||||
#endif
|
||||
|
||||
/* Macro, trading safety for speed */
|
||||
|
@ -58,9 +59,9 @@ PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *);
|
|||
#define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->ob_item[i] = v)
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(int) PyTuple_ClearFreeList(void);
|
||||
int PyTuple_ClearFreeList(void);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) _PyTuple_DebugMallocStats(FILE *out);
|
||||
void _PyTuple_DebugMallocStats(FILE *out);
|
||||
#endif /* Py_LIMITED_API */
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
|
|
6
third_party/python/Include/ucnhash.h
vendored
6
third_party/python/Include/ucnhash.h
vendored
|
@ -1,6 +1,8 @@
|
|||
#ifndef Py_LIMITED_API
|
||||
#ifndef Py_UCNHASH_H
|
||||
#define Py_UCNHASH_H
|
||||
#ifndef Py_LIMITED_API
|
||||
#include "third_party/python/Include/object.h"
|
||||
#include "third_party/python/Include/unicodeobject.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -28,5 +30,5 @@ typedef struct {
|
|||
} _PyUnicode_Name_CAPI;
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !Py_UCNHASH_H */
|
||||
#endif /* !Py_LIMITED_API */
|
||||
#endif /* !Py_UCNHASH_H */
|
||||
|
|
504
third_party/python/Include/unicodeobject.h
vendored
504
third_party/python/Include/unicodeobject.h
vendored
File diff suppressed because it is too large
Load diff
57
third_party/python/Include/warnings.h
vendored
57
third_party/python/Include/warnings.h
vendored
|
@ -1,60 +1,35 @@
|
|||
#ifndef Py_WARNINGS_H
|
||||
#define Py_WARNINGS_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject*) _PyWarnings_Init(void);
|
||||
PyObject *_PyWarnings_Init(void);
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(int) PyErr_WarnEx(
|
||||
PyObject *category,
|
||||
const char *message, /* UTF-8 encoded string */
|
||||
Py_ssize_t stack_level);
|
||||
PyAPI_FUNC(int) PyErr_WarnFormat(
|
||||
PyObject *category,
|
||||
Py_ssize_t stack_level,
|
||||
const char *format, /* ASCII-encoded string */
|
||||
...);
|
||||
int PyErr_WarnEx(PyObject *, const char *, Py_ssize_t);
|
||||
int PyErr_WarnFormat(PyObject *, Py_ssize_t, const char *, ...);
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000
|
||||
/* Emit a ResourceWarning warning */
|
||||
PyAPI_FUNC(int) PyErr_ResourceWarning(
|
||||
PyObject *source,
|
||||
Py_ssize_t stack_level,
|
||||
const char *format, /* ASCII-encoded string */
|
||||
...);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API + 0 >= 0x03060000
|
||||
int PyErr_ResourceWarning(PyObject *, Py_ssize_t, const char *, ...);
|
||||
#endif
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(int) PyErr_WarnExplicitObject(
|
||||
PyObject *category,
|
||||
PyObject *message,
|
||||
PyObject *filename,
|
||||
int lineno,
|
||||
PyObject *module,
|
||||
PyObject *registry);
|
||||
#endif
|
||||
PyAPI_FUNC(int) PyErr_WarnExplicit(
|
||||
PyObject *category,
|
||||
const char *message, /* UTF-8 encoded string */
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
int lineno,
|
||||
const char *module, /* UTF-8 encoded string */
|
||||
PyObject *registry);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(int)
|
||||
PyErr_WarnExplicitFormat(PyObject *category,
|
||||
const char *filename, int lineno,
|
||||
const char *module, PyObject *registry,
|
||||
const char *format, ...);
|
||||
int PyErr_WarnExplicitObject(PyObject *, PyObject *, PyObject *, int,
|
||||
PyObject *, PyObject *);
|
||||
#endif
|
||||
|
||||
int PyErr_WarnExplicit(PyObject *, const char *, const char *, int,
|
||||
const char *, PyObject *);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
int PyErr_WarnExplicitFormat(PyObject *, const char *, int, const char *,
|
||||
PyObject *, const char *, ...);
|
||||
#endif
|
||||
|
||||
/* DEPRECATED: Use PyErr_WarnEx() instead. */
|
||||
#ifndef Py_LIMITED_API
|
||||
#define PyErr_Warn(category, msg) PyErr_WarnEx(category, msg, 1)
|
||||
#endif
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !Py_WARNINGS_H */
|
||||
|
||||
|
|
17
third_party/python/Include/weakrefobject.h
vendored
17
third_party/python/Include/weakrefobject.h
vendored
|
@ -1,5 +1,6 @@
|
|||
#ifndef Py_WEAKREFOBJECT_H
|
||||
#define Py_WEAKREFOBJECT_H
|
||||
#include "third_party/python/Include/object.h"
|
||||
COSMOPOLITAN_C_START_
|
||||
/* clang-format off */
|
||||
|
||||
|
@ -36,9 +37,9 @@ struct _PyWeakReference {
|
|||
};
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) _PyWeakref_RefType;
|
||||
PyAPI_DATA(PyTypeObject) _PyWeakref_ProxyType;
|
||||
PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType;
|
||||
extern PyTypeObject _PyWeakref_RefType;
|
||||
extern PyTypeObject _PyWeakref_ProxyType;
|
||||
extern PyTypeObject _PyWeakref_CallableProxyType;
|
||||
|
||||
#define PyWeakref_CheckRef(op) PyObject_TypeCheck(op, &_PyWeakref_RefType)
|
||||
#define PyWeakref_CheckRefExact(op) \
|
||||
|
@ -51,16 +52,16 @@ PyAPI_DATA(PyTypeObject) _PyWeakref_CallableProxyType;
|
|||
(PyWeakref_CheckRef(op) || PyWeakref_CheckProxy(op))
|
||||
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyWeakref_NewRef(PyObject *ob,
|
||||
PyObject * PyWeakref_NewRef(PyObject *ob,
|
||||
PyObject *callback);
|
||||
PyAPI_FUNC(PyObject *) PyWeakref_NewProxy(PyObject *ob,
|
||||
PyObject * PyWeakref_NewProxy(PyObject *ob,
|
||||
PyObject *callback);
|
||||
PyAPI_FUNC(PyObject *) PyWeakref_GetObject(PyObject *ref);
|
||||
PyObject * PyWeakref_GetObject(PyObject *ref);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(Py_ssize_t) _PyWeakref_GetWeakrefCount(PyWeakReference *head);
|
||||
Py_ssize_t _PyWeakref_GetWeakrefCount(PyWeakReference *head);
|
||||
|
||||
PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference *self);
|
||||
void _PyWeakref_ClearRef(PyWeakReference *self);
|
||||
#endif
|
||||
|
||||
/* Explanation for the Py_REFCNT() check: when a weakref's target is part
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue