@@ -1108,6 +1108,10 @@ static inline jl_uint128_t zext_read128(const jl_value_t *x, size_t nb) JL_NOTSA
1108
1108
memcpy (& y , x , nb );
1109
1109
return y ;
1110
1110
}
1111
+ static void assign_uint128 (jl_value_t * v , jl_uint128_t x , size_t nb ) JL_NOTSAFEPOINT
1112
+ {
1113
+ memcpy (v , & x , nb );
1114
+ }
1111
1115
#endif
1112
1116
1113
1117
JL_DLLEXPORT jl_value_t * jl_new_bits (jl_value_t * dt , const void * data )
@@ -1173,6 +1177,8 @@ JL_DLLEXPORT jl_value_t *jl_atomic_new_bits(jl_value_t *dt, const char *data)
1173
1177
* (uint64_t * )v = jl_atomic_load ((_Atomic (uint64_t )* )data );
1174
1178
#endif
1175
1179
#if MAX_POINTERATOMIC_SIZE >= 16
1180
+ else if (nb <= 12 )
1181
+ assign_uint128 (v , jl_atomic_load ((_Atomic (jl_uint128_t )* )data ), 12 );
1176
1182
else if (nb <= 16 )
1177
1183
* (jl_uint128_t * )v = jl_atomic_load ((_Atomic (jl_uint128_t )* )data );
1178
1184
#endif
@@ -1239,6 +1245,8 @@ JL_DLLEXPORT jl_value_t *jl_atomic_swap_bits(jl_value_t *dt, char *dst, const jl
1239
1245
* (uint64_t * )v = jl_atomic_exchange ((_Atomic (uint64_t )* )dst , zext_read64 (src , nb ));
1240
1246
#endif
1241
1247
#if MAX_POINTERATOMIC_SIZE >= 16
1248
+ else if (nb <= 12 )
1249
+ assign_uint128 (v , jl_atomic_exchange ((_Atomic (jl_uint128_t )* )dst , zext_read128 (src , nb )), 12 );
1242
1250
else if (nb <= 16 )
1243
1251
* (jl_uint128_t * )v = jl_atomic_exchange ((_Atomic (jl_uint128_t )* )dst , zext_read128 (src , nb ));
1244
1252
#endif
@@ -1288,7 +1296,7 @@ JL_DLLEXPORT int jl_atomic_bool_cmpswap_bits(char *dst, const jl_value_t *expect
1288
1296
return success ;
1289
1297
}
1290
1298
1291
- JL_DLLEXPORT int jl_atomic_cmpswap_bits (jl_datatype_t * dt , jl_value_t * y /* pre-allocated output */ , char * dst , const jl_value_t * expected , const jl_value_t * src , int nb )
1299
+ JL_DLLEXPORT int jl_atomic_cmpswap_bits (jl_datatype_t * dt , jl_value_t * y /* NEW pre-allocated output */ , char * dst , const jl_value_t * expected , const jl_value_t * src , int nb )
1292
1300
{
1293
1301
// dst must have the required alignment for an atomic of the given size
1294
1302
// n.b.: this does not spuriously fail if there are padding bits
@@ -1359,18 +1367,19 @@ JL_DLLEXPORT int jl_atomic_cmpswap_bits(jl_datatype_t *dt, jl_value_t *y /* pre-
1359
1367
#endif
1360
1368
#if MAX_POINTERATOMIC_SIZE >= 16
1361
1369
else if (nb <= 16 ) {
1362
- jl_uint128_t * y128 = (jl_uint128_t * )y ;
1363
1370
if (dt == et ) {
1364
- * y128 = zext_read128 (expected , nb );
1371
+ jl_uint128_t y128 = zext_read128 (expected , nb );
1365
1372
jl_uint128_t z128 = zext_read128 (src , nb );
1366
1373
while (1 ) {
1367
- success = jl_atomic_cmpswap ((_Atomic (jl_uint128_t )* )dst , y128 , z128 );
1368
- if (success || (dt -> layout -> flags .isbitsegal && !dt -> layout -> flags .haspadding ) || !jl_egal__bits (y , expected , dt ))
1374
+ success = jl_atomic_cmpswap ((_Atomic (jl_uint128_t )* )dst , & y128 , z128 );
1375
+ assign_uint128 (y , y128 , nb );
1376
+ if (success || (dt -> layout -> flags .isbitsegal && !dt -> layout -> flags .haspadding ) || !jl_egal__bits (y , expected , dt )) {
1369
1377
break ;
1378
+ }
1370
1379
}
1371
1380
}
1372
1381
else {
1373
- * y128 = jl_atomic_load ((_Atomic (jl_uint128_t )* )dst );
1382
+ assign_uint128 ( y , jl_atomic_load ((_Atomic (jl_uint128_t )* )dst ), nb );
1374
1383
success = 0 ;
1375
1384
}
1376
1385
}
0 commit comments