@@ -215,140 +215,6 @@ arraydata_realloc(arraydata *data, Py_ssize_t size, int itemsize)
215215
216216#endif
217217
218- #ifdef Py_GIL_DISABLED
219-
220- // This really doesn't belong here, for show at the moment.
221- static void
222- _Py_atomic_source_memcpy_relaxed (void * dest , void * src , size_t n )
223- {
224- int diff = (int )((uintptr_t )dest ^ (uintptr_t )src );
225-
226- // the first half is needed to deal with misalignment
227-
228- if (diff & 1 ) { // dest and src not word aligned with each other
229- for (void * end = (char * )dest + n ; dest < end ;
230- dest = (char * )dest + 1 , src = (char * )src + 1 ) {
231- * ((char * )dest ) = _Py_atomic_load_char_relaxed ((char * )src );
232- }
233-
234- return ;
235- }
236-
237- if ((uintptr_t )dest & 1 ) { // dest and src not word aligned in memory
238- if (n ) {
239- * (char * )dest = _Py_atomic_load_char_relaxed ((char * )src );
240- dest = (char * )dest + 1 ;
241- src = (char * )src + 1 ;
242- n -= 1 ;
243- }
244-
245- if (!n ) {
246- return ;
247- }
248- }
249-
250- if (diff & 2 ) { // dest and src not dword aligned with each other
251- size_t n2 = n / 2 ;
252-
253- for (void * end = (short * )dest + n2 ; dest < end ;
254- dest = (short * )dest + 1 , src = (short * )src + 1 ) {
255- * ((short * )dest ) = _Py_atomic_load_short_relaxed ((short * )src );
256- }
257-
258- if (n & 1 ) {
259- * ((char * )dest ) = _Py_atomic_load_char_relaxed ((char * )src );
260- }
261-
262- return ;
263- }
264-
265- if ((uintptr_t )dest & 2 ) { // dest and src not dword aligned in memory
266- if (n >= 2 ) {
267- * (short * )dest = _Py_atomic_load_short_relaxed ((short * )src );
268- dest = (short * )dest + 1 ;
269- src = (short * )src + 1 ;
270- n -= 2 ;
271- }
272-
273- if (!n ) {
274- return ;
275- }
276- }
277-
278- if (diff & 4 ) { // dest and src not qword aligned with each other
279- size_t n4 = n / 4 ;
280-
281- for (void * end = (PY_UINT32_T * )dest + n4 ; dest < end ;
282- dest = (PY_UINT32_T * )dest + 1 , src = (PY_UINT32_T * )src + 1 ) {
283- * ((PY_UINT32_T * )dest ) = (PY_UINT32_T )_Py_atomic_load_uint32_relaxed ((PY_UINT32_T * )src );
284- }
285-
286- if (n & 2 ) {
287- * ((short * )dest ) = _Py_atomic_load_short_relaxed ((short * )src );
288- dest = (short * )dest + 1 ;
289- src = (short * )src + 1 ;
290- }
291-
292- if (n & 1 ) {
293- * ((char * )dest ) = _Py_atomic_load_char_relaxed ((char * )src );
294- }
295-
296- return ;
297- }
298-
299- if ((uintptr_t )dest & 4 ) { // dest and src not qword aligned in memory
300- if (n >= 4 ) {
301- * (PY_UINT32_T * )dest = _Py_atomic_load_uint32_relaxed ((PY_UINT32_T * )src );
302- dest = (PY_UINT32_T * )dest + 1 ;
303- src = (PY_UINT32_T * )src + 1 ;
304- n -= 4 ;
305- }
306-
307- if (!n ) {
308- return ;
309- }
310- }
311-
312- // the second half is aligned copy
313-
314- size_t n8 = n / 8 ;
315-
316- if (n8 ) {
317- for (void * end = (PY_UINT64_T * )dest + n8 ; dest < end ;
318- dest = (PY_UINT64_T * )dest + 1 , src = (PY_UINT64_T * )src + 1 ) {
319- * ((PY_UINT64_T * )dest ) = (PY_UINT64_T )_Py_atomic_load_uint64_relaxed ((PY_UINT64_T * )src );
320- }
321-
322- n -= n8 * 8 ;
323- }
324-
325- if (n & 4 ) {
326- * ((PY_UINT32_T * )dest ) = (PY_UINT32_T )_Py_atomic_load_uint32_relaxed ((PY_UINT32_T * )src );
327- dest = (PY_UINT32_T * )dest + 1 ;
328- src = (PY_UINT32_T * )src + 1 ;
329- }
330-
331- if (n & 2 ) {
332- * ((short * )dest ) = _Py_atomic_load_short_relaxed ((short * )src );
333- dest = (short * )dest + 1 ;
334- src = (short * )src + 1 ;
335- }
336-
337- if (n & 1 ) {
338- * ((char * )dest ) = _Py_atomic_load_char_relaxed ((char * )src );
339- }
340- }
341-
342- #define FT_ATOMIC_SOURCE_MEMCPY_RELAXED (dest , src , n ) \
343- _Py_atomic_source_memcpy_relaxed((dest), (src), (n))
344-
345- #else
346-
347- #define FT_ATOMIC_SOURCE_MEMCPY_RELAXED (dest , src , n ) \
348- memcpy((dest), (src), (n))
349-
350- #endif
351-
352218static int
353219array_resize (arrayobject * self , Py_ssize_t newsize )
354220{
@@ -425,7 +291,7 @@ array_resize(arrayobject *self, Py_ssize_t newsize)
425291 }
426292 if (data != NULL ) {
427293 Py_ssize_t size = Py_SIZE (self );
428- FT_ATOMIC_SOURCE_MEMCPY_RELAXED (newdata -> items , data -> items , Py_MIN (size , newsize ) * itemsize );
294+ memcpy (newdata -> items , data -> items , Py_MIN (size , newsize ) * itemsize );
429295 arraydata_free (data , _PyObject_GC_IS_SHARED (self ));
430296 }
431297 _Py_atomic_store_ptr_release (& self -> data , newdata );
@@ -1337,8 +1203,7 @@ array_slice(arrayobject *a, Py_ssize_t ilow, Py_ssize_t ihigh)
13371203 if (np == NULL )
13381204 return NULL ;
13391205 if (ihigh > ilow ) {
1340- FT_ATOMIC_SOURCE_MEMCPY_RELAXED (
1341- np -> data -> items , a -> data -> items + ilow * a -> ob_descr -> itemsize ,
1206+ memcpy (np -> data -> items , a -> data -> items + ilow * a -> ob_descr -> itemsize ,
13421207 (ihigh - ilow ) * a -> ob_descr -> itemsize );
13431208 }
13441209 return (PyObject * )np ;
@@ -2990,7 +2855,7 @@ array_subscr_slice_lock_held(PyObject *op, PyObject *item)
29902855 slicelength , self -> ob_descr );
29912856 if (result == NULL )
29922857 return NULL ;
2993- FT_ATOMIC_SOURCE_MEMCPY_RELAXED (((arrayobject * )result )-> data -> items ,
2858+ memcpy (((arrayobject * )result )-> data -> items ,
29942859 self -> data -> items + start * itemsize ,
29952860 slicelength * itemsize );
29962861 return result ;
0 commit comments