[PATCH] [libcxx] Add __atomic header that handles needed atomic operations.
David Majnemer
david.majnemer at gmail.com
Fri Jun 12 09:37:51 PDT 2015
================
Comment at: src/mutex.cpp:255-267
@@ -254,9 +254,9 @@
#endif // _LIBCPP_NO_EXCEPTIONS
- flag = 1;
+ __libcpp_atomic_store(&flag, 1, _AO_Relaxed);
pthread_mutex_unlock(&mut);
func(arg);
pthread_mutex_lock(&mut);
- flag = ~0ul;
+ __libcpp_atomic_store(&flag, ~0ul, _AO_Relaxed);
pthread_mutex_unlock(&mut);
pthread_cond_broadcast(&cv);
#ifndef _LIBCPP_NO_EXCEPTIONS
@@ -264,5 +264,5 @@
catch (...)
{
pthread_mutex_lock(&mut);
- flag = 0ul;
+ __libcpp_atomic_store(&flag, 0ul, _AO_Relaxed);
pthread_mutex_unlock(&mut);
----------------
Can you please leave a note that says that these relaxed stores pair with the relaxed load in the header? The atomic nature of the stores look superfluous because they are performed under the mutex.
http://reviews.llvm.org/D10406
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the cfe-commits
mailing list