|
|
#ifndef Py_INTERNAL_LONG_H |
|
|
#define Py_INTERNAL_LONG_H |
|
|
#ifdef __cplusplus |
|
|
extern "C" { |
|
|
#endif |
|
|
|
|
|
#ifndef Py_BUILD_CORE |
|
|
# error "this header requires Py_BUILD_CORE define" |
|
|
#endif |
|
|
|
|
|
#include "pycore_interp.h" |
|
|
#include "pycore_pystate.h" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define _PY_LONG_DEFAULT_MAX_STR_DIGITS 4300 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define _PY_LONG_MAX_STR_DIGITS_THRESHOLD 640 |
|
|
|
|
|
#if ((_PY_LONG_DEFAULT_MAX_STR_DIGITS != 0) && \ |
|
|
(_PY_LONG_DEFAULT_MAX_STR_DIGITS < _PY_LONG_MAX_STR_DIGITS_THRESHOLD)) |
|
|
# error "_PY_LONG_DEFAULT_MAX_STR_DIGITS smaller than threshold." |
|
|
#endif |
|
|
|
|
|
|
|
|
static inline PyObject* __PyLong_GetSmallInt_internal(int value) |
|
|
{ |
|
|
PyInterpreterState *interp = _PyInterpreterState_GET(); |
|
|
assert(-_PY_NSMALLNEGINTS <= value && value < _PY_NSMALLPOSINTS); |
|
|
size_t index = _PY_NSMALLNEGINTS + value; |
|
|
PyObject *obj = (PyObject*)interp->small_ints[index]; |
|
|
|
|
|
|
|
|
assert(obj != NULL); |
|
|
return obj; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static inline PyObject* _PyLong_GetZero(void) |
|
|
{ return __PyLong_GetSmallInt_internal(0); } |
|
|
|
|
|
|
|
|
|
|
|
static inline PyObject* _PyLong_GetOne(void) |
|
|
{ return __PyLong_GetSmallInt_internal(1); } |
|
|
|
|
|
#ifdef __cplusplus |
|
|
} |
|
|
#endif |
|
|
#endif |
|
|
|