aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/stream_executor/platform
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <nobody@tensorflow.org>2016-05-23 14:59:26 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-05-23 16:03:09 -0700
commit81af087fb71a8323b0af09694a4de1ab54646de8 (patch)
tree0f06c3289f848c387ed331646ff81620c7d08750 /tensorflow/stream_executor/platform
parent5ab5d97710e27022b789939b26f63386abdfb526 (diff)
Add macros for mutex_lock and shared_lock, so compilation fails if
mutex_lock is used incorrectly with mutex_lock(mu) Change: 123048062
Diffstat (limited to 'tensorflow/stream_executor/platform')
-rw-r--r--tensorflow/stream_executor/platform/default/mutex.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/tensorflow/stream_executor/platform/default/mutex.h b/tensorflow/stream_executor/platform/default/mutex.h
index 0ce1eeadbb..b834895da5 100644
--- a/tensorflow/stream_executor/platform/default/mutex.h
+++ b/tensorflow/stream_executor/platform/default/mutex.h
@@ -35,6 +35,9 @@ limitations under the License.
namespace perftools {
namespace gputools {
+#undef mutex_lock
+#undef shared_lock
+
enum ConditionResult { kCond_Timeout, kCond_MaybeNotified };
#ifdef STREAM_EXECUTOR_USE_SHARED_MUTEX
@@ -62,6 +65,9 @@ class SCOPED_LOCKABLE mutex_lock : public std::unique_lock<BaseMutex> {
~mutex_lock() RELEASE() {}
};
+// Catch bug where variable name is omitted, e.g. mutex_lock (mu);
+#define mutex_lock(x) static_assert(0, "mutex_lock_decl_missing_var_name");
+
#ifdef STREAM_EXECUTOR_USE_SHARED_MUTEX
// TODO(vrv): Annotate these with ACQUIRE_SHARED after implementing
// as classes.
@@ -70,6 +76,9 @@ typedef std::shared_lock<BaseMutex> shared_lock;
typedef mutex_lock shared_lock;
#endif
+// Catch bug where variable name is omitted, e.g. shared_lock (mu);
+#define shared_lock(x) static_assert(0, "shared_lock_decl_missing_var_name");
+
using std::condition_variable;
inline ConditionResult WaitForMilliseconds(mutex_lock* mu,