[libcamera-devel] [RFC PATCH 0/6] Introduce clang thread safety annotations

Hirokazu Honda hiroh at chromium.org
Fri Oct 29 06:14:18 CEST 2021


This introduces clang thread safety annotations and applies it
to libcamera Android HAL adaptation layer. It is necessary to add
new classes that wrap std::mutex and std::unique_lock with the
annotations. It is because no C++ standard library annotates all
the mutex classes today. libstdc++ doesn't annotate any classes.
libc++ annotates for std::mutex, std::lock_guard and
std::scoped_lock, but doesn't for std::unique_lock.

Document: https://clang.llvm.org/docs/ThreadSafetyAnalysis.html

Hirokazu Honda (6):
  libcamera: base: Add thread safety annotation macros
  libcamera: base: Add mutex classes with thread safety annotations
  android: camera_hal_manager: Add thread safety annotation
  android: camera_stream: Add thread safety annotation
  android: camera_device: Add thread safety annotation
  android: camera_request: Add thread safety annotation

 include/libcamera/base/meson.build          |   2 +
 include/libcamera/base/mutex.h              |  66 +++++++++
 include/libcamera/base/thread.h             |   5 +-
 include/libcamera/base/thread_annotations.h | 151 ++++++++++++++++++++
 meson.build                                 |   1 +
 src/android/camera_device.cpp               |  26 ++--
 src/android/camera_device.h                 |  18 +--
 src/android/camera_hal_manager.cpp          |  10 +-
 src/android/camera_hal_manager.h            |  14 +-
 src/android/camera_request.h                |   7 +-
 src/android/camera_stream.cpp               |  22 +--
 src/android/camera_stream.h                 |  13 +-
 12 files changed, 278 insertions(+), 57 deletions(-)
 create mode 100644 include/libcamera/base/mutex.h
 create mode 100644 include/libcamera/base/thread_annotations.h

--
2.33.1.1089.g2158813163f-goog


More information about the libcamera-devel mailing list