Skip to content

Commit 057a6b5

Browse files
committed
Change atomic inclusion to make C11 less unique
With the previous refactoring and breaking out the implementation code into seperate headers, it is no longer required that the atomic_stdc.h implementation be included "special" in the atomics header. Clean up the ordering of includes so that every implementation follows the same include ordering. The stdc implementations of the atomics is type independent and we don't enforce inline wrappers because that results in a massive number of warnings from opal_lifo due to its interesting use of volatile. This patch takes the do-no-harm approach, but we need to clean up opal_lifo in a future patch. Signed-off-by: Brian Barrett <[email protected]>
1 parent 14c5d15 commit 057a6b5

File tree

2 files changed

+53
-53
lines changed

2 files changed

+53
-53
lines changed

opal/include/opal/sys/atomic.h

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -56,55 +56,8 @@
5656
#include "opal/sys/architecture.h"
5757
#include "opal_stdatomic.h"
5858

59-
#if OPAL_ASSEMBLY_BUILTIN == OPAL_BUILTIN_C11 && !defined(__INTEL_COMPILER)
60-
61-
# include "atomic_stdc.h"
62-
63-
#else /* !OPAL_C_HAVE__ATOMIC */
64-
65-
6659
BEGIN_C_DECLS
6760

68-
/**********************************************************************
69-
*
70-
* Load the appropriate architecture files and set some reasonable
71-
* default values for our support
72-
*
73-
*********************************************************************/
74-
# if defined(DOXYGEN)
75-
/* don't include system-level gorp when generating doxygen files */
76-
# elif OPAL_ASSEMBLY_BUILTIN == OPAL_BUILTIN_GCC
77-
# include "opal/sys/gcc_builtin/atomic.h"
78-
# elif OPAL_ASSEMBLY_ARCH == OPAL_X86_64
79-
# include "opal/sys/x86_64/atomic.h"
80-
# elif OPAL_ASSEMBLY_ARCH == OPAL_ARM
81-
# include "opal/sys/arm/atomic.h"
82-
# elif OPAL_ASSEMBLY_ARCH == OPAL_ARM64
83-
# include "opal/sys/arm64/atomic.h"
84-
# elif OPAL_ASSEMBLY_ARCH == OPAL_IA32
85-
# include "opal/sys/ia32/atomic.h"
86-
# elif OPAL_ASSEMBLY_ARCH == OPAL_POWERPC32
87-
# include "opal/sys/powerpc/atomic.h"
88-
# elif OPAL_ASSEMBLY_ARCH == OPAL_POWERPC64
89-
# include "opal/sys/powerpc/atomic.h"
90-
# endif
91-
92-
# ifndef DOXYGEN
93-
/* compare and set operations can't really be emulated from software,
94-
so if these defines aren't already set, they should be set to 0
95-
now */
96-
# ifndef OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_128
97-
# define OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_128 0
98-
# endif
99-
# ifndef OPAL_HAVE_ATOMIC_LLSC_32
100-
# define OPAL_HAVE_ATOMIC_LLSC_32 0
101-
# endif
102-
# ifndef OPAL_HAVE_ATOMIC_LLSC_64
103-
# define OPAL_HAVE_ATOMIC_LLSC_64 0
104-
# endif
105-
# endif /* DOXYGEN */
106-
107-
10861
/**********************************************************************
10962
*
11063
* Memory Barriers
@@ -158,6 +111,18 @@ static inline void opal_atomic_wmb(void);
158111
* over the 32 and 64 bit implementations).
159112
*
160113
*********************************************************************/
114+
115+
/*
116+
* The stdc implementation is implemetned as macros around the C11
117+
* atomic interface (which is a type-independent interface). While it
118+
* would be better to have type checking so developers using the C11
119+
* interface didn't accidently munge something that broke on other
120+
* implementations, there are a ton of warnings due to volatile casing
121+
* in the opal_lifo code. Don't enforce the types of the function
122+
* calls on C11 until we can sort that out.
123+
*/
124+
#if !(OPAL_ASSEMBLY_BUILTIN == OPAL_BUILTIN_C11 && !defined(__INTEL_COMPILER))
125+
161126
/**
162127
* Atomic compare and set of 32 bit intergers with acquire and release semantics.
163128
*
@@ -284,7 +249,6 @@ static inline bool opal_atomic_compare_exchange_strong_acq_ptr(opal_atomic_intpt
284249
static inline bool opal_atomic_compare_exchange_strong_rel_ptr(opal_atomic_intptr_t *addr,
285250
intptr_t *oldval, intptr_t newval);
286251

287-
288252
/**********************************************************************
289253
*
290254
* Swap
@@ -321,6 +285,8 @@ static inline int64_t opal_atomic_swap_64(opal_atomic_int64_t *addr, int64_t new
321285
*/
322286
static inline intptr_t opal_atomic_swap_ptr(opal_atomic_intptr_t *addr, intptr_t newval);
323287

288+
#endif /* #if !(OPAL_ASSEMBLY_BUILTIN == OPAL_BUILTIN_C11 && !defined(__INTEL_COMPILER)) */
289+
324290

325291
/**********************************************************************
326292
*
@@ -410,8 +376,6 @@ static inline size_t opal_atomic_fetch_add_size_t(opal_atomic_size_t *addr, size
410376
static inline void opal_atomic_add(type *addr, type delta);
411377
#endif
412378

413-
#endif /* !OPAL_C_HAVE__ATOMIC */
414-
415379

416380
/**********************************************************************
417381
*
@@ -444,20 +408,56 @@ static inline void opal_atomic_sc_ptr(opal_atomic_intptr_t *addr, intptr_t newva
444408

445409
#endif
446410

411+
412+
/**********************************************************************
413+
*
414+
* Load the appropriate architecture files and set some reasonable
415+
* default values for our support
416+
*
417+
*********************************************************************/
418+
419+
#if defined(DOXYGEN)
420+
/* don't include system-level gorp when generating doxygen files */
421+
#elif OPAL_ASSEMBLY_BUILTIN == OPAL_BUILTIN_C11 && !defined(__INTEL_COMPILER)
422+
# include "opal/sys/atomic_stdc.h"
423+
#elif OPAL_ASSEMBLY_BUILTIN == OPAL_BUILTIN_GCC
424+
# include "opal/sys/gcc_builtin/atomic.h"
425+
#elif OPAL_ASSEMBLY_ARCH == OPAL_X86_64
426+
# include "opal/sys/x86_64/atomic.h"
427+
#elif OPAL_ASSEMBLY_ARCH == OPAL_ARM64
428+
# include "opal/sys/arm64/atomic.h"
429+
#elif OPAL_ASSEMBLY_ARCH == OPAL_POWERPC64
430+
# include "opal/sys/powerpc/atomic.h"
431+
#endif
432+
447433
#if OPAL_ASSEMBLY_ARCH == OPAL_ARM64
448434
# include "opal/sys/arm64/atomic_llsc.h"
449435
#elif OPAL_ASSEMBLY_ARCH == OPAL_POWERPC64
450436
# include "opal/sys/powerpc/atomic_llsc.h"
451437
#endif
452438

453-
#if !defined(OPAL_HAVE_ATOMIC_LLSC_32)
439+
440+
/**********************************************************************
441+
*
442+
* Ensure defines for the few optional features are always defined
443+
*
444+
*********************************************************************/
445+
446+
#ifndef OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_128
447+
# define OPAL_HAVE_ATOMIC_COMPARE_EXCHANGE_128 0
448+
#endif
449+
450+
#ifndef OPAL_HAVE_ATOMIC_LLSC_32
454451
# define OPAL_HAVE_ATOMIC_LLSC_32 0
455452
#endif
456453

457-
#if !defined(OPAL_HAVE_ATOMIC_LLSC_64)
454+
#ifndef OPAL_HAVE_ATOMIC_LLSC_64
458455
# define OPAL_HAVE_ATOMIC_LLSC_64 0
459456
#endif
460457

458+
#ifndef OPAL_HAVE_ATOMIC_LLSC_PTR
459+
# define OPAL_HAVE_ATOMIC_LLSC_PTR 0
460+
#endif
461461

462462
END_C_DECLS
463463

opal/include/opal/sys/atomic_stdc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ opal_atomic_compare_exchange_strong_128(opal_atomic_int128_t *addr, opal_int128_
149149
/*
150150
* Lock initialization function. It set the lock to UNLOCKED.
151151
*/
152-
static inline void opal_atomic_lock_init(opal_atomic_lock_t *lock, bool value)
152+
static inline void opal_atomic_lock_init(opal_atomic_lock_t *lock, int32_t value)
153153
{
154154
atomic_flag_clear_explicit(lock, memory_order_relaxed);
155155
}

0 commit comments

Comments
 (0)