[llvm] r200360 - Remove unnecessary call to pthread_mutexattr_setpshared()

Mark Seaborn mseaborn at chromium.org
Tue Jan 28 16:20:44 PST 2014


Author: mseaborn
Date: Tue Jan 28 18:20:44 2014
New Revision: 200360

URL: http://llvm.org/viewvc/llvm-project?rev=200360&view=rev
Log:
Remove unnecessary call to pthread_mutexattr_setpshared()

The default value of this attribute is PTHREAD_PROCESS_PRIVATE, so
there's no point in calling pthread_mutexattr_setpshared() to set
that.

See: http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_mutexattr_getpshared.html

This removes some ifdefs that tend to need to be extended for other
platforms (e.g. for NaCl).

Note that this call was in the first implementation of Mutex, added in
r22403, so it doesn't appear to have been added in response to a
performance problem.

Differential Revision: http://llvm-reviews.chandlerc.com/D2633

Modified:
    llvm/trunk/lib/Support/Mutex.cpp

Modified: llvm/trunk/lib/Support/Mutex.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Mutex.cpp?rev=200360&r1=200359&r2=200360&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Mutex.cpp (original)
+++ llvm/trunk/lib/Support/Mutex.cpp Tue Jan 28 18:20:44 2014
@@ -59,13 +59,6 @@ MutexImpl::MutexImpl( bool recursive)
   errorcode = pthread_mutexattr_settype(&attr, kind);
   assert(errorcode == 0);
 
-#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && \
-    !defined(__DragonFly__) && !defined(__Bitrig__)
-  // Make it a process local mutex
-  errorcode = pthread_mutexattr_setpshared(&attr, PTHREAD_PROCESS_PRIVATE);
-  assert(errorcode == 0);
-#endif
-
   // Initialize the mutex
   errorcode = pthread_mutex_init(mutex, &attr);
   assert(errorcode == 0);





More information about the llvm-commits mailing list