First version of Threefish512-CTR with BLAKE3-MAC & a custom shamirs secret sharing port alongside C bridges with test vectors & Compilation instructions
This commit is contained in:
6
crypto/README.md
Normal file
6
crypto/README.md
Normal file
@@ -0,0 +1,6 @@
|
||||
**Use following command to check if build succeeded (check for stripped symbols)**:
|
||||
Linux:
|
||||
`$ readelf -Ws ~/Documents/shamirs_secret_sharing/dll_dist/shamirs_secret_sharing.cpython-311-aarch64-linux-gnu.so`
|
||||
|
||||
Windows:
|
||||
`$ llvm-nm -g C:\Users\wm\Documents\projekt_payments.org.im\crypto\shamirs_secret_sharing\shamir_bridge.dll`
|
||||
20
crypto/shamirs_secret_sharing/README.md
Normal file
20
crypto/shamirs_secret_sharing/README.md
Normal file
@@ -0,0 +1,20 @@
|
||||
## To compile the python encryption layer
|
||||
### linux:
|
||||
pre:
|
||||
`sudo apt update && sudo apt install python3 python3-pip -y`
|
||||
|
||||
please create a venv, install numpy & nuitka inside using the pip binary it provide; `python3 -m venv env && ./env/bin/pip install nuitka numpy`
|
||||
|
||||
compile cmd: `./env/bin/python3 -m nuitka shamirs_secret_sharing.py --module --output-dir=dll_dist --mingw64 --include-package=numpy`
|
||||
### windows:
|
||||
can globally install nuitka & numpy using `python -m pip install numpy nuitka`
|
||||
|
||||
compile cmd: `python -m nuitka shamirs_secret_sharing.py --module --output-dir=dll_dist --mingw64 --include-package=numpy`
|
||||
|
||||
|
||||
## To compile the bridge
|
||||
### windows:
|
||||
`$ gcc -shared py_bridge.c -o shamir_bridge.dll -Iinclude -Llibs -lpython312`
|
||||
|
||||
### linux:
|
||||
`$ gcc -shared -fPIC py_bridge-lin.c -o shamir_bridge.so $(python3.11-config --includes --ldflags)`
|
||||
@@ -0,0 +1,846 @@
|
||||
# This file was generated by Nuitka
|
||||
|
||||
# Stubs included by default
|
||||
from __future__ import annotations
|
||||
from typing import Any
|
||||
from typing_extensions import Self
|
||||
import asyncio
|
||||
import ctypes
|
||||
import numpy
|
||||
import platform
|
||||
import secrets
|
||||
|
||||
__name__ = 'Shamir´s Secret Sharing by serpent192 / Privy Services (port)'
|
||||
malloc = libc.malloc
|
||||
_loop = None
|
||||
def as_run(coro: Any) -> Any:
|
||||
...
|
||||
|
||||
class SharmirsShares:
|
||||
def __init__(self: Self) -> None: ...
|
||||
def add(self: Self, a: int, b: int) -> int: ...
|
||||
def multiply(self: Self, a: int, b: int) -> int: ...
|
||||
def div(self: Self, a: int, b: int) -> int: ...
|
||||
def interp_polynomial(self: Self, xsamp: np.ndarray, ysamp: np.ndarray, x: int) -> int: ...
|
||||
def evaluate(self: Self, coefficients: np.ndarray, x: int, degree: int) -> int: ...
|
||||
def newCoeff(self: Self, interception: int, degree: int) -> np.ndarray: ...
|
||||
def newCoords(self: Self) -> np.ndarray: ...
|
||||
@staticmethod
|
||||
def c_string(py_str: str) -> Any: ...
|
||||
@staticmethod
|
||||
def combine_wrapper(c_array: Any, length: Any) -> Any: ...
|
||||
@staticmethod
|
||||
def split_wrapper(c_array: Any, length: Any, shares_num: Any, threshold: Any) -> Any: ...
|
||||
|
||||
exports = {'combine_wrapper': SharmirsShares.combine_wrapper, 'split_wrapper': SharmirsShares.split_wrapper}
|
||||
|
||||
__name__ = ...
|
||||
|
||||
|
||||
|
||||
# Modules used internally, to allow implicit dependencies to be seen:
|
||||
import os
|
||||
import ntpath
|
||||
import sys
|
||||
import warnings
|
||||
import numpy._core.False_
|
||||
import numpy._core.ScalarType
|
||||
import numpy._core.True_
|
||||
import numpy._core.abs
|
||||
import numpy._core.absolute
|
||||
import numpy._core.acos
|
||||
import numpy._core.acosh
|
||||
import numpy._core.add
|
||||
import numpy._core.all
|
||||
import numpy._core.allclose
|
||||
import numpy._core.amax
|
||||
import numpy._core.amin
|
||||
import numpy._core.any
|
||||
import numpy._core.arange
|
||||
import numpy._core.arccos
|
||||
import numpy._core.arccosh
|
||||
import numpy._core.arcsin
|
||||
import numpy._core.arcsinh
|
||||
import numpy._core.arctan
|
||||
import numpy._core.arctan2
|
||||
import numpy._core.arctanh
|
||||
import numpy._core.argmax
|
||||
import numpy._core.argmin
|
||||
import numpy._core.argpartition
|
||||
import numpy._core.argsort
|
||||
import numpy._core.argwhere
|
||||
import numpy._core.around
|
||||
import numpy._core.array
|
||||
import numpy._core.array2string
|
||||
import numpy._core.array_equal
|
||||
import numpy._core.array_equiv
|
||||
import numpy._core.array_repr
|
||||
import numpy._core.array_str
|
||||
import numpy._core.asanyarray
|
||||
import numpy._core.asarray
|
||||
import numpy._core.ascontiguousarray
|
||||
import numpy._core.asfortranarray
|
||||
import numpy._core.asin
|
||||
import numpy._core.asinh
|
||||
import numpy._core.astype
|
||||
import numpy._core.atan
|
||||
import numpy._core.atan2
|
||||
import numpy._core.atanh
|
||||
import numpy._core.atleast_1d
|
||||
import numpy._core.atleast_2d
|
||||
import numpy._core.atleast_3d
|
||||
import numpy._core.base_repr
|
||||
import numpy._core.binary_repr
|
||||
import numpy._core.bitwise_and
|
||||
import numpy._core.bitwise_count
|
||||
import numpy._core.bitwise_invert
|
||||
import numpy._core.bitwise_left_shift
|
||||
import numpy._core.bitwise_not
|
||||
import numpy._core.bitwise_or
|
||||
import numpy._core.bitwise_right_shift
|
||||
import numpy._core.bitwise_xor
|
||||
import numpy._core.block
|
||||
import numpy._core.bool
|
||||
import numpy._core.bool_
|
||||
import numpy._core.broadcast
|
||||
import numpy._core.busday_count
|
||||
import numpy._core.busday_offset
|
||||
import numpy._core.busdaycalendar
|
||||
import numpy._core.byte
|
||||
import numpy._core.bytes_
|
||||
import numpy._core.can_cast
|
||||
import numpy._core.cbrt
|
||||
import numpy._core.cdouble
|
||||
import numpy._core.ceil
|
||||
import numpy._core.character
|
||||
import numpy._core.choose
|
||||
import numpy._core.clip
|
||||
import numpy._core.clongdouble
|
||||
import numpy._core.complex64
|
||||
import numpy._core.complex128
|
||||
import numpy._core.complexfloating
|
||||
import numpy._core.compress
|
||||
import numpy._core.concat
|
||||
import numpy._core.concatenate
|
||||
import numpy._core.conj
|
||||
import numpy._core.conjugate
|
||||
import numpy._core.convolve
|
||||
import numpy._core.copysign
|
||||
import numpy._core.copyto
|
||||
import numpy._core.correlate
|
||||
import numpy._core.cos
|
||||
import numpy._core.cosh
|
||||
import numpy._core.count_nonzero
|
||||
import numpy._core.cross
|
||||
import numpy._core.csingle
|
||||
import numpy._core.cumprod
|
||||
import numpy._core.cumsum
|
||||
import numpy._core.cumulative_prod
|
||||
import numpy._core.cumulative_sum
|
||||
import numpy._core.datetime64
|
||||
import numpy._core.datetime_as_string
|
||||
import numpy._core.datetime_data
|
||||
import numpy._core.deg2rad
|
||||
import numpy._core.degrees
|
||||
import numpy._core.diagonal
|
||||
import numpy._core.divide
|
||||
import numpy._core.divmod
|
||||
import numpy._core.dot
|
||||
import numpy._core.double
|
||||
import numpy._core.dtype
|
||||
import numpy._core.e
|
||||
import numpy._core.einsum
|
||||
import numpy._core.einsum_path
|
||||
import numpy._core.empty
|
||||
import numpy._core.empty_like
|
||||
import numpy._core.equal
|
||||
import numpy._core.errstate
|
||||
import numpy._core.euler_gamma
|
||||
import numpy._core.exp
|
||||
import numpy._core.exp2
|
||||
import numpy._core.expm1
|
||||
import numpy._core.fabs
|
||||
import numpy._core.finfo
|
||||
import numpy._core.flatiter
|
||||
import numpy._core.flatnonzero
|
||||
import numpy._core.flexible
|
||||
import numpy._core.float16
|
||||
import numpy._core.float32
|
||||
import numpy._core.float64
|
||||
import numpy._core.float_power
|
||||
import numpy._core.floating
|
||||
import numpy._core.floor
|
||||
import numpy._core.floor_divide
|
||||
import numpy._core.fmax
|
||||
import numpy._core.fmin
|
||||
import numpy._core.fmod
|
||||
import numpy._core.format_float_positional
|
||||
import numpy._core.format_float_scientific
|
||||
import numpy._core.frexp
|
||||
import numpy._core.from_dlpack
|
||||
import numpy._core.frombuffer
|
||||
import numpy._core.fromfile
|
||||
import numpy._core.fromfunction
|
||||
import numpy._core.fromiter
|
||||
import numpy._core.frompyfunc
|
||||
import numpy._core.fromstring
|
||||
import numpy._core.full
|
||||
import numpy._core.full_like
|
||||
import numpy._core.gcd
|
||||
import numpy._core.generic
|
||||
import numpy._core.geomspace
|
||||
import numpy._core.get_printoptions
|
||||
import numpy._core.getbufsize
|
||||
import numpy._core.geterr
|
||||
import numpy._core.geterrcall
|
||||
import numpy._core.greater
|
||||
import numpy._core.greater_equal
|
||||
import numpy._core.half
|
||||
import numpy._core.heaviside
|
||||
import numpy._core.hstack
|
||||
import numpy._core.hypot
|
||||
import numpy._core.identity
|
||||
import numpy._core.iinfo
|
||||
import numpy._core.indices
|
||||
import numpy._core.inexact
|
||||
import numpy._core.inf
|
||||
import numpy._core.inner
|
||||
import numpy._core.int8
|
||||
import numpy._core.int16
|
||||
import numpy._core.int32
|
||||
import numpy._core.int64
|
||||
import numpy._core.int_
|
||||
import numpy._core.intc
|
||||
import numpy._core.integer
|
||||
import numpy._core.intp
|
||||
import numpy._core.invert
|
||||
import numpy._core.is_busday
|
||||
import numpy._core.isclose
|
||||
import numpy._core.isdtype
|
||||
import numpy._core.isfinite
|
||||
import numpy._core.isfortran
|
||||
import numpy._core.isinf
|
||||
import numpy._core.isnan
|
||||
import numpy._core.isnat
|
||||
import numpy._core.isscalar
|
||||
import numpy._core.issubdtype
|
||||
import numpy._core.lcm
|
||||
import numpy._core.ldexp
|
||||
import numpy._core.left_shift
|
||||
import numpy._core.less
|
||||
import numpy._core.less_equal
|
||||
import numpy._core.lexsort
|
||||
import numpy._core.linspace
|
||||
import numpy._core.little_endian
|
||||
import numpy._core.log
|
||||
import numpy._core.log1p
|
||||
import numpy._core.log2
|
||||
import numpy._core.log10
|
||||
import numpy._core.logaddexp
|
||||
import numpy._core.logaddexp2
|
||||
import numpy._core.logical_and
|
||||
import numpy._core.logical_not
|
||||
import numpy._core.logical_or
|
||||
import numpy._core.logical_xor
|
||||
import numpy._core.logspace
|
||||
import numpy._core.long
|
||||
import numpy._core.longdouble
|
||||
import numpy._core.longlong
|
||||
import numpy._core.matmul
|
||||
import numpy._core.matrix_transpose
|
||||
import numpy._core.matvec
|
||||
import numpy._core.max
|
||||
import numpy._core.maximum
|
||||
import numpy._core.may_share_memory
|
||||
import numpy._core.mean
|
||||
import numpy._core.min
|
||||
import numpy._core.min_scalar_type
|
||||
import numpy._core.minimum
|
||||
import numpy._core.mod
|
||||
import numpy._core.modf
|
||||
import numpy._core.moveaxis
|
||||
import numpy._core.multiply
|
||||
import numpy._core.nan
|
||||
import numpy._core.ndarray
|
||||
import numpy._core.ndim
|
||||
import numpy._core.nditer
|
||||
import numpy._core.negative
|
||||
import numpy._core.nested_iters
|
||||
import numpy._core.newaxis
|
||||
import numpy._core.nextafter
|
||||
import numpy._core.nonzero
|
||||
import numpy._core.not_equal
|
||||
import numpy._core.number
|
||||
import numpy._core.object_
|
||||
import numpy._core.ones
|
||||
import numpy._core.ones_like
|
||||
import numpy._core.outer
|
||||
import numpy._core.partition
|
||||
import numpy._core.permute_dims
|
||||
import numpy._core.pi
|
||||
import numpy._core.positive
|
||||
import numpy._core.pow
|
||||
import numpy._core.power
|
||||
import numpy._core.prod
|
||||
import numpy._core.promote_types
|
||||
import numpy._core.ptp
|
||||
import numpy._core.put
|
||||
import numpy._core.putmask
|
||||
import numpy._core.rad2deg
|
||||
import numpy._core.radians
|
||||
import numpy._core.ravel
|
||||
import numpy._core.recarray
|
||||
import numpy._core.reciprocal
|
||||
import numpy._core.record
|
||||
import numpy._core.remainder
|
||||
import numpy._core.repeat
|
||||
import numpy._core.require
|
||||
import numpy._core.reshape
|
||||
import numpy._core.resize
|
||||
import numpy._core.result_type
|
||||
import numpy._core.right_shift
|
||||
import numpy._core.rint
|
||||
import numpy._core.roll
|
||||
import numpy._core.rollaxis
|
||||
import numpy._core.round
|
||||
import numpy._core.sctypeDict
|
||||
import numpy._core.searchsorted
|
||||
import numpy._core.set_printoptions
|
||||
import numpy._core.setbufsize
|
||||
import numpy._core.seterr
|
||||
import numpy._core.seterrcall
|
||||
import numpy._core.shape
|
||||
import numpy._core.shares_memory
|
||||
import numpy._core.short
|
||||
import numpy._core.sign
|
||||
import numpy._core.signbit
|
||||
import numpy._core.signedinteger
|
||||
import numpy._core.sin
|
||||
import numpy._core.single
|
||||
import numpy._core.sinh
|
||||
import numpy._core.size
|
||||
import numpy._core.sort
|
||||
import numpy._core.spacing
|
||||
import numpy._core.sqrt
|
||||
import numpy._core.square
|
||||
import numpy._core.squeeze
|
||||
import numpy._core.stack
|
||||
import numpy._core.std
|
||||
import numpy._core.str_
|
||||
import numpy._core.subtract
|
||||
import numpy._core.sum
|
||||
import numpy._core.swapaxes
|
||||
import numpy._core.take
|
||||
import numpy._core.tan
|
||||
import numpy._core.tanh
|
||||
import numpy._core.tensordot
|
||||
import numpy._core.timedelta64
|
||||
import numpy._core.trace
|
||||
import numpy._core.transpose
|
||||
import numpy._core.true_divide
|
||||
import numpy._core.trunc
|
||||
import numpy._core.typecodes
|
||||
import numpy._core.ubyte
|
||||
import numpy._core.ufunc
|
||||
import numpy._core.uint
|
||||
import numpy._core.uint8
|
||||
import numpy._core.uint16
|
||||
import numpy._core.uint32
|
||||
import numpy._core.uint64
|
||||
import numpy._core.uintc
|
||||
import numpy._core.uintp
|
||||
import numpy._core.ulong
|
||||
import numpy._core.ulonglong
|
||||
import numpy._core.unsignedinteger
|
||||
import numpy._core.unstack
|
||||
import numpy._core.ushort
|
||||
import numpy._core.var
|
||||
import numpy._core.vdot
|
||||
import numpy._core.vecdot
|
||||
import numpy._core.vecmat
|
||||
import numpy._core.void
|
||||
import numpy._core.vstack
|
||||
import numpy._core.where
|
||||
import numpy._core.zeros
|
||||
import numpy._core.zeros_like
|
||||
import numpy.matrixlib.asmatrix
|
||||
import numpy.matrixlib.bmat
|
||||
import numpy.matrixlib.matrix
|
||||
import numpy.distutils
|
||||
import pathlib
|
||||
import enum
|
||||
import numpy._core._multiarray_umath
|
||||
import yaml
|
||||
import json
|
||||
import argparse
|
||||
import copyreg
|
||||
import textwrap
|
||||
import ctypes
|
||||
import _ctypes
|
||||
import ast
|
||||
import math
|
||||
import re
|
||||
import numpy._NoValue
|
||||
import inspect
|
||||
import pickle
|
||||
import contextlib
|
||||
import functools
|
||||
import numpy._utils.set_module
|
||||
import numbers
|
||||
import _thread
|
||||
import _dummy_thread
|
||||
import operator
|
||||
import code_generators
|
||||
import code_generators.genapi
|
||||
import code_generators.numpy_api
|
||||
import numpy.strings.multiply
|
||||
import numpy.strings.partition
|
||||
import numpy.strings.rpartition
|
||||
import itertools
|
||||
import types
|
||||
import _frozen_importlib_external
|
||||
import mmap
|
||||
import builtins
|
||||
import numpy.eye
|
||||
import collections
|
||||
import contextvars
|
||||
import collections.Counter
|
||||
import numpy.add
|
||||
import numpy.equal
|
||||
import numpy.greater
|
||||
import numpy.greater_equal
|
||||
import numpy.less
|
||||
import numpy.less_equal
|
||||
import numpy.multiply
|
||||
import numpy.not_equal
|
||||
import locale
|
||||
import pytest
|
||||
import distutils
|
||||
import distutils.core
|
||||
import Cython
|
||||
import Cython.Build
|
||||
import setuptools
|
||||
import setuptools.extension
|
||||
import setuptools.Extension
|
||||
import setuptools.setup
|
||||
import numpy.testing.assert_
|
||||
import numpy._core._rational_tests
|
||||
import numpy.testing.HAS_REFCOUNT
|
||||
import numpy.testing.assert_array_equal
|
||||
import numpy.testing.assert_equal
|
||||
import numpy.testing.assert_raises
|
||||
import threading
|
||||
import numpy._core._multiarray_tests
|
||||
import numpy.testing.IS_WASM
|
||||
import numpy.testing.IS_64BIT
|
||||
import numpy.testing.IS_PYPY
|
||||
import sysconfig
|
||||
import numpy.testing.IS_EDITABLE
|
||||
import numpy.testing.extbuild
|
||||
import array_interface_testing
|
||||
import typing
|
||||
import gc
|
||||
import hypothesis
|
||||
import hypothesis.extra
|
||||
import numpy.testing.assert_raises_regex
|
||||
import random
|
||||
import numpy._core._umath_tests
|
||||
import platform
|
||||
import subprocess
|
||||
import tempfile
|
||||
import datetime
|
||||
import cython
|
||||
import Cython.Compiler
|
||||
import Cython.Compiler.Version
|
||||
import checks
|
||||
import zoneinfo
|
||||
import zoneinfo.ZoneInfo
|
||||
import zoneinfo.ZoneInfoNotFoundError
|
||||
import numpy._core._struct_ufunc_tests
|
||||
import numpy.row_stack
|
||||
import numpy.testing.IS_PYSTON
|
||||
import numpy.testing.assert_allclose
|
||||
import numpy.testing.assert_almost_equal
|
||||
import traceback
|
||||
import numpy.exp2
|
||||
import numpy.log10
|
||||
import numpy.arange
|
||||
import numpy.array
|
||||
import numpy.dtype
|
||||
import numpy.errstate
|
||||
import numpy.geomspace
|
||||
import numpy.isnan
|
||||
import numpy.linspace
|
||||
import numpy.logspace
|
||||
import numpy.ndarray
|
||||
import numpy.nextafter
|
||||
import numpy.sqrt
|
||||
import numpy.stack
|
||||
import numpy._core.sctypes
|
||||
import numpy.double
|
||||
import numpy.half
|
||||
import numpy.longdouble
|
||||
import numpy.single
|
||||
import numpy.float16
|
||||
import numpy.float32
|
||||
import numpy.float64
|
||||
import numpy.uint16
|
||||
import numpy.testing.NOGIL_BUILD
|
||||
import limited_api1
|
||||
import limited_api2
|
||||
import limited_api_latest
|
||||
import numpy.testing.IS_MUSL
|
||||
import numpy.testing.temppath
|
||||
import asyncio
|
||||
import mem_policy
|
||||
import numpy.allclose
|
||||
import numpy.asarray
|
||||
import numpy.average
|
||||
import numpy.isscalar
|
||||
import numpy.memmap
|
||||
import numpy.prod
|
||||
import numpy.subtract
|
||||
import numpy.sum
|
||||
import numpy.testing.break_cycles
|
||||
import collections.abc
|
||||
import importlib
|
||||
import io
|
||||
import weakref
|
||||
import decimal
|
||||
import numpy.testing.BLAS_SUPPORTS_FPE
|
||||
import numpy.testing.assert_array_almost_equal
|
||||
import numpy.testing.assert_array_compare
|
||||
import numpy.testing.assert_array_less
|
||||
import numpy.testing.check_support_sve
|
||||
import numpy.testing.runstring
|
||||
import fractions
|
||||
import _testbuffer
|
||||
import time
|
||||
import multiprocessing
|
||||
import multiprocessing.shared_memory
|
||||
import concurrent
|
||||
import concurrent.futures
|
||||
import concurrent.futures.ProcessPoolExecutor
|
||||
import concurrent.futures.ThreadPoolExecutor
|
||||
import numpy.all
|
||||
import numpy.nditer
|
||||
import numpy.random.rand
|
||||
import numpy.random.randint
|
||||
import numpy.random.randn
|
||||
import numpy.testing.assert_array_max_ulp
|
||||
import unittest
|
||||
import unittest.mock
|
||||
import copy
|
||||
import numpy._utils.asbytes
|
||||
import numpy._utils.asunicode
|
||||
import numpy.testing._assert_valid_refcount
|
||||
import hashlib
|
||||
import hypothesis.strategies
|
||||
import numpy.testing._gen_alignment_data
|
||||
import numpy._core._simd
|
||||
import string
|
||||
import numpy._core._operand_flag_tests
|
||||
import numpy.linalg._umath_linalg
|
||||
import numpy.testing.assert_no_warnings
|
||||
import fnmatch
|
||||
import collections.namedtuple
|
||||
import numpy.testing.assert_array_almost_equal_nulp
|
||||
import cmath
|
||||
import numpy._distributor_init_local
|
||||
import PyInstaller
|
||||
import PyInstaller.compat
|
||||
import PyInstaller.utils
|
||||
import PyInstaller.utils.hooks
|
||||
import numpy._typing._96Bit
|
||||
import numpy._typing._128Bit
|
||||
import numpy.ufunc
|
||||
import scipy_doctest
|
||||
import scipy_doctest.conftest
|
||||
import pytest_run_parallel
|
||||
import doctest
|
||||
import numpy.intp
|
||||
import abc
|
||||
import shutil
|
||||
import numpy.distutils.core
|
||||
import numpy.distutils.misc_util
|
||||
import numpy.distutils.system_info
|
||||
import errno
|
||||
import pprint
|
||||
import codecs
|
||||
import fileinput
|
||||
import charset_normalizer
|
||||
import numpy_distutils
|
||||
import numpy_distutils.command
|
||||
import numpy_distutils.command.build_flib
|
||||
import numpy.distutils.fcompiler
|
||||
import numpy_distutils.fcompiler
|
||||
import numpy.distutils.cpuinfo
|
||||
import numpy_distutils.command.cpuinfo
|
||||
import numpy_distutils.cpuinfo
|
||||
import numpy.f2py._backends.f2py_build_generator
|
||||
import shlex
|
||||
import atexit
|
||||
import glob
|
||||
import numpy.fft._pocketfft_umath
|
||||
import numpy.pi
|
||||
import queue
|
||||
import numpy.random.random
|
||||
import bz2
|
||||
import gzip
|
||||
import lzma
|
||||
import urllib
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
import urllib.error
|
||||
import struct
|
||||
import tokenize
|
||||
import zipfile
|
||||
import numpy.ma.MaskedArray
|
||||
import numpy.ma.make_mask_descr
|
||||
import numpy.linalg.eigvals
|
||||
import numpy.linalg.inv
|
||||
import numpy.linalg.lstsq
|
||||
import numpy.histogramdd
|
||||
import threadpoolctl
|
||||
import numpy.lib.NumpyVersion
|
||||
import numpy.ediff1d
|
||||
import numpy.intersect1d
|
||||
import numpy.isin
|
||||
import numpy.setdiff1d
|
||||
import numpy.setxor1d
|
||||
import numpy.union1d
|
||||
import numpy.unique
|
||||
import numpy.lib.Arrayterator
|
||||
import hypothesis.extra.numpy
|
||||
import numpy.angle
|
||||
import numpy.bartlett
|
||||
import numpy.blackman
|
||||
import numpy.corrcoef
|
||||
import numpy.cov
|
||||
import numpy.delete
|
||||
import numpy.diff
|
||||
import numpy.digitize
|
||||
import numpy.extract
|
||||
import numpy.flipud
|
||||
import numpy.gradient
|
||||
import numpy.hamming
|
||||
import numpy.hanning
|
||||
import numpy.i0
|
||||
import numpy.insert
|
||||
import numpy.interp
|
||||
import numpy.kaiser
|
||||
import numpy.meshgrid
|
||||
import numpy.piecewise
|
||||
import numpy.place
|
||||
import numpy.rot90
|
||||
import numpy.select
|
||||
import numpy.sinc
|
||||
import numpy.trapezoid
|
||||
import numpy.trim_zeros
|
||||
import numpy.unwrap
|
||||
import numpy.vectorize
|
||||
import numpy.histogram
|
||||
import numpy.histogram_bin_edges
|
||||
import multiprocessing.Value
|
||||
import multiprocessing.get_context
|
||||
import numpy.testing.assert_no_gc_cycles
|
||||
import numpy.testing.tempdir
|
||||
import numpy.apply_along_axis
|
||||
import numpy.apply_over_axes
|
||||
import numpy.array_split
|
||||
import numpy.column_stack
|
||||
import numpy.dsplit
|
||||
import numpy.dstack
|
||||
import numpy.expand_dims
|
||||
import numpy.hsplit
|
||||
import numpy.kron
|
||||
import numpy.put_along_axis
|
||||
import numpy.split
|
||||
import numpy.take_along_axis
|
||||
import numpy.tile
|
||||
import numpy.vsplit
|
||||
import numpy.diag
|
||||
import numpy.fliplr
|
||||
import numpy.histogram2d
|
||||
import numpy.mask_indices
|
||||
import numpy.ones
|
||||
import numpy.tri
|
||||
import numpy.tril_indices
|
||||
import numpy.tril_indices_from
|
||||
import numpy.triu_indices
|
||||
import numpy.triu_indices_from
|
||||
import numpy.vander
|
||||
import numpy.zeros
|
||||
import numpy.common_type
|
||||
import numpy.iscomplex
|
||||
import numpy.iscomplexobj
|
||||
import numpy.isneginf
|
||||
import numpy.isposinf
|
||||
import numpy.isreal
|
||||
import numpy.isrealobj
|
||||
import numpy.mintypecode
|
||||
import numpy.nan_to_num
|
||||
import numpy.real_if_close
|
||||
import numpy.fix
|
||||
import numpy._typing.NDArray
|
||||
import numpy.atleast_2d
|
||||
import numpy.cdouble
|
||||
import numpy.csingle
|
||||
import numpy.dot
|
||||
import numpy.identity
|
||||
import numpy.inf
|
||||
import numpy.matmul
|
||||
import numpy.linalg.LinAlgError
|
||||
import numpy.linalg.matrix_power
|
||||
import numpy.linalg.matrix_rank
|
||||
import numpy.linalg.multi_dot
|
||||
import numpy.linalg.norm
|
||||
import numpy.testing.HAS_LAPACK64
|
||||
import numpy.linalg.lapack_lite
|
||||
import resource
|
||||
import numpy.transpose
|
||||
import numpy.amax
|
||||
import numpy.amin
|
||||
import numpy.bool_
|
||||
import numpy.finfo
|
||||
import numpy.iinfo
|
||||
import numpy.ma.masked_array
|
||||
import numpy.ma.masked
|
||||
import numpy.ma.nomask
|
||||
import numpy.ma.MaskType
|
||||
import numpy.ma.absolute
|
||||
import numpy.ma.add
|
||||
import numpy.ma.all
|
||||
import numpy.ma.allclose
|
||||
import numpy.ma.allequal
|
||||
import numpy.ma.alltrue
|
||||
import numpy.ma.arange
|
||||
import numpy.ma.arccos
|
||||
import numpy.ma.arcsin
|
||||
import numpy.ma.arctan
|
||||
import numpy.ma.arctan2
|
||||
import numpy.ma.array
|
||||
import numpy.ma.average
|
||||
import numpy.ma.choose
|
||||
import numpy.ma.concatenate
|
||||
import numpy.ma.conjugate
|
||||
import numpy.ma.cos
|
||||
import numpy.ma.cosh
|
||||
import numpy.ma.count
|
||||
import numpy.ma.divide
|
||||
import numpy.ma.equal
|
||||
import numpy.ma.exp
|
||||
import numpy.ma.filled
|
||||
import numpy.ma.getmask
|
||||
import numpy.ma.greater
|
||||
import numpy.ma.greater_equal
|
||||
import numpy.ma.inner
|
||||
import numpy.ma.isMaskedArray
|
||||
import numpy.ma.less
|
||||
import numpy.ma.less_equal
|
||||
import numpy.ma.log
|
||||
import numpy.ma.log10
|
||||
import numpy.ma.make_mask
|
||||
import numpy.ma.masked_equal
|
||||
import numpy.ma.masked_greater
|
||||
import numpy.ma.masked_greater_equal
|
||||
import numpy.ma.masked_inside
|
||||
import numpy.ma.masked_less
|
||||
import numpy.ma.masked_less_equal
|
||||
import numpy.ma.masked_not_equal
|
||||
import numpy.ma.masked_outside
|
||||
import numpy.ma.masked_print_option
|
||||
import numpy.ma.masked_values
|
||||
import numpy.ma.masked_where
|
||||
import numpy.ma.maximum
|
||||
import numpy.ma.minimum
|
||||
import numpy.ma.multiply
|
||||
import numpy.ma.nonzero
|
||||
import numpy.ma.not_equal
|
||||
import numpy.ma.ones
|
||||
import numpy.ma.outer
|
||||
import numpy.ma.product
|
||||
import numpy.ma.put
|
||||
import numpy.ma.ravel
|
||||
import numpy.ma.repeat
|
||||
import numpy.ma.resize
|
||||
import numpy.ma.shape
|
||||
import numpy.ma.sin
|
||||
import numpy.ma.sinh
|
||||
import numpy.ma.sometrue
|
||||
import numpy.ma.sort
|
||||
import numpy.ma.sqrt
|
||||
import numpy.ma.subtract
|
||||
import numpy.ma.sum
|
||||
import numpy.ma.take
|
||||
import numpy.ma.tan
|
||||
import numpy.ma.tanh
|
||||
import numpy.ma.transpose
|
||||
import numpy.ma.where
|
||||
import numpy.ma.zeros
|
||||
import numpy.testing.build_err_msg
|
||||
import numpy.linalg.pinv
|
||||
import numpy.asmatrix
|
||||
import numpy.bmat
|
||||
import numpy.matrix
|
||||
import numpy.polynomial.Chebyshev
|
||||
import numpy.polynomial.Hermite
|
||||
import numpy.polynomial.HermiteE
|
||||
import numpy.polynomial.Laguerre
|
||||
import numpy.polynomial.Legendre
|
||||
import numpy.polynomial.Polynomial
|
||||
import numpy.random._bounded_integers
|
||||
import numpy.random._common
|
||||
import numpy.random._generator
|
||||
import numpy.random._mt19937
|
||||
import numpy.random._pcg64
|
||||
import numpy.random._philox
|
||||
import numpy.random._sfc64
|
||||
import numpy.random.bit_generator
|
||||
import numpy.random.mtrand
|
||||
import cffi
|
||||
import timeit
|
||||
import numba
|
||||
import numpy.random.PCG64
|
||||
import cffi.FFI
|
||||
import numpy.random.MT19937
|
||||
import numpy.random.PCG64DXSM
|
||||
import numpy.random.SFC64
|
||||
import numpy.random.Generator
|
||||
import numpy.random.Philox
|
||||
import numpy.random.RandomState
|
||||
import numpy.random.SeedSequence
|
||||
import numpy.random.default_rng
|
||||
import importlib.util
|
||||
import dataclasses
|
||||
import importlib.metadata
|
||||
import unittest.case
|
||||
import numpy.isfinite
|
||||
import win32pdh
|
||||
import numpy.imag
|
||||
import numpy.real
|
||||
import difflib
|
||||
import psutil
|
||||
import numpy.testing.assert_approx_equal
|
||||
import numpy.testing.assert_string_equal
|
||||
import numpy.testing.assert_warns
|
||||
import numpy.testing.clear_and_catch_warnings
|
||||
import numpy.testing.suppress_warnings
|
||||
import numpy.testing.IS_INSTALLED
|
||||
import numpy.testing.NUMPY_ROOT
|
||||
import numpy.ctypeslib.as_array
|
||||
import numpy.ctypeslib.load_library
|
||||
import numpy.ctypeslib.ndpointer
|
||||
import pkgutil
|
||||
import numpy._typing.ArrayLike
|
||||
import numpy._typing.DTypeLike
|
||||
import numpy._typing.NBitBase
|
||||
import mypy
|
||||
import mypy.types
|
||||
import mypy.build
|
||||
import mypy.nodes
|
||||
import mypy.plugin
|
||||
import __future__
|
||||
import numpy._typing._Shape
|
||||
import collections.defaultdict
|
||||
import secrets
|
||||
109
crypto/shamirs_secret_sharing/include/Python.h
Normal file
109
crypto/shamirs_secret_sharing/include/Python.h
Normal file
@@ -0,0 +1,109 @@
|
||||
// Entry point of the Python C API.
|
||||
// C extensions should only #include <Python.h>, and not include directly
|
||||
// the other Python header files included by <Python.h>.
|
||||
|
||||
#ifndef Py_PYTHON_H
|
||||
#define Py_PYTHON_H
|
||||
|
||||
// Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" {
|
||||
|
||||
// Include Python header files
|
||||
#include "patchlevel.h"
|
||||
#include "pyconfig.h"
|
||||
#include "pymacconfig.h"
|
||||
|
||||
#if defined(__sgi) && !defined(_SGI_MP_SOURCE)
|
||||
# define _SGI_MP_SOURCE
|
||||
#endif
|
||||
|
||||
// stdlib.h, stdio.h, errno.h and string.h headers are not used by Python
|
||||
// headers, but kept for backward compatibility. They are excluded from the
|
||||
// limited C API of Python 3.11.
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
|
||||
# include <stdlib.h>
|
||||
# include <stdio.h> // FILE*
|
||||
# include <errno.h> // errno
|
||||
# include <string.h> // memcpy()
|
||||
#endif
|
||||
#ifndef MS_WINDOWS
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDDEF_H
|
||||
# include <stddef.h> // size_t
|
||||
#endif
|
||||
|
||||
#include <assert.h> // assert()
|
||||
#include <wchar.h> // wchar_t
|
||||
|
||||
#include "pyport.h"
|
||||
#include "pymacro.h"
|
||||
#include "pymath.h"
|
||||
#include "pymem.h"
|
||||
#include "pytypedefs.h"
|
||||
#include "pybuffer.h"
|
||||
#include "object.h"
|
||||
#include "objimpl.h"
|
||||
#include "typeslots.h"
|
||||
#include "pyhash.h"
|
||||
#include "cpython/pydebug.h"
|
||||
#include "bytearrayobject.h"
|
||||
#include "bytesobject.h"
|
||||
#include "unicodeobject.h"
|
||||
#include "cpython/initconfig.h"
|
||||
#include "pystate.h"
|
||||
#include "pyerrors.h"
|
||||
#include "longobject.h"
|
||||
#include "cpython/longintrepr.h"
|
||||
#include "boolobject.h"
|
||||
#include "floatobject.h"
|
||||
#include "complexobject.h"
|
||||
#include "rangeobject.h"
|
||||
#include "memoryobject.h"
|
||||
#include "tupleobject.h"
|
||||
#include "listobject.h"
|
||||
#include "dictobject.h"
|
||||
#include "cpython/odictobject.h"
|
||||
#include "enumobject.h"
|
||||
#include "setobject.h"
|
||||
#include "methodobject.h"
|
||||
#include "moduleobject.h"
|
||||
#include "cpython/funcobject.h"
|
||||
#include "cpython/classobject.h"
|
||||
#include "fileobject.h"
|
||||
#include "pycapsule.h"
|
||||
#include "cpython/code.h"
|
||||
#include "pyframe.h"
|
||||
#include "traceback.h"
|
||||
#include "sliceobject.h"
|
||||
#include "cpython/cellobject.h"
|
||||
#include "iterobject.h"
|
||||
#include "cpython/genobject.h"
|
||||
#include "descrobject.h"
|
||||
#include "genericaliasobject.h"
|
||||
#include "warnings.h"
|
||||
#include "weakrefobject.h"
|
||||
#include "structseq.h"
|
||||
#include "cpython/picklebufobject.h"
|
||||
#include "cpython/pytime.h"
|
||||
#include "codecs.h"
|
||||
#include "pythread.h"
|
||||
#include "cpython/context.h"
|
||||
#include "modsupport.h"
|
||||
#include "compile.h"
|
||||
#include "pythonrun.h"
|
||||
#include "pylifecycle.h"
|
||||
#include "ceval.h"
|
||||
#include "sysmodule.h"
|
||||
#include "osmodule.h"
|
||||
#include "intrcheck.h"
|
||||
#include "import.h"
|
||||
#include "abstract.h"
|
||||
#include "bltinmodule.h"
|
||||
#include "cpython/pyctype.h"
|
||||
#include "pystrtod.h"
|
||||
#include "pystrcmp.h"
|
||||
#include "fileutils.h"
|
||||
#include "cpython/pyfpe.h"
|
||||
#include "tracemalloc.h"
|
||||
|
||||
#endif /* !Py_PYTHON_H */
|
||||
899
crypto/shamirs_secret_sharing/include/abstract.h
Normal file
899
crypto/shamirs_secret_sharing/include/abstract.h
Normal file
@@ -0,0 +1,899 @@
|
||||
/* Abstract Object Interface (many thanks to Jim Fulton) */
|
||||
|
||||
#ifndef Py_ABSTRACTOBJECT_H
|
||||
#define Py_ABSTRACTOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* === Object Protocol ================================================== */
|
||||
|
||||
/* Implemented elsewhere:
|
||||
|
||||
int PyObject_Print(PyObject *o, FILE *fp, int flags);
|
||||
|
||||
Print an object 'o' on file 'fp'. Returns -1 on error. The flags argument
|
||||
is used to enable certain printing options. The only option currently
|
||||
supported is Py_PRINT_RAW. By default (flags=0), PyObject_Print() formats
|
||||
the object by calling PyObject_Repr(). If flags equals to Py_PRINT_RAW, it
|
||||
formats the object by calling PyObject_Str(). */
|
||||
|
||||
|
||||
/* Implemented elsewhere:
|
||||
|
||||
int PyObject_HasAttrString(PyObject *o, const char *attr_name);
|
||||
|
||||
Returns 1 if object 'o' has the attribute attr_name, and 0 otherwise.
|
||||
|
||||
This is equivalent to the Python expression: hasattr(o,attr_name).
|
||||
|
||||
This function always succeeds. */
|
||||
|
||||
|
||||
/* Implemented elsewhere:
|
||||
|
||||
PyObject* PyObject_GetAttrString(PyObject *o, const char *attr_name);
|
||||
|
||||
Retrieve an attributed named attr_name form object o.
|
||||
Returns the attribute value on success, or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o.attr_name. */
|
||||
|
||||
|
||||
/* Implemented elsewhere:
|
||||
|
||||
int PyObject_HasAttr(PyObject *o, PyObject *attr_name);
|
||||
|
||||
Returns 1 if o has the attribute attr_name, and 0 otherwise.
|
||||
|
||||
This is equivalent to the Python expression: hasattr(o,attr_name).
|
||||
|
||||
This function always succeeds. */
|
||||
|
||||
/* Implemented elsewhere:
|
||||
|
||||
PyObject* PyObject_GetAttr(PyObject *o, PyObject *attr_name);
|
||||
|
||||
Retrieve an attributed named 'attr_name' form object 'o'.
|
||||
Returns the attribute value on success, or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o.attr_name. */
|
||||
|
||||
|
||||
/* Implemented elsewhere:
|
||||
|
||||
int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v);
|
||||
|
||||
Set the value of the attribute named attr_name, for object 'o',
|
||||
to the value 'v'. Raise an exception and return -1 on failure; return 0 on
|
||||
success.
|
||||
|
||||
This is the equivalent of the Python statement o.attr_name=v. */
|
||||
|
||||
|
||||
/* Implemented elsewhere:
|
||||
|
||||
int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v);
|
||||
|
||||
Set the value of the attribute named attr_name, for object 'o', to the value
|
||||
'v'. an exception and return -1 on failure; return 0 on success.
|
||||
|
||||
This is the equivalent of the Python statement o.attr_name=v. */
|
||||
|
||||
/* Implemented as a macro:
|
||||
|
||||
int PyObject_DelAttrString(PyObject *o, const char *attr_name);
|
||||
|
||||
Delete attribute named attr_name, for object o. Returns
|
||||
-1 on failure.
|
||||
|
||||
This is the equivalent of the Python statement: del o.attr_name. */
|
||||
#define PyObject_DelAttrString(O, A) PyObject_SetAttrString((O), (A), NULL)
|
||||
|
||||
|
||||
/* Implemented as a macro:
|
||||
|
||||
int PyObject_DelAttr(PyObject *o, PyObject *attr_name);
|
||||
|
||||
Delete attribute named attr_name, for object o. Returns -1
|
||||
on failure. This is the equivalent of the Python
|
||||
statement: del o.attr_name. */
|
||||
#define PyObject_DelAttr(O, A) PyObject_SetAttr((O), (A), NULL)
|
||||
|
||||
|
||||
/* Implemented elsewhere:
|
||||
|
||||
PyObject *PyObject_Repr(PyObject *o);
|
||||
|
||||
Compute the string representation of object 'o'. Returns the
|
||||
string representation on success, NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: repr(o).
|
||||
|
||||
Called by the repr() built-in function. */
|
||||
|
||||
|
||||
/* Implemented elsewhere:
|
||||
|
||||
PyObject *PyObject_Str(PyObject *o);
|
||||
|
||||
Compute the string representation of object, o. Returns the
|
||||
string representation on success, NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: str(o).
|
||||
|
||||
Called by the str() and print() built-in functions. */
|
||||
|
||||
|
||||
/* Declared elsewhere
|
||||
|
||||
PyAPI_FUNC(int) PyCallable_Check(PyObject *o);
|
||||
|
||||
Determine if the object, o, is callable. Return 1 if the object is callable
|
||||
and 0 otherwise.
|
||||
|
||||
This function always succeeds. */
|
||||
|
||||
|
||||
#ifdef PY_SSIZE_T_CLEAN
|
||||
# define PyObject_CallFunction _PyObject_CallFunction_SizeT
|
||||
# define PyObject_CallMethod _PyObject_CallMethod_SizeT
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000
|
||||
/* Call a callable Python object without any arguments */
|
||||
PyAPI_FUNC(PyObject *) PyObject_CallNoArgs(PyObject *func);
|
||||
#endif
|
||||
|
||||
|
||||
/* Call a callable Python object 'callable' with arguments given by the
|
||||
tuple 'args' and keywords arguments given by the dictionary 'kwargs'.
|
||||
|
||||
'args' must not be NULL, use an empty tuple if no arguments are
|
||||
needed. If no named arguments are needed, 'kwargs' can be NULL.
|
||||
|
||||
This is the equivalent of the Python expression:
|
||||
callable(*args, **kwargs). */
|
||||
PyAPI_FUNC(PyObject *) PyObject_Call(PyObject *callable,
|
||||
PyObject *args, PyObject *kwargs);
|
||||
|
||||
|
||||
/* Call a callable Python object 'callable', with arguments given by the
|
||||
tuple 'args'. If no arguments are needed, then 'args' can be NULL.
|
||||
|
||||
Returns the result of the call on success, or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression:
|
||||
callable(*args). */
|
||||
PyAPI_FUNC(PyObject *) PyObject_CallObject(PyObject *callable,
|
||||
PyObject *args);
|
||||
|
||||
/* Call a callable Python object, callable, with a variable number of C
|
||||
arguments. The C arguments are described using a mkvalue-style format
|
||||
string.
|
||||
|
||||
The format may be NULL, indicating that no arguments are provided.
|
||||
|
||||
Returns the result of the call on success, or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression:
|
||||
callable(arg1, arg2, ...). */
|
||||
PyAPI_FUNC(PyObject *) PyObject_CallFunction(PyObject *callable,
|
||||
const char *format, ...);
|
||||
|
||||
/* Call the method named 'name' of object 'obj' with a variable number of
|
||||
C arguments. The C arguments are described by a mkvalue format string.
|
||||
|
||||
The format can be NULL, indicating that no arguments are provided.
|
||||
|
||||
Returns the result of the call on success, or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression:
|
||||
obj.name(arg1, arg2, ...). */
|
||||
PyAPI_FUNC(PyObject *) PyObject_CallMethod(PyObject *obj,
|
||||
const char *name,
|
||||
const char *format, ...);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyObject_CallFunction_SizeT(PyObject *callable,
|
||||
const char *format,
|
||||
...);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyObject_CallMethod_SizeT(PyObject *obj,
|
||||
const char *name,
|
||||
const char *format,
|
||||
...);
|
||||
|
||||
/* Call a callable Python object 'callable' with a variable number of C
|
||||
arguments. The C arguments are provided as PyObject* values, terminated
|
||||
by a NULL.
|
||||
|
||||
Returns the result of the call on success, or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression:
|
||||
callable(arg1, arg2, ...). */
|
||||
PyAPI_FUNC(PyObject *) PyObject_CallFunctionObjArgs(PyObject *callable,
|
||||
...);
|
||||
|
||||
/* Call the method named 'name' of object 'obj' with a variable number of
|
||||
C arguments. The C arguments are provided as PyObject* values, terminated
|
||||
by NULL.
|
||||
|
||||
Returns the result of the call on success, or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: obj.name(*args). */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyObject_CallMethodObjArgs(
|
||||
PyObject *obj,
|
||||
PyObject *name,
|
||||
...);
|
||||
|
||||
/* Given a vectorcall nargsf argument, return the actual number of arguments.
|
||||
* (For use outside the limited API, this is re-defined as a static inline
|
||||
* function in cpython/abstract.h)
|
||||
*/
|
||||
PyAPI_FUNC(Py_ssize_t) PyVectorcall_NARGS(size_t nargsf);
|
||||
|
||||
/* Call "callable" (which must support vectorcall) with positional arguments
|
||||
"tuple" and keyword arguments "dict". "dict" may also be NULL */
|
||||
PyAPI_FUNC(PyObject *) PyVectorcall_Call(PyObject *callable, PyObject *tuple, PyObject *dict);
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030C0000
|
||||
#define PY_VECTORCALL_ARGUMENTS_OFFSET \
|
||||
(_Py_STATIC_CAST(size_t, 1) << (8 * sizeof(size_t) - 1))
|
||||
|
||||
/* Perform a PEP 590-style vector call on 'callable' */
|
||||
PyAPI_FUNC(PyObject *) PyObject_Vectorcall(
|
||||
PyObject *callable,
|
||||
PyObject *const *args,
|
||||
size_t nargsf,
|
||||
PyObject *kwnames);
|
||||
|
||||
/* Call the method 'name' on args[0] with arguments in args[1..nargsf-1]. */
|
||||
PyAPI_FUNC(PyObject *) PyObject_VectorcallMethod(
|
||||
PyObject *name, PyObject *const *args,
|
||||
size_t nargsf, PyObject *kwnames);
|
||||
#endif
|
||||
|
||||
/* Implemented elsewhere:
|
||||
|
||||
Py_hash_t PyObject_Hash(PyObject *o);
|
||||
|
||||
Compute and return the hash, hash_value, of an object, o. On
|
||||
failure, return -1.
|
||||
|
||||
This is the equivalent of the Python expression: hash(o). */
|
||||
|
||||
|
||||
/* Implemented elsewhere:
|
||||
|
||||
int PyObject_IsTrue(PyObject *o);
|
||||
|
||||
Returns 1 if the object, o, is considered to be true, 0 if o is
|
||||
considered to be false and -1 on failure.
|
||||
|
||||
This is equivalent to the Python expression: not not o. */
|
||||
|
||||
|
||||
/* Implemented elsewhere:
|
||||
|
||||
int PyObject_Not(PyObject *o);
|
||||
|
||||
Returns 0 if the object, o, is considered to be true, 1 if o is
|
||||
considered to be false and -1 on failure.
|
||||
|
||||
This is equivalent to the Python expression: not o. */
|
||||
|
||||
|
||||
/* Get the type of an object.
|
||||
|
||||
On success, returns a type object corresponding to the object type of object
|
||||
'o'. On failure, returns NULL.
|
||||
|
||||
This is equivalent to the Python expression: type(o) */
|
||||
PyAPI_FUNC(PyObject *) PyObject_Type(PyObject *o);
|
||||
|
||||
|
||||
/* Return the size of object 'o'. If the object 'o' provides both sequence and
|
||||
mapping protocols, the sequence size is returned.
|
||||
|
||||
On error, -1 is returned.
|
||||
|
||||
This is the equivalent to the Python expression: len(o) */
|
||||
PyAPI_FUNC(Py_ssize_t) PyObject_Size(PyObject *o);
|
||||
|
||||
|
||||
/* For DLL compatibility */
|
||||
#undef PyObject_Length
|
||||
PyAPI_FUNC(Py_ssize_t) PyObject_Length(PyObject *o);
|
||||
#define PyObject_Length PyObject_Size
|
||||
|
||||
/* Return element of 'o' corresponding to the object 'key'. Return NULL
|
||||
on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o[key] */
|
||||
PyAPI_FUNC(PyObject *) PyObject_GetItem(PyObject *o, PyObject *key);
|
||||
|
||||
|
||||
/* Map the object 'key' to the value 'v' into 'o'.
|
||||
|
||||
Raise an exception and return -1 on failure; return 0 on success.
|
||||
|
||||
This is the equivalent of the Python statement: o[key]=v. */
|
||||
PyAPI_FUNC(int) PyObject_SetItem(PyObject *o, PyObject *key, PyObject *v);
|
||||
|
||||
/* Remove the mapping for the string 'key' from the object 'o'.
|
||||
Returns -1 on failure.
|
||||
|
||||
This is equivalent to the Python statement: del o[key]. */
|
||||
PyAPI_FUNC(int) PyObject_DelItemString(PyObject *o, const char *key);
|
||||
|
||||
/* Delete the mapping for the object 'key' from the object 'o'.
|
||||
Returns -1 on failure.
|
||||
|
||||
This is the equivalent of the Python statement: del o[key]. */
|
||||
PyAPI_FUNC(int) PyObject_DelItem(PyObject *o, PyObject *key);
|
||||
|
||||
|
||||
/* === Old Buffer API ============================================ */
|
||||
|
||||
/* FIXME: usage of these should all be replaced in Python itself
|
||||
but for backwards compatibility we will implement them.
|
||||
Their usage without a corresponding "unlock" mechanism
|
||||
may create issues (but they would already be there). */
|
||||
|
||||
/* Takes an arbitrary object which must support the (character, single segment)
|
||||
buffer interface and returns a pointer to a read-only memory location
|
||||
usable as character based input for subsequent processing.
|
||||
|
||||
Return 0 on success. buffer and buffer_len are only set in case no error
|
||||
occurs. Otherwise, -1 is returned and an exception set. */
|
||||
Py_DEPRECATED(3.0)
|
||||
PyAPI_FUNC(int) PyObject_AsCharBuffer(PyObject *obj,
|
||||
const char **buffer,
|
||||
Py_ssize_t *buffer_len);
|
||||
|
||||
/* Checks whether an arbitrary object supports the (character, single segment)
|
||||
buffer interface.
|
||||
|
||||
Returns 1 on success, 0 on failure. */
|
||||
Py_DEPRECATED(3.0) PyAPI_FUNC(int) PyObject_CheckReadBuffer(PyObject *obj);
|
||||
|
||||
/* Same as PyObject_AsCharBuffer() except that this API expects (readable,
|
||||
single segment) buffer interface and returns a pointer to a read-only memory
|
||||
location which can contain arbitrary data.
|
||||
|
||||
0 is returned on success. buffer and buffer_len are only set in case no
|
||||
error occurs. Otherwise, -1 is returned and an exception set. */
|
||||
Py_DEPRECATED(3.0)
|
||||
PyAPI_FUNC(int) PyObject_AsReadBuffer(PyObject *obj,
|
||||
const void **buffer,
|
||||
Py_ssize_t *buffer_len);
|
||||
|
||||
/* Takes an arbitrary object which must support the (writable, single segment)
|
||||
buffer interface and returns a pointer to a writable memory location in
|
||||
buffer of size 'buffer_len'.
|
||||
|
||||
Return 0 on success. buffer and buffer_len are only set in case no error
|
||||
occurs. Otherwise, -1 is returned and an exception set. */
|
||||
Py_DEPRECATED(3.0)
|
||||
PyAPI_FUNC(int) PyObject_AsWriteBuffer(PyObject *obj,
|
||||
void **buffer,
|
||||
Py_ssize_t *buffer_len);
|
||||
|
||||
|
||||
/* === New Buffer API ============================================ */
|
||||
|
||||
/* Takes an arbitrary object and returns the result of calling
|
||||
obj.__format__(format_spec). */
|
||||
PyAPI_FUNC(PyObject *) PyObject_Format(PyObject *obj,
|
||||
PyObject *format_spec);
|
||||
|
||||
|
||||
/* ==== Iterators ================================================ */
|
||||
|
||||
/* Takes an object and returns an iterator for it.
|
||||
This is typically a new iterator but if the argument is an iterator, this
|
||||
returns itself. */
|
||||
PyAPI_FUNC(PyObject *) PyObject_GetIter(PyObject *);
|
||||
|
||||
/* Takes an AsyncIterable object and returns an AsyncIterator for it.
|
||||
This is typically a new iterator but if the argument is an AsyncIterator,
|
||||
this returns itself. */
|
||||
PyAPI_FUNC(PyObject *) PyObject_GetAIter(PyObject *);
|
||||
|
||||
/* Returns non-zero if the object 'obj' provides iterator protocols, and 0 otherwise.
|
||||
|
||||
This function always succeeds. */
|
||||
PyAPI_FUNC(int) PyIter_Check(PyObject *);
|
||||
|
||||
/* Returns non-zero if the object 'obj' provides AsyncIterator protocols, and 0 otherwise.
|
||||
|
||||
This function always succeeds. */
|
||||
PyAPI_FUNC(int) PyAIter_Check(PyObject *);
|
||||
|
||||
/* Takes an iterator object and calls its tp_iternext slot,
|
||||
returning the next value.
|
||||
|
||||
If the iterator is exhausted, this returns NULL without setting an
|
||||
exception.
|
||||
|
||||
NULL with an exception means an error occurred. */
|
||||
PyAPI_FUNC(PyObject *) PyIter_Next(PyObject *);
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000
|
||||
|
||||
/* Takes generator, coroutine or iterator object and sends the value into it.
|
||||
Returns:
|
||||
- PYGEN_RETURN (0) if generator has returned.
|
||||
'result' parameter is filled with return value
|
||||
- PYGEN_ERROR (-1) if exception was raised.
|
||||
'result' parameter is NULL
|
||||
- PYGEN_NEXT (1) if generator has yielded.
|
||||
'result' parameter is filled with yielded value. */
|
||||
PyAPI_FUNC(PySendResult) PyIter_Send(PyObject *, PyObject *, PyObject **);
|
||||
#endif
|
||||
|
||||
|
||||
/* === Number Protocol ================================================== */
|
||||
|
||||
/* Returns 1 if the object 'o' provides numeric protocols, and 0 otherwise.
|
||||
|
||||
This function always succeeds. */
|
||||
PyAPI_FUNC(int) PyNumber_Check(PyObject *o);
|
||||
|
||||
/* Returns the result of adding o1 and o2, or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 + o2. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_Add(PyObject *o1, PyObject *o2);
|
||||
|
||||
/* Returns the result of subtracting o2 from o1, or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 - o2. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_Subtract(PyObject *o1, PyObject *o2);
|
||||
|
||||
/* Returns the result of multiplying o1 and o2, or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 * o2. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_Multiply(PyObject *o1, PyObject *o2);
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||
/* This is the equivalent of the Python expression: o1 @ o2. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_MatrixMultiply(PyObject *o1, PyObject *o2);
|
||||
#endif
|
||||
|
||||
/* Returns the result of dividing o1 by o2 giving an integral result,
|
||||
or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 // o2. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_FloorDivide(PyObject *o1, PyObject *o2);
|
||||
|
||||
/* Returns the result of dividing o1 by o2 giving a float result, or NULL on
|
||||
failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 / o2. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_TrueDivide(PyObject *o1, PyObject *o2);
|
||||
|
||||
/* Returns the remainder of dividing o1 by o2, or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 % o2. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_Remainder(PyObject *o1, PyObject *o2);
|
||||
|
||||
/* See the built-in function divmod.
|
||||
|
||||
Returns NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: divmod(o1, o2). */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_Divmod(PyObject *o1, PyObject *o2);
|
||||
|
||||
/* See the built-in function pow. Returns NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: pow(o1, o2, o3),
|
||||
where o3 is optional. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_Power(PyObject *o1, PyObject *o2,
|
||||
PyObject *o3);
|
||||
|
||||
/* Returns the negation of o on success, or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: -o. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_Negative(PyObject *o);
|
||||
|
||||
/* Returns the positive of o on success, or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: +o. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_Positive(PyObject *o);
|
||||
|
||||
/* Returns the absolute value of 'o', or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: abs(o). */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_Absolute(PyObject *o);
|
||||
|
||||
/* Returns the bitwise negation of 'o' on success, or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: ~o. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_Invert(PyObject *o);
|
||||
|
||||
/* Returns the result of left shifting o1 by o2 on success, or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 << o2. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_Lshift(PyObject *o1, PyObject *o2);
|
||||
|
||||
/* Returns the result of right shifting o1 by o2 on success, or NULL on
|
||||
failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 >> o2. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_Rshift(PyObject *o1, PyObject *o2);
|
||||
|
||||
/* Returns the result of bitwise and of o1 and o2 on success, or NULL on
|
||||
failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 & o2. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_And(PyObject *o1, PyObject *o2);
|
||||
|
||||
/* Returns the bitwise exclusive or of o1 by o2 on success, or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 ^ o2. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_Xor(PyObject *o1, PyObject *o2);
|
||||
|
||||
/* Returns the result of bitwise or on o1 and o2 on success, or NULL on
|
||||
failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 | o2. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_Or(PyObject *o1, PyObject *o2);
|
||||
|
||||
/* Returns 1 if obj is an index integer (has the nb_index slot of the
|
||||
tp_as_number structure filled in), and 0 otherwise. */
|
||||
PyAPI_FUNC(int) PyIndex_Check(PyObject *);
|
||||
|
||||
/* Returns the object 'o' converted to a Python int, or NULL with an exception
|
||||
raised on failure. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_Index(PyObject *o);
|
||||
|
||||
/* Returns the object 'o' converted to Py_ssize_t by going through
|
||||
PyNumber_Index() first.
|
||||
|
||||
If an overflow error occurs while converting the int to Py_ssize_t, then the
|
||||
second argument 'exc' is the error-type to return. If it is NULL, then the
|
||||
overflow error is cleared and the value is clipped. */
|
||||
PyAPI_FUNC(Py_ssize_t) PyNumber_AsSsize_t(PyObject *o, PyObject *exc);
|
||||
|
||||
/* Returns the object 'o' converted to an integer object on success, or NULL
|
||||
on failure.
|
||||
|
||||
This is the equivalent of the Python expression: int(o). */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_Long(PyObject *o);
|
||||
|
||||
/* Returns the object 'o' converted to a float object on success, or NULL
|
||||
on failure.
|
||||
|
||||
This is the equivalent of the Python expression: float(o). */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_Float(PyObject *o);
|
||||
|
||||
|
||||
/* --- In-place variants of (some of) the above number protocol functions -- */
|
||||
|
||||
/* Returns the result of adding o2 to o1, possibly in-place, or NULL
|
||||
on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 += o2. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_InPlaceAdd(PyObject *o1, PyObject *o2);
|
||||
|
||||
/* Returns the result of subtracting o2 from o1, possibly in-place or
|
||||
NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 -= o2. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_InPlaceSubtract(PyObject *o1, PyObject *o2);
|
||||
|
||||
/* Returns the result of multiplying o1 by o2, possibly in-place, or NULL on
|
||||
failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 *= o2. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_InPlaceMultiply(PyObject *o1, PyObject *o2);
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||
/* This is the equivalent of the Python expression: o1 @= o2. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_InPlaceMatrixMultiply(PyObject *o1, PyObject *o2);
|
||||
#endif
|
||||
|
||||
/* Returns the result of dividing o1 by o2 giving an integral result, possibly
|
||||
in-place, or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 /= o2. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_InPlaceFloorDivide(PyObject *o1,
|
||||
PyObject *o2);
|
||||
|
||||
/* Returns the result of dividing o1 by o2 giving a float result, possibly
|
||||
in-place, or null on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 /= o2. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_InPlaceTrueDivide(PyObject *o1,
|
||||
PyObject *o2);
|
||||
|
||||
/* Returns the remainder of dividing o1 by o2, possibly in-place, or NULL on
|
||||
failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 %= o2. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_InPlaceRemainder(PyObject *o1, PyObject *o2);
|
||||
|
||||
/* Returns the result of raising o1 to the power of o2, possibly in-place,
|
||||
or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 **= o2,
|
||||
or o1 = pow(o1, o2, o3) if o3 is present. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_InPlacePower(PyObject *o1, PyObject *o2,
|
||||
PyObject *o3);
|
||||
|
||||
/* Returns the result of left shifting o1 by o2, possibly in-place, or NULL
|
||||
on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 <<= o2. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_InPlaceLshift(PyObject *o1, PyObject *o2);
|
||||
|
||||
/* Returns the result of right shifting o1 by o2, possibly in-place or NULL
|
||||
on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 >>= o2. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_InPlaceRshift(PyObject *o1, PyObject *o2);
|
||||
|
||||
/* Returns the result of bitwise and of o1 and o2, possibly in-place, or NULL
|
||||
on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 &= o2. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_InPlaceAnd(PyObject *o1, PyObject *o2);
|
||||
|
||||
/* Returns the bitwise exclusive or of o1 by o2, possibly in-place, or NULL
|
||||
on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 ^= o2. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_InPlaceXor(PyObject *o1, PyObject *o2);
|
||||
|
||||
/* Returns the result of bitwise or of o1 and o2, possibly in-place,
|
||||
or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 |= o2. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_InPlaceOr(PyObject *o1, PyObject *o2);
|
||||
|
||||
/* Returns the integer n converted to a string with a base, with a base
|
||||
marker of 0b, 0o or 0x prefixed if applicable.
|
||||
|
||||
If n is not an int object, it is converted with PyNumber_Index first. */
|
||||
PyAPI_FUNC(PyObject *) PyNumber_ToBase(PyObject *n, int base);
|
||||
|
||||
|
||||
/* === Sequence protocol ================================================ */
|
||||
|
||||
/* Return 1 if the object provides sequence protocol, and zero
|
||||
otherwise.
|
||||
|
||||
This function always succeeds. */
|
||||
PyAPI_FUNC(int) PySequence_Check(PyObject *o);
|
||||
|
||||
/* Return the size of sequence object o, or -1 on failure. */
|
||||
PyAPI_FUNC(Py_ssize_t) PySequence_Size(PyObject *o);
|
||||
|
||||
/* For DLL compatibility */
|
||||
#undef PySequence_Length
|
||||
PyAPI_FUNC(Py_ssize_t) PySequence_Length(PyObject *o);
|
||||
#define PySequence_Length PySequence_Size
|
||||
|
||||
|
||||
/* Return the concatenation of o1 and o2 on success, and NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 + o2. */
|
||||
PyAPI_FUNC(PyObject *) PySequence_Concat(PyObject *o1, PyObject *o2);
|
||||
|
||||
/* Return the result of repeating sequence object 'o' 'count' times,
|
||||
or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o * count. */
|
||||
PyAPI_FUNC(PyObject *) PySequence_Repeat(PyObject *o, Py_ssize_t count);
|
||||
|
||||
/* Return the ith element of o, or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o[i]. */
|
||||
PyAPI_FUNC(PyObject *) PySequence_GetItem(PyObject *o, Py_ssize_t i);
|
||||
|
||||
/* Return the slice of sequence object o between i1 and i2, or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o[i1:i2]. */
|
||||
PyAPI_FUNC(PyObject *) PySequence_GetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2);
|
||||
|
||||
/* Assign object 'v' to the ith element of the sequence 'o'. Raise an exception
|
||||
and return -1 on failure; return 0 on success.
|
||||
|
||||
This is the equivalent of the Python statement o[i] = v. */
|
||||
PyAPI_FUNC(int) PySequence_SetItem(PyObject *o, Py_ssize_t i, PyObject *v);
|
||||
|
||||
/* Delete the 'i'-th element of the sequence 'v'. Returns -1 on failure.
|
||||
|
||||
This is the equivalent of the Python statement: del o[i]. */
|
||||
PyAPI_FUNC(int) PySequence_DelItem(PyObject *o, Py_ssize_t i);
|
||||
|
||||
/* Assign the sequence object 'v' to the slice in sequence object 'o',
|
||||
from 'i1' to 'i2'. Returns -1 on failure.
|
||||
|
||||
This is the equivalent of the Python statement: o[i1:i2] = v. */
|
||||
PyAPI_FUNC(int) PySequence_SetSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2,
|
||||
PyObject *v);
|
||||
|
||||
/* Delete the slice in sequence object 'o' from 'i1' to 'i2'.
|
||||
Returns -1 on failure.
|
||||
|
||||
This is the equivalent of the Python statement: del o[i1:i2]. */
|
||||
PyAPI_FUNC(int) PySequence_DelSlice(PyObject *o, Py_ssize_t i1, Py_ssize_t i2);
|
||||
|
||||
/* Returns the sequence 'o' as a tuple on success, and NULL on failure.
|
||||
|
||||
This is equivalent to the Python expression: tuple(o). */
|
||||
PyAPI_FUNC(PyObject *) PySequence_Tuple(PyObject *o);
|
||||
|
||||
/* Returns the sequence 'o' as a list on success, and NULL on failure.
|
||||
This is equivalent to the Python expression: list(o) */
|
||||
PyAPI_FUNC(PyObject *) PySequence_List(PyObject *o);
|
||||
|
||||
/* Return the sequence 'o' as a list, unless it's already a tuple or list.
|
||||
|
||||
Use PySequence_Fast_GET_ITEM to access the members of this list, and
|
||||
PySequence_Fast_GET_SIZE to get its length.
|
||||
|
||||
Returns NULL on failure. If the object does not support iteration, raises a
|
||||
TypeError exception with 'm' as the message text. */
|
||||
PyAPI_FUNC(PyObject *) PySequence_Fast(PyObject *o, const char* m);
|
||||
|
||||
/* Return the size of the sequence 'o', assuming that 'o' was returned by
|
||||
PySequence_Fast and is not NULL. */
|
||||
#define PySequence_Fast_GET_SIZE(o) \
|
||||
(PyList_Check(o) ? PyList_GET_SIZE(o) : PyTuple_GET_SIZE(o))
|
||||
|
||||
/* Return the 'i'-th element of the sequence 'o', assuming that o was returned
|
||||
by PySequence_Fast, and that i is within bounds. */
|
||||
#define PySequence_Fast_GET_ITEM(o, i)\
|
||||
(PyList_Check(o) ? PyList_GET_ITEM((o), (i)) : PyTuple_GET_ITEM((o), (i)))
|
||||
|
||||
/* Return a pointer to the underlying item array for
|
||||
an object returned by PySequence_Fast */
|
||||
#define PySequence_Fast_ITEMS(sf) \
|
||||
(PyList_Check(sf) ? ((PyListObject *)(sf))->ob_item \
|
||||
: ((PyTupleObject *)(sf))->ob_item)
|
||||
|
||||
/* Return the number of occurrences on value on 'o', that is, return
|
||||
the number of keys for which o[key] == value.
|
||||
|
||||
On failure, return -1. This is equivalent to the Python expression:
|
||||
o.count(value). */
|
||||
PyAPI_FUNC(Py_ssize_t) PySequence_Count(PyObject *o, PyObject *value);
|
||||
|
||||
/* Return 1 if 'ob' is in the sequence 'seq'; 0 if 'ob' is not in the sequence
|
||||
'seq'; -1 on error.
|
||||
|
||||
Use __contains__ if possible, else _PySequence_IterSearch(). */
|
||||
PyAPI_FUNC(int) PySequence_Contains(PyObject *seq, PyObject *ob);
|
||||
|
||||
/* For DLL-level backwards compatibility */
|
||||
#undef PySequence_In
|
||||
/* Determine if the sequence 'o' contains 'value'. If an item in 'o' is equal
|
||||
to 'value', return 1, otherwise return 0. On error, return -1.
|
||||
|
||||
This is equivalent to the Python expression: value in o. */
|
||||
PyAPI_FUNC(int) PySequence_In(PyObject *o, PyObject *value);
|
||||
|
||||
/* For source-level backwards compatibility */
|
||||
#define PySequence_In PySequence_Contains
|
||||
|
||||
|
||||
/* Return the first index for which o[i] == value.
|
||||
On error, return -1.
|
||||
|
||||
This is equivalent to the Python expression: o.index(value). */
|
||||
PyAPI_FUNC(Py_ssize_t) PySequence_Index(PyObject *o, PyObject *value);
|
||||
|
||||
|
||||
/* --- In-place versions of some of the above Sequence functions --- */
|
||||
|
||||
/* Append sequence 'o2' to sequence 'o1', in-place when possible. Return the
|
||||
resulting object, which could be 'o1', or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 += o2. */
|
||||
PyAPI_FUNC(PyObject *) PySequence_InPlaceConcat(PyObject *o1, PyObject *o2);
|
||||
|
||||
/* Repeat sequence 'o' by 'count', in-place when possible. Return the resulting
|
||||
object, which could be 'o', or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o1 *= count. */
|
||||
PyAPI_FUNC(PyObject *) PySequence_InPlaceRepeat(PyObject *o, Py_ssize_t count);
|
||||
|
||||
|
||||
/* === Mapping protocol ================================================= */
|
||||
|
||||
/* Return 1 if the object provides mapping protocol, and 0 otherwise.
|
||||
|
||||
This function always succeeds. */
|
||||
PyAPI_FUNC(int) PyMapping_Check(PyObject *o);
|
||||
|
||||
/* Returns the number of keys in mapping object 'o' on success, and -1 on
|
||||
failure. This is equivalent to the Python expression: len(o). */
|
||||
PyAPI_FUNC(Py_ssize_t) PyMapping_Size(PyObject *o);
|
||||
|
||||
/* For DLL compatibility */
|
||||
#undef PyMapping_Length
|
||||
PyAPI_FUNC(Py_ssize_t) PyMapping_Length(PyObject *o);
|
||||
#define PyMapping_Length PyMapping_Size
|
||||
|
||||
|
||||
/* Implemented as a macro:
|
||||
|
||||
int PyMapping_DelItemString(PyObject *o, const char *key);
|
||||
|
||||
Remove the mapping for the string 'key' from the mapping 'o'. Returns -1 on
|
||||
failure.
|
||||
|
||||
This is equivalent to the Python statement: del o[key]. */
|
||||
#define PyMapping_DelItemString(O, K) PyObject_DelItemString((O), (K))
|
||||
|
||||
/* Implemented as a macro:
|
||||
|
||||
int PyMapping_DelItem(PyObject *o, PyObject *key);
|
||||
|
||||
Remove the mapping for the object 'key' from the mapping object 'o'.
|
||||
Returns -1 on failure.
|
||||
|
||||
This is equivalent to the Python statement: del o[key]. */
|
||||
#define PyMapping_DelItem(O, K) PyObject_DelItem((O), (K))
|
||||
|
||||
/* On success, return 1 if the mapping object 'o' has the key 'key',
|
||||
and 0 otherwise.
|
||||
|
||||
This is equivalent to the Python expression: key in o.
|
||||
|
||||
This function always succeeds. */
|
||||
PyAPI_FUNC(int) PyMapping_HasKeyString(PyObject *o, const char *key);
|
||||
|
||||
/* Return 1 if the mapping object has the key 'key', and 0 otherwise.
|
||||
|
||||
This is equivalent to the Python expression: key in o.
|
||||
|
||||
This function always succeeds. */
|
||||
PyAPI_FUNC(int) PyMapping_HasKey(PyObject *o, PyObject *key);
|
||||
|
||||
/* On success, return a list or tuple of the keys in mapping object 'o'.
|
||||
On failure, return NULL. */
|
||||
PyAPI_FUNC(PyObject *) PyMapping_Keys(PyObject *o);
|
||||
|
||||
/* On success, return a list or tuple of the values in mapping object 'o'.
|
||||
On failure, return NULL. */
|
||||
PyAPI_FUNC(PyObject *) PyMapping_Values(PyObject *o);
|
||||
|
||||
/* On success, return a list or tuple of the items in mapping object 'o',
|
||||
where each item is a tuple containing a key-value pair. On failure, return
|
||||
NULL. */
|
||||
PyAPI_FUNC(PyObject *) PyMapping_Items(PyObject *o);
|
||||
|
||||
/* Return element of 'o' corresponding to the string 'key' or NULL on failure.
|
||||
|
||||
This is the equivalent of the Python expression: o[key]. */
|
||||
PyAPI_FUNC(PyObject *) PyMapping_GetItemString(PyObject *o,
|
||||
const char *key);
|
||||
|
||||
/* Map the string 'key' to the value 'v' in the mapping 'o'.
|
||||
Returns -1 on failure.
|
||||
|
||||
This is the equivalent of the Python statement: o[key]=v. */
|
||||
PyAPI_FUNC(int) PyMapping_SetItemString(PyObject *o, const char *key,
|
||||
PyObject *value);
|
||||
|
||||
/* isinstance(object, typeorclass) */
|
||||
PyAPI_FUNC(int) PyObject_IsInstance(PyObject *object, PyObject *typeorclass);
|
||||
|
||||
/* issubclass(object, typeorclass) */
|
||||
PyAPI_FUNC(int) PyObject_IsSubclass(PyObject *object, PyObject *typeorclass);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
# define Py_CPYTHON_ABSTRACTOBJECT_H
|
||||
# include "cpython/abstract.h"
|
||||
# undef Py_CPYTHON_ABSTRACTOBJECT_H
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* Py_ABSTRACTOBJECT_H */
|
||||
14
crypto/shamirs_secret_sharing/include/bltinmodule.h
Normal file
14
crypto/shamirs_secret_sharing/include/bltinmodule.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef Py_BLTINMODULE_H
|
||||
#define Py_BLTINMODULE_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyFilter_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyMap_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyZip_Type;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_BLTINMODULE_H */
|
||||
42
crypto/shamirs_secret_sharing/include/boolobject.h
Normal file
42
crypto/shamirs_secret_sharing/include/boolobject.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/* Boolean object interface */
|
||||
|
||||
#ifndef Py_BOOLOBJECT_H
|
||||
#define Py_BOOLOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
// PyBool_Type is declared by object.h
|
||||
|
||||
#define PyBool_Check(x) Py_IS_TYPE((x), &PyBool_Type)
|
||||
|
||||
/* Py_False and Py_True are the only two bools in existence. */
|
||||
|
||||
/* Don't use these directly */
|
||||
PyAPI_DATA(PyLongObject) _Py_FalseStruct;
|
||||
PyAPI_DATA(PyLongObject) _Py_TrueStruct;
|
||||
|
||||
/* Use these macros */
|
||||
#define Py_False _PyObject_CAST(&_Py_FalseStruct)
|
||||
#define Py_True _PyObject_CAST(&_Py_TrueStruct)
|
||||
|
||||
// Test if an object is the True singleton, the same as "x is True" in Python.
|
||||
PyAPI_FUNC(int) Py_IsTrue(PyObject *x);
|
||||
#define Py_IsTrue(x) Py_Is((x), Py_True)
|
||||
|
||||
// Test if an object is the False singleton, the same as "x is False" in Python.
|
||||
PyAPI_FUNC(int) Py_IsFalse(PyObject *x);
|
||||
#define Py_IsFalse(x) Py_Is((x), Py_False)
|
||||
|
||||
/* Macros for returning Py_True or Py_False, respectively */
|
||||
#define Py_RETURN_TRUE return Py_True
|
||||
#define Py_RETURN_FALSE return Py_False
|
||||
|
||||
/* Function to return a bool from a C long */
|
||||
PyAPI_FUNC(PyObject *) PyBool_FromLong(long);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_BOOLOBJECT_H */
|
||||
44
crypto/shamirs_secret_sharing/include/bytearrayobject.h
Normal file
44
crypto/shamirs_secret_sharing/include/bytearrayobject.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/* ByteArray object interface */
|
||||
|
||||
#ifndef Py_BYTEARRAYOBJECT_H
|
||||
#define Py_BYTEARRAYOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Type PyByteArrayObject represents a mutable array of bytes.
|
||||
* The Python API is that of a sequence;
|
||||
* the bytes are mapped to ints in [0, 256).
|
||||
* Bytes are not characters; they may be used to encode characters.
|
||||
* The only way to go between bytes and str/unicode is via encoding
|
||||
* and decoding.
|
||||
* For the convenience of C programmers, the bytes type is considered
|
||||
* to contain a char pointer, not an unsigned char pointer.
|
||||
*/
|
||||
|
||||
/* Type object */
|
||||
PyAPI_DATA(PyTypeObject) PyByteArray_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyByteArrayIter_Type;
|
||||
|
||||
/* Type check macros */
|
||||
#define PyByteArray_Check(self) PyObject_TypeCheck((self), &PyByteArray_Type)
|
||||
#define PyByteArray_CheckExact(self) Py_IS_TYPE((self), &PyByteArray_Type)
|
||||
|
||||
/* Direct API functions */
|
||||
PyAPI_FUNC(PyObject *) PyByteArray_FromObject(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyByteArray_Concat(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyByteArray_FromStringAndSize(const char *, Py_ssize_t);
|
||||
PyAPI_FUNC(Py_ssize_t) PyByteArray_Size(PyObject *);
|
||||
PyAPI_FUNC(char *) PyByteArray_AsString(PyObject *);
|
||||
PyAPI_FUNC(int) PyByteArray_Resize(PyObject *, Py_ssize_t);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
# define Py_CPYTHON_BYTEARRAYOBJECT_H
|
||||
# include "cpython/bytearrayobject.h"
|
||||
# undef Py_CPYTHON_BYTEARRAYOBJECT_H
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_BYTEARRAYOBJECT_H */
|
||||
69
crypto/shamirs_secret_sharing/include/bytesobject.h
Normal file
69
crypto/shamirs_secret_sharing/include/bytesobject.h
Normal file
@@ -0,0 +1,69 @@
|
||||
|
||||
/* Bytes object interface */
|
||||
|
||||
#ifndef Py_BYTESOBJECT_H
|
||||
#define Py_BYTESOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdarg.h> // va_list
|
||||
|
||||
/*
|
||||
Type PyBytesObject represents a byte string. An extra zero byte is
|
||||
reserved at the end to ensure it is zero-terminated, but a size is
|
||||
present so strings with null bytes in them can be represented. This
|
||||
is an immutable object type.
|
||||
|
||||
There are functions to create new bytes objects, to test
|
||||
an object for bytes-ness, and to get the
|
||||
byte string value. The latter function returns a null pointer
|
||||
if the object is not of the proper type.
|
||||
There is a variant that takes an explicit size as well as a
|
||||
variant that assumes a zero-terminated string. Note that none of the
|
||||
functions should be applied to NULL pointer.
|
||||
*/
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyBytes_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyBytesIter_Type;
|
||||
|
||||
#define PyBytes_Check(op) \
|
||||
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_BYTES_SUBCLASS)
|
||||
#define PyBytes_CheckExact(op) Py_IS_TYPE((op), &PyBytes_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyBytes_FromStringAndSize(const char *, Py_ssize_t);
|
||||
PyAPI_FUNC(PyObject *) PyBytes_FromString(const char *);
|
||||
PyAPI_FUNC(PyObject *) PyBytes_FromObject(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyBytes_FromFormatV(const char*, va_list)
|
||||
Py_GCC_ATTRIBUTE((format(printf, 1, 0)));
|
||||
PyAPI_FUNC(PyObject *) PyBytes_FromFormat(const char*, ...)
|
||||
Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
|
||||
PyAPI_FUNC(Py_ssize_t) PyBytes_Size(PyObject *);
|
||||
PyAPI_FUNC(char *) PyBytes_AsString(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyBytes_Repr(PyObject *, int);
|
||||
PyAPI_FUNC(void) PyBytes_Concat(PyObject **, PyObject *);
|
||||
PyAPI_FUNC(void) PyBytes_ConcatAndDel(PyObject **, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyBytes_DecodeEscape(const char *, Py_ssize_t,
|
||||
const char *, Py_ssize_t,
|
||||
const char *);
|
||||
|
||||
/* Provides access to the internal data buffer and size of a bytes object.
|
||||
Passing NULL as len parameter will force the string buffer to be
|
||||
0-terminated (passing a string with embedded NUL characters will
|
||||
cause an exception). */
|
||||
PyAPI_FUNC(int) PyBytes_AsStringAndSize(
|
||||
PyObject *obj, /* bytes object */
|
||||
char **s, /* pointer to buffer variable */
|
||||
Py_ssize_t *len /* pointer to length variable or NULL */
|
||||
);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
# define Py_CPYTHON_BYTESOBJECT_H
|
||||
# include "cpython/bytesobject.h"
|
||||
# undef Py_CPYTHON_BYTESOBJECT_H
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_BYTESOBJECT_H */
|
||||
168
crypto/shamirs_secret_sharing/include/ceval.h
Normal file
168
crypto/shamirs_secret_sharing/include/ceval.h
Normal file
@@ -0,0 +1,168 @@
|
||||
/* Interface to random parts in ceval.c */
|
||||
|
||||
#ifndef Py_CEVAL_H
|
||||
#define Py_CEVAL_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyEval_EvalCode(PyObject *, PyObject *, PyObject *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyEval_EvalCodeEx(PyObject *co,
|
||||
PyObject *globals,
|
||||
PyObject *locals,
|
||||
PyObject *const *args, int argc,
|
||||
PyObject *const *kwds, int kwdc,
|
||||
PyObject *const *defs, int defc,
|
||||
PyObject *kwdefs, PyObject *closure);
|
||||
|
||||
/* PyEval_CallObjectWithKeywords(), PyEval_CallObject(), PyEval_CallFunction
|
||||
* and PyEval_CallMethod are deprecated. Since they are officially part of the
|
||||
* stable ABI (PEP 384), they must be kept for backward compatibility.
|
||||
* PyObject_Call(), PyObject_CallFunction() and PyObject_CallMethod() are
|
||||
* recommended to call a callable object.
|
||||
*/
|
||||
|
||||
Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallObjectWithKeywords(
|
||||
PyObject *callable,
|
||||
PyObject *args,
|
||||
PyObject *kwargs);
|
||||
|
||||
/* Deprecated since PyEval_CallObjectWithKeywords is deprecated */
|
||||
#define PyEval_CallObject(callable, arg) \
|
||||
PyEval_CallObjectWithKeywords((callable), (arg), _PyObject_CAST(_Py_NULL))
|
||||
|
||||
Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallFunction(
|
||||
PyObject *callable, const char *format, ...);
|
||||
Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyEval_CallMethod(
|
||||
PyObject *obj, const char *name, const char *format, ...);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyEval_GetBuiltins(void);
|
||||
PyAPI_FUNC(PyObject *) PyEval_GetGlobals(void);
|
||||
PyAPI_FUNC(PyObject *) PyEval_GetLocals(void);
|
||||
PyAPI_FUNC(PyFrameObject *) PyEval_GetFrame(void);
|
||||
|
||||
PyAPI_FUNC(int) Py_AddPendingCall(int (*func)(void *), void *arg);
|
||||
PyAPI_FUNC(int) Py_MakePendingCalls(void);
|
||||
|
||||
/* Protection against deeply nested recursive calls
|
||||
|
||||
In Python 3.0, this protection has two levels:
|
||||
* normal anti-recursion protection is triggered when the recursion level
|
||||
exceeds the current recursion limit. It raises a RecursionError, and sets
|
||||
the "overflowed" flag in the thread state structure. This flag
|
||||
temporarily *disables* the normal protection; this allows cleanup code
|
||||
to potentially outgrow the recursion limit while processing the
|
||||
RecursionError.
|
||||
* "last chance" anti-recursion protection is triggered when the recursion
|
||||
level exceeds "current recursion limit + 50". By construction, this
|
||||
protection can only be triggered when the "overflowed" flag is set. It
|
||||
means the cleanup code has itself gone into an infinite loop, or the
|
||||
RecursionError has been mistakingly ignored. When this protection is
|
||||
triggered, the interpreter aborts with a Fatal Error.
|
||||
|
||||
In addition, the "overflowed" flag is automatically reset when the
|
||||
recursion level drops below "current recursion limit - 50". This heuristic
|
||||
is meant to ensure that the normal anti-recursion protection doesn't get
|
||||
disabled too long.
|
||||
|
||||
Please note: this scheme has its own limitations. See:
|
||||
http://mail.python.org/pipermail/python-dev/2008-August/082106.html
|
||||
for some observations.
|
||||
*/
|
||||
PyAPI_FUNC(void) Py_SetRecursionLimit(int);
|
||||
PyAPI_FUNC(int) Py_GetRecursionLimit(void);
|
||||
|
||||
PyAPI_FUNC(int) Py_EnterRecursiveCall(const char *where);
|
||||
PyAPI_FUNC(void) Py_LeaveRecursiveCall(void);
|
||||
|
||||
PyAPI_FUNC(const char *) PyEval_GetFuncName(PyObject *);
|
||||
PyAPI_FUNC(const char *) PyEval_GetFuncDesc(PyObject *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyEval_EvalFrame(PyFrameObject *);
|
||||
PyAPI_FUNC(PyObject *) PyEval_EvalFrameEx(PyFrameObject *f, int exc);
|
||||
|
||||
/* Interface for threads.
|
||||
|
||||
A module that plans to do a blocking system call (or something else
|
||||
that lasts a long time and doesn't touch Python data) can allow other
|
||||
threads to run as follows:
|
||||
|
||||
...preparations here...
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
...blocking system call here...
|
||||
Py_END_ALLOW_THREADS
|
||||
...interpret result here...
|
||||
|
||||
The Py_BEGIN_ALLOW_THREADS/Py_END_ALLOW_THREADS pair expands to a
|
||||
{}-surrounded block.
|
||||
To leave the block in the middle (e.g., with return), you must insert
|
||||
a line containing Py_BLOCK_THREADS before the return, e.g.
|
||||
|
||||
if (...premature_exit...) {
|
||||
Py_BLOCK_THREADS
|
||||
PyErr_SetFromErrno(PyExc_OSError);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
An alternative is:
|
||||
|
||||
Py_BLOCK_THREADS
|
||||
if (...premature_exit...) {
|
||||
PyErr_SetFromErrno(PyExc_OSError);
|
||||
return NULL;
|
||||
}
|
||||
Py_UNBLOCK_THREADS
|
||||
|
||||
For convenience, that the value of 'errno' is restored across
|
||||
Py_END_ALLOW_THREADS and Py_BLOCK_THREADS.
|
||||
|
||||
WARNING: NEVER NEST CALLS TO Py_BEGIN_ALLOW_THREADS AND
|
||||
Py_END_ALLOW_THREADS!!!
|
||||
|
||||
Note that not yet all candidates have been converted to use this
|
||||
mechanism!
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(PyThreadState *) PyEval_SaveThread(void);
|
||||
PyAPI_FUNC(void) PyEval_RestoreThread(PyThreadState *);
|
||||
|
||||
Py_DEPRECATED(3.9) PyAPI_FUNC(int) PyEval_ThreadsInitialized(void);
|
||||
Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void);
|
||||
/* PyEval_AcquireLock() and PyEval_ReleaseLock() are part of stable ABI.
|
||||
* They will be removed from this header file in the future version.
|
||||
* But they will be remained in ABI until Python 4.0.
|
||||
*/
|
||||
Py_DEPRECATED(3.2) PyAPI_FUNC(void) PyEval_AcquireLock(void);
|
||||
Py_DEPRECATED(3.2) PyAPI_FUNC(void) PyEval_ReleaseLock(void);
|
||||
PyAPI_FUNC(void) PyEval_AcquireThread(PyThreadState *tstate);
|
||||
PyAPI_FUNC(void) PyEval_ReleaseThread(PyThreadState *tstate);
|
||||
|
||||
#define Py_BEGIN_ALLOW_THREADS { \
|
||||
PyThreadState *_save; \
|
||||
_save = PyEval_SaveThread();
|
||||
#define Py_BLOCK_THREADS PyEval_RestoreThread(_save);
|
||||
#define Py_UNBLOCK_THREADS _save = PyEval_SaveThread();
|
||||
#define Py_END_ALLOW_THREADS PyEval_RestoreThread(_save); \
|
||||
}
|
||||
|
||||
/* Masks and values used by FORMAT_VALUE opcode. */
|
||||
#define FVC_MASK 0x3
|
||||
#define FVC_NONE 0x0
|
||||
#define FVC_STR 0x1
|
||||
#define FVC_REPR 0x2
|
||||
#define FVC_ASCII 0x3
|
||||
#define FVS_MASK 0x4
|
||||
#define FVS_HAVE_SPEC 0x4
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
# define Py_CPYTHON_CEVAL_H
|
||||
# include "cpython/ceval.h"
|
||||
# undef Py_CPYTHON_CEVAL_H
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_CEVAL_H */
|
||||
248
crypto/shamirs_secret_sharing/include/codecs.h
Normal file
248
crypto/shamirs_secret_sharing/include/codecs.h
Normal file
@@ -0,0 +1,248 @@
|
||||
#ifndef Py_CODECREGISTRY_H
|
||||
#define Py_CODECREGISTRY_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
|
||||
Python Codec Registry and support functions
|
||||
|
||||
|
||||
Written by Marc-Andre Lemburg (mal@lemburg.com).
|
||||
|
||||
Copyright (c) Corporation for National Research Initiatives.
|
||||
|
||||
------------------------------------------------------------------------ */
|
||||
|
||||
/* Register a new codec search function.
|
||||
|
||||
As side effect, this tries to load the encodings package, if not
|
||||
yet done, to make sure that it is always first in the list of
|
||||
search functions.
|
||||
|
||||
The search_function's refcount is incremented by this function. */
|
||||
|
||||
PyAPI_FUNC(int) PyCodec_Register(
|
||||
PyObject *search_function
|
||||
);
|
||||
|
||||
/* Unregister a codec search function and clear the registry's cache.
|
||||
If the search function is not registered, do nothing.
|
||||
Return 0 on success. Raise an exception and return -1 on error. */
|
||||
|
||||
PyAPI_FUNC(int) PyCodec_Unregister(
|
||||
PyObject *search_function
|
||||
);
|
||||
|
||||
/* Codec registry lookup API.
|
||||
|
||||
Looks up the given encoding and returns a CodecInfo object with
|
||||
function attributes which implement the different aspects of
|
||||
processing the encoding.
|
||||
|
||||
The encoding string is looked up converted to all lower-case
|
||||
characters. This makes encodings looked up through this mechanism
|
||||
effectively case-insensitive.
|
||||
|
||||
If no codec is found, a KeyError is set and NULL returned.
|
||||
|
||||
As side effect, this tries to load the encodings package, if not
|
||||
yet done. This is part of the lazy load strategy for the encodings
|
||||
package.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) _PyCodec_Lookup(
|
||||
const char *encoding
|
||||
);
|
||||
|
||||
PyAPI_FUNC(int) _PyCodec_Forget(
|
||||
const char *encoding
|
||||
);
|
||||
#endif
|
||||
|
||||
/* Codec registry encoding check API.
|
||||
|
||||
Returns 1/0 depending on whether there is a registered codec for
|
||||
the given encoding.
|
||||
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(int) PyCodec_KnownEncoding(
|
||||
const char *encoding
|
||||
);
|
||||
|
||||
/* Generic codec based encoding API.
|
||||
|
||||
object is passed through the encoder function found for the given
|
||||
encoding using the error handling method defined by errors. errors
|
||||
may be NULL to use the default method defined for the codec.
|
||||
|
||||
Raises a LookupError in case no encoder can be found.
|
||||
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_Encode(
|
||||
PyObject *object,
|
||||
const char *encoding,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
/* Generic codec based decoding API.
|
||||
|
||||
object is passed through the decoder function found for the given
|
||||
encoding using the error handling method defined by errors. errors
|
||||
may be NULL to use the default method defined for the codec.
|
||||
|
||||
Raises a LookupError in case no encoder can be found.
|
||||
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_Decode(
|
||||
PyObject *object,
|
||||
const char *encoding,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
/* Text codec specific encoding and decoding API.
|
||||
|
||||
Checks the encoding against a list of codecs which do not
|
||||
implement a str<->bytes encoding before attempting the
|
||||
operation.
|
||||
|
||||
Please note that these APIs are internal and should not
|
||||
be used in Python C extensions.
|
||||
|
||||
XXX (ncoghlan): should we make these, or something like them, public
|
||||
in Python 3.5+?
|
||||
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) _PyCodec_LookupTextEncoding(
|
||||
const char *encoding,
|
||||
const char *alternate_command
|
||||
);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyCodec_EncodeText(
|
||||
PyObject *object,
|
||||
const char *encoding,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyCodec_DecodeText(
|
||||
PyObject *object,
|
||||
const char *encoding,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
/* These two aren't actually text encoding specific, but _io.TextIOWrapper
|
||||
* is the only current API consumer.
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) _PyCodecInfo_GetIncrementalDecoder(
|
||||
PyObject *codec_info,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyCodecInfo_GetIncrementalEncoder(
|
||||
PyObject *codec_info,
|
||||
const char *errors
|
||||
);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* --- Codec Lookup APIs --------------------------------------------------
|
||||
|
||||
All APIs return a codec object with incremented refcount and are
|
||||
based on _PyCodec_Lookup(). The same comments w/r to the encoding
|
||||
name also apply to these APIs.
|
||||
|
||||
*/
|
||||
|
||||
/* Get an encoder function for the given encoding. */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_Encoder(
|
||||
const char *encoding
|
||||
);
|
||||
|
||||
/* Get a decoder function for the given encoding. */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_Decoder(
|
||||
const char *encoding
|
||||
);
|
||||
|
||||
/* Get an IncrementalEncoder object for the given encoding. */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_IncrementalEncoder(
|
||||
const char *encoding,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
/* Get an IncrementalDecoder object function for the given encoding. */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_IncrementalDecoder(
|
||||
const char *encoding,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
/* Get a StreamReader factory function for the given encoding. */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_StreamReader(
|
||||
const char *encoding,
|
||||
PyObject *stream,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
/* Get a StreamWriter factory function for the given encoding. */
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCodec_StreamWriter(
|
||||
const char *encoding,
|
||||
PyObject *stream,
|
||||
const char *errors
|
||||
);
|
||||
|
||||
/* Unicode encoding error handling callback registry API */
|
||||
|
||||
/* Register the error handling callback function error under the given
|
||||
name. This function will be called by the codec when it encounters
|
||||
unencodable characters/undecodable bytes and doesn't know the
|
||||
callback name, when name is specified as the error parameter
|
||||
in the call to the encode/decode function.
|
||||
Return 0 on success, -1 on error */
|
||||
PyAPI_FUNC(int) PyCodec_RegisterError(const char *name, PyObject *error);
|
||||
|
||||
/* Lookup the error handling callback function registered under the given
|
||||
name. As a special case NULL can be passed, in which case
|
||||
the error handling callback for "strict" will be returned. */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_LookupError(const char *name);
|
||||
|
||||
/* raise exc as an exception */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_StrictErrors(PyObject *exc);
|
||||
|
||||
/* ignore the unicode error, skipping the faulty input */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_IgnoreErrors(PyObject *exc);
|
||||
|
||||
/* replace the unicode encode error with ? or U+FFFD */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_ReplaceErrors(PyObject *exc);
|
||||
|
||||
/* replace the unicode encode error with XML character references */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_XMLCharRefReplaceErrors(PyObject *exc);
|
||||
|
||||
/* replace the unicode encode error with backslash escapes (\x, \u and \U) */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_BackslashReplaceErrors(PyObject *exc);
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||
/* replace the unicode encode error with backslash escapes (\N, \x, \u and \U) */
|
||||
PyAPI_FUNC(PyObject *) PyCodec_NameReplaceErrors(PyObject *exc);
|
||||
#endif
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_DATA(const char *) Py_hexdigits;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_CODECREGISTRY_H */
|
||||
22
crypto/shamirs_secret_sharing/include/compile.h
Normal file
22
crypto/shamirs_secret_sharing/include/compile.h
Normal file
@@ -0,0 +1,22 @@
|
||||
#ifndef Py_COMPILE_H
|
||||
#define Py_COMPILE_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* These definitions must match corresponding definitions in graminit.h. */
|
||||
#define Py_single_input 256
|
||||
#define Py_file_input 257
|
||||
#define Py_eval_input 258
|
||||
#define Py_func_type_input 345
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
# define Py_CPYTHON_COMPILE_H
|
||||
# include "cpython/compile.h"
|
||||
# undef Py_CPYTHON_COMPILE_H
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_COMPILE_H */
|
||||
30
crypto/shamirs_secret_sharing/include/complexobject.h
Normal file
30
crypto/shamirs_secret_sharing/include/complexobject.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/* Complex number structure */
|
||||
|
||||
#ifndef Py_COMPLEXOBJECT_H
|
||||
#define Py_COMPLEXOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Complex object interface */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyComplex_Type;
|
||||
|
||||
#define PyComplex_Check(op) PyObject_TypeCheck((op), &PyComplex_Type)
|
||||
#define PyComplex_CheckExact(op) Py_IS_TYPE((op), &PyComplex_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyComplex_FromDoubles(double real, double imag);
|
||||
|
||||
PyAPI_FUNC(double) PyComplex_RealAsDouble(PyObject *op);
|
||||
PyAPI_FUNC(double) PyComplex_ImagAsDouble(PyObject *op);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
# define Py_CPYTHON_COMPLEXOBJECT_H
|
||||
# include "cpython/complexobject.h"
|
||||
# undef Py_CPYTHON_COMPLEXOBJECT_H
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_COMPLEXOBJECT_H */
|
||||
206
crypto/shamirs_secret_sharing/include/cpython/abstract.h
Normal file
206
crypto/shamirs_secret_sharing/include/cpython/abstract.h
Normal file
@@ -0,0 +1,206 @@
|
||||
#ifndef Py_CPYTHON_ABSTRACTOBJECT_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
/* === Object Protocol ================================================== */
|
||||
|
||||
#ifdef PY_SSIZE_T_CLEAN
|
||||
# define _PyObject_CallMethodId _PyObject_CallMethodId_SizeT
|
||||
#endif
|
||||
|
||||
/* Convert keyword arguments from the FASTCALL (stack: C array, kwnames: tuple)
|
||||
format to a Python dictionary ("kwargs" dict).
|
||||
|
||||
The type of kwnames keys is not checked. The final function getting
|
||||
arguments is responsible to check if all keys are strings, for example using
|
||||
PyArg_ParseTupleAndKeywords() or PyArg_ValidateKeywordArguments().
|
||||
|
||||
Duplicate keys are merged using the last value. If duplicate keys must raise
|
||||
an exception, the caller is responsible to implement an explicit keys on
|
||||
kwnames. */
|
||||
PyAPI_FUNC(PyObject *) _PyStack_AsDict(
|
||||
PyObject *const *values,
|
||||
PyObject *kwnames);
|
||||
|
||||
/* Suggested size (number of positional arguments) for arrays of PyObject*
|
||||
allocated on a C stack to avoid allocating memory on the heap memory. Such
|
||||
array is used to pass positional arguments to call functions of the
|
||||
PyObject_Vectorcall() family.
|
||||
|
||||
The size is chosen to not abuse the C stack and so limit the risk of stack
|
||||
overflow. The size is also chosen to allow using the small stack for most
|
||||
function calls of the Python standard library. On 64-bit CPU, it allocates
|
||||
40 bytes on the stack. */
|
||||
#define _PY_FASTCALL_SMALL_STACK 5
|
||||
|
||||
PyAPI_FUNC(PyObject *) _Py_CheckFunctionResult(
|
||||
PyThreadState *tstate,
|
||||
PyObject *callable,
|
||||
PyObject *result,
|
||||
const char *where);
|
||||
|
||||
/* === Vectorcall protocol (PEP 590) ============================= */
|
||||
|
||||
/* Call callable using tp_call. Arguments are like PyObject_Vectorcall()
|
||||
or PyObject_FastCallDict() (both forms are supported),
|
||||
except that nargs is plainly the number of arguments without flags. */
|
||||
PyAPI_FUNC(PyObject *) _PyObject_MakeTpCall(
|
||||
PyThreadState *tstate,
|
||||
PyObject *callable,
|
||||
PyObject *const *args, Py_ssize_t nargs,
|
||||
PyObject *keywords);
|
||||
|
||||
// PyVectorcall_NARGS() is exported as a function for the stable ABI.
|
||||
// Here (when we are not using the stable ABI), the name is overridden to
|
||||
// call a static inline function for best performance.
|
||||
#define PyVectorcall_NARGS(n) _PyVectorcall_NARGS(n)
|
||||
static inline Py_ssize_t
|
||||
_PyVectorcall_NARGS(size_t n)
|
||||
{
|
||||
return n & ~PY_VECTORCALL_ARGUMENTS_OFFSET;
|
||||
}
|
||||
|
||||
PyAPI_FUNC(vectorcallfunc) PyVectorcall_Function(PyObject *callable);
|
||||
|
||||
// Backwards compatibility aliases for API that was provisional in Python 3.8
|
||||
#define _PyObject_Vectorcall PyObject_Vectorcall
|
||||
#define _PyObject_VectorcallMethod PyObject_VectorcallMethod
|
||||
#define _PyObject_FastCallDict PyObject_VectorcallDict
|
||||
#define _PyVectorcall_Function PyVectorcall_Function
|
||||
#define _PyObject_CallOneArg PyObject_CallOneArg
|
||||
#define _PyObject_CallMethodNoArgs PyObject_CallMethodNoArgs
|
||||
#define _PyObject_CallMethodOneArg PyObject_CallMethodOneArg
|
||||
|
||||
/* Same as PyObject_Vectorcall except that keyword arguments are passed as
|
||||
dict, which may be NULL if there are no keyword arguments. */
|
||||
PyAPI_FUNC(PyObject *) PyObject_VectorcallDict(
|
||||
PyObject *callable,
|
||||
PyObject *const *args,
|
||||
size_t nargsf,
|
||||
PyObject *kwargs);
|
||||
|
||||
// Same as PyObject_Vectorcall(), except without keyword arguments
|
||||
PyAPI_FUNC(PyObject *) _PyObject_FastCall(
|
||||
PyObject *func,
|
||||
PyObject *const *args,
|
||||
Py_ssize_t nargs);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyObject_CallOneArg(PyObject *func, PyObject *arg);
|
||||
|
||||
static inline PyObject *
|
||||
PyObject_CallMethodNoArgs(PyObject *self, PyObject *name)
|
||||
{
|
||||
size_t nargsf = 1 | PY_VECTORCALL_ARGUMENTS_OFFSET;
|
||||
return PyObject_VectorcallMethod(name, &self, nargsf, _Py_NULL);
|
||||
}
|
||||
|
||||
static inline PyObject *
|
||||
PyObject_CallMethodOneArg(PyObject *self, PyObject *name, PyObject *arg)
|
||||
{
|
||||
PyObject *args[2] = {self, arg};
|
||||
size_t nargsf = 2 | PY_VECTORCALL_ARGUMENTS_OFFSET;
|
||||
assert(arg != NULL);
|
||||
return PyObject_VectorcallMethod(name, args, nargsf, _Py_NULL);
|
||||
}
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyObject_CallMethod(PyObject *obj,
|
||||
PyObject *name,
|
||||
const char *format, ...);
|
||||
|
||||
/* Like PyObject_CallMethod(), but expect a _Py_Identifier*
|
||||
as the method name. */
|
||||
PyAPI_FUNC(PyObject *) _PyObject_CallMethodId(PyObject *obj,
|
||||
_Py_Identifier *name,
|
||||
const char *format, ...);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyObject_CallMethodId_SizeT(PyObject *obj,
|
||||
_Py_Identifier *name,
|
||||
const char *format,
|
||||
...);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyObject_CallMethodIdObjArgs(
|
||||
PyObject *obj,
|
||||
_Py_Identifier *name,
|
||||
...);
|
||||
|
||||
static inline PyObject *
|
||||
_PyObject_VectorcallMethodId(
|
||||
_Py_Identifier *name, PyObject *const *args,
|
||||
size_t nargsf, PyObject *kwnames)
|
||||
{
|
||||
PyObject *oname = _PyUnicode_FromId(name); /* borrowed */
|
||||
if (!oname) {
|
||||
return _Py_NULL;
|
||||
}
|
||||
return PyObject_VectorcallMethod(oname, args, nargsf, kwnames);
|
||||
}
|
||||
|
||||
static inline PyObject *
|
||||
_PyObject_CallMethodIdNoArgs(PyObject *self, _Py_Identifier *name)
|
||||
{
|
||||
size_t nargsf = 1 | PY_VECTORCALL_ARGUMENTS_OFFSET;
|
||||
return _PyObject_VectorcallMethodId(name, &self, nargsf, _Py_NULL);
|
||||
}
|
||||
|
||||
static inline PyObject *
|
||||
_PyObject_CallMethodIdOneArg(PyObject *self, _Py_Identifier *name, PyObject *arg)
|
||||
{
|
||||
PyObject *args[2] = {self, arg};
|
||||
size_t nargsf = 2 | PY_VECTORCALL_ARGUMENTS_OFFSET;
|
||||
assert(arg != NULL);
|
||||
return _PyObject_VectorcallMethodId(name, args, nargsf, _Py_NULL);
|
||||
}
|
||||
|
||||
PyAPI_FUNC(int) _PyObject_HasLen(PyObject *o);
|
||||
|
||||
/* Guess the size of object 'o' using len(o) or o.__length_hint__().
|
||||
If neither of those return a non-negative value, then return the default
|
||||
value. If one of the calls fails, this function returns -1. */
|
||||
PyAPI_FUNC(Py_ssize_t) PyObject_LengthHint(PyObject *o, Py_ssize_t);
|
||||
|
||||
/* === Sequence protocol ================================================ */
|
||||
|
||||
/* Assume tp_as_sequence and sq_item exist and that 'i' does not
|
||||
need to be corrected for a negative index. */
|
||||
#define PySequence_ITEM(o, i)\
|
||||
( Py_TYPE(o)->tp_as_sequence->sq_item((o), (i)) )
|
||||
|
||||
#define PY_ITERSEARCH_COUNT 1
|
||||
#define PY_ITERSEARCH_INDEX 2
|
||||
#define PY_ITERSEARCH_CONTAINS 3
|
||||
|
||||
/* Iterate over seq.
|
||||
|
||||
Result depends on the operation:
|
||||
|
||||
PY_ITERSEARCH_COUNT: return # of times obj appears in seq; -1 if
|
||||
error.
|
||||
PY_ITERSEARCH_INDEX: return 0-based index of first occurrence of
|
||||
obj in seq; set ValueError and return -1 if none found;
|
||||
also return -1 on error.
|
||||
PY_ITERSEARCH_CONTAINS: return 1 if obj in seq, else 0; -1 on
|
||||
error. */
|
||||
PyAPI_FUNC(Py_ssize_t) _PySequence_IterSearch(PyObject *seq,
|
||||
PyObject *obj, int operation);
|
||||
|
||||
/* === Mapping protocol ================================================= */
|
||||
|
||||
PyAPI_FUNC(int) _PyObject_RealIsInstance(PyObject *inst, PyObject *cls);
|
||||
|
||||
PyAPI_FUNC(int) _PyObject_RealIsSubclass(PyObject *derived, PyObject *cls);
|
||||
|
||||
PyAPI_FUNC(char *const *) _PySequence_BytesToCharpArray(PyObject* self);
|
||||
|
||||
PyAPI_FUNC(void) _Py_FreeCharPArray(char *const array[]);
|
||||
|
||||
/* For internal use by buffer API functions */
|
||||
PyAPI_FUNC(void) _Py_add_one_to_index_F(int nd, Py_ssize_t *index,
|
||||
const Py_ssize_t *shape);
|
||||
PyAPI_FUNC(void) _Py_add_one_to_index_C(int nd, Py_ssize_t *index,
|
||||
const Py_ssize_t *shape);
|
||||
|
||||
/* Convert Python int to Py_ssize_t. Do nothing if the argument is None. */
|
||||
PyAPI_FUNC(int) _Py_convert_optional_to_ssize_t(PyObject *, void *);
|
||||
|
||||
/* Same as PyNumber_Index but can return an instance of a subclass of int. */
|
||||
PyAPI_FUNC(PyObject *) _PyNumber_Index(PyObject *o);
|
||||
@@ -0,0 +1,34 @@
|
||||
#ifndef Py_CPYTHON_BYTEARRAYOBJECT_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
/* Object layout */
|
||||
typedef struct {
|
||||
PyObject_VAR_HEAD
|
||||
Py_ssize_t ob_alloc; /* How many bytes allocated in ob_bytes */
|
||||
char *ob_bytes; /* Physical backing buffer */
|
||||
char *ob_start; /* Logical start inside ob_bytes */
|
||||
Py_ssize_t ob_exports; /* How many buffer exports */
|
||||
} PyByteArrayObject;
|
||||
|
||||
PyAPI_DATA(char) _PyByteArray_empty_string[];
|
||||
|
||||
/* Macros and static inline functions, trading safety for speed */
|
||||
#define _PyByteArray_CAST(op) \
|
||||
(assert(PyByteArray_Check(op)), _Py_CAST(PyByteArrayObject*, op))
|
||||
|
||||
static inline char* PyByteArray_AS_STRING(PyObject *op)
|
||||
{
|
||||
PyByteArrayObject *self = _PyByteArray_CAST(op);
|
||||
if (Py_SIZE(self)) {
|
||||
return self->ob_start;
|
||||
}
|
||||
return _PyByteArray_empty_string;
|
||||
}
|
||||
#define PyByteArray_AS_STRING(self) PyByteArray_AS_STRING(_PyObject_CAST(self))
|
||||
|
||||
static inline Py_ssize_t PyByteArray_GET_SIZE(PyObject *op) {
|
||||
PyByteArrayObject *self = _PyByteArray_CAST(op);
|
||||
return Py_SIZE(self);
|
||||
}
|
||||
#define PyByteArray_GET_SIZE(self) PyByteArray_GET_SIZE(_PyObject_CAST(self))
|
||||
129
crypto/shamirs_secret_sharing/include/cpython/bytesobject.h
Normal file
129
crypto/shamirs_secret_sharing/include/cpython/bytesobject.h
Normal file
@@ -0,0 +1,129 @@
|
||||
#ifndef Py_CPYTHON_BYTESOBJECT_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
PyObject_VAR_HEAD
|
||||
Py_DEPRECATED(3.11) Py_hash_t ob_shash;
|
||||
char ob_sval[1];
|
||||
|
||||
/* Invariants:
|
||||
* ob_sval contains space for 'ob_size+1' elements.
|
||||
* ob_sval[ob_size] == 0.
|
||||
* ob_shash is the hash of the byte string or -1 if not computed yet.
|
||||
*/
|
||||
} PyBytesObject;
|
||||
|
||||
PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, Py_ssize_t);
|
||||
PyAPI_FUNC(PyObject*) _PyBytes_FormatEx(
|
||||
const char *format,
|
||||
Py_ssize_t format_len,
|
||||
PyObject *args,
|
||||
int use_bytearray);
|
||||
PyAPI_FUNC(PyObject*) _PyBytes_FromHex(
|
||||
PyObject *string,
|
||||
int use_bytearray);
|
||||
|
||||
/* Helper for PyBytes_DecodeEscape that detects invalid escape chars. */
|
||||
PyAPI_FUNC(PyObject *) _PyBytes_DecodeEscape(const char *, Py_ssize_t,
|
||||
const char *, const char **);
|
||||
|
||||
/* Macros and static inline functions, trading safety for speed */
|
||||
#define _PyBytes_CAST(op) \
|
||||
(assert(PyBytes_Check(op)), _Py_CAST(PyBytesObject*, op))
|
||||
|
||||
static inline char* PyBytes_AS_STRING(PyObject *op)
|
||||
{
|
||||
return _PyBytes_CAST(op)->ob_sval;
|
||||
}
|
||||
#define PyBytes_AS_STRING(op) PyBytes_AS_STRING(_PyObject_CAST(op))
|
||||
|
||||
static inline Py_ssize_t PyBytes_GET_SIZE(PyObject *op) {
|
||||
PyBytesObject *self = _PyBytes_CAST(op);
|
||||
return Py_SIZE(self);
|
||||
}
|
||||
#define PyBytes_GET_SIZE(self) PyBytes_GET_SIZE(_PyObject_CAST(self))
|
||||
|
||||
/* _PyBytes_Join(sep, x) is like sep.join(x). sep must be PyBytesObject*,
|
||||
x must be an iterable object. */
|
||||
PyAPI_FUNC(PyObject *) _PyBytes_Join(PyObject *sep, PyObject *x);
|
||||
|
||||
|
||||
/* The _PyBytesWriter structure is big: it contains an embedded "stack buffer".
|
||||
A _PyBytesWriter variable must be declared at the end of variables in a
|
||||
function to optimize the memory allocation on the stack. */
|
||||
typedef struct {
|
||||
/* bytes, bytearray or NULL (when the small buffer is used) */
|
||||
PyObject *buffer;
|
||||
|
||||
/* Number of allocated size. */
|
||||
Py_ssize_t allocated;
|
||||
|
||||
/* Minimum number of allocated bytes,
|
||||
incremented by _PyBytesWriter_Prepare() */
|
||||
Py_ssize_t min_size;
|
||||
|
||||
/* If non-zero, use a bytearray instead of a bytes object for buffer. */
|
||||
int use_bytearray;
|
||||
|
||||
/* If non-zero, overallocate the buffer (default: 0).
|
||||
This flag must be zero if use_bytearray is non-zero. */
|
||||
int overallocate;
|
||||
|
||||
/* Stack buffer */
|
||||
int use_small_buffer;
|
||||
char small_buffer[512];
|
||||
} _PyBytesWriter;
|
||||
|
||||
/* Initialize a bytes writer
|
||||
|
||||
By default, the overallocation is disabled. Set the overallocate attribute
|
||||
to control the allocation of the buffer. */
|
||||
PyAPI_FUNC(void) _PyBytesWriter_Init(_PyBytesWriter *writer);
|
||||
|
||||
/* Get the buffer content and reset the writer.
|
||||
Return a bytes object, or a bytearray object if use_bytearray is non-zero.
|
||||
Raise an exception and return NULL on error. */
|
||||
PyAPI_FUNC(PyObject *) _PyBytesWriter_Finish(_PyBytesWriter *writer,
|
||||
void *str);
|
||||
|
||||
/* Deallocate memory of a writer (clear its internal buffer). */
|
||||
PyAPI_FUNC(void) _PyBytesWriter_Dealloc(_PyBytesWriter *writer);
|
||||
|
||||
/* Allocate the buffer to write size bytes.
|
||||
Return the pointer to the beginning of buffer data.
|
||||
Raise an exception and return NULL on error. */
|
||||
PyAPI_FUNC(void*) _PyBytesWriter_Alloc(_PyBytesWriter *writer,
|
||||
Py_ssize_t size);
|
||||
|
||||
/* Ensure that the buffer is large enough to write *size* bytes.
|
||||
Add size to the writer minimum size (min_size attribute).
|
||||
|
||||
str is the current pointer inside the buffer.
|
||||
Return the updated current pointer inside the buffer.
|
||||
Raise an exception and return NULL on error. */
|
||||
PyAPI_FUNC(void*) _PyBytesWriter_Prepare(_PyBytesWriter *writer,
|
||||
void *str,
|
||||
Py_ssize_t size);
|
||||
|
||||
/* Resize the buffer to make it larger.
|
||||
The new buffer may be larger than size bytes because of overallocation.
|
||||
Return the updated current pointer inside the buffer.
|
||||
Raise an exception and return NULL on error.
|
||||
|
||||
Note: size must be greater than the number of allocated bytes in the writer.
|
||||
|
||||
This function doesn't use the writer minimum size (min_size attribute).
|
||||
|
||||
See also _PyBytesWriter_Prepare().
|
||||
*/
|
||||
PyAPI_FUNC(void*) _PyBytesWriter_Resize(_PyBytesWriter *writer,
|
||||
void *str,
|
||||
Py_ssize_t size);
|
||||
|
||||
/* Write bytes.
|
||||
Raise an exception and return NULL on error. */
|
||||
PyAPI_FUNC(void*) _PyBytesWriter_WriteBytes(_PyBytesWriter *writer,
|
||||
void *str,
|
||||
const void *bytes,
|
||||
Py_ssize_t size);
|
||||
44
crypto/shamirs_secret_sharing/include/cpython/cellobject.h
Normal file
44
crypto/shamirs_secret_sharing/include/cpython/cellobject.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/* Cell object interface */
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
#ifndef Py_CELLOBJECT_H
|
||||
#define Py_CELLOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
/* Content of the cell or NULL when empty */
|
||||
PyObject *ob_ref;
|
||||
} PyCellObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyCell_Type;
|
||||
|
||||
#define PyCell_Check(op) Py_IS_TYPE((op), &PyCell_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCell_New(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyCell_Get(PyObject *);
|
||||
PyAPI_FUNC(int) PyCell_Set(PyObject *, PyObject *);
|
||||
|
||||
static inline PyObject* PyCell_GET(PyObject *op) {
|
||||
PyCellObject *cell;
|
||||
assert(PyCell_Check(op));
|
||||
cell = _Py_CAST(PyCellObject*, op);
|
||||
return cell->ob_ref;
|
||||
}
|
||||
#define PyCell_GET(op) PyCell_GET(_PyObject_CAST(op))
|
||||
|
||||
static inline void PyCell_SET(PyObject *op, PyObject *value) {
|
||||
PyCellObject *cell;
|
||||
assert(PyCell_Check(op));
|
||||
cell = _Py_CAST(PyCellObject*, op);
|
||||
cell->ob_ref = value;
|
||||
}
|
||||
#define PyCell_SET(op, value) PyCell_SET(_PyObject_CAST(op), (value))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_TUPLEOBJECT_H */
|
||||
#endif /* Py_LIMITED_API */
|
||||
35
crypto/shamirs_secret_sharing/include/cpython/ceval.h
Normal file
35
crypto/shamirs_secret_sharing/include/cpython/ceval.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef Py_CPYTHON_CEVAL_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
|
||||
PyAPI_FUNC(void) PyEval_SetProfileAllThreads(Py_tracefunc, PyObject *);
|
||||
PyAPI_DATA(int) _PyEval_SetProfile(PyThreadState *tstate, Py_tracefunc func, PyObject *arg);
|
||||
PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
|
||||
PyAPI_FUNC(void) PyEval_SetTraceAllThreads(Py_tracefunc, PyObject *);
|
||||
PyAPI_FUNC(int) _PyEval_SetTrace(PyThreadState *tstate, Py_tracefunc func, PyObject *arg);
|
||||
|
||||
/* Helper to look up a builtin object */
|
||||
PyAPI_FUNC(PyObject *) _PyEval_GetBuiltin(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) _PyEval_GetBuiltinId(_Py_Identifier *);
|
||||
/* Look at the current frame's (if any) code's co_flags, and turn on
|
||||
the corresponding compiler flags in cf->cf_flags. Return 1 if any
|
||||
flag was set, else return 0. */
|
||||
PyAPI_FUNC(int) PyEval_MergeCompilerFlags(PyCompilerFlags *cf);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyEval_EvalFrameDefault(PyThreadState *tstate, struct _PyInterpreterFrame *f, int exc);
|
||||
|
||||
PyAPI_FUNC(void) _PyEval_SetSwitchInterval(unsigned long microseconds);
|
||||
PyAPI_FUNC(unsigned long) _PyEval_GetSwitchInterval(void);
|
||||
|
||||
PyAPI_FUNC(int) _PyEval_MakePendingCalls(PyThreadState *);
|
||||
|
||||
PyAPI_FUNC(Py_ssize_t) PyUnstable_Eval_RequestCodeExtraIndex(freefunc);
|
||||
// Old name -- remove when this API changes:
|
||||
_Py_DEPRECATED_EXTERNALLY(3.12) static inline Py_ssize_t
|
||||
_PyEval_RequestCodeExtraIndex(freefunc f) {
|
||||
return PyUnstable_Eval_RequestCodeExtraIndex(f);
|
||||
}
|
||||
|
||||
PyAPI_FUNC(int) _PyEval_SliceIndex(PyObject *, Py_ssize_t *);
|
||||
PyAPI_FUNC(int) _PyEval_SliceIndexNotNone(PyObject *, Py_ssize_t *);
|
||||
71
crypto/shamirs_secret_sharing/include/cpython/classobject.h
Normal file
71
crypto/shamirs_secret_sharing/include/cpython/classobject.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/* Former class object interface -- now only bound methods are here */
|
||||
|
||||
/* Revealing some structures (not for general use) */
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
#ifndef Py_CLASSOBJECT_H
|
||||
#define Py_CLASSOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyObject *im_func; /* The callable object implementing the method */
|
||||
PyObject *im_self; /* The instance it is bound to */
|
||||
PyObject *im_weakreflist; /* List of weak references */
|
||||
vectorcallfunc vectorcall;
|
||||
} PyMethodObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyMethod_Type;
|
||||
|
||||
#define PyMethod_Check(op) Py_IS_TYPE((op), &PyMethod_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *);
|
||||
|
||||
#define _PyMethod_CAST(meth) \
|
||||
(assert(PyMethod_Check(meth)), _Py_CAST(PyMethodObject*, meth))
|
||||
|
||||
/* Static inline functions for direct access to these values.
|
||||
Type checks are *not* done, so use with care. */
|
||||
static inline PyObject* PyMethod_GET_FUNCTION(PyObject *meth) {
|
||||
return _PyMethod_CAST(meth)->im_func;
|
||||
}
|
||||
#define PyMethod_GET_FUNCTION(meth) PyMethod_GET_FUNCTION(_PyObject_CAST(meth))
|
||||
|
||||
static inline PyObject* PyMethod_GET_SELF(PyObject *meth) {
|
||||
return _PyMethod_CAST(meth)->im_self;
|
||||
}
|
||||
#define PyMethod_GET_SELF(meth) PyMethod_GET_SELF(_PyObject_CAST(meth))
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyObject *func;
|
||||
} PyInstanceMethodObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyInstanceMethod_Type;
|
||||
|
||||
#define PyInstanceMethod_Check(op) Py_IS_TYPE((op), &PyInstanceMethod_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyInstanceMethod_New(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyInstanceMethod_Function(PyObject *);
|
||||
|
||||
#define _PyInstanceMethod_CAST(meth) \
|
||||
(assert(PyInstanceMethod_Check(meth)), \
|
||||
_Py_CAST(PyInstanceMethodObject*, meth))
|
||||
|
||||
/* Static inline function for direct access to these values.
|
||||
Type checks are *not* done, so use with care. */
|
||||
static inline PyObject* PyInstanceMethod_GET_FUNCTION(PyObject *meth) {
|
||||
return _PyInstanceMethod_CAST(meth)->func;
|
||||
}
|
||||
#define PyInstanceMethod_GET_FUNCTION(meth) PyInstanceMethod_GET_FUNCTION(_PyObject_CAST(meth))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // !Py_CLASSOBJECT_H
|
||||
#endif // !Py_LIMITED_API
|
||||
389
crypto/shamirs_secret_sharing/include/cpython/code.h
Normal file
389
crypto/shamirs_secret_sharing/include/cpython/code.h
Normal file
@@ -0,0 +1,389 @@
|
||||
/* Definitions for bytecode */
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
#ifndef Py_CODE_H
|
||||
#define Py_CODE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Count of all local monitoring events */
|
||||
#define _PY_MONITORING_LOCAL_EVENTS 10
|
||||
/* Count of all "real" monitoring events (not derived from other events) */
|
||||
#define _PY_MONITORING_UNGROUPED_EVENTS 15
|
||||
/* Count of all monitoring events */
|
||||
#define _PY_MONITORING_EVENTS 17
|
||||
|
||||
/* Tables of which tools are active for each monitored event. */
|
||||
/* For 3.12 ABI compatibility this is over sized */
|
||||
typedef struct _Py_LocalMonitors {
|
||||
/* Only _PY_MONITORING_LOCAL_EVENTS of these are used */
|
||||
uint8_t tools[_PY_MONITORING_UNGROUPED_EVENTS];
|
||||
} _Py_LocalMonitors;
|
||||
|
||||
typedef struct _Py_GlobalMonitors {
|
||||
uint8_t tools[_PY_MONITORING_UNGROUPED_EVENTS];
|
||||
} _Py_GlobalMonitors;
|
||||
|
||||
/* Each instruction in a code object is a fixed-width value,
|
||||
* currently 2 bytes: 1-byte opcode + 1-byte oparg. The EXTENDED_ARG
|
||||
* opcode allows for larger values but the current limit is 3 uses
|
||||
* of EXTENDED_ARG (see Python/compile.c), for a maximum
|
||||
* 32-bit value. This aligns with the note in Python/compile.c
|
||||
* (compiler_addop_i_line) indicating that the max oparg value is
|
||||
* 2**32 - 1, rather than INT_MAX.
|
||||
*/
|
||||
|
||||
typedef union {
|
||||
uint16_t cache;
|
||||
struct {
|
||||
uint8_t code;
|
||||
uint8_t arg;
|
||||
} op;
|
||||
} _Py_CODEUNIT;
|
||||
|
||||
|
||||
/* These macros only remain defined for compatibility. */
|
||||
#define _Py_OPCODE(word) ((word).op.code)
|
||||
#define _Py_OPARG(word) ((word).op.arg)
|
||||
|
||||
static inline _Py_CODEUNIT
|
||||
_py_make_codeunit(uint8_t opcode, uint8_t oparg)
|
||||
{
|
||||
// No designated initialisers because of C++ compat
|
||||
_Py_CODEUNIT word;
|
||||
word.op.code = opcode;
|
||||
word.op.arg = oparg;
|
||||
return word;
|
||||
}
|
||||
|
||||
static inline void
|
||||
_py_set_opcode(_Py_CODEUNIT *word, uint8_t opcode)
|
||||
{
|
||||
word->op.code = opcode;
|
||||
}
|
||||
|
||||
#define _Py_MAKE_CODEUNIT(opcode, oparg) _py_make_codeunit((opcode), (oparg))
|
||||
#define _Py_SET_OPCODE(word, opcode) _py_set_opcode(&(word), (opcode))
|
||||
|
||||
|
||||
typedef struct {
|
||||
PyObject *_co_code;
|
||||
PyObject *_co_varnames;
|
||||
PyObject *_co_cellvars;
|
||||
PyObject *_co_freevars;
|
||||
} _PyCoCached;
|
||||
|
||||
/* Ancillary data structure used for instrumentation.
|
||||
Line instrumentation creates an array of
|
||||
these. One entry per code unit.*/
|
||||
typedef struct {
|
||||
uint8_t original_opcode;
|
||||
int8_t line_delta;
|
||||
} _PyCoLineInstrumentationData;
|
||||
|
||||
/* Main data structure used for instrumentation.
|
||||
* This is allocated when needed for instrumentation
|
||||
*/
|
||||
typedef struct {
|
||||
/* Monitoring specific to this code object */
|
||||
_Py_LocalMonitors local_monitors;
|
||||
/* Monitoring that is active on this code object */
|
||||
_Py_LocalMonitors active_monitors;
|
||||
/* The tools that are to be notified for events for the matching code unit */
|
||||
uint8_t *tools;
|
||||
/* Information to support line events */
|
||||
_PyCoLineInstrumentationData *lines;
|
||||
/* The tools that are to be notified for line events for the matching code unit */
|
||||
uint8_t *line_tools;
|
||||
/* Information to support instruction events */
|
||||
/* The underlying instructions, which can themselves be instrumented */
|
||||
uint8_t *per_instruction_opcodes;
|
||||
/* The tools that are to be notified for instruction events for the matching code unit */
|
||||
uint8_t *per_instruction_tools;
|
||||
} _PyCoMonitoringData;
|
||||
|
||||
// To avoid repeating ourselves in deepfreeze.py, all PyCodeObject members are
|
||||
// defined in this macro:
|
||||
#define _PyCode_DEF(SIZE) { \
|
||||
PyObject_VAR_HEAD \
|
||||
\
|
||||
/* Note only the following fields are used in hash and/or comparisons \
|
||||
* \
|
||||
* - co_name \
|
||||
* - co_argcount \
|
||||
* - co_posonlyargcount \
|
||||
* - co_kwonlyargcount \
|
||||
* - co_nlocals \
|
||||
* - co_stacksize \
|
||||
* - co_flags \
|
||||
* - co_firstlineno \
|
||||
* - co_consts \
|
||||
* - co_names \
|
||||
* - co_localsplusnames \
|
||||
* This is done to preserve the name and line number for tracebacks \
|
||||
* and debuggers; otherwise, constant de-duplication would collapse \
|
||||
* identical functions/lambdas defined on different lines. \
|
||||
*/ \
|
||||
\
|
||||
/* These fields are set with provided values on new code objects. */ \
|
||||
\
|
||||
/* The hottest fields (in the eval loop) are grouped here at the top. */ \
|
||||
PyObject *co_consts; /* list (constants used) */ \
|
||||
PyObject *co_names; /* list of strings (names used) */ \
|
||||
PyObject *co_exceptiontable; /* Byte string encoding exception handling \
|
||||
table */ \
|
||||
int co_flags; /* CO_..., see below */ \
|
||||
\
|
||||
/* The rest are not so impactful on performance. */ \
|
||||
int co_argcount; /* #arguments, except *args */ \
|
||||
int co_posonlyargcount; /* #positional only arguments */ \
|
||||
int co_kwonlyargcount; /* #keyword only arguments */ \
|
||||
int co_stacksize; /* #entries needed for evaluation stack */ \
|
||||
int co_firstlineno; /* first source line number */ \
|
||||
\
|
||||
/* redundant values (derived from co_localsplusnames and \
|
||||
co_localspluskinds) */ \
|
||||
int co_nlocalsplus; /* number of local + cell + free variables */ \
|
||||
int co_framesize; /* Size of frame in words */ \
|
||||
int co_nlocals; /* number of local variables */ \
|
||||
int co_ncellvars; /* total number of cell variables */ \
|
||||
int co_nfreevars; /* number of free variables */ \
|
||||
uint32_t co_version; /* version number */ \
|
||||
\
|
||||
PyObject *co_localsplusnames; /* tuple mapping offsets to names */ \
|
||||
PyObject *co_localspluskinds; /* Bytes mapping to local kinds (one byte \
|
||||
per variable) */ \
|
||||
PyObject *co_filename; /* unicode (where it was loaded from) */ \
|
||||
PyObject *co_name; /* unicode (name, for reference) */ \
|
||||
PyObject *co_qualname; /* unicode (qualname, for reference) */ \
|
||||
PyObject *co_linetable; /* bytes object that holds location info */ \
|
||||
PyObject *co_weakreflist; /* to support weakrefs to code objects */ \
|
||||
_PyCoCached *_co_cached; /* cached co_* attributes */ \
|
||||
uint64_t _co_instrumentation_version; /* current instrumentation version */ \
|
||||
_PyCoMonitoringData *_co_monitoring; /* Monitoring data */ \
|
||||
int _co_firsttraceable; /* index of first traceable instruction */ \
|
||||
/* Scratch space for extra data relating to the code object. \
|
||||
Type is a void* to keep the format private in codeobject.c to force \
|
||||
people to go through the proper APIs. */ \
|
||||
void *co_extra; \
|
||||
char co_code_adaptive[(SIZE)]; \
|
||||
}
|
||||
|
||||
/* Bytecode object */
|
||||
struct PyCodeObject _PyCode_DEF(1);
|
||||
|
||||
/* Masks for co_flags above */
|
||||
#define CO_OPTIMIZED 0x0001
|
||||
#define CO_NEWLOCALS 0x0002
|
||||
#define CO_VARARGS 0x0004
|
||||
#define CO_VARKEYWORDS 0x0008
|
||||
#define CO_NESTED 0x0010
|
||||
#define CO_GENERATOR 0x0020
|
||||
|
||||
/* The CO_COROUTINE flag is set for coroutine functions (defined with
|
||||
``async def`` keywords) */
|
||||
#define CO_COROUTINE 0x0080
|
||||
#define CO_ITERABLE_COROUTINE 0x0100
|
||||
#define CO_ASYNC_GENERATOR 0x0200
|
||||
|
||||
/* bpo-39562: These constant values are changed in Python 3.9
|
||||
to prevent collision with compiler flags. CO_FUTURE_ and PyCF_
|
||||
constants must be kept unique. PyCF_ constants can use bits from
|
||||
0x0100 to 0x10000. CO_FUTURE_ constants use bits starting at 0x20000. */
|
||||
#define CO_FUTURE_DIVISION 0x20000
|
||||
#define CO_FUTURE_ABSOLUTE_IMPORT 0x40000 /* do absolute imports by default */
|
||||
#define CO_FUTURE_WITH_STATEMENT 0x80000
|
||||
#define CO_FUTURE_PRINT_FUNCTION 0x100000
|
||||
#define CO_FUTURE_UNICODE_LITERALS 0x200000
|
||||
|
||||
#define CO_FUTURE_BARRY_AS_BDFL 0x400000
|
||||
#define CO_FUTURE_GENERATOR_STOP 0x800000
|
||||
#define CO_FUTURE_ANNOTATIONS 0x1000000
|
||||
|
||||
/* This should be defined if a future statement modifies the syntax.
|
||||
For example, when a keyword is added.
|
||||
*/
|
||||
#define PY_PARSER_REQUIRES_FUTURE_KEYWORD
|
||||
|
||||
#define CO_MAXBLOCKS 21 /* Max static block nesting within a function */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyCode_Type;
|
||||
|
||||
#define PyCode_Check(op) Py_IS_TYPE((op), &PyCode_Type)
|
||||
|
||||
static inline Py_ssize_t PyCode_GetNumFree(PyCodeObject *op) {
|
||||
assert(PyCode_Check(op));
|
||||
return op->co_nfreevars;
|
||||
}
|
||||
|
||||
static inline int PyCode_GetFirstFree(PyCodeObject *op) {
|
||||
assert(PyCode_Check(op));
|
||||
return op->co_nlocalsplus - op->co_nfreevars;
|
||||
}
|
||||
|
||||
#define _PyCode_CODE(CO) _Py_RVALUE((_Py_CODEUNIT *)(CO)->co_code_adaptive)
|
||||
#define _PyCode_NBYTES(CO) (Py_SIZE(CO) * (Py_ssize_t)sizeof(_Py_CODEUNIT))
|
||||
|
||||
/* Unstable public interface */
|
||||
PyAPI_FUNC(PyCodeObject *) PyUnstable_Code_New(
|
||||
int, int, int, int, int, PyObject *, PyObject *,
|
||||
PyObject *, PyObject *, PyObject *, PyObject *,
|
||||
PyObject *, PyObject *, PyObject *, int, PyObject *,
|
||||
PyObject *);
|
||||
|
||||
PyAPI_FUNC(PyCodeObject *) PyUnstable_Code_NewWithPosOnlyArgs(
|
||||
int, int, int, int, int, int, PyObject *, PyObject *,
|
||||
PyObject *, PyObject *, PyObject *, PyObject *,
|
||||
PyObject *, PyObject *, PyObject *, int, PyObject *,
|
||||
PyObject *);
|
||||
/* same as struct above */
|
||||
// Old names -- remove when this API changes:
|
||||
_Py_DEPRECATED_EXTERNALLY(3.12) static inline PyCodeObject *
|
||||
PyCode_New(
|
||||
int a, int b, int c, int d, int e, PyObject *f, PyObject *g,
|
||||
PyObject *h, PyObject *i, PyObject *j, PyObject *k,
|
||||
PyObject *l, PyObject *m, PyObject *n, int o, PyObject *p,
|
||||
PyObject *q)
|
||||
{
|
||||
return PyUnstable_Code_New(
|
||||
a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q);
|
||||
}
|
||||
_Py_DEPRECATED_EXTERNALLY(3.12) static inline PyCodeObject *
|
||||
PyCode_NewWithPosOnlyArgs(
|
||||
int a, int poac, int b, int c, int d, int e, PyObject *f, PyObject *g,
|
||||
PyObject *h, PyObject *i, PyObject *j, PyObject *k,
|
||||
PyObject *l, PyObject *m, PyObject *n, int o, PyObject *p,
|
||||
PyObject *q)
|
||||
{
|
||||
return PyUnstable_Code_NewWithPosOnlyArgs(
|
||||
a, poac, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q);
|
||||
}
|
||||
|
||||
/* Creates a new empty code object with the specified source location. */
|
||||
PyAPI_FUNC(PyCodeObject *)
|
||||
PyCode_NewEmpty(const char *filename, const char *funcname, int firstlineno);
|
||||
|
||||
/* Return the line number associated with the specified bytecode index
|
||||
in this code object. If you just need the line number of a frame,
|
||||
use PyFrame_GetLineNumber() instead. */
|
||||
PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int);
|
||||
|
||||
PyAPI_FUNC(int) PyCode_Addr2Location(PyCodeObject *, int, int *, int *, int *, int *);
|
||||
|
||||
#define PY_FOREACH_CODE_EVENT(V) \
|
||||
V(CREATE) \
|
||||
V(DESTROY)
|
||||
|
||||
typedef enum {
|
||||
#define PY_DEF_EVENT(op) PY_CODE_EVENT_##op,
|
||||
PY_FOREACH_CODE_EVENT(PY_DEF_EVENT)
|
||||
#undef PY_DEF_EVENT
|
||||
} PyCodeEvent;
|
||||
|
||||
|
||||
/*
|
||||
* A callback that is invoked for different events in a code object's lifecycle.
|
||||
*
|
||||
* The callback is invoked with a borrowed reference to co, after it is
|
||||
* created and before it is destroyed.
|
||||
*
|
||||
* If the callback sets an exception, it must return -1. Otherwise
|
||||
* it should return 0.
|
||||
*/
|
||||
typedef int (*PyCode_WatchCallback)(
|
||||
PyCodeEvent event,
|
||||
PyCodeObject* co);
|
||||
|
||||
/*
|
||||
* Register a per-interpreter callback that will be invoked for code object
|
||||
* lifecycle events.
|
||||
*
|
||||
* Returns a handle that may be passed to PyCode_ClearWatcher on success,
|
||||
* or -1 and sets an error if no more handles are available.
|
||||
*/
|
||||
PyAPI_FUNC(int) PyCode_AddWatcher(PyCode_WatchCallback callback);
|
||||
|
||||
/*
|
||||
* Clear the watcher associated with the watcher_id handle.
|
||||
*
|
||||
* Returns 0 on success or -1 if no watcher exists for the provided id.
|
||||
*/
|
||||
PyAPI_FUNC(int) PyCode_ClearWatcher(int watcher_id);
|
||||
|
||||
/* for internal use only */
|
||||
struct _opaque {
|
||||
int computed_line;
|
||||
const uint8_t *lo_next;
|
||||
const uint8_t *limit;
|
||||
};
|
||||
|
||||
typedef struct _line_offsets {
|
||||
int ar_start;
|
||||
int ar_end;
|
||||
int ar_line;
|
||||
struct _opaque opaque;
|
||||
} PyCodeAddressRange;
|
||||
|
||||
/* Update *bounds to describe the first and one-past-the-last instructions in the
|
||||
same line as lasti. Return the number of that line.
|
||||
*/
|
||||
PyAPI_FUNC(int) _PyCode_CheckLineNumber(int lasti, PyCodeAddressRange *bounds);
|
||||
|
||||
/* Create a comparable key used to compare constants taking in account the
|
||||
* object type. It is used to make sure types are not coerced (e.g., float and
|
||||
* complex) _and_ to distinguish 0.0 from -0.0 e.g. on IEEE platforms
|
||||
*
|
||||
* Return (type(obj), obj, ...): a tuple with variable size (at least 2 items)
|
||||
* depending on the type and the value. The type is the first item to not
|
||||
* compare bytes and str which can raise a BytesWarning exception. */
|
||||
PyAPI_FUNC(PyObject*) _PyCode_ConstantKey(PyObject *obj);
|
||||
|
||||
PyAPI_FUNC(PyObject*) PyCode_Optimize(PyObject *code, PyObject* consts,
|
||||
PyObject *names, PyObject *lnotab);
|
||||
|
||||
PyAPI_FUNC(int) PyUnstable_Code_GetExtra(
|
||||
PyObject *code, Py_ssize_t index, void **extra);
|
||||
PyAPI_FUNC(int) PyUnstable_Code_SetExtra(
|
||||
PyObject *code, Py_ssize_t index, void *extra);
|
||||
// Old names -- remove when this API changes:
|
||||
_Py_DEPRECATED_EXTERNALLY(3.12) static inline int
|
||||
_PyCode_GetExtra(PyObject *code, Py_ssize_t index, void **extra)
|
||||
{
|
||||
return PyUnstable_Code_GetExtra(code, index, extra);
|
||||
}
|
||||
_Py_DEPRECATED_EXTERNALLY(3.12) static inline int
|
||||
_PyCode_SetExtra(PyObject *code, Py_ssize_t index, void *extra)
|
||||
{
|
||||
return PyUnstable_Code_SetExtra(code, index, extra);
|
||||
}
|
||||
|
||||
/* Equivalent to getattr(code, 'co_code') in Python.
|
||||
Returns a strong reference to a bytes object. */
|
||||
PyAPI_FUNC(PyObject *) PyCode_GetCode(PyCodeObject *code);
|
||||
/* Equivalent to getattr(code, 'co_varnames') in Python. */
|
||||
PyAPI_FUNC(PyObject *) PyCode_GetVarnames(PyCodeObject *code);
|
||||
/* Equivalent to getattr(code, 'co_cellvars') in Python. */
|
||||
PyAPI_FUNC(PyObject *) PyCode_GetCellvars(PyCodeObject *code);
|
||||
/* Equivalent to getattr(code, 'co_freevars') in Python. */
|
||||
PyAPI_FUNC(PyObject *) PyCode_GetFreevars(PyCodeObject *code);
|
||||
|
||||
typedef enum _PyCodeLocationInfoKind {
|
||||
/* short forms are 0 to 9 */
|
||||
PY_CODE_LOCATION_INFO_SHORT0 = 0,
|
||||
/* one lineforms are 10 to 12 */
|
||||
PY_CODE_LOCATION_INFO_ONE_LINE0 = 10,
|
||||
PY_CODE_LOCATION_INFO_ONE_LINE1 = 11,
|
||||
PY_CODE_LOCATION_INFO_ONE_LINE2 = 12,
|
||||
|
||||
PY_CODE_LOCATION_INFO_NO_COLUMNS = 13,
|
||||
PY_CODE_LOCATION_INFO_LONG = 14,
|
||||
PY_CODE_LOCATION_INFO_NONE = 15
|
||||
} _PyCodeLocationInfoKind;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // !Py_CODE_H
|
||||
#endif // !Py_LIMITED_API
|
||||
69
crypto/shamirs_secret_sharing/include/cpython/compile.h
Normal file
69
crypto/shamirs_secret_sharing/include/cpython/compile.h
Normal file
@@ -0,0 +1,69 @@
|
||||
#ifndef Py_CPYTHON_COMPILE_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
/* Public interface */
|
||||
#define PyCF_MASK (CO_FUTURE_DIVISION | CO_FUTURE_ABSOLUTE_IMPORT | \
|
||||
CO_FUTURE_WITH_STATEMENT | CO_FUTURE_PRINT_FUNCTION | \
|
||||
CO_FUTURE_UNICODE_LITERALS | CO_FUTURE_BARRY_AS_BDFL | \
|
||||
CO_FUTURE_GENERATOR_STOP | CO_FUTURE_ANNOTATIONS)
|
||||
#define PyCF_MASK_OBSOLETE (CO_NESTED)
|
||||
|
||||
/* bpo-39562: CO_FUTURE_ and PyCF_ constants must be kept unique.
|
||||
PyCF_ constants can use bits from 0x0100 to 0x10000.
|
||||
CO_FUTURE_ constants use bits starting at 0x20000. */
|
||||
#define PyCF_SOURCE_IS_UTF8 0x0100
|
||||
#define PyCF_DONT_IMPLY_DEDENT 0x0200
|
||||
#define PyCF_ONLY_AST 0x0400
|
||||
#define PyCF_IGNORE_COOKIE 0x0800
|
||||
#define PyCF_TYPE_COMMENTS 0x1000
|
||||
#define PyCF_ALLOW_TOP_LEVEL_AWAIT 0x2000
|
||||
#define PyCF_ALLOW_INCOMPLETE_INPUT 0x4000
|
||||
#define PyCF_COMPILE_MASK (PyCF_ONLY_AST | PyCF_ALLOW_TOP_LEVEL_AWAIT | \
|
||||
PyCF_TYPE_COMMENTS | PyCF_DONT_IMPLY_DEDENT | \
|
||||
PyCF_ALLOW_INCOMPLETE_INPUT)
|
||||
|
||||
typedef struct {
|
||||
int cf_flags; /* bitmask of CO_xxx flags relevant to future */
|
||||
int cf_feature_version; /* minor Python version (PyCF_ONLY_AST) */
|
||||
} PyCompilerFlags;
|
||||
|
||||
#define _PyCompilerFlags_INIT \
|
||||
(PyCompilerFlags){.cf_flags = 0, .cf_feature_version = PY_MINOR_VERSION}
|
||||
|
||||
/* source location information */
|
||||
typedef struct {
|
||||
int lineno;
|
||||
int end_lineno;
|
||||
int col_offset;
|
||||
int end_col_offset;
|
||||
} _PyCompilerSrcLocation;
|
||||
|
||||
#define SRC_LOCATION_FROM_AST(n) \
|
||||
(_PyCompilerSrcLocation){ \
|
||||
.lineno = (n)->lineno, \
|
||||
.end_lineno = (n)->end_lineno, \
|
||||
.col_offset = (n)->col_offset, \
|
||||
.end_col_offset = (n)->end_col_offset }
|
||||
|
||||
/* Future feature support */
|
||||
|
||||
typedef struct {
|
||||
int ff_features; /* flags set by future statements */
|
||||
_PyCompilerSrcLocation ff_location; /* location of last future statement */
|
||||
} PyFutureFeatures;
|
||||
|
||||
#define FUTURE_NESTED_SCOPES "nested_scopes"
|
||||
#define FUTURE_GENERATORS "generators"
|
||||
#define FUTURE_DIVISION "division"
|
||||
#define FUTURE_ABSOLUTE_IMPORT "absolute_import"
|
||||
#define FUTURE_WITH_STATEMENT "with_statement"
|
||||
#define FUTURE_PRINT_FUNCTION "print_function"
|
||||
#define FUTURE_UNICODE_LITERALS "unicode_literals"
|
||||
#define FUTURE_BARRY_AS_BDFL "barry_as_FLUFL"
|
||||
#define FUTURE_GENERATOR_STOP "generator_stop"
|
||||
#define FUTURE_ANNOTATIONS "annotations"
|
||||
|
||||
#define PY_INVALID_STACK_EFFECT INT_MAX
|
||||
PyAPI_FUNC(int) PyCompile_OpcodeStackEffect(int opcode, int oparg);
|
||||
PyAPI_FUNC(int) PyCompile_OpcodeStackEffectWithJump(int opcode, int oparg, int jump);
|
||||
@@ -0,0 +1,44 @@
|
||||
#ifndef Py_CPYTHON_COMPLEXOBJECT_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
double real;
|
||||
double imag;
|
||||
} Py_complex;
|
||||
|
||||
/* Operations on complex numbers from complexmodule.c */
|
||||
|
||||
PyAPI_FUNC(Py_complex) _Py_c_sum(Py_complex, Py_complex);
|
||||
PyAPI_FUNC(Py_complex) _Py_c_diff(Py_complex, Py_complex);
|
||||
PyAPI_FUNC(Py_complex) _Py_c_neg(Py_complex);
|
||||
PyAPI_FUNC(Py_complex) _Py_c_prod(Py_complex, Py_complex);
|
||||
PyAPI_FUNC(Py_complex) _Py_c_quot(Py_complex, Py_complex);
|
||||
PyAPI_FUNC(Py_complex) _Py_c_pow(Py_complex, Py_complex);
|
||||
PyAPI_FUNC(double) _Py_c_abs(Py_complex);
|
||||
|
||||
/* Complex object interface */
|
||||
|
||||
/*
|
||||
PyComplexObject represents a complex number with double-precision
|
||||
real and imaginary parts.
|
||||
*/
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
Py_complex cval;
|
||||
} PyComplexObject;
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyComplex_FromCComplex(Py_complex);
|
||||
|
||||
PyAPI_FUNC(Py_complex) PyComplex_AsCComplex(PyObject *op);
|
||||
|
||||
#ifdef Py_BUILD_CORE
|
||||
/* Format the object based on the format_spec, as defined in PEP 3101
|
||||
(Advanced String Formatting). */
|
||||
extern int _PyComplex_FormatAdvancedWriter(
|
||||
_PyUnicodeWriter *writer,
|
||||
PyObject *obj,
|
||||
PyObject *format_spec,
|
||||
Py_ssize_t start,
|
||||
Py_ssize_t end);
|
||||
#endif // Py_BUILD_CORE
|
||||
78
crypto/shamirs_secret_sharing/include/cpython/context.h
Normal file
78
crypto/shamirs_secret_sharing/include/cpython/context.h
Normal file
@@ -0,0 +1,78 @@
|
||||
#ifndef Py_LIMITED_API
|
||||
#ifndef Py_CONTEXT_H
|
||||
#define Py_CONTEXT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyContext_Type;
|
||||
typedef struct _pycontextobject PyContext;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyContextVar_Type;
|
||||
typedef struct _pycontextvarobject PyContextVar;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyContextToken_Type;
|
||||
typedef struct _pycontexttokenobject PyContextToken;
|
||||
|
||||
|
||||
#define PyContext_CheckExact(o) Py_IS_TYPE((o), &PyContext_Type)
|
||||
#define PyContextVar_CheckExact(o) Py_IS_TYPE((o), &PyContextVar_Type)
|
||||
#define PyContextToken_CheckExact(o) Py_IS_TYPE((o), &PyContextToken_Type)
|
||||
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyContext_New(void);
|
||||
PyAPI_FUNC(PyObject *) PyContext_Copy(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyContext_CopyCurrent(void);
|
||||
|
||||
PyAPI_FUNC(int) PyContext_Enter(PyObject *);
|
||||
PyAPI_FUNC(int) PyContext_Exit(PyObject *);
|
||||
|
||||
|
||||
/* Create a new context variable.
|
||||
|
||||
default_value can be NULL.
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) PyContextVar_New(
|
||||
const char *name, PyObject *default_value);
|
||||
|
||||
|
||||
/* Get a value for the variable.
|
||||
|
||||
Returns -1 if an error occurred during lookup.
|
||||
|
||||
Returns 0 if value either was or was not found.
|
||||
|
||||
If value was found, *value will point to it.
|
||||
If not, it will point to:
|
||||
|
||||
- default_value, if not NULL;
|
||||
- the default value of "var", if not NULL;
|
||||
- NULL.
|
||||
|
||||
'*value' will be a new ref, if not NULL.
|
||||
*/
|
||||
PyAPI_FUNC(int) PyContextVar_Get(
|
||||
PyObject *var, PyObject *default_value, PyObject **value);
|
||||
|
||||
|
||||
/* Set a new value for the variable.
|
||||
Returns NULL if an error occurs.
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) PyContextVar_Set(PyObject *var, PyObject *value);
|
||||
|
||||
|
||||
/* Reset a variable to its previous value.
|
||||
Returns 0 on success, -1 on error.
|
||||
*/
|
||||
PyAPI_FUNC(int) PyContextVar_Reset(PyObject *var, PyObject *token);
|
||||
|
||||
|
||||
/* This method is exposed only for CPython tests. Don not use it. */
|
||||
PyAPI_FUNC(PyObject *) _PyContext_NewHamtForTests(void);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_CONTEXT_H */
|
||||
#endif /* !Py_LIMITED_API */
|
||||
64
crypto/shamirs_secret_sharing/include/cpython/descrobject.h
Normal file
64
crypto/shamirs_secret_sharing/include/cpython/descrobject.h
Normal file
@@ -0,0 +1,64 @@
|
||||
#ifndef Py_CPYTHON_DESCROBJECT_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args,
|
||||
void *wrapped);
|
||||
|
||||
typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args,
|
||||
void *wrapped, PyObject *kwds);
|
||||
|
||||
struct wrapperbase {
|
||||
const char *name;
|
||||
int offset;
|
||||
void *function;
|
||||
wrapperfunc wrapper;
|
||||
const char *doc;
|
||||
int flags;
|
||||
PyObject *name_strobj;
|
||||
};
|
||||
|
||||
/* Flags for above struct */
|
||||
#define PyWrapperFlag_KEYWORDS 1 /* wrapper function takes keyword args */
|
||||
|
||||
/* Various kinds of descriptor objects */
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyTypeObject *d_type;
|
||||
PyObject *d_name;
|
||||
PyObject *d_qualname;
|
||||
} PyDescrObject;
|
||||
|
||||
#define PyDescr_COMMON PyDescrObject d_common
|
||||
|
||||
#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type)
|
||||
#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name)
|
||||
|
||||
typedef struct {
|
||||
PyDescr_COMMON;
|
||||
PyMethodDef *d_method;
|
||||
vectorcallfunc vectorcall;
|
||||
} PyMethodDescrObject;
|
||||
|
||||
typedef struct {
|
||||
PyDescr_COMMON;
|
||||
PyMemberDef *d_member;
|
||||
} PyMemberDescrObject;
|
||||
|
||||
typedef struct {
|
||||
PyDescr_COMMON;
|
||||
PyGetSetDef *d_getset;
|
||||
} PyGetSetDescrObject;
|
||||
|
||||
typedef struct {
|
||||
PyDescr_COMMON;
|
||||
struct wrapperbase *d_base;
|
||||
void *d_wrapped; /* This can be any function pointer */
|
||||
} PyWrapperDescrObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) _PyMethodWrapper_Type;
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
|
||||
struct wrapperbase *, void *);
|
||||
PyAPI_FUNC(int) PyDescr_IsData(PyObject *);
|
||||
118
crypto/shamirs_secret_sharing/include/cpython/dictobject.h
Normal file
118
crypto/shamirs_secret_sharing/include/cpython/dictobject.h
Normal file
@@ -0,0 +1,118 @@
|
||||
#ifndef Py_CPYTHON_DICTOBJECT_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
typedef struct _dictkeysobject PyDictKeysObject;
|
||||
typedef struct _dictvalues PyDictValues;
|
||||
|
||||
/* The ma_values pointer is NULL for a combined table
|
||||
* or points to an array of PyObject* for a split table
|
||||
*/
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
|
||||
/* Number of items in the dictionary */
|
||||
Py_ssize_t ma_used;
|
||||
|
||||
/* Dictionary version: globally unique, value change each time
|
||||
the dictionary is modified */
|
||||
#ifdef Py_BUILD_CORE
|
||||
uint64_t ma_version_tag;
|
||||
#else
|
||||
Py_DEPRECATED(3.12) uint64_t ma_version_tag;
|
||||
#endif
|
||||
|
||||
PyDictKeysObject *ma_keys;
|
||||
|
||||
/* If ma_values is NULL, the table is "combined": keys and values
|
||||
are stored in ma_keys.
|
||||
|
||||
If ma_values is not NULL, the table is split:
|
||||
keys are stored in ma_keys and values are stored in ma_values */
|
||||
PyDictValues *ma_values;
|
||||
} PyDictObject;
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyDict_GetItem_KnownHash(PyObject *mp, PyObject *key,
|
||||
Py_hash_t hash);
|
||||
PyAPI_FUNC(PyObject *) _PyDict_GetItemWithError(PyObject *dp, PyObject *key);
|
||||
PyAPI_FUNC(PyObject *) _PyDict_GetItemIdWithError(PyObject *dp,
|
||||
_Py_Identifier *key);
|
||||
PyAPI_FUNC(PyObject *) _PyDict_GetItemStringWithError(PyObject *, const char *);
|
||||
PyAPI_FUNC(PyObject *) PyDict_SetDefault(
|
||||
PyObject *mp, PyObject *key, PyObject *defaultobj);
|
||||
PyAPI_FUNC(int) _PyDict_SetItem_KnownHash(PyObject *mp, PyObject *key,
|
||||
PyObject *item, Py_hash_t hash);
|
||||
PyAPI_FUNC(int) _PyDict_DelItem_KnownHash(PyObject *mp, PyObject *key,
|
||||
Py_hash_t hash);
|
||||
PyAPI_FUNC(int) _PyDict_DelItemIf(PyObject *mp, PyObject *key,
|
||||
int (*predicate)(PyObject *value));
|
||||
PyAPI_FUNC(int) _PyDict_Next(
|
||||
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, Py_hash_t *hash);
|
||||
|
||||
/* Get the number of items of a dictionary. */
|
||||
static inline Py_ssize_t PyDict_GET_SIZE(PyObject *op) {
|
||||
PyDictObject *mp;
|
||||
assert(PyDict_Check(op));
|
||||
mp = _Py_CAST(PyDictObject*, op);
|
||||
return mp->ma_used;
|
||||
}
|
||||
#define PyDict_GET_SIZE(op) PyDict_GET_SIZE(_PyObject_CAST(op))
|
||||
|
||||
PyAPI_FUNC(int) _PyDict_Contains_KnownHash(PyObject *, PyObject *, Py_hash_t);
|
||||
PyAPI_FUNC(int) _PyDict_ContainsId(PyObject *, _Py_Identifier *);
|
||||
PyAPI_FUNC(PyObject *) _PyDict_NewPresized(Py_ssize_t minused);
|
||||
PyAPI_FUNC(void) _PyDict_MaybeUntrack(PyObject *mp);
|
||||
PyAPI_FUNC(int) _PyDict_HasOnlyStringKeys(PyObject *mp);
|
||||
PyAPI_FUNC(Py_ssize_t) _PyDict_SizeOf(PyDictObject *);
|
||||
PyAPI_FUNC(PyObject *) _PyDict_Pop(PyObject *, PyObject *, PyObject *);
|
||||
#define _PyDict_HasSplitTable(d) ((d)->ma_values != NULL)
|
||||
|
||||
/* Like PyDict_Merge, but override can be 0, 1 or 2. If override is 0,
|
||||
the first occurrence of a key wins, if override is 1, the last occurrence
|
||||
of a key wins, if override is 2, a KeyError with conflicting key as
|
||||
argument is raised.
|
||||
*/
|
||||
PyAPI_FUNC(int) _PyDict_MergeEx(PyObject *mp, PyObject *other, int override);
|
||||
PyAPI_FUNC(int) _PyDict_SetItemId(PyObject *dp, _Py_Identifier *key, PyObject *item);
|
||||
|
||||
PyAPI_FUNC(int) _PyDict_DelItemId(PyObject *mp, _Py_Identifier *key);
|
||||
PyAPI_FUNC(void) _PyDict_DebugMallocStats(FILE *out);
|
||||
|
||||
/* _PyDictView */
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyDictObject *dv_dict;
|
||||
} _PyDictViewObject;
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyDictView_New(PyObject *, PyTypeObject *);
|
||||
PyAPI_FUNC(PyObject *) _PyDictView_Intersect(PyObject* self, PyObject *other);
|
||||
|
||||
/* Dictionary watchers */
|
||||
|
||||
#define PY_FOREACH_DICT_EVENT(V) \
|
||||
V(ADDED) \
|
||||
V(MODIFIED) \
|
||||
V(DELETED) \
|
||||
V(CLONED) \
|
||||
V(CLEARED) \
|
||||
V(DEALLOCATED)
|
||||
|
||||
typedef enum {
|
||||
#define PY_DEF_EVENT(EVENT) PyDict_EVENT_##EVENT,
|
||||
PY_FOREACH_DICT_EVENT(PY_DEF_EVENT)
|
||||
#undef PY_DEF_EVENT
|
||||
} PyDict_WatchEvent;
|
||||
|
||||
// Callback to be invoked when a watched dict is cleared, dealloced, or modified.
|
||||
// In clear/dealloc case, key and new_value will be NULL. Otherwise, new_value will be the
|
||||
// new value for key, NULL if key is being deleted.
|
||||
typedef int(*PyDict_WatchCallback)(PyDict_WatchEvent event, PyObject* dict, PyObject* key, PyObject* new_value);
|
||||
|
||||
// Register/unregister a dict-watcher callback
|
||||
PyAPI_FUNC(int) PyDict_AddWatcher(PyDict_WatchCallback callback);
|
||||
PyAPI_FUNC(int) PyDict_ClearWatcher(int watcher_id);
|
||||
|
||||
// Mark given dictionary as "watched" (callback will be called if it is modified)
|
||||
PyAPI_FUNC(int) PyDict_Watch(int watcher_id, PyObject* dict);
|
||||
PyAPI_FUNC(int) PyDict_Unwatch(int watcher_id, PyObject* dict);
|
||||
19
crypto/shamirs_secret_sharing/include/cpython/fileobject.h
Normal file
19
crypto/shamirs_secret_sharing/include/cpython/fileobject.h
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef Py_CPYTHON_FILEOBJECT_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(char *) Py_UniversalNewlineFgets(char *, int, FILE*, PyObject *);
|
||||
PyAPI_FUNC(char *) _Py_UniversalNewlineFgetsWithSize(char *, int, FILE*, PyObject *, size_t*);
|
||||
|
||||
/* The std printer acts as a preliminary sys.stderr until the new io
|
||||
infrastructure is in place. */
|
||||
PyAPI_FUNC(PyObject *) PyFile_NewStdPrinter(int);
|
||||
PyAPI_DATA(PyTypeObject) PyStdPrinter_Type;
|
||||
|
||||
typedef PyObject * (*Py_OpenCodeHookFunction)(PyObject *, void *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyFile_OpenCode(const char *utf8path);
|
||||
PyAPI_FUNC(PyObject *) PyFile_OpenCodeObject(PyObject *path);
|
||||
PyAPI_FUNC(int) PyFile_SetOpenCodeHook(Py_OpenCodeHookFunction hook, void *userData);
|
||||
|
||||
PyAPI_FUNC(int) _PyLong_FileDescriptor_Converter(PyObject *, void *);
|
||||
@@ -0,0 +1,8 @@
|
||||
#ifndef Py_CPYTHON_FILEUTILS_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
// Used by _testcapi which must not use the internal C API
|
||||
PyAPI_FUNC(FILE*) _Py_fopen_obj(
|
||||
PyObject *path,
|
||||
const char *mode);
|
||||
27
crypto/shamirs_secret_sharing/include/cpython/floatobject.h
Normal file
27
crypto/shamirs_secret_sharing/include/cpython/floatobject.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef Py_CPYTHON_FLOATOBJECT_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
double ob_fval;
|
||||
} PyFloatObject;
|
||||
|
||||
#define _PyFloat_CAST(op) \
|
||||
(assert(PyFloat_Check(op)), _Py_CAST(PyFloatObject*, op))
|
||||
|
||||
// Static inline version of PyFloat_AsDouble() trading safety for speed.
|
||||
// It doesn't check if op is a double object.
|
||||
static inline double PyFloat_AS_DOUBLE(PyObject *op) {
|
||||
return _PyFloat_CAST(op)->ob_fval;
|
||||
}
|
||||
#define PyFloat_AS_DOUBLE(op) PyFloat_AS_DOUBLE(_PyObject_CAST(op))
|
||||
|
||||
|
||||
PyAPI_FUNC(int) PyFloat_Pack2(double x, char *p, int le);
|
||||
PyAPI_FUNC(int) PyFloat_Pack4(double x, char *p, int le);
|
||||
PyAPI_FUNC(int) PyFloat_Pack8(double x, char *p, int le);
|
||||
|
||||
PyAPI_FUNC(double) PyFloat_Unpack2(const char *p, int le);
|
||||
PyAPI_FUNC(double) PyFloat_Unpack4(const char *p, int le);
|
||||
PyAPI_FUNC(double) PyFloat_Unpack8(const char *p, int le);
|
||||
29
crypto/shamirs_secret_sharing/include/cpython/frameobject.h
Normal file
29
crypto/shamirs_secret_sharing/include/cpython/frameobject.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/* Frame object interface */
|
||||
|
||||
#ifndef Py_CPYTHON_FRAMEOBJECT_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
/* Standard object interface */
|
||||
|
||||
PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *,
|
||||
PyObject *, PyObject *);
|
||||
|
||||
/* The rest of the interface is specific for frame objects */
|
||||
|
||||
/* Conversions between "fast locals" and locals in dictionary */
|
||||
|
||||
PyAPI_FUNC(void) PyFrame_LocalsToFast(PyFrameObject *, int);
|
||||
|
||||
/* -- Caveat emptor --
|
||||
* The concept of entry frames is an implementation detail of the CPython
|
||||
* interpreter. This API is considered unstable and is provided for the
|
||||
* convenience of debuggers, profilers and state-inspecting tools. Notice that
|
||||
* this API can be changed in future minor versions if the underlying frame
|
||||
* mechanism change or the concept of an 'entry frame' or its semantics becomes
|
||||
* obsolete or outdated. */
|
||||
|
||||
PyAPI_FUNC(int) _PyFrame_IsEntryFrame(PyFrameObject *frame);
|
||||
|
||||
PyAPI_FUNC(int) PyFrame_FastToLocalsWithError(PyFrameObject *f);
|
||||
PyAPI_FUNC(void) PyFrame_FastToLocals(PyFrameObject *);
|
||||
190
crypto/shamirs_secret_sharing/include/cpython/funcobject.h
Normal file
190
crypto/shamirs_secret_sharing/include/cpython/funcobject.h
Normal file
@@ -0,0 +1,190 @@
|
||||
/* Function object interface */
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
#ifndef Py_FUNCOBJECT_H
|
||||
#define Py_FUNCOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
#define _Py_COMMON_FIELDS(PREFIX) \
|
||||
PyObject *PREFIX ## globals; \
|
||||
PyObject *PREFIX ## builtins; \
|
||||
PyObject *PREFIX ## name; \
|
||||
PyObject *PREFIX ## qualname; \
|
||||
PyObject *PREFIX ## code; /* A code object, the __code__ attribute */ \
|
||||
PyObject *PREFIX ## defaults; /* NULL or a tuple */ \
|
||||
PyObject *PREFIX ## kwdefaults; /* NULL or a dict */ \
|
||||
PyObject *PREFIX ## closure; /* NULL or a tuple of cell objects */
|
||||
|
||||
typedef struct {
|
||||
_Py_COMMON_FIELDS(fc_)
|
||||
} PyFrameConstructor;
|
||||
|
||||
/* Function objects and code objects should not be confused with each other:
|
||||
*
|
||||
* Function objects are created by the execution of the 'def' statement.
|
||||
* They reference a code object in their __code__ attribute, which is a
|
||||
* purely syntactic object, i.e. nothing more than a compiled version of some
|
||||
* source code lines. There is one code object per source code "fragment",
|
||||
* but each code object can be referenced by zero or many function objects
|
||||
* depending only on how many times the 'def' statement in the source was
|
||||
* executed so far.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
_Py_COMMON_FIELDS(func_)
|
||||
PyObject *func_doc; /* The __doc__ attribute, can be anything */
|
||||
PyObject *func_dict; /* The __dict__ attribute, a dict or NULL */
|
||||
PyObject *func_weakreflist; /* List of weak references */
|
||||
PyObject *func_module; /* The __module__ attribute, can be anything */
|
||||
PyObject *func_annotations; /* Annotations, a dict or NULL */
|
||||
PyObject *func_typeparams; /* Tuple of active type variables or NULL */
|
||||
vectorcallfunc vectorcall;
|
||||
/* Version number for use by specializer.
|
||||
* Can set to non-zero when we want to specialize.
|
||||
* Will be set to zero if any of these change:
|
||||
* defaults
|
||||
* kwdefaults (only if the object changes, not the contents of the dict)
|
||||
* code
|
||||
* annotations
|
||||
* vectorcall function pointer */
|
||||
uint32_t func_version;
|
||||
|
||||
/* Invariant:
|
||||
* func_closure contains the bindings for func_code->co_freevars, so
|
||||
* PyTuple_Size(func_closure) == PyCode_GetNumFree(func_code)
|
||||
* (func_closure may be NULL if PyCode_GetNumFree(func_code) == 0).
|
||||
*/
|
||||
} PyFunctionObject;
|
||||
|
||||
#undef _Py_COMMON_FIELDS
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyFunction_Type;
|
||||
|
||||
#define PyFunction_Check(op) Py_IS_TYPE((op), &PyFunction_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyFunction_New(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_NewWithQualName(PyObject *, PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetCode(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetGlobals(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetModule(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetDefaults(PyObject *);
|
||||
PyAPI_FUNC(int) PyFunction_SetDefaults(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(void) PyFunction_SetVectorcall(PyFunctionObject *, vectorcallfunc);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetKwDefaults(PyObject *);
|
||||
PyAPI_FUNC(int) PyFunction_SetKwDefaults(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetClosure(PyObject *);
|
||||
PyAPI_FUNC(int) PyFunction_SetClosure(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyFunction_GetAnnotations(PyObject *);
|
||||
PyAPI_FUNC(int) PyFunction_SetAnnotations(PyObject *, PyObject *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyFunction_Vectorcall(
|
||||
PyObject *func,
|
||||
PyObject *const *stack,
|
||||
size_t nargsf,
|
||||
PyObject *kwnames);
|
||||
|
||||
#define _PyFunction_CAST(func) \
|
||||
(assert(PyFunction_Check(func)), _Py_CAST(PyFunctionObject*, func))
|
||||
|
||||
/* Static inline functions for direct access to these values.
|
||||
Type checks are *not* done, so use with care. */
|
||||
static inline PyObject* PyFunction_GET_CODE(PyObject *func) {
|
||||
return _PyFunction_CAST(func)->func_code;
|
||||
}
|
||||
#define PyFunction_GET_CODE(func) PyFunction_GET_CODE(_PyObject_CAST(func))
|
||||
|
||||
static inline PyObject* PyFunction_GET_GLOBALS(PyObject *func) {
|
||||
return _PyFunction_CAST(func)->func_globals;
|
||||
}
|
||||
#define PyFunction_GET_GLOBALS(func) PyFunction_GET_GLOBALS(_PyObject_CAST(func))
|
||||
|
||||
static inline PyObject* PyFunction_GET_MODULE(PyObject *func) {
|
||||
return _PyFunction_CAST(func)->func_module;
|
||||
}
|
||||
#define PyFunction_GET_MODULE(func) PyFunction_GET_MODULE(_PyObject_CAST(func))
|
||||
|
||||
static inline PyObject* PyFunction_GET_DEFAULTS(PyObject *func) {
|
||||
return _PyFunction_CAST(func)->func_defaults;
|
||||
}
|
||||
#define PyFunction_GET_DEFAULTS(func) PyFunction_GET_DEFAULTS(_PyObject_CAST(func))
|
||||
|
||||
static inline PyObject* PyFunction_GET_KW_DEFAULTS(PyObject *func) {
|
||||
return _PyFunction_CAST(func)->func_kwdefaults;
|
||||
}
|
||||
#define PyFunction_GET_KW_DEFAULTS(func) PyFunction_GET_KW_DEFAULTS(_PyObject_CAST(func))
|
||||
|
||||
static inline PyObject* PyFunction_GET_CLOSURE(PyObject *func) {
|
||||
return _PyFunction_CAST(func)->func_closure;
|
||||
}
|
||||
#define PyFunction_GET_CLOSURE(func) PyFunction_GET_CLOSURE(_PyObject_CAST(func))
|
||||
|
||||
static inline PyObject* PyFunction_GET_ANNOTATIONS(PyObject *func) {
|
||||
return _PyFunction_CAST(func)->func_annotations;
|
||||
}
|
||||
#define PyFunction_GET_ANNOTATIONS(func) PyFunction_GET_ANNOTATIONS(_PyObject_CAST(func))
|
||||
|
||||
/* The classmethod and staticmethod types lives here, too */
|
||||
PyAPI_DATA(PyTypeObject) PyClassMethod_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyStaticMethod_Type;
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyClassMethod_New(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyStaticMethod_New(PyObject *);
|
||||
|
||||
#define PY_FOREACH_FUNC_EVENT(V) \
|
||||
V(CREATE) \
|
||||
V(DESTROY) \
|
||||
V(MODIFY_CODE) \
|
||||
V(MODIFY_DEFAULTS) \
|
||||
V(MODIFY_KWDEFAULTS)
|
||||
|
||||
typedef enum {
|
||||
#define PY_DEF_EVENT(EVENT) PyFunction_EVENT_##EVENT,
|
||||
PY_FOREACH_FUNC_EVENT(PY_DEF_EVENT)
|
||||
#undef PY_DEF_EVENT
|
||||
} PyFunction_WatchEvent;
|
||||
|
||||
/*
|
||||
* A callback that is invoked for different events in a function's lifecycle.
|
||||
*
|
||||
* The callback is invoked with a borrowed reference to func, after it is
|
||||
* created and before it is modified or destroyed. The callback should not
|
||||
* modify func.
|
||||
*
|
||||
* When a function's code object, defaults, or kwdefaults are modified the
|
||||
* callback will be invoked with the respective event and new_value will
|
||||
* contain a borrowed reference to the new value that is about to be stored in
|
||||
* the function. Otherwise the third argument is NULL.
|
||||
*
|
||||
* If the callback returns with an exception set, it must return -1. Otherwise
|
||||
* it should return 0.
|
||||
*/
|
||||
typedef int (*PyFunction_WatchCallback)(
|
||||
PyFunction_WatchEvent event,
|
||||
PyFunctionObject *func,
|
||||
PyObject *new_value);
|
||||
|
||||
/*
|
||||
* Register a per-interpreter callback that will be invoked for function lifecycle
|
||||
* events.
|
||||
*
|
||||
* Returns a handle that may be passed to PyFunction_ClearWatcher on success,
|
||||
* or -1 and sets an error if no more handles are available.
|
||||
*/
|
||||
PyAPI_FUNC(int) PyFunction_AddWatcher(PyFunction_WatchCallback callback);
|
||||
|
||||
/*
|
||||
* Clear the watcher associated with the watcher_id handle.
|
||||
*
|
||||
* Returns 0 on success or -1 if no watcher exists for the supplied id.
|
||||
*/
|
||||
PyAPI_FUNC(int) PyFunction_ClearWatcher(int watcher_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_FUNCOBJECT_H */
|
||||
#endif /* Py_LIMITED_API */
|
||||
89
crypto/shamirs_secret_sharing/include/cpython/genobject.h
Normal file
89
crypto/shamirs_secret_sharing/include/cpython/genobject.h
Normal file
@@ -0,0 +1,89 @@
|
||||
/* Generator object interface */
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
#ifndef Py_GENOBJECT_H
|
||||
#define Py_GENOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* --- Generators --------------------------------------------------------- */
|
||||
|
||||
/* _PyGenObject_HEAD defines the initial segment of generator
|
||||
and coroutine objects. */
|
||||
#define _PyGenObject_HEAD(prefix) \
|
||||
PyObject_HEAD \
|
||||
/* List of weak reference. */ \
|
||||
PyObject *prefix##_weakreflist; \
|
||||
/* Name of the generator. */ \
|
||||
PyObject *prefix##_name; \
|
||||
/* Qualified name of the generator. */ \
|
||||
PyObject *prefix##_qualname; \
|
||||
_PyErr_StackItem prefix##_exc_state; \
|
||||
PyObject *prefix##_origin_or_finalizer; \
|
||||
char prefix##_hooks_inited; \
|
||||
char prefix##_closed; \
|
||||
char prefix##_running_async; \
|
||||
/* The frame */ \
|
||||
int8_t prefix##_frame_state; \
|
||||
PyObject *prefix##_iframe[1]; \
|
||||
|
||||
typedef struct {
|
||||
/* The gi_ prefix is intended to remind of generator-iterator. */
|
||||
_PyGenObject_HEAD(gi)
|
||||
} PyGenObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyGen_Type;
|
||||
|
||||
#define PyGen_Check(op) PyObject_TypeCheck((op), &PyGen_Type)
|
||||
#define PyGen_CheckExact(op) Py_IS_TYPE((op), &PyGen_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyGen_New(PyFrameObject *);
|
||||
PyAPI_FUNC(PyObject *) PyGen_NewWithQualName(PyFrameObject *,
|
||||
PyObject *name, PyObject *qualname);
|
||||
PyAPI_FUNC(int) _PyGen_SetStopIterationValue(PyObject *);
|
||||
PyAPI_FUNC(int) _PyGen_FetchStopIterationValue(PyObject **);
|
||||
PyAPI_FUNC(void) _PyGen_Finalize(PyObject *self);
|
||||
PyAPI_FUNC(PyCodeObject *) PyGen_GetCode(PyGenObject *gen);
|
||||
|
||||
|
||||
/* --- PyCoroObject ------------------------------------------------------- */
|
||||
|
||||
typedef struct {
|
||||
_PyGenObject_HEAD(cr)
|
||||
} PyCoroObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyCoro_Type;
|
||||
PyAPI_DATA(PyTypeObject) _PyCoroWrapper_Type;
|
||||
|
||||
#define PyCoro_CheckExact(op) Py_IS_TYPE((op), &PyCoro_Type)
|
||||
PyAPI_FUNC(PyObject *) PyCoro_New(PyFrameObject *,
|
||||
PyObject *name, PyObject *qualname);
|
||||
|
||||
|
||||
/* --- Asynchronous Generators -------------------------------------------- */
|
||||
|
||||
typedef struct {
|
||||
_PyGenObject_HEAD(ag)
|
||||
} PyAsyncGenObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyAsyncGen_Type;
|
||||
PyAPI_DATA(PyTypeObject) _PyAsyncGenASend_Type;
|
||||
PyAPI_DATA(PyTypeObject) _PyAsyncGenWrappedValue_Type;
|
||||
PyAPI_DATA(PyTypeObject) _PyAsyncGenAThrow_Type;
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyAsyncGen_New(PyFrameObject *,
|
||||
PyObject *name, PyObject *qualname);
|
||||
|
||||
#define PyAsyncGen_CheckExact(op) Py_IS_TYPE((op), &PyAsyncGen_Type)
|
||||
|
||||
#define PyAsyncGenASend_CheckExact(op) Py_IS_TYPE((op), &_PyAsyncGenASend_Type)
|
||||
|
||||
|
||||
#undef _PyGenObject_HEAD
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_GENOBJECT_H */
|
||||
#endif /* Py_LIMITED_API */
|
||||
46
crypto/shamirs_secret_sharing/include/cpython/import.h
Normal file
46
crypto/shamirs_secret_sharing/include/cpython/import.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef Py_CPYTHON_IMPORT_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
PyMODINIT_FUNC PyInit__imp(void);
|
||||
|
||||
PyAPI_FUNC(int) _PyImport_IsInitialized(PyInterpreterState *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyImport_GetModuleId(_Py_Identifier *name);
|
||||
PyAPI_FUNC(int) _PyImport_SetModule(PyObject *name, PyObject *module);
|
||||
PyAPI_FUNC(int) _PyImport_SetModuleString(const char *name, PyObject* module);
|
||||
|
||||
PyAPI_FUNC(void) _PyImport_AcquireLock(PyInterpreterState *interp);
|
||||
PyAPI_FUNC(int) _PyImport_ReleaseLock(PyInterpreterState *interp);
|
||||
|
||||
PyAPI_FUNC(int) _PyImport_FixupBuiltin(
|
||||
PyObject *mod,
|
||||
const char *name, /* UTF-8 encoded string */
|
||||
PyObject *modules
|
||||
);
|
||||
PyAPI_FUNC(int) _PyImport_FixupExtensionObject(PyObject*, PyObject *,
|
||||
PyObject *, PyObject *);
|
||||
|
||||
struct _inittab {
|
||||
const char *name; /* ASCII encoded string */
|
||||
PyObject* (*initfunc)(void);
|
||||
};
|
||||
// This is not used after Py_Initialize() is called.
|
||||
PyAPI_DATA(struct _inittab *) PyImport_Inittab;
|
||||
PyAPI_FUNC(int) PyImport_ExtendInittab(struct _inittab *newtab);
|
||||
|
||||
struct _frozen {
|
||||
const char *name; /* ASCII encoded string */
|
||||
const unsigned char *code;
|
||||
int size;
|
||||
int is_package;
|
||||
PyObject *(*get_code)(void);
|
||||
};
|
||||
|
||||
/* Embedding apps may change this pointer to point to their favorite
|
||||
collection of frozen modules: */
|
||||
|
||||
PyAPI_DATA(const struct _frozen *) PyImport_FrozenModules;
|
||||
|
||||
PyAPI_DATA(PyObject *) _PyImport_GetModuleAttr(PyObject *, PyObject *);
|
||||
PyAPI_DATA(PyObject *) _PyImport_GetModuleAttrString(const char *, const char *);
|
||||
256
crypto/shamirs_secret_sharing/include/cpython/initconfig.h
Normal file
256
crypto/shamirs_secret_sharing/include/cpython/initconfig.h
Normal file
@@ -0,0 +1,256 @@
|
||||
#ifndef Py_PYCORECONFIG_H
|
||||
#define Py_PYCORECONFIG_H
|
||||
#ifndef Py_LIMITED_API
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* --- PyStatus ----------------------------------------------- */
|
||||
|
||||
typedef struct {
|
||||
enum {
|
||||
_PyStatus_TYPE_OK=0,
|
||||
_PyStatus_TYPE_ERROR=1,
|
||||
_PyStatus_TYPE_EXIT=2
|
||||
} _type;
|
||||
const char *func;
|
||||
const char *err_msg;
|
||||
int exitcode;
|
||||
} PyStatus;
|
||||
|
||||
PyAPI_FUNC(PyStatus) PyStatus_Ok(void);
|
||||
PyAPI_FUNC(PyStatus) PyStatus_Error(const char *err_msg);
|
||||
PyAPI_FUNC(PyStatus) PyStatus_NoMemory(void);
|
||||
PyAPI_FUNC(PyStatus) PyStatus_Exit(int exitcode);
|
||||
PyAPI_FUNC(int) PyStatus_IsError(PyStatus err);
|
||||
PyAPI_FUNC(int) PyStatus_IsExit(PyStatus err);
|
||||
PyAPI_FUNC(int) PyStatus_Exception(PyStatus err);
|
||||
PyAPI_FUNC(PyObject *) _PyErr_SetFromPyStatus(PyStatus status);
|
||||
|
||||
/* --- PyWideStringList ------------------------------------------------ */
|
||||
|
||||
typedef struct {
|
||||
/* If length is greater than zero, items must be non-NULL
|
||||
and all items strings must be non-NULL */
|
||||
Py_ssize_t length;
|
||||
wchar_t **items;
|
||||
} PyWideStringList;
|
||||
|
||||
PyAPI_FUNC(PyStatus) PyWideStringList_Append(PyWideStringList *list,
|
||||
const wchar_t *item);
|
||||
PyAPI_FUNC(PyStatus) PyWideStringList_Insert(PyWideStringList *list,
|
||||
Py_ssize_t index,
|
||||
const wchar_t *item);
|
||||
|
||||
|
||||
/* --- PyPreConfig ----------------------------------------------- */
|
||||
|
||||
typedef struct PyPreConfig {
|
||||
int _config_init; /* _PyConfigInitEnum value */
|
||||
|
||||
/* Parse Py_PreInitializeFromBytesArgs() arguments?
|
||||
See PyConfig.parse_argv */
|
||||
int parse_argv;
|
||||
|
||||
/* If greater than 0, enable isolated mode: sys.path contains
|
||||
neither the script's directory nor the user's site-packages directory.
|
||||
|
||||
Set to 1 by the -I command line option. If set to -1 (default), inherit
|
||||
Py_IsolatedFlag value. */
|
||||
int isolated;
|
||||
|
||||
/* If greater than 0: use environment variables.
|
||||
Set to 0 by -E command line option. If set to -1 (default), it is
|
||||
set to !Py_IgnoreEnvironmentFlag. */
|
||||
int use_environment;
|
||||
|
||||
/* Set the LC_CTYPE locale to the user preferred locale? If equals to 0,
|
||||
set coerce_c_locale and coerce_c_locale_warn to 0. */
|
||||
int configure_locale;
|
||||
|
||||
/* Coerce the LC_CTYPE locale if it's equal to "C"? (PEP 538)
|
||||
|
||||
Set to 0 by PYTHONCOERCECLOCALE=0. Set to 1 by PYTHONCOERCECLOCALE=1.
|
||||
Set to 2 if the user preferred LC_CTYPE locale is "C".
|
||||
|
||||
If it is equal to 1, LC_CTYPE locale is read to decide if it should be
|
||||
coerced or not (ex: PYTHONCOERCECLOCALE=1). Internally, it is set to 2
|
||||
if the LC_CTYPE locale must be coerced.
|
||||
|
||||
Disable by default (set to 0). Set it to -1 to let Python decide if it
|
||||
should be enabled or not. */
|
||||
int coerce_c_locale;
|
||||
|
||||
/* Emit a warning if the LC_CTYPE locale is coerced?
|
||||
|
||||
Set to 1 by PYTHONCOERCECLOCALE=warn.
|
||||
|
||||
Disable by default (set to 0). Set it to -1 to let Python decide if it
|
||||
should be enabled or not. */
|
||||
int coerce_c_locale_warn;
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
/* If greater than 1, use the "mbcs" encoding instead of the UTF-8
|
||||
encoding for the filesystem encoding.
|
||||
|
||||
Set to 1 if the PYTHONLEGACYWINDOWSFSENCODING environment variable is
|
||||
set to a non-empty string. If set to -1 (default), inherit
|
||||
Py_LegacyWindowsFSEncodingFlag value.
|
||||
|
||||
See PEP 529 for more details. */
|
||||
int legacy_windows_fs_encoding;
|
||||
#endif
|
||||
|
||||
/* Enable UTF-8 mode? (PEP 540)
|
||||
|
||||
Disabled by default (equals to 0).
|
||||
|
||||
Set to 1 by "-X utf8" and "-X utf8=1" command line options.
|
||||
Set to 1 by PYTHONUTF8=1 environment variable.
|
||||
|
||||
Set to 0 by "-X utf8=0" and PYTHONUTF8=0.
|
||||
|
||||
If equals to -1, it is set to 1 if the LC_CTYPE locale is "C" or
|
||||
"POSIX", otherwise it is set to 0. Inherit Py_UTF8Mode value value. */
|
||||
int utf8_mode;
|
||||
|
||||
/* If non-zero, enable the Python Development Mode.
|
||||
|
||||
Set to 1 by the -X dev command line option. Set by the PYTHONDEVMODE
|
||||
environment variable. */
|
||||
int dev_mode;
|
||||
|
||||
/* Memory allocator: PYTHONMALLOC env var.
|
||||
See PyMemAllocatorName for valid values. */
|
||||
int allocator;
|
||||
} PyPreConfig;
|
||||
|
||||
PyAPI_FUNC(void) PyPreConfig_InitPythonConfig(PyPreConfig *config);
|
||||
PyAPI_FUNC(void) PyPreConfig_InitIsolatedConfig(PyPreConfig *config);
|
||||
|
||||
|
||||
/* --- PyConfig ---------------------------------------------- */
|
||||
|
||||
/* This structure is best documented in the Doc/c-api/init_config.rst file. */
|
||||
typedef struct PyConfig {
|
||||
int _config_init; /* _PyConfigInitEnum value */
|
||||
|
||||
int isolated;
|
||||
int use_environment;
|
||||
int dev_mode;
|
||||
int install_signal_handlers;
|
||||
int use_hash_seed;
|
||||
unsigned long hash_seed;
|
||||
int faulthandler;
|
||||
int tracemalloc;
|
||||
int perf_profiling;
|
||||
int import_time;
|
||||
int code_debug_ranges;
|
||||
int show_ref_count;
|
||||
int dump_refs;
|
||||
wchar_t *dump_refs_file;
|
||||
int malloc_stats;
|
||||
wchar_t *filesystem_encoding;
|
||||
wchar_t *filesystem_errors;
|
||||
wchar_t *pycache_prefix;
|
||||
int parse_argv;
|
||||
PyWideStringList orig_argv;
|
||||
PyWideStringList argv;
|
||||
PyWideStringList xoptions;
|
||||
PyWideStringList warnoptions;
|
||||
int site_import;
|
||||
int bytes_warning;
|
||||
int warn_default_encoding;
|
||||
int inspect;
|
||||
int interactive;
|
||||
int optimization_level;
|
||||
int parser_debug;
|
||||
int write_bytecode;
|
||||
int verbose;
|
||||
int quiet;
|
||||
int user_site_directory;
|
||||
int configure_c_stdio;
|
||||
int buffered_stdio;
|
||||
wchar_t *stdio_encoding;
|
||||
wchar_t *stdio_errors;
|
||||
#ifdef MS_WINDOWS
|
||||
int legacy_windows_stdio;
|
||||
#endif
|
||||
wchar_t *check_hash_pycs_mode;
|
||||
int use_frozen_modules;
|
||||
int safe_path;
|
||||
int int_max_str_digits;
|
||||
|
||||
/* --- Path configuration inputs ------------ */
|
||||
int pathconfig_warnings;
|
||||
wchar_t *program_name;
|
||||
wchar_t *pythonpath_env;
|
||||
wchar_t *home;
|
||||
wchar_t *platlibdir;
|
||||
|
||||
/* --- Path configuration outputs ----------- */
|
||||
int module_search_paths_set;
|
||||
PyWideStringList module_search_paths;
|
||||
wchar_t *stdlib_dir;
|
||||
wchar_t *executable;
|
||||
wchar_t *base_executable;
|
||||
wchar_t *prefix;
|
||||
wchar_t *base_prefix;
|
||||
wchar_t *exec_prefix;
|
||||
wchar_t *base_exec_prefix;
|
||||
|
||||
/* --- Parameter only used by Py_Main() ---------- */
|
||||
int skip_source_first_line;
|
||||
wchar_t *run_command;
|
||||
wchar_t *run_module;
|
||||
wchar_t *run_filename;
|
||||
|
||||
/* --- Private fields ---------------------------- */
|
||||
|
||||
// Install importlib? If equals to 0, importlib is not initialized at all.
|
||||
// Needed by freeze_importlib.
|
||||
int _install_importlib;
|
||||
|
||||
// If equal to 0, stop Python initialization before the "main" phase.
|
||||
int _init_main;
|
||||
|
||||
// If non-zero, we believe we're running from a source tree.
|
||||
int _is_python_build;
|
||||
} PyConfig;
|
||||
|
||||
PyAPI_FUNC(void) PyConfig_InitPythonConfig(PyConfig *config);
|
||||
PyAPI_FUNC(void) PyConfig_InitIsolatedConfig(PyConfig *config);
|
||||
PyAPI_FUNC(void) PyConfig_Clear(PyConfig *);
|
||||
PyAPI_FUNC(PyStatus) PyConfig_SetString(
|
||||
PyConfig *config,
|
||||
wchar_t **config_str,
|
||||
const wchar_t *str);
|
||||
PyAPI_FUNC(PyStatus) PyConfig_SetBytesString(
|
||||
PyConfig *config,
|
||||
wchar_t **config_str,
|
||||
const char *str);
|
||||
PyAPI_FUNC(PyStatus) PyConfig_Read(PyConfig *config);
|
||||
PyAPI_FUNC(PyStatus) PyConfig_SetBytesArgv(
|
||||
PyConfig *config,
|
||||
Py_ssize_t argc,
|
||||
char * const *argv);
|
||||
PyAPI_FUNC(PyStatus) PyConfig_SetArgv(PyConfig *config,
|
||||
Py_ssize_t argc,
|
||||
wchar_t * const *argv);
|
||||
PyAPI_FUNC(PyStatus) PyConfig_SetWideStringList(PyConfig *config,
|
||||
PyWideStringList *list,
|
||||
Py_ssize_t length, wchar_t **items);
|
||||
|
||||
|
||||
/* --- Helper functions --------------------------------------- */
|
||||
|
||||
/* Get the original command line arguments, before Python modified them.
|
||||
|
||||
See also PyConfig.orig_argv. */
|
||||
PyAPI_FUNC(void) Py_GetArgcArgv(int *argc, wchar_t ***argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_LIMITED_API */
|
||||
#endif /* !Py_PYCORECONFIG_H */
|
||||
@@ -0,0 +1,11 @@
|
||||
#ifndef Py_CPYTHON_INTERPRETERIDOBJECT_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
/* Interpreter ID Object */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) _PyInterpreterID_Type;
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyInterpreterID_New(int64_t);
|
||||
PyAPI_FUNC(PyObject *) _PyInterpreterState_GetIDObject(PyInterpreterState *);
|
||||
PyAPI_FUNC(PyInterpreterState *) _PyInterpreterID_LookUp(PyObject *);
|
||||
47
crypto/shamirs_secret_sharing/include/cpython/listobject.h
Normal file
47
crypto/shamirs_secret_sharing/include/cpython/listobject.h
Normal file
@@ -0,0 +1,47 @@
|
||||
#ifndef Py_CPYTHON_LISTOBJECT_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
PyObject_VAR_HEAD
|
||||
/* Vector of pointers to list elements. list[0] is ob_item[0], etc. */
|
||||
PyObject **ob_item;
|
||||
|
||||
/* ob_item contains space for 'allocated' elements. The number
|
||||
* currently in use is ob_size.
|
||||
* Invariants:
|
||||
* 0 <= ob_size <= allocated
|
||||
* len(list) == ob_size
|
||||
* ob_item == NULL implies ob_size == allocated == 0
|
||||
* list.sort() temporarily sets allocated to -1 to detect mutations.
|
||||
*
|
||||
* Items must normally not be NULL, except during construction when
|
||||
* the list is not yet visible outside the function that builds it.
|
||||
*/
|
||||
Py_ssize_t allocated;
|
||||
} PyListObject;
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyList_Extend(PyListObject *, PyObject *);
|
||||
PyAPI_FUNC(void) _PyList_DebugMallocStats(FILE *out);
|
||||
|
||||
/* Cast argument to PyListObject* type. */
|
||||
#define _PyList_CAST(op) \
|
||||
(assert(PyList_Check(op)), _Py_CAST(PyListObject*, (op)))
|
||||
|
||||
// Macros and static inline functions, trading safety for speed
|
||||
|
||||
static inline Py_ssize_t PyList_GET_SIZE(PyObject *op) {
|
||||
PyListObject *list = _PyList_CAST(op);
|
||||
return Py_SIZE(list);
|
||||
}
|
||||
#define PyList_GET_SIZE(op) PyList_GET_SIZE(_PyObject_CAST(op))
|
||||
|
||||
#define PyList_GET_ITEM(op, index) (_PyList_CAST(op)->ob_item[(index)])
|
||||
|
||||
static inline void
|
||||
PyList_SET_ITEM(PyObject *op, Py_ssize_t index, PyObject *value) {
|
||||
PyListObject *list = _PyList_CAST(op);
|
||||
list->ob_item[index] = value;
|
||||
}
|
||||
#define PyList_SET_ITEM(op, index, value) \
|
||||
PyList_SET_ITEM(_PyObject_CAST(op), (index), _PyObject_CAST(value))
|
||||
133
crypto/shamirs_secret_sharing/include/cpython/longintrepr.h
Normal file
133
crypto/shamirs_secret_sharing/include/cpython/longintrepr.h
Normal file
@@ -0,0 +1,133 @@
|
||||
#ifndef Py_LIMITED_API
|
||||
#ifndef Py_LONGINTREPR_H
|
||||
#define Py_LONGINTREPR_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* This is published for the benefit of "friends" marshal.c and _decimal.c. */
|
||||
|
||||
/* Parameters of the integer representation. There are two different
|
||||
sets of parameters: one set for 30-bit digits, stored in an unsigned 32-bit
|
||||
integer type, and one set for 15-bit digits with each digit stored in an
|
||||
unsigned short. The value of PYLONG_BITS_IN_DIGIT, defined either at
|
||||
configure time or in pyport.h, is used to decide which digit size to use.
|
||||
|
||||
Type 'digit' should be able to hold 2*PyLong_BASE-1, and type 'twodigits'
|
||||
should be an unsigned integer type able to hold all integers up to
|
||||
PyLong_BASE*PyLong_BASE-1. x_sub assumes that 'digit' is an unsigned type,
|
||||
and that overflow is handled by taking the result modulo 2**N for some N >
|
||||
PyLong_SHIFT. The majority of the code doesn't care about the precise
|
||||
value of PyLong_SHIFT, but there are some notable exceptions:
|
||||
|
||||
- PyLong_{As,From}ByteArray require that PyLong_SHIFT be at least 8
|
||||
|
||||
- long_hash() requires that PyLong_SHIFT is *strictly* less than the number
|
||||
of bits in an unsigned long, as do the PyLong <-> long (or unsigned long)
|
||||
conversion functions
|
||||
|
||||
- the Python int <-> size_t/Py_ssize_t conversion functions expect that
|
||||
PyLong_SHIFT is strictly less than the number of bits in a size_t
|
||||
|
||||
- the marshal code currently expects that PyLong_SHIFT is a multiple of 15
|
||||
|
||||
- NSMALLNEGINTS and NSMALLPOSINTS should be small enough to fit in a single
|
||||
digit; with the current values this forces PyLong_SHIFT >= 9
|
||||
|
||||
The values 15 and 30 should fit all of the above requirements, on any
|
||||
platform.
|
||||
*/
|
||||
|
||||
#if PYLONG_BITS_IN_DIGIT == 30
|
||||
typedef uint32_t digit;
|
||||
typedef int32_t sdigit; /* signed variant of digit */
|
||||
typedef uint64_t twodigits;
|
||||
typedef int64_t stwodigits; /* signed variant of twodigits */
|
||||
#define PyLong_SHIFT 30
|
||||
#define _PyLong_DECIMAL_SHIFT 9 /* max(e such that 10**e fits in a digit) */
|
||||
#define _PyLong_DECIMAL_BASE ((digit)1000000000) /* 10 ** DECIMAL_SHIFT */
|
||||
#elif PYLONG_BITS_IN_DIGIT == 15
|
||||
typedef unsigned short digit;
|
||||
typedef short sdigit; /* signed variant of digit */
|
||||
typedef unsigned long twodigits;
|
||||
typedef long stwodigits; /* signed variant of twodigits */
|
||||
#define PyLong_SHIFT 15
|
||||
#define _PyLong_DECIMAL_SHIFT 4 /* max(e such that 10**e fits in a digit) */
|
||||
#define _PyLong_DECIMAL_BASE ((digit)10000) /* 10 ** DECIMAL_SHIFT */
|
||||
#else
|
||||
#error "PYLONG_BITS_IN_DIGIT should be 15 or 30"
|
||||
#endif
|
||||
#define PyLong_BASE ((digit)1 << PyLong_SHIFT)
|
||||
#define PyLong_MASK ((digit)(PyLong_BASE - 1))
|
||||
|
||||
/* Long integer representation.
|
||||
The absolute value of a number is equal to
|
||||
SUM(for i=0 through abs(ob_size)-1) ob_digit[i] * 2**(SHIFT*i)
|
||||
Negative numbers are represented with ob_size < 0;
|
||||
zero is represented by ob_size == 0.
|
||||
In a normalized number, ob_digit[abs(ob_size)-1] (the most significant
|
||||
digit) is never zero. Also, in all cases, for all valid i,
|
||||
0 <= ob_digit[i] <= MASK.
|
||||
The allocation function takes care of allocating extra memory
|
||||
so that ob_digit[0] ... ob_digit[abs(ob_size)-1] are actually available.
|
||||
We always allocate memory for at least one digit, so accessing ob_digit[0]
|
||||
is always safe. However, in the case ob_size == 0, the contents of
|
||||
ob_digit[0] may be undefined.
|
||||
|
||||
CAUTION: Generic code manipulating subtypes of PyVarObject has to
|
||||
aware that ints abuse ob_size's sign bit.
|
||||
*/
|
||||
|
||||
typedef struct _PyLongValue {
|
||||
uintptr_t lv_tag; /* Number of digits, sign and flags */
|
||||
digit ob_digit[1];
|
||||
} _PyLongValue;
|
||||
|
||||
struct _longobject {
|
||||
PyObject_HEAD
|
||||
_PyLongValue long_value;
|
||||
};
|
||||
|
||||
PyAPI_FUNC(PyLongObject *) _PyLong_New(Py_ssize_t);
|
||||
|
||||
/* Return a copy of src. */
|
||||
PyAPI_FUNC(PyObject *) _PyLong_Copy(PyLongObject *src);
|
||||
|
||||
PyAPI_FUNC(PyLongObject *)
|
||||
_PyLong_FromDigits(int negative, Py_ssize_t digit_count, digit *digits);
|
||||
|
||||
|
||||
/* Inline some internals for speed. These should be in pycore_long.h
|
||||
* if user code didn't need them inlined. */
|
||||
|
||||
#define _PyLong_SIGN_MASK 3
|
||||
#define _PyLong_NON_SIZE_BITS 3
|
||||
|
||||
|
||||
static inline int
|
||||
_PyLong_IsCompact(const PyLongObject* op) {
|
||||
assert(PyType_HasFeature((op)->ob_base.ob_type, Py_TPFLAGS_LONG_SUBCLASS));
|
||||
return op->long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS);
|
||||
}
|
||||
|
||||
#define PyUnstable_Long_IsCompact _PyLong_IsCompact
|
||||
|
||||
static inline Py_ssize_t
|
||||
_PyLong_CompactValue(const PyLongObject *op)
|
||||
{
|
||||
Py_ssize_t sign;
|
||||
assert(PyType_HasFeature((op)->ob_base.ob_type, Py_TPFLAGS_LONG_SUBCLASS));
|
||||
assert(PyUnstable_Long_IsCompact(op));
|
||||
sign = 1 - (op->long_value.lv_tag & _PyLong_SIGN_MASK);
|
||||
return sign * (Py_ssize_t)op->long_value.ob_digit[0];
|
||||
}
|
||||
|
||||
#define PyUnstable_Long_CompactValue _PyLong_CompactValue
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_LONGINTREPR_H */
|
||||
#endif /* Py_LIMITED_API */
|
||||
100
crypto/shamirs_secret_sharing/include/cpython/longobject.h
Normal file
100
crypto/shamirs_secret_sharing/include/cpython/longobject.h
Normal file
@@ -0,0 +1,100 @@
|
||||
#ifndef Py_CPYTHON_LONGOBJECT_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(int) _PyLong_AsInt(PyObject *);
|
||||
|
||||
PyAPI_FUNC(int) _PyLong_UnsignedShort_Converter(PyObject *, void *);
|
||||
PyAPI_FUNC(int) _PyLong_UnsignedInt_Converter(PyObject *, void *);
|
||||
PyAPI_FUNC(int) _PyLong_UnsignedLong_Converter(PyObject *, void *);
|
||||
PyAPI_FUNC(int) _PyLong_UnsignedLongLong_Converter(PyObject *, void *);
|
||||
PyAPI_FUNC(int) _PyLong_Size_t_Converter(PyObject *, void *);
|
||||
|
||||
/* _PyLong_Frexp returns a double x and an exponent e such that the
|
||||
true value is approximately equal to x * 2**e. e is >= 0. x is
|
||||
0.0 if and only if the input is 0 (in which case, e and x are both
|
||||
zeroes); otherwise, 0.5 <= abs(x) < 1.0. On overflow, which is
|
||||
possible if the number of bits doesn't fit into a Py_ssize_t, sets
|
||||
OverflowError and returns -1.0 for x, 0 for e. */
|
||||
PyAPI_FUNC(double) _PyLong_Frexp(PyLongObject *a, Py_ssize_t *e);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromUnicodeObject(PyObject *u, int base);
|
||||
PyAPI_FUNC(PyObject *) _PyLong_FromBytes(const char *, Py_ssize_t, int);
|
||||
|
||||
/* _PyLong_Sign. Return 0 if v is 0, -1 if v < 0, +1 if v > 0.
|
||||
v must not be NULL, and must be a normalized long.
|
||||
There are no error cases.
|
||||
*/
|
||||
PyAPI_FUNC(int) _PyLong_Sign(PyObject *v);
|
||||
|
||||
/* _PyLong_NumBits. Return the number of bits needed to represent the
|
||||
absolute value of a long. For example, this returns 1 for 1 and -1, 2
|
||||
for 2 and -2, and 2 for 3 and -3. It returns 0 for 0.
|
||||
v must not be NULL, and must be a normalized long.
|
||||
(size_t)-1 is returned and OverflowError set if the true result doesn't
|
||||
fit in a size_t.
|
||||
*/
|
||||
PyAPI_FUNC(size_t) _PyLong_NumBits(PyObject *v);
|
||||
|
||||
/* _PyLong_DivmodNear. Given integers a and b, compute the nearest
|
||||
integer q to the exact quotient a / b, rounding to the nearest even integer
|
||||
in the case of a tie. Return (q, r), where r = a - q*b. The remainder r
|
||||
will satisfy abs(r) <= abs(b)/2, with equality possible only if q is
|
||||
even.
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) _PyLong_DivmodNear(PyObject *, PyObject *);
|
||||
|
||||
/* _PyLong_FromByteArray: View the n unsigned bytes as a binary integer in
|
||||
base 256, and return a Python int with the same numeric value.
|
||||
If n is 0, the integer is 0. Else:
|
||||
If little_endian is 1/true, bytes[n-1] is the MSB and bytes[0] the LSB;
|
||||
else (little_endian is 0/false) bytes[0] is the MSB and bytes[n-1] the
|
||||
LSB.
|
||||
If is_signed is 0/false, view the bytes as a non-negative integer.
|
||||
If is_signed is 1/true, view the bytes as a 2's-complement integer,
|
||||
non-negative if bit 0x80 of the MSB is clear, negative if set.
|
||||
Error returns:
|
||||
+ Return NULL with the appropriate exception set if there's not
|
||||
enough memory to create the Python int.
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) _PyLong_FromByteArray(
|
||||
const unsigned char* bytes, size_t n,
|
||||
int little_endian, int is_signed);
|
||||
|
||||
/* _PyLong_AsByteArray: Convert the least-significant 8*n bits of long
|
||||
v to a base-256 integer, stored in array bytes. Normally return 0,
|
||||
return -1 on error.
|
||||
If little_endian is 1/true, store the MSB at bytes[n-1] and the LSB at
|
||||
bytes[0]; else (little_endian is 0/false) store the MSB at bytes[0] and
|
||||
the LSB at bytes[n-1].
|
||||
If is_signed is 0/false, it's an error if v < 0; else (v >= 0) n bytes
|
||||
are filled and there's nothing special about bit 0x80 of the MSB.
|
||||
If is_signed is 1/true, bytes is filled with the 2's-complement
|
||||
representation of v's value. Bit 0x80 of the MSB is the sign bit.
|
||||
Error returns (-1):
|
||||
+ is_signed is 0 and v < 0. TypeError is set in this case, and bytes
|
||||
isn't altered.
|
||||
+ n isn't big enough to hold the full mathematical value of v. For
|
||||
example, if is_signed is 0 and there are more digits in the v than
|
||||
fit in n; or if is_signed is 1, v < 0, and n is just 1 bit shy of
|
||||
being large enough to hold a sign bit. OverflowError is set in this
|
||||
case, but bytes holds the least-significant n bytes of the true value.
|
||||
*/
|
||||
PyAPI_FUNC(int) _PyLong_AsByteArray(PyLongObject* v,
|
||||
unsigned char* bytes, size_t n,
|
||||
int little_endian, int is_signed);
|
||||
|
||||
/* _PyLong_Format: Convert the long to a string object with given base,
|
||||
appending a base prefix of 0[box] if base is 2, 8 or 16. */
|
||||
PyAPI_FUNC(PyObject *) _PyLong_Format(PyObject *obj, int base);
|
||||
|
||||
/* For use by the gcd function in mathmodule.c */
|
||||
PyAPI_FUNC(PyObject *) _PyLong_GCD(PyObject *, PyObject *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyLong_Rshift(PyObject *, size_t);
|
||||
PyAPI_FUNC(PyObject *) _PyLong_Lshift(PyObject *, size_t);
|
||||
|
||||
|
||||
PyAPI_FUNC(int) PyUnstable_Long_IsCompact(const PyLongObject* op);
|
||||
PyAPI_FUNC(Py_ssize_t) PyUnstable_Long_CompactValue(const PyLongObject* op);
|
||||
|
||||
52
crypto/shamirs_secret_sharing/include/cpython/memoryobject.h
Normal file
52
crypto/shamirs_secret_sharing/include/cpython/memoryobject.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#ifndef Py_CPYTHON_MEMORYOBJECT_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) _PyManagedBuffer_Type;
|
||||
|
||||
/* The structs are declared here so that macros can work, but they shouldn't
|
||||
be considered public. Don't access their fields directly, use the macros
|
||||
and functions instead! */
|
||||
#define _Py_MANAGED_BUFFER_RELEASED 0x001 /* access to exporter blocked */
|
||||
#define _Py_MANAGED_BUFFER_FREE_FORMAT 0x002 /* free format */
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
int flags; /* state flags */
|
||||
Py_ssize_t exports; /* number of direct memoryview exports */
|
||||
Py_buffer master; /* snapshot buffer obtained from the original exporter */
|
||||
} _PyManagedBufferObject;
|
||||
|
||||
|
||||
/* memoryview state flags */
|
||||
#define _Py_MEMORYVIEW_RELEASED 0x001 /* access to master buffer blocked */
|
||||
#define _Py_MEMORYVIEW_C 0x002 /* C-contiguous layout */
|
||||
#define _Py_MEMORYVIEW_FORTRAN 0x004 /* Fortran contiguous layout */
|
||||
#define _Py_MEMORYVIEW_SCALAR 0x008 /* scalar: ndim = 0 */
|
||||
#define _Py_MEMORYVIEW_PIL 0x010 /* PIL-style layout */
|
||||
#define _Py_MEMORYVIEW_RESTRICTED 0x020 /* Disallow new references to the memoryview's buffer */
|
||||
|
||||
typedef struct {
|
||||
PyObject_VAR_HEAD
|
||||
_PyManagedBufferObject *mbuf; /* managed buffer */
|
||||
Py_hash_t hash; /* hash value for read-only views */
|
||||
int flags; /* state flags */
|
||||
Py_ssize_t exports; /* number of buffer re-exports */
|
||||
Py_buffer view; /* private copy of the exporter's view */
|
||||
PyObject *weakreflist;
|
||||
Py_ssize_t ob_array[1]; /* shape, strides, suboffsets */
|
||||
} PyMemoryViewObject;
|
||||
|
||||
#define _PyMemoryView_CAST(op) _Py_CAST(PyMemoryViewObject*, op)
|
||||
|
||||
/* Get a pointer to the memoryview's private copy of the exporter's buffer. */
|
||||
static inline Py_buffer* PyMemoryView_GET_BUFFER(PyObject *op) {
|
||||
return (&_PyMemoryView_CAST(op)->view);
|
||||
}
|
||||
#define PyMemoryView_GET_BUFFER(op) PyMemoryView_GET_BUFFER(_PyObject_CAST(op))
|
||||
|
||||
/* Get a pointer to the exporting object (this may be NULL!). */
|
||||
static inline PyObject* PyMemoryView_GET_BASE(PyObject *op) {
|
||||
return _PyMemoryView_CAST(op)->view.obj;
|
||||
}
|
||||
#define PyMemoryView_GET_BASE(op) PyMemoryView_GET_BASE(_PyObject_CAST(op))
|
||||
66
crypto/shamirs_secret_sharing/include/cpython/methodobject.h
Normal file
66
crypto/shamirs_secret_sharing/include/cpython/methodobject.h
Normal file
@@ -0,0 +1,66 @@
|
||||
#ifndef Py_CPYTHON_METHODOBJECT_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
// PyCFunctionObject structure
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
PyMethodDef *m_ml; /* Description of the C function to call */
|
||||
PyObject *m_self; /* Passed as 'self' arg to the C func, can be NULL */
|
||||
PyObject *m_module; /* The __module__ attribute, can be anything */
|
||||
PyObject *m_weakreflist; /* List of weak references */
|
||||
vectorcallfunc vectorcall;
|
||||
} PyCFunctionObject;
|
||||
|
||||
#define _PyCFunctionObject_CAST(func) \
|
||||
(assert(PyCFunction_Check(func)), \
|
||||
_Py_CAST(PyCFunctionObject*, (func)))
|
||||
|
||||
|
||||
// PyCMethodObject structure
|
||||
|
||||
typedef struct {
|
||||
PyCFunctionObject func;
|
||||
PyTypeObject *mm_class; /* Class that defines this method */
|
||||
} PyCMethodObject;
|
||||
|
||||
#define _PyCMethodObject_CAST(func) \
|
||||
(assert(PyCMethod_Check(func)), \
|
||||
_Py_CAST(PyCMethodObject*, (func)))
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyCMethod_Type;
|
||||
|
||||
#define PyCMethod_CheckExact(op) Py_IS_TYPE((op), &PyCMethod_Type)
|
||||
#define PyCMethod_Check(op) PyObject_TypeCheck((op), &PyCMethod_Type)
|
||||
|
||||
|
||||
/* Static inline functions for direct access to these values.
|
||||
Type checks are *not* done, so use with care. */
|
||||
static inline PyCFunction PyCFunction_GET_FUNCTION(PyObject *func) {
|
||||
return _PyCFunctionObject_CAST(func)->m_ml->ml_meth;
|
||||
}
|
||||
#define PyCFunction_GET_FUNCTION(func) PyCFunction_GET_FUNCTION(_PyObject_CAST(func))
|
||||
|
||||
static inline PyObject* PyCFunction_GET_SELF(PyObject *func_obj) {
|
||||
PyCFunctionObject *func = _PyCFunctionObject_CAST(func_obj);
|
||||
if (func->m_ml->ml_flags & METH_STATIC) {
|
||||
return _Py_NULL;
|
||||
}
|
||||
return func->m_self;
|
||||
}
|
||||
#define PyCFunction_GET_SELF(func) PyCFunction_GET_SELF(_PyObject_CAST(func))
|
||||
|
||||
static inline int PyCFunction_GET_FLAGS(PyObject *func) {
|
||||
return _PyCFunctionObject_CAST(func)->m_ml->ml_flags;
|
||||
}
|
||||
#define PyCFunction_GET_FLAGS(func) PyCFunction_GET_FLAGS(_PyObject_CAST(func))
|
||||
|
||||
static inline PyTypeObject* PyCFunction_GET_CLASS(PyObject *func_obj) {
|
||||
PyCFunctionObject *func = _PyCFunctionObject_CAST(func_obj);
|
||||
if (func->m_ml->ml_flags & METH_METHOD) {
|
||||
return _PyCMethodObject_CAST(func)->mm_class;
|
||||
}
|
||||
return _Py_NULL;
|
||||
}
|
||||
#define PyCFunction_GET_CLASS(func) PyCFunction_GET_CLASS(_PyObject_CAST(func))
|
||||
109
crypto/shamirs_secret_sharing/include/cpython/modsupport.h
Normal file
109
crypto/shamirs_secret_sharing/include/cpython/modsupport.h
Normal file
@@ -0,0 +1,109 @@
|
||||
#ifndef Py_CPYTHON_MODSUPPORT_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
/* If PY_SSIZE_T_CLEAN is defined, each functions treats #-specifier
|
||||
to mean Py_ssize_t */
|
||||
#ifdef PY_SSIZE_T_CLEAN
|
||||
#define _Py_VaBuildStack _Py_VaBuildStack_SizeT
|
||||
#else
|
||||
PyAPI_FUNC(PyObject *) _Py_VaBuildValue_SizeT(const char *, va_list);
|
||||
PyAPI_FUNC(PyObject **) _Py_VaBuildStack_SizeT(
|
||||
PyObject **small_stack,
|
||||
Py_ssize_t small_stack_len,
|
||||
const char *format,
|
||||
va_list va,
|
||||
Py_ssize_t *p_nargs);
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(int) _PyArg_UnpackStack(
|
||||
PyObject *const *args,
|
||||
Py_ssize_t nargs,
|
||||
const char *name,
|
||||
Py_ssize_t min,
|
||||
Py_ssize_t max,
|
||||
...);
|
||||
|
||||
PyAPI_FUNC(int) _PyArg_NoKeywords(const char *funcname, PyObject *kwargs);
|
||||
PyAPI_FUNC(int) _PyArg_NoKwnames(const char *funcname, PyObject *kwnames);
|
||||
PyAPI_FUNC(int) _PyArg_NoPositional(const char *funcname, PyObject *args);
|
||||
#define _PyArg_NoKeywords(funcname, kwargs) \
|
||||
((kwargs) == NULL || _PyArg_NoKeywords((funcname), (kwargs)))
|
||||
#define _PyArg_NoKwnames(funcname, kwnames) \
|
||||
((kwnames) == NULL || _PyArg_NoKwnames((funcname), (kwnames)))
|
||||
#define _PyArg_NoPositional(funcname, args) \
|
||||
((args) == NULL || _PyArg_NoPositional((funcname), (args)))
|
||||
|
||||
#define _Py_ANY_VARARGS(n) ((n) == PY_SSIZE_T_MAX)
|
||||
|
||||
PyAPI_FUNC(void) _PyArg_BadArgument(const char *, const char *, const char *, PyObject *);
|
||||
PyAPI_FUNC(int) _PyArg_CheckPositional(const char *, Py_ssize_t,
|
||||
Py_ssize_t, Py_ssize_t);
|
||||
#define _PyArg_CheckPositional(funcname, nargs, min, max) \
|
||||
((!_Py_ANY_VARARGS(max) && (min) <= (nargs) && (nargs) <= (max)) \
|
||||
|| _PyArg_CheckPositional((funcname), (nargs), (min), (max)))
|
||||
|
||||
PyAPI_FUNC(PyObject **) _Py_VaBuildStack(
|
||||
PyObject **small_stack,
|
||||
Py_ssize_t small_stack_len,
|
||||
const char *format,
|
||||
va_list va,
|
||||
Py_ssize_t *p_nargs);
|
||||
|
||||
typedef struct _PyArg_Parser {
|
||||
int initialized;
|
||||
const char *format;
|
||||
const char * const *keywords;
|
||||
const char *fname;
|
||||
const char *custom_msg;
|
||||
int pos; /* number of positional-only arguments */
|
||||
int min; /* minimal number of arguments */
|
||||
int max; /* maximal number of positional arguments */
|
||||
PyObject *kwtuple; /* tuple of keyword parameter names */
|
||||
struct _PyArg_Parser *next;
|
||||
} _PyArg_Parser;
|
||||
|
||||
#ifdef PY_SSIZE_T_CLEAN
|
||||
#define _PyArg_ParseTupleAndKeywordsFast _PyArg_ParseTupleAndKeywordsFast_SizeT
|
||||
#define _PyArg_ParseStack _PyArg_ParseStack_SizeT
|
||||
#define _PyArg_ParseStackAndKeywords _PyArg_ParseStackAndKeywords_SizeT
|
||||
#define _PyArg_VaParseTupleAndKeywordsFast _PyArg_VaParseTupleAndKeywordsFast_SizeT
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(int) _PyArg_ParseTupleAndKeywordsFast(PyObject *, PyObject *,
|
||||
struct _PyArg_Parser *, ...);
|
||||
PyAPI_FUNC(int) _PyArg_ParseStack(
|
||||
PyObject *const *args,
|
||||
Py_ssize_t nargs,
|
||||
const char *format,
|
||||
...);
|
||||
PyAPI_FUNC(int) _PyArg_ParseStackAndKeywords(
|
||||
PyObject *const *args,
|
||||
Py_ssize_t nargs,
|
||||
PyObject *kwnames,
|
||||
struct _PyArg_Parser *,
|
||||
...);
|
||||
PyAPI_FUNC(int) _PyArg_VaParseTupleAndKeywordsFast(PyObject *, PyObject *,
|
||||
struct _PyArg_Parser *, va_list);
|
||||
PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywords(
|
||||
PyObject *const *args, Py_ssize_t nargs,
|
||||
PyObject *kwargs, PyObject *kwnames,
|
||||
struct _PyArg_Parser *parser,
|
||||
int minpos, int maxpos, int minkw,
|
||||
PyObject **buf);
|
||||
|
||||
PyAPI_FUNC(PyObject * const *) _PyArg_UnpackKeywordsWithVararg(
|
||||
PyObject *const *args, Py_ssize_t nargs,
|
||||
PyObject *kwargs, PyObject *kwnames,
|
||||
struct _PyArg_Parser *parser,
|
||||
int minpos, int maxpos, int minkw,
|
||||
int vararg, PyObject **buf);
|
||||
|
||||
#define _PyArg_UnpackKeywords(args, nargs, kwargs, kwnames, parser, minpos, maxpos, minkw, buf) \
|
||||
(((minkw) == 0 && (kwargs) == NULL && (kwnames) == NULL && \
|
||||
(minpos) <= (nargs) && (nargs) <= (maxpos) && (args) != NULL) ? (args) : \
|
||||
_PyArg_UnpackKeywords((args), (nargs), (kwargs), (kwnames), (parser), \
|
||||
(minpos), (maxpos), (minkw), (buf)))
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyModule_CreateInitialized(PyModuleDef*, int apiver);
|
||||
PyAPI_FUNC(int) _PyModule_Add(PyObject *, const char *, PyObject *);
|
||||
575
crypto/shamirs_secret_sharing/include/cpython/object.h
Normal file
575
crypto/shamirs_secret_sharing/include/cpython/object.h
Normal file
@@ -0,0 +1,575 @@
|
||||
#ifndef Py_CPYTHON_OBJECT_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(void) _Py_NewReference(PyObject *op);
|
||||
PyAPI_FUNC(void) _Py_NewReferenceNoTotal(PyObject *op);
|
||||
|
||||
#ifdef Py_TRACE_REFS
|
||||
/* Py_TRACE_REFS is such major surgery that we call external routines. */
|
||||
PyAPI_FUNC(void) _Py_ForgetReference(PyObject *);
|
||||
#endif
|
||||
|
||||
#ifdef Py_REF_DEBUG
|
||||
/* These are useful as debugging aids when chasing down refleaks. */
|
||||
PyAPI_FUNC(Py_ssize_t) _Py_GetGlobalRefTotal(void);
|
||||
# define _Py_GetRefTotal() _Py_GetGlobalRefTotal()
|
||||
PyAPI_FUNC(Py_ssize_t) _Py_GetLegacyRefTotal(void);
|
||||
PyAPI_FUNC(Py_ssize_t) _PyInterpreterState_GetRefTotal(PyInterpreterState *);
|
||||
#endif
|
||||
|
||||
|
||||
/********************* String Literals ****************************************/
|
||||
/* This structure helps managing static strings. The basic usage goes like this:
|
||||
Instead of doing
|
||||
|
||||
r = PyObject_CallMethod(o, "foo", "args", ...);
|
||||
|
||||
do
|
||||
|
||||
_Py_IDENTIFIER(foo);
|
||||
...
|
||||
r = _PyObject_CallMethodId(o, &PyId_foo, "args", ...);
|
||||
|
||||
PyId_foo is a static variable, either on block level or file level. On first
|
||||
usage, the string "foo" is interned, and the structures are linked. On interpreter
|
||||
shutdown, all strings are released.
|
||||
|
||||
Alternatively, _Py_static_string allows choosing the variable name.
|
||||
_PyUnicode_FromId returns a borrowed reference to the interned string.
|
||||
_PyObject_{Get,Set,Has}AttrId are __getattr__ versions using _Py_Identifier*.
|
||||
*/
|
||||
typedef struct _Py_Identifier {
|
||||
const char* string;
|
||||
// Index in PyInterpreterState.unicode.ids.array. It is process-wide
|
||||
// unique and must be initialized to -1.
|
||||
Py_ssize_t index;
|
||||
} _Py_Identifier;
|
||||
|
||||
#ifndef Py_BUILD_CORE
|
||||
// For now we are keeping _Py_IDENTIFIER for continued use
|
||||
// in non-builtin extensions (and naughty PyPI modules).
|
||||
|
||||
#define _Py_static_string_init(value) { .string = (value), .index = -1 }
|
||||
#define _Py_static_string(varname, value) static _Py_Identifier varname = _Py_static_string_init(value)
|
||||
#define _Py_IDENTIFIER(varname) _Py_static_string(PyId_##varname, #varname)
|
||||
|
||||
#endif /* !Py_BUILD_CORE */
|
||||
|
||||
typedef struct {
|
||||
/* Number implementations must check *both*
|
||||
arguments for proper type and implement the necessary conversions
|
||||
in the slot functions themselves. */
|
||||
|
||||
binaryfunc nb_add;
|
||||
binaryfunc nb_subtract;
|
||||
binaryfunc nb_multiply;
|
||||
binaryfunc nb_remainder;
|
||||
binaryfunc nb_divmod;
|
||||
ternaryfunc nb_power;
|
||||
unaryfunc nb_negative;
|
||||
unaryfunc nb_positive;
|
||||
unaryfunc nb_absolute;
|
||||
inquiry nb_bool;
|
||||
unaryfunc nb_invert;
|
||||
binaryfunc nb_lshift;
|
||||
binaryfunc nb_rshift;
|
||||
binaryfunc nb_and;
|
||||
binaryfunc nb_xor;
|
||||
binaryfunc nb_or;
|
||||
unaryfunc nb_int;
|
||||
void *nb_reserved; /* the slot formerly known as nb_long */
|
||||
unaryfunc nb_float;
|
||||
|
||||
binaryfunc nb_inplace_add;
|
||||
binaryfunc nb_inplace_subtract;
|
||||
binaryfunc nb_inplace_multiply;
|
||||
binaryfunc nb_inplace_remainder;
|
||||
ternaryfunc nb_inplace_power;
|
||||
binaryfunc nb_inplace_lshift;
|
||||
binaryfunc nb_inplace_rshift;
|
||||
binaryfunc nb_inplace_and;
|
||||
binaryfunc nb_inplace_xor;
|
||||
binaryfunc nb_inplace_or;
|
||||
|
||||
binaryfunc nb_floor_divide;
|
||||
binaryfunc nb_true_divide;
|
||||
binaryfunc nb_inplace_floor_divide;
|
||||
binaryfunc nb_inplace_true_divide;
|
||||
|
||||
unaryfunc nb_index;
|
||||
|
||||
binaryfunc nb_matrix_multiply;
|
||||
binaryfunc nb_inplace_matrix_multiply;
|
||||
} PyNumberMethods;
|
||||
|
||||
typedef struct {
|
||||
lenfunc sq_length;
|
||||
binaryfunc sq_concat;
|
||||
ssizeargfunc sq_repeat;
|
||||
ssizeargfunc sq_item;
|
||||
void *was_sq_slice;
|
||||
ssizeobjargproc sq_ass_item;
|
||||
void *was_sq_ass_slice;
|
||||
objobjproc sq_contains;
|
||||
|
||||
binaryfunc sq_inplace_concat;
|
||||
ssizeargfunc sq_inplace_repeat;
|
||||
} PySequenceMethods;
|
||||
|
||||
typedef struct {
|
||||
lenfunc mp_length;
|
||||
binaryfunc mp_subscript;
|
||||
objobjargproc mp_ass_subscript;
|
||||
} PyMappingMethods;
|
||||
|
||||
typedef PySendResult (*sendfunc)(PyObject *iter, PyObject *value, PyObject **result);
|
||||
|
||||
typedef struct {
|
||||
unaryfunc am_await;
|
||||
unaryfunc am_aiter;
|
||||
unaryfunc am_anext;
|
||||
sendfunc am_send;
|
||||
} PyAsyncMethods;
|
||||
|
||||
typedef struct {
|
||||
getbufferproc bf_getbuffer;
|
||||
releasebufferproc bf_releasebuffer;
|
||||
} PyBufferProcs;
|
||||
|
||||
/* Allow printfunc in the tp_vectorcall_offset slot for
|
||||
* backwards-compatibility */
|
||||
typedef Py_ssize_t printfunc;
|
||||
|
||||
// If this structure is modified, Doc/includes/typestruct.h should be updated
|
||||
// as well.
|
||||
struct _typeobject {
|
||||
PyObject_VAR_HEAD
|
||||
const char *tp_name; /* For printing, in format "<module>.<name>" */
|
||||
Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */
|
||||
|
||||
/* Methods to implement standard operations */
|
||||
|
||||
destructor tp_dealloc;
|
||||
Py_ssize_t tp_vectorcall_offset;
|
||||
getattrfunc tp_getattr;
|
||||
setattrfunc tp_setattr;
|
||||
PyAsyncMethods *tp_as_async; /* formerly known as tp_compare (Python 2)
|
||||
or tp_reserved (Python 3) */
|
||||
reprfunc tp_repr;
|
||||
|
||||
/* Method suites for standard classes */
|
||||
|
||||
PyNumberMethods *tp_as_number;
|
||||
PySequenceMethods *tp_as_sequence;
|
||||
PyMappingMethods *tp_as_mapping;
|
||||
|
||||
/* More standard operations (here for binary compatibility) */
|
||||
|
||||
hashfunc tp_hash;
|
||||
ternaryfunc tp_call;
|
||||
reprfunc tp_str;
|
||||
getattrofunc tp_getattro;
|
||||
setattrofunc tp_setattro;
|
||||
|
||||
/* Functions to access object as input/output buffer */
|
||||
PyBufferProcs *tp_as_buffer;
|
||||
|
||||
/* Flags to define presence of optional/expanded features */
|
||||
unsigned long tp_flags;
|
||||
|
||||
const char *tp_doc; /* Documentation string */
|
||||
|
||||
/* Assigned meaning in release 2.0 */
|
||||
/* call function for all accessible objects */
|
||||
traverseproc tp_traverse;
|
||||
|
||||
/* delete references to contained objects */
|
||||
inquiry tp_clear;
|
||||
|
||||
/* Assigned meaning in release 2.1 */
|
||||
/* rich comparisons */
|
||||
richcmpfunc tp_richcompare;
|
||||
|
||||
/* weak reference enabler */
|
||||
Py_ssize_t tp_weaklistoffset;
|
||||
|
||||
/* Iterators */
|
||||
getiterfunc tp_iter;
|
||||
iternextfunc tp_iternext;
|
||||
|
||||
/* Attribute descriptor and subclassing stuff */
|
||||
PyMethodDef *tp_methods;
|
||||
PyMemberDef *tp_members;
|
||||
PyGetSetDef *tp_getset;
|
||||
// Strong reference on a heap type, borrowed reference on a static type
|
||||
PyTypeObject *tp_base;
|
||||
PyObject *tp_dict;
|
||||
descrgetfunc tp_descr_get;
|
||||
descrsetfunc tp_descr_set;
|
||||
Py_ssize_t tp_dictoffset;
|
||||
initproc tp_init;
|
||||
allocfunc tp_alloc;
|
||||
newfunc tp_new;
|
||||
freefunc tp_free; /* Low-level free-memory routine */
|
||||
inquiry tp_is_gc; /* For PyObject_IS_GC */
|
||||
PyObject *tp_bases;
|
||||
PyObject *tp_mro; /* method resolution order */
|
||||
PyObject *tp_cache; /* no longer used */
|
||||
void *tp_subclasses; /* for static builtin types this is an index */
|
||||
PyObject *tp_weaklist; /* not used for static builtin types */
|
||||
destructor tp_del;
|
||||
|
||||
/* Type attribute cache version tag. Added in version 2.6 */
|
||||
unsigned int tp_version_tag;
|
||||
|
||||
destructor tp_finalize;
|
||||
vectorcallfunc tp_vectorcall;
|
||||
|
||||
/* bitset of which type-watchers care about this type */
|
||||
unsigned char tp_watched;
|
||||
};
|
||||
|
||||
/* This struct is used by the specializer
|
||||
* It should should be treated as an opaque blob
|
||||
* by code other than the specializer and interpreter. */
|
||||
struct _specialization_cache {
|
||||
// In order to avoid bloating the bytecode with lots of inline caches, the
|
||||
// members of this structure have a somewhat unique contract. They are set
|
||||
// by the specialization machinery, and are invalidated by PyType_Modified.
|
||||
// The rules for using them are as follows:
|
||||
// - If getitem is non-NULL, then it is the same Python function that
|
||||
// PyType_Lookup(cls, "__getitem__") would return.
|
||||
// - If getitem is NULL, then getitem_version is meaningless.
|
||||
// - If getitem->func_version == getitem_version, then getitem can be called
|
||||
// with two positional arguments and no keyword arguments, and has neither
|
||||
// *args nor **kwargs (as required by BINARY_SUBSCR_GETITEM):
|
||||
PyObject *getitem;
|
||||
uint32_t getitem_version;
|
||||
};
|
||||
|
||||
/* The *real* layout of a type object when allocated on the heap */
|
||||
typedef struct _heaptypeobject {
|
||||
/* Note: there's a dependency on the order of these members
|
||||
in slotptr() in typeobject.c . */
|
||||
PyTypeObject ht_type;
|
||||
PyAsyncMethods as_async;
|
||||
PyNumberMethods as_number;
|
||||
PyMappingMethods as_mapping;
|
||||
PySequenceMethods as_sequence; /* as_sequence comes after as_mapping,
|
||||
so that the mapping wins when both
|
||||
the mapping and the sequence define
|
||||
a given operator (e.g. __getitem__).
|
||||
see add_operators() in typeobject.c . */
|
||||
PyBufferProcs as_buffer;
|
||||
PyObject *ht_name, *ht_slots, *ht_qualname;
|
||||
struct _dictkeysobject *ht_cached_keys;
|
||||
PyObject *ht_module;
|
||||
char *_ht_tpname; // Storage for "tp_name"; see PyType_FromModuleAndSpec
|
||||
struct _specialization_cache _spec_cache; // For use by the specializer.
|
||||
/* here are optional user slots, followed by the members. */
|
||||
} PyHeapTypeObject;
|
||||
|
||||
PyAPI_FUNC(const char *) _PyType_Name(PyTypeObject *);
|
||||
PyAPI_FUNC(PyObject *) _PyType_Lookup(PyTypeObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) _PyType_LookupId(PyTypeObject *, _Py_Identifier *);
|
||||
PyAPI_FUNC(PyObject *) _PyObject_LookupSpecialId(PyObject *, _Py_Identifier *);
|
||||
#ifndef Py_BUILD_CORE
|
||||
// Backward compatibility for 3rd-party extensions
|
||||
// that may be using the old name.
|
||||
#define _PyObject_LookupSpecial _PyObject_LookupSpecialId
|
||||
#endif
|
||||
PyAPI_FUNC(PyTypeObject *) _PyType_CalculateMetaclass(PyTypeObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) _PyType_GetDocFromInternalDoc(const char *, const char *);
|
||||
PyAPI_FUNC(PyObject *) _PyType_GetTextSignatureFromInternalDoc(const char *, const char *);
|
||||
PyAPI_FUNC(PyObject *) PyType_GetModuleByDef(PyTypeObject *, PyModuleDef *);
|
||||
PyAPI_FUNC(PyObject *) PyType_GetDict(PyTypeObject *);
|
||||
|
||||
PyAPI_FUNC(int) PyObject_Print(PyObject *, FILE *, int);
|
||||
PyAPI_FUNC(void) _Py_BreakPoint(void);
|
||||
PyAPI_FUNC(void) _PyObject_Dump(PyObject *);
|
||||
PyAPI_FUNC(int) _PyObject_IsFreed(PyObject *);
|
||||
|
||||
PyAPI_FUNC(int) _PyObject_IsAbstract(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) _PyObject_GetAttrId(PyObject *, _Py_Identifier *);
|
||||
PyAPI_FUNC(int) _PyObject_SetAttrId(PyObject *, _Py_Identifier *, PyObject *);
|
||||
/* Replacements of PyObject_GetAttr() and _PyObject_GetAttrId() which
|
||||
don't raise AttributeError.
|
||||
|
||||
Return 1 and set *result != NULL if an attribute is found.
|
||||
Return 0 and set *result == NULL if an attribute is not found;
|
||||
an AttributeError is silenced.
|
||||
Return -1 and set *result == NULL if an error other than AttributeError
|
||||
is raised.
|
||||
*/
|
||||
PyAPI_FUNC(int) _PyObject_LookupAttr(PyObject *, PyObject *, PyObject **);
|
||||
PyAPI_FUNC(int) _PyObject_LookupAttrId(PyObject *, _Py_Identifier *, PyObject **);
|
||||
|
||||
PyAPI_FUNC(int) _PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);
|
||||
|
||||
PyAPI_FUNC(PyObject **) _PyObject_GetDictPtr(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) _PyObject_NextNotImplemented(PyObject *);
|
||||
PyAPI_FUNC(void) PyObject_CallFinalizer(PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_CallFinalizerFromDealloc(PyObject *);
|
||||
|
||||
/* Same as PyObject_Generic{Get,Set}Attr, but passing the attributes
|
||||
dict as the last parameter. */
|
||||
PyAPI_FUNC(PyObject *)
|
||||
_PyObject_GenericGetAttrWithDict(PyObject *, PyObject *, PyObject *, int);
|
||||
PyAPI_FUNC(int)
|
||||
_PyObject_GenericSetAttrWithDict(PyObject *, PyObject *,
|
||||
PyObject *, PyObject *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyObject_FunctionStr(PyObject *);
|
||||
|
||||
/* Safely decref `dst` and set `dst` to `src`.
|
||||
*
|
||||
* As in case of Py_CLEAR "the obvious" code can be deadly:
|
||||
*
|
||||
* Py_DECREF(dst);
|
||||
* dst = src;
|
||||
*
|
||||
* The safe way is:
|
||||
*
|
||||
* Py_SETREF(dst, src);
|
||||
*
|
||||
* That arranges to set `dst` to `src` _before_ decref'ing, so that any code
|
||||
* triggered as a side-effect of `dst` getting torn down no longer believes
|
||||
* `dst` points to a valid object.
|
||||
*
|
||||
* Temporary variables are used to only evalutate macro arguments once and so
|
||||
* avoid the duplication of side effects. _Py_TYPEOF() or memcpy() is used to
|
||||
* avoid a miscompilation caused by type punning. See Py_CLEAR() comment for
|
||||
* implementation details about type punning.
|
||||
*
|
||||
* The memcpy() implementation does not emit a compiler warning if 'src' has
|
||||
* not the same type than 'src': any pointer type is accepted for 'src'.
|
||||
*/
|
||||
#ifdef _Py_TYPEOF
|
||||
#define Py_SETREF(dst, src) \
|
||||
do { \
|
||||
_Py_TYPEOF(dst)* _tmp_dst_ptr = &(dst); \
|
||||
_Py_TYPEOF(dst) _tmp_old_dst = (*_tmp_dst_ptr); \
|
||||
*_tmp_dst_ptr = (src); \
|
||||
Py_DECREF(_tmp_old_dst); \
|
||||
} while (0)
|
||||
#else
|
||||
#define Py_SETREF(dst, src) \
|
||||
do { \
|
||||
PyObject **_tmp_dst_ptr = _Py_CAST(PyObject**, &(dst)); \
|
||||
PyObject *_tmp_old_dst = (*_tmp_dst_ptr); \
|
||||
PyObject *_tmp_src = _PyObject_CAST(src); \
|
||||
memcpy(_tmp_dst_ptr, &_tmp_src, sizeof(PyObject*)); \
|
||||
Py_DECREF(_tmp_old_dst); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
/* Py_XSETREF() is a variant of Py_SETREF() that uses Py_XDECREF() instead of
|
||||
* Py_DECREF().
|
||||
*/
|
||||
#ifdef _Py_TYPEOF
|
||||
#define Py_XSETREF(dst, src) \
|
||||
do { \
|
||||
_Py_TYPEOF(dst)* _tmp_dst_ptr = &(dst); \
|
||||
_Py_TYPEOF(dst) _tmp_old_dst = (*_tmp_dst_ptr); \
|
||||
*_tmp_dst_ptr = (src); \
|
||||
Py_XDECREF(_tmp_old_dst); \
|
||||
} while (0)
|
||||
#else
|
||||
#define Py_XSETREF(dst, src) \
|
||||
do { \
|
||||
PyObject **_tmp_dst_ptr = _Py_CAST(PyObject**, &(dst)); \
|
||||
PyObject *_tmp_old_dst = (*_tmp_dst_ptr); \
|
||||
PyObject *_tmp_src = _PyObject_CAST(src); \
|
||||
memcpy(_tmp_dst_ptr, &_tmp_src, sizeof(PyObject*)); \
|
||||
Py_XDECREF(_tmp_old_dst); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
|
||||
PyAPI_DATA(PyTypeObject) _PyNone_Type;
|
||||
PyAPI_DATA(PyTypeObject) _PyNotImplemented_Type;
|
||||
|
||||
/* Maps Py_LT to Py_GT, ..., Py_GE to Py_LE.
|
||||
* Defined in object.c.
|
||||
*/
|
||||
PyAPI_DATA(int) _Py_SwappedOp[];
|
||||
|
||||
PyAPI_FUNC(void)
|
||||
_PyDebugAllocatorStats(FILE *out, const char *block_name, int num_blocks,
|
||||
size_t sizeof_block);
|
||||
PyAPI_FUNC(void)
|
||||
_PyObject_DebugTypeStats(FILE *out);
|
||||
|
||||
/* Define a pair of assertion macros:
|
||||
_PyObject_ASSERT_FROM(), _PyObject_ASSERT_WITH_MSG() and _PyObject_ASSERT().
|
||||
|
||||
These work like the regular C assert(), in that they will abort the
|
||||
process with a message on stderr if the given condition fails to hold,
|
||||
but compile away to nothing if NDEBUG is defined.
|
||||
|
||||
However, before aborting, Python will also try to call _PyObject_Dump() on
|
||||
the given object. This may be of use when investigating bugs in which a
|
||||
particular object is corrupt (e.g. buggy a tp_visit method in an extension
|
||||
module breaking the garbage collector), to help locate the broken objects.
|
||||
|
||||
The WITH_MSG variant allows you to supply an additional message that Python
|
||||
will attempt to print to stderr, after the object dump. */
|
||||
#ifdef NDEBUG
|
||||
/* No debugging: compile away the assertions: */
|
||||
# define _PyObject_ASSERT_FROM(obj, expr, msg, filename, lineno, func) \
|
||||
((void)0)
|
||||
#else
|
||||
/* With debugging: generate checks: */
|
||||
# define _PyObject_ASSERT_FROM(obj, expr, msg, filename, lineno, func) \
|
||||
((expr) \
|
||||
? (void)(0) \
|
||||
: _PyObject_AssertFailed((obj), Py_STRINGIFY(expr), \
|
||||
(msg), (filename), (lineno), (func)))
|
||||
#endif
|
||||
|
||||
#define _PyObject_ASSERT_WITH_MSG(obj, expr, msg) \
|
||||
_PyObject_ASSERT_FROM((obj), expr, (msg), __FILE__, __LINE__, __func__)
|
||||
#define _PyObject_ASSERT(obj, expr) \
|
||||
_PyObject_ASSERT_WITH_MSG((obj), expr, NULL)
|
||||
|
||||
#define _PyObject_ASSERT_FAILED_MSG(obj, msg) \
|
||||
_PyObject_AssertFailed((obj), NULL, (msg), __FILE__, __LINE__, __func__)
|
||||
|
||||
/* Declare and define _PyObject_AssertFailed() even when NDEBUG is defined,
|
||||
to avoid causing compiler/linker errors when building extensions without
|
||||
NDEBUG against a Python built with NDEBUG defined.
|
||||
|
||||
msg, expr and function can be NULL. */
|
||||
PyAPI_FUNC(void) _Py_NO_RETURN _PyObject_AssertFailed(
|
||||
PyObject *obj,
|
||||
const char *expr,
|
||||
const char *msg,
|
||||
const char *file,
|
||||
int line,
|
||||
const char *function);
|
||||
|
||||
/* Check if an object is consistent. For example, ensure that the reference
|
||||
counter is greater than or equal to 1, and ensure that ob_type is not NULL.
|
||||
|
||||
Call _PyObject_AssertFailed() if the object is inconsistent.
|
||||
|
||||
If check_content is zero, only check header fields: reduce the overhead.
|
||||
|
||||
The function always return 1. The return value is just here to be able to
|
||||
write:
|
||||
|
||||
assert(_PyObject_CheckConsistency(obj, 1)); */
|
||||
PyAPI_FUNC(int) _PyObject_CheckConsistency(
|
||||
PyObject *op,
|
||||
int check_content);
|
||||
|
||||
|
||||
/* Trashcan mechanism, thanks to Christian Tismer.
|
||||
|
||||
When deallocating a container object, it's possible to trigger an unbounded
|
||||
chain of deallocations, as each Py_DECREF in turn drops the refcount on "the
|
||||
next" object in the chain to 0. This can easily lead to stack overflows,
|
||||
especially in threads (which typically have less stack space to work with).
|
||||
|
||||
A container object can avoid this by bracketing the body of its tp_dealloc
|
||||
function with a pair of macros:
|
||||
|
||||
static void
|
||||
mytype_dealloc(mytype *p)
|
||||
{
|
||||
... declarations go here ...
|
||||
|
||||
PyObject_GC_UnTrack(p); // must untrack first
|
||||
Py_TRASHCAN_BEGIN(p, mytype_dealloc)
|
||||
... The body of the deallocator goes here, including all calls ...
|
||||
... to Py_DECREF on contained objects. ...
|
||||
Py_TRASHCAN_END // there should be no code after this
|
||||
}
|
||||
|
||||
CAUTION: Never return from the middle of the body! If the body needs to
|
||||
"get out early", put a label immediately before the Py_TRASHCAN_END
|
||||
call, and goto it. Else the call-depth counter (see below) will stay
|
||||
above 0 forever, and the trashcan will never get emptied.
|
||||
|
||||
How it works: The BEGIN macro increments a call-depth counter. So long
|
||||
as this counter is small, the body of the deallocator is run directly without
|
||||
further ado. But if the counter gets large, it instead adds p to a list of
|
||||
objects to be deallocated later, skips the body of the deallocator, and
|
||||
resumes execution after the END macro. The tp_dealloc routine then returns
|
||||
without deallocating anything (and so unbounded call-stack depth is avoided).
|
||||
|
||||
When the call stack finishes unwinding again, code generated by the END macro
|
||||
notices this, and calls another routine to deallocate all the objects that
|
||||
may have been added to the list of deferred deallocations. In effect, a
|
||||
chain of N deallocations is broken into (N-1)/(_PyTrash_UNWIND_LEVEL-1) pieces,
|
||||
with the call stack never exceeding a depth of _PyTrash_UNWIND_LEVEL.
|
||||
|
||||
Since the tp_dealloc of a subclass typically calls the tp_dealloc of the base
|
||||
class, we need to ensure that the trashcan is only triggered on the tp_dealloc
|
||||
of the actual class being deallocated. Otherwise we might end up with a
|
||||
partially-deallocated object. To check this, the tp_dealloc function must be
|
||||
passed as second argument to Py_TRASHCAN_BEGIN().
|
||||
*/
|
||||
|
||||
/* Python 3.9 private API, invoked by the macros below. */
|
||||
PyAPI_FUNC(int) _PyTrash_begin(PyThreadState *tstate, PyObject *op);
|
||||
PyAPI_FUNC(void) _PyTrash_end(PyThreadState *tstate);
|
||||
/* Python 3.10 private API, invoked by the Py_TRASHCAN_BEGIN(). */
|
||||
PyAPI_FUNC(int) _PyTrash_cond(PyObject *op, destructor dealloc);
|
||||
|
||||
#define Py_TRASHCAN_BEGIN_CONDITION(op, cond) \
|
||||
do { \
|
||||
PyThreadState *_tstate = NULL; \
|
||||
/* If "cond" is false, then _tstate remains NULL and the deallocator \
|
||||
* is run normally without involving the trashcan */ \
|
||||
if (cond) { \
|
||||
_tstate = _PyThreadState_UncheckedGet(); \
|
||||
if (_PyTrash_begin(_tstate, _PyObject_CAST(op))) { \
|
||||
break; \
|
||||
} \
|
||||
}
|
||||
/* The body of the deallocator is here. */
|
||||
#define Py_TRASHCAN_END \
|
||||
if (_tstate) { \
|
||||
_PyTrash_end(_tstate); \
|
||||
} \
|
||||
} while (0);
|
||||
|
||||
#define Py_TRASHCAN_BEGIN(op, dealloc) \
|
||||
Py_TRASHCAN_BEGIN_CONDITION((op), \
|
||||
_PyTrash_cond(_PyObject_CAST(op), (destructor)(dealloc)))
|
||||
|
||||
/* The following two macros, Py_TRASHCAN_SAFE_BEGIN and
|
||||
* Py_TRASHCAN_SAFE_END, are deprecated since version 3.11 and
|
||||
* will be removed in the future.
|
||||
* Use Py_TRASHCAN_BEGIN and Py_TRASHCAN_END instead.
|
||||
*/
|
||||
Py_DEPRECATED(3.11) typedef int UsingDeprecatedTrashcanMacro;
|
||||
#define Py_TRASHCAN_SAFE_BEGIN(op) \
|
||||
do { \
|
||||
UsingDeprecatedTrashcanMacro cond=1; \
|
||||
Py_TRASHCAN_BEGIN_CONDITION((op), cond);
|
||||
#define Py_TRASHCAN_SAFE_END(op) \
|
||||
Py_TRASHCAN_END; \
|
||||
} while(0);
|
||||
|
||||
PyAPI_FUNC(void *) PyObject_GetItemData(PyObject *obj);
|
||||
|
||||
PyAPI_FUNC(int) _PyObject_VisitManagedDict(PyObject *obj, visitproc visit, void *arg);
|
||||
PyAPI_FUNC(void) _PyObject_ClearManagedDict(PyObject *obj);
|
||||
|
||||
#define TYPE_MAX_WATCHERS 8
|
||||
|
||||
typedef int(*PyType_WatchCallback)(PyTypeObject *);
|
||||
PyAPI_FUNC(int) PyType_AddWatcher(PyType_WatchCallback callback);
|
||||
PyAPI_FUNC(int) PyType_ClearWatcher(int watcher_id);
|
||||
PyAPI_FUNC(int) PyType_Watch(int watcher_id, PyObject *type);
|
||||
PyAPI_FUNC(int) PyType_Unwatch(int watcher_id, PyObject *type);
|
||||
|
||||
/* Attempt to assign a version tag to the given type.
|
||||
*
|
||||
* Returns 1 if the type already had a valid version tag or a new one was
|
||||
* assigned, or 0 if a new tag could not be assigned.
|
||||
*/
|
||||
PyAPI_FUNC(int) PyUnstable_Type_AssignVersionTag(PyTypeObject *type);
|
||||
95
crypto/shamirs_secret_sharing/include/cpython/objimpl.h
Normal file
95
crypto/shamirs_secret_sharing/include/cpython/objimpl.h
Normal file
@@ -0,0 +1,95 @@
|
||||
#ifndef Py_CPYTHON_OBJIMPL_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
static inline size_t _PyObject_SIZE(PyTypeObject *type) {
|
||||
return _Py_STATIC_CAST(size_t, type->tp_basicsize);
|
||||
}
|
||||
|
||||
/* _PyObject_VAR_SIZE returns the number of bytes (as size_t) allocated for a
|
||||
vrbl-size object with nitems items, exclusive of gc overhead (if any). The
|
||||
value is rounded up to the closest multiple of sizeof(void *), in order to
|
||||
ensure that pointer fields at the end of the object are correctly aligned
|
||||
for the platform (this is of special importance for subclasses of, e.g.,
|
||||
str or int, so that pointers can be stored after the embedded data).
|
||||
|
||||
Note that there's no memory wastage in doing this, as malloc has to
|
||||
return (at worst) pointer-aligned memory anyway.
|
||||
*/
|
||||
#if ((SIZEOF_VOID_P - 1) & SIZEOF_VOID_P) != 0
|
||||
# error "_PyObject_VAR_SIZE requires SIZEOF_VOID_P be a power of 2"
|
||||
#endif
|
||||
|
||||
static inline size_t _PyObject_VAR_SIZE(PyTypeObject *type, Py_ssize_t nitems) {
|
||||
size_t size = _Py_STATIC_CAST(size_t, type->tp_basicsize);
|
||||
size += _Py_STATIC_CAST(size_t, nitems) * _Py_STATIC_CAST(size_t, type->tp_itemsize);
|
||||
return _Py_SIZE_ROUND_UP(size, SIZEOF_VOID_P);
|
||||
}
|
||||
|
||||
|
||||
/* This example code implements an object constructor with a custom
|
||||
allocator, where PyObject_New is inlined, and shows the important
|
||||
distinction between two steps (at least):
|
||||
1) the actual allocation of the object storage;
|
||||
2) the initialization of the Python specific fields
|
||||
in this storage with PyObject_{Init, InitVar}.
|
||||
|
||||
PyObject *
|
||||
YourObject_New(...)
|
||||
{
|
||||
PyObject *op;
|
||||
|
||||
op = (PyObject *) Your_Allocator(_PyObject_SIZE(YourTypeStruct));
|
||||
if (op == NULL) {
|
||||
return PyErr_NoMemory();
|
||||
}
|
||||
|
||||
PyObject_Init(op, &YourTypeStruct);
|
||||
|
||||
op->ob_field = value;
|
||||
...
|
||||
return op;
|
||||
}
|
||||
|
||||
Note that in C++, the use of the new operator usually implies that
|
||||
the 1st step is performed automatically for you, so in a C++ class
|
||||
constructor you would start directly with PyObject_Init/InitVar. */
|
||||
|
||||
|
||||
typedef struct {
|
||||
/* user context passed as the first argument to the 2 functions */
|
||||
void *ctx;
|
||||
|
||||
/* allocate an arena of size bytes */
|
||||
void* (*alloc) (void *ctx, size_t size);
|
||||
|
||||
/* free an arena */
|
||||
void (*free) (void *ctx, void *ptr, size_t size);
|
||||
} PyObjectArenaAllocator;
|
||||
|
||||
/* Get the arena allocator. */
|
||||
PyAPI_FUNC(void) PyObject_GetArenaAllocator(PyObjectArenaAllocator *allocator);
|
||||
|
||||
/* Set the arena allocator. */
|
||||
PyAPI_FUNC(void) PyObject_SetArenaAllocator(PyObjectArenaAllocator *allocator);
|
||||
|
||||
|
||||
/* Test if an object implements the garbage collector protocol */
|
||||
PyAPI_FUNC(int) PyObject_IS_GC(PyObject *obj);
|
||||
|
||||
|
||||
/* Code built with Py_BUILD_CORE must include pycore_gc.h instead which
|
||||
defines a different _PyGC_FINALIZED() macro. */
|
||||
#ifndef Py_BUILD_CORE
|
||||
// Kept for backward compatibility with Python 3.8
|
||||
# define _PyGC_FINALIZED(o) PyObject_GC_IsFinalized(o)
|
||||
#endif
|
||||
|
||||
|
||||
// Test if a type supports weak references
|
||||
PyAPI_FUNC(int) PyType_SUPPORTS_WEAKREFS(PyTypeObject *type);
|
||||
|
||||
PyAPI_FUNC(PyObject **) PyObject_GET_WEAKREFS_LISTPTR(PyObject *op);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyUnstable_Object_GC_NewWithExtraData(PyTypeObject *,
|
||||
size_t);
|
||||
43
crypto/shamirs_secret_sharing/include/cpython/odictobject.h
Normal file
43
crypto/shamirs_secret_sharing/include/cpython/odictobject.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef Py_ODICTOBJECT_H
|
||||
#define Py_ODICTOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* OrderedDict */
|
||||
/* This API is optional and mostly redundant. */
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
|
||||
typedef struct _odictobject PyODictObject;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyODict_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyODictIter_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyODictKeys_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyODictItems_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyODictValues_Type;
|
||||
|
||||
#define PyODict_Check(op) PyObject_TypeCheck((op), &PyODict_Type)
|
||||
#define PyODict_CheckExact(op) Py_IS_TYPE((op), &PyODict_Type)
|
||||
#define PyODict_SIZE(op) PyDict_GET_SIZE((op))
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyODict_New(void);
|
||||
PyAPI_FUNC(int) PyODict_SetItem(PyObject *od, PyObject *key, PyObject *item);
|
||||
PyAPI_FUNC(int) PyODict_DelItem(PyObject *od, PyObject *key);
|
||||
|
||||
/* wrappers around PyDict* functions */
|
||||
#define PyODict_GetItem(od, key) PyDict_GetItem(_PyObject_CAST(od), (key))
|
||||
#define PyODict_GetItemWithError(od, key) \
|
||||
PyDict_GetItemWithError(_PyObject_CAST(od), (key))
|
||||
#define PyODict_Contains(od, key) PyDict_Contains(_PyObject_CAST(od), (key))
|
||||
#define PyODict_Size(od) PyDict_Size(_PyObject_CAST(od))
|
||||
#define PyODict_GetItemString(od, key) \
|
||||
PyDict_GetItemString(_PyObject_CAST(od), (key))
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_ODICTOBJECT_H */
|
||||
@@ -0,0 +1,31 @@
|
||||
/* PickleBuffer object. This is built-in for ease of use from third-party
|
||||
* C extensions.
|
||||
*/
|
||||
|
||||
#ifndef Py_PICKLEBUFOBJECT_H
|
||||
#define Py_PICKLEBUFOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyPickleBuffer_Type;
|
||||
|
||||
#define PyPickleBuffer_Check(op) Py_IS_TYPE((op), &PyPickleBuffer_Type)
|
||||
|
||||
/* Create a PickleBuffer redirecting to the given buffer-enabled object */
|
||||
PyAPI_FUNC(PyObject *) PyPickleBuffer_FromObject(PyObject *);
|
||||
/* Get the PickleBuffer's underlying view to the original object
|
||||
* (NULL if released)
|
||||
*/
|
||||
PyAPI_FUNC(const Py_buffer *) PyPickleBuffer_GetBuffer(PyObject *);
|
||||
/* Release the PickleBuffer. Returns 0 on success, -1 on error. */
|
||||
PyAPI_FUNC(int) PyPickleBuffer_Release(PyObject *);
|
||||
|
||||
#endif /* !Py_LIMITED_API */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_PICKLEBUFOBJECT_H */
|
||||
@@ -0,0 +1,88 @@
|
||||
#ifndef Py_CPYTHON_PTRHEAD_STUBS_H
|
||||
#define Py_CPYTHON_PTRHEAD_STUBS_H
|
||||
|
||||
#if !defined(HAVE_PTHREAD_STUBS)
|
||||
# error "this header file requires stubbed pthreads."
|
||||
#endif
|
||||
|
||||
#ifndef _POSIX_THREADS
|
||||
# define _POSIX_THREADS 1
|
||||
#endif
|
||||
|
||||
/* Minimal pthread stubs for CPython.
|
||||
*
|
||||
* The stubs implement the minimum pthread API for CPython.
|
||||
* - pthread_create() fails.
|
||||
* - pthread_exit() calls exit(0).
|
||||
* - pthread_key_*() functions implement minimal TSS without destructor.
|
||||
* - all other functions do nothing and return 0.
|
||||
*/
|
||||
|
||||
#ifdef __wasi__
|
||||
// WASI's bits/alltypes.h provides type definitions when __NEED_ is set.
|
||||
// The header file can be included multiple times.
|
||||
# define __NEED_pthread_cond_t 1
|
||||
# define __NEED_pthread_condattr_t 1
|
||||
# define __NEED_pthread_mutex_t 1
|
||||
# define __NEED_pthread_mutexattr_t 1
|
||||
# define __NEED_pthread_key_t 1
|
||||
# define __NEED_pthread_t 1
|
||||
# define __NEED_pthread_attr_t 1
|
||||
# include <bits/alltypes.h>
|
||||
#else
|
||||
typedef struct { void *__x; } pthread_cond_t;
|
||||
typedef struct { unsigned __attr; } pthread_condattr_t;
|
||||
typedef struct { void *__x; } pthread_mutex_t;
|
||||
typedef struct { unsigned __attr; } pthread_mutexattr_t;
|
||||
typedef unsigned pthread_key_t;
|
||||
typedef unsigned pthread_t;
|
||||
typedef struct { unsigned __attr; } pthread_attr_t;
|
||||
#endif
|
||||
|
||||
// mutex
|
||||
PyAPI_FUNC(int) pthread_mutex_init(pthread_mutex_t *restrict mutex,
|
||||
const pthread_mutexattr_t *restrict attr);
|
||||
PyAPI_FUNC(int) pthread_mutex_destroy(pthread_mutex_t *mutex);
|
||||
PyAPI_FUNC(int) pthread_mutex_trylock(pthread_mutex_t *mutex);
|
||||
PyAPI_FUNC(int) pthread_mutex_lock(pthread_mutex_t *mutex);
|
||||
PyAPI_FUNC(int) pthread_mutex_unlock(pthread_mutex_t *mutex);
|
||||
|
||||
// condition
|
||||
PyAPI_FUNC(int) pthread_cond_init(pthread_cond_t *restrict cond,
|
||||
const pthread_condattr_t *restrict attr);
|
||||
PyAPI_FUNC(int) pthread_cond_destroy(pthread_cond_t *cond);
|
||||
PyAPI_FUNC(int) pthread_cond_wait(pthread_cond_t *restrict cond,
|
||||
pthread_mutex_t *restrict mutex);
|
||||
PyAPI_FUNC(int) pthread_cond_timedwait(pthread_cond_t *restrict cond,
|
||||
pthread_mutex_t *restrict mutex,
|
||||
const struct timespec *restrict abstime);
|
||||
PyAPI_FUNC(int) pthread_cond_signal(pthread_cond_t *cond);
|
||||
PyAPI_FUNC(int) pthread_condattr_init(pthread_condattr_t *attr);
|
||||
PyAPI_FUNC(int) pthread_condattr_setclock(
|
||||
pthread_condattr_t *attr, clockid_t clock_id);
|
||||
|
||||
// pthread
|
||||
PyAPI_FUNC(int) pthread_create(pthread_t *restrict thread,
|
||||
const pthread_attr_t *restrict attr,
|
||||
void *(*start_routine)(void *),
|
||||
void *restrict arg);
|
||||
PyAPI_FUNC(int) pthread_detach(pthread_t thread);
|
||||
PyAPI_FUNC(pthread_t) pthread_self(void);
|
||||
PyAPI_FUNC(int) pthread_exit(void *retval) __attribute__ ((__noreturn__));
|
||||
PyAPI_FUNC(int) pthread_attr_init(pthread_attr_t *attr);
|
||||
PyAPI_FUNC(int) pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize);
|
||||
PyAPI_FUNC(int) pthread_attr_destroy(pthread_attr_t *attr);
|
||||
|
||||
|
||||
// pthread_key
|
||||
#ifndef PTHREAD_KEYS_MAX
|
||||
# define PTHREAD_KEYS_MAX 128
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(int) pthread_key_create(pthread_key_t *key,
|
||||
void (*destr_function)(void *));
|
||||
PyAPI_FUNC(int) pthread_key_delete(pthread_key_t key);
|
||||
PyAPI_FUNC(void *) pthread_getspecific(pthread_key_t key);
|
||||
PyAPI_FUNC(int) pthread_setspecific(pthread_key_t key, const void *value);
|
||||
|
||||
#endif // Py_CPYTHON_PTRHEAD_STUBS_H
|
||||
39
crypto/shamirs_secret_sharing/include/cpython/pyctype.h
Normal file
39
crypto/shamirs_secret_sharing/include/cpython/pyctype.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef Py_LIMITED_API
|
||||
#ifndef PYCTYPE_H
|
||||
#define PYCTYPE_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PY_CTF_LOWER 0x01
|
||||
#define PY_CTF_UPPER 0x02
|
||||
#define PY_CTF_ALPHA (PY_CTF_LOWER|PY_CTF_UPPER)
|
||||
#define PY_CTF_DIGIT 0x04
|
||||
#define PY_CTF_ALNUM (PY_CTF_ALPHA|PY_CTF_DIGIT)
|
||||
#define PY_CTF_SPACE 0x08
|
||||
#define PY_CTF_XDIGIT 0x10
|
||||
|
||||
PyAPI_DATA(const unsigned int) _Py_ctype_table[256];
|
||||
|
||||
/* Unlike their C counterparts, the following macros are not meant to
|
||||
* handle an int with any of the values [EOF, 0-UCHAR_MAX]. The argument
|
||||
* must be a signed/unsigned char. */
|
||||
#define Py_ISLOWER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_LOWER)
|
||||
#define Py_ISUPPER(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_UPPER)
|
||||
#define Py_ISALPHA(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALPHA)
|
||||
#define Py_ISDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_DIGIT)
|
||||
#define Py_ISXDIGIT(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_XDIGIT)
|
||||
#define Py_ISALNUM(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_ALNUM)
|
||||
#define Py_ISSPACE(c) (_Py_ctype_table[Py_CHARMASK(c)] & PY_CTF_SPACE)
|
||||
|
||||
PyAPI_DATA(const unsigned char) _Py_ctype_tolower[256];
|
||||
PyAPI_DATA(const unsigned char) _Py_ctype_toupper[256];
|
||||
|
||||
#define Py_TOLOWER(c) (_Py_ctype_tolower[Py_CHARMASK(c)])
|
||||
#define Py_TOUPPER(c) (_Py_ctype_toupper[Py_CHARMASK(c)])
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !PYCTYPE_H */
|
||||
#endif /* !Py_LIMITED_API */
|
||||
38
crypto/shamirs_secret_sharing/include/cpython/pydebug.h
Normal file
38
crypto/shamirs_secret_sharing/include/cpython/pydebug.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef Py_LIMITED_API
|
||||
#ifndef Py_PYDEBUG_H
|
||||
#define Py_PYDEBUG_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_DebugFlag;
|
||||
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_VerboseFlag;
|
||||
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_QuietFlag;
|
||||
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_InteractiveFlag;
|
||||
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_InspectFlag;
|
||||
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_OptimizeFlag;
|
||||
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_NoSiteFlag;
|
||||
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_BytesWarningFlag;
|
||||
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_FrozenFlag;
|
||||
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_IgnoreEnvironmentFlag;
|
||||
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_DontWriteBytecodeFlag;
|
||||
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_NoUserSiteDirectory;
|
||||
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_UnbufferedStdioFlag;
|
||||
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_HashRandomizationFlag;
|
||||
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_IsolatedFlag;
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_LegacyWindowsFSEncodingFlag;
|
||||
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_LegacyWindowsStdioFlag;
|
||||
#endif
|
||||
|
||||
/* this is a wrapper around getenv() that pays attention to
|
||||
Py_IgnoreEnvironmentFlag. It should be used for getting variables like
|
||||
PYTHONPATH and PYTHONHOME from the environment */
|
||||
PyAPI_FUNC(char*) Py_GETENV(const char *name);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_PYDEBUG_H */
|
||||
#endif /* Py_LIMITED_API */
|
||||
178
crypto/shamirs_secret_sharing/include/cpython/pyerrors.h
Normal file
178
crypto/shamirs_secret_sharing/include/cpython/pyerrors.h
Normal file
@@ -0,0 +1,178 @@
|
||||
#ifndef Py_CPYTHON_ERRORS_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
/* Error objects */
|
||||
|
||||
/* PyException_HEAD defines the initial segment of every exception class. */
|
||||
#define PyException_HEAD PyObject_HEAD PyObject *dict;\
|
||||
PyObject *args; PyObject *notes; PyObject *traceback;\
|
||||
PyObject *context; PyObject *cause;\
|
||||
char suppress_context;
|
||||
|
||||
typedef struct {
|
||||
PyException_HEAD
|
||||
} PyBaseExceptionObject;
|
||||
|
||||
typedef struct {
|
||||
PyException_HEAD
|
||||
PyObject *msg;
|
||||
PyObject *excs;
|
||||
} PyBaseExceptionGroupObject;
|
||||
|
||||
typedef struct {
|
||||
PyException_HEAD
|
||||
PyObject *msg;
|
||||
PyObject *filename;
|
||||
PyObject *lineno;
|
||||
PyObject *offset;
|
||||
PyObject *end_lineno;
|
||||
PyObject *end_offset;
|
||||
PyObject *text;
|
||||
PyObject *print_file_and_line;
|
||||
} PySyntaxErrorObject;
|
||||
|
||||
typedef struct {
|
||||
PyException_HEAD
|
||||
PyObject *msg;
|
||||
PyObject *name;
|
||||
PyObject *path;
|
||||
PyObject *name_from;
|
||||
} PyImportErrorObject;
|
||||
|
||||
typedef struct {
|
||||
PyException_HEAD
|
||||
PyObject *encoding;
|
||||
PyObject *object;
|
||||
Py_ssize_t start;
|
||||
Py_ssize_t end;
|
||||
PyObject *reason;
|
||||
} PyUnicodeErrorObject;
|
||||
|
||||
typedef struct {
|
||||
PyException_HEAD
|
||||
PyObject *code;
|
||||
} PySystemExitObject;
|
||||
|
||||
typedef struct {
|
||||
PyException_HEAD
|
||||
PyObject *myerrno;
|
||||
PyObject *strerror;
|
||||
PyObject *filename;
|
||||
PyObject *filename2;
|
||||
#ifdef MS_WINDOWS
|
||||
PyObject *winerror;
|
||||
#endif
|
||||
Py_ssize_t written; /* only for BlockingIOError, -1 otherwise */
|
||||
} PyOSErrorObject;
|
||||
|
||||
typedef struct {
|
||||
PyException_HEAD
|
||||
PyObject *value;
|
||||
} PyStopIterationObject;
|
||||
|
||||
typedef struct {
|
||||
PyException_HEAD
|
||||
PyObject *name;
|
||||
} PyNameErrorObject;
|
||||
|
||||
typedef struct {
|
||||
PyException_HEAD
|
||||
PyObject *obj;
|
||||
PyObject *name;
|
||||
} PyAttributeErrorObject;
|
||||
|
||||
/* Compatibility typedefs */
|
||||
typedef PyOSErrorObject PyEnvironmentErrorObject;
|
||||
#ifdef MS_WINDOWS
|
||||
typedef PyOSErrorObject PyWindowsErrorObject;
|
||||
#endif
|
||||
|
||||
/* Error handling definitions */
|
||||
|
||||
PyAPI_FUNC(void) _PyErr_SetKeyError(PyObject *);
|
||||
PyAPI_FUNC(_PyErr_StackItem*) _PyErr_GetTopmostException(PyThreadState *tstate);
|
||||
PyAPI_FUNC(PyObject*) _PyErr_GetHandledException(PyThreadState *);
|
||||
PyAPI_FUNC(void) _PyErr_SetHandledException(PyThreadState *, PyObject *);
|
||||
PyAPI_FUNC(void) _PyErr_GetExcInfo(PyThreadState *, PyObject **, PyObject **, PyObject **);
|
||||
|
||||
/* Context manipulation (PEP 3134) */
|
||||
|
||||
Py_DEPRECATED(3.12) PyAPI_FUNC(void) _PyErr_ChainExceptions(PyObject *, PyObject *, PyObject *);
|
||||
PyAPI_FUNC(void) _PyErr_ChainExceptions1(PyObject *);
|
||||
|
||||
/* Like PyErr_Format(), but saves current exception as __context__ and
|
||||
__cause__.
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) _PyErr_FormatFromCause(
|
||||
PyObject *exception,
|
||||
const char *format, /* ASCII-encoded string */
|
||||
...
|
||||
);
|
||||
|
||||
/* In exceptions.c */
|
||||
|
||||
PyAPI_FUNC(int) _PyException_AddNote(
|
||||
PyObject *exc,
|
||||
PyObject *note);
|
||||
|
||||
PyAPI_FUNC(PyObject*) PyUnstable_Exc_PrepReraiseStar(
|
||||
PyObject *orig,
|
||||
PyObject *excs);
|
||||
|
||||
/* In signalmodule.c */
|
||||
|
||||
int PySignal_SetWakeupFd(int fd);
|
||||
PyAPI_FUNC(int) _PyErr_CheckSignals(void);
|
||||
|
||||
/* Support for adding program text to SyntaxErrors */
|
||||
|
||||
PyAPI_FUNC(void) PyErr_SyntaxLocationObject(
|
||||
PyObject *filename,
|
||||
int lineno,
|
||||
int col_offset);
|
||||
|
||||
PyAPI_FUNC(void) PyErr_RangedSyntaxLocationObject(
|
||||
PyObject *filename,
|
||||
int lineno,
|
||||
int col_offset,
|
||||
int end_lineno,
|
||||
int end_col_offset);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyErr_ProgramTextObject(
|
||||
PyObject *filename,
|
||||
int lineno);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyErr_ProgramDecodedTextObject(
|
||||
PyObject *filename,
|
||||
int lineno,
|
||||
const char* encoding);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyUnicodeTranslateError_Create(
|
||||
PyObject *object,
|
||||
Py_ssize_t start,
|
||||
Py_ssize_t end,
|
||||
const char *reason /* UTF-8 encoded string */
|
||||
);
|
||||
|
||||
PyAPI_FUNC(void) _PyErr_WriteUnraisableMsg(
|
||||
const char *err_msg,
|
||||
PyObject *obj);
|
||||
|
||||
PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalErrorFunc(
|
||||
const char *func,
|
||||
const char *message);
|
||||
|
||||
PyAPI_FUNC(void) _Py_NO_RETURN _Py_FatalErrorFormat(
|
||||
const char *func,
|
||||
const char *format,
|
||||
...);
|
||||
|
||||
extern PyObject *_PyErr_SetImportErrorWithNameFrom(
|
||||
PyObject *,
|
||||
PyObject *,
|
||||
PyObject *,
|
||||
PyObject *);
|
||||
|
||||
|
||||
#define Py_FatalError(message) _Py_FatalErrorFunc(__func__, (message))
|
||||
15
crypto/shamirs_secret_sharing/include/cpython/pyfpe.h
Normal file
15
crypto/shamirs_secret_sharing/include/cpython/pyfpe.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifndef Py_PYFPE_H
|
||||
#define Py_PYFPE_H
|
||||
/* Header excluded from the stable API */
|
||||
#ifndef Py_LIMITED_API
|
||||
|
||||
/* These macros used to do something when Python was built with --with-fpectl,
|
||||
* but support for that was dropped in 3.7. We continue to define them though,
|
||||
* to avoid breaking API users.
|
||||
*/
|
||||
|
||||
#define PyFPE_START_PROTECT(err_string, leave_stmt)
|
||||
#define PyFPE_END_PROTECT(v)
|
||||
|
||||
#endif /* !defined(Py_LIMITED_API) */
|
||||
#endif /* !Py_PYFPE_H */
|
||||
35
crypto/shamirs_secret_sharing/include/cpython/pyframe.h
Normal file
35
crypto/shamirs_secret_sharing/include/cpython/pyframe.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef Py_CPYTHON_PYFRAME_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyFrame_Type;
|
||||
|
||||
#define PyFrame_Check(op) Py_IS_TYPE((op), &PyFrame_Type)
|
||||
|
||||
PyAPI_FUNC(PyFrameObject *) PyFrame_GetBack(PyFrameObject *frame);
|
||||
PyAPI_FUNC(PyObject *) PyFrame_GetLocals(PyFrameObject *frame);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyFrame_GetGlobals(PyFrameObject *frame);
|
||||
PyAPI_FUNC(PyObject *) PyFrame_GetBuiltins(PyFrameObject *frame);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyFrame_GetGenerator(PyFrameObject *frame);
|
||||
PyAPI_FUNC(int) PyFrame_GetLasti(PyFrameObject *frame);
|
||||
PyAPI_FUNC(PyObject*) PyFrame_GetVar(PyFrameObject *frame, PyObject *name);
|
||||
PyAPI_FUNC(PyObject*) PyFrame_GetVarString(PyFrameObject *frame, const char *name);
|
||||
|
||||
/* The following functions are for use by debuggers and other tools
|
||||
* implementing custom frame evaluators with PEP 523. */
|
||||
|
||||
struct _PyInterpreterFrame;
|
||||
|
||||
/* Returns the code object of the frame (strong reference).
|
||||
* Does not raise an exception. */
|
||||
PyAPI_FUNC(PyObject *) PyUnstable_InterpreterFrame_GetCode(struct _PyInterpreterFrame *frame);
|
||||
|
||||
/* Returns a byte ofsset into the last executed instruction.
|
||||
* Does not raise an exception. */
|
||||
PyAPI_FUNC(int) PyUnstable_InterpreterFrame_GetLasti(struct _PyInterpreterFrame *frame);
|
||||
|
||||
/* Returns the currently executing line number, or -1 if there is no line number.
|
||||
* Does not raise an exception. */
|
||||
PyAPI_FUNC(int) PyUnstable_InterpreterFrame_GetLine(struct _PyInterpreterFrame *frame);
|
||||
111
crypto/shamirs_secret_sharing/include/cpython/pylifecycle.h
Normal file
111
crypto/shamirs_secret_sharing/include/cpython/pylifecycle.h
Normal file
@@ -0,0 +1,111 @@
|
||||
#ifndef Py_CPYTHON_PYLIFECYCLE_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
/* Py_FrozenMain is kept out of the Limited API until documented and present
|
||||
in all builds of Python */
|
||||
PyAPI_FUNC(int) Py_FrozenMain(int argc, char **argv);
|
||||
|
||||
/* Only used by applications that embed the interpreter and need to
|
||||
* override the standard encoding determination mechanism
|
||||
*/
|
||||
Py_DEPRECATED(3.11) PyAPI_FUNC(int) Py_SetStandardStreamEncoding(
|
||||
const char *encoding,
|
||||
const char *errors);
|
||||
|
||||
/* PEP 432 Multi-phase initialization API (Private while provisional!) */
|
||||
|
||||
PyAPI_FUNC(PyStatus) Py_PreInitialize(
|
||||
const PyPreConfig *src_config);
|
||||
PyAPI_FUNC(PyStatus) Py_PreInitializeFromBytesArgs(
|
||||
const PyPreConfig *src_config,
|
||||
Py_ssize_t argc,
|
||||
char **argv);
|
||||
PyAPI_FUNC(PyStatus) Py_PreInitializeFromArgs(
|
||||
const PyPreConfig *src_config,
|
||||
Py_ssize_t argc,
|
||||
wchar_t **argv);
|
||||
|
||||
PyAPI_FUNC(int) _Py_IsCoreInitialized(void);
|
||||
|
||||
|
||||
/* Initialization and finalization */
|
||||
|
||||
PyAPI_FUNC(PyStatus) Py_InitializeFromConfig(
|
||||
const PyConfig *config);
|
||||
PyAPI_FUNC(PyStatus) _Py_InitializeMain(void);
|
||||
|
||||
PyAPI_FUNC(int) Py_RunMain(void);
|
||||
|
||||
|
||||
PyAPI_FUNC(void) _Py_NO_RETURN Py_ExitStatusException(PyStatus err);
|
||||
|
||||
/* Restore signals that the interpreter has called SIG_IGN on to SIG_DFL. */
|
||||
PyAPI_FUNC(void) _Py_RestoreSignals(void);
|
||||
|
||||
PyAPI_FUNC(int) Py_FdIsInteractive(FILE *, const char *);
|
||||
PyAPI_FUNC(int) _Py_FdIsInteractive(FILE *fp, PyObject *filename);
|
||||
|
||||
Py_DEPRECATED(3.11) PyAPI_FUNC(void) _Py_SetProgramFullPath(const wchar_t *);
|
||||
|
||||
PyAPI_FUNC(const char *) _Py_gitidentifier(void);
|
||||
PyAPI_FUNC(const char *) _Py_gitversion(void);
|
||||
|
||||
PyAPI_FUNC(int) _Py_IsFinalizing(void);
|
||||
PyAPI_FUNC(int) _Py_IsInterpreterFinalizing(PyInterpreterState *interp);
|
||||
|
||||
/* Random */
|
||||
PyAPI_FUNC(int) _PyOS_URandom(void *buffer, Py_ssize_t size);
|
||||
PyAPI_FUNC(int) _PyOS_URandomNonblock(void *buffer, Py_ssize_t size);
|
||||
|
||||
/* Legacy locale support */
|
||||
PyAPI_FUNC(int) _Py_CoerceLegacyLocale(int warn);
|
||||
PyAPI_FUNC(int) _Py_LegacyLocaleDetected(int warn);
|
||||
PyAPI_FUNC(char *) _Py_SetLocaleFromEnv(int category);
|
||||
|
||||
/* --- PyInterpreterConfig ------------------------------------ */
|
||||
|
||||
#define PyInterpreterConfig_DEFAULT_GIL (0)
|
||||
#define PyInterpreterConfig_SHARED_GIL (1)
|
||||
#define PyInterpreterConfig_OWN_GIL (2)
|
||||
|
||||
typedef struct {
|
||||
// XXX "allow_object_sharing"? "own_objects"?
|
||||
int use_main_obmalloc;
|
||||
int allow_fork;
|
||||
int allow_exec;
|
||||
int allow_threads;
|
||||
int allow_daemon_threads;
|
||||
int check_multi_interp_extensions;
|
||||
int gil;
|
||||
} PyInterpreterConfig;
|
||||
|
||||
#define _PyInterpreterConfig_INIT \
|
||||
{ \
|
||||
.use_main_obmalloc = 0, \
|
||||
.allow_fork = 0, \
|
||||
.allow_exec = 0, \
|
||||
.allow_threads = 1, \
|
||||
.allow_daemon_threads = 0, \
|
||||
.check_multi_interp_extensions = 1, \
|
||||
.gil = PyInterpreterConfig_OWN_GIL, \
|
||||
}
|
||||
|
||||
#define _PyInterpreterConfig_LEGACY_INIT \
|
||||
{ \
|
||||
.use_main_obmalloc = 1, \
|
||||
.allow_fork = 1, \
|
||||
.allow_exec = 1, \
|
||||
.allow_threads = 1, \
|
||||
.allow_daemon_threads = 1, \
|
||||
.check_multi_interp_extensions = 0, \
|
||||
.gil = PyInterpreterConfig_SHARED_GIL, \
|
||||
}
|
||||
|
||||
PyAPI_FUNC(PyStatus) Py_NewInterpreterFromConfig(
|
||||
PyThreadState **tstate_p,
|
||||
const PyInterpreterConfig *config);
|
||||
|
||||
typedef void (*atexit_datacallbackfunc)(void *);
|
||||
PyAPI_FUNC(int) _Py_AtExit(
|
||||
PyInterpreterState *, atexit_datacallbackfunc, void *);
|
||||
98
crypto/shamirs_secret_sharing/include/cpython/pymem.h
Normal file
98
crypto/shamirs_secret_sharing/include/cpython/pymem.h
Normal file
@@ -0,0 +1,98 @@
|
||||
#ifndef Py_CPYTHON_PYMEM_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(void *) PyMem_RawMalloc(size_t size);
|
||||
PyAPI_FUNC(void *) PyMem_RawCalloc(size_t nelem, size_t elsize);
|
||||
PyAPI_FUNC(void *) PyMem_RawRealloc(void *ptr, size_t new_size);
|
||||
PyAPI_FUNC(void) PyMem_RawFree(void *ptr);
|
||||
|
||||
/* Try to get the allocators name set by _PyMem_SetupAllocators(). */
|
||||
PyAPI_FUNC(const char*) _PyMem_GetCurrentAllocatorName(void);
|
||||
|
||||
/* strdup() using PyMem_RawMalloc() */
|
||||
PyAPI_FUNC(char *) _PyMem_RawStrdup(const char *str);
|
||||
|
||||
/* strdup() using PyMem_Malloc() */
|
||||
PyAPI_FUNC(char *) _PyMem_Strdup(const char *str);
|
||||
|
||||
/* wcsdup() using PyMem_RawMalloc() */
|
||||
PyAPI_FUNC(wchar_t*) _PyMem_RawWcsdup(const wchar_t *str);
|
||||
|
||||
|
||||
typedef enum {
|
||||
/* PyMem_RawMalloc(), PyMem_RawRealloc() and PyMem_RawFree() */
|
||||
PYMEM_DOMAIN_RAW,
|
||||
|
||||
/* PyMem_Malloc(), PyMem_Realloc() and PyMem_Free() */
|
||||
PYMEM_DOMAIN_MEM,
|
||||
|
||||
/* PyObject_Malloc(), PyObject_Realloc() and PyObject_Free() */
|
||||
PYMEM_DOMAIN_OBJ
|
||||
} PyMemAllocatorDomain;
|
||||
|
||||
typedef enum {
|
||||
PYMEM_ALLOCATOR_NOT_SET = 0,
|
||||
PYMEM_ALLOCATOR_DEFAULT = 1,
|
||||
PYMEM_ALLOCATOR_DEBUG = 2,
|
||||
PYMEM_ALLOCATOR_MALLOC = 3,
|
||||
PYMEM_ALLOCATOR_MALLOC_DEBUG = 4,
|
||||
#ifdef WITH_PYMALLOC
|
||||
PYMEM_ALLOCATOR_PYMALLOC = 5,
|
||||
PYMEM_ALLOCATOR_PYMALLOC_DEBUG = 6,
|
||||
#endif
|
||||
} PyMemAllocatorName;
|
||||
|
||||
|
||||
typedef struct {
|
||||
/* user context passed as the first argument to the 4 functions */
|
||||
void *ctx;
|
||||
|
||||
/* allocate a memory block */
|
||||
void* (*malloc) (void *ctx, size_t size);
|
||||
|
||||
/* allocate a memory block initialized by zeros */
|
||||
void* (*calloc) (void *ctx, size_t nelem, size_t elsize);
|
||||
|
||||
/* allocate or resize a memory block */
|
||||
void* (*realloc) (void *ctx, void *ptr, size_t new_size);
|
||||
|
||||
/* release a memory block */
|
||||
void (*free) (void *ctx, void *ptr);
|
||||
} PyMemAllocatorEx;
|
||||
|
||||
/* Get the memory block allocator of the specified domain. */
|
||||
PyAPI_FUNC(void) PyMem_GetAllocator(PyMemAllocatorDomain domain,
|
||||
PyMemAllocatorEx *allocator);
|
||||
|
||||
/* Set the memory block allocator of the specified domain.
|
||||
|
||||
The new allocator must return a distinct non-NULL pointer when requesting
|
||||
zero bytes.
|
||||
|
||||
For the PYMEM_DOMAIN_RAW domain, the allocator must be thread-safe: the GIL
|
||||
is not held when the allocator is called.
|
||||
|
||||
If the new allocator is not a hook (don't call the previous allocator), the
|
||||
PyMem_SetupDebugHooks() function must be called to reinstall the debug hooks
|
||||
on top on the new allocator. */
|
||||
PyAPI_FUNC(void) PyMem_SetAllocator(PyMemAllocatorDomain domain,
|
||||
PyMemAllocatorEx *allocator);
|
||||
|
||||
/* Setup hooks to detect bugs in the following Python memory allocator
|
||||
functions:
|
||||
|
||||
- PyMem_RawMalloc(), PyMem_RawRealloc(), PyMem_RawFree()
|
||||
- PyMem_Malloc(), PyMem_Realloc(), PyMem_Free()
|
||||
- PyObject_Malloc(), PyObject_Realloc() and PyObject_Free()
|
||||
|
||||
Newly allocated memory is filled with the byte 0xCB, freed memory is filled
|
||||
with the byte 0xDB. Additional checks:
|
||||
|
||||
- detect API violations, ex: PyObject_Free() called on a buffer allocated
|
||||
by PyMem_Malloc()
|
||||
- detect write before the start of the buffer (buffer underflow)
|
||||
- detect write after the end of the buffer (buffer overflow)
|
||||
|
||||
The function does nothing if Python is not compiled is debug mode. */
|
||||
PyAPI_FUNC(void) PyMem_SetupDebugHooks(void);
|
||||
456
crypto/shamirs_secret_sharing/include/cpython/pystate.h
Normal file
456
crypto/shamirs_secret_sharing/include/cpython/pystate.h
Normal file
@@ -0,0 +1,456 @@
|
||||
#ifndef Py_CPYTHON_PYSTATE_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
Runtime Feature Flags
|
||||
|
||||
Each flag indicate whether or not a specific runtime feature
|
||||
is available in a given context. For example, forking the process
|
||||
might not be allowed in the current interpreter (i.e. os.fork() would fail).
|
||||
*/
|
||||
|
||||
/* Set if the interpreter share obmalloc runtime state
|
||||
with the main interpreter. */
|
||||
#define Py_RTFLAGS_USE_MAIN_OBMALLOC (1UL << 5)
|
||||
|
||||
/* Set if import should check a module for subinterpreter support. */
|
||||
#define Py_RTFLAGS_MULTI_INTERP_EXTENSIONS (1UL << 8)
|
||||
|
||||
/* Set if threads are allowed. */
|
||||
#define Py_RTFLAGS_THREADS (1UL << 10)
|
||||
|
||||
/* Set if daemon threads are allowed. */
|
||||
#define Py_RTFLAGS_DAEMON_THREADS (1UL << 11)
|
||||
|
||||
/* Set if os.fork() is allowed. */
|
||||
#define Py_RTFLAGS_FORK (1UL << 15)
|
||||
|
||||
/* Set if os.exec*() is allowed. */
|
||||
#define Py_RTFLAGS_EXEC (1UL << 16)
|
||||
|
||||
|
||||
PyAPI_FUNC(int) _PyInterpreterState_HasFeature(PyInterpreterState *interp,
|
||||
unsigned long feature);
|
||||
|
||||
|
||||
/* private interpreter helpers */
|
||||
|
||||
PyAPI_FUNC(int) _PyInterpreterState_RequiresIDRef(PyInterpreterState *);
|
||||
PyAPI_FUNC(void) _PyInterpreterState_RequireIDRef(PyInterpreterState *, int);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyInterpreterState_GetMainModule(PyInterpreterState *);
|
||||
|
||||
|
||||
/* State unique per thread */
|
||||
|
||||
/* Py_tracefunc return -1 when raising an exception, or 0 for success. */
|
||||
typedef int (*Py_tracefunc)(PyObject *, PyFrameObject *, int, PyObject *);
|
||||
|
||||
/* The following values are used for 'what' for tracefunc functions
|
||||
*
|
||||
* To add a new kind of trace event, also update "trace_init" in
|
||||
* Python/sysmodule.c to define the Python level event name
|
||||
*/
|
||||
#define PyTrace_CALL 0
|
||||
#define PyTrace_EXCEPTION 1
|
||||
#define PyTrace_LINE 2
|
||||
#define PyTrace_RETURN 3
|
||||
#define PyTrace_C_CALL 4
|
||||
#define PyTrace_C_EXCEPTION 5
|
||||
#define PyTrace_C_RETURN 6
|
||||
#define PyTrace_OPCODE 7
|
||||
|
||||
// Internal structure: you should not use it directly, but use public functions
|
||||
// like PyThreadState_EnterTracing() and PyThreadState_LeaveTracing().
|
||||
typedef struct _PyCFrame {
|
||||
/* This struct will be threaded through the C stack
|
||||
* allowing fast access to per-thread state that needs
|
||||
* to be accessed quickly by the interpreter, but can
|
||||
* be modified outside of the interpreter.
|
||||
*
|
||||
* WARNING: This makes data on the C stack accessible from
|
||||
* heap objects. Care must be taken to maintain stack
|
||||
* discipline and make sure that instances of this struct cannot
|
||||
* accessed outside of their lifetime.
|
||||
*/
|
||||
/* Pointer to the currently executing frame (it can be NULL) */
|
||||
struct _PyInterpreterFrame *current_frame;
|
||||
struct _PyCFrame *previous;
|
||||
} _PyCFrame;
|
||||
|
||||
typedef struct _err_stackitem {
|
||||
/* This struct represents a single execution context where we might
|
||||
* be currently handling an exception. It is a per-coroutine state
|
||||
* (coroutine in the computer science sense, including the thread
|
||||
* and generators).
|
||||
*
|
||||
* This is used as an entry on the exception stack, where each
|
||||
* entry indicates if it is currently handling an exception.
|
||||
* This ensures that the exception state is not impacted
|
||||
* by "yields" from an except handler. The thread
|
||||
* always has an entry (the bottom-most one).
|
||||
*/
|
||||
|
||||
/* The exception currently being handled in this context, if any. */
|
||||
PyObject *exc_value;
|
||||
|
||||
struct _err_stackitem *previous_item;
|
||||
|
||||
} _PyErr_StackItem;
|
||||
|
||||
typedef struct _stack_chunk {
|
||||
struct _stack_chunk *previous;
|
||||
size_t size;
|
||||
size_t top;
|
||||
PyObject * data[1]; /* Variable sized */
|
||||
} _PyStackChunk;
|
||||
|
||||
struct _py_trashcan {
|
||||
int delete_nesting;
|
||||
PyObject *delete_later;
|
||||
};
|
||||
|
||||
struct _ts {
|
||||
/* See Python/ceval.c for comments explaining most fields */
|
||||
|
||||
PyThreadState *prev;
|
||||
PyThreadState *next;
|
||||
PyInterpreterState *interp;
|
||||
|
||||
struct {
|
||||
/* Has been initialized to a safe state.
|
||||
|
||||
In order to be effective, this must be set to 0 during or right
|
||||
after allocation. */
|
||||
unsigned int initialized:1;
|
||||
|
||||
/* Has been bound to an OS thread. */
|
||||
unsigned int bound:1;
|
||||
/* Has been unbound from its OS thread. */
|
||||
unsigned int unbound:1;
|
||||
/* Has been bound aa current for the GILState API. */
|
||||
unsigned int bound_gilstate:1;
|
||||
/* Currently in use (maybe holds the GIL). */
|
||||
unsigned int active:1;
|
||||
|
||||
/* various stages of finalization */
|
||||
unsigned int finalizing:1;
|
||||
unsigned int cleared:1;
|
||||
unsigned int finalized:1;
|
||||
|
||||
/* padding to align to 4 bytes */
|
||||
unsigned int :24;
|
||||
} _status;
|
||||
|
||||
int py_recursion_remaining;
|
||||
int py_recursion_limit;
|
||||
|
||||
int c_recursion_remaining;
|
||||
int recursion_headroom; /* Allow 50 more calls to handle any errors. */
|
||||
|
||||
/* 'tracing' keeps track of the execution depth when tracing/profiling.
|
||||
This is to prevent the actual trace/profile code from being recorded in
|
||||
the trace/profile. */
|
||||
int tracing;
|
||||
int what_event; /* The event currently being monitored, if any. */
|
||||
|
||||
/* Pointer to current _PyCFrame in the C stack frame of the currently,
|
||||
* or most recently, executing _PyEval_EvalFrameDefault. */
|
||||
_PyCFrame *cframe;
|
||||
|
||||
Py_tracefunc c_profilefunc;
|
||||
Py_tracefunc c_tracefunc;
|
||||
PyObject *c_profileobj;
|
||||
PyObject *c_traceobj;
|
||||
|
||||
/* The exception currently being raised */
|
||||
PyObject *current_exception;
|
||||
|
||||
/* Pointer to the top of the exception stack for the exceptions
|
||||
* we may be currently handling. (See _PyErr_StackItem above.)
|
||||
* This is never NULL. */
|
||||
_PyErr_StackItem *exc_info;
|
||||
|
||||
PyObject *dict; /* Stores per-thread state */
|
||||
|
||||
int gilstate_counter;
|
||||
|
||||
PyObject *async_exc; /* Asynchronous exception to raise */
|
||||
unsigned long thread_id; /* Thread id where this tstate was created */
|
||||
|
||||
/* Native thread id where this tstate was created. This will be 0 except on
|
||||
* those platforms that have the notion of native thread id, for which the
|
||||
* macro PY_HAVE_THREAD_NATIVE_ID is then defined.
|
||||
*/
|
||||
unsigned long native_thread_id;
|
||||
|
||||
struct _py_trashcan trash;
|
||||
|
||||
/* Called when a thread state is deleted normally, but not when it
|
||||
* is destroyed after fork().
|
||||
* Pain: to prevent rare but fatal shutdown errors (issue 18808),
|
||||
* Thread.join() must wait for the join'ed thread's tstate to be unlinked
|
||||
* from the tstate chain. That happens at the end of a thread's life,
|
||||
* in pystate.c.
|
||||
* The obvious way doesn't quite work: create a lock which the tstate
|
||||
* unlinking code releases, and have Thread.join() wait to acquire that
|
||||
* lock. The problem is that we _are_ at the end of the thread's life:
|
||||
* if the thread holds the last reference to the lock, decref'ing the
|
||||
* lock will delete the lock, and that may trigger arbitrary Python code
|
||||
* if there's a weakref, with a callback, to the lock. But by this time
|
||||
* _PyRuntime.gilstate.tstate_current is already NULL, so only the simplest
|
||||
* of C code can be allowed to run (in particular it must not be possible to
|
||||
* release the GIL).
|
||||
* So instead of holding the lock directly, the tstate holds a weakref to
|
||||
* the lock: that's the value of on_delete_data below. Decref'ing a
|
||||
* weakref is harmless.
|
||||
* on_delete points to _threadmodule.c's static release_sentinel() function.
|
||||
* After the tstate is unlinked, release_sentinel is called with the
|
||||
* weakref-to-lock (on_delete_data) argument, and release_sentinel releases
|
||||
* the indirectly held lock.
|
||||
*/
|
||||
void (*on_delete)(void *);
|
||||
void *on_delete_data;
|
||||
|
||||
int coroutine_origin_tracking_depth;
|
||||
|
||||
PyObject *async_gen_firstiter;
|
||||
PyObject *async_gen_finalizer;
|
||||
|
||||
PyObject *context;
|
||||
uint64_t context_ver;
|
||||
|
||||
/* Unique thread state id. */
|
||||
uint64_t id;
|
||||
|
||||
_PyStackChunk *datastack_chunk;
|
||||
PyObject **datastack_top;
|
||||
PyObject **datastack_limit;
|
||||
/* XXX signal handlers should also be here */
|
||||
|
||||
/* The following fields are here to avoid allocation during init.
|
||||
The data is exposed through PyThreadState pointer fields.
|
||||
These fields should not be accessed directly outside of init.
|
||||
This is indicated by an underscore prefix on the field names.
|
||||
|
||||
All other PyInterpreterState pointer fields are populated when
|
||||
needed and default to NULL.
|
||||
*/
|
||||
// Note some fields do not have a leading underscore for backward
|
||||
// compatibility. See https://bugs.python.org/issue45953#msg412046.
|
||||
|
||||
/* The thread's exception stack entry. (Always the last entry.) */
|
||||
_PyErr_StackItem exc_state;
|
||||
|
||||
/* The bottom-most frame on the stack. */
|
||||
_PyCFrame root_cframe;
|
||||
};
|
||||
|
||||
/* WASI has limited call stack. Python's recursion limit depends on code
|
||||
layout, optimization, and WASI runtime. Wasmtime can handle about 700
|
||||
recursions, sometimes less. 500 is a more conservative limit. */
|
||||
#ifdef Py_DEBUG
|
||||
# if defined(__wasi__)
|
||||
# define C_RECURSION_LIMIT 150
|
||||
# else
|
||||
# define C_RECURSION_LIMIT 500
|
||||
# endif
|
||||
#else
|
||||
# if defined(__wasi__)
|
||||
# define C_RECURSION_LIMIT 500
|
||||
# elif defined(__s390x__)
|
||||
# define C_RECURSION_LIMIT 800
|
||||
# elif defined(_WIN32)
|
||||
# define C_RECURSION_LIMIT 3000
|
||||
# elif defined(_Py_ADDRESS_SANITIZER)
|
||||
# define C_RECURSION_LIMIT 4000
|
||||
# else
|
||||
// This value is duplicated in Lib/test/support/__init__.py
|
||||
# define C_RECURSION_LIMIT 10000
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* other API */
|
||||
|
||||
// Alias for backward compatibility with Python 3.8
|
||||
#define _PyInterpreterState_Get PyInterpreterState_Get
|
||||
|
||||
/* An alias for the internal _PyThreadState_New(),
|
||||
kept for stable ABI compatibility. */
|
||||
PyAPI_FUNC(PyThreadState *) _PyThreadState_Prealloc(PyInterpreterState *);
|
||||
|
||||
/* Similar to PyThreadState_Get(), but don't issue a fatal error
|
||||
* if it is NULL. */
|
||||
PyAPI_FUNC(PyThreadState *) _PyThreadState_UncheckedGet(void);
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyThreadState_GetDict(PyThreadState *tstate);
|
||||
|
||||
// Disable tracing and profiling.
|
||||
PyAPI_FUNC(void) PyThreadState_EnterTracing(PyThreadState *tstate);
|
||||
|
||||
// Reset tracing and profiling: enable them if a trace function or a profile
|
||||
// function is set, otherwise disable them.
|
||||
PyAPI_FUNC(void) PyThreadState_LeaveTracing(PyThreadState *tstate);
|
||||
|
||||
/* PyGILState */
|
||||
|
||||
/* Helper/diagnostic function - return 1 if the current thread
|
||||
currently holds the GIL, 0 otherwise.
|
||||
|
||||
The function returns 1 if _PyGILState_check_enabled is non-zero. */
|
||||
PyAPI_FUNC(int) PyGILState_Check(void);
|
||||
|
||||
/* Get the single PyInterpreterState used by this process' GILState
|
||||
implementation.
|
||||
|
||||
This function doesn't check for error. Return NULL before _PyGILState_Init()
|
||||
is called and after _PyGILState_Fini() is called.
|
||||
|
||||
See also _PyInterpreterState_Get() and _PyInterpreterState_GET(). */
|
||||
PyAPI_FUNC(PyInterpreterState *) _PyGILState_GetInterpreterStateUnsafe(void);
|
||||
|
||||
/* The implementation of sys._current_frames() Returns a dict mapping
|
||||
thread id to that thread's current frame.
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) _PyThread_CurrentFrames(void);
|
||||
|
||||
/* The implementation of sys._current_exceptions() Returns a dict mapping
|
||||
thread id to that thread's current exception.
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) _PyThread_CurrentExceptions(void);
|
||||
|
||||
/* Routines for advanced debuggers, requested by David Beazley.
|
||||
Don't use unless you know what you are doing! */
|
||||
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Main(void);
|
||||
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void);
|
||||
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Next(PyInterpreterState *);
|
||||
PyAPI_FUNC(PyThreadState *) PyInterpreterState_ThreadHead(PyInterpreterState *);
|
||||
PyAPI_FUNC(PyThreadState *) PyThreadState_Next(PyThreadState *);
|
||||
PyAPI_FUNC(void) PyThreadState_DeleteCurrent(void);
|
||||
|
||||
/* Frame evaluation API */
|
||||
|
||||
typedef PyObject* (*_PyFrameEvalFunction)(PyThreadState *tstate, struct _PyInterpreterFrame *, int);
|
||||
|
||||
PyAPI_FUNC(_PyFrameEvalFunction) _PyInterpreterState_GetEvalFrameFunc(
|
||||
PyInterpreterState *interp);
|
||||
PyAPI_FUNC(void) _PyInterpreterState_SetEvalFrameFunc(
|
||||
PyInterpreterState *interp,
|
||||
_PyFrameEvalFunction eval_frame);
|
||||
|
||||
PyAPI_FUNC(const PyConfig*) _PyInterpreterState_GetConfig(PyInterpreterState *interp);
|
||||
|
||||
/* Get a copy of the current interpreter configuration.
|
||||
|
||||
Return 0 on success. Raise an exception and return -1 on error.
|
||||
|
||||
The caller must initialize 'config', using PyConfig_InitPythonConfig()
|
||||
for example.
|
||||
|
||||
Python must be preinitialized to call this method.
|
||||
The caller must hold the GIL.
|
||||
|
||||
Once done with the configuration, PyConfig_Clear() must be called to clear
|
||||
it. */
|
||||
PyAPI_FUNC(int) _PyInterpreterState_GetConfigCopy(
|
||||
struct PyConfig *config);
|
||||
|
||||
/* Set the configuration of the current interpreter.
|
||||
|
||||
This function should be called during or just after the Python
|
||||
initialization.
|
||||
|
||||
Update the sys module with the new configuration. If the sys module was
|
||||
modified directly after the Python initialization, these changes are lost.
|
||||
|
||||
Some configuration like faulthandler or warnoptions can be updated in the
|
||||
configuration, but don't reconfigure Python (don't enable/disable
|
||||
faulthandler and don't reconfigure warnings filters).
|
||||
|
||||
Return 0 on success. Raise an exception and return -1 on error.
|
||||
|
||||
The configuration should come from _PyInterpreterState_GetConfigCopy(). */
|
||||
PyAPI_FUNC(int) _PyInterpreterState_SetConfig(
|
||||
const struct PyConfig *config);
|
||||
|
||||
// Get the configuration of the current interpreter.
|
||||
// The caller must hold the GIL.
|
||||
PyAPI_FUNC(const PyConfig*) _Py_GetConfig(void);
|
||||
|
||||
|
||||
/* cross-interpreter data */
|
||||
|
||||
// _PyCrossInterpreterData is similar to Py_buffer as an effectively
|
||||
// opaque struct that holds data outside the object machinery. This
|
||||
// is necessary to pass safely between interpreters in the same process.
|
||||
typedef struct _xid _PyCrossInterpreterData;
|
||||
|
||||
typedef PyObject *(*xid_newobjectfunc)(_PyCrossInterpreterData *);
|
||||
typedef void (*xid_freefunc)(void *);
|
||||
|
||||
struct _xid {
|
||||
// data is the cross-interpreter-safe derivation of a Python object
|
||||
// (see _PyObject_GetCrossInterpreterData). It will be NULL if the
|
||||
// new_object func (below) encodes the data.
|
||||
void *data;
|
||||
// obj is the Python object from which the data was derived. This
|
||||
// is non-NULL only if the data remains bound to the object in some
|
||||
// way, such that the object must be "released" (via a decref) when
|
||||
// the data is released. In that case the code that sets the field,
|
||||
// likely a registered "crossinterpdatafunc", is responsible for
|
||||
// ensuring it owns the reference (i.e. incref).
|
||||
PyObject *obj;
|
||||
// interp is the ID of the owning interpreter of the original
|
||||
// object. It corresponds to the active interpreter when
|
||||
// _PyObject_GetCrossInterpreterData() was called. This should only
|
||||
// be set by the cross-interpreter machinery.
|
||||
//
|
||||
// We use the ID rather than the PyInterpreterState to avoid issues
|
||||
// with deleted interpreters. Note that IDs are never re-used, so
|
||||
// each one will always correspond to a specific interpreter
|
||||
// (whether still alive or not).
|
||||
int64_t interp;
|
||||
// new_object is a function that returns a new object in the current
|
||||
// interpreter given the data. The resulting object (a new
|
||||
// reference) will be equivalent to the original object. This field
|
||||
// is required.
|
||||
xid_newobjectfunc new_object;
|
||||
// free is called when the data is released. If it is NULL then
|
||||
// nothing will be done to free the data. For some types this is
|
||||
// okay (e.g. bytes) and for those types this field should be set
|
||||
// to NULL. However, for most the data was allocated just for
|
||||
// cross-interpreter use, so it must be freed when
|
||||
// _PyCrossInterpreterData_Release is called or the memory will
|
||||
// leak. In that case, at the very least this field should be set
|
||||
// to PyMem_RawFree (the default if not explicitly set to NULL).
|
||||
// The call will happen with the original interpreter activated.
|
||||
xid_freefunc free;
|
||||
};
|
||||
|
||||
PyAPI_FUNC(void) _PyCrossInterpreterData_Init(
|
||||
_PyCrossInterpreterData *data,
|
||||
PyInterpreterState *interp, void *shared, PyObject *obj,
|
||||
xid_newobjectfunc new_object);
|
||||
PyAPI_FUNC(int) _PyCrossInterpreterData_InitWithSize(
|
||||
_PyCrossInterpreterData *,
|
||||
PyInterpreterState *interp, const size_t, PyObject *,
|
||||
xid_newobjectfunc);
|
||||
PyAPI_FUNC(void) _PyCrossInterpreterData_Clear(
|
||||
PyInterpreterState *, _PyCrossInterpreterData *);
|
||||
|
||||
PyAPI_FUNC(int) _PyObject_GetCrossInterpreterData(PyObject *, _PyCrossInterpreterData *);
|
||||
PyAPI_FUNC(PyObject *) _PyCrossInterpreterData_NewObject(_PyCrossInterpreterData *);
|
||||
PyAPI_FUNC(int) _PyCrossInterpreterData_Release(_PyCrossInterpreterData *);
|
||||
|
||||
PyAPI_FUNC(int) _PyObject_CheckCrossInterpreterData(PyObject *);
|
||||
|
||||
/* cross-interpreter data registry */
|
||||
|
||||
typedef int (*crossinterpdatafunc)(PyThreadState *tstate, PyObject *,
|
||||
_PyCrossInterpreterData *);
|
||||
|
||||
PyAPI_FUNC(int) _PyCrossInterpreterData_RegisterClass(PyTypeObject *, crossinterpdatafunc);
|
||||
PyAPI_FUNC(int) _PyCrossInterpreterData_UnregisterClass(PyTypeObject *);
|
||||
PyAPI_FUNC(crossinterpdatafunc) _PyCrossInterpreterData_Lookup(PyObject *);
|
||||
121
crypto/shamirs_secret_sharing/include/cpython/pythonrun.h
Normal file
121
crypto/shamirs_secret_sharing/include/cpython/pythonrun.h
Normal file
@@ -0,0 +1,121 @@
|
||||
#ifndef Py_CPYTHON_PYTHONRUN_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(int) PyRun_SimpleStringFlags(const char *, PyCompilerFlags *);
|
||||
PyAPI_FUNC(int) _PyRun_SimpleFileObject(
|
||||
FILE *fp,
|
||||
PyObject *filename,
|
||||
int closeit,
|
||||
PyCompilerFlags *flags);
|
||||
PyAPI_FUNC(int) PyRun_AnyFileExFlags(
|
||||
FILE *fp,
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
int closeit,
|
||||
PyCompilerFlags *flags);
|
||||
PyAPI_FUNC(int) _PyRun_AnyFileObject(
|
||||
FILE *fp,
|
||||
PyObject *filename,
|
||||
int closeit,
|
||||
PyCompilerFlags *flags);
|
||||
PyAPI_FUNC(int) PyRun_SimpleFileExFlags(
|
||||
FILE *fp,
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
int closeit,
|
||||
PyCompilerFlags *flags);
|
||||
PyAPI_FUNC(int) PyRun_InteractiveOneFlags(
|
||||
FILE *fp,
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
PyCompilerFlags *flags);
|
||||
PyAPI_FUNC(int) PyRun_InteractiveOneObject(
|
||||
FILE *fp,
|
||||
PyObject *filename,
|
||||
PyCompilerFlags *flags);
|
||||
PyAPI_FUNC(int) PyRun_InteractiveLoopFlags(
|
||||
FILE *fp,
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
PyCompilerFlags *flags);
|
||||
PyAPI_FUNC(int) _PyRun_InteractiveLoopObject(
|
||||
FILE *fp,
|
||||
PyObject *filename,
|
||||
PyCompilerFlags *flags);
|
||||
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyRun_StringFlags(const char *, int, PyObject *,
|
||||
PyObject *, PyCompilerFlags *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyRun_FileExFlags(
|
||||
FILE *fp,
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
int start,
|
||||
PyObject *globals,
|
||||
PyObject *locals,
|
||||
int closeit,
|
||||
PyCompilerFlags *flags);
|
||||
|
||||
|
||||
PyAPI_FUNC(PyObject *) Py_CompileStringExFlags(
|
||||
const char *str,
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
int start,
|
||||
PyCompilerFlags *flags,
|
||||
int optimize);
|
||||
PyAPI_FUNC(PyObject *) Py_CompileStringObject(
|
||||
const char *str,
|
||||
PyObject *filename, int start,
|
||||
PyCompilerFlags *flags,
|
||||
int optimize);
|
||||
|
||||
#define Py_CompileString(str, p, s) Py_CompileStringExFlags((str), (p), (s), NULL, -1)
|
||||
#define Py_CompileStringFlags(str, p, s, f) Py_CompileStringExFlags((str), (p), (s), (f), -1)
|
||||
|
||||
|
||||
PyAPI_FUNC(const char *) _Py_SourceAsString(
|
||||
PyObject *cmd,
|
||||
const char *funcname,
|
||||
const char *what,
|
||||
PyCompilerFlags *cf,
|
||||
PyObject **cmd_copy);
|
||||
|
||||
|
||||
/* A function flavor is also exported by libpython. It is required when
|
||||
libpython is accessed directly rather than using header files which defines
|
||||
macros below. On Windows, for example, PyAPI_FUNC() uses dllexport to
|
||||
export functions in pythonXX.dll. */
|
||||
PyAPI_FUNC(PyObject *) PyRun_String(const char *str, int s, PyObject *g, PyObject *l);
|
||||
PyAPI_FUNC(int) PyRun_AnyFile(FILE *fp, const char *name);
|
||||
PyAPI_FUNC(int) PyRun_AnyFileEx(FILE *fp, const char *name, int closeit);
|
||||
PyAPI_FUNC(int) PyRun_AnyFileFlags(FILE *, const char *, PyCompilerFlags *);
|
||||
PyAPI_FUNC(int) PyRun_SimpleString(const char *s);
|
||||
PyAPI_FUNC(int) PyRun_SimpleFile(FILE *f, const char *p);
|
||||
PyAPI_FUNC(int) PyRun_SimpleFileEx(FILE *f, const char *p, int c);
|
||||
PyAPI_FUNC(int) PyRun_InteractiveOne(FILE *f, const char *p);
|
||||
PyAPI_FUNC(int) PyRun_InteractiveLoop(FILE *f, const char *p);
|
||||
PyAPI_FUNC(PyObject *) PyRun_File(FILE *fp, const char *p, int s, PyObject *g, PyObject *l);
|
||||
PyAPI_FUNC(PyObject *) PyRun_FileEx(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, int c);
|
||||
PyAPI_FUNC(PyObject *) PyRun_FileFlags(FILE *fp, const char *p, int s, PyObject *g, PyObject *l, PyCompilerFlags *flags);
|
||||
|
||||
/* Use macros for a bunch of old variants */
|
||||
#define PyRun_String(str, s, g, l) PyRun_StringFlags((str), (s), (g), (l), NULL)
|
||||
#define PyRun_AnyFile(fp, name) PyRun_AnyFileExFlags((fp), (name), 0, NULL)
|
||||
#define PyRun_AnyFileEx(fp, name, closeit) \
|
||||
PyRun_AnyFileExFlags((fp), (name), (closeit), NULL)
|
||||
#define PyRun_AnyFileFlags(fp, name, flags) \
|
||||
PyRun_AnyFileExFlags((fp), (name), 0, (flags))
|
||||
#define PyRun_SimpleString(s) PyRun_SimpleStringFlags((s), NULL)
|
||||
#define PyRun_SimpleFile(f, p) PyRun_SimpleFileExFlags((f), (p), 0, NULL)
|
||||
#define PyRun_SimpleFileEx(f, p, c) PyRun_SimpleFileExFlags((f), (p), (c), NULL)
|
||||
#define PyRun_InteractiveOne(f, p) PyRun_InteractiveOneFlags((f), (p), NULL)
|
||||
#define PyRun_InteractiveLoop(f, p) PyRun_InteractiveLoopFlags((f), (p), NULL)
|
||||
#define PyRun_File(fp, p, s, g, l) \
|
||||
PyRun_FileExFlags((fp), (p), (s), (g), (l), 0, NULL)
|
||||
#define PyRun_FileEx(fp, p, s, g, l, c) \
|
||||
PyRun_FileExFlags((fp), (p), (s), (g), (l), (c), NULL)
|
||||
#define PyRun_FileFlags(fp, p, s, g, l, flags) \
|
||||
PyRun_FileExFlags((fp), (p), (s), (g), (l), 0, (flags))
|
||||
|
||||
|
||||
/* Stuff with no proper home (yet) */
|
||||
PyAPI_FUNC(char *) PyOS_Readline(FILE *, FILE *, const char *);
|
||||
PyAPI_DATA(PyThreadState*) _PyOS_ReadlineTState;
|
||||
PyAPI_DATA(char) *(*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, const char *);
|
||||
42
crypto/shamirs_secret_sharing/include/cpython/pythread.h
Normal file
42
crypto/shamirs_secret_sharing/include/cpython/pythread.h
Normal file
@@ -0,0 +1,42 @@
|
||||
#ifndef Py_CPYTHON_PYTHREAD_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
#define PYTHREAD_INVALID_THREAD_ID ((unsigned long)-1)
|
||||
|
||||
#ifdef HAVE_FORK
|
||||
/* Private function to reinitialize a lock at fork in the child process.
|
||||
Reset the lock to the unlocked state.
|
||||
Return 0 on success, return -1 on error. */
|
||||
PyAPI_FUNC(int) _PyThread_at_fork_reinit(PyThread_type_lock *lock);
|
||||
#endif /* HAVE_FORK */
|
||||
|
||||
#ifdef HAVE_PTHREAD_H
|
||||
/* Darwin needs pthread.h to know type name the pthread_key_t. */
|
||||
# include <pthread.h>
|
||||
# define NATIVE_TSS_KEY_T pthread_key_t
|
||||
#elif defined(NT_THREADS)
|
||||
/* In Windows, native TSS key type is DWORD,
|
||||
but hardcode the unsigned long to avoid errors for include directive.
|
||||
*/
|
||||
# define NATIVE_TSS_KEY_T unsigned long
|
||||
#elif defined(HAVE_PTHREAD_STUBS)
|
||||
# include "cpython/pthread_stubs.h"
|
||||
# define NATIVE_TSS_KEY_T pthread_key_t
|
||||
#else
|
||||
# error "Require native threads. See https://bugs.python.org/issue31370"
|
||||
#endif
|
||||
|
||||
/* When Py_LIMITED_API is not defined, the type layout of Py_tss_t is
|
||||
exposed to allow static allocation in the API clients. Even in this case,
|
||||
you must handle TSS keys through API functions due to compatibility.
|
||||
*/
|
||||
struct _Py_tss_t {
|
||||
int _is_initialized;
|
||||
NATIVE_TSS_KEY_T _key;
|
||||
};
|
||||
|
||||
#undef NATIVE_TSS_KEY_T
|
||||
|
||||
/* When static allocation, you must initialize with Py_tss_NEEDS_INIT. */
|
||||
#define Py_tss_NEEDS_INIT {0}
|
||||
331
crypto/shamirs_secret_sharing/include/cpython/pytime.h
Normal file
331
crypto/shamirs_secret_sharing/include/cpython/pytime.h
Normal file
@@ -0,0 +1,331 @@
|
||||
// The _PyTime_t API is written to use timestamp and timeout values stored in
|
||||
// various formats and to read clocks.
|
||||
//
|
||||
// The _PyTime_t type is an integer to support directly common arithmetic
|
||||
// operations like t1 + t2.
|
||||
//
|
||||
// The _PyTime_t API supports a resolution of 1 nanosecond. The _PyTime_t type
|
||||
// is signed to support negative timestamps. The supported range is around
|
||||
// [-292.3 years; +292.3 years]. Using the Unix epoch (January 1st, 1970), the
|
||||
// supported date range is around [1677-09-21; 2262-04-11].
|
||||
//
|
||||
// Formats:
|
||||
//
|
||||
// * seconds
|
||||
// * seconds as a floating pointer number (C double)
|
||||
// * milliseconds (10^-3 seconds)
|
||||
// * microseconds (10^-6 seconds)
|
||||
// * 100 nanoseconds (10^-7 seconds)
|
||||
// * nanoseconds (10^-9 seconds)
|
||||
// * timeval structure, 1 microsecond resolution (10^-6 seconds)
|
||||
// * timespec structure, 1 nanosecond resolution (10^-9 seconds)
|
||||
//
|
||||
// Integer overflows are detected and raise OverflowError. Conversion to a
|
||||
// resolution worse than 1 nanosecond is rounded correctly with the requested
|
||||
// rounding mode. There are 4 rounding modes: floor (towards -inf), ceiling
|
||||
// (towards +inf), half even and up (away from zero).
|
||||
//
|
||||
// Some functions clamp the result in the range [_PyTime_MIN; _PyTime_MAX], so
|
||||
// the caller doesn't have to handle errors and doesn't need to hold the GIL.
|
||||
// For example, _PyTime_Add(t1, t2) computes t1+t2 and clamp the result on
|
||||
// overflow.
|
||||
//
|
||||
// Clocks:
|
||||
//
|
||||
// * System clock
|
||||
// * Monotonic clock
|
||||
// * Performance counter
|
||||
//
|
||||
// Operations like (t * k / q) with integers are implemented in a way to reduce
|
||||
// the risk of integer overflow. Such operation is used to convert a clock
|
||||
// value expressed in ticks with a frequency to _PyTime_t, like
|
||||
// QueryPerformanceCounter() with QueryPerformanceFrequency().
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
#ifndef Py_PYTIME_H
|
||||
#define Py_PYTIME_H
|
||||
|
||||
/**************************************************************************
|
||||
Symbols and macros to supply platform-independent interfaces to time related
|
||||
functions and constants
|
||||
**************************************************************************/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef __clang__
|
||||
struct timeval;
|
||||
#endif
|
||||
|
||||
/* _PyTime_t: Python timestamp with subsecond precision. It can be used to
|
||||
store a duration, and so indirectly a date (related to another date, like
|
||||
UNIX epoch). */
|
||||
typedef int64_t _PyTime_t;
|
||||
// _PyTime_MIN nanoseconds is around -292.3 years
|
||||
#define _PyTime_MIN INT64_MIN
|
||||
// _PyTime_MAX nanoseconds is around +292.3 years
|
||||
#define _PyTime_MAX INT64_MAX
|
||||
#define _SIZEOF_PYTIME_T 8
|
||||
|
||||
typedef enum {
|
||||
/* Round towards minus infinity (-inf).
|
||||
For example, used to read a clock. */
|
||||
_PyTime_ROUND_FLOOR=0,
|
||||
/* Round towards infinity (+inf).
|
||||
For example, used for timeout to wait "at least" N seconds. */
|
||||
_PyTime_ROUND_CEILING=1,
|
||||
/* Round to nearest with ties going to nearest even integer.
|
||||
For example, used to round from a Python float. */
|
||||
_PyTime_ROUND_HALF_EVEN=2,
|
||||
/* Round away from zero
|
||||
For example, used for timeout. _PyTime_ROUND_CEILING rounds
|
||||
-1e-9 to 0 milliseconds which causes bpo-31786 issue.
|
||||
_PyTime_ROUND_UP rounds -1e-9 to -1 millisecond which keeps
|
||||
the timeout sign as expected. select.poll(timeout) must block
|
||||
for negative values." */
|
||||
_PyTime_ROUND_UP=3,
|
||||
/* _PyTime_ROUND_TIMEOUT (an alias for _PyTime_ROUND_UP) should be
|
||||
used for timeouts. */
|
||||
_PyTime_ROUND_TIMEOUT = _PyTime_ROUND_UP
|
||||
} _PyTime_round_t;
|
||||
|
||||
|
||||
/* Convert a time_t to a PyLong. */
|
||||
PyAPI_FUNC(PyObject *) _PyLong_FromTime_t(
|
||||
time_t sec);
|
||||
|
||||
/* Convert a PyLong to a time_t. */
|
||||
PyAPI_FUNC(time_t) _PyLong_AsTime_t(
|
||||
PyObject *obj);
|
||||
|
||||
/* Convert a number of seconds, int or float, to time_t. */
|
||||
PyAPI_FUNC(int) _PyTime_ObjectToTime_t(
|
||||
PyObject *obj,
|
||||
time_t *sec,
|
||||
_PyTime_round_t);
|
||||
|
||||
/* Convert a number of seconds, int or float, to a timeval structure.
|
||||
usec is in the range [0; 999999] and rounded towards zero.
|
||||
For example, -1.2 is converted to (-2, 800000). */
|
||||
PyAPI_FUNC(int) _PyTime_ObjectToTimeval(
|
||||
PyObject *obj,
|
||||
time_t *sec,
|
||||
long *usec,
|
||||
_PyTime_round_t);
|
||||
|
||||
/* Convert a number of seconds, int or float, to a timespec structure.
|
||||
nsec is in the range [0; 999999999] and rounded towards zero.
|
||||
For example, -1.2 is converted to (-2, 800000000). */
|
||||
PyAPI_FUNC(int) _PyTime_ObjectToTimespec(
|
||||
PyObject *obj,
|
||||
time_t *sec,
|
||||
long *nsec,
|
||||
_PyTime_round_t);
|
||||
|
||||
|
||||
/* Create a timestamp from a number of seconds. */
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_FromSeconds(int seconds);
|
||||
|
||||
/* Macro to create a timestamp from a number of seconds, no integer overflow.
|
||||
Only use the macro for small values, prefer _PyTime_FromSeconds(). */
|
||||
#define _PYTIME_FROMSECONDS(seconds) \
|
||||
((_PyTime_t)(seconds) * (1000 * 1000 * 1000))
|
||||
|
||||
/* Create a timestamp from a number of nanoseconds. */
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_FromNanoseconds(_PyTime_t ns);
|
||||
|
||||
/* Create a timestamp from a number of microseconds.
|
||||
* Clamp to [_PyTime_MIN; _PyTime_MAX] on overflow. */
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_FromMicrosecondsClamp(_PyTime_t us);
|
||||
|
||||
/* Create a timestamp from nanoseconds (Python int). */
|
||||
PyAPI_FUNC(int) _PyTime_FromNanosecondsObject(_PyTime_t *t,
|
||||
PyObject *obj);
|
||||
|
||||
/* Convert a number of seconds (Python float or int) to a timestamp.
|
||||
Raise an exception and return -1 on error, return 0 on success. */
|
||||
PyAPI_FUNC(int) _PyTime_FromSecondsObject(_PyTime_t *t,
|
||||
PyObject *obj,
|
||||
_PyTime_round_t round);
|
||||
|
||||
/* Convert a number of milliseconds (Python float or int, 10^-3) to a timestamp.
|
||||
Raise an exception and return -1 on error, return 0 on success. */
|
||||
PyAPI_FUNC(int) _PyTime_FromMillisecondsObject(_PyTime_t *t,
|
||||
PyObject *obj,
|
||||
_PyTime_round_t round);
|
||||
|
||||
/* Convert a timestamp to a number of seconds as a C double. */
|
||||
PyAPI_FUNC(double) _PyTime_AsSecondsDouble(_PyTime_t t);
|
||||
|
||||
/* Convert timestamp to a number of milliseconds (10^-3 seconds). */
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_AsMilliseconds(_PyTime_t t,
|
||||
_PyTime_round_t round);
|
||||
|
||||
/* Convert timestamp to a number of microseconds (10^-6 seconds). */
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_AsMicroseconds(_PyTime_t t,
|
||||
_PyTime_round_t round);
|
||||
|
||||
/* Convert timestamp to a number of nanoseconds (10^-9 seconds). */
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_AsNanoseconds(_PyTime_t t);
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
// Convert timestamp to a number of 100 nanoseconds (10^-7 seconds).
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_As100Nanoseconds(_PyTime_t t,
|
||||
_PyTime_round_t round);
|
||||
#endif
|
||||
|
||||
/* Convert timestamp to a number of nanoseconds (10^-9 seconds) as a Python int
|
||||
object. */
|
||||
PyAPI_FUNC(PyObject *) _PyTime_AsNanosecondsObject(_PyTime_t t);
|
||||
|
||||
#ifndef MS_WINDOWS
|
||||
/* Create a timestamp from a timeval structure.
|
||||
Raise an exception and return -1 on overflow, return 0 on success. */
|
||||
PyAPI_FUNC(int) _PyTime_FromTimeval(_PyTime_t *tp, struct timeval *tv);
|
||||
#endif
|
||||
|
||||
/* Convert a timestamp to a timeval structure (microsecond resolution).
|
||||
tv_usec is always positive.
|
||||
Raise an exception and return -1 if the conversion overflowed,
|
||||
return 0 on success. */
|
||||
PyAPI_FUNC(int) _PyTime_AsTimeval(_PyTime_t t,
|
||||
struct timeval *tv,
|
||||
_PyTime_round_t round);
|
||||
|
||||
/* Similar to _PyTime_AsTimeval() but don't raise an exception on overflow.
|
||||
On overflow, clamp tv_sec to _PyTime_t min/max. */
|
||||
PyAPI_FUNC(void) _PyTime_AsTimeval_clamp(_PyTime_t t,
|
||||
struct timeval *tv,
|
||||
_PyTime_round_t round);
|
||||
|
||||
/* Convert a timestamp to a number of seconds (secs) and microseconds (us).
|
||||
us is always positive. This function is similar to _PyTime_AsTimeval()
|
||||
except that secs is always a time_t type, whereas the timeval structure
|
||||
uses a C long for tv_sec on Windows.
|
||||
Raise an exception and return -1 if the conversion overflowed,
|
||||
return 0 on success. */
|
||||
PyAPI_FUNC(int) _PyTime_AsTimevalTime_t(
|
||||
_PyTime_t t,
|
||||
time_t *secs,
|
||||
int *us,
|
||||
_PyTime_round_t round);
|
||||
|
||||
#if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_KQUEUE)
|
||||
/* Create a timestamp from a timespec structure.
|
||||
Raise an exception and return -1 on overflow, return 0 on success. */
|
||||
PyAPI_FUNC(int) _PyTime_FromTimespec(_PyTime_t *tp, struct timespec *ts);
|
||||
|
||||
/* Convert a timestamp to a timespec structure (nanosecond resolution).
|
||||
tv_nsec is always positive.
|
||||
Raise an exception and return -1 on error, return 0 on success. */
|
||||
PyAPI_FUNC(int) _PyTime_AsTimespec(_PyTime_t t, struct timespec *ts);
|
||||
|
||||
/* Similar to _PyTime_AsTimespec() but don't raise an exception on overflow.
|
||||
On overflow, clamp tv_sec to _PyTime_t min/max. */
|
||||
PyAPI_FUNC(void) _PyTime_AsTimespec_clamp(_PyTime_t t, struct timespec *ts);
|
||||
#endif
|
||||
|
||||
|
||||
// Compute t1 + t2. Clamp to [_PyTime_MIN; _PyTime_MAX] on overflow.
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_Add(_PyTime_t t1, _PyTime_t t2);
|
||||
|
||||
/* Compute ticks * mul / div.
|
||||
Clamp to [_PyTime_MIN; _PyTime_MAX] on overflow.
|
||||
The caller must ensure that ((div - 1) * mul) cannot overflow. */
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_MulDiv(_PyTime_t ticks,
|
||||
_PyTime_t mul,
|
||||
_PyTime_t div);
|
||||
|
||||
/* Structure used by time.get_clock_info() */
|
||||
typedef struct {
|
||||
const char *implementation;
|
||||
int monotonic;
|
||||
int adjustable;
|
||||
double resolution;
|
||||
} _Py_clock_info_t;
|
||||
|
||||
/* Get the current time from the system clock.
|
||||
|
||||
If the internal clock fails, silently ignore the error and return 0.
|
||||
On integer overflow, silently ignore the overflow and clamp the clock to
|
||||
[_PyTime_MIN; _PyTime_MAX].
|
||||
|
||||
Use _PyTime_GetSystemClockWithInfo() to check for failure. */
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_GetSystemClock(void);
|
||||
|
||||
/* Get the current time from the system clock.
|
||||
* On success, set *t and *info (if not NULL), and return 0.
|
||||
* On error, raise an exception and return -1.
|
||||
*/
|
||||
PyAPI_FUNC(int) _PyTime_GetSystemClockWithInfo(
|
||||
_PyTime_t *t,
|
||||
_Py_clock_info_t *info);
|
||||
|
||||
/* Get the time of a monotonic clock, i.e. a clock that cannot go backwards.
|
||||
The clock is not affected by system clock updates. The reference point of
|
||||
the returned value is undefined, so that only the difference between the
|
||||
results of consecutive calls is valid.
|
||||
|
||||
If the internal clock fails, silently ignore the error and return 0.
|
||||
On integer overflow, silently ignore the overflow and clamp the clock to
|
||||
[_PyTime_MIN; _PyTime_MAX].
|
||||
|
||||
Use _PyTime_GetMonotonicClockWithInfo() to check for failure. */
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_GetMonotonicClock(void);
|
||||
|
||||
/* Get the time of a monotonic clock, i.e. a clock that cannot go backwards.
|
||||
The clock is not affected by system clock updates. The reference point of
|
||||
the returned value is undefined, so that only the difference between the
|
||||
results of consecutive calls is valid.
|
||||
|
||||
Fill info (if set) with information of the function used to get the time.
|
||||
|
||||
Return 0 on success, raise an exception and return -1 on error. */
|
||||
PyAPI_FUNC(int) _PyTime_GetMonotonicClockWithInfo(
|
||||
_PyTime_t *t,
|
||||
_Py_clock_info_t *info);
|
||||
|
||||
|
||||
/* Converts a timestamp to the Gregorian time, using the local time zone.
|
||||
Return 0 on success, raise an exception and return -1 on error. */
|
||||
PyAPI_FUNC(int) _PyTime_localtime(time_t t, struct tm *tm);
|
||||
|
||||
/* Converts a timestamp to the Gregorian time, assuming UTC.
|
||||
Return 0 on success, raise an exception and return -1 on error. */
|
||||
PyAPI_FUNC(int) _PyTime_gmtime(time_t t, struct tm *tm);
|
||||
|
||||
/* Get the performance counter: clock with the highest available resolution to
|
||||
measure a short duration.
|
||||
|
||||
If the internal clock fails, silently ignore the error and return 0.
|
||||
On integer overflow, silently ignore the overflow and clamp the clock to
|
||||
[_PyTime_MIN; _PyTime_MAX].
|
||||
|
||||
Use _PyTime_GetPerfCounterWithInfo() to check for failure. */
|
||||
PyAPI_FUNC(_PyTime_t) _PyTime_GetPerfCounter(void);
|
||||
|
||||
/* Get the performance counter: clock with the highest available resolution to
|
||||
measure a short duration.
|
||||
|
||||
Fill info (if set) with information of the function used to get the time.
|
||||
|
||||
Return 0 on success, raise an exception and return -1 on error. */
|
||||
PyAPI_FUNC(int) _PyTime_GetPerfCounterWithInfo(
|
||||
_PyTime_t *t,
|
||||
_Py_clock_info_t *info);
|
||||
|
||||
|
||||
// Create a deadline.
|
||||
// Pseudo code: _PyTime_GetMonotonicClock() + timeout.
|
||||
PyAPI_FUNC(_PyTime_t) _PyDeadline_Init(_PyTime_t timeout);
|
||||
|
||||
// Get remaining time from a deadline.
|
||||
// Pseudo code: deadline - _PyTime_GetMonotonicClock().
|
||||
PyAPI_FUNC(_PyTime_t) _PyDeadline_Get(_PyTime_t deadline);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Py_PYTIME_H */
|
||||
#endif /* Py_LIMITED_API */
|
||||
72
crypto/shamirs_secret_sharing/include/cpython/setobject.h
Normal file
72
crypto/shamirs_secret_sharing/include/cpython/setobject.h
Normal file
@@ -0,0 +1,72 @@
|
||||
#ifndef Py_CPYTHON_SETOBJECT_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
/* There are three kinds of entries in the table:
|
||||
|
||||
1. Unused: key == NULL and hash == 0
|
||||
2. Dummy: key == dummy and hash == -1
|
||||
3. Active: key != NULL and key != dummy and hash != -1
|
||||
|
||||
The hash field of Unused slots is always zero.
|
||||
|
||||
The hash field of Dummy slots are set to -1
|
||||
meaning that dummy entries can be detected by
|
||||
either entry->key==dummy or by entry->hash==-1.
|
||||
*/
|
||||
|
||||
#define PySet_MINSIZE 8
|
||||
|
||||
typedef struct {
|
||||
PyObject *key;
|
||||
Py_hash_t hash; /* Cached hash code of the key */
|
||||
} setentry;
|
||||
|
||||
/* The SetObject data structure is shared by set and frozenset objects.
|
||||
|
||||
Invariant for sets:
|
||||
- hash is -1
|
||||
|
||||
Invariants for frozensets:
|
||||
- data is immutable.
|
||||
- hash is the hash of the frozenset or -1 if not computed yet.
|
||||
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
|
||||
Py_ssize_t fill; /* Number active and dummy entries*/
|
||||
Py_ssize_t used; /* Number active entries */
|
||||
|
||||
/* The table contains mask + 1 slots, and that's a power of 2.
|
||||
* We store the mask instead of the size because the mask is more
|
||||
* frequently needed.
|
||||
*/
|
||||
Py_ssize_t mask;
|
||||
|
||||
/* The table points to a fixed-size smalltable for small tables
|
||||
* or to additional malloc'ed memory for bigger tables.
|
||||
* The table pointer is never NULL which saves us from repeated
|
||||
* runtime null-tests.
|
||||
*/
|
||||
setentry *table;
|
||||
Py_hash_t hash; /* Only used by frozenset objects */
|
||||
Py_ssize_t finger; /* Search finger for pop() */
|
||||
|
||||
setentry smalltable[PySet_MINSIZE];
|
||||
PyObject *weakreflist; /* List of weak references */
|
||||
} PySetObject;
|
||||
|
||||
#define _PySet_CAST(so) \
|
||||
(assert(PyAnySet_Check(so)), _Py_CAST(PySetObject*, so))
|
||||
|
||||
static inline Py_ssize_t PySet_GET_SIZE(PyObject *so) {
|
||||
return _PySet_CAST(so)->used;
|
||||
}
|
||||
#define PySet_GET_SIZE(so) PySet_GET_SIZE(_PyObject_CAST(so))
|
||||
|
||||
PyAPI_DATA(PyObject *) _PySet_Dummy;
|
||||
|
||||
PyAPI_FUNC(int) _PySet_NextEntry(PyObject *set, Py_ssize_t *pos, PyObject **key, Py_hash_t *hash);
|
||||
PyAPI_FUNC(int) _PySet_Update(PyObject *set, PyObject *iterable);
|
||||
16
crypto/shamirs_secret_sharing/include/cpython/sysmodule.h
Normal file
16
crypto/shamirs_secret_sharing/include/cpython/sysmodule.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef Py_CPYTHON_SYSMODULE_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PySys_GetAttr(PyThreadState *tstate,
|
||||
PyObject *name);
|
||||
|
||||
PyAPI_FUNC(size_t) _PySys_GetSizeOf(PyObject *);
|
||||
|
||||
typedef int(*Py_AuditHookFunction)(const char *, PyObject *, void *);
|
||||
|
||||
PyAPI_FUNC(int) PySys_Audit(
|
||||
const char *event,
|
||||
const char *argFormat,
|
||||
...);
|
||||
PyAPI_FUNC(int) PySys_AddAuditHook(Py_AuditHookFunction, void*);
|
||||
16
crypto/shamirs_secret_sharing/include/cpython/traceback.h
Normal file
16
crypto/shamirs_secret_sharing/include/cpython/traceback.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifndef Py_CPYTHON_TRACEBACK_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
typedef struct _traceback PyTracebackObject;
|
||||
|
||||
struct _traceback {
|
||||
PyObject_HEAD
|
||||
PyTracebackObject *tb_next;
|
||||
PyFrameObject *tb_frame;
|
||||
int tb_lasti;
|
||||
int tb_lineno;
|
||||
};
|
||||
|
||||
PyAPI_FUNC(int) _Py_DisplaySourceLine(PyObject *, PyObject *, int, int, int *, PyObject **);
|
||||
PyAPI_FUNC(void) _PyTraceback_Add(const char *, const char *, int);
|
||||
39
crypto/shamirs_secret_sharing/include/cpython/tupleobject.h
Normal file
39
crypto/shamirs_secret_sharing/include/cpython/tupleobject.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#ifndef Py_CPYTHON_TUPLEOBJECT_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
PyObject_VAR_HEAD
|
||||
/* ob_item contains space for 'ob_size' elements.
|
||||
Items must normally not be NULL, except during construction when
|
||||
the tuple is not yet visible outside the function that builds it. */
|
||||
PyObject *ob_item[1];
|
||||
} PyTupleObject;
|
||||
|
||||
PyAPI_FUNC(int) _PyTuple_Resize(PyObject **, Py_ssize_t);
|
||||
PyAPI_FUNC(void) _PyTuple_MaybeUntrack(PyObject *);
|
||||
|
||||
/* Cast argument to PyTupleObject* type. */
|
||||
#define _PyTuple_CAST(op) \
|
||||
(assert(PyTuple_Check(op)), _Py_CAST(PyTupleObject*, (op)))
|
||||
|
||||
// Macros and static inline functions, trading safety for speed
|
||||
|
||||
static inline Py_ssize_t PyTuple_GET_SIZE(PyObject *op) {
|
||||
PyTupleObject *tuple = _PyTuple_CAST(op);
|
||||
return Py_SIZE(tuple);
|
||||
}
|
||||
#define PyTuple_GET_SIZE(op) PyTuple_GET_SIZE(_PyObject_CAST(op))
|
||||
|
||||
#define PyTuple_GET_ITEM(op, index) (_PyTuple_CAST(op)->ob_item[(index)])
|
||||
|
||||
/* Function *only* to be used to fill in brand new tuples */
|
||||
static inline void
|
||||
PyTuple_SET_ITEM(PyObject *op, Py_ssize_t index, PyObject *value) {
|
||||
PyTupleObject *tuple = _PyTuple_CAST(op);
|
||||
tuple->ob_item[index] = value;
|
||||
}
|
||||
#define PyTuple_SET_ITEM(op, index, value) \
|
||||
PyTuple_SET_ITEM(_PyObject_CAST(op), (index), _PyObject_CAST(value))
|
||||
|
||||
PyAPI_FUNC(void) _PyTuple_DebugMallocStats(FILE *out);
|
||||
963
crypto/shamirs_secret_sharing/include/cpython/unicodeobject.h
Normal file
963
crypto/shamirs_secret_sharing/include/cpython/unicodeobject.h
Normal file
@@ -0,0 +1,963 @@
|
||||
#ifndef Py_CPYTHON_UNICODEOBJECT_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
/* Py_UNICODE was the native Unicode storage format (code unit) used by
|
||||
Python and represents a single Unicode element in the Unicode type.
|
||||
With PEP 393, Py_UNICODE is deprecated and replaced with a
|
||||
typedef to wchar_t. */
|
||||
#define PY_UNICODE_TYPE wchar_t
|
||||
/* Py_DEPRECATED(3.3) */ typedef wchar_t Py_UNICODE;
|
||||
|
||||
/* --- Internal Unicode Operations ---------------------------------------- */
|
||||
|
||||
// Static inline functions to work with surrogates
|
||||
static inline int Py_UNICODE_IS_SURROGATE(Py_UCS4 ch) {
|
||||
return (0xD800 <= ch && ch <= 0xDFFF);
|
||||
}
|
||||
static inline int Py_UNICODE_IS_HIGH_SURROGATE(Py_UCS4 ch) {
|
||||
return (0xD800 <= ch && ch <= 0xDBFF);
|
||||
}
|
||||
static inline int Py_UNICODE_IS_LOW_SURROGATE(Py_UCS4 ch) {
|
||||
return (0xDC00 <= ch && ch <= 0xDFFF);
|
||||
}
|
||||
|
||||
// Join two surrogate characters and return a single Py_UCS4 value.
|
||||
static inline Py_UCS4 Py_UNICODE_JOIN_SURROGATES(Py_UCS4 high, Py_UCS4 low) {
|
||||
assert(Py_UNICODE_IS_HIGH_SURROGATE(high));
|
||||
assert(Py_UNICODE_IS_LOW_SURROGATE(low));
|
||||
return 0x10000 + (((high & 0x03FF) << 10) | (low & 0x03FF));
|
||||
}
|
||||
|
||||
// High surrogate = top 10 bits added to 0xD800.
|
||||
// The character must be in the range [U+10000; U+10ffff].
|
||||
static inline Py_UCS4 Py_UNICODE_HIGH_SURROGATE(Py_UCS4 ch) {
|
||||
assert(0x10000 <= ch && ch <= 0x10ffff);
|
||||
return (0xD800 - (0x10000 >> 10) + (ch >> 10));
|
||||
}
|
||||
|
||||
// Low surrogate = bottom 10 bits added to 0xDC00.
|
||||
// The character must be in the range [U+10000; U+10ffff].
|
||||
static inline Py_UCS4 Py_UNICODE_LOW_SURROGATE(Py_UCS4 ch) {
|
||||
assert(0x10000 <= ch && ch <= 0x10ffff);
|
||||
return (0xDC00 + (ch & 0x3FF));
|
||||
}
|
||||
|
||||
/* --- Unicode Type ------------------------------------------------------- */
|
||||
|
||||
/* ASCII-only strings created through PyUnicode_New use the PyASCIIObject
|
||||
structure. state.ascii and state.compact are set, and the data
|
||||
immediately follow the structure. utf8_length can be found
|
||||
in the length field; the utf8 pointer is equal to the data pointer. */
|
||||
typedef struct {
|
||||
/* There are 4 forms of Unicode strings:
|
||||
|
||||
- compact ascii:
|
||||
|
||||
* structure = PyASCIIObject
|
||||
* test: PyUnicode_IS_COMPACT_ASCII(op)
|
||||
* kind = PyUnicode_1BYTE_KIND
|
||||
* compact = 1
|
||||
* ascii = 1
|
||||
* (length is the length of the utf8)
|
||||
* (data starts just after the structure)
|
||||
* (since ASCII is decoded from UTF-8, the utf8 string are the data)
|
||||
|
||||
- compact:
|
||||
|
||||
* structure = PyCompactUnicodeObject
|
||||
* test: PyUnicode_IS_COMPACT(op) && !PyUnicode_IS_ASCII(op)
|
||||
* kind = PyUnicode_1BYTE_KIND, PyUnicode_2BYTE_KIND or
|
||||
PyUnicode_4BYTE_KIND
|
||||
* compact = 1
|
||||
* ascii = 0
|
||||
* utf8 is not shared with data
|
||||
* utf8_length = 0 if utf8 is NULL
|
||||
* (data starts just after the structure)
|
||||
|
||||
- legacy string:
|
||||
|
||||
* structure = PyUnicodeObject structure
|
||||
* test: !PyUnicode_IS_COMPACT(op)
|
||||
* kind = PyUnicode_1BYTE_KIND, PyUnicode_2BYTE_KIND or
|
||||
PyUnicode_4BYTE_KIND
|
||||
* compact = 0
|
||||
* data.any is not NULL
|
||||
* utf8 is shared and utf8_length = length with data.any if ascii = 1
|
||||
* utf8_length = 0 if utf8 is NULL
|
||||
|
||||
Compact strings use only one memory block (structure + characters),
|
||||
whereas legacy strings use one block for the structure and one block
|
||||
for characters.
|
||||
|
||||
Legacy strings are created by subclasses of Unicode.
|
||||
|
||||
See also _PyUnicode_CheckConsistency().
|
||||
*/
|
||||
PyObject_HEAD
|
||||
Py_ssize_t length; /* Number of code points in the string */
|
||||
Py_hash_t hash; /* Hash value; -1 if not set */
|
||||
struct {
|
||||
/* If interned is non-zero, the two references from the
|
||||
dictionary to this object are *not* counted in ob_refcnt.
|
||||
The possible values here are:
|
||||
0: Not Interned
|
||||
1: Interned
|
||||
2: Interned and Immortal
|
||||
3: Interned, Immortal, and Static
|
||||
This categorization allows the runtime to determine the right
|
||||
cleanup mechanism at runtime shutdown. */
|
||||
unsigned int interned:2;
|
||||
/* Character size:
|
||||
|
||||
- PyUnicode_1BYTE_KIND (1):
|
||||
|
||||
* character type = Py_UCS1 (8 bits, unsigned)
|
||||
* all characters are in the range U+0000-U+00FF (latin1)
|
||||
* if ascii is set, all characters are in the range U+0000-U+007F
|
||||
(ASCII), otherwise at least one character is in the range
|
||||
U+0080-U+00FF
|
||||
|
||||
- PyUnicode_2BYTE_KIND (2):
|
||||
|
||||
* character type = Py_UCS2 (16 bits, unsigned)
|
||||
* all characters are in the range U+0000-U+FFFF (BMP)
|
||||
* at least one character is in the range U+0100-U+FFFF
|
||||
|
||||
- PyUnicode_4BYTE_KIND (4):
|
||||
|
||||
* character type = Py_UCS4 (32 bits, unsigned)
|
||||
* all characters are in the range U+0000-U+10FFFF
|
||||
* at least one character is in the range U+10000-U+10FFFF
|
||||
*/
|
||||
unsigned int kind:3;
|
||||
/* Compact is with respect to the allocation scheme. Compact unicode
|
||||
objects only require one memory block while non-compact objects use
|
||||
one block for the PyUnicodeObject struct and another for its data
|
||||
buffer. */
|
||||
unsigned int compact:1;
|
||||
/* The string only contains characters in the range U+0000-U+007F (ASCII)
|
||||
and the kind is PyUnicode_1BYTE_KIND. If ascii is set and compact is
|
||||
set, use the PyASCIIObject structure. */
|
||||
unsigned int ascii:1;
|
||||
/* The object is statically allocated. */
|
||||
unsigned int statically_allocated:1;
|
||||
/* Padding to ensure that PyUnicode_DATA() is always aligned to
|
||||
4 bytes (see issue #19537 on m68k). */
|
||||
unsigned int :24;
|
||||
} state;
|
||||
} PyASCIIObject;
|
||||
|
||||
/* Non-ASCII strings allocated through PyUnicode_New use the
|
||||
PyCompactUnicodeObject structure. state.compact is set, and the data
|
||||
immediately follow the structure. */
|
||||
typedef struct {
|
||||
PyASCIIObject _base;
|
||||
Py_ssize_t utf8_length; /* Number of bytes in utf8, excluding the
|
||||
* terminating \0. */
|
||||
char *utf8; /* UTF-8 representation (null-terminated) */
|
||||
} PyCompactUnicodeObject;
|
||||
|
||||
/* Object format for Unicode subclasses. */
|
||||
typedef struct {
|
||||
PyCompactUnicodeObject _base;
|
||||
union {
|
||||
void *any;
|
||||
Py_UCS1 *latin1;
|
||||
Py_UCS2 *ucs2;
|
||||
Py_UCS4 *ucs4;
|
||||
} data; /* Canonical, smallest-form Unicode buffer */
|
||||
} PyUnicodeObject;
|
||||
|
||||
PyAPI_FUNC(int) _PyUnicode_CheckConsistency(
|
||||
PyObject *op,
|
||||
int check_content);
|
||||
|
||||
|
||||
#define _PyASCIIObject_CAST(op) \
|
||||
(assert(PyUnicode_Check(op)), \
|
||||
_Py_CAST(PyASCIIObject*, (op)))
|
||||
#define _PyCompactUnicodeObject_CAST(op) \
|
||||
(assert(PyUnicode_Check(op)), \
|
||||
_Py_CAST(PyCompactUnicodeObject*, (op)))
|
||||
#define _PyUnicodeObject_CAST(op) \
|
||||
(assert(PyUnicode_Check(op)), \
|
||||
_Py_CAST(PyUnicodeObject*, (op)))
|
||||
|
||||
|
||||
/* --- Flexible String Representation Helper Macros (PEP 393) -------------- */
|
||||
|
||||
/* Values for PyASCIIObject.state: */
|
||||
|
||||
/* Interning state. */
|
||||
#define SSTATE_NOT_INTERNED 0
|
||||
#define SSTATE_INTERNED_MORTAL 1
|
||||
#define SSTATE_INTERNED_IMMORTAL 2
|
||||
#define SSTATE_INTERNED_IMMORTAL_STATIC 3
|
||||
|
||||
/* Use only if you know it's a string */
|
||||
static inline unsigned int PyUnicode_CHECK_INTERNED(PyObject *op) {
|
||||
return _PyASCIIObject_CAST(op)->state.interned;
|
||||
}
|
||||
#define PyUnicode_CHECK_INTERNED(op) PyUnicode_CHECK_INTERNED(_PyObject_CAST(op))
|
||||
|
||||
/* For backward compatibility */
|
||||
static inline unsigned int PyUnicode_IS_READY(PyObject* Py_UNUSED(op)) {
|
||||
return 1;
|
||||
}
|
||||
#define PyUnicode_IS_READY(op) PyUnicode_IS_READY(_PyObject_CAST(op))
|
||||
|
||||
/* Return true if the string contains only ASCII characters, or 0 if not. The
|
||||
string may be compact (PyUnicode_IS_COMPACT_ASCII) or not, but must be
|
||||
ready. */
|
||||
static inline unsigned int PyUnicode_IS_ASCII(PyObject *op) {
|
||||
return _PyASCIIObject_CAST(op)->state.ascii;
|
||||
}
|
||||
#define PyUnicode_IS_ASCII(op) PyUnicode_IS_ASCII(_PyObject_CAST(op))
|
||||
|
||||
/* Return true if the string is compact or 0 if not.
|
||||
No type checks or Ready calls are performed. */
|
||||
static inline unsigned int PyUnicode_IS_COMPACT(PyObject *op) {
|
||||
return _PyASCIIObject_CAST(op)->state.compact;
|
||||
}
|
||||
#define PyUnicode_IS_COMPACT(op) PyUnicode_IS_COMPACT(_PyObject_CAST(op))
|
||||
|
||||
/* Return true if the string is a compact ASCII string (use PyASCIIObject
|
||||
structure), or 0 if not. No type checks or Ready calls are performed. */
|
||||
static inline int PyUnicode_IS_COMPACT_ASCII(PyObject *op) {
|
||||
return (_PyASCIIObject_CAST(op)->state.ascii && PyUnicode_IS_COMPACT(op));
|
||||
}
|
||||
#define PyUnicode_IS_COMPACT_ASCII(op) PyUnicode_IS_COMPACT_ASCII(_PyObject_CAST(op))
|
||||
|
||||
enum PyUnicode_Kind {
|
||||
/* Return values of the PyUnicode_KIND() function: */
|
||||
PyUnicode_1BYTE_KIND = 1,
|
||||
PyUnicode_2BYTE_KIND = 2,
|
||||
PyUnicode_4BYTE_KIND = 4
|
||||
};
|
||||
|
||||
// PyUnicode_KIND(): Return one of the PyUnicode_*_KIND values defined above.
|
||||
//
|
||||
// gh-89653: Converting this macro to a static inline function would introduce
|
||||
// new compiler warnings on "kind < PyUnicode_KIND(str)" (compare signed and
|
||||
// unsigned numbers) where kind type is an int or on
|
||||
// "unsigned int kind = PyUnicode_KIND(str)" (cast signed to unsigned).
|
||||
#define PyUnicode_KIND(op) _Py_RVALUE(_PyASCIIObject_CAST(op)->state.kind)
|
||||
|
||||
/* Return a void pointer to the raw unicode buffer. */
|
||||
static inline void* _PyUnicode_COMPACT_DATA(PyObject *op) {
|
||||
if (PyUnicode_IS_ASCII(op)) {
|
||||
return _Py_STATIC_CAST(void*, (_PyASCIIObject_CAST(op) + 1));
|
||||
}
|
||||
return _Py_STATIC_CAST(void*, (_PyCompactUnicodeObject_CAST(op) + 1));
|
||||
}
|
||||
|
||||
static inline void* _PyUnicode_NONCOMPACT_DATA(PyObject *op) {
|
||||
void *data;
|
||||
assert(!PyUnicode_IS_COMPACT(op));
|
||||
data = _PyUnicodeObject_CAST(op)->data.any;
|
||||
assert(data != NULL);
|
||||
return data;
|
||||
}
|
||||
|
||||
static inline void* PyUnicode_DATA(PyObject *op) {
|
||||
if (PyUnicode_IS_COMPACT(op)) {
|
||||
return _PyUnicode_COMPACT_DATA(op);
|
||||
}
|
||||
return _PyUnicode_NONCOMPACT_DATA(op);
|
||||
}
|
||||
#define PyUnicode_DATA(op) PyUnicode_DATA(_PyObject_CAST(op))
|
||||
|
||||
/* Return pointers to the canonical representation cast to unsigned char,
|
||||
Py_UCS2, or Py_UCS4 for direct character access.
|
||||
No checks are performed, use PyUnicode_KIND() before to ensure
|
||||
these will work correctly. */
|
||||
|
||||
#define PyUnicode_1BYTE_DATA(op) _Py_STATIC_CAST(Py_UCS1*, PyUnicode_DATA(op))
|
||||
#define PyUnicode_2BYTE_DATA(op) _Py_STATIC_CAST(Py_UCS2*, PyUnicode_DATA(op))
|
||||
#define PyUnicode_4BYTE_DATA(op) _Py_STATIC_CAST(Py_UCS4*, PyUnicode_DATA(op))
|
||||
|
||||
/* Returns the length of the unicode string. */
|
||||
static inline Py_ssize_t PyUnicode_GET_LENGTH(PyObject *op) {
|
||||
return _PyASCIIObject_CAST(op)->length;
|
||||
}
|
||||
#define PyUnicode_GET_LENGTH(op) PyUnicode_GET_LENGTH(_PyObject_CAST(op))
|
||||
|
||||
/* Write into the canonical representation, this function does not do any sanity
|
||||
checks and is intended for usage in loops. The caller should cache the
|
||||
kind and data pointers obtained from other function calls.
|
||||
index is the index in the string (starts at 0) and value is the new
|
||||
code point value which should be written to that location. */
|
||||
static inline void PyUnicode_WRITE(int kind, void *data,
|
||||
Py_ssize_t index, Py_UCS4 value)
|
||||
{
|
||||
assert(index >= 0);
|
||||
if (kind == PyUnicode_1BYTE_KIND) {
|
||||
assert(value <= 0xffU);
|
||||
_Py_STATIC_CAST(Py_UCS1*, data)[index] = _Py_STATIC_CAST(Py_UCS1, value);
|
||||
}
|
||||
else if (kind == PyUnicode_2BYTE_KIND) {
|
||||
assert(value <= 0xffffU);
|
||||
_Py_STATIC_CAST(Py_UCS2*, data)[index] = _Py_STATIC_CAST(Py_UCS2, value);
|
||||
}
|
||||
else {
|
||||
assert(kind == PyUnicode_4BYTE_KIND);
|
||||
assert(value <= 0x10ffffU);
|
||||
_Py_STATIC_CAST(Py_UCS4*, data)[index] = value;
|
||||
}
|
||||
}
|
||||
#define PyUnicode_WRITE(kind, data, index, value) \
|
||||
PyUnicode_WRITE(_Py_STATIC_CAST(int, kind), _Py_CAST(void*, data), \
|
||||
(index), _Py_STATIC_CAST(Py_UCS4, value))
|
||||
|
||||
/* Read a code point from the string's canonical representation. No checks
|
||||
or ready calls are performed. */
|
||||
static inline Py_UCS4 PyUnicode_READ(int kind,
|
||||
const void *data, Py_ssize_t index)
|
||||
{
|
||||
assert(index >= 0);
|
||||
if (kind == PyUnicode_1BYTE_KIND) {
|
||||
return _Py_STATIC_CAST(const Py_UCS1*, data)[index];
|
||||
}
|
||||
if (kind == PyUnicode_2BYTE_KIND) {
|
||||
return _Py_STATIC_CAST(const Py_UCS2*, data)[index];
|
||||
}
|
||||
assert(kind == PyUnicode_4BYTE_KIND);
|
||||
return _Py_STATIC_CAST(const Py_UCS4*, data)[index];
|
||||
}
|
||||
#define PyUnicode_READ(kind, data, index) \
|
||||
PyUnicode_READ(_Py_STATIC_CAST(int, kind), \
|
||||
_Py_STATIC_CAST(const void*, data), \
|
||||
(index))
|
||||
|
||||
/* PyUnicode_READ_CHAR() is less efficient than PyUnicode_READ() because it
|
||||
calls PyUnicode_KIND() and might call it twice. For single reads, use
|
||||
PyUnicode_READ_CHAR, for multiple consecutive reads callers should
|
||||
cache kind and use PyUnicode_READ instead. */
|
||||
static inline Py_UCS4 PyUnicode_READ_CHAR(PyObject *unicode, Py_ssize_t index)
|
||||
{
|
||||
int kind;
|
||||
|
||||
assert(index >= 0);
|
||||
// Tolerate reading the NUL character at str[len(str)]
|
||||
assert(index <= PyUnicode_GET_LENGTH(unicode));
|
||||
|
||||
kind = PyUnicode_KIND(unicode);
|
||||
if (kind == PyUnicode_1BYTE_KIND) {
|
||||
return PyUnicode_1BYTE_DATA(unicode)[index];
|
||||
}
|
||||
if (kind == PyUnicode_2BYTE_KIND) {
|
||||
return PyUnicode_2BYTE_DATA(unicode)[index];
|
||||
}
|
||||
assert(kind == PyUnicode_4BYTE_KIND);
|
||||
return PyUnicode_4BYTE_DATA(unicode)[index];
|
||||
}
|
||||
#define PyUnicode_READ_CHAR(unicode, index) \
|
||||
PyUnicode_READ_CHAR(_PyObject_CAST(unicode), (index))
|
||||
|
||||
/* Return a maximum character value which is suitable for creating another
|
||||
string based on op. This is always an approximation but more efficient
|
||||
than iterating over the string. */
|
||||
static inline Py_UCS4 PyUnicode_MAX_CHAR_VALUE(PyObject *op)
|
||||
{
|
||||
int kind;
|
||||
|
||||
if (PyUnicode_IS_ASCII(op)) {
|
||||
return 0x7fU;
|
||||
}
|
||||
|
||||
kind = PyUnicode_KIND(op);
|
||||
if (kind == PyUnicode_1BYTE_KIND) {
|
||||
return 0xffU;
|
||||
}
|
||||
if (kind == PyUnicode_2BYTE_KIND) {
|
||||
return 0xffffU;
|
||||
}
|
||||
assert(kind == PyUnicode_4BYTE_KIND);
|
||||
return 0x10ffffU;
|
||||
}
|
||||
#define PyUnicode_MAX_CHAR_VALUE(op) \
|
||||
PyUnicode_MAX_CHAR_VALUE(_PyObject_CAST(op))
|
||||
|
||||
/* === Public API ========================================================= */
|
||||
|
||||
/* --- Plain Py_UNICODE --------------------------------------------------- */
|
||||
|
||||
/* With PEP 393, this is the recommended way to allocate a new unicode object.
|
||||
This function will allocate the object and its buffer in a single memory
|
||||
block. Objects created using this function are not resizable. */
|
||||
PyAPI_FUNC(PyObject*) PyUnicode_New(
|
||||
Py_ssize_t size, /* Number of code points in the new string */
|
||||
Py_UCS4 maxchar /* maximum code point value in the string */
|
||||
);
|
||||
|
||||
/* For backward compatibility */
|
||||
static inline int PyUnicode_READY(PyObject* Py_UNUSED(op))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#define PyUnicode_READY(op) PyUnicode_READY(_PyObject_CAST(op))
|
||||
|
||||
/* Get a copy of a Unicode string. */
|
||||
PyAPI_FUNC(PyObject*) _PyUnicode_Copy(
|
||||
PyObject *unicode
|
||||
);
|
||||
|
||||
/* Copy character from one unicode object into another, this function performs
|
||||
character conversion when necessary and falls back to memcpy() if possible.
|
||||
|
||||
Fail if to is too small (smaller than *how_many* or smaller than
|
||||
len(from)-from_start), or if kind(from[from_start:from_start+how_many]) >
|
||||
kind(to), or if *to* has more than 1 reference.
|
||||
|
||||
Return the number of written character, or return -1 and raise an exception
|
||||
on error.
|
||||
|
||||
Pseudo-code:
|
||||
|
||||
how_many = min(how_many, len(from) - from_start)
|
||||
to[to_start:to_start+how_many] = from[from_start:from_start+how_many]
|
||||
return how_many
|
||||
|
||||
Note: The function doesn't write a terminating null character.
|
||||
*/
|
||||
PyAPI_FUNC(Py_ssize_t) PyUnicode_CopyCharacters(
|
||||
PyObject *to,
|
||||
Py_ssize_t to_start,
|
||||
PyObject *from,
|
||||
Py_ssize_t from_start,
|
||||
Py_ssize_t how_many
|
||||
);
|
||||
|
||||
/* Unsafe version of PyUnicode_CopyCharacters(): don't check arguments and so
|
||||
may crash if parameters are invalid (e.g. if the output string
|
||||
is too short). */
|
||||
PyAPI_FUNC(void) _PyUnicode_FastCopyCharacters(
|
||||
PyObject *to,
|
||||
Py_ssize_t to_start,
|
||||
PyObject *from,
|
||||
Py_ssize_t from_start,
|
||||
Py_ssize_t how_many
|
||||
);
|
||||
|
||||
/* Fill a string with a character: write fill_char into
|
||||
unicode[start:start+length].
|
||||
|
||||
Fail if fill_char is bigger than the string maximum character, or if the
|
||||
string has more than 1 reference.
|
||||
|
||||
Return the number of written character, or return -1 and raise an exception
|
||||
on error. */
|
||||
PyAPI_FUNC(Py_ssize_t) PyUnicode_Fill(
|
||||
PyObject *unicode,
|
||||
Py_ssize_t start,
|
||||
Py_ssize_t length,
|
||||
Py_UCS4 fill_char
|
||||
);
|
||||
|
||||
/* Unsafe version of PyUnicode_Fill(): don't check arguments and so may crash
|
||||
if parameters are invalid (e.g. if length is longer than the string). */
|
||||
PyAPI_FUNC(void) _PyUnicode_FastFill(
|
||||
PyObject *unicode,
|
||||
Py_ssize_t start,
|
||||
Py_ssize_t length,
|
||||
Py_UCS4 fill_char
|
||||
);
|
||||
|
||||
/* Create a new string from a buffer of Py_UCS1, Py_UCS2 or Py_UCS4 characters.
|
||||
Scan the string to find the maximum character. */
|
||||
PyAPI_FUNC(PyObject*) PyUnicode_FromKindAndData(
|
||||
int kind,
|
||||
const void *buffer,
|
||||
Py_ssize_t size);
|
||||
|
||||
/* Create a new string from a buffer of ASCII characters.
|
||||
WARNING: Don't check if the string contains any non-ASCII character. */
|
||||
PyAPI_FUNC(PyObject*) _PyUnicode_FromASCII(
|
||||
const char *buffer,
|
||||
Py_ssize_t size);
|
||||
|
||||
/* Compute the maximum character of the substring unicode[start:end].
|
||||
Return 127 for an empty string. */
|
||||
PyAPI_FUNC(Py_UCS4) _PyUnicode_FindMaxChar (
|
||||
PyObject *unicode,
|
||||
Py_ssize_t start,
|
||||
Py_ssize_t end);
|
||||
|
||||
/* --- _PyUnicodeWriter API ----------------------------------------------- */
|
||||
|
||||
typedef struct {
|
||||
PyObject *buffer;
|
||||
void *data;
|
||||
int kind;
|
||||
Py_UCS4 maxchar;
|
||||
Py_ssize_t size;
|
||||
Py_ssize_t pos;
|
||||
|
||||
/* minimum number of allocated characters (default: 0) */
|
||||
Py_ssize_t min_length;
|
||||
|
||||
/* minimum character (default: 127, ASCII) */
|
||||
Py_UCS4 min_char;
|
||||
|
||||
/* If non-zero, overallocate the buffer (default: 0). */
|
||||
unsigned char overallocate;
|
||||
|
||||
/* If readonly is 1, buffer is a shared string (cannot be modified)
|
||||
and size is set to 0. */
|
||||
unsigned char readonly;
|
||||
} _PyUnicodeWriter ;
|
||||
|
||||
/* Initialize a Unicode writer.
|
||||
*
|
||||
* By default, the minimum buffer size is 0 character and overallocation is
|
||||
* disabled. Set min_length, min_char and overallocate attributes to control
|
||||
* the allocation of the buffer. */
|
||||
PyAPI_FUNC(void)
|
||||
_PyUnicodeWriter_Init(_PyUnicodeWriter *writer);
|
||||
|
||||
/* Prepare the buffer to write 'length' characters
|
||||
with the specified maximum character.
|
||||
|
||||
Return 0 on success, raise an exception and return -1 on error. */
|
||||
#define _PyUnicodeWriter_Prepare(WRITER, LENGTH, MAXCHAR) \
|
||||
(((MAXCHAR) <= (WRITER)->maxchar \
|
||||
&& (LENGTH) <= (WRITER)->size - (WRITER)->pos) \
|
||||
? 0 \
|
||||
: (((LENGTH) == 0) \
|
||||
? 0 \
|
||||
: _PyUnicodeWriter_PrepareInternal((WRITER), (LENGTH), (MAXCHAR))))
|
||||
|
||||
/* Don't call this function directly, use the _PyUnicodeWriter_Prepare() macro
|
||||
instead. */
|
||||
PyAPI_FUNC(int)
|
||||
_PyUnicodeWriter_PrepareInternal(_PyUnicodeWriter *writer,
|
||||
Py_ssize_t length, Py_UCS4 maxchar);
|
||||
|
||||
/* Prepare the buffer to have at least the kind KIND.
|
||||
For example, kind=PyUnicode_2BYTE_KIND ensures that the writer will
|
||||
support characters in range U+000-U+FFFF.
|
||||
|
||||
Return 0 on success, raise an exception and return -1 on error. */
|
||||
#define _PyUnicodeWriter_PrepareKind(WRITER, KIND) \
|
||||
((KIND) <= (WRITER)->kind \
|
||||
? 0 \
|
||||
: _PyUnicodeWriter_PrepareKindInternal((WRITER), (KIND)))
|
||||
|
||||
/* Don't call this function directly, use the _PyUnicodeWriter_PrepareKind()
|
||||
macro instead. */
|
||||
PyAPI_FUNC(int)
|
||||
_PyUnicodeWriter_PrepareKindInternal(_PyUnicodeWriter *writer,
|
||||
int kind);
|
||||
|
||||
/* Append a Unicode character.
|
||||
Return 0 on success, raise an exception and return -1 on error. */
|
||||
PyAPI_FUNC(int)
|
||||
_PyUnicodeWriter_WriteChar(_PyUnicodeWriter *writer,
|
||||
Py_UCS4 ch
|
||||
);
|
||||
|
||||
/* Append a Unicode string.
|
||||
Return 0 on success, raise an exception and return -1 on error. */
|
||||
PyAPI_FUNC(int)
|
||||
_PyUnicodeWriter_WriteStr(_PyUnicodeWriter *writer,
|
||||
PyObject *str /* Unicode string */
|
||||
);
|
||||
|
||||
/* Append a substring of a Unicode string.
|
||||
Return 0 on success, raise an exception and return -1 on error. */
|
||||
PyAPI_FUNC(int)
|
||||
_PyUnicodeWriter_WriteSubstring(_PyUnicodeWriter *writer,
|
||||
PyObject *str, /* Unicode string */
|
||||
Py_ssize_t start,
|
||||
Py_ssize_t end
|
||||
);
|
||||
|
||||
/* Append an ASCII-encoded byte string.
|
||||
Return 0 on success, raise an exception and return -1 on error. */
|
||||
PyAPI_FUNC(int)
|
||||
_PyUnicodeWriter_WriteASCIIString(_PyUnicodeWriter *writer,
|
||||
const char *str, /* ASCII-encoded byte string */
|
||||
Py_ssize_t len /* number of bytes, or -1 if unknown */
|
||||
);
|
||||
|
||||
/* Append a latin1-encoded byte string.
|
||||
Return 0 on success, raise an exception and return -1 on error. */
|
||||
PyAPI_FUNC(int)
|
||||
_PyUnicodeWriter_WriteLatin1String(_PyUnicodeWriter *writer,
|
||||
const char *str, /* latin1-encoded byte string */
|
||||
Py_ssize_t len /* length in bytes */
|
||||
);
|
||||
|
||||
/* Get the value of the writer as a Unicode string. Clear the
|
||||
buffer of the writer. Raise an exception and return NULL
|
||||
on error. */
|
||||
PyAPI_FUNC(PyObject *)
|
||||
_PyUnicodeWriter_Finish(_PyUnicodeWriter *writer);
|
||||
|
||||
/* Deallocate memory of a writer (clear its internal buffer). */
|
||||
PyAPI_FUNC(void)
|
||||
_PyUnicodeWriter_Dealloc(_PyUnicodeWriter *writer);
|
||||
|
||||
|
||||
/* Format the object based on the format_spec, as defined in PEP 3101
|
||||
(Advanced String Formatting). */
|
||||
PyAPI_FUNC(int) _PyUnicode_FormatAdvancedWriter(
|
||||
_PyUnicodeWriter *writer,
|
||||
PyObject *obj,
|
||||
PyObject *format_spec,
|
||||
Py_ssize_t start,
|
||||
Py_ssize_t end);
|
||||
|
||||
/* --- Manage the default encoding ---------------------------------------- */
|
||||
|
||||
/* Returns a pointer to the default encoding (UTF-8) of the
|
||||
Unicode object unicode.
|
||||
|
||||
Like PyUnicode_AsUTF8AndSize(), this also caches the UTF-8 representation
|
||||
in the unicodeobject.
|
||||
|
||||
_PyUnicode_AsString is a #define for PyUnicode_AsUTF8 to
|
||||
support the previous internal function with the same behaviour.
|
||||
|
||||
Use of this API is DEPRECATED since no size information can be
|
||||
extracted from the returned data.
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(const char *) PyUnicode_AsUTF8(PyObject *unicode);
|
||||
|
||||
#define _PyUnicode_AsString PyUnicode_AsUTF8
|
||||
|
||||
/* --- UTF-7 Codecs ------------------------------------------------------- */
|
||||
|
||||
PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF7(
|
||||
PyObject *unicode, /* Unicode object */
|
||||
int base64SetO, /* Encode RFC2152 Set O characters in base64 */
|
||||
int base64WhiteSpace, /* Encode whitespace (sp, ht, nl, cr) in base64 */
|
||||
const char *errors /* error handling */
|
||||
);
|
||||
|
||||
/* --- UTF-8 Codecs ------------------------------------------------------- */
|
||||
|
||||
PyAPI_FUNC(PyObject*) _PyUnicode_AsUTF8String(
|
||||
PyObject *unicode,
|
||||
const char *errors);
|
||||
|
||||
/* --- UTF-32 Codecs ------------------------------------------------------ */
|
||||
|
||||
PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF32(
|
||||
PyObject *object, /* Unicode object */
|
||||
const char *errors, /* error handling */
|
||||
int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */
|
||||
);
|
||||
|
||||
/* --- UTF-16 Codecs ------------------------------------------------------ */
|
||||
|
||||
/* Returns a Python string object holding the UTF-16 encoded value of
|
||||
the Unicode data.
|
||||
|
||||
If byteorder is not 0, output is written according to the following
|
||||
byte order:
|
||||
|
||||
byteorder == -1: little endian
|
||||
byteorder == 0: native byte order (writes a BOM mark)
|
||||
byteorder == 1: big endian
|
||||
|
||||
If byteorder is 0, the output string will always start with the
|
||||
Unicode BOM mark (U+FEFF). In the other two modes, no BOM mark is
|
||||
prepended.
|
||||
*/
|
||||
PyAPI_FUNC(PyObject*) _PyUnicode_EncodeUTF16(
|
||||
PyObject* unicode, /* Unicode object */
|
||||
const char *errors, /* error handling */
|
||||
int byteorder /* byteorder to use 0=BOM+native;-1=LE,1=BE */
|
||||
);
|
||||
|
||||
/* --- Unicode-Escape Codecs ---------------------------------------------- */
|
||||
|
||||
/* Variant of PyUnicode_DecodeUnicodeEscape that supports partial decoding. */
|
||||
PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscapeStateful(
|
||||
const char *string, /* Unicode-Escape encoded string */
|
||||
Py_ssize_t length, /* size of string */
|
||||
const char *errors, /* error handling */
|
||||
Py_ssize_t *consumed /* bytes consumed */
|
||||
);
|
||||
/* Helper for PyUnicode_DecodeUnicodeEscape that detects invalid escape
|
||||
chars. */
|
||||
PyAPI_FUNC(PyObject*) _PyUnicode_DecodeUnicodeEscapeInternal(
|
||||
const char *string, /* Unicode-Escape encoded string */
|
||||
Py_ssize_t length, /* size of string */
|
||||
const char *errors, /* error handling */
|
||||
Py_ssize_t *consumed, /* bytes consumed */
|
||||
const char **first_invalid_escape /* on return, points to first
|
||||
invalid escaped char in
|
||||
string. */
|
||||
);
|
||||
|
||||
/* --- Raw-Unicode-Escape Codecs ---------------------------------------------- */
|
||||
|
||||
/* Variant of PyUnicode_DecodeRawUnicodeEscape that supports partial decoding. */
|
||||
PyAPI_FUNC(PyObject*) _PyUnicode_DecodeRawUnicodeEscapeStateful(
|
||||
const char *string, /* Unicode-Escape encoded string */
|
||||
Py_ssize_t length, /* size of string */
|
||||
const char *errors, /* error handling */
|
||||
Py_ssize_t *consumed /* bytes consumed */
|
||||
);
|
||||
|
||||
/* --- Latin-1 Codecs ----------------------------------------------------- */
|
||||
|
||||
PyAPI_FUNC(PyObject*) _PyUnicode_AsLatin1String(
|
||||
PyObject* unicode,
|
||||
const char* errors);
|
||||
|
||||
/* --- ASCII Codecs ------------------------------------------------------- */
|
||||
|
||||
PyAPI_FUNC(PyObject*) _PyUnicode_AsASCIIString(
|
||||
PyObject* unicode,
|
||||
const char* errors);
|
||||
|
||||
/* --- Character Map Codecs ----------------------------------------------- */
|
||||
|
||||
/* Translate an Unicode object by applying a character mapping table to
|
||||
it and return the resulting Unicode object.
|
||||
|
||||
The mapping table must map Unicode ordinal integers to Unicode strings,
|
||||
Unicode ordinal integers or None (causing deletion of the character).
|
||||
|
||||
Mapping tables may be dictionaries or sequences. Unmapped character
|
||||
ordinals (ones which cause a LookupError) are left untouched and
|
||||
are copied as-is.
|
||||
*/
|
||||
PyAPI_FUNC(PyObject*) _PyUnicode_EncodeCharmap(
|
||||
PyObject *unicode, /* Unicode object */
|
||||
PyObject *mapping, /* encoding mapping */
|
||||
const char *errors /* error handling */
|
||||
);
|
||||
|
||||
/* --- Decimal Encoder ---------------------------------------------------- */
|
||||
|
||||
/* Coverts a Unicode object holding a decimal value to an ASCII string
|
||||
for using in int, float and complex parsers.
|
||||
Transforms code points that have decimal digit property to the
|
||||
corresponding ASCII digit code points. Transforms spaces to ASCII.
|
||||
Transforms code points starting from the first non-ASCII code point that
|
||||
is neither a decimal digit nor a space to the end into '?'. */
|
||||
|
||||
PyAPI_FUNC(PyObject*) _PyUnicode_TransformDecimalAndSpaceToASCII(
|
||||
PyObject *unicode /* Unicode object */
|
||||
);
|
||||
|
||||
/* --- Methods & Slots ---------------------------------------------------- */
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyUnicode_JoinArray(
|
||||
PyObject *separator,
|
||||
PyObject *const *items,
|
||||
Py_ssize_t seqlen
|
||||
);
|
||||
|
||||
/* Test whether a unicode is equal to ASCII identifier. Return 1 if true,
|
||||
0 otherwise. The right argument must be ASCII identifier.
|
||||
Any error occurs inside will be cleared before return. */
|
||||
PyAPI_FUNC(int) _PyUnicode_EqualToASCIIId(
|
||||
PyObject *left, /* Left string */
|
||||
_Py_Identifier *right /* Right identifier */
|
||||
);
|
||||
|
||||
/* Test whether a unicode is equal to ASCII string. Return 1 if true,
|
||||
0 otherwise. The right argument must be ASCII-encoded string.
|
||||
Any error occurs inside will be cleared before return. */
|
||||
PyAPI_FUNC(int) _PyUnicode_EqualToASCIIString(
|
||||
PyObject *left,
|
||||
const char *right /* ASCII-encoded string */
|
||||
);
|
||||
|
||||
/* Externally visible for str.strip(unicode) */
|
||||
PyAPI_FUNC(PyObject *) _PyUnicode_XStrip(
|
||||
PyObject *self,
|
||||
int striptype,
|
||||
PyObject *sepobj
|
||||
);
|
||||
|
||||
/* Using explicit passed-in values, insert the thousands grouping
|
||||
into the string pointed to by buffer. For the argument descriptions,
|
||||
see Objects/stringlib/localeutil.h */
|
||||
PyAPI_FUNC(Py_ssize_t) _PyUnicode_InsertThousandsGrouping(
|
||||
_PyUnicodeWriter *writer,
|
||||
Py_ssize_t n_buffer,
|
||||
PyObject *digits,
|
||||
Py_ssize_t d_pos,
|
||||
Py_ssize_t n_digits,
|
||||
Py_ssize_t min_width,
|
||||
const char *grouping,
|
||||
PyObject *thousands_sep,
|
||||
Py_UCS4 *maxchar);
|
||||
|
||||
/* === Characters Type APIs =============================================== */
|
||||
|
||||
/* These should not be used directly. Use the Py_UNICODE_IS* and
|
||||
Py_UNICODE_TO* macros instead.
|
||||
|
||||
These APIs are implemented in Objects/unicodectype.c.
|
||||
|
||||
*/
|
||||
|
||||
PyAPI_FUNC(int) _PyUnicode_IsLowercase(
|
||||
Py_UCS4 ch /* Unicode character */
|
||||
);
|
||||
|
||||
PyAPI_FUNC(int) _PyUnicode_IsUppercase(
|
||||
Py_UCS4 ch /* Unicode character */
|
||||
);
|
||||
|
||||
PyAPI_FUNC(int) _PyUnicode_IsTitlecase(
|
||||
Py_UCS4 ch /* Unicode character */
|
||||
);
|
||||
|
||||
PyAPI_FUNC(int) _PyUnicode_IsXidStart(
|
||||
Py_UCS4 ch /* Unicode character */
|
||||
);
|
||||
|
||||
PyAPI_FUNC(int) _PyUnicode_IsXidContinue(
|
||||
Py_UCS4 ch /* Unicode character */
|
||||
);
|
||||
|
||||
PyAPI_FUNC(int) _PyUnicode_IsWhitespace(
|
||||
const Py_UCS4 ch /* Unicode character */
|
||||
);
|
||||
|
||||
PyAPI_FUNC(int) _PyUnicode_IsLinebreak(
|
||||
const Py_UCS4 ch /* Unicode character */
|
||||
);
|
||||
|
||||
/* Py_DEPRECATED(3.3) */ PyAPI_FUNC(Py_UCS4) _PyUnicode_ToLowercase(
|
||||
Py_UCS4 ch /* Unicode character */
|
||||
);
|
||||
|
||||
/* Py_DEPRECATED(3.3) */ PyAPI_FUNC(Py_UCS4) _PyUnicode_ToUppercase(
|
||||
Py_UCS4 ch /* Unicode character */
|
||||
);
|
||||
|
||||
Py_DEPRECATED(3.3) PyAPI_FUNC(Py_UCS4) _PyUnicode_ToTitlecase(
|
||||
Py_UCS4 ch /* Unicode character */
|
||||
);
|
||||
|
||||
PyAPI_FUNC(int) _PyUnicode_ToLowerFull(
|
||||
Py_UCS4 ch, /* Unicode character */
|
||||
Py_UCS4 *res
|
||||
);
|
||||
|
||||
PyAPI_FUNC(int) _PyUnicode_ToTitleFull(
|
||||
Py_UCS4 ch, /* Unicode character */
|
||||
Py_UCS4 *res
|
||||
);
|
||||
|
||||
PyAPI_FUNC(int) _PyUnicode_ToUpperFull(
|
||||
Py_UCS4 ch, /* Unicode character */
|
||||
Py_UCS4 *res
|
||||
);
|
||||
|
||||
PyAPI_FUNC(int) _PyUnicode_ToFoldedFull(
|
||||
Py_UCS4 ch, /* Unicode character */
|
||||
Py_UCS4 *res
|
||||
);
|
||||
|
||||
PyAPI_FUNC(int) _PyUnicode_IsCaseIgnorable(
|
||||
Py_UCS4 ch /* Unicode character */
|
||||
);
|
||||
|
||||
PyAPI_FUNC(int) _PyUnicode_IsCased(
|
||||
Py_UCS4 ch /* Unicode character */
|
||||
);
|
||||
|
||||
PyAPI_FUNC(int) _PyUnicode_ToDecimalDigit(
|
||||
Py_UCS4 ch /* Unicode character */
|
||||
);
|
||||
|
||||
PyAPI_FUNC(int) _PyUnicode_ToDigit(
|
||||
Py_UCS4 ch /* Unicode character */
|
||||
);
|
||||
|
||||
PyAPI_FUNC(double) _PyUnicode_ToNumeric(
|
||||
Py_UCS4 ch /* Unicode character */
|
||||
);
|
||||
|
||||
PyAPI_FUNC(int) _PyUnicode_IsDecimalDigit(
|
||||
Py_UCS4 ch /* Unicode character */
|
||||
);
|
||||
|
||||
PyAPI_FUNC(int) _PyUnicode_IsDigit(
|
||||
Py_UCS4 ch /* Unicode character */
|
||||
);
|
||||
|
||||
PyAPI_FUNC(int) _PyUnicode_IsNumeric(
|
||||
Py_UCS4 ch /* Unicode character */
|
||||
);
|
||||
|
||||
PyAPI_FUNC(int) _PyUnicode_IsPrintable(
|
||||
Py_UCS4 ch /* Unicode character */
|
||||
);
|
||||
|
||||
PyAPI_FUNC(int) _PyUnicode_IsAlpha(
|
||||
Py_UCS4 ch /* Unicode character */
|
||||
);
|
||||
|
||||
// Helper array used by Py_UNICODE_ISSPACE().
|
||||
PyAPI_DATA(const unsigned char) _Py_ascii_whitespace[];
|
||||
|
||||
// Since splitting on whitespace is an important use case, and
|
||||
// whitespace in most situations is solely ASCII whitespace, we
|
||||
// optimize for the common case by using a quick look-up table
|
||||
// _Py_ascii_whitespace (see below) with an inlined check.
|
||||
static inline int Py_UNICODE_ISSPACE(Py_UCS4 ch) {
|
||||
if (ch < 128) {
|
||||
return _Py_ascii_whitespace[ch];
|
||||
}
|
||||
return _PyUnicode_IsWhitespace(ch);
|
||||
}
|
||||
|
||||
#define Py_UNICODE_ISLOWER(ch) _PyUnicode_IsLowercase(ch)
|
||||
#define Py_UNICODE_ISUPPER(ch) _PyUnicode_IsUppercase(ch)
|
||||
#define Py_UNICODE_ISTITLE(ch) _PyUnicode_IsTitlecase(ch)
|
||||
#define Py_UNICODE_ISLINEBREAK(ch) _PyUnicode_IsLinebreak(ch)
|
||||
|
||||
#define Py_UNICODE_TOLOWER(ch) _PyUnicode_ToLowercase(ch)
|
||||
#define Py_UNICODE_TOUPPER(ch) _PyUnicode_ToUppercase(ch)
|
||||
#define Py_UNICODE_TOTITLE(ch) _PyUnicode_ToTitlecase(ch)
|
||||
|
||||
#define Py_UNICODE_ISDECIMAL(ch) _PyUnicode_IsDecimalDigit(ch)
|
||||
#define Py_UNICODE_ISDIGIT(ch) _PyUnicode_IsDigit(ch)
|
||||
#define Py_UNICODE_ISNUMERIC(ch) _PyUnicode_IsNumeric(ch)
|
||||
#define Py_UNICODE_ISPRINTABLE(ch) _PyUnicode_IsPrintable(ch)
|
||||
|
||||
#define Py_UNICODE_TODECIMAL(ch) _PyUnicode_ToDecimalDigit(ch)
|
||||
#define Py_UNICODE_TODIGIT(ch) _PyUnicode_ToDigit(ch)
|
||||
#define Py_UNICODE_TONUMERIC(ch) _PyUnicode_ToNumeric(ch)
|
||||
|
||||
#define Py_UNICODE_ISALPHA(ch) _PyUnicode_IsAlpha(ch)
|
||||
|
||||
static inline int Py_UNICODE_ISALNUM(Py_UCS4 ch) {
|
||||
return (Py_UNICODE_ISALPHA(ch)
|
||||
|| Py_UNICODE_ISDECIMAL(ch)
|
||||
|| Py_UNICODE_ISDIGIT(ch)
|
||||
|| Py_UNICODE_ISNUMERIC(ch));
|
||||
}
|
||||
|
||||
|
||||
/* === Misc functions ===================================================== */
|
||||
|
||||
PyAPI_FUNC(PyObject*) _PyUnicode_FormatLong(PyObject *, int, int, int);
|
||||
|
||||
/* Return an interned Unicode object for an Identifier; may fail if there is no memory.*/
|
||||
PyAPI_FUNC(PyObject*) _PyUnicode_FromId(_Py_Identifier*);
|
||||
|
||||
/* Fast equality check when the inputs are known to be exact unicode types
|
||||
and where the hash values are equal (i.e. a very probable match) */
|
||||
PyAPI_FUNC(int) _PyUnicode_EQ(PyObject *, PyObject *);
|
||||
|
||||
/* Equality check. */
|
||||
PyAPI_FUNC(int) _PyUnicode_Equal(PyObject *, PyObject *);
|
||||
|
||||
PyAPI_FUNC(int) _PyUnicode_WideCharString_Converter(PyObject *, void *);
|
||||
PyAPI_FUNC(int) _PyUnicode_WideCharString_Opt_Converter(PyObject *, void *);
|
||||
|
||||
PyAPI_FUNC(Py_ssize_t) _PyUnicode_ScanIdentifier(PyObject *);
|
||||
20
crypto/shamirs_secret_sharing/include/cpython/warnings.h
Normal file
20
crypto/shamirs_secret_sharing/include/cpython/warnings.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef Py_CPYTHON_WARNINGS_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(int) PyErr_WarnExplicitObject(
|
||||
PyObject *category,
|
||||
PyObject *message,
|
||||
PyObject *filename,
|
||||
int lineno,
|
||||
PyObject *module,
|
||||
PyObject *registry);
|
||||
|
||||
PyAPI_FUNC(int) PyErr_WarnExplicitFormat(
|
||||
PyObject *category,
|
||||
const char *filename, int lineno,
|
||||
const char *module, PyObject *registry,
|
||||
const char *format, ...);
|
||||
|
||||
// DEPRECATED: Use PyErr_WarnEx() instead.
|
||||
#define PyErr_Warn(category, msg) PyErr_WarnEx((category), (msg), 1)
|
||||
@@ -0,0 +1,56 @@
|
||||
#ifndef Py_CPYTHON_WEAKREFOBJECT_H
|
||||
# error "this header file must not be included directly"
|
||||
#endif
|
||||
|
||||
/* PyWeakReference is the base struct for the Python ReferenceType, ProxyType,
|
||||
* and CallableProxyType.
|
||||
*/
|
||||
struct _PyWeakReference {
|
||||
PyObject_HEAD
|
||||
|
||||
/* The object to which this is a weak reference, or Py_None if none.
|
||||
* Note that this is a stealth reference: wr_object's refcount is
|
||||
* not incremented to reflect this pointer.
|
||||
*/
|
||||
PyObject *wr_object;
|
||||
|
||||
/* A callable to invoke when wr_object dies, or NULL if none. */
|
||||
PyObject *wr_callback;
|
||||
|
||||
/* A cache for wr_object's hash code. As usual for hashes, this is -1
|
||||
* if the hash code isn't known yet.
|
||||
*/
|
||||
Py_hash_t hash;
|
||||
|
||||
/* If wr_object is weakly referenced, wr_object has a doubly-linked NULL-
|
||||
* terminated list of weak references to it. These are the list pointers.
|
||||
* If wr_object goes away, wr_object is set to Py_None, and these pointers
|
||||
* have no meaning then.
|
||||
*/
|
||||
PyWeakReference *wr_prev;
|
||||
PyWeakReference *wr_next;
|
||||
vectorcallfunc vectorcall;
|
||||
};
|
||||
|
||||
PyAPI_FUNC(Py_ssize_t) _PyWeakref_GetWeakrefCount(PyWeakReference *head);
|
||||
|
||||
PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference *self);
|
||||
|
||||
static inline PyObject* PyWeakref_GET_OBJECT(PyObject *ref_obj) {
|
||||
PyWeakReference *ref;
|
||||
PyObject *obj;
|
||||
assert(PyWeakref_Check(ref_obj));
|
||||
ref = _Py_CAST(PyWeakReference*, ref_obj);
|
||||
obj = ref->wr_object;
|
||||
// Explanation for the Py_REFCNT() check: when a weakref's target is part
|
||||
// of a long chain of deallocations which triggers the trashcan mechanism,
|
||||
// clearing the weakrefs can be delayed long after the target's refcount
|
||||
// has dropped to zero. In the meantime, code accessing the weakref will
|
||||
// be able to "see" the target object even though it is supposed to be
|
||||
// unreachable. See issue gh-60806.
|
||||
if (Py_REFCNT(obj) > 0) {
|
||||
return obj;
|
||||
}
|
||||
return Py_None;
|
||||
}
|
||||
#define PyWeakref_GET_OBJECT(ref) PyWeakref_GET_OBJECT(_PyObject_CAST(ref))
|
||||
267
crypto/shamirs_secret_sharing/include/datetime.h
Normal file
267
crypto/shamirs_secret_sharing/include/datetime.h
Normal file
@@ -0,0 +1,267 @@
|
||||
/* datetime.h
|
||||
*/
|
||||
#ifndef Py_LIMITED_API
|
||||
#ifndef DATETIME_H
|
||||
#define DATETIME_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Fields are packed into successive bytes, each viewed as unsigned and
|
||||
* big-endian, unless otherwise noted:
|
||||
*
|
||||
* byte offset
|
||||
* 0 year 2 bytes, 1-9999
|
||||
* 2 month 1 byte, 1-12
|
||||
* 3 day 1 byte, 1-31
|
||||
* 4 hour 1 byte, 0-23
|
||||
* 5 minute 1 byte, 0-59
|
||||
* 6 second 1 byte, 0-59
|
||||
* 7 usecond 3 bytes, 0-999999
|
||||
* 10
|
||||
*/
|
||||
|
||||
/* # of bytes for year, month, and day. */
|
||||
#define _PyDateTime_DATE_DATASIZE 4
|
||||
|
||||
/* # of bytes for hour, minute, second, and usecond. */
|
||||
#define _PyDateTime_TIME_DATASIZE 6
|
||||
|
||||
/* # of bytes for year, month, day, hour, minute, second, and usecond. */
|
||||
#define _PyDateTime_DATETIME_DATASIZE 10
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PyObject_HEAD
|
||||
Py_hash_t hashcode; /* -1 when unknown */
|
||||
int days; /* -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS */
|
||||
int seconds; /* 0 <= seconds < 24*3600 is invariant */
|
||||
int microseconds; /* 0 <= microseconds < 1000000 is invariant */
|
||||
} PyDateTime_Delta;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PyObject_HEAD /* a pure abstract base class */
|
||||
} PyDateTime_TZInfo;
|
||||
|
||||
|
||||
/* The datetime and time types have hashcodes, and an optional tzinfo member,
|
||||
* present if and only if hastzinfo is true.
|
||||
*/
|
||||
#define _PyTZINFO_HEAD \
|
||||
PyObject_HEAD \
|
||||
Py_hash_t hashcode; \
|
||||
char hastzinfo; /* boolean flag */
|
||||
|
||||
/* No _PyDateTime_BaseTZInfo is allocated; it's just to have something
|
||||
* convenient to cast to, when getting at the hastzinfo member of objects
|
||||
* starting with _PyTZINFO_HEAD.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
_PyTZINFO_HEAD
|
||||
} _PyDateTime_BaseTZInfo;
|
||||
|
||||
/* All time objects are of PyDateTime_TimeType, but that can be allocated
|
||||
* in two ways, with or without a tzinfo member. Without is the same as
|
||||
* tzinfo == None, but consumes less memory. _PyDateTime_BaseTime is an
|
||||
* internal struct used to allocate the right amount of space for the
|
||||
* "without" case.
|
||||
*/
|
||||
#define _PyDateTime_TIMEHEAD \
|
||||
_PyTZINFO_HEAD \
|
||||
unsigned char data[_PyDateTime_TIME_DATASIZE];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
_PyDateTime_TIMEHEAD
|
||||
} _PyDateTime_BaseTime; /* hastzinfo false */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
_PyDateTime_TIMEHEAD
|
||||
unsigned char fold;
|
||||
PyObject *tzinfo;
|
||||
} PyDateTime_Time; /* hastzinfo true */
|
||||
|
||||
|
||||
/* All datetime objects are of PyDateTime_DateTimeType, but that can be
|
||||
* allocated in two ways too, just like for time objects above. In addition,
|
||||
* the plain date type is a base class for datetime, so it must also have
|
||||
* a hastzinfo member (although it's unused there).
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
_PyTZINFO_HEAD
|
||||
unsigned char data[_PyDateTime_DATE_DATASIZE];
|
||||
} PyDateTime_Date;
|
||||
|
||||
#define _PyDateTime_DATETIMEHEAD \
|
||||
_PyTZINFO_HEAD \
|
||||
unsigned char data[_PyDateTime_DATETIME_DATASIZE];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
_PyDateTime_DATETIMEHEAD
|
||||
} _PyDateTime_BaseDateTime; /* hastzinfo false */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
_PyDateTime_DATETIMEHEAD
|
||||
unsigned char fold;
|
||||
PyObject *tzinfo;
|
||||
} PyDateTime_DateTime; /* hastzinfo true */
|
||||
|
||||
|
||||
/* Apply for date and datetime instances. */
|
||||
|
||||
// o is a pointer to a time or a datetime object.
|
||||
#define _PyDateTime_HAS_TZINFO(o) (((_PyDateTime_BaseTZInfo *)(o))->hastzinfo)
|
||||
|
||||
#define PyDateTime_GET_YEAR(o) ((((PyDateTime_Date*)(o))->data[0] << 8) | \
|
||||
((PyDateTime_Date*)(o))->data[1])
|
||||
#define PyDateTime_GET_MONTH(o) (((PyDateTime_Date*)(o))->data[2])
|
||||
#define PyDateTime_GET_DAY(o) (((PyDateTime_Date*)(o))->data[3])
|
||||
|
||||
#define PyDateTime_DATE_GET_HOUR(o) (((PyDateTime_DateTime*)(o))->data[4])
|
||||
#define PyDateTime_DATE_GET_MINUTE(o) (((PyDateTime_DateTime*)(o))->data[5])
|
||||
#define PyDateTime_DATE_GET_SECOND(o) (((PyDateTime_DateTime*)(o))->data[6])
|
||||
#define PyDateTime_DATE_GET_MICROSECOND(o) \
|
||||
((((PyDateTime_DateTime*)(o))->data[7] << 16) | \
|
||||
(((PyDateTime_DateTime*)(o))->data[8] << 8) | \
|
||||
((PyDateTime_DateTime*)(o))->data[9])
|
||||
#define PyDateTime_DATE_GET_FOLD(o) (((PyDateTime_DateTime*)(o))->fold)
|
||||
#define PyDateTime_DATE_GET_TZINFO(o) (_PyDateTime_HAS_TZINFO((o)) ? \
|
||||
((PyDateTime_DateTime *)(o))->tzinfo : Py_None)
|
||||
|
||||
/* Apply for time instances. */
|
||||
#define PyDateTime_TIME_GET_HOUR(o) (((PyDateTime_Time*)(o))->data[0])
|
||||
#define PyDateTime_TIME_GET_MINUTE(o) (((PyDateTime_Time*)(o))->data[1])
|
||||
#define PyDateTime_TIME_GET_SECOND(o) (((PyDateTime_Time*)(o))->data[2])
|
||||
#define PyDateTime_TIME_GET_MICROSECOND(o) \
|
||||
((((PyDateTime_Time*)(o))->data[3] << 16) | \
|
||||
(((PyDateTime_Time*)(o))->data[4] << 8) | \
|
||||
((PyDateTime_Time*)(o))->data[5])
|
||||
#define PyDateTime_TIME_GET_FOLD(o) (((PyDateTime_Time*)(o))->fold)
|
||||
#define PyDateTime_TIME_GET_TZINFO(o) (_PyDateTime_HAS_TZINFO(o) ? \
|
||||
((PyDateTime_Time *)(o))->tzinfo : Py_None)
|
||||
|
||||
/* Apply for time delta instances */
|
||||
#define PyDateTime_DELTA_GET_DAYS(o) (((PyDateTime_Delta*)(o))->days)
|
||||
#define PyDateTime_DELTA_GET_SECONDS(o) (((PyDateTime_Delta*)(o))->seconds)
|
||||
#define PyDateTime_DELTA_GET_MICROSECONDS(o) \
|
||||
(((PyDateTime_Delta*)(o))->microseconds)
|
||||
|
||||
|
||||
/* Define structure for C API. */
|
||||
typedef struct {
|
||||
/* type objects */
|
||||
PyTypeObject *DateType;
|
||||
PyTypeObject *DateTimeType;
|
||||
PyTypeObject *TimeType;
|
||||
PyTypeObject *DeltaType;
|
||||
PyTypeObject *TZInfoType;
|
||||
|
||||
/* singletons */
|
||||
PyObject *TimeZone_UTC;
|
||||
|
||||
/* constructors */
|
||||
PyObject *(*Date_FromDate)(int, int, int, PyTypeObject*);
|
||||
PyObject *(*DateTime_FromDateAndTime)(int, int, int, int, int, int, int,
|
||||
PyObject*, PyTypeObject*);
|
||||
PyObject *(*Time_FromTime)(int, int, int, int, PyObject*, PyTypeObject*);
|
||||
PyObject *(*Delta_FromDelta)(int, int, int, int, PyTypeObject*);
|
||||
PyObject *(*TimeZone_FromTimeZone)(PyObject *offset, PyObject *name);
|
||||
|
||||
/* constructors for the DB API */
|
||||
PyObject *(*DateTime_FromTimestamp)(PyObject*, PyObject*, PyObject*);
|
||||
PyObject *(*Date_FromTimestamp)(PyObject*, PyObject*);
|
||||
|
||||
/* PEP 495 constructors */
|
||||
PyObject *(*DateTime_FromDateAndTimeAndFold)(int, int, int, int, int, int, int,
|
||||
PyObject*, int, PyTypeObject*);
|
||||
PyObject *(*Time_FromTimeAndFold)(int, int, int, int, PyObject*, int, PyTypeObject*);
|
||||
|
||||
} PyDateTime_CAPI;
|
||||
|
||||
#define PyDateTime_CAPSULE_NAME "datetime.datetime_CAPI"
|
||||
|
||||
|
||||
/* This block is only used as part of the public API and should not be
|
||||
* included in _datetimemodule.c, which does not use the C API capsule.
|
||||
* See bpo-35081 for more details.
|
||||
* */
|
||||
#ifndef _PY_DATETIME_IMPL
|
||||
/* Define global variable for the C API and a macro for setting it. */
|
||||
static PyDateTime_CAPI *PyDateTimeAPI = NULL;
|
||||
|
||||
#define PyDateTime_IMPORT \
|
||||
PyDateTimeAPI = (PyDateTime_CAPI *)PyCapsule_Import(PyDateTime_CAPSULE_NAME, 0)
|
||||
|
||||
/* Macro for access to the UTC singleton */
|
||||
#define PyDateTime_TimeZone_UTC PyDateTimeAPI->TimeZone_UTC
|
||||
|
||||
/* Macros for type checking when not building the Python core. */
|
||||
#define PyDate_Check(op) PyObject_TypeCheck((op), PyDateTimeAPI->DateType)
|
||||
#define PyDate_CheckExact(op) Py_IS_TYPE((op), PyDateTimeAPI->DateType)
|
||||
|
||||
#define PyDateTime_Check(op) PyObject_TypeCheck((op), PyDateTimeAPI->DateTimeType)
|
||||
#define PyDateTime_CheckExact(op) Py_IS_TYPE((op), PyDateTimeAPI->DateTimeType)
|
||||
|
||||
#define PyTime_Check(op) PyObject_TypeCheck((op), PyDateTimeAPI->TimeType)
|
||||
#define PyTime_CheckExact(op) Py_IS_TYPE((op), PyDateTimeAPI->TimeType)
|
||||
|
||||
#define PyDelta_Check(op) PyObject_TypeCheck((op), PyDateTimeAPI->DeltaType)
|
||||
#define PyDelta_CheckExact(op) Py_IS_TYPE((op), PyDateTimeAPI->DeltaType)
|
||||
|
||||
#define PyTZInfo_Check(op) PyObject_TypeCheck((op), PyDateTimeAPI->TZInfoType)
|
||||
#define PyTZInfo_CheckExact(op) Py_IS_TYPE((op), PyDateTimeAPI->TZInfoType)
|
||||
|
||||
|
||||
/* Macros for accessing constructors in a simplified fashion. */
|
||||
#define PyDate_FromDate(year, month, day) \
|
||||
PyDateTimeAPI->Date_FromDate((year), (month), (day), PyDateTimeAPI->DateType)
|
||||
|
||||
#define PyDateTime_FromDateAndTime(year, month, day, hour, min, sec, usec) \
|
||||
PyDateTimeAPI->DateTime_FromDateAndTime((year), (month), (day), (hour), \
|
||||
(min), (sec), (usec), Py_None, PyDateTimeAPI->DateTimeType)
|
||||
|
||||
#define PyDateTime_FromDateAndTimeAndFold(year, month, day, hour, min, sec, usec, fold) \
|
||||
PyDateTimeAPI->DateTime_FromDateAndTimeAndFold((year), (month), (day), (hour), \
|
||||
(min), (sec), (usec), Py_None, (fold), PyDateTimeAPI->DateTimeType)
|
||||
|
||||
#define PyTime_FromTime(hour, minute, second, usecond) \
|
||||
PyDateTimeAPI->Time_FromTime((hour), (minute), (second), (usecond), \
|
||||
Py_None, PyDateTimeAPI->TimeType)
|
||||
|
||||
#define PyTime_FromTimeAndFold(hour, minute, second, usecond, fold) \
|
||||
PyDateTimeAPI->Time_FromTimeAndFold((hour), (minute), (second), (usecond), \
|
||||
Py_None, (fold), PyDateTimeAPI->TimeType)
|
||||
|
||||
#define PyDelta_FromDSU(days, seconds, useconds) \
|
||||
PyDateTimeAPI->Delta_FromDelta((days), (seconds), (useconds), 1, \
|
||||
PyDateTimeAPI->DeltaType)
|
||||
|
||||
#define PyTimeZone_FromOffset(offset) \
|
||||
PyDateTimeAPI->TimeZone_FromTimeZone((offset), NULL)
|
||||
|
||||
#define PyTimeZone_FromOffsetAndName(offset, name) \
|
||||
PyDateTimeAPI->TimeZone_FromTimeZone((offset), (name))
|
||||
|
||||
/* Macros supporting the DB API. */
|
||||
#define PyDateTime_FromTimestamp(args) \
|
||||
PyDateTimeAPI->DateTime_FromTimestamp( \
|
||||
(PyObject*) (PyDateTimeAPI->DateTimeType), (args), NULL)
|
||||
|
||||
#define PyDate_FromTimestamp(args) \
|
||||
PyDateTimeAPI->Date_FromTimestamp( \
|
||||
(PyObject*) (PyDateTimeAPI->DateType), (args))
|
||||
|
||||
#endif /* !defined(_PY_DATETIME_IMPL) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif /* !Py_LIMITED_API */
|
||||
100
crypto/shamirs_secret_sharing/include/descrobject.h
Normal file
100
crypto/shamirs_secret_sharing/include/descrobject.h
Normal file
@@ -0,0 +1,100 @@
|
||||
/* Descriptors */
|
||||
#ifndef Py_DESCROBJECT_H
|
||||
#define Py_DESCROBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef PyObject *(*getter)(PyObject *, void *);
|
||||
typedef int (*setter)(PyObject *, PyObject *, void *);
|
||||
|
||||
struct PyGetSetDef {
|
||||
const char *name;
|
||||
getter get;
|
||||
setter set;
|
||||
const char *doc;
|
||||
void *closure;
|
||||
};
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyClassMethodDescr_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyMemberDescr_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyMethodDescr_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyProperty_Type;
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
|
||||
PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);
|
||||
PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *, PyMemberDef *);
|
||||
PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *, PyGetSetDef *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *);
|
||||
|
||||
|
||||
/* An array of PyMemberDef structures defines the name, type and offset
|
||||
of selected members of a C structure. These can be read by
|
||||
PyMember_GetOne() and set by PyMember_SetOne() (except if their READONLY
|
||||
flag is set). The array must be terminated with an entry whose name
|
||||
pointer is NULL. */
|
||||
struct PyMemberDef {
|
||||
const char *name;
|
||||
int type;
|
||||
Py_ssize_t offset;
|
||||
int flags;
|
||||
const char *doc;
|
||||
};
|
||||
|
||||
// These constants used to be in structmember.h, not prefixed by Py_.
|
||||
// (structmember.h now has aliases to the new names.)
|
||||
|
||||
/* Types */
|
||||
#define Py_T_SHORT 0
|
||||
#define Py_T_INT 1
|
||||
#define Py_T_LONG 2
|
||||
#define Py_T_FLOAT 3
|
||||
#define Py_T_DOUBLE 4
|
||||
#define Py_T_STRING 5
|
||||
#define _Py_T_OBJECT 6 // Deprecated, use Py_T_OBJECT_EX instead
|
||||
/* the ordering here is weird for binary compatibility */
|
||||
#define Py_T_CHAR 7 /* 1-character string */
|
||||
#define Py_T_BYTE 8 /* 8-bit signed int */
|
||||
/* unsigned variants: */
|
||||
#define Py_T_UBYTE 9
|
||||
#define Py_T_USHORT 10
|
||||
#define Py_T_UINT 11
|
||||
#define Py_T_ULONG 12
|
||||
|
||||
/* Added by Jack: strings contained in the structure */
|
||||
#define Py_T_STRING_INPLACE 13
|
||||
|
||||
/* Added by Lillo: bools contained in the structure (assumed char) */
|
||||
#define Py_T_BOOL 14
|
||||
|
||||
#define Py_T_OBJECT_EX 16
|
||||
#define Py_T_LONGLONG 17
|
||||
#define Py_T_ULONGLONG 18
|
||||
|
||||
#define Py_T_PYSSIZET 19 /* Py_ssize_t */
|
||||
#define _Py_T_NONE 20 // Deprecated. Value is always None.
|
||||
|
||||
/* Flags */
|
||||
#define Py_READONLY 1
|
||||
#define Py_AUDIT_READ 2 // Added in 3.10, harmless no-op before that
|
||||
#define _Py_WRITE_RESTRICTED 4 // Deprecated, no-op. Do not reuse the value.
|
||||
#define Py_RELATIVE_OFFSET 8
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyMember_GetOne(const char *, PyMemberDef *);
|
||||
PyAPI_FUNC(int) PyMember_SetOne(char *, PyMemberDef *, PyObject *);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
# define Py_CPYTHON_DESCROBJECT_H
|
||||
# include "cpython/descrobject.h"
|
||||
# undef Py_CPYTHON_DESCROBJECT_H
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_DESCROBJECT_H */
|
||||
97
crypto/shamirs_secret_sharing/include/dictobject.h
Normal file
97
crypto/shamirs_secret_sharing/include/dictobject.h
Normal file
@@ -0,0 +1,97 @@
|
||||
#ifndef Py_DICTOBJECT_H
|
||||
#define Py_DICTOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Dictionary object type -- mapping from hashable object to object */
|
||||
|
||||
/* The distribution includes a separate file, Objects/dictnotes.txt,
|
||||
describing explorations into dictionary design and optimization.
|
||||
It covers typical dictionary use patterns, the parameters for
|
||||
tuning dictionaries, and several ideas for possible optimizations.
|
||||
*/
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyDict_Type;
|
||||
|
||||
#define PyDict_Check(op) \
|
||||
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_DICT_SUBCLASS)
|
||||
#define PyDict_CheckExact(op) Py_IS_TYPE((op), &PyDict_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyDict_New(void);
|
||||
PyAPI_FUNC(PyObject *) PyDict_GetItem(PyObject *mp, PyObject *key);
|
||||
PyAPI_FUNC(PyObject *) PyDict_GetItemWithError(PyObject *mp, PyObject *key);
|
||||
PyAPI_FUNC(int) PyDict_SetItem(PyObject *mp, PyObject *key, PyObject *item);
|
||||
PyAPI_FUNC(int) PyDict_DelItem(PyObject *mp, PyObject *key);
|
||||
PyAPI_FUNC(void) PyDict_Clear(PyObject *mp);
|
||||
PyAPI_FUNC(int) PyDict_Next(
|
||||
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value);
|
||||
PyAPI_FUNC(PyObject *) PyDict_Keys(PyObject *mp);
|
||||
PyAPI_FUNC(PyObject *) PyDict_Values(PyObject *mp);
|
||||
PyAPI_FUNC(PyObject *) PyDict_Items(PyObject *mp);
|
||||
PyAPI_FUNC(Py_ssize_t) PyDict_Size(PyObject *mp);
|
||||
PyAPI_FUNC(PyObject *) PyDict_Copy(PyObject *mp);
|
||||
PyAPI_FUNC(int) PyDict_Contains(PyObject *mp, PyObject *key);
|
||||
|
||||
/* PyDict_Update(mp, other) is equivalent to PyDict_Merge(mp, other, 1). */
|
||||
PyAPI_FUNC(int) PyDict_Update(PyObject *mp, PyObject *other);
|
||||
|
||||
/* PyDict_Merge updates/merges from a mapping object (an object that
|
||||
supports PyMapping_Keys() and PyObject_GetItem()). If override is true,
|
||||
the last occurrence of a key wins, else the first. The Python
|
||||
dict.update(other) is equivalent to PyDict_Merge(dict, other, 1).
|
||||
*/
|
||||
PyAPI_FUNC(int) PyDict_Merge(PyObject *mp,
|
||||
PyObject *other,
|
||||
int override);
|
||||
|
||||
/* PyDict_MergeFromSeq2 updates/merges from an iterable object producing
|
||||
iterable objects of length 2. If override is true, the last occurrence
|
||||
of a key wins, else the first. The Python dict constructor dict(seq2)
|
||||
is equivalent to dict={}; PyDict_MergeFromSeq(dict, seq2, 1).
|
||||
*/
|
||||
PyAPI_FUNC(int) PyDict_MergeFromSeq2(PyObject *d,
|
||||
PyObject *seq2,
|
||||
int override);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyDict_GetItemString(PyObject *dp, const char *key);
|
||||
PyAPI_FUNC(int) PyDict_SetItemString(PyObject *dp, const char *key, PyObject *item);
|
||||
PyAPI_FUNC(int) PyDict_DelItemString(PyObject *dp, const char *key);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000
|
||||
PyAPI_FUNC(PyObject *) PyObject_GenericGetDict(PyObject *, void *);
|
||||
#endif
|
||||
|
||||
/* Dictionary (keys, values, items) views */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyDictKeys_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictValues_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictItems_Type;
|
||||
|
||||
#define PyDictKeys_Check(op) PyObject_TypeCheck((op), &PyDictKeys_Type)
|
||||
#define PyDictValues_Check(op) PyObject_TypeCheck((op), &PyDictValues_Type)
|
||||
#define PyDictItems_Check(op) PyObject_TypeCheck((op), &PyDictItems_Type)
|
||||
/* This excludes Values, since they are not sets. */
|
||||
# define PyDictViewSet_Check(op) \
|
||||
(PyDictKeys_Check(op) || PyDictItems_Check(op))
|
||||
|
||||
/* Dictionary (key, value, items) iterators */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyDictIterKey_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictIterValue_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictIterItem_Type;
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyDictRevIterKey_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictRevIterItem_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyDictRevIterValue_Type;
|
||||
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
# define Py_CPYTHON_DICTOBJECT_H
|
||||
# include "cpython/dictobject.h"
|
||||
# undef Py_CPYTHON_DICTOBJECT_H
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_DICTOBJECT_H */
|
||||
499
crypto/shamirs_secret_sharing/include/dynamic_annotations.h
Normal file
499
crypto/shamirs_secret_sharing/include/dynamic_annotations.h
Normal file
@@ -0,0 +1,499 @@
|
||||
/* Copyright (c) 2008-2009, Google Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are
|
||||
* met:
|
||||
*
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Neither the name of Google Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* ---
|
||||
* Author: Kostya Serebryany
|
||||
* Copied to CPython by Jeffrey Yasskin, with all macros renamed to
|
||||
* start with _Py_ to avoid colliding with users embedding Python, and
|
||||
* with deprecated macros removed.
|
||||
*/
|
||||
|
||||
/* This file defines dynamic annotations for use with dynamic analysis
|
||||
tool such as valgrind, PIN, etc.
|
||||
|
||||
Dynamic annotation is a source code annotation that affects
|
||||
the generated code (that is, the annotation is not a comment).
|
||||
Each such annotation is attached to a particular
|
||||
instruction and/or to a particular object (address) in the program.
|
||||
|
||||
The annotations that should be used by users are macros in all upper-case
|
||||
(e.g., _Py_ANNOTATE_NEW_MEMORY).
|
||||
|
||||
Actual implementation of these macros may differ depending on the
|
||||
dynamic analysis tool being used.
|
||||
|
||||
See https://code.google.com/p/data-race-test/ for more information.
|
||||
|
||||
This file supports the following dynamic analysis tools:
|
||||
- None (DYNAMIC_ANNOTATIONS_ENABLED is not defined or zero).
|
||||
Macros are defined empty.
|
||||
- ThreadSanitizer, Helgrind, DRD (DYNAMIC_ANNOTATIONS_ENABLED is 1).
|
||||
Macros are defined as calls to non-inlinable empty functions
|
||||
that are intercepted by Valgrind. */
|
||||
|
||||
#ifndef __DYNAMIC_ANNOTATIONS_H__
|
||||
#define __DYNAMIC_ANNOTATIONS_H__
|
||||
|
||||
#ifndef DYNAMIC_ANNOTATIONS_ENABLED
|
||||
# define DYNAMIC_ANNOTATIONS_ENABLED 0
|
||||
#endif
|
||||
|
||||
#if DYNAMIC_ANNOTATIONS_ENABLED != 0
|
||||
|
||||
/* -------------------------------------------------------------
|
||||
Annotations useful when implementing condition variables such as CondVar,
|
||||
using conditional critical sections (Await/LockWhen) and when constructing
|
||||
user-defined synchronization mechanisms.
|
||||
|
||||
The annotations _Py_ANNOTATE_HAPPENS_BEFORE() and
|
||||
_Py_ANNOTATE_HAPPENS_AFTER() can be used to define happens-before arcs in
|
||||
user-defined synchronization mechanisms: the race detector will infer an
|
||||
arc from the former to the latter when they share the same argument
|
||||
pointer.
|
||||
|
||||
Example 1 (reference counting):
|
||||
|
||||
void Unref() {
|
||||
_Py_ANNOTATE_HAPPENS_BEFORE(&refcount_);
|
||||
if (AtomicDecrementByOne(&refcount_) == 0) {
|
||||
_Py_ANNOTATE_HAPPENS_AFTER(&refcount_);
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
Example 2 (message queue):
|
||||
|
||||
void MyQueue::Put(Type *e) {
|
||||
MutexLock lock(&mu_);
|
||||
_Py_ANNOTATE_HAPPENS_BEFORE(e);
|
||||
PutElementIntoMyQueue(e);
|
||||
}
|
||||
|
||||
Type *MyQueue::Get() {
|
||||
MutexLock lock(&mu_);
|
||||
Type *e = GetElementFromMyQueue();
|
||||
_Py_ANNOTATE_HAPPENS_AFTER(e);
|
||||
return e;
|
||||
}
|
||||
|
||||
Note: when possible, please use the existing reference counting and message
|
||||
queue implementations instead of inventing new ones. */
|
||||
|
||||
/* Report that wait on the condition variable at address "cv" has succeeded
|
||||
and the lock at address "lock" is held. */
|
||||
#define _Py_ANNOTATE_CONDVAR_LOCK_WAIT(cv, lock) \
|
||||
AnnotateCondVarWait(__FILE__, __LINE__, cv, lock)
|
||||
|
||||
/* Report that wait on the condition variable at "cv" has succeeded. Variant
|
||||
w/o lock. */
|
||||
#define _Py_ANNOTATE_CONDVAR_WAIT(cv) \
|
||||
AnnotateCondVarWait(__FILE__, __LINE__, cv, NULL)
|
||||
|
||||
/* Report that we are about to signal on the condition variable at address
|
||||
"cv". */
|
||||
#define _Py_ANNOTATE_CONDVAR_SIGNAL(cv) \
|
||||
AnnotateCondVarSignal(__FILE__, __LINE__, cv)
|
||||
|
||||
/* Report that we are about to signal_all on the condition variable at "cv". */
|
||||
#define _Py_ANNOTATE_CONDVAR_SIGNAL_ALL(cv) \
|
||||
AnnotateCondVarSignalAll(__FILE__, __LINE__, cv)
|
||||
|
||||
/* Annotations for user-defined synchronization mechanisms. */
|
||||
#define _Py_ANNOTATE_HAPPENS_BEFORE(obj) _Py_ANNOTATE_CONDVAR_SIGNAL(obj)
|
||||
#define _Py_ANNOTATE_HAPPENS_AFTER(obj) _Py_ANNOTATE_CONDVAR_WAIT(obj)
|
||||
|
||||
/* Report that the bytes in the range [pointer, pointer+size) are about
|
||||
to be published safely. The race checker will create a happens-before
|
||||
arc from the call _Py_ANNOTATE_PUBLISH_MEMORY_RANGE(pointer, size) to
|
||||
subsequent accesses to this memory.
|
||||
Note: this annotation may not work properly if the race detector uses
|
||||
sampling, i.e. does not observe all memory accesses.
|
||||
*/
|
||||
#define _Py_ANNOTATE_PUBLISH_MEMORY_RANGE(pointer, size) \
|
||||
AnnotatePublishMemoryRange(__FILE__, __LINE__, pointer, size)
|
||||
|
||||
/* Instruct the tool to create a happens-before arc between mu->Unlock() and
|
||||
mu->Lock(). This annotation may slow down the race detector and hide real
|
||||
races. Normally it is used only when it would be difficult to annotate each
|
||||
of the mutex's critical sections individually using the annotations above.
|
||||
This annotation makes sense only for hybrid race detectors. For pure
|
||||
happens-before detectors this is a no-op. For more details see
|
||||
https://code.google.com/p/data-race-test/wiki/PureHappensBeforeVsHybrid . */
|
||||
#define _Py_ANNOTATE_PURE_HAPPENS_BEFORE_MUTEX(mu) \
|
||||
AnnotateMutexIsUsedAsCondVar(__FILE__, __LINE__, mu)
|
||||
|
||||
/* -------------------------------------------------------------
|
||||
Annotations useful when defining memory allocators, or when memory that
|
||||
was protected in one way starts to be protected in another. */
|
||||
|
||||
/* Report that a new memory at "address" of size "size" has been allocated.
|
||||
This might be used when the memory has been retrieved from a free list and
|
||||
is about to be reused, or when the locking discipline for a variable
|
||||
changes. */
|
||||
#define _Py_ANNOTATE_NEW_MEMORY(address, size) \
|
||||
AnnotateNewMemory(__FILE__, __LINE__, address, size)
|
||||
|
||||
/* -------------------------------------------------------------
|
||||
Annotations useful when defining FIFO queues that transfer data between
|
||||
threads. */
|
||||
|
||||
/* Report that the producer-consumer queue (such as ProducerConsumerQueue) at
|
||||
address "pcq" has been created. The _Py_ANNOTATE_PCQ_* annotations should
|
||||
be used only for FIFO queues. For non-FIFO queues use
|
||||
_Py_ANNOTATE_HAPPENS_BEFORE (for put) and _Py_ANNOTATE_HAPPENS_AFTER (for
|
||||
get). */
|
||||
#define _Py_ANNOTATE_PCQ_CREATE(pcq) \
|
||||
AnnotatePCQCreate(__FILE__, __LINE__, pcq)
|
||||
|
||||
/* Report that the queue at address "pcq" is about to be destroyed. */
|
||||
#define _Py_ANNOTATE_PCQ_DESTROY(pcq) \
|
||||
AnnotatePCQDestroy(__FILE__, __LINE__, pcq)
|
||||
|
||||
/* Report that we are about to put an element into a FIFO queue at address
|
||||
"pcq". */
|
||||
#define _Py_ANNOTATE_PCQ_PUT(pcq) \
|
||||
AnnotatePCQPut(__FILE__, __LINE__, pcq)
|
||||
|
||||
/* Report that we've just got an element from a FIFO queue at address "pcq". */
|
||||
#define _Py_ANNOTATE_PCQ_GET(pcq) \
|
||||
AnnotatePCQGet(__FILE__, __LINE__, pcq)
|
||||
|
||||
/* -------------------------------------------------------------
|
||||
Annotations that suppress errors. It is usually better to express the
|
||||
program's synchronization using the other annotations, but these can
|
||||
be used when all else fails. */
|
||||
|
||||
/* Report that we may have a benign race at "pointer", with size
|
||||
"sizeof(*(pointer))". "pointer" must be a non-void* pointer. Insert at the
|
||||
point where "pointer" has been allocated, preferably close to the point
|
||||
where the race happens. See also _Py_ANNOTATE_BENIGN_RACE_STATIC. */
|
||||
#define _Py_ANNOTATE_BENIGN_RACE(pointer, description) \
|
||||
AnnotateBenignRaceSized(__FILE__, __LINE__, pointer, \
|
||||
sizeof(*(pointer)), description)
|
||||
|
||||
/* Same as _Py_ANNOTATE_BENIGN_RACE(address, description), but applies to
|
||||
the memory range [address, address+size). */
|
||||
#define _Py_ANNOTATE_BENIGN_RACE_SIZED(address, size, description) \
|
||||
AnnotateBenignRaceSized(__FILE__, __LINE__, address, size, description)
|
||||
|
||||
/* Request the analysis tool to ignore all reads in the current thread
|
||||
until _Py_ANNOTATE_IGNORE_READS_END is called.
|
||||
Useful to ignore intentional racey reads, while still checking
|
||||
other reads and all writes.
|
||||
See also _Py_ANNOTATE_UNPROTECTED_READ. */
|
||||
#define _Py_ANNOTATE_IGNORE_READS_BEGIN() \
|
||||
AnnotateIgnoreReadsBegin(__FILE__, __LINE__)
|
||||
|
||||
/* Stop ignoring reads. */
|
||||
#define _Py_ANNOTATE_IGNORE_READS_END() \
|
||||
AnnotateIgnoreReadsEnd(__FILE__, __LINE__)
|
||||
|
||||
/* Similar to _Py_ANNOTATE_IGNORE_READS_BEGIN, but ignore writes. */
|
||||
#define _Py_ANNOTATE_IGNORE_WRITES_BEGIN() \
|
||||
AnnotateIgnoreWritesBegin(__FILE__, __LINE__)
|
||||
|
||||
/* Stop ignoring writes. */
|
||||
#define _Py_ANNOTATE_IGNORE_WRITES_END() \
|
||||
AnnotateIgnoreWritesEnd(__FILE__, __LINE__)
|
||||
|
||||
/* Start ignoring all memory accesses (reads and writes). */
|
||||
#define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN() \
|
||||
do {\
|
||||
_Py_ANNOTATE_IGNORE_READS_BEGIN();\
|
||||
_Py_ANNOTATE_IGNORE_WRITES_BEGIN();\
|
||||
}while(0)\
|
||||
|
||||
/* Stop ignoring all memory accesses. */
|
||||
#define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_END() \
|
||||
do {\
|
||||
_Py_ANNOTATE_IGNORE_WRITES_END();\
|
||||
_Py_ANNOTATE_IGNORE_READS_END();\
|
||||
}while(0)\
|
||||
|
||||
/* Similar to _Py_ANNOTATE_IGNORE_READS_BEGIN, but ignore synchronization events:
|
||||
RWLOCK* and CONDVAR*. */
|
||||
#define _Py_ANNOTATE_IGNORE_SYNC_BEGIN() \
|
||||
AnnotateIgnoreSyncBegin(__FILE__, __LINE__)
|
||||
|
||||
/* Stop ignoring sync events. */
|
||||
#define _Py_ANNOTATE_IGNORE_SYNC_END() \
|
||||
AnnotateIgnoreSyncEnd(__FILE__, __LINE__)
|
||||
|
||||
|
||||
/* Enable (enable!=0) or disable (enable==0) race detection for all threads.
|
||||
This annotation could be useful if you want to skip expensive race analysis
|
||||
during some period of program execution, e.g. during initialization. */
|
||||
#define _Py_ANNOTATE_ENABLE_RACE_DETECTION(enable) \
|
||||
AnnotateEnableRaceDetection(__FILE__, __LINE__, enable)
|
||||
|
||||
/* -------------------------------------------------------------
|
||||
Annotations useful for debugging. */
|
||||
|
||||
/* Request to trace every access to "address". */
|
||||
#define _Py_ANNOTATE_TRACE_MEMORY(address) \
|
||||
AnnotateTraceMemory(__FILE__, __LINE__, address)
|
||||
|
||||
/* Report the current thread name to a race detector. */
|
||||
#define _Py_ANNOTATE_THREAD_NAME(name) \
|
||||
AnnotateThreadName(__FILE__, __LINE__, name)
|
||||
|
||||
/* -------------------------------------------------------------
|
||||
Annotations useful when implementing locks. They are not
|
||||
normally needed by modules that merely use locks.
|
||||
The "lock" argument is a pointer to the lock object. */
|
||||
|
||||
/* Report that a lock has been created at address "lock". */
|
||||
#define _Py_ANNOTATE_RWLOCK_CREATE(lock) \
|
||||
AnnotateRWLockCreate(__FILE__, __LINE__, lock)
|
||||
|
||||
/* Report that the lock at address "lock" is about to be destroyed. */
|
||||
#define _Py_ANNOTATE_RWLOCK_DESTROY(lock) \
|
||||
AnnotateRWLockDestroy(__FILE__, __LINE__, lock)
|
||||
|
||||
/* Report that the lock at address "lock" has been acquired.
|
||||
is_w=1 for writer lock, is_w=0 for reader lock. */
|
||||
#define _Py_ANNOTATE_RWLOCK_ACQUIRED(lock, is_w) \
|
||||
AnnotateRWLockAcquired(__FILE__, __LINE__, lock, is_w)
|
||||
|
||||
/* Report that the lock at address "lock" is about to be released. */
|
||||
#define _Py_ANNOTATE_RWLOCK_RELEASED(lock, is_w) \
|
||||
AnnotateRWLockReleased(__FILE__, __LINE__, lock, is_w)
|
||||
|
||||
/* -------------------------------------------------------------
|
||||
Annotations useful when implementing barriers. They are not
|
||||
normally needed by modules that merely use barriers.
|
||||
The "barrier" argument is a pointer to the barrier object. */
|
||||
|
||||
/* Report that the "barrier" has been initialized with initial "count".
|
||||
If 'reinitialization_allowed' is true, initialization is allowed to happen
|
||||
multiple times w/o calling barrier_destroy() */
|
||||
#define _Py_ANNOTATE_BARRIER_INIT(barrier, count, reinitialization_allowed) \
|
||||
AnnotateBarrierInit(__FILE__, __LINE__, barrier, count, \
|
||||
reinitialization_allowed)
|
||||
|
||||
/* Report that we are about to enter barrier_wait("barrier"). */
|
||||
#define _Py_ANNOTATE_BARRIER_WAIT_BEFORE(barrier) \
|
||||
AnnotateBarrierWaitBefore(__FILE__, __LINE__, barrier)
|
||||
|
||||
/* Report that we just exited barrier_wait("barrier"). */
|
||||
#define _Py_ANNOTATE_BARRIER_WAIT_AFTER(barrier) \
|
||||
AnnotateBarrierWaitAfter(__FILE__, __LINE__, barrier)
|
||||
|
||||
/* Report that the "barrier" has been destroyed. */
|
||||
#define _Py_ANNOTATE_BARRIER_DESTROY(barrier) \
|
||||
AnnotateBarrierDestroy(__FILE__, __LINE__, barrier)
|
||||
|
||||
/* -------------------------------------------------------------
|
||||
Annotations useful for testing race detectors. */
|
||||
|
||||
/* Report that we expect a race on the variable at "address".
|
||||
Use only in unit tests for a race detector. */
|
||||
#define _Py_ANNOTATE_EXPECT_RACE(address, description) \
|
||||
AnnotateExpectRace(__FILE__, __LINE__, address, description)
|
||||
|
||||
/* A no-op. Insert where you like to test the interceptors. */
|
||||
#define _Py_ANNOTATE_NO_OP(arg) \
|
||||
AnnotateNoOp(__FILE__, __LINE__, arg)
|
||||
|
||||
/* Force the race detector to flush its state. The actual effect depends on
|
||||
* the implementation of the detector. */
|
||||
#define _Py_ANNOTATE_FLUSH_STATE() \
|
||||
AnnotateFlushState(__FILE__, __LINE__)
|
||||
|
||||
|
||||
#else /* DYNAMIC_ANNOTATIONS_ENABLED == 0 */
|
||||
|
||||
#define _Py_ANNOTATE_RWLOCK_CREATE(lock) /* empty */
|
||||
#define _Py_ANNOTATE_RWLOCK_DESTROY(lock) /* empty */
|
||||
#define _Py_ANNOTATE_RWLOCK_ACQUIRED(lock, is_w) /* empty */
|
||||
#define _Py_ANNOTATE_RWLOCK_RELEASED(lock, is_w) /* empty */
|
||||
#define _Py_ANNOTATE_BARRIER_INIT(barrier, count, reinitialization_allowed) /* */
|
||||
#define _Py_ANNOTATE_BARRIER_WAIT_BEFORE(barrier) /* empty */
|
||||
#define _Py_ANNOTATE_BARRIER_WAIT_AFTER(barrier) /* empty */
|
||||
#define _Py_ANNOTATE_BARRIER_DESTROY(barrier) /* empty */
|
||||
#define _Py_ANNOTATE_CONDVAR_LOCK_WAIT(cv, lock) /* empty */
|
||||
#define _Py_ANNOTATE_CONDVAR_WAIT(cv) /* empty */
|
||||
#define _Py_ANNOTATE_CONDVAR_SIGNAL(cv) /* empty */
|
||||
#define _Py_ANNOTATE_CONDVAR_SIGNAL_ALL(cv) /* empty */
|
||||
#define _Py_ANNOTATE_HAPPENS_BEFORE(obj) /* empty */
|
||||
#define _Py_ANNOTATE_HAPPENS_AFTER(obj) /* empty */
|
||||
#define _Py_ANNOTATE_PUBLISH_MEMORY_RANGE(address, size) /* empty */
|
||||
#define _Py_ANNOTATE_UNPUBLISH_MEMORY_RANGE(address, size) /* empty */
|
||||
#define _Py_ANNOTATE_SWAP_MEMORY_RANGE(address, size) /* empty */
|
||||
#define _Py_ANNOTATE_PCQ_CREATE(pcq) /* empty */
|
||||
#define _Py_ANNOTATE_PCQ_DESTROY(pcq) /* empty */
|
||||
#define _Py_ANNOTATE_PCQ_PUT(pcq) /* empty */
|
||||
#define _Py_ANNOTATE_PCQ_GET(pcq) /* empty */
|
||||
#define _Py_ANNOTATE_NEW_MEMORY(address, size) /* empty */
|
||||
#define _Py_ANNOTATE_EXPECT_RACE(address, description) /* empty */
|
||||
#define _Py_ANNOTATE_BENIGN_RACE(address, description) /* empty */
|
||||
#define _Py_ANNOTATE_BENIGN_RACE_SIZED(address, size, description) /* empty */
|
||||
#define _Py_ANNOTATE_PURE_HAPPENS_BEFORE_MUTEX(mu) /* empty */
|
||||
#define _Py_ANNOTATE_MUTEX_IS_USED_AS_CONDVAR(mu) /* empty */
|
||||
#define _Py_ANNOTATE_TRACE_MEMORY(arg) /* empty */
|
||||
#define _Py_ANNOTATE_THREAD_NAME(name) /* empty */
|
||||
#define _Py_ANNOTATE_IGNORE_READS_BEGIN() /* empty */
|
||||
#define _Py_ANNOTATE_IGNORE_READS_END() /* empty */
|
||||
#define _Py_ANNOTATE_IGNORE_WRITES_BEGIN() /* empty */
|
||||
#define _Py_ANNOTATE_IGNORE_WRITES_END() /* empty */
|
||||
#define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_BEGIN() /* empty */
|
||||
#define _Py_ANNOTATE_IGNORE_READS_AND_WRITES_END() /* empty */
|
||||
#define _Py_ANNOTATE_IGNORE_SYNC_BEGIN() /* empty */
|
||||
#define _Py_ANNOTATE_IGNORE_SYNC_END() /* empty */
|
||||
#define _Py_ANNOTATE_ENABLE_RACE_DETECTION(enable) /* empty */
|
||||
#define _Py_ANNOTATE_NO_OP(arg) /* empty */
|
||||
#define _Py_ANNOTATE_FLUSH_STATE() /* empty */
|
||||
|
||||
#endif /* DYNAMIC_ANNOTATIONS_ENABLED */
|
||||
|
||||
/* Use the macros above rather than using these functions directly. */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void AnnotateRWLockCreate(const char *file, int line,
|
||||
const volatile void *lock);
|
||||
void AnnotateRWLockDestroy(const char *file, int line,
|
||||
const volatile void *lock);
|
||||
void AnnotateRWLockAcquired(const char *file, int line,
|
||||
const volatile void *lock, long is_w);
|
||||
void AnnotateRWLockReleased(const char *file, int line,
|
||||
const volatile void *lock, long is_w);
|
||||
void AnnotateBarrierInit(const char *file, int line,
|
||||
const volatile void *barrier, long count,
|
||||
long reinitialization_allowed);
|
||||
void AnnotateBarrierWaitBefore(const char *file, int line,
|
||||
const volatile void *barrier);
|
||||
void AnnotateBarrierWaitAfter(const char *file, int line,
|
||||
const volatile void *barrier);
|
||||
void AnnotateBarrierDestroy(const char *file, int line,
|
||||
const volatile void *barrier);
|
||||
void AnnotateCondVarWait(const char *file, int line,
|
||||
const volatile void *cv,
|
||||
const volatile void *lock);
|
||||
void AnnotateCondVarSignal(const char *file, int line,
|
||||
const volatile void *cv);
|
||||
void AnnotateCondVarSignalAll(const char *file, int line,
|
||||
const volatile void *cv);
|
||||
void AnnotatePublishMemoryRange(const char *file, int line,
|
||||
const volatile void *address,
|
||||
long size);
|
||||
void AnnotateUnpublishMemoryRange(const char *file, int line,
|
||||
const volatile void *address,
|
||||
long size);
|
||||
void AnnotatePCQCreate(const char *file, int line,
|
||||
const volatile void *pcq);
|
||||
void AnnotatePCQDestroy(const char *file, int line,
|
||||
const volatile void *pcq);
|
||||
void AnnotatePCQPut(const char *file, int line,
|
||||
const volatile void *pcq);
|
||||
void AnnotatePCQGet(const char *file, int line,
|
||||
const volatile void *pcq);
|
||||
void AnnotateNewMemory(const char *file, int line,
|
||||
const volatile void *address,
|
||||
long size);
|
||||
void AnnotateExpectRace(const char *file, int line,
|
||||
const volatile void *address,
|
||||
const char *description);
|
||||
void AnnotateBenignRace(const char *file, int line,
|
||||
const volatile void *address,
|
||||
const char *description);
|
||||
void AnnotateBenignRaceSized(const char *file, int line,
|
||||
const volatile void *address,
|
||||
long size,
|
||||
const char *description);
|
||||
void AnnotateMutexIsUsedAsCondVar(const char *file, int line,
|
||||
const volatile void *mu);
|
||||
void AnnotateTraceMemory(const char *file, int line,
|
||||
const volatile void *arg);
|
||||
void AnnotateThreadName(const char *file, int line,
|
||||
const char *name);
|
||||
void AnnotateIgnoreReadsBegin(const char *file, int line);
|
||||
void AnnotateIgnoreReadsEnd(const char *file, int line);
|
||||
void AnnotateIgnoreWritesBegin(const char *file, int line);
|
||||
void AnnotateIgnoreWritesEnd(const char *file, int line);
|
||||
void AnnotateEnableRaceDetection(const char *file, int line, int enable);
|
||||
void AnnotateNoOp(const char *file, int line,
|
||||
const volatile void *arg);
|
||||
void AnnotateFlushState(const char *file, int line);
|
||||
|
||||
/* Return non-zero value if running under valgrind.
|
||||
|
||||
If "valgrind.h" is included into dynamic_annotations.c,
|
||||
the regular valgrind mechanism will be used.
|
||||
See http://valgrind.org/docs/manual/manual-core-adv.html about
|
||||
RUNNING_ON_VALGRIND and other valgrind "client requests".
|
||||
The file "valgrind.h" may be obtained by doing
|
||||
svn co svn://svn.valgrind.org/valgrind/trunk/include
|
||||
|
||||
If for some reason you can't use "valgrind.h" or want to fake valgrind,
|
||||
there are two ways to make this function return non-zero:
|
||||
- Use environment variable: export RUNNING_ON_VALGRIND=1
|
||||
- Make your tool intercept the function RunningOnValgrind() and
|
||||
change its return value.
|
||||
*/
|
||||
int RunningOnValgrind(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#if DYNAMIC_ANNOTATIONS_ENABLED != 0 && defined(__cplusplus)
|
||||
|
||||
/* _Py_ANNOTATE_UNPROTECTED_READ is the preferred way to annotate racey reads.
|
||||
|
||||
Instead of doing
|
||||
_Py_ANNOTATE_IGNORE_READS_BEGIN();
|
||||
... = x;
|
||||
_Py_ANNOTATE_IGNORE_READS_END();
|
||||
one can use
|
||||
... = _Py_ANNOTATE_UNPROTECTED_READ(x); */
|
||||
template <class T>
|
||||
inline T _Py_ANNOTATE_UNPROTECTED_READ(const volatile T &x) {
|
||||
_Py_ANNOTATE_IGNORE_READS_BEGIN();
|
||||
T res = x;
|
||||
_Py_ANNOTATE_IGNORE_READS_END();
|
||||
return res;
|
||||
}
|
||||
/* Apply _Py_ANNOTATE_BENIGN_RACE_SIZED to a static variable. */
|
||||
#define _Py_ANNOTATE_BENIGN_RACE_STATIC(static_var, description) \
|
||||
namespace { \
|
||||
class static_var ## _annotator { \
|
||||
public: \
|
||||
static_var ## _annotator() { \
|
||||
_Py_ANNOTATE_BENIGN_RACE_SIZED(&static_var, \
|
||||
sizeof(static_var), \
|
||||
# static_var ": " description); \
|
||||
} \
|
||||
}; \
|
||||
static static_var ## _annotator the ## static_var ## _annotator;\
|
||||
}
|
||||
#else /* DYNAMIC_ANNOTATIONS_ENABLED == 0 */
|
||||
|
||||
#define _Py_ANNOTATE_UNPROTECTED_READ(x) (x)
|
||||
#define _Py_ANNOTATE_BENIGN_RACE_STATIC(static_var, description) /* empty */
|
||||
|
||||
#endif /* DYNAMIC_ANNOTATIONS_ENABLED */
|
||||
|
||||
#endif /* __DYNAMIC_ANNOTATIONS_H__ */
|
||||
17
crypto/shamirs_secret_sharing/include/enumobject.h
Normal file
17
crypto/shamirs_secret_sharing/include/enumobject.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef Py_ENUMOBJECT_H
|
||||
#define Py_ENUMOBJECT_H
|
||||
|
||||
/* Enumerate Object */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyEnum_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyReversed_Type;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !Py_ENUMOBJECT_H */
|
||||
38
crypto/shamirs_secret_sharing/include/errcode.h
Normal file
38
crypto/shamirs_secret_sharing/include/errcode.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef Py_ERRCODE_H
|
||||
#define Py_ERRCODE_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Error codes passed around between file input, tokenizer, parser and
|
||||
interpreter. This is necessary so we can turn them into Python
|
||||
exceptions at a higher level. Note that some errors have a
|
||||
slightly different meaning when passed from the tokenizer to the
|
||||
parser than when passed from the parser to the interpreter; e.g.
|
||||
the parser only returns E_EOF when it hits EOF immediately, and it
|
||||
never returns E_OK. */
|
||||
|
||||
#define E_OK 10 /* No error */
|
||||
#define E_EOF 11 /* End Of File */
|
||||
#define E_INTR 12 /* Interrupted */
|
||||
#define E_TOKEN 13 /* Bad token */
|
||||
#define E_SYNTAX 14 /* Syntax error */
|
||||
#define E_NOMEM 15 /* Ran out of memory */
|
||||
#define E_DONE 16 /* Parsing complete */
|
||||
#define E_ERROR 17 /* Execution error */
|
||||
#define E_TABSPACE 18 /* Inconsistent mixing of tabs and spaces */
|
||||
#define E_OVERFLOW 19 /* Node had too many children */
|
||||
#define E_TOODEEP 20 /* Too many indentation levels */
|
||||
#define E_DEDENT 21 /* No matching outer block for dedent */
|
||||
#define E_DECODE 22 /* Error in decoding into Unicode */
|
||||
#define E_EOFS 23 /* EOF in triple-quoted string */
|
||||
#define E_EOLS 24 /* EOL in single-quoted string */
|
||||
#define E_LINECONT 25 /* Unexpected characters after a line continuation */
|
||||
#define E_BADSINGLE 27 /* Ill-formed single statement input */
|
||||
#define E_INTERACT_STOP 28 /* Interactive mode stopped tokenization */
|
||||
#define E_COLUMNOVERFLOW 29 /* Column offset overflow */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_ERRCODE_H */
|
||||
36
crypto/shamirs_secret_sharing/include/exports.h
Normal file
36
crypto/shamirs_secret_sharing/include/exports.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef Py_EXPORTS_H
|
||||
#define Py_EXPORTS_H
|
||||
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
#if defined(Py_ENABLE_SHARED)
|
||||
#define Py_IMPORTED_SYMBOL __declspec(dllimport)
|
||||
#define Py_EXPORTED_SYMBOL __declspec(dllexport)
|
||||
#define Py_LOCAL_SYMBOL
|
||||
#else
|
||||
#define Py_IMPORTED_SYMBOL
|
||||
#define Py_EXPORTED_SYMBOL
|
||||
#define Py_LOCAL_SYMBOL
|
||||
#endif
|
||||
#else
|
||||
/*
|
||||
* If we only ever used gcc >= 5, we could use __has_attribute(visibility)
|
||||
* as a cross-platform way to determine if visibility is supported. However,
|
||||
* we may still need to support gcc >= 4, as some Ubuntu LTS and Centos versions
|
||||
* have 4 < gcc < 5.
|
||||
*/
|
||||
#ifndef __has_attribute
|
||||
#define __has_attribute(x) 0 // Compatibility with non-clang compilers.
|
||||
#endif
|
||||
#if (defined(__GNUC__) && (__GNUC__ >= 4)) ||\
|
||||
(defined(__clang__) && __has_attribute(visibility))
|
||||
#define Py_IMPORTED_SYMBOL __attribute__ ((visibility ("default")))
|
||||
#define Py_EXPORTED_SYMBOL __attribute__ ((visibility ("default")))
|
||||
#define Py_LOCAL_SYMBOL __attribute__ ((visibility ("hidden")))
|
||||
#else
|
||||
#define Py_IMPORTED_SYMBOL
|
||||
#define Py_EXPORTED_SYMBOL
|
||||
#define Py_LOCAL_SYMBOL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif /* Py_EXPORTS_H */
|
||||
49
crypto/shamirs_secret_sharing/include/fileobject.h
Normal file
49
crypto/shamirs_secret_sharing/include/fileobject.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/* File object interface (what's left of it -- see io.py) */
|
||||
|
||||
#ifndef Py_FILEOBJECT_H
|
||||
#define Py_FILEOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PY_STDIOTEXTMODE "b"
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyFile_FromFd(int, const char *, const char *, int,
|
||||
const char *, const char *,
|
||||
const char *, int);
|
||||
PyAPI_FUNC(PyObject *) PyFile_GetLine(PyObject *, int);
|
||||
PyAPI_FUNC(int) PyFile_WriteObject(PyObject *, PyObject *, int);
|
||||
PyAPI_FUNC(int) PyFile_WriteString(const char *, PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_AsFileDescriptor(PyObject *);
|
||||
|
||||
/* The default encoding used by the platform file system APIs
|
||||
If non-NULL, this is different than the default encoding for strings
|
||||
*/
|
||||
Py_DEPRECATED(3.12) PyAPI_DATA(const char *) Py_FileSystemDefaultEncoding;
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000
|
||||
Py_DEPRECATED(3.12) PyAPI_DATA(const char *) Py_FileSystemDefaultEncodeErrors;
|
||||
#endif
|
||||
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_HasFileSystemDefaultEncoding;
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000
|
||||
Py_DEPRECATED(3.12) PyAPI_DATA(int) Py_UTF8Mode;
|
||||
#endif
|
||||
|
||||
/* A routine to check if a file descriptor can be select()-ed. */
|
||||
#ifdef _MSC_VER
|
||||
/* On Windows, any socket fd can be select()-ed, no matter how high */
|
||||
#define _PyIsSelectable_fd(FD) (1)
|
||||
#else
|
||||
#define _PyIsSelectable_fd(FD) ((unsigned int)(FD) < (unsigned int)FD_SETSIZE)
|
||||
#endif
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
# define Py_CPYTHON_FILEOBJECT_H
|
||||
# include "cpython/fileobject.h"
|
||||
# undef Py_CPYTHON_FILEOBJECT_H
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_FILEOBJECT_H */
|
||||
26
crypto/shamirs_secret_sharing/include/fileutils.h
Normal file
26
crypto/shamirs_secret_sharing/include/fileutils.h
Normal file
@@ -0,0 +1,26 @@
|
||||
#ifndef Py_FILEUTILS_H
|
||||
#define Py_FILEUTILS_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||
PyAPI_FUNC(wchar_t *) Py_DecodeLocale(
|
||||
const char *arg,
|
||||
size_t *size);
|
||||
|
||||
PyAPI_FUNC(char*) Py_EncodeLocale(
|
||||
const wchar_t *text,
|
||||
size_t *error_pos);
|
||||
#endif
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
# define Py_CPYTHON_FILEUTILS_H
|
||||
# include "cpython/fileutils.h"
|
||||
# undef Py_CPYTHON_FILEUTILS_H
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_FILEUTILS_H */
|
||||
54
crypto/shamirs_secret_sharing/include/floatobject.h
Normal file
54
crypto/shamirs_secret_sharing/include/floatobject.h
Normal file
@@ -0,0 +1,54 @@
|
||||
|
||||
/* Float object interface */
|
||||
|
||||
/*
|
||||
PyFloatObject represents a (double precision) floating-point number.
|
||||
*/
|
||||
|
||||
#ifndef Py_FLOATOBJECT_H
|
||||
#define Py_FLOATOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyFloat_Type;
|
||||
|
||||
#define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type)
|
||||
#define PyFloat_CheckExact(op) Py_IS_TYPE((op), &PyFloat_Type)
|
||||
|
||||
#define Py_RETURN_NAN return PyFloat_FromDouble(Py_NAN)
|
||||
|
||||
#define Py_RETURN_INF(sign) \
|
||||
do { \
|
||||
if (copysign(1., sign) == 1.) { \
|
||||
return PyFloat_FromDouble(Py_HUGE_VAL); \
|
||||
} \
|
||||
else { \
|
||||
return PyFloat_FromDouble(-Py_HUGE_VAL); \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
PyAPI_FUNC(double) PyFloat_GetMax(void);
|
||||
PyAPI_FUNC(double) PyFloat_GetMin(void);
|
||||
PyAPI_FUNC(PyObject*) PyFloat_GetInfo(void);
|
||||
|
||||
/* Return Python float from string PyObject. */
|
||||
PyAPI_FUNC(PyObject*) PyFloat_FromString(PyObject*);
|
||||
|
||||
/* Return Python float from C double. */
|
||||
PyAPI_FUNC(PyObject*) PyFloat_FromDouble(double);
|
||||
|
||||
/* Extract C double from Python float. The macro version trades safety for
|
||||
speed. */
|
||||
PyAPI_FUNC(double) PyFloat_AsDouble(PyObject*);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
# define Py_CPYTHON_FLOATOBJECT_H
|
||||
# include "cpython/floatobject.h"
|
||||
# undef Py_CPYTHON_FLOATOBJECT_H
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_FLOATOBJECT_H */
|
||||
20
crypto/shamirs_secret_sharing/include/frameobject.h
Normal file
20
crypto/shamirs_secret_sharing/include/frameobject.h
Normal file
@@ -0,0 +1,20 @@
|
||||
/* Frame object interface */
|
||||
|
||||
#ifndef Py_FRAMEOBJECT_H
|
||||
#define Py_FRAMEOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "pyframe.h"
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
# define Py_CPYTHON_FRAMEOBJECT_H
|
||||
# include "cpython/frameobject.h"
|
||||
# undef Py_CPYTHON_FRAMEOBJECT_H
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_FRAMEOBJECT_H */
|
||||
14
crypto/shamirs_secret_sharing/include/genericaliasobject.h
Normal file
14
crypto/shamirs_secret_sharing/include/genericaliasobject.h
Normal file
@@ -0,0 +1,14 @@
|
||||
// Implementation of PEP 585: support list[int] etc.
|
||||
#ifndef Py_GENERICALIASOBJECT_H
|
||||
#define Py_GENERICALIASOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(PyObject *) Py_GenericAlias(PyObject *, PyObject *);
|
||||
PyAPI_DATA(PyTypeObject) Py_GenericAliasType;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_GENERICALIASOBJECT_H */
|
||||
98
crypto/shamirs_secret_sharing/include/import.h
Normal file
98
crypto/shamirs_secret_sharing/include/import.h
Normal file
@@ -0,0 +1,98 @@
|
||||
/* Module definition and import interface */
|
||||
|
||||
#ifndef Py_IMPORT_H
|
||||
#define Py_IMPORT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(long) PyImport_GetMagicNumber(void);
|
||||
PyAPI_FUNC(const char *) PyImport_GetMagicTag(void);
|
||||
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModule(
|
||||
const char *name, /* UTF-8 encoded string */
|
||||
PyObject *co
|
||||
);
|
||||
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleEx(
|
||||
const char *name, /* UTF-8 encoded string */
|
||||
PyObject *co,
|
||||
const char *pathname /* decoded from the filesystem encoding */
|
||||
);
|
||||
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleWithPathnames(
|
||||
const char *name, /* UTF-8 encoded string */
|
||||
PyObject *co,
|
||||
const char *pathname, /* decoded from the filesystem encoding */
|
||||
const char *cpathname /* decoded from the filesystem encoding */
|
||||
);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_FUNC(PyObject *) PyImport_ExecCodeModuleObject(
|
||||
PyObject *name,
|
||||
PyObject *co,
|
||||
PyObject *pathname,
|
||||
PyObject *cpathname
|
||||
);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyImport_GetModuleDict(void);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000
|
||||
PyAPI_FUNC(PyObject *) PyImport_GetModule(PyObject *name);
|
||||
#endif
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_FUNC(PyObject *) PyImport_AddModuleObject(
|
||||
PyObject *name
|
||||
);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyImport_AddModule(
|
||||
const char *name /* UTF-8 encoded string */
|
||||
);
|
||||
PyAPI_FUNC(PyObject *) PyImport_ImportModule(
|
||||
const char *name /* UTF-8 encoded string */
|
||||
);
|
||||
PyAPI_FUNC(PyObject *) PyImport_ImportModuleNoBlock(
|
||||
const char *name /* UTF-8 encoded string */
|
||||
);
|
||||
PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevel(
|
||||
const char *name, /* UTF-8 encoded string */
|
||||
PyObject *globals,
|
||||
PyObject *locals,
|
||||
PyObject *fromlist,
|
||||
int level
|
||||
);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||
PyAPI_FUNC(PyObject *) PyImport_ImportModuleLevelObject(
|
||||
PyObject *name,
|
||||
PyObject *globals,
|
||||
PyObject *locals,
|
||||
PyObject *fromlist,
|
||||
int level
|
||||
);
|
||||
#endif
|
||||
|
||||
#define PyImport_ImportModuleEx(n, g, l, f) \
|
||||
PyImport_ImportModuleLevel((n), (g), (l), (f), 0)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyImport_GetImporter(PyObject *path);
|
||||
PyAPI_FUNC(PyObject *) PyImport_Import(PyObject *name);
|
||||
PyAPI_FUNC(PyObject *) PyImport_ReloadModule(PyObject *m);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_FUNC(int) PyImport_ImportFrozenModuleObject(
|
||||
PyObject *name
|
||||
);
|
||||
#endif
|
||||
PyAPI_FUNC(int) PyImport_ImportFrozenModule(
|
||||
const char *name /* UTF-8 encoded string */
|
||||
);
|
||||
|
||||
PyAPI_FUNC(int) PyImport_AppendInittab(
|
||||
const char *name, /* ASCII encoded string */
|
||||
PyObject* (*initfunc)(void)
|
||||
);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
# define Py_CPYTHON_IMPORT_H
|
||||
# include "cpython/import.h"
|
||||
# undef Py_CPYTHON_IMPORT_H
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_IMPORT_H */
|
||||
17
crypto/shamirs_secret_sharing/include/interpreteridobject.h
Normal file
17
crypto/shamirs_secret_sharing/include/interpreteridobject.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#ifndef Py_INTERPRETERIDOBJECT_H
|
||||
#define Py_INTERPRETERIDOBJECT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
# define Py_CPYTHON_INTERPRETERIDOBJECT_H
|
||||
# include "cpython/interpreteridobject.h"
|
||||
# undef Py_CPYTHON_INTERPRETERIDOBJECT_H
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_INTERPRETERIDOBJECT_H */
|
||||
30
crypto/shamirs_secret_sharing/include/intrcheck.h
Normal file
30
crypto/shamirs_secret_sharing/include/intrcheck.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef Py_INTRCHECK_H
|
||||
#define Py_INTRCHECK_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(int) PyOS_InterruptOccurred(void);
|
||||
#ifdef HAVE_FORK
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03070000
|
||||
PyAPI_FUNC(void) PyOS_BeforeFork(void);
|
||||
PyAPI_FUNC(void) PyOS_AfterFork_Parent(void);
|
||||
PyAPI_FUNC(void) PyOS_AfterFork_Child(void);
|
||||
#endif
|
||||
#endif
|
||||
/* Deprecated, please use PyOS_AfterFork_Child() instead */
|
||||
Py_DEPRECATED(3.7) PyAPI_FUNC(void) PyOS_AfterFork(void);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(int) _PyOS_IsMainThread(void);
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
/* windows.h is not included by Python.h so use void* instead of HANDLE */
|
||||
PyAPI_FUNC(void*) _PyOS_SigintEvent(void);
|
||||
#endif
|
||||
#endif /* !Py_LIMITED_API */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_INTRCHECK_H */
|
||||
27
crypto/shamirs_secret_sharing/include/iterobject.h
Normal file
27
crypto/shamirs_secret_sharing/include/iterobject.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#ifndef Py_ITEROBJECT_H
|
||||
#define Py_ITEROBJECT_H
|
||||
/* Iterators (the basic kind, over a sequence) */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PySeqIter_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyCallIter_Type;
|
||||
#ifdef Py_BUILD_CORE
|
||||
extern PyTypeObject _PyAnextAwaitable_Type;
|
||||
#endif
|
||||
|
||||
#define PySeqIter_Check(op) Py_IS_TYPE((op), &PySeqIter_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PySeqIter_New(PyObject *);
|
||||
|
||||
|
||||
#define PyCallIter_Check(op) Py_IS_TYPE((op), &PyCallIter_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCallIter_New(PyObject *, PyObject *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_ITEROBJECT_H */
|
||||
|
||||
52
crypto/shamirs_secret_sharing/include/listobject.h
Normal file
52
crypto/shamirs_secret_sharing/include/listobject.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* List object interface
|
||||
|
||||
Another generally useful object type is a list of object pointers.
|
||||
This is a mutable type: the list items can be changed, and items can be
|
||||
added or removed. Out-of-range indices or non-list objects are ignored.
|
||||
|
||||
WARNING: PyList_SetItem does not increment the new item's reference count,
|
||||
but does decrement the reference count of the item it replaces, if not nil.
|
||||
It does *decrement* the reference count if it is *not* inserted in the list.
|
||||
Similarly, PyList_GetItem does not increment the returned item's reference
|
||||
count.
|
||||
*/
|
||||
|
||||
#ifndef Py_LISTOBJECT_H
|
||||
#define Py_LISTOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyList_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyListIter_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyListRevIter_Type;
|
||||
|
||||
#define PyList_Check(op) \
|
||||
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LIST_SUBCLASS)
|
||||
#define PyList_CheckExact(op) Py_IS_TYPE((op), &PyList_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyList_New(Py_ssize_t size);
|
||||
PyAPI_FUNC(Py_ssize_t) PyList_Size(PyObject *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyList_GetItem(PyObject *, Py_ssize_t);
|
||||
PyAPI_FUNC(int) PyList_SetItem(PyObject *, Py_ssize_t, PyObject *);
|
||||
PyAPI_FUNC(int) PyList_Insert(PyObject *, Py_ssize_t, PyObject *);
|
||||
PyAPI_FUNC(int) PyList_Append(PyObject *, PyObject *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyList_GetSlice(PyObject *, Py_ssize_t, Py_ssize_t);
|
||||
PyAPI_FUNC(int) PyList_SetSlice(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *);
|
||||
|
||||
PyAPI_FUNC(int) PyList_Sort(PyObject *);
|
||||
PyAPI_FUNC(int) PyList_Reverse(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyList_AsTuple(PyObject *);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
# define Py_CPYTHON_LISTOBJECT_H
|
||||
# include "cpython/listobject.h"
|
||||
# undef Py_CPYTHON_LISTOBJECT_H
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_LISTOBJECT_H */
|
||||
108
crypto/shamirs_secret_sharing/include/longobject.h
Normal file
108
crypto/shamirs_secret_sharing/include/longobject.h
Normal file
@@ -0,0 +1,108 @@
|
||||
#ifndef Py_LONGOBJECT_H
|
||||
#define Py_LONGOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Long (arbitrary precision) integer object interface */
|
||||
|
||||
// PyLong_Type is declared by object.h
|
||||
|
||||
#define PyLong_Check(op) \
|
||||
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LONG_SUBCLASS)
|
||||
#define PyLong_CheckExact(op) Py_IS_TYPE((op), &PyLong_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromLong(long);
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLong(unsigned long);
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromSize_t(size_t);
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromSsize_t(Py_ssize_t);
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromDouble(double);
|
||||
PyAPI_FUNC(long) PyLong_AsLong(PyObject *);
|
||||
PyAPI_FUNC(long) PyLong_AsLongAndOverflow(PyObject *, int *);
|
||||
PyAPI_FUNC(Py_ssize_t) PyLong_AsSsize_t(PyObject *);
|
||||
PyAPI_FUNC(size_t) PyLong_AsSize_t(PyObject *);
|
||||
PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLong(PyObject *);
|
||||
PyAPI_FUNC(unsigned long) PyLong_AsUnsignedLongMask(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyLong_GetInfo(void);
|
||||
|
||||
/* It may be useful in the future. I've added it in the PyInt -> PyLong
|
||||
cleanup to keep the extra information. [CH] */
|
||||
#define PyLong_AS_LONG(op) PyLong_AsLong(op)
|
||||
|
||||
/* Issue #1983: pid_t can be longer than a C long on some systems */
|
||||
#if !defined(SIZEOF_PID_T) || SIZEOF_PID_T == SIZEOF_INT
|
||||
#define _Py_PARSE_PID "i"
|
||||
#define PyLong_FromPid PyLong_FromLong
|
||||
# ifndef Py_LIMITED_API
|
||||
# define PyLong_AsPid _PyLong_AsInt
|
||||
# elif SIZEOF_INT == SIZEOF_LONG
|
||||
# define PyLong_AsPid PyLong_AsLong
|
||||
# else
|
||||
static inline int
|
||||
PyLong_AsPid(PyObject *obj)
|
||||
{
|
||||
int overflow;
|
||||
long result = PyLong_AsLongAndOverflow(obj, &overflow);
|
||||
if (overflow || result > INT_MAX || result < INT_MIN) {
|
||||
PyErr_SetString(PyExc_OverflowError,
|
||||
"Python int too large to convert to C int");
|
||||
return -1;
|
||||
}
|
||||
return (int)result;
|
||||
}
|
||||
# endif
|
||||
#elif SIZEOF_PID_T == SIZEOF_LONG
|
||||
#define _Py_PARSE_PID "l"
|
||||
#define PyLong_FromPid PyLong_FromLong
|
||||
#define PyLong_AsPid PyLong_AsLong
|
||||
#elif defined(SIZEOF_LONG_LONG) && SIZEOF_PID_T == SIZEOF_LONG_LONG
|
||||
#define _Py_PARSE_PID "L"
|
||||
#define PyLong_FromPid PyLong_FromLongLong
|
||||
#define PyLong_AsPid PyLong_AsLongLong
|
||||
#else
|
||||
#error "sizeof(pid_t) is neither sizeof(int), sizeof(long) or sizeof(long long)"
|
||||
#endif /* SIZEOF_PID_T */
|
||||
|
||||
#if SIZEOF_VOID_P == SIZEOF_INT
|
||||
# define _Py_PARSE_INTPTR "i"
|
||||
# define _Py_PARSE_UINTPTR "I"
|
||||
#elif SIZEOF_VOID_P == SIZEOF_LONG
|
||||
# define _Py_PARSE_INTPTR "l"
|
||||
# define _Py_PARSE_UINTPTR "k"
|
||||
#elif defined(SIZEOF_LONG_LONG) && SIZEOF_VOID_P == SIZEOF_LONG_LONG
|
||||
# define _Py_PARSE_INTPTR "L"
|
||||
# define _Py_PARSE_UINTPTR "K"
|
||||
#else
|
||||
# error "void* different in size from int, long and long long"
|
||||
#endif /* SIZEOF_VOID_P */
|
||||
|
||||
PyAPI_FUNC(double) PyLong_AsDouble(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromVoidPtr(void *);
|
||||
PyAPI_FUNC(void *) PyLong_AsVoidPtr(PyObject *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromLongLong(long long);
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromUnsignedLongLong(unsigned long long);
|
||||
PyAPI_FUNC(long long) PyLong_AsLongLong(PyObject *);
|
||||
PyAPI_FUNC(unsigned long long) PyLong_AsUnsignedLongLong(PyObject *);
|
||||
PyAPI_FUNC(unsigned long long) PyLong_AsUnsignedLongLongMask(PyObject *);
|
||||
PyAPI_FUNC(long long) PyLong_AsLongLongAndOverflow(PyObject *, int *);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyLong_FromString(const char *, char **, int);
|
||||
|
||||
/* These aren't really part of the int object, but they're handy. The
|
||||
functions are in Python/mystrtoul.c.
|
||||
*/
|
||||
PyAPI_FUNC(unsigned long) PyOS_strtoul(const char *, char **, int);
|
||||
PyAPI_FUNC(long) PyOS_strtol(const char *, char **, int);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
# define Py_CPYTHON_LONGOBJECT_H
|
||||
# include "cpython/longobject.h"
|
||||
# undef Py_CPYTHON_LONGOBJECT_H
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_LONGOBJECT_H */
|
||||
31
crypto/shamirs_secret_sharing/include/marshal.h
Normal file
31
crypto/shamirs_secret_sharing/include/marshal.h
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
/* Interface for marshal.c */
|
||||
|
||||
#ifndef Py_MARSHAL_H
|
||||
#define Py_MARSHAL_H
|
||||
#ifndef Py_LIMITED_API
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromString(const char *,
|
||||
Py_ssize_t);
|
||||
PyAPI_FUNC(PyObject *) PyMarshal_WriteObjectToString(PyObject *, int);
|
||||
|
||||
#define Py_MARSHAL_VERSION 4
|
||||
|
||||
PyAPI_FUNC(long) PyMarshal_ReadLongFromFile(FILE *);
|
||||
PyAPI_FUNC(int) PyMarshal_ReadShortFromFile(FILE *);
|
||||
PyAPI_FUNC(PyObject *) PyMarshal_ReadObjectFromFile(FILE *);
|
||||
PyAPI_FUNC(PyObject *) PyMarshal_ReadLastObjectFromFile(FILE *);
|
||||
|
||||
PyAPI_FUNC(void) PyMarshal_WriteLongToFile(long, FILE *, int);
|
||||
PyAPI_FUNC(void) PyMarshal_WriteObjectToFile(PyObject *, FILE *, int);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* Py_LIMITED_API */
|
||||
#endif /* !Py_MARSHAL_H */
|
||||
34
crypto/shamirs_secret_sharing/include/memoryobject.h
Normal file
34
crypto/shamirs_secret_sharing/include/memoryobject.h
Normal file
@@ -0,0 +1,34 @@
|
||||
/* Memory view object. In Python this is available as "memoryview". */
|
||||
|
||||
#ifndef Py_MEMORYOBJECT_H
|
||||
#define Py_MEMORYOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyMemoryView_Type;
|
||||
|
||||
#define PyMemoryView_Check(op) Py_IS_TYPE((op), &PyMemoryView_Type)
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyMemoryView_FromObject(PyObject *base);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_FUNC(PyObject *) PyMemoryView_FromMemory(char *mem, Py_ssize_t size,
|
||||
int flags);
|
||||
#endif
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030b0000
|
||||
PyAPI_FUNC(PyObject *) PyMemoryView_FromBuffer(const Py_buffer *info);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyMemoryView_GetContiguous(PyObject *base,
|
||||
int buffertype,
|
||||
char order);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
# define Py_CPYTHON_MEMORYOBJECT_H
|
||||
# include "cpython/memoryobject.h"
|
||||
# undef Py_CPYTHON_MEMORYOBJECT_H
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_MEMORYOBJECT_H */
|
||||
132
crypto/shamirs_secret_sharing/include/methodobject.h
Normal file
132
crypto/shamirs_secret_sharing/include/methodobject.h
Normal file
@@ -0,0 +1,132 @@
|
||||
|
||||
/* Method object interface */
|
||||
|
||||
#ifndef Py_METHODOBJECT_H
|
||||
#define Py_METHODOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* This is about the type 'builtin_function_or_method',
|
||||
not Python methods in user-defined classes. See classobject.h
|
||||
for the latter. */
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyCFunction_Type;
|
||||
|
||||
#define PyCFunction_CheckExact(op) Py_IS_TYPE((op), &PyCFunction_Type)
|
||||
#define PyCFunction_Check(op) PyObject_TypeCheck((op), &PyCFunction_Type)
|
||||
|
||||
typedef PyObject *(*PyCFunction)(PyObject *, PyObject *);
|
||||
typedef PyObject *(*_PyCFunctionFast) (PyObject *, PyObject *const *, Py_ssize_t);
|
||||
typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *,
|
||||
PyObject *);
|
||||
typedef PyObject *(*_PyCFunctionFastWithKeywords) (PyObject *,
|
||||
PyObject *const *, Py_ssize_t,
|
||||
PyObject *);
|
||||
typedef PyObject *(*PyCMethod)(PyObject *, PyTypeObject *, PyObject *const *,
|
||||
size_t, PyObject *);
|
||||
|
||||
// Cast an function to the PyCFunction type to use it with PyMethodDef.
|
||||
//
|
||||
// This macro can be used to prevent compiler warnings if the first parameter
|
||||
// uses a different pointer type than PyObject* (ex: METH_VARARGS and METH_O
|
||||
// calling conventions).
|
||||
//
|
||||
// The macro can also be used for METH_FASTCALL and METH_VARARGS|METH_KEYWORDS
|
||||
// calling conventions to avoid compiler warnings because the function has more
|
||||
// than 2 parameters. The macro first casts the function to the
|
||||
// "void func(void)" type to prevent compiler warnings.
|
||||
//
|
||||
// If a function is declared with the METH_NOARGS calling convention, it must
|
||||
// have 2 parameters. Since the second parameter is unused, Py_UNUSED() can be
|
||||
// used to prevent a compiler warning. If the function has a single parameter,
|
||||
// it triggers an undefined behavior when Python calls it with 2 parameters
|
||||
// (bpo-33012).
|
||||
#define _PyCFunction_CAST(func) \
|
||||
_Py_CAST(PyCFunction, _Py_CAST(void(*)(void), (func)))
|
||||
|
||||
PyAPI_FUNC(PyCFunction) PyCFunction_GetFunction(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyCFunction_GetSelf(PyObject *);
|
||||
PyAPI_FUNC(int) PyCFunction_GetFlags(PyObject *);
|
||||
|
||||
Py_DEPRECATED(3.9) PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *);
|
||||
|
||||
struct PyMethodDef {
|
||||
const char *ml_name; /* The name of the built-in function/method */
|
||||
PyCFunction ml_meth; /* The C function that implements it */
|
||||
int ml_flags; /* Combination of METH_xxx flags, which mostly
|
||||
describe the args expected by the C func */
|
||||
const char *ml_doc; /* The __doc__ attribute, or NULL */
|
||||
};
|
||||
|
||||
/* PyCFunction_New is declared as a function for stable ABI (declaration is
|
||||
* needed for e.g. GCC with -fvisibility=hidden), but redefined as a macro
|
||||
* that calls PyCFunction_NewEx. */
|
||||
PyAPI_FUNC(PyObject *) PyCFunction_New(PyMethodDef *, PyObject *);
|
||||
#define PyCFunction_New(ML, SELF) PyCFunction_NewEx((ML), (SELF), NULL)
|
||||
|
||||
/* PyCFunction_NewEx is similar: on 3.9+, this calls PyCMethod_New. */
|
||||
PyAPI_FUNC(PyObject *) PyCFunction_NewEx(PyMethodDef *, PyObject *,
|
||||
PyObject *);
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000
|
||||
#define PyCFunction_NewEx(ML, SELF, MOD) PyCMethod_New((ML), (SELF), (MOD), NULL)
|
||||
PyAPI_FUNC(PyObject *) PyCMethod_New(PyMethodDef *, PyObject *,
|
||||
PyObject *, PyTypeObject *);
|
||||
#endif
|
||||
|
||||
|
||||
/* Flag passed to newmethodobject */
|
||||
/* #define METH_OLDARGS 0x0000 -- unsupported now */
|
||||
#define METH_VARARGS 0x0001
|
||||
#define METH_KEYWORDS 0x0002
|
||||
/* METH_NOARGS and METH_O must not be combined with the flags above. */
|
||||
#define METH_NOARGS 0x0004
|
||||
#define METH_O 0x0008
|
||||
|
||||
/* METH_CLASS and METH_STATIC are a little different; these control
|
||||
the construction of methods for a class. These cannot be used for
|
||||
functions in modules. */
|
||||
#define METH_CLASS 0x0010
|
||||
#define METH_STATIC 0x0020
|
||||
|
||||
/* METH_COEXIST allows a method to be entered even though a slot has
|
||||
already filled the entry. When defined, the flag allows a separate
|
||||
method, "__contains__" for example, to coexist with a defined
|
||||
slot like sq_contains. */
|
||||
|
||||
#define METH_COEXIST 0x0040
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030a0000
|
||||
# define METH_FASTCALL 0x0080
|
||||
#endif
|
||||
|
||||
/* This bit is preserved for Stackless Python */
|
||||
#ifdef STACKLESS
|
||||
# define METH_STACKLESS 0x0100
|
||||
#else
|
||||
# define METH_STACKLESS 0x0000
|
||||
#endif
|
||||
|
||||
/* METH_METHOD means the function stores an
|
||||
* additional reference to the class that defines it;
|
||||
* both self and class are passed to it.
|
||||
* It uses PyCMethodObject instead of PyCFunctionObject.
|
||||
* May not be combined with METH_NOARGS, METH_O, METH_CLASS or METH_STATIC.
|
||||
*/
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000
|
||||
#define METH_METHOD 0x0200
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
# define Py_CPYTHON_METHODOBJECT_H
|
||||
# include "cpython/methodobject.h"
|
||||
# undef Py_CPYTHON_METHODOBJECT_H
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_METHODOBJECT_H */
|
||||
168
crypto/shamirs_secret_sharing/include/modsupport.h
Normal file
168
crypto/shamirs_secret_sharing/include/modsupport.h
Normal file
@@ -0,0 +1,168 @@
|
||||
|
||||
#ifndef Py_MODSUPPORT_H
|
||||
#define Py_MODSUPPORT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Module support interface */
|
||||
|
||||
#include <stdarg.h> // va_list
|
||||
|
||||
/* If PY_SSIZE_T_CLEAN is defined, each functions treats #-specifier
|
||||
to mean Py_ssize_t */
|
||||
#ifdef PY_SSIZE_T_CLEAN
|
||||
#define PyArg_Parse _PyArg_Parse_SizeT
|
||||
#define PyArg_ParseTuple _PyArg_ParseTuple_SizeT
|
||||
#define PyArg_ParseTupleAndKeywords _PyArg_ParseTupleAndKeywords_SizeT
|
||||
#define PyArg_VaParse _PyArg_VaParse_SizeT
|
||||
#define PyArg_VaParseTupleAndKeywords _PyArg_VaParseTupleAndKeywords_SizeT
|
||||
#define Py_BuildValue _Py_BuildValue_SizeT
|
||||
#define Py_VaBuildValue _Py_VaBuildValue_SizeT
|
||||
#endif
|
||||
|
||||
/* Due to a glitch in 3.2, the _SizeT versions weren't exported from the DLL. */
|
||||
#if !defined(PY_SSIZE_T_CLEAN) || !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_FUNC(int) PyArg_Parse(PyObject *, const char *, ...);
|
||||
PyAPI_FUNC(int) PyArg_ParseTuple(PyObject *, const char *, ...);
|
||||
PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *,
|
||||
const char *, char **, ...);
|
||||
PyAPI_FUNC(int) PyArg_VaParse(PyObject *, const char *, va_list);
|
||||
PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *,
|
||||
const char *, char **, va_list);
|
||||
#endif
|
||||
PyAPI_FUNC(int) PyArg_ValidateKeywordArguments(PyObject *);
|
||||
PyAPI_FUNC(int) PyArg_UnpackTuple(PyObject *, const char *, Py_ssize_t, Py_ssize_t, ...);
|
||||
PyAPI_FUNC(PyObject *) Py_BuildValue(const char *, ...);
|
||||
PyAPI_FUNC(PyObject *) _Py_BuildValue_SizeT(const char *, ...);
|
||||
|
||||
|
||||
PyAPI_FUNC(PyObject *) Py_VaBuildValue(const char *, va_list);
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030a0000
|
||||
// Add an attribute with name 'name' and value 'obj' to the module 'mod.
|
||||
// On success, return 0 on success.
|
||||
// On error, raise an exception and return -1.
|
||||
PyAPI_FUNC(int) PyModule_AddObjectRef(PyObject *mod, const char *name, PyObject *value);
|
||||
#endif /* Py_LIMITED_API */
|
||||
|
||||
// Similar to PyModule_AddObjectRef() but steal a reference to 'obj'
|
||||
// (Py_DECREF(obj)) on success (if it returns 0).
|
||||
PyAPI_FUNC(int) PyModule_AddObject(PyObject *mod, const char *, PyObject *value);
|
||||
|
||||
PyAPI_FUNC(int) PyModule_AddIntConstant(PyObject *, const char *, long);
|
||||
PyAPI_FUNC(int) PyModule_AddStringConstant(PyObject *, const char *, const char *);
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000
|
||||
/* New in 3.9 */
|
||||
PyAPI_FUNC(int) PyModule_AddType(PyObject *module, PyTypeObject *type);
|
||||
#endif /* Py_LIMITED_API */
|
||||
|
||||
#define PyModule_AddIntMacro(m, c) PyModule_AddIntConstant((m), #c, (c))
|
||||
#define PyModule_AddStringMacro(m, c) PyModule_AddStringConstant((m), #c, (c))
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||
/* New in 3.5 */
|
||||
PyAPI_FUNC(int) PyModule_SetDocString(PyObject *, const char *);
|
||||
PyAPI_FUNC(int) PyModule_AddFunctions(PyObject *, PyMethodDef *);
|
||||
PyAPI_FUNC(int) PyModule_ExecDef(PyObject *module, PyModuleDef *def);
|
||||
#endif
|
||||
|
||||
#define Py_CLEANUP_SUPPORTED 0x20000
|
||||
|
||||
#define PYTHON_API_VERSION 1013
|
||||
#define PYTHON_API_STRING "1013"
|
||||
/* The API version is maintained (independently from the Python version)
|
||||
so we can detect mismatches between the interpreter and dynamically
|
||||
loaded modules. These are diagnosed by an error message but
|
||||
the module is still loaded (because the mismatch can only be tested
|
||||
after loading the module). The error message is intended to
|
||||
explain the core dump a few seconds later.
|
||||
|
||||
The symbol PYTHON_API_STRING defines the same value as a string
|
||||
literal. *** PLEASE MAKE SURE THE DEFINITIONS MATCH. ***
|
||||
|
||||
Please add a line or two to the top of this log for each API
|
||||
version change:
|
||||
|
||||
22-Feb-2006 MvL 1013 PEP 353 - long indices for sequence lengths
|
||||
|
||||
19-Aug-2002 GvR 1012 Changes to string object struct for
|
||||
interning changes, saving 3 bytes.
|
||||
|
||||
17-Jul-2001 GvR 1011 Descr-branch, just to be on the safe side
|
||||
|
||||
25-Jan-2001 FLD 1010 Parameters added to PyCode_New() and
|
||||
PyFrame_New(); Python 2.1a2
|
||||
|
||||
14-Mar-2000 GvR 1009 Unicode API added
|
||||
|
||||
3-Jan-1999 GvR 1007 Decided to change back! (Don't reuse 1008!)
|
||||
|
||||
3-Dec-1998 GvR 1008 Python 1.5.2b1
|
||||
|
||||
18-Jan-1997 GvR 1007 string interning and other speedups
|
||||
|
||||
11-Oct-1996 GvR renamed Py_Ellipses to Py_Ellipsis :-(
|
||||
|
||||
30-Jul-1996 GvR Slice and ellipses syntax added
|
||||
|
||||
23-Jul-1996 GvR For 1.4 -- better safe than sorry this time :-)
|
||||
|
||||
7-Nov-1995 GvR Keyword arguments (should've been done at 1.3 :-( )
|
||||
|
||||
10-Jan-1995 GvR Renamed globals to new naming scheme
|
||||
|
||||
9-Jan-1995 GvR Initial version (incompatible with older API)
|
||||
*/
|
||||
|
||||
/* The PYTHON_ABI_VERSION is introduced in PEP 384. For the lifetime of
|
||||
Python 3, it will stay at the value of 3; changes to the limited API
|
||||
must be performed in a strictly backwards-compatible manner. */
|
||||
#define PYTHON_ABI_VERSION 3
|
||||
#define PYTHON_ABI_STRING "3"
|
||||
|
||||
#ifdef Py_TRACE_REFS
|
||||
/* When we are tracing reference counts, rename module creation functions so
|
||||
modules compiled with incompatible settings will generate a
|
||||
link-time error. */
|
||||
#define PyModule_Create2 PyModule_Create2TraceRefs
|
||||
#define PyModule_FromDefAndSpec2 PyModule_FromDefAndSpec2TraceRefs
|
||||
#endif
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyModule_Create2(PyModuleDef*, int apiver);
|
||||
|
||||
#ifdef Py_LIMITED_API
|
||||
#define PyModule_Create(module) \
|
||||
PyModule_Create2((module), PYTHON_ABI_VERSION)
|
||||
#else
|
||||
#define PyModule_Create(module) \
|
||||
PyModule_Create2((module), PYTHON_API_VERSION)
|
||||
#endif
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||
/* New in 3.5 */
|
||||
PyAPI_FUNC(PyObject *) PyModule_FromDefAndSpec2(PyModuleDef *def,
|
||||
PyObject *spec,
|
||||
int module_api_version);
|
||||
|
||||
#ifdef Py_LIMITED_API
|
||||
#define PyModule_FromDefAndSpec(module, spec) \
|
||||
PyModule_FromDefAndSpec2((module), (spec), PYTHON_ABI_VERSION)
|
||||
#else
|
||||
#define PyModule_FromDefAndSpec(module, spec) \
|
||||
PyModule_FromDefAndSpec2((module), (spec), PYTHON_API_VERSION)
|
||||
#endif /* Py_LIMITED_API */
|
||||
|
||||
#endif /* New in 3.5 */
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
# define Py_CPYTHON_MODSUPPORT_H
|
||||
# include "cpython/modsupport.h"
|
||||
# undef Py_CPYTHON_MODSUPPORT_H
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_MODSUPPORT_H */
|
||||
119
crypto/shamirs_secret_sharing/include/moduleobject.h
Normal file
119
crypto/shamirs_secret_sharing/include/moduleobject.h
Normal file
@@ -0,0 +1,119 @@
|
||||
|
||||
/* Module object interface */
|
||||
|
||||
#ifndef Py_MODULEOBJECT_H
|
||||
#define Py_MODULEOBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyModule_Type;
|
||||
|
||||
#define PyModule_Check(op) PyObject_TypeCheck((op), &PyModule_Type)
|
||||
#define PyModule_CheckExact(op) Py_IS_TYPE((op), &PyModule_Type)
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_FUNC(PyObject *) PyModule_NewObject(
|
||||
PyObject *name
|
||||
);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyModule_New(
|
||||
const char *name /* UTF-8 encoded string */
|
||||
);
|
||||
PyAPI_FUNC(PyObject *) PyModule_GetDict(PyObject *);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_FUNC(PyObject *) PyModule_GetNameObject(PyObject *);
|
||||
#endif
|
||||
PyAPI_FUNC(const char *) PyModule_GetName(PyObject *);
|
||||
Py_DEPRECATED(3.2) PyAPI_FUNC(const char *) PyModule_GetFilename(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyModule_GetFilenameObject(PyObject *);
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(void) _PyModule_Clear(PyObject *);
|
||||
PyAPI_FUNC(void) _PyModule_ClearDict(PyObject *);
|
||||
PyAPI_FUNC(int) _PyModuleSpec_IsInitializing(PyObject *);
|
||||
#endif
|
||||
PyAPI_FUNC(PyModuleDef*) PyModule_GetDef(PyObject*);
|
||||
PyAPI_FUNC(void*) PyModule_GetState(PyObject*);
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||
/* New in 3.5 */
|
||||
PyAPI_FUNC(PyObject *) PyModuleDef_Init(PyModuleDef*);
|
||||
PyAPI_DATA(PyTypeObject) PyModuleDef_Type;
|
||||
#endif
|
||||
|
||||
typedef struct PyModuleDef_Base {
|
||||
PyObject_HEAD
|
||||
/* The function used to re-initialize the module.
|
||||
This is only set for legacy (single-phase init) extension modules
|
||||
and only used for those that support multiple initializations
|
||||
(m_size >= 0).
|
||||
It is set by _PyImport_LoadDynamicModuleWithSpec()
|
||||
and _imp.create_builtin(). */
|
||||
PyObject* (*m_init)(void);
|
||||
/* The module's index into its interpreter's modules_by_index cache.
|
||||
This is set for all extension modules but only used for legacy ones.
|
||||
(See PyInterpreterState.modules_by_index for more info.)
|
||||
It is set by PyModuleDef_Init(). */
|
||||
Py_ssize_t m_index;
|
||||
/* A copy of the module's __dict__ after the first time it was loaded.
|
||||
This is only set/used for legacy modules that do not support
|
||||
multiple initializations.
|
||||
It is set by _PyImport_FixupExtensionObject(). */
|
||||
PyObject* m_copy;
|
||||
} PyModuleDef_Base;
|
||||
|
||||
#define PyModuleDef_HEAD_INIT { \
|
||||
PyObject_HEAD_INIT(_Py_NULL) \
|
||||
_Py_NULL, /* m_init */ \
|
||||
0, /* m_index */ \
|
||||
_Py_NULL, /* m_copy */ \
|
||||
}
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||
/* New in 3.5 */
|
||||
struct PyModuleDef_Slot {
|
||||
int slot;
|
||||
void *value;
|
||||
};
|
||||
|
||||
#define Py_mod_create 1
|
||||
#define Py_mod_exec 2
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030c0000
|
||||
# define Py_mod_multiple_interpreters 3
|
||||
#endif
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
#define _Py_mod_LAST_SLOT 3
|
||||
#endif
|
||||
|
||||
#endif /* New in 3.5 */
|
||||
|
||||
/* for Py_mod_multiple_interpreters: */
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030c0000
|
||||
# define Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED ((void *)0)
|
||||
# define Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED ((void *)1)
|
||||
# define Py_MOD_PER_INTERPRETER_GIL_SUPPORTED ((void *)2)
|
||||
#endif
|
||||
|
||||
struct PyModuleDef {
|
||||
PyModuleDef_Base m_base;
|
||||
const char* m_name;
|
||||
const char* m_doc;
|
||||
Py_ssize_t m_size;
|
||||
PyMethodDef *m_methods;
|
||||
PyModuleDef_Slot *m_slots;
|
||||
traverseproc m_traverse;
|
||||
inquiry m_clear;
|
||||
freefunc m_free;
|
||||
};
|
||||
|
||||
|
||||
// Internal C API
|
||||
#ifdef Py_BUILD_CORE
|
||||
extern int _PyModule_IsExtension(PyObject *obj);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_MODULEOBJECT_H */
|
||||
993
crypto/shamirs_secret_sharing/include/object.h
Normal file
993
crypto/shamirs_secret_sharing/include/object.h
Normal file
@@ -0,0 +1,993 @@
|
||||
#ifndef Py_OBJECT_H
|
||||
#define Py_OBJECT_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Object and type object interface */
|
||||
|
||||
/*
|
||||
Objects are structures allocated on the heap. Special rules apply to
|
||||
the use of objects to ensure they are properly garbage-collected.
|
||||
Objects are never allocated statically or on the stack; they must be
|
||||
accessed through special macros and functions only. (Type objects are
|
||||
exceptions to the first rule; the standard types are represented by
|
||||
statically initialized type objects, although work on type/class unification
|
||||
for Python 2.2 made it possible to have heap-allocated type objects too).
|
||||
|
||||
An object has a 'reference count' that is increased or decreased when a
|
||||
pointer to the object is copied or deleted; when the reference count
|
||||
reaches zero there are no references to the object left and it can be
|
||||
removed from the heap.
|
||||
|
||||
An object has a 'type' that determines what it represents and what kind
|
||||
of data it contains. An object's type is fixed when it is created.
|
||||
Types themselves are represented as objects; an object contains a
|
||||
pointer to the corresponding type object. The type itself has a type
|
||||
pointer pointing to the object representing the type 'type', which
|
||||
contains a pointer to itself!.
|
||||
|
||||
Objects do not float around in memory; once allocated an object keeps
|
||||
the same size and address. Objects that must hold variable-size data
|
||||
can contain pointers to variable-size parts of the object. Not all
|
||||
objects of the same type have the same size; but the size cannot change
|
||||
after allocation. (These restrictions are made so a reference to an
|
||||
object can be simply a pointer -- moving an object would require
|
||||
updating all the pointers, and changing an object's size would require
|
||||
moving it if there was another object right next to it.)
|
||||
|
||||
Objects are always accessed through pointers of the type 'PyObject *'.
|
||||
The type 'PyObject' is a structure that only contains the reference count
|
||||
and the type pointer. The actual memory allocated for an object
|
||||
contains other data that can only be accessed after casting the pointer
|
||||
to a pointer to a longer structure type. This longer type must start
|
||||
with the reference count and type fields; the macro PyObject_HEAD should be
|
||||
used for this (to accommodate for future changes). The implementation
|
||||
of a particular object type can cast the object pointer to the proper
|
||||
type and back.
|
||||
|
||||
A standard interface exists for objects that contain an array of items
|
||||
whose size is determined when the object is allocated.
|
||||
*/
|
||||
|
||||
#include "pystats.h"
|
||||
|
||||
/* Py_DEBUG implies Py_REF_DEBUG. */
|
||||
#if defined(Py_DEBUG) && !defined(Py_REF_DEBUG)
|
||||
# define Py_REF_DEBUG
|
||||
#endif
|
||||
|
||||
#if defined(Py_LIMITED_API) && defined(Py_TRACE_REFS)
|
||||
# error Py_LIMITED_API is incompatible with Py_TRACE_REFS
|
||||
#endif
|
||||
|
||||
#ifdef Py_TRACE_REFS
|
||||
/* Define pointers to support a doubly-linked list of all live heap objects. */
|
||||
#define _PyObject_HEAD_EXTRA \
|
||||
PyObject *_ob_next; \
|
||||
PyObject *_ob_prev;
|
||||
|
||||
#define _PyObject_EXTRA_INIT _Py_NULL, _Py_NULL,
|
||||
|
||||
#else
|
||||
# define _PyObject_HEAD_EXTRA
|
||||
# define _PyObject_EXTRA_INIT
|
||||
#endif
|
||||
|
||||
/* PyObject_HEAD defines the initial segment of every PyObject. */
|
||||
#define PyObject_HEAD PyObject ob_base;
|
||||
|
||||
/*
|
||||
Immortalization:
|
||||
|
||||
The following indicates the immortalization strategy depending on the amount
|
||||
of available bits in the reference count field. All strategies are backwards
|
||||
compatible but the specific reference count value or immortalization check
|
||||
might change depending on the specializations for the underlying system.
|
||||
|
||||
Proper deallocation of immortal instances requires distinguishing between
|
||||
statically allocated immortal instances vs those promoted by the runtime to be
|
||||
immortal. The latter should be the only instances that require
|
||||
cleanup during runtime finalization.
|
||||
*/
|
||||
|
||||
#if SIZEOF_VOID_P > 4
|
||||
/*
|
||||
In 64+ bit systems, an object will be marked as immortal by setting all of the
|
||||
lower 32 bits of the reference count field, which is equal to: 0xFFFFFFFF
|
||||
|
||||
Using the lower 32 bits makes the value backwards compatible by allowing
|
||||
C-Extensions without the updated checks in Py_INCREF and Py_DECREF to safely
|
||||
increase and decrease the objects reference count. The object would lose its
|
||||
immortality, but the execution would still be correct.
|
||||
|
||||
Reference count increases will use saturated arithmetic, taking advantage of
|
||||
having all the lower 32 bits set, which will avoid the reference count to go
|
||||
beyond the refcount limit. Immortality checks for reference count decreases will
|
||||
be done by checking the bit sign flag in the lower 32 bits.
|
||||
*/
|
||||
#define _Py_IMMORTAL_REFCNT UINT_MAX
|
||||
|
||||
#else
|
||||
/*
|
||||
In 32 bit systems, an object will be marked as immortal by setting all of the
|
||||
lower 30 bits of the reference count field, which is equal to: 0x3FFFFFFF
|
||||
|
||||
Using the lower 30 bits makes the value backwards compatible by allowing
|
||||
C-Extensions without the updated checks in Py_INCREF and Py_DECREF to safely
|
||||
increase and decrease the objects reference count. The object would lose its
|
||||
immortality, but the execution would still be correct.
|
||||
|
||||
Reference count increases and decreases will first go through an immortality
|
||||
check by comparing the reference count field to the immortality reference count.
|
||||
*/
|
||||
#define _Py_IMMORTAL_REFCNT (UINT_MAX >> 2)
|
||||
#endif
|
||||
|
||||
// Make all internal uses of PyObject_HEAD_INIT immortal while preserving the
|
||||
// C-API expectation that the refcnt will be set to 1.
|
||||
#ifdef Py_BUILD_CORE
|
||||
#define PyObject_HEAD_INIT(type) \
|
||||
{ \
|
||||
_PyObject_EXTRA_INIT \
|
||||
{ _Py_IMMORTAL_REFCNT }, \
|
||||
(type) \
|
||||
},
|
||||
#else
|
||||
#define PyObject_HEAD_INIT(type) \
|
||||
{ \
|
||||
_PyObject_EXTRA_INIT \
|
||||
{ 1 }, \
|
||||
(type) \
|
||||
},
|
||||
#endif /* Py_BUILD_CORE */
|
||||
|
||||
#define PyVarObject_HEAD_INIT(type, size) \
|
||||
{ \
|
||||
PyObject_HEAD_INIT(type) \
|
||||
(size) \
|
||||
},
|
||||
|
||||
/* PyObject_VAR_HEAD defines the initial segment of all variable-size
|
||||
* container objects. These end with a declaration of an array with 1
|
||||
* element, but enough space is malloc'ed so that the array actually
|
||||
* has room for ob_size elements. Note that ob_size is an element count,
|
||||
* not necessarily a byte count.
|
||||
*/
|
||||
#define PyObject_VAR_HEAD PyVarObject ob_base;
|
||||
#define Py_INVALID_SIZE (Py_ssize_t)-1
|
||||
|
||||
/* Nothing is actually declared to be a PyObject, but every pointer to
|
||||
* a Python object can be cast to a PyObject*. This is inheritance built
|
||||
* by hand. Similarly every pointer to a variable-size Python object can,
|
||||
* in addition, be cast to PyVarObject*.
|
||||
*/
|
||||
struct _object {
|
||||
_PyObject_HEAD_EXTRA
|
||||
|
||||
#if (defined(__GNUC__) || defined(__clang__)) \
|
||||
&& !(defined __STDC_VERSION__ && __STDC_VERSION__ >= 201112L)
|
||||
// On C99 and older, anonymous union is a GCC and clang extension
|
||||
__extension__
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
// Ignore MSC warning C4201: "nonstandard extension used:
|
||||
// nameless struct/union"
|
||||
__pragma(warning(push))
|
||||
__pragma(warning(disable: 4201))
|
||||
#endif
|
||||
union {
|
||||
Py_ssize_t ob_refcnt;
|
||||
#if SIZEOF_VOID_P > 4
|
||||
PY_UINT32_T ob_refcnt_split[2];
|
||||
#endif
|
||||
};
|
||||
#ifdef _MSC_VER
|
||||
__pragma(warning(pop))
|
||||
#endif
|
||||
|
||||
PyTypeObject *ob_type;
|
||||
};
|
||||
|
||||
/* Cast argument to PyObject* type. */
|
||||
#define _PyObject_CAST(op) _Py_CAST(PyObject*, (op))
|
||||
|
||||
typedef struct {
|
||||
PyObject ob_base;
|
||||
Py_ssize_t ob_size; /* Number of items in variable part */
|
||||
} PyVarObject;
|
||||
|
||||
/* Cast argument to PyVarObject* type. */
|
||||
#define _PyVarObject_CAST(op) _Py_CAST(PyVarObject*, (op))
|
||||
|
||||
|
||||
// Test if the 'x' object is the 'y' object, the same as "x is y" in Python.
|
||||
PyAPI_FUNC(int) Py_Is(PyObject *x, PyObject *y);
|
||||
#define Py_Is(x, y) ((x) == (y))
|
||||
|
||||
|
||||
static inline Py_ssize_t Py_REFCNT(PyObject *ob) {
|
||||
return ob->ob_refcnt;
|
||||
}
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
|
||||
# define Py_REFCNT(ob) Py_REFCNT(_PyObject_CAST(ob))
|
||||
#endif
|
||||
|
||||
|
||||
// bpo-39573: The Py_SET_TYPE() function must be used to set an object type.
|
||||
static inline PyTypeObject* Py_TYPE(PyObject *ob) {
|
||||
return ob->ob_type;
|
||||
}
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
|
||||
# define Py_TYPE(ob) Py_TYPE(_PyObject_CAST(ob))
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyLong_Type;
|
||||
PyAPI_DATA(PyTypeObject) PyBool_Type;
|
||||
|
||||
// bpo-39573: The Py_SET_SIZE() function must be used to set an object size.
|
||||
static inline Py_ssize_t Py_SIZE(PyObject *ob) {
|
||||
assert(ob->ob_type != &PyLong_Type);
|
||||
assert(ob->ob_type != &PyBool_Type);
|
||||
return _PyVarObject_CAST(ob)->ob_size;
|
||||
}
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
|
||||
# define Py_SIZE(ob) Py_SIZE(_PyObject_CAST(ob))
|
||||
#endif
|
||||
|
||||
static inline Py_ALWAYS_INLINE int _Py_IsImmortal(PyObject *op)
|
||||
{
|
||||
#if SIZEOF_VOID_P > 4
|
||||
return _Py_CAST(PY_INT32_T, op->ob_refcnt) < 0;
|
||||
#else
|
||||
return op->ob_refcnt == _Py_IMMORTAL_REFCNT;
|
||||
#endif
|
||||
}
|
||||
#define _Py_IsImmortal(op) _Py_IsImmortal(_PyObject_CAST(op))
|
||||
|
||||
static inline int Py_IS_TYPE(PyObject *ob, PyTypeObject *type) {
|
||||
return Py_TYPE(ob) == type;
|
||||
}
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
|
||||
# define Py_IS_TYPE(ob, type) Py_IS_TYPE(_PyObject_CAST(ob), (type))
|
||||
#endif
|
||||
|
||||
|
||||
static inline void Py_SET_REFCNT(PyObject *ob, Py_ssize_t refcnt) {
|
||||
// This immortal check is for code that is unaware of immortal objects.
|
||||
// The runtime tracks these objects and we should avoid as much
|
||||
// as possible having extensions inadvertently change the refcnt
|
||||
// of an immortalized object.
|
||||
if (_Py_IsImmortal(ob)) {
|
||||
return;
|
||||
}
|
||||
ob->ob_refcnt = refcnt;
|
||||
}
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
|
||||
# define Py_SET_REFCNT(ob, refcnt) Py_SET_REFCNT(_PyObject_CAST(ob), (refcnt))
|
||||
#endif
|
||||
|
||||
|
||||
static inline void Py_SET_TYPE(PyObject *ob, PyTypeObject *type) {
|
||||
ob->ob_type = type;
|
||||
}
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
|
||||
# define Py_SET_TYPE(ob, type) Py_SET_TYPE(_PyObject_CAST(ob), type)
|
||||
#endif
|
||||
|
||||
static inline void Py_SET_SIZE(PyVarObject *ob, Py_ssize_t size) {
|
||||
assert(ob->ob_base.ob_type != &PyLong_Type);
|
||||
assert(ob->ob_base.ob_type != &PyBool_Type);
|
||||
ob->ob_size = size;
|
||||
}
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
|
||||
# define Py_SET_SIZE(ob, size) Py_SET_SIZE(_PyVarObject_CAST(ob), (size))
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
Type objects contain a string containing the type name (to help somewhat
|
||||
in debugging), the allocation parameters (see PyObject_New() and
|
||||
PyObject_NewVar()),
|
||||
and methods for accessing objects of the type. Methods are optional, a
|
||||
nil pointer meaning that particular kind of access is not available for
|
||||
this type. The Py_DECREF() macro uses the tp_dealloc method without
|
||||
checking for a nil pointer; it should always be implemented except if
|
||||
the implementation can guarantee that the reference count will never
|
||||
reach zero (e.g., for statically allocated type objects).
|
||||
|
||||
NB: the methods for certain type groups are now contained in separate
|
||||
method blocks.
|
||||
*/
|
||||
|
||||
typedef PyObject * (*unaryfunc)(PyObject *);
|
||||
typedef PyObject * (*binaryfunc)(PyObject *, PyObject *);
|
||||
typedef PyObject * (*ternaryfunc)(PyObject *, PyObject *, PyObject *);
|
||||
typedef int (*inquiry)(PyObject *);
|
||||
typedef Py_ssize_t (*lenfunc)(PyObject *);
|
||||
typedef PyObject *(*ssizeargfunc)(PyObject *, Py_ssize_t);
|
||||
typedef PyObject *(*ssizessizeargfunc)(PyObject *, Py_ssize_t, Py_ssize_t);
|
||||
typedef int(*ssizeobjargproc)(PyObject *, Py_ssize_t, PyObject *);
|
||||
typedef int(*ssizessizeobjargproc)(PyObject *, Py_ssize_t, Py_ssize_t, PyObject *);
|
||||
typedef int(*objobjargproc)(PyObject *, PyObject *, PyObject *);
|
||||
|
||||
typedef int (*objobjproc)(PyObject *, PyObject *);
|
||||
typedef int (*visitproc)(PyObject *, void *);
|
||||
typedef int (*traverseproc)(PyObject *, visitproc, void *);
|
||||
|
||||
|
||||
typedef void (*freefunc)(void *);
|
||||
typedef void (*destructor)(PyObject *);
|
||||
typedef PyObject *(*getattrfunc)(PyObject *, char *);
|
||||
typedef PyObject *(*getattrofunc)(PyObject *, PyObject *);
|
||||
typedef int (*setattrfunc)(PyObject *, char *, PyObject *);
|
||||
typedef int (*setattrofunc)(PyObject *, PyObject *, PyObject *);
|
||||
typedef PyObject *(*reprfunc)(PyObject *);
|
||||
typedef Py_hash_t (*hashfunc)(PyObject *);
|
||||
typedef PyObject *(*richcmpfunc) (PyObject *, PyObject *, int);
|
||||
typedef PyObject *(*getiterfunc) (PyObject *);
|
||||
typedef PyObject *(*iternextfunc) (PyObject *);
|
||||
typedef PyObject *(*descrgetfunc) (PyObject *, PyObject *, PyObject *);
|
||||
typedef int (*descrsetfunc) (PyObject *, PyObject *, PyObject *);
|
||||
typedef int (*initproc)(PyObject *, PyObject *, PyObject *);
|
||||
typedef PyObject *(*newfunc)(PyTypeObject *, PyObject *, PyObject *);
|
||||
typedef PyObject *(*allocfunc)(PyTypeObject *, Py_ssize_t);
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030c0000 // 3.12
|
||||
typedef PyObject *(*vectorcallfunc)(PyObject *callable, PyObject *const *args,
|
||||
size_t nargsf, PyObject *kwnames);
|
||||
#endif
|
||||
|
||||
typedef struct{
|
||||
int slot; /* slot id, see below */
|
||||
void *pfunc; /* function pointer */
|
||||
} PyType_Slot;
|
||||
|
||||
typedef struct{
|
||||
const char* name;
|
||||
int basicsize;
|
||||
int itemsize;
|
||||
unsigned int flags;
|
||||
PyType_Slot *slots; /* terminated by slot==0. */
|
||||
} PyType_Spec;
|
||||
|
||||
PyAPI_FUNC(PyObject*) PyType_FromSpec(PyType_Spec*);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_FUNC(PyObject*) PyType_FromSpecWithBases(PyType_Spec*, PyObject*);
|
||||
#endif
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03040000
|
||||
PyAPI_FUNC(void*) PyType_GetSlot(PyTypeObject*, int);
|
||||
#endif
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03090000
|
||||
PyAPI_FUNC(PyObject*) PyType_FromModuleAndSpec(PyObject *, PyType_Spec *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyType_GetModule(PyTypeObject *);
|
||||
PyAPI_FUNC(void *) PyType_GetModuleState(PyTypeObject *);
|
||||
#endif
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030B0000
|
||||
PyAPI_FUNC(PyObject *) PyType_GetName(PyTypeObject *);
|
||||
PyAPI_FUNC(PyObject *) PyType_GetQualName(PyTypeObject *);
|
||||
#endif
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030C0000
|
||||
PyAPI_FUNC(PyObject *) PyType_FromMetaclass(PyTypeObject*, PyObject*, PyType_Spec*, PyObject*);
|
||||
PyAPI_FUNC(void *) PyObject_GetTypeData(PyObject *obj, PyTypeObject *cls);
|
||||
PyAPI_FUNC(Py_ssize_t) PyType_GetTypeDataSize(PyTypeObject *cls);
|
||||
#endif
|
||||
|
||||
/* Generic type check */
|
||||
PyAPI_FUNC(int) PyType_IsSubtype(PyTypeObject *, PyTypeObject *);
|
||||
|
||||
static inline int PyObject_TypeCheck(PyObject *ob, PyTypeObject *type) {
|
||||
return Py_IS_TYPE(ob, type) || PyType_IsSubtype(Py_TYPE(ob), type);
|
||||
}
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
|
||||
# define PyObject_TypeCheck(ob, type) PyObject_TypeCheck(_PyObject_CAST(ob), (type))
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyType_Type; /* built-in 'type' */
|
||||
PyAPI_DATA(PyTypeObject) PyBaseObject_Type; /* built-in 'object' */
|
||||
PyAPI_DATA(PyTypeObject) PySuper_Type; /* built-in 'super' */
|
||||
|
||||
PyAPI_FUNC(unsigned long) PyType_GetFlags(PyTypeObject*);
|
||||
|
||||
PyAPI_FUNC(int) PyType_Ready(PyTypeObject *);
|
||||
PyAPI_FUNC(PyObject *) PyType_GenericAlloc(PyTypeObject *, Py_ssize_t);
|
||||
PyAPI_FUNC(PyObject *) PyType_GenericNew(PyTypeObject *,
|
||||
PyObject *, PyObject *);
|
||||
PyAPI_FUNC(unsigned int) PyType_ClearCache(void);
|
||||
PyAPI_FUNC(void) PyType_Modified(PyTypeObject *);
|
||||
|
||||
/* Generic operations on objects */
|
||||
PyAPI_FUNC(PyObject *) PyObject_Repr(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyObject_Str(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyObject_ASCII(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyObject_Bytes(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyObject_RichCompare(PyObject *, PyObject *, int);
|
||||
PyAPI_FUNC(int) PyObject_RichCompareBool(PyObject *, PyObject *, int);
|
||||
PyAPI_FUNC(PyObject *) PyObject_GetAttrString(PyObject *, const char *);
|
||||
PyAPI_FUNC(int) PyObject_SetAttrString(PyObject *, const char *, PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_HasAttrString(PyObject *, const char *);
|
||||
PyAPI_FUNC(PyObject *) PyObject_GetAttr(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_SetAttr(PyObject *, PyObject *, PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_HasAttr(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyObject_SelfIter(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyObject_GenericGetAttr(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_GenericSetAttr(PyObject *, PyObject *, PyObject *);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_FUNC(int) PyObject_GenericSetDict(PyObject *, PyObject *, void *);
|
||||
#endif
|
||||
PyAPI_FUNC(Py_hash_t) PyObject_Hash(PyObject *);
|
||||
PyAPI_FUNC(Py_hash_t) PyObject_HashNotImplemented(PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_IsTrue(PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_Not(PyObject *);
|
||||
PyAPI_FUNC(int) PyCallable_Check(PyObject *);
|
||||
PyAPI_FUNC(void) PyObject_ClearWeakRefs(PyObject *);
|
||||
|
||||
/* PyObject_Dir(obj) acts like Python builtins.dir(obj), returning a
|
||||
list of strings. PyObject_Dir(NULL) is like builtins.dir(),
|
||||
returning the names of the current locals. In this case, if there are
|
||||
no current locals, NULL is returned, and PyErr_Occurred() is false.
|
||||
*/
|
||||
PyAPI_FUNC(PyObject *) PyObject_Dir(PyObject *);
|
||||
|
||||
/* Pickle support. */
|
||||
#ifndef Py_LIMITED_API
|
||||
PyAPI_FUNC(PyObject *) _PyObject_GetState(PyObject *);
|
||||
#endif
|
||||
|
||||
|
||||
/* Helpers for printing recursive container types */
|
||||
PyAPI_FUNC(int) Py_ReprEnter(PyObject *);
|
||||
PyAPI_FUNC(void) Py_ReprLeave(PyObject *);
|
||||
|
||||
/* Flag bits for printing: */
|
||||
#define Py_PRINT_RAW 1 /* No string quotes etc. */
|
||||
|
||||
/*
|
||||
Type flags (tp_flags)
|
||||
|
||||
These flags are used to change expected features and behavior for a
|
||||
particular type.
|
||||
|
||||
Arbitration of the flag bit positions will need to be coordinated among
|
||||
all extension writers who publicly release their extensions (this will
|
||||
be fewer than you might expect!).
|
||||
|
||||
Most flags were removed as of Python 3.0 to make room for new flags. (Some
|
||||
flags are not for backwards compatibility but to indicate the presence of an
|
||||
optional feature; these flags remain of course.)
|
||||
|
||||
Type definitions should use Py_TPFLAGS_DEFAULT for their tp_flags value.
|
||||
|
||||
Code can use PyType_HasFeature(type_ob, flag_value) to test whether the
|
||||
given type object has a specified feature.
|
||||
*/
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
|
||||
/* Track types initialized using _PyStaticType_InitBuiltin(). */
|
||||
#define _Py_TPFLAGS_STATIC_BUILTIN (1 << 1)
|
||||
|
||||
/* Placement of weakref pointers are managed by the VM, not by the type.
|
||||
* The VM will automatically set tp_weaklistoffset.
|
||||
*/
|
||||
#define Py_TPFLAGS_MANAGED_WEAKREF (1 << 3)
|
||||
|
||||
/* Placement of dict (and values) pointers are managed by the VM, not by the type.
|
||||
* The VM will automatically set tp_dictoffset.
|
||||
*/
|
||||
#define Py_TPFLAGS_MANAGED_DICT (1 << 4)
|
||||
|
||||
#define Py_TPFLAGS_PREHEADER (Py_TPFLAGS_MANAGED_WEAKREF | Py_TPFLAGS_MANAGED_DICT)
|
||||
|
||||
/* Set if instances of the type object are treated as sequences for pattern matching */
|
||||
#define Py_TPFLAGS_SEQUENCE (1 << 5)
|
||||
/* Set if instances of the type object are treated as mappings for pattern matching */
|
||||
#define Py_TPFLAGS_MAPPING (1 << 6)
|
||||
#endif
|
||||
|
||||
/* Disallow creating instances of the type: set tp_new to NULL and don't create
|
||||
* the "__new__" key in the type dictionary. */
|
||||
#define Py_TPFLAGS_DISALLOW_INSTANTIATION (1UL << 7)
|
||||
|
||||
/* Set if the type object is immutable: type attributes cannot be set nor deleted */
|
||||
#define Py_TPFLAGS_IMMUTABLETYPE (1UL << 8)
|
||||
|
||||
/* Set if the type object is dynamically allocated */
|
||||
#define Py_TPFLAGS_HEAPTYPE (1UL << 9)
|
||||
|
||||
/* Set if the type allows subclassing */
|
||||
#define Py_TPFLAGS_BASETYPE (1UL << 10)
|
||||
|
||||
/* Set if the type implements the vectorcall protocol (PEP 590) */
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030C0000
|
||||
#define Py_TPFLAGS_HAVE_VECTORCALL (1UL << 11)
|
||||
#ifndef Py_LIMITED_API
|
||||
// Backwards compatibility alias for API that was provisional in Python 3.8
|
||||
#define _Py_TPFLAGS_HAVE_VECTORCALL Py_TPFLAGS_HAVE_VECTORCALL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Set if the type is 'ready' -- fully initialized */
|
||||
#define Py_TPFLAGS_READY (1UL << 12)
|
||||
|
||||
/* Set while the type is being 'readied', to prevent recursive ready calls */
|
||||
#define Py_TPFLAGS_READYING (1UL << 13)
|
||||
|
||||
/* Objects support garbage collection (see objimpl.h) */
|
||||
#define Py_TPFLAGS_HAVE_GC (1UL << 14)
|
||||
|
||||
/* These two bits are preserved for Stackless Python, next after this is 17 */
|
||||
#ifdef STACKLESS
|
||||
#define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION (3UL << 15)
|
||||
#else
|
||||
#define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION 0
|
||||
#endif
|
||||
|
||||
/* Objects behave like an unbound method */
|
||||
#define Py_TPFLAGS_METHOD_DESCRIPTOR (1UL << 17)
|
||||
|
||||
/* Object has up-to-date type attribute cache */
|
||||
#define Py_TPFLAGS_VALID_VERSION_TAG (1UL << 19)
|
||||
|
||||
/* Type is abstract and cannot be instantiated */
|
||||
#define Py_TPFLAGS_IS_ABSTRACT (1UL << 20)
|
||||
|
||||
// This undocumented flag gives certain built-ins their unique pattern-matching
|
||||
// behavior, which allows a single positional subpattern to match against the
|
||||
// subject itself (rather than a mapped attribute on it):
|
||||
#define _Py_TPFLAGS_MATCH_SELF (1UL << 22)
|
||||
|
||||
/* Items (ob_size*tp_itemsize) are found at the end of an instance's memory */
|
||||
#define Py_TPFLAGS_ITEMS_AT_END (1UL << 23)
|
||||
|
||||
/* These flags are used to determine if a type is a subclass. */
|
||||
#define Py_TPFLAGS_LONG_SUBCLASS (1UL << 24)
|
||||
#define Py_TPFLAGS_LIST_SUBCLASS (1UL << 25)
|
||||
#define Py_TPFLAGS_TUPLE_SUBCLASS (1UL << 26)
|
||||
#define Py_TPFLAGS_BYTES_SUBCLASS (1UL << 27)
|
||||
#define Py_TPFLAGS_UNICODE_SUBCLASS (1UL << 28)
|
||||
#define Py_TPFLAGS_DICT_SUBCLASS (1UL << 29)
|
||||
#define Py_TPFLAGS_BASE_EXC_SUBCLASS (1UL << 30)
|
||||
#define Py_TPFLAGS_TYPE_SUBCLASS (1UL << 31)
|
||||
|
||||
#define Py_TPFLAGS_DEFAULT ( \
|
||||
Py_TPFLAGS_HAVE_STACKLESS_EXTENSION | \
|
||||
0)
|
||||
|
||||
/* NOTE: Some of the following flags reuse lower bits (removed as part of the
|
||||
* Python 3.0 transition). */
|
||||
|
||||
/* The following flags are kept for compatibility; in previous
|
||||
* versions they indicated presence of newer tp_* fields on the
|
||||
* type struct.
|
||||
* Starting with 3.8, binary compatibility of C extensions across
|
||||
* feature releases of Python is not supported anymore (except when
|
||||
* using the stable ABI, in which all classes are created dynamically,
|
||||
* using the interpreter's memory layout.)
|
||||
* Note that older extensions using the stable ABI set these flags,
|
||||
* so the bits must not be repurposed.
|
||||
*/
|
||||
#define Py_TPFLAGS_HAVE_FINALIZE (1UL << 0)
|
||||
#define Py_TPFLAGS_HAVE_VERSION_TAG (1UL << 18)
|
||||
|
||||
|
||||
/*
|
||||
The macros Py_INCREF(op) and Py_DECREF(op) are used to increment or decrement
|
||||
reference counts. Py_DECREF calls the object's deallocator function when
|
||||
the refcount falls to 0; for
|
||||
objects that don't contain references to other objects or heap memory
|
||||
this can be the standard function free(). Both macros can be used
|
||||
wherever a void expression is allowed. The argument must not be a
|
||||
NULL pointer. If it may be NULL, use Py_XINCREF/Py_XDECREF instead.
|
||||
The macro _Py_NewReference(op) initialize reference counts to 1, and
|
||||
in special builds (Py_REF_DEBUG, Py_TRACE_REFS) performs additional
|
||||
bookkeeping appropriate to the special build.
|
||||
|
||||
We assume that the reference count field can never overflow; this can
|
||||
be proven when the size of the field is the same as the pointer size, so
|
||||
we ignore the possibility. Provided a C int is at least 32 bits (which
|
||||
is implicitly assumed in many parts of this code), that's enough for
|
||||
about 2**31 references to an object.
|
||||
|
||||
XXX The following became out of date in Python 2.2, but I'm not sure
|
||||
XXX what the full truth is now. Certainly, heap-allocated type objects
|
||||
XXX can and should be deallocated.
|
||||
Type objects should never be deallocated; the type pointer in an object
|
||||
is not considered to be a reference to the type object, to save
|
||||
complications in the deallocation function. (This is actually a
|
||||
decision that's up to the implementer of each new type so if you want,
|
||||
you can count such references to the type object.)
|
||||
*/
|
||||
|
||||
#if defined(Py_REF_DEBUG) && !defined(Py_LIMITED_API)
|
||||
PyAPI_FUNC(void) _Py_NegativeRefcount(const char *filename, int lineno,
|
||||
PyObject *op);
|
||||
PyAPI_FUNC(void) _Py_INCREF_IncRefTotal(void);
|
||||
PyAPI_FUNC(void) _Py_DECREF_DecRefTotal(void);
|
||||
#endif // Py_REF_DEBUG && !Py_LIMITED_API
|
||||
|
||||
PyAPI_FUNC(void) _Py_Dealloc(PyObject *);
|
||||
|
||||
/*
|
||||
These are provided as conveniences to Python runtime embedders, so that
|
||||
they can have object code that is not dependent on Python compilation flags.
|
||||
*/
|
||||
PyAPI_FUNC(void) Py_IncRef(PyObject *);
|
||||
PyAPI_FUNC(void) Py_DecRef(PyObject *);
|
||||
|
||||
// Similar to Py_IncRef() and Py_DecRef() but the argument must be non-NULL.
|
||||
// Private functions used by Py_INCREF() and Py_DECREF().
|
||||
PyAPI_FUNC(void) _Py_IncRef(PyObject *);
|
||||
PyAPI_FUNC(void) _Py_DecRef(PyObject *);
|
||||
|
||||
static inline Py_ALWAYS_INLINE void Py_INCREF(PyObject *op)
|
||||
{
|
||||
#if defined(Py_LIMITED_API) && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG))
|
||||
// Stable ABI implements Py_INCREF() as a function call on limited C API
|
||||
// version 3.12 and newer, and on Python built in debug mode. _Py_IncRef()
|
||||
// was added to Python 3.10.0a7, use Py_IncRef() on older Python versions.
|
||||
// Py_IncRef() accepts NULL whereas _Py_IncRef() doesn't.
|
||||
# if Py_LIMITED_API+0 >= 0x030a00A7
|
||||
_Py_IncRef(op);
|
||||
# else
|
||||
Py_IncRef(op);
|
||||
# endif
|
||||
#else
|
||||
// Non-limited C API and limited C API for Python 3.9 and older access
|
||||
// directly PyObject.ob_refcnt.
|
||||
#if SIZEOF_VOID_P > 4
|
||||
// Portable saturated add, branching on the carry flag and set low bits
|
||||
PY_UINT32_T cur_refcnt = op->ob_refcnt_split[PY_BIG_ENDIAN];
|
||||
PY_UINT32_T new_refcnt = cur_refcnt + 1;
|
||||
if (new_refcnt == 0) {
|
||||
return;
|
||||
}
|
||||
op->ob_refcnt_split[PY_BIG_ENDIAN] = new_refcnt;
|
||||
#else
|
||||
// Explicitly check immortality against the immortal value
|
||||
if (_Py_IsImmortal(op)) {
|
||||
return;
|
||||
}
|
||||
op->ob_refcnt++;
|
||||
#endif
|
||||
_Py_INCREF_STAT_INC();
|
||||
#ifdef Py_REF_DEBUG
|
||||
_Py_INCREF_IncRefTotal();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
|
||||
# define Py_INCREF(op) Py_INCREF(_PyObject_CAST(op))
|
||||
#endif
|
||||
|
||||
#if defined(Py_LIMITED_API) && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG))
|
||||
// Stable ABI implements Py_DECREF() as a function call on limited C API
|
||||
// version 3.12 and newer, and on Python built in debug mode. _Py_DecRef() was
|
||||
// added to Python 3.10.0a7, use Py_DecRef() on older Python versions.
|
||||
// Py_DecRef() accepts NULL whereas _Py_IncRef() doesn't.
|
||||
static inline void Py_DECREF(PyObject *op) {
|
||||
# if Py_LIMITED_API+0 >= 0x030a00A7
|
||||
_Py_DecRef(op);
|
||||
# else
|
||||
Py_DecRef(op);
|
||||
# endif
|
||||
}
|
||||
#define Py_DECREF(op) Py_DECREF(_PyObject_CAST(op))
|
||||
|
||||
#elif defined(Py_REF_DEBUG)
|
||||
static inline void Py_DECREF(const char *filename, int lineno, PyObject *op)
|
||||
{
|
||||
if (op->ob_refcnt <= 0) {
|
||||
_Py_NegativeRefcount(filename, lineno, op);
|
||||
}
|
||||
if (_Py_IsImmortal(op)) {
|
||||
return;
|
||||
}
|
||||
_Py_DECREF_STAT_INC();
|
||||
_Py_DECREF_DecRefTotal();
|
||||
if (--op->ob_refcnt == 0) {
|
||||
_Py_Dealloc(op);
|
||||
}
|
||||
}
|
||||
#define Py_DECREF(op) Py_DECREF(__FILE__, __LINE__, _PyObject_CAST(op))
|
||||
|
||||
#else
|
||||
static inline Py_ALWAYS_INLINE void Py_DECREF(PyObject *op)
|
||||
{
|
||||
// Non-limited C API and limited C API for Python 3.9 and older access
|
||||
// directly PyObject.ob_refcnt.
|
||||
if (_Py_IsImmortal(op)) {
|
||||
return;
|
||||
}
|
||||
_Py_DECREF_STAT_INC();
|
||||
if (--op->ob_refcnt == 0) {
|
||||
_Py_Dealloc(op);
|
||||
}
|
||||
}
|
||||
#define Py_DECREF(op) Py_DECREF(_PyObject_CAST(op))
|
||||
#endif
|
||||
|
||||
|
||||
/* Safely decref `op` and set `op` to NULL, especially useful in tp_clear
|
||||
* and tp_dealloc implementations.
|
||||
*
|
||||
* Note that "the obvious" code can be deadly:
|
||||
*
|
||||
* Py_XDECREF(op);
|
||||
* op = NULL;
|
||||
*
|
||||
* Typically, `op` is something like self->containee, and `self` is done
|
||||
* using its `containee` member. In the code sequence above, suppose
|
||||
* `containee` is non-NULL with a refcount of 1. Its refcount falls to
|
||||
* 0 on the first line, which can trigger an arbitrary amount of code,
|
||||
* possibly including finalizers (like __del__ methods or weakref callbacks)
|
||||
* coded in Python, which in turn can release the GIL and allow other threads
|
||||
* to run, etc. Such code may even invoke methods of `self` again, or cause
|
||||
* cyclic gc to trigger, but-- oops! --self->containee still points to the
|
||||
* object being torn down, and it may be in an insane state while being torn
|
||||
* down. This has in fact been a rich historic source of miserable (rare &
|
||||
* hard-to-diagnose) segfaulting (and other) bugs.
|
||||
*
|
||||
* The safe way is:
|
||||
*
|
||||
* Py_CLEAR(op);
|
||||
*
|
||||
* That arranges to set `op` to NULL _before_ decref'ing, so that any code
|
||||
* triggered as a side-effect of `op` getting torn down no longer believes
|
||||
* `op` points to a valid object.
|
||||
*
|
||||
* There are cases where it's safe to use the naive code, but they're brittle.
|
||||
* For example, if `op` points to a Python integer, you know that destroying
|
||||
* one of those can't cause problems -- but in part that relies on that
|
||||
* Python integers aren't currently weakly referencable. Best practice is
|
||||
* to use Py_CLEAR() even if you can't think of a reason for why you need to.
|
||||
*
|
||||
* gh-98724: Use a temporary variable to only evaluate the macro argument once,
|
||||
* to avoid the duplication of side effects if the argument has side effects.
|
||||
*
|
||||
* gh-99701: If the PyObject* type is used with casting arguments to PyObject*,
|
||||
* the code can be miscompiled with strict aliasing because of type punning.
|
||||
* With strict aliasing, a compiler considers that two pointers of different
|
||||
* types cannot read or write the same memory which enables optimization
|
||||
* opportunities.
|
||||
*
|
||||
* If available, use _Py_TYPEOF() to use the 'op' type for temporary variables,
|
||||
* and so avoid type punning. Otherwise, use memcpy() which causes type erasure
|
||||
* and so prevents the compiler to reuse an old cached 'op' value after
|
||||
* Py_CLEAR().
|
||||
*/
|
||||
#ifdef _Py_TYPEOF
|
||||
#define Py_CLEAR(op) \
|
||||
do { \
|
||||
_Py_TYPEOF(op)* _tmp_op_ptr = &(op); \
|
||||
_Py_TYPEOF(op) _tmp_old_op = (*_tmp_op_ptr); \
|
||||
if (_tmp_old_op != NULL) { \
|
||||
*_tmp_op_ptr = _Py_NULL; \
|
||||
Py_DECREF(_tmp_old_op); \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define Py_CLEAR(op) \
|
||||
do { \
|
||||
PyObject **_tmp_op_ptr = _Py_CAST(PyObject**, &(op)); \
|
||||
PyObject *_tmp_old_op = (*_tmp_op_ptr); \
|
||||
if (_tmp_old_op != NULL) { \
|
||||
PyObject *_null_ptr = _Py_NULL; \
|
||||
memcpy(_tmp_op_ptr, &_null_ptr, sizeof(PyObject*)); \
|
||||
Py_DECREF(_tmp_old_op); \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
|
||||
/* Function to use in case the object pointer can be NULL: */
|
||||
static inline void Py_XINCREF(PyObject *op)
|
||||
{
|
||||
if (op != _Py_NULL) {
|
||||
Py_INCREF(op);
|
||||
}
|
||||
}
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
|
||||
# define Py_XINCREF(op) Py_XINCREF(_PyObject_CAST(op))
|
||||
#endif
|
||||
|
||||
static inline void Py_XDECREF(PyObject *op)
|
||||
{
|
||||
if (op != _Py_NULL) {
|
||||
Py_DECREF(op);
|
||||
}
|
||||
}
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
|
||||
# define Py_XDECREF(op) Py_XDECREF(_PyObject_CAST(op))
|
||||
#endif
|
||||
|
||||
// Create a new strong reference to an object:
|
||||
// increment the reference count of the object and return the object.
|
||||
PyAPI_FUNC(PyObject*) Py_NewRef(PyObject *obj);
|
||||
|
||||
// Similar to Py_NewRef(), but the object can be NULL.
|
||||
PyAPI_FUNC(PyObject*) Py_XNewRef(PyObject *obj);
|
||||
|
||||
static inline PyObject* _Py_NewRef(PyObject *obj)
|
||||
{
|
||||
Py_INCREF(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
static inline PyObject* _Py_XNewRef(PyObject *obj)
|
||||
{
|
||||
Py_XINCREF(obj);
|
||||
return obj;
|
||||
}
|
||||
|
||||
// Py_NewRef() and Py_XNewRef() are exported as functions for the stable ABI.
|
||||
// Names overridden with macros by static inline functions for best
|
||||
// performances.
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
|
||||
# define Py_NewRef(obj) _Py_NewRef(_PyObject_CAST(obj))
|
||||
# define Py_XNewRef(obj) _Py_XNewRef(_PyObject_CAST(obj))
|
||||
#else
|
||||
# define Py_NewRef(obj) _Py_NewRef(obj)
|
||||
# define Py_XNewRef(obj) _Py_XNewRef(obj)
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
_Py_NoneStruct is an object of undefined type which can be used in contexts
|
||||
where NULL (nil) is not suitable (since NULL often means 'error').
|
||||
|
||||
Don't forget to apply Py_INCREF() when returning this value!!!
|
||||
*/
|
||||
PyAPI_DATA(PyObject) _Py_NoneStruct; /* Don't use this directly */
|
||||
#define Py_None (&_Py_NoneStruct)
|
||||
|
||||
// Test if an object is the None singleton, the same as "x is None" in Python.
|
||||
PyAPI_FUNC(int) Py_IsNone(PyObject *x);
|
||||
#define Py_IsNone(x) Py_Is((x), Py_None)
|
||||
|
||||
/* Macro for returning Py_None from a function */
|
||||
#define Py_RETURN_NONE return Py_None
|
||||
|
||||
/*
|
||||
Py_NotImplemented is a singleton used to signal that an operation is
|
||||
not implemented for a given type combination.
|
||||
*/
|
||||
PyAPI_DATA(PyObject) _Py_NotImplementedStruct; /* Don't use this directly */
|
||||
#define Py_NotImplemented (&_Py_NotImplementedStruct)
|
||||
|
||||
/* Macro for returning Py_NotImplemented from a function */
|
||||
#define Py_RETURN_NOTIMPLEMENTED return Py_NotImplemented
|
||||
|
||||
/* Rich comparison opcodes */
|
||||
#define Py_LT 0
|
||||
#define Py_LE 1
|
||||
#define Py_EQ 2
|
||||
#define Py_NE 3
|
||||
#define Py_GT 4
|
||||
#define Py_GE 5
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000
|
||||
/* Result of calling PyIter_Send */
|
||||
typedef enum {
|
||||
PYGEN_RETURN = 0,
|
||||
PYGEN_ERROR = -1,
|
||||
PYGEN_NEXT = 1,
|
||||
} PySendResult;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Macro for implementing rich comparisons
|
||||
*
|
||||
* Needs to be a macro because any C-comparable type can be used.
|
||||
*/
|
||||
#define Py_RETURN_RICHCOMPARE(val1, val2, op) \
|
||||
do { \
|
||||
switch (op) { \
|
||||
case Py_EQ: if ((val1) == (val2)) Py_RETURN_TRUE; Py_RETURN_FALSE; \
|
||||
case Py_NE: if ((val1) != (val2)) Py_RETURN_TRUE; Py_RETURN_FALSE; \
|
||||
case Py_LT: if ((val1) < (val2)) Py_RETURN_TRUE; Py_RETURN_FALSE; \
|
||||
case Py_GT: if ((val1) > (val2)) Py_RETURN_TRUE; Py_RETURN_FALSE; \
|
||||
case Py_LE: if ((val1) <= (val2)) Py_RETURN_TRUE; Py_RETURN_FALSE; \
|
||||
case Py_GE: if ((val1) >= (val2)) Py_RETURN_TRUE; Py_RETURN_FALSE; \
|
||||
default: \
|
||||
Py_UNREACHABLE(); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
/*
|
||||
More conventions
|
||||
================
|
||||
|
||||
Argument Checking
|
||||
-----------------
|
||||
|
||||
Functions that take objects as arguments normally don't check for nil
|
||||
arguments, but they do check the type of the argument, and return an
|
||||
error if the function doesn't apply to the type.
|
||||
|
||||
Failure Modes
|
||||
-------------
|
||||
|
||||
Functions may fail for a variety of reasons, including running out of
|
||||
memory. This is communicated to the caller in two ways: an error string
|
||||
is set (see errors.h), and the function result differs: functions that
|
||||
normally return a pointer return NULL for failure, functions returning
|
||||
an integer return -1 (which could be a legal return value too!), and
|
||||
other functions return 0 for success and -1 for failure.
|
||||
Callers should always check for errors before using the result. If
|
||||
an error was set, the caller must either explicitly clear it, or pass
|
||||
the error on to its caller.
|
||||
|
||||
Reference Counts
|
||||
----------------
|
||||
|
||||
It takes a while to get used to the proper usage of reference counts.
|
||||
|
||||
Functions that create an object set the reference count to 1; such new
|
||||
objects must be stored somewhere or destroyed again with Py_DECREF().
|
||||
Some functions that 'store' objects, such as PyTuple_SetItem() and
|
||||
PyList_SetItem(),
|
||||
don't increment the reference count of the object, since the most
|
||||
frequent use is to store a fresh object. Functions that 'retrieve'
|
||||
objects, such as PyTuple_GetItem() and PyDict_GetItemString(), also
|
||||
don't increment
|
||||
the reference count, since most frequently the object is only looked at
|
||||
quickly. Thus, to retrieve an object and store it again, the caller
|
||||
must call Py_INCREF() explicitly.
|
||||
|
||||
NOTE: functions that 'consume' a reference count, like
|
||||
PyList_SetItem(), consume the reference even if the object wasn't
|
||||
successfully stored, to simplify error handling.
|
||||
|
||||
It seems attractive to make other functions that take an object as
|
||||
argument consume a reference count; however, this may quickly get
|
||||
confusing (even the current practice is already confusing). Consider
|
||||
it carefully, it may save lots of calls to Py_INCREF() and Py_DECREF() at
|
||||
times.
|
||||
*/
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
# define Py_CPYTHON_OBJECT_H
|
||||
# include "cpython/object.h"
|
||||
# undef Py_CPYTHON_OBJECT_H
|
||||
#endif
|
||||
|
||||
|
||||
static inline int
|
||||
PyType_HasFeature(PyTypeObject *type, unsigned long feature)
|
||||
{
|
||||
unsigned long flags;
|
||||
#ifdef Py_LIMITED_API
|
||||
// PyTypeObject is opaque in the limited C API
|
||||
flags = PyType_GetFlags(type);
|
||||
#else
|
||||
flags = type->tp_flags;
|
||||
#endif
|
||||
return ((flags & feature) != 0);
|
||||
}
|
||||
|
||||
#define PyType_FastSubclass(type, flag) PyType_HasFeature((type), (flag))
|
||||
|
||||
static inline int PyType_Check(PyObject *op) {
|
||||
return PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_TYPE_SUBCLASS);
|
||||
}
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
|
||||
# define PyType_Check(op) PyType_Check(_PyObject_CAST(op))
|
||||
#endif
|
||||
|
||||
#define _PyType_CAST(op) \
|
||||
(assert(PyType_Check(op)), _Py_CAST(PyTypeObject*, (op)))
|
||||
|
||||
static inline int PyType_CheckExact(PyObject *op) {
|
||||
return Py_IS_TYPE(op, &PyType_Type);
|
||||
}
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 < 0x030b0000
|
||||
# define PyType_CheckExact(op) PyType_CheckExact(_PyObject_CAST(op))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif // !Py_OBJECT_H
|
||||
234
crypto/shamirs_secret_sharing/include/objimpl.h
Normal file
234
crypto/shamirs_secret_sharing/include/objimpl.h
Normal file
@@ -0,0 +1,234 @@
|
||||
/* The PyObject_ memory family: high-level object memory interfaces.
|
||||
See pymem.h for the low-level PyMem_ family.
|
||||
*/
|
||||
|
||||
#ifndef Py_OBJIMPL_H
|
||||
#define Py_OBJIMPL_H
|
||||
|
||||
#include "pymem.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* BEWARE:
|
||||
|
||||
Each interface exports both functions and macros. Extension modules should
|
||||
use the functions, to ensure binary compatibility across Python versions.
|
||||
Because the Python implementation is free to change internal details, and
|
||||
the macros may (or may not) expose details for speed, if you do use the
|
||||
macros you must recompile your extensions with each Python release.
|
||||
|
||||
Never mix calls to PyObject_ memory functions with calls to the platform
|
||||
malloc/realloc/ calloc/free, or with calls to PyMem_.
|
||||
*/
|
||||
|
||||
/*
|
||||
Functions and macros for modules that implement new object types.
|
||||
|
||||
- PyObject_New(type, typeobj) allocates memory for a new object of the given
|
||||
type, and initializes part of it. 'type' must be the C structure type used
|
||||
to represent the object, and 'typeobj' the address of the corresponding
|
||||
type object. Reference count and type pointer are filled in; the rest of
|
||||
the bytes of the object are *undefined*! The resulting expression type is
|
||||
'type *'. The size of the object is determined by the tp_basicsize field
|
||||
of the type object.
|
||||
|
||||
- PyObject_NewVar(type, typeobj, n) is similar but allocates a variable-size
|
||||
object with room for n items. In addition to the refcount and type pointer
|
||||
fields, this also fills in the ob_size field.
|
||||
|
||||
- PyObject_Free(op) releases the memory allocated for an object. It does not
|
||||
run a destructor -- it only frees the memory. PyObject_Free is identical.
|
||||
|
||||
- PyObject_Init(op, typeobj) and PyObject_InitVar(op, typeobj, n) don't
|
||||
allocate memory. Instead of a 'type' parameter, they take a pointer to a
|
||||
new object (allocated by an arbitrary allocator), and initialize its object
|
||||
header fields.
|
||||
|
||||
Note that objects created with PyObject_{New, NewVar} are allocated using the
|
||||
specialized Python allocator (implemented in obmalloc.c), if WITH_PYMALLOC is
|
||||
enabled. In addition, a special debugging allocator is used if Py_DEBUG
|
||||
macro is also defined.
|
||||
|
||||
In case a specific form of memory management is needed (for example, if you
|
||||
must use the platform malloc heap(s), or shared memory, or C++ local storage or
|
||||
operator new), you must first allocate the object with your custom allocator,
|
||||
then pass its pointer to PyObject_{Init, InitVar} for filling in its Python-
|
||||
specific fields: reference count, type pointer, possibly others. You should
|
||||
be aware that Python has no control over these objects because they don't
|
||||
cooperate with the Python memory manager. Such objects may not be eligible
|
||||
for automatic garbage collection and you have to make sure that they are
|
||||
released accordingly whenever their destructor gets called (cf. the specific
|
||||
form of memory management you're using).
|
||||
|
||||
Unless you have specific memory management requirements, use
|
||||
PyObject_{New, NewVar, Del}.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Raw object memory interface
|
||||
* ===========================
|
||||
*/
|
||||
|
||||
/* Functions to call the same malloc/realloc/free as used by Python's
|
||||
object allocator. If WITH_PYMALLOC is enabled, these may differ from
|
||||
the platform malloc/realloc/free. The Python object allocator is
|
||||
designed for fast, cache-conscious allocation of many "small" objects,
|
||||
and with low hidden memory overhead.
|
||||
|
||||
PyObject_Malloc(0) returns a unique non-NULL pointer if possible.
|
||||
|
||||
PyObject_Realloc(NULL, n) acts like PyObject_Malloc(n).
|
||||
PyObject_Realloc(p != NULL, 0) does not return NULL, or free the memory
|
||||
at p.
|
||||
|
||||
Returned pointers must be checked for NULL explicitly; no action is
|
||||
performed on failure other than to return NULL (no warning it printed, no
|
||||
exception is set, etc).
|
||||
|
||||
For allocating objects, use PyObject_{New, NewVar} instead whenever
|
||||
possible. The PyObject_{Malloc, Realloc, Free} family is exposed
|
||||
so that you can exploit Python's small-block allocator for non-object
|
||||
uses. If you must use these routines to allocate object memory, make sure
|
||||
the object gets initialized via PyObject_{Init, InitVar} after obtaining
|
||||
the raw memory.
|
||||
*/
|
||||
PyAPI_FUNC(void *) PyObject_Malloc(size_t size);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||
PyAPI_FUNC(void *) PyObject_Calloc(size_t nelem, size_t elsize);
|
||||
#endif
|
||||
PyAPI_FUNC(void *) PyObject_Realloc(void *ptr, size_t new_size);
|
||||
PyAPI_FUNC(void) PyObject_Free(void *ptr);
|
||||
|
||||
|
||||
// Deprecated aliases only kept for backward compatibility.
|
||||
// PyObject_Del and PyObject_DEL are defined with no parameter to be able to
|
||||
// use them as function pointers (ex: tp_free = PyObject_Del).
|
||||
#define PyObject_MALLOC PyObject_Malloc
|
||||
#define PyObject_REALLOC PyObject_Realloc
|
||||
#define PyObject_FREE PyObject_Free
|
||||
#define PyObject_Del PyObject_Free
|
||||
#define PyObject_DEL PyObject_Free
|
||||
|
||||
|
||||
/*
|
||||
* Generic object allocator interface
|
||||
* ==================================
|
||||
*/
|
||||
|
||||
/* Functions */
|
||||
PyAPI_FUNC(PyObject *) PyObject_Init(PyObject *, PyTypeObject *);
|
||||
PyAPI_FUNC(PyVarObject *) PyObject_InitVar(PyVarObject *,
|
||||
PyTypeObject *, Py_ssize_t);
|
||||
|
||||
#define PyObject_INIT(op, typeobj) \
|
||||
PyObject_Init(_PyObject_CAST(op), (typeobj))
|
||||
#define PyObject_INIT_VAR(op, typeobj, size) \
|
||||
PyObject_InitVar(_PyVarObject_CAST(op), (typeobj), (size))
|
||||
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyObject_New(PyTypeObject *);
|
||||
PyAPI_FUNC(PyVarObject *) _PyObject_NewVar(PyTypeObject *, Py_ssize_t);
|
||||
|
||||
#define PyObject_New(type, typeobj) ((type *)_PyObject_New(typeobj))
|
||||
|
||||
// Alias to PyObject_New(). In Python 3.8, PyObject_NEW() called directly
|
||||
// PyObject_MALLOC() with _PyObject_SIZE().
|
||||
#define PyObject_NEW(type, typeobj) PyObject_New(type, (typeobj))
|
||||
|
||||
#define PyObject_NewVar(type, typeobj, n) \
|
||||
( (type *) _PyObject_NewVar((typeobj), (n)) )
|
||||
|
||||
// Alias to PyObject_NewVar(). In Python 3.8, PyObject_NEW_VAR() called
|
||||
// directly PyObject_MALLOC() with _PyObject_VAR_SIZE().
|
||||
#define PyObject_NEW_VAR(type, typeobj, n) PyObject_NewVar(type, (typeobj), (n))
|
||||
|
||||
|
||||
/*
|
||||
* Garbage Collection Support
|
||||
* ==========================
|
||||
*/
|
||||
|
||||
/* C equivalent of gc.collect(). */
|
||||
PyAPI_FUNC(Py_ssize_t) PyGC_Collect(void);
|
||||
/* C API for controlling the state of the garbage collector */
|
||||
PyAPI_FUNC(int) PyGC_Enable(void);
|
||||
PyAPI_FUNC(int) PyGC_Disable(void);
|
||||
PyAPI_FUNC(int) PyGC_IsEnabled(void);
|
||||
|
||||
|
||||
#if !defined(Py_LIMITED_API)
|
||||
/* Visit all live GC-capable objects, similar to gc.get_objects(None). The
|
||||
* supplied callback is called on every such object with the void* arg set
|
||||
* to the supplied arg. Returning 0 from the callback ends iteration, returning
|
||||
* 1 allows iteration to continue. Returning any other value may result in
|
||||
* undefined behaviour.
|
||||
*
|
||||
* If new objects are (de)allocated by the callback it is undefined if they
|
||||
* will be visited.
|
||||
|
||||
* Garbage collection is disabled during operation. Explicitly running a
|
||||
* collection in the callback may lead to undefined behaviour e.g. visiting the
|
||||
* same objects multiple times or not at all.
|
||||
*/
|
||||
typedef int (*gcvisitobjects_t)(PyObject*, void*);
|
||||
PyAPI_FUNC(void) PyUnstable_GC_VisitObjects(gcvisitobjects_t callback, void* arg);
|
||||
#endif
|
||||
|
||||
/* Test if a type has a GC head */
|
||||
#define PyType_IS_GC(t) PyType_HasFeature((t), Py_TPFLAGS_HAVE_GC)
|
||||
|
||||
PyAPI_FUNC(PyVarObject *) _PyObject_GC_Resize(PyVarObject *, Py_ssize_t);
|
||||
#define PyObject_GC_Resize(type, op, n) \
|
||||
( (type *) _PyObject_GC_Resize(_PyVarObject_CAST(op), (n)) )
|
||||
|
||||
|
||||
|
||||
PyAPI_FUNC(PyObject *) _PyObject_GC_New(PyTypeObject *);
|
||||
PyAPI_FUNC(PyVarObject *) _PyObject_GC_NewVar(PyTypeObject *, Py_ssize_t);
|
||||
|
||||
/* Tell the GC to track this object.
|
||||
*
|
||||
* See also private _PyObject_GC_TRACK() macro. */
|
||||
PyAPI_FUNC(void) PyObject_GC_Track(void *);
|
||||
|
||||
/* Tell the GC to stop tracking this object.
|
||||
*
|
||||
* See also private _PyObject_GC_UNTRACK() macro. */
|
||||
PyAPI_FUNC(void) PyObject_GC_UnTrack(void *);
|
||||
|
||||
PyAPI_FUNC(void) PyObject_GC_Del(void *);
|
||||
|
||||
#define PyObject_GC_New(type, typeobj) \
|
||||
_Py_CAST(type*, _PyObject_GC_New(typeobj))
|
||||
#define PyObject_GC_NewVar(type, typeobj, n) \
|
||||
_Py_CAST(type*, _PyObject_GC_NewVar((typeobj), (n)))
|
||||
|
||||
PyAPI_FUNC(int) PyObject_GC_IsTracked(PyObject *);
|
||||
PyAPI_FUNC(int) PyObject_GC_IsFinalized(PyObject *);
|
||||
|
||||
/* Utility macro to help write tp_traverse functions.
|
||||
* To use this macro, the tp_traverse function must name its arguments
|
||||
* "visit" and "arg". This is intended to keep tp_traverse functions
|
||||
* looking as much alike as possible.
|
||||
*/
|
||||
#define Py_VISIT(op) \
|
||||
do { \
|
||||
if (op) { \
|
||||
int vret = visit(_PyObject_CAST(op), arg); \
|
||||
if (vret) \
|
||||
return vret; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
# define Py_CPYTHON_OBJIMPL_H
|
||||
# include "cpython/objimpl.h"
|
||||
# undef Py_CPYTHON_OBJIMPL_H
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_OBJIMPL_H */
|
||||
271
crypto/shamirs_secret_sharing/include/opcode.h
Normal file
271
crypto/shamirs_secret_sharing/include/opcode.h
Normal file
@@ -0,0 +1,271 @@
|
||||
// Auto-generated by Tools/build/generate_opcode_h.py from Lib/opcode.py
|
||||
|
||||
#ifndef Py_OPCODE_H
|
||||
#define Py_OPCODE_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Instruction opcodes for compiled code */
|
||||
#define CACHE 0
|
||||
#define POP_TOP 1
|
||||
#define PUSH_NULL 2
|
||||
#define INTERPRETER_EXIT 3
|
||||
#define END_FOR 4
|
||||
#define END_SEND 5
|
||||
#define NOP 9
|
||||
#define UNARY_NEGATIVE 11
|
||||
#define UNARY_NOT 12
|
||||
#define UNARY_INVERT 15
|
||||
#define RESERVED 17
|
||||
#define BINARY_SUBSCR 25
|
||||
#define BINARY_SLICE 26
|
||||
#define STORE_SLICE 27
|
||||
#define GET_LEN 30
|
||||
#define MATCH_MAPPING 31
|
||||
#define MATCH_SEQUENCE 32
|
||||
#define MATCH_KEYS 33
|
||||
#define PUSH_EXC_INFO 35
|
||||
#define CHECK_EXC_MATCH 36
|
||||
#define CHECK_EG_MATCH 37
|
||||
#define WITH_EXCEPT_START 49
|
||||
#define GET_AITER 50
|
||||
#define GET_ANEXT 51
|
||||
#define BEFORE_ASYNC_WITH 52
|
||||
#define BEFORE_WITH 53
|
||||
#define END_ASYNC_FOR 54
|
||||
#define CLEANUP_THROW 55
|
||||
#define STORE_SUBSCR 60
|
||||
#define DELETE_SUBSCR 61
|
||||
#define GET_ITER 68
|
||||
#define GET_YIELD_FROM_ITER 69
|
||||
#define LOAD_BUILD_CLASS 71
|
||||
#define LOAD_ASSERTION_ERROR 74
|
||||
#define RETURN_GENERATOR 75
|
||||
#define RETURN_VALUE 83
|
||||
#define SETUP_ANNOTATIONS 85
|
||||
#define LOAD_LOCALS 87
|
||||
#define POP_EXCEPT 89
|
||||
#define HAVE_ARGUMENT 90
|
||||
#define STORE_NAME 90
|
||||
#define DELETE_NAME 91
|
||||
#define UNPACK_SEQUENCE 92
|
||||
#define FOR_ITER 93
|
||||
#define UNPACK_EX 94
|
||||
#define STORE_ATTR 95
|
||||
#define DELETE_ATTR 96
|
||||
#define STORE_GLOBAL 97
|
||||
#define DELETE_GLOBAL 98
|
||||
#define SWAP 99
|
||||
#define LOAD_CONST 100
|
||||
#define LOAD_NAME 101
|
||||
#define BUILD_TUPLE 102
|
||||
#define BUILD_LIST 103
|
||||
#define BUILD_SET 104
|
||||
#define BUILD_MAP 105
|
||||
#define LOAD_ATTR 106
|
||||
#define COMPARE_OP 107
|
||||
#define IMPORT_NAME 108
|
||||
#define IMPORT_FROM 109
|
||||
#define JUMP_FORWARD 110
|
||||
#define POP_JUMP_IF_FALSE 114
|
||||
#define POP_JUMP_IF_TRUE 115
|
||||
#define LOAD_GLOBAL 116
|
||||
#define IS_OP 117
|
||||
#define CONTAINS_OP 118
|
||||
#define RERAISE 119
|
||||
#define COPY 120
|
||||
#define RETURN_CONST 121
|
||||
#define BINARY_OP 122
|
||||
#define SEND 123
|
||||
#define LOAD_FAST 124
|
||||
#define STORE_FAST 125
|
||||
#define DELETE_FAST 126
|
||||
#define LOAD_FAST_CHECK 127
|
||||
#define POP_JUMP_IF_NOT_NONE 128
|
||||
#define POP_JUMP_IF_NONE 129
|
||||
#define RAISE_VARARGS 130
|
||||
#define GET_AWAITABLE 131
|
||||
#define MAKE_FUNCTION 132
|
||||
#define BUILD_SLICE 133
|
||||
#define JUMP_BACKWARD_NO_INTERRUPT 134
|
||||
#define MAKE_CELL 135
|
||||
#define LOAD_CLOSURE 136
|
||||
#define LOAD_DEREF 137
|
||||
#define STORE_DEREF 138
|
||||
#define DELETE_DEREF 139
|
||||
#define JUMP_BACKWARD 140
|
||||
#define LOAD_SUPER_ATTR 141
|
||||
#define CALL_FUNCTION_EX 142
|
||||
#define LOAD_FAST_AND_CLEAR 143
|
||||
#define EXTENDED_ARG 144
|
||||
#define LIST_APPEND 145
|
||||
#define SET_ADD 146
|
||||
#define MAP_ADD 147
|
||||
#define COPY_FREE_VARS 149
|
||||
#define YIELD_VALUE 150
|
||||
#define RESUME 151
|
||||
#define MATCH_CLASS 152
|
||||
#define FORMAT_VALUE 155
|
||||
#define BUILD_CONST_KEY_MAP 156
|
||||
#define BUILD_STRING 157
|
||||
#define LIST_EXTEND 162
|
||||
#define SET_UPDATE 163
|
||||
#define DICT_MERGE 164
|
||||
#define DICT_UPDATE 165
|
||||
#define CALL 171
|
||||
#define KW_NAMES 172
|
||||
#define CALL_INTRINSIC_1 173
|
||||
#define CALL_INTRINSIC_2 174
|
||||
#define LOAD_FROM_DICT_OR_GLOBALS 175
|
||||
#define LOAD_FROM_DICT_OR_DEREF 176
|
||||
#define MIN_INSTRUMENTED_OPCODE 237
|
||||
#define INSTRUMENTED_LOAD_SUPER_ATTR 237
|
||||
#define INSTRUMENTED_POP_JUMP_IF_NONE 238
|
||||
#define INSTRUMENTED_POP_JUMP_IF_NOT_NONE 239
|
||||
#define INSTRUMENTED_RESUME 240
|
||||
#define INSTRUMENTED_CALL 241
|
||||
#define INSTRUMENTED_RETURN_VALUE 242
|
||||
#define INSTRUMENTED_YIELD_VALUE 243
|
||||
#define INSTRUMENTED_CALL_FUNCTION_EX 244
|
||||
#define INSTRUMENTED_JUMP_FORWARD 245
|
||||
#define INSTRUMENTED_JUMP_BACKWARD 246
|
||||
#define INSTRUMENTED_RETURN_CONST 247
|
||||
#define INSTRUMENTED_FOR_ITER 248
|
||||
#define INSTRUMENTED_POP_JUMP_IF_FALSE 249
|
||||
#define INSTRUMENTED_POP_JUMP_IF_TRUE 250
|
||||
#define INSTRUMENTED_END_FOR 251
|
||||
#define INSTRUMENTED_END_SEND 252
|
||||
#define INSTRUMENTED_INSTRUCTION 253
|
||||
#define INSTRUMENTED_LINE 254
|
||||
#define MIN_PSEUDO_OPCODE 256
|
||||
#define SETUP_FINALLY 256
|
||||
#define SETUP_CLEANUP 257
|
||||
#define SETUP_WITH 258
|
||||
#define POP_BLOCK 259
|
||||
#define JUMP 260
|
||||
#define JUMP_NO_INTERRUPT 261
|
||||
#define LOAD_METHOD 262
|
||||
#define LOAD_SUPER_METHOD 263
|
||||
#define LOAD_ZERO_SUPER_METHOD 264
|
||||
#define LOAD_ZERO_SUPER_ATTR 265
|
||||
#define STORE_FAST_MAYBE_NULL 266
|
||||
#define MAX_PSEUDO_OPCODE 266
|
||||
#define BINARY_OP_ADD_FLOAT 6
|
||||
#define BINARY_OP_ADD_INT 7
|
||||
#define BINARY_OP_ADD_UNICODE 8
|
||||
#define BINARY_OP_INPLACE_ADD_UNICODE 10
|
||||
#define BINARY_OP_MULTIPLY_FLOAT 13
|
||||
#define BINARY_OP_MULTIPLY_INT 14
|
||||
#define BINARY_OP_SUBTRACT_FLOAT 16
|
||||
#define BINARY_OP_SUBTRACT_INT 18
|
||||
#define BINARY_SUBSCR_DICT 19
|
||||
#define BINARY_SUBSCR_GETITEM 20
|
||||
#define BINARY_SUBSCR_LIST_INT 21
|
||||
#define BINARY_SUBSCR_TUPLE_INT 22
|
||||
#define CALL_PY_EXACT_ARGS 23
|
||||
#define CALL_PY_WITH_DEFAULTS 24
|
||||
#define CALL_BOUND_METHOD_EXACT_ARGS 28
|
||||
#define CALL_BUILTIN_CLASS 29
|
||||
#define CALL_BUILTIN_FAST_WITH_KEYWORDS 34
|
||||
#define CALL_METHOD_DESCRIPTOR_FAST_WITH_KEYWORDS 38
|
||||
#define CALL_NO_KW_BUILTIN_FAST 39
|
||||
#define CALL_NO_KW_BUILTIN_O 40
|
||||
#define CALL_NO_KW_ISINSTANCE 41
|
||||
#define CALL_NO_KW_LEN 42
|
||||
#define CALL_NO_KW_LIST_APPEND 43
|
||||
#define CALL_NO_KW_METHOD_DESCRIPTOR_FAST 44
|
||||
#define CALL_NO_KW_METHOD_DESCRIPTOR_NOARGS 45
|
||||
#define CALL_NO_KW_METHOD_DESCRIPTOR_O 46
|
||||
#define CALL_NO_KW_STR_1 47
|
||||
#define CALL_NO_KW_TUPLE_1 48
|
||||
#define CALL_NO_KW_TYPE_1 56
|
||||
#define COMPARE_OP_FLOAT 57
|
||||
#define COMPARE_OP_INT 58
|
||||
#define COMPARE_OP_STR 59
|
||||
#define FOR_ITER_LIST 62
|
||||
#define FOR_ITER_TUPLE 63
|
||||
#define FOR_ITER_RANGE 64
|
||||
#define FOR_ITER_GEN 65
|
||||
#define LOAD_SUPER_ATTR_ATTR 66
|
||||
#define LOAD_SUPER_ATTR_METHOD 67
|
||||
#define LOAD_ATTR_CLASS 70
|
||||
#define LOAD_ATTR_GETATTRIBUTE_OVERRIDDEN 72
|
||||
#define LOAD_ATTR_INSTANCE_VALUE 73
|
||||
#define LOAD_ATTR_MODULE 76
|
||||
#define LOAD_ATTR_PROPERTY 77
|
||||
#define LOAD_ATTR_SLOT 78
|
||||
#define LOAD_ATTR_WITH_HINT 79
|
||||
#define LOAD_ATTR_METHOD_LAZY_DICT 80
|
||||
#define LOAD_ATTR_METHOD_NO_DICT 81
|
||||
#define LOAD_ATTR_METHOD_WITH_VALUES 82
|
||||
#define LOAD_CONST__LOAD_FAST 84
|
||||
#define LOAD_FAST__LOAD_CONST 86
|
||||
#define LOAD_FAST__LOAD_FAST 88
|
||||
#define LOAD_GLOBAL_BUILTIN 111
|
||||
#define LOAD_GLOBAL_MODULE 112
|
||||
#define STORE_ATTR_INSTANCE_VALUE 113
|
||||
#define STORE_ATTR_SLOT 148
|
||||
#define STORE_ATTR_WITH_HINT 153
|
||||
#define STORE_FAST__LOAD_FAST 154
|
||||
#define STORE_FAST__STORE_FAST 158
|
||||
#define STORE_SUBSCR_DICT 159
|
||||
#define STORE_SUBSCR_LIST_INT 160
|
||||
#define UNPACK_SEQUENCE_LIST 161
|
||||
#define UNPACK_SEQUENCE_TUPLE 166
|
||||
#define UNPACK_SEQUENCE_TWO_TUPLE 167
|
||||
#define SEND_GEN 168
|
||||
|
||||
#define HAS_ARG(op) ((((op) >= HAVE_ARGUMENT) && (!IS_PSEUDO_OPCODE(op)))\
|
||||
|| ((op) == JUMP) \
|
||||
|| ((op) == JUMP_NO_INTERRUPT) \
|
||||
|| ((op) == LOAD_METHOD) \
|
||||
|| ((op) == LOAD_SUPER_METHOD) \
|
||||
|| ((op) == LOAD_ZERO_SUPER_METHOD) \
|
||||
|| ((op) == LOAD_ZERO_SUPER_ATTR) \
|
||||
|| ((op) == STORE_FAST_MAYBE_NULL) \
|
||||
)
|
||||
|
||||
#define HAS_CONST(op) (false\
|
||||
|| ((op) == LOAD_CONST) \
|
||||
|| ((op) == RETURN_CONST) \
|
||||
|| ((op) == KW_NAMES) \
|
||||
)
|
||||
|
||||
#define NB_ADD 0
|
||||
#define NB_AND 1
|
||||
#define NB_FLOOR_DIVIDE 2
|
||||
#define NB_LSHIFT 3
|
||||
#define NB_MATRIX_MULTIPLY 4
|
||||
#define NB_MULTIPLY 5
|
||||
#define NB_REMAINDER 6
|
||||
#define NB_OR 7
|
||||
#define NB_POWER 8
|
||||
#define NB_RSHIFT 9
|
||||
#define NB_SUBTRACT 10
|
||||
#define NB_TRUE_DIVIDE 11
|
||||
#define NB_XOR 12
|
||||
#define NB_INPLACE_ADD 13
|
||||
#define NB_INPLACE_AND 14
|
||||
#define NB_INPLACE_FLOOR_DIVIDE 15
|
||||
#define NB_INPLACE_LSHIFT 16
|
||||
#define NB_INPLACE_MATRIX_MULTIPLY 17
|
||||
#define NB_INPLACE_MULTIPLY 18
|
||||
#define NB_INPLACE_REMAINDER 19
|
||||
#define NB_INPLACE_OR 20
|
||||
#define NB_INPLACE_POWER 21
|
||||
#define NB_INPLACE_RSHIFT 22
|
||||
#define NB_INPLACE_SUBTRACT 23
|
||||
#define NB_INPLACE_TRUE_DIVIDE 24
|
||||
#define NB_INPLACE_XOR 25
|
||||
|
||||
/* Defined in Lib/opcode.py */
|
||||
#define ENABLE_SPECIALIZATION 1
|
||||
|
||||
#define IS_PSEUDO_OPCODE(op) (((op) >= MIN_PSEUDO_OPCODE) && ((op) <= MAX_PSEUDO_OPCODE))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_OPCODE_H */
|
||||
51
crypto/shamirs_secret_sharing/include/osdefs.h
Normal file
51
crypto/shamirs_secret_sharing/include/osdefs.h
Normal file
@@ -0,0 +1,51 @@
|
||||
#ifndef Py_OSDEFS_H
|
||||
#define Py_OSDEFS_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Operating system dependencies */
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
#define SEP L'\\'
|
||||
#define ALTSEP L'/'
|
||||
#define MAXPATHLEN 256
|
||||
#define DELIM L';'
|
||||
#endif
|
||||
|
||||
#ifdef __VXWORKS__
|
||||
#define DELIM L';'
|
||||
#endif
|
||||
|
||||
/* Filename separator */
|
||||
#ifndef SEP
|
||||
#define SEP L'/'
|
||||
#endif
|
||||
|
||||
/* Max pathname length */
|
||||
#ifdef __hpux
|
||||
#include <sys/param.h>
|
||||
#include <limits.h>
|
||||
#ifndef PATH_MAX
|
||||
#define PATH_MAX MAXPATHLEN
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
#if defined(PATH_MAX) && PATH_MAX > 1024
|
||||
#define MAXPATHLEN PATH_MAX
|
||||
#else
|
||||
#define MAXPATHLEN 1024
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Search path entry delimiter */
|
||||
#ifndef DELIM
|
||||
#define DELIM L':'
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_OSDEFS_H */
|
||||
17
crypto/shamirs_secret_sharing/include/osmodule.h
Normal file
17
crypto/shamirs_secret_sharing/include/osmodule.h
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
/* os module interface */
|
||||
|
||||
#ifndef Py_OSMODULE_H
|
||||
#define Py_OSMODULE_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000
|
||||
PyAPI_FUNC(PyObject *) PyOS_FSPath(PyObject *path);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_OSMODULE_H */
|
||||
35
crypto/shamirs_secret_sharing/include/patchlevel.h
Normal file
35
crypto/shamirs_secret_sharing/include/patchlevel.h
Normal file
@@ -0,0 +1,35 @@
|
||||
|
||||
/* Python version identification scheme.
|
||||
|
||||
When the major or minor version changes, the VERSION variable in
|
||||
configure.ac must also be changed.
|
||||
|
||||
There is also (independent) API version information in modsupport.h.
|
||||
*/
|
||||
|
||||
/* Values for PY_RELEASE_LEVEL */
|
||||
#define PY_RELEASE_LEVEL_ALPHA 0xA
|
||||
#define PY_RELEASE_LEVEL_BETA 0xB
|
||||
#define PY_RELEASE_LEVEL_GAMMA 0xC /* For release candidates */
|
||||
#define PY_RELEASE_LEVEL_FINAL 0xF /* Serial should be 0 here */
|
||||
/* Higher for patch releases */
|
||||
|
||||
/* Version parsed out into numeric values */
|
||||
/*--start constants--*/
|
||||
#define PY_MAJOR_VERSION 3
|
||||
#define PY_MINOR_VERSION 12
|
||||
#define PY_MICRO_VERSION 8
|
||||
#define PY_RELEASE_LEVEL PY_RELEASE_LEVEL_FINAL
|
||||
#define PY_RELEASE_SERIAL 0
|
||||
|
||||
/* Version as a string */
|
||||
#define PY_VERSION "3.12.8"
|
||||
/*--end constants--*/
|
||||
|
||||
/* Version as a single 4-byte hex number, e.g. 0x010502B2 == 1.5.2b2.
|
||||
Use this for numeric comparisons, e.g. #if PY_VERSION_HEX >= ... */
|
||||
#define PY_VERSION_HEX ((PY_MAJOR_VERSION << 24) | \
|
||||
(PY_MINOR_VERSION << 16) | \
|
||||
(PY_MICRO_VERSION << 8) | \
|
||||
(PY_RELEASE_LEVEL << 4) | \
|
||||
(PY_RELEASE_SERIAL << 0))
|
||||
99
crypto/shamirs_secret_sharing/include/py_curses.h
Normal file
99
crypto/shamirs_secret_sharing/include/py_curses.h
Normal file
@@ -0,0 +1,99 @@
|
||||
|
||||
#ifndef Py_CURSES_H
|
||||
#define Py_CURSES_H
|
||||
|
||||
#ifdef __APPLE__
|
||||
/*
|
||||
** On Mac OS X 10.2 [n]curses.h and stdlib.h use different guards
|
||||
** against multiple definition of wchar_t.
|
||||
*/
|
||||
#ifdef _BSD_WCHAR_T_DEFINED_
|
||||
#define _WCHAR_T
|
||||
#endif
|
||||
#endif /* __APPLE__ */
|
||||
|
||||
/* On FreeBSD, [n]curses.h and stdlib.h/wchar.h use different guards
|
||||
against multiple definition of wchar_t and wint_t. */
|
||||
#if defined(__FreeBSD__) && defined(_XOPEN_SOURCE_EXTENDED)
|
||||
# ifndef __wchar_t
|
||||
# define __wchar_t
|
||||
# endif
|
||||
# ifndef __wint_t
|
||||
# define __wint_t
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_CURSES_IS_PAD) && defined(WINDOW_HAS_FLAGS)
|
||||
/* The following definition is necessary for ncurses 5.7; without it,
|
||||
some of [n]curses.h set NCURSES_OPAQUE to 1, and then Python
|
||||
can't get at the WINDOW flags field. */
|
||||
#define NCURSES_OPAQUE 0
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NCURSES_H
|
||||
#include <ncurses.h>
|
||||
#else
|
||||
#include <curses.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NCURSES_H
|
||||
/* configure was checking <curses.h>, but we will
|
||||
use <ncurses.h>, which has some or all these features. */
|
||||
#if !defined(WINDOW_HAS_FLAGS) && !(NCURSES_OPAQUE+0)
|
||||
#define WINDOW_HAS_FLAGS 1
|
||||
#endif
|
||||
#if !defined(HAVE_CURSES_IS_PAD) && NCURSES_VERSION_PATCH+0 >= 20090906
|
||||
#define HAVE_CURSES_IS_PAD 1
|
||||
#endif
|
||||
#ifndef MVWDELCH_IS_EXPRESSION
|
||||
#define MVWDELCH_IS_EXPRESSION 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define PyCurses_API_pointers 4
|
||||
|
||||
/* Type declarations */
|
||||
|
||||
typedef struct {
|
||||
PyObject_HEAD
|
||||
WINDOW *win;
|
||||
char *encoding;
|
||||
} PyCursesWindowObject;
|
||||
|
||||
#define PyCursesWindow_Check(v) Py_IS_TYPE((v), &PyCursesWindow_Type)
|
||||
|
||||
#define PyCurses_CAPSULE_NAME "_curses._C_API"
|
||||
|
||||
|
||||
#ifdef CURSES_MODULE
|
||||
/* This section is used when compiling _cursesmodule.c */
|
||||
|
||||
#else
|
||||
/* This section is used in modules that use the _cursesmodule API */
|
||||
|
||||
static void **PyCurses_API;
|
||||
|
||||
#define PyCursesWindow_Type (*_PyType_CAST(PyCurses_API[0]))
|
||||
#define PyCursesSetupTermCalled {if (! ((int (*)(void))PyCurses_API[1]) () ) return NULL;}
|
||||
#define PyCursesInitialised {if (! ((int (*)(void))PyCurses_API[2]) () ) return NULL;}
|
||||
#define PyCursesInitialisedColor {if (! ((int (*)(void))PyCurses_API[3]) () ) return NULL;}
|
||||
|
||||
#define import_curses() \
|
||||
PyCurses_API = (void **)PyCapsule_Import(PyCurses_CAPSULE_NAME, 1);
|
||||
|
||||
#endif
|
||||
|
||||
/* general error messages */
|
||||
static const char catchall_ERR[] = "curses function returned ERR";
|
||||
static const char catchall_NULL[] = "curses function returned NULL";
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !defined(Py_CURSES_H) */
|
||||
|
||||
145
crypto/shamirs_secret_sharing/include/pybuffer.h
Normal file
145
crypto/shamirs_secret_sharing/include/pybuffer.h
Normal file
@@ -0,0 +1,145 @@
|
||||
/* Public Py_buffer API */
|
||||
|
||||
#ifndef Py_BUFFER_H
|
||||
#define Py_BUFFER_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030b0000
|
||||
|
||||
/* === New Buffer API ============================================
|
||||
* Limited API and stable ABI since Python 3.11
|
||||
*
|
||||
* Py_buffer struct layout and size is now part of the stable abi3. The
|
||||
* struct layout and size must not be changed in any way, as it would
|
||||
* break the ABI.
|
||||
*
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
void *buf;
|
||||
PyObject *obj; /* owned reference */
|
||||
Py_ssize_t len;
|
||||
Py_ssize_t itemsize; /* This is Py_ssize_t so it can be
|
||||
pointed to by strides in simple case.*/
|
||||
int readonly;
|
||||
int ndim;
|
||||
char *format;
|
||||
Py_ssize_t *shape;
|
||||
Py_ssize_t *strides;
|
||||
Py_ssize_t *suboffsets;
|
||||
void *internal;
|
||||
} Py_buffer;
|
||||
|
||||
typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
|
||||
typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
|
||||
|
||||
/* Return 1 if the getbuffer function is available, otherwise return 0. */
|
||||
PyAPI_FUNC(int) PyObject_CheckBuffer(PyObject *obj);
|
||||
|
||||
/* This is a C-API version of the getbuffer function call. It checks
|
||||
to make sure object has the required function pointer and issues the
|
||||
call.
|
||||
|
||||
Returns -1 and raises an error on failure and returns 0 on success. */
|
||||
PyAPI_FUNC(int) PyObject_GetBuffer(PyObject *obj, Py_buffer *view,
|
||||
int flags);
|
||||
|
||||
/* Get the memory area pointed to by the indices for the buffer given.
|
||||
Note that view->ndim is the assumed size of indices. */
|
||||
PyAPI_FUNC(void *) PyBuffer_GetPointer(const Py_buffer *view, const Py_ssize_t *indices);
|
||||
|
||||
/* Return the implied itemsize of the data-format area from a
|
||||
struct-style description. */
|
||||
PyAPI_FUNC(Py_ssize_t) PyBuffer_SizeFromFormat(const char *format);
|
||||
|
||||
/* Implementation in memoryobject.c */
|
||||
PyAPI_FUNC(int) PyBuffer_ToContiguous(void *buf, const Py_buffer *view,
|
||||
Py_ssize_t len, char order);
|
||||
|
||||
PyAPI_FUNC(int) PyBuffer_FromContiguous(const Py_buffer *view, const void *buf,
|
||||
Py_ssize_t len, char order);
|
||||
|
||||
/* Copy len bytes of data from the contiguous chunk of memory
|
||||
pointed to by buf into the buffer exported by obj. Return
|
||||
0 on success and return -1 and raise a PyBuffer_Error on
|
||||
error (i.e. the object does not have a buffer interface or
|
||||
it is not working).
|
||||
|
||||
If fort is 'F', then if the object is multi-dimensional,
|
||||
then the data will be copied into the array in
|
||||
Fortran-style (first dimension varies the fastest). If
|
||||
fort is 'C', then the data will be copied into the array
|
||||
in C-style (last dimension varies the fastest). If fort
|
||||
is 'A', then it does not matter and the copy will be made
|
||||
in whatever way is more efficient. */
|
||||
PyAPI_FUNC(int) PyObject_CopyData(PyObject *dest, PyObject *src);
|
||||
|
||||
/* Copy the data from the src buffer to the buffer of destination. */
|
||||
PyAPI_FUNC(int) PyBuffer_IsContiguous(const Py_buffer *view, char fort);
|
||||
|
||||
/*Fill the strides array with byte-strides of a contiguous
|
||||
(Fortran-style if fort is 'F' or C-style otherwise)
|
||||
array of the given shape with the given number of bytes
|
||||
per element. */
|
||||
PyAPI_FUNC(void) PyBuffer_FillContiguousStrides(int ndims,
|
||||
Py_ssize_t *shape,
|
||||
Py_ssize_t *strides,
|
||||
int itemsize,
|
||||
char fort);
|
||||
|
||||
/* Fills in a buffer-info structure correctly for an exporter
|
||||
that can only share a contiguous chunk of memory of
|
||||
"unsigned bytes" of the given length.
|
||||
|
||||
Returns 0 on success and -1 (with raising an error) on error. */
|
||||
PyAPI_FUNC(int) PyBuffer_FillInfo(Py_buffer *view, PyObject *o, void *buf,
|
||||
Py_ssize_t len, int readonly,
|
||||
int flags);
|
||||
|
||||
/* Releases a Py_buffer obtained from getbuffer ParseTuple's "s*". */
|
||||
PyAPI_FUNC(void) PyBuffer_Release(Py_buffer *view);
|
||||
|
||||
/* Maximum number of dimensions */
|
||||
#define PyBUF_MAX_NDIM 64
|
||||
|
||||
/* Flags for getting buffers. Keep these in sync with inspect.BufferFlags. */
|
||||
#define PyBUF_SIMPLE 0
|
||||
#define PyBUF_WRITABLE 0x0001
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
/* we used to include an E, backwards compatible alias */
|
||||
#define PyBUF_WRITEABLE PyBUF_WRITABLE
|
||||
#endif
|
||||
|
||||
#define PyBUF_FORMAT 0x0004
|
||||
#define PyBUF_ND 0x0008
|
||||
#define PyBUF_STRIDES (0x0010 | PyBUF_ND)
|
||||
#define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
|
||||
#define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
|
||||
#define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
|
||||
#define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
|
||||
|
||||
#define PyBUF_CONTIG (PyBUF_ND | PyBUF_WRITABLE)
|
||||
#define PyBUF_CONTIG_RO (PyBUF_ND)
|
||||
|
||||
#define PyBUF_STRIDED (PyBUF_STRIDES | PyBUF_WRITABLE)
|
||||
#define PyBUF_STRIDED_RO (PyBUF_STRIDES)
|
||||
|
||||
#define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_WRITABLE | PyBUF_FORMAT)
|
||||
#define PyBUF_RECORDS_RO (PyBUF_STRIDES | PyBUF_FORMAT)
|
||||
|
||||
#define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_WRITABLE | PyBUF_FORMAT)
|
||||
#define PyBUF_FULL_RO (PyBUF_INDIRECT | PyBUF_FORMAT)
|
||||
|
||||
|
||||
#define PyBUF_READ 0x100
|
||||
#define PyBUF_WRITE 0x200
|
||||
|
||||
#endif /* !Py_LIMITED_API || Py_LIMITED_API >= 3.11 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* Py_BUFFER_H */
|
||||
59
crypto/shamirs_secret_sharing/include/pycapsule.h
Normal file
59
crypto/shamirs_secret_sharing/include/pycapsule.h
Normal file
@@ -0,0 +1,59 @@
|
||||
|
||||
/* Capsule objects let you wrap a C "void *" pointer in a Python
|
||||
object. They're a way of passing data through the Python interpreter
|
||||
without creating your own custom type.
|
||||
|
||||
Capsules are used for communication between extension modules.
|
||||
They provide a way for an extension module to export a C interface
|
||||
to other extension modules, so that extension modules can use the
|
||||
Python import mechanism to link to one another.
|
||||
|
||||
For more information, please see "c-api/capsule.html" in the
|
||||
documentation.
|
||||
*/
|
||||
|
||||
#ifndef Py_CAPSULE_H
|
||||
#define Py_CAPSULE_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
PyAPI_DATA(PyTypeObject) PyCapsule_Type;
|
||||
|
||||
typedef void (*PyCapsule_Destructor)(PyObject *);
|
||||
|
||||
#define PyCapsule_CheckExact(op) Py_IS_TYPE((op), &PyCapsule_Type)
|
||||
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyCapsule_New(
|
||||
void *pointer,
|
||||
const char *name,
|
||||
PyCapsule_Destructor destructor);
|
||||
|
||||
PyAPI_FUNC(void *) PyCapsule_GetPointer(PyObject *capsule, const char *name);
|
||||
|
||||
PyAPI_FUNC(PyCapsule_Destructor) PyCapsule_GetDestructor(PyObject *capsule);
|
||||
|
||||
PyAPI_FUNC(const char *) PyCapsule_GetName(PyObject *capsule);
|
||||
|
||||
PyAPI_FUNC(void *) PyCapsule_GetContext(PyObject *capsule);
|
||||
|
||||
PyAPI_FUNC(int) PyCapsule_IsValid(PyObject *capsule, const char *name);
|
||||
|
||||
PyAPI_FUNC(int) PyCapsule_SetPointer(PyObject *capsule, void *pointer);
|
||||
|
||||
PyAPI_FUNC(int) PyCapsule_SetDestructor(PyObject *capsule, PyCapsule_Destructor destructor);
|
||||
|
||||
PyAPI_FUNC(int) PyCapsule_SetName(PyObject *capsule, const char *name);
|
||||
|
||||
PyAPI_FUNC(int) PyCapsule_SetContext(PyObject *capsule, void *context);
|
||||
|
||||
PyAPI_FUNC(void *) PyCapsule_Import(
|
||||
const char *name, /* UTF-8 encoded string */
|
||||
int no_block);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_CAPSULE_H */
|
||||
742
crypto/shamirs_secret_sharing/include/pyconfig.h
Normal file
742
crypto/shamirs_secret_sharing/include/pyconfig.h
Normal file
@@ -0,0 +1,742 @@
|
||||
#ifndef Py_CONFIG_H
|
||||
#define Py_CONFIG_H
|
||||
|
||||
/* pyconfig.h. NOT Generated automatically by configure.
|
||||
|
||||
This is a manually maintained version used for the Watcom,
|
||||
Borland and Microsoft Visual C++ compilers. It is a
|
||||
standard part of the Python distribution.
|
||||
|
||||
WINDOWS DEFINES:
|
||||
The code specific to Windows should be wrapped around one of
|
||||
the following #defines
|
||||
|
||||
MS_WIN64 - Code specific to the MS Win64 API
|
||||
MS_WIN32 - Code specific to the MS Win32 (and Win64) API (obsolete, this covers all supported APIs)
|
||||
MS_WINDOWS - Code specific to Windows, but all versions.
|
||||
Py_ENABLE_SHARED - Code if the Python core is built as a DLL.
|
||||
|
||||
Also note that neither "_M_IX86" or "_MSC_VER" should be used for
|
||||
any purpose other than "Windows Intel x86 specific" and "Microsoft
|
||||
compiler specific". Therefore, these should be very rare.
|
||||
|
||||
|
||||
NOTE: The following symbols are deprecated:
|
||||
NT, USE_DL_EXPORT, USE_DL_IMPORT, DL_EXPORT, DL_IMPORT
|
||||
MS_CORE_DLL.
|
||||
|
||||
WIN32 is still required for the locale module.
|
||||
|
||||
*/
|
||||
|
||||
/* Deprecated USE_DL_EXPORT macro - please use Py_BUILD_CORE */
|
||||
#ifdef USE_DL_EXPORT
|
||||
# define Py_BUILD_CORE
|
||||
#endif /* USE_DL_EXPORT */
|
||||
|
||||
/* Visual Studio 2005 introduces deprecation warnings for
|
||||
"insecure" and POSIX functions. The insecure functions should
|
||||
be replaced by *_s versions (according to Microsoft); the
|
||||
POSIX functions by _* versions (which, according to Microsoft,
|
||||
would be ISO C conforming). Neither renaming is feasible, so
|
||||
we just silence the warnings. */
|
||||
|
||||
#ifndef _CRT_SECURE_NO_DEPRECATE
|
||||
#define _CRT_SECURE_NO_DEPRECATE 1
|
||||
#endif
|
||||
#ifndef _CRT_NONSTDC_NO_DEPRECATE
|
||||
#define _CRT_NONSTDC_NO_DEPRECATE 1
|
||||
#endif
|
||||
|
||||
#define HAVE_IO_H
|
||||
#define HAVE_SYS_UTIME_H
|
||||
#define HAVE_TEMPNAM
|
||||
#define HAVE_TMPFILE
|
||||
#define HAVE_TMPNAM
|
||||
#define HAVE_CLOCK
|
||||
#define HAVE_STRERROR
|
||||
|
||||
#include <io.h>
|
||||
|
||||
#define HAVE_STRFTIME
|
||||
#define DONT_HAVE_SIG_ALARM
|
||||
#define DONT_HAVE_SIG_PAUSE
|
||||
#define LONG_BIT 32
|
||||
#define WORD_BIT 32
|
||||
|
||||
#define MS_WIN32 /* only support win32 and greater. */
|
||||
#define MS_WINDOWS
|
||||
#define NT_THREADS
|
||||
#define WITH_THREAD
|
||||
#ifndef NETSCAPE_PI
|
||||
#define USE_SOCKET
|
||||
#endif
|
||||
|
||||
#if defined(Py_BUILD_CORE) || defined(Py_BUILD_CORE_BUILTIN) || defined(Py_BUILD_CORE_MODULE)
|
||||
#include <winapifamily.h>
|
||||
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
|
||||
#define MS_WINDOWS_DESKTOP
|
||||
#endif
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
|
||||
#define MS_WINDOWS_APP
|
||||
#endif
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_SYSTEM)
|
||||
#define MS_WINDOWS_SYSTEM
|
||||
#endif
|
||||
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_GAMES)
|
||||
#define MS_WINDOWS_GAMES
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you support windows console io */
|
||||
#if defined(MS_WINDOWS_DESKTOP) || defined(MS_WINDOWS_APP) || defined(MS_WINDOWS_SYSTEM)
|
||||
#define HAVE_WINDOWS_CONSOLE_IO 1
|
||||
#endif
|
||||
#endif /* Py_BUILD_CORE || Py_BUILD_CORE_BUILTIN || Py_BUILD_CORE_MODULE */
|
||||
|
||||
/* Compiler specific defines */
|
||||
|
||||
/* ------------------------------------------------------------------------*/
|
||||
/* Microsoft C defines _MSC_VER, as does clang-cl.exe */
|
||||
#ifdef _MSC_VER
|
||||
|
||||
/* We want COMPILER to expand to a string containing _MSC_VER's *value*.
|
||||
* This is horridly tricky, because the stringization operator only works
|
||||
* on macro arguments, and doesn't evaluate macros passed *as* arguments.
|
||||
*/
|
||||
#define _Py_PASTE_VERSION(SUFFIX) \
|
||||
("[MSC v." _Py_STRINGIZE(_MSC_VER) " " SUFFIX "]")
|
||||
/* e.g., this produces, after compile-time string catenation,
|
||||
* ("[MSC v.1900 64 bit (Intel)]")
|
||||
*
|
||||
* _Py_STRINGIZE(_MSC_VER) expands to
|
||||
* _Py_STRINGIZE1(_MSC_VER) and this second macro call is scanned
|
||||
* again for macros and so further expands to
|
||||
* _Py_STRINGIZE1(1900) which then expands to
|
||||
* "1900"
|
||||
*/
|
||||
#define _Py_STRINGIZE(X) _Py_STRINGIZE1(X)
|
||||
#define _Py_STRINGIZE1(X) #X
|
||||
|
||||
/* MSVC defines _WINxx to differentiate the windows platform types
|
||||
|
||||
Note that for compatibility reasons _WIN32 is defined on Win32
|
||||
*and* on Win64. For the same reasons, in Python, MS_WIN32 is
|
||||
defined on Win32 *and* Win64. Win32 only code must therefore be
|
||||
guarded as follows:
|
||||
#if defined(MS_WIN32) && !defined(MS_WIN64)
|
||||
*/
|
||||
#ifdef _WIN64
|
||||
#define MS_WIN64
|
||||
#endif
|
||||
|
||||
/* set the COMPILER and support tier
|
||||
*
|
||||
* win_amd64 MSVC (x86_64-pc-windows-msvc): 1
|
||||
* win32 MSVC (i686-pc-windows-msvc): 1
|
||||
* win_arm64 MSVC (aarch64-pc-windows-msvc): 3
|
||||
* other archs and ICC: 0
|
||||
*/
|
||||
#ifdef MS_WIN64
|
||||
#if defined(_M_X64) || defined(_M_AMD64)
|
||||
#if defined(__clang__)
|
||||
#define COMPILER ("[Clang " __clang_version__ "] 64 bit (AMD64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
|
||||
#define PY_SUPPORT_TIER 0
|
||||
#elif defined(__INTEL_COMPILER)
|
||||
#define COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 64 bit (amd64) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
|
||||
#define PY_SUPPORT_TIER 0
|
||||
#else
|
||||
#define COMPILER _Py_PASTE_VERSION("64 bit (AMD64)")
|
||||
#define PY_SUPPORT_TIER 1
|
||||
#endif /* __clang__ */
|
||||
#define PYD_PLATFORM_TAG "win_amd64"
|
||||
#elif defined(_M_ARM64)
|
||||
#define COMPILER _Py_PASTE_VERSION("64 bit (ARM64)")
|
||||
#define PY_SUPPORT_TIER 3
|
||||
#define PYD_PLATFORM_TAG "win_arm64"
|
||||
#else
|
||||
#define COMPILER _Py_PASTE_VERSION("64 bit (Unknown)")
|
||||
#define PY_SUPPORT_TIER 0
|
||||
#endif
|
||||
#endif /* MS_WIN64 */
|
||||
|
||||
/* set the version macros for the windows headers */
|
||||
/* Python 3.12+ requires Windows 8.1 or greater */
|
||||
#define Py_WINVER 0x0603 /* _WIN32_WINNT_WINBLUE (8.1) */
|
||||
#define Py_NTDDI NTDDI_WINBLUE
|
||||
|
||||
/* We only set these values when building Python - we don't want to force
|
||||
these values on extensions, as that will affect the prototypes and
|
||||
structures exposed in the Windows headers. Even when building Python, we
|
||||
allow a single source file to override this - they may need access to
|
||||
structures etc so it can optionally use new Windows features if it
|
||||
determines at runtime they are available.
|
||||
*/
|
||||
#if defined(Py_BUILD_CORE) || defined(Py_BUILD_CORE_BUILTIN) || defined(Py_BUILD_CORE_MODULE)
|
||||
#ifndef NTDDI_VERSION
|
||||
#define NTDDI_VERSION Py_NTDDI
|
||||
#endif
|
||||
#ifndef WINVER
|
||||
#define WINVER Py_WINVER
|
||||
#endif
|
||||
#ifndef _WIN32_WINNT
|
||||
#define _WIN32_WINNT Py_WINVER
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* _W64 is not defined for VC6 or eVC4 */
|
||||
#ifndef _W64
|
||||
#define _W64
|
||||
#endif
|
||||
|
||||
/* Define like size_t, omitting the "unsigned" */
|
||||
#ifdef MS_WIN64
|
||||
typedef __int64 Py_ssize_t;
|
||||
# define PY_SSIZE_T_MAX LLONG_MAX
|
||||
#else
|
||||
typedef _W64 int Py_ssize_t;
|
||||
# define PY_SSIZE_T_MAX INT_MAX
|
||||
#endif
|
||||
#define HAVE_PY_SSIZE_T 1
|
||||
|
||||
#if defined(MS_WIN32) && !defined(MS_WIN64)
|
||||
#if defined(_M_IX86)
|
||||
#if defined(__clang__)
|
||||
#define COMPILER ("[Clang " __clang_version__ "] 32 bit (Intel) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
|
||||
#define PY_SUPPORT_TIER 0
|
||||
#elif defined(__INTEL_COMPILER)
|
||||
#define COMPILER ("[ICC v." _Py_STRINGIZE(__INTEL_COMPILER) " 32 bit (Intel) with MSC v." _Py_STRINGIZE(_MSC_VER) " CRT]")
|
||||
#define PY_SUPPORT_TIER 0
|
||||
#else
|
||||
#define COMPILER _Py_PASTE_VERSION("32 bit (Intel)")
|
||||
#define PY_SUPPORT_TIER 1
|
||||
#endif /* __clang__ */
|
||||
#define PYD_PLATFORM_TAG "win32"
|
||||
#elif defined(_M_ARM)
|
||||
#define COMPILER _Py_PASTE_VERSION("32 bit (ARM)")
|
||||
#define PYD_PLATFORM_TAG "win_arm32"
|
||||
#define PY_SUPPORT_TIER 0
|
||||
#else
|
||||
#define COMPILER _Py_PASTE_VERSION("32 bit (Unknown)")
|
||||
#define PY_SUPPORT_TIER 0
|
||||
#endif
|
||||
#endif /* MS_WIN32 && !MS_WIN64 */
|
||||
|
||||
typedef int pid_t;
|
||||
|
||||
/* define some ANSI types that are not defined in earlier Win headers */
|
||||
#if _MSC_VER >= 1200
|
||||
/* This file only exists in VC 6.0 or higher */
|
||||
#include <basetsd.h>
|
||||
#endif
|
||||
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
/* ------------------------------------------------------------------------*/
|
||||
/* mingw and mingw-w64 define __MINGW32__ */
|
||||
#ifdef __MINGW32__
|
||||
|
||||
#ifdef _WIN64
|
||||
#define MS_WIN64
|
||||
#endif
|
||||
|
||||
#endif /* __MINGW32__*/
|
||||
|
||||
/* ------------------------------------------------------------------------*/
|
||||
/* egcs/gnu-win32 defines __GNUC__ and _WIN32 */
|
||||
#if defined(__GNUC__) && defined(_WIN32)
|
||||
/* XXX These defines are likely incomplete, but should be easy to fix.
|
||||
They should be complete enough to build extension modules. */
|
||||
/* Suggested by Rene Liebscher <R.Liebscher@gmx.de> to avoid a GCC 2.91.*
|
||||
bug that requires structure imports. More recent versions of the
|
||||
compiler don't exhibit this bug.
|
||||
*/
|
||||
#if (__GNUC__==2) && (__GNUC_MINOR__<=91)
|
||||
#warning "Please use an up-to-date version of gcc! (>2.91 recommended)"
|
||||
#endif
|
||||
|
||||
#define COMPILER "[gcc]"
|
||||
#define PY_LONG_LONG long long
|
||||
#define PY_LLONG_MIN LLONG_MIN
|
||||
#define PY_LLONG_MAX LLONG_MAX
|
||||
#define PY_ULLONG_MAX ULLONG_MAX
|
||||
#endif /* GNUC */
|
||||
|
||||
/* ------------------------------------------------------------------------*/
|
||||
/* lcc-win32 defines __LCC__ */
|
||||
#if defined(__LCC__)
|
||||
/* XXX These defines are likely incomplete, but should be easy to fix.
|
||||
They should be complete enough to build extension modules. */
|
||||
|
||||
#define COMPILER "[lcc-win32]"
|
||||
typedef int pid_t;
|
||||
/* __declspec() is supported here too - do nothing to get the defaults */
|
||||
|
||||
#endif /* LCC */
|
||||
|
||||
/* ------------------------------------------------------------------------*/
|
||||
/* End of compilers - finish up */
|
||||
|
||||
#ifndef NO_STDIO_H
|
||||
# include <stdio.h>
|
||||
#endif
|
||||
|
||||
/* 64 bit ints are usually spelt __int64 unless compiler has overridden */
|
||||
#ifndef PY_LONG_LONG
|
||||
# define PY_LONG_LONG __int64
|
||||
# define PY_LLONG_MAX _I64_MAX
|
||||
# define PY_LLONG_MIN _I64_MIN
|
||||
# define PY_ULLONG_MAX _UI64_MAX
|
||||
#endif
|
||||
|
||||
/* For Windows the Python core is in a DLL by default. Test
|
||||
Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
|
||||
#if !defined(MS_NO_COREDLL) && !defined(Py_NO_ENABLE_SHARED)
|
||||
# define Py_ENABLE_SHARED 1 /* standard symbol for shared library */
|
||||
# define MS_COREDLL /* deprecated old symbol */
|
||||
#endif /* !MS_NO_COREDLL && ... */
|
||||
|
||||
/* All windows compilers that use this header support __declspec */
|
||||
#define HAVE_DECLSPEC_DLL
|
||||
|
||||
/* For an MSVC DLL, we can nominate the .lib files used by extensions */
|
||||
#ifdef MS_COREDLL
|
||||
# if !defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_BUILTIN)
|
||||
/* not building the core - must be an ext */
|
||||
# if defined(_MSC_VER)
|
||||
/* So MSVC users need not specify the .lib
|
||||
file in their Makefile (other compilers are
|
||||
generally taken care of by distutils.) */
|
||||
# if defined(_DEBUG)
|
||||
# pragma comment(lib,"python312_d.lib")
|
||||
# elif defined(Py_LIMITED_API)
|
||||
# pragma comment(lib,"python3.lib")
|
||||
# else
|
||||
# pragma comment(lib,"python312.lib")
|
||||
# endif /* _DEBUG */
|
||||
# endif /* _MSC_VER */
|
||||
# endif /* Py_BUILD_CORE */
|
||||
#endif /* MS_COREDLL */
|
||||
|
||||
#ifdef MS_WIN64
|
||||
/* maintain "win32" sys.platform for backward compatibility of Python code,
|
||||
the Win64 API should be close enough to the Win32 API to make this
|
||||
preferable */
|
||||
# define PLATFORM "win32"
|
||||
# define SIZEOF_VOID_P 8
|
||||
# define SIZEOF_TIME_T 8
|
||||
# define SIZEOF_OFF_T 4
|
||||
# define SIZEOF_FPOS_T 8
|
||||
# define SIZEOF_HKEY 8
|
||||
# define SIZEOF_SIZE_T 8
|
||||
# define ALIGNOF_SIZE_T 8
|
||||
# define ALIGNOF_MAX_ALIGN_T 8
|
||||
/* configure.ac defines HAVE_LARGEFILE_SUPPORT iff
|
||||
sizeof(off_t) > sizeof(long), and sizeof(long long) >= sizeof(off_t).
|
||||
On Win64 the second condition is not true, but if fpos_t replaces off_t
|
||||
then this is true. The uses of HAVE_LARGEFILE_SUPPORT imply that Win64
|
||||
should define this. */
|
||||
# define HAVE_LARGEFILE_SUPPORT
|
||||
#elif defined(MS_WIN32)
|
||||
# define PLATFORM "win32"
|
||||
# define HAVE_LARGEFILE_SUPPORT
|
||||
# define SIZEOF_VOID_P 4
|
||||
# define SIZEOF_OFF_T 4
|
||||
# define SIZEOF_FPOS_T 8
|
||||
# define SIZEOF_HKEY 4
|
||||
# define SIZEOF_SIZE_T 4
|
||||
# define ALIGNOF_SIZE_T 4
|
||||
/* MS VS2005 changes time_t to a 64-bit type on all platforms */
|
||||
# if defined(_MSC_VER) && _MSC_VER >= 1400
|
||||
# define SIZEOF_TIME_T 8
|
||||
# else
|
||||
# define SIZEOF_TIME_T 4
|
||||
# endif
|
||||
# define ALIGNOF_MAX_ALIGN_T 8
|
||||
#endif
|
||||
|
||||
#ifdef _DEBUG
|
||||
# define Py_DEBUG
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef MS_WIN32
|
||||
|
||||
#define SIZEOF_SHORT 2
|
||||
#define SIZEOF_INT 4
|
||||
#define SIZEOF_LONG 4
|
||||
#define ALIGNOF_LONG 4
|
||||
#define SIZEOF_LONG_LONG 8
|
||||
#define SIZEOF_DOUBLE 8
|
||||
#define SIZEOF_FLOAT 4
|
||||
|
||||
/* VC 7.1 has them and VC 6.0 does not. VC 6.0 has a version number of 1200.
|
||||
Microsoft eMbedded Visual C++ 4.0 has a version number of 1201 and doesn't
|
||||
define these.
|
||||
If some compiler does not provide them, modify the #if appropriately. */
|
||||
#if defined(_MSC_VER)
|
||||
#if _MSC_VER > 1300
|
||||
#define HAVE_UINTPTR_T 1
|
||||
#define HAVE_INTPTR_T 1
|
||||
#else
|
||||
/* VC6, VS 2002 and eVC4 don't support the C99 LL suffix for 64-bit integer literals */
|
||||
#define Py_LL(x) x##I64
|
||||
#endif /* _MSC_VER > 1300 */
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#endif
|
||||
|
||||
/* define signed and unsigned exact-width 32-bit and 64-bit types, used in the
|
||||
implementation of Python integers. */
|
||||
#define PY_UINT32_T uint32_t
|
||||
#define PY_UINT64_T uint64_t
|
||||
#define PY_INT32_T int32_t
|
||||
#define PY_INT64_T int64_t
|
||||
|
||||
/* Fairly standard from here! */
|
||||
|
||||
/* Define if on AIX 3.
|
||||
System headers sometimes define this.
|
||||
We just want to avoid a redefinition error message. */
|
||||
#ifndef _ALL_SOURCE
|
||||
/* #undef _ALL_SOURCE */
|
||||
#endif
|
||||
|
||||
/* Define to empty if the keyword does not work. */
|
||||
/* #define const */
|
||||
|
||||
/* Define to 1 if you have the <conio.h> header file. */
|
||||
#define HAVE_CONIO_H 1
|
||||
|
||||
/* Define to 1 if you have the <direct.h> header file. */
|
||||
#define HAVE_DIRECT_H 1
|
||||
|
||||
/* Define to 1 if you have the declaration of `tzname', and to 0 if you don't.
|
||||
*/
|
||||
#define HAVE_DECL_TZNAME 1
|
||||
|
||||
/* Define if you have dirent.h. */
|
||||
/* #define DIRENT 1 */
|
||||
|
||||
/* Define to the type of elements in the array set by `getgroups'.
|
||||
Usually this is either `int' or `gid_t'. */
|
||||
/* #undef GETGROUPS_T */
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
/* #undef gid_t */
|
||||
|
||||
/* Define if your struct tm has tm_zone. */
|
||||
/* #undef HAVE_TM_ZONE */
|
||||
|
||||
/* Define if you don't have tm_zone but do have the external array
|
||||
tzname. */
|
||||
#define HAVE_TZNAME
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
/* #undef mode_t */
|
||||
|
||||
/* Define if you don't have dirent.h, but have ndir.h. */
|
||||
/* #undef NDIR */
|
||||
|
||||
/* Define to `long' if <sys/types.h> doesn't define. */
|
||||
/* #undef off_t */
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
/* #undef pid_t */
|
||||
|
||||
/* Define if the system does not provide POSIX.1 features except
|
||||
with this defined. */
|
||||
/* #undef _POSIX_1_SOURCE */
|
||||
|
||||
/* Define if you need to in order for stat and other things to work. */
|
||||
/* #undef _POSIX_SOURCE */
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#define RETSIGTYPE void
|
||||
|
||||
/* Define to `unsigned' if <sys/types.h> doesn't define. */
|
||||
/* #undef size_t */
|
||||
|
||||
/* Define if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
||||
/* Define if you don't have dirent.h, but have sys/dir.h. */
|
||||
/* #undef SYSDIR */
|
||||
|
||||
/* Define if you don't have dirent.h, but have sys/ndir.h. */
|
||||
/* #undef SYSNDIR */
|
||||
|
||||
/* Define if you can safely include both <sys/time.h> and <time.h>. */
|
||||
/* #undef TIME_WITH_SYS_TIME */
|
||||
|
||||
/* Define if your <sys/time.h> declares struct tm. */
|
||||
/* #define TM_IN_SYS_TIME 1 */
|
||||
|
||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
||||
/* #undef uid_t */
|
||||
|
||||
/* Define if the closedir function returns void instead of int. */
|
||||
/* #undef VOID_CLOSEDIR */
|
||||
|
||||
/* Define if getpgrp() must be called as getpgrp(0)
|
||||
and (consequently) setpgrp() as setpgrp(0, 0). */
|
||||
/* #undef GETPGRP_HAVE_ARGS */
|
||||
|
||||
/* Define this if your time.h defines altzone */
|
||||
/* #define HAVE_ALTZONE */
|
||||
|
||||
/* Define if you have the putenv function. */
|
||||
#define HAVE_PUTENV
|
||||
|
||||
/* Define if your compiler supports function prototypes */
|
||||
#define HAVE_PROTOTYPES
|
||||
|
||||
/* Define if you can safely include both <sys/select.h> and <sys/time.h>
|
||||
(which you can't on SCO ODT 3.0). */
|
||||
/* #undef SYS_SELECT_WITH_SYS_TIME */
|
||||
|
||||
/* Define if you want build the _decimal module using a coroutine-local rather
|
||||
than a thread-local context */
|
||||
#define WITH_DECIMAL_CONTEXTVAR 1
|
||||
|
||||
/* Define if you want documentation strings in extension modules */
|
||||
#define WITH_DOC_STRINGS 1
|
||||
|
||||
/* Define if you want to compile in rudimentary thread support */
|
||||
/* #undef WITH_THREAD */
|
||||
|
||||
/* Define if you want to use the GNU readline library */
|
||||
/* #define WITH_READLINE 1 */
|
||||
|
||||
/* Use Python's own small-block memory-allocator. */
|
||||
#define WITH_PYMALLOC 1
|
||||
|
||||
/* Define if you want to compile in object freelists optimization */
|
||||
#define WITH_FREELISTS 1
|
||||
|
||||
/* Define if you have clock. */
|
||||
/* #define HAVE_CLOCK */
|
||||
|
||||
/* Define when any dynamic module loading is enabled */
|
||||
#define HAVE_DYNAMIC_LOADING
|
||||
|
||||
/* Define if you have ftime. */
|
||||
#define HAVE_FTIME
|
||||
|
||||
/* Define if you have getpeername. */
|
||||
#define HAVE_GETPEERNAME
|
||||
|
||||
/* Define if you have getpgrp. */
|
||||
/* #undef HAVE_GETPGRP */
|
||||
|
||||
/* Define if you have getpid. */
|
||||
#define HAVE_GETPID
|
||||
|
||||
/* Define if you have gettimeofday. */
|
||||
/* #undef HAVE_GETTIMEOFDAY */
|
||||
|
||||
/* Define if you have getwd. */
|
||||
/* #undef HAVE_GETWD */
|
||||
|
||||
/* Define if you have lstat. */
|
||||
/* #undef HAVE_LSTAT */
|
||||
|
||||
/* Define if you have the mktime function. */
|
||||
#define HAVE_MKTIME
|
||||
|
||||
/* Define if you have nice. */
|
||||
/* #undef HAVE_NICE */
|
||||
|
||||
/* Define if you have readlink. */
|
||||
/* #undef HAVE_READLINK */
|
||||
|
||||
/* Define if you have setpgid. */
|
||||
/* #undef HAVE_SETPGID */
|
||||
|
||||
/* Define if you have setpgrp. */
|
||||
/* #undef HAVE_SETPGRP */
|
||||
|
||||
/* Define if you have setsid. */
|
||||
/* #undef HAVE_SETSID */
|
||||
|
||||
/* Define if you have setvbuf. */
|
||||
#define HAVE_SETVBUF
|
||||
|
||||
/* Define if you have siginterrupt. */
|
||||
/* #undef HAVE_SIGINTERRUPT */
|
||||
|
||||
/* Define to 1 if you have the `shutdown' function. */
|
||||
#define HAVE_SHUTDOWN 1
|
||||
|
||||
/* Define if you have symlink. */
|
||||
/* #undef HAVE_SYMLINK */
|
||||
|
||||
/* Define if you have tcgetpgrp. */
|
||||
/* #undef HAVE_TCGETPGRP */
|
||||
|
||||
/* Define if you have tcsetpgrp. */
|
||||
/* #undef HAVE_TCSETPGRP */
|
||||
|
||||
/* Define if you have times. */
|
||||
/* #undef HAVE_TIMES */
|
||||
|
||||
/* Define to 1 if you have the `umask' function. */
|
||||
#define HAVE_UMASK 1
|
||||
|
||||
/* Define if you have uname. */
|
||||
/* #undef HAVE_UNAME */
|
||||
|
||||
/* Define if you have waitpid. */
|
||||
/* #undef HAVE_WAITPID */
|
||||
|
||||
/* Define to 1 if you have the `wcsftime' function. */
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1310
|
||||
#define HAVE_WCSFTIME 1
|
||||
#endif
|
||||
|
||||
/* Define to 1 if you have the `wcscoll' function. */
|
||||
#define HAVE_WCSCOLL 1
|
||||
|
||||
/* Define to 1 if you have the `wcsxfrm' function. */
|
||||
#define HAVE_WCSXFRM 1
|
||||
|
||||
/* Define if the zlib library has inflateCopy */
|
||||
#define HAVE_ZLIB_COPY 1
|
||||
|
||||
/* Define if you have the <dlfcn.h> header file. */
|
||||
/* #undef HAVE_DLFCN_H */
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#define HAVE_ERRNO_H 1
|
||||
|
||||
/* Define if you have the <fcntl.h> header file. */
|
||||
#define HAVE_FCNTL_H 1
|
||||
|
||||
/* Define to 1 if you have the <process.h> header file. */
|
||||
#define HAVE_PROCESS_H 1
|
||||
|
||||
/* Define to 1 if you have the <signal.h> header file. */
|
||||
#define HAVE_SIGNAL_H 1
|
||||
|
||||
/* Define if you have the <stddef.h> header file. */
|
||||
#define HAVE_STDDEF_H 1
|
||||
|
||||
/* Define if you have the <sys/audioio.h> header file. */
|
||||
/* #undef HAVE_SYS_AUDIOIO_H */
|
||||
|
||||
/* Define if you have the <sys/param.h> header file. */
|
||||
/* #define HAVE_SYS_PARAM_H 1 */
|
||||
|
||||
/* Define if you have the <sys/select.h> header file. */
|
||||
/* #define HAVE_SYS_SELECT_H 1 */
|
||||
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#define HAVE_SYS_STAT_H 1
|
||||
|
||||
/* Define if you have the <sys/time.h> header file. */
|
||||
/* #define HAVE_SYS_TIME_H 1 */
|
||||
|
||||
/* Define if you have the <sys/times.h> header file. */
|
||||
/* #define HAVE_SYS_TIMES_H 1 */
|
||||
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#define HAVE_SYS_TYPES_H 1
|
||||
|
||||
/* Define if you have the <sys/un.h> header file. */
|
||||
/* #define HAVE_SYS_UN_H 1 */
|
||||
|
||||
/* Define if you have the <sys/utime.h> header file. */
|
||||
/* #define HAVE_SYS_UTIME_H 1 */
|
||||
|
||||
/* Define if you have the <sys/utsname.h> header file. */
|
||||
/* #define HAVE_SYS_UTSNAME_H 1 */
|
||||
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
/* #define HAVE_UNISTD_H 1 */
|
||||
|
||||
/* Define if you have the <utime.h> header file. */
|
||||
/* #define HAVE_UTIME_H 1 */
|
||||
|
||||
/* Define if the compiler provides a wchar.h header file. */
|
||||
#define HAVE_WCHAR_H 1
|
||||
|
||||
/* The size of `wchar_t', as computed by sizeof. */
|
||||
#define SIZEOF_WCHAR_T 2
|
||||
|
||||
/* The size of `_Bool', as computed by sizeof. */
|
||||
#define SIZEOF__BOOL 1
|
||||
|
||||
/* The size of `pid_t', as computed by sizeof. */
|
||||
#define SIZEOF_PID_T SIZEOF_INT
|
||||
|
||||
/* Define if you have the dl library (-ldl). */
|
||||
/* #undef HAVE_LIBDL */
|
||||
|
||||
/* Define if you have the mpc library (-lmpc). */
|
||||
/* #undef HAVE_LIBMPC */
|
||||
|
||||
/* Define if you have the nsl library (-lnsl). */
|
||||
#define HAVE_LIBNSL 1
|
||||
|
||||
/* Define if you have the seq library (-lseq). */
|
||||
/* #undef HAVE_LIBSEQ */
|
||||
|
||||
/* Define if you have the socket library (-lsocket). */
|
||||
#define HAVE_LIBSOCKET 1
|
||||
|
||||
/* Define if you have the sun library (-lsun). */
|
||||
/* #undef HAVE_LIBSUN */
|
||||
|
||||
/* Define if you have the termcap library (-ltermcap). */
|
||||
/* #undef HAVE_LIBTERMCAP */
|
||||
|
||||
/* Define if you have the termlib library (-ltermlib). */
|
||||
/* #undef HAVE_LIBTERMLIB */
|
||||
|
||||
/* Define if you have the thread library (-lthread). */
|
||||
/* #undef HAVE_LIBTHREAD */
|
||||
|
||||
/* WinSock does not use a bitmask in select, and uses
|
||||
socket handles greater than FD_SETSIZE */
|
||||
#define Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE
|
||||
|
||||
/* Define if C doubles are 64-bit IEEE 754 binary format, stored with the
|
||||
least significant byte first */
|
||||
#define DOUBLE_IS_LITTLE_ENDIAN_IEEE754 1
|
||||
|
||||
/* Define to 1 if you have the `erf' function. */
|
||||
#define HAVE_ERF 1
|
||||
|
||||
/* Define to 1 if you have the `erfc' function. */
|
||||
#define HAVE_ERFC 1
|
||||
|
||||
// netdb.h functions (provided by winsock.h)
|
||||
#define HAVE_GETHOSTNAME 1
|
||||
#define HAVE_GETHOSTBYADDR 1
|
||||
#define HAVE_GETHOSTBYNAME 1
|
||||
#define HAVE_GETPROTOBYNAME 1
|
||||
#define HAVE_GETSERVBYNAME 1
|
||||
#define HAVE_GETSERVBYPORT 1
|
||||
// sys/socket.h functions (provided by winsock.h)
|
||||
#define HAVE_INET_PTON 1
|
||||
#define HAVE_INET_NTOA 1
|
||||
#define HAVE_ACCEPT 1
|
||||
#define HAVE_BIND 1
|
||||
#define HAVE_CONNECT 1
|
||||
#define HAVE_GETSOCKNAME 1
|
||||
#define HAVE_LISTEN 1
|
||||
#define HAVE_RECVFROM 1
|
||||
#define HAVE_SENDTO 1
|
||||
#define HAVE_SETSOCKOPT 1
|
||||
#define HAVE_SOCKET 1
|
||||
|
||||
/* Define to 1 if you have the `dup' function. */
|
||||
#define HAVE_DUP 1
|
||||
|
||||
/* framework name */
|
||||
#define _PYTHONFRAMEWORK ""
|
||||
|
||||
/* Define if libssl has X509_VERIFY_PARAM_set1_host and related function */
|
||||
#define HAVE_X509_VERIFY_PARAM_SET1_HOST 1
|
||||
|
||||
#endif /* !Py_CONFIG_H */
|
||||
59
crypto/shamirs_secret_sharing/include/pydtrace.h
Normal file
59
crypto/shamirs_secret_sharing/include/pydtrace.h
Normal file
@@ -0,0 +1,59 @@
|
||||
/* Static DTrace probes interface */
|
||||
|
||||
#ifndef Py_DTRACE_H
|
||||
#define Py_DTRACE_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef WITH_DTRACE
|
||||
|
||||
#include "pydtrace_probes.h"
|
||||
|
||||
/* pydtrace_probes.h, on systems with DTrace, is auto-generated to include
|
||||
`PyDTrace_{PROBE}` and `PyDTrace_{PROBE}_ENABLED()` macros for every probe
|
||||
defined in pydtrace.d.
|
||||
|
||||
Calling these functions must be guarded by a `PyDTrace_{PROBE}_ENABLED()`
|
||||
check to minimize performance impact when probing is off. For example:
|
||||
|
||||
if (PyDTrace_FUNCTION_ENTRY_ENABLED())
|
||||
PyDTrace_FUNCTION_ENTRY(f);
|
||||
*/
|
||||
|
||||
#else
|
||||
|
||||
/* Without DTrace, compile to nothing. */
|
||||
|
||||
static inline void PyDTrace_LINE(const char *arg0, const char *arg1, int arg2) {}
|
||||
static inline void PyDTrace_FUNCTION_ENTRY(const char *arg0, const char *arg1, int arg2) {}
|
||||
static inline void PyDTrace_FUNCTION_RETURN(const char *arg0, const char *arg1, int arg2) {}
|
||||
static inline void PyDTrace_GC_START(int arg0) {}
|
||||
static inline void PyDTrace_GC_DONE(Py_ssize_t arg0) {}
|
||||
static inline void PyDTrace_INSTANCE_NEW_START(int arg0) {}
|
||||
static inline void PyDTrace_INSTANCE_NEW_DONE(int arg0) {}
|
||||
static inline void PyDTrace_INSTANCE_DELETE_START(int arg0) {}
|
||||
static inline void PyDTrace_INSTANCE_DELETE_DONE(int arg0) {}
|
||||
static inline void PyDTrace_IMPORT_FIND_LOAD_START(const char *arg0) {}
|
||||
static inline void PyDTrace_IMPORT_FIND_LOAD_DONE(const char *arg0, int arg1) {}
|
||||
static inline void PyDTrace_AUDIT(const char *arg0, void *arg1) {}
|
||||
|
||||
static inline int PyDTrace_LINE_ENABLED(void) { return 0; }
|
||||
static inline int PyDTrace_FUNCTION_ENTRY_ENABLED(void) { return 0; }
|
||||
static inline int PyDTrace_FUNCTION_RETURN_ENABLED(void) { return 0; }
|
||||
static inline int PyDTrace_GC_START_ENABLED(void) { return 0; }
|
||||
static inline int PyDTrace_GC_DONE_ENABLED(void) { return 0; }
|
||||
static inline int PyDTrace_INSTANCE_NEW_START_ENABLED(void) { return 0; }
|
||||
static inline int PyDTrace_INSTANCE_NEW_DONE_ENABLED(void) { return 0; }
|
||||
static inline int PyDTrace_INSTANCE_DELETE_START_ENABLED(void) { return 0; }
|
||||
static inline int PyDTrace_INSTANCE_DELETE_DONE_ENABLED(void) { return 0; }
|
||||
static inline int PyDTrace_IMPORT_FIND_LOAD_START_ENABLED(void) { return 0; }
|
||||
static inline int PyDTrace_IMPORT_FIND_LOAD_DONE_ENABLED(void) { return 0; }
|
||||
static inline int PyDTrace_AUDIT_ENABLED(void) { return 0; }
|
||||
|
||||
#endif /* !WITH_DTRACE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_DTRACE_H */
|
||||
337
crypto/shamirs_secret_sharing/include/pyerrors.h
Normal file
337
crypto/shamirs_secret_sharing/include/pyerrors.h
Normal file
@@ -0,0 +1,337 @@
|
||||
#ifndef Py_ERRORS_H
|
||||
#define Py_ERRORS_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdarg.h> // va_list
|
||||
|
||||
/* Error handling definitions */
|
||||
|
||||
PyAPI_FUNC(void) PyErr_SetNone(PyObject *);
|
||||
PyAPI_FUNC(void) PyErr_SetObject(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(void) PyErr_SetString(
|
||||
PyObject *exception,
|
||||
const char *string /* decoded from utf-8 */
|
||||
);
|
||||
PyAPI_FUNC(PyObject *) PyErr_Occurred(void);
|
||||
PyAPI_FUNC(void) PyErr_Clear(void);
|
||||
PyAPI_FUNC(void) PyErr_Fetch(PyObject **, PyObject **, PyObject **);
|
||||
PyAPI_FUNC(void) PyErr_Restore(PyObject *, PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyErr_GetRaisedException(void);
|
||||
PyAPI_FUNC(void) PyErr_SetRaisedException(PyObject *);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030b0000
|
||||
PyAPI_FUNC(PyObject*) PyErr_GetHandledException(void);
|
||||
PyAPI_FUNC(void) PyErr_SetHandledException(PyObject *);
|
||||
#endif
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_FUNC(void) PyErr_GetExcInfo(PyObject **, PyObject **, PyObject **);
|
||||
PyAPI_FUNC(void) PyErr_SetExcInfo(PyObject *, PyObject *, PyObject *);
|
||||
#endif
|
||||
|
||||
/* Defined in Python/pylifecycle.c
|
||||
|
||||
The Py_FatalError() function is replaced with a macro which logs
|
||||
automatically the name of the current function, unless the Py_LIMITED_API
|
||||
macro is defined. */
|
||||
PyAPI_FUNC(void) _Py_NO_RETURN Py_FatalError(const char *message);
|
||||
|
||||
/* Error testing and normalization */
|
||||
PyAPI_FUNC(int) PyErr_GivenExceptionMatches(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(int) PyErr_ExceptionMatches(PyObject *);
|
||||
PyAPI_FUNC(void) PyErr_NormalizeException(PyObject**, PyObject**, PyObject**);
|
||||
|
||||
/* Traceback manipulation (PEP 3134) */
|
||||
PyAPI_FUNC(int) PyException_SetTraceback(PyObject *, PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyException_GetTraceback(PyObject *);
|
||||
|
||||
/* Cause manipulation (PEP 3134) */
|
||||
PyAPI_FUNC(PyObject *) PyException_GetCause(PyObject *);
|
||||
PyAPI_FUNC(void) PyException_SetCause(PyObject *, PyObject *);
|
||||
|
||||
/* Context manipulation (PEP 3134) */
|
||||
PyAPI_FUNC(PyObject *) PyException_GetContext(PyObject *);
|
||||
PyAPI_FUNC(void) PyException_SetContext(PyObject *, PyObject *);
|
||||
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyException_GetArgs(PyObject *);
|
||||
PyAPI_FUNC(void) PyException_SetArgs(PyObject *, PyObject *);
|
||||
|
||||
/* */
|
||||
|
||||
#define PyExceptionClass_Check(x) \
|
||||
(PyType_Check((x)) && \
|
||||
PyType_FastSubclass((PyTypeObject*)(x), Py_TPFLAGS_BASE_EXC_SUBCLASS))
|
||||
|
||||
#define PyExceptionInstance_Check(x) \
|
||||
PyType_FastSubclass(Py_TYPE(x), Py_TPFLAGS_BASE_EXC_SUBCLASS)
|
||||
|
||||
PyAPI_FUNC(const char *) PyExceptionClass_Name(PyObject *);
|
||||
|
||||
#define PyExceptionInstance_Class(x) _PyObject_CAST(Py_TYPE(x))
|
||||
|
||||
#define _PyBaseExceptionGroup_Check(x) \
|
||||
PyObject_TypeCheck((x), (PyTypeObject *)PyExc_BaseExceptionGroup)
|
||||
|
||||
/* Predefined exceptions */
|
||||
|
||||
PyAPI_DATA(PyObject *) PyExc_BaseException;
|
||||
PyAPI_DATA(PyObject *) PyExc_Exception;
|
||||
PyAPI_DATA(PyObject *) PyExc_BaseExceptionGroup;
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||
PyAPI_DATA(PyObject *) PyExc_StopAsyncIteration;
|
||||
#endif
|
||||
PyAPI_DATA(PyObject *) PyExc_StopIteration;
|
||||
PyAPI_DATA(PyObject *) PyExc_GeneratorExit;
|
||||
PyAPI_DATA(PyObject *) PyExc_ArithmeticError;
|
||||
PyAPI_DATA(PyObject *) PyExc_LookupError;
|
||||
|
||||
PyAPI_DATA(PyObject *) PyExc_AssertionError;
|
||||
PyAPI_DATA(PyObject *) PyExc_AttributeError;
|
||||
PyAPI_DATA(PyObject *) PyExc_BufferError;
|
||||
PyAPI_DATA(PyObject *) PyExc_EOFError;
|
||||
PyAPI_DATA(PyObject *) PyExc_FloatingPointError;
|
||||
PyAPI_DATA(PyObject *) PyExc_OSError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ImportError;
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000
|
||||
PyAPI_DATA(PyObject *) PyExc_ModuleNotFoundError;
|
||||
#endif
|
||||
PyAPI_DATA(PyObject *) PyExc_IndexError;
|
||||
PyAPI_DATA(PyObject *) PyExc_KeyError;
|
||||
PyAPI_DATA(PyObject *) PyExc_KeyboardInterrupt;
|
||||
PyAPI_DATA(PyObject *) PyExc_MemoryError;
|
||||
PyAPI_DATA(PyObject *) PyExc_NameError;
|
||||
PyAPI_DATA(PyObject *) PyExc_OverflowError;
|
||||
PyAPI_DATA(PyObject *) PyExc_RuntimeError;
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||
PyAPI_DATA(PyObject *) PyExc_RecursionError;
|
||||
#endif
|
||||
PyAPI_DATA(PyObject *) PyExc_NotImplementedError;
|
||||
PyAPI_DATA(PyObject *) PyExc_SyntaxError;
|
||||
PyAPI_DATA(PyObject *) PyExc_IndentationError;
|
||||
PyAPI_DATA(PyObject *) PyExc_TabError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ReferenceError;
|
||||
PyAPI_DATA(PyObject *) PyExc_SystemError;
|
||||
PyAPI_DATA(PyObject *) PyExc_SystemExit;
|
||||
PyAPI_DATA(PyObject *) PyExc_TypeError;
|
||||
PyAPI_DATA(PyObject *) PyExc_UnboundLocalError;
|
||||
PyAPI_DATA(PyObject *) PyExc_UnicodeError;
|
||||
PyAPI_DATA(PyObject *) PyExc_UnicodeEncodeError;
|
||||
PyAPI_DATA(PyObject *) PyExc_UnicodeDecodeError;
|
||||
PyAPI_DATA(PyObject *) PyExc_UnicodeTranslateError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ValueError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ZeroDivisionError;
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_DATA(PyObject *) PyExc_BlockingIOError;
|
||||
PyAPI_DATA(PyObject *) PyExc_BrokenPipeError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ChildProcessError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ConnectionError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ConnectionAbortedError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ConnectionRefusedError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ConnectionResetError;
|
||||
PyAPI_DATA(PyObject *) PyExc_FileExistsError;
|
||||
PyAPI_DATA(PyObject *) PyExc_FileNotFoundError;
|
||||
PyAPI_DATA(PyObject *) PyExc_InterruptedError;
|
||||
PyAPI_DATA(PyObject *) PyExc_IsADirectoryError;
|
||||
PyAPI_DATA(PyObject *) PyExc_NotADirectoryError;
|
||||
PyAPI_DATA(PyObject *) PyExc_PermissionError;
|
||||
PyAPI_DATA(PyObject *) PyExc_ProcessLookupError;
|
||||
PyAPI_DATA(PyObject *) PyExc_TimeoutError;
|
||||
#endif
|
||||
|
||||
|
||||
/* Compatibility aliases */
|
||||
PyAPI_DATA(PyObject *) PyExc_EnvironmentError;
|
||||
PyAPI_DATA(PyObject *) PyExc_IOError;
|
||||
#ifdef MS_WINDOWS
|
||||
PyAPI_DATA(PyObject *) PyExc_WindowsError;
|
||||
#endif
|
||||
|
||||
/* Predefined warning categories */
|
||||
PyAPI_DATA(PyObject *) PyExc_Warning;
|
||||
PyAPI_DATA(PyObject *) PyExc_UserWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_DeprecationWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_PendingDeprecationWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_SyntaxWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_RuntimeWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_FutureWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_ImportWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_UnicodeWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_BytesWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_EncodingWarning;
|
||||
PyAPI_DATA(PyObject *) PyExc_ResourceWarning;
|
||||
|
||||
|
||||
/* Convenience functions */
|
||||
|
||||
PyAPI_FUNC(int) PyErr_BadArgument(void);
|
||||
PyAPI_FUNC(PyObject *) PyErr_NoMemory(void);
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetFromErrno(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilenameObject(
|
||||
PyObject *, PyObject *);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03040000
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilenameObjects(
|
||||
PyObject *, PyObject *, PyObject *);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetFromErrnoWithFilename(
|
||||
PyObject *exc,
|
||||
const char *filename /* decoded from the filesystem encoding */
|
||||
);
|
||||
|
||||
PyAPI_FUNC(PyObject *) PyErr_Format(
|
||||
PyObject *exception,
|
||||
const char *format, /* ASCII-encoded string */
|
||||
...
|
||||
);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03050000
|
||||
PyAPI_FUNC(PyObject *) PyErr_FormatV(
|
||||
PyObject *exception,
|
||||
const char *format,
|
||||
va_list vargs);
|
||||
#endif
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErrWithFilename(
|
||||
int ierr,
|
||||
const char *filename /* decoded from the filesystem encoding */
|
||||
);
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetFromWindowsErr(int);
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObject(
|
||||
PyObject *,int, PyObject *);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03040000
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilenameObjects(
|
||||
PyObject *,int, PyObject *, PyObject *);
|
||||
#endif
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErrWithFilename(
|
||||
PyObject *exc,
|
||||
int ierr,
|
||||
const char *filename /* decoded from the filesystem encoding */
|
||||
);
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetExcFromWindowsErr(PyObject *, int);
|
||||
#endif /* MS_WINDOWS */
|
||||
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03060000
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetImportErrorSubclass(PyObject *, PyObject *,
|
||||
PyObject *, PyObject *);
|
||||
#endif
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x03030000
|
||||
PyAPI_FUNC(PyObject *) PyErr_SetImportError(PyObject *, PyObject *,
|
||||
PyObject *);
|
||||
#endif
|
||||
|
||||
/* Export the old function so that the existing API remains available: */
|
||||
PyAPI_FUNC(void) PyErr_BadInternalCall(void);
|
||||
PyAPI_FUNC(void) _PyErr_BadInternalCall(const char *filename, int lineno);
|
||||
/* Mask the old API with a call to the new API for code compiled under
|
||||
Python 2.0: */
|
||||
#define PyErr_BadInternalCall() _PyErr_BadInternalCall(__FILE__, __LINE__)
|
||||
|
||||
/* Function to create a new exception */
|
||||
PyAPI_FUNC(PyObject *) PyErr_NewException(
|
||||
const char *name, PyObject *base, PyObject *dict);
|
||||
PyAPI_FUNC(PyObject *) PyErr_NewExceptionWithDoc(
|
||||
const char *name, const char *doc, PyObject *base, PyObject *dict);
|
||||
PyAPI_FUNC(void) PyErr_WriteUnraisable(PyObject *);
|
||||
|
||||
|
||||
/* In signalmodule.c */
|
||||
PyAPI_FUNC(int) PyErr_CheckSignals(void);
|
||||
PyAPI_FUNC(void) PyErr_SetInterrupt(void);
|
||||
#if !defined(Py_LIMITED_API) || Py_LIMITED_API+0 >= 0x030A0000
|
||||
PyAPI_FUNC(int) PyErr_SetInterruptEx(int signum);
|
||||
#endif
|
||||
|
||||
/* Support for adding program text to SyntaxErrors */
|
||||
PyAPI_FUNC(void) PyErr_SyntaxLocation(
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
int lineno);
|
||||
PyAPI_FUNC(void) PyErr_SyntaxLocationEx(
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
int lineno,
|
||||
int col_offset);
|
||||
PyAPI_FUNC(PyObject *) PyErr_ProgramText(
|
||||
const char *filename, /* decoded from the filesystem encoding */
|
||||
int lineno);
|
||||
|
||||
/* The following functions are used to create and modify unicode
|
||||
exceptions from C */
|
||||
|
||||
/* create a UnicodeDecodeError object */
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_Create(
|
||||
const char *encoding, /* UTF-8 encoded string */
|
||||
const char *object,
|
||||
Py_ssize_t length,
|
||||
Py_ssize_t start,
|
||||
Py_ssize_t end,
|
||||
const char *reason /* UTF-8 encoded string */
|
||||
);
|
||||
|
||||
/* get the encoding attribute */
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetEncoding(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetEncoding(PyObject *);
|
||||
|
||||
/* get the object attribute */
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetObject(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetObject(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetObject(PyObject *);
|
||||
|
||||
/* get the value of the start attribute (the int * may not be NULL)
|
||||
return 0 on success, -1 on failure */
|
||||
PyAPI_FUNC(int) PyUnicodeEncodeError_GetStart(PyObject *, Py_ssize_t *);
|
||||
PyAPI_FUNC(int) PyUnicodeDecodeError_GetStart(PyObject *, Py_ssize_t *);
|
||||
PyAPI_FUNC(int) PyUnicodeTranslateError_GetStart(PyObject *, Py_ssize_t *);
|
||||
|
||||
/* assign a new value to the start attribute
|
||||
return 0 on success, -1 on failure */
|
||||
PyAPI_FUNC(int) PyUnicodeEncodeError_SetStart(PyObject *, Py_ssize_t);
|
||||
PyAPI_FUNC(int) PyUnicodeDecodeError_SetStart(PyObject *, Py_ssize_t);
|
||||
PyAPI_FUNC(int) PyUnicodeTranslateError_SetStart(PyObject *, Py_ssize_t);
|
||||
|
||||
/* get the value of the end attribute (the int *may not be NULL)
|
||||
return 0 on success, -1 on failure */
|
||||
PyAPI_FUNC(int) PyUnicodeEncodeError_GetEnd(PyObject *, Py_ssize_t *);
|
||||
PyAPI_FUNC(int) PyUnicodeDecodeError_GetEnd(PyObject *, Py_ssize_t *);
|
||||
PyAPI_FUNC(int) PyUnicodeTranslateError_GetEnd(PyObject *, Py_ssize_t *);
|
||||
|
||||
/* assign a new value to the end attribute
|
||||
return 0 on success, -1 on failure */
|
||||
PyAPI_FUNC(int) PyUnicodeEncodeError_SetEnd(PyObject *, Py_ssize_t);
|
||||
PyAPI_FUNC(int) PyUnicodeDecodeError_SetEnd(PyObject *, Py_ssize_t);
|
||||
PyAPI_FUNC(int) PyUnicodeTranslateError_SetEnd(PyObject *, Py_ssize_t);
|
||||
|
||||
/* get the value of the reason attribute */
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeEncodeError_GetReason(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeDecodeError_GetReason(PyObject *);
|
||||
PyAPI_FUNC(PyObject *) PyUnicodeTranslateError_GetReason(PyObject *);
|
||||
|
||||
/* assign a new value to the reason attribute
|
||||
return 0 on success, -1 on failure */
|
||||
PyAPI_FUNC(int) PyUnicodeEncodeError_SetReason(
|
||||
PyObject *exc,
|
||||
const char *reason /* UTF-8 encoded string */
|
||||
);
|
||||
PyAPI_FUNC(int) PyUnicodeDecodeError_SetReason(
|
||||
PyObject *exc,
|
||||
const char *reason /* UTF-8 encoded string */
|
||||
);
|
||||
PyAPI_FUNC(int) PyUnicodeTranslateError_SetReason(
|
||||
PyObject *exc,
|
||||
const char *reason /* UTF-8 encoded string */
|
||||
);
|
||||
|
||||
PyAPI_FUNC(int) PyOS_snprintf(char *str, size_t size, const char *format, ...)
|
||||
Py_GCC_ATTRIBUTE((format(printf, 3, 4)));
|
||||
PyAPI_FUNC(int) PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va)
|
||||
Py_GCC_ATTRIBUTE((format(printf, 3, 0)));
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
# define Py_CPYTHON_ERRORS_H
|
||||
# include "cpython/pyerrors.h"
|
||||
# undef Py_CPYTHON_ERRORS_H
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_ERRORS_H */
|
||||
57
crypto/shamirs_secret_sharing/include/pyexpat.h
Normal file
57
crypto/shamirs_secret_sharing/include/pyexpat.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/* Stuff to export relevant 'expat' entry points from pyexpat to other
|
||||
* parser modules, such as cElementTree. */
|
||||
|
||||
/* note: you must import expat.h before importing this module! */
|
||||
|
||||
#define PyExpat_CAPI_MAGIC "pyexpat.expat_CAPI 1.1"
|
||||
#define PyExpat_CAPSULE_NAME "pyexpat.expat_CAPI"
|
||||
|
||||
struct PyExpat_CAPI
|
||||
{
|
||||
char* magic; /* set to PyExpat_CAPI_MAGIC */
|
||||
int size; /* set to sizeof(struct PyExpat_CAPI) */
|
||||
int MAJOR_VERSION;
|
||||
int MINOR_VERSION;
|
||||
int MICRO_VERSION;
|
||||
/* pointers to selected expat functions. add new functions at
|
||||
the end, if needed */
|
||||
const XML_LChar * (*ErrorString)(enum XML_Error code);
|
||||
enum XML_Error (*GetErrorCode)(XML_Parser parser);
|
||||
XML_Size (*GetErrorColumnNumber)(XML_Parser parser);
|
||||
XML_Size (*GetErrorLineNumber)(XML_Parser parser);
|
||||
enum XML_Status (*Parse)(
|
||||
XML_Parser parser, const char *s, int len, int isFinal);
|
||||
XML_Parser (*ParserCreate_MM)(
|
||||
const XML_Char *encoding, const XML_Memory_Handling_Suite *memsuite,
|
||||
const XML_Char *namespaceSeparator);
|
||||
void (*ParserFree)(XML_Parser parser);
|
||||
void (*SetCharacterDataHandler)(
|
||||
XML_Parser parser, XML_CharacterDataHandler handler);
|
||||
void (*SetCommentHandler)(
|
||||
XML_Parser parser, XML_CommentHandler handler);
|
||||
void (*SetDefaultHandlerExpand)(
|
||||
XML_Parser parser, XML_DefaultHandler handler);
|
||||
void (*SetElementHandler)(
|
||||
XML_Parser parser, XML_StartElementHandler start,
|
||||
XML_EndElementHandler end);
|
||||
void (*SetNamespaceDeclHandler)(
|
||||
XML_Parser parser, XML_StartNamespaceDeclHandler start,
|
||||
XML_EndNamespaceDeclHandler end);
|
||||
void (*SetProcessingInstructionHandler)(
|
||||
XML_Parser parser, XML_ProcessingInstructionHandler handler);
|
||||
void (*SetUnknownEncodingHandler)(
|
||||
XML_Parser parser, XML_UnknownEncodingHandler handler,
|
||||
void *encodingHandlerData);
|
||||
void (*SetUserData)(XML_Parser parser, void *userData);
|
||||
void (*SetStartDoctypeDeclHandler)(XML_Parser parser,
|
||||
XML_StartDoctypeDeclHandler start);
|
||||
enum XML_Status (*SetEncoding)(XML_Parser parser, const XML_Char *encoding);
|
||||
int (*DefaultUnknownEncodingHandler)(
|
||||
void *encodingHandlerData, const XML_Char *name, XML_Encoding *info);
|
||||
/* might be NULL for expat < 2.1.0 */
|
||||
int (*SetHashSalt)(XML_Parser parser, unsigned long hash_salt);
|
||||
/* might be NULL for expat < 2.6.0 */
|
||||
XML_Bool (*SetReparseDeferralEnabled)(XML_Parser parser, XML_Bool enabled);
|
||||
/* always add new stuff to the end! */
|
||||
};
|
||||
|
||||
26
crypto/shamirs_secret_sharing/include/pyframe.h
Normal file
26
crypto/shamirs_secret_sharing/include/pyframe.h
Normal file
@@ -0,0 +1,26 @@
|
||||
/* Limited C API of PyFrame API
|
||||
*
|
||||
* Include "frameobject.h" to get the PyFrameObject structure.
|
||||
*/
|
||||
|
||||
#ifndef Py_PYFRAME_H
|
||||
#define Py_PYFRAME_H
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Return the line of code the frame is currently executing. */
|
||||
PyAPI_FUNC(int) PyFrame_GetLineNumber(PyFrameObject *);
|
||||
|
||||
PyAPI_FUNC(PyCodeObject *) PyFrame_GetCode(PyFrameObject *frame);
|
||||
|
||||
#ifndef Py_LIMITED_API
|
||||
# define Py_CPYTHON_PYFRAME_H
|
||||
# include "cpython/pyframe.h"
|
||||
# undef Py_CPYTHON_PYFRAME_H
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif /* !Py_PYFRAME_H */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user