@@ -399,36 +399,16 @@ bool opal_atomic_compare_exchange_strong_rel_64 (volatile int64_t *addr, int64_t
399
399
400
400
#if defined(DOXYGEN ) || OPAL_HAVE_ATOMIC_MATH_32 || OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_32
401
401
402
- /* OPAL_HAVE_INLINE_ATOMIC_*_32 will be 1 if <arch>/atomic.h provides
403
- a static inline version of it (in assembly). If we have to fall
404
- back on compare-exchange 32, that too will be inline. */
405
- #if OPAL_HAVE_INLINE_ATOMIC_ADD_32 || (!defined(OPAL_HAVE_ATOMIC_ADD_32 ) && OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_32 )
406
- static inline
407
- #endif
408
- int32_t opal_atomic_add_fetch_32 (volatile int32_t * addr , int delta );
409
-
410
- #if OPAL_HAVE_INLINE_ATOMIC_AND_32 || (!defined(OPAL_HAVE_ATOMIC_AND_32 ) && OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_32 )
411
- static inline
412
- #endif
413
- int32_t opal_atomic_and_fetch_32 (volatile int32_t * addr , int32_t value );
414
-
415
- #if OPAL_HAVE_INLINE_ATOMIC_OR_32 || (!defined(OPAL_HAVE_ATOMIC_OR_32 ) && OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_32 )
416
- static inline
417
- #endif
418
- int32_t opal_atomic_or_fetch_32 (volatile int32_t * addr , int32_t value );
419
-
420
- #if OPAL_HAVE_INLINE_ATOMIC_XOR_32 || (!defined(OPAL_HAVE_ATOMIC_XOR_32 ) && OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_32 )
421
- static inline
422
- #endif
423
- int32_t opal_atomic_xor_fetch_32 (volatile int32_t * addr , int32_t value );
424
-
425
- /* OPAL_HAVE_INLINE_ATOMIC_*_32 will be 1 if <arch>/atomic.h provides
426
- a static inline version of it (in assembly). If we have to fall
427
- back to compare-exchange 32, that too will be inline. */
428
- #if OPAL_HAVE_INLINE_ATOMIC_SUB_32 || (!defined(OPAL_HAVE_ATOMIC_ADD_32 ) && OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_32 )
429
- static inline
430
- #endif
431
- int32_t opal_atomic_sub_fetch_32 (volatile int32_t * addr , int delta );
402
+ static inline int32_t opal_atomic_add_fetch_32 (volatile int32_t * addr , int delta );
403
+ static inline int32_t opal_atomic_fetch_add_32 (volatile int32_t * addr , int delta );
404
+ static inline int32_t opal_atomic_and_fetch_32 (volatile int32_t * addr , int32_t value );
405
+ static inline int32_t opal_atomic_fetch_and_32 (volatile int32_t * addr , int32_t value );
406
+ static inline int32_t opal_atomic_or_fetch_32 (volatile int32_t * addr , int32_t value );
407
+ static inline int32_t opal_atomic_fetch_or_32 (volatile int32_t * addr , int32_t value );
408
+ static inline int32_t opal_atomic_xor_fetch_32 (volatile int32_t * addr , int32_t value );
409
+ static inline int32_t opal_atomic_fetch_xor_32 (volatile int32_t * addr , int32_t value );
410
+ static inline int32_t opal_atomic_sub_fetch_32 (volatile int32_t * addr , int delta );
411
+ static inline int32_t opal_atomic_fetch_sub_32 (volatile int32_t * addr , int delta );
432
412
433
413
#endif /* OPAL_HAVE_ATOMIC_MATH_32 */
434
414
@@ -445,36 +425,15 @@ int32_t opal_atomic_sub_fetch_32(volatile int32_t *addr, int delta);
445
425
446
426
#if defined(DOXYGEN ) || OPAL_HAVE_ATOMIC_MATH_64 || OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_64
447
427
448
- /* OPAL_HAVE_INLINE_ATOMIC_*_64 will be 1 if <arch>/atomic.h provides
449
- a static inline version of it (in assembly). If we have to fall
450
- back to compare-exchange 64, that too will be inline */
451
- #if OPAL_HAVE_INLINE_ATOMIC_ADD_64 || (!defined(OPAL_HAVE_ATOMIC_ADD_64 ) && OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_64 )
452
- static inline
453
- #endif
454
- int64_t opal_atomic_add_fetch_64 (volatile int64_t * addr , int64_t delta );
455
-
456
- #if OPAL_HAVE_INLINE_ATOMIC_AND_64 || (!defined(OPAL_HAVE_ATOMIC_AND_64 ) && OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_64 )
457
- static inline
458
- #endif
459
- int64_t opal_atomic_and_fetch_64 (volatile int64_t * addr , int64_t value );
460
-
461
- #if OPAL_HAVE_INLINE_ATOMIC_OR_64 || (!defined(OPAL_HAVE_ATOMIC_OR_64 ) && OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_64 )
462
- static inline
463
- #endif
464
- int64_t opal_atomic_or_fetch_64 (volatile int64_t * addr , int64_t value );
465
-
466
- #if OPAL_HAVE_INLINE_ATOMIC_XOR_64 || (!defined(OPAL_HAVE_ATOMIC_XOR_64 ) && OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_64 )
467
- static inline
468
- #endif
469
- int64_t opal_atomic_xor_fetch_64 (volatile int64_t * addr , int64_t value );
470
-
471
- /* OPAL_HAVE_INLINE_ATOMIC_*_64 will be 1 if <arch>/atomic.h provides
472
- a static inline version of it (in assembly). If we have to fall
473
- back to compare-exchange 64, that too will be inline */
474
- #if OPAL_HAVE_INLINE_ATOMIC_SUB_64 || (!defined(OPAL_HAVE_ATOMIC_ADD_64 ) && OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_64 )
475
- static inline
476
- #endif
477
- int64_t opal_atomic_sub_fetch_64 (volatile int64_t * addr , int64_t delta );
428
+ static inline int64_t opal_atomic_add_fetch_64 (volatile int64_t * addr , int64_t delta );
429
+ static inline int64_t opal_atomic_fetch_add_64 (volatile int64_t * addr , int64_t delta );
430
+ static inline int64_t opal_atomic_and_fetch_64 (volatile int64_t * addr , int64_t value );
431
+ static inline int64_t opal_atomic_fetch_and_64 (volatile int64_t * addr , int64_t value );
432
+ static inline int64_t opal_atomic_or_fetch_64 (volatile int64_t * addr , int64_t value );
433
+ static inline int64_t opal_atomic_fetch_or_64 (volatile int64_t * addr , int64_t value );
434
+ static inline int64_t opal_atomic_fetch_xor_64 (volatile int64_t * addr , int64_t value );
435
+ static inline int64_t opal_atomic_sub_fetch_64 (volatile int64_t * addr , int64_t delta );
436
+ static inline int64_t opal_atomic_fetch_sub_64 (volatile int64_t * addr , int64_t delta );
478
437
479
438
#endif /* OPAL_HAVE_ATOMIC_MATH_32 */
480
439
@@ -501,6 +460,19 @@ opal_atomic_add_fetch_size_t(volatile size_t *addr, size_t delta)
501
460
#error "Unknown size_t size"
502
461
#endif
503
462
}
463
+
464
+ static inline size_t
465
+ opal_atomic_fetch_add_size_t (volatile size_t * addr , size_t delta )
466
+ {
467
+ #if SIZEOF_SIZE_T == 4
468
+ return (size_t ) opal_atomic_fetch_add_32 ((int32_t * ) addr , delta );
469
+ #elif SIZEOF_SIZE_T == 8
470
+ return (size_t ) opal_atomic_fetch_add_64 ((int64_t * ) addr , delta );
471
+ #else
472
+ #error "Unknown size_t size"
473
+ #endif
474
+ }
475
+
504
476
static inline size_t
505
477
opal_atomic_sub_fetch_size_t (volatile size_t * addr , size_t delta )
506
478
{
@@ -512,13 +484,30 @@ opal_atomic_sub_fetch_size_t(volatile size_t *addr, size_t delta)
512
484
#error "Unknown size_t size"
513
485
#endif
514
486
}
487
+
488
+ static inline size_t
489
+ opal_atomic_fetch_sub_size_t (volatile size_t * addr , size_t delta )
490
+ {
491
+ #if SIZEOF_SIZE_T == 4
492
+ return (size_t ) opal_atomic_fetch_sub_32 ((int32_t * ) addr , delta );
493
+ #elif SIZEOF_SIZE_T == 8
494
+ return (size_t ) opal_atomic_fetch_sub_64 ((int64_t * ) addr , delta );
495
+ #else
496
+ #error "Unknown size_t size"
497
+ #endif
498
+ }
499
+
515
500
#else
516
501
#if SIZEOF_SIZE_T == 4
517
- #define opal_atomic_add_fetch_size_t (addr , delta ) ((size_t) opal_atomic_add_fetch_32((int32_t*) addr, delta))
518
- #define opal_atomic_sub_fetch_size_t (addr , delta ) ((size_t) opal_atomic_sub_fetch_32((int32_t*) addr, delta))
519
- #elif SIZEOF_SIZE_T == 8
520
- #define opal_atomic_add_fetch_size_t (addr , delta ) ((size_t) opal_atomic_add_fetch_64((int64_t*) addr, delta))
521
- #define opal_atomic_sub_fetch_size_t (addr , delta ) ((size_t) opal_atomic_sub_fetch_64((int64_t*) addr, delta))
502
+ #define opal_atomic_add_fetch_size_t (addr , delta ) ((size_t) opal_atomic_add_fetch_32((volatile int32_t *) addr, delta))
503
+ #define opal_atomic_fetch_add_size_t (addr , delta ) ((size_t) opal_atomic_fetch_add_32((volatile int32_t *) addr, delta))
504
+ #define opal_atomic_sub_fetch_size_t (addr , delta ) ((size_t) opal_atomic_sub_fetch_32((volatile int32_t *) addr, delta))
505
+ #define opal_atomic_fetch_sub_size_t (addr , delta ) ((size_t) opal_atomic_fetch_sub_32((volatile int32_t *) addr, delta))
506
+ #elif SIZEOF_SIZE_T == 8
507
+ #define opal_atomic_add_fetch_size_t (addr , delta ) ((size_t) opal_atomic_add_fetch_64((volatile int64_t *) addr, delta))
508
+ #define opal_atomic_fetch_add_size_t (addr , delta ) ((size_t) opal_atomic_fetch_add_64((volatile int64_t *) addr, delta))
509
+ #define opal_atomic_sub_fetch_size_t (addr , delta ) ((size_t) opal_atomic_sub_fetch_64((volatile int64_t *) addr, delta))
510
+ #define opal_atomic_fetch_sub_size_t (addr , delta ) ((size_t) opal_atomic_fetch_sub_64((volatile int64_t *) addr, delta))
522
511
#else
523
512
#error "Unknown size_t size"
524
513
#endif
@@ -599,19 +588,15 @@ static inline bool opal_atomic_compare_exchange_strong_rel_ptr (volatile void* a
599
588
600
589
#if defined(DOXYGEN ) || (OPAL_HAVE_ATOMIC_MATH_32 || OPAL_HAVE_ATOMIC_MATH_64 )
601
590
602
- static inline void opal_atomic_add_fetch_xx (volatile void * addr ,
591
+ static inline void opal_atomic_add_xx (volatile void * addr ,
603
592
int32_t value , size_t length );
604
- static inline void opal_atomic_sub_fetch_xx (volatile void * addr ,
593
+ static inline void opal_atomic_sub_xx (volatile void * addr ,
605
594
int32_t value , size_t length );
606
- #if SIZEOF_VOID_P == 4 && OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_32
607
- static inline int32_t opal_atomic_add_fetch_ptr ( volatile void * addr , void * delta );
608
- static inline int32_t opal_atomic_sub_fetch_ptr ( volatile void * addr , void * delta );
609
- #elif SIZEOF_VOID_P == 8 && OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_64
610
- static inline int64_t opal_atomic_add_fetch_ptr ( volatile void * addr , void * delta );
611
- static inline int64_t opal_atomic_sub_fetch_ptr ( volatile void * addr , void * delta );
612
- #else
613
- #error Atomic arithmetic on pointers not supported
614
- #endif
595
+
596
+ static inline intptr_t opal_atomic_add_fetch_ptr ( volatile void * addr , void * delta );
597
+ static inline intptr_t opal_atomic_fetch_add_ptr ( volatile void * addr , void * delta );
598
+ static inline intptr_t opal_atomic_sub_fetch_ptr ( volatile void * addr , void * delta );
599
+ static inline intptr_t opal_atomic_fetch_sub_ptr ( volatile void * addr , void * delta );
615
600
616
601
/**
617
602
* Atomically increment the content depending on the type. This
@@ -623,8 +608,8 @@ static inline int64_t opal_atomic_sub_fetch_ptr( volatile void* addr, void* delt
623
608
* @param addr Address of <TYPE>
624
609
* @param delta Value to add (converted to <TYPE>).
625
610
*/
626
- #define opal_atomic_add_fetch ( ADDR , VALUE ) \
627
- opal_atomic_add_fetch_xx ( (volatile void*)(ADDR), (int32_t)(VALUE), \
611
+ #define opal_atomic_add ( ADDR , VALUE ) \
612
+ opal_atomic_add_xx ( (volatile void*)(ADDR), (int32_t)(VALUE), \
628
613
sizeof(*(ADDR)) )
629
614
630
615
/**
@@ -637,8 +622,8 @@ static inline int64_t opal_atomic_sub_fetch_ptr( volatile void* addr, void* delt
637
622
* @param addr Address of <TYPE>
638
623
* @param delta Value to substract (converted to <TYPE>).
639
624
*/
640
- #define opal_atomic_sub_fetch ( ADDR , VALUE ) \
641
- opal_atomic_sub_fetch_xx ( (volatile void*)(ADDR), (int32_t)(VALUE), \
625
+ #define opal_atomic_sub ( ADDR , VALUE ) \
626
+ opal_atomic_sub_xx ( (volatile void*)(ADDR), (int32_t)(VALUE), \
642
627
sizeof(*(ADDR)) )
643
628
644
629
#endif /* OPAL_HAVE_ATOMIC_MATH_32 || OPAL_HAVE_ATOMIC_MATH_64 */
0 commit comments