Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
gh-129069: make list ass_slice and memory_repeat safe in free-threading#131882
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
0c8dcfc
67c9459
e460b5a
fcdb634
b1e9216
944abf0
3a9e249
0f96d58
47f3d81
adf2c15
b569865
87d48ff
26ee081
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -545,6 +545,64 @@ static inline Py_ssize_t | ||
_Py_atomic_load_ssize_acquire(const Py_ssize_t *obj); | ||
// --- _Py_atomic_memcpy / _Py_atomic_memmove ------------ | ||
static inline void * | ||
_Py_atomic_memcpy_ptr_relaxed(void *dest, void *src, Py_ssize_t sn) | ||
{ | ||
size_t n = (size_t)sn; | ||
assert(((uintptr_t)dest & (sizeof (void *) - 1)) == 0); | ||
assert(((uintptr_t)src & (sizeof (void *) - 1)) == 0); | ||
assert(n % sizeof(void *) == 0); | ||
if (dest != src) { | ||
void **d = (void **)dest; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. For the sake of my brain: could we use some more descriptive variable names here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. How brain feel about these? | ||
void **s = (void **)src; | ||
void **e = d + n / sizeof(void *); | ||
for (; d != e; d++, s++) { | ||
void *v = _Py_atomic_load_ptr_relaxed(s); | ||
_Py_atomic_store_ptr_relaxed(d, v); | ||
} | ||
} | ||
return dest; | ||
} | ||
static inline void * | ||
_Py_atomic_memmove_ptr_relaxed(void *dest, void *src, Py_ssize_t sn) | ||
{ | ||
size_t n = (size_t)sn; | ||
assert(((uintptr_t)dest & (sizeof (void *) - 1)) == 0); | ||
assert(((uintptr_t)src & (sizeof (void *) - 1)) == 0); | ||
assert(n % sizeof(void *) == 0); | ||
if (dest < src || dest >= (void *)((char *)src + n)) { | ||
void **d = (void **)dest; | ||
void **s = (void **)src; | ||
void **e = d + n / sizeof(void *); | ||
for (; d != e; d++, s++) { | ||
void *v = _Py_atomic_load_ptr_relaxed(s); | ||
_Py_atomic_store_ptr_relaxed(d, v); | ||
} | ||
} | ||
else if (dest > src) { | ||
n = n / sizeof(void *) - 1; | ||
void **d = (void **)dest + n; | ||
void **s = (void **)src + n; | ||
void **e = (void **)dest - 1; | ||
for (; d != e; d--, s--) { | ||
void *v = _Py_atomic_load_ptr_relaxed(s); | ||
_Py_atomic_store_ptr_relaxed(d, v); | ||
} | ||
} | ||
return dest; | ||
} | ||
// --- _Py_atomic_fence ------------------------------------------------------ | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Fix data race andavoid jagged writes in ``list.list_ass_slice``. |
Uh oh!
There was an error while loading.Please reload this page.