ZTWHHH commited on
Commit
3577708
·
verified ·
1 Parent(s): 762f6e1

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. llava_next/include/python3.10/Python.h +148 -0
  2. llava_next/include/python3.10/abstract.h +873 -0
  3. llava_next/include/python3.10/bytesobject.h +69 -0
  4. llava_next/include/python3.10/code.h +20 -0
  5. llava_next/include/python3.10/codecs.h +248 -0
  6. llava_next/include/python3.10/compile.h +25 -0
  7. llava_next/include/python3.10/complexobject.h +69 -0
  8. llava_next/include/python3.10/context.h +81 -0
  9. llava_next/include/python3.10/cpython/bytesobject.h +118 -0
  10. llava_next/include/python3.10/cpython/ceval.h +30 -0
  11. llava_next/include/python3.10/cpython/code.h +184 -0
  12. llava_next/include/python3.10/cpython/compile.h +54 -0
  13. llava_next/include/python3.10/cpython/dictobject.h +84 -0
  14. llava_next/include/python3.10/cpython/fileobject.h +18 -0
  15. llava_next/include/python3.10/cpython/fileutils.h +172 -0
  16. llava_next/include/python3.10/cpython/import.h +46 -0
  17. llava_next/include/python3.10/cpython/interpreteridobject.h +11 -0
  18. llava_next/include/python3.10/cpython/listobject.h +34 -0
  19. llava_next/include/python3.10/cpython/methodobject.h +35 -0
  20. llava_next/include/python3.10/cpython/object.h +552 -0
  21. llava_next/include/python3.10/cpython/pyctype.h +39 -0
  22. llava_next/include/python3.10/cpython/pydebug.h +38 -0
  23. llava_next/include/python3.10/cpython/pyerrors.h +214 -0
  24. llava_next/include/python3.10/cpython/pyfpe.h +15 -0
  25. llava_next/include/python3.10/cpython/pymem.h +98 -0
  26. llava_next/include/python3.10/cpython/pystate.h +305 -0
  27. llava_next/include/python3.10/cpython/pytime.h +247 -0
  28. llava_next/include/python3.10/cpython/sysmodule.h +16 -0
  29. llava_next/include/python3.10/cpython/traceback.h +14 -0
  30. llava_next/include/python3.10/cpython/tupleobject.h +28 -0
  31. llava_next/include/python3.10/cpython/unicodeobject.h +1169 -0
  32. llava_next/include/python3.10/eval.h +27 -0
  33. llava_next/include/python3.10/floatobject.h +118 -0
  34. llava_next/include/python3.10/genobject.h +100 -0
  35. llava_next/include/python3.10/internal/pycore_abstract.h +22 -0
  36. llava_next/include/python3.10/internal/pycore_accu.h +39 -0
  37. llava_next/include/python3.10/internal/pycore_ast.h +855 -0
  38. llava_next/include/python3.10/internal/pycore_ast_state.h +255 -0
  39. llava_next/include/python3.10/internal/pycore_atomic.h +557 -0
  40. llava_next/include/python3.10/internal/pycore_atomic_funcs.h +94 -0
  41. llava_next/include/python3.10/internal/pycore_bitutils.h +176 -0
  42. llava_next/include/python3.10/internal/pycore_blocks_output_buffer.h +317 -0
  43. llava_next/include/python3.10/internal/pycore_bytes_methods.h +73 -0
  44. llava_next/include/python3.10/internal/pycore_call.h +39 -0
  45. llava_next/include/python3.10/internal/pycore_code.h +34 -0
  46. llava_next/include/python3.10/internal/pycore_context.h +42 -0
  47. llava_next/include/python3.10/internal/pycore_dtoa.h +23 -0
  48. llava_next/include/python3.10/internal/pycore_fileutils.h +71 -0
  49. llava_next/include/python3.10/internal/pycore_list.h +20 -0
  50. llava_next/include/python3.10/internal/pycore_pathconfig.h +73 -0
llava_next/include/python3.10/Python.h ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_PYTHON_H
2
+ #define Py_PYTHON_H
3
+ /* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */
4
+
5
+ /* Include nearly all Python header files */
6
+
7
+ #include "patchlevel.h"
8
+ #include "pyconfig.h"
9
+ #include "pymacconfig.h"
10
+
11
+ #include <limits.h>
12
+
13
+ #ifndef UCHAR_MAX
14
+ #error "Something's broken. UCHAR_MAX should be defined in limits.h."
15
+ #endif
16
+
17
+ #if UCHAR_MAX != 255
18
+ #error "Python's source code assumes C's unsigned char is an 8-bit type."
19
+ #endif
20
+
21
+ #if defined(__sgi) && !defined(_SGI_MP_SOURCE)
22
+ #define _SGI_MP_SOURCE
23
+ #endif
24
+
25
+ #include <stdio.h>
26
+ #ifndef NULL
27
+ # error "Python.h requires that stdio.h define NULL."
28
+ #endif
29
+
30
+ #include <string.h>
31
+ #ifdef HAVE_ERRNO_H
32
+ #include <errno.h>
33
+ #endif
34
+ #include <stdlib.h>
35
+ #ifndef MS_WINDOWS
36
+ #include <unistd.h>
37
+ #endif
38
+
39
+ /* For size_t? */
40
+ #ifdef HAVE_STDDEF_H
41
+ #include <stddef.h>
42
+ #endif
43
+
44
+ /* CAUTION: Build setups should ensure that NDEBUG is defined on the
45
+ * compiler command line when building Python in release mode; else
46
+ * assert() calls won't be removed.
47
+ */
48
+ #include <assert.h>
49
+
50
+ #include "pyport.h"
51
+ #include "pymacro.h"
52
+
53
+ /* A convenient way for code to know if sanitizers are enabled. */
54
+ #if defined(__has_feature)
55
+ # if __has_feature(memory_sanitizer)
56
+ # if !defined(_Py_MEMORY_SANITIZER)
57
+ # define _Py_MEMORY_SANITIZER
58
+ # endif
59
+ # endif
60
+ # if __has_feature(address_sanitizer)
61
+ # if !defined(_Py_ADDRESS_SANITIZER)
62
+ # define _Py_ADDRESS_SANITIZER
63
+ # endif
64
+ # endif
65
+ #elif defined(__GNUC__)
66
+ # if defined(__SANITIZE_ADDRESS__)
67
+ # define _Py_ADDRESS_SANITIZER
68
+ # endif
69
+ #endif
70
+
71
+ #include "pymath.h"
72
+ #include "pymem.h"
73
+
74
+ #include "object.h"
75
+ #include "objimpl.h"
76
+ #include "typeslots.h"
77
+ #include "pyhash.h"
78
+
79
+ #include "cpython/pydebug.h"
80
+
81
+ #include "bytearrayobject.h"
82
+ #include "bytesobject.h"
83
+ #include "unicodeobject.h"
84
+ #include "longobject.h"
85
+ #include "longintrepr.h"
86
+ #include "boolobject.h"
87
+ #include "floatobject.h"
88
+ #include "complexobject.h"
89
+ #include "rangeobject.h"
90
+ #include "memoryobject.h"
91
+ #include "tupleobject.h"
92
+ #include "listobject.h"
93
+ #include "dictobject.h"
94
+ #include "cpython/odictobject.h"
95
+ #include "enumobject.h"
96
+ #include "setobject.h"
97
+ #include "methodobject.h"
98
+ #include "moduleobject.h"
99
+ #include "funcobject.h"
100
+ #include "classobject.h"
101
+ #include "fileobject.h"
102
+ #include "pycapsule.h"
103
+ #include "code.h"
104
+ #include "pyframe.h"
105
+ #include "traceback.h"
106
+ #include "sliceobject.h"
107
+ #include "cellobject.h"
108
+ #include "iterobject.h"
109
+ #include "cpython/initconfig.h"
110
+ #include "genobject.h"
111
+ #include "descrobject.h"
112
+ #include "genericaliasobject.h"
113
+ #include "warnings.h"
114
+ #include "weakrefobject.h"
115
+ #include "structseq.h"
116
+ #include "namespaceobject.h"
117
+ #include "cpython/picklebufobject.h"
118
+ #include "cpython/pytime.h"
119
+
120
+ #include "codecs.h"
121
+ #include "pyerrors.h"
122
+ #include "pythread.h"
123
+ #include "pystate.h"
124
+ #include "context.h"
125
+
126
+ #include "modsupport.h"
127
+ #include "compile.h"
128
+ #include "pythonrun.h"
129
+ #include "pylifecycle.h"
130
+ #include "ceval.h"
131
+ #include "sysmodule.h"
132
+ #include "osmodule.h"
133
+ #include "intrcheck.h"
134
+ #include "import.h"
135
+
136
+ #include "abstract.h"
137
+ #include "bltinmodule.h"
138
+
139
+ #include "eval.h"
140
+
141
+ #include "cpython/pyctype.h"
142
+ #include "pystrtod.h"
143
+ #include "pystrcmp.h"
144
+ #include "fileutils.h"
145
+ #include "cpython/pyfpe.h"
146
+ #include "tracemalloc.h"
147
+
148
+ #endif /* !Py_PYTHON_H */
llava_next/include/python3.10/abstract.h ADDED
@@ -0,0 +1,873 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Abstract Object Interface (many thanks to Jim Fulton) */
2
+
3
+ #ifndef Py_ABSTRACTOBJECT_H
4
+ #define Py_ABSTRACTOBJECT_H
5
+ #ifdef __cplusplus
6
+ extern "C" {
7
+ #endif
8
+
9
+ /* === Object Protocol ================================================== */
10
+
11
+ /* Implemented elsewhere:
12
+
13
+ int PyObject_Print(PyObject *o, FILE *fp, int flags);
14
+
15
+ Print an object 'o' on file 'fp'. Returns -1 on error. The flags argument
16
+ is used to enable certain printing options. The only option currently
17
+ supported is Py_Print_RAW.
18
+
19
+ (What should be said about Py_Print_RAW?). */
20
+
21
+
22
+ /* Implemented elsewhere:
23
+
24
+ int PyObject_HasAttrString(PyObject *o, const char *attr_name);
25
+
26
+ Returns 1 if object 'o' has the attribute attr_name, and 0 otherwise.
27
+
28
+ This is equivalent to the Python expression: hasattr(o,attr_name).
29
+
30
+ This function always succeeds. */
31
+
32
+
33
+ /* Implemented elsewhere:
34
+
35
+ PyObject* PyObject_GetAttrString(PyObject *o, const char *attr_name);
36
+
37
+ Retrieve an attributed named attr_name form object o.
38
+ Returns the attribute value on success, or NULL on failure.
39
+
40
+ This is the equivalent of the Python expression: o.attr_name. */
41
+
42
+
43
+ /* Implemented elsewhere:
44
+
45
+ int PyObject_HasAttr(PyObject *o, PyObject *attr_name);
46
+
47
+ Returns 1 if o has the attribute attr_name, and 0 otherwise.
48
+
49
+ This is equivalent to the Python expression: hasattr(o,attr_name).
50
+
51
+ This function always succeeds. */
52
+
53
+ /* Implemented elsewhere:
54
+
55
+ PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name);
56
+
57
+ Retrieve an attributed named 'attr_name' form object 'o'.
58
+ Returns the attribute value on success, or NULL on failure.
59
+
60
+ This is the equivalent of the Python expression: o.attr_name. */
61
+
62
+
63
+ /* Implemented elsewhere:
64
+
65
+ int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v);
66
+
67
+ Set the value of the attribute named attr_name, for object 'o',
68
+ to the value 'v'. Raise an exception and return -1 on failure; return 0 on
69
+ success.
70
+
71
+ This is the equivalent of the Python statement o.attr_name=v. */
72
+
73
+
74
+ /* Implemented elsewhere:
75
+
76
+ int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v);
77
+
78
+ Set the value of the attribute named attr_name, for object 'o', to the value
79
+ 'v'. an exception and return -1 on failure; return 0 on success.
80
+
81
+ This is the equivalent of the Python statement o.attr_name=v. */
82
+
83
+ /* Implemented as a macro:
84
+
85
+ int PyObject_DelAttrString(PyObject *o, const char *attr_name);
86
+
87
+ Delete attribute named attr_name, for object o. Returns
88
+ -1 on failure.
89
+
90
+ This is the equivalent of the Python statement: del o.attr_name. */
91
+ #define PyObject_DelAttrString(O,A) PyObject_SetAttrString((O),(A), NULL)
92
+
93
+
94
+ /* Implemented as a macro:
95
+
96
+ int PyObject_DelAttr(PyObject *o, PyObject *attr_name);
97
+
98
+ Delete attribute named attr_name, for object o. Returns -1
99
+ on failure. This is the equivalent of the Python
100
+ statement: del o.attr_name. */
101
+ #define PyObject_DelAttr(O,A) PyObject_SetAttr((O),(A), NULL)
102
+
103
+
104
+ /* Implemented elsewhere:
105
+
106
+ PyObject *PyObject_Repr(PyObject *o);
107
+
108
+ Compute the string representation of object 'o'. Returns the
109
+ string representation on success, NULL on failure.
110
+
111
+ This is the equivalent of the Python expression: repr(o).
112
+
113
+ Called by the repr() built-in function. */
114
+
115
+
116
+ /* Implemented elsewhere:
117
+
118
+ PyObject *PyObject_Str(PyObject *o);
119
+
120
+ Compute the string representation of object, o. Returns the
121
+ string representation on success, NULL on failure.
122
+
123
+ This is the equivalent of the Python expression: str(o).
124
+
125
+ Called by the str() and print() built-in functions. */
126
+
127
+
128
+ /* Declared elsewhere
129
+
130
+ PyAPI_FUNC(int) PyCallable_Check(PyObject *o);
131
+
132
+ Determine if the object, o, is callable. Return 1 if the object is callable
133
+ and 0 otherwise.
134
+
135
+ This function always succeeds. */
136
+
137
+
138
+ #ifdef PY_SSIZE_T_CLEAN
139
+ # define PyObject_CallFunction _PyObject_CallFunction_SizeT
140
+ # define PyObject_CallMethod _PyObject_CallMethod_SizeT
141
+ #endif
142
+
143
+
144
+ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000
145
+ /* Call a callable Python object without any arguments */
146
+ PyAPI_FUNC(PyObject *) PyObject_CallNoArgs(PyObject *func);
147
+ #endif
148
+
149
+
150
+ /* Call a callable Python object 'callable' with arguments given by the
151
+ tuple 'args' and keywords arguments given by the dictionary 'kwargs'.
152
+
153
+ 'args' must not be NULL, use an empty tuple if no arguments are
154
+ needed. If no named arguments are needed, 'kwargs' can be NULL.
155
+
156
+ This is the equivalent of the Python expression:
157
+ callable(*args, **kwargs). */
158
+ PyAPI_FUNC(PyObject *) PyObject_Call(PyObject *callable,
159
+ PyObject *args, PyObject *kwargs);
160
+
161
+
162
+ /* Call a callable Python object 'callable', with arguments given by the
163
+ tuple 'args'. If no arguments are needed, then 'args' can be NULL.
164
+
165
+ Returns the result of the call on success, or NULL on failure.
166
+
167
+ This is the equivalent of the Python expression:
168
+ callable(*args). */
169
+ PyAPI_FUNC(PyObject *) PyObject_CallObject(PyObject *callable,
170
+ PyObject *args);
171
+
172
+ /* Call a callable Python object, callable, with a variable number of C
173
+ arguments. The C arguments are described using a mkvalue-style format
174
+ string.
175
+
176
+ The format may be NULL, indicating that no arguments are provided.
177
+
178
+ Returns the result of the call on success, or NULL on failure.
179
+
180
+ This is the equivalent of the Python expression:
181
+ callable(arg1, arg2, ...). */
182
+ PyAPI_FUNC(PyObject *) PyObject_CallFunction(PyObject *callable,
183
+ const char *format, ...);
184
+
185
+ /* Call the method named 'name' of object 'obj' with a variable number of
186
+ C arguments. The C arguments are described by a mkvalue format string.
187
+
188
+ The format can be NULL, indicating that no arguments are provided.
189
+
190
+ Returns the result of the call on success, or NULL on failure.
191
+
192
+ This is the equivalent of the Python expression:
193
+ obj.name(arg1, arg2, ...). */
194
+ PyAPI_FUNC(PyObject *) PyObject_CallMethod(PyObject *obj,
195
+ const char *name,
196
+ const char *format, ...);
197
+
198
+ PyAPI_FUNC(PyObject *) _PyObject_CallFunction_SizeT(PyObject *callable,
199
+ const char *format,
200
+ ...);
201
+
202
+ PyAPI_FUNC(PyObject *) _PyObject_CallMethod_SizeT(PyObject *obj,
203
+ const char *name,
204
+ const char *format,
205
+ ...);
206
+
207
+ /* Call a callable Python object 'callable' with a variable number of C
208
+ arguments. The C arguments are provided as PyObject* values, terminated
209
+ by a NULL.
210
+
211
+ Returns the result of the call on success, or NULL on failure.
212
+
213
+ This is the equivalent of the Python expression:
214
+ callable(arg1, arg2, ...). */
215
+ PyAPI_FUNC(PyObject *) PyObject_CallFunctionObjArgs(PyObject *callable,
216
+ ...);
217
+
218
+ /* Call the method named 'name' of object 'obj' with a variable number of
219
+ C arguments. The C arguments are provided as PyObject* values, terminated
220
+ by NULL.
221
+
222
+ Returns the result of the call on success, or NULL on failure.
223
+
224
+ This is the equivalent of the Python expression: obj.name(*args). */
225
+
226
+ PyAPI_FUNC(PyObject *) PyObject_CallMethodObjArgs(
227
+ PyObject *obj,
228
+ PyObject *name,
229
+ ...);
230
+
231
+
232
+ /* Implemented elsewhere:
233
+
234
+ Py_hash_t PyObject_Hash(PyObject *o);
235
+
236
+ Compute and return the hash, hash_value, of an object, o. On
237
+ failure, return -1.
238
+
239
+ This is the equivalent of the Python expression: hash(o). */
240
+
241
+
242
+ /* Implemented elsewhere:
243
+
244
+ int PyObject_IsTrue(PyObject *o);
245
+
246
+ Returns 1 if the object, o, is considered to be true, 0 if o is
247
+ considered to be false and -1 on failure.
248
+
249
+ This is equivalent to the Python expression: not not o. */
250
+
251
+
252
+ /* Implemented elsewhere:
253
+
254
+ int PyObject_Not(PyObject *o);
255
+
256
+ Returns 0 if the object, o, is considered to be true, 1 if o is
257
+ considered to be false and -1 on failure.
258
+
259
+ This is equivalent to the Python expression: not o. */
260
+
261
+
262
+ /* Get the type of an object.
263
+
264
+ On success, returns a type object corresponding to the object type of object
265
+ 'o'. On failure, returns NULL.
266
+
267
+ This is equivalent to the Python expression: type(o) */
268
+ PyAPI_FUNC(PyObject *) PyObject_Type(PyObject *o);
269
+
270
+
271
+ /* Return the size of object 'o'. If the object 'o' provides both sequence and
272
+ mapping protocols, the sequence size is returned.
273
+
274
+ On error, -1 is returned.
275
+
276
+ This is the equivalent to the Python expression: len(o) */
277
+ PyAPI_FUNC(Py_ssize_t) PyObject_Size(PyObject *o);
278
+
279
+
280
+ /* For DLL compatibility */
281
+ #undef PyObject_Length
282
+ PyAPI_FUNC(Py_ssize_t) PyObject_Length(PyObject *o);
283
+ #define PyObject_Length PyObject_Size
284
+
285
+ /* Return element of 'o' corresponding to the object 'key'. Return NULL
286
+ on failure.
287
+
288
+ This is the equivalent of the Python expression: o[key] */
289
+ PyAPI_FUNC(PyObject *) PyObject_GetItem(PyObject *o, PyObject *key);
290
+
291
+
292
+ /* Map the object 'key' to the value 'v' into 'o'.
293
+
294
+ Raise an exception and return -1 on failure; return 0 on success.
295
+
296
+ This is the equivalent of the Python statement: o[key]=v. */
297
+ PyAPI_FUNC(int) PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v);
298
+
299
+ /* Remove the mapping for the string 'key' from the object 'o'.
300
+ Returns -1 on failure.
301
+
302
+ This is equivalent to the Python statement: del o[key]. */
303
+ PyAPI_FUNC(int) PyObject_DelItemString(PyObject *o, const char *key);
304
+
305
+ /* Delete the mapping for the object 'key' from the object 'o'.
306
+ Returns -1 on failure.
307
+
308
+ This is the equivalent of the Python statement: del o[key]. */
309
+ PyAPI_FUNC(int) PyObject_DelItem(PyObject *o, PyObject *key);
310
+
311
+
312
+ /* === Old Buffer API ============================================ */
313
+
314
+ /* FIXME: usage of these should all be replaced in Python itself
315
+ but for backwards compatibility we will implement them.
316
+ Their usage without a corresponding "unlock" mechanism
317
+ may create issues (but they would already be there). */
318
+
319
+ /* Takes an arbitrary object which must support the (character, single segment)
320
+ buffer interface and returns a pointer to a read-only memory location
321
+ usable as character based input for subsequent processing.
322
+
323
+ Return 0 on success. buffer and buffer_len are only set in case no error
324
+ occurs. Otherwise, -1 is returned and an exception set. */
325
+ Py_DEPRECATED(3.0)
326
+ PyAPI_FUNC(int) PyObject_AsCharBuffer(PyObject *obj,
327
+ const char **buffer,
328
+ Py_ssize_t *buffer_len);
329
+
330
+ /* Checks whether an arbitrary object supports the (character, single segment)
331
+ buffer interface.
332
+
333
+ Returns 1 on success, 0 on failure. */
334
+ Py_DEPRECATED(3.0) PyAPI_FUNC(int) PyObject_CheckReadBuffer(PyObject *obj);
335
+
336
+ /* Same as PyObject_AsCharBuffer() except that this API expects (readable,
337
+ single segment) buffer interface and returns a pointer to a read-only memory
338
+ location which can contain arbitrary data.
339
+
340
+ 0 is returned on success. buffer and buffer_len are only set in case no
341
+ error occurs. Otherwise, -1 is returned and an exception set. */
342
+ Py_DEPRECATED(3.0)
343
+ PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *obj,
344
+ const void **buffer,
345
+ Py_ssize_t *buffer_len);
346
+
347
+ /* Takes an arbitrary object which must support the (writable, single segment)
348
+ buffer interface and returns a pointer to a writable memory location in
349
+ buffer of size 'buffer_len'.
350
+
351
+ Return 0 on success. buffer and buffer_len are only set in case no error
352
+ occurs. Otherwise, -1 is returned and an exception set. */
353
+ Py_DEPRECATED(3.0)
354
+ PyAPI_FUNC(int) PyObject_AsWriteBuffer(PyObject *obj,
355
+ void **buffer,
356
+ Py_ssize_t *buffer_len);
357
+
358
+
359
+ /* === New Buffer API ============================================ */
360
+
361
+ /* Takes an arbitrary object and returns the result of calling
362
+ obj.__format__(format_spec). */
363
+ PyAPI_FUNC(PyObject *) PyObject_Format(PyObject *obj,
364
+ PyObject *format_spec);
365
+
366
+
367
+ /* ==== Iterators ================================================ */
368
+
369
+ /* Takes an object and returns an iterator for it.
370
+ This is typically a new iterator but if the argument is an iterator, this
371
+ returns itself. */
372
+ PyAPI_FUNC(PyObject *) PyObject_GetIter(PyObject *);
373
+
374
+ /* Takes an AsyncIterable object and returns an AsyncIterator for it.
375
+ This is typically a new iterator but if the argument is an AsyncIterator,
376
+ this returns itself. */
377
+ PyAPI_FUNC(PyObject *) PyObject_GetAIter(PyObject *);
378
+
379
+ /* Returns non-zero if the object 'obj' provides iterator protocols, and 0 otherwise.
380
+
381
+ This function always succeeds. */
382
+ PyAPI_FUNC(int) PyIter_Check(PyObject *);
383
+
384
+ /* Returns non-zero if the object 'obj' provides AsyncIterator protocols, and 0 otherwise.
385
+
386
+ This function always succeeds. */
387
+ PyAPI_FUNC(int) PyAIter_Check(PyObject *);
388
+
389
+ /* Takes an iterator object and calls its tp_iternext slot,
390
+ returning the next value.
391
+
392
+ If the iterator is exhausted, this returns NULL without setting an
393
+ exception.
394
+
395
+ NULL with an exception means an error occurred. */
396
+ PyAPI_FUNC(PyObject *) PyIter_Next(PyObject *);
397
+
398
+ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000
399
+
400
+ /* Takes generator, coroutine or iterator object and sends the value into it.
401
+ Returns:
402
+ - PYGEN_RETURN (0) if generator has returned.
403
+ 'result' parameter is filled with return value
404
+ - PYGEN_ERROR (-1) if exception was raised.
405
+ 'result' parameter is NULL
406
+ - PYGEN_NEXT (1) if generator has yielded.
407
+ 'result' parameter is filled with yielded value. */
408
+ PyAPI_FUNC(PySendResult) PyIter_Send(PyObject *, PyObject *, PyObject **);
409
+ #endif
410
+
411
+
412
+ /* === Number Protocol ================================================== */
413
+
414
+ /* Returns 1 if the object 'o' provides numeric protocols, and 0 otherwise.
415
+
416
+ This function always succeeds. */
417
+ PyAPI_FUNC(int) PyNumber_Check(PyObject *o);
418
+
419
+ /* Returns the result of adding o1 and o2, or NULL on failure.
420
+
421
+ This is the equivalent of the Python expression: o1 + o2. */
422
+ PyAPI_FUNC(PyObject *) PyNumber_Add(PyObject *o1, PyObject *o2);
423
+
424
+ /* Returns the result of subtracting o2 from o1, or NULL on failure.
425
+
426
+ This is the equivalent of the Python expression: o1 - o2. */
427
+ PyAPI_FUNC(PyObject *) PyNumber_Subtract(PyObject *o1, PyObject *o2);
428
+
429
+ /* Returns the result of multiplying o1 and o2, or NULL on failure.
430
+
431
+ This is the equivalent of the Python expression: o1 * o2. */
432
+ PyAPI_FUNC(PyObject *) PyNumber_Multiply(PyObject *o1, PyObject *o2);
433
+
434
+ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
435
+ /* This is the equivalent of the Python expression: o1 @ o2. */
436
+ PyAPI_FUNC(PyObject *) PyNumber_MatrixMultiply(PyObject *o1, PyObject *o2);
437
+ #endif
438
+
439
+ /* Returns the result of dividing o1 by o2 giving an integral result,
440
+ or NULL on failure.
441
+
442
+ This is the equivalent of the Python expression: o1 // o2. */
443
+ PyAPI_FUNC(PyObject *) PyNumber_FloorDivide(PyObject *o1, PyObject *o2);
444
+
445
+ /* Returns the result of dividing o1 by o2 giving a float result, or NULL on
446
+ failure.
447
+
448
+ This is the equivalent of the Python expression: o1 / o2. */
449
+ PyAPI_FUNC(PyObject *) PyNumber_TrueDivide(PyObject *o1, PyObject *o2);
450
+
451
+ /* Returns the remainder of dividing o1 by o2, or NULL on failure.
452
+
453
+ This is the equivalent of the Python expression: o1 % o2. */
454
+ PyAPI_FUNC(PyObject *) PyNumber_Remainder(PyObject *o1, PyObject *o2);
455
+
456
+ /* See the built-in function divmod.
457
+
458
+ Returns NULL on failure.
459
+
460
+ This is the equivalent of the Python expression: divmod(o1, o2). */
461
+ PyAPI_FUNC(PyObject *) PyNumber_Divmod(PyObject *o1, PyObject *o2);
462
+
463
+ /* See the built-in function pow. Returns NULL on failure.
464
+
465
+ This is the equivalent of the Python expression: pow(o1, o2, o3),
466
+ where o3 is optional. */
467
+ PyAPI_FUNC(PyObject *) PyNumber_Power(PyObject *o1, PyObject *o2,
468
+ PyObject *o3);
469
+
470
+ /* Returns the negation of o on success, or NULL on failure.
471
+
472
+ This is the equivalent of the Python expression: -o. */
473
+ PyAPI_FUNC(PyObject *) PyNumber_Negative(PyObject *o);
474
+
475
+ /* Returns the positive of o on success, or NULL on failure.
476
+
477
+ This is the equivalent of the Python expression: +o. */
478
+ PyAPI_FUNC(PyObject *) PyNumber_Positive(PyObject *o);
479
+
480
+ /* Returns the absolute value of 'o', or NULL on failure.
481
+
482
+ This is the equivalent of the Python expression: abs(o). */
483
+ PyAPI_FUNC(PyObject *) PyNumber_Absolute(PyObject *o);
484
+
485
+ /* Returns the bitwise negation of 'o' on success, or NULL on failure.
486
+
487
+ This is the equivalent of the Python expression: ~o. */
488
+ PyAPI_FUNC(PyObject *) PyNumber_Invert(PyObject *o);
489
+
490
+ /* Returns the result of left shifting o1 by o2 on success, or NULL on failure.
491
+
492
+ This is the equivalent of the Python expression: o1 << o2. */
493
+ PyAPI_FUNC(PyObject *) PyNumber_Lshift(PyObject *o1, PyObject *o2);
494
+
495
+ /* Returns the result of right shifting o1 by o2 on success, or NULL on
496
+ failure.
497
+
498
+ This is the equivalent of the Python expression: o1 >> o2. */
499
+ PyAPI_FUNC(PyObject *) PyNumber_Rshift(PyObject *o1, PyObject *o2);
500
+
501
+ /* Returns the result of bitwise and of o1 and o2 on success, or NULL on
502
+ failure.
503
+
504
+ This is the equivalent of the Python expression: o1 & o2. */
505
+ PyAPI_FUNC(PyObject *) PyNumber_And(PyObject *o1, PyObject *o2);
506
+
507
+ /* Returns the bitwise exclusive or of o1 by o2 on success, or NULL on failure.
508
+
509
+ This is the equivalent of the Python expression: o1 ^ o2. */
510
+ PyAPI_FUNC(PyObject *) PyNumber_Xor(PyObject *o1, PyObject *o2);
511
+
512
+ /* Returns the result of bitwise or on o1 and o2 on success, or NULL on
513
+ failure.
514
+
515
+ This is the equivalent of the Python expression: o1 | o2. */
516
+ PyAPI_FUNC(PyObject *) PyNumber_Or(PyObject *o1, PyObject *o2);
517
+
518
+ /* Returns 1 if obj is an index integer (has the nb_index slot of the
519
+ tp_as_number structure filled in), and 0 otherwise. */
520
+ PyAPI_FUNC(int) PyIndex_Check(PyObject *);
521
+
522
+ /* Returns the object 'o' converted to a Python int, or NULL with an exception
523
+ raised on failure. */
524
+ PyAPI_FUNC(PyObject *) PyNumber_Index(PyObject *o);
525
+
526
+ /* Returns the object 'o' converted to Py_ssize_t by going through
527
+ PyNumber_Index() first.
528
+
529
+ If an overflow error occurs while converting the int to Py_ssize_t, then the
530
+ second argument 'exc' is the error-type to return. If it is NULL, then the
531
+ overflow error is cleared and the value is clipped. */
532
+ PyAPI_FUNC(Py_ssize_t) PyNumber_AsSsize_t(PyObject *o, PyObject *exc);
533
+
534
+ /* Returns the object 'o' converted to an integer object on success, or NULL
535
+ on failure.
536
+
537
+ This is the equivalent of the Python expression: int(o). */
538
+ PyAPI_FUNC(PyObject *) PyNumber_Long(PyObject *o);
539
+
540
+ /* Returns the object 'o' converted to a float object on success, or NULL
541
+ on failure.
542
+
543
+ This is the equivalent of the Python expression: float(o). */
544
+ PyAPI_FUNC(PyObject *) PyNumber_Float(PyObject *o);
545
+
546
+
547
+ /* --- In-place variants of (some of) the above number protocol functions -- */
548
+
549
+ /* Returns the result of adding o2 to o1, possibly in-place, or NULL
550
+ on failure.
551
+
552
+ This is the equivalent of the Python expression: o1 += o2. */
553
+ PyAPI_FUNC(PyObject *) PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2);
554
+
555
+ /* Returns the result of subtracting o2 from o1, possibly in-place or
556
+ NULL on failure.
557
+
558
+ This is the equivalent of the Python expression: o1 -= o2. */
559
+ PyAPI_FUNC(PyObject *) PyNumber_InPlaceSubtract(PyObject *o1, PyObject *o2);
560
+
561
+ /* Returns the result of multiplying o1 by o2, possibly in-place, or NULL on
562
+ failure.
563
+
564
+ This is the equivalent of the Python expression: o1 *= o2. */
565
+ PyAPI_FUNC(PyObject *) PyNumber_InPlaceMultiply(PyObject *o1, PyObject *o2);
566
+
567
+ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
568
+ /* This is the equivalent of the Python expression: o1 @= o2. */
569
+ PyAPI_FUNC(PyObject *) PyNumber_InPlaceMatrixMultiply(PyObject *o1, PyObject *o2);
570
+ #endif
571
+
572
+ /* Returns the result of dividing o1 by o2 giving an integral result, possibly
573
+ in-place, or NULL on failure.
574
+
575
+ This is the equivalent of the Python expression: o1 /= o2. */
576
+ PyAPI_FUNC(PyObject *) PyNumber_InPlaceFloorDivide(PyObject *o1,
577
+ PyObject *o2);
578
+
579
+ /* Returns the result of dividing o1 by o2 giving a float result, possibly
580
+ in-place, or null on failure.
581
+
582
+ This is the equivalent of the Python expression: o1 /= o2. */
583
+ PyAPI_FUNC(PyObject *) PyNumber_InPlaceTrueDivide(PyObject *o1,
584
+ PyObject *o2);
585
+
586
+ /* Returns the remainder of dividing o1 by o2, possibly in-place, or NULL on
587
+ failure.
588
+
589
+ This is the equivalent of the Python expression: o1 %= o2. */
590
+ PyAPI_FUNC(PyObject *) PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2);
591
+
592
+ /* Returns the result of raising o1 to the power of o2, possibly in-place,
593
+ or NULL on failure.
594
+
595
+ This is the equivalent of the Python expression: o1 **= o2,
596
+ or o1 = pow(o1, o2, o3) if o3 is present. */
597
+ PyAPI_FUNC(PyObject *) PyNumber_InPlacePower(PyObject *o1, PyObject *o2,
598
+ PyObject *o3);
599
+
600
+ /* Returns the result of left shifting o1 by o2, possibly in-place, or NULL
601
+ on failure.
602
+
603
+ This is the equivalent of the Python expression: o1 <<= o2. */
604
+ PyAPI_FUNC(PyObject *) PyNumber_InPlaceLshift(PyObject *o1, PyObject *o2);
605
+
606
+ /* Returns the result of right shifting o1 by o2, possibly in-place or NULL
607
+ on failure.
608
+
609
+ This is the equivalent of the Python expression: o1 >>= o2. */
610
+ PyAPI_FUNC(PyObject *) PyNumber_InPlaceRshift(PyObject *o1, PyObject *o2);
611
+
612
+ /* Returns the result of bitwise and of o1 and o2, possibly in-place, or NULL
613
+ on failure.
614
+
615
+ This is the equivalent of the Python expression: o1 &= o2. */
616
+ PyAPI_FUNC(PyObject *) PyNumber_InPlaceAnd(PyObject *o1, PyObject *o2);
617
+
618
+ /* Returns the bitwise exclusive or of o1 by o2, possibly in-place, or NULL
619
+ on failure.
620
+
621
+ This is the equivalent of the Python expression: o1 ^= o2. */
622
+ PyAPI_FUNC(PyObject *) PyNumber_InPlaceXor(PyObject *o1, PyObject *o2);
623
+
624
+ /* Returns the result of bitwise or of o1 and o2, possibly in-place,
625
+ or NULL on failure.
626
+
627
+ This is the equivalent of the Python expression: o1 |= o2. */
628
+ PyAPI_FUNC(PyObject *) PyNumber_InPlaceOr(PyObject *o1, PyObject *o2);
629
+
630
+ /* Returns the integer n converted to a string with a base, with a base
631
+ marker of 0b, 0o or 0x prefixed if applicable.
632
+
633
+ If n is not an int object, it is converted with PyNumber_Index first. */
634
+ PyAPI_FUNC(PyObject *) PyNumber_ToBase(PyObject *n, int base);
635
+
636
+
637
+ /* === Sequence protocol ================================================ */
638
+
639
+ /* Return 1 if the object provides sequence protocol, and zero
640
+ otherwise.
641
+
642
+ This function always succeeds. */
643
+ PyAPI_FUNC(int) PySequence_Check(PyObject *o);
644
+
645
+ /* Return the size of sequence object o, or -1 on failure. */
646
+ PyAPI_FUNC(Py_ssize_t) PySequence_Size(PyObject *o);
647
+
648
+ /* For DLL compatibility */
649
+ #undef PySequence_Length
650
+ PyAPI_FUNC(Py_ssize_t) PySequence_Length(PyObject *o);
651
+ #define PySequence_Length PySequence_Size
652
+
653
+
654
+ /* Return the concatenation of o1 and o2 on success, and NULL on failure.
655
+
656
+ This is the equivalent of the Python expression: o1 + o2. */
657
+ PyAPI_FUNC(PyObject *) PySequence_Concat(PyObject *o1, PyObject *o2);
658
+
659
+ /* Return the result of repeating sequence object 'o' 'count' times,
660
+ or NULL on failure.
661
+
662
+ This is the equivalent of the Python expression: o * count. */
663
+ PyAPI_FUNC(PyObject *) PySequence_Repeat(PyObject *o, Py_ssize_t count);
664
+
665
+ /* Return the ith element of o, or NULL on failure.
666
+
667
+ This is the equivalent of the Python expression: o[i]. */
668
+ PyAPI_FUNC(PyObject *) PySequence_GetItem(PyObject *o, Py_ssize_t i);
669
+
670
+ /* Return the slice of sequence object o between i1 and i2, or NULL on failure.
671
+
672
+ This is the equivalent of the Python expression: o[i1:i2]. */
673
+ PyAPI_FUNC(PyObject *) PySequence_GetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2);
674
+
675
+ /* Assign object 'v' to the ith element of the sequence 'o'. Raise an exception
676
+ and return -1 on failure; return 0 on success.
677
+
678
+ This is the equivalent of the Python statement o[i] = v. */
679
+ PyAPI_FUNC(int) PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v);
680
+
681
+ /* Delete the 'i'-th element of the sequence 'v'. Returns -1 on failure.
682
+
683
+ This is the equivalent of the Python statement: del o[i]. */
684
+ PyAPI_FUNC(int) PySequence_DelItem(PyObject *o, Py_ssize_t i);
685
+
686
+ /* Assign the sequence object 'v' to the slice in sequence object 'o',
687
+ from 'i1' to 'i2'. Returns -1 on failure.
688
+
689
+ This is the equivalent of the Python statement: o[i1:i2] = v. */
690
+ PyAPI_FUNC(int) PySequence_SetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2,
691
+ PyObject *v);
692
+
693
+ /* Delete the slice in sequence object 'o' from 'i1' to 'i2'.
694
+ Returns -1 on failure.
695
+
696
+ This is the equivalent of the Python statement: del o[i1:i2]. */
697
+ PyAPI_FUNC(int) PySequence_DelSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2);
698
+
699
+ /* Returns the sequence 'o' as a tuple on success, and NULL on failure.
700
+
701
+ This is equivalent to the Python expression: tuple(o). */
702
+ PyAPI_FUNC(PyObject *) PySequence_Tuple(PyObject *o);
703
+
704
+ /* Returns the sequence 'o' as a list on success, and NULL on failure.
705
+ This is equivalent to the Python expression: list(o) */
706
+ PyAPI_FUNC(PyObject *) PySequence_List(PyObject *o);
707
+
708
+ /* Return the sequence 'o' as a list, unless it's already a tuple or list.
709
+
710
+ Use PySequence_Fast_GET_ITEM to access the members of this list, and
711
+ PySequence_Fast_GET_SIZE to get its length.
712
+
713
+ Returns NULL on failure. If the object does not support iteration, raises a
714
+ TypeError exception with 'm' as the message text. */
715
+ PyAPI_FUNC(PyObject *) PySequence_Fast(PyObject *o, const char* m);
716
+
717
+ /* Return the size of the sequence 'o', assuming that 'o' was returned by
718
+ PySequence_Fast and is not NULL. */
719
+ #define PySequence_Fast_GET_SIZE(o) \
720
+ (PyList_Check(o) ? PyList_GET_SIZE(o) : PyTuple_GET_SIZE(o))
721
+
722
+ /* Return the 'i'-th element of the sequence 'o', assuming that o was returned
723
+ by PySequence_Fast, and that i is within bounds. */
724
+ #define PySequence_Fast_GET_ITEM(o, i)\
725
+ (PyList_Check(o) ? PyList_GET_ITEM(o, i) : PyTuple_GET_ITEM(o, i))
726
+
727
+ /* Return a pointer to the underlying item array for
728
+ an object returned by PySequence_Fast */
729
+ #define PySequence_Fast_ITEMS(sf) \
730
+ (PyList_Check(sf) ? ((PyListObject *)(sf))->ob_item \
731
+ : ((PyTupleObject *)(sf))->ob_item)
732
+
733
+ /* Return the number of occurrences on value on 'o', that is, return
734
+ the number of keys for which o[key] == value.
735
+
736
+ On failure, return -1. This is equivalent to the Python expression:
737
+ o.count(value). */
738
+ PyAPI_FUNC(Py_ssize_t) PySequence_Count(PyObject *o, PyObject *value);
739
+
740
+ /* Return 1 if 'ob' is in the sequence 'seq'; 0 if 'ob' is not in the sequence
741
+ 'seq'; -1 on error.
742
+
743
+ Use __contains__ if possible, else _PySequence_IterSearch(). */
744
+ PyAPI_FUNC(int) PySequence_Contains(PyObject *seq, PyObject *ob);
745
+
746
+ /* For DLL-level backwards compatibility */
747
+ #undef PySequence_In
748
+ /* Determine if the sequence 'o' contains 'value'. If an item in 'o' is equal
749
+ to 'value', return 1, otherwise return 0. On error, return -1.
750
+
751
+ This is equivalent to the Python expression: value in o. */
752
+ PyAPI_FUNC(int) PySequence_In(PyObject *o, PyObject *value);
753
+
754
+ /* For source-level backwards compatibility */
755
+ #define PySequence_In PySequence_Contains
756
+
757
+
758
+ /* Return the first index for which o[i] == value.
759
+ On error, return -1.
760
+
761
+ This is equivalent to the Python expression: o.index(value). */
762
+ PyAPI_FUNC(Py_ssize_t) PySequence_Index(PyObject *o, PyObject *value);
763
+
764
+
765
+ /* --- In-place versions of some of the above Sequence functions --- */
766
+
767
+ /* Append sequence 'o2' to sequence 'o1', in-place when possible. Return the
768
+ resulting object, which could be 'o1', or NULL on failure.
769
+
770
+ This is the equivalent of the Python expression: o1 += o2. */
771
+ PyAPI_FUNC(PyObject *) PySequence_InPlaceConcat(PyObject *o1, PyObject *o2);
772
+
773
+ /* Repeat sequence 'o' by 'count', in-place when possible. Return the resulting
774
+ object, which could be 'o', or NULL on failure.
775
+
776
+ This is the equivalent of the Python expression: o1 *= count. */
777
+ PyAPI_FUNC(PyObject *) PySequence_InPlaceRepeat(PyObject *o, Py_ssize_t count);
778
+
779
+
780
+ /* === Mapping protocol ================================================= */
781
+
782
+ /* Return 1 if the object provides mapping protocol, and 0 otherwise.
783
+
784
+ This function always succeeds. */
785
+ PyAPI_FUNC(int) PyMapping_Check(PyObject *o);
786
+
787
+ /* Returns the number of keys in mapping object 'o' on success, and -1 on
788
+ failure. This is equivalent to the Python expression: len(o). */
789
+ PyAPI_FUNC(Py_ssize_t) PyMapping_Size(PyObject *o);
790
+
791
+ /* For DLL compatibility */
792
+ #undef PyMapping_Length
793
+ PyAPI_FUNC(Py_ssize_t) PyMapping_Length(PyObject *o);
794
+ #define PyMapping_Length PyMapping_Size
795
+
796
+
797
+ /* Implemented as a macro:
798
+
799
+ int PyMapping_DelItemString(PyObject *o, const char *key);
800
+
801
+ Remove the mapping for the string 'key' from the mapping 'o'. Returns -1 on
802
+ failure.
803
+
804
+ This is equivalent to the Python statement: del o[key]. */
805
+ #define PyMapping_DelItemString(O,K) PyObject_DelItemString((O),(K))
806
+
807
+ /* Implemented as a macro:
808
+
809
+ int PyMapping_DelItem(PyObject *o, PyObject *key);
810
+
811
+ Remove the mapping for the object 'key' from the mapping object 'o'.
812
+ Returns -1 on failure.
813
+
814
+ This is equivalent to the Python statement: del o[key]. */
815
+ #define PyMapping_DelItem(O,K) PyObject_DelItem((O),(K))
816
+
817
+ /* On success, return 1 if the mapping object 'o' has the key 'key',
818
+ and 0 otherwise.
819
+
820
+ This is equivalent to the Python expression: key in o.
821
+
822
+ This function always succeeds. */
823
+ PyAPI_FUNC(int) PyMapping_HasKeyString(PyObject *o, const char *key);
824
+
825
+ /* Return 1 if the mapping object has the key 'key', and 0 otherwise.
826
+
827
+ This is equivalent to the Python expression: key in o.
828
+
829
+ This function always succeeds. */
830
+ PyAPI_FUNC(int) PyMapping_HasKey(PyObject *o, PyObject *key);
831
+
832
+ /* On success, return a list or tuple of the keys in mapping object 'o'.
833
+ On failure, return NULL. */
834
+ PyAPI_FUNC(PyObject *) PyMapping_Keys(PyObject *o);
835
+
836
+ /* On success, return a list or tuple of the values in mapping object 'o'.
837
+ On failure, return NULL. */
838
+ PyAPI_FUNC(PyObject *) PyMapping_Values(PyObject *o);
839
+
840
+ /* On success, return a list or tuple of the items in mapping object 'o',
841
+ where each item is a tuple containing a key-value pair. On failure, return
842
+ NULL. */
843
+ PyAPI_FUNC(PyObject *) PyMapping_Items(PyObject *o);
844
+
845
+ /* Return element of 'o' corresponding to the string 'key' or NULL on failure.
846
+
847
+ This is the equivalent of the Python expression: o[key]. */
848
+ PyAPI_FUNC(PyObject *) PyMapping_GetItemString(PyObject *o,
849
+ const char *key);
850
+
851
+ /* Map the string 'key' to the value 'v' in the mapping 'o'.
852
+ Returns -1 on failure.
853
+
854
+ This is the equivalent of the Python statement: o[key]=v. */
855
+ PyAPI_FUNC(int) PyMapping_SetItemString(PyObject *o, const char *key,
856
+ PyObject *value);
857
+
858
+ /* isinstance(object, typeorclass) */
859
+ PyAPI_FUNC(int) PyObject_IsInstance(PyObject *object, PyObject *typeorclass);
860
+
861
+ /* issubclass(object, typeorclass) */
862
+ PyAPI_FUNC(int) PyObject_IsSubclass(PyObject *object, PyObject *typeorclass);
863
+
864
+ #ifndef Py_LIMITED_API
865
+ # define Py_CPYTHON_ABSTRACTOBJECT_H
866
+ # include "cpython/abstract.h"
867
+ # undef Py_CPYTHON_ABSTRACTOBJECT_H
868
+ #endif
869
+
870
+ #ifdef __cplusplus
871
+ }
872
+ #endif
873
+ #endif /* Py_ABSTRACTOBJECT_H */
llava_next/include/python3.10/bytesobject.h ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* Bytes object interface */
3
+
4
+ #ifndef Py_BYTESOBJECT_H
5
+ #define Py_BYTESOBJECT_H
6
+ #ifdef __cplusplus
7
+ extern "C" {
8
+ #endif
9
+
10
+ #include <stdarg.h>
11
+
12
+ /*
13
+ Type PyBytesObject represents a byte string. An extra zero byte is
14
+ reserved at the end to ensure it is zero-terminated, but a size is
15
+ present so strings with null bytes in them can be represented. This
16
+ is an immutable object type.
17
+
18
+ There are functions to create new bytes objects, to test
19
+ an object for bytes-ness, and to get the
20
+ byte string value. The latter function returns a null pointer
21
+ if the object is not of the proper type.
22
+ There is a variant that takes an explicit size as well as a
23
+ variant that assumes a zero-terminated string. Note that none of the
24
+ functions should be applied to NULL pointer.
25
+ */
26
+
27
+ PyAPI_DATA(PyTypeObject) PyBytes_Type;
28
+ PyAPI_DATA(PyTypeObject) PyBytesIter_Type;
29
+
30
+ #define PyBytes_Check(op) \
31
+ PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_BYTES_SUBCLASS)
32
+ #define PyBytes_CheckExact(op) Py_IS_TYPE(op, &PyBytes_Type)
33
+
34
+ PyAPI_FUNC(PyObject *) PyBytes_FromStringAndSize(const char *, Py_ssize_t);
35
+ PyAPI_FUNC(PyObject *) PyBytes_FromString(const char *);
36
+ PyAPI_FUNC(PyObject *) PyBytes_FromObject(PyObject *);
37
+ PyAPI_FUNC(PyObject *) PyBytes_FromFormatV(const char*, va_list)
38
+ Py_GCC_ATTRIBUTE((format(printf, 1, 0)));
39
+ PyAPI_FUNC(PyObject *) PyBytes_FromFormat(const char*, ...)
40
+ Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
41
+ PyAPI_FUNC(Py_ssize_t) PyBytes_Size(PyObject *);
42
+ PyAPI_FUNC(char *) PyBytes_AsString(PyObject *);
43
+ PyAPI_FUNC(PyObject *) PyBytes_Repr(PyObject *, int);
44
+ PyAPI_FUNC(void) PyBytes_Concat(PyObject **, PyObject *);
45
+ PyAPI_FUNC(void) PyBytes_ConcatAndDel(PyObject **, PyObject *);
46
+ PyAPI_FUNC(PyObject *) PyBytes_DecodeEscape(const char *, Py_ssize_t,
47
+ const char *, Py_ssize_t,
48
+ const char *);
49
+
50
+ /* Provides access to the internal data buffer and size of a bytes object.
51
+ Passing NULL as len parameter will force the string buffer to be
52
+ 0-terminated (passing a string with embedded NUL characters will
53
+ cause an exception). */
54
+ PyAPI_FUNC(int) PyBytes_AsStringAndSize(
55
+ PyObject *obj, /* bytes object */
56
+ char **s, /* pointer to buffer variable */
57
+ Py_ssize_t *len /* pointer to length variable or NULL */
58
+ );
59
+
60
+ #ifndef Py_LIMITED_API
61
+ # define Py_CPYTHON_BYTESOBJECT_H
62
+ # include "cpython/bytesobject.h"
63
+ # undef Py_CPYTHON_BYTESOBJECT_H
64
+ #endif
65
+
66
+ #ifdef __cplusplus
67
+ }
68
+ #endif
69
+ #endif /* !Py_BYTESOBJECT_H */
llava_next/include/python3.10/code.h ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Definitions for bytecode */
2
+
3
+ #ifndef Py_CODE_H
4
+ #define Py_CODE_H
5
+ #ifdef __cplusplus
6
+ extern "C" {
7
+ #endif
8
+
9
+ typedef struct PyCodeObject PyCodeObject;
10
+
11
+ #ifndef Py_LIMITED_API
12
+ # define Py_CPYTHON_CODE_H
13
+ # include "cpython/code.h"
14
+ # undef Py_CPYTHON_CODE_H
15
+ #endif
16
+
17
+ #ifdef __cplusplus
18
+ }
19
+ #endif
20
+ #endif /* !Py_CODE_H */
llava_next/include/python3.10/codecs.h ADDED
@@ -0,0 +1,248 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_CODECREGISTRY_H
2
+ #define Py_CODECREGISTRY_H
3
+ #ifdef __cplusplus
4
+ extern "C" {
5
+ #endif
6
+
7
+ /* ------------------------------------------------------------------------
8
+
9
+ Python Codec Registry and support functions
10
+
11
+
12
+ Written by Marc-Andre Lemburg (mal@lemburg.com).
13
+
14
+ Copyright (c) Corporation for National Research Initiatives.
15
+
16
+ ------------------------------------------------------------------------ */
17
+
18
+ /* Register a new codec search function.
19
+
20
+ As side effect, this tries to load the encodings package, if not
21
+ yet done, to make sure that it is always first in the list of
22
+ search functions.
23
+
24
+ The search_function's refcount is incremented by this function. */
25
+
26
+ PyAPI_FUNC(int) PyCodec_Register(
27
+ PyObject *search_function
28
+ );
29
+
30
+ /* Unregister a codec search function and clear the registry's cache.
31
+ If the search function is not registered, do nothing.
32
+ Return 0 on success. Raise an exception and return -1 on error. */
33
+
34
+ PyAPI_FUNC(int) PyCodec_Unregister(
35
+ PyObject *search_function
36
+ );
37
+
38
+ /* Codec registry lookup API.
39
+
40
+ Looks up the given encoding and returns a CodecInfo object with
41
+ function attributes which implement the different aspects of
42
+ processing the encoding.
43
+
44
+ The encoding string is looked up converted to all lower-case
45
+ characters. This makes encodings looked up through this mechanism
46
+ effectively case-insensitive.
47
+
48
+ If no codec is found, a KeyError is set and NULL returned.
49
+
50
+ As side effect, this tries to load the encodings package, if not
51
+ yet done. This is part of the lazy load strategy for the encodings
52
+ package.
53
+
54
+ */
55
+
56
+ #ifndef Py_LIMITED_API
57
+ PyAPI_FUNC(PyObject *) _PyCodec_Lookup(
58
+ const char *encoding
59
+ );
60
+
61
+ PyAPI_FUNC(int) _PyCodec_Forget(
62
+ const char *encoding
63
+ );
64
+ #endif
65
+
66
+ /* Codec registry encoding check API.
67
+
68
+ Returns 1/0 depending on whether there is a registered codec for
69
+ the given encoding.
70
+
71
+ */
72
+
73
+ PyAPI_FUNC(int) PyCodec_KnownEncoding(
74
+ const char *encoding
75
+ );
76
+
77
+ /* Generic codec based encoding API.
78
+
79
+ object is passed through the encoder function found for the given
80
+ encoding using the error handling method defined by errors. errors
81
+ may be NULL to use the default method defined for the codec.
82
+
83
+ Raises a LookupError in case no encoder can be found.
84
+
85
+ */
86
+
87
+ PyAPI_FUNC(PyObject *) PyCodec_Encode(
88
+ PyObject *object,
89
+ const char *encoding,
90
+ const char *errors
91
+ );
92
+
93
+ /* Generic codec based decoding API.
94
+
95
+ object is passed through the decoder function found for the given
96
+ encoding using the error handling method defined by errors. errors
97
+ may be NULL to use the default method defined for the codec.
98
+
99
+ Raises a LookupError in case no encoder can be found.
100
+
101
+ */
102
+
103
+ PyAPI_FUNC(PyObject *) PyCodec_Decode(
104
+ PyObject *object,
105
+ const char *encoding,
106
+ const char *errors
107
+ );
108
+
109
+ #ifndef Py_LIMITED_API
110
+ /* Text codec specific encoding and decoding API.
111
+
112
+ Checks the encoding against a list of codecs which do not
113
+ implement a str<->bytes encoding before attempting the
114
+ operation.
115
+
116
+ Please note that these APIs are internal and should not
117
+ be used in Python C extensions.
118
+
119
+ XXX (ncoghlan): should we make these, or something like them, public
120
+ in Python 3.5+?
121
+
122
+ */
123
+ PyAPI_FUNC(PyObject *) _PyCodec_LookupTextEncoding(
124
+ const char *encoding,
125
+ const char *alternate_command
126
+ );
127
+
128
+ PyAPI_FUNC(PyObject *) _PyCodec_EncodeText(
129
+ PyObject *object,
130
+ const char *encoding,
131
+ const char *errors
132
+ );
133
+
134
+ PyAPI_FUNC(PyObject *) _PyCodec_DecodeText(
135
+ PyObject *object,
136
+ const char *encoding,
137
+ const char *errors
138
+ );
139
+
140
+ /* These two aren't actually text encoding specific, but _io.TextIOWrapper
141
+ * is the only current API consumer.
142
+ */
143
+ PyAPI_FUNC(PyObject *) _PyCodecInfo_GetIncrementalDecoder(
144
+ PyObject *codec_info,
145
+ const char *errors
146
+ );
147
+
148
+ PyAPI_FUNC(PyObject *) _PyCodecInfo_GetIncrementalEncoder(
149
+ PyObject *codec_info,
150
+ const char *errors
151
+ );
152
+ #endif
153
+
154
+
155
+
156
+ /* --- Codec Lookup APIs --------------------------------------------------
157
+
158
+ All APIs return a codec object with incremented refcount and are
159
+ based on _PyCodec_Lookup(). The same comments w/r to the encoding
160
+ name also apply to these APIs.
161
+
162
+ */
163
+
164
+ /* Get an encoder function for the given encoding. */
165
+
166
+ PyAPI_FUNC(PyObject *) PyCodec_Encoder(
167
+ const char *encoding
168
+ );
169
+
170
+ /* Get a decoder function for the given encoding. */
171
+
172
+ PyAPI_FUNC(PyObject *) PyCodec_Decoder(
173
+ const char *encoding
174
+ );
175
+
176
+ /* Get an IncrementalEncoder object for the given encoding. */
177
+
178
+ PyAPI_FUNC(PyObject *) PyCodec_IncrementalEncoder(
179
+ const char *encoding,
180
+ const char *errors
181
+ );
182
+
183
+ /* Get an IncrementalDecoder object function for the given encoding. */
184
+
185
+ PyAPI_FUNC(PyObject *) PyCodec_IncrementalDecoder(
186
+ const char *encoding,
187
+ const char *errors
188
+ );
189
+
190
+ /* Get a StreamReader factory function for the given encoding. */
191
+
192
+ PyAPI_FUNC(PyObject *) PyCodec_StreamReader(
193
+ const char *encoding,
194
+ PyObject *stream,
195
+ const char *errors
196
+ );
197
+
198
+ /* Get a StreamWriter factory function for the given encoding. */
199
+
200
+ PyAPI_FUNC(PyObject *) PyCodec_StreamWriter(
201
+ const char *encoding,
202
+ PyObject *stream,
203
+ const char *errors
204
+ );
205
+
206
+ /* Unicode encoding error handling callback registry API */
207
+
208
+ /* Register the error handling callback function error under the given
209
+ name. This function will be called by the codec when it encounters
210
+ unencodable characters/undecodable bytes and doesn't know the
211
+ callback name, when name is specified as the error parameter
212
+ in the call to the encode/decode function.
213
+ Return 0 on success, -1 on error */
214
+ PyAPI_FUNC(int) PyCodec_RegisterError(const char *name, PyObject *error);
215
+
216
+ /* Lookup the error handling callback function registered under the given
217
+ name. As a special case NULL can be passed, in which case
218
+ the error handling callback for "strict" will be returned. */
219
+ PyAPI_FUNC(PyObject *) PyCodec_LookupError(const char *name);
220
+
221
+ /* raise exc as an exception */
222
+ PyAPI_FUNC(PyObject *) PyCodec_StrictErrors(PyObject *exc);
223
+
224
+ /* ignore the unicode error, skipping the faulty input */
225
+ PyAPI_FUNC(PyObject *) PyCodec_IgnoreErrors(PyObject *exc);
226
+
227
+ /* replace the unicode encode error with ? or U+FFFD */
228
+ PyAPI_FUNC(PyObject *) PyCodec_ReplaceErrors(PyObject *exc);
229
+
230
+ /* replace the unicode encode error with XML character references */
231
+ PyAPI_FUNC(PyObject *) PyCodec_XMLCharRefReplaceErrors(PyObject *exc);
232
+
233
+ /* replace the unicode encode error with backslash escapes (\x, \u and \U) */
234
+ PyAPI_FUNC(PyObject *) PyCodec_BackslashReplaceErrors(PyObject *exc);
235
+
236
+ #if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
237
+ /* replace the unicode encode error with backslash escapes (\N, \x, \u and \U) */
238
+ PyAPI_FUNC(PyObject *) PyCodec_NameReplaceErrors(PyObject *exc);
239
+ #endif
240
+
241
+ #ifndef Py_LIMITED_API
242
+ PyAPI_DATA(const char *) Py_hexdigits;
243
+ #endif
244
+
245
+ #ifdef __cplusplus
246
+ }
247
+ #endif
248
+ #endif /* !Py_CODECREGISTRY_H */
llava_next/include/python3.10/compile.h ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_COMPILE_H
2
+ #define Py_COMPILE_H
3
+ #ifdef __cplusplus
4
+ extern "C" {
5
+ #endif
6
+
7
+ /* These definitions must match corresponding definitions in graminit.h. */
8
+ #define Py_single_input 256
9
+ #define Py_file_input 257
10
+ #define Py_eval_input 258
11
+ #define Py_func_type_input 345
12
+
13
+ /* This doesn't need to match anything */
14
+ #define Py_fstring_input 800
15
+
16
+ #ifndef Py_LIMITED_API
17
+ # define Py_CPYTHON_COMPILE_H
18
+ # include "cpython/compile.h"
19
+ # undef Py_CPYTHON_COMPILE_H
20
+ #endif
21
+
22
+ #ifdef __cplusplus
23
+ }
24
+ #endif
25
+ #endif /* !Py_COMPILE_H */
llava_next/include/python3.10/complexobject.h ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Complex number structure */
2
+
3
+ #ifndef Py_COMPLEXOBJECT_H
4
+ #define Py_COMPLEXOBJECT_H
5
+ #ifdef __cplusplus
6
+ extern "C" {
7
+ #endif
8
+
9
+ #ifndef Py_LIMITED_API
10
+ typedef struct {
11
+ double real;
12
+ double imag;
13
+ } Py_complex;
14
+
15
+ /* Operations on complex numbers from complexmodule.c */
16
+
17
+ PyAPI_FUNC(Py_complex) _Py_c_sum(Py_complex, Py_complex);
18
+ PyAPI_FUNC(Py_complex) _Py_c_diff(Py_complex, Py_complex);
19
+ PyAPI_FUNC(Py_complex) _Py_c_neg(Py_complex);
20
+ PyAPI_FUNC(Py_complex) _Py_c_prod(Py_complex, Py_complex);
21
+ PyAPI_FUNC(Py_complex) _Py_c_quot(Py_complex, Py_complex);
22
+ PyAPI_FUNC(Py_complex) _Py_c_pow(Py_complex, Py_complex);
23
+ PyAPI_FUNC(double) _Py_c_abs(Py_complex);
24
+ #endif
25
+
26
+ /* Complex object interface */
27
+
28
+ /*
29
+ PyComplexObject represents a complex number with double-precision
30
+ real and imaginary parts.
31
+ */
32
+ #ifndef Py_LIMITED_API
33
+ typedef struct {
34
+ PyObject_HEAD
35
+ Py_complex cval;
36
+ } PyComplexObject;
37
+ #endif
38
+
39
+ PyAPI_DATA(PyTypeObject) PyComplex_Type;
40
+
41
+ #define PyComplex_Check(op) PyObject_TypeCheck(op, &PyComplex_Type)
42
+ #define PyComplex_CheckExact(op) Py_IS_TYPE(op, &PyComplex_Type)
43
+
44
+ #ifndef Py_LIMITED_API
45
+ PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
46
+ #endif
47
+ PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag);
48
+
49
+ PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op);
50
+ PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op);
51
+ #ifndef Py_LIMITED_API
52
+ PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op);
53
+ #endif
54
+
55
+ /* Format the object based on the format_spec, as defined in PEP 3101
56
+ (Advanced String Formatting). */
57
+ #ifndef Py_LIMITED_API
58
+ PyAPI_FUNC(int) _PyComplex_FormatAdvancedWriter(
59
+ _PyUnicodeWriter *writer,
60
+ PyObject *obj,
61
+ PyObject *format_spec,
62
+ Py_ssize_t start,
63
+ Py_ssize_t end);
64
+ #endif
65
+
66
+ #ifdef __cplusplus
67
+ }
68
+ #endif
69
+ #endif /* !Py_COMPLEXOBJECT_H */
llava_next/include/python3.10/context.h ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_CONTEXT_H
2
+ #define Py_CONTEXT_H
3
+ #ifdef __cplusplus
4
+ extern "C" {
5
+ #endif
6
+
7
+ #ifndef Py_LIMITED_API
8
+
9
+
10
+ PyAPI_DATA(PyTypeObject) PyContext_Type;
11
+ typedef struct _pycontextobject PyContext;
12
+
13
+ PyAPI_DATA(PyTypeObject) PyContextVar_Type;
14
+ typedef struct _pycontextvarobject PyContextVar;
15
+
16
+ PyAPI_DATA(PyTypeObject) PyContextToken_Type;
17
+ typedef struct _pycontexttokenobject PyContextToken;
18
+
19
+
20
+ #define PyContext_CheckExact(o) Py_IS_TYPE(o, &PyContext_Type)
21
+ #define PyContextVar_CheckExact(o) Py_IS_TYPE(o, &PyContextVar_Type)
22
+ #define PyContextToken_CheckExact(o) Py_IS_TYPE(o, &PyContextToken_Type)
23
+
24
+
25
+ PyAPI_FUNC(PyObject *) PyContext_New(void);
26
+ PyAPI_FUNC(PyObject *) PyContext_Copy(PyObject *);
27
+ PyAPI_FUNC(PyObject *) PyContext_CopyCurrent(void);
28
+
29
+ PyAPI_FUNC(int) PyContext_Enter(PyObject *);
30
+ PyAPI_FUNC(int) PyContext_Exit(PyObject *);
31
+
32
+
33
+ /* Create a new context variable.
34
+
35
+ default_value can be NULL.
36
+ */
37
+ PyAPI_FUNC(PyObject *) PyContextVar_New(
38
+ const char *name, PyObject *default_value);
39
+
40
+
41
+ /* Get a value for the variable.
42
+
43
+ Returns -1 if an error occurred during lookup.
44
+
45
+ Returns 0 if value either was or was not found.
46
+
47
+ If value was found, *value will point to it.
48
+ If not, it will point to:
49
+
50
+ - default_value, if not NULL;
51
+ - the default value of "var", if not NULL;
52
+ - NULL.
53
+
54
+ '*value' will be a new ref, if not NULL.
55
+ */
56
+ PyAPI_FUNC(int) PyContextVar_Get(
57
+ PyObject *var, PyObject *default_value, PyObject **value);
58
+
59
+
60
+ /* Set a new value for the variable.
61
+ Returns NULL if an error occurs.
62
+ */
63
+ PyAPI_FUNC(PyObject *) PyContextVar_Set(PyObject *var, PyObject *value);
64
+
65
+
66
+ /* Reset a variable to its previous value.
67
+ Returns 0 on success, -1 on error.
68
+ */
69
+ PyAPI_FUNC(int) PyContextVar_Reset(PyObject *var, PyObject *token);
70
+
71
+
72
+ /* This method is exposed only for CPython tests. Don not use it. */
73
+ PyAPI_FUNC(PyObject *) _PyContext_NewHamtForTests(void);
74
+
75
+
76
+ #endif /* !Py_LIMITED_API */
77
+
78
+ #ifdef __cplusplus
79
+ }
80
+ #endif
81
+ #endif /* !Py_CONTEXT_H */
llava_next/include/python3.10/cpython/bytesobject.h ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_CPYTHON_BYTESOBJECT_H
2
+ # error "this header file must not be included directly"
3
+ #endif
4
+
5
+ typedef struct {
6
+ PyObject_VAR_HEAD
7
+ Py_hash_t ob_shash;
8
+ char ob_sval[1];
9
+
10
+ /* Invariants:
11
+ * ob_sval contains space for 'ob_size+1' elements.
12
+ * ob_sval[ob_size] == 0.
13
+ * ob_shash is the hash of the byte string or -1 if not computed yet.
14
+ */
15
+ } PyBytesObject;
16
+
17
+ PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, Py_ssize_t);
18
+ PyAPI_FUNC(PyObject*) _PyBytes_FormatEx(
19
+ const char *format,
20
+ Py_ssize_t format_len,
21
+ PyObject *args,
22
+ int use_bytearray);
23
+ PyAPI_FUNC(PyObject*) _PyBytes_FromHex(
24
+ PyObject *string,
25
+ int use_bytearray);
26
+
27
+ /* Helper for PyBytes_DecodeEscape that detects invalid escape chars. */
28
+ PyAPI_FUNC(PyObject *) _PyBytes_DecodeEscape(const char *, Py_ssize_t,
29
+ const char *, const char **);
30
+
31
+ /* Macro, trading safety for speed */
32
+ #define PyBytes_AS_STRING(op) (assert(PyBytes_Check(op)), \
33
+ (((PyBytesObject *)(op))->ob_sval))
34
+ #define PyBytes_GET_SIZE(op) (assert(PyBytes_Check(op)),Py_SIZE(op))
35
+
36
+ /* _PyBytes_Join(sep, x) is like sep.join(x). sep must be PyBytesObject*,
37
+ x must be an iterable object. */
38
+ PyAPI_FUNC(PyObject *) _PyBytes_Join(PyObject *sep, PyObject *x);
39
+
40
+
41
+ /* The _PyBytesWriter structure is big: it contains an embedded "stack buffer".
42
+ A _PyBytesWriter variable must be declared at the end of variables in a
43
+ function to optimize the memory allocation on the stack. */
44
+ typedef struct {
45
+ /* bytes, bytearray or NULL (when the small buffer is used) */
46
+ PyObject *buffer;
47
+
48
+ /* Number of allocated size. */
49
+ Py_ssize_t allocated;
50
+
51
+ /* Minimum number of allocated bytes,
52
+ incremented by _PyBytesWriter_Prepare() */
53
+ Py_ssize_t min_size;
54
+
55
+ /* If non-zero, use a bytearray instead of a bytes object for buffer. */
56
+ int use_bytearray;
57
+
58
+ /* If non-zero, overallocate the buffer (default: 0).
59
+ This flag must be zero if use_bytearray is non-zero. */
60
+ int overallocate;
61
+
62
+ /* Stack buffer */
63
+ int use_small_buffer;
64
+ char small_buffer[512];
65
+ } _PyBytesWriter;
66
+
67
+ /* Initialize a bytes writer
68
+
69
+ By default, the overallocation is disabled. Set the overallocate attribute
70
+ to control the allocation of the buffer. */
71
+ PyAPI_FUNC(void) _PyBytesWriter_Init(_PyBytesWriter *writer);
72
+
73
+ /* Get the buffer content and reset the writer.
74
+ Return a bytes object, or a bytearray object if use_bytearray is non-zero.
75
+ Raise an exception and return NULL on error. */
76
+ PyAPI_FUNC(PyObject *) _PyBytesWriter_Finish(_PyBytesWriter *writer,
77
+ void *str);
78
+
79
+ /* Deallocate memory of a writer (clear its internal buffer). */
80
+ PyAPI_FUNC(void) _PyBytesWriter_Dealloc(_PyBytesWriter *writer);
81
+
82
+ /* Allocate the buffer to write size bytes.
83
+ Return the pointer to the beginning of buffer data.
84
+ Raise an exception and return NULL on error. */
85
+ PyAPI_FUNC(void*) _PyBytesWriter_Alloc(_PyBytesWriter *writer,
86
+ Py_ssize_t size);
87
+
88
+ /* Ensure that the buffer is large enough to write *size* bytes.
89
+ Add size to the writer minimum size (min_size attribute).
90
+
91
+ str is the current pointer inside the buffer.
92
+ Return the updated current pointer inside the buffer.
93
+ Raise an exception and return NULL on error. */
94
+ PyAPI_FUNC(void*) _PyBytesWriter_Prepare(_PyBytesWriter *writer,
95
+ void *str,
96
+ Py_ssize_t size);
97
+
98
+ /* Resize the buffer to make it larger.
99
+ The new buffer may be larger than size bytes because of overallocation.
100
+ Return the updated current pointer inside the buffer.
101
+ Raise an exception and return NULL on error.
102
+
103
+ Note: size must be greater than the number of allocated bytes in the writer.
104
+
105
+ This function doesn't use the writer minimum size (min_size attribute).
106
+
107
+ See also _PyBytesWriter_Prepare().
108
+ */
109
+ PyAPI_FUNC(void*) _PyBytesWriter_Resize(_PyBytesWriter *writer,
110
+ void *str,
111
+ Py_ssize_t size);
112
+
113
+ /* Write bytes.
114
+ Raise an exception and return NULL on error. */
115
+ PyAPI_FUNC(void*) _PyBytesWriter_WriteBytes(_PyBytesWriter *writer,
116
+ void *str,
117
+ const void *bytes,
118
+ Py_ssize_t size);
llava_next/include/python3.10/cpython/ceval.h ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_CPYTHON_CEVAL_H
2
+ # error "this header file must not be included directly"
3
+ #endif
4
+
5
+ PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
6
+ PyAPI_DATA(int) _PyEval_SetProfile(PyThreadState *tstate, Py_tracefunc func, PyObject *arg);
7
+ PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
8
+ PyAPI_FUNC(int) _PyEval_SetTrace(PyThreadState *tstate, Py_tracefunc func, PyObject *arg);
9
+ PyAPI_FUNC(int) _PyEval_GetCoroutineOriginTrackingDepth(void);
10
+ PyAPI_FUNC(int) _PyEval_SetAsyncGenFirstiter(PyObject *);
11
+ PyAPI_FUNC(PyObject *) _PyEval_GetAsyncGenFirstiter(void);
12
+ PyAPI_FUNC(int) _PyEval_SetAsyncGenFinalizer(PyObject *);
13
+ PyAPI_FUNC(PyObject *) _PyEval_GetAsyncGenFinalizer(void);
14
+
15
+ /* Helper to look up a builtin object */
16
+ PyAPI_FUNC(PyObject *) _PyEval_GetBuiltinId(_Py_Identifier *);
17
+ /* Look at the current frame's (if any) code's co_flags, and turn on
18
+ the corresponding compiler flags in cf->cf_flags. Return 1 if any
19
+ flag was set, else return 0. */
20
+ PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf);
21
+
22
+ PyAPI_FUNC(PyObject *) _PyEval_EvalFrameDefault(PyThreadState *tstate, PyFrameObject *f, int exc);
23
+
24
+ PyAPI_FUNC(void) _PyEval_SetSwitchInterval(unsigned long microseconds);
25
+ PyAPI_FUNC(unsigned long) _PyEval_GetSwitchInterval(void);
26
+
27
+ PyAPI_FUNC(Py_ssize_t) _PyEval_RequestCodeExtraIndex(freefunc);
28
+
29
+ PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *);
30
+ PyAPI_FUNC(int) _PyEval_SliceIndexNotNone(PyObject *, Py_ssize_t *);
llava_next/include/python3.10/cpython/code.h ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_CPYTHON_CODE_H
2
+ # error "this header file must not be included directly"
3
+ #endif
4
+
5
+ typedef uint16_t _Py_CODEUNIT;
6
+
7
+ #ifdef WORDS_BIGENDIAN
8
+ # define _Py_OPCODE(word) ((word) >> 8)
9
+ # define _Py_OPARG(word) ((word) & 255)
10
+ #else
11
+ # define _Py_OPCODE(word) ((word) & 255)
12
+ # define _Py_OPARG(word) ((word) >> 8)
13
+ #endif
14
+
15
+ typedef struct _PyOpcache _PyOpcache;
16
+
17
+ /* Bytecode object */
18
+ struct PyCodeObject {
19
+ PyObject_HEAD
20
+ int co_argcount; /* #arguments, except *args */
21
+ int co_posonlyargcount; /* #positional only arguments */
22
+ int co_kwonlyargcount; /* #keyword only arguments */
23
+ int co_nlocals; /* #local variables */
24
+ int co_stacksize; /* #entries needed for evaluation stack */
25
+ int co_flags; /* CO_..., see below */
26
+ int co_firstlineno; /* first source line number */
27
+ PyObject *co_code; /* instruction opcodes */
28
+ PyObject *co_consts; /* list (constants used) */
29
+ PyObject *co_names; /* list of strings (names used) */
30
+ PyObject *co_varnames; /* tuple of strings (local variable names) */
31
+ PyObject *co_freevars; /* tuple of strings (free variable names) */
32
+ PyObject *co_cellvars; /* tuple of strings (cell variable names) */
33
+ /* The rest aren't used in either hash or comparisons, except for co_name,
34
+ used in both. This is done to preserve the name and line number
35
+ for tracebacks and debuggers; otherwise, constant de-duplication
36
+ would collapse identical functions/lambdas defined on different lines.
37
+ */
38
+ Py_ssize_t *co_cell2arg; /* Maps cell vars which are arguments. */
39
+ PyObject *co_filename; /* unicode (where it was loaded from) */
40
+ PyObject *co_name; /* unicode (name, for reference) */
41
+ PyObject *co_linetable; /* string (encoding addr<->lineno mapping) See
42
+ Objects/lnotab_notes.txt for details. */
43
+ void *co_zombieframe; /* for optimization only (see frameobject.c) */
44
+ PyObject *co_weakreflist; /* to support weakrefs to code objects */
45
+ /* Scratch space for extra data relating to the code object.
46
+ Type is a void* to keep the format private in codeobject.c to force
47
+ people to go through the proper APIs. */
48
+ void *co_extra;
49
+
50
+ /* Per opcodes just-in-time cache
51
+ *
52
+ * To reduce cache size, we use indirect mapping from opcode index to
53
+ * cache object:
54
+ * cache = co_opcache[co_opcache_map[next_instr - first_instr] - 1]
55
+ */
56
+
57
+ // co_opcache_map is indexed by (next_instr - first_instr).
58
+ // * 0 means there is no cache for this opcode.
59
+ // * n > 0 means there is cache in co_opcache[n-1].
60
+ unsigned char *co_opcache_map;
61
+ _PyOpcache *co_opcache;
62
+ int co_opcache_flag; // used to determine when create a cache.
63
+ unsigned char co_opcache_size; // length of co_opcache.
64
+ };
65
+
66
+ /* Masks for co_flags above */
67
+ #define CO_OPTIMIZED 0x0001
68
+ #define CO_NEWLOCALS 0x0002
69
+ #define CO_VARARGS 0x0004
70
+ #define CO_VARKEYWORDS 0x0008
71
+ #define CO_NESTED 0x0010
72
+ #define CO_GENERATOR 0x0020
73
+ /* The CO_NOFREE flag is set if there are no free or cell variables.
74
+ This information is redundant, but it allows a single flag test
75
+ to determine whether there is any extra work to be done when the
76
+ call frame it setup.
77
+ */
78
+ #define CO_NOFREE 0x0040
79
+
80
+ /* The CO_COROUTINE flag is set for coroutine functions (defined with
81
+ ``async def`` keywords) */
82
+ #define CO_COROUTINE 0x0080
83
+ #define CO_ITERABLE_COROUTINE 0x0100
84
+ #define CO_ASYNC_GENERATOR 0x0200
85
+
86
+ /* bpo-39562: These constant values are changed in Python 3.9
87
+ to prevent collision with compiler flags. CO_FUTURE_ and PyCF_
88
+ constants must be kept unique. PyCF_ constants can use bits from
89
+ 0x0100 to 0x10000. CO_FUTURE_ constants use bits starting at 0x20000. */
90
+ #define CO_FUTURE_DIVISION 0x20000
91
+ #define CO_FUTURE_ABSOLUTE_IMPORT 0x40000 /* do absolute imports by default */
92
+ #define CO_FUTURE_WITH_STATEMENT 0x80000
93
+ #define CO_FUTURE_PRINT_FUNCTION 0x100000
94
+ #define CO_FUTURE_UNICODE_LITERALS 0x200000
95
+
96
+ #define CO_FUTURE_BARRY_AS_BDFL 0x400000
97
+ #define CO_FUTURE_GENERATOR_STOP 0x800000
98
+ #define CO_FUTURE_ANNOTATIONS 0x1000000
99
+
100
+ /* This value is found in the co_cell2arg array when the associated cell
101
+ variable does not correspond to an argument. */
102
+ #define CO_CELL_NOT_AN_ARG (-1)
103
+
104
+ /* This should be defined if a future statement modifies the syntax.
105
+ For example, when a keyword is added.
106
+ */
107
+ #define PY_PARSER_REQUIRES_FUTURE_KEYWORD
108
+
109
+ #define CO_MAXBLOCKS 20 /* Max static block nesting within a function */
110
+
111
+ PyAPI_DATA(PyTypeObject) PyCode_Type;
112
+
113
+ #define PyCode_Check(op) Py_IS_TYPE(op, &PyCode_Type)
114
+ #define PyCode_GetNumFree(op) (PyTuple_GET_SIZE((op)->co_freevars))
115
+
116
+ /* Public interface */
117
+ PyAPI_FUNC(PyCodeObject *) PyCode_New(
118
+ int, int, int, int, int, PyObject *, PyObject *,
119
+ PyObject *, PyObject *, PyObject *, PyObject *,
120
+ PyObject *, PyObject *, int, PyObject *);
121
+
122
+ PyAPI_FUNC(PyCodeObject *) PyCode_NewWithPosOnlyArgs(
123
+ int, int, int, int, int, int, PyObject *, PyObject *,
124
+ PyObject *, PyObject *, PyObject *, PyObject *,
125
+ PyObject *, PyObject *, int, PyObject *);
126
+ /* same as struct above */
127
+
128
+ /* Creates a new empty code object with the specified source location. */
129
+ PyAPI_FUNC(PyCodeObject *)
130
+ PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno);
131
+
132
+ /* Return the line number associated with the specified bytecode index
133
+ in this code object. If you just need the line number of a frame,
134
+ use PyFrame_GetLineNumber() instead. */
135
+ PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int);
136
+
137
+ /* for internal use only */
138
+ struct _opaque {
139
+ int computed_line;
140
+ const char *lo_next;
141
+ const char *limit;
142
+ };
143
+
144
+ typedef struct _line_offsets {
145
+ int ar_start;
146
+ int ar_end;
147
+ int ar_line;
148
+ struct _opaque opaque;
149
+ } PyCodeAddressRange;
150
+
151
+ /* Update *bounds to describe the first and one-past-the-last instructions in the
152
+ same line as lasti. Return the number of that line.
153
+ */
154
+ PyAPI_FUNC(int) _PyCode_CheckLineNumber(int lasti, PyCodeAddressRange *bounds);
155
+
156
+ /* Create a comparable key used to compare constants taking in account the
157
+ * object type. It is used to make sure types are not coerced (e.g., float and
158
+ * complex) _and_ to distinguish 0.0 from -0.0 e.g. on IEEE platforms
159
+ *
160
+ * Return (type(obj), obj, ...): a tuple with variable size (at least 2 items)
161
+ * depending on the type and the value. The type is the first item to not
162
+ * compare bytes and str which can raise a BytesWarning exception. */
163
+ PyAPI_FUNC(PyObject*) _PyCode_ConstantKey(PyObject *obj);
164
+
165
+ PyAPI_FUNC(PyObject*) PyCode_Optimize(PyObject *code, PyObject* consts,
166
+ PyObject *names, PyObject *lnotab);
167
+
168
+
169
+ PyAPI_FUNC(int) _PyCode_GetExtra(PyObject *code, Py_ssize_t index,
170
+ void **extra);
171
+ PyAPI_FUNC(int) _PyCode_SetExtra(PyObject *code, Py_ssize_t index,
172
+ void *extra);
173
+
174
+ /** API for initializing the line number table. */
175
+ int _PyCode_InitAddressRange(PyCodeObject* co, PyCodeAddressRange *bounds);
176
+
177
+ /** Out of process API for initializing the line number table. */
178
+ void PyLineTable_InitAddressRange(const char *linetable, Py_ssize_t length, int firstlineno, PyCodeAddressRange *range);
179
+
180
+ /** API for traversing the line number table. */
181
+ int PyLineTable_NextAddressRange(PyCodeAddressRange *range);
182
+ int PyLineTable_PreviousAddressRange(PyCodeAddressRange *range);
183
+
184
+
llava_next/include/python3.10/cpython/compile.h ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_CPYTHON_COMPILE_H
2
+ # error "this header file must not be included directly"
3
+ #endif
4
+
5
+ /* Public interface */
6
+ #define PyCF_MASK (CO_FUTURE_DIVISION | CO_FUTURE_ABSOLUTE_IMPORT | \
7
+ CO_FUTURE_WITH_STATEMENT | CO_FUTURE_PRINT_FUNCTION | \
8
+ CO_FUTURE_UNICODE_LITERALS | CO_FUTURE_BARRY_AS_BDFL | \
9
+ CO_FUTURE_GENERATOR_STOP | CO_FUTURE_ANNOTATIONS)
10
+ #define PyCF_MASK_OBSOLETE (CO_NESTED)
11
+
12
+ /* bpo-39562: CO_FUTURE_ and PyCF_ constants must be kept unique.
13
+ PyCF_ constants can use bits from 0x0100 to 0x10000.
14
+ CO_FUTURE_ constants use bits starting at 0x20000. */
15
+ #define PyCF_SOURCE_IS_UTF8 0x0100
16
+ #define PyCF_DONT_IMPLY_DEDENT 0x0200
17
+ #define PyCF_ONLY_AST 0x0400
18
+ #define PyCF_IGNORE_COOKIE 0x0800
19
+ #define PyCF_TYPE_COMMENTS 0x1000
20
+ #define PyCF_ALLOW_TOP_LEVEL_AWAIT 0x2000
21
+ #define PyCF_ALLOW_INCOMPLETE_INPUT 0x4000
22
+ #define PyCF_COMPILE_MASK (PyCF_ONLY_AST | PyCF_ALLOW_TOP_LEVEL_AWAIT | \
23
+ PyCF_TYPE_COMMENTS | PyCF_DONT_IMPLY_DEDENT | \
24
+ PyCF_ALLOW_INCOMPLETE_INPUT)
25
+
26
+ typedef struct {
27
+ int cf_flags; /* bitmask of CO_xxx flags relevant to future */
28
+ int cf_feature_version; /* minor Python version (PyCF_ONLY_AST) */
29
+ } PyCompilerFlags;
30
+
31
+ #define _PyCompilerFlags_INIT \
32
+ (PyCompilerFlags){.cf_flags = 0, .cf_feature_version = PY_MINOR_VERSION}
33
+
34
+ /* Future feature support */
35
+
36
+ typedef struct {
37
+ int ff_features; /* flags set by future statements */
38
+ int ff_lineno; /* line number of last future statement */
39
+ } PyFutureFeatures;
40
+
41
+ #define FUTURE_NESTED_SCOPES "nested_scopes"
42
+ #define FUTURE_GENERATORS "generators"
43
+ #define FUTURE_DIVISION "division"
44
+ #define FUTURE_ABSOLUTE_IMPORT "absolute_import"
45
+ #define FUTURE_WITH_STATEMENT "with_statement"
46
+ #define FUTURE_PRINT_FUNCTION "print_function"
47
+ #define FUTURE_UNICODE_LITERALS "unicode_literals"
48
+ #define FUTURE_BARRY_AS_BDFL "barry_as_FLUFL"
49
+ #define FUTURE_GENERATOR_STOP "generator_stop"
50
+ #define FUTURE_ANNOTATIONS "annotations"
51
+
52
+ #define PY_INVALID_STACK_EFFECT INT_MAX
53
+ PyAPI_FUNC(int) PyCompile_OpcodeStackEffect(int opcode, int oparg);
54
+ PyAPI_FUNC(int) PyCompile_OpcodeStackEffectWithJump(int opcode, int oparg, int jump);
llava_next/include/python3.10/cpython/dictobject.h ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_CPYTHON_DICTOBJECT_H
2
+ # error "this header file must not be included directly"
3
+ #endif
4
+
5
+ typedef struct _dictkeysobject PyDictKeysObject;
6
+
7
+ /* The ma_values pointer is NULL for a combined table
8
+ * or points to an array of PyObject* for a split table
9
+ */
10
+ typedef struct {
11
+ PyObject_HEAD
12
+
13
+ /* Number of items in the dictionary */
14
+ Py_ssize_t ma_used;
15
+
16
+ /* Dictionary version: globally unique, value change each time
17
+ the dictionary is modified */
18
+ uint64_t ma_version_tag;
19
+
20
+ PyDictKeysObject *ma_keys;
21
+
22
+ /* If ma_values is NULL, the table is "combined": keys and values
23
+ are stored in ma_keys.
24
+
25
+ If ma_values is not NULL, the table is split:
26
+ keys are stored in ma_keys and values are stored in ma_values */
27
+ PyObject **ma_values;
28
+ } PyDictObject;
29
+
30
+ PyAPI_FUNC(PyObject *) _PyDict_GetItem_KnownHash(PyObject *mp, PyObject *key,
31
+ Py_hash_t hash);
32
+ PyAPI_FUNC(PyObject *) _PyDict_GetItemIdWithError(PyObject *dp,
33
+ struct _Py_Identifier *key);
34
+ PyAPI_FUNC(PyObject *) _PyDict_GetItemStringWithError(PyObject *, const char *);
35
+ PyAPI_FUNC(PyObject *) PyDict_SetDefault(
36
+ PyObject *mp, PyObject *key, PyObject *defaultobj);
37
+ PyAPI_FUNC(int) _PyDict_SetItem_KnownHash(PyObject *mp, PyObject *key,
38
+ PyObject *item, Py_hash_t hash);
39
+ PyAPI_FUNC(int) _PyDict_DelItem_KnownHash(PyObject *mp, PyObject *key,
40
+ Py_hash_t hash);
41
+ PyAPI_FUNC(int) _PyDict_DelItemIf(PyObject *mp, PyObject *key,
42
+ int (*predicate)(PyObject *value));
43
+ PyDictKeysObject *_PyDict_NewKeysForClass(void);
44
+ PyAPI_FUNC(int) _PyDict_Next(
45
+ PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, Py_hash_t *hash);
46
+
47
+ /* Get the number of items of a dictionary. */
48
+ #define PyDict_GET_SIZE(mp) (assert(PyDict_Check(mp)),((PyDictObject *)mp)->ma_used)
49
+ PyAPI_FUNC(int) _PyDict_Contains_KnownHash(PyObject *, PyObject *, Py_hash_t);
50
+ PyAPI_FUNC(int) _PyDict_ContainsId(PyObject *, struct _Py_Identifier *);
51
+ PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused);
52
+ PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp);
53
+ PyAPI_FUNC(int) _PyDict_HasOnlyStringKeys(PyObject *mp);
54
+ Py_ssize_t _PyDict_KeysSize(PyDictKeysObject *keys);
55
+ PyAPI_FUNC(Py_ssize_t) _PyDict_SizeOf(PyDictObject *);
56
+ PyAPI_FUNC(PyObject *) _PyDict_Pop(PyObject *, PyObject *, PyObject *);
57
+ PyObject *_PyDict_Pop_KnownHash(PyObject *, PyObject *, Py_hash_t, PyObject *);
58
+ PyObject *_PyDict_FromKeys(PyObject *, PyObject *, PyObject *);
59
+ #define _PyDict_HasSplitTable(d) ((d)->ma_values != NULL)
60
+
61
+ /* Like PyDict_Merge, but override can be 0, 1 or 2. If override is 0,
62
+ the first occurrence of a key wins, if override is 1, the last occurrence
63
+ of a key wins, if override is 2, a KeyError with conflicting key as
64
+ argument is raised.
65
+ */
66
+ PyAPI_FUNC(int) _PyDict_MergeEx(PyObject *mp, PyObject *other, int override);
67
+ PyAPI_FUNC(int) _PyDict_SetItemId(PyObject *dp, struct _Py_Identifier *key, PyObject *item);
68
+
69
+ PyAPI_FUNC(int) _PyDict_DelItemId(PyObject *mp, struct _Py_Identifier *key);
70
+ PyAPI_FUNC(void) _PyDict_DebugMallocStats(FILE *out);
71
+
72
+ int _PyObjectDict_SetItem(PyTypeObject *tp, PyObject **dictptr, PyObject *name, PyObject *value);
73
+ PyObject *_PyDict_LoadGlobal(PyDictObject *, PyDictObject *, PyObject *);
74
+ Py_ssize_t _PyDict_GetItemHint(PyDictObject *, PyObject *, Py_ssize_t, PyObject **);
75
+
76
+ /* _PyDictView */
77
+
78
+ typedef struct {
79
+ PyObject_HEAD
80
+ PyDictObject *dv_dict;
81
+ } _PyDictViewObject;
82
+
83
+ PyAPI_FUNC(PyObject *) _PyDictView_New(PyObject *, PyTypeObject *);
84
+ PyAPI_FUNC(PyObject *) _PyDictView_Intersect(PyObject* self, PyObject *other);
llava_next/include/python3.10/cpython/fileobject.h ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_CPYTHON_FILEOBJECT_H
2
+ # error "this header file must not be included directly"
3
+ #endif
4
+
5
+ PyAPI_FUNC(char *) Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *);
6
+
7
+ /* The std printer acts as a preliminary sys.stderr until the new io
8
+ infrastructure is in place. */
9
+ PyAPI_FUNC(PyObject *) PyFile_NewStdPrinter(int);
10
+ PyAPI_DATA(PyTypeObject) PyStdPrinter_Type;
11
+
12
+ typedef PyObject * (*Py_OpenCodeHookFunction)(PyObject *, void *);
13
+
14
+ PyAPI_FUNC(PyObject *) PyFile_OpenCode(const char *utf8path);
15
+ PyAPI_FUNC(PyObject *) PyFile_OpenCodeObject(PyObject *path);
16
+ PyAPI_FUNC(int) PyFile_SetOpenCodeHook(Py_OpenCodeHookFunction hook, void *userData);
17
+
18
+ PyAPI_FUNC(int) _PyLong_FileDescriptor_Converter(PyObject *, void *);
llava_next/include/python3.10/cpython/fileutils.h ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_CPYTHON_FILEUTILS_H
2
+ # error "this header file must not be included directly"
3
+ #endif
4
+
5
+ typedef enum {
6
+ _Py_ERROR_UNKNOWN=0,
7
+ _Py_ERROR_STRICT,
8
+ _Py_ERROR_SURROGATEESCAPE,
9
+ _Py_ERROR_REPLACE,
10
+ _Py_ERROR_IGNORE,
11
+ _Py_ERROR_BACKSLASHREPLACE,
12
+ _Py_ERROR_SURROGATEPASS,
13
+ _Py_ERROR_XMLCHARREFREPLACE,
14
+ _Py_ERROR_OTHER
15
+ } _Py_error_handler;
16
+
17
+ PyAPI_FUNC(_Py_error_handler) _Py_GetErrorHandler(const char *errors);
18
+
19
+ PyAPI_FUNC(int) _Py_DecodeLocaleEx(
20
+ const char *arg,
21
+ wchar_t **wstr,
22
+ size_t *wlen,
23
+ const char **reason,
24
+ int current_locale,
25
+ _Py_error_handler errors);
26
+
27
+ PyAPI_FUNC(int) _Py_EncodeLocaleEx(
28
+ const wchar_t *text,
29
+ char **str,
30
+ size_t *error_pos,
31
+ const char **reason,
32
+ int current_locale,
33
+ _Py_error_handler errors);
34
+
35
+ PyAPI_FUNC(char*) _Py_EncodeLocaleRaw(
36
+ const wchar_t *text,
37
+ size_t *error_pos);
38
+
39
+ PyAPI_FUNC(PyObject *) _Py_device_encoding(int);
40
+
41
+ #if defined(MS_WINDOWS) || defined(__APPLE__)
42
+ /* On Windows, the count parameter of read() is an int (bpo-9015, bpo-9611).
43
+ On macOS 10.13, read() and write() with more than INT_MAX bytes
44
+ fail with EINVAL (bpo-24658). */
45
+ # define _PY_READ_MAX INT_MAX
46
+ # define _PY_WRITE_MAX INT_MAX
47
+ #else
48
+ /* write() should truncate the input to PY_SSIZE_T_MAX bytes,
49
+ but it's safer to do it ourself to have a portable behaviour */
50
+ # define _PY_READ_MAX PY_SSIZE_T_MAX
51
+ # define _PY_WRITE_MAX PY_SSIZE_T_MAX
52
+ #endif
53
+
54
+ #ifdef MS_WINDOWS
55
+ struct _Py_stat_struct {
56
+ unsigned long st_dev;
57
+ uint64_t st_ino;
58
+ unsigned short st_mode;
59
+ int st_nlink;
60
+ int st_uid;
61
+ int st_gid;
62
+ unsigned long st_rdev;
63
+ __int64 st_size;
64
+ time_t st_atime;
65
+ int st_atime_nsec;
66
+ time_t st_mtime;
67
+ int st_mtime_nsec;
68
+ time_t st_ctime;
69
+ int st_ctime_nsec;
70
+ unsigned long st_file_attributes;
71
+ unsigned long st_reparse_tag;
72
+ };
73
+ #else
74
+ # define _Py_stat_struct stat
75
+ #endif
76
+
77
+ PyAPI_FUNC(int) _Py_fstat(
78
+ int fd,
79
+ struct _Py_stat_struct *status);
80
+
81
+ PyAPI_FUNC(int) _Py_fstat_noraise(
82
+ int fd,
83
+ struct _Py_stat_struct *status);
84
+
85
+ PyAPI_FUNC(int) _Py_stat(
86
+ PyObject *path,
87
+ struct stat *status);
88
+
89
+ PyAPI_FUNC(int) _Py_open(
90
+ const char *pathname,
91
+ int flags);
92
+
93
+ PyAPI_FUNC(int) _Py_open_noraise(
94
+ const char *pathname,
95
+ int flags);
96
+
97
+ PyAPI_FUNC(FILE *) _Py_wfopen(
98
+ const wchar_t *path,
99
+ const wchar_t *mode);
100
+
101
+ PyAPI_FUNC(FILE*) _Py_fopen_obj(
102
+ PyObject *path,
103
+ const char *mode);
104
+
105
+ PyAPI_FUNC(Py_ssize_t) _Py_read(
106
+ int fd,
107
+ void *buf,
108
+ size_t count);
109
+
110
+ PyAPI_FUNC(Py_ssize_t) _Py_write(
111
+ int fd,
112
+ const void *buf,
113
+ size_t count);
114
+
115
+ PyAPI_FUNC(Py_ssize_t) _Py_write_noraise(
116
+ int fd,
117
+ const void *buf,
118
+ size_t count);
119
+
120
+ #ifdef HAVE_READLINK
121
+ PyAPI_FUNC(int) _Py_wreadlink(
122
+ const wchar_t *path,
123
+ wchar_t *buf,
124
+ /* Number of characters of 'buf' buffer
125
+ including the trailing NUL character */
126
+ size_t buflen);
127
+ #endif
128
+
129
+ #ifdef HAVE_REALPATH
130
+ PyAPI_FUNC(wchar_t*) _Py_wrealpath(
131
+ const wchar_t *path,
132
+ wchar_t *resolved_path,
133
+ /* Number of characters of 'resolved_path' buffer
134
+ including the trailing NUL character */
135
+ size_t resolved_path_len);
136
+ #endif
137
+
138
+ #ifndef MS_WINDOWS
139
+ PyAPI_FUNC(int) _Py_isabs(const wchar_t *path);
140
+ #endif
141
+
142
+ PyAPI_FUNC(int) _Py_abspath(const wchar_t *path, wchar_t **abspath_p);
143
+
144
+ PyAPI_FUNC(wchar_t*) _Py_wgetcwd(
145
+ wchar_t *buf,
146
+ /* Number of characters of 'buf' buffer
147
+ including the trailing NUL character */
148
+ size_t buflen);
149
+
150
+ PyAPI_FUNC(int) _Py_get_inheritable(int fd);
151
+
152
+ PyAPI_FUNC(int) _Py_set_inheritable(int fd, int inheritable,
153
+ int *atomic_flag_works);
154
+
155
+ PyAPI_FUNC(int) _Py_set_inheritable_async_safe(int fd, int inheritable,
156
+ int *atomic_flag_works);
157
+
158
+ PyAPI_FUNC(int) _Py_dup(int fd);
159
+
160
+ #ifndef MS_WINDOWS
161
+ PyAPI_FUNC(int) _Py_get_blocking(int fd);
162
+
163
+ PyAPI_FUNC(int) _Py_set_blocking(int fd, int blocking);
164
+ #else /* MS_WINDOWS */
165
+ PyAPI_FUNC(void*) _Py_get_osfhandle_noraise(int fd);
166
+
167
+ PyAPI_FUNC(void*) _Py_get_osfhandle(int fd);
168
+
169
+ PyAPI_FUNC(int) _Py_open_osfhandle_noraise(void *handle, int flags);
170
+
171
+ PyAPI_FUNC(int) _Py_open_osfhandle(void *handle, int flags);
172
+ #endif /* MS_WINDOWS */
llava_next/include/python3.10/cpython/import.h ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_CPYTHON_IMPORT_H
2
+ # error "this header file must not be included directly"
3
+ #endif
4
+
5
+ PyMODINIT_FUNC PyInit__imp(void);
6
+
7
+ PyAPI_FUNC(int) _PyImport_IsInitialized(PyInterpreterState *);
8
+
9
+ PyAPI_FUNC(PyObject *) _PyImport_GetModuleId(struct _Py_Identifier *name);
10
+ PyAPI_FUNC(int) _PyImport_SetModule(PyObject *name, PyObject *module);
11
+ PyAPI_FUNC(int) _PyImport_SetModuleString(const char *name, PyObject* module);
12
+
13
+ PyAPI_FUNC(void) _PyImport_AcquireLock(void);
14
+ PyAPI_FUNC(int) _PyImport_ReleaseLock(void);
15
+
16
+ /* Obsolete since 3.5, will be removed in 3.11. */
17
+ Py_DEPRECATED(3.10) PyAPI_FUNC(PyObject *) _PyImport_FindExtensionObject(PyObject *, PyObject *);
18
+
19
+ PyAPI_FUNC(int) _PyImport_FixupBuiltin(
20
+ PyObject *mod,
21
+ const char *name, /* UTF-8 encoded string */
22
+ PyObject *modules
23
+ );
24
+ PyAPI_FUNC(int) _PyImport_FixupExtensionObject(PyObject*, PyObject *,
25
+ PyObject *, PyObject *);
26
+
27
+ struct _inittab {
28
+ const char *name; /* ASCII encoded string */
29
+ PyObject* (*initfunc)(void);
30
+ };
31
+ PyAPI_DATA(struct _inittab *) PyImport_Inittab;
32
+ PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab);
33
+
34
+ struct _frozen {
35
+ const char *name; /* ASCII encoded string */
36
+ const unsigned char *code;
37
+ int size;
38
+ };
39
+
40
+ /* Embedding apps may change this pointer to point to their favorite
41
+ collection of frozen modules: */
42
+
43
+ PyAPI_DATA(const struct _frozen *) PyImport_FrozenModules;
44
+
45
+ PyAPI_DATA(PyObject *) _PyImport_GetModuleAttr(PyObject *, PyObject *);
46
+ PyAPI_DATA(PyObject *) _PyImport_GetModuleAttrString(const char *, const char *);
llava_next/include/python3.10/cpython/interpreteridobject.h ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_CPYTHON_INTERPRETERIDOBJECT_H
2
+ # error "this header file must not be included directly"
3
+ #endif
4
+
5
+ /* Interpreter ID Object */
6
+
7
+ PyAPI_DATA(PyTypeObject) _PyInterpreterID_Type;
8
+
9
+ PyAPI_FUNC(PyObject *) _PyInterpreterID_New(int64_t);
10
+ PyAPI_FUNC(PyObject *) _PyInterpreterState_GetIDObject(PyInterpreterState *);
11
+ PyAPI_FUNC(PyInterpreterState *) _PyInterpreterID_LookUp(PyObject *);
llava_next/include/python3.10/cpython/listobject.h ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_CPYTHON_LISTOBJECT_H
2
+ # error "this header file must not be included directly"
3
+ #endif
4
+
5
+ typedef struct {
6
+ PyObject_VAR_HEAD
7
+ /* Vector of pointers to list elements. list[0] is ob_item[0], etc. */
8
+ PyObject **ob_item;
9
+
10
+ /* ob_item contains space for 'allocated' elements. The number
11
+ * currently in use is ob_size.
12
+ * Invariants:
13
+ * 0 <= ob_size <= allocated
14
+ * len(list) == ob_size
15
+ * ob_item == NULL implies ob_size == allocated == 0
16
+ * list.sort() temporarily sets allocated to -1 to detect mutations.
17
+ *
18
+ * Items must normally not be NULL, except during construction when
19
+ * the list is not yet visible outside the function that builds it.
20
+ */
21
+ Py_ssize_t allocated;
22
+ } PyListObject;
23
+
24
+ PyAPI_FUNC(PyObject *) _PyList_Extend(PyListObject *, PyObject *);
25
+ PyAPI_FUNC(void) _PyList_DebugMallocStats(FILE *out);
26
+
27
+ /* Macro, trading safety for speed */
28
+
29
+ /* Cast argument to PyListObject* type. */
30
+ #define _PyList_CAST(op) (assert(PyList_Check(op)), (PyListObject *)(op))
31
+
32
+ #define PyList_GET_ITEM(op, i) (_PyList_CAST(op)->ob_item[i])
33
+ #define PyList_SET_ITEM(op, i, v) ((void)(_PyList_CAST(op)->ob_item[i] = (v)))
34
+ #define PyList_GET_SIZE(op) Py_SIZE(_PyList_CAST(op))
llava_next/include/python3.10/cpython/methodobject.h ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_CPYTHON_METHODOBJECT_H
2
+ # error "this header file must not be included directly"
3
+ #endif
4
+
5
+ PyAPI_DATA(PyTypeObject) PyCMethod_Type;
6
+
7
+ #define PyCMethod_CheckExact(op) Py_IS_TYPE(op, &PyCMethod_Type)
8
+ #define PyCMethod_Check(op) PyObject_TypeCheck(op, &PyCMethod_Type)
9
+
10
+ /* Macros for direct access to these values. Type checks are *not*
11
+ done, so use with care. */
12
+ #define PyCFunction_GET_FUNCTION(func) \
13
+ (((PyCFunctionObject *)func) -> m_ml -> ml_meth)
14
+ #define PyCFunction_GET_SELF(func) \
15
+ (((PyCFunctionObject *)func) -> m_ml -> ml_flags & METH_STATIC ? \
16
+ NULL : ((PyCFunctionObject *)func) -> m_self)
17
+ #define PyCFunction_GET_FLAGS(func) \
18
+ (((PyCFunctionObject *)func) -> m_ml -> ml_flags)
19
+ #define PyCFunction_GET_CLASS(func) \
20
+ (((PyCFunctionObject *)func) -> m_ml -> ml_flags & METH_METHOD ? \
21
+ ((PyCMethodObject *)func) -> mm_class : NULL)
22
+
23
+ typedef struct {
24
+ PyObject_HEAD
25
+ PyMethodDef *m_ml; /* Description of the C function to call */
26
+ PyObject *m_self; /* Passed as 'self' arg to the C func, can be NULL */
27
+ PyObject *m_module; /* The __module__ attribute, can be anything */
28
+ PyObject *m_weakreflist; /* List of weak references */
29
+ vectorcallfunc vectorcall;
30
+ } PyCFunctionObject;
31
+
32
+ typedef struct {
33
+ PyCFunctionObject func;
34
+ PyTypeObject *mm_class; /* Class that defines this method */
35
+ } PyCMethodObject;
llava_next/include/python3.10/cpython/object.h ADDED
@@ -0,0 +1,552 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_CPYTHON_OBJECT_H
2
+ # error "this header file must not be included directly"
3
+ #endif
4
+
5
+ PyAPI_FUNC(void) _Py_NewReference(PyObject *op);
6
+
7
+ #ifdef Py_TRACE_REFS
8
+ /* Py_TRACE_REFS is such major surgery that we call external routines. */
9
+ PyAPI_FUNC(void) _Py_ForgetReference(PyObject *);
10
+ #endif
11
+
12
+ #ifdef Py_REF_DEBUG
13
+ PyAPI_FUNC(Py_ssize_t) _Py_GetRefTotal(void);
14
+ #endif
15
+
16
+
17
+ /********************* String Literals ****************************************/
18
+ /* This structure helps managing static strings. The basic usage goes like this:
19
+ Instead of doing
20
+
21
+ r = PyObject_CallMethod(o, "foo", "args", ...);
22
+
23
+ do
24
+
25
+ _Py_IDENTIFIER(foo);
26
+ ...
27
+ r = _PyObject_CallMethodId(o, &PyId_foo, "args", ...);
28
+
29
+ PyId_foo is a static variable, either on block level or file level. On first
30
+ usage, the string "foo" is interned, and the structures are linked. On interpreter
31
+ shutdown, all strings are released.
32
+
33
+ Alternatively, _Py_static_string allows choosing the variable name.
34
+ _PyUnicode_FromId returns a borrowed reference to the interned string.
35
+ _PyObject_{Get,Set,Has}AttrId are __getattr__ versions using _Py_Identifier*.
36
+ */
37
+ typedef struct _Py_Identifier {
38
+ const char* string;
39
+ // Index in PyInterpreterState.unicode.ids.array. It is process-wide
40
+ // unique and must be initialized to -1.
41
+ Py_ssize_t index;
42
+ } _Py_Identifier;
43
+
44
+ #define _Py_static_string_init(value) { .string = value, .index = -1 }
45
+ #define _Py_static_string(varname, value) static _Py_Identifier varname = _Py_static_string_init(value)
46
+ #define _Py_IDENTIFIER(varname) _Py_static_string(PyId_##varname, #varname)
47
+
48
+ /* buffer interface */
49
+ typedef struct bufferinfo {
50
+ void *buf;
51
+ PyObject *obj; /* owned reference */
52
+ Py_ssize_t len;
53
+ Py_ssize_t itemsize; /* This is Py_ssize_t so it can be
54
+ pointed to by strides in simple case.*/
55
+ int readonly;
56
+ int ndim;
57
+ char *format;
58
+ Py_ssize_t *shape;
59
+ Py_ssize_t *strides;
60
+ Py_ssize_t *suboffsets;
61
+ void *internal;
62
+ } Py_buffer;
63
+
64
+ typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
65
+ typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
66
+
67
+ typedef PyObject *(*vectorcallfunc)(PyObject *callable, PyObject *const *args,
68
+ size_t nargsf, PyObject *kwnames);
69
+
70
+ /* Maximum number of dimensions */
71
+ #define PyBUF_MAX_NDIM 64
72
+
73
+ /* Flags for getting buffers */
74
+ #define PyBUF_SIMPLE 0
75
+ #define PyBUF_WRITABLE 0x0001
76
+ /* we used to include an E, backwards compatible alias */
77
+ #define PyBUF_WRITEABLE PyBUF_WRITABLE
78
+ #define PyBUF_FORMAT 0x0004
79
+ #define PyBUF_ND 0x0008
80
+ #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
81
+ #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
82
+ #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
83
+ #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
84
+ #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
85
+
86
+ #define PyBUF_CONTIG (PyBUF_ND | PyBUF_WRITABLE)
87
+ #define PyBUF_CONTIG_RO (PyBUF_ND)
88
+
89
+ #define PyBUF_STRIDED (PyBUF_STRIDES | PyBUF_WRITABLE)
90
+ #define PyBUF_STRIDED_RO (PyBUF_STRIDES)
91
+
92
+ #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_WRITABLE | PyBUF_FORMAT)
93
+ #define PyBUF_RECORDS_RO (PyBUF_STRIDES | PyBUF_FORMAT)
94
+
95
+ #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_WRITABLE | PyBUF_FORMAT)
96
+ #define PyBUF_FULL_RO (PyBUF_INDIRECT | PyBUF_FORMAT)
97
+
98
+
99
+ #define PyBUF_READ 0x100
100
+ #define PyBUF_WRITE 0x200
101
+ /* End buffer interface */
102
+
103
+
104
+ typedef struct {
105
+ /* Number implementations must check *both*
106
+ arguments for proper type and implement the necessary conversions
107
+ in the slot functions themselves. */
108
+
109
+ binaryfunc nb_add;
110
+ binaryfunc nb_subtract;
111
+ binaryfunc nb_multiply;
112
+ binaryfunc nb_remainder;
113
+ binaryfunc nb_divmod;
114
+ ternaryfunc nb_power;
115
+ unaryfunc nb_negative;
116
+ unaryfunc nb_positive;
117
+ unaryfunc nb_absolute;
118
+ inquiry nb_bool;
119
+ unaryfunc nb_invert;
120
+ binaryfunc nb_lshift;
121
+ binaryfunc nb_rshift;
122
+ binaryfunc nb_and;
123
+ binaryfunc nb_xor;
124
+ binaryfunc nb_or;
125
+ unaryfunc nb_int;
126
+ void *nb_reserved; /* the slot formerly known as nb_long */
127
+ unaryfunc nb_float;
128
+
129
+ binaryfunc nb_inplace_add;
130
+ binaryfunc nb_inplace_subtract;
131
+ binaryfunc nb_inplace_multiply;
132
+ binaryfunc nb_inplace_remainder;
133
+ ternaryfunc nb_inplace_power;
134
+ binaryfunc nb_inplace_lshift;
135
+ binaryfunc nb_inplace_rshift;
136
+ binaryfunc nb_inplace_and;
137
+ binaryfunc nb_inplace_xor;
138
+ binaryfunc nb_inplace_or;
139
+
140
+ binaryfunc nb_floor_divide;
141
+ binaryfunc nb_true_divide;
142
+ binaryfunc nb_inplace_floor_divide;
143
+ binaryfunc nb_inplace_true_divide;
144
+
145
+ unaryfunc nb_index;
146
+
147
+ binaryfunc nb_matrix_multiply;
148
+ binaryfunc nb_inplace_matrix_multiply;
149
+ } PyNumberMethods;
150
+
151
+ typedef struct {
152
+ lenfunc sq_length;
153
+ binaryfunc sq_concat;
154
+ ssizeargfunc sq_repeat;
155
+ ssizeargfunc sq_item;
156
+ void *was_sq_slice;
157
+ ssizeobjargproc sq_ass_item;
158
+ void *was_sq_ass_slice;
159
+ objobjproc sq_contains;
160
+
161
+ binaryfunc sq_inplace_concat;
162
+ ssizeargfunc sq_inplace_repeat;
163
+ } PySequenceMethods;
164
+
165
+ typedef struct {
166
+ lenfunc mp_length;
167
+ binaryfunc mp_subscript;
168
+ objobjargproc mp_ass_subscript;
169
+ } PyMappingMethods;
170
+
171
+ typedef PySendResult (*sendfunc)(PyObject *iter, PyObject *value, PyObject **result);
172
+
173
+ typedef struct {
174
+ unaryfunc am_await;
175
+ unaryfunc am_aiter;
176
+ unaryfunc am_anext;
177
+ sendfunc am_send;
178
+ } PyAsyncMethods;
179
+
180
+ typedef struct {
181
+ getbufferproc bf_getbuffer;
182
+ releasebufferproc bf_releasebuffer;
183
+ } PyBufferProcs;
184
+
185
+ /* Allow printfunc in the tp_vectorcall_offset slot for
186
+ * backwards-compatibility */
187
+ typedef Py_ssize_t printfunc;
188
+
189
+ // If this structure is modified, Doc/includes/typestruct.h should be updated
190
+ // as well.
191
+ struct _typeobject {
192
+ PyObject_VAR_HEAD
193
+ const char *tp_name; /* For printing, in format "<module>.<name>" */
194
+ Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */
195
+
196
+ /* Methods to implement standard operations */
197
+
198
+ destructor tp_dealloc;
199
+ Py_ssize_t tp_vectorcall_offset;
200
+ getattrfunc tp_getattr;
201
+ setattrfunc tp_setattr;
202
+ PyAsyncMethods *tp_as_async; /* formerly known as tp_compare (Python 2)
203
+ or tp_reserved (Python 3) */
204
+ reprfunc tp_repr;
205
+
206
+ /* Method suites for standard classes */
207
+
208
+ PyNumberMethods *tp_as_number;
209
+ PySequenceMethods *tp_as_sequence;
210
+ PyMappingMethods *tp_as_mapping;
211
+
212
+ /* More standard operations (here for binary compatibility) */
213
+
214
+ hashfunc tp_hash;
215
+ ternaryfunc tp_call;
216
+ reprfunc tp_str;
217
+ getattrofunc tp_getattro;
218
+ setattrofunc tp_setattro;
219
+
220
+ /* Functions to access object as input/output buffer */
221
+ PyBufferProcs *tp_as_buffer;
222
+
223
+ /* Flags to define presence of optional/expanded features */
224
+ unsigned long tp_flags;
225
+
226
+ const char *tp_doc; /* Documentation string */
227
+
228
+ /* Assigned meaning in release 2.0 */
229
+ /* call function for all accessible objects */
230
+ traverseproc tp_traverse;
231
+
232
+ /* delete references to contained objects */
233
+ inquiry tp_clear;
234
+
235
+ /* Assigned meaning in release 2.1 */
236
+ /* rich comparisons */
237
+ richcmpfunc tp_richcompare;
238
+
239
+ /* weak reference enabler */
240
+ Py_ssize_t tp_weaklistoffset;
241
+
242
+ /* Iterators */
243
+ getiterfunc tp_iter;
244
+ iternextfunc tp_iternext;
245
+
246
+ /* Attribute descriptor and subclassing stuff */
247
+ struct PyMethodDef *tp_methods;
248
+ struct PyMemberDef *tp_members;
249
+ struct PyGetSetDef *tp_getset;
250
+ // Strong reference on a heap type, borrowed reference on a static type
251
+ struct _typeobject *tp_base;
252
+ PyObject *tp_dict;
253
+ descrgetfunc tp_descr_get;
254
+ descrsetfunc tp_descr_set;
255
+ Py_ssize_t tp_dictoffset;
256
+ initproc tp_init;
257
+ allocfunc tp_alloc;
258
+ newfunc tp_new;
259
+ freefunc tp_free; /* Low-level free-memory routine */
260
+ inquiry tp_is_gc; /* For PyObject_IS_GC */
261
+ PyObject *tp_bases;
262
+ PyObject *tp_mro; /* method resolution order */
263
+ PyObject *tp_cache;
264
+ PyObject *tp_subclasses;
265
+ PyObject *tp_weaklist;
266
+ destructor tp_del;
267
+
268
+ /* Type attribute cache version tag. Added in version 2.6 */
269
+ unsigned int tp_version_tag;
270
+
271
+ destructor tp_finalize;
272
+ vectorcallfunc tp_vectorcall;
273
+ };
274
+
275
+ /* The *real* layout of a type object when allocated on the heap */
276
+ typedef struct _heaptypeobject {
277
+ /* Note: there's a dependency on the order of these members
278
+ in slotptr() in typeobject.c . */
279
+ PyTypeObject ht_type;
280
+ PyAsyncMethods as_async;
281
+ PyNumberMethods as_number;
282
+ PyMappingMethods as_mapping;
283
+ PySequenceMethods as_sequence; /* as_sequence comes after as_mapping,
284
+ so that the mapping wins when both
285
+ the mapping and the sequence define
286
+ a given operator (e.g. __getitem__).
287
+ see add_operators() in typeobject.c . */
288
+ PyBufferProcs as_buffer;
289
+ PyObject *ht_name, *ht_slots, *ht_qualname;
290
+ struct _dictkeysobject *ht_cached_keys;
291
+ PyObject *ht_module;
292
+ /* here are optional user slots, followed by the members. */
293
+ } PyHeapTypeObject;
294
+
295
+ /* access macro to the members which are floating "behind" the object */
296
+ #define PyHeapType_GET_MEMBERS(etype) \
297
+ ((PyMemberDef *)(((char *)etype) + Py_TYPE(etype)->tp_basicsize))
298
+
299
+ PyAPI_FUNC(const char *) _PyType_Name(PyTypeObject *);
300
+ PyAPI_FUNC(PyObject *) _PyType_Lookup(PyTypeObject *, PyObject *);
301
+ PyAPI_FUNC(PyObject *) _PyType_LookupId(PyTypeObject *, _Py_Identifier *);
302
+ PyAPI_FUNC(PyObject *) _PyObject_LookupSpecial(PyObject *, _Py_Identifier *);
303
+ PyAPI_FUNC(PyTypeObject *) _PyType_CalculateMetaclass(PyTypeObject *, PyObject *);
304
+ PyAPI_FUNC(PyObject *) _PyType_GetDocFromInternalDoc(const char *, const char *);
305
+ PyAPI_FUNC(PyObject *) _PyType_GetTextSignatureFromInternalDoc(const char *, const char *);
306
+ struct PyModuleDef;
307
+ PyAPI_FUNC(PyObject *) _PyType_GetModuleByDef(PyTypeObject *, struct PyModuleDef *);
308
+
309
+ struct _Py_Identifier;
310
+ PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int);
311
+ PyAPI_FUNC(void) _Py_BreakPoint(void);
312
+ PyAPI_FUNC(void) _PyObject_Dump(PyObject *);
313
+ PyAPI_FUNC(int) _PyObject_IsFreed(PyObject *);
314
+
315
+ PyAPI_FUNC(int) _PyObject_IsAbstract(PyObject *);
316
+ PyAPI_FUNC(PyObject *) _PyObject_GetAttrId(PyObject *, struct _Py_Identifier *);
317
+ PyAPI_FUNC(int) _PyObject_SetAttrId(PyObject *, struct _Py_Identifier *, PyObject *);
318
+ /* Replacements of PyObject_GetAttr() and _PyObject_GetAttrId() which
319
+ don't raise AttributeError.
320
+
321
+ Return 1 and set *result != NULL if an attribute is found.
322
+ Return 0 and set *result == NULL if an attribute is not found;
323
+ an AttributeError is silenced.
324
+ Return -1 and set *result == NULL if an error other than AttributeError
325
+ is raised.
326
+ */
327
+ PyAPI_FUNC(int) _PyObject_LookupAttr(PyObject *, PyObject *, PyObject **);
328
+ PyAPI_FUNC(int) _PyObject_LookupAttrId(PyObject *, struct _Py_Identifier *, PyObject **);
329
+
330
+ PyAPI_FUNC(int) _PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);
331
+
332
+ PyAPI_FUNC(PyObject **) _PyObject_GetDictPtr(PyObject *);
333
+ PyAPI_FUNC(PyObject *) _PyObject_NextNotImplemented(PyObject *);
334
+ PyAPI_FUNC(void) PyObject_CallFinalizer(PyObject *);
335
+ PyAPI_FUNC(int) PyObject_CallFinalizerFromDealloc(PyObject *);
336
+
337
+ /* Same as PyObject_Generic{Get,Set}Attr, but passing the attributes
338
+ dict as the last parameter. */
339
+ PyAPI_FUNC(PyObject *)
340
+ _PyObject_GenericGetAttrWithDict(PyObject *, PyObject *, PyObject *, int);
341
+ PyAPI_FUNC(int)
342
+ _PyObject_GenericSetAttrWithDict(PyObject *, PyObject *,
343
+ PyObject *, PyObject *);
344
+
345
+ PyAPI_FUNC(PyObject *) _PyObject_FunctionStr(PyObject *);
346
+
347
+ /* Safely decref `op` and set `op` to `op2`.
348
+ *
349
+ * As in case of Py_CLEAR "the obvious" code can be deadly:
350
+ *
351
+ * Py_DECREF(op);
352
+ * op = op2;
353
+ *
354
+ * The safe way is:
355
+ *
356
+ * Py_SETREF(op, op2);
357
+ *
358
+ * That arranges to set `op` to `op2` _before_ decref'ing, so that any code
359
+ * triggered as a side-effect of `op` getting torn down no longer believes
360
+ * `op` points to a valid object.
361
+ *
362
+ * Py_XSETREF is a variant of Py_SETREF that uses Py_XDECREF instead of
363
+ * Py_DECREF.
364
+ */
365
+
366
+ #define Py_SETREF(op, op2) \
367
+ do { \
368
+ PyObject *_py_tmp = _PyObject_CAST(op); \
369
+ (op) = (op2); \
370
+ Py_DECREF(_py_tmp); \
371
+ } while (0)
372
+
373
+ #define Py_XSETREF(op, op2) \
374
+ do { \
375
+ PyObject *_py_tmp = _PyObject_CAST(op); \
376
+ (op) = (op2); \
377
+ Py_XDECREF(_py_tmp); \
378
+ } while (0)
379
+
380
+
381
+ PyAPI_DATA(PyTypeObject) _PyNone_Type;
382
+ PyAPI_DATA(PyTypeObject) _PyNotImplemented_Type;
383
+
384
+ /* Maps Py_LT to Py_GT, ..., Py_GE to Py_LE.
385
+ * Defined in object.c.
386
+ */
387
+ PyAPI_DATA(int) _Py_SwappedOp[];
388
+
389
+ PyAPI_FUNC(void)
390
+ _PyDebugAllocatorStats(FILE *out, const char *block_name, int num_blocks,
391
+ size_t sizeof_block);
392
+ PyAPI_FUNC(void)
393
+ _PyObject_DebugTypeStats(FILE *out);
394
+
395
+ /* Define a pair of assertion macros:
396
+ _PyObject_ASSERT_FROM(), _PyObject_ASSERT_WITH_MSG() and _PyObject_ASSERT().
397
+
398
+ These work like the regular C assert(), in that they will abort the
399
+ process with a message on stderr if the given condition fails to hold,
400
+ but compile away to nothing if NDEBUG is defined.
401
+
402
+ However, before aborting, Python will also try to call _PyObject_Dump() on
403
+ the given object. This may be of use when investigating bugs in which a
404
+ particular object is corrupt (e.g. buggy a tp_visit method in an extension
405
+ module breaking the garbage collector), to help locate the broken objects.
406
+
407
+ The WITH_MSG variant allows you to supply an additional message that Python
408
+ will attempt to print to stderr, after the object dump. */
409
+ #ifdef NDEBUG
410
+ /* No debugging: compile away the assertions: */
411
+ # define _PyObject_ASSERT_FROM(obj, expr, msg, filename, lineno, func) \
412
+ ((void)0)
413
+ #else
414
+ /* With debugging: generate checks: */
415
+ # define _PyObject_ASSERT_FROM(obj, expr, msg, filename, lineno, func) \
416
+ ((expr) \
417
+ ? (void)(0) \
418
+ : _PyObject_AssertFailed((obj), Py_STRINGIFY(expr), \
419
+ (msg), (filename), (lineno), (func)))
420
+ #endif
421
+
422
+ #define _PyObject_ASSERT_WITH_MSG(obj, expr, msg) \
423
+ _PyObject_ASSERT_FROM(obj, expr, msg, __FILE__, __LINE__, __func__)
424
+ #define _PyObject_ASSERT(obj, expr) \
425
+ _PyObject_ASSERT_WITH_MSG(obj, expr, NULL)
426
+
427
+ #define _PyObject_ASSERT_FAILED_MSG(obj, msg) \
428
+ _PyObject_AssertFailed((obj), NULL, (msg), __FILE__, __LINE__, __func__)
429
+
430
+ /* Declare and define _PyObject_AssertFailed() even when NDEBUG is defined,
431
+ to avoid causing compiler/linker errors when building extensions without
432
+ NDEBUG against a Python built with NDEBUG defined.
433
+
434
+ msg, expr and function can be NULL. */
435
+ PyAPI_FUNC(void) _Py_NO_RETURN _PyObject_AssertFailed(
436
+ PyObject *obj,
437
+ const char *expr,
438
+ const char *msg,
439
+ const char *file,
440
+ int line,
441
+ const char *function);
442
+
443
+ /* Check if an object is consistent. For example, ensure that the reference
444
+ counter is greater than or equal to 1, and ensure that ob_type is not NULL.
445
+
446
+ Call _PyObject_AssertFailed() if the object is inconsistent.
447
+
448
+ If check_content is zero, only check header fields: reduce the overhead.
449
+
450
+ The function always return 1. The return value is just here to be able to
451
+ write:
452
+
453
+ assert(_PyObject_CheckConsistency(obj, 1)); */
454
+ PyAPI_FUNC(int) _PyObject_CheckConsistency(
455
+ PyObject *op,
456
+ int check_content);
457
+
458
+
459
+ /* Trashcan mechanism, thanks to Christian Tismer.
460
+
461
+ When deallocating a container object, it's possible to trigger an unbounded
462
+ chain of deallocations, as each Py_DECREF in turn drops the refcount on "the
463
+ next" object in the chain to 0. This can easily lead to stack overflows,
464
+ especially in threads (which typically have less stack space to work with).
465
+
466
+ A container object can avoid this by bracketing the body of its tp_dealloc
467
+ function with a pair of macros:
468
+
469
+ static void
470
+ mytype_dealloc(mytype *p)
471
+ {
472
+ ... declarations go here ...
473
+
474
+ PyObject_GC_UnTrack(p); // must untrack first
475
+ Py_TRASHCAN_BEGIN(p, mytype_dealloc)
476
+ ... The body of the deallocator goes here, including all calls ...
477
+ ... to Py_DECREF on contained objects. ...
478
+ Py_TRASHCAN_END // there should be no code after this
479
+ }
480
+
481
+ CAUTION: Never return from the middle of the body! If the body needs to
482
+ "get out early", put a label immediately before the Py_TRASHCAN_END
483
+ call, and goto it. Else the call-depth counter (see below) will stay
484
+ above 0 forever, and the trashcan will never get emptied.
485
+
486
+ How it works: The BEGIN macro increments a call-depth counter. So long
487
+ as this counter is small, the body of the deallocator is run directly without
488
+ further ado. But if the counter gets large, it instead adds p to a list of
489
+ objects to be deallocated later, skips the body of the deallocator, and
490
+ resumes execution after the END macro. The tp_dealloc routine then returns
491
+ without deallocating anything (and so unbounded call-stack depth is avoided).
492
+
493
+ When the call stack finishes unwinding again, code generated by the END macro
494
+ notices this, and calls another routine to deallocate all the objects that
495
+ may have been added to the list of deferred deallocations. In effect, a
496
+ chain of N deallocations is broken into (N-1)/(PyTrash_UNWIND_LEVEL-1) pieces,
497
+ with the call stack never exceeding a depth of PyTrash_UNWIND_LEVEL.
498
+
499
+ Since the tp_dealloc of a subclass typically calls the tp_dealloc of the base
500
+ class, we need to ensure that the trashcan is only triggered on the tp_dealloc
501
+ of the actual class being deallocated. Otherwise we might end up with a
502
+ partially-deallocated object. To check this, the tp_dealloc function must be
503
+ passed as second argument to Py_TRASHCAN_BEGIN().
504
+ */
505
+
506
+ /* This is the old private API, invoked by the macros before 3.2.4.
507
+ Kept for binary compatibility of extensions using the stable ABI. */
508
+ PyAPI_FUNC(void) _PyTrash_deposit_object(PyObject*);
509
+ PyAPI_FUNC(void) _PyTrash_destroy_chain(void);
510
+
511
+ /* This is the old private API, invoked by the macros before 3.9.
512
+ Kept for binary compatibility of extensions using the stable ABI. */
513
+ PyAPI_FUNC(void) _PyTrash_thread_deposit_object(PyObject*);
514
+ PyAPI_FUNC(void) _PyTrash_thread_destroy_chain(void);
515
+
516
+ /* Forward declarations for PyThreadState */
517
+ struct _ts;
518
+
519
+ /* Python 3.9 private API, invoked by the macros below. */
520
+ PyAPI_FUNC(int) _PyTrash_begin(struct _ts *tstate, PyObject *op);
521
+ PyAPI_FUNC(void) _PyTrash_end(struct _ts *tstate);
522
+ /* Python 3.10 private API, invoked by the Py_TRASHCAN_BEGIN(). */
523
+ PyAPI_FUNC(int) _PyTrash_cond(PyObject *op, destructor dealloc);
524
+
525
+ #define PyTrash_UNWIND_LEVEL 50
526
+
527
+ #define Py_TRASHCAN_BEGIN_CONDITION(op, cond) \
528
+ do { \
529
+ PyThreadState *_tstate = NULL; \
530
+ /* If "cond" is false, then _tstate remains NULL and the deallocator \
531
+ * is run normally without involving the trashcan */ \
532
+ if (cond) { \
533
+ _tstate = PyThreadState_Get(); \
534
+ if (_PyTrash_begin(_tstate, _PyObject_CAST(op))) { \
535
+ break; \
536
+ } \
537
+ }
538
+ /* The body of the deallocator is here. */
539
+ #define Py_TRASHCAN_END \
540
+ if (_tstate) { \
541
+ _PyTrash_end(_tstate); \
542
+ } \
543
+ } while (0);
544
+
545
+ #define Py_TRASHCAN_BEGIN(op, dealloc) \
546
+ Py_TRASHCAN_BEGIN_CONDITION(op, \
547
+ _PyTrash_cond(_PyObject_CAST(op), (destructor)dealloc))
548
+
549
+ /* For backwards compatibility, these macros enable the trashcan
550
+ * unconditionally */
551
+ #define Py_TRASHCAN_SAFE_BEGIN(op) Py_TRASHCAN_BEGIN_CONDITION(op, 1)
552
+ #define Py_TRASHCAN_SAFE_END(op) Py_TRASHCAN_END
llava_next/include/python3.10/cpython/pyctype.h ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_LIMITED_API
2
+ #ifndef PYCTYPE_H
3
+ #define PYCTYPE_H
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+
8
+ #define PY_CTF_LOWER 0x01
9
+ #define PY_CTF_UPPER 0x02
10
+ #define PY_CTF_ALPHA (PY_CTF_LOWER|PY_CTF_UPPER)
11
+ #define PY_CTF_DIGIT 0x04
12
+ #define PY_CTF_ALNUM (PY_CTF_ALPHA|PY_CTF_DIGIT)
13
+ #define PY_CTF_SPACE 0x08
14
+ #define PY_CTF_XDIGIT 0x10
15
+
16
+ PyAPI_DATA(const unsigned int) _Py_ctype_table[256];
17
+
18
+ /* Unlike their C counterparts, the following macros are not meant to
19
+ * handle an int with any of the values [EOF, 0-UCHAR_MAX]. The argument
20
+ * must be a signed/unsigned char. */
21
+ #define Py_ISLOWER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_LOWER)
22
+ #define Py_ISUPPER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_UPPER)
23
+ #define Py_ISALPHA(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALPHA)
24
+ #define Py_ISDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_DIGIT)
25
+ #define Py_ISXDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_XDIGIT)
26
+ #define Py_ISALNUM(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALNUM)
27
+ #define Py_ISSPACE(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_SPACE)
28
+
29
+ PyAPI_DATA(const unsigned char) _Py_ctype_tolower[256];
30
+ PyAPI_DATA(const unsigned char) _Py_ctype_toupper[256];
31
+
32
+ #define Py_TOLOWER(c) (_Py_ctype_tolower[Py_CHARMASK(c)])
33
+ #define Py_TOUPPER(c) (_Py_ctype_toupper[Py_CHARMASK(c)])
34
+
35
+ #ifdef __cplusplus
36
+ }
37
+ #endif
38
+ #endif /* !PYCTYPE_H */
39
+ #endif /* !Py_LIMITED_API */
llava_next/include/python3.10/cpython/pydebug.h ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_LIMITED_API
2
+ #ifndef Py_PYDEBUG_H
3
+ #define Py_PYDEBUG_H
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+
8
+ PyAPI_DATA(int) Py_DebugFlag;
9
+ PyAPI_DATA(int) Py_VerboseFlag;
10
+ PyAPI_DATA(int) Py_QuietFlag;
11
+ PyAPI_DATA(int) Py_InteractiveFlag;
12
+ PyAPI_DATA(int) Py_InspectFlag;
13
+ PyAPI_DATA(int) Py_OptimizeFlag;
14
+ PyAPI_DATA(int) Py_NoSiteFlag;
15
+ PyAPI_DATA(int) Py_BytesWarningFlag;
16
+ PyAPI_DATA(int) Py_FrozenFlag;
17
+ PyAPI_DATA(int) Py_IgnoreEnvironmentFlag;
18
+ PyAPI_DATA(int) Py_DontWriteBytecodeFlag;
19
+ PyAPI_DATA(int) Py_NoUserSiteDirectory;
20
+ PyAPI_DATA(int) Py_UnbufferedStdioFlag;
21
+ PyAPI_DATA(int) Py_HashRandomizationFlag;
22
+ PyAPI_DATA(int) Py_IsolatedFlag;
23
+
24
+ #ifdef MS_WINDOWS
25
+ PyAPI_DATA(int) Py_LegacyWindowsFSEncodingFlag;
26
+ PyAPI_DATA(int) Py_LegacyWindowsStdioFlag;
27
+ #endif
28
+
29
+ /* this is a wrapper around getenv() that pays attention to
30
+ Py_IgnoreEnvironmentFlag. It should be used for getting variables like
31
+ PYTHONPATH and PYTHONHOME from the environment */
32
+ #define Py_GETENV(s) (Py_IgnoreEnvironmentFlag ? NULL : getenv(s))
33
+
34
+ #ifdef __cplusplus
35
+ }
36
+ #endif
37
+ #endif /* !Py_PYDEBUG_H */
38
+ #endif /* Py_LIMITED_API */
llava_next/include/python3.10/cpython/pyerrors.h ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_CPYTHON_ERRORS_H
2
+ # error "this header file must not be included directly"
3
+ #endif
4
+
5
+ /* Error objects */
6
+
7
+ /* PyException_HEAD defines the initial segment of every exception class. */
8
+ #define PyException_HEAD PyObject_HEAD PyObject *dict;\
9
+ PyObject *args; PyObject *traceback;\
10
+ PyObject *context; PyObject *cause;\
11
+ char suppress_context;
12
+
13
+ typedef struct {
14
+ PyException_HEAD
15
+ } PyBaseExceptionObject;
16
+
17
+ typedef struct {
18
+ PyException_HEAD
19
+ PyObject *msg;
20
+ PyObject *filename;
21
+ PyObject *lineno;
22
+ PyObject *offset;
23
+ PyObject *end_lineno;
24
+ PyObject *end_offset;
25
+ PyObject *text;
26
+ PyObject *print_file_and_line;
27
+ } PySyntaxErrorObject;
28
+
29
+ typedef struct {
30
+ PyException_HEAD
31
+ PyObject *msg;
32
+ PyObject *name;
33
+ PyObject *path;
34
+ } PyImportErrorObject;
35
+
36
+ typedef struct {
37
+ PyException_HEAD
38
+ PyObject *encoding;
39
+ PyObject *object;
40
+ Py_ssize_t start;
41
+ Py_ssize_t end;
42
+ PyObject *reason;
43
+ } PyUnicodeErrorObject;
44
+
45
+ typedef struct {
46
+ PyException_HEAD
47
+ PyObject *code;
48
+ } PySystemExitObject;
49
+
50
+ typedef struct {
51
+ PyException_HEAD
52
+ PyObject *myerrno;
53
+ PyObject *strerror;
54
+ PyObject *filename;
55
+ PyObject *filename2;
56
+ #ifdef MS_WINDOWS
57
+ PyObject *winerror;
58
+ #endif
59
+ Py_ssize_t written; /* only for BlockingIOError, -1 otherwise */
60
+ } PyOSErrorObject;
61
+
62
+ typedef struct {
63
+ PyException_HEAD
64
+ PyObject *value;
65
+ } PyStopIterationObject;
66
+
67
+ typedef struct {
68
+ PyException_HEAD
69
+ PyObject *name;
70
+ } PyNameErrorObject;
71
+
72
+ typedef struct {
73
+ PyException_HEAD
74
+ PyObject *obj;
75
+ PyObject *name;
76
+ } PyAttributeErrorObject;
77
+
78
+ /* Compatibility typedefs */
79
+ typedef PyOSErrorObject PyEnvironmentErrorObject;
80
+ #ifdef MS_WINDOWS
81
+ typedef PyOSErrorObject PyWindowsErrorObject;
82
+ #endif
83
+
84
+ /* Error handling definitions */
85
+
86
+ PyAPI_FUNC(void) _PyErr_SetKeyError(PyObject *);
87
+ PyAPI_FUNC(_PyErr_StackItem*) _PyErr_GetTopmostException(PyThreadState *tstate);
88
+ PyAPI_FUNC(void) _PyErr_GetExcInfo(PyThreadState *, PyObject **, PyObject **, PyObject **);
89
+
90
+ /* Context manipulation (PEP 3134) */
91
+
92
+ PyAPI_FUNC(void) _PyErr_ChainExceptions(PyObject *, PyObject *, PyObject *);
93
+
94
+ /* Convenience functions */
95
+
96
+ #ifdef MS_WINDOWS
97
+ Py_DEPRECATED(3.3)
98
+ PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithUnicodeFilename(
99
+ PyObject *, const Py_UNICODE *);
100
+ #endif /* MS_WINDOWS */
101
+
102
+ /* Like PyErr_Format(), but saves current exception as __context__ and
103
+ __cause__.
104
+ */
105
+ PyAPI_FUNC(PyObject *) _PyErr_FormatFromCause(
106
+ PyObject *exception,
107
+ const char *format, /* ASCII-encoded string */
108
+ ...
109
+ );
110
+
111
+ #ifdef MS_WINDOWS
112
+ /* XXX redeclare to use WSTRING */
113
+ Py_DEPRECATED(3.3)
114
+ PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithUnicodeFilename(
115
+ int, const Py_UNICODE *);
116
+ Py_DEPRECATED(3.3)
117
+ PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithUnicodeFilename(
118
+ PyObject *,int, const Py_UNICODE *);
119
+ #endif
120
+
121
+ /* In exceptions.c */
122
+
123
+ /* Helper that attempts to replace the current exception with one of the
124
+ * same type but with a prefix added to the exception text. The resulting
125
+ * exception description looks like:
126
+ *
127
+ * prefix (exc_type: original_exc_str)
128
+ *
129
+ * Only some exceptions can be safely replaced. If the function determines
130
+ * it isn't safe to perform the replacement, it will leave the original
131
+ * unmodified exception in place.
132
+ *
133
+ * Returns a borrowed reference to the new exception (if any), NULL if the
134
+ * existing exception was left in place.
135
+ */
136
+ PyAPI_FUNC(PyObject *) _PyErr_TrySetFromCause(
137
+ const char *prefix_format, /* ASCII-encoded string */
138
+ ...
139
+ );
140
+
141
+ /* In signalmodule.c */
142
+
143
+ int PySignal_SetWakeupFd(int fd);
144
+ PyAPI_FUNC(int) _PyErr_CheckSignals(void);
145
+
146
+ /* Support for adding program text to SyntaxErrors */
147
+
148
+ PyAPI_FUNC(void) PyErr_SyntaxLocationObject(
149
+ PyObject *filename,
150
+ int lineno,
151
+ int col_offset);
152
+
153
+ PyAPI_FUNC(void) PyErr_RangedSyntaxLocationObject(
154
+ PyObject *filename,
155
+ int lineno,
156
+ int col_offset,
157
+ int end_lineno,
158
+ int end_col_offset);
159
+
160
+ PyAPI_FUNC(PyObject *) PyErr_ProgramTextObject(
161
+ PyObject *filename,
162
+ int lineno);
163
+
164
+ /* Create a UnicodeEncodeError object.
165
+ *
166
+ * TODO: This API will be removed in Python 3.11.
167
+ */
168
+ Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_Create(
169
+ const char *encoding, /* UTF-8 encoded string */
170
+ const Py_UNICODE *object,
171
+ Py_ssize_t length,
172
+ Py_ssize_t start,
173
+ Py_ssize_t end,
174
+ const char *reason /* UTF-8 encoded string */
175
+ );
176
+
177
+ /* Create a UnicodeTranslateError object.
178
+ *
179
+ * TODO: This API will be removed in Python 3.11.
180
+ */
181
+ Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_Create(
182
+ const Py_UNICODE *object,
183
+ Py_ssize_t length,
184
+ Py_ssize_t start,
185
+ Py_ssize_t end,
186
+ const char *reason /* UTF-8 encoded string */
187
+ );
188
+
189
+ PyAPI_FUNC(PyObject *) _PyErr_ProgramDecodedTextObject(
190
+ PyObject *filename,
191
+ int lineno,
192
+ const char* encoding);
193
+
194
+ PyAPI_FUNC(PyObject *) _PyUnicodeTranslateError_Create(
195
+ PyObject *object,
196
+ Py_ssize_t start,
197
+ Py_ssize_t end,
198
+ const char *reason /* UTF-8 encoded string */
199
+ );
200
+
201
+ PyAPI_FUNC(void) _PyErr_WriteUnraisableMsg(
202
+ const char *err_msg,
203
+ PyObject *obj);
204
+
205
+ PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalErrorFunc(
206
+ const char *func,
207
+ const char *message);
208
+
209
+ PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalErrorFormat(
210
+ const char *func,
211
+ const char *format,
212
+ ...);
213
+
214
+ #define Py_FatalError(message) _Py_FatalErrorFunc(__func__, message)
llava_next/include/python3.10/cpython/pyfpe.h ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_PYFPE_H
2
+ #define Py_PYFPE_H
3
+ /* Header excluded from the stable API */
4
+ #ifndef Py_LIMITED_API
5
+
6
+ /* These macros used to do something when Python was built with --with-fpectl,
7
+ * but support for that was dropped in 3.7. We continue to define them though,
8
+ * to avoid breaking API users.
9
+ */
10
+
11
+ #define PyFPE_START_PROTECT(err_string, leave_stmt)
12
+ #define PyFPE_END_PROTECT(v)
13
+
14
+ #endif /* !defined(Py_LIMITED_API) */
15
+ #endif /* !Py_PYFPE_H */
llava_next/include/python3.10/cpython/pymem.h ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_CPYTHON_PYMEM_H
2
+ # error "this header file must not be included directly"
3
+ #endif
4
+
5
+ PyAPI_FUNC(void *) PyMem_RawMalloc(size_t size);
6
+ PyAPI_FUNC(void *) PyMem_RawCalloc(size_t nelem, size_t elsize);
7
+ PyAPI_FUNC(void *) PyMem_RawRealloc(void *ptr, size_t new_size);
8
+ PyAPI_FUNC(void) PyMem_RawFree(void *ptr);
9
+
10
+ /* Try to get the allocators name set by _PyMem_SetupAllocators(). */
11
+ PyAPI_FUNC(const char*) _PyMem_GetCurrentAllocatorName(void);
12
+
13
+ /* strdup() using PyMem_RawMalloc() */
14
+ PyAPI_FUNC(char *) _PyMem_RawStrdup(const char *str);
15
+
16
+ /* strdup() using PyMem_Malloc() */
17
+ PyAPI_FUNC(char *) _PyMem_Strdup(const char *str);
18
+
19
+ /* wcsdup() using PyMem_RawMalloc() */
20
+ PyAPI_FUNC(wchar_t*) _PyMem_RawWcsdup(const wchar_t *str);
21
+
22
+
23
+ typedef enum {
24
+ /* PyMem_RawMalloc(), PyMem_RawRealloc() and PyMem_RawFree() */
25
+ PYMEM_DOMAIN_RAW,
26
+
27
+ /* PyMem_Malloc(), PyMem_Realloc() and PyMem_Free() */
28
+ PYMEM_DOMAIN_MEM,
29
+
30
+ /* PyObject_Malloc(), PyObject_Realloc() and PyObject_Free() */
31
+ PYMEM_DOMAIN_OBJ
32
+ } PyMemAllocatorDomain;
33
+
34
+ typedef enum {
35
+ PYMEM_ALLOCATOR_NOT_SET = 0,
36
+ PYMEM_ALLOCATOR_DEFAULT = 1,
37
+ PYMEM_ALLOCATOR_DEBUG = 2,
38
+ PYMEM_ALLOCATOR_MALLOC = 3,
39
+ PYMEM_ALLOCATOR_MALLOC_DEBUG = 4,
40
+ #ifdef WITH_PYMALLOC
41
+ PYMEM_ALLOCATOR_PYMALLOC = 5,
42
+ PYMEM_ALLOCATOR_PYMALLOC_DEBUG = 6,
43
+ #endif
44
+ } PyMemAllocatorName;
45
+
46
+
47
+ typedef struct {
48
+ /* user context passed as the first argument to the 4 functions */
49
+ void *ctx;
50
+
51
+ /* allocate a memory block */
52
+ void* (*malloc) (void *ctx, size_t size);
53
+
54
+ /* allocate a memory block initialized by zeros */
55
+ void* (*calloc) (void *ctx, size_t nelem, size_t elsize);
56
+
57
+ /* allocate or resize a memory block */
58
+ void* (*realloc) (void *ctx, void *ptr, size_t new_size);
59
+
60
+ /* release a memory block */
61
+ void (*free) (void *ctx, void *ptr);
62
+ } PyMemAllocatorEx;
63
+
64
+ /* Get the memory block allocator of the specified domain. */
65
+ PyAPI_FUNC(void) PyMem_GetAllocator(PyMemAllocatorDomain domain,
66
+ PyMemAllocatorEx *allocator);
67
+
68
+ /* Set the memory block allocator of the specified domain.
69
+
70
+ The new allocator must return a distinct non-NULL pointer when requesting
71
+ zero bytes.
72
+
73
+ For the PYMEM_DOMAIN_RAW domain, the allocator must be thread-safe: the GIL
74
+ is not held when the allocator is called.
75
+
76
+ If the new allocator is not a hook (don't call the previous allocator), the
77
+ PyMem_SetupDebugHooks() function must be called to reinstall the debug hooks
78
+ on top on the new allocator. */
79
+ PyAPI_FUNC(void) PyMem_SetAllocator(PyMemAllocatorDomain domain,
80
+ PyMemAllocatorEx *allocator);
81
+
82
+ /* Setup hooks to detect bugs in the following Python memory allocator
83
+ functions:
84
+
85
+ - PyMem_RawMalloc(), PyMem_RawRealloc(), PyMem_RawFree()
86
+ - PyMem_Malloc(), PyMem_Realloc(), PyMem_Free()
87
+ - PyObject_Malloc(), PyObject_Realloc() and PyObject_Free()
88
+
89
+ Newly allocated memory is filled with the byte 0xCB, freed memory is filled
90
+ with the byte 0xDB. Additional checks:
91
+
92
+ - detect API violations, ex: PyObject_Free() called on a buffer allocated
93
+ by PyMem_Malloc()
94
+ - detect write before the start of the buffer (buffer underflow)
95
+ - detect write after the end of the buffer (buffer overflow)
96
+
97
+ The function does nothing if Python is not compiled is debug mode. */
98
+ PyAPI_FUNC(void) PyMem_SetupDebugHooks(void);
llava_next/include/python3.10/cpython/pystate.h ADDED
@@ -0,0 +1,305 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_CPYTHON_PYSTATE_H
2
+ # error "this header file must not be included directly"
3
+ #endif
4
+
5
+ PyAPI_FUNC(int) _PyInterpreterState_RequiresIDRef(PyInterpreterState *);
6
+ PyAPI_FUNC(void) _PyInterpreterState_RequireIDRef(PyInterpreterState *, int);
7
+
8
+ PyAPI_FUNC(PyObject *) _PyInterpreterState_GetMainModule(PyInterpreterState *);
9
+
10
+ /* State unique per thread */
11
+
12
+ /* Py_tracefunc return -1 when raising an exception, or 0 for success. */
13
+ typedef int (*Py_tracefunc)(PyObject *, PyFrameObject *, int, PyObject *);
14
+
15
+ /* The following values are used for 'what' for tracefunc functions
16
+ *
17
+ * To add a new kind of trace event, also update "trace_init" in
18
+ * Python/sysmodule.c to define the Python level event name
19
+ */
20
+ #define PyTrace_CALL 0
21
+ #define PyTrace_EXCEPTION 1
22
+ #define PyTrace_LINE 2
23
+ #define PyTrace_RETURN 3
24
+ #define PyTrace_C_CALL 4
25
+ #define PyTrace_C_EXCEPTION 5
26
+ #define PyTrace_C_RETURN 6
27
+ #define PyTrace_OPCODE 7
28
+
29
+
30
+ typedef struct _cframe {
31
+ /* This struct will be threaded through the C stack
32
+ * allowing fast access to per-thread state that needs
33
+ * to be accessed quickly by the interpreter, but can
34
+ * be modified outside of the interpreter.
35
+ *
36
+ * WARNING: This makes data on the C stack accessible from
37
+ * heap objects. Care must be taken to maintain stack
38
+ * discipline and make sure that instances of this struct cannot
39
+ * accessed outside of their lifetime.
40
+ */
41
+ int use_tracing;
42
+ struct _cframe *previous;
43
+ } CFrame;
44
+
45
+ typedef struct _err_stackitem {
46
+ /* This struct represents an entry on the exception stack, which is a
47
+ * per-coroutine state. (Coroutine in the computer science sense,
48
+ * including the thread and generators).
49
+ * This ensures that the exception state is not impacted by "yields"
50
+ * from an except handler.
51
+ */
52
+ PyObject *exc_type, *exc_value, *exc_traceback;
53
+
54
+ struct _err_stackitem *previous_item;
55
+
56
+ } _PyErr_StackItem;
57
+
58
+
59
+ // The PyThreadState typedef is in Include/pystate.h.
60
+ struct _ts {
61
+ /* See Python/ceval.c for comments explaining most fields */
62
+
63
+ struct _ts *prev;
64
+ struct _ts *next;
65
+ PyInterpreterState *interp;
66
+
67
+ /* Borrowed reference to the current frame (it can be NULL) */
68
+ PyFrameObject *frame;
69
+ int recursion_depth;
70
+ int recursion_headroom; /* Allow 50 more calls to handle any errors. */
71
+ int stackcheck_counter;
72
+
73
+ /* 'tracing' keeps track of the execution depth when tracing/profiling.
74
+ This is to prevent the actual trace/profile code from being recorded in
75
+ the trace/profile. */
76
+ int tracing;
77
+
78
+ /* Pointer to current CFrame in the C stack frame of the currently,
79
+ * or most recently, executing _PyEval_EvalFrameDefault. */
80
+ CFrame *cframe;
81
+
82
+ Py_tracefunc c_profilefunc;
83
+ Py_tracefunc c_tracefunc;
84
+ PyObject *c_profileobj;
85
+ PyObject *c_traceobj;
86
+
87
+ /* The exception currently being raised */
88
+ PyObject *curexc_type;
89
+ PyObject *curexc_value;
90
+ PyObject *curexc_traceback;
91
+
92
+ /* The exception currently being handled, if no coroutines/generators
93
+ * are present. Always last element on the stack referred to be exc_info.
94
+ */
95
+ _PyErr_StackItem exc_state;
96
+
97
+ /* Pointer to the top of the stack of the exceptions currently
98
+ * being handled */
99
+ _PyErr_StackItem *exc_info;
100
+
101
+ PyObject *dict; /* Stores per-thread state */
102
+
103
+ int gilstate_counter;
104
+
105
+ PyObject *async_exc; /* Asynchronous exception to raise */
106
+ unsigned long thread_id; /* Thread id where this tstate was created */
107
+
108
+ int trash_delete_nesting;
109
+ PyObject *trash_delete_later;
110
+
111
+ /* Called when a thread state is deleted normally, but not when it
112
+ * is destroyed after fork().
113
+ * Pain: to prevent rare but fatal shutdown errors (issue 18808),
114
+ * Thread.join() must wait for the join'ed thread's tstate to be unlinked
115
+ * from the tstate chain. That happens at the end of a thread's life,
116
+ * in pystate.c.
117
+ * The obvious way doesn't quite work: create a lock which the tstate
118
+ * unlinking code releases, and have Thread.join() wait to acquire that
119
+ * lock. The problem is that we _are_ at the end of the thread's life:
120
+ * if the thread holds the last reference to the lock, decref'ing the
121
+ * lock will delete the lock, and that may trigger arbitrary Python code
122
+ * if there's a weakref, with a callback, to the lock. But by this time
123
+ * _PyRuntime.gilstate.tstate_current is already NULL, so only the simplest
124
+ * of C code can be allowed to run (in particular it must not be possible to
125
+ * release the GIL).
126
+ * So instead of holding the lock directly, the tstate holds a weakref to
127
+ * the lock: that's the value of on_delete_data below. Decref'ing a
128
+ * weakref is harmless.
129
+ * on_delete points to _threadmodule.c's static release_sentinel() function.
130
+ * After the tstate is unlinked, release_sentinel is called with the
131
+ * weakref-to-lock (on_delete_data) argument, and release_sentinel releases
132
+ * the indirectly held lock.
133
+ */
134
+ void (*on_delete)(void *);
135
+ void *on_delete_data;
136
+
137
+ int coroutine_origin_tracking_depth;
138
+
139
+ PyObject *async_gen_firstiter;
140
+ PyObject *async_gen_finalizer;
141
+
142
+ PyObject *context;
143
+ uint64_t context_ver;
144
+
145
+ /* Unique thread state id. */
146
+ uint64_t id;
147
+
148
+ CFrame root_cframe;
149
+
150
+ /* XXX signal handlers should also be here */
151
+
152
+ };
153
+
154
+ // Alias for backward compatibility with Python 3.8
155
+ #define _PyInterpreterState_Get PyInterpreterState_Get
156
+
157
+ PyAPI_FUNC(PyThreadState *) _PyThreadState_Prealloc(PyInterpreterState *);
158
+
159
+ /* Similar to PyThreadState_Get(), but don't issue a fatal error
160
+ * if it is NULL. */
161
+ PyAPI_FUNC(PyThreadState *) _PyThreadState_UncheckedGet(void);
162
+
163
+ PyAPI_FUNC(PyObject *) _PyThreadState_GetDict(PyThreadState *tstate);
164
+
165
+ /* PyGILState */
166
+
167
+ /* Helper/diagnostic function - return 1 if the current thread
168
+ currently holds the GIL, 0 otherwise.
169
+
170
+ The function returns 1 if _PyGILState_check_enabled is non-zero. */
171
+ PyAPI_FUNC(int) PyGILState_Check(void);
172
+
173
+ /* Get the single PyInterpreterState used by this process' GILState
174
+ implementation.
175
+
176
+ This function doesn't check for error. Return NULL before _PyGILState_Init()
177
+ is called and after _PyGILState_Fini() is called.
178
+
179
+ See also _PyInterpreterState_Get() and _PyInterpreterState_GET(). */
180
+ PyAPI_FUNC(PyInterpreterState *) _PyGILState_GetInterpreterStateUnsafe(void);
181
+
182
+ /* The implementation of sys._current_frames() Returns a dict mapping
183
+ thread id to that thread's current frame.
184
+ */
185
+ PyAPI_FUNC(PyObject *) _PyThread_CurrentFrames(void);
186
+
187
+ /* The implementation of sys._current_exceptions() Returns a dict mapping
188
+ thread id to that thread's current exception.
189
+ */
190
+ PyAPI_FUNC(PyObject *) _PyThread_CurrentExceptions(void);
191
+
192
+ /* Routines for advanced debuggers, requested by David Beazley.
193
+ Don't use unless you know what you are doing! */
194
+ PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Main(void);
195
+ PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void);
196
+ PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *);
197
+ PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);
198
+ PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *);
199
+ PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);
200
+
201
+ /* Frame evaluation API */
202
+
203
+ typedef PyObject* (*_PyFrameEvalFunction)(PyThreadState *tstate, PyFrameObject *, int);
204
+
205
+ PyAPI_FUNC(_PyFrameEvalFunction) _PyInterpreterState_GetEvalFrameFunc(
206
+ PyInterpreterState *interp);
207
+ PyAPI_FUNC(void) _PyInterpreterState_SetEvalFrameFunc(
208
+ PyInterpreterState *interp,
209
+ _PyFrameEvalFunction eval_frame);
210
+
211
+ PyAPI_FUNC(const PyConfig*) _PyInterpreterState_GetConfig(PyInterpreterState *interp);
212
+
213
+ /* Get a copy of the current interpreter configuration.
214
+
215
+ Return 0 on success. Raise an exception and return -1 on error.
216
+
217
+ The caller must initialize 'config', using PyConfig_InitPythonConfig()
218
+ for example.
219
+
220
+ Python must be preinitialized to call this method.
221
+ The caller must hold the GIL. */
222
+ PyAPI_FUNC(int) _PyInterpreterState_GetConfigCopy(
223
+ struct PyConfig *config);
224
+
225
+ /* Set the configuration of the current interpreter.
226
+
227
+ This function should be called during or just after the Python
228
+ initialization.
229
+
230
+ Update the sys module with the new configuration. If the sys module was
231
+ modified directly after the Python initialization, these changes are lost.
232
+
233
+ Some configuration like faulthandler or warnoptions can be updated in the
234
+ configuration, but don't reconfigure Python (don't enable/disable
235
+ faulthandler and don't reconfigure warnings filters).
236
+
237
+ Return 0 on success. Raise an exception and return -1 on error.
238
+
239
+ The configuration should come from _PyInterpreterState_GetConfigCopy(). */
240
+ PyAPI_FUNC(int) _PyInterpreterState_SetConfig(
241
+ const struct PyConfig *config);
242
+
243
+ // Get the configuration of the current interpreter.
244
+ // The caller must hold the GIL.
245
+ PyAPI_FUNC(const PyConfig*) _Py_GetConfig(void);
246
+
247
+
248
+ /* cross-interpreter data */
249
+
250
+ struct _xid;
251
+
252
+ // _PyCrossInterpreterData is similar to Py_buffer as an effectively
253
+ // opaque struct that holds data outside the object machinery. This
254
+ // is necessary to pass safely between interpreters in the same process.
255
+ typedef struct _xid {
256
+ // data is the cross-interpreter-safe derivation of a Python object
257
+ // (see _PyObject_GetCrossInterpreterData). It will be NULL if the
258
+ // new_object func (below) encodes the data.
259
+ void *data;
260
+ // obj is the Python object from which the data was derived. This
261
+ // is non-NULL only if the data remains bound to the object in some
262
+ // way, such that the object must be "released" (via a decref) when
263
+ // the data is released. In that case the code that sets the field,
264
+ // likely a registered "crossinterpdatafunc", is responsible for
265
+ // ensuring it owns the reference (i.e. incref).
266
+ PyObject *obj;
267
+ // interp is the ID of the owning interpreter of the original
268
+ // object. It corresponds to the active interpreter when
269
+ // _PyObject_GetCrossInterpreterData() was called. This should only
270
+ // be set by the cross-interpreter machinery.
271
+ //
272
+ // We use the ID rather than the PyInterpreterState to avoid issues
273
+ // with deleted interpreters. Note that IDs are never re-used, so
274
+ // each one will always correspond to a specific interpreter
275
+ // (whether still alive or not).
276
+ int64_t interp;
277
+ // new_object is a function that returns a new object in the current
278
+ // interpreter given the data. The resulting object (a new
279
+ // reference) will be equivalent to the original object. This field
280
+ // is required.
281
+ PyObject *(*new_object)(struct _xid *);
282
+ // free is called when the data is released. If it is NULL then
283
+ // nothing will be done to free the data. For some types this is
284
+ // okay (e.g. bytes) and for those types this field should be set
285
+ // to NULL. However, for most the data was allocated just for
286
+ // cross-interpreter use, so it must be freed when
287
+ // _PyCrossInterpreterData_Release is called or the memory will
288
+ // leak. In that case, at the very least this field should be set
289
+ // to PyMem_RawFree (the default if not explicitly set to NULL).
290
+ // The call will happen with the original interpreter activated.
291
+ void (*free)(void *);
292
+ } _PyCrossInterpreterData;
293
+
294
+ PyAPI_FUNC(int) _PyObject_GetCrossInterpreterData(PyObject *, _PyCrossInterpreterData *);
295
+ PyAPI_FUNC(PyObject *) _PyCrossInterpreterData_NewObject(_PyCrossInterpreterData *);
296
+ PyAPI_FUNC(void) _PyCrossInterpreterData_Release(_PyCrossInterpreterData *);
297
+
298
+ PyAPI_FUNC(int) _PyObject_CheckCrossInterpreterData(PyObject *);
299
+
300
+ /* cross-interpreter data registry */
301
+
302
+ typedef int (*crossinterpdatafunc)(PyObject *, struct _xid *);
303
+
304
+ PyAPI_FUNC(int) _PyCrossInterpreterData_RegisterClass(PyTypeObject *, crossinterpdatafunc);
305
+ PyAPI_FUNC(crossinterpdatafunc) _PyCrossInterpreterData_Lookup(PyObject *);
llava_next/include/python3.10/cpython/pytime.h ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_LIMITED_API
2
+ #ifndef Py_PYTIME_H
3
+ #define Py_PYTIME_H
4
+
5
+ /**************************************************************************
6
+ Symbols and macros to supply platform-independent interfaces to time related
7
+ functions and constants
8
+ **************************************************************************/
9
+ #ifdef __cplusplus
10
+ extern "C" {
11
+ #endif
12
+
13
+ /* _PyTime_t: Python timestamp with subsecond precision. It can be used to
14
+ store a duration, and so indirectly a date (related to another date, like
15
+ UNIX epoch). */
16
+ typedef int64_t _PyTime_t;
17
+ #define _PyTime_MIN INT64_MIN
18
+ #define _PyTime_MAX INT64_MAX
19
+
20
+ typedef enum {
21
+ /* Round towards minus infinity (-inf).
22
+ For example, used to read a clock. */
23
+ _PyTime_ROUND_FLOOR=0,
24
+ /* Round towards infinity (+inf).
25
+ For example, used for timeout to wait "at least" N seconds. */
26
+ _PyTime_ROUND_CEILING=1,
27
+ /* Round to nearest with ties going to nearest even integer.
28
+ For example, used to round from a Python float. */
29
+ _PyTime_ROUND_HALF_EVEN=2,
30
+ /* Round away from zero
31
+ For example, used for timeout. _PyTime_ROUND_CEILING rounds
32
+ -1e-9 to 0 milliseconds which causes bpo-31786 issue.
33
+ _PyTime_ROUND_UP rounds -1e-9 to -1 millisecond which keeps
34
+ the timeout sign as expected. select.poll(timeout) must block
35
+ for negative values." */
36
+ _PyTime_ROUND_UP=3,
37
+ /* _PyTime_ROUND_TIMEOUT (an alias for _PyTime_ROUND_UP) should be
38
+ used for timeouts. */
39
+ _PyTime_ROUND_TIMEOUT = _PyTime_ROUND_UP
40
+ } _PyTime_round_t;
41
+
42
+
43
+ /* Convert a time_t to a PyLong. */
44
+ PyAPI_FUNC(PyObject *) _PyLong_FromTime_t(
45
+ time_t sec);
46
+
47
+ /* Convert a PyLong to a time_t. */
48
+ PyAPI_FUNC(time_t) _PyLong_AsTime_t(
49
+ PyObject *obj);
50
+
51
+ /* Convert a number of seconds, int or float, to time_t. */
52
+ PyAPI_FUNC(int) _PyTime_ObjectToTime_t(
53
+ PyObject *obj,
54
+ time_t *sec,
55
+ _PyTime_round_t);
56
+
57
+ /* Convert a number of seconds, int or float, to a timeval structure.
58
+ usec is in the range [0; 999999] and rounded towards zero.
59
+ For example, -1.2 is converted to (-2, 800000). */
60
+ PyAPI_FUNC(int) _PyTime_ObjectToTimeval(
61
+ PyObject *obj,
62
+ time_t *sec,
63
+ long *usec,
64
+ _PyTime_round_t);
65
+
66
+ /* Convert a number of seconds, int or float, to a timespec structure.
67
+ nsec is in the range [0; 999999999] and rounded towards zero.
68
+ For example, -1.2 is converted to (-2, 800000000). */
69
+ PyAPI_FUNC(int) _PyTime_ObjectToTimespec(
70
+ PyObject *obj,
71
+ time_t *sec,
72
+ long *nsec,
73
+ _PyTime_round_t);
74
+
75
+
76
+ /* Create a timestamp from a number of seconds. */
77
+ PyAPI_FUNC(_PyTime_t) _PyTime_FromSeconds(int seconds);
78
+
79
+ /* Macro to create a timestamp from a number of seconds, no integer overflow.
80
+ Only use the macro for small values, prefer _PyTime_FromSeconds(). */
81
+ #define _PYTIME_FROMSECONDS(seconds) \
82
+ ((_PyTime_t)(seconds) * (1000 * 1000 * 1000))
83
+
84
+ /* Create a timestamp from a number of nanoseconds. */
85
+ PyAPI_FUNC(_PyTime_t) _PyTime_FromNanoseconds(_PyTime_t ns);
86
+
87
+ /* Create a timestamp from nanoseconds (Python int). */
88
+ PyAPI_FUNC(int) _PyTime_FromNanosecondsObject(_PyTime_t *t,
89
+ PyObject *obj);
90
+
91
+ /* Convert a number of seconds (Python float or int) to a timestamp.
92
+ Raise an exception and return -1 on error, return 0 on success. */
93
+ PyAPI_FUNC(int) _PyTime_FromSecondsObject(_PyTime_t *t,
94
+ PyObject *obj,
95
+ _PyTime_round_t round);
96
+
97
+ /* Convert a number of milliseconds (Python float or int, 10^-3) to a timestamp.
98
+ Raise an exception and return -1 on error, return 0 on success. */
99
+ PyAPI_FUNC(int) _PyTime_FromMillisecondsObject(_PyTime_t *t,
100
+ PyObject *obj,
101
+ _PyTime_round_t round);
102
+
103
+ /* Convert a timestamp to a number of seconds as a C double. */
104
+ PyAPI_FUNC(double) _PyTime_AsSecondsDouble(_PyTime_t t);
105
+
106
+ /* Convert timestamp to a number of milliseconds (10^-3 seconds). */
107
+ PyAPI_FUNC(_PyTime_t) _PyTime_AsMilliseconds(_PyTime_t t,
108
+ _PyTime_round_t round);
109
+
110
+ /* Convert timestamp to a number of microseconds (10^-6 seconds). */
111
+ PyAPI_FUNC(_PyTime_t) _PyTime_AsMicroseconds(_PyTime_t t,
112
+ _PyTime_round_t round);
113
+
114
+ /* Convert timestamp to a number of nanoseconds (10^-9 seconds) as a Python int
115
+ object. */
116
+ PyAPI_FUNC(PyObject *) _PyTime_AsNanosecondsObject(_PyTime_t t);
117
+
118
+ /* Create a timestamp from a timeval structure.
119
+ Raise an exception and return -1 on overflow, return 0 on success. */
120
+ PyAPI_FUNC(int) _PyTime_FromTimeval(_PyTime_t *tp, struct timeval *tv);
121
+
122
+ /* Convert a timestamp to a timeval structure (microsecond resolution).
123
+ tv_usec is always positive.
124
+ Raise an exception and return -1 if the conversion overflowed,
125
+ return 0 on success. */
126
+ PyAPI_FUNC(int) _PyTime_AsTimeval(_PyTime_t t,
127
+ struct timeval *tv,
128
+ _PyTime_round_t round);
129
+
130
+ /* Similar to _PyTime_AsTimeval(), but don't raise an exception on error. */
131
+ PyAPI_FUNC(int) _PyTime_AsTimeval_noraise(_PyTime_t t,
132
+ struct timeval *tv,
133
+ _PyTime_round_t round);
134
+
135
+ /* Convert a timestamp to a number of seconds (secs) and microseconds (us).
136
+ us is always positive. This function is similar to _PyTime_AsTimeval()
137
+ except that secs is always a time_t type, whereas the timeval structure
138
+ uses a C long for tv_sec on Windows.
139
+ Raise an exception and return -1 if the conversion overflowed,
140
+ return 0 on success. */
141
+ PyAPI_FUNC(int) _PyTime_AsTimevalTime_t(
142
+ _PyTime_t t,
143
+ time_t *secs,
144
+ int *us,
145
+ _PyTime_round_t round);
146
+
147
+ #if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_KQUEUE)
148
+ /* Create a timestamp from a timespec structure.
149
+ Raise an exception and return -1 on overflow, return 0 on success. */
150
+ PyAPI_FUNC(int) _PyTime_FromTimespec(_PyTime_t *tp, struct timespec *ts);
151
+
152
+ /* Convert a timestamp to a timespec structure (nanosecond resolution).
153
+ tv_nsec is always positive.
154
+ Raise an exception and return -1 on error, return 0 on success. */
155
+ PyAPI_FUNC(int) _PyTime_AsTimespec(_PyTime_t t, struct timespec *ts);
156
+ #endif
157
+
158
+ /* Compute ticks * mul / div.
159
+ The caller must ensure that ((div - 1) * mul) cannot overflow. */
160
+ PyAPI_FUNC(_PyTime_t) _PyTime_MulDiv(_PyTime_t ticks,
161
+ _PyTime_t mul,
162
+ _PyTime_t div);
163
+
164
+ /* Structure used by time.get_clock_info() */
165
+ typedef struct {
166
+ const char *implementation;
167
+ int monotonic;
168
+ int adjustable;
169
+ double resolution;
170
+ } _Py_clock_info_t;
171
+
172
+ /* Get the current time from the system clock.
173
+
174
+ If the internal clock fails, silently ignore the error and return 0.
175
+ On integer overflow, silently ignore the overflow and truncated the clock to
176
+ _PyTime_MIN or _PyTime_MAX.
177
+
178
+ Use _PyTime_GetSystemClockWithInfo() to check for failure. */
179
+ PyAPI_FUNC(_PyTime_t) _PyTime_GetSystemClock(void);
180
+
181
+ /* Get the current time from the system clock.
182
+ * On success, set *t and *info (if not NULL), and return 0.
183
+ * On error, raise an exception and return -1.
184
+ */
185
+ PyAPI_FUNC(int) _PyTime_GetSystemClockWithInfo(
186
+ _PyTime_t *t,
187
+ _Py_clock_info_t *info);
188
+
189
+ /* Get the time of a monotonic clock, i.e. a clock that cannot go backwards.
190
+ The clock is not affected by system clock updates. The reference point of
191
+ the returned value is undefined, so that only the difference between the
192
+ results of consecutive calls is valid.
193
+
194
+ If the internal clock fails, silently ignore the error and return 0.
195
+ On integer overflow, silently ignore the overflow and truncated the clock to
196
+ _PyTime_MIN or _PyTime_MAX.
197
+
198
+ Use _PyTime_GetMonotonicClockWithInfo() to check for failure. */
199
+ PyAPI_FUNC(_PyTime_t) _PyTime_GetMonotonicClock(void);
200
+
201
+ /* Get the time of a monotonic clock, i.e. a clock that cannot go backwards.
202
+ The clock is not affected by system clock updates. The reference point of
203
+ the returned value is undefined, so that only the difference between the
204
+ results of consecutive calls is valid.
205
+
206
+ Fill info (if set) with information of the function used to get the time.
207
+
208
+ Return 0 on success, raise an exception and return -1 on error. */
209
+ PyAPI_FUNC(int) _PyTime_GetMonotonicClockWithInfo(
210
+ _PyTime_t *t,
211
+ _Py_clock_info_t *info);
212
+
213
+
214
+ /* Converts a timestamp to the Gregorian time, using the local time zone.
215
+ Return 0 on success, raise an exception and return -1 on error. */
216
+ PyAPI_FUNC(int) _PyTime_localtime(time_t t, struct tm *tm);
217
+
218
+ /* Converts a timestamp to the Gregorian time, assuming UTC.
219
+ Return 0 on success, raise an exception and return -1 on error. */
220
+ PyAPI_FUNC(int) _PyTime_gmtime(time_t t, struct tm *tm);
221
+
222
+ /* Get the performance counter: clock with the highest available resolution to
223
+ measure a short duration.
224
+
225
+ If the internal clock fails, silently ignore the error and return 0.
226
+ On integer overflow, silently ignore the overflow and truncated the clock to
227
+ _PyTime_MIN or _PyTime_MAX.
228
+
229
+ Use _PyTime_GetPerfCounterWithInfo() to check for failure. */
230
+ PyAPI_FUNC(_PyTime_t) _PyTime_GetPerfCounter(void);
231
+
232
+ /* Get the performance counter: clock with the highest available resolution to
233
+ measure a short duration.
234
+
235
+ Fill info (if set) with information of the function used to get the time.
236
+
237
+ Return 0 on success, raise an exception and return -1 on error. */
238
+ PyAPI_FUNC(int) _PyTime_GetPerfCounterWithInfo(
239
+ _PyTime_t *t,
240
+ _Py_clock_info_t *info);
241
+
242
+ #ifdef __cplusplus
243
+ }
244
+ #endif
245
+
246
+ #endif /* Py_PYTIME_H */
247
+ #endif /* Py_LIMITED_API */
llava_next/include/python3.10/cpython/sysmodule.h ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_CPYTHON_SYSMODULE_H
2
+ # error "this header file must not be included directly"
3
+ #endif
4
+
5
+ PyAPI_FUNC(PyObject *) _PySys_GetObjectId(_Py_Identifier *key);
6
+ PyAPI_FUNC(int) _PySys_SetObjectId(_Py_Identifier *key, PyObject *);
7
+
8
+ PyAPI_FUNC(size_t) _PySys_GetSizeOf(PyObject *);
9
+
10
+ typedef int(*Py_AuditHookFunction)(const char *, PyObject *, void *);
11
+
12
+ PyAPI_FUNC(int) PySys_Audit(
13
+ const char *event,
14
+ const char *argFormat,
15
+ ...);
16
+ PyAPI_FUNC(int) PySys_AddAuditHook(Py_AuditHookFunction, void*);
llava_next/include/python3.10/cpython/traceback.h ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_CPYTHON_TRACEBACK_H
2
+ # error "this header file must not be included directly"
3
+ #endif
4
+
5
+ typedef struct _traceback {
6
+ PyObject_HEAD
7
+ struct _traceback *tb_next;
8
+ PyFrameObject *tb_frame;
9
+ int tb_lasti;
10
+ int tb_lineno;
11
+ } PyTracebackObject;
12
+
13
+ PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, PyObject *, int, int);
14
+ PyAPI_FUNC(void) _PyTraceback_Add(const char *, const char *, int);
llava_next/include/python3.10/cpython/tupleobject.h ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_CPYTHON_TUPLEOBJECT_H
2
+ # error "this header file must not be included directly"
3
+ #endif
4
+
5
+ typedef struct {
6
+ PyObject_VAR_HEAD
7
+ /* ob_item contains space for 'ob_size' elements.
8
+ Items must normally not be NULL, except during construction when
9
+ the tuple is not yet visible outside the function that builds it. */
10
+ PyObject *ob_item[1];
11
+ } PyTupleObject;
12
+
13
+ PyAPI_FUNC(int) _PyTuple_Resize(PyObject **, Py_ssize_t);
14
+ PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *);
15
+
16
+ /* Macros trading safety for speed */
17
+
18
+ /* Cast argument to PyTupleObject* type. */
19
+ #define _PyTuple_CAST(op) (assert(PyTuple_Check(op)), (PyTupleObject *)(op))
20
+
21
+ #define PyTuple_GET_SIZE(op) Py_SIZE(_PyTuple_CAST(op))
22
+
23
+ #define PyTuple_GET_ITEM(op, i) (_PyTuple_CAST(op)->ob_item[i])
24
+
25
+ /* Macro, *only* to be used to fill in brand new tuples */
26
+ #define PyTuple_SET_ITEM(op, i, v) ((void)(_PyTuple_CAST(op)->ob_item[i] = v))
27
+
28
+ PyAPI_FUNC(void) _PyTuple_DebugMallocStats(FILE *out);
llava_next/include/python3.10/cpython/unicodeobject.h ADDED
@@ -0,0 +1,1169 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_CPYTHON_UNICODEOBJECT_H
2
+ # error "this header file must not be included directly"
3
+ #endif
4
+
5
+ /* Py_UNICODE was the native Unicode storage format (code unit) used by
6
+ Python and represents a single Unicode element in the Unicode type.
7
+ With PEP 393, Py_UNICODE is deprecated and replaced with a
8
+ typedef to wchar_t. */
9
+ #define PY_UNICODE_TYPE wchar_t
10
+ /* Py_DEPRECATED(3.3) */ typedef wchar_t Py_UNICODE;
11
+
12
+ /* --- Internal Unicode Operations ---------------------------------------- */
13
+
14
+ #ifndef USE_UNICODE_WCHAR_CACHE
15
+ # define USE_UNICODE_WCHAR_CACHE 1
16
+ #endif /* USE_UNICODE_WCHAR_CACHE */
17
+
18
+ /* Since splitting on whitespace is an important use case, and
19
+ whitespace in most situations is solely ASCII whitespace, we
20
+ optimize for the common case by using a quick look-up table
21
+ _Py_ascii_whitespace (see below) with an inlined check.
22
+
23
+ */
24
+ #define Py_UNICODE_ISSPACE(ch) \
25
+ ((Py_UCS4)(ch) < 128U ? _Py_ascii_whitespace[(ch)] : _PyUnicode_IsWhitespace(ch))
26
+
27
+ #define Py_UNICODE_ISLOWER(ch) _PyUnicode_IsLowercase(ch)
28
+ #define Py_UNICODE_ISUPPER(ch) _PyUnicode_IsUppercase(ch)
29
+ #define Py_UNICODE_ISTITLE(ch) _PyUnicode_IsTitlecase(ch)
30
+ #define Py_UNICODE_ISLINEBREAK(ch) _PyUnicode_IsLinebreak(ch)
31
+
32
+ #define Py_UNICODE_TOLOWER(ch) _PyUnicode_ToLowercase(ch)
33
+ #define Py_UNICODE_TOUPPER(ch) _PyUnicode_ToUppercase(ch)
34
+ #define Py_UNICODE_TOTITLE(ch) _PyUnicode_ToTitlecase(ch)
35
+
36
+ #define Py_UNICODE_ISDECIMAL(ch) _PyUnicode_IsDecimalDigit(ch)
37
+ #define Py_UNICODE_ISDIGIT(ch) _PyUnicode_IsDigit(ch)
38
+ #define Py_UNICODE_ISNUMERIC(ch) _PyUnicode_IsNumeric(ch)
39
+ #define Py_UNICODE_ISPRINTABLE(ch) _PyUnicode_IsPrintable(ch)
40
+
41
+ #define Py_UNICODE_TODECIMAL(ch) _PyUnicode_ToDecimalDigit(ch)
42
+ #define Py_UNICODE_TODIGIT(ch) _PyUnicode_ToDigit(ch)
43
+ #define Py_UNICODE_TONUMERIC(ch) _PyUnicode_ToNumeric(ch)
44
+
45
+ #define Py_UNICODE_ISALPHA(ch) _PyUnicode_IsAlpha(ch)
46
+
47
+ #define Py_UNICODE_ISALNUM(ch) \
48
+ (Py_UNICODE_ISALPHA(ch) || \
49
+ Py_UNICODE_ISDECIMAL(ch) || \
50
+ Py_UNICODE_ISDIGIT(ch) || \
51
+ Py_UNICODE_ISNUMERIC(ch))
52
+
53
+ Py_DEPRECATED(3.3) static inline void
54
+ Py_UNICODE_COPY(Py_UNICODE *target, const Py_UNICODE *source, Py_ssize_t length) {
55
+ memcpy(target, source, (size_t)(length) * sizeof(Py_UNICODE));
56
+ }
57
+
58
+ Py_DEPRECATED(3.3) static inline void
59
+ Py_UNICODE_FILL(Py_UNICODE *target, Py_UNICODE value, Py_ssize_t length) {
60
+ Py_ssize_t i;
61
+ for (i = 0; i < length; i++) {
62
+ target[i] = value;
63
+ }
64
+ }
65
+
66
+ /* macros to work with surrogates */
67
+ #define Py_UNICODE_IS_SURROGATE(ch) (0xD800 <= (ch) && (ch) <= 0xDFFF)
68
+ #define Py_UNICODE_IS_HIGH_SURROGATE(ch) (0xD800 <= (ch) && (ch) <= 0xDBFF)
69
+ #define Py_UNICODE_IS_LOW_SURROGATE(ch) (0xDC00 <= (ch) && (ch) <= 0xDFFF)
70
+ /* Join two surrogate characters and return a single Py_UCS4 value. */
71
+ #define Py_UNICODE_JOIN_SURROGATES(high, low) \
72
+ (((((Py_UCS4)(high) & 0x03FF) << 10) | \
73
+ ((Py_UCS4)(low) & 0x03FF)) + 0x10000)
74
+ /* high surrogate = top 10 bits added to D800 */
75
+ #define Py_UNICODE_HIGH_SURROGATE(ch) (0xD800 - (0x10000 >> 10) + ((ch) >> 10))
76
+ /* low surrogate = bottom 10 bits added to DC00 */
77
+ #define Py_UNICODE_LOW_SURROGATE(ch) (0xDC00 + ((ch) & 0x3FF))
78
+
79
+ /* --- Unicode Type ------------------------------------------------------- */
80
+
81
+ /* ASCII-only strings created through PyUnicode_New use the PyASCIIObject
82
+ structure. state.ascii and state.compact are set, and the data
83
+ immediately follow the structure. utf8_length and wstr_length can be found
84
+ in the length field; the utf8 pointer is equal to the data pointer. */
85
+ typedef struct {
86
+ /* There are 4 forms of Unicode strings:
87
+
88
+ - compact ascii:
89
+
90
+ * structure = PyASCIIObject
91
+ * test: PyUnicode_IS_COMPACT_ASCII(op)
92
+ * kind = PyUnicode_1BYTE_KIND
93
+ * compact = 1
94
+ * ascii = 1
95
+ * ready = 1
96
+ * (length is the length of the utf8 and wstr strings)
97
+ * (data starts just after the structure)
98
+ * (since ASCII is decoded from UTF-8, the utf8 string are the data)
99
+
100
+ - compact:
101
+
102
+ * structure = PyCompactUnicodeObject
103
+ * test: PyUnicode_IS_COMPACT(op) && !PyUnicode_IS_ASCII(op)
104
+ * kind = PyUnicode_1BYTE_KIND, PyUnicode_2BYTE_KIND or
105
+ PyUnicode_4BYTE_KIND
106
+ * compact = 1
107
+ * ready = 1
108
+ * ascii = 0
109
+ * utf8 is not shared with data
110
+ * utf8_length = 0 if utf8 is NULL
111
+ * wstr is shared with data and wstr_length=length
112
+ if kind=PyUnicode_2BYTE_KIND and sizeof(wchar_t)=2
113
+ or if kind=PyUnicode_4BYTE_KIND and sizeof(wchar_t)=4
114
+ * wstr_length = 0 if wstr is NULL
115
+ * (data starts just after the structure)
116
+
117
+ - legacy string, not ready:
118
+
119
+ * structure = PyUnicodeObject
120
+ * test: kind == PyUnicode_WCHAR_KIND
121
+ * length = 0 (use wstr_length)
122
+ * hash = -1
123
+ * kind = PyUnicode_WCHAR_KIND
124
+ * compact = 0
125
+ * ascii = 0
126
+ * ready = 0
127
+ * interned = SSTATE_NOT_INTERNED
128
+ * wstr is not NULL
129
+ * data.any is NULL
130
+ * utf8 is NULL
131
+ * utf8_length = 0
132
+
133
+ - legacy string, ready:
134
+
135
+ * structure = PyUnicodeObject structure
136
+ * test: !PyUnicode_IS_COMPACT(op) && kind != PyUnicode_WCHAR_KIND
137
+ * kind = PyUnicode_1BYTE_KIND, PyUnicode_2BYTE_KIND or
138
+ PyUnicode_4BYTE_KIND
139
+ * compact = 0
140
+ * ready = 1
141
+ * data.any is not NULL
142
+ * utf8 is shared and utf8_length = length with data.any if ascii = 1
143
+ * utf8_length = 0 if utf8 is NULL
144
+ * wstr is shared with data.any and wstr_length = length
145
+ if kind=PyUnicode_2BYTE_KIND and sizeof(wchar_t)=2
146
+ or if kind=PyUnicode_4BYTE_KIND and sizeof(wchar_4)=4
147
+ * wstr_length = 0 if wstr is NULL
148
+
149
+ Compact strings use only one memory block (structure + characters),
150
+ whereas legacy strings use one block for the structure and one block
151
+ for characters.
152
+
153
+ Legacy strings are created by PyUnicode_FromUnicode() and
154
+ PyUnicode_FromStringAndSize(NULL, size) functions. They become ready
155
+ when PyUnicode_READY() is called.
156
+
157
+ See also _PyUnicode_CheckConsistency().
158
+ */
159
+ PyObject_HEAD
160
+ Py_ssize_t length; /* Number of code points in the string */
161
+ Py_hash_t hash; /* Hash value; -1 if not set */
162
+ struct {
163
+ /*
164
+ SSTATE_NOT_INTERNED (0)
165
+ SSTATE_INTERNED_MORTAL (1)
166
+ SSTATE_INTERNED_IMMORTAL (2)
167
+
168
+ If interned != SSTATE_NOT_INTERNED, the two references from the
169
+ dictionary to this object are *not* counted in ob_refcnt.
170
+ */
171
+ unsigned int interned:2;
172
+ /* Character size:
173
+
174
+ - PyUnicode_WCHAR_KIND (0):
175
+
176
+ * character type = wchar_t (16 or 32 bits, depending on the
177
+ platform)
178
+
179
+ - PyUnicode_1BYTE_KIND (1):
180
+
181
+ * character type = Py_UCS1 (8 bits, unsigned)
182
+ * all characters are in the range U+0000-U+00FF (latin1)
183
+ * if ascii is set, all characters are in the range U+0000-U+007F
184
+ (ASCII), otherwise at least one character is in the range
185
+ U+0080-U+00FF
186
+
187
+ - PyUnicode_2BYTE_KIND (2):
188
+
189
+ * character type = Py_UCS2 (16 bits, unsigned)
190
+ * all characters are in the range U+0000-U+FFFF (BMP)
191
+ * at least one character is in the range U+0100-U+FFFF
192
+
193
+ - PyUnicode_4BYTE_KIND (4):
194
+
195
+ * character type = Py_UCS4 (32 bits, unsigned)
196
+ * all characters are in the range U+0000-U+10FFFF
197
+ * at least one character is in the range U+10000-U+10FFFF
198
+ */
199
+ unsigned int kind:3;
200
+ /* Compact is with respect to the allocation scheme. Compact unicode
201
+ objects only require one memory block while non-compact objects use
202
+ one block for the PyUnicodeObject struct and another for its data
203
+ buffer. */
204
+ unsigned int compact:1;
205
+ /* The string only contains characters in the range U+0000-U+007F (ASCII)
206
+ and the kind is PyUnicode_1BYTE_KIND. If ascii is set and compact is
207
+ set, use the PyASCIIObject structure. */
208
+ unsigned int ascii:1;
209
+ /* The ready flag indicates whether the object layout is initialized
210
+ completely. This means that this is either a compact object, or
211
+ the data pointer is filled out. The bit is redundant, and helps
212
+ to minimize the test in PyUnicode_IS_READY(). */
213
+ unsigned int ready:1;
214
+ /* Padding to ensure that PyUnicode_DATA() is always aligned to
215
+ 4 bytes (see issue #19537 on m68k). */
216
+ unsigned int :24;
217
+ } state;
218
+ wchar_t *wstr; /* wchar_t representation (null-terminated) */
219
+ } PyASCIIObject;
220
+
221
+ /* Non-ASCII strings allocated through PyUnicode_New use the
222
+ PyCompactUnicodeObject structure. state.compact is set, and the data
223
+ immediately follow the structure. */
224
+ typedef struct {
225
+ PyASCIIObject _base;
226
+ Py_ssize_t utf8_length; /* Number of bytes in utf8, excluding the
227
+ * terminating \0. */
228
+ char *utf8; /* UTF-8 representation (null-terminated) */
229
+ Py_ssize_t wstr_length; /* Number of code points in wstr, possible
230
+ * surrogates count as two code points. */
231
+ } PyCompactUnicodeObject;
232
+
233
+ /* Strings allocated through PyUnicode_FromUnicode(NULL, len) use the
234
+ PyUnicodeObject structure. The actual string data is initially in the wstr
235
+ block, and copied into the data block using _PyUnicode_Ready. */
236
+ typedef struct {
237
+ PyCompactUnicodeObject _base;
238
+ union {
239
+ void *any;
240
+ Py_UCS1 *latin1;
241
+ Py_UCS2 *ucs2;
242
+ Py_UCS4 *ucs4;
243
+ } data; /* Canonical, smallest-form Unicode buffer */
244
+ } PyUnicodeObject;
245
+
246
+ PyAPI_FUNC(int) _PyUnicode_CheckConsistency(
247
+ PyObject *op,
248
+ int check_content);
249
+
250
+ /* Fast access macros */
251
+
252
+ /* Returns the deprecated Py_UNICODE representation's size in code units
253
+ (this includes surrogate pairs as 2 units).
254
+ If the Py_UNICODE representation is not available, it will be computed
255
+ on request. Use PyUnicode_GET_LENGTH() for the length in code points. */
256
+
257
+ /* Py_DEPRECATED(3.3) */
258
+ #define PyUnicode_GET_SIZE(op) \
259
+ (assert(PyUnicode_Check(op)), \
260
+ (((PyASCIIObject *)(op))->wstr) ? \
261
+ PyUnicode_WSTR_LENGTH(op) : \
262
+ ((void)PyUnicode_AsUnicode(_PyObject_CAST(op)),\
263
+ assert(((PyASCIIObject *)(op))->wstr), \
264
+ PyUnicode_WSTR_LENGTH(op)))
265
+
266
+ /* Py_DEPRECATED(3.3) */
267
+ #define PyUnicode_GET_DATA_SIZE(op) \
268
+ (PyUnicode_GET_SIZE(op) * Py_UNICODE_SIZE)
269
+
270
+ /* Alias for PyUnicode_AsUnicode(). This will create a wchar_t/Py_UNICODE
271
+ representation on demand. Using this macro is very inefficient now,
272
+ try to port your code to use the new PyUnicode_*BYTE_DATA() macros or
273
+ use PyUnicode_WRITE() and PyUnicode_READ(). */
274
+
275
+ /* Py_DEPRECATED(3.3) */
276
+ #define PyUnicode_AS_UNICODE(op) \
277
+ (assert(PyUnicode_Check(op)), \
278
+ (((PyASCIIObject *)(op))->wstr) ? (((PyASCIIObject *)(op))->wstr) : \
279
+ PyUnicode_AsUnicode(_PyObject_CAST(op)))
280
+
281
+ /* Py_DEPRECATED(3.3) */
282
+ #define PyUnicode_AS_DATA(op) \
283
+ ((const char *)(PyUnicode_AS_UNICODE(op)))
284
+
285
+
286
+ /* --- Flexible String Representation Helper Macros (PEP 393) -------------- */
287
+
288
+ /* Values for PyASCIIObject.state: */
289
+
290
+ /* Interning state. */
291
+ #define SSTATE_NOT_INTERNED 0
292
+ #define SSTATE_INTERNED_MORTAL 1
293
+ #define SSTATE_INTERNED_IMMORTAL 2
294
+
295
+ /* Return true if the string contains only ASCII characters, or 0 if not. The
296
+ string may be compact (PyUnicode_IS_COMPACT_ASCII) or not, but must be
297
+ ready. */
298
+ #define PyUnicode_IS_ASCII(op) \
299
+ (assert(PyUnicode_Check(op)), \
300
+ assert(PyUnicode_IS_READY(op)), \
301
+ ((PyASCIIObject*)op)->state.ascii)
302
+
303
+ /* Return true if the string is compact or 0 if not.
304
+ No type checks or Ready calls are performed. */
305
+ #define PyUnicode_IS_COMPACT(op) \
306
+ (((PyASCIIObject*)(op))->state.compact)
307
+
308
+ /* Return true if the string is a compact ASCII string (use PyASCIIObject
309
+ structure), or 0 if not. No type checks or Ready calls are performed. */
310
+ #define PyUnicode_IS_COMPACT_ASCII(op) \
311
+ (((PyASCIIObject*)op)->state.ascii && PyUnicode_IS_COMPACT(op))
312
+
313
+ enum PyUnicode_Kind {
314
+ /* String contains only wstr byte characters. This is only possible
315
+ when the string was created with a legacy API and _PyUnicode_Ready()
316
+ has not been called yet. */
317
+ PyUnicode_WCHAR_KIND = 0,
318
+ /* Return values of the PyUnicode_KIND() macro: */
319
+ PyUnicode_1BYTE_KIND = 1,
320
+ PyUnicode_2BYTE_KIND = 2,
321
+ PyUnicode_4BYTE_KIND = 4
322
+ };
323
+
324
+ /* Return pointers to the canonical representation cast to unsigned char,
325
+ Py_UCS2, or Py_UCS4 for direct character access.
326
+ No checks are performed, use PyUnicode_KIND() before to ensure
327
+ these will work correctly. */
328
+
329
+ #define PyUnicode_1BYTE_DATA(op) ((Py_UCS1*)PyUnicode_DATA(op))
330
+ #define PyUnicode_2BYTE_DATA(op) ((Py_UCS2*)PyUnicode_DATA(op))
331
+ #define PyUnicode_4BYTE_DATA(op) ((Py_UCS4*)PyUnicode_DATA(op))
332
+
333
+ /* Return one of the PyUnicode_*_KIND values defined above. */
334
+ #define PyUnicode_KIND(op) \
335
+ (assert(PyUnicode_Check(op)), \
336
+ assert(PyUnicode_IS_READY(op)), \
337
+ ((PyASCIIObject *)(op))->state.kind)
338
+
339
+ /* Return a void pointer to the raw unicode buffer. */
340
+ #define _PyUnicode_COMPACT_DATA(op) \
341
+ (PyUnicode_IS_ASCII(op) ? \
342
+ ((void*)((PyASCIIObject*)(op) + 1)) : \
343
+ ((void*)((PyCompactUnicodeObject*)(op) + 1)))
344
+
345
+ #define _PyUnicode_NONCOMPACT_DATA(op) \
346
+ (assert(((PyUnicodeObject*)(op))->data.any), \
347
+ ((((PyUnicodeObject *)(op))->data.any)))
348
+
349
+ #define PyUnicode_DATA(op) \
350
+ (assert(PyUnicode_Check(op)), \
351
+ PyUnicode_IS_COMPACT(op) ? _PyUnicode_COMPACT_DATA(op) : \
352
+ _PyUnicode_NONCOMPACT_DATA(op))
353
+
354
+ /* In the access macros below, "kind" may be evaluated more than once.
355
+ All other macro parameters are evaluated exactly once, so it is safe
356
+ to put side effects into them (such as increasing the index). */
357
+
358
+ /* Write into the canonical representation, this macro does not do any sanity
359
+ checks and is intended for usage in loops. The caller should cache the
360
+ kind and data pointers obtained from other macro calls.
361
+ index is the index in the string (starts at 0) and value is the new
362
+ code point value which should be written to that location. */
363
+ #define PyUnicode_WRITE(kind, data, index, value) \
364
+ do { \
365
+ switch ((kind)) { \
366
+ case PyUnicode_1BYTE_KIND: { \
367
+ ((Py_UCS1 *)(data))[(index)] = (Py_UCS1)(value); \
368
+ break; \
369
+ } \
370
+ case PyUnicode_2BYTE_KIND: { \
371
+ ((Py_UCS2 *)(data))[(index)] = (Py_UCS2)(value); \
372
+ break; \
373
+ } \
374
+ default: { \
375
+ assert((kind) == PyUnicode_4BYTE_KIND); \
376
+ ((Py_UCS4 *)(data))[(index)] = (Py_UCS4)(value); \
377
+ } \
378
+ } \
379
+ } while (0)
380
+
381
+ /* Read a code point from the string's canonical representation. No checks
382
+ or ready calls are performed. */
383
+ #define PyUnicode_READ(kind, data, index) \
384
+ ((Py_UCS4) \
385
+ ((kind) == PyUnicode_1BYTE_KIND ? \
386
+ ((const Py_UCS1 *)(data))[(index)] : \
387
+ ((kind) == PyUnicode_2BYTE_KIND ? \
388
+ ((const Py_UCS2 *)(data))[(index)] : \
389
+ ((const Py_UCS4 *)(data))[(index)] \
390
+ ) \
391
+ ))
392
+
393
+ /* PyUnicode_READ_CHAR() is less efficient than PyUnicode_READ() because it
394
+ calls PyUnicode_KIND() and might call it twice. For single reads, use
395
+ PyUnicode_READ_CHAR, for multiple consecutive reads callers should
396
+ cache kind and use PyUnicode_READ instead. */
397
+ #define PyUnicode_READ_CHAR(unicode, index) \
398
+ (assert(PyUnicode_Check(unicode)), \
399
+ assert(PyUnicode_IS_READY(unicode)), \
400
+ (Py_UCS4) \
401
+ (PyUnicode_KIND((unicode)) == PyUnicode_1BYTE_KIND ? \
402
+ ((const Py_UCS1 *)(PyUnicode_DATA((unicode))))[(index)] : \
403
+ (PyUnicode_KIND((unicode)) == PyUnicode_2BYTE_KIND ? \
404
+ ((const Py_UCS2 *)(PyUnicode_DATA((unicode))))[(index)] : \
405
+ ((const Py_UCS4 *)(PyUnicode_DATA((unicode))))[(index)] \
406
+ ) \
407
+ ))
408
+
409
+ /* Returns the length of the unicode string. The caller has to make sure that
410
+ the string has it's canonical representation set before calling
411
+ this macro. Call PyUnicode_(FAST_)Ready to ensure that. */
412
+ #define PyUnicode_GET_LENGTH(op) \
413
+ (assert(PyUnicode_Check(op)), \
414
+ assert(PyUnicode_IS_READY(op)), \
415
+ ((PyASCIIObject *)(op))->length)
416
+
417
+
418
+ /* Fast check to determine whether an object is ready. Equivalent to
419
+ PyUnicode_IS_COMPACT(op) || ((PyUnicodeObject*)(op))->data.any */
420
+
421
+ #define PyUnicode_IS_READY(op) (((PyASCIIObject*)op)->state.ready)
422
+
423
+ /* PyUnicode_READY() does less work than _PyUnicode_Ready() in the best
424
+ case. If the canonical representation is not yet set, it will still call
425
+ _PyUnicode_Ready().
426
+ Returns 0 on success and -1 on errors. */
427
+ #define PyUnicode_READY(op) \
428
+ (assert(PyUnicode_Check(op)), \
429
+ (PyUnicode_IS_READY(op) ? \
430
+ 0 : _PyUnicode_Ready(_PyObject_CAST(op))))
431
+
432
+ /* Return a maximum character value which is suitable for creating another
433
+ string based on op. This is always an approximation but more efficient
434
+ than iterating over the string. */
435
+ #define PyUnicode_MAX_CHAR_VALUE(op) \
436
+ (assert(PyUnicode_IS_READY(op)), \
437
+ (PyUnicode_IS_ASCII(op) ? \
438
+ (0x7f) : \
439
+ (PyUnicode_KIND(op) == PyUnicode_1BYTE_KIND ? \
440
+ (0xffU) : \
441
+ (PyUnicode_KIND(op) == PyUnicode_2BYTE_KIND ? \
442
+ (0xffffU) : \
443
+ (0x10ffffU)))))
444
+
445
+ Py_DEPRECATED(3.3)
446
+ static inline Py_ssize_t _PyUnicode_get_wstr_length(PyObject *op) {
447
+ return PyUnicode_IS_COMPACT_ASCII(op) ?
448
+ ((PyASCIIObject*)op)->length :
449
+ ((PyCompactUnicodeObject*)op)->wstr_length;
450
+ }
451
+ #define PyUnicode_WSTR_LENGTH(op) _PyUnicode_get_wstr_length((PyObject*)op)
452
+
453
+ /* === Public API ========================================================= */
454
+
455
+ /* --- Plain Py_UNICODE --------------------------------------------------- */
456
+
457
+ /* With PEP 393, this is the recommended way to allocate a new unicode object.
458
+ This function will allocate the object and its buffer in a single memory
459
+ block. Objects created using this function are not resizable. */
460
+ PyAPI_FUNC(PyObject*) PyUnicode_New(
461
+ Py_ssize_t size, /* Number of code points in the new string */
462
+ Py_UCS4 maxchar /* maximum code point value in the string */
463
+ );
464
+
465
+ /* Initializes the canonical string representation from the deprecated
466
+ wstr/Py_UNICODE representation. This function is used to convert Unicode
467
+ objects which were created using the old API to the new flexible format
468
+ introduced with PEP 393.
469
+
470
+ Don't call this function directly, use the public PyUnicode_READY() macro
471
+ instead. */
472
+ PyAPI_FUNC(int) _PyUnicode_Ready(
473
+ PyObject *unicode /* Unicode object */
474
+ );
475
+
476
+ /* Get a copy of a Unicode string. */
477
+ PyAPI_FUNC(PyObject*) _PyUnicode_Copy(
478
+ PyObject *unicode
479
+ );
480
+
481
+ /* Copy character from one unicode object into another, this function performs
482
+ character conversion when necessary and falls back to memcpy() if possible.
483
+
484
+ Fail if to is too small (smaller than *how_many* or smaller than
485
+ len(from)-from_start), or if kind(from[from_start:from_start+how_many]) >
486
+ kind(to), or if *to* has more than 1 reference.
487
+
488
+ Return the number of written character, or return -1 and raise an exception
489
+ on error.
490
+
491
+ Pseudo-code:
492
+
493
+ how_many = min(how_many, len(from) - from_start)
494
+ to[to_start:to_start+how_many] = from[from_start:from_start+how_many]
495
+ return how_many
496
+
497
+ Note: The function doesn't write a terminating null character.
498
+ */
499
+ PyAPI_FUNC(Py_ssize_t) PyUnicode_CopyCharacters(
500
+ PyObject *to,
501
+ Py_ssize_t to_start,
502
+ PyObject *from,
503
+ Py_ssize_t from_start,
504
+ Py_ssize_t how_many
505
+ );
506
+
507
+ /* Unsafe version of PyUnicode_CopyCharacters(): don't check arguments and so
508
+ may crash if parameters are invalid (e.g. if the output string
509
+ is too short). */
510
+ PyAPI_FUNC(void) _PyUnicode_FastCopyCharacters(
511
+ PyObject *to,
512
+ Py_ssize_t to_start,
513
+ PyObject *from,
514
+ Py_ssize_t from_start,
515
+ Py_ssize_t how_many
516
+ );
517
+
518
+ /* Fill a string with a character: write fill_char into
519
+ unicode[start:start+length].
520
+
521
+ Fail if fill_char is bigger than the string maximum character, or if the
522
+ string has more than 1 reference.
523
+
524
+ Return the number of written character, or return -1 and raise an exception
525
+ on error. */
526
+ PyAPI_FUNC(Py_ssize_t) PyUnicode_Fill(
527
+ PyObject *unicode,
528
+ Py_ssize_t start,
529
+ Py_ssize_t length,
530
+ Py_UCS4 fill_char
531
+ );
532
+
533
+ /* Unsafe version of PyUnicode_Fill(): don't check arguments and so may crash
534
+ if parameters are invalid (e.g. if length is longer than the string). */
535
+ PyAPI_FUNC(void) _PyUnicode_FastFill(
536
+ PyObject *unicode,
537
+ Py_ssize_t start,
538
+ Py_ssize_t length,
539
+ Py_UCS4 fill_char
540
+ );
541
+
542
+ /* Create a Unicode Object from the Py_UNICODE buffer u of the given
543
+ size.
544
+
545
+ u may be NULL which causes the contents to be undefined. It is the
546
+ user's responsibility to fill in the needed data afterwards. Note
547
+ that modifying the Unicode object contents after construction is
548
+ only allowed if u was set to NULL.
549
+
550
+ The buffer is copied into the new object. */
551
+ Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_FromUnicode(
552
+ const Py_UNICODE *u, /* Unicode buffer */
553
+ Py_ssize_t size /* size of buffer */
554
+ );
555
+
556
+ /* Create a new string from a buffer of Py_UCS1, Py_UCS2 or Py_UCS4 characters.
557
+ Scan the string to find the maximum character. */
558
+ PyAPI_FUNC(PyObject*) PyUnicode_FromKindAndData(
559
+ int kind,
560
+ const void *buffer,
561
+ Py_ssize_t size);
562
+
563
+ /* Create a new string from a buffer of ASCII characters.
564
+ WARNING: Don't check if the string contains any non-ASCII character. */
565
+ PyAPI_FUNC(PyObject*) _PyUnicode_FromASCII(
566
+ const char *buffer,
567
+ Py_ssize_t size);
568
+
569
+ /* Compute the maximum character of the substring unicode[start:end].
570
+ Return 127 for an empty string. */
571
+ PyAPI_FUNC(Py_UCS4) _PyUnicode_FindMaxChar (
572
+ PyObject *unicode,
573
+ Py_ssize_t start,
574
+ Py_ssize_t end);
575
+
576
+ /* Return a read-only pointer to the Unicode object's internal
577
+ Py_UNICODE buffer.
578
+ If the wchar_t/Py_UNICODE representation is not yet available, this
579
+ function will calculate it. */
580
+ Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicode(
581
+ PyObject *unicode /* Unicode object */
582
+ );
583
+
584
+ /* Similar to PyUnicode_AsUnicode(), but raises a ValueError if the string
585
+ contains null characters. */
586
+ PyAPI_FUNC(const Py_UNICODE *) _PyUnicode_AsUnicode(
587
+ PyObject *unicode /* Unicode object */
588
+ );
589
+
590
+ /* Return a read-only pointer to the Unicode object's internal
591
+ Py_UNICODE buffer and save the length at size.
592
+ If the wchar_t/Py_UNICODE representation is not yet available, this
593
+ function will calculate it. */
594
+
595
+ Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UNICODE *) PyUnicode_AsUnicodeAndSize(
596
+ PyObject *unicode, /* Unicode object */
597
+ Py_ssize_t *size /* location where to save the length */
598
+ );
599
+
600
+
601
+ /* --- _PyUnicodeWriter API ----------------------------------------------- */
602
+
603
+ typedef struct {
604
+ PyObject *buffer;
605
+ void *data;
606
+ enum PyUnicode_Kind kind;
607
+ Py_UCS4 maxchar;
608
+ Py_ssize_t size;
609
+ Py_ssize_t pos;
610
+
611
+ /* minimum number of allocated characters (default: 0) */
612
+ Py_ssize_t min_length;
613
+
614
+ /* minimum character (default: 127, ASCII) */
615
+ Py_UCS4 min_char;
616
+
617
+ /* If non-zero, overallocate the buffer (default: 0). */
618
+ unsigned char overallocate;
619
+
620
+ /* If readonly is 1, buffer is a shared string (cannot be modified)
621
+ and size is set to 0. */
622
+ unsigned char readonly;
623
+ } _PyUnicodeWriter ;
624
+
625
+ /* Initialize a Unicode writer.
626
+ *
627
+ * By default, the minimum buffer size is 0 character and overallocation is
628
+ * disabled. Set min_length, min_char and overallocate attributes to control
629
+ * the allocation of the buffer. */
630
+ PyAPI_FUNC(void)
631
+ _PyUnicodeWriter_Init(_PyUnicodeWriter *writer);
632
+
633
+ /* Prepare the buffer to write 'length' characters
634
+ with the specified maximum character.
635
+
636
+ Return 0 on success, raise an exception and return -1 on error. */
637
+ #define _PyUnicodeWriter_Prepare(WRITER, LENGTH, MAXCHAR) \
638
+ (((MAXCHAR) <= (WRITER)->maxchar \
639
+ && (LENGTH) <= (WRITER)->size - (WRITER)->pos) \
640
+ ? 0 \
641
+ : (((LENGTH) == 0) \
642
+ ? 0 \
643
+ : _PyUnicodeWriter_PrepareInternal((WRITER), (LENGTH), (MAXCHAR))))
644
+
645
+ /* Don't call this function directly, use the _PyUnicodeWriter_Prepare() macro
646
+ instead. */
647
+ PyAPI_FUNC(int)
648
+ _PyUnicodeWriter_PrepareInternal(_PyUnicodeWriter *writer,
649
+ Py_ssize_t length, Py_UCS4 maxchar);
650
+
651
+ /* Prepare the buffer to have at least the kind KIND.
652
+ For example, kind=PyUnicode_2BYTE_KIND ensures that the writer will
653
+ support characters in range U+000-U+FFFF.
654
+
655
+ Return 0 on success, raise an exception and return -1 on error. */
656
+ #define _PyUnicodeWriter_PrepareKind(WRITER, KIND) \
657
+ (assert((KIND) != PyUnicode_WCHAR_KIND), \
658
+ (KIND) <= (WRITER)->kind \
659
+ ? 0 \
660
+ : _PyUnicodeWriter_PrepareKindInternal((WRITER), (KIND)))
661
+
662
+ /* Don't call this function directly, use the _PyUnicodeWriter_PrepareKind()
663
+ macro instead. */
664
+ PyAPI_FUNC(int)
665
+ _PyUnicodeWriter_PrepareKindInternal(_PyUnicodeWriter *writer,
666
+ enum PyUnicode_Kind kind);
667
+
668
+ /* Append a Unicode character.
669
+ Return 0 on success, raise an exception and return -1 on error. */
670
+ PyAPI_FUNC(int)
671
+ _PyUnicodeWriter_WriteChar(_PyUnicodeWriter *writer,
672
+ Py_UCS4 ch
673
+ );
674
+
675
+ /* Append a Unicode string.
676
+ Return 0 on success, raise an exception and return -1 on error. */
677
+ PyAPI_FUNC(int)
678
+ _PyUnicodeWriter_WriteStr(_PyUnicodeWriter *writer,
679
+ PyObject *str /* Unicode string */
680
+ );
681
+
682
+ /* Append a substring of a Unicode string.
683
+ Return 0 on success, raise an exception and return -1 on error. */
684
+ PyAPI_FUNC(int)
685
+ _PyUnicodeWriter_WriteSubstring(_PyUnicodeWriter *writer,
686
+ PyObject *str, /* Unicode string */
687
+ Py_ssize_t start,
688
+ Py_ssize_t end
689
+ );
690
+
691
+ /* Append an ASCII-encoded byte string.
692
+ Return 0 on success, raise an exception and return -1 on error. */
693
+ PyAPI_FUNC(int)
694
+ _PyUnicodeWriter_WriteASCIIString(_PyUnicodeWriter *writer,
695
+ const char *str, /* ASCII-encoded byte string */
696
+ Py_ssize_t len /* number of bytes, or -1 if unknown */
697
+ );
698
+
699
+ /* Append a latin1-encoded byte string.
700
+ Return 0 on success, raise an exception and return -1 on error. */
701
+ PyAPI_FUNC(int)
702
+ _PyUnicodeWriter_WriteLatin1String(_PyUnicodeWriter *writer,
703
+ const char *str, /* latin1-encoded byte string */
704
+ Py_ssize_t len /* length in bytes */
705
+ );
706
+
707
+ /* Get the value of the writer as a Unicode string. Clear the
708
+ buffer of the writer. Raise an exception and return NULL
709
+ on error. */
710
+ PyAPI_FUNC(PyObject *)
711
+ _PyUnicodeWriter_Finish(_PyUnicodeWriter *writer);
712
+
713
+ /* Deallocate memory of a writer (clear its internal buffer). */
714
+ PyAPI_FUNC(void)
715
+ _PyUnicodeWriter_Dealloc(_PyUnicodeWriter *writer);
716
+
717
+
718
+ /* Format the object based on the format_spec, as defined in PEP 3101
719
+ (Advanced String Formatting). */
720
+ PyAPI_FUNC(int) _PyUnicode_FormatAdvancedWriter(
721
+ _PyUnicodeWriter *writer,
722
+ PyObject *obj,
723
+ PyObject *format_spec,
724
+ Py_ssize_t start,
725
+ Py_ssize_t end);
726
+
727
+ /* --- Manage the default encoding ---------------------------------------- */
728
+
729
+ /* Returns a pointer to the default encoding (UTF-8) of the
730
+ Unicode object unicode.
731
+
732
+ Like PyUnicode_AsUTF8AndSize(), this also caches the UTF-8 representation
733
+ in the unicodeobject.
734
+
735
+ _PyUnicode_AsString is a #define for PyUnicode_AsUTF8 to
736
+ support the previous internal function with the same behaviour.
737
+
738
+ Use of this API is DEPRECATED since no size information can be
739
+ extracted from the returned data.
740
+ */
741
+
742
+ PyAPI_FUNC(const char *) PyUnicode_AsUTF8(PyObject *unicode);
743
+
744
+ #define _PyUnicode_AsString PyUnicode_AsUTF8
745
+
746
+ /* --- Generic Codecs ----------------------------------------------------- */
747
+
748
+ /* Encodes a Py_UNICODE buffer of the given size and returns a
749
+ Python string object. */
750
+ Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_Encode(
751
+ const Py_UNICODE *s, /* Unicode char buffer */
752
+ Py_ssize_t size, /* number of Py_UNICODE chars to encode */
753
+ const char *encoding, /* encoding */
754
+ const char *errors /* error handling */
755
+ );
756
+
757
+ /* --- UTF-7 Codecs ------------------------------------------------------- */
758
+
759
+ Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF7(
760
+ const Py_UNICODE *data, /* Unicode char buffer */
761
+ Py_ssize_t length, /* number of Py_UNICODE chars to encode */
762
+ int base64SetO, /* Encode RFC2152 Set O characters in base64 */
763
+ int base64WhiteSpace, /* Encode whitespace (sp, ht, nl, cr) in base64 */
764
+ const char *errors /* error handling */
765
+ );
766
+
767
+ PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF7(
768
+ PyObject *unicode, /* Unicode object */
769
+ int base64SetO, /* Encode RFC2152 Set O characters in base64 */
770
+ int base64WhiteSpace, /* Encode whitespace (sp, ht, nl, cr) in base64 */
771
+ const char *errors /* error handling */
772
+ );
773
+
774
+ /* --- UTF-8 Codecs ------------------------------------------------------- */
775
+
776
+ PyAPI_FUNC(PyObject*) _PyUnicode_AsUTF8String(
777
+ PyObject *unicode,
778
+ const char *errors);
779
+
780
+ Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF8(
781
+ const Py_UNICODE *data, /* Unicode char buffer */
782
+ Py_ssize_t length, /* number of Py_UNICODE chars to encode */
783
+ const char *errors /* error handling */
784
+ );
785
+
786
+ /* --- UTF-32 Codecs ------------------------------------------------------ */
787
+
788
+ Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF32(
789
+ const Py_UNICODE *data, /* Unicode char buffer */
790
+ Py_ssize_t length, /* number of Py_UNICODE chars to encode */
791
+ const char *errors, /* error handling */
792
+ int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */
793
+ );
794
+
795
+ PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF32(
796
+ PyObject *object, /* Unicode object */
797
+ const char *errors, /* error handling */
798
+ int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */
799
+ );
800
+
801
+ /* --- UTF-16 Codecs ------------------------------------------------------ */
802
+
803
+ /* Returns a Python string object holding the UTF-16 encoded value of
804
+ the Unicode data.
805
+
806
+ If byteorder is not 0, output is written according to the following
807
+ byte order:
808
+
809
+ byteorder == -1: little endian
810
+ byteorder == 0: native byte order (writes a BOM mark)
811
+ byteorder == 1: big endian
812
+
813
+ If byteorder is 0, the output string will always start with the
814
+ Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is
815
+ prepended.
816
+
817
+ Note that Py_UNICODE data is being interpreted as UTF-16 reduced to
818
+ UCS-2. This trick makes it possible to add full UTF-16 capabilities
819
+ at a later point without compromising the APIs.
820
+
821
+ */
822
+ Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeUTF16(
823
+ const Py_UNICODE *data, /* Unicode char buffer */
824
+ Py_ssize_t length, /* number of Py_UNICODE chars to encode */
825
+ const char *errors, /* error handling */
826
+ int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */
827
+ );
828
+
829
+ PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF16(
830
+ PyObject* unicode, /* Unicode object */
831
+ const char *errors, /* error handling */
832
+ int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */
833
+ );
834
+
835
+ /* --- Unicode-Escape Codecs ---------------------------------------------- */
836
+
837
+ /* Variant of PyUnicode_DecodeUnicodeEscape that supports partial decoding. */
838
+ PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscapeStateful(
839
+ const char *string, /* Unicode-Escape encoded string */
840
+ Py_ssize_t length, /* size of string */
841
+ const char *errors, /* error handling */
842
+ Py_ssize_t *consumed /* bytes consumed */
843
+ );
844
+
845
+ /* Helper for PyUnicode_DecodeUnicodeEscape that detects invalid escape
846
+ chars. */
847
+ PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscapeInternal(
848
+ const char *string, /* Unicode-Escape encoded string */
849
+ Py_ssize_t length, /* size of string */
850
+ const char *errors, /* error handling */
851
+ Py_ssize_t *consumed, /* bytes consumed */
852
+ const char **first_invalid_escape /* on return, points to first
853
+ invalid escaped char in
854
+ string. */
855
+ );
856
+
857
+ Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeUnicodeEscape(
858
+ const Py_UNICODE *data, /* Unicode char buffer */
859
+ Py_ssize_t length /* Number of Py_UNICODE chars to encode */
860
+ );
861
+
862
+ /* --- Raw-Unicode-Escape Codecs ------------------------------------------ */
863
+
864
+ Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeRawUnicodeEscape(
865
+ const Py_UNICODE *data, /* Unicode char buffer */
866
+ Py_ssize_t length /* Number of Py_UNICODE chars to encode */
867
+ );
868
+
869
+ /* Variant of PyUnicode_DecodeRawUnicodeEscape that supports partial decoding. */
870
+ PyAPI_FUNC(PyObject*) _PyUnicode_DecodeRawUnicodeEscapeStateful(
871
+ const char *string, /* Unicode-Escape encoded string */
872
+ Py_ssize_t length, /* size of string */
873
+ const char *errors, /* error handling */
874
+ Py_ssize_t *consumed /* bytes consumed */
875
+ );
876
+
877
+ /* --- Latin-1 Codecs ----------------------------------------------------- */
878
+
879
+ PyAPI_FUNC(PyObject*) _PyUnicode_AsLatin1String(
880
+ PyObject* unicode,
881
+ const char* errors);
882
+
883
+ Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeLatin1(
884
+ const Py_UNICODE *data, /* Unicode char buffer */
885
+ Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
886
+ const char *errors /* error handling */
887
+ );
888
+
889
+ /* --- ASCII Codecs ------------------------------------------------------- */
890
+
891
+ PyAPI_FUNC(PyObject*) _PyUnicode_AsASCIIString(
892
+ PyObject* unicode,
893
+ const char* errors);
894
+
895
+ Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeASCII(
896
+ const Py_UNICODE *data, /* Unicode char buffer */
897
+ Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
898
+ const char *errors /* error handling */
899
+ );
900
+
901
+ /* --- Character Map Codecs ----------------------------------------------- */
902
+
903
+ Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeCharmap(
904
+ const Py_UNICODE *data, /* Unicode char buffer */
905
+ Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
906
+ PyObject *mapping, /* encoding mapping */
907
+ const char *errors /* error handling */
908
+ );
909
+
910
+ PyAPI_FUNC(PyObject*) _PyUnicode_EncodeCharmap(
911
+ PyObject *unicode, /* Unicode object */
912
+ PyObject *mapping, /* encoding mapping */
913
+ const char *errors /* error handling */
914
+ );
915
+
916
+ /* Translate a Py_UNICODE buffer of the given length by applying a
917
+ character mapping table to it and return the resulting Unicode
918
+ object.
919
+
920
+ The mapping table must map Unicode ordinal integers to Unicode strings,
921
+ Unicode ordinal integers or None (causing deletion of the character).
922
+
923
+ Mapping tables may be dictionaries or sequences. Unmapped character
924
+ ordinals (ones which cause a LookupError) are left untouched and
925
+ are copied as-is.
926
+
927
+ */
928
+ Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject *) PyUnicode_TranslateCharmap(
929
+ const Py_UNICODE *data, /* Unicode char buffer */
930
+ Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
931
+ PyObject *table, /* Translate table */
932
+ const char *errors /* error handling */
933
+ );
934
+
935
+ /* --- MBCS codecs for Windows -------------------------------------------- */
936
+
937
+ #ifdef MS_WINDOWS
938
+ Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_EncodeMBCS(
939
+ const Py_UNICODE *data, /* Unicode char buffer */
940
+ Py_ssize_t length, /* number of Py_UNICODE chars to encode */
941
+ const char *errors /* error handling */
942
+ );
943
+ #endif
944
+
945
+ /* --- Decimal Encoder ---------------------------------------------------- */
946
+
947
+ /* Takes a Unicode string holding a decimal value and writes it into
948
+ an output buffer using standard ASCII digit codes.
949
+
950
+ The output buffer has to provide at least length+1 bytes of storage
951
+ area. The output string is 0-terminated.
952
+
953
+ The encoder converts whitespace to ' ', decimal characters to their
954
+ corresponding ASCII digit and all other Latin-1 characters except
955
+ \0 as-is. Characters outside this range (Unicode ordinals 1-256)
956
+ are treated as errors. This includes embedded NULL bytes.
957
+
958
+ Error handling is defined by the errors argument:
959
+
960
+ NULL or "strict": raise a ValueError
961
+ "ignore": ignore the wrong characters (these are not copied to the
962
+ output buffer)
963
+ "replace": replaces illegal characters with '?'
964
+
965
+ Returns 0 on success, -1 on failure.
966
+
967
+ */
968
+
969
+ Py_DEPRECATED(3.3) PyAPI_FUNC(int) PyUnicode_EncodeDecimal(
970
+ Py_UNICODE *s, /* Unicode buffer */
971
+ Py_ssize_t length, /* Number of Py_UNICODE chars to encode */
972
+ char *output, /* Output buffer; must have size >= length */
973
+ const char *errors /* error handling */
974
+ );
975
+
976
+ /* Transforms code points that have decimal digit property to the
977
+ corresponding ASCII digit code points.
978
+
979
+ Returns a new Unicode string on success, NULL on failure.
980
+ */
981
+
982
+ Py_DEPRECATED(3.3)
983
+ PyAPI_FUNC(PyObject*) PyUnicode_TransformDecimalToASCII(
984
+ Py_UNICODE *s, /* Unicode buffer */
985
+ Py_ssize_t length /* Number of Py_UNICODE chars to transform */
986
+ );
987
+
988
+ /* Coverts a Unicode object holding a decimal value to an ASCII string
989
+ for using in int, float and complex parsers.
990
+ Transforms code points that have decimal digit property to the
991
+ corresponding ASCII digit code points. Transforms spaces to ASCII.
992
+ Transforms code points starting from the first non-ASCII code point that
993
+ is neither a decimal digit nor a space to the end into '?'. */
994
+
995
+ PyAPI_FUNC(PyObject*) _PyUnicode_TransformDecimalAndSpaceToASCII(
996
+ PyObject *unicode /* Unicode object */
997
+ );
998
+
999
+ /* --- Methods & Slots ---------------------------------------------------- */
1000
+
1001
+ PyAPI_FUNC(PyObject *) _PyUnicode_JoinArray(
1002
+ PyObject *separator,
1003
+ PyObject *const *items,
1004
+ Py_ssize_t seqlen
1005
+ );
1006
+
1007
+ /* Test whether a unicode is equal to ASCII identifier. Return 1 if true,
1008
+ 0 otherwise. The right argument must be ASCII identifier.
1009
+ Any error occurs inside will be cleared before return. */
1010
+ PyAPI_FUNC(int) _PyUnicode_EqualToASCIIId(
1011
+ PyObject *left, /* Left string */
1012
+ _Py_Identifier *right /* Right identifier */
1013
+ );
1014
+
1015
+ /* Test whether a unicode is equal to ASCII string. Return 1 if true,
1016
+ 0 otherwise. The right argument must be ASCII-encoded string.
1017
+ Any error occurs inside will be cleared before return. */
1018
+ PyAPI_FUNC(int) _PyUnicode_EqualToASCIIString(
1019
+ PyObject *left,
1020
+ const char *right /* ASCII-encoded string */
1021
+ );
1022
+
1023
+ /* Externally visible for str.strip(unicode) */
1024
+ PyAPI_FUNC(PyObject *) _PyUnicode_XStrip(
1025
+ PyObject *self,
1026
+ int striptype,
1027
+ PyObject *sepobj
1028
+ );
1029
+
1030
+ /* Using explicit passed-in values, insert the thousands grouping
1031
+ into the string pointed to by buffer. For the argument descriptions,
1032
+ see Objects/stringlib/localeutil.h */
1033
+ PyAPI_FUNC(Py_ssize_t) _PyUnicode_InsertThousandsGrouping(
1034
+ _PyUnicodeWriter *writer,
1035
+ Py_ssize_t n_buffer,
1036
+ PyObject *digits,
1037
+ Py_ssize_t d_pos,
1038
+ Py_ssize_t n_digits,
1039
+ Py_ssize_t min_width,
1040
+ const char *grouping,
1041
+ PyObject *thousands_sep,
1042
+ Py_UCS4 *maxchar);
1043
+
1044
+ /* === Characters Type APIs =============================================== */
1045
+
1046
+ /* Helper array used by Py_UNICODE_ISSPACE(). */
1047
+
1048
+ PyAPI_DATA(const unsigned char) _Py_ascii_whitespace[];
1049
+
1050
+ /* These should not be used directly. Use the Py_UNICODE_IS* and
1051
+ Py_UNICODE_TO* macros instead.
1052
+
1053
+ These APIs are implemented in Objects/unicodectype.c.
1054
+
1055
+ */
1056
+
1057
+ PyAPI_FUNC(int) _PyUnicode_IsLowercase(
1058
+ Py_UCS4 ch /* Unicode character */
1059
+ );
1060
+
1061
+ PyAPI_FUNC(int) _PyUnicode_IsUppercase(
1062
+ Py_UCS4 ch /* Unicode character */
1063
+ );
1064
+
1065
+ PyAPI_FUNC(int) _PyUnicode_IsTitlecase(
1066
+ Py_UCS4 ch /* Unicode character */
1067
+ );
1068
+
1069
+ PyAPI_FUNC(int) _PyUnicode_IsXidStart(
1070
+ Py_UCS4 ch /* Unicode character */
1071
+ );
1072
+
1073
+ PyAPI_FUNC(int) _PyUnicode_IsXidContinue(
1074
+ Py_UCS4 ch /* Unicode character */
1075
+ );
1076
+
1077
+ PyAPI_FUNC(int) _PyUnicode_IsWhitespace(
1078
+ const Py_UCS4 ch /* Unicode character */
1079
+ );
1080
+
1081
+ PyAPI_FUNC(int) _PyUnicode_IsLinebreak(
1082
+ const Py_UCS4 ch /* Unicode character */
1083
+ );
1084
+
1085
+ /* Py_DEPRECATED(3.3) */ PyAPI_FUNC(Py_UCS4) _PyUnicode_ToLowercase(
1086
+ Py_UCS4 ch /* Unicode character */
1087
+ );
1088
+
1089
+ /* Py_DEPRECATED(3.3) */ PyAPI_FUNC(Py_UCS4) _PyUnicode_ToUppercase(
1090
+ Py_UCS4 ch /* Unicode character */
1091
+ );
1092
+
1093
+ Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UCS4) _PyUnicode_ToTitlecase(
1094
+ Py_UCS4 ch /* Unicode character */
1095
+ );
1096
+
1097
+ PyAPI_FUNC(int) _PyUnicode_ToLowerFull(
1098
+ Py_UCS4 ch, /* Unicode character */
1099
+ Py_UCS4 *res
1100
+ );
1101
+
1102
+ PyAPI_FUNC(int) _PyUnicode_ToTitleFull(
1103
+ Py_UCS4 ch, /* Unicode character */
1104
+ Py_UCS4 *res
1105
+ );
1106
+
1107
+ PyAPI_FUNC(int) _PyUnicode_ToUpperFull(
1108
+ Py_UCS4 ch, /* Unicode character */
1109
+ Py_UCS4 *res
1110
+ );
1111
+
1112
+ PyAPI_FUNC(int) _PyUnicode_ToFoldedFull(
1113
+ Py_UCS4 ch, /* Unicode character */
1114
+ Py_UCS4 *res
1115
+ );
1116
+
1117
+ PyAPI_FUNC(int) _PyUnicode_IsCaseIgnorable(
1118
+ Py_UCS4 ch /* Unicode character */
1119
+ );
1120
+
1121
+ PyAPI_FUNC(int) _PyUnicode_IsCased(
1122
+ Py_UCS4 ch /* Unicode character */
1123
+ );
1124
+
1125
+ PyAPI_FUNC(int) _PyUnicode_ToDecimalDigit(
1126
+ Py_UCS4 ch /* Unicode character */
1127
+ );
1128
+
1129
+ PyAPI_FUNC(int) _PyUnicode_ToDigit(
1130
+ Py_UCS4 ch /* Unicode character */
1131
+ );
1132
+
1133
+ PyAPI_FUNC(double) _PyUnicode_ToNumeric(
1134
+ Py_UCS4 ch /* Unicode character */
1135
+ );
1136
+
1137
+ PyAPI_FUNC(int) _PyUnicode_IsDecimalDigit(
1138
+ Py_UCS4 ch /* Unicode character */
1139
+ );
1140
+
1141
+ PyAPI_FUNC(int) _PyUnicode_IsDigit(
1142
+ Py_UCS4 ch /* Unicode character */
1143
+ );
1144
+
1145
+ PyAPI_FUNC(int) _PyUnicode_IsNumeric(
1146
+ Py_UCS4 ch /* Unicode character */
1147
+ );
1148
+
1149
+ PyAPI_FUNC(int) _PyUnicode_IsPrintable(
1150
+ Py_UCS4 ch /* Unicode character */
1151
+ );
1152
+
1153
+ PyAPI_FUNC(int) _PyUnicode_IsAlpha(
1154
+ Py_UCS4 ch /* Unicode character */
1155
+ );
1156
+
1157
+ PyAPI_FUNC(PyObject*) _PyUnicode_FormatLong(PyObject *, int, int, int);
1158
+
1159
+ /* Return an interned Unicode object for an Identifier; may fail if there is no memory.*/
1160
+ PyAPI_FUNC(PyObject*) _PyUnicode_FromId(_Py_Identifier*);
1161
+
1162
+ /* Fast equality check when the inputs are known to be exact unicode types
1163
+ and where the hash values are equal (i.e. a very probable match) */
1164
+ PyAPI_FUNC(int) _PyUnicode_EQ(PyObject *, PyObject *);
1165
+
1166
+ PyAPI_FUNC(int) _PyUnicode_WideCharString_Converter(PyObject *, void *);
1167
+ PyAPI_FUNC(int) _PyUnicode_WideCharString_Opt_Converter(PyObject *, void *);
1168
+
1169
+ PyAPI_FUNC(Py_ssize_t) _PyUnicode_ScanIdentifier(PyObject *);
llava_next/include/python3.10/eval.h ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* Interface to execute compiled code */
3
+
4
+ #ifndef Py_EVAL_H
5
+ #define Py_EVAL_H
6
+ #ifdef __cplusplus
7
+ extern "C" {
8
+ #endif
9
+
10
+ PyAPI_FUNC(PyObject *) PyEval_EvalCode(PyObject *, PyObject *, PyObject *);
11
+
12
+ PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyObject *co,
13
+ PyObject *globals,
14
+ PyObject *locals,
15
+ PyObject *const *args, int argc,
16
+ PyObject *const *kwds, int kwdc,
17
+ PyObject *const *defs, int defc,
18
+ PyObject *kwdefs, PyObject *closure);
19
+
20
+ #ifndef Py_LIMITED_API
21
+ PyAPI_FUNC(PyObject *) _PyEval_CallTracing(PyObject *func, PyObject *args);
22
+ #endif
23
+
24
+ #ifdef __cplusplus
25
+ }
26
+ #endif
27
+ #endif /* !Py_EVAL_H */
llava_next/include/python3.10/floatobject.h ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* Float object interface */
3
+
4
+ /*
5
+ PyFloatObject represents a (double precision) floating point number.
6
+ */
7
+
8
+ #ifndef Py_FLOATOBJECT_H
9
+ #define Py_FLOATOBJECT_H
10
+ #ifdef __cplusplus
11
+ extern "C" {
12
+ #endif
13
+
14
+ #ifndef Py_LIMITED_API
15
+ typedef struct {
16
+ PyObject_HEAD
17
+ double ob_fval;
18
+ } PyFloatObject;
19
+ #endif
20
+
21
+ PyAPI_DATA(PyTypeObject) PyFloat_Type;
22
+
23
+ #define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type)
24
+ #define PyFloat_CheckExact(op) Py_IS_TYPE(op, &PyFloat_Type)
25
+
26
+ #ifdef Py_NAN
27
+ #define Py_RETURN_NAN return PyFloat_FromDouble(Py_NAN)
28
+ #endif
29
+
30
+ #define Py_RETURN_INF(sign) do \
31
+ if (copysign(1., sign) == 1.) { \
32
+ return PyFloat_FromDouble(Py_HUGE_VAL); \
33
+ } else { \
34
+ return PyFloat_FromDouble(-Py_HUGE_VAL); \
35
+ } while(0)
36
+
37
+ PyAPI_FUNC(double) PyFloat_GetMax(void);
38
+ PyAPI_FUNC(double) PyFloat_GetMin(void);
39
+ PyAPI_FUNC(PyObject *) PyFloat_GetInfo(void);
40
+
41
+ /* Return Python float from string PyObject. */
42
+ PyAPI_FUNC(PyObject *) PyFloat_FromString(PyObject*);
43
+
44
+ /* Return Python float from C double. */
45
+ PyAPI_FUNC(PyObject *) PyFloat_FromDouble(double);
46
+
47
+ /* Extract C double from Python float. The macro version trades safety for
48
+ speed. */
49
+ PyAPI_FUNC(double) PyFloat_AsDouble(PyObject *);
50
+ #ifndef Py_LIMITED_API
51
+ #define PyFloat_AS_DOUBLE(op) (((PyFloatObject *)(op))->ob_fval)
52
+ #endif
53
+
54
+ #ifndef Py_LIMITED_API
55
+ /* _PyFloat_{Pack,Unpack}{4,8}
56
+ *
57
+ * The struct and pickle (at least) modules need an efficient platform-
58
+ * independent way to store floating-point values as byte strings.
59
+ * The Pack routines produce a string from a C double, and the Unpack
60
+ * routines produce a C double from such a string. The suffix (4 or 8)
61
+ * specifies the number of bytes in the string.
62
+ *
63
+ * On platforms that appear to use (see _PyFloat_Init()) IEEE-754 formats
64
+ * these functions work by copying bits. On other platforms, the formats the
65
+ * 4- byte format is identical to the IEEE-754 single precision format, and
66
+ * the 8-byte format to the IEEE-754 double precision format, although the
67
+ * packing of INFs and NaNs (if such things exist on the platform) isn't
68
+ * handled correctly, and attempting to unpack a string containing an IEEE
69
+ * INF or NaN will raise an exception.
70
+ *
71
+ * On non-IEEE platforms with more precision, or larger dynamic range, than
72
+ * 754 supports, not all values can be packed; on non-IEEE platforms with less
73
+ * precision, or smaller dynamic range, not all values can be unpacked. What
74
+ * happens in such cases is partly accidental (alas).
75
+ */
76
+
77
+ /* The pack routines write 2, 4 or 8 bytes, starting at p. le is a bool
78
+ * argument, true if you want the string in little-endian format (exponent
79
+ * last, at p+1, p+3 or p+7), false if you want big-endian format (exponent
80
+ * first, at p).
81
+ * Return value: 0 if all is OK, -1 if error (and an exception is
82
+ * set, most likely OverflowError).
83
+ * There are two problems on non-IEEE platforms:
84
+ * 1): What this does is undefined if x is a NaN or infinity.
85
+ * 2): -0.0 and +0.0 produce the same string.
86
+ */
87
+ PyAPI_FUNC(int) _PyFloat_Pack2(double x, unsigned char *p, int le);
88
+ PyAPI_FUNC(int) _PyFloat_Pack4(double x, unsigned char *p, int le);
89
+ PyAPI_FUNC(int) _PyFloat_Pack8(double x, unsigned char *p, int le);
90
+
91
+ /* The unpack routines read 2, 4 or 8 bytes, starting at p. le is a bool
92
+ * argument, true if the string is in little-endian format (exponent
93
+ * last, at p+1, p+3 or p+7), false if big-endian (exponent first, at p).
94
+ * Return value: The unpacked double. On error, this is -1.0 and
95
+ * PyErr_Occurred() is true (and an exception is set, most likely
96
+ * OverflowError). Note that on a non-IEEE platform this will refuse
97
+ * to unpack a string that represents a NaN or infinity.
98
+ */
99
+ PyAPI_FUNC(double) _PyFloat_Unpack2(const unsigned char *p, int le);
100
+ PyAPI_FUNC(double) _PyFloat_Unpack4(const unsigned char *p, int le);
101
+ PyAPI_FUNC(double) _PyFloat_Unpack8(const unsigned char *p, int le);
102
+
103
+ PyAPI_FUNC(void) _PyFloat_DebugMallocStats(FILE* out);
104
+
105
+ /* Format the object based on the format_spec, as defined in PEP 3101
106
+ (Advanced String Formatting). */
107
+ PyAPI_FUNC(int) _PyFloat_FormatAdvancedWriter(
108
+ _PyUnicodeWriter *writer,
109
+ PyObject *obj,
110
+ PyObject *format_spec,
111
+ Py_ssize_t start,
112
+ Py_ssize_t end);
113
+ #endif /* Py_LIMITED_API */
114
+
115
+ #ifdef __cplusplus
116
+ }
117
+ #endif
118
+ #endif /* !Py_FLOATOBJECT_H */
llava_next/include/python3.10/genobject.h ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /* Generator object interface */
3
+
4
+ #ifndef Py_LIMITED_API
5
+ #ifndef Py_GENOBJECT_H
6
+ #define Py_GENOBJECT_H
7
+ #ifdef __cplusplus
8
+ extern "C" {
9
+ #endif
10
+
11
+ #include "pystate.h" /* _PyErr_StackItem */
12
+ #include "abstract.h" /* PySendResult */
13
+
14
+ /* _PyGenObject_HEAD defines the initial segment of generator
15
+ and coroutine objects. */
16
+ #define _PyGenObject_HEAD(prefix) \
17
+ PyObject_HEAD \
18
+ /* Note: gi_frame can be NULL if the generator is "finished" */ \
19
+ PyFrameObject *prefix##_frame; \
20
+ /* The code object backing the generator */ \
21
+ PyObject *prefix##_code; \
22
+ /* List of weak reference. */ \
23
+ PyObject *prefix##_weakreflist; \
24
+ /* Name of the generator. */ \
25
+ PyObject *prefix##_name; \
26
+ /* Qualified name of the generator. */ \
27
+ PyObject *prefix##_qualname; \
28
+ _PyErr_StackItem prefix##_exc_state;
29
+
30
+ typedef struct {
31
+ /* The gi_ prefix is intended to remind of generator-iterator. */
32
+ _PyGenObject_HEAD(gi)
33
+ } PyGenObject;
34
+
35
+ PyAPI_DATA(PyTypeObject) PyGen_Type;
36
+
37
+ #define PyGen_Check(op) PyObject_TypeCheck(op, &PyGen_Type)
38
+ #define PyGen_CheckExact(op) Py_IS_TYPE(op, &PyGen_Type)
39
+
40
+ PyAPI_FUNC(PyObject *) PyGen_New(PyFrameObject *);
41
+ PyAPI_FUNC(PyObject *) PyGen_NewWithQualName(PyFrameObject *,
42
+ PyObject *name, PyObject *qualname);
43
+ PyAPI_FUNC(int) _PyGen_SetStopIterationValue(PyObject *);
44
+ PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **);
45
+ PyObject *_PyGen_yf(PyGenObject *);
46
+ PyAPI_FUNC(void) _PyGen_Finalize(PyObject *self);
47
+
48
+ #ifndef Py_LIMITED_API
49
+ typedef struct {
50
+ _PyGenObject_HEAD(cr)
51
+ PyObject *cr_origin;
52
+ } PyCoroObject;
53
+
54
+ PyAPI_DATA(PyTypeObject) PyCoro_Type;
55
+ PyAPI_DATA(PyTypeObject) _PyCoroWrapper_Type;
56
+
57
+ #define PyCoro_CheckExact(op) Py_IS_TYPE(op, &PyCoro_Type)
58
+ PyObject *_PyCoro_GetAwaitableIter(PyObject *o);
59
+ PyAPI_FUNC(PyObject *) PyCoro_New(PyFrameObject *,
60
+ PyObject *name, PyObject *qualname);
61
+
62
+ /* Asynchronous Generators */
63
+
64
+ typedef struct {
65
+ _PyGenObject_HEAD(ag)
66
+ PyObject *ag_finalizer;
67
+
68
+ /* Flag is set to 1 when hooks set up by sys.set_asyncgen_hooks
69
+ were called on the generator, to avoid calling them more
70
+ than once. */
71
+ int ag_hooks_inited;
72
+
73
+ /* Flag is set to 1 when aclose() is called for the first time, or
74
+ when a StopAsyncIteration exception is raised. */
75
+ int ag_closed;
76
+
77
+ int ag_running_async;
78
+ } PyAsyncGenObject;
79
+
80
+ PyAPI_DATA(PyTypeObject) PyAsyncGen_Type;
81
+ PyAPI_DATA(PyTypeObject) _PyAsyncGenASend_Type;
82
+ PyAPI_DATA(PyTypeObject) _PyAsyncGenWrappedValue_Type;
83
+ PyAPI_DATA(PyTypeObject) _PyAsyncGenAThrow_Type;
84
+
85
+ PyAPI_FUNC(PyObject *) PyAsyncGen_New(PyFrameObject *,
86
+ PyObject *name, PyObject *qualname);
87
+
88
+ #define PyAsyncGen_CheckExact(op) Py_IS_TYPE(op, &PyAsyncGen_Type)
89
+
90
+ PyObject *_PyAsyncGenValueWrapperNew(PyObject *);
91
+
92
+ #endif
93
+
94
+ #undef _PyGenObject_HEAD
95
+
96
+ #ifdef __cplusplus
97
+ }
98
+ #endif
99
+ #endif /* !Py_GENOBJECT_H */
100
+ #endif /* Py_LIMITED_API */
llava_next/include/python3.10/internal/pycore_abstract.h ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_INTERNAL_ABSTRACT_H
2
+ #define Py_INTERNAL_ABSTRACT_H
3
+ #ifdef __cplusplus
4
+ extern "C" {
5
+ #endif
6
+
7
+ #ifndef Py_BUILD_CORE
8
+ # error "this header requires Py_BUILD_CORE define"
9
+ #endif
10
+
11
+ // Fast inlined version of PyIndex_Check()
12
+ static inline int
13
+ _PyIndex_Check(PyObject *obj)
14
+ {
15
+ PyNumberMethods *tp_as_number = Py_TYPE(obj)->tp_as_number;
16
+ return (tp_as_number != NULL && tp_as_number->nb_index != NULL);
17
+ }
18
+
19
+ #ifdef __cplusplus
20
+ }
21
+ #endif
22
+ #endif /* !Py_INTERNAL_ABSTRACT_H */
llava_next/include/python3.10/internal/pycore_accu.h ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_LIMITED_API
2
+ #ifndef Py_INTERNAL_ACCU_H
3
+ #define Py_INTERNAL_ACCU_H
4
+ #ifdef __cplusplus
5
+ extern "C" {
6
+ #endif
7
+
8
+ /*** This is a private API for use by the interpreter and the stdlib.
9
+ *** Its definition may be changed or removed at any moment.
10
+ ***/
11
+
12
+ #ifndef Py_BUILD_CORE
13
+ # error "this header requires Py_BUILD_CORE define"
14
+ #endif
15
+
16
+ /*
17
+ * A two-level accumulator of unicode objects that avoids both the overhead
18
+ * of keeping a huge number of small separate objects, and the quadratic
19
+ * behaviour of using a naive repeated concatenation scheme.
20
+ */
21
+
22
+ #undef small /* defined by some Windows headers */
23
+
24
+ typedef struct {
25
+ PyObject *large; /* A list of previously accumulated large strings */
26
+ PyObject *small; /* Pending small strings */
27
+ } _PyAccu;
28
+
29
+ PyAPI_FUNC(int) _PyAccu_Init(_PyAccu *acc);
30
+ PyAPI_FUNC(int) _PyAccu_Accumulate(_PyAccu *acc, PyObject *unicode);
31
+ PyAPI_FUNC(PyObject *) _PyAccu_FinishAsList(_PyAccu *acc);
32
+ PyAPI_FUNC(PyObject *) _PyAccu_Finish(_PyAccu *acc);
33
+ PyAPI_FUNC(void) _PyAccu_Destroy(_PyAccu *acc);
34
+
35
+ #ifdef __cplusplus
36
+ }
37
+ #endif
38
+ #endif /* !Py_INTERNAL_ACCU_H */
39
+ #endif /* !Py_LIMITED_API */
llava_next/include/python3.10/internal/pycore_ast.h ADDED
@@ -0,0 +1,855 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // File automatically generated by Parser/asdl_c.py.
2
+
3
+ #ifndef Py_INTERNAL_AST_H
4
+ #define Py_INTERNAL_AST_H
5
+ #ifdef __cplusplus
6
+ extern "C" {
7
+ #endif
8
+
9
+ #ifndef Py_BUILD_CORE
10
+ # error "this header requires Py_BUILD_CORE define"
11
+ #endif
12
+
13
+ #include "pycore_asdl.h"
14
+
15
+ typedef struct _mod *mod_ty;
16
+
17
+ typedef struct _stmt *stmt_ty;
18
+
19
+ typedef struct _expr *expr_ty;
20
+
21
+ typedef enum _expr_context { Load=1, Store=2, Del=3 } expr_context_ty;
22
+
23
+ typedef enum _boolop { And=1, Or=2 } boolop_ty;
24
+
25
+ typedef enum _operator { Add=1, Sub=2, Mult=3, MatMult=4, Div=5, Mod=6, Pow=7,
26
+ LShift=8, RShift=9, BitOr=10, BitXor=11, BitAnd=12,
27
+ FloorDiv=13 } operator_ty;
28
+
29
+ typedef enum _unaryop { Invert=1, Not=2, UAdd=3, USub=4 } unaryop_ty;
30
+
31
+ typedef enum _cmpop { Eq=1, NotEq=2, Lt=3, LtE=4, Gt=5, GtE=6, Is=7, IsNot=8,
32
+ In=9, NotIn=10 } cmpop_ty;
33
+
34
+ typedef struct _comprehension *comprehension_ty;
35
+
36
+ typedef struct _excepthandler *excepthandler_ty;
37
+
38
+ typedef struct _arguments *arguments_ty;
39
+
40
+ typedef struct _arg *arg_ty;
41
+
42
+ typedef struct _keyword *keyword_ty;
43
+
44
+ typedef struct _alias *alias_ty;
45
+
46
+ typedef struct _withitem *withitem_ty;
47
+
48
+ typedef struct _match_case *match_case_ty;
49
+
50
+ typedef struct _pattern *pattern_ty;
51
+
52
+ typedef struct _type_ignore *type_ignore_ty;
53
+
54
+
55
+ typedef struct {
56
+ _ASDL_SEQ_HEAD
57
+ mod_ty typed_elements[1];
58
+ } asdl_mod_seq;
59
+
60
+ asdl_mod_seq *_Py_asdl_mod_seq_new(Py_ssize_t size, PyArena *arena);
61
+
62
+ typedef struct {
63
+ _ASDL_SEQ_HEAD
64
+ stmt_ty typed_elements[1];
65
+ } asdl_stmt_seq;
66
+
67
+ asdl_stmt_seq *_Py_asdl_stmt_seq_new(Py_ssize_t size, PyArena *arena);
68
+
69
+ typedef struct {
70
+ _ASDL_SEQ_HEAD
71
+ expr_ty typed_elements[1];
72
+ } asdl_expr_seq;
73
+
74
+ asdl_expr_seq *_Py_asdl_expr_seq_new(Py_ssize_t size, PyArena *arena);
75
+
76
+ typedef struct {
77
+ _ASDL_SEQ_HEAD
78
+ comprehension_ty typed_elements[1];
79
+ } asdl_comprehension_seq;
80
+
81
+ asdl_comprehension_seq *_Py_asdl_comprehension_seq_new(Py_ssize_t size, PyArena
82
+ *arena);
83
+
84
+ typedef struct {
85
+ _ASDL_SEQ_HEAD
86
+ excepthandler_ty typed_elements[1];
87
+ } asdl_excepthandler_seq;
88
+
89
+ asdl_excepthandler_seq *_Py_asdl_excepthandler_seq_new(Py_ssize_t size, PyArena
90
+ *arena);
91
+
92
+ typedef struct {
93
+ _ASDL_SEQ_HEAD
94
+ arguments_ty typed_elements[1];
95
+ } asdl_arguments_seq;
96
+
97
+ asdl_arguments_seq *_Py_asdl_arguments_seq_new(Py_ssize_t size, PyArena *arena);
98
+
99
+ typedef struct {
100
+ _ASDL_SEQ_HEAD
101
+ arg_ty typed_elements[1];
102
+ } asdl_arg_seq;
103
+
104
+ asdl_arg_seq *_Py_asdl_arg_seq_new(Py_ssize_t size, PyArena *arena);
105
+
106
+ typedef struct {
107
+ _ASDL_SEQ_HEAD
108
+ keyword_ty typed_elements[1];
109
+ } asdl_keyword_seq;
110
+
111
+ asdl_keyword_seq *_Py_asdl_keyword_seq_new(Py_ssize_t size, PyArena *arena);
112
+
113
+ typedef struct {
114
+ _ASDL_SEQ_HEAD
115
+ alias_ty typed_elements[1];
116
+ } asdl_alias_seq;
117
+
118
+ asdl_alias_seq *_Py_asdl_alias_seq_new(Py_ssize_t size, PyArena *arena);
119
+
120
+ typedef struct {
121
+ _ASDL_SEQ_HEAD
122
+ withitem_ty typed_elements[1];
123
+ } asdl_withitem_seq;
124
+
125
+ asdl_withitem_seq *_Py_asdl_withitem_seq_new(Py_ssize_t size, PyArena *arena);
126
+
127
+ typedef struct {
128
+ _ASDL_SEQ_HEAD
129
+ match_case_ty typed_elements[1];
130
+ } asdl_match_case_seq;
131
+
132
+ asdl_match_case_seq *_Py_asdl_match_case_seq_new(Py_ssize_t size, PyArena
133
+ *arena);
134
+
135
+ typedef struct {
136
+ _ASDL_SEQ_HEAD
137
+ pattern_ty typed_elements[1];
138
+ } asdl_pattern_seq;
139
+
140
+ asdl_pattern_seq *_Py_asdl_pattern_seq_new(Py_ssize_t size, PyArena *arena);
141
+
142
+ typedef struct {
143
+ _ASDL_SEQ_HEAD
144
+ type_ignore_ty typed_elements[1];
145
+ } asdl_type_ignore_seq;
146
+
147
+ asdl_type_ignore_seq *_Py_asdl_type_ignore_seq_new(Py_ssize_t size, PyArena
148
+ *arena);
149
+
150
+
151
+ enum _mod_kind {Module_kind=1, Interactive_kind=2, Expression_kind=3,
152
+ FunctionType_kind=4};
153
+ struct _mod {
154
+ enum _mod_kind kind;
155
+ union {
156
+ struct {
157
+ asdl_stmt_seq *body;
158
+ asdl_type_ignore_seq *type_ignores;
159
+ } Module;
160
+
161
+ struct {
162
+ asdl_stmt_seq *body;
163
+ } Interactive;
164
+
165
+ struct {
166
+ expr_ty body;
167
+ } Expression;
168
+
169
+ struct {
170
+ asdl_expr_seq *argtypes;
171
+ expr_ty returns;
172
+ } FunctionType;
173
+
174
+ } v;
175
+ };
176
+
177
+ enum _stmt_kind {FunctionDef_kind=1, AsyncFunctionDef_kind=2, ClassDef_kind=3,
178
+ Return_kind=4, Delete_kind=5, Assign_kind=6,
179
+ AugAssign_kind=7, AnnAssign_kind=8, For_kind=9,
180
+ AsyncFor_kind=10, While_kind=11, If_kind=12, With_kind=13,
181
+ AsyncWith_kind=14, Match_kind=15, Raise_kind=16, Try_kind=17,
182
+ Assert_kind=18, Import_kind=19, ImportFrom_kind=20,
183
+ Global_kind=21, Nonlocal_kind=22, Expr_kind=23, Pass_kind=24,
184
+ Break_kind=25, Continue_kind=26};
185
+ struct _stmt {
186
+ enum _stmt_kind kind;
187
+ union {
188
+ struct {
189
+ identifier name;
190
+ arguments_ty args;
191
+ asdl_stmt_seq *body;
192
+ asdl_expr_seq *decorator_list;
193
+ expr_ty returns;
194
+ string type_comment;
195
+ } FunctionDef;
196
+
197
+ struct {
198
+ identifier name;
199
+ arguments_ty args;
200
+ asdl_stmt_seq *body;
201
+ asdl_expr_seq *decorator_list;
202
+ expr_ty returns;
203
+ string type_comment;
204
+ } AsyncFunctionDef;
205
+
206
+ struct {
207
+ identifier name;
208
+ asdl_expr_seq *bases;
209
+ asdl_keyword_seq *keywords;
210
+ asdl_stmt_seq *body;
211
+ asdl_expr_seq *decorator_list;
212
+ } ClassDef;
213
+
214
+ struct {
215
+ expr_ty value;
216
+ } Return;
217
+
218
+ struct {
219
+ asdl_expr_seq *targets;
220
+ } Delete;
221
+
222
+ struct {
223
+ asdl_expr_seq *targets;
224
+ expr_ty value;
225
+ string type_comment;
226
+ } Assign;
227
+
228
+ struct {
229
+ expr_ty target;
230
+ operator_ty op;
231
+ expr_ty value;
232
+ } AugAssign;
233
+
234
+ struct {
235
+ expr_ty target;
236
+ expr_ty annotation;
237
+ expr_ty value;
238
+ int simple;
239
+ } AnnAssign;
240
+
241
+ struct {
242
+ expr_ty target;
243
+ expr_ty iter;
244
+ asdl_stmt_seq *body;
245
+ asdl_stmt_seq *orelse;
246
+ string type_comment;
247
+ } For;
248
+
249
+ struct {
250
+ expr_ty target;
251
+ expr_ty iter;
252
+ asdl_stmt_seq *body;
253
+ asdl_stmt_seq *orelse;
254
+ string type_comment;
255
+ } AsyncFor;
256
+
257
+ struct {
258
+ expr_ty test;
259
+ asdl_stmt_seq *body;
260
+ asdl_stmt_seq *orelse;
261
+ } While;
262
+
263
+ struct {
264
+ expr_ty test;
265
+ asdl_stmt_seq *body;
266
+ asdl_stmt_seq *orelse;
267
+ } If;
268
+
269
+ struct {
270
+ asdl_withitem_seq *items;
271
+ asdl_stmt_seq *body;
272
+ string type_comment;
273
+ } With;
274
+
275
+ struct {
276
+ asdl_withitem_seq *items;
277
+ asdl_stmt_seq *body;
278
+ string type_comment;
279
+ } AsyncWith;
280
+
281
+ struct {
282
+ expr_ty subject;
283
+ asdl_match_case_seq *cases;
284
+ } Match;
285
+
286
+ struct {
287
+ expr_ty exc;
288
+ expr_ty cause;
289
+ } Raise;
290
+
291
+ struct {
292
+ asdl_stmt_seq *body;
293
+ asdl_excepthandler_seq *handlers;
294
+ asdl_stmt_seq *orelse;
295
+ asdl_stmt_seq *finalbody;
296
+ } Try;
297
+
298
+ struct {
299
+ expr_ty test;
300
+ expr_ty msg;
301
+ } Assert;
302
+
303
+ struct {
304
+ asdl_alias_seq *names;
305
+ } Import;
306
+
307
+ struct {
308
+ identifier module;
309
+ asdl_alias_seq *names;
310
+ int level;
311
+ } ImportFrom;
312
+
313
+ struct {
314
+ asdl_identifier_seq *names;
315
+ } Global;
316
+
317
+ struct {
318
+ asdl_identifier_seq *names;
319
+ } Nonlocal;
320
+
321
+ struct {
322
+ expr_ty value;
323
+ } Expr;
324
+
325
+ } v;
326
+ int lineno;
327
+ int col_offset;
328
+ int end_lineno;
329
+ int end_col_offset;
330
+ };
331
+
332
+ enum _expr_kind {BoolOp_kind=1, NamedExpr_kind=2, BinOp_kind=3, UnaryOp_kind=4,
333
+ Lambda_kind=5, IfExp_kind=6, Dict_kind=7, Set_kind=8,
334
+ ListComp_kind=9, SetComp_kind=10, DictComp_kind=11,
335
+ GeneratorExp_kind=12, Await_kind=13, Yield_kind=14,
336
+ YieldFrom_kind=15, Compare_kind=16, Call_kind=17,
337
+ FormattedValue_kind=18, JoinedStr_kind=19, Constant_kind=20,
338
+ Attribute_kind=21, Subscript_kind=22, Starred_kind=23,
339
+ Name_kind=24, List_kind=25, Tuple_kind=26, Slice_kind=27};
340
+ struct _expr {
341
+ enum _expr_kind kind;
342
+ union {
343
+ struct {
344
+ boolop_ty op;
345
+ asdl_expr_seq *values;
346
+ } BoolOp;
347
+
348
+ struct {
349
+ expr_ty target;
350
+ expr_ty value;
351
+ } NamedExpr;
352
+
353
+ struct {
354
+ expr_ty left;
355
+ operator_ty op;
356
+ expr_ty right;
357
+ } BinOp;
358
+
359
+ struct {
360
+ unaryop_ty op;
361
+ expr_ty operand;
362
+ } UnaryOp;
363
+
364
+ struct {
365
+ arguments_ty args;
366
+ expr_ty body;
367
+ } Lambda;
368
+
369
+ struct {
370
+ expr_ty test;
371
+ expr_ty body;
372
+ expr_ty orelse;
373
+ } IfExp;
374
+
375
+ struct {
376
+ asdl_expr_seq *keys;
377
+ asdl_expr_seq *values;
378
+ } Dict;
379
+
380
+ struct {
381
+ asdl_expr_seq *elts;
382
+ } Set;
383
+
384
+ struct {
385
+ expr_ty elt;
386
+ asdl_comprehension_seq *generators;
387
+ } ListComp;
388
+
389
+ struct {
390
+ expr_ty elt;
391
+ asdl_comprehension_seq *generators;
392
+ } SetComp;
393
+
394
+ struct {
395
+ expr_ty key;
396
+ expr_ty value;
397
+ asdl_comprehension_seq *generators;
398
+ } DictComp;
399
+
400
+ struct {
401
+ expr_ty elt;
402
+ asdl_comprehension_seq *generators;
403
+ } GeneratorExp;
404
+
405
+ struct {
406
+ expr_ty value;
407
+ } Await;
408
+
409
+ struct {
410
+ expr_ty value;
411
+ } Yield;
412
+
413
+ struct {
414
+ expr_ty value;
415
+ } YieldFrom;
416
+
417
+ struct {
418
+ expr_ty left;
419
+ asdl_int_seq *ops;
420
+ asdl_expr_seq *comparators;
421
+ } Compare;
422
+
423
+ struct {
424
+ expr_ty func;
425
+ asdl_expr_seq *args;
426
+ asdl_keyword_seq *keywords;
427
+ } Call;
428
+
429
+ struct {
430
+ expr_ty value;
431
+ int conversion;
432
+ expr_ty format_spec;
433
+ } FormattedValue;
434
+
435
+ struct {
436
+ asdl_expr_seq *values;
437
+ } JoinedStr;
438
+
439
+ struct {
440
+ constant value;
441
+ string kind;
442
+ } Constant;
443
+
444
+ struct {
445
+ expr_ty value;
446
+ identifier attr;
447
+ expr_context_ty ctx;
448
+ } Attribute;
449
+
450
+ struct {
451
+ expr_ty value;
452
+ expr_ty slice;
453
+ expr_context_ty ctx;
454
+ } Subscript;
455
+
456
+ struct {
457
+ expr_ty value;
458
+ expr_context_ty ctx;
459
+ } Starred;
460
+
461
+ struct {
462
+ identifier id;
463
+ expr_context_ty ctx;
464
+ } Name;
465
+
466
+ struct {
467
+ asdl_expr_seq *elts;
468
+ expr_context_ty ctx;
469
+ } List;
470
+
471
+ struct {
472
+ asdl_expr_seq *elts;
473
+ expr_context_ty ctx;
474
+ } Tuple;
475
+
476
+ struct {
477
+ expr_ty lower;
478
+ expr_ty upper;
479
+ expr_ty step;
480
+ } Slice;
481
+
482
+ } v;
483
+ int lineno;
484
+ int col_offset;
485
+ int end_lineno;
486
+ int end_col_offset;
487
+ };
488
+
489
+ struct _comprehension {
490
+ expr_ty target;
491
+ expr_ty iter;
492
+ asdl_expr_seq *ifs;
493
+ int is_async;
494
+ };
495
+
496
+ enum _excepthandler_kind {ExceptHandler_kind=1};
497
+ struct _excepthandler {
498
+ enum _excepthandler_kind kind;
499
+ union {
500
+ struct {
501
+ expr_ty type;
502
+ identifier name;
503
+ asdl_stmt_seq *body;
504
+ } ExceptHandler;
505
+
506
+ } v;
507
+ int lineno;
508
+ int col_offset;
509
+ int end_lineno;
510
+ int end_col_offset;
511
+ };
512
+
513
+ struct _arguments {
514
+ asdl_arg_seq *posonlyargs;
515
+ asdl_arg_seq *args;
516
+ arg_ty vararg;
517
+ asdl_arg_seq *kwonlyargs;
518
+ asdl_expr_seq *kw_defaults;
519
+ arg_ty kwarg;
520
+ asdl_expr_seq *defaults;
521
+ };
522
+
523
+ struct _arg {
524
+ identifier arg;
525
+ expr_ty annotation;
526
+ string type_comment;
527
+ int lineno;
528
+ int col_offset;
529
+ int end_lineno;
530
+ int end_col_offset;
531
+ };
532
+
533
+ struct _keyword {
534
+ identifier arg;
535
+ expr_ty value;
536
+ int lineno;
537
+ int col_offset;
538
+ int end_lineno;
539
+ int end_col_offset;
540
+ };
541
+
542
+ struct _alias {
543
+ identifier name;
544
+ identifier asname;
545
+ int lineno;
546
+ int col_offset;
547
+ int end_lineno;
548
+ int end_col_offset;
549
+ };
550
+
551
+ struct _withitem {
552
+ expr_ty context_expr;
553
+ expr_ty optional_vars;
554
+ };
555
+
556
+ struct _match_case {
557
+ pattern_ty pattern;
558
+ expr_ty guard;
559
+ asdl_stmt_seq *body;
560
+ };
561
+
562
+ enum _pattern_kind {MatchValue_kind=1, MatchSingleton_kind=2,
563
+ MatchSequence_kind=3, MatchMapping_kind=4,
564
+ MatchClass_kind=5, MatchStar_kind=6, MatchAs_kind=7,
565
+ MatchOr_kind=8};
566
+ struct _pattern {
567
+ enum _pattern_kind kind;
568
+ union {
569
+ struct {
570
+ expr_ty value;
571
+ } MatchValue;
572
+
573
+ struct {
574
+ constant value;
575
+ } MatchSingleton;
576
+
577
+ struct {
578
+ asdl_pattern_seq *patterns;
579
+ } MatchSequence;
580
+
581
+ struct {
582
+ asdl_expr_seq *keys;
583
+ asdl_pattern_seq *patterns;
584
+ identifier rest;
585
+ } MatchMapping;
586
+
587
+ struct {
588
+ expr_ty cls;
589
+ asdl_pattern_seq *patterns;
590
+ asdl_identifier_seq *kwd_attrs;
591
+ asdl_pattern_seq *kwd_patterns;
592
+ } MatchClass;
593
+
594
+ struct {
595
+ identifier name;
596
+ } MatchStar;
597
+
598
+ struct {
599
+ pattern_ty pattern;
600
+ identifier name;
601
+ } MatchAs;
602
+
603
+ struct {
604
+ asdl_pattern_seq *patterns;
605
+ } MatchOr;
606
+
607
+ } v;
608
+ int lineno;
609
+ int col_offset;
610
+ int end_lineno;
611
+ int end_col_offset;
612
+ };
613
+
614
+ enum _type_ignore_kind {TypeIgnore_kind=1};
615
+ struct _type_ignore {
616
+ enum _type_ignore_kind kind;
617
+ union {
618
+ struct {
619
+ int lineno;
620
+ string tag;
621
+ } TypeIgnore;
622
+
623
+ } v;
624
+ };
625
+
626
+
627
+ // Note: these macros affect function definitions, not only call sites.
628
+ mod_ty _PyAST_Module(asdl_stmt_seq * body, asdl_type_ignore_seq * type_ignores,
629
+ PyArena *arena);
630
+ mod_ty _PyAST_Interactive(asdl_stmt_seq * body, PyArena *arena);
631
+ mod_ty _PyAST_Expression(expr_ty body, PyArena *arena);
632
+ mod_ty _PyAST_FunctionType(asdl_expr_seq * argtypes, expr_ty returns, PyArena
633
+ *arena);
634
+ stmt_ty _PyAST_FunctionDef(identifier name, arguments_ty args, asdl_stmt_seq *
635
+ body, asdl_expr_seq * decorator_list, expr_ty
636
+ returns, string type_comment, int lineno, int
637
+ col_offset, int end_lineno, int end_col_offset,
638
+ PyArena *arena);
639
+ stmt_ty _PyAST_AsyncFunctionDef(identifier name, arguments_ty args,
640
+ asdl_stmt_seq * body, asdl_expr_seq *
641
+ decorator_list, expr_ty returns, string
642
+ type_comment, int lineno, int col_offset, int
643
+ end_lineno, int end_col_offset, PyArena *arena);
644
+ stmt_ty _PyAST_ClassDef(identifier name, asdl_expr_seq * bases,
645
+ asdl_keyword_seq * keywords, asdl_stmt_seq * body,
646
+ asdl_expr_seq * decorator_list, int lineno, int
647
+ col_offset, int end_lineno, int end_col_offset, PyArena
648
+ *arena);
649
+ stmt_ty _PyAST_Return(expr_ty value, int lineno, int col_offset, int
650
+ end_lineno, int end_col_offset, PyArena *arena);
651
+ stmt_ty _PyAST_Delete(asdl_expr_seq * targets, int lineno, int col_offset, int
652
+ end_lineno, int end_col_offset, PyArena *arena);
653
+ stmt_ty _PyAST_Assign(asdl_expr_seq * targets, expr_ty value, string
654
+ type_comment, int lineno, int col_offset, int end_lineno,
655
+ int end_col_offset, PyArena *arena);
656
+ stmt_ty _PyAST_AugAssign(expr_ty target, operator_ty op, expr_ty value, int
657
+ lineno, int col_offset, int end_lineno, int
658
+ end_col_offset, PyArena *arena);
659
+ stmt_ty _PyAST_AnnAssign(expr_ty target, expr_ty annotation, expr_ty value, int
660
+ simple, int lineno, int col_offset, int end_lineno,
661
+ int end_col_offset, PyArena *arena);
662
+ stmt_ty _PyAST_For(expr_ty target, expr_ty iter, asdl_stmt_seq * body,
663
+ asdl_stmt_seq * orelse, string type_comment, int lineno, int
664
+ col_offset, int end_lineno, int end_col_offset, PyArena
665
+ *arena);
666
+ stmt_ty _PyAST_AsyncFor(expr_ty target, expr_ty iter, asdl_stmt_seq * body,
667
+ asdl_stmt_seq * orelse, string type_comment, int
668
+ lineno, int col_offset, int end_lineno, int
669
+ end_col_offset, PyArena *arena);
670
+ stmt_ty _PyAST_While(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq *
671
+ orelse, int lineno, int col_offset, int end_lineno, int
672
+ end_col_offset, PyArena *arena);
673
+ stmt_ty _PyAST_If(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse,
674
+ int lineno, int col_offset, int end_lineno, int
675
+ end_col_offset, PyArena *arena);
676
+ stmt_ty _PyAST_With(asdl_withitem_seq * items, asdl_stmt_seq * body, string
677
+ type_comment, int lineno, int col_offset, int end_lineno,
678
+ int end_col_offset, PyArena *arena);
679
+ stmt_ty _PyAST_AsyncWith(asdl_withitem_seq * items, asdl_stmt_seq * body,
680
+ string type_comment, int lineno, int col_offset, int
681
+ end_lineno, int end_col_offset, PyArena *arena);
682
+ stmt_ty _PyAST_Match(expr_ty subject, asdl_match_case_seq * cases, int lineno,
683
+ int col_offset, int end_lineno, int end_col_offset,
684
+ PyArena *arena);
685
+ stmt_ty _PyAST_Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset,
686
+ int end_lineno, int end_col_offset, PyArena *arena);
687
+ stmt_ty _PyAST_Try(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
688
+ asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int
689
+ lineno, int col_offset, int end_lineno, int end_col_offset,
690
+ PyArena *arena);
691
+ stmt_ty _PyAST_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset,
692
+ int end_lineno, int end_col_offset, PyArena *arena);
693
+ stmt_ty _PyAST_Import(asdl_alias_seq * names, int lineno, int col_offset, int
694
+ end_lineno, int end_col_offset, PyArena *arena);
695
+ stmt_ty _PyAST_ImportFrom(identifier module, asdl_alias_seq * names, int level,
696
+ int lineno, int col_offset, int end_lineno, int
697
+ end_col_offset, PyArena *arena);
698
+ stmt_ty _PyAST_Global(asdl_identifier_seq * names, int lineno, int col_offset,
699
+ int end_lineno, int end_col_offset, PyArena *arena);
700
+ stmt_ty _PyAST_Nonlocal(asdl_identifier_seq * names, int lineno, int
701
+ col_offset, int end_lineno, int end_col_offset, PyArena
702
+ *arena);
703
+ stmt_ty _PyAST_Expr(expr_ty value, int lineno, int col_offset, int end_lineno,
704
+ int end_col_offset, PyArena *arena);
705
+ stmt_ty _PyAST_Pass(int lineno, int col_offset, int end_lineno, int
706
+ end_col_offset, PyArena *arena);
707
+ stmt_ty _PyAST_Break(int lineno, int col_offset, int end_lineno, int
708
+ end_col_offset, PyArena *arena);
709
+ stmt_ty _PyAST_Continue(int lineno, int col_offset, int end_lineno, int
710
+ end_col_offset, PyArena *arena);
711
+ expr_ty _PyAST_BoolOp(boolop_ty op, asdl_expr_seq * values, int lineno, int
712
+ col_offset, int end_lineno, int end_col_offset, PyArena
713
+ *arena);
714
+ expr_ty _PyAST_NamedExpr(expr_ty target, expr_ty value, int lineno, int
715
+ col_offset, int end_lineno, int end_col_offset,
716
+ PyArena *arena);
717
+ expr_ty _PyAST_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno,
718
+ int col_offset, int end_lineno, int end_col_offset,
719
+ PyArena *arena);
720
+ expr_ty _PyAST_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int
721
+ col_offset, int end_lineno, int end_col_offset, PyArena
722
+ *arena);
723
+ expr_ty _PyAST_Lambda(arguments_ty args, expr_ty body, int lineno, int
724
+ col_offset, int end_lineno, int end_col_offset, PyArena
725
+ *arena);
726
+ expr_ty _PyAST_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno,
727
+ int col_offset, int end_lineno, int end_col_offset,
728
+ PyArena *arena);
729
+ expr_ty _PyAST_Dict(asdl_expr_seq * keys, asdl_expr_seq * values, int lineno,
730
+ int col_offset, int end_lineno, int end_col_offset, PyArena
731
+ *arena);
732
+ expr_ty _PyAST_Set(asdl_expr_seq * elts, int lineno, int col_offset, int
733
+ end_lineno, int end_col_offset, PyArena *arena);
734
+ expr_ty _PyAST_ListComp(expr_ty elt, asdl_comprehension_seq * generators, int
735
+ lineno, int col_offset, int end_lineno, int
736
+ end_col_offset, PyArena *arena);
737
+ expr_ty _PyAST_SetComp(expr_ty elt, asdl_comprehension_seq * generators, int
738
+ lineno, int col_offset, int end_lineno, int
739
+ end_col_offset, PyArena *arena);
740
+ expr_ty _PyAST_DictComp(expr_ty key, expr_ty value, asdl_comprehension_seq *
741
+ generators, int lineno, int col_offset, int end_lineno,
742
+ int end_col_offset, PyArena *arena);
743
+ expr_ty _PyAST_GeneratorExp(expr_ty elt, asdl_comprehension_seq * generators,
744
+ int lineno, int col_offset, int end_lineno, int
745
+ end_col_offset, PyArena *arena);
746
+ expr_ty _PyAST_Await(expr_ty value, int lineno, int col_offset, int end_lineno,
747
+ int end_col_offset, PyArena *arena);
748
+ expr_ty _PyAST_Yield(expr_ty value, int lineno, int col_offset, int end_lineno,
749
+ int end_col_offset, PyArena *arena);
750
+ expr_ty _PyAST_YieldFrom(expr_ty value, int lineno, int col_offset, int
751
+ end_lineno, int end_col_offset, PyArena *arena);
752
+ expr_ty _PyAST_Compare(expr_ty left, asdl_int_seq * ops, asdl_expr_seq *
753
+ comparators, int lineno, int col_offset, int end_lineno,
754
+ int end_col_offset, PyArena *arena);
755
+ expr_ty _PyAST_Call(expr_ty func, asdl_expr_seq * args, asdl_keyword_seq *
756
+ keywords, int lineno, int col_offset, int end_lineno, int
757
+ end_col_offset, PyArena *arena);
758
+ expr_ty _PyAST_FormattedValue(expr_ty value, int conversion, expr_ty
759
+ format_spec, int lineno, int col_offset, int
760
+ end_lineno, int end_col_offset, PyArena *arena);
761
+ expr_ty _PyAST_JoinedStr(asdl_expr_seq * values, int lineno, int col_offset,
762
+ int end_lineno, int end_col_offset, PyArena *arena);
763
+ expr_ty _PyAST_Constant(constant value, string kind, int lineno, int
764
+ col_offset, int end_lineno, int end_col_offset, PyArena
765
+ *arena);
766
+ expr_ty _PyAST_Attribute(expr_ty value, identifier attr, expr_context_ty ctx,
767
+ int lineno, int col_offset, int end_lineno, int
768
+ end_col_offset, PyArena *arena);
769
+ expr_ty _PyAST_Subscript(expr_ty value, expr_ty slice, expr_context_ty ctx, int
770
+ lineno, int col_offset, int end_lineno, int
771
+ end_col_offset, PyArena *arena);
772
+ expr_ty _PyAST_Starred(expr_ty value, expr_context_ty ctx, int lineno, int
773
+ col_offset, int end_lineno, int end_col_offset, PyArena
774
+ *arena);
775
+ expr_ty _PyAST_Name(identifier id, expr_context_ty ctx, int lineno, int
776
+ col_offset, int end_lineno, int end_col_offset, PyArena
777
+ *arena);
778
+ expr_ty _PyAST_List(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
779
+ col_offset, int end_lineno, int end_col_offset, PyArena
780
+ *arena);
781
+ expr_ty _PyAST_Tuple(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
782
+ col_offset, int end_lineno, int end_col_offset, PyArena
783
+ *arena);
784
+ expr_ty _PyAST_Slice(expr_ty lower, expr_ty upper, expr_ty step, int lineno,
785
+ int col_offset, int end_lineno, int end_col_offset,
786
+ PyArena *arena);
787
+ comprehension_ty _PyAST_comprehension(expr_ty target, expr_ty iter,
788
+ asdl_expr_seq * ifs, int is_async,
789
+ PyArena *arena);
790
+ excepthandler_ty _PyAST_ExceptHandler(expr_ty type, identifier name,
791
+ asdl_stmt_seq * body, int lineno, int
792
+ col_offset, int end_lineno, int
793
+ end_col_offset, PyArena *arena);
794
+ arguments_ty _PyAST_arguments(asdl_arg_seq * posonlyargs, asdl_arg_seq * args,
795
+ arg_ty vararg, asdl_arg_seq * kwonlyargs,
796
+ asdl_expr_seq * kw_defaults, arg_ty kwarg,
797
+ asdl_expr_seq * defaults, PyArena *arena);
798
+ arg_ty _PyAST_arg(identifier arg, expr_ty annotation, string type_comment, int
799
+ lineno, int col_offset, int end_lineno, int end_col_offset,
800
+ PyArena *arena);
801
+ keyword_ty _PyAST_keyword(identifier arg, expr_ty value, int lineno, int
802
+ col_offset, int end_lineno, int end_col_offset,
803
+ PyArena *arena);
804
+ alias_ty _PyAST_alias(identifier name, identifier asname, int lineno, int
805
+ col_offset, int end_lineno, int end_col_offset, PyArena
806
+ *arena);
807
+ withitem_ty _PyAST_withitem(expr_ty context_expr, expr_ty optional_vars,
808
+ PyArena *arena);
809
+ match_case_ty _PyAST_match_case(pattern_ty pattern, expr_ty guard,
810
+ asdl_stmt_seq * body, PyArena *arena);
811
+ pattern_ty _PyAST_MatchValue(expr_ty value, int lineno, int col_offset, int
812
+ end_lineno, int end_col_offset, PyArena *arena);
813
+ pattern_ty _PyAST_MatchSingleton(constant value, int lineno, int col_offset,
814
+ int end_lineno, int end_col_offset, PyArena
815
+ *arena);
816
+ pattern_ty _PyAST_MatchSequence(asdl_pattern_seq * patterns, int lineno, int
817
+ col_offset, int end_lineno, int end_col_offset,
818
+ PyArena *arena);
819
+ pattern_ty _PyAST_MatchMapping(asdl_expr_seq * keys, asdl_pattern_seq *
820
+ patterns, identifier rest, int lineno, int
821
+ col_offset, int end_lineno, int end_col_offset,
822
+ PyArena *arena);
823
+ pattern_ty _PyAST_MatchClass(expr_ty cls, asdl_pattern_seq * patterns,
824
+ asdl_identifier_seq * kwd_attrs, asdl_pattern_seq
825
+ * kwd_patterns, int lineno, int col_offset, int
826
+ end_lineno, int end_col_offset, PyArena *arena);
827
+ pattern_ty _PyAST_MatchStar(identifier name, int lineno, int col_offset, int
828
+ end_lineno, int end_col_offset, PyArena *arena);
829
+ pattern_ty _PyAST_MatchAs(pattern_ty pattern, identifier name, int lineno, int
830
+ col_offset, int end_lineno, int end_col_offset,
831
+ PyArena *arena);
832
+ pattern_ty _PyAST_MatchOr(asdl_pattern_seq * patterns, int lineno, int
833
+ col_offset, int end_lineno, int end_col_offset,
834
+ PyArena *arena);
835
+ type_ignore_ty _PyAST_TypeIgnore(int lineno, string tag, PyArena *arena);
836
+
837
+
838
+ PyObject* PyAST_mod2obj(mod_ty t);
839
+ mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode);
840
+ int PyAST_Check(PyObject* obj);
841
+
842
+ extern int _PyAST_Validate(mod_ty);
843
+
844
+ /* _PyAST_ExprAsUnicode is defined in ast_unparse.c */
845
+ extern PyObject* _PyAST_ExprAsUnicode(expr_ty);
846
+
847
+ /* Return the borrowed reference to the first literal string in the
848
+ sequence of statements or NULL if it doesn't start from a literal string.
849
+ Doesn't set exception. */
850
+ extern PyObject* _PyAST_GetDocString(asdl_stmt_seq *);
851
+
852
+ #ifdef __cplusplus
853
+ }
854
+ #endif
855
+ #endif /* !Py_INTERNAL_AST_H */
llava_next/include/python3.10/internal/pycore_ast_state.h ADDED
@@ -0,0 +1,255 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // File automatically generated by Parser/asdl_c.py.
2
+
3
+ #ifndef Py_INTERNAL_AST_STATE_H
4
+ #define Py_INTERNAL_AST_STATE_H
5
+ #ifdef __cplusplus
6
+ extern "C" {
7
+ #endif
8
+
9
+ #ifndef Py_BUILD_CORE
10
+ # error "this header requires Py_BUILD_CORE define"
11
+ #endif
12
+
13
+ struct ast_state {
14
+ int initialized;
15
+ PyObject *AST_type;
16
+ PyObject *Add_singleton;
17
+ PyObject *Add_type;
18
+ PyObject *And_singleton;
19
+ PyObject *And_type;
20
+ PyObject *AnnAssign_type;
21
+ PyObject *Assert_type;
22
+ PyObject *Assign_type;
23
+ PyObject *AsyncFor_type;
24
+ PyObject *AsyncFunctionDef_type;
25
+ PyObject *AsyncWith_type;
26
+ PyObject *Attribute_type;
27
+ PyObject *AugAssign_type;
28
+ PyObject *Await_type;
29
+ PyObject *BinOp_type;
30
+ PyObject *BitAnd_singleton;
31
+ PyObject *BitAnd_type;
32
+ PyObject *BitOr_singleton;
33
+ PyObject *BitOr_type;
34
+ PyObject *BitXor_singleton;
35
+ PyObject *BitXor_type;
36
+ PyObject *BoolOp_type;
37
+ PyObject *Break_type;
38
+ PyObject *Call_type;
39
+ PyObject *ClassDef_type;
40
+ PyObject *Compare_type;
41
+ PyObject *Constant_type;
42
+ PyObject *Continue_type;
43
+ PyObject *Del_singleton;
44
+ PyObject *Del_type;
45
+ PyObject *Delete_type;
46
+ PyObject *DictComp_type;
47
+ PyObject *Dict_type;
48
+ PyObject *Div_singleton;
49
+ PyObject *Div_type;
50
+ PyObject *Eq_singleton;
51
+ PyObject *Eq_type;
52
+ PyObject *ExceptHandler_type;
53
+ PyObject *Expr_type;
54
+ PyObject *Expression_type;
55
+ PyObject *FloorDiv_singleton;
56
+ PyObject *FloorDiv_type;
57
+ PyObject *For_type;
58
+ PyObject *FormattedValue_type;
59
+ PyObject *FunctionDef_type;
60
+ PyObject *FunctionType_type;
61
+ PyObject *GeneratorExp_type;
62
+ PyObject *Global_type;
63
+ PyObject *GtE_singleton;
64
+ PyObject *GtE_type;
65
+ PyObject *Gt_singleton;
66
+ PyObject *Gt_type;
67
+ PyObject *IfExp_type;
68
+ PyObject *If_type;
69
+ PyObject *ImportFrom_type;
70
+ PyObject *Import_type;
71
+ PyObject *In_singleton;
72
+ PyObject *In_type;
73
+ PyObject *Interactive_type;
74
+ PyObject *Invert_singleton;
75
+ PyObject *Invert_type;
76
+ PyObject *IsNot_singleton;
77
+ PyObject *IsNot_type;
78
+ PyObject *Is_singleton;
79
+ PyObject *Is_type;
80
+ PyObject *JoinedStr_type;
81
+ PyObject *LShift_singleton;
82
+ PyObject *LShift_type;
83
+ PyObject *Lambda_type;
84
+ PyObject *ListComp_type;
85
+ PyObject *List_type;
86
+ PyObject *Load_singleton;
87
+ PyObject *Load_type;
88
+ PyObject *LtE_singleton;
89
+ PyObject *LtE_type;
90
+ PyObject *Lt_singleton;
91
+ PyObject *Lt_type;
92
+ PyObject *MatMult_singleton;
93
+ PyObject *MatMult_type;
94
+ PyObject *MatchAs_type;
95
+ PyObject *MatchClass_type;
96
+ PyObject *MatchMapping_type;
97
+ PyObject *MatchOr_type;
98
+ PyObject *MatchSequence_type;
99
+ PyObject *MatchSingleton_type;
100
+ PyObject *MatchStar_type;
101
+ PyObject *MatchValue_type;
102
+ PyObject *Match_type;
103
+ PyObject *Mod_singleton;
104
+ PyObject *Mod_type;
105
+ PyObject *Module_type;
106
+ PyObject *Mult_singleton;
107
+ PyObject *Mult_type;
108
+ PyObject *Name_type;
109
+ PyObject *NamedExpr_type;
110
+ PyObject *Nonlocal_type;
111
+ PyObject *NotEq_singleton;
112
+ PyObject *NotEq_type;
113
+ PyObject *NotIn_singleton;
114
+ PyObject *NotIn_type;
115
+ PyObject *Not_singleton;
116
+ PyObject *Not_type;
117
+ PyObject *Or_singleton;
118
+ PyObject *Or_type;
119
+ PyObject *Pass_type;
120
+ PyObject *Pow_singleton;
121
+ PyObject *Pow_type;
122
+ PyObject *RShift_singleton;
123
+ PyObject *RShift_type;
124
+ PyObject *Raise_type;
125
+ PyObject *Return_type;
126
+ PyObject *SetComp_type;
127
+ PyObject *Set_type;
128
+ PyObject *Slice_type;
129
+ PyObject *Starred_type;
130
+ PyObject *Store_singleton;
131
+ PyObject *Store_type;
132
+ PyObject *Sub_singleton;
133
+ PyObject *Sub_type;
134
+ PyObject *Subscript_type;
135
+ PyObject *Try_type;
136
+ PyObject *Tuple_type;
137
+ PyObject *TypeIgnore_type;
138
+ PyObject *UAdd_singleton;
139
+ PyObject *UAdd_type;
140
+ PyObject *USub_singleton;
141
+ PyObject *USub_type;
142
+ PyObject *UnaryOp_type;
143
+ PyObject *While_type;
144
+ PyObject *With_type;
145
+ PyObject *YieldFrom_type;
146
+ PyObject *Yield_type;
147
+ PyObject *__dict__;
148
+ PyObject *__doc__;
149
+ PyObject *__match_args__;
150
+ PyObject *__module__;
151
+ PyObject *_attributes;
152
+ PyObject *_fields;
153
+ PyObject *alias_type;
154
+ PyObject *annotation;
155
+ PyObject *arg;
156
+ PyObject *arg_type;
157
+ PyObject *args;
158
+ PyObject *argtypes;
159
+ PyObject *arguments_type;
160
+ PyObject *asname;
161
+ PyObject *ast;
162
+ PyObject *attr;
163
+ PyObject *bases;
164
+ PyObject *body;
165
+ PyObject *boolop_type;
166
+ PyObject *cases;
167
+ PyObject *cause;
168
+ PyObject *cls;
169
+ PyObject *cmpop_type;
170
+ PyObject *col_offset;
171
+ PyObject *comparators;
172
+ PyObject *comprehension_type;
173
+ PyObject *context_expr;
174
+ PyObject *conversion;
175
+ PyObject *ctx;
176
+ PyObject *decorator_list;
177
+ PyObject *defaults;
178
+ PyObject *elt;
179
+ PyObject *elts;
180
+ PyObject *end_col_offset;
181
+ PyObject *end_lineno;
182
+ PyObject *exc;
183
+ PyObject *excepthandler_type;
184
+ PyObject *expr_context_type;
185
+ PyObject *expr_type;
186
+ PyObject *finalbody;
187
+ PyObject *format_spec;
188
+ PyObject *func;
189
+ PyObject *generators;
190
+ PyObject *guard;
191
+ PyObject *handlers;
192
+ PyObject *id;
193
+ PyObject *ifs;
194
+ PyObject *is_async;
195
+ PyObject *items;
196
+ PyObject *iter;
197
+ PyObject *key;
198
+ PyObject *keys;
199
+ PyObject *keyword_type;
200
+ PyObject *keywords;
201
+ PyObject *kind;
202
+ PyObject *kw_defaults;
203
+ PyObject *kwarg;
204
+ PyObject *kwd_attrs;
205
+ PyObject *kwd_patterns;
206
+ PyObject *kwonlyargs;
207
+ PyObject *left;
208
+ PyObject *level;
209
+ PyObject *lineno;
210
+ PyObject *lower;
211
+ PyObject *match_case_type;
212
+ PyObject *mod_type;
213
+ PyObject *module;
214
+ PyObject *msg;
215
+ PyObject *name;
216
+ PyObject *names;
217
+ PyObject *op;
218
+ PyObject *operand;
219
+ PyObject *operator_type;
220
+ PyObject *ops;
221
+ PyObject *optional_vars;
222
+ PyObject *orelse;
223
+ PyObject *pattern;
224
+ PyObject *pattern_type;
225
+ PyObject *patterns;
226
+ PyObject *posonlyargs;
227
+ PyObject *rest;
228
+ PyObject *returns;
229
+ PyObject *right;
230
+ PyObject *simple;
231
+ PyObject *slice;
232
+ PyObject *step;
233
+ PyObject *stmt_type;
234
+ PyObject *subject;
235
+ PyObject *tag;
236
+ PyObject *target;
237
+ PyObject *targets;
238
+ PyObject *test;
239
+ PyObject *type;
240
+ PyObject *type_comment;
241
+ PyObject *type_ignore_type;
242
+ PyObject *type_ignores;
243
+ PyObject *unaryop_type;
244
+ PyObject *upper;
245
+ PyObject *value;
246
+ PyObject *values;
247
+ PyObject *vararg;
248
+ PyObject *withitem_type;
249
+ };
250
+
251
+ #ifdef __cplusplus
252
+ }
253
+ #endif
254
+ #endif /* !Py_INTERNAL_AST_STATE_H */
255
+
llava_next/include/python3.10/internal/pycore_atomic.h ADDED
@@ -0,0 +1,557 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_ATOMIC_H
2
+ #define Py_ATOMIC_H
3
+ #ifdef __cplusplus
4
+ extern "C" {
5
+ #endif
6
+
7
+ #ifndef Py_BUILD_CORE
8
+ # error "this header requires Py_BUILD_CORE define"
9
+ #endif
10
+
11
+ #include "dynamic_annotations.h" /* _Py_ANNOTATE_MEMORY_ORDER */
12
+ #include "pyconfig.h"
13
+
14
+ #ifdef HAVE_STD_ATOMIC
15
+ # include <stdatomic.h>
16
+ #endif
17
+
18
+
19
+ #if defined(_MSC_VER)
20
+ #include <intrin.h>
21
+ #if defined(_M_IX86) || defined(_M_X64)
22
+ # include <immintrin.h>
23
+ #endif
24
+ #endif
25
+
26
+ /* This is modeled after the atomics interface from C1x, according to
27
+ * the draft at
28
+ * http://www.open-std.org/JTC1/SC22/wg14/www/docs/n1425.pdf.
29
+ * Operations and types are named the same except with a _Py_ prefix
30
+ * and have the same semantics.
31
+ *
32
+ * Beware, the implementations here are deep magic.
33
+ */
34
+
35
+ #if defined(HAVE_STD_ATOMIC)
36
+
37
+ typedef enum _Py_memory_order {
38
+ _Py_memory_order_relaxed = memory_order_relaxed,
39
+ _Py_memory_order_acquire = memory_order_acquire,
40
+ _Py_memory_order_release = memory_order_release,
41
+ _Py_memory_order_acq_rel = memory_order_acq_rel,
42
+ _Py_memory_order_seq_cst = memory_order_seq_cst
43
+ } _Py_memory_order;
44
+
45
+ typedef struct _Py_atomic_address {
46
+ atomic_uintptr_t _value;
47
+ } _Py_atomic_address;
48
+
49
+ typedef struct _Py_atomic_int {
50
+ atomic_int _value;
51
+ } _Py_atomic_int;
52
+
53
+ #define _Py_atomic_signal_fence(/*memory_order*/ ORDER) \
54
+ atomic_signal_fence(ORDER)
55
+
56
+ #define _Py_atomic_thread_fence(/*memory_order*/ ORDER) \
57
+ atomic_thread_fence(ORDER)
58
+
59
+ #define _Py_atomic_store_explicit(ATOMIC_VAL, NEW_VAL, ORDER) \
60
+ atomic_store_explicit(&((ATOMIC_VAL)->_value), NEW_VAL, ORDER)
61
+
62
+ #define _Py_atomic_load_explicit(ATOMIC_VAL, ORDER) \
63
+ atomic_load_explicit(&((ATOMIC_VAL)->_value), ORDER)
64
+
65
+ // Use builtin atomic operations in GCC >= 4.7 and clang
66
+ #elif defined(HAVE_BUILTIN_ATOMIC)
67
+
68
+ typedef enum _Py_memory_order {
69
+ _Py_memory_order_relaxed = __ATOMIC_RELAXED,
70
+ _Py_memory_order_acquire = __ATOMIC_ACQUIRE,
71
+ _Py_memory_order_release = __ATOMIC_RELEASE,
72
+ _Py_memory_order_acq_rel = __ATOMIC_ACQ_REL,
73
+ _Py_memory_order_seq_cst = __ATOMIC_SEQ_CST
74
+ } _Py_memory_order;
75
+
76
+ typedef struct _Py_atomic_address {
77
+ uintptr_t _value;
78
+ } _Py_atomic_address;
79
+
80
+ typedef struct _Py_atomic_int {
81
+ int _value;
82
+ } _Py_atomic_int;
83
+
84
+ #define _Py_atomic_signal_fence(/*memory_order*/ ORDER) \
85
+ __atomic_signal_fence(ORDER)
86
+
87
+ #define _Py_atomic_thread_fence(/*memory_order*/ ORDER) \
88
+ __atomic_thread_fence(ORDER)
89
+
90
+ #define _Py_atomic_store_explicit(ATOMIC_VAL, NEW_VAL, ORDER) \
91
+ (assert((ORDER) == __ATOMIC_RELAXED \
92
+ || (ORDER) == __ATOMIC_SEQ_CST \
93
+ || (ORDER) == __ATOMIC_RELEASE), \
94
+ __atomic_store_n(&((ATOMIC_VAL)->_value), NEW_VAL, ORDER))
95
+
96
+ #define _Py_atomic_load_explicit(ATOMIC_VAL, ORDER) \
97
+ (assert((ORDER) == __ATOMIC_RELAXED \
98
+ || (ORDER) == __ATOMIC_SEQ_CST \
99
+ || (ORDER) == __ATOMIC_ACQUIRE \
100
+ || (ORDER) == __ATOMIC_CONSUME), \
101
+ __atomic_load_n(&((ATOMIC_VAL)->_value), ORDER))
102
+
103
+ /* Only support GCC (for expression statements) and x86 (for simple
104
+ * atomic semantics) and MSVC x86/x64/ARM */
105
+ #elif defined(__GNUC__) && (defined(__i386__) || defined(__amd64))
106
+ typedef enum _Py_memory_order {
107
+ _Py_memory_order_relaxed,
108
+ _Py_memory_order_acquire,
109
+ _Py_memory_order_release,
110
+ _Py_memory_order_acq_rel,
111
+ _Py_memory_order_seq_cst
112
+ } _Py_memory_order;
113
+
114
+ typedef struct _Py_atomic_address {
115
+ uintptr_t _value;
116
+ } _Py_atomic_address;
117
+
118
+ typedef struct _Py_atomic_int {
119
+ int _value;
120
+ } _Py_atomic_int;
121
+
122
+
123
+ static __inline__ void
124
+ _Py_atomic_signal_fence(_Py_memory_order order)
125
+ {
126
+ if (order != _Py_memory_order_relaxed)
127
+ __asm__ volatile("":::"memory");
128
+ }
129
+
130
+ static __inline__ void
131
+ _Py_atomic_thread_fence(_Py_memory_order order)
132
+ {
133
+ if (order != _Py_memory_order_relaxed)
134
+ __asm__ volatile("mfence":::"memory");
135
+ }
136
+
137
+ /* Tell the race checker about this operation's effects. */
138
+ static __inline__ void
139
+ _Py_ANNOTATE_MEMORY_ORDER(const volatile void *address, _Py_memory_order order)
140
+ {
141
+ (void)address; /* shut up -Wunused-parameter */
142
+ switch(order) {
143
+ case _Py_memory_order_release:
144
+ case _Py_memory_order_acq_rel:
145
+ case _Py_memory_order_seq_cst:
146
+ _Py_ANNOTATE_HAPPENS_BEFORE(address);
147
+ break;
148
+ case _Py_memory_order_relaxed:
149
+ case _Py_memory_order_acquire:
150
+ break;
151
+ }
152
+ switch(order) {
153
+ case _Py_memory_order_acquire:
154
+ case _Py_memory_order_acq_rel:
155
+ case _Py_memory_order_seq_cst:
156
+ _Py_ANNOTATE_HAPPENS_AFTER(address);
157
+ break;
158
+ case _Py_memory_order_relaxed:
159
+ case _Py_memory_order_release:
160
+ break;
161
+ }
162
+ }
163
+
164
+ #define _Py_atomic_store_explicit(ATOMIC_VAL, NEW_VAL, ORDER) \
165
+ __extension__ ({ \
166
+ __typeof__(ATOMIC_VAL) atomic_val = ATOMIC_VAL; \
167
+ __typeof__(atomic_val->_value) new_val = NEW_VAL;\
168
+ volatile __typeof__(new_val) *volatile_data = &atomic_val->_value; \
169
+ _Py_memory_order order = ORDER; \
170
+ _Py_ANNOTATE_MEMORY_ORDER(atomic_val, order); \
171
+ \
172
+ /* Perform the operation. */ \
173
+ _Py_ANNOTATE_IGNORE_WRITES_BEGIN(); \
174
+ switch(order) { \
175
+ case _Py_memory_order_release: \
176
+ _Py_atomic_signal_fence(_Py_memory_order_release); \
177
+ /* fallthrough */ \
178
+ case _Py_memory_order_relaxed: \
179
+ *volatile_data = new_val; \
180
+ break; \
181
+ \
182
+ case _Py_memory_order_acquire: \
183
+ case _Py_memory_order_acq_rel: \
184
+ case _Py_memory_order_seq_cst: \
185
+ __asm__ volatile("xchg %0, %1" \
186
+ : "+r"(new_val) \
187
+ : "m"(atomic_val->_value) \
188
+ : "memory"); \
189
+ break; \
190
+ } \
191
+ _Py_ANNOTATE_IGNORE_WRITES_END(); \
192
+ })
193
+
194
+ #define _Py_atomic_load_explicit(ATOMIC_VAL, ORDER) \
195
+ __extension__ ({ \
196
+ __typeof__(ATOMIC_VAL) atomic_val = ATOMIC_VAL; \
197
+ __typeof__(atomic_val->_value) result; \
198
+ volatile __typeof__(result) *volatile_data = &atomic_val->_value; \
199
+ _Py_memory_order order = ORDER; \
200
+ _Py_ANNOTATE_MEMORY_ORDER(atomic_val, order); \
201
+ \
202
+ /* Perform the operation. */ \
203
+ _Py_ANNOTATE_IGNORE_READS_BEGIN(); \
204
+ switch(order) { \
205
+ case _Py_memory_order_release: \
206
+ case _Py_memory_order_acq_rel: \
207
+ case _Py_memory_order_seq_cst: \
208
+ /* Loads on x86 are not releases by default, so need a */ \
209
+ /* thread fence. */ \
210
+ _Py_atomic_thread_fence(_Py_memory_order_release); \
211
+ break; \
212
+ default: \
213
+ /* No fence */ \
214
+ break; \
215
+ } \
216
+ result = *volatile_data; \
217
+ switch(order) { \
218
+ case _Py_memory_order_acquire: \
219
+ case _Py_memory_order_acq_rel: \
220
+ case _Py_memory_order_seq_cst: \
221
+ /* Loads on x86 are automatically acquire operations so */ \
222
+ /* can get by with just a compiler fence. */ \
223
+ _Py_atomic_signal_fence(_Py_memory_order_acquire); \
224
+ break; \
225
+ default: \
226
+ /* No fence */ \
227
+ break; \
228
+ } \
229
+ _Py_ANNOTATE_IGNORE_READS_END(); \
230
+ result; \
231
+ })
232
+
233
+ #elif defined(_MSC_VER)
234
+ /* _Interlocked* functions provide a full memory barrier and are therefore
235
+ enough for acq_rel and seq_cst. If the HLE variants aren't available
236
+ in hardware they will fall back to a full memory barrier as well.
237
+
238
+ This might affect performance but likely only in some very specific and
239
+ hard to measure scenario.
240
+ */
241
+ #if defined(_M_IX86) || defined(_M_X64)
242
+ typedef enum _Py_memory_order {
243
+ _Py_memory_order_relaxed,
244
+ _Py_memory_order_acquire,
245
+ _Py_memory_order_release,
246
+ _Py_memory_order_acq_rel,
247
+ _Py_memory_order_seq_cst
248
+ } _Py_memory_order;
249
+
250
+ typedef struct _Py_atomic_address {
251
+ volatile uintptr_t _value;
252
+ } _Py_atomic_address;
253
+
254
+ typedef struct _Py_atomic_int {
255
+ volatile int _value;
256
+ } _Py_atomic_int;
257
+
258
+
259
+ #if defined(_M_X64)
260
+ #define _Py_atomic_store_64bit(ATOMIC_VAL, NEW_VAL, ORDER) \
261
+ switch (ORDER) { \
262
+ case _Py_memory_order_acquire: \
263
+ _InterlockedExchange64_HLEAcquire((__int64 volatile*)&((ATOMIC_VAL)->_value), (__int64)(NEW_VAL)); \
264
+ break; \
265
+ case _Py_memory_order_release: \
266
+ _InterlockedExchange64_HLERelease((__int64 volatile*)&((ATOMIC_VAL)->_value), (__int64)(NEW_VAL)); \
267
+ break; \
268
+ default: \
269
+ _InterlockedExchange64((__int64 volatile*)&((ATOMIC_VAL)->_value), (__int64)(NEW_VAL)); \
270
+ break; \
271
+ }
272
+ #else
273
+ #define _Py_atomic_store_64bit(ATOMIC_VAL, NEW_VAL, ORDER) ((void)0);
274
+ #endif
275
+
276
+ #define _Py_atomic_store_32bit(ATOMIC_VAL, NEW_VAL, ORDER) \
277
+ switch (ORDER) { \
278
+ case _Py_memory_order_acquire: \
279
+ _InterlockedExchange_HLEAcquire((volatile long*)&((ATOMIC_VAL)->_value), (int)(NEW_VAL)); \
280
+ break; \
281
+ case _Py_memory_order_release: \
282
+ _InterlockedExchange_HLERelease((volatile long*)&((ATOMIC_VAL)->_value), (int)(NEW_VAL)); \
283
+ break; \
284
+ default: \
285
+ _InterlockedExchange((volatile long*)&((ATOMIC_VAL)->_value), (int)(NEW_VAL)); \
286
+ break; \
287
+ }
288
+
289
+ #if defined(_M_X64)
290
+ /* This has to be an intptr_t for now.
291
+ gil_created() uses -1 as a sentinel value, if this returns
292
+ a uintptr_t it will do an unsigned compare and crash
293
+ */
294
+ inline intptr_t _Py_atomic_load_64bit_impl(volatile uintptr_t* value, int order) {
295
+ __int64 old;
296
+ switch (order) {
297
+ case _Py_memory_order_acquire:
298
+ {
299
+ do {
300
+ old = *value;
301
+ } while(_InterlockedCompareExchange64_HLEAcquire((volatile __int64*)value, old, old) != old);
302
+ break;
303
+ }
304
+ case _Py_memory_order_release:
305
+ {
306
+ do {
307
+ old = *value;
308
+ } while(_InterlockedCompareExchange64_HLERelease((volatile __int64*)value, old, old) != old);
309
+ break;
310
+ }
311
+ case _Py_memory_order_relaxed:
312
+ old = *value;
313
+ break;
314
+ default:
315
+ {
316
+ do {
317
+ old = *value;
318
+ } while(_InterlockedCompareExchange64((volatile __int64*)value, old, old) != old);
319
+ break;
320
+ }
321
+ }
322
+ return old;
323
+ }
324
+
325
+ #define _Py_atomic_load_64bit(ATOMIC_VAL, ORDER) \
326
+ _Py_atomic_load_64bit_impl((volatile uintptr_t*)&((ATOMIC_VAL)->_value), (ORDER))
327
+
328
+ #else
329
+ #define _Py_atomic_load_64bit(ATOMIC_VAL, ORDER) ((ATOMIC_VAL)->_value)
330
+ #endif
331
+
332
+ inline int _Py_atomic_load_32bit_impl(volatile int* value, int order) {
333
+ long old;
334
+ switch (order) {
335
+ case _Py_memory_order_acquire:
336
+ {
337
+ do {
338
+ old = *value;
339
+ } while(_InterlockedCompareExchange_HLEAcquire((volatile long*)value, old, old) != old);
340
+ break;
341
+ }
342
+ case _Py_memory_order_release:
343
+ {
344
+ do {
345
+ old = *value;
346
+ } while(_InterlockedCompareExchange_HLERelease((volatile long*)value, old, old) != old);
347
+ break;
348
+ }
349
+ case _Py_memory_order_relaxed:
350
+ old = *value;
351
+ break;
352
+ default:
353
+ {
354
+ do {
355
+ old = *value;
356
+ } while(_InterlockedCompareExchange((volatile long*)value, old, old) != old);
357
+ break;
358
+ }
359
+ }
360
+ return old;
361
+ }
362
+
363
+ #define _Py_atomic_load_32bit(ATOMIC_VAL, ORDER) \
364
+ _Py_atomic_load_32bit_impl((volatile int*)&((ATOMIC_VAL)->_value), (ORDER))
365
+
366
+ #define _Py_atomic_store_explicit(ATOMIC_VAL, NEW_VAL, ORDER) \
367
+ if (sizeof((ATOMIC_VAL)->_value) == 8) { \
368
+ _Py_atomic_store_64bit((ATOMIC_VAL), NEW_VAL, ORDER) } else { \
369
+ _Py_atomic_store_32bit((ATOMIC_VAL), NEW_VAL, ORDER) }
370
+
371
+ #define _Py_atomic_load_explicit(ATOMIC_VAL, ORDER) \
372
+ ( \
373
+ sizeof((ATOMIC_VAL)->_value) == 8 ? \
374
+ _Py_atomic_load_64bit((ATOMIC_VAL), ORDER) : \
375
+ _Py_atomic_load_32bit((ATOMIC_VAL), ORDER) \
376
+ )
377
+ #elif defined(_M_ARM) || defined(_M_ARM64)
378
+ typedef enum _Py_memory_order {
379
+ _Py_memory_order_relaxed,
380
+ _Py_memory_order_acquire,
381
+ _Py_memory_order_release,
382
+ _Py_memory_order_acq_rel,
383
+ _Py_memory_order_seq_cst
384
+ } _Py_memory_order;
385
+
386
+ typedef struct _Py_atomic_address {
387
+ volatile uintptr_t _value;
388
+ } _Py_atomic_address;
389
+
390
+ typedef struct _Py_atomic_int {
391
+ volatile int _value;
392
+ } _Py_atomic_int;
393
+
394
+
395
+ #if defined(_M_ARM64)
396
+ #define _Py_atomic_store_64bit(ATOMIC_VAL, NEW_VAL, ORDER) \
397
+ switch (ORDER) { \
398
+ case _Py_memory_order_acquire: \
399
+ _InterlockedExchange64_acq((__int64 volatile*)&((ATOMIC_VAL)->_value), (__int64)NEW_VAL); \
400
+ break; \
401
+ case _Py_memory_order_release: \
402
+ _InterlockedExchange64_rel((__int64 volatile*)&((ATOMIC_VAL)->_value), (__int64)NEW_VAL); \
403
+ break; \
404
+ default: \
405
+ _InterlockedExchange64((__int64 volatile*)&((ATOMIC_VAL)->_value), (__int64)NEW_VAL); \
406
+ break; \
407
+ }
408
+ #else
409
+ #define _Py_atomic_store_64bit(ATOMIC_VAL, NEW_VAL, ORDER) ((void)0);
410
+ #endif
411
+
412
+ #define _Py_atomic_store_32bit(ATOMIC_VAL, NEW_VAL, ORDER) \
413
+ switch (ORDER) { \
414
+ case _Py_memory_order_acquire: \
415
+ _InterlockedExchange_acq((volatile long*)&((ATOMIC_VAL)->_value), (int)NEW_VAL); \
416
+ break; \
417
+ case _Py_memory_order_release: \
418
+ _InterlockedExchange_rel((volatile long*)&((ATOMIC_VAL)->_value), (int)NEW_VAL); \
419
+ break; \
420
+ default: \
421
+ _InterlockedExchange((volatile long*)&((ATOMIC_VAL)->_value), (int)NEW_VAL); \
422
+ break; \
423
+ }
424
+
425
+ #if defined(_M_ARM64)
426
+ /* This has to be an intptr_t for now.
427
+ gil_created() uses -1 as a sentinel value, if this returns
428
+ a uintptr_t it will do an unsigned compare and crash
429
+ */
430
+ inline intptr_t _Py_atomic_load_64bit_impl(volatile uintptr_t* value, int order) {
431
+ uintptr_t old;
432
+ switch (order) {
433
+ case _Py_memory_order_acquire:
434
+ {
435
+ do {
436
+ old = *value;
437
+ } while(_InterlockedCompareExchange64_acq(value, old, old) != old);
438
+ break;
439
+ }
440
+ case _Py_memory_order_release:
441
+ {
442
+ do {
443
+ old = *value;
444
+ } while(_InterlockedCompareExchange64_rel(value, old, old) != old);
445
+ break;
446
+ }
447
+ case _Py_memory_order_relaxed:
448
+ old = *value;
449
+ break;
450
+ default:
451
+ {
452
+ do {
453
+ old = *value;
454
+ } while(_InterlockedCompareExchange64(value, old, old) != old);
455
+ break;
456
+ }
457
+ }
458
+ return old;
459
+ }
460
+
461
+ #define _Py_atomic_load_64bit(ATOMIC_VAL, ORDER) \
462
+ _Py_atomic_load_64bit_impl((volatile uintptr_t*)&((ATOMIC_VAL)->_value), (ORDER))
463
+
464
+ #else
465
+ #define _Py_atomic_load_64bit(ATOMIC_VAL, ORDER) ((ATOMIC_VAL)->_value)
466
+ #endif
467
+
468
+ inline int _Py_atomic_load_32bit_impl(volatile int* value, int order) {
469
+ int old;
470
+ switch (order) {
471
+ case _Py_memory_order_acquire:
472
+ {
473
+ do {
474
+ old = *value;
475
+ } while(_InterlockedCompareExchange_acq(value, old, old) != old);
476
+ break;
477
+ }
478
+ case _Py_memory_order_release:
479
+ {
480
+ do {
481
+ old = *value;
482
+ } while(_InterlockedCompareExchange_rel(value, old, old) != old);
483
+ break;
484
+ }
485
+ case _Py_memory_order_relaxed:
486
+ old = *value;
487
+ break;
488
+ default:
489
+ {
490
+ do {
491
+ old = *value;
492
+ } while(_InterlockedCompareExchange(value, old, old) != old);
493
+ break;
494
+ }
495
+ }
496
+ return old;
497
+ }
498
+
499
+ #define _Py_atomic_load_32bit(ATOMIC_VAL, ORDER) \
500
+ _Py_atomic_load_32bit_impl((volatile int*)&((ATOMIC_VAL)->_value), (ORDER))
501
+
502
+ #define _Py_atomic_store_explicit(ATOMIC_VAL, NEW_VAL, ORDER) \
503
+ if (sizeof((ATOMIC_VAL)->_value) == 8) { \
504
+ _Py_atomic_store_64bit((ATOMIC_VAL), (NEW_VAL), (ORDER)) } else { \
505
+ _Py_atomic_store_32bit((ATOMIC_VAL), (NEW_VAL), (ORDER)) }
506
+
507
+ #define _Py_atomic_load_explicit(ATOMIC_VAL, ORDER) \
508
+ ( \
509
+ sizeof((ATOMIC_VAL)->_value) == 8 ? \
510
+ _Py_atomic_load_64bit((ATOMIC_VAL), (ORDER)) : \
511
+ _Py_atomic_load_32bit((ATOMIC_VAL), (ORDER)) \
512
+ )
513
+ #endif
514
+ #else /* !gcc x86 !_msc_ver */
515
+ typedef enum _Py_memory_order {
516
+ _Py_memory_order_relaxed,
517
+ _Py_memory_order_acquire,
518
+ _Py_memory_order_release,
519
+ _Py_memory_order_acq_rel,
520
+ _Py_memory_order_seq_cst
521
+ } _Py_memory_order;
522
+
523
+ typedef struct _Py_atomic_address {
524
+ uintptr_t _value;
525
+ } _Py_atomic_address;
526
+
527
+ typedef struct _Py_atomic_int {
528
+ int _value;
529
+ } _Py_atomic_int;
530
+ /* Fall back to other compilers and processors by assuming that simple
531
+ volatile accesses are atomic. This is false, so people should port
532
+ this. */
533
+ #define _Py_atomic_signal_fence(/*memory_order*/ ORDER) ((void)0)
534
+ #define _Py_atomic_thread_fence(/*memory_order*/ ORDER) ((void)0)
535
+ #define _Py_atomic_store_explicit(ATOMIC_VAL, NEW_VAL, ORDER) \
536
+ ((ATOMIC_VAL)->_value = NEW_VAL)
537
+ #define _Py_atomic_load_explicit(ATOMIC_VAL, ORDER) \
538
+ ((ATOMIC_VAL)->_value)
539
+ #endif
540
+
541
+ /* Standardized shortcuts. */
542
+ #define _Py_atomic_store(ATOMIC_VAL, NEW_VAL) \
543
+ _Py_atomic_store_explicit((ATOMIC_VAL), (NEW_VAL), _Py_memory_order_seq_cst)
544
+ #define _Py_atomic_load(ATOMIC_VAL) \
545
+ _Py_atomic_load_explicit((ATOMIC_VAL), _Py_memory_order_seq_cst)
546
+
547
+ /* Python-local extensions */
548
+
549
+ #define _Py_atomic_store_relaxed(ATOMIC_VAL, NEW_VAL) \
550
+ _Py_atomic_store_explicit((ATOMIC_VAL), (NEW_VAL), _Py_memory_order_relaxed)
551
+ #define _Py_atomic_load_relaxed(ATOMIC_VAL) \
552
+ _Py_atomic_load_explicit((ATOMIC_VAL), _Py_memory_order_relaxed)
553
+
554
+ #ifdef __cplusplus
555
+ }
556
+ #endif
557
+ #endif /* Py_ATOMIC_H */
llava_next/include/python3.10/internal/pycore_atomic_funcs.h ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Atomic functions: similar to pycore_atomic.h, but don't need
2
+ to declare variables as atomic.
3
+
4
+ Py_ssize_t type:
5
+
6
+ * value = _Py_atomic_size_get(&var)
7
+ * _Py_atomic_size_set(&var, value)
8
+
9
+ Use sequentially-consistent ordering (__ATOMIC_SEQ_CST memory order):
10
+ enforce total ordering with all other atomic functions.
11
+ */
12
+ #ifndef Py_ATOMIC_FUNC_H
13
+ #define Py_ATOMIC_FUNC_H
14
+ #ifdef __cplusplus
15
+ extern "C" {
16
+ #endif
17
+
18
+ #ifndef Py_BUILD_CORE
19
+ # error "this header requires Py_BUILD_CORE define"
20
+ #endif
21
+
22
+ #if defined(_MSC_VER)
23
+ # include <intrin.h> // _InterlockedExchange()
24
+ #endif
25
+
26
+
27
+ // Use builtin atomic operations in GCC >= 4.7 and clang
28
+ #ifdef HAVE_BUILTIN_ATOMIC
29
+
30
+ static inline Py_ssize_t _Py_atomic_size_get(Py_ssize_t *var)
31
+ {
32
+ return __atomic_load_n(var, __ATOMIC_SEQ_CST);
33
+ }
34
+
35
+ static inline void _Py_atomic_size_set(Py_ssize_t *var, Py_ssize_t value)
36
+ {
37
+ __atomic_store_n(var, value, __ATOMIC_SEQ_CST);
38
+ }
39
+
40
+ #elif defined(_MSC_VER)
41
+
42
+ static inline Py_ssize_t _Py_atomic_size_get(Py_ssize_t *var)
43
+ {
44
+ #if SIZEOF_VOID_P == 8
45
+ Py_BUILD_ASSERT(sizeof(__int64) == sizeof(*var));
46
+ volatile __int64 *volatile_var = (volatile __int64 *)var;
47
+ __int64 old;
48
+ do {
49
+ old = *volatile_var;
50
+ } while(_InterlockedCompareExchange64(volatile_var, old, old) != old);
51
+ #else
52
+ Py_BUILD_ASSERT(sizeof(long) == sizeof(*var));
53
+ volatile long *volatile_var = (volatile long *)var;
54
+ long old;
55
+ do {
56
+ old = *volatile_var;
57
+ } while(_InterlockedCompareExchange(volatile_var, old, old) != old);
58
+ #endif
59
+ return old;
60
+ }
61
+
62
+ static inline void _Py_atomic_size_set(Py_ssize_t *var, Py_ssize_t value)
63
+ {
64
+ #if SIZEOF_VOID_P == 8
65
+ Py_BUILD_ASSERT(sizeof(__int64) == sizeof(*var));
66
+ volatile __int64 *volatile_var = (volatile __int64 *)var;
67
+ _InterlockedExchange64(volatile_var, value);
68
+ #else
69
+ Py_BUILD_ASSERT(sizeof(long) == sizeof(*var));
70
+ volatile long *volatile_var = (volatile long *)var;
71
+ _InterlockedExchange(volatile_var, value);
72
+ #endif
73
+ }
74
+
75
+ #else
76
+ // Fallback implementation using volatile
77
+
78
+ static inline Py_ssize_t _Py_atomic_size_get(Py_ssize_t *var)
79
+ {
80
+ volatile Py_ssize_t *volatile_var = (volatile Py_ssize_t *)var;
81
+ return *volatile_var;
82
+ }
83
+
84
+ static inline void _Py_atomic_size_set(Py_ssize_t *var, Py_ssize_t value)
85
+ {
86
+ volatile Py_ssize_t *volatile_var = (volatile Py_ssize_t *)var;
87
+ *volatile_var = value;
88
+ }
89
+ #endif
90
+
91
+ #ifdef __cplusplus
92
+ }
93
+ #endif
94
+ #endif /* Py_ATOMIC_FUNC_H */
llava_next/include/python3.10/internal/pycore_bitutils.h ADDED
@@ -0,0 +1,176 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Bit and bytes utilities.
2
+
3
+ Bytes swap functions, reverse order of bytes:
4
+
5
+ - _Py_bswap16(uint16_t)
6
+ - _Py_bswap32(uint32_t)
7
+ - _Py_bswap64(uint64_t)
8
+ */
9
+
10
+ #ifndef Py_INTERNAL_BITUTILS_H
11
+ #define Py_INTERNAL_BITUTILS_H
12
+ #ifdef __cplusplus
13
+ extern "C" {
14
+ #endif
15
+
16
+ #ifndef Py_BUILD_CORE
17
+ # error "this header requires Py_BUILD_CORE define"
18
+ #endif
19
+
20
+ #if defined(__GNUC__) \
21
+ && ((__GNUC__ >= 5) || (__GNUC__ == 4) && (__GNUC_MINOR__ >= 8))
22
+ /* __builtin_bswap16() is available since GCC 4.8,
23
+ __builtin_bswap32() is available since GCC 4.3,
24
+ __builtin_bswap64() is available since GCC 4.3. */
25
+ # define _PY_HAVE_BUILTIN_BSWAP
26
+ #endif
27
+
28
+ #ifdef _MSC_VER
29
+ /* Get _byteswap_ushort(), _byteswap_ulong(), _byteswap_uint64() */
30
+ # include <intrin.h>
31
+ #endif
32
+
33
+ static inline uint16_t
34
+ _Py_bswap16(uint16_t word)
35
+ {
36
+ #if defined(_PY_HAVE_BUILTIN_BSWAP) || _Py__has_builtin(__builtin_bswap16)
37
+ return __builtin_bswap16(word);
38
+ #elif defined(_MSC_VER)
39
+ Py_BUILD_ASSERT(sizeof(word) == sizeof(unsigned short));
40
+ return _byteswap_ushort(word);
41
+ #else
42
+ // Portable implementation which doesn't rely on circular bit shift
43
+ return ( ((word & UINT16_C(0x00FF)) << 8)
44
+ | ((word & UINT16_C(0xFF00)) >> 8));
45
+ #endif
46
+ }
47
+
48
+ static inline uint32_t
49
+ _Py_bswap32(uint32_t word)
50
+ {
51
+ #if defined(_PY_HAVE_BUILTIN_BSWAP) || _Py__has_builtin(__builtin_bswap32)
52
+ return __builtin_bswap32(word);
53
+ #elif defined(_MSC_VER)
54
+ Py_BUILD_ASSERT(sizeof(word) == sizeof(unsigned long));
55
+ return _byteswap_ulong(word);
56
+ #else
57
+ // Portable implementation which doesn't rely on circular bit shift
58
+ return ( ((word & UINT32_C(0x000000FF)) << 24)
59
+ | ((word & UINT32_C(0x0000FF00)) << 8)
60
+ | ((word & UINT32_C(0x00FF0000)) >> 8)
61
+ | ((word & UINT32_C(0xFF000000)) >> 24));
62
+ #endif
63
+ }
64
+
65
+ static inline uint64_t
66
+ _Py_bswap64(uint64_t word)
67
+ {
68
+ #if defined(_PY_HAVE_BUILTIN_BSWAP) || _Py__has_builtin(__builtin_bswap64)
69
+ return __builtin_bswap64(word);
70
+ #elif defined(_MSC_VER)
71
+ return _byteswap_uint64(word);
72
+ #else
73
+ // Portable implementation which doesn't rely on circular bit shift
74
+ return ( ((word & UINT64_C(0x00000000000000FF)) << 56)
75
+ | ((word & UINT64_C(0x000000000000FF00)) << 40)
76
+ | ((word & UINT64_C(0x0000000000FF0000)) << 24)
77
+ | ((word & UINT64_C(0x00000000FF000000)) << 8)
78
+ | ((word & UINT64_C(0x000000FF00000000)) >> 8)
79
+ | ((word & UINT64_C(0x0000FF0000000000)) >> 24)
80
+ | ((word & UINT64_C(0x00FF000000000000)) >> 40)
81
+ | ((word & UINT64_C(0xFF00000000000000)) >> 56));
82
+ #endif
83
+ }
84
+
85
+
86
+ // Population count: count the number of 1's in 'x'
87
+ // (number of bits set to 1), also known as the hamming weight.
88
+ //
89
+ // Implementation note. CPUID is not used, to test if x86 POPCNT instruction
90
+ // can be used, to keep the implementation simple. For example, Visual Studio
91
+ // __popcnt() is not used this reason. The clang and GCC builtin function can
92
+ // use the x86 POPCNT instruction if the target architecture has SSE4a or
93
+ // newer.
94
+ static inline int
95
+ _Py_popcount32(uint32_t x)
96
+ {
97
+ #if (defined(__clang__) || defined(__GNUC__))
98
+
99
+ #if SIZEOF_INT >= 4
100
+ Py_BUILD_ASSERT(sizeof(x) <= sizeof(unsigned int));
101
+ return __builtin_popcount(x);
102
+ #else
103
+ // The C standard guarantees that unsigned long will always be big enough
104
+ // to hold a uint32_t value without losing information.
105
+ Py_BUILD_ASSERT(sizeof(x) <= sizeof(unsigned long));
106
+ return __builtin_popcountl(x);
107
+ #endif
108
+
109
+ #else
110
+ // 32-bit SWAR (SIMD Within A Register) popcount
111
+
112
+ // Binary: 0 1 0 1 ...
113
+ const uint32_t M1 = 0x55555555;
114
+ // Binary: 00 11 00 11. ..
115
+ const uint32_t M2 = 0x33333333;
116
+ // Binary: 0000 1111 0000 1111 ...
117
+ const uint32_t M4 = 0x0F0F0F0F;
118
+ // 256**4 + 256**3 + 256**2 + 256**1
119
+ const uint32_t SUM = 0x01010101;
120
+
121
+ // Put count of each 2 bits into those 2 bits
122
+ x = x - ((x >> 1) & M1);
123
+ // Put count of each 4 bits into those 4 bits
124
+ x = (x & M2) + ((x >> 2) & M2);
125
+ // Put count of each 8 bits into those 8 bits
126
+ x = (x + (x >> 4)) & M4;
127
+ // Sum of the 4 byte counts
128
+ return (uint32_t)((uint64_t)x * (uint64_t)SUM) >> 24;
129
+ #endif
130
+ }
131
+
132
+
133
+ // Return the index of the most significant 1 bit in 'x'. This is the smallest
134
+ // integer k such that x < 2**k. Equivalent to floor(log2(x)) + 1 for x != 0.
135
+ static inline int
136
+ _Py_bit_length(unsigned long x)
137
+ {
138
+ #if (defined(__clang__) || defined(__GNUC__))
139
+ if (x != 0) {
140
+ // __builtin_clzl() is available since GCC 3.4.
141
+ // Undefined behavior for x == 0.
142
+ return (int)sizeof(unsigned long) * 8 - __builtin_clzl(x);
143
+ }
144
+ else {
145
+ return 0;
146
+ }
147
+ #elif defined(_MSC_VER)
148
+ // _BitScanReverse() is documented to search 32 bits.
149
+ Py_BUILD_ASSERT(sizeof(unsigned long) <= 4);
150
+ unsigned long msb;
151
+ if (_BitScanReverse(&msb, x)) {
152
+ return (int)msb + 1;
153
+ }
154
+ else {
155
+ return 0;
156
+ }
157
+ #else
158
+ const int BIT_LENGTH_TABLE[32] = {
159
+ 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4,
160
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5
161
+ };
162
+ int msb = 0;
163
+ while (x >= 32) {
164
+ msb += 6;
165
+ x >>= 6;
166
+ }
167
+ msb += BIT_LENGTH_TABLE[x];
168
+ return msb;
169
+ #endif
170
+ }
171
+
172
+
173
+ #ifdef __cplusplus
174
+ }
175
+ #endif
176
+ #endif /* !Py_INTERNAL_BITUTILS_H */
llava_next/include/python3.10/internal/pycore_blocks_output_buffer.h ADDED
@@ -0,0 +1,317 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ _BlocksOutputBuffer is used to maintain an output buffer
3
+ that has unpredictable size. Suitable for compression/decompression
4
+ API (bz2/lzma/zlib) that has stream->next_out and stream->avail_out:
5
+
6
+ stream->next_out: point to the next output position.
7
+ stream->avail_out: the number of available bytes left in the buffer.
8
+
9
+ It maintains a list of bytes object, so there is no overhead of resizing
10
+ the buffer.
11
+
12
+ Usage:
13
+
14
+ 1, Initialize the struct instance like this:
15
+ _BlocksOutputBuffer buffer = {.list = NULL};
16
+ Set .list to NULL for _BlocksOutputBuffer_OnError()
17
+
18
+ 2, Initialize the buffer use one of these functions:
19
+ _BlocksOutputBuffer_InitAndGrow()
20
+ _BlocksOutputBuffer_InitWithSize()
21
+
22
+ 3, If (avail_out == 0), grow the buffer:
23
+ _BlocksOutputBuffer_Grow()
24
+
25
+ 4, Get the current outputted data size:
26
+ _BlocksOutputBuffer_GetDataSize()
27
+
28
+ 5, Finish the buffer, and return a bytes object:
29
+ _BlocksOutputBuffer_Finish()
30
+
31
+ 6, Clean up the buffer when an error occurred:
32
+ _BlocksOutputBuffer_OnError()
33
+ */
34
+
35
+ #ifndef Py_INTERNAL_BLOCKS_OUTPUT_BUFFER_H
36
+ #define Py_INTERNAL_BLOCKS_OUTPUT_BUFFER_H
37
+ #ifdef __cplusplus
38
+ extern "C" {
39
+ #endif
40
+
41
+ #include "Python.h"
42
+
43
+ typedef struct {
44
+ // List of bytes objects
45
+ PyObject *list;
46
+ // Number of whole allocated size
47
+ Py_ssize_t allocated;
48
+ // Max length of the buffer, negative number means unlimited length.
49
+ Py_ssize_t max_length;
50
+ } _BlocksOutputBuffer;
51
+
52
+ static const char unable_allocate_msg[] = "Unable to allocate output buffer.";
53
+
54
+ /* In 32-bit build, the max block size should <= INT32_MAX. */
55
+ #define OUTPUT_BUFFER_MAX_BLOCK_SIZE (256*1024*1024)
56
+
57
+ /* Block size sequence */
58
+ #define KB (1024)
59
+ #define MB (1024*1024)
60
+ static const Py_ssize_t BUFFER_BLOCK_SIZE[] =
61
+ { 32*KB, 64*KB, 256*KB, 1*MB, 4*MB, 8*MB, 16*MB, 16*MB,
62
+ 32*MB, 32*MB, 32*MB, 32*MB, 64*MB, 64*MB, 128*MB, 128*MB,
63
+ OUTPUT_BUFFER_MAX_BLOCK_SIZE };
64
+ #undef KB
65
+ #undef MB
66
+
67
+ /* According to the block sizes defined by BUFFER_BLOCK_SIZE, the whole
68
+ allocated size growth step is:
69
+ 1 32 KB +32 KB
70
+ 2 96 KB +64 KB
71
+ 3 352 KB +256 KB
72
+ 4 1.34 MB +1 MB
73
+ 5 5.34 MB +4 MB
74
+ 6 13.34 MB +8 MB
75
+ 7 29.34 MB +16 MB
76
+ 8 45.34 MB +16 MB
77
+ 9 77.34 MB +32 MB
78
+ 10 109.34 MB +32 MB
79
+ 11 141.34 MB +32 MB
80
+ 12 173.34 MB +32 MB
81
+ 13 237.34 MB +64 MB
82
+ 14 301.34 MB +64 MB
83
+ 15 429.34 MB +128 MB
84
+ 16 557.34 MB +128 MB
85
+ 17 813.34 MB +256 MB
86
+ 18 1069.34 MB +256 MB
87
+ 19 1325.34 MB +256 MB
88
+ 20 1581.34 MB +256 MB
89
+ 21 1837.34 MB +256 MB
90
+ 22 2093.34 MB +256 MB
91
+ ...
92
+ */
93
+
94
+ /* Initialize the buffer, and grow the buffer.
95
+
96
+ max_length: Max length of the buffer, -1 for unlimited length.
97
+
98
+ On success, return allocated size (>=0)
99
+ On failure, return -1
100
+ */
101
+ static inline Py_ssize_t
102
+ _BlocksOutputBuffer_InitAndGrow(_BlocksOutputBuffer *buffer,
103
+ const Py_ssize_t max_length,
104
+ void **next_out)
105
+ {
106
+ PyObject *b;
107
+ Py_ssize_t block_size;
108
+
109
+ // ensure .list was set to NULL
110
+ assert(buffer->list == NULL);
111
+
112
+ // get block size
113
+ if (0 <= max_length && max_length < BUFFER_BLOCK_SIZE[0]) {
114
+ block_size = max_length;
115
+ } else {
116
+ block_size = BUFFER_BLOCK_SIZE[0];
117
+ }
118
+
119
+ // the first block
120
+ b = PyBytes_FromStringAndSize(NULL, block_size);
121
+ if (b == NULL) {
122
+ return -1;
123
+ }
124
+
125
+ // create the list
126
+ buffer->list = PyList_New(1);
127
+ if (buffer->list == NULL) {
128
+ Py_DECREF(b);
129
+ return -1;
130
+ }
131
+ PyList_SET_ITEM(buffer->list, 0, b);
132
+
133
+ // set variables
134
+ buffer->allocated = block_size;
135
+ buffer->max_length = max_length;
136
+
137
+ *next_out = PyBytes_AS_STRING(b);
138
+ return block_size;
139
+ }
140
+
141
+ /* Initialize the buffer, with an initial size.
142
+
143
+ Check block size limit in the outer wrapper function. For example, some libs
144
+ accept UINT32_MAX as the maximum block size, then init_size should <= it.
145
+
146
+ On success, return allocated size (>=0)
147
+ On failure, return -1
148
+ */
149
+ static inline Py_ssize_t
150
+ _BlocksOutputBuffer_InitWithSize(_BlocksOutputBuffer *buffer,
151
+ const Py_ssize_t init_size,
152
+ void **next_out)
153
+ {
154
+ PyObject *b;
155
+
156
+ // ensure .list was set to NULL
157
+ assert(buffer->list == NULL);
158
+
159
+ // the first block
160
+ b = PyBytes_FromStringAndSize(NULL, init_size);
161
+ if (b == NULL) {
162
+ PyErr_SetString(PyExc_MemoryError, unable_allocate_msg);
163
+ return -1;
164
+ }
165
+
166
+ // create the list
167
+ buffer->list = PyList_New(1);
168
+ if (buffer->list == NULL) {
169
+ Py_DECREF(b);
170
+ return -1;
171
+ }
172
+ PyList_SET_ITEM(buffer->list, 0, b);
173
+
174
+ // set variables
175
+ buffer->allocated = init_size;
176
+ buffer->max_length = -1;
177
+
178
+ *next_out = PyBytes_AS_STRING(b);
179
+ return init_size;
180
+ }
181
+
182
+ /* Grow the buffer. The avail_out must be 0, please check it before calling.
183
+
184
+ On success, return allocated size (>=0)
185
+ On failure, return -1
186
+ */
187
+ static inline Py_ssize_t
188
+ _BlocksOutputBuffer_Grow(_BlocksOutputBuffer *buffer,
189
+ void **next_out,
190
+ const Py_ssize_t avail_out)
191
+ {
192
+ PyObject *b;
193
+ const Py_ssize_t list_len = Py_SIZE(buffer->list);
194
+ Py_ssize_t block_size;
195
+
196
+ // ensure no gaps in the data
197
+ if (avail_out != 0) {
198
+ PyErr_SetString(PyExc_SystemError,
199
+ "avail_out is non-zero in _BlocksOutputBuffer_Grow().");
200
+ return -1;
201
+ }
202
+
203
+ // get block size
204
+ if (list_len < (Py_ssize_t) Py_ARRAY_LENGTH(BUFFER_BLOCK_SIZE)) {
205
+ block_size = BUFFER_BLOCK_SIZE[list_len];
206
+ } else {
207
+ block_size = BUFFER_BLOCK_SIZE[Py_ARRAY_LENGTH(BUFFER_BLOCK_SIZE) - 1];
208
+ }
209
+
210
+ // check max_length
211
+ if (buffer->max_length >= 0) {
212
+ // if (rest == 0), should not grow the buffer.
213
+ Py_ssize_t rest = buffer->max_length - buffer->allocated;
214
+ assert(rest > 0);
215
+
216
+ // block_size of the last block
217
+ if (block_size > rest) {
218
+ block_size = rest;
219
+ }
220
+ }
221
+
222
+ // check buffer->allocated overflow
223
+ if (block_size > PY_SSIZE_T_MAX - buffer->allocated) {
224
+ PyErr_SetString(PyExc_MemoryError, unable_allocate_msg);
225
+ return -1;
226
+ }
227
+
228
+ // create the block
229
+ b = PyBytes_FromStringAndSize(NULL, block_size);
230
+ if (b == NULL) {
231
+ PyErr_SetString(PyExc_MemoryError, unable_allocate_msg);
232
+ return -1;
233
+ }
234
+ if (PyList_Append(buffer->list, b) < 0) {
235
+ Py_DECREF(b);
236
+ return -1;
237
+ }
238
+ Py_DECREF(b);
239
+
240
+ // set variables
241
+ buffer->allocated += block_size;
242
+
243
+ *next_out = PyBytes_AS_STRING(b);
244
+ return block_size;
245
+ }
246
+
247
+ /* Return the current outputted data size. */
248
+ static inline Py_ssize_t
249
+ _BlocksOutputBuffer_GetDataSize(_BlocksOutputBuffer *buffer,
250
+ const Py_ssize_t avail_out)
251
+ {
252
+ return buffer->allocated - avail_out;
253
+ }
254
+
255
+ /* Finish the buffer.
256
+
257
+ Return a bytes object on success
258
+ Return NULL on failure
259
+ */
260
+ static inline PyObject *
261
+ _BlocksOutputBuffer_Finish(_BlocksOutputBuffer *buffer,
262
+ const Py_ssize_t avail_out)
263
+ {
264
+ PyObject *result, *block;
265
+ const Py_ssize_t list_len = Py_SIZE(buffer->list);
266
+
267
+ // fast path for single block
268
+ if ((list_len == 1 && avail_out == 0) ||
269
+ (list_len == 2 && Py_SIZE(PyList_GET_ITEM(buffer->list, 1)) == avail_out))
270
+ {
271
+ block = PyList_GET_ITEM(buffer->list, 0);
272
+ Py_INCREF(block);
273
+
274
+ Py_CLEAR(buffer->list);
275
+ return block;
276
+ }
277
+
278
+ // final bytes object
279
+ result = PyBytes_FromStringAndSize(NULL, buffer->allocated - avail_out);
280
+ if (result == NULL) {
281
+ PyErr_SetString(PyExc_MemoryError, unable_allocate_msg);
282
+ return NULL;
283
+ }
284
+
285
+ // memory copy
286
+ if (list_len > 0) {
287
+ char *posi = PyBytes_AS_STRING(result);
288
+
289
+ // blocks except the last one
290
+ Py_ssize_t i = 0;
291
+ for (; i < list_len-1; i++) {
292
+ block = PyList_GET_ITEM(buffer->list, i);
293
+ memcpy(posi, PyBytes_AS_STRING(block), Py_SIZE(block));
294
+ posi += Py_SIZE(block);
295
+ }
296
+ // the last block
297
+ block = PyList_GET_ITEM(buffer->list, i);
298
+ memcpy(posi, PyBytes_AS_STRING(block), Py_SIZE(block) - avail_out);
299
+ } else {
300
+ assert(Py_SIZE(result) == 0);
301
+ }
302
+
303
+ Py_CLEAR(buffer->list);
304
+ return result;
305
+ }
306
+
307
+ /* Clean up the buffer when an error occurred. */
308
+ static inline void
309
+ _BlocksOutputBuffer_OnError(_BlocksOutputBuffer *buffer)
310
+ {
311
+ Py_CLEAR(buffer->list);
312
+ }
313
+
314
+ #ifdef __cplusplus
315
+ }
316
+ #endif
317
+ #endif /* Py_INTERNAL_BLOCKS_OUTPUT_BUFFER_H */
llava_next/include/python3.10/internal/pycore_bytes_methods.h ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_LIMITED_API
2
+ #ifndef Py_BYTES_CTYPE_H
3
+ #define Py_BYTES_CTYPE_H
4
+
5
+ #ifndef Py_BUILD_CORE
6
+ # error "this header requires Py_BUILD_CORE define"
7
+ #endif
8
+
9
+ /*
10
+ * The internal implementation behind PyBytes (bytes) and PyByteArray (bytearray)
11
+ * methods of the given names, they operate on ASCII byte strings.
12
+ */
13
+ extern PyObject* _Py_bytes_isspace(const char *cptr, Py_ssize_t len);
14
+ extern PyObject* _Py_bytes_isalpha(const char *cptr, Py_ssize_t len);
15
+ extern PyObject* _Py_bytes_isalnum(const char *cptr, Py_ssize_t len);
16
+ extern PyObject* _Py_bytes_isascii(const char *cptr, Py_ssize_t len);
17
+ extern PyObject* _Py_bytes_isdigit(const char *cptr, Py_ssize_t len);
18
+ extern PyObject* _Py_bytes_islower(const char *cptr, Py_ssize_t len);
19
+ extern PyObject* _Py_bytes_isupper(const char *cptr, Py_ssize_t len);
20
+ extern PyObject* _Py_bytes_istitle(const char *cptr, Py_ssize_t len);
21
+
22
+ /* These store their len sized answer in the given preallocated *result arg. */
23
+ extern void _Py_bytes_lower(char *result, const char *cptr, Py_ssize_t len);
24
+ extern void _Py_bytes_upper(char *result, const char *cptr, Py_ssize_t len);
25
+ extern void _Py_bytes_title(char *result, const char *s, Py_ssize_t len);
26
+ extern void _Py_bytes_capitalize(char *result, const char *s, Py_ssize_t len);
27
+ extern void _Py_bytes_swapcase(char *result, const char *s, Py_ssize_t len);
28
+
29
+ extern PyObject *_Py_bytes_find(const char *str, Py_ssize_t len, PyObject *args);
30
+ extern PyObject *_Py_bytes_index(const char *str, Py_ssize_t len, PyObject *args);
31
+ extern PyObject *_Py_bytes_rfind(const char *str, Py_ssize_t len, PyObject *args);
32
+ extern PyObject *_Py_bytes_rindex(const char *str, Py_ssize_t len, PyObject *args);
33
+ extern PyObject *_Py_bytes_count(const char *str, Py_ssize_t len, PyObject *args);
34
+ extern int _Py_bytes_contains(const char *str, Py_ssize_t len, PyObject *arg);
35
+ extern PyObject *_Py_bytes_startswith(const char *str, Py_ssize_t len, PyObject *args);
36
+ extern PyObject *_Py_bytes_endswith(const char *str, Py_ssize_t len, PyObject *args);
37
+
38
+ /* The maketrans() static method. */
39
+ extern PyObject* _Py_bytes_maketrans(Py_buffer *frm, Py_buffer *to);
40
+
41
+ /* Shared __doc__ strings. */
42
+ extern const char _Py_isspace__doc__[];
43
+ extern const char _Py_isalpha__doc__[];
44
+ extern const char _Py_isalnum__doc__[];
45
+ extern const char _Py_isascii__doc__[];
46
+ extern const char _Py_isdigit__doc__[];
47
+ extern const char _Py_islower__doc__[];
48
+ extern const char _Py_isupper__doc__[];
49
+ extern const char _Py_istitle__doc__[];
50
+ extern const char _Py_lower__doc__[];
51
+ extern const char _Py_upper__doc__[];
52
+ extern const char _Py_title__doc__[];
53
+ extern const char _Py_capitalize__doc__[];
54
+ extern const char _Py_swapcase__doc__[];
55
+ extern const char _Py_count__doc__[];
56
+ extern const char _Py_find__doc__[];
57
+ extern const char _Py_index__doc__[];
58
+ extern const char _Py_rfind__doc__[];
59
+ extern const char _Py_rindex__doc__[];
60
+ extern const char _Py_startswith__doc__[];
61
+ extern const char _Py_endswith__doc__[];
62
+ extern const char _Py_maketrans__doc__[];
63
+ extern const char _Py_expandtabs__doc__[];
64
+ extern const char _Py_ljust__doc__[];
65
+ extern const char _Py_rjust__doc__[];
66
+ extern const char _Py_center__doc__[];
67
+ extern const char _Py_zfill__doc__[];
68
+
69
+ /* this is needed because some docs are shared from the .o, not static */
70
+ #define PyDoc_STRVAR_shared(name,str) const char name[] = PyDoc_STR(str)
71
+
72
+ #endif /* !Py_BYTES_CTYPE_H */
73
+ #endif /* !Py_LIMITED_API */
llava_next/include/python3.10/internal/pycore_call.h ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_INTERNAL_CALL_H
2
+ #define Py_INTERNAL_CALL_H
3
+ #ifdef __cplusplus
4
+ extern "C" {
5
+ #endif
6
+
7
+ #ifndef Py_BUILD_CORE
8
+ # error "this header requires Py_BUILD_CORE define"
9
+ #endif
10
+
11
+ PyAPI_FUNC(PyObject *) _PyObject_Call_Prepend(
12
+ PyThreadState *tstate,
13
+ PyObject *callable,
14
+ PyObject *obj,
15
+ PyObject *args,
16
+ PyObject *kwargs);
17
+
18
+ PyAPI_FUNC(PyObject *) _PyObject_FastCallDictTstate(
19
+ PyThreadState *tstate,
20
+ PyObject *callable,
21
+ PyObject *const *args,
22
+ size_t nargsf,
23
+ PyObject *kwargs);
24
+
25
+ PyAPI_FUNC(PyObject *) _PyObject_Call(
26
+ PyThreadState *tstate,
27
+ PyObject *callable,
28
+ PyObject *args,
29
+ PyObject *kwargs);
30
+
31
+ static inline PyObject *
32
+ _PyObject_CallNoArgTstate(PyThreadState *tstate, PyObject *func) {
33
+ return _PyObject_VectorcallTstate(tstate, func, NULL, 0, NULL);
34
+ }
35
+
36
+ #ifdef __cplusplus
37
+ }
38
+ #endif
39
+ #endif /* !Py_INTERNAL_CALL_H */
llava_next/include/python3.10/internal/pycore_code.h ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_INTERNAL_CODE_H
2
+ #define Py_INTERNAL_CODE_H
3
+ #ifdef __cplusplus
4
+ extern "C" {
5
+ #endif
6
+
7
+ typedef struct {
8
+ PyObject *ptr; /* Cached pointer (borrowed reference) */
9
+ uint64_t globals_ver; /* ma_version of global dict */
10
+ uint64_t builtins_ver; /* ma_version of builtin dict */
11
+ } _PyOpcache_LoadGlobal;
12
+
13
+ typedef struct {
14
+ PyTypeObject *type;
15
+ Py_ssize_t hint;
16
+ unsigned int tp_version_tag;
17
+ } _PyOpCodeOpt_LoadAttr;
18
+
19
+ struct _PyOpcache {
20
+ union {
21
+ _PyOpcache_LoadGlobal lg;
22
+ _PyOpCodeOpt_LoadAttr la;
23
+ } u;
24
+ char optimized;
25
+ };
26
+
27
+ /* Private API */
28
+ int _PyCode_InitOpcache(PyCodeObject *co);
29
+
30
+
31
+ #ifdef __cplusplus
32
+ }
33
+ #endif
34
+ #endif /* !Py_INTERNAL_CODE_H */
llava_next/include/python3.10/internal/pycore_context.h ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_INTERNAL_CONTEXT_H
2
+ #define Py_INTERNAL_CONTEXT_H
3
+
4
+ #ifndef Py_BUILD_CORE
5
+ # error "this header requires Py_BUILD_CORE define"
6
+ #endif
7
+
8
+ #include "pycore_hamt.h" /* PyHamtObject */
9
+
10
+ struct _pycontextobject {
11
+ PyObject_HEAD
12
+ PyContext *ctx_prev;
13
+ PyHamtObject *ctx_vars;
14
+ PyObject *ctx_weakreflist;
15
+ int ctx_entered;
16
+ };
17
+
18
+
19
+ struct _pycontextvarobject {
20
+ PyObject_HEAD
21
+ PyObject *var_name;
22
+ PyObject *var_default;
23
+ PyObject *var_cached;
24
+ uint64_t var_cached_tsid;
25
+ uint64_t var_cached_tsver;
26
+ Py_hash_t var_hash;
27
+ };
28
+
29
+
30
+ struct _pycontexttokenobject {
31
+ PyObject_HEAD
32
+ PyContext *tok_ctx;
33
+ PyContextVar *tok_var;
34
+ PyObject *tok_oldval;
35
+ int tok_used;
36
+ };
37
+
38
+
39
+ int _PyContext_Init(void);
40
+ void _PyContext_Fini(PyInterpreterState *interp);
41
+
42
+ #endif /* !Py_INTERNAL_CONTEXT_H */
llava_next/include/python3.10/internal/pycore_dtoa.h ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef PY_NO_SHORT_FLOAT_REPR
2
+ #ifdef __cplusplus
3
+ extern "C" {
4
+ #endif
5
+
6
+ #ifndef Py_BUILD_CORE
7
+ # error "this header requires Py_BUILD_CORE define"
8
+ #endif
9
+
10
+ /* These functions are used by modules compiled as C extension like math:
11
+ they must be exported. */
12
+
13
+ PyAPI_FUNC(double) _Py_dg_strtod(const char *str, char **ptr);
14
+ PyAPI_FUNC(char *) _Py_dg_dtoa(double d, int mode, int ndigits,
15
+ int *decpt, int *sign, char **rve);
16
+ PyAPI_FUNC(void) _Py_dg_freedtoa(char *s);
17
+ PyAPI_FUNC(double) _Py_dg_stdnan(int sign);
18
+ PyAPI_FUNC(double) _Py_dg_infinity(int sign);
19
+
20
+ #ifdef __cplusplus
21
+ }
22
+ #endif
23
+ #endif /* !PY_NO_SHORT_FLOAT_REPR */
llava_next/include/python3.10/internal/pycore_fileutils.h ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_INTERNAL_FILEUTILS_H
2
+ #define Py_INTERNAL_FILEUTILS_H
3
+ #ifdef __cplusplus
4
+ extern "C" {
5
+ #endif
6
+
7
+ #ifndef Py_BUILD_CORE
8
+ # error "Py_BUILD_CORE must be defined to include this header"
9
+ #endif
10
+
11
+ #include <locale.h> /* struct lconv */
12
+
13
+ PyAPI_DATA(int) _Py_HasFileSystemDefaultEncodeErrors;
14
+
15
+ PyAPI_FUNC(int) _Py_DecodeUTF8Ex(
16
+ const char *arg,
17
+ Py_ssize_t arglen,
18
+ wchar_t **wstr,
19
+ size_t *wlen,
20
+ const char **reason,
21
+ _Py_error_handler errors);
22
+
23
+ PyAPI_FUNC(int) _Py_EncodeUTF8Ex(
24
+ const wchar_t *text,
25
+ char **str,
26
+ size_t *error_pos,
27
+ const char **reason,
28
+ int raw_malloc,
29
+ _Py_error_handler errors);
30
+
31
+ PyAPI_FUNC(wchar_t*) _Py_DecodeUTF8_surrogateescape(
32
+ const char *arg,
33
+ Py_ssize_t arglen,
34
+ size_t *wlen);
35
+
36
+ PyAPI_FUNC(int) _Py_GetForceASCII(void);
37
+
38
+ /* Reset "force ASCII" mode (if it was initialized).
39
+
40
+ This function should be called when Python changes the LC_CTYPE locale,
41
+ so the "force ASCII" mode can be detected again on the new locale
42
+ encoding. */
43
+ PyAPI_FUNC(void) _Py_ResetForceASCII(void);
44
+
45
+
46
+ PyAPI_FUNC(int) _Py_GetLocaleconvNumeric(
47
+ struct lconv *lc,
48
+ PyObject **decimal_point,
49
+ PyObject **thousands_sep);
50
+
51
+ PyAPI_FUNC(void) _Py_closerange(int first, int last);
52
+
53
+ PyAPI_FUNC(wchar_t*) _Py_GetLocaleEncoding(void);
54
+ PyAPI_FUNC(PyObject*) _Py_GetLocaleEncodingObject(void);
55
+
56
+ #ifdef HAVE_NON_UNICODE_WCHAR_T_REPRESENTATION
57
+ extern int _Py_LocaleUsesNonUnicodeWchar(void);
58
+
59
+ extern wchar_t* _Py_DecodeNonUnicodeWchar(
60
+ const wchar_t* native,
61
+ Py_ssize_t size);
62
+
63
+ extern int _Py_EncodeNonUnicodeWchar_InPlace(
64
+ wchar_t* unicode,
65
+ Py_ssize_t size);
66
+ #endif
67
+
68
+ #ifdef __cplusplus
69
+ }
70
+ #endif
71
+ #endif /* !Py_INTERNAL_FILEUTILS_H */
llava_next/include/python3.10/internal/pycore_list.h ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_INTERNAL_LIST_H
2
+ #define Py_INTERNAL_LIST_H
3
+ #ifdef __cplusplus
4
+ extern "C" {
5
+ #endif
6
+
7
+ #ifndef Py_BUILD_CORE
8
+ # error "this header requires Py_BUILD_CORE define"
9
+ #endif
10
+
11
+ #include "listobject.h" // _PyList_CAST()
12
+
13
+
14
+ #define _PyList_ITEMS(op) (_PyList_CAST(op)->ob_item)
15
+
16
+
17
+ #ifdef __cplusplus
18
+ }
19
+ #endif
20
+ #endif /* !Py_INTERNAL_LIST_H */
llava_next/include/python3.10/internal/pycore_pathconfig.h ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #ifndef Py_INTERNAL_PATHCONFIG_H
2
+ #define Py_INTERNAL_PATHCONFIG_H
3
+ #ifdef __cplusplus
4
+ extern "C" {
5
+ #endif
6
+
7
+ #ifndef Py_BUILD_CORE
8
+ # error "this header requires Py_BUILD_CORE define"
9
+ #endif
10
+
11
+ typedef struct _PyPathConfig {
12
+ /* Full path to the Python program */
13
+ wchar_t *program_full_path;
14
+ wchar_t *prefix;
15
+ wchar_t *exec_prefix;
16
+ /* Set by Py_SetPath(), or computed by _PyConfig_InitPathConfig() */
17
+ wchar_t *module_search_path;
18
+ /* Python program name */
19
+ wchar_t *program_name;
20
+ /* Set by Py_SetPythonHome() or PYTHONHOME environment variable */
21
+ wchar_t *home;
22
+ #ifdef MS_WINDOWS
23
+ /* isolated and site_import are used to set Py_IsolatedFlag and
24
+ Py_NoSiteFlag flags on Windows in read_pth_file(). These fields
25
+ are ignored when their value are equal to -1 (unset). */
26
+ int isolated;
27
+ int site_import;
28
+ /* Set when a venv is detected */
29
+ wchar_t *base_executable;
30
+ #endif
31
+ } _PyPathConfig;
32
+
33
+ #ifdef MS_WINDOWS
34
+ # define _PyPathConfig_INIT \
35
+ {.module_search_path = NULL, \
36
+ .isolated = -1, \
37
+ .site_import = -1}
38
+ #else
39
+ # define _PyPathConfig_INIT \
40
+ {.module_search_path = NULL}
41
+ #endif
42
+ /* Note: _PyPathConfig_INIT sets other fields to 0/NULL */
43
+
44
+ PyAPI_DATA(_PyPathConfig) _Py_path_config;
45
+ #ifdef MS_WINDOWS
46
+ PyAPI_DATA(wchar_t*) _Py_dll_path;
47
+ #endif
48
+
49
+ extern void _PyPathConfig_ClearGlobal(void);
50
+
51
+ extern PyStatus _PyPathConfig_Calculate(
52
+ _PyPathConfig *pathconfig,
53
+ const PyConfig *config);
54
+ extern int _PyPathConfig_ComputeSysPath0(
55
+ const PyWideStringList *argv,
56
+ PyObject **path0);
57
+ extern PyStatus _Py_FindEnvConfigValue(
58
+ FILE *env_file,
59
+ const wchar_t *key,
60
+ wchar_t **value_p);
61
+
62
+ #ifdef MS_WINDOWS
63
+ extern wchar_t* _Py_GetDLLPath(void);
64
+ #endif
65
+
66
+ extern PyStatus _PyConfig_WritePathConfig(const PyConfig *config);
67
+ extern void _Py_DumpPathConfig(PyThreadState *tstate);
68
+ extern PyObject* _PyPathConfig_AsDict(void);
69
+
70
+ #ifdef __cplusplus
71
+ }
72
+ #endif
73
+ #endif /* !Py_INTERNAL_PATHCONFIG_H */