[llvm-commits] [llvm] r81110 - in /llvm/trunk: include/llvm/System/Mutex.h lib/System/Mutex.cpp lib/System/RWMutex.cpp lib/System/Unix/Process.inc
Duncan Sands
baldrick at free.fr
Sun Sep 6 03:53:23 PDT 2009
Author: baldrick
Date: Sun Sep 6 05:53:22 2009
New Revision: 81110
URL: http://llvm.org/viewvc/llvm-project?rev=81110&view=rev
Log:
Tweak code into an equivalent form for which icc
doesn't warn about unreachable instructions. Patch
by Erick Tryzelaar (#111).
Modified:
llvm/trunk/include/llvm/System/Mutex.h
llvm/trunk/lib/System/Mutex.cpp
llvm/trunk/lib/System/RWMutex.cpp
llvm/trunk/lib/System/Unix/Process.inc
Modified: llvm/trunk/include/llvm/System/Mutex.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/System/Mutex.h?rev=81110&r1=81109&r2=81110&view=diff
==============================================================================
--- llvm/trunk/include/llvm/System/Mutex.h (original)
+++ llvm/trunk/include/llvm/System/Mutex.h Sun Sep 6 05:53:22 2009
@@ -93,32 +93,36 @@
MutexImpl(rec), acquired(0), recursive(rec) { }
bool acquire() {
- if (!mt_only || llvm_is_multithreaded())
+ if (!mt_only || llvm_is_multithreaded()) {
return MutexImpl::acquire();
-
- // Single-threaded debugging code. This would be racy in multithreaded
- // mode, but provides not sanity checks in single threaded mode.
- assert((recursive || acquired == 0) && "Lock already acquired!!");
- ++acquired;
- return true;
+ } else {
+ // Single-threaded debugging code. This would be racy in
+ // multithreaded mode, but provides not sanity checks in single
+ // threaded mode.
+ assert((recursive || acquired == 0) && "Lock already acquired!!");
+ ++acquired;
+ return true;
+ }
}
bool release() {
- if (!mt_only || llvm_is_multithreaded())
+ if (!mt_only || llvm_is_multithreaded()) {
return MutexImpl::release();
-
- // Single-threaded debugging code. This would be racy in multithreaded
- // mode, but provides not sanity checks in single threaded mode.
- assert(((recursive && acquired) || (acquired == 1)) &&
- "Lock not acquired before release!");
- --acquired;
- return true;
+ } else {
+ // Single-threaded debugging code. This would be racy in
+ // multithreaded mode, but provides not sanity checks in single
+ // threaded mode.
+ assert(((recursive && acquired) || (acquired == 1)) &&
+ "Lock not acquired before release!");
+ --acquired;
+ return true;
+ }
}
bool tryacquire() {
if (!mt_only || llvm_is_multithreaded())
return MutexImpl::tryacquire();
- return true;
+ else return true;
}
private:
Modified: llvm/trunk/lib/System/Mutex.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Mutex.cpp?rev=81110&r1=81109&r2=81110&view=diff
==============================================================================
--- llvm/trunk/lib/System/Mutex.cpp (original)
+++ llvm/trunk/lib/System/Mutex.cpp Sun Sep 6 05:53:22 2009
@@ -115,8 +115,7 @@
int errorcode = pthread_mutex_lock(mutex);
return errorcode == 0;
- }
- return false;
+ } else return false;
}
bool
@@ -129,8 +128,7 @@
int errorcode = pthread_mutex_unlock(mutex);
return errorcode == 0;
- }
- return false;
+ } else return false;
}
bool
@@ -143,8 +141,7 @@
int errorcode = pthread_mutex_trylock(mutex);
return errorcode == 0;
- }
- return false;
+ } else return false;
}
}
Modified: llvm/trunk/lib/System/RWMutex.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/RWMutex.cpp?rev=81110&r1=81109&r2=81110&view=diff
==============================================================================
--- llvm/trunk/lib/System/RWMutex.cpp (original)
+++ llvm/trunk/lib/System/RWMutex.cpp Sun Sep 6 05:53:22 2009
@@ -117,8 +117,7 @@
int errorcode = pthread_rwlock_rdlock(rwlock);
return errorcode == 0;
- }
- return false;
+ } else return false;
}
bool
@@ -131,8 +130,7 @@
int errorcode = pthread_rwlock_unlock(rwlock);
return errorcode == 0;
- }
- return false;
+ } else return false;
}
bool
@@ -145,8 +143,7 @@
int errorcode = pthread_rwlock_wrlock(rwlock);
return errorcode == 0;
- }
- return false;
+ } else return false;
}
bool
@@ -159,8 +156,7 @@
int errorcode = pthread_rwlock_unlock(rwlock);
return errorcode == 0;
- }
- return false;
+ } else return false;
}
}
Modified: llvm/trunk/lib/System/Unix/Process.inc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/Unix/Process.inc?rev=81110&r1=81109&r2=81110&view=diff
==============================================================================
--- llvm/trunk/lib/System/Unix/Process.inc (original)
+++ llvm/trunk/lib/System/Unix/Process.inc Sun Sep 6 05:53:22 2009
@@ -181,25 +181,28 @@
bool Process::StandardInIsUserInput() {
#if HAVE_ISATTY
return isatty(0);
-#endif
+#else
// If we don't have isatty, just return false.
return false;
+#endif
}
bool Process::StandardOutIsDisplayed() {
#if HAVE_ISATTY
return isatty(1);
-#endif
+#else
// If we don't have isatty, just return false.
return false;
+#endif
}
bool Process::StandardErrIsDisplayed() {
#if HAVE_ISATTY
return isatty(2);
-#endif
+#else
// If we don't have isatty, just return false.
return false;
+#endif
}
static unsigned getColumns(int FileID) {
More information about the llvm-commits
mailing list