8000 gh-84436: Add static flag in PyLongObject's lv_tag by eduardo-elizondo · Pull Request #103403 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-84436: Add static flag in PyLongObject's lv_tag #103403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Also correctly set the flags in SetDigit functions
  • Loading branch information
eduardo-elizondo committed Apr 10, 2023
commit 2a23b75d7f32dfc95d21e79ece9e663d34489472
7 changes: 5 additions & 2 deletions Include/internal/pycore_long.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,17 @@ _PyLong_SetSignAndDigitCount(PyLongObject *op, int sign, Py_ssize_t size)
assert(size >= 0);
assert(-1 <= sign && sign <= 1);
assert(sign != 0 || size == 0);
op->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(sign, (size_t)size);
op->long_value.lv_tag = TAG_FROM_SIGN_AND_SIZE(sign, (size_t)size) |
(op->long_value.lv_tag & SIGN_STATIC);
}

static inline void
_PyLong_SetDigitCount(PyLongObject *op, Py_ssize_t size)
{
assert(size >= 0);
op->long_value.lv_tag = (((size_t)size) << NON_SIZE_BITS) | (op->long_value.lv_tag & SIGN_MASK);
op->long_value.lv_tag = (((size_t)size) << NON_SIZE_BITS) |
(op->long_value.lv_tag & SIGN_MASK) |
(op->long_value.lv_tag & SIGN_STATIC);
}

#define NON_SIZE_MASK ~((1 << NON_SIZE_BITS) - 1)
Expand Down
0