summaryrefslogtreecommitdiff
path: root/include/libcamera/base
diff options
context:
space:
mode:
Diffstat (limited to 'include/libcamera/base')
-rw-r--r--include/libcamera/base/backtrace.h2
-rw-r--r--include/libcamera/base/bound_method.h4
-rw-r--r--include/libcamera/base/class.h2
-rw-r--r--include/libcamera/base/compiler.h2
-rw-r--r--include/libcamera/base/event_dispatcher.h2
-rw-r--r--include/libcamera/base/event_dispatcher_poll.h2
-rw-r--r--include/libcamera/base/event_notifier.h2
-rw-r--r--include/libcamera/base/file.h2
-rw-r--r--include/libcamera/base/flags.h10
-rw-r--r--include/libcamera/base/log.h12
-rw-r--r--include/libcamera/base/meson.build28
-rw-r--r--include/libcamera/base/message.h4
-rw-r--r--include/libcamera/base/mutex.h4
-rw-r--r--include/libcamera/base/object.h6
-rw-r--r--include/libcamera/base/private.h2
-rw-r--r--include/libcamera/base/semaphore.h12
-rw-r--r--include/libcamera/base/shared_fd.h2
-rw-r--r--include/libcamera/base/signal.h21
-rw-r--r--include/libcamera/base/span.h2
-rw-r--r--include/libcamera/base/thread.h2
-rw-r--r--include/libcamera/base/thread_annotations.h4
-rw-r--r--include/libcamera/base/timer.h2
-rw-r--r--include/libcamera/base/unique_fd.h2
-rw-r--r--include/libcamera/base/utils.h16
24 files changed, 94 insertions, 53 deletions
diff --git a/include/libcamera/base/backtrace.h b/include/libcamera/base/backtrace.h
index 752034d1..699ddd9e 100644
--- a/include/libcamera/base/backtrace.h
+++ b/include/libcamera/base/backtrace.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2021, Ideas on Board Oy
*
- * backtrace.h - Call stack backtraces
+ * Call stack backtraces
*/
#pragma once
diff --git a/include/libcamera/base/bound_method.h b/include/libcamera/base/bound_method.h
index e73a4d98..dd3488ee 100644
--- a/include/libcamera/base/bound_method.h
+++ b/include/libcamera/base/bound_method.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * bound_method.h - Method bind and invocation
+ * Method bind and invocation
*/
#pragma once
@@ -72,7 +72,7 @@ public:
}
virtual ~BoundMethodBase() = default;
- template<typename T, typename std::enable_if_t<!std::is_same<Object, T>::value> * = nullptr>
+ template<typename T, std::enable_if_t<!std::is_same<Object, T>::value> * = nullptr>
bool match(T *obj) { return obj == obj_; }
bool match(Object *object) { return object == object_; }
diff --git a/include/libcamera/base/class.h b/include/libcamera/base/class.h
index 571eecf4..a808422e 100644
--- a/include/libcamera/base/class.h
+++ b/include/libcamera/base/class.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2020, Google Inc.
*
- * class.h - Utilities and helpers for classes
+ * Utilities and helpers for classes
*/
#pragma once
diff --git a/include/libcamera/base/compiler.h b/include/libcamera/base/compiler.h
index 02564f2f..fda8fdfd 100644
--- a/include/libcamera/base/compiler.h
+++ b/include/libcamera/base/compiler.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2021, Google Inc.
*
- * compiler.h - Compiler support
+ * Compiler support
*/
#pragma once
diff --git a/include/libcamera/base/event_dispatcher.h b/include/libcamera/base/event_dispatcher.h
index 184f1b12..e9a09c6e 100644
--- a/include/libcamera/base/event_dispatcher.h
+++ b/include/libcamera/base/event_dispatcher.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * event_dispatcher.h - Event dispatcher
+ * Event dispatcher
*/
#pragma once
diff --git a/include/libcamera/base/event_dispatcher_poll.h b/include/libcamera/base/event_dispatcher_poll.h
index b7840309..1f7e05cf 100644
--- a/include/libcamera/base/event_dispatcher_poll.h
+++ b/include/libcamera/base/event_dispatcher_poll.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * event_dispatcher_poll.h - Poll-based event dispatcher
+ * Poll-based event dispatcher
*/
#pragma once
diff --git a/include/libcamera/base/event_notifier.h b/include/libcamera/base/event_notifier.h
index e5c0594d..158f2d44 100644
--- a/include/libcamera/base/event_notifier.h
+++ b/include/libcamera/base/event_notifier.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * event_notifier.h - File descriptor event notifier
+ * File descriptor event notifier
*/
#pragma once
diff --git a/include/libcamera/base/file.h b/include/libcamera/base/file.h
index 0cdc2ed0..5637934c 100644
--- a/include/libcamera/base/file.h
+++ b/include/libcamera/base/file.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2020, Google Inc.
*
- * file.h - File I/O operations
+ * File I/O operations
*/
#pragma once
diff --git a/include/libcamera/base/flags.h b/include/libcamera/base/flags.h
index bff3b93c..af4f6e35 100644
--- a/include/libcamera/base/flags.h
+++ b/include/libcamera/base/flags.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2020, Google Inc.
*
- * flags.h - Type-safe enum-based bitfields
+ * Type-safe enum-based bitfields
*/
#pragma once
@@ -147,7 +147,7 @@ struct flags_enable_operators {
};
template<typename E>
-typename std::enable_if_t<flags_enable_operators<E>::enable, Flags<E>>
+std::enable_if_t<flags_enable_operators<E>::enable, Flags<E>>
operator|(E lhs, E rhs)
{
using type = std::underlying_type_t<E>;
@@ -155,7 +155,7 @@ operator|(E lhs, E rhs)
}
template<typename E>
-typename std::enable_if_t<flags_enable_operators<E>::enable, Flags<E>>
+std::enable_if_t<flags_enable_operators<E>::enable, Flags<E>>
operator&(E lhs, E rhs)
{
using type = std::underlying_type_t<E>;
@@ -163,7 +163,7 @@ operator&(E lhs, E rhs)
}
template<typename E>
-typename std::enable_if_t<flags_enable_operators<E>::enable, Flags<E>>
+std::enable_if_t<flags_enable_operators<E>::enable, Flags<E>>
operator^(E lhs, E rhs)
{
using type = std::underlying_type_t<E>;
@@ -171,7 +171,7 @@ operator^(E lhs, E rhs)
}
template<typename E>
-typename std::enable_if_t<flags_enable_operators<E>::enable, Flags<E>>
+std::enable_if_t<flags_enable_operators<E>::enable, Flags<E>>
operator~(E rhs)
{
using type = std::underlying_type_t<E>;
diff --git a/include/libcamera/base/log.h b/include/libcamera/base/log.h
index 3fc5ced3..b5775e49 100644
--- a/include/libcamera/base/log.h
+++ b/include/libcamera/base/log.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2018, Google Inc.
*
- * log.h - Logging infrastructure
+ * Logging infrastructure
*/
#pragma once
@@ -29,16 +29,18 @@ enum LogSeverity {
class LogCategory
{
public:
- explicit LogCategory(const char *name);
+ static LogCategory *create(const char *name);
- const char *name() const { return name_; }
+ const std::string &name() const { return name_; }
LogSeverity severity() const { return severity_; }
void setSeverity(LogSeverity severity);
static const LogCategory &defaultCategory();
private:
- const char *name_;
+ explicit LogCategory(const char *name);
+
+ const std::string name_;
LogSeverity severity_;
};
@@ -49,7 +51,7 @@ extern const LogCategory &_LOG_CATEGORY(name)();
const LogCategory &_LOG_CATEGORY(name)() \
{ \
/* The instance will be deleted by the Logger destructor. */ \
- static LogCategory *category = new LogCategory(#name); \
+ static LogCategory *category = LogCategory::create(#name); \
return *category; \
}
diff --git a/include/libcamera/base/meson.build b/include/libcamera/base/meson.build
index 4410aba8..bace25d5 100644
--- a/include/libcamera/base/meson.build
+++ b/include/libcamera/base/meson.build
@@ -2,31 +2,39 @@
libcamera_base_include_dir = libcamera_include_dir / 'base'
-libcamera_base_headers = files([
- 'backtrace.h',
+libcamera_base_public_headers = files([
'bound_method.h',
'class.h',
'compiler.h',
+ 'flags.h',
+ 'object.h',
+ 'shared_fd.h',
+ 'signal.h',
+ 'span.h',
+ 'unique_fd.h',
+])
+
+libcamera_base_private_headers = files([
+ 'backtrace.h',
'event_dispatcher.h',
'event_dispatcher_poll.h',
'event_notifier.h',
'file.h',
- 'flags.h',
'log.h',
'message.h',
'mutex.h',
- 'object.h',
'private.h',
'semaphore.h',
- 'shared_fd.h',
- 'signal.h',
- 'span.h',
'thread.h',
'thread_annotations.h',
'timer.h',
- 'unique_fd.h',
'utils.h',
])
-install_headers(libcamera_base_headers,
- subdir: libcamera_base_include_dir)
+libcamera_base_headers = [
+ libcamera_base_public_headers,
+ libcamera_base_private_headers,
+]
+
+install_headers(libcamera_base_public_headers,
+ subdir : libcamera_base_include_dir)
diff --git a/include/libcamera/base/message.h b/include/libcamera/base/message.h
index 65572c74..4b232031 100644
--- a/include/libcamera/base/message.h
+++ b/include/libcamera/base/message.h
@@ -2,13 +2,15 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * message.h - Message queue support
+ * Message queue support
*/
#pragma once
#include <atomic>
+#include <libcamera/base/private.h>
+
#include <libcamera/base/bound_method.h>
namespace libcamera {
diff --git a/include/libcamera/base/mutex.h b/include/libcamera/base/mutex.h
index 2d23e49e..fa9a8d0d 100644
--- a/include/libcamera/base/mutex.h
+++ b/include/libcamera/base/mutex.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2021, Google Inc.
*
- * mutex.h - Mutex classes with clang thread safety annotation
+ * Mutex classes with clang thread safety annotation
*/
#pragma once
@@ -10,6 +10,8 @@
#include <condition_variable>
#include <mutex>
+#include <libcamera/base/private.h>
+
#include <libcamera/base/thread_annotations.h>
namespace libcamera {
diff --git a/include/libcamera/base/object.h b/include/libcamera/base/object.h
index eef1a2c9..508773cd 100644
--- a/include/libcamera/base/object.h
+++ b/include/libcamera/base/object.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * object.h - Base object
+ * Base object
*/
#pragma once
@@ -32,7 +32,7 @@ public:
void postMessage(std::unique_ptr<Message> msg);
template<typename T, typename R, typename... FuncArgs, typename... Args,
- typename std::enable_if_t<std::is_base_of<Object, T>::value> * = nullptr>
+ std::enable_if_t<std::is_base_of<Object, T>::value> * = nullptr>
R invokeMethod(R (T::*func)(FuncArgs...), ConnectionType type,
Args&&... args)
{
@@ -49,6 +49,8 @@ public:
protected:
virtual void message(Message *msg);
+ bool assertThreadBound(const char *message);
+
private:
friend class SignalBase;
friend class Thread;
diff --git a/include/libcamera/base/private.h b/include/libcamera/base/private.h
index 163012bf..8670c40b 100644
--- a/include/libcamera/base/private.h
+++ b/include/libcamera/base/private.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2021, Google Inc.
*
- * private.h - Private Header Validation
+ * Private Header Validation
*
* A selection of internal libcamera headers are installed as part
* of the libcamera package to allow sharing of a select subset of
diff --git a/include/libcamera/base/semaphore.h b/include/libcamera/base/semaphore.h
index c11e8dd1..59d4aa44 100644
--- a/include/libcamera/base/semaphore.h
+++ b/include/libcamera/base/semaphore.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * semaphore.h - General-purpose counting semaphore
+ * General-purpose counting semaphore
*/
#pragma once
@@ -18,15 +18,15 @@ class Semaphore
public:
Semaphore(unsigned int n = 0);
- unsigned int available();
- void acquire(unsigned int n = 1);
- bool tryAcquire(unsigned int n = 1);
- void release(unsigned int n = 1);
+ unsigned int available() LIBCAMERA_TSA_EXCLUDES(mutex_);
+ void acquire(unsigned int n = 1) LIBCAMERA_TSA_EXCLUDES(mutex_);
+ bool tryAcquire(unsigned int n = 1) LIBCAMERA_TSA_EXCLUDES(mutex_);
+ void release(unsigned int n = 1) LIBCAMERA_TSA_EXCLUDES(mutex_);
private:
Mutex mutex_;
ConditionVariable cv_;
- unsigned int available_;
+ unsigned int available_ LIBCAMERA_TSA_GUARDED_BY(mutex_);
};
} /* namespace libcamera */
diff --git a/include/libcamera/base/shared_fd.h b/include/libcamera/base/shared_fd.h
index e53a8b88..61fe11c1 100644
--- a/include/libcamera/base/shared_fd.h
+++ b/include/libcamera/base/shared_fd.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * shared_fd.h - File descriptor wrapper with shared ownership
+ * File descriptor wrapper with shared ownership
*/
#pragma once
diff --git a/include/libcamera/base/signal.h b/include/libcamera/base/signal.h
index 91000d0d..849fbbda 100644
--- a/include/libcamera/base/signal.h
+++ b/include/libcamera/base/signal.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * signal.h - Signal & slot implementation
+ * Signal & slot implementation
*/
#pragma once
@@ -13,10 +13,11 @@
#include <vector>
#include <libcamera/base/bound_method.h>
-#include <libcamera/base/object.h>
namespace libcamera {
+class Object;
+
class SignalBase
{
public:
@@ -44,7 +45,7 @@ public:
}
#ifndef __DOXYGEN__
- template<typename T, typename R, typename std::enable_if_t<std::is_base_of<Object, T>::value> * = nullptr>
+ template<typename T, typename R, std::enable_if_t<std::is_base_of<Object, T>::value> * = nullptr>
void connect(T *obj, R (T::*func)(Args...),
ConnectionType type = ConnectionTypeAuto)
{
@@ -52,7 +53,7 @@ public:
SignalBase::connect(new BoundMethodMember<T, R, Args...>(obj, object, func, type));
}
- template<typename T, typename R, typename std::enable_if_t<!std::is_base_of<Object, T>::value> * = nullptr>
+ template<typename T, typename R, std::enable_if_t<!std::is_base_of<Object, T>::value> * = nullptr>
#else
template<typename T, typename R>
#endif
@@ -63,7 +64,11 @@ public:
#ifndef __DOXYGEN__
template<typename T, typename Func,
- typename std::enable_if_t<std::is_base_of<Object, T>::value> * = nullptr>
+ std::enable_if_t<std::is_base_of<Object, T>::value
+#if __cplusplus >= 201703L
+ && std::is_invocable_v<Func, Args...>
+#endif
+ > * = nullptr>
void connect(T *obj, Func func, ConnectionType type = ConnectionTypeAuto)
{
Object *object = static_cast<Object *>(obj);
@@ -71,7 +76,11 @@ public:
}
template<typename T, typename Func,
- typename std::enable_if_t<!std::is_base_of<Object, T>::value> * = nullptr>
+ std::enable_if_t<!std::is_base_of<Object, T>::value
+#if __cplusplus >= 201703L
+ && std::is_invocable_v<Func, Args...>
+#endif
+ > * = nullptr>
#else
template<typename T, typename Func>
#endif
diff --git a/include/libcamera/base/span.h b/include/libcamera/base/span.h
index 88d2e3de..c3e63f69 100644
--- a/include/libcamera/base/span.h
+++ b/include/libcamera/base/span.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2020, Google Inc.
*
- * span.h - C++20 std::span<> implementation for C++11
+ * C++20 std::span<> implementation for C++11
*/
#pragma once
diff --git a/include/libcamera/base/thread.h b/include/libcamera/base/thread.h
index 9d00f102..4f33de63 100644
--- a/include/libcamera/base/thread.h
+++ b/include/libcamera/base/thread.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * thread.h - Thread support
+ * Thread support
*/
#pragma once
diff --git a/include/libcamera/base/thread_annotations.h b/include/libcamera/base/thread_annotations.h
index e81929f6..81930f08 100644
--- a/include/libcamera/base/thread_annotations.h
+++ b/include/libcamera/base/thread_annotations.h
@@ -2,11 +2,13 @@
/*
* Copyright (C) 2021, Google Inc.
*
- * thread_annotation.h - Macro of Clang thread safety analysis
+ * Macro of Clang thread safety analysis
*/
#pragma once
+#include <libcamera/base/private.h>
+
/*
* Enable thread safety attributes only with clang.
* The attributes can be safely erased when compiling with other compilers.
diff --git a/include/libcamera/base/timer.h b/include/libcamera/base/timer.h
index 759b68ad..5ef45959 100644
--- a/include/libcamera/base/timer.h
+++ b/include/libcamera/base/timer.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2019, Google Inc.
*
- * timer.h - Generic timer
+ * Generic timer
*/
#pragma once
diff --git a/include/libcamera/base/unique_fd.h b/include/libcamera/base/unique_fd.h
index ae4d96b7..c9a3b5d0 100644
--- a/include/libcamera/base/unique_fd.h
+++ b/include/libcamera/base/unique_fd.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2021, Google Inc.
*
- * unique_fd.h - File descriptor wrapper that owns a file descriptor.
+ * File descriptor wrapper that owns a file descriptor.
*/
#pragma once
diff --git a/include/libcamera/base/utils.h b/include/libcamera/base/utils.h
index cfff0583..4ae02dc9 100644
--- a/include/libcamera/base/utils.h
+++ b/include/libcamera/base/utils.h
@@ -2,7 +2,7 @@
/*
* Copyright (C) 2018, Google Inc.
*
- * utils.h - Miscellaneous utility functions
+ * Miscellaneous utility functions
*/
#pragma once
@@ -170,6 +170,12 @@ public:
class iterator
{
public:
+ using difference_type = std::size_t;
+ using value_type = std::string;
+ using pointer = value_type *;
+ using reference = value_type &;
+ using iterator_category = std::input_iterator_tag;
+
iterator(const StringSplitter *ss, std::string::size_type pos);
iterator &operator++();
@@ -361,6 +367,14 @@ decltype(auto) abs_diff(const T &a, const T &b)
return a - b;
}
+double strtod(const char *__restrict nptr, char **__restrict endptr);
+
+template<class Enum>
+constexpr std::underlying_type_t<Enum> to_underlying(Enum e) noexcept
+{
+ return static_cast<std::underlying_type_t<Enum>>(e);
+}
+
} /* namespace utils */
#ifndef __DOXYGEN__