Skip to content

Commit 9a8f060

Browse files
committed
Update Python inlined files: 3.12.7 (3.1)
1 parent 65e59d8 commit 9a8f060

File tree

2 files changed

+319
-95
lines changed

2 files changed

+319
-95
lines changed

graalpython/com.oracle.graal.python.cext/include/cpython/longintrepr.h

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,53 @@ typedef long stwodigits; /* signed variant of twodigits */
7979
aware that ints abuse ob_size's sign bit.
8080
*/
8181

82-
struct _longobject {
83-
PyObject_VAR_HEAD
82+
typedef struct _PyLongValue {
83+
uintptr_t lv_tag; /* Number of digits, sign and flags */
8484
digit ob_digit[1];
85+
} _PyLongValue;
86+
87+
struct _longobject {
88+
PyObject_HEAD
89+
_PyLongValue long_value;
8590
};
8691

8792
PyAPI_FUNC(PyLongObject *) _PyLong_New(Py_ssize_t);
8893

8994
/* Return a copy of src. */
9095
PyAPI_FUNC(PyObject *) _PyLong_Copy(PyLongObject *src);
9196

97+
PyAPI_FUNC(PyLongObject *)
98+
_PyLong_FromDigits(int negative, Py_ssize_t digit_count, digit *digits);
99+
100+
101+
/* Inline some internals for speed. These should be in pycore_long.h
102+
* if user code didn't need them inlined. */
103+
104+
#define _PyLong_SIGN_MASK 3
105+
#define _PyLong_NON_SIZE_BITS 3
106+
107+
108+
static inline int
109+
_PyLong_IsCompact(const PyLongObject* op) {
110+
assert(PyType_HasFeature((op)->ob_base.ob_type, Py_TPFLAGS_LONG_SUBCLASS));
111+
return op->long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS);
112+
}
113+
114+
#define PyUnstable_Long_IsCompact _PyLong_IsCompact
115+
116+
static inline Py_ssize_t
117+
_PyLong_CompactValue(const PyLongObject *op)
118+
{
119+
Py_ssize_t sign;
120+
assert(PyType_HasFeature((op)->ob_base.ob_type, Py_TPFLAGS_LONG_SUBCLASS));
121+
assert(PyUnstable_Long_IsCompact(op));
122+
sign = 1 - (op->long_value.lv_tag & _PyLong_SIGN_MASK);
123+
return sign * (Py_ssize_t)op->long_value.ob_digit[0];
124+
}
125+
126+
#define PyUnstable_Long_CompactValue _PyLong_CompactValue
127+
128+
92129
#ifdef __cplusplus
93130
}
94131
#endif

0 commit comments

Comments
 (0)