summaryrefslogtreecommitdiff
path: root/services/surfaceflinger/MutexUtils.h
diff options
context:
space:
mode:
Diffstat (limited to 'services/surfaceflinger/MutexUtils.h')
-rw-r--r--services/surfaceflinger/MutexUtils.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/services/surfaceflinger/MutexUtils.h b/services/surfaceflinger/MutexUtils.h
index f8be6f3b85..58f7cb4c43 100644
--- a/services/surfaceflinger/MutexUtils.h
+++ b/services/surfaceflinger/MutexUtils.h
@@ -50,4 +50,14 @@ struct SCOPED_CAPABILITY TimedLock {
const status_t status;
};
+// Require, under penalty of compilation failure, that the compiler thinks that a mutex is held.
+#define REQUIRE_MUTEX(expr) ([]() REQUIRES(expr) {})()
+
+// Tell the compiler that we know that a mutex is held.
+#define ASSERT_MUTEX(expr) ([]() ASSERT_CAPABILITY(expr) {})()
+
+// Specify that one mutex is an alias for another.
+// (e.g. SurfaceFlinger::mStateLock and Layer::mFlinger->mStateLock)
+#define MUTEX_ALIAS(held, alias) (REQUIRE_MUTEX(held), ASSERT_MUTEX(alias))
+
} // namespace android