diff options
author | Hans Wennborg <hans@hanshq.net> | 2016-06-09 15:54:43 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2016-06-09 15:54:43 +0000 |
commit | 5b89fbc822ab687016280afe7abf388ae2fa9e6e (patch) | |
tree | 93ad2fae75926580bdad1f15dc60a75da62bbd40 /openmp | |
parent | d2454d66e38f9ab6c5212e0cf3520f12ed2b7145 (diff) | |
download | bcm5719-llvm-5b89fbc822ab687016280afe7abf388ae2fa9e6e.tar.gz bcm5719-llvm-5b89fbc822ab687016280afe7abf388ae2fa9e6e.zip |
kmp_lock.h: Fix VS2013 build after r271324
MSVC doesn't allow std::atomic<>s in a union since they don't have trivial
copy constructor. Replacing them with e.g. std::atomic_int works, but that
breaks the GCC build on Linux, because then calls to e.g. std::atomic_load_explicit
fail, as they expect a real std::atomic<> pointer.
Fixing this with an #ifdef to unbreak the build for now.
llvm-svn: 272271
Diffstat (limited to 'openmp')
-rw-r--r-- | openmp/runtime/src/kmp_lock.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/openmp/runtime/src/kmp_lock.h b/openmp/runtime/src/kmp_lock.h index d71317239da..566d74c00f8 100644 --- a/openmp/runtime/src/kmp_lock.h +++ b/openmp/runtime/src/kmp_lock.h @@ -237,6 +237,21 @@ extern void __kmp_destroy_nested_futex_lock( kmp_futex_lock_t *lck ); #ifdef __cplusplus +#ifdef _MSC_VER +// MSVC won't allow use of std::atomic<> in a union since it has non-trivial copy constructor. + +struct kmp_base_ticket_lock { + // `initialized' must be the first entry in the lock data structure! + std::atomic_bool initialized; + volatile union kmp_ticket_lock *self; // points to the lock union + ident_t const * location; // Source code location of omp_init_lock(). + std::atomic_uint next_ticket; // ticket number to give to next thread which acquires + std::atomic_uint now_serving; // ticket number for thread which holds the lock + std::atomic_int owner_id; // (gtid+1) of owning thread, 0 if unlocked + std::atomic_int depth_locked; // depth locked, for nested locks only + kmp_lock_flags_t flags; // lock specifics, e.g. critical section lock +}; +#else struct kmp_base_ticket_lock { // `initialized' must be the first entry in the lock data structure! std::atomic<bool> initialized; @@ -248,6 +263,7 @@ struct kmp_base_ticket_lock { std::atomic<int> depth_locked; // depth locked, for nested locks only kmp_lock_flags_t flags; // lock specifics, e.g. critical section lock }; +#endif #else // __cplusplus |