Skip to content

Commit ac4e968

Browse files
committed
use _Py_IS_ALIGNED()
1 parent 26ee081 commit ac4e968

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Include/cpython/pyatomic.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -551,8 +551,8 @@ static inline void *
551551
_Py_atomic_memcpy_ptr_store_relaxed(void *dest, void *src, Py_ssize_t n)
552552
{
553553
size_t size = (size_t)n;
554-
assert(((uintptr_t)dest & (sizeof (void *) - 1)) == 0);
555-
assert(((uintptr_t)src & (sizeof (void *) - 1)) == 0);
554+
assert(_Py_IS_ALIGNED(dest, sizeof(void *)));
555+
assert(_Py_IS_ALIGNED(src, sizeof(void *)));
556556
assert(size % sizeof(void *) == 0);
557557

558558
if (dest != src) {
@@ -572,8 +572,8 @@ static inline void *
572572
_Py_atomic_memmove_ptr_store_relaxed(void *dest, void *src, Py_ssize_t n)
573573
{
574574
size_t size = (size_t)n;
575-
assert(((uintptr_t)dest & (sizeof (void *) - 1)) == 0);
576-
assert(((uintptr_t)src & (sizeof (void *) - 1)) == 0);
575+
assert(_Py_IS_ALIGNED(dest, sizeof(void *)));
576+
assert(_Py_IS_ALIGNED(src, sizeof(void *)));
577577
assert(size % sizeof(void *) == 0);
578578

579579
if (dest < src || dest >= (void *)((char *)src + size)) {

Include/internal/pycore_list.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ _Py_memory_ptrs_repeat(char* dest, Py_ssize_t len_dest, Py_ssize_t len_src)
5959
{
6060
assert(len_src > 0);
6161
assert(len_src % sizeof(void *) == 0);
62-
assert(((uintptr_t)dest & (sizeof (void *) - 1)) == 0);
62+
assert(_Py_IS_ALIGNED(dest, sizeof(void *)));
6363
Py_ssize_t copied = len_src;
6464
while (copied < len_dest) {
6565
Py_ssize_t bytes_to_copy = Py_MIN(copied, len_dest - copied);

0 commit comments

Comments
 (0)