4141 * The following #defines will be true / false based on
4242 * assembly support:
4343 *
44- * - \c OPAL_HAVE_ATOMIC_SPINLOCKS atomic spinlocks
45- *
4644 * Note that for the Atomic math, atomic add/sub may be implemented as
4745 * C code using opal_atomic_compare_exchange. The appearance of atomic
4846 * operation will be upheld in these cases.
6664
6765
6866BEGIN_C_DECLS
69- /**********************************************************************
70- *
71- * Data structures for atomic ops
72- *
73- *********************************************************************/
74- /**
75- * Volatile lock object (with optional padding).
76- *
77- * \note The internals of the lock are included here, but should be
78- * considered private. The implementation currently in use may choose
79- * to use an int or unsigned char as the lock value - the user is not
80- * informed either way.
81- */
82- struct opal_atomic_lock_t {
83- union {
84- opal_atomic_int32_t lock ; /**< The lock address (an integer) */
85- volatile unsigned char sparc_lock ; /**< The lock address on sparc */
86- char padding [sizeof (int )]; /**< Array for optional padding */
87- } u ;
88- };
89- typedef struct opal_atomic_lock_t opal_atomic_lock_t ;
9067
9168/**********************************************************************
9269 *
@@ -105,16 +82,6 @@ typedef struct opal_atomic_lock_t opal_atomic_lock_t;
10582#define OPAL_HAVE_INLINE_ATOMIC_XOR_64 1
10683#define OPAL_HAVE_INLINE_ATOMIC_SUB_64 1
10784
108- /**
109- * Enumeration of lock states
110- */
111- enum { OPAL_ATOMIC_LOCK_UNLOCKED = 0 , OPAL_ATOMIC_LOCK_LOCKED = 1 };
112-
113- # define OPAL_ATOMIC_LOCK_INIT \
114- { \
115- .u = {.lock = OPAL_ATOMIC_LOCK_UNLOCKED } \
116- }
117-
11885/**********************************************************************
11986 *
12087 * Load the appropriate architecture files and set some reasonable
@@ -374,73 +341,39 @@ static inline intptr_t opal_atomic_swap_ptr(opal_atomic_intptr_t *addr, intptr_t
374341
375342/**********************************************************************
376343 *
377- * Atomic spinlocks - always inlined, if have atomic compare-and-swap
344+ * Atomic spinlocks
378345 *
379346 *********************************************************************/
380-
381- # if !defined(OPAL_HAVE_ATOMIC_SPINLOCKS ) && !defined(DOXYGEN )
382- /* 0 is more like "pending" - we'll fix up at the end after all
383- the static inline functions are declared */
384- # define OPAL_HAVE_ATOMIC_SPINLOCKS 0
385- # endif
386-
387- # if defined(DOXYGEN ) || OPAL_HAVE_ATOMIC_SPINLOCKS \
388- || (OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_32 || OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_64 )
389-
390347/**
391348 * Initialize a lock to value
392349 *
393350 * @param lock Address of the lock
394351 * @param value Initial value to set lock to
395352 */
396- # if OPAL_HAVE_ATOMIC_SPINLOCKS == 0
397- static inline
398- # endif
399- void
400- opal_atomic_lock_init (opal_atomic_lock_t * lock , int32_t value );
353+ static inline void opal_atomic_lock_init (opal_atomic_lock_t * lock , int32_t value );
401354
402355/**
403356 * Try to acquire a lock.
404357 *
405358 * @param lock Address of the lock.
406359 * @return 0 if the lock was acquired, 1 otherwise.
407360 */
408- # if OPAL_HAVE_ATOMIC_SPINLOCKS == 0
409- static inline
410- # endif
411- int
412- opal_atomic_trylock (opal_atomic_lock_t * lock );
361+ static inline int opal_atomic_trylock (opal_atomic_lock_t * lock );
413362
414363/**
415364 * Acquire a lock by spinning.
416365 *
417366 * @param lock Address of the lock.
418367 */
419- # if OPAL_HAVE_ATOMIC_SPINLOCKS == 0
420- static inline
421- # endif
422- void
423- opal_atomic_lock (opal_atomic_lock_t * lock );
368+ static inline void opal_atomic_lock (opal_atomic_lock_t * lock );
424369
425370/**
426371 * Release a lock.
427372 *
428373 * @param lock Address of the lock.
429374 */
430- # if OPAL_HAVE_ATOMIC_SPINLOCKS == 0
431- static inline
432- # endif
433- void
434- opal_atomic_unlock (opal_atomic_lock_t * lock );
435-
436- # if OPAL_HAVE_ATOMIC_SPINLOCKS == 0
437- # undef OPAL_HAVE_ATOMIC_SPINLOCKS
438- # define OPAL_HAVE_ATOMIC_SPINLOCKS \
439- (OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_32 || OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_64)
440- # define OPAL_NEED_INLINE_ATOMIC_SPINLOCKS 1
441- # endif
375+ static inline void opal_atomic_unlock (opal_atomic_lock_t * lock );
442376
443- # endif /* OPAL_HAVE_ATOMIC_SPINLOCKS */
444377
445378/**********************************************************************
446379 *
0 commit comments