From: Simon Marchi Date: Thu, 7 Dec 2023 17:00:23 +0000 (+0000) Subject: src.ctf.lttng-live: remove some goto error-handling X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=HEAD;hp=5ce9818ba4e76858b2ef12c81ba75c1306f195d3 src.ctf.lttng-live: remove some goto error-handling Change-Id: I9b6d967d54c63d7f7544bb0d1a1eb778a8df64d4 Signed-off-by: Simon Marchi Reviewed-on: https://review.lttng.org/c/babeltrace/+/12396 Reviewed-by: Philippe Proulx Tested-by: jenkins --- diff --git a/.clang-format b/.clang-format index 300e046c..cba56253 100644 --- a/.clang-format +++ b/.clang-format @@ -79,7 +79,33 @@ ForEachMacros: [ 'bt_list_for_each_prev', 'bt_list_for_each_prev_safe', ] -IncludeBlocks: Preserve +IncludeBlocks: Regroup +IncludeCategories: + # Babeltrace 2 public headers + - Regex: '^$' + Priority: 3 + # System C headers + - Regex: '^<.+\.h>$' + Priority: 2 + # System C++ headers + - Regex: '^<.+>$' + Priority: 1 + # Logging headers + - Regex: '^"(logging\.hpp|logging/comp-logging\.h|logging/log\.h)"$' + Priority: 4 + # Common headers + - Regex: '^"(argpar|autodisc|common|compat|cpp-common|ctfser|fd-cache|param-parse|py-common|logging|string-format)/.+"$' + Priority: 5 + # Plugins common headers + - Regex: '^"plugins/common/.+"$' + Priority: 6 + # tap header file + - Regex: '^"(tap/)?tap\.h"$' + Priority: 8 + # The rest (local headers) + - Regex: '.+' + Priority: 7 +IncludeIsMainRegex: "please_dont_do_that" IndentAccessModifiers: false IndentCaseBlocks: false IndentCaseLabels: false @@ -98,7 +124,7 @@ PPIndentWidth: 4 PointerAlignment: Right ReferenceAlignment: Left ReflowComments: false -SortIncludes: false +SortIncludes: CaseInsensitive SortUsingDeclarations: false SpaceAfterCStyleCast: true SpaceAfterLogicalNot: false diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 00000000..acbb1421 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,103 @@ +Checks: '-*, + bugprone-argument-comment, + bugprone-assert-side-effect, + bugprone-assignment-in-if-condition, + bugprone-bad-signal-to-kill-thread, + bugprone-bool-pointer-implicit-conversion, + bugprone-copy-constructor-init, + bugprone-dangling-handle, + bugprone-exception-escape, + bugprone-fold-init-type, + bugprone-forward-declaration-namespace, + bugprone-forwarding-reference-overload, + bugprone-inaccurate-erase, + bugprone-incorrect-roundings, + bugprone-infinite-loop, + bugprone-integer-division, + bugprone-macro-parentheses, + bugprone-macro-repeated-side-effects, + bugprone-misplaced-operator-in-strlen-in-alloc, + bugprone-misplaced-pointer-arithmetic-in-alloc, + bugprone-move-forwarding-reference, + bugprone-multiple-statement-macro, + bugprone-not-null-terminated-result, + bugprone-parent-virtual-call, + bugprone-posix-return, + bugprone-shared-ptr-array-mismatch, + bugprone-signal-handler, + bugprone-signed-char-misuse, + bugprone-sizeof-container, + bugprone-sizeof-expression, + bugprone-standalone-empty, + bugprone-string-constructor, + bugprone-string-integer-assignment, + bugprone-string-literal-with-embedded-nul, + bugprone-suspicious-enum-usage, + bugprone-suspicious-include, + bugprone-suspicious-memory-comparison + bugprone-suspicious-memset-usage, + bugprone-suspicious-missing-comma, + bugprone-suspicious-realloc-usage, + bugprone-suspicious-semicolon, + bugprone-suspicious-string-compare, + bugprone-swapped-arguments, + bugprone-terminating-continue, + bugprone-throw-keyword-missing, + bugprone-too-small-loop-variable, + bugprone-unchecked-optional-access + bugprone-undefined-memory-manipulation, + bugprone-undelegated-constructor, + bugprone-unhandled-exception-at-new, + bugprone-unhandled-self-assignment, + bugprone-unused-raii, + bugprone-unused-return-value, + bugprone-use-after-move, + bugprone-virtual-near-miss, + bugprone-unused-raii, + bugprone-use-after-move, + cppcoreguidelines-avoid-const-or-ref-data-members, + cppcoreguidelines-pro-type-const-cast, + cppcoreguidelines-slicing, + cppcoreguidelines-special-member-functions, + cppcoreguidelines-virtual-class-destructor, + google-build-explicit-make-pair, + google-explicit-constructor, + misc-const-correctness, + misc-misleading-identifier, + misc-non-copyable-objects, + misc-throw-by-value-catch-by-reference, + misc-unused-parameters, + misc-unused-using-decls, + modernize-avoid-bind, + modernize-concat-nested-namespaces, + modernize-loop-convert, + modernize-make-shared, + modernize-make-unique, + modernize-pass-by-value, + modernize-redundant-void-arg, + modernize-replace-auto-ptr, + modernize-replace-random-shuffle, + modernize-replace-auto-ptr, + modernize-shrink-to-fit, + modernize-use-bool-literals, + modernize-use-default-member-init, + modernize-use-emplace, + modernize-use-equals-default, + modernize-use-equals-delete, + modernize-use-noexcept, + modernize-use-nullptr, + modernize-use-override, + modernize-use-transparent-functors, + modernize-use-using, + performance-*, + -performance-no-int-to-ptr, + readability-redundant-member-init, + readability-simplify-boolean-expr' +FormatStyle: 'file' +CheckOptions: + - key: bugprone-assert-side-effect.AssertMacros + value: BT_ASSERT,BT_ASSERT_DBG + - key: cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor + value: true + - key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctionsWhenCopyIsDeleted + value: true diff --git a/.editorconfig b/.editorconfig index 9461f5ba..7fca3371 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,6 +9,10 @@ indent_size = 8 indent_style = tab tab_width = 8 -[*.{py,hpp,cpp}] +[*.{py,py.in,hpp,cpp}] indent_style = space indent_size = 4 + +[*.{h,c}] +indent_style = tab +indent_size = 8 diff --git a/.gitignore b/.gitignore index 58610444..2267bc7b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,17 +1,18 @@ -/tests/bitfield/test_bitfield -/tests/argpar/test_argpar -/tests/ctf-writer/ctf_writer +/tests/bitfield/test-bitfield +/tests/argpar/test-argpar +/tests/ctf-writer/ctf-writer /tests/lib/plugin -/tests/lib/test_bt_uuid -/tests/lib/test_bt_values -/tests/lib/test_graph_topo -/tests/lib/test_trace_ir_ref -/tests/lib/test_simple_sink -/tests/lib/test_remove_destruction_listener_in_destruction_listener +/tests/lib/test-bt-uuid +/tests/lib/test-bt-values +/tests/lib/test-fields-bin +/tests/lib/test-graph-topo +/tests/lib/test-trace-ir-ref +/tests/lib/test-simple-sink +/tests/lib/test-remove-destruction-listener-in-destruction-listener /tests/lib/conds/conds-triggers -/tests/param-validation/test_param_validation -/tests/plugins/flt.lttng-utils.debug-info/test_bin_info -/tests/plugins/flt.lttng-utils.debug-info/test_dwarf +/tests/param-validation/test-param-validation +/tests/plugins/flt.lttng-utils.debug-info/test-bin-info +/tests/plugins/flt.lttng-utils.debug-info/test-dwarf /tests/plugins/src.ctf.fs/succeed/gen-trace-simple /tests/plugins/sink.ctf.fs/succeed/gen-trace-float /tests/plugins/sink.ctf.fs/succeed/gen-trace-double @@ -26,10 +27,13 @@ .deps *.bkp *.trs -/src/plugins/ctf/common/metadata/lexer.cpp -/src/plugins/ctf/common/metadata/parser.cpp -/src/plugins/ctf/common/metadata/parser.hpp -/src/plugins/ctf/common/metadata/parser.output +.dirstamp +/src/plugins/ctf/common/src/metadata/tsdl/lexer.cpp +/src/plugins/ctf/common/src/metadata/tsdl/parser.cpp +/src/plugins/ctf/common/src/metadata/tsdl/parser.hpp +/src/plugins/ctf/common/src/metadata/tsdl/parser.output +/src/bindings/python/bt2/bt2.egg-info +/src/bindings/python/bt2/dist /src/cli/babeltrace2 /src/cli/babeltrace2.bin /src/cli/babeltrace2-log diff --git a/.reuse/dep5 b/.reuse/dep5 new file mode 100644 index 00000000..2f272d84 --- /dev/null +++ b/.reuse/dep5 @@ -0,0 +1,12 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ + +Files: + src/cpp-common/vendor/fmt/*.h + src/cpp-common/vendor/fmt/*.cc +Copyright: 2012 - present, Victor Zverovich +License: MIT + +Files: + src/cpp-common/vendor/wise-enum/*.h +Copyright: 2017 - present, Nir Friedman +License: BSL-1.0 diff --git a/CONTRIBUTING.adoc b/CONTRIBUTING.adoc index 9af7a419..37105c6c 100644 --- a/CONTRIBUTING.adoc +++ b/CONTRIBUTING.adoc @@ -2,7 +2,7 @@ = Babeltrace{nbsp}2 contributor's guide Jérémie Galarneau, Philippe Proulx -1 December 2020 +22 February 2024 :toc: left :toclevels: 3 :icons: font @@ -10,6 +10,7 @@ Jérémie Galarneau, Philippe Proulx :bt2: Babeltrace{nbsp}2 :c-cpp: C/{cpp} :cpp11: {cpp}11 +:fmt: pass:[{fmt}] This is a partial contributor's guide for the https://babeltrace.org[{bt2}] project. If you have any @@ -439,7 +440,6 @@ level, for example: + [source,c] ---- -BT_HIDDEN char *bt_common_get_home_plugin_path(int log_level); ---- + @@ -1148,7 +1148,6 @@ struct my_comp { /* ... */ }; -BT_HIDDEN bt_self_component_status my_comp_init( bt_self_component_source *self_comp_src, bt_value *params, void *init_method_data) @@ -1493,7 +1492,7 @@ tests to run in, so nothing more is needed. If building in-tree, you can run single tests from the tree directly: ---- -$ ./tests/plugins/sink.text.pretty/test_enum +$ ./tests/plugins/sink.text.pretty/test-enum.sh ---- If building out-of-tree, you can get the appropriate environment by sourcing @@ -1502,15 +1501,16 @@ want to run tests. ---- $ source /path/to/my/build/tests/utils/env.sh -$ ./tests/plugins/sink.text.pretty/test_enum +$ ./tests/plugins/sink.text.pretty/test-enum.sh ---- ==== Python -You can use the `tests/utils/run_python_bt2` script to run any command -within an environment making the build's `bt2` Python package available. +You can use the `tests/utils/run-in-py-env.sh` script to run any command +within an environment making the build's `bt2` Python package available, +as well as the testing utility Python modules. -`run_python_bt2` uses <> which needs to know the +`run-in-py-env.sh` uses <> which needs to know the build directory, so make sure you set the `BT_TESTS_BUILDDIR` environment variable correctly _if you build out of tree_, for example: @@ -1519,10 +1519,10 @@ $ export BT_TESTS_BUILDDIR=/path/to/build/babeltrace/tests ---- You can run any command which needs the `bt2` Python package through -`run_python_bt2`, for example: +`run-in-py-env.sh`, for example: ---- -$ ./tests/utils/run_python_bt2 ipython3 +$ ./tests/utils/run-in-py-env.sh ipython3 ---- === Report format @@ -1568,13 +1568,13 @@ To run all the `bt2` Python package tests: * Run: + ---- -$ ./tests/utils/run_python_bt2 ./tests/bindings/python/bt2/test_python_bt2 +$ ./tests/utils/run-in-py-env.sh ./tests/bindings/python/bt2/test-python-bt2.sh ---- + or: + ---- -$ ./tests/utils/run_python_bt2 python3 ./tests/utils/python/testrunner.py \ +$ ./tests/utils/run-in-py-env.sh python3 ./tests/utils/python/testrunner.py \ ./tests/bindings/python/bt2/ -p '*.py' ---- @@ -1584,7 +1584,7 @@ To run **all the tests** in a test module (for example, * Run: + ---- -$ ./tests/utils/run_python_bt2 python3 ./tests/utils/python/testrunner.py \ +$ ./tests/utils/run-in-py-env.sh python3 ./tests/utils/python/testrunner.py \ ./tests/bindings/python/bt2 -t test_value ---- @@ -1594,7 +1594,7 @@ To run a **specific test case** (for example, `RealValueTestCase` within * Run: + ---- -$ ./tests/utils/run_python_bt2 python3 ./tests/utils/python/testrunner.py \ +$ ./tests/utils/run-in-py-env.sh python3 ./tests/utils/python/testrunner.py \ ./tests/bindings/python/bt2/ -t test_value.RealValueTestCase ---- @@ -1604,13 +1604,14 @@ To run a **specific test** (for example, * Run: + ---- -$ ./tests/utils/run_python_bt2 python3 ./tests/utils/python/testrunner.py \ +$ ./tests/utils/run-in-py-env.sh python3 ./tests/utils/python/testrunner.py \ ./tests/bindings/python/bt2/ -t test_value.RealValueTestCase.test_assign_pos_int ---- == {cpp} usage -Some parts of {bt2} are written in {cpp}. +A significant part and, in general, all the new code of {bt2} is written +in {cpp}. This section shows what's important to know about {cpp} to contribute to {bt2}. @@ -1623,13 +1624,206 @@ In other words, libbabeltrace2 _must_ expose a pure C99 API to preserve ABI compatibility over time. ==== -=== Standard and dependencies +=== Standard The {bt2} project is configured to use the {cpp11} standard. {cpp11} makes it possible to build {bt2} with a broad range of compilers, from GCC{nbsp}4.8 and Clang{nbsp}3.3. +=== Common {cpp} code + +Many parts of the project need common {cpp} code. You'll find all of it +under `src/cpp-common`. + +In general, anything under a namespace named `internal` is internal to +the API containing it. For example, everything under the `bt2::internal` +namespace is internal to the `bt2` namespace and therefore isn't meant +to be used outside the `src/cpp-common/bt2` directory. + +==== `bt2`: libbabeltrace2 {cpp} bindings + +`src/cpp-common/bt2` contains our internal {cpp} bindings of +the libbabeltrace2 C{nbsp}API, under the `bt2` namespace. + +Those bindings are designed to have, as much as possible, no performance +impact. Anything which inherits `bt2::BorrowedObject` contains a single +libbabeltrace2 object pointer. + +Pass and return borrowed objects _by value_ (copy). + +In general, the following holds: + +[options="header,autowidth",cols="2"] +|=== +|{cpp} expression +|Equivalent C{nbsp}expression + +|`bt2::Xyz` +|`bt_xyz *` + +|`const bt2::Xyz` +|`bt_xyz * const` + +|`bt2::ConstXyz` +|`const bt_xyz *` + +|`const bt2::ConstXyz` +|`const bt_xyz * const` +|=== + +==== `bt2c`: general common {cpp} code + +Similar to the role of `src/common` for C code. + +In general, everything in here is under the `bt2c` namespace. + +Notable files are: + +`align.hpp`:: + The `bt2c::align()` function template: a wrapper of + `src/common/align.h`. + +`c-string-view.hpp`:: + The `bt2c::CStringView` class: a view on a constant null-terminated + C{nbsp}string. ++ +We have this because `bt2s::string_view` doesn't imply null termination, +only a beginning and a length. ++ +A `bt2c::CStringView` instance is convertible to `const char *` and may +be empty (the underlying pointer is null). + +`call.hpp`:: + The `bt2c::call()` function template: a partial implementation of + https://en.cppreference.com/w/cpp/utility/functional[INVOKE]. ++ +We use this mostly to assign the result of calling an immediately +invoked function expression (lambda) to an `auto` variable without +risking to assign the lambda itself, should we forget the calling +parentheses: ++ +[source,cpp] +---- +const auto res = bt2c::call([&] { + /* Complex initialization */ +}); +---- + +`endian.hpp`:: + Typed wrappers of `src/compat/endian.h`. + +`exc.hpp`:: + Common exception classes. + +`fmt.hpp`:: + Common https://fmt.dev/[{fmt}] formatters. + +`logging.hpp`:: + The `bt2c::Logger` class and helper `BT_CPPLOG*()` macros for any + {cpp} logging. ++ +When possible, prefer using this over the C{nbsp}logging API. ++ +One important benefit is that this API uses {fmt} to format the logging +message instead of `vsnprintf()`. + +`prio-heap.hpp`:: + The `bt2c::PrioHeap` class template: an efficient heap data + structure. + +`read-fixed-len-int.hpp`:: + The function templates `bt2c::readFixedLenInt()`, + `bt2c::readFixedLenIntLe()`, and `bt2c::readFixedLenIntBe()`: read a + fixed-length integer from a byte buffer. + +`safe-ops.hpp`:: + The `bt2c::safe*()` function templates: arithmetic operations which + assert that there's no possible overflow. + +`std-int.hpp`:: + The `bt2c::StdIntT` type alias template: becomes one of the + `std::*int*_t` types depending on its parameters. ++ +For example, `bt2c::StdIntT<32, true>` is `std::int32_t`. + +`type-traits.hpp`:: + Common type traits. + +`uuid.hpp`:: + The following classes: + +`bt2c::Uuid`::: + Container of a 16-byte + https://en.wikipedia.org/wiki/Universally_unique_identifier[UUID]. ++ +Provides the static `generate()` method as well as conversion to +`bt2c::UuidView`. + +`bt2c::UuidView`::: + View on a UUID (not a container). ++ +Provides byte access, comparison, as well as string conversion methods. ++ +Also provides conversion to `bt2c::Uuid`. + +`vector.hpp`:: + The `bt2c::vectorFastRemove()` function template: remove an element + from an `std::vector` instance quickly when the order isn't + important. + +==== `bt2s`: drop-in replacements of {cpp}14 to {cpp}20 STL features + +Everything under the `bt2s` namespace has its equivalent under the `std` +namespace, but in {cpp} versions we don't yet have access to, namely: + +`make_unique.hpp`:: + `bt2s::make_unique()`, a drop-in replacement of `std::make_unique()` + ({cpp}14). + +`optional.hpp`:: + Drop-in replacement of the `std::optional` API ({cpp}17). + +`span.hpp`:: + Drop-in replacement of the `std::span` API ({cpp}20). + +`string-view.hpp`:: + Drop-in replacement of the `std::string_view` API ({cpp}17). + +==== `vendor`: copies of {cpp} dependencies + +This directory contains copies of the source code of {cpp} dependencies +to avoid packaging issues. + +They are: + +`fmt`:: + https://fmt.dev/[{fmt}]. + +`nlohmann`:: + https://json.nlohmann.me/[JSON for Modern C++]. + +`optional-lite`:: + https://github.com/martinmoene/optional-lite[optional lite]. ++ +IMPORTANT: Use the symbols of `src/cpp-common/bt2s/optional.hpp`, under +the `bt2s` namespace, instead of using this directly. + +`span-lite`:: + https://github.com/martinmoene/span-lite[span lite]. ++ +IMPORTANT: Use the symbols of `src/cpp-common/bt2s/span.hpp`, under the +`bt2s` namespace, instead of using this directly. + +`string-view-lite`:: + https://github.com/martinmoene/string-view-lite[string_view lite]. ++ +IMPORTANT: Use the symbols of `src/cpp-common/bt2s/string-view.hpp`, +under the `bt2s` namespace, instead of using this directly. + +`wise_enum`:: + https://github.com/quicknir/wise_enum[wise_enum]. + === Automake/Libtool requirements To add a {cpp} source file to a part of the project, use the `.cpp` @@ -1676,19 +1870,25 @@ https://clang.llvm.org/docs/ClangFormatStyleOptions.html[style] of the You _must_ format modified and new {cpp} files with clang-format before you create a contribution patch. -You need clang-format{nbsp}14 to use the project's `.clang-format` file. +You need clang-format{nbsp}15 to use the project's `.clang-format` file. To automatically format all the project's {cpp} files, run: ---- -$ ./tools/format-cpp +$ ./tools/format-cpp.sh +---- + +To only format the {cpp} files of a given directory: + +---- +$ ./tools/format-cpp.sh ./src/cli ---- Use the `FORMATTER` environment variable to override the default formatter (`clang-format{nbsp}-i`): ---- -$ FORMATTER='clang-format-10 -i' ./tools/format-cpp +$ FORMATTER='my-clang-format-15 -i' ./tools/format-cpp.sh ---- ==== Naming @@ -1700,25 +1900,26 @@ $ FORMATTER='clang-format-10 -i' ./tools/format-cpp * Use camel case with an uppercase first letter for: ** Types: `Pistachio`, `NutManager`. ** Template parameters: `PlanetT`, `TotalSize`. +** Enumerators: `Type::SignedInt`, `Scope::Function`. * Use snake case with uppercase letters for: ** Definition/macro names: `MARK_AS_UNUSED()`, `SOME_FEATURE_EXISTS`. -** Enumerators: `Type::SIGNED_INT`, `Scope::FUNCTION`. * Use only lowercase letters and digits for namespaces: `mylib`, `bt2`. -* Use the suffix `T` for type template parameters: +* Use the `T` suffix for type template parameters and the `V` suffix for + non-type template parameters: + [source,cpp] ---- -template +template ---- -* Name a template parameter pack `Args`. +* Name a template parameter pack `ArgTs`. + [source,cpp] ---- -template +template ---- * Use an underscore prefix for private and protected methods and member @@ -1726,12 +1927,17 @@ template * Use the prefix `_m` for private and protected member variable names: `_mLogger`, `_mSize`, `_mFieldClass`. ++ +This is to avoid name clashes with private/protected getters/setters. -* Name setters and getters like the property name, without `set` and +* Name setters and getters like the property name, without the `set` and `get` prefixes. * Use the `is` or `has` prefix, if possible, to name the functions which return `bool`. ++ +However, try to keep the name readable. For example, prefer +`colorIsBlue()` over `isColorBlue()`. === Coding convention @@ -1753,25 +1959,145 @@ Here are a few important reminders: For a class named `MyClass`, name the corresponding files `my-class.hpp` and `my-class.cpp`. -* When defining a class, put constructors as the first methods, whatever - their access (public/protected/private), then the destructor, and then - the rest. +* Use the `inline` keyword, not `static inline`, for header-only + functions that are not templates. -* Declare variables as close to where they are used as possible. +* When defining a class, use this order: ++ +-- +. Friends (without any preceding access specifier). + +. Public types and type aliases. ++ +Private/protected types may be here too if they can't be lower. + +. Constructors, whatever their access. + +. Destructor (always public). + +. Copy-assignment and move-assignment operators. + +. Public methods. + +. Protected types and type aliases. + +. Protected methods. + +. Private types and type aliases. + +. Private methods. + +. Protected data members. + +. Private data members. +-- + +* Declare variables as close to where they're used as possible. + +* In general, try to avoid variables if it doesn't lead to more lines. ++ +For example, given: ++ +[source,cpp] +---- +const auto size = getSize(myObj, 23); +auto& obj = this->_objForSize(size); + +abc::sendObj(obj, SendOpts::WAIT); +---- ++ +Prefer this: ++ +[source,cpp] +---- +abc::sendObj(this->_objForSize(getSize(myObj, 23)), SendOpts::WAIT); +---- + +* If you really need variables, then scope them to avoid "`leaking`" + them: ++ +[source,cpp] +---- +doSomeStuff(123, &obj); + +{ + const auto status = tryChange(obj); + + BT_CPPLOGD("New status: {}.", status); + BT_ASSERT(status == Status::CONTINUE); +} + +doMoreStuff(&obj); +---- ++ +This also means to either use a dedicated, named method/function or to +use `bt2c::call()` with an immediately invoked function expression +(lambda) to perform complex initialization of an ideally `const` +variable: ++ +[source,cpp] +---- +const auto size = bt2c::call([this] { + auto& sender = this->_curSender(); + + if (sender.strategy() == Strategy::ACK) { + return sender.strategySize(); + } else if (sender.strategy() == Strategy::NACK) { + return 0; + } + + return _mDefSize; +}); +---- + +* Always use `bt2c::call()` to call an immediately invoked function + expression (see the previous point). + +* If possible, initialize object members without a default value with + the initializer list of a constructor, not in the constructor body. ++ +If the initialization is complex, either use a dedicated, named +method/function or `bt2c::call()` with an immediately invoked function +expression (lambda): ++ +[source,cpp] +---- +MyObj::MyObj(const std::size_t size) : + _mSize {size}, + _mOtherObj {bt2c::call([size] { + /* Complex initialization here */ + })} +{ +} +---- * Use `auto` when possible. ++ +Use `auto&` instead of `const auto&` when you know that the type is +`const` anyway. ++ +Don't use `auto *`. -* Use `const` as much as possible, even for pointer - (`+const char* const+`) and numeric values (`const unsigned int`) +* Use `const` as much as possible, even for pointers + (`+const char * const+`) and numeric values (`const unsigned int`) which never need to change. +* Prefer the `pass:[MyObj myObj {...}]` initialization form over + `pass:[auto myObj = MyObj {...}]`. + * Implement simple setters, getters, and one-liners in header files and - everything else that's not a template in source files. + everything else that's not a template in source files, including + constructors. * Make methods `const noexcept` or `const` as much as possible. * Make constructors `explicit` unless you really need an implicit - constructor (which is rare). + constructor (which is rare), including default constructors: ++ +[source,cpp] +---- +explicit Meow(); +---- * Use `std::unique_ptr` to manage memory when possible. + @@ -1811,7 +2137,11 @@ If the value is optional::: * Use type aliases (`using`), not type definitions (`typedef`). -* Use anonymous namespaces for local functions instead of `static`. +* In a `.cpp` file, use anonymous namespaces for local symbols instead + of `static` or `inline`. + +* Prefer a function in an anonymous namespace in a `.cpp` file over a + private static method if it doesn't need private access to an object. * Don't pollute the global namespace: ** Don't use `using namespace xyz` anywhere. @@ -1856,7 +2186,7 @@ Example: void Obj::doSomething(std::string str) { _mName = std::move(str); - // ... + /* ... */ } ---- @@ -1868,9 +2198,8 @@ convention. [source,cpp] ---- /* + * SPDX-FileCopyrightText: 2020 Harry Burnett * SPDX-License-Identifier: MIT - * - * Copyright 2020 Harry Burnett */ #ifndef BABELTRACE_BABY_HPP @@ -1889,27 +2218,31 @@ class Toy; */ class Baby : public Human { + friend class Parent; + public: using Toys = std::unordered_set; enum class Gender { - MALE, - FEMALE, - UNKNOWN, + Male, + Female, + Other, }; - Baby() = default; + explicit Baby() = default; explicit Baby(const Toys& toys); Baby(const Baby&) = delete; Baby(Baby&&) = delete; - Baby& operator=(const Baby&) = delete; - Baby& operator=(Baby&&) = delete; protected: - explicit Baby(Gender initialGender = Gender::UNKNOWN); + explicit Baby(Gender initialGender = Gender::OTHER); public: + ~Baby(); + Baby& operator=(const Baby&) = delete; + Baby& operator=(Baby&&) = delete; + /* * Eats `weight` grams of food. */ @@ -1945,8 +2278,18 @@ private: Toys _mToys; }; -} // namespace life +} /* namespace life */ -#endif // BABELTRACE_BABY_HPP +#endif /* BABELTRACE_BABY_HPP */ ---- ==== + +== Python Usage + +=== Formatting + +All Python code must be formatted using the version of +https://github.com/psf/black[Black] specified in `dev-requirements.txt`. + +All Python imports must be sorted using the version of +https://pycqa.github.io/isort/[isort] indicated in `dev-requirements.txt`. diff --git a/LICENSE b/LICENSE index 1beedf98..d3b6dcb7 100644 --- a/LICENSE +++ b/LICENSE @@ -92,6 +92,32 @@ This applies to: doc/api/libbabeltrace2/* +The typing Python module is provided under the terms of the Python Software +Foundation License 2: + + SPDX-License-Identifier: PSF-2.0 + +According with: + + LICENSES/PSF-2.0 + +This applies to: + + tests/utils/python/typing/typing.py + +The Normand Python module is provided under the terms of the +MIT License: + + SPDX-License-Identifier: MIT + +According with: + + LICENSES/MIT + +This applies to: + + tests/utils/python/normand.py + In addition, other licenses may also apply, see SPDX-License-Identifier in individual files. diff --git a/LICENSES/BSD-2-Clause b/LICENSES/BSD-2-Clause deleted file mode 100644 index 9522a8f3..00000000 --- a/LICENSES/BSD-2-Clause +++ /dev/null @@ -1,31 +0,0 @@ -Valid-License-Identifier: BSD-2-Clause -SPDX-URL: https://spdx.org/licenses/BSD-2-Clause.html -Usage-Guide: - To use the BSD 2-Clause "Simplified" License License put the following - SPDX tag/value pair into a comment according to the placement - guidelines in the licensing rules documentation: - SPDX-License-Identifier: BSD-2-Clause -License-Text: - -Copyright (c) . All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, -this list of conditions and the following disclaimer in the documentation -and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/LICENSES/BSD-2-Clause.txt b/LICENSES/BSD-2-Clause.txt new file mode 100644 index 00000000..9522a8f3 --- /dev/null +++ b/LICENSES/BSD-2-Clause.txt @@ -0,0 +1,31 @@ +Valid-License-Identifier: BSD-2-Clause +SPDX-URL: https://spdx.org/licenses/BSD-2-Clause.html +Usage-Guide: + To use the BSD 2-Clause "Simplified" License License put the following + SPDX tag/value pair into a comment according to the placement + guidelines in the licensing rules documentation: + SPDX-License-Identifier: BSD-2-Clause +License-Text: + +Copyright (c) . All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/LICENSES/BSD-4-Clause b/LICENSES/BSD-4-Clause deleted file mode 100644 index 72ac05fe..00000000 --- a/LICENSES/BSD-4-Clause +++ /dev/null @@ -1,53 +0,0 @@ -Valid-License-Identifier: BSD-4-Clause -SPDX-URL: https://spdx.org/licenses/BSD-4-Clause.html -Usage-Guide: - To use the BSD 4-Clause "Original" or "Old" License put the following - SPDX tag/value pair into a comment according to the placement - guidelines in the licensing rules documentation: - SPDX-License-Identifier: BSD-4-Clause -License-Text: - -Copyright (c) 1993 The Regents of the University of California. All -rights reserved. - -This software was developed by the Computer Systems Engineering group -at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and -contributed to Berkeley. - -All advertising materials mentioning features or use of this software -must display the following acknowledgement: This product includes -software developed by the University of California, Lawrence Berkeley -Laboratory. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - 3. All advertising materials mentioning features or use of this - software must display the following acknowledgement: This product - includes software developed by the University of California, - Berkeley and its contributors. - - 4. Neither the name of the University nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS -BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR -BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE -OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/LICENSES/BSD-4-Clause.txt b/LICENSES/BSD-4-Clause.txt new file mode 100644 index 00000000..72ac05fe --- /dev/null +++ b/LICENSES/BSD-4-Clause.txt @@ -0,0 +1,53 @@ +Valid-License-Identifier: BSD-4-Clause +SPDX-URL: https://spdx.org/licenses/BSD-4-Clause.html +Usage-Guide: + To use the BSD 4-Clause "Original" or "Old" License put the following + SPDX tag/value pair into a comment according to the placement + guidelines in the licensing rules documentation: + SPDX-License-Identifier: BSD-4-Clause +License-Text: + +Copyright (c) 1993 The Regents of the University of California. All +rights reserved. + +This software was developed by the Computer Systems Engineering group +at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and +contributed to Berkeley. + +All advertising materials mentioning features or use of this software +must display the following acknowledgement: This product includes +software developed by the University of California, Lawrence Berkeley +Laboratory. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + + 3. All advertising materials mentioning features or use of this + software must display the following acknowledgement: This product + includes software developed by the University of California, + Berkeley and its contributors. + + 4. Neither the name of the University nor the names of its + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/LICENSES/BSL-1.0 b/LICENSES/BSL-1.0 deleted file mode 100644 index 36b7cd93..00000000 --- a/LICENSES/BSL-1.0 +++ /dev/null @@ -1,23 +0,0 @@ -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff --git a/LICENSES/BSL-1.0.txt b/LICENSES/BSL-1.0.txt new file mode 100644 index 00000000..36b7cd93 --- /dev/null +++ b/LICENSES/BSL-1.0.txt @@ -0,0 +1,23 @@ +Boost Software License - Version 1.0 - August 17th, 2003 + +Permission is hereby granted, free of charge, to any person or organization +obtaining a copy of the software and accompanying documentation covered by +this license (the "Software") to use, reproduce, display, distribute, +execute, and transmit the Software, and to prepare derivative works of the +Software, and to permit third-parties to whom the Software is furnished to +do so, all subject to the following: + +The copyright notices in the Software and this entire statement, including +the above license grant, this restriction and the following disclaimer, +must be included in all copies of the Software, in whole or in part, and +all derivative works of the Software, unless such copies or derivative +works are solely in the form of machine-executable object code generated by +a source language processor. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/LICENSES/CC-BY-SA-4.0 b/LICENSES/CC-BY-SA-4.0 deleted file mode 100644 index b3427f5e..00000000 --- a/LICENSES/CC-BY-SA-4.0 +++ /dev/null @@ -1,359 +0,0 @@ -Valid-License-Identifier: CC-BY-SA-4.0 -SPDX-URL: https://spdx.org/licenses/CC-BY-SA-4.0.html -Usage-Guide: - To use the Creative Commons Attribution Share Alike 4.0 International - License put the following SPDX tag/value pair into a comment according - to the placement guidelines in the licensing rules documentation: - SPDX-License-Identifier: CC-BY-SA-4.0 -License-Text: - -Creative Commons Attribution-ShareAlike 4.0 International Creative Commons -Corporation ("Creative Commons") is not a law firm and does not provide legal -services or legal advice. Distribution of Creative Commons public licenses -does not create a lawyer-client or other relationship. Creative Commons makes -its licenses and related information available on an "as-is" basis. Creative -Commons gives no warranties regarding its licenses, any material licensed -under their terms and conditions, or any related information. Creative Commons -disclaims all liability for damages resulting from their use to the fullest -extent possible. - -Using Creative Commons Public Licenses - -Creative Commons public licenses provide a standard set of terms and conditions -that creators and other rights holders may use to share original works of -authorship and other material subject to copyright and certain other rights -specified in the public license below. The following considerations are for -informational purposes only, are not exhaustive, and do not form part of our -licenses. - -Considerations for licensors: Our public licenses are intended for use by -those authorized to give the public permission to use material in ways otherwise -restricted by copyright and certain other rights. Our licenses are irrevocable. -Licensors should read and understand the terms and conditions of the license -they choose before applying it. Licensors should also secure all rights necessary -before applying our licenses so that the public can reuse the material as -expected. Licensors should clearly mark any material not subject to the license. -This includes other CC-licensed material, or material used under an exception -or limitation to copyright. More considerations for licensors : wiki.creativecommons.org/Considerations_for_licensors - -Considerations for the public: By using one of our public licenses, a licensor -grants the public permission to use the licensed material under specified -terms and conditions. If the licensor's permission is not necessary for any -reason–for example, because of any applicable exception or limitation to copyright–then -that use is not regulated by the license. Our licenses grant only permissions -under copyright and certain other rights that a licensor has authority to -grant. Use of the licensed material may still be restricted for other reasons, -including because others have copyright or other rights in the material. A -licensor may make special requests, such as asking that all changes be marked -or described. - -Although not required by our licenses, you are encouraged to respect those -requests where reasonable. More considerations for the public : wiki.creativecommons.org/Considerations_for_licensees - -Creative Commons Attribution-ShareAlike 4.0 International Public License - -By exercising the Licensed Rights (defined below), You accept and agree to -be bound by the terms and conditions of this Creative Commons Attribution-ShareAlike -4.0 International Public License ("Public License"). To the extent this Public -License may be interpreted as a contract, You are granted the Licensed Rights -in consideration of Your acceptance of these terms and conditions, and the -Licensor grants You such rights in consideration of benefits the Licensor -receives from making the Licensed Material available under these terms and -conditions. - -Section 1 – Definitions. - -a. Adapted Material means material subject to Copyright and Similar Rights -that is derived from or based upon the Licensed Material and in which the -Licensed Material is translated, altered, arranged, transformed, or otherwise -modified in a manner requiring permission under the Copyright and Similar -Rights held by the Licensor. For purposes of this Public License, where the -Licensed Material is a musical work, performance, or sound recording, Adapted -Material is always produced where the Licensed Material is synched in timed -relation with a moving image. - -b. Adapter's License means the license You apply to Your Copyright and Similar -Rights in Your contributions to Adapted Material in accordance with the terms -and conditions of this Public License. - -c. BY-SA Compatible License means a license listed at creativecommons.org/compatiblelicenses, -approved by Creative Commons as essentially the equivalent of this Public -License. - -d. Copyright and Similar Rights means copyright and/or similar rights closely -related to copyright including, without limitation, performance, broadcast, -sound recording, and Sui Generis Database Rights, without regard to how the -rights are labeled or categorized. For purposes of this Public License, the -rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. - -e. Effective Technological Measures means those measures that, in the absence -of proper authority, may not be circumvented under laws fulfilling obligations -under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, -and/or similar international agreements. - -f. Exceptions and Limitations means fair use, fair dealing, and/or any other -exception or limitation to Copyright and Similar Rights that applies to Your -use of the Licensed Material. - -g. License Elements means the license attributes listed in the name of a Creative -Commons Public License. The License Elements of this Public License are Attribution -and ShareAlike. - -h. Licensed Material means the artistic or literary work, database, or other -material to which the Licensor applied this Public License. - -i. Licensed Rights means the rights granted to You subject to the terms and -conditions of this Public License, which are limited to all Copyright and -Similar Rights that apply to Your use of the Licensed Material and that the -Licensor has authority to license. - -j. Licensor means the individual(s) or entity(ies) granting rights under this -Public License. - -k. Share means to provide material to the public by any means or process that -requires permission under the Licensed Rights, such as reproduction, public -display, public performance, distribution, dissemination, communication, or -importation, and to make material available to the public including in ways -that members of the public may access the material from a place and at a time -individually chosen by them. - -l. Sui Generis Database Rights means rights other than copyright resulting -from Directive 96/9/EC of the European Parliament and of the Council of 11 -March 1996 on the legal protection of databases, as amended and/or succeeded, -as well as other essentially equivalent rights anywhere in the world. - -m. You means the individual or entity exercising the Licensed Rights under -this Public License. Your has a corresponding meaning. - -Section 2 – Scope. - - a. License grant. - -1. Subject to the terms and conditions of this Public License, the Licensor -hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, -irrevocable license to exercise the Licensed Rights in the Licensed Material -to: - - A. reproduce and Share the Licensed Material, in whole or in part; and - - B. produce, reproduce, and Share Adapted Material. - -2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions -and Limitations apply to Your use, this Public License does not apply, and -You do not need to comply with its terms and conditions. - - 3. Term. The term of this Public License is specified in Section 6(a). - -4. Media and formats; technical modifications allowed. The Licensor authorizes -You to exercise the Licensed Rights in all media and formats whether now known -or hereafter created, and to make technical modifications necessary to do -so. The Licensor waives and/or agrees not to assert any right or authority -to forbid You from making technical modifications necessary to exercise the -Licensed Rights, including technical modifications necessary to circumvent -Effective Technological Measures. For purposes of this Public License, simply -making modifications authorized by this Section 2(a)(4) never produces Adapted -Material. - - 5. Downstream recipients. - -A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed -Material automatically receives an offer from the Licensor to exercise the -Licensed Rights under the terms and conditions of this Public License. - -B. Additional offer from the Licensor – Adapted Material. Every recipient -of Adapted Material from You automatically receives an offer from the Licensor -to exercise the Licensed Rights in the Adapted Material under the conditions -of the Adapter's License You apply. - -C. No downstream restrictions. You may not offer or impose any additional -or different terms or conditions on, or apply any Effective Technological -Measures to, the Licensed Material if doing so restricts exercise of the Licensed -Rights by any recipient of the Licensed Material. - -6. No endorsement. Nothing in this Public License constitutes or may be construed -as permission to assert or imply that You are, or that Your use of the Licensed -Material is, connected with, or sponsored, endorsed, or granted official status -by, the Licensor or others designated to receive attribution as provided in -Section 3(a)(1)(A)(i). - - b. Other rights. - -1. Moral rights, such as the right of integrity, are not licensed under this -Public License, nor are publicity, privacy, and/or other similar personality -rights; however, to the extent possible, the Licensor waives and/or agrees -not to assert any such rights held by the Licensor to the limited extent necessary -to allow You to exercise the Licensed Rights, but not otherwise. - -2. Patent and trademark rights are not licensed under this Public License. - -3. To the extent possible, the Licensor waives any right to collect royalties -from You for the exercise of the Licensed Rights, whether directly or through -a collecting society under any voluntary or waivable statutory or compulsory -licensing scheme. In all other cases the Licensor expressly reserves any right -to collect such royalties. - -Section 3 – License Conditions. - -Your exercise of the Licensed Rights is expressly made subject to the following -conditions. - - a. Attribution. - -1. If You Share the Licensed Material (including in modified form), You must: - -A. retain the following if it is supplied by the Licensor with the Licensed -Material: - -i. identification of the creator(s) of the Licensed Material and any others -designated to receive attribution, in any reasonable manner requested by the -Licensor (including by pseudonym if designated); - - ii. a copyright notice; - - iii. a notice that refers to this Public License; - - iv. a notice that refers to the disclaimer of warranties; - -v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; - -B. indicate if You modified the Licensed Material and retain an indication -of any previous modifications; and - -C. indicate the Licensed Material is licensed under this Public License, and -include the text of, or the URI or hyperlink to, this Public License. - -2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner -based on the medium, means, and context in which You Share the Licensed Material. -For example, it may be reasonable to satisfy the conditions by providing a -URI or hyperlink to a resource that includes the required information. - -3. If requested by the Licensor, You must remove any of the information required -by Section 3(a)(1)(A) to the extent reasonably practicable. - -b. ShareAlike.In addition to the conditions in Section 3(a), if You Share -Adapted Material You produce, the following conditions also apply. - -1. The Adapter's License You apply must be a Creative Commons license with -the same License Elements, this version or later, or a BY-SA Compatible License. - -2. You must include the text of, or the URI or hyperlink to, the Adapter's -License You apply. You may satisfy this condition in any reasonable manner -based on the medium, means, and context in which You Share Adapted Material. - -3. You may not offer or impose any additional or different terms or conditions -on, or apply any Effective Technological Measures to, Adapted Material that -restrict exercise of the rights granted under the Adapter's License You apply. - -Section 4 – Sui Generis Database Rights. - -Where the Licensed Rights include Sui Generis Database Rights that apply to -Your use of the Licensed Material: - -a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, -reuse, reproduce, and Share all or a substantial portion of the contents of -the database; - -b. if You include all or a substantial portion of the database contents in -a database in which You have Sui Generis Database Rights, then the database -in which You have Sui Generis Database Rights (but not its individual contents) -is Adapted Material, including for purposes of Section 3(b); and - -c. You must comply with the conditions in Section 3(a) if You Share all or -a substantial portion of the contents of the database. - -For the avoidance of doubt, this Section 4 supplements and does not replace -Your obligations under this Public License where the Licensed Rights include -other Copyright and Similar Rights. - -Section 5 – Disclaimer of Warranties and Limitation of Liability. - -a. Unless otherwise separately undertaken by the Licensor, to the extent possible, -the Licensor offers the Licensed Material as-is and as-available, and makes -no representations or warranties of any kind concerning the Licensed Material, -whether express, implied, statutory, or other. This includes, without limitation, -warranties of title, merchantability, fitness for a particular purpose, non-infringement, -absence of latent or other defects, accuracy, or the presence or absence of -errors, whether or not known or discoverable. Where disclaimers of warranties -are not allowed in full or in part, this disclaimer may not apply to You. - -b. To the extent possible, in no event will the Licensor be liable to You -on any legal theory (including, without limitation, negligence) or otherwise -for any direct, special, indirect, incidental, consequential, punitive, exemplary, -or other losses, costs, expenses, or damages arising out of this Public License -or use of the Licensed Material, even if the Licensor has been advised of -the possibility of such losses, costs, expenses, or damages. Where a limitation -of liability is not allowed in full or in part, this limitation may not apply -to You. - -c. The disclaimer of warranties and limitation of liability provided above -shall be interpreted in a manner that, to the extent possible, most closely -approximates an absolute disclaimer and waiver of all liability. - -Section 6 – Term and Termination. - -a. This Public License applies for the term of the Copyright and Similar Rights -licensed here. However, if You fail to comply with this Public License, then -Your rights under this Public License terminate automatically. - -b. Where Your right to use the Licensed Material has terminated under Section -6(a), it reinstates: - -1. automatically as of the date the violation is cured, provided it is cured -within 30 days of Your discovery of the violation; or - - 2. upon express reinstatement by the Licensor. - -c. For the avoidance of doubt, this Section 6(b) does not affect any right -the Licensor may have to seek remedies for Your violations of this Public -License. - -d. For the avoidance of doubt, the Licensor may also offer the Licensed Material -under separate terms or conditions or stop distributing the Licensed Material -at any time; however, doing so will not terminate this Public License. - - e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. - -Section 7 – Other Terms and Conditions. - -a. The Licensor shall not be bound by any additional or different terms or -conditions communicated by You unless expressly agreed. - -b. Any arrangements, understandings, or agreements regarding the Licensed -Material not stated herein are separate from and independent of the terms -and conditions of this Public License. - -Section 8 – Interpretation. - -a. For the avoidance of doubt, this Public License does not, and shall not -be interpreted to, reduce, limit, restrict, or impose conditions on any use -of the Licensed Material that could lawfully be made without permission under -this Public License. - -b. To the extent possible, if any provision of this Public License is deemed -unenforceable, it shall be automatically reformed to the minimum extent necessary -to make it enforceable. If the provision cannot be reformed, it shall be severed -from this Public License without affecting the enforceability of the remaining -terms and conditions. - -c. No term or condition of this Public License will be waived and no failure -to comply consented to unless expressly agreed to by the Licensor. - -d. Nothing in this Public License constitutes or may be interpreted as a limitation -upon, or waiver of, any privileges and immunities that apply to the Licensor -or You, including from the legal processes of any jurisdiction or authority. - -Creative Commons is not a party to its public licenses. Notwithstanding, Creative -Commons may elect to apply one of its public licenses to material it publishes -and in those instances will be considered the "Licensor." The text of the -Creative Commons public licenses is dedicated to the public domain under the -CC0 Public Domain Dedication. Except for the limited purpose of indicating -that material is shared under a Creative Commons public license or as otherwise -permitted by the Creative Commons policies published at creativecommons.org/policies, -Creative Commons does not authorize the use of the trademark "Creative Commons" -or any other trademark or logo of Creative Commons without its prior written -consent including, without limitation, in connection with any unauthorized -modifications to any of its public licenses or any other arrangements, understandings, -or agreements concerning use of licensed material. For the avoidance of doubt, -this paragraph does not form part of the public licenses. - -Creative Commons may be contacted at creativecommons.org. diff --git a/LICENSES/CC-BY-SA-4.0.txt b/LICENSES/CC-BY-SA-4.0.txt new file mode 100644 index 00000000..b3427f5e --- /dev/null +++ b/LICENSES/CC-BY-SA-4.0.txt @@ -0,0 +1,359 @@ +Valid-License-Identifier: CC-BY-SA-4.0 +SPDX-URL: https://spdx.org/licenses/CC-BY-SA-4.0.html +Usage-Guide: + To use the Creative Commons Attribution Share Alike 4.0 International + License put the following SPDX tag/value pair into a comment according + to the placement guidelines in the licensing rules documentation: + SPDX-License-Identifier: CC-BY-SA-4.0 +License-Text: + +Creative Commons Attribution-ShareAlike 4.0 International Creative Commons +Corporation ("Creative Commons") is not a law firm and does not provide legal +services or legal advice. Distribution of Creative Commons public licenses +does not create a lawyer-client or other relationship. Creative Commons makes +its licenses and related information available on an "as-is" basis. Creative +Commons gives no warranties regarding its licenses, any material licensed +under their terms and conditions, or any related information. Creative Commons +disclaims all liability for damages resulting from their use to the fullest +extent possible. + +Using Creative Commons Public Licenses + +Creative Commons public licenses provide a standard set of terms and conditions +that creators and other rights holders may use to share original works of +authorship and other material subject to copyright and certain other rights +specified in the public license below. The following considerations are for +informational purposes only, are not exhaustive, and do not form part of our +licenses. + +Considerations for licensors: Our public licenses are intended for use by +those authorized to give the public permission to use material in ways otherwise +restricted by copyright and certain other rights. Our licenses are irrevocable. +Licensors should read and understand the terms and conditions of the license +they choose before applying it. Licensors should also secure all rights necessary +before applying our licenses so that the public can reuse the material as +expected. Licensors should clearly mark any material not subject to the license. +This includes other CC-licensed material, or material used under an exception +or limitation to copyright. More considerations for licensors : wiki.creativecommons.org/Considerations_for_licensors + +Considerations for the public: By using one of our public licenses, a licensor +grants the public permission to use the licensed material under specified +terms and conditions. If the licensor's permission is not necessary for any +reason–for example, because of any applicable exception or limitation to copyright–then +that use is not regulated by the license. Our licenses grant only permissions +under copyright and certain other rights that a licensor has authority to +grant. Use of the licensed material may still be restricted for other reasons, +including because others have copyright or other rights in the material. A +licensor may make special requests, such as asking that all changes be marked +or described. + +Although not required by our licenses, you are encouraged to respect those +requests where reasonable. More considerations for the public : wiki.creativecommons.org/Considerations_for_licensees + +Creative Commons Attribution-ShareAlike 4.0 International Public License + +By exercising the Licensed Rights (defined below), You accept and agree to +be bound by the terms and conditions of this Creative Commons Attribution-ShareAlike +4.0 International Public License ("Public License"). To the extent this Public +License may be interpreted as a contract, You are granted the Licensed Rights +in consideration of Your acceptance of these terms and conditions, and the +Licensor grants You such rights in consideration of benefits the Licensor +receives from making the Licensed Material available under these terms and +conditions. + +Section 1 – Definitions. + +a. Adapted Material means material subject to Copyright and Similar Rights +that is derived from or based upon the Licensed Material and in which the +Licensed Material is translated, altered, arranged, transformed, or otherwise +modified in a manner requiring permission under the Copyright and Similar +Rights held by the Licensor. For purposes of this Public License, where the +Licensed Material is a musical work, performance, or sound recording, Adapted +Material is always produced where the Licensed Material is synched in timed +relation with a moving image. + +b. Adapter's License means the license You apply to Your Copyright and Similar +Rights in Your contributions to Adapted Material in accordance with the terms +and conditions of this Public License. + +c. BY-SA Compatible License means a license listed at creativecommons.org/compatiblelicenses, +approved by Creative Commons as essentially the equivalent of this Public +License. + +d. Copyright and Similar Rights means copyright and/or similar rights closely +related to copyright including, without limitation, performance, broadcast, +sound recording, and Sui Generis Database Rights, without regard to how the +rights are labeled or categorized. For purposes of this Public License, the +rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights. + +e. Effective Technological Measures means those measures that, in the absence +of proper authority, may not be circumvented under laws fulfilling obligations +under Article 11 of the WIPO Copyright Treaty adopted on December 20, 1996, +and/or similar international agreements. + +f. Exceptions and Limitations means fair use, fair dealing, and/or any other +exception or limitation to Copyright and Similar Rights that applies to Your +use of the Licensed Material. + +g. License Elements means the license attributes listed in the name of a Creative +Commons Public License. The License Elements of this Public License are Attribution +and ShareAlike. + +h. Licensed Material means the artistic or literary work, database, or other +material to which the Licensor applied this Public License. + +i. Licensed Rights means the rights granted to You subject to the terms and +conditions of this Public License, which are limited to all Copyright and +Similar Rights that apply to Your use of the Licensed Material and that the +Licensor has authority to license. + +j. Licensor means the individual(s) or entity(ies) granting rights under this +Public License. + +k. Share means to provide material to the public by any means or process that +requires permission under the Licensed Rights, such as reproduction, public +display, public performance, distribution, dissemination, communication, or +importation, and to make material available to the public including in ways +that members of the public may access the material from a place and at a time +individually chosen by them. + +l. Sui Generis Database Rights means rights other than copyright resulting +from Directive 96/9/EC of the European Parliament and of the Council of 11 +March 1996 on the legal protection of databases, as amended and/or succeeded, +as well as other essentially equivalent rights anywhere in the world. + +m. You means the individual or entity exercising the Licensed Rights under +this Public License. Your has a corresponding meaning. + +Section 2 – Scope. + + a. License grant. + +1. Subject to the terms and conditions of this Public License, the Licensor +hereby grants You a worldwide, royalty-free, non-sublicensable, non-exclusive, +irrevocable license to exercise the Licensed Rights in the Licensed Material +to: + + A. reproduce and Share the Licensed Material, in whole or in part; and + + B. produce, reproduce, and Share Adapted Material. + +2. Exceptions and Limitations. For the avoidance of doubt, where Exceptions +and Limitations apply to Your use, this Public License does not apply, and +You do not need to comply with its terms and conditions. + + 3. Term. The term of this Public License is specified in Section 6(a). + +4. Media and formats; technical modifications allowed. The Licensor authorizes +You to exercise the Licensed Rights in all media and formats whether now known +or hereafter created, and to make technical modifications necessary to do +so. The Licensor waives and/or agrees not to assert any right or authority +to forbid You from making technical modifications necessary to exercise the +Licensed Rights, including technical modifications necessary to circumvent +Effective Technological Measures. For purposes of this Public License, simply +making modifications authorized by this Section 2(a)(4) never produces Adapted +Material. + + 5. Downstream recipients. + +A. Offer from the Licensor – Licensed Material. Every recipient of the Licensed +Material automatically receives an offer from the Licensor to exercise the +Licensed Rights under the terms and conditions of this Public License. + +B. Additional offer from the Licensor – Adapted Material. Every recipient +of Adapted Material from You automatically receives an offer from the Licensor +to exercise the Licensed Rights in the Adapted Material under the conditions +of the Adapter's License You apply. + +C. No downstream restrictions. You may not offer or impose any additional +or different terms or conditions on, or apply any Effective Technological +Measures to, the Licensed Material if doing so restricts exercise of the Licensed +Rights by any recipient of the Licensed Material. + +6. No endorsement. Nothing in this Public License constitutes or may be construed +as permission to assert or imply that You are, or that Your use of the Licensed +Material is, connected with, or sponsored, endorsed, or granted official status +by, the Licensor or others designated to receive attribution as provided in +Section 3(a)(1)(A)(i). + + b. Other rights. + +1. Moral rights, such as the right of integrity, are not licensed under this +Public License, nor are publicity, privacy, and/or other similar personality +rights; however, to the extent possible, the Licensor waives and/or agrees +not to assert any such rights held by the Licensor to the limited extent necessary +to allow You to exercise the Licensed Rights, but not otherwise. + +2. Patent and trademark rights are not licensed under this Public License. + +3. To the extent possible, the Licensor waives any right to collect royalties +from You for the exercise of the Licensed Rights, whether directly or through +a collecting society under any voluntary or waivable statutory or compulsory +licensing scheme. In all other cases the Licensor expressly reserves any right +to collect such royalties. + +Section 3 – License Conditions. + +Your exercise of the Licensed Rights is expressly made subject to the following +conditions. + + a. Attribution. + +1. If You Share the Licensed Material (including in modified form), You must: + +A. retain the following if it is supplied by the Licensor with the Licensed +Material: + +i. identification of the creator(s) of the Licensed Material and any others +designated to receive attribution, in any reasonable manner requested by the +Licensor (including by pseudonym if designated); + + ii. a copyright notice; + + iii. a notice that refers to this Public License; + + iv. a notice that refers to the disclaimer of warranties; + +v. a URI or hyperlink to the Licensed Material to the extent reasonably practicable; + +B. indicate if You modified the Licensed Material and retain an indication +of any previous modifications; and + +C. indicate the Licensed Material is licensed under this Public License, and +include the text of, or the URI or hyperlink to, this Public License. + +2. You may satisfy the conditions in Section 3(a)(1) in any reasonable manner +based on the medium, means, and context in which You Share the Licensed Material. +For example, it may be reasonable to satisfy the conditions by providing a +URI or hyperlink to a resource that includes the required information. + +3. If requested by the Licensor, You must remove any of the information required +by Section 3(a)(1)(A) to the extent reasonably practicable. + +b. ShareAlike.In addition to the conditions in Section 3(a), if You Share +Adapted Material You produce, the following conditions also apply. + +1. The Adapter's License You apply must be a Creative Commons license with +the same License Elements, this version or later, or a BY-SA Compatible License. + +2. You must include the text of, or the URI or hyperlink to, the Adapter's +License You apply. You may satisfy this condition in any reasonable manner +based on the medium, means, and context in which You Share Adapted Material. + +3. You may not offer or impose any additional or different terms or conditions +on, or apply any Effective Technological Measures to, Adapted Material that +restrict exercise of the rights granted under the Adapter's License You apply. + +Section 4 – Sui Generis Database Rights. + +Where the Licensed Rights include Sui Generis Database Rights that apply to +Your use of the Licensed Material: + +a. for the avoidance of doubt, Section 2(a)(1) grants You the right to extract, +reuse, reproduce, and Share all or a substantial portion of the contents of +the database; + +b. if You include all or a substantial portion of the database contents in +a database in which You have Sui Generis Database Rights, then the database +in which You have Sui Generis Database Rights (but not its individual contents) +is Adapted Material, including for purposes of Section 3(b); and + +c. You must comply with the conditions in Section 3(a) if You Share all or +a substantial portion of the contents of the database. + +For the avoidance of doubt, this Section 4 supplements and does not replace +Your obligations under this Public License where the Licensed Rights include +other Copyright and Similar Rights. + +Section 5 – Disclaimer of Warranties and Limitation of Liability. + +a. Unless otherwise separately undertaken by the Licensor, to the extent possible, +the Licensor offers the Licensed Material as-is and as-available, and makes +no representations or warranties of any kind concerning the Licensed Material, +whether express, implied, statutory, or other. This includes, without limitation, +warranties of title, merchantability, fitness for a particular purpose, non-infringement, +absence of latent or other defects, accuracy, or the presence or absence of +errors, whether or not known or discoverable. Where disclaimers of warranties +are not allowed in full or in part, this disclaimer may not apply to You. + +b. To the extent possible, in no event will the Licensor be liable to You +on any legal theory (including, without limitation, negligence) or otherwise +for any direct, special, indirect, incidental, consequential, punitive, exemplary, +or other losses, costs, expenses, or damages arising out of this Public License +or use of the Licensed Material, even if the Licensor has been advised of +the possibility of such losses, costs, expenses, or damages. Where a limitation +of liability is not allowed in full or in part, this limitation may not apply +to You. + +c. The disclaimer of warranties and limitation of liability provided above +shall be interpreted in a manner that, to the extent possible, most closely +approximates an absolute disclaimer and waiver of all liability. + +Section 6 – Term and Termination. + +a. This Public License applies for the term of the Copyright and Similar Rights +licensed here. However, if You fail to comply with this Public License, then +Your rights under this Public License terminate automatically. + +b. Where Your right to use the Licensed Material has terminated under Section +6(a), it reinstates: + +1. automatically as of the date the violation is cured, provided it is cured +within 30 days of Your discovery of the violation; or + + 2. upon express reinstatement by the Licensor. + +c. For the avoidance of doubt, this Section 6(b) does not affect any right +the Licensor may have to seek remedies for Your violations of this Public +License. + +d. For the avoidance of doubt, the Licensor may also offer the Licensed Material +under separate terms or conditions or stop distributing the Licensed Material +at any time; however, doing so will not terminate this Public License. + + e. Sections 1, 5, 6, 7, and 8 survive termination of this Public License. + +Section 7 – Other Terms and Conditions. + +a. The Licensor shall not be bound by any additional or different terms or +conditions communicated by You unless expressly agreed. + +b. Any arrangements, understandings, or agreements regarding the Licensed +Material not stated herein are separate from and independent of the terms +and conditions of this Public License. + +Section 8 – Interpretation. + +a. For the avoidance of doubt, this Public License does not, and shall not +be interpreted to, reduce, limit, restrict, or impose conditions on any use +of the Licensed Material that could lawfully be made without permission under +this Public License. + +b. To the extent possible, if any provision of this Public License is deemed +unenforceable, it shall be automatically reformed to the minimum extent necessary +to make it enforceable. If the provision cannot be reformed, it shall be severed +from this Public License without affecting the enforceability of the remaining +terms and conditions. + +c. No term or condition of this Public License will be waived and no failure +to comply consented to unless expressly agreed to by the Licensor. + +d. Nothing in this Public License constitutes or may be interpreted as a limitation +upon, or waiver of, any privileges and immunities that apply to the Licensor +or You, including from the legal processes of any jurisdiction or authority. + +Creative Commons is not a party to its public licenses. Notwithstanding, Creative +Commons may elect to apply one of its public licenses to material it publishes +and in those instances will be considered the "Licensor." The text of the +Creative Commons public licenses is dedicated to the public domain under the +CC0 Public Domain Dedication. Except for the limited purpose of indicating +that material is shared under a Creative Commons public license or as otherwise +permitted by the Creative Commons policies published at creativecommons.org/policies, +Creative Commons does not authorize the use of the trademark "Creative Commons" +or any other trademark or logo of Creative Commons without its prior written +consent including, without limitation, in connection with any unauthorized +modifications to any of its public licenses or any other arrangements, understandings, +or agreements concerning use of licensed material. For the avoidance of doubt, +this paragraph does not form part of the public licenses. + +Creative Commons may be contacted at creativecommons.org. diff --git a/LICENSES/FSFAP.txt b/LICENSES/FSFAP.txt new file mode 100644 index 00000000..32bc8a88 --- /dev/null +++ b/LICENSES/FSFAP.txt @@ -0,0 +1 @@ +Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty. diff --git a/LICENSES/FSFULLR.txt b/LICENSES/FSFULLR.txt new file mode 100644 index 00000000..2acb219e --- /dev/null +++ b/LICENSES/FSFULLR.txt @@ -0,0 +1,3 @@ +Copyright 1996-2006 Free Software Foundation, Inc. + +This file is free software; the Free Software Foundation gives unlimited permission to copy and/or distribute it, with or without modifications, as long as this notice is preserved. diff --git a/LICENSES/GPL-2.0 b/LICENSES/GPL-2.0 deleted file mode 100644 index cdd31bf8..00000000 --- a/LICENSES/GPL-2.0 +++ /dev/null @@ -1,353 +0,0 @@ -Valid-License-Identifier: GPL-2.0-only -Valid-License-Identifier: GPL-2.0-or-later -SPDX-URL: https://spdx.org/licenses/GPL-2.0.html -Usage-Guide: - To use this license in source code, put one of the following SPDX - tag/value pairs into a comment according to the placement - guidelines in the licensing rules documentation. - For 'GNU General Public License (GPL) version 2 only' use: - SPDX-License-Identifier: GPL-2.0-only - For 'GNU General Public License (GPL) version 2 or any later version' use: - SPDX-License-Identifier: GPL-2.0-or-later -License-Text: - - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/LICENSES/GPL-2.0-only.txt b/LICENSES/GPL-2.0-only.txt new file mode 100644 index 00000000..17cb2864 --- /dev/null +++ b/LICENSES/GPL-2.0-only.txt @@ -0,0 +1,117 @@ +GNU GENERAL PUBLIC LICENSE +Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification follow. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. + + c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + + one line to give the program's name and an idea of what it does. Copyright (C) yyyy name of author + + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. + +signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice diff --git a/LICENSES/GPL-2.0-or-later.txt b/LICENSES/GPL-2.0-or-later.txt new file mode 100644 index 00000000..17cb2864 --- /dev/null +++ b/LICENSES/GPL-2.0-or-later.txt @@ -0,0 +1,117 @@ +GNU GENERAL PUBLIC LICENSE +Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Lesser General Public License instead.) You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. + +Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and modification follow. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. + + c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. + +10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + + one line to give the program's name and an idea of what it does. Copyright (C) yyyy name of author + + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. + +signature of Ty Coon, 1 April 1989 Ty Coon, President of Vice diff --git a/LICENSES/GPL-3.0 b/LICENSES/GPL-3.0 deleted file mode 100644 index 4c0b5296..00000000 --- a/LICENSES/GPL-3.0 +++ /dev/null @@ -1,638 +0,0 @@ -Valid-License-Identifier: GPL-3.0-only -Valid-License-Identifier: GPL-3.0-or-later -SPDX-URL: https://spdx.org/licenses/GPL-3.0.html -Usage-Guide: - To use this license in source code, put one of the following SPDX - tag/value pairs into a comment according to the placement - guidelines in the licensing rules documentation. - For 'GNU General Public License (GPL) version 3 only' use: - SPDX-License-Identifier: GPL-3.0-only - For 'GNU General Public License (GPL) version 3 or any later version' use: - SPDX-License-Identifier: GPL-3.0-or-later -License-Text: - -GNU GENERAL PUBLIC LICENSE - -Version 3, 29 June 2007 - -Copyright © 2007 Free Software Foundation, Inc. - -Everyone is permitted to copy and distribute verbatim copies of this license -document, but changing it is not allowed. - -Preamble - -The GNU General Public License is a free, copyleft license for software and -other kinds of works. - -The licenses for most software and other practical works are designed to take -away your freedom to share and change the works. By contrast, the GNU General -Public License is intended to guarantee your freedom to share and change all -versions of a program--to make sure it remains free software for all its users. -We, the Free Software Foundation, use the GNU General Public License for most -of our software; it applies also to any other work released this way by its -authors. You can apply it to your programs, too. - -When we speak of free software, we are referring to freedom, not price. Our -General Public Licenses are designed to make sure that you have the freedom -to distribute copies of free software (and charge for them if you wish), that -you receive source code or can get it if you want it, that you can change -the software or use pieces of it in new free programs, and that you know you -can do these things. - -To protect your rights, we need to prevent others from denying you these rights -or asking you to surrender the rights. Therefore, you have certain responsibilities -if you distribute copies of the software, or if you modify it: responsibilities -to respect the freedom of others. - -For example, if you distribute copies of such a program, whether gratis or -for a fee, you must pass on to the recipients the same freedoms that you received. -You must make sure that they, too, receive or can get the source code. And -you must show them these terms so they know their rights. - -Developers that use the GNU GPL protect your rights with two steps: (1) assert -copyright on the software, and (2) offer you this License giving you legal -permission to copy, distribute and/or modify it. - -For the developers' and authors' protection, the GPL clearly explains that -there is no warranty for this free software. For both users' and authors' -sake, the GPL requires that modified versions be marked as changed, so that -their problems will not be attributed erroneously to authors of previous versions. - -Some devices are designed to deny users access to install or run modified -versions of the software inside them, although the manufacturer can do so. -This is fundamentally incompatible with the aim of protecting users' freedom -to change the software. The systematic pattern of such abuse occurs in the -area of products for individuals to use, which is precisely where it is most -unacceptable. Therefore, we have designed this version of the GPL to prohibit -the practice for those products. If such problems arise substantially in other -domains, we stand ready to extend this provision to those domains in future -versions of the GPL, as needed to protect the freedom of users. - -Finally, every program is threatened constantly by software patents. States -should not allow patents to restrict development and use of software on general-purpose -computers, but in those that do, we wish to avoid the special danger that -patents applied to a free program could make it effectively proprietary. To -prevent this, the GPL assures that patents cannot be used to render the program -non-free. - -The precise terms and conditions for copying, distribution and modification -follow. - -TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - -"Copyright" also means copyright-like laws that apply to other kinds of works, -such as semiconductor masks. - -"The Program" refers to any copyrightable work licensed under this License. -Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals -or organizations. - -To "modify" a work means to copy from or adapt all or part of the work in -a fashion requiring copyright permission, other than the making of an exact -copy. The resulting work is called a "modified version" of the earlier work -or a work "based on" the earlier work. - -A "covered work" means either the unmodified Program or a work based on the -Program. - -To "propagate" a work means to do anything with it that, without permission, -would make you directly or secondarily liable for infringement under applicable -copyright law, except executing it on a computer or modifying a private copy. -Propagation includes copying, distribution (with or without modification), -making available to the public, and in some countries other activities as -well. - -To "convey" a work means any kind of propagation that enables other parties -to make or receive copies. Mere interaction with a user through a computer -network, with no transfer of a copy, is not conveying. - -An interactive user interface displays "Appropriate Legal Notices" to the -extent that it includes a convenient and prominently visible feature that -(1) displays an appropriate copyright notice, and (2) tells the user that -there is no warranty for the work (except to the extent that warranties are -provided), that licensees may convey the work under this License, and how -to view a copy of this License. If the interface presents a list of user commands -or options, such as a menu, a prominent item in the list meets this criterion. - - 1. Source Code. - -The "source code" for a work means the preferred form of the work for making -modifications to it. "Object code" means any non-source form of a work. - -A "Standard Interface" means an interface that either is an official standard -defined by a recognized standards body, or, in the case of interfaces specified -for a particular programming language, one that is widely used among developers -working in that language. - -The "System Libraries" of an executable work include anything, other than -the work as a whole, that (a) is included in the normal form of packaging -a Major Component, but which is not part of that Major Component, and (b) -serves only to enable use of the work with that Major Component, or to implement -a Standard Interface for which an implementation is available to the public -in source code form. A "Major Component", in this context, means a major essential -component (kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to produce -the work, or an object code interpreter used to run it. - -The "Corresponding Source" for a work in object code form means all the source -code needed to generate, install, and (for an executable work) run the object -code and to modify the work, including scripts to control those activities. -However, it does not include the work's System Libraries, or general-purpose -tools or generally available free programs which are used unmodified in performing -those activities but which are not part of the work. For example, Corresponding -Source includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically linked -subprograms that the work is specifically designed to require, such as by -intimate data communication or control flow between those subprograms and -other parts of the work. - -The Corresponding Source need not include anything that users can regenerate -automatically from other parts of the Corresponding Source. - - The Corresponding Source for a work in source code form is that same work. - - 2. Basic Permissions. - -All rights granted under this License are granted for the term of copyright -on the Program, and are irrevocable provided the stated conditions are met. -This License explicitly affirms your unlimited permission to run the unmodified -Program. The output from running a covered work is covered by this License -only if the output, given its content, constitutes a covered work. This License -acknowledges your rights of fair use or other equivalent, as provided by copyright -law. - -You may make, run and propagate covered works that you do not convey, without -conditions so long as your license otherwise remains in force. You may convey -covered works to others for the sole purpose of having them make modifications -exclusively for you, or provide you with facilities for running those works, -provided that you comply with the terms of this License in conveying all material -for which you do not control copyright. Those thus making or running the covered -works for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of your copyrighted -material outside their relationship with you. - -Conveying under any other circumstances is permitted solely under the conditions -stated below. Sublicensing is not allowed; section 10 makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - -No covered work shall be deemed part of an effective technological measure -under any applicable law fulfilling obligations under article 11 of the WIPO -copyright treaty adopted on 20 December 1996, or similar laws prohibiting -or restricting circumvention of such measures. - -When you convey a covered work, you waive any legal power to forbid circumvention -of technological measures to the extent such circumvention is effected by -exercising rights under this License with respect to the covered work, and -you disclaim any intention to limit operation or modification of the work -as a means of enforcing, against the work's users, your or third parties' -legal rights to forbid circumvention of technological measures. - - 4. Conveying Verbatim Copies. - -You may convey verbatim copies of the Program's source code as you receive -it, in any medium, provided that you conspicuously and appropriately publish -on each copy an appropriate copyright notice; keep intact all notices stating -that this License and any non-permissive terms added in accord with section -7 apply to the code; keep intact all notices of the absence of any warranty; -and give all recipients a copy of this License along with the Program. - -You may charge any price or no price for each copy that you convey, and you -may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - -You may convey a work based on the Program, or the modifications to produce -it from the Program, in the form of source code under the terms of section -4, provided that you also meet all of these conditions: - -a) The work must carry prominent notices stating that you modified it, and -giving a relevant date. - -b) The work must carry prominent notices stating that it is released under -this License and any conditions added under section 7. This requirement modifies -the requirement in section 4 to "keep intact all notices". - -c) You must license the entire work, as a whole, under this License to anyone -who comes into possession of a copy. This License will therefore apply, along -with any applicable section 7 additional terms, to the whole of the work, -and all its parts, regardless of how they are packaged. This License gives -no permission to license the work in any other way, but it does not invalidate -such permission if you have separately received it. - -d) If the work has interactive user interfaces, each must display Appropriate -Legal Notices; however, if the Program has interactive interfaces that do -not display Appropriate Legal Notices, your work need not make them do so. - -A compilation of a covered work with other separate and independent works, -which are not by their nature extensions of the covered work, and which are -not combined with it such as to form a larger program, in or on a volume of -a storage or distribution medium, is called an "aggregate" if the compilation -and its resulting copyright are not used to limit the access or legal rights -of the compilation's users beyond what the individual works permit. Inclusion -of a covered work in an aggregate does not cause this License to apply to -the other parts of the aggregate. - - 6. Conveying Non-Source Forms. - -You may convey a covered work in object code form under the terms of sections -4 and 5, provided that you also convey the machine-readable Corresponding -Source under the terms of this License, in one of these ways: - -a) Convey the object code in, or embodied in, a physical product (including -a physical distribution medium), accompanied by the Corresponding Source fixed -on a durable physical medium customarily used for software interchange. - -b) Convey the object code in, or embodied in, a physical product (including -a physical distribution medium), accompanied by a written offer, valid for -at least three years and valid for as long as you offer spare parts or customer -support for that product model, to give anyone who possesses the object code -either (1) a copy of the Corresponding Source for all the software in the -product that is covered by this License, on a durable physical medium customarily -used for software interchange, for a price no more than your reasonable cost -of physically performing this conveying of source, or (2) access to copy the -Corresponding Source from a network server at no charge. - -c) Convey individual copies of the object code with a copy of the written -offer to provide the Corresponding Source. This alternative is allowed only -occasionally and noncommercially, and only if you received the object code -with such an offer, in accord with subsection 6b. - -d) Convey the object code by offering access from a designated place (gratis -or for a charge), and offer equivalent access to the Corresponding Source -in the same way through the same place at no further charge. You need not -require recipients to copy the Corresponding Source along with the object -code. If the place to copy the object code is a network server, the Corresponding -Source may be on a different server (operated by you or a third party) that -supports equivalent copying facilities, provided you maintain clear directions -next to the object code saying where to find the Corresponding Source. Regardless -of what server hosts the Corresponding Source, you remain obligated to ensure -that it is available for as long as needed to satisfy these requirements. - -e) Convey the object code using peer-to-peer transmission, provided you inform -other peers where the object code and Corresponding Source of the work are -being offered to the general public at no charge under subsection 6d. - -A separable portion of the object code, whose source code is excluded from -the Corresponding Source as a System Library, need not be included in conveying -the object code work. - -A "User Product" is either (1) a "consumer product", which means any tangible -personal property which is normally used for personal, family, or household -purposes, or (2) anything designed or sold for incorporation into a dwelling. -In determining whether a product is a consumer product, doubtful cases shall -be resolved in favor of coverage. For a particular product received by a particular -user, "normally used" refers to a typical or common use of that class of product, -regardless of the status of the particular user or of the way in which the -particular user actually uses, or expects or is expected to use, the product. -A product is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent the -only significant mode of use of the product. - -"Installation Information" for a User Product means any methods, procedures, -authorization keys, or other information required to install and execute modified -versions of a covered work in that User Product from a modified version of -its Corresponding Source. The information must suffice to ensure that the -continued functioning of the modified object code is in no case prevented -or interfered with solely because modification has been made. - -If you convey an object code work under this section in, or with, or specifically -for use in, a User Product, and the conveying occurs as part of a transaction -in which the right of possession and use of the User Product is transferred -to the recipient in perpetuity or for a fixed term (regardless of how the -transaction is characterized), the Corresponding Source conveyed under this -section must be accompanied by the Installation Information. But this requirement -does not apply if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has been installed -in ROM). - -The requirement to provide Installation Information does not include a requirement -to continue to provide support service, warranty, or updates for a work that -has been modified or installed by the recipient, or for the User Product in -which it has been modified or installed. Access to a network may be denied -when the modification itself materially and adversely affects the operation -of the network or violates the rules and protocols for communication across -the network. - -Corresponding Source conveyed, and Installation Information provided, in accord -with this section must be in a format that is publicly documented (and with -an implementation available to the public in source code form), and must require -no special password or key for unpacking, reading or copying. - - 7. Additional Terms. - -"Additional permissions" are terms that supplement the terms of this License -by making exceptions from one or more of its conditions. Additional permissions -that are applicable to the entire Program shall be treated as though they -were included in this License, to the extent that they are valid under applicable -law. If additional permissions apply only to part of the Program, that part -may be used separately under those permissions, but the entire Program remains -governed by this License without regard to the additional permissions. - -When you convey a copy of a covered work, you may at your option remove any -additional permissions from that copy, or from any part of it. (Additional -permissions may be written to require their own removal in certain cases when -you modify the work.) You may place additional permissions on material, added -by you to a covered work, for which you have or can give appropriate copyright -permission. - -Notwithstanding any other provision of this License, for material you add -to a covered work, you may (if authorized by the copyright holders of that -material) supplement the terms of this License with terms: - -a) Disclaiming warranty or limiting liability differently from the terms of -sections 15 and 16 of this License; or - -b) Requiring preservation of specified reasonable legal notices or author -attributions in that material or in the Appropriate Legal Notices displayed -by works containing it; or - -c) Prohibiting misrepresentation of the origin of that material, or requiring -that modified versions of such material be marked in reasonable ways as different -from the original version; or - -d) Limiting the use for publicity purposes of names of licensors or authors -of the material; or - -e) Declining to grant rights under trademark law for use of some trade names, -trademarks, or service marks; or - -f) Requiring indemnification of licensors and authors of that material by -anyone who conveys the material (or modified versions of it) with contractual -assumptions of liability to the recipient, for any liability that these contractual -assumptions directly impose on those licensors and authors. - -All other non-permissive additional terms are considered "further restrictions" -within the meaning of section 10. If the Program as you received it, or any -part of it, contains a notice stating that it is governed by this License -along with a term that is a further restriction, you may remove that term. -If a license document contains a further restriction but permits relicensing -or conveying under this License, you may add to a covered work material governed -by the terms of that license document, provided that the further restriction -does not survive such relicensing or conveying. - -If you add terms to a covered work in accord with this section, you must place, -in the relevant source files, a statement of the additional terms that apply -to those files, or a notice indicating where to find the applicable terms. - -Additional terms, permissive or non-permissive, may be stated in the form -of a separately written license, or stated as exceptions; the above requirements -apply either way. - - 8. Termination. - -You may not propagate or modify a covered work except as expressly provided -under this License. Any attempt otherwise to propagate or modify it is void, -and will automatically terminate your rights under this License (including -any patent licenses granted under the third paragraph of section 11). - -However, if you cease all violation of this License, then your license from -a particular copyright holder is reinstated (a) provisionally, unless and -until the copyright holder explicitly and finally terminates your license, -and (b) permanently, if the copyright holder fails to notify you of the violation -by some reasonable means prior to 60 days after the cessation. - -Moreover, your license from a particular copyright holder is reinstated permanently -if the copyright holder notifies you of the violation by some reasonable means, -this is the first time you have received notice of violation of this License -(for any work) from that copyright holder, and you cure the violation prior -to 30 days after your receipt of the notice. - -Termination of your rights under this section does not terminate the licenses -of parties who have received copies or rights from you under this License. -If your rights have been terminated and not permanently reinstated, you do -not qualify to receive new licenses for the same material under section 10. - - 9. Acceptance Not Required for Having Copies. - -You are not required to accept this License in order to receive or run a copy -of the Program. Ancillary propagation of a covered work occurring solely as -a consequence of using peer-to-peer transmission to receive a copy likewise -does not require acceptance. However, nothing other than this License grants -you permission to propagate or modify any covered work. These actions infringe -copyright if you do not accept this License. Therefore, by modifying or propagating -a covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - -Each time you convey a covered work, the recipient automatically receives -a license from the original licensors, to run, modify and propagate that work, -subject to this License. You are not responsible for enforcing compliance -by third parties with this License. - -An "entity transaction" is a transaction transferring control of an organization, -or substantially all assets of one, or subdividing an organization, or merging -organizations. If propagation of a covered work results from an entity transaction, -each party to that transaction who receives a copy of the work also receives -whatever licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the Corresponding -Source of the work from the predecessor in interest, if the predecessor has -it or can get it with reasonable efforts. - -You may not impose any further restrictions on the exercise of the rights -granted or affirmed under this License. For example, you may not impose a -license fee, royalty, or other charge for exercise of rights granted under -this License, and you may not initiate litigation (including a cross-claim -or counterclaim in a lawsuit) alleging that any patent claim is infringed -by making, using, selling, offering for sale, or importing the Program or -any portion of it. - - 11. Patents. - -A "contributor" is a copyright holder who authorizes use under this License -of the Program or a work on which the Program is based. The work thus licensed -is called the contributor's "contributor version". - -A contributor's "essential patent claims" are all patent claims owned or controlled -by the contributor, whether already acquired or hereafter acquired, that would -be infringed by some manner, permitted by this License, of making, using, -or selling its contributor version, but do not include claims that would be -infringed only as a consequence of further modification of the contributor -version. For purposes of this definition, "control" includes the right to -grant patent sublicenses in a manner consistent with the requirements of this -License. - -Each contributor grants you a non-exclusive, worldwide, royalty-free patent -license under the contributor's essential patent claims, to make, use, sell, -offer for sale, import and otherwise run, modify and propagate the contents -of its contributor version. - -In the following three paragraphs, a "patent license" is any express agreement -or commitment, however denominated, not to enforce a patent (such as an express -permission to practice a patent or covenant not to sue for patent infringement). -To "grant" such a patent license to a party means to make such an agreement -or commitment not to enforce a patent against the party. - -If you convey a covered work, knowingly relying on a patent license, and the -Corresponding Source of the work is not available for anyone to copy, free -of charge and under the terms of this License, through a publicly available -network server or other readily accessible means, then you must either (1) -cause the Corresponding Source to be so available, or (2) arrange to deprive -yourself of the benefit of the patent license for this particular work, or -(3) arrange, in a manner consistent with the requirements of this License, -to extend the patent license to downstream recipients. "Knowingly relying" -means you have actual knowledge that, but for the patent license, your conveying -the covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that country -that you have reason to believe are valid. - -If, pursuant to or in connection with a single transaction or arrangement, -you convey, or propagate by procuring conveyance of, a covered work, and grant -a patent license to some of the parties receiving the covered work authorizing -them to use, propagate, modify or convey a specific copy of the covered work, -then the patent license you grant is automatically extended to all recipients -of the covered work and works based on it. - -A patent license is "discriminatory" if it does not include within the scope -of its coverage, prohibits the exercise of, or is conditioned on the non-exercise -of one or more of the rights that are specifically granted under this License. -You may not convey a covered work if you are a party to an arrangement with -a third party that is in the business of distributing software, under which -you make payment to the third party based on the extent of your activity of -conveying the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory patent -license (a) in connection with copies of the covered work conveyed by you -(or copies made from those copies), or (b) primarily for and in connection -with specific products or compilations that contain the covered work, unless -you entered into that arrangement, or that patent license was granted, prior -to 28 March 2007. - -Nothing in this License shall be construed as excluding or limiting any implied -license or other defenses to infringement that may otherwise be available -to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - -If conditions are imposed on you (whether by court order, agreement or otherwise) -that contradict the conditions of this License, they do not excuse you from -the conditions of this License. If you cannot convey a covered work so as -to satisfy simultaneously your obligations under this License and any other -pertinent obligations, then as a consequence you may not convey it at all. -For example, if you agree to terms that obligate you to collect a royalty -for further conveying from those to whom you convey the Program, the only -way you could satisfy both those terms and this License would be to refrain -entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - -Notwithstanding any other provision of this License, you have permission to -link or combine any covered work with a work licensed under version 3 of the -GNU Affero General Public License into a single combined work, and to convey -the resulting work. The terms of this License will continue to apply to the -part which is the covered work, but the special requirements of the GNU Affero -General Public License, section 13, concerning interaction through a network -will apply to the combination as such. - - 14. Revised Versions of this License. - -The Free Software Foundation may publish revised and/or new versions of the -GNU General Public License from time to time. Such new versions will be similar -in spirit to the present version, but may differ in detail to address new -problems or concerns. - -Each version is given a distinguishing version number. If the Program specifies -that a certain numbered version of the GNU General Public License "or any -later version" applies to it, you have the option of following the terms and -conditions either of that numbered version or of any later version published -by the Free Software Foundation. If the Program does not specify a version -number of the GNU General Public License, you may choose any version ever -published by the Free Software Foundation. - -If the Program specifies that a proxy can decide which future versions of -the GNU General Public License can be used, that proxy's public statement -of acceptance of a version permanently authorizes you to choose that version -for the Program. - -Later license versions may give you additional or different permissions. However, -no additional obligations are imposed on any author or copyright holder as -a result of your choosing to follow a later version. - - 15. Disclaimer of Warranty. - -THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE -LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER -EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM -PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR -CORRECTION. - - 16. Limitation of Liability. - -IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL -ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM -AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, -INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO -USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED -INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE -PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER -PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - -If the disclaimer of warranty and limitation of liability provided above cannot -be given local legal effect according to their terms, reviewing courts shall -apply local law that most closely approximates an absolute waiver of all civil -liability in connection with the Program, unless a warranty or assumption -of liability accompanies a copy of the Program in return for a fee. END OF -TERMS AND CONDITIONS - -How to Apply These Terms to Your New Programs - -If you develop a new program, and you want it to be of the greatest possible -use to the public, the best way to achieve this is to make it free software -which everyone can redistribute and change under these terms. - -To do so, attach the following notices to the program. It is safest to attach -them to the start of each source file to most effectively state the exclusion -of warranty; and each file should have at least the "copyright" line and a -pointer to where the full notice is found. - - - -Copyright (C) - -This program is free software: you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - -If the program does terminal interaction, make it output a short notice like -this when it starts in an interactive mode: - - Copyright (C) - -This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - -This is free software, and you are welcome to redistribute it under certain -conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands might -be different; for a GUI interface, you would use an "about box". - -You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. For -more information on this, and how to apply and follow the GNU GPL, see . - -The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General Public -License instead of this License. But first, please read . diff --git a/LICENSES/GPL-3.0-or-later.txt b/LICENSES/GPL-3.0-or-later.txt new file mode 100644 index 00000000..f6cdd22a --- /dev/null +++ b/LICENSES/GPL-3.0-or-later.txt @@ -0,0 +1,232 @@ +GNU GENERAL PUBLIC LICENSE +Version 3, 29 June 2007 + +Copyright © 2007 Free Software Foundation, Inc. + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +Preamble + +The GNU General Public License is a free, copyleft license for software and other kinds of works. + +The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. + +When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. + +To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. + +For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. + +Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. + +For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. + +Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. + +Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. + +The precise terms and conditions for copying, distribution and modification follow. + +TERMS AND CONDITIONS + +0. Definitions. + +“This License” refers to version 3 of the GNU General Public License. + +“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. + +“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations. + +To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work. + +A “covered work” means either the unmodified Program or a work based on the Program. + +To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. + +To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. + +An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. + +1. Source Code. +The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work. + +A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. + +The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. + +The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. + +The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. + +The Corresponding Source for a work in source code form is that same work. + +2. Basic Permissions. +All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. + +3. Protecting Users' Legal Rights From Anti-Circumvention Law. +No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. + +When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. + +4. Conveying Verbatim Copies. +You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. + +You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. + +5. Conveying Modified Source Versions. +You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”. + + c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. + +A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. + +6. Conveying Non-Source Forms. +You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: + + a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. + + d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. + +A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. + +A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. + +“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. + +If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). + +The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. + +Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. + +7. Additional Terms. +“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or authors of the material; or + + e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. + +All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. + +8. Termination. +You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). + +However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. + +Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. + +Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. + +9. Acceptance Not Required for Having Copies. +You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. + +10. Automatic Licensing of Downstream Recipients. +Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. + +An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. + +11. Patents. +A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”. + +A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. + +In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. + +If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. + +A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. + +12. No Surrender of Others' Freedom. +If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. + +13. Use with the GNU Affero General Public License. +Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. + +14. Revised Versions of this License. +The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. + +If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. + +Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. + +15. Disclaimer of Warranty. +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. Limitation of Liability. +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +17. Interpretation of Sections 15 and 16. +If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Programs + +If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. + +To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + +If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”. + +You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . + +The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . diff --git a/LICENSES/LGPL-2.1 b/LICENSES/LGPL-2.1 deleted file mode 100644 index 8738a8d5..00000000 --- a/LICENSES/LGPL-2.1 +++ /dev/null @@ -1,503 +0,0 @@ -Valid-License-Identifier: LGPL-2.1-only -Valid-License-Identifier: LGPL-2.1-or-later -SPDX-URL: https://spdx.org/licenses/LGPL-2.1.html -Usage-Guide: - To use this license in source code, put one of the following SPDX - tag/value pairs into a comment according to the placement - guidelines in the licensing rules documentation. - For 'GNU Lesser General Public License (LGPL) version 2.1 only' use: - SPDX-License-Identifier: LGPL-2.1-only - For 'GNU Lesser General Public License (LGPL) version 2.1 or any later - version' use: - SPDX-License-Identifier: LGPL-2.1-or-later -License-Text: - -GNU LESSER GENERAL PUBLIC LICENSE -Version 2.1, February 1999 - -Copyright (C) 1991, 1999 Free Software Foundation, Inc. -51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -Everyone is permitted to copy and distribute verbatim copies of this -license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts as -the successor of the GNU Library Public License, version 2, hence the -version number 2.1.] - -Preamble - -The licenses for most software are designed to take away your freedom to -share and change it. By contrast, the GNU General Public Licenses are -intended to guarantee your freedom to share and change free software--to -make sure the software is free for all its users. - -This license, the Lesser General Public License, applies to some specially -designated software packages--typically libraries--of the Free Software -Foundation and other authors who decide to use it. You can use it too, but -we suggest you first think carefully about whether this license or the -ordinary General Public License is the better strategy to use in any -particular case, based on the explanations below. - -When we speak of free software, we are referring to freedom of use, not -price. Our General Public Licenses are designed to make sure that you have -the freedom to distribute copies of free software (and charge for this -service if you wish); that you receive source code or can get it if you -want it; that you can change the software and use pieces of it in new free -programs; and that you are informed that you can do these things. - -To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for you if -you distribute copies of the library or if you modify it. - -For example, if you distribute copies of the library, whether gratis or for -a fee, you must give the recipients all the rights that we gave you. You -must make sure that they, too, receive or can get the source code. If you -link other code with the library, you must provide complete object files to -the recipients, so that they can relink them with the library after making -changes to the library and recompiling it. And you must show them these -terms so they know their rights. - -We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - -To protect each distributor, we want to make it very clear that there is no -warranty for the free library. Also, if the library is modified by someone -else and passed on, the recipients should know that what they have is not -the original version, so that the original author's reputation will not be -affected by problems that might be introduced by others. - -Finally, software patents pose a constant threat to the existence of any -free program. We wish to make sure that a company cannot effectively -restrict the users of a free program by obtaining a restrictive license -from a patent holder. Therefore, we insist that any patent license obtained -for a version of the library must be consistent with the full freedom of -use specified in this license. - -Most GNU software, including some libraries, is covered by the ordinary GNU -General Public License. This license, the GNU Lesser General Public -License, applies to certain designated libraries, and is quite different -from the ordinary General Public License. We use this license for certain -libraries in order to permit linking those libraries into non-free -programs. - -When a program is linked with a library, whether statically or using a -shared library, the combination of the two is legally speaking a combined -work, a derivative of the original library. The ordinary General Public -License therefore permits such linking only if the entire combination fits -its criteria of freedom. The Lesser General Public License permits more lax -criteria for linking other code with the library. - -We call this license the "Lesser" General Public License because it does -Less to protect the user's freedom than the ordinary General Public -License. It also provides other free software developers Less of an -advantage over competing non-free programs. These disadvantages are the -reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - -For example, on rare occasions, there may be a special need to encourage -the widest possible use of a certain library, so that it becomes a de-facto -standard. To achieve this, non-free programs must be allowed to use the -library. A more frequent case is that a free library does the same job as -widely used non-free libraries. In this case, there is little to gain by -limiting the free library to free software only, so we use the Lesser -General Public License. - -In other cases, permission to use a particular library in non-free programs -enables a greater number of people to use a large body of free -software. For example, permission to use the GNU C Library in non-free -programs enables many more people to use the whole GNU operating system, as -well as its variant, the GNU/Linux operating system. - -Although the Lesser General Public License is Less protective of the users' -freedom, it does ensure that the user of a program that is linked with the -Library has the freedom and the wherewithal to run that program using a -modified version of the Library. - -The precise terms and conditions for copying, distribution and modification -follow. Pay close attention to the difference between a "work based on the -library" and a "work that uses the library". The former contains code -derived from the library, whereas the latter must be combined with the -library in order to run. - -TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - -0. This License Agreement applies to any software library or other program - which contains a notice placed by the copyright holder or other - authorized party saying it may be distributed under the terms of this - Lesser General Public License (also called "this License"). Each - licensee is addressed as "you". - - A "library" means a collection of software functions and/or data - prepared so as to be conveniently linked with application programs - (which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work which - has been distributed under these terms. A "work based on the Library" - means either the Library or any derivative work under copyright law: - that is to say, a work containing the Library or a portion of it, either - verbatim or with modifications and/or translated straightforwardly into - another language. (Hereinafter, translation is included without - limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for making - modifications to it. For a library, complete source code means all the - source code for all modules it contains, plus any associated interface - definition files, plus the scripts used to control compilation and - installation of the library. - - Activities other than copying, distribution and modification are not - covered by this License; they are outside its scope. The act of running - a program using the Library is not restricted, and output from such a - program is covered only if its contents constitute a work based on the - Library (independent of the use of the Library in a tool for writing - it). Whether that is true depends on what the Library does and what the - program that uses the Library does. - -1. You may copy and distribute verbatim copies of the Library's complete - source code as you receive it, in any medium, provided that you - conspicuously and appropriately publish on each copy an appropriate - copyright notice and disclaimer of warranty; keep intact all the notices - that refer to this License and to the absence of any warranty; and - distribute a copy of this License along with the Library. - - You may charge a fee for the physical act of transferring a copy, and - you may at your option offer warranty protection in exchange for a fee. - -2. You may modify your copy or copies of the Library or any portion of it, - thus forming a work based on the Library, and copy and distribute such - modifications or work under the terms of Section 1 above, provided that - you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices stating - that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no charge to - all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a table - of data to be supplied by an application program that uses the - facility, other than as an argument passed when the facility is - invoked, then you must make a good faith effort to ensure that, in - the event an application does not supply such function or table, the - facility still operates, and performs whatever part of its purpose - remains meaningful. - - (For example, a function in a library to compute square roots has a - purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must be - optional: if the application does not supply it, the square root - function must still compute square roots.) - - These requirements apply to the modified work as a whole. If - identifiable sections of that work are not derived from the Library, and - can be reasonably considered independent and separate works in - themselves, then this License, and its terms, do not apply to those - sections when you distribute them as separate works. But when you - distribute the same sections as part of a whole which is a work based on - the Library, the distribution of the whole must be on the terms of this - License, whose permissions for other licensees extend to the entire - whole, and thus to each and every part regardless of who wrote it. - - Thus, it is not the intent of this section to claim rights or contest - your rights to work written entirely by you; rather, the intent is to - exercise the right to control the distribution of derivative or - collective works based on the Library. - - In addition, mere aggregation of another work not based on the Library - with the Library (or with a work based on the Library) on a volume of a - storage or distribution medium does not bring the other work under the - scope of this License. - -3. You may opt to apply the terms of the ordinary GNU General Public - License instead of this License to a given copy of the Library. To do - this, you must alter all the notices that refer to this License, so that - they refer to the ordinary GNU General Public License, version 2, - instead of to this License. (If a newer version than version 2 of the - ordinary GNU General Public License has appeared, then you can specify - that version instead if you wish.) Do not make any other change in these - notices. - - Once this change is made in a given copy, it is irreversible for that - copy, so the ordinary GNU General Public License applies to all - subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of the - Library into a program that is not a library. - -4. You may copy and distribute the Library (or a portion or derivative of - it, under Section 2) in object code or executable form under the terms - of Sections 1 and 2 above provided that you accompany it with the - complete corresponding machine-readable source code, which must be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange. - - If distribution of object code is made by offering access to copy from a - designated place, then offering equivalent access to copy the source - code from the same place satisfies the requirement to distribute the - source code, even though third parties are not compelled to copy the - source along with the object code. - -5. A program that contains no derivative of any portion of the Library, but - is designed to work with the Library by being compiled or linked with - it, is called a "work that uses the Library". Such a work, in isolation, - is not a derivative work of the Library, and therefore falls outside the - scope of this License. - - However, linking a "work that uses the Library" with the Library creates - an executable that is a derivative of the Library (because it contains - portions of the Library), rather than a "work that uses the - library". The executable is therefore covered by this License. Section 6 - states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file - that is part of the Library, the object code for the work may be a - derivative work of the Library even though the source code is - not. Whether this is true is especially significant if the work can be - linked without the Library, or if the work is itself a library. The - threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data structure - layouts and accessors, and small macros and small inline functions (ten - lines or less in length), then the use of the object file is - unrestricted, regardless of whether it is legally a derivative - work. (Executables containing this object code plus portions of the - Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may - distribute the object code for the work under the terms of Section - 6. Any executables containing that work also fall under Section 6, - whether or not they are linked directly with the Library itself. - -6. As an exception to the Sections above, you may also combine or link a - "work that uses the Library" with the Library to produce a work - containing portions of the Library, and distribute that work under terms - of your choice, provided that the terms permit modification of the work - for the customer's own use and reverse engineering for debugging such - modifications. - - You must give prominent notice with each copy of the work that the - Library is used in it and that the Library and its use are covered by - this License. You must supply a copy of this License. If the work during - execution displays copyright notices, you must include the copyright - notice for the Library among them, as well as a reference directing the - user to the copy of this License. Also, you must do one of these things: - - a) Accompany the work with the complete corresponding machine-readable - source code for the Library including whatever changes were used in - the work (which must be distributed under Sections 1 and 2 above); - and, if the work is an executable linked with the Library, with the - complete machine-readable "work that uses the Library", as object - code and/or source code, so that the user can modify the Library and - then relink to produce a modified executable containing the modified - Library. (It is understood that the user who changes the contents of - definitions files in the Library will not necessarily be able to - recompile the application to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a copy - of the library already present on the user's computer system, rather - than copying library functions into the executable, and (2) will - operate properly with a modified version of the library, if the user - installs one, as long as the modified version is interface-compatible - with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at least three - years, to give the same user the materials specified in Subsection - 6a, above, for a charge no more than the cost of performing this - distribution. - - d) If distribution of the work is made by offering access to copy from a - designated place, offer equivalent access to copy the above specified - materials from the same place. - - e) Verify that the user has already received a copy of these materials - or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the Library" - must include any data and utility programs needed for reproducing the - executable from it. However, as a special exception, the materials to be - distributed need not include anything that is normally distributed (in - either source or binary form) with the major components (compiler, - kernel, and so on) of the operating system on which the executable runs, - unless that component itself accompanies the executable. - - It may happen that this requirement contradicts the license restrictions - of other proprietary libraries that do not normally accompany the - operating system. Such a contradiction means you cannot use both them - and the Library together in an executable that you distribute. - -7. You may place library facilities that are a work based on the Library - side-by-side in a single library together with other library facilities - not covered by this License, and distribute such a combined library, - provided that the separate distribution of the work based on the Library - and of the other library facilities is otherwise permitted, and provided - that you do these two things: - - a) Accompany the combined library with a copy of the same work based on - the Library, uncombined with any other library facilities. This must - be distributed under the terms of the Sections above. - - b) Give prominent notice with the combined library of the fact that part - of it is a work based on the Library, and explaining where to find - the accompanying uncombined form of the same work. - -8. You may not copy, modify, sublicense, link with, or distribute the - Library except as expressly provided under this License. Any attempt - otherwise to copy, modify, sublicense, link with, or distribute the - Library is void, and will automatically terminate your rights under this - License. However, parties who have received copies, or rights, from you - under this License will not have their licenses terminated so long as - such parties remain in full compliance. - -9. You are not required to accept this License, since you have not signed - it. However, nothing else grants you permission to modify or distribute - the Library or its derivative works. These actions are prohibited by law - if you do not accept this License. Therefore, by modifying or - distributing the Library (or any work based on the Library), you - indicate your acceptance of this License to do so, and all its terms and - conditions for copying, distributing or modifying the Library or works - based on it. - -10. Each time you redistribute the Library (or any work based on the - Library), the recipient automatically receives a license from the - original licensor to copy, distribute, link with or modify the Library - subject to these terms and conditions. You may not impose any further - restrictions on the recipients' exercise of the rights granted - herein. You are not responsible for enforcing compliance by third - parties with this License. - -11. If, as a consequence of a court judgment or allegation of patent - infringement or for any other reason (not limited to patent issues), - conditions are imposed on you (whether by court order, agreement or - otherwise) that contradict the conditions of this License, they do not - excuse you from the conditions of this License. If you cannot - distribute so as to satisfy simultaneously your obligations under this - License and any other pertinent obligations, then as a consequence you - may not distribute the Library at all. For example, if a patent license - would not permit royalty-free redistribution of the Library by all - those who receive copies directly or indirectly through you, then the - only way you could satisfy both it and this License would be to refrain - entirely from distribution of the Library. - - If any portion of this section is held invalid or unenforceable under - any particular circumstance, the balance of the section is intended to - apply, and the section as a whole is intended to apply in other - circumstances. - - It is not the purpose of this section to induce you to infringe any - patents or other property right claims or to contest validity of any - such claims; this section has the sole purpose of protecting the - integrity of the free software distribution system which is implemented - by public license practices. Many people have made generous - contributions to the wide range of software distributed through that - system in reliance on consistent application of that system; it is up - to the author/donor to decide if he or she is willing to distribute - software through any other system and a licensee cannot impose that - choice. - - This section is intended to make thoroughly clear what is believed to - be a consequence of the rest of this License. - -12. If the distribution and/or use of the Library is restricted in certain - countries either by patents or by copyrighted interfaces, the original - copyright holder who places the Library under this License may add an - explicit geographical distribution limitation excluding those - countries, so that distribution is permitted only in or among countries - not thus excluded. In such case, this License incorporates the - limitation as if written in the body of this License. - -13. The Free Software Foundation may publish revised and/or new versions of - the Lesser General Public License from time to time. Such new versions - will be similar in spirit to the present version, but may differ in - detail to address new problems or concerns. - - Each version is given a distinguishing version number. If the Library - specifies a version number of this License which applies to it and "any - later version", you have the option of following the terms and - conditions either of that version or of any later version published by - the Free Software Foundation. If the Library does not specify a license - version number, you may choose any version ever published by the Free - Software Foundation. - -14. If you wish to incorporate parts of the Library into other free - programs whose distribution conditions are incompatible with these, - write to the author to ask for permission. For software which is - copyrighted by the Free Software Foundation, write to the Free Software - Foundation; we sometimes make exceptions for this. Our decision will be - guided by the two goals of preserving the free status of all - derivatives of our free software and of promoting the sharing and reuse - of software generally. - -NO WARRANTY - -15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY - FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN - OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES - PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER - EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE - ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH - YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL - NECESSARY SERVICING, REPAIR OR CORRECTION. - -16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING - WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR - REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR - DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL - DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY - (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED - INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF - THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR - OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. - -END OF TERMS AND CONDITIONS - -How to Apply These Terms to Your New Libraries - -If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - -To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - -one line to give the library's name and an idea of what it does. -Copyright (C) year name of author - -This library is free software; you can redistribute it and/or modify it -under the terms of the GNU Lesser General Public License as published by -the Free Software Foundation; either version 2.1 of the License, or (at -your option) any later version. - -This library is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License -for more details. - -You should have received a copy of the GNU Lesser General Public License -along with this library; if not, write to the Free Software Foundation, -Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add -information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - -Yoyodyne, Inc., hereby disclaims all copyright interest in -the library `Frob' (a library for tweaking knobs) written -by James Random Hacker. - -signature of Ty Coon, 1 April 1990 -Ty Coon, President of Vice -That's all there is to it! diff --git a/LICENSES/LGPL-2.1-only.txt b/LICENSES/LGPL-2.1-only.txt new file mode 100644 index 00000000..c9aa5301 --- /dev/null +++ b/LICENSES/LGPL-2.1-only.txt @@ -0,0 +1,175 @@ +GNU LESSER GENERAL PUBLIC LICENSE + +Version 2.1, February 1999 + +Copyright (C) 1991, 1999 Free Software Foundation, Inc. +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] + +Preamble + +The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. + +This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. + +When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. + +To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. + +For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. + +We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. + +To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. + +Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. + +Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. + +When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. + +We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. + +For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. + +In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. + +Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. + +The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. + +TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + +0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". + +A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. + +The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) + +"Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. + +Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. + +1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. + +You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. + +(For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. + +3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. + +Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. + +This option is useful when you wish to copy part of the code of the Library into a program that is not a library. + +4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. + +If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. + +5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. + +However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. + +When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. + +If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) + +Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. + +6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. + +You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: + + a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. + + e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. + +For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. + +It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. + +7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. + + b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. + +8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. + +9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. + +10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. + +11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. + +12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. + +13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. + +14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS + +How to Apply These Terms to Your New Libraries + +If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). + +To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. + + one line to give the library's name and an idea of what it does. + Copyright (C) year name of author + + This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: + +Yoyodyne, Inc., hereby disclaims all copyright interest in +the library `Frob' (a library for tweaking knobs) written +by James Random Hacker. + +signature of Ty Coon, 1 April 1990 +Ty Coon, President of Vice +That's all there is to it! diff --git a/LICENSES/LicenseRef-Autoconf-exception-macro.txt b/LICENSES/LicenseRef-Autoconf-exception-macro.txt new file mode 100644 index 00000000..8b5b4677 --- /dev/null +++ b/LICENSES/LicenseRef-Autoconf-exception-macro.txt @@ -0,0 +1,12 @@ +As a special exception, the respective Autoconf Macro's copyright owner +gives unlimited permission to copy, distribute and modify the configure +scripts that are the output of Autoconf when processing the Macro. You +need not follow the terms of the GNU General Public License when using +or distributing such scripts, even though portions of the text of the +Macro appear in them. The GNU General Public License (GPL) does govern +all other use of the material that constitutes the Autoconf Macro. + +This special exception to the GPL applies to versions of the Autoconf +Macro released by the Autoconf Archive. When you make and distribute a +modified version of the Autoconf Macro, you may extend this special +exception to the GPL to apply to your modified version as well. diff --git a/LICENSES/MIT b/LICENSES/MIT deleted file mode 100644 index f33a68ce..00000000 --- a/LICENSES/MIT +++ /dev/null @@ -1,30 +0,0 @@ -Valid-License-Identifier: MIT -SPDX-URL: https://spdx.org/licenses/MIT.html -Usage-Guide: - To use the MIT License put the following SPDX tag/value pair into a - comment according to the placement guidelines in the licensing rules - documentation: - SPDX-License-Identifier: MIT -License-Text: - -MIT License - -Copyright (c) - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff --git a/LICENSES/MIT.txt b/LICENSES/MIT.txt new file mode 100644 index 00000000..f33a68ce --- /dev/null +++ b/LICENSES/MIT.txt @@ -0,0 +1,30 @@ +Valid-License-Identifier: MIT +SPDX-URL: https://spdx.org/licenses/MIT.html +Usage-Guide: + To use the MIT License put the following SPDX tag/value pair into a + comment according to the placement guidelines in the licensing rules + documentation: + SPDX-License-Identifier: MIT +License-Text: + +MIT License + +Copyright (c) + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/LICENSES/PSF-2.0.txt b/LICENSES/PSF-2.0.txt new file mode 100644 index 00000000..1df6b3b8 --- /dev/null +++ b/LICENSES/PSF-2.0.txt @@ -0,0 +1,254 @@ +A. HISTORY OF THE SOFTWARE +========================== + +Python was created in the early 1990s by Guido van Rossum at Stichting +Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands +as a successor of a language called ABC. Guido remains Python's +principal author, although it includes many contributions from others. + +In 1995, Guido continued his work on Python at the Corporation for +National Research Initiatives (CNRI, see http://www.cnri.reston.va.us) +in Reston, Virginia where he released several versions of the +software. + +In May 2000, Guido and the Python core development team moved to +BeOpen.com to form the BeOpen PythonLabs team. In October of the same +year, the PythonLabs team moved to Digital Creations, which became +Zope Corporation. In 2001, the Python Software Foundation (PSF, see +https://www.python.org/psf/) was formed, a non-profit organization +created specifically to own Python-related Intellectual Property. +Zope Corporation was a sponsoring member of the PSF. + +All Python releases are Open Source (see http://www.opensource.org for +the Open Source Definition). Historically, most, but not all, Python +releases have also been GPL-compatible; the table below summarizes +the various releases. + + Release Derived Year Owner GPL- + from compatible? (1) + + 0.9.0 thru 1.2 1991-1995 CWI yes + 1.3 thru 1.5.2 1.2 1995-1999 CNRI yes + 1.6 1.5.2 2000 CNRI no + 2.0 1.6 2000 BeOpen.com no + 1.6.1 1.6 2001 CNRI yes (2) + 2.1 2.0+1.6.1 2001 PSF no + 2.0.1 2.0+1.6.1 2001 PSF yes + 2.1.1 2.1+2.0.1 2001 PSF yes + 2.1.2 2.1.1 2002 PSF yes + 2.1.3 2.1.2 2002 PSF yes + 2.2 and above 2.1.1 2001-now PSF yes + +Footnotes: + +(1) GPL-compatible doesn't mean that we're distributing Python under + the GPL. All Python licenses, unlike the GPL, let you distribute + a modified version without making your changes open source. The + GPL-compatible licenses make it possible to combine Python with + other software that is released under the GPL; the others don't. + +(2) According to Richard Stallman, 1.6.1 is not GPL-compatible, + because its license has a choice of law clause. According to + CNRI, however, Stallman's lawyer has told CNRI's lawyer that 1.6.1 + is "not incompatible" with the GPL. + +Thanks to the many outside volunteers who have worked under Guido's +direction to make these releases possible. + + +B. TERMS AND CONDITIONS FOR ACCESSING OR OTHERWISE USING PYTHON +=============================================================== + +PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2 +-------------------------------------------- + +1. This LICENSE AGREEMENT is between the Python Software Foundation +("PSF"), and the Individual or Organization ("Licensee") accessing and +otherwise using this software ("Python") in source or binary form and +its associated documentation. + +2. Subject to the terms and conditions of this License Agreement, PSF hereby +grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, +analyze, test, perform and/or display publicly, prepare derivative works, +distribute, and otherwise use Python alone or in any derivative version, +provided, however, that PSF's License Agreement and PSF's notice of copyright, +i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, +2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2022 Python Software Foundation; +All Rights Reserved" are retained in Python alone or in any derivative version +prepared by Licensee. + +3. In the event Licensee prepares a derivative work that is based on +or incorporates Python or any part thereof, and wants to make +the derivative work available to others as provided herein, then +Licensee hereby agrees to include in any such work a brief summary of +the changes made to Python. + +4. PSF is making Python available to Licensee on an "AS IS" +basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR +IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND +DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS +FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT +INFRINGE ANY THIRD PARTY RIGHTS. + +5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON +FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS +A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON, +OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. + +6. This License Agreement will automatically terminate upon a material +breach of its terms and conditions. + +7. Nothing in this License Agreement shall be deemed to create any +relationship of agency, partnership, or joint venture between PSF and +Licensee. This License Agreement does not grant permission to use PSF +trademarks or trade name in a trademark sense to endorse or promote +products or services of Licensee, or any third party. + +8. By copying, installing or otherwise using Python, Licensee +agrees to be bound by the terms and conditions of this License +Agreement. + + +BEOPEN.COM LICENSE AGREEMENT FOR PYTHON 2.0 +------------------------------------------- + +BEOPEN PYTHON OPEN SOURCE LICENSE AGREEMENT VERSION 1 + +1. This LICENSE AGREEMENT is between BeOpen.com ("BeOpen"), having an +office at 160 Saratoga Avenue, Santa Clara, CA 95051, and the +Individual or Organization ("Licensee") accessing and otherwise using +this software in source or binary form and its associated +documentation ("the Software"). + +2. Subject to the terms and conditions of this BeOpen Python License +Agreement, BeOpen hereby grants Licensee a non-exclusive, +royalty-free, world-wide license to reproduce, analyze, test, perform +and/or display publicly, prepare derivative works, distribute, and +otherwise use the Software alone or in any derivative version, +provided, however, that the BeOpen Python License is retained in the +Software, alone or in any derivative version prepared by Licensee. + +3. BeOpen is making the Software available to Licensee on an "AS IS" +basis. BEOPEN MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR +IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, BEOPEN MAKES NO AND +DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS +FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE WILL NOT +INFRINGE ANY THIRD PARTY RIGHTS. + +4. BEOPEN SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF THE +SOFTWARE FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS +AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THE SOFTWARE, OR ANY +DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. + +5. This License Agreement will automatically terminate upon a material +breach of its terms and conditions. + +6. This License Agreement shall be governed by and interpreted in all +respects by the law of the State of California, excluding conflict of +law provisions. Nothing in this License Agreement shall be deemed to +create any relationship of agency, partnership, or joint venture +between BeOpen and Licensee. This License Agreement does not grant +permission to use BeOpen trademarks or trade names in a trademark +sense to endorse or promote products or services of Licensee, or any +third party. As an exception, the "BeOpen Python" logos available at +http://www.pythonlabs.com/logos.html may be used according to the +permissions granted on that web page. + +7. By copying, installing or otherwise using the software, Licensee +agrees to be bound by the terms and conditions of this License +Agreement. + + +CNRI LICENSE AGREEMENT FOR PYTHON 1.6.1 +--------------------------------------- + +1. This LICENSE AGREEMENT is between the Corporation for National +Research Initiatives, having an office at 1895 Preston White Drive, +Reston, VA 20191 ("CNRI"), and the Individual or Organization +("Licensee") accessing and otherwise using Python 1.6.1 software in +source or binary form and its associated documentation. + +2. Subject to the terms and conditions of this License Agreement, CNRI +hereby grants Licensee a nonexclusive, royalty-free, world-wide +license to reproduce, analyze, test, perform and/or display publicly, +prepare derivative works, distribute, and otherwise use Python 1.6.1 +alone or in any derivative version, provided, however, that CNRI's +License Agreement and CNRI's notice of copyright, i.e., "Copyright (c) +1995-2001 Corporation for National Research Initiatives; All Rights +Reserved" are retained in Python 1.6.1 alone or in any derivative +version prepared by Licensee. Alternately, in lieu of CNRI's License +Agreement, Licensee may substitute the following text (omitting the +quotes): "Python 1.6.1 is made available subject to the terms and +conditions in CNRI's License Agreement. This Agreement together with +Python 1.6.1 may be located on the internet using the following +unique, persistent identifier (known as a handle): 1895.22/1013. This +Agreement may also be obtained from a proxy server on the internet +using the following URL: http://hdl.handle.net/1895.22/1013". + +3. In the event Licensee prepares a derivative work that is based on +or incorporates Python 1.6.1 or any part thereof, and wants to make +the derivative work available to others as provided herein, then +Licensee hereby agrees to include in any such work a brief summary of +the changes made to Python 1.6.1. + +4. CNRI is making Python 1.6.1 available to Licensee on an "AS IS" +basis. CNRI MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR +IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, CNRI MAKES NO AND +DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS +FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON 1.6.1 WILL NOT +INFRINGE ANY THIRD PARTY RIGHTS. + +5. CNRI SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON +1.6.1 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS +A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON 1.6.1, +OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. + +6. This License Agreement will automatically terminate upon a material +breach of its terms and conditions. + +7. This License Agreement shall be governed by the federal +intellectual property law of the United States, including without +limitation the federal copyright law, and, to the extent such +U.S. federal law does not apply, by the law of the Commonwealth of +Virginia, excluding Virginia's conflict of law provisions. +Notwithstanding the foregoing, with regard to derivative works based +on Python 1.6.1 that incorporate non-separable material that was +previously distributed under the GNU General Public License (GPL), the +law of the Commonwealth of Virginia shall govern this License +Agreement only as to issues arising under or with respect to +Paragraphs 4, 5, and 7 of this License Agreement. Nothing in this +License Agreement shall be deemed to create any relationship of +agency, partnership, or joint venture between CNRI and Licensee. This +License Agreement does not grant permission to use CNRI trademarks or +trade name in a trademark sense to endorse or promote products or +services of Licensee, or any third party. + +8. By clicking on the "ACCEPT" button where indicated, or by copying, +installing or otherwise using Python 1.6.1, Licensee agrees to be +bound by the terms and conditions of this License Agreement. + + ACCEPT + + +CWI LICENSE AGREEMENT FOR PYTHON 0.9.0 THROUGH 1.2 +-------------------------------------------------- + +Copyright (c) 1991 - 1995, Stichting Mathematisch Centrum Amsterdam, +The Netherlands. All rights reserved. + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that the name of Stichting Mathematisch +Centrum or CWI not be used in advertising or publicity pertaining to +distribution of the software without specific, written prior +permission. + +STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO +THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE +FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/Makefile.am b/Makefile.am index 642466fa..0f4493b5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -17,14 +17,21 @@ dist_doc_DATA = \ dist_noinst_DATA = CodingStyle EXTRA_DIST = \ - LICENSES/BSD-2-Clause \ - LICENSES/BSD-4-Clause \ - LICENSES/BSL-1.0 \ - LICENSES/CC-BY-SA-4.0 \ - LICENSES/GPL-2.0 \ - LICENSES/GPL-3.0 \ - LICENSES/LGPL-2.1 \ - LICENSES/MIT \ + LICENSES/BSD-2-Clause.txt \ + LICENSES/BSD-4-Clause.txt \ + LICENSES/BSL-1.0.txt \ + LICENSES/CC-BY-SA-4.0.txt \ + LICENSES/FSFAP.txt \ + LICENSES/FSFULLR.txt \ + LICENSES/GPL-2.0-only.txt \ + LICENSES/GPL-2.0-or-later.txt \ + LICENSES/GPL-3.0-or-later.txt \ + LICENSES/LGPL-2.1-only.txt \ + LICENSES/LicenseRef-Autoconf-exception-macro.txt \ + LICENSES/MIT.txt \ + LICENSES/PSF-2.0.txt \ std-ext-lib.txt \ - tools/format-cpp \ + tools/format-cpp.sh \ + tools/lint-py.sh \ + tools/shellcheck.sh \ version diff --git a/README.adoc b/README.adoc index d43246ae..5c7c48e4 100644 --- a/README.adoc +++ b/README.adoc @@ -1,17 +1,22 @@ // Render with Asciidoctor -= Babeltrace -13 April 2020 += Babeltrace 2 +4 March 2024 :btversion: 2.0 :bt2: Babeltrace{nbsp}2 - +ifdef::env-github[] +:toc: macro +endif::[] +ifndef::env-github[] +:toc: left +endif::[] Babeltrace /ˈbæbəltreɪs/, an https://efficios.com/[EfficiOS] project, is an open-source https://en.wikipedia.org/wiki/Tracing_(software)[trace] manipulation framework. -https://ci.lttng.org/job/babeltrace_master_build[image:https://img.shields.io/jenkins/s/https/ci.lttng.org/babeltrace_master_build.svg[]] +https://ci.lttng.org/job/babeltrace_master_linuxbuild[image:https://img.shields.io/jenkins/s/https/ci.lttng.org/babeltrace_master_linuxbuild.svg[]] https://scan.coverity.com/projects/babeltrace[image:https://img.shields.io/coverity/scan/babeltrace.svg[]] The **_{bt2}_** project offers a library with a @@ -22,34 +27,45 @@ https://babeltrace.org/docs/v{btversion}/man1/babeltrace2.1/[command-line tool] (CLI) which makes it very easy for mere mortals to view, convert, transform, and analyze traces. +image::doc/api/libbabeltrace2/images/basic-convert-graph.png[A basic {bt2} conversion graph] + {bt2} is also the reference parser implementation of the -https://diamon.org/ctf/[Common Trace Format] (CTF), a versatile -trace format produced by various tracers and tools such as +https://diamon.org/ctf/[Common Trace Format] (CTF), a flexible +trace format which various tracers and tools such as https://lttng.org/[LTTng] and -https://barectf.org/[barectf]. The {bt2} library and its Python bindings -can read and write CTF traces. +https://barectf.org/[barectf] produce natively. +The {bt2} library and its Python bindings can read and write CTF traces. -See Babeltrace's https://babeltrace.org[official website], in +See the {bt2} https://babeltrace.org[official website], in particular the https://babeltrace.org/docs/v{btversion}/man7/babeltrace2-intro.7[`**babeltrace2-intro**(7)`] manual page, to learn more about the project. [NOTE] +ifdef::env-github[] +.**Babeltrace{nbsp}1 vs. {bt2}** +endif::[] +ifndef::env-github[] .Babeltrace{nbsp}1 vs. {bt2} +endif::[] ==== -The Babeltrace project exists since 2010. In 2020, {bt2} was -released. {bt2} is a complete rewrite of the library, Python -bindings, and CLI. It is plugin-based and offers much more features and -potential than Babeltrace{nbsp}1 while showing comparable performance. +The Babeltrace project exists since 2010. -Because {bt2} is still a young major release, some -distributions still provide packages for the Babeltrace{nbsp}1 project. -Both projects can coexist on the same system as there are no common -files. +In 2020, {bt2} was released. {bt2} is a complete rewrite of the library, +Python bindings, and CLI. It's plugin-based and offers much more +features and potential than Babeltrace{nbsp}1 while delivering +comparable performance. -This file documents the **{bt2}** project. +Some Linux distributions still provide packages for the +Babeltrace{nbsp}1 project. Both projects can coexist on the same system +as there are no conflicting files. + +This README documents the **{bt2}** project. ==== +ifdef::env-github[] +toc::[] +endif::[] == Build Babeltrace{nbsp}{btversion} from source @@ -70,11 +86,11 @@ https://clang.llvm.org/[Clang] is one of those. Tools:: * https://www.gnu.org/software/make/[GNU Make] * **If you build from a Git clone**: - ** https://www.gnu.org/software/automake/[GNU Automake]{nbsp}≥{nbsp}1.12 + ** https://www.gnu.org/software/automake/[GNU Automake]{nbsp}≥{nbsp}1.13 ** https://www.gnu.org/software/autoconf/[GNU Autoconf]{nbsp}≥{nbsp}2.69 ** https://www.gnu.org/software/libtool/[GNU Libtool]{nbsp}≥{nbsp}2.2 ** https://github.com/westes/flex[flex]{nbsp}≥{nbsp}2.5.35 - ** https://www.gnu.org/software/bison/bison.html[GNU Bison]{nbsp}≥{nbsp}2.4 + ** https://www.gnu.org/software/bison/bison.html[GNU Bison]{nbsp}≥{nbsp}2.5 Libraries:: * A C library (for example, @@ -106,6 +122,25 @@ _**If you need the `bt2` Python bindings documentation**_:: Python{nbsp}3 (Debian/Ubuntu/Fedora: `python3-sphinx`) +[NOTE] +ifdef::env-github[] +.**Thanks for the code!** +endif::[] +ifndef::env-github[] +.Thanks for the code! +endif::[] +==== +We'd like to thank the authors of the following projects which are +embedded into the {bt2} source tree: + +* https://github.com/fmtlib/fmt[\{fmt}] +* https://github.com/nlohmann/json[JSON for Modern {cpp}] +* https://github.com/martinmoene/optional-lite[optional lite] +* https://github.com/martinmoene/span-lite[span lite] +* https://github.com/martinmoene/string-view-lite[string_view lite] +* https://github.com/quicknir/wise_enum[wise_enum] +* https://github.com/wonder-mice/zf_log[zf_log] +==== === Procedure @@ -133,6 +168,14 @@ The following options can modify the build: `--enable-api-doc`:: Build the {bt2}{nbsp}C{nbsp}API HTML documentation. +`--enable-built-in-plugins`:: + Statically link the official plugins into the + `babeltrace2` executable. + +`--enable-built-in-python-plugin-support`:: + Statically link the Python plugin provider into the + `babeltrace2` executable. + `--enable-debug-info`:: Build the https://lttng.org/[LTTng] debug information filter component class @@ -158,18 +201,18 @@ The following environment variables can modify the build: `BABELTRACE_DEBUG_MODE`:: Set to `1` to enable the debug mode. + -The debug mode enables more run-time assertions to detect bugs in the -{bt2} project. +The debug mode enables more run-time assertions to detect bugs while +developing the {bt2} project. `BABELTRACE_DEV_MODE`:: Set to `1` to enable the <>. + The {bt2} developer mode enables more precondition and postcondition -assertions to detect programming errors. +assertions to detect C{nbsp}API usage errors. `BABELTRACE_MINIMAL_LOG_LEVEL`:: - Set the build-time, minimal logging level for all the project's - modules. + Set the build-time, minimal logging level for all the modules + of the project. + Set to `TRACE`, `DEBUG`, or `INFO`. @@ -177,9 +220,9 @@ Set to `TRACE`, `DEBUG`, or `INFO`. Installation directory of {bt2} plugin providers. `BABELTRACE_PLUGINS_DIR`:: - Installation directory of {bt2} project plugins. + Installation directory of {bt2} official plugins. -See `./configure --help` to list all the available options and +Run `./configure --help` to list all the available options and environment variables. -- @@ -192,28 +235,32 @@ $ make To install {bt2}: -* Do: +* Run: + [role="term"] ---- # make install ---- - [[dev-mode]] === Build {bt2} for plugin or application development -If you are developing a {bt2} plugin or an application which uses -libbabeltrace2, we recommend that: +If you're developing a {bt2} plugin or an application which uses +libbabeltrace2, we recommend to: -* You build {bt2} from source in _developer mode_. +* Build {bt2} from source in _developer mode_. + The {bt2} developer mode enables more precondition and postcondition -assertions to detect programming errors. +assertions to detect C{nbsp}API usage errors. ++ +The +https://babeltrace.org/docs/v{btversion}/libbabeltrace2[{bt2}{nbsp}C{nbsp}API documentation] +always lists the precondition and postconditions of +functions. + Set `BABELTRACE_DEV_MODE=1` when you <> the {bt2} build. -* You use _TRACE_ as the minimal logging level at build time to have +* Use _TRACE_ as the minimal logging level at build time to have access to more logging, should you need it to debug your plugin or application. + @@ -236,46 +283,48 @@ $ BABELTRACE_DEV_MODE=1 BABELTRACE_MINIMAL_LOG_LEVEL=TRACE ./configure \ ---- See the -https://babeltrace.org/docs/v{btversion}/libbabeltrace2[{bt2}{nbsp}C{nbsp}API] -documentation for more information. - +https://babeltrace.org/docs/v{btversion}/libbabeltrace2[{bt2}{nbsp}C{nbsp}API +documentation] for more information. == Use Babeltrace{nbsp}{btversion} -See the https://babeltrace.org[Babeltrace website] to learn how -to use the different parts of the project. +See the https://babeltrace.org[{bt2} website] to learn how to use the +different parts of the project. +If you're new to {bt2}, make sure to read the +https://babeltrace.org/docs/v{btversion}/man7/babeltrace2-intro.7[`**babeltrace2-intro**(7)`] +manual page to familiarize yourself with the project. === Run-time requirements -Libraries:: - * A C library (for example, - https://www.gnu.org/software/libc/[GNU{nbsp}C Library], - https://www.musl-libc.org/[musl libc]) - * https://developer.gnome.org/glib/[GLib]{nbsp}≥{nbsp}2.28 - (Debian/Ubuntu: `libglib2.0-0`; Fedora: `glib2`) +Libraries:: {empty} ++ +* A C library (for example, + https://www.gnu.org/software/libc/[GNU{nbsp}C Library] or + https://www.musl-libc.org/[musl libc]) -_**If you need the `bt2` Python bindings**_:: - * https://www.python.org[Python]{nbsp}≥{nbsp}3.4 - (Debian/Ubuntu/Fedora: `python3`) +* https://developer.gnome.org/glib/[GLib]{nbsp}≥{nbsp}2.28 + (Debian/Ubuntu: `libglib2.0-0`; Fedora: `glib2`) -_**If you need the https://lttng.org/[LTTng] debug information filter component class (https://babeltrace.org/docs/v{btversion}/man7/babeltrace2-filter.lttng-utils.debug-info.7/[`filter.lttng-utils.debug-info`])**_:: - * https://sourceware.org/elfutils/[elfutils]{nbsp}≥{nbsp}0.154 - (Debian/Ubuntu: `libelf` and `libdw`; Fedora: `elfutils-libs` and - `elfutils-libelf`) +_**If you need the `bt2` Python bindings**_:: {empty} ++ +* https://www.python.org[Python]{nbsp}≥{nbsp}3.4 + (Debian/Ubuntu/Fedora: `python3`) +_**If you need the https://lttng.org/[LTTng] debug information filter component class (https://babeltrace.org/docs/v{btversion}/man7/babeltrace2-filter.lttng-utils.debug-info.7/[`filter.lttng-utils.debug-info`])**_:: {empty} ++ +* https://sourceware.org/elfutils/[elfutils]{nbsp}≥{nbsp}0.154 + (Debian/Ubuntu: `libelf` and `libdw`; Fedora: `elfutils-libs` and + `elfutils-libelf`) == Community -[NOTE] -==== Babeltrace was born to parse CTF traces produced by LTTng{nbsp}2.0 and -pretty-print their events. +to pretty-print their events. -Even though Babeltrace is independent from the LTTng project today, -their communities remain very close, which is why they share some -communication channels and services. -==== +Even though {bt2} is independent from the LTTng project today, their +communities remain very close, which is why they share some +communication channels and services: Mailing list:: https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev[lttng-dev] @@ -285,15 +334,15 @@ IRC channel:: irc://irc.oftc.net/lttng[`#lttng`] on the OFTC network Bug tracker:: - https://bugs.lttng.org/projects/babeltrace[Babeltrace bug tracker] + https://bugs.lttng.org/projects/babeltrace[{bt2} bug tracker] GitHub project:: https://github.com/efficios/babeltrace/[efficios/babeltrace] Continuous integration:: - https://ci.lttng.org/job/babeltrace_master_build/[Babeltrace's master build] - on LTTng's CI + https://ci.lttng.org/view/Babeltrace/[{bt2} jobs] + on the LTTng CI Code review:: - https://review.lttng.org/q/project:babeltrace[_babeltrace_ project] - on LTTng Review + https://review.lttng.org/q/project:babeltrace[{bt2} project] + on LTTng Review (Gerrit) diff --git a/configure.ac b/configure.ac index 89884d97..799df2f7 100644 --- a/configure.ac +++ b/configure.ac @@ -50,7 +50,7 @@ AC_CANONICAL_HOST ## Automake base setup ## ## ## -AM_INIT_AUTOMAKE([1.12 foreign dist-bzip2 no-dist-gzip tar-ustar nostdinc -Wall -Wno-portability -Werror]) +AM_INIT_AUTOMAKE([1.13 foreign dist-bzip2 no-dist-gzip tar-ustar nostdinc subdir-objects -Wall -Wno-portability -Werror]) AM_MAINTAINER_MODE([enable]) # Enable silent rules by default @@ -110,7 +110,7 @@ AX_C___ATTRIBUTE__ AS_IF([test "x$ax_cv___attribute__" != "xyes"], [AC_MSG_ERROR([The compiler does not support __attribute__ extensions])]) -# Make sur we have pthread support +# Make sure we have pthread support AX_PTHREAD([], [AC_MSG_ERROR([Could not configure pthread support])]) # Checks for typedefs, structures, and compiler characteristics. @@ -211,12 +211,12 @@ AX_PROG_BISON_VERSION([2.5], [have_bison=yes]) AS_IF([test "x$have_bison" != "xyes"], [ AE_IF_IN_GIT_REPO([ AC_MSG_FAILURE([dnl -Bison >= 2.4 is required when building from the Git repository. You can +Bison >= 2.5 is required when building from the Git repository. You can set the YACC variable to override automatic detection. ]) ], [ AC_MSG_WARN([dnl -Missing Bison >= 2.4. Note that the parser files are already built in +Missing Bison >= 2.5. Note that the parser files are already built in this distribution tarball, so Bison is only needed if you intend to modify their sources. You can set the YACC variable to override automatic detection. @@ -250,7 +250,7 @@ AM_CONDITIONAL([HAVE_FLEX], [test "x$have_flex" = "xyes"]) # Always check for python, we will fail later if some features require it and # it's unavailable. -AM_PATH_PYTHON([3.0], [ +AM_PATH_PYTHON([3.4], [ AE_PATH_PYTHON_MODULES([PYTHON]) # pythondir is the path where extra modules are to be installed @@ -380,7 +380,7 @@ AS_IF([test "$BABELTRACE_MINIMAL_LOG_LEVEL" != "TRACE" && \ test "$BABELTRACE_MINIMAL_LOG_LEVEL" != "INFO"], [AC_MSG_ERROR([Invalid BABELTRACE_MINIMAL_LOG_LEVEL value ($BABELTRACE_MINIMAL_LOG_LEVEL): use TRACE, DEBUG, or INFO.])] ) -AC_DEFINE_UNQUOTED([BT_MINIMAL_LOG_LEVEL], [BT_LOG_$BABELTRACE_MINIMAL_LOG_LEVEL], [Minimal log level]) +AC_DEFINE_UNQUOTED([BT_LOG_MINIMAL_LEVEL], [__BT_LOGGING_LEVEL_$BABELTRACE_MINIMAL_LOG_LEVEL], [Minimal log level]) # BABELTRACE_DEV_MODE: AC_ARG_VAR([BABELTRACE_DEV_MODE], [Set to 1 to enable the Babeltrace developer mode (enables run-time checks for plugin developers)]) @@ -396,9 +396,9 @@ AS_IF([test "x$BABELTRACE_DEBUG_MODE" = x1], [ ], [BABELTRACE_DEBUG_MODE=0]) -## ## -## Optionnal features selection ## -## ## +## ## +## Optional features selection ## +## ## # Python bindings # Disabled by default @@ -448,6 +448,7 @@ AE_FEATURE([Werror],[Treat compiler warnings as errors.]) # When given, build with AddressSanitizer. AE_FEATURE_DEFAULT_DISABLE AE_FEATURE([asan],[Build with AddressSanitizer.]) +AE_FEATURE([ubsan],[Build with UndefinedBehaviorSanitizer.]) ## ## ## Check for conflicting features selection ## @@ -513,6 +514,9 @@ AE_IF_FEATURE_ENABLED([built-in-python-plugin-support], [AC_DEFINE([BT_BUILT_IN_PYTHON_PLUGIN_SUPPORT], [1], [Define to 1 to register plug-in attributes in static executable sections])] ) +AE_IF_FEATURE_ENABLED([python-plugins], [ENABLE_PYTHON_PLUGINS=1], [ENABLE_PYTHON_PLUGINS=0]) +AC_SUBST([ENABLE_PYTHON_PLUGINS]) + AE_IF_FEATURE_ENABLED([debug-info], [ENABLE_DEBUG_INFO_VAL=1], [ENABLE_DEBUG_INFO_VAL=0]) AC_SUBST([ENABLE_DEBUG_INFO_VAL]) @@ -534,10 +538,28 @@ AS_IF([test -n "$PYTHON_CONFIG"], [have_python_dev=yes], [have_python_dev=no]) AM_CONDITIONAL([HAVE_PYTHON], [test "x$have_python" = xyes]) AM_CONDITIONAL([HAVE_PYTHON_DEV], [test "x$have_python_dev" = xyes]) +AS_IF([test "x$have_python" = xyes], [ + AX_COMPARE_VERSION(["$PYTHON_VERSION"], [ge], ["3.12"], [ + have_python_312_or_greater=yes + ]) +]) + +AM_CONDITIONAL([HAVE_PYTHON_312_OR_GREATER], [test "x$have_python_312_or_greater" = xyes]) + AS_IF([AE_IS_FEATURE_ENABLED([python-bindings]) || AE_IS_FEATURE_ENABLED([python-plugins])], [ AS_IF([test "x$have_python_dev" = xno], [ AC_MSG_ERROR([Cannot find a suitable python-config. You can override the python-config path with the PYTHON_CONFIG environment variable.]) ]) + + AX_COMPARE_VERSION(["$PYTHON_VERSION"], [ge], ["3.12"], [ + AC_MSG_CHECKING([for python setuptools]) + AS_IF(["$PYTHON" -c "import setuptools" 2>/dev/null], [ + AC_MSG_RESULT([yes]) + ], [ + AC_MSG_RESULT([no]) + AC_MSG_ERROR([Python >= 3.12 removed 'distutils', the 'setuptools' module needs to be installed for the selected interpreter.]) + ]) + ]) ]) AE_IF_FEATURE_ENABLED([python-bindings-doc], @@ -584,7 +606,7 @@ AE_IF_FEATURE_ENABLED([api-doc], DX_XML_FEATURE(OFF) DX_PDF_FEATURE(OFF) DX_PS_FEATURE(OFF) - DX_INIT_DOXYGEN([Babeltrace 2], [$(builddir)/Doxyfile], [output]) + DX_INIT_DOXYGEN([babeltrace2], [$(builddir)/Doxyfile], [output]) AS_IF([test -z "$DX_DOXYGEN"], [AC_MSG_ERROR([You need doxygen to enable the API documentation])] ) @@ -645,13 +667,19 @@ AE_IF_FEATURE_ENABLED([asan], [ ASAN_LDFLAGS="-fsanitize=address" ]) - +# If --enable-ubsan is used... +AE_IF_FEATURE_ENABLED([ubsan], [ + # ... add -fsanitize=undefined to the *FLAGS variables. + UBSAN_CFLAGS="-fsanitize=undefined" + UBSAN_CXXFLAGS="-fsanitize=undefined" + UBSAN_LDFLAGS="-fsanitize=undefined" +]) # CFLAGS from libraries (the glib ones are needed for the following sizeof # test). -AM_CFLAGS="${PTHREAD_CFLAGS} ${GLIB_CFLAGS} ${ASAN_CFLAGS}" -AM_CXXFLAGS="${PTHREAD_CFLAGS} ${GLIB_CFLAGS} ${ASAN_CXXFLAGS}" -AM_LDFLAGS="${ASAN_LDFLAGS}" +AM_CFLAGS="-fvisibility=hidden ${PTHREAD_CFLAGS} ${GLIB_CFLAGS} ${ASAN_CFLAGS} ${UBSAN_CFLAGS}" +AM_CXXFLAGS="-fvisibility=hidden -fvisibility-inlines-hidden ${PTHREAD_CFLAGS} ${GLIB_CFLAGS} ${ASAN_CXXFLAGS} ${UBSAN_CFLAGS}" +AM_LDFLAGS="${ASAN_LDFLAGS} ${UBSAN_CFLAGS}" # Check that the current size_t matches the size that glib thinks it should # be. This catches problems on multi-arch where people try to do a 32-bit @@ -704,6 +732,7 @@ m4_define([WARN_FLAGS_LIST], [ dnl dnl Clang's does not. Enable Clang's `-Wshadow-field-in-constructor`, to make dnl Clang warn about that. -Wshadow-field-in-constructor dnl + -Wshadow-field dnl -Wjump-misses-init dnl -Wsuggest-attribute=format dnl -Wtautological-constant-out-of-range-compare dnl @@ -717,7 +746,6 @@ m4_define([WARN_FLAGS_LIST], [ dnl -Wduplicated-branches dnl -Wlogical-op dnl -Wsuggest-override dnl - -Wno-unused-parameter dnl -Wno-sign-compare dnl dnl dnl Some versions of SWIG (like 3.0.12) generate code that produces @@ -732,7 +760,6 @@ m4_define([WARN_FLAGS_LIST], [ dnl dnl dnl Ref: https://github.com/swig/swig/issues/1259 -Wno-cast-function-type dnl - -Wno-missing-field-initializers dnl -Wno-maybe-uninitialized dnl ]) @@ -771,79 +798,35 @@ AC_SUBST(AM_CPPFLAGS) # Add glib to global link libs LIBS="$LIBS $GLIB_LIBS" +# Disable exceptions for the {fmt} library. This means, for example, that a +# format error will result in an assertion failure (instead of throwing an +# `fmt::format_error` exception). +AC_DEFINE_UNQUOTED([FMT_EXCEPTIONS], 0, [Disable {fmt} exceptions.]) + # Abuse autoconf's AC_ARG_PROGRAM output variable 'program_transform_name' # to rename babeltrace2.bin to babeltrace2 at install time. program_transform_name="s&babeltrace2\.bin&babeltrace2&;$program_transform_name" AC_SUBST(program_transform_name) AC_CONFIG_FILES([ - doc/api/Makefile doc/api/libbabeltrace2/Doxyfile doc/api/libbabeltrace2/Makefile - doc/bindings/Makefile doc/bindings/python/Makefile - doc/contributing-images/Makefile doc/Makefile doc/man/asciidoc-attrs.conf doc/man/Makefile include/Makefile Makefile - src/argpar/Makefile - src/autodisc/Makefile src/babeltrace2-ctf-writer.pc src/babeltrace2.pc - src/bindings/Makefile src/bindings/python/bt2/bt2/version.py src/bindings/python/bt2/Makefile src/bindings/python/bt2/setup.py - src/bindings/python/Makefile src/cli/Makefile - src/common/Makefile - src/cpp-common/Makefile - src/compat/Makefile - src/ctfser/Makefile - src/ctf-writer/Makefile - src/fd-cache/Makefile - src/lib/graph/Makefile - src/lib/graph/message/Makefile - src/lib/Makefile - src/lib/plugin/Makefile - src/lib/prio-heap/Makefile - src/lib/trace-ir/Makefile - src/logging/Makefile src/Makefile - src/plugins/common/Makefile - src/plugins/common/muxing/Makefile - src/plugins/common/param-validation/Makefile - src/plugins/ctf/common/bfcr/Makefile - src/plugins/ctf/common/Makefile - src/plugins/ctf/common/metadata/Makefile - src/plugins/ctf/common/msg-iter/Makefile - src/plugins/ctf/fs-sink/Makefile - src/plugins/ctf/fs-src/Makefile - src/plugins/ctf/lttng-live/Makefile - src/plugins/ctf/Makefile - src/plugins/lttng-utils/debug-info/Makefile - src/plugins/lttng-utils/Makefile - src/plugins/Makefile - src/plugins/text/dmesg/Makefile - src/plugins/text/Makefile - src/plugins/text/pretty/Makefile - src/plugins/text/details/Makefile - src/plugins/utils/counter/Makefile - src/plugins/utils/dummy/Makefile - src/plugins/utils/Makefile - src/plugins/utils/muxer/Makefile - src/plugins/utils/trimmer/Makefile - src/py-common/Makefile - src/python-plugin-provider/Makefile - src/param-parse/Makefile - src/string-format/Makefile tests/bitfield/Makefile tests/ctf-writer/Makefile tests/lib/Makefile - tests/lib/test-plugin-plugins/Makefile - tests/lib/conds/Makefile tests/Makefile tests/param-validation/Makefile tests/plugins/Makefile @@ -856,12 +839,11 @@ AC_CONFIG_FILES([ tests/plugins/flt.utils.muxer/succeed/Makefile tests/plugins/flt.utils.trimmer/Makefile tests/plugins/sink.text.pretty/Makefile + tests/utils/env.sh tests/utils/Makefile tests/utils/tap/Makefile ]) -AC_CONFIG_FILES([tests/utils/env.sh],[chmod +x tests/utils/env.sh]) - AC_OUTPUT # diff --git a/dev-requirements.txt b/dev-requirements.txt index 452c0de6..76abc5d0 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,2 +1,3 @@ -black ~= 22.0 +black ~= 23.9.1 flake8 >= 3.8 +isort ~= 5.12 diff --git a/doc/Makefile.am b/doc/Makefile.am index 7047f0e5..160cd5a9 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,7 +1,26 @@ # SPDX-License-Identifier: MIT -SUBDIRS = contributing-images man bindings +SUBDIRS = man if ENABLE_API_DOC -SUBDIRS += api +SUBDIRS += api/libbabeltrace2 endif + +if ENABLE_PYTHON_BINDINGS_DOC +SUBDIRS += bindings/python +endif + +EXTRA_DIST = \ + contributing-images/bt-ref01.png \ + contributing-images/bt-ref02.png \ + contributing-images/bt-ref03.png \ + contributing-images/bt-ref04.png \ + contributing-images/bt-ref05.png \ + contributing-images/bt-ref06.png \ + contributing-images/bt-ref07.png \ + contributing-images/bt-ref08.png \ + contributing-images/bt-ref09.png \ + contributing-images/bt-ref10.png \ + contributing-images/bt-ref11.png \ + contributing-images/bt-ref12.png \ + contributing-images/bt-ref13.png diff --git a/doc/api/Makefile.am b/doc/api/Makefile.am deleted file mode 100644 index c5f96ec7..00000000 --- a/doc/api/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -# SPDX-License-Identifier: MIT - -SUBDIRS = libbabeltrace2 diff --git a/doc/api/libbabeltrace2/Doxyfile.in b/doc/api/libbabeltrace2/Doxyfile.in index cd94819e..07a7c281 100644 --- a/doc/api/libbabeltrace2/Doxyfile.in +++ b/doc/api/libbabeltrace2/Doxyfile.in @@ -28,7 +28,7 @@ ALIASES += bt_max_mip_version="0" ALIASES += bt_name="Babeltrace 2" ALIASES += bt_name_version_min_maj="Babeltrace \bt_version_min_maj" ALIASES += bt_api="Babeltrace 2 C API" -ALIASES += bt_p{1}="\1" +ALIASES += bt_p{1}="\1" ALIASES += bt_dt_opt="Optional:" ALIASES += bt_man{2}="\1(\2)" ALIASES += bt_cli="babeltrace2" diff --git a/doc/api/libbabeltrace2/examples/distill.c b/doc/api/libbabeltrace2/examples/distill.c index 81fe2e82..bf92f65d 100644 --- a/doc/api/libbabeltrace2/examples/distill.c +++ b/doc/api/libbabeltrace2/examples/distill.c @@ -110,7 +110,7 @@ distill_message_iterator_initialize( /* Keep a link to the component's private data */ distill_iter->distill = distill; - /* Create the uptream message iterator */ + /* Create the upstream message iterator */ bt_message_iterator_create_from_message_iterator(self_message_iterator, distill->in_port, &distill_iter->message_iterator); @@ -150,7 +150,6 @@ bool message_passes(struct distill_message_iterator *distill_iter, /* Move as is if it's not an event message */ if (bt_message_get_type(message) != BT_MESSAGE_TYPE_EVENT) { - passes = false; goto end; } diff --git a/doc/api/libbabeltrace2/examples/epitome.c b/doc/api/libbabeltrace2/examples/epitome.c index 852ca3f7..ab68408f 100644 --- a/doc/api/libbabeltrace2/examples/epitome.c +++ b/doc/api/libbabeltrace2/examples/epitome.c @@ -81,7 +81,7 @@ epitome_out_graph_is_configured(bt_self_component_sink *self_component_sink) bt_self_component_sink_borrow_input_port_by_index( self_component_sink, 0); - /* Create the uptream message iterator */ + /* Create the upstream message iterator */ bt_message_iterator_create_from_sink_component(self_component_sink, in_port, &epitome_out->message_iterator); diff --git a/doc/bindings/Makefile.am b/doc/bindings/Makefile.am deleted file mode 100644 index a9d7ab1b..00000000 --- a/doc/bindings/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -# SPDX-License-Identifier: MIT - -if ENABLE_PYTHON_BINDINGS_DOC -SUBDIRS = python -endif diff --git a/doc/bindings/python/ext/bt2sphinxurl.py b/doc/bindings/python/ext/bt2sphinxurl.py index d76cc1c7..830e0d1e 100644 --- a/doc/bindings/python/ext/bt2sphinxurl.py +++ b/doc/bindings/python/ext/bt2sphinxurl.py @@ -33,12 +33,13 @@ # # :bt2link:`libbabeltrace2 ` -import docutils -import docutils.utils -import docutils.nodes import re import functools +import docutils +import docutils.nodes +import docutils.utils + def _bt2man_role( bt2_version, name, rawtext, text, lineno, inliner, options=None, content=None diff --git a/doc/bindings/python/source/common.rst b/doc/bindings/python/source/common.rst index 812127ab..cb595145 100644 --- a/doc/bindings/python/source/common.rst +++ b/doc/bindings/python/source/common.rst @@ -1,3 +1,7 @@ +.. + SPDX-FileCopyrightText: 2020 Philippe Proulx + SPDX-License-Identifier: CC-BY-SA-4.0 + .. non-breaking space substitution (see ): diff --git a/doc/bindings/python/source/conf.py b/doc/bindings/python/source/conf.py index 148cc92a..99e60af8 100644 --- a/doc/bindings/python/source/conf.py +++ b/doc/bindings/python/source/conf.py @@ -2,9 +2,10 @@ # # Copyright (c) 2020 Philippe Proulx -import bt2 import re +import bt2 + # project project = "Babeltrace 2 Python bindings" copyright = "2020, EfficiOS, Inc" diff --git a/doc/bindings/python/source/examples.rst b/doc/bindings/python/source/examples.rst index ab8bd399..e2a46cc7 100644 --- a/doc/bindings/python/source/examples.rst +++ b/doc/bindings/python/source/examples.rst @@ -1,3 +1,7 @@ +.. + SPDX-FileCopyrightText: 2020 Philippe Proulx + SPDX-License-Identifier: CC-BY-SA-4.0 + .. include:: common.rst .. _examples: diff --git a/doc/bindings/python/source/index.rst b/doc/bindings/python/source/index.rst index 2a2c8b16..bf90b63a 100644 --- a/doc/bindings/python/source/index.rst +++ b/doc/bindings/python/source/index.rst @@ -1,3 +1,7 @@ +.. + SPDX-FileCopyrightText: 2020 Philippe Proulx + SPDX-License-Identifier: CC-BY-SA-4.0 + .. include:: common.rst Welcome! diff --git a/doc/bindings/python/source/installation.rst b/doc/bindings/python/source/installation.rst index 5b0412dc..03a7db29 100644 --- a/doc/bindings/python/source/installation.rst +++ b/doc/bindings/python/source/installation.rst @@ -1,3 +1,7 @@ +.. + SPDX-FileCopyrightText: 2020 Philippe Proulx + SPDX-License-Identifier: CC-BY-SA-4.0 + .. include:: common.rst Installation diff --git a/doc/contributing-images/Makefile.am b/doc/contributing-images/Makefile.am deleted file mode 100644 index 338b7bb4..00000000 --- a/doc/contributing-images/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -# SPDX-License-Identifier: MIT - -EXTRA_DIST = bt-ref01.png bt-ref02.png bt-ref03.png bt-ref04.png \ - bt-ref05.png bt-ref06.png bt-ref07.png bt-ref08.png \ - bt-ref09.png bt-ref10.png bt-ref11.png bt-ref12.png \ - bt-ref13.png diff --git a/doc/man/babeltrace2-filter.lttng-utils.debug-info.7.txt b/doc/man/babeltrace2-filter.lttng-utils.debug-info.7.txt index f98c7d7c..bccd8549 100644 --- a/doc/man/babeltrace2-filter.lttng-utils.debug-info.7.txt +++ b/doc/man/babeltrace2-filter.lttng-utils.debug-info.7.txt @@ -1,6 +1,6 @@ = babeltrace2-filter.lttng-utils.debug-info(7) :manpagetype: component class -:revdate: 14 September 2019 +:revdate: 1 September 2023 :compcls: compcls:filter.lttng-utils.debug-info :defdebuginfoname: `debug_info` @@ -229,10 +229,12 @@ param:debug-info-field-name='NAME' vtype:[optional string]:: of the created events 'NAME' instead of the default {defdebuginfoname}. -param:full-path=`yes` vtype:[optional boolean]:: - Use the full path when writing the executable name (`bin`) and - source file name (`src`) fields in the {defdebuginfoname} context - field of the created events. +param:full-path='VAL' vtype:[optional boolean]:: + If 'VAL' is true, then use the full path when writing the executable + name (`bin`) and source file name (`src`) fields in the + {defdebuginfoname} context field of the created events. ++ +Default: false. param:target-prefix='DIR' vtype:[optional string]:: Use 'DIR' as the root directory of the target file system instead of diff --git a/doc/man/babeltrace2-filter.utils.trimmer.7.txt b/doc/man/babeltrace2-filter.utils.trimmer.7.txt index b1f754e5..707aac6c 100644 --- a/doc/man/babeltrace2-filter.utils.trimmer.7.txt +++ b/doc/man/babeltrace2-filter.utils.trimmer.7.txt @@ -1,6 +1,6 @@ = babeltrace2-filter.utils.trimmer(7) :manpagetype: component class -:revdate: 14 September 2019 +:revdate: 1 September 2023 == NAME @@ -74,9 +74,11 @@ treats it as such. If you don't specify this parameter, the component discards no events from the beginning of the trimming time range. -param:gmt=`yes` vtype:[optional boolean]:: - Set the time zone of the param:begin and param:end parameters - to GMT instead of the local time zone. +param:gmt='VAL' vtype:[optional boolean]:: + If 'VAL' is true, then set the time zone of the param:begin and + param:end parameters to GMT instead of the local time zone. ++ +Default: false. == PORTS diff --git a/doc/man/babeltrace2-query.1.txt b/doc/man/babeltrace2-query.1.txt index c9e13456..22dd1f5f 100644 --- a/doc/man/babeltrace2-query.1.txt +++ b/doc/man/babeltrace2-query.1.txt @@ -85,7 +85,7 @@ $ babeltrace2 query src.ctf.lttng-live sessions \ [role="term"] ---- $ babeltrace2 query src.ctf.fs metadata-info \ - --params='path="/path/to/trace"' + --params='inputs=["/path/to/trace"]' ---- ==== @@ -94,7 +94,7 @@ $ babeltrace2 query src.ctf.fs metadata-info \ [role="term"] ---- $ babeltrace2 query src.ctf.fs babeltrace.trace-infos \ - --params='path="/path/to/trace"' + --params='inputs=["/path/to/trace"]' ---- ==== diff --git a/doc/man/babeltrace2-sink.ctf.fs.7.txt b/doc/man/babeltrace2-sink.ctf.fs.7.txt index df913414..73660277 100644 --- a/doc/man/babeltrace2-sink.ctf.fs.7.txt +++ b/doc/man/babeltrace2-sink.ctf.fs.7.txt @@ -1,6 +1,6 @@ = babeltrace2-sink.ctf.fs(7) :manpagetype: component class -:revdate: 14 September 2019 +:revdate: 1 September 2023 == NAME @@ -194,18 +194,24 @@ until the path does not exist. == INITIALIZATION PARAMETERS -param:assume-single-trace=`yes` vtype:[optional boolean]:: - Assume that the component only receives messages related to a single - input trace. +param:assume-single-trace='VAL' vtype:[optional boolean]:: + If 'VAL' is true, then assume that the component only receives + messages related to a single input trace. + This parameter affects how the component builds the output trace path (see <>). ++ +Default: false. -param:ignore-discarded-events=`yes` vtype:[optional boolean]:: - Ignore discarded events messages. +param:ignore-discarded-events='VAL' vtype:[optional boolean]:: + If 'VAL' is true, then ignore discarded events messages. ++ +Default: false. -param:ignore-discarded-packets=`yes` vtype:[optional boolean]:: - Ignore discarded packets messages. +param:ignore-discarded-packets='VAL' vtype:[optional boolean]:: + If 'VAL' is true, then ignore discarded packets messages. ++ +Default: false. param:path='PATH' vtype:[string]:: Base output path. @@ -213,8 +219,10 @@ param:path='PATH' vtype:[string]:: See <> to learn how the component uses this parameter to build the output path for a given input trace. -param:quiet=`yes` vtype:[optional boolean]:: - Do not write anything to the standard output. +param:quiet='VAL' vtype:[optional boolean]:: + If 'VAL' is true, then do not write anything to the standard output. ++ +Default: false. == PORTS diff --git a/doc/man/babeltrace2-sink.text.details.7.txt b/doc/man/babeltrace2-sink.text.details.7.txt index dc879219..8a23dd4e 100644 --- a/doc/man/babeltrace2-sink.text.details.7.txt +++ b/doc/man/babeltrace2-sink.text.details.7.txt @@ -1,6 +1,6 @@ = babeltrace2-sink.text.details(7) :manpagetype: component class -:revdate: 14 September 2019 +:revdate: 1 September 2023 == NAME @@ -113,8 +113,8 @@ param:color=(`never` | `auto` | `always`) vtype:[optional string]:: The `BABELTRACE_TERM_COLOR` environment variable overrides this parameter. -param:compact=`yes` vtype:[optional boolean]:: - Enable compact mode. +param:compact='VAL' vtype:[optional boolean]:: + If 'VAL' is true, then enable compact mode. + In compact mode, the component prints one line per message, omitting many details about messages. This is useful if you only need the time, @@ -122,24 +122,38 @@ type, and very basic information of messages. + In compact mode, the component still prints the full metadata blocks. You can remove such blocks with the param:with-metadata parameter. ++ +Default: false. -param:with-metadata=`no` vtype:[optional boolean]:: - Do not print metadata blocks. +param:with-metadata='VAL' vtype:[optional boolean]:: + If 'VAL' is false, then do not print metadata blocks. ++ +Default: true. -param:with-stream-class-name=`no` vtype:[optional boolean]:: - Do not print stream class names. +param:with-stream-class-name='VAL' vtype:[optional boolean]:: + If 'VAL' is false, then do not print stream class names. ++ +Default: true. -param:with-stream-name=`no` vtype:[optional boolean]:: - Do not print stream names. +param:with-stream-name='VAL' vtype:[optional boolean]:: + If 'VAL' is false, then do not print stream names. ++ +Default: true. -param:with-time=`no` vtype:[optional boolean]:: - Do not print timing information. +param:with-time='VAL' vtype:[optional boolean]:: + If 'VAL' is false, then do not print timing information. ++ +Default: true. -param:with-trace-name=`no` vtype:[optional boolean]:: - Do not print trace names. +param:with-trace-name='VAL' vtype:[optional boolean]:: + If 'VAL' is false, then do not print trace names. ++ +Default: true. -param:with-uuid=`no` vtype:[optional boolean]:: - Do not print UUIDs. +param:with-uuid='VAL' vtype:[optional boolean]:: + If 'VAL' is false, then do not print UUIDs. ++ +Default: true. == PORTS diff --git a/doc/man/babeltrace2-sink.text.pretty.7.txt b/doc/man/babeltrace2-sink.text.pretty.7.txt index 6d0cd292..49687911 100644 --- a/doc/man/babeltrace2-sink.text.pretty.7.txt +++ b/doc/man/babeltrace2-sink.text.pretty.7.txt @@ -1,6 +1,6 @@ = babeltrace2-sink.text.pretty(7) :manpagetype: component class -:revdate: 14 September 2019 +:revdate: 1 September 2023 == NAME @@ -43,20 +43,28 @@ man:babeltrace(1) (Babeltrace~1 command-line tool). == INITIALIZATION PARAMETERS -param:clock-cycles=`yes` vtype:[optional boolean]:: - Print event times in clock cycles instead of hours, minutes, - seconds, and nanoseconds. +param:clock-cycles='VAL' vtype:[optional boolean]:: + If 'VAL' is true, then print event times in clock cycles instead of + hours, minutes, seconds, and nanoseconds. ++ +Default: false. -param:clock-date=`yes` vtype:[optional boolean]:: - Print event times _and_ dates. +param:clock-date='VAL' vtype:[optional boolean]:: + If 'VAL' is true, then print event times _and_ dates. ++ +Default: false. -param:clock-gmt=`yes` vtype:[optional boolean]:: - Print event times in the GMT time zone instead of the local time - zone. +param:clock-gmt='VAL' vtype:[optional boolean]:: + If 'VAL' is true, then print event times in the GMT time zone + instead of the local time zone. ++ +Default: false. -param:clock-seconds=`yes` vtype:[optional boolean]:: - Print event times in seconds instead of hours, minutes, - seconds, and nanoseconds. +param:clock-seconds='VAL' vtype:[optional boolean]:: + If 'VAL' is true, then print event times in seconds instead of + hours, minutes, seconds, and nanoseconds. ++ +Default: false. param:color=(`never` | `auto` | `always`) vtype:[optional string]:: Force the terminal color support, one of: @@ -80,52 +88,200 @@ param:field-default=(`show` | `hide`) vtype:[optional string]:: By default, show or hide all the fields. This sets the default value of all the parameters which start with `field-`. -param:field-emf=(`yes` | `no`) vtype:[optional boolean]:: +param:field-emf='VAL' vtype:[optional boolean]:: Show or hide the event's Eclipse Modeling Framework URI field. ++ +Default, depending on the param:field-default parameter: ++ +-- +`show`:: + True + +`hide`:: + False + +Not set:: + False +-- -param:field-loglevel=(`yes` | `no`) vtype:[optional boolean]:: +param:field-loglevel='VAL' vtype:[optional boolean]:: Show or hide the event's logging level field. ++ +Default, depending on the param:field-default parameter: ++ +-- +`show`:: + True -param:field-trace=(`yes` | `no`) vtype:[optional boolean]:: +`hide`:: + False + +Not set:: + False +-- + +param:field-trace='VAL' vtype:[optional boolean]:: Show or hide the trace name field. ++ +Default, depending on the param:field-default parameter: ++ +-- +`show`:: + True -param:field-trace:domain=(`yes` | `no`) vtype:[optional boolean]:: +`hide`:: + False + +Not set:: + False +-- + +param:field-trace:domain='VAL' vtype:[optional boolean]:: Show or hide the tracing domain field. ++ +Default, depending on the param:field-default parameter: ++ +-- +`show`:: + True + +`hide`:: + False + +Not set:: + False +-- -param:field-trace:hostname=(`yes` | `no`) vtype:[optional boolean]:: +param:field-trace:hostname='VAL' vtype:[optional boolean]:: Show or hide the hostname field. ++ +Default, depending on the param:field-default parameter: ++ +-- +`show`:: + True -param:field-trace:procname=(`yes` | `no`) vtype:[optional boolean]:: +`hide`:: + False + +Not set:: + True +-- + +param:field-trace:procname='VAL' vtype:[optional boolean]:: Show or hide the process name field. ++ +Default, depending on the param:field-default parameter: ++ +-- +`show`:: + True -param:field-trace:vpid=(`yes` | `no`) vtype:[optional boolean]:: +`hide`:: + False + +Not set:: + True +-- + +param:field-trace:vpid='VAL' vtype:[optional boolean]:: Show or hide the virtual process ID field. ++ +Default, depending on the param:field-default parameter: ++ +-- +`show`:: + True -param:name-context=(`yes` | `no`) vtype:[optional boolean]:: - Show or hide the field names in the context scopes. +`hide`:: + False + +Not set:: + True +-- param:name-default=(`show` | `hide`) vtype:[optional string]:: By default, show or hide all the names. This sets the default value of all the parameters which start with `name-`. -param:name-header=(`yes` | `no`) vtype:[optional boolean]:: +param:name-header='VAL' vtype:[optional boolean]:: Show or hide the field names in the header scopes. ++ +Default, depending on the param:name-default parameter: ++ +-- +`show`:: + True + +`hide`:: + False + +Not set:: + False +-- -param:name-payload=(`yes` | `no`) vtype:[optional boolean]:: +param:name-context='VAL' vtype:[optional boolean]:: + Show or hide the field names in the context scopes. ++ +Default, depending on the param:name-default parameter: ++ +-- +`show`:: + True + +`hide`:: + False + +Not set:: + True +-- + +param:name-payload='VAL' vtype:[optional boolean]:: Show or hide the field names in the event payload scopes. ++ +Default, depending on the param:name-default parameter: ++ +-- +`show`:: + True + +`hide`:: + False + +Not set:: + True +-- -param:name-scope=(`yes` | `no`) vtype:[optional boolean]:: +param:name-scope='VAL' vtype:[optional boolean]:: Show or hide the scope names. ++ +Default, depending on the param:name-default parameter: ++ +-- +`show`:: + True -param:no-delta=`yes` vtype:[optional boolean]:: - Do not print the time delta between consecutive lines. +`hide`:: + False + +Not set:: + False +-- + +param:no-delta='VAL' vtype:[optional boolean]:: + If 'VAL' is true, then do not print the time delta between + consecutive lines. ++ +Default: false. param:path='PATH' vtype:[optional string]:: Print the text output to the file 'PATH' instead of the standard output. -param:verbose=`yes` vtype:[optional boolean]:: - Turn the verbose mode on. +param:verbose='VAL' vtype:[optional boolean]:: + If 'VAL' if true, then turn the verbose mode on. ++ +Default: false. == PORTS diff --git a/doc/man/babeltrace2-sink.utils.counter.7.txt b/doc/man/babeltrace2-sink.utils.counter.7.txt index 60f051d5..082750a0 100644 --- a/doc/man/babeltrace2-sink.utils.counter.7.txt +++ b/doc/man/babeltrace2-sink.utils.counter.7.txt @@ -1,6 +1,6 @@ = babeltrace2-sink.utils.counter(7) :manpagetype: component class -:revdate: 14 September 2019 +:revdate: 1 September 2023 == NAME @@ -54,8 +54,11 @@ the zero counts with the param:hide-zero parameter. == INITIALIZATION PARAMETERS -param:hide-zero=`yes` vtype:[optional boolean]:: - Do not print the statistics lines where the count is zero. +param:hide-zero='VAL' vtype:[optional boolean]:: + If 'VAL' is true, then do not print the statistics lines where the + count is zero. ++ +Default: false. param:step='STEP' vtype:[optional unsigned integer]:: Print a new block of statistics every 'STEP' consumed messages diff --git a/doc/man/babeltrace2-source.ctf.fs.7.txt b/doc/man/babeltrace2-source.ctf.fs.7.txt index 3156ee54..7aa20b69 100644 --- a/doc/man/babeltrace2-source.ctf.fs.7.txt +++ b/doc/man/babeltrace2-source.ctf.fs.7.txt @@ -1,6 +1,6 @@ = babeltrace2-source.ctf.fs(7) :manpagetype: component class -:revdate: 14 September 2019 +:revdate: 1 September 2023 == NAME @@ -167,9 +167,12 @@ param:clock-class-offset-s='SEC' vtype:[optional signed integer]:: You can combine this parameter with the param:clock-class-offset-ns parameter. -param:force-clock-class-origin-unix-epoch=`yes` vtype:[optional boolean]:: - Force the origin of all clock classes that the component creates to - have a Unix epoch origin, whatever the detected tracer. +param:force-clock-class-origin-unix-epoch='VAL' vtype:[optional boolean]:: + If 'VAL' is true, then force the origin of all clock classes that + the component creates to have a Unix epoch origin, whatever the + detected tracer. ++ +Default: false. param:inputs='DIRS' vtype:[array of strings]:: Open and read the physical CTF traces located in 'DIRS'. diff --git a/doc/man/babeltrace2-source.text.dmesg.7.txt b/doc/man/babeltrace2-source.text.dmesg.7.txt index 9079fe4b..1e75c9d2 100644 --- a/doc/man/babeltrace2-source.text.dmesg.7.txt +++ b/doc/man/babeltrace2-source.text.dmesg.7.txt @@ -1,6 +1,6 @@ = babeltrace2-source.text.dmesg(7) :manpagetype: component class -:revdate: 14 September 2019 +:revdate: 1 September 2023 == NAME @@ -69,10 +69,12 @@ requires that the input kernel ring buffer lines be sorted by timestamp == INITIALIZATION PARAMETERS -param:no-extract-timestamp=`yes` vtype:[optional boolean]:: - Do :not: extract timestamps from the kernel ring buffer lines: set - the created event's payload's `str` field to the whole line, - including any timestamp prefix. +param:no-extract-timestamp='VAL' vtype:[optional boolean]:: + If 'VAL' is true, then do :not: extract timestamps from the kernel + ring buffer lines: set the created event's payload's `str` field to + the whole line, including any timestamp prefix. ++ +Default: false. param:path='PATH' vtype:[optional string]:: Read the kernel ring buffer lines from the file 'PATH' instead of diff --git a/include/babeltrace2/babeltrace.h b/include/babeltrace2/babeltrace.h index 82c402ad..82f62514 100644 --- a/include/babeltrace2/babeltrace.h +++ b/include/babeltrace2/babeltrace.h @@ -45,6 +45,13 @@ #define __BT_ATTR_FORMAT_PRINTF(_string_index, _first_to_check) \ __attribute__((format(__BT_PRINTF_FORMAT, _string_index, _first_to_check))) +/* Internal: `noexcept` specifier if C++ ≥ 11 */ +#if defined(__cplusplus) && (__cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900)) +# define __BT_NOEXCEPT noexcept +#else +# define __BT_NOEXCEPT +#endif + #include #include #include @@ -104,5 +111,6 @@ #undef __BT_LOGGING_LEVEL_ERROR #undef __BT_LOGGING_LEVEL_FATAL #undef __BT_LOGGING_LEVEL_NONE +#undef __BT_NOEXCEPT #endif /* BABELTRACE2_BABELTRACE_H */ diff --git a/include/babeltrace2/error-reporting.h b/include/babeltrace2/error-reporting.h index 43922e23..29e53e16 100644 --- a/include/babeltrace2/error-reporting.h +++ b/include/babeltrace2/error-reporting.h @@ -4,6 +4,8 @@ * Copyright (C) 2010-2019 EfficiOS Inc. and Linux Foundation */ +/* IWYU pragma: private, include */ + #ifndef BABELTRACE2_ERROR_REPORTING_H #define BABELTRACE2_ERROR_REPORTING_H @@ -431,7 +433,7 @@ Once you are done with the returned error, do one of: Moves an error's ownership to the library. */ extern -const bt_error *bt_current_thread_take_error(void); +const bt_error *bt_current_thread_take_error(void) __BT_NOEXCEPT; /*! @brief @@ -464,7 +466,7 @@ corresponds to catching an exception and discarding it. Calls this function and assigns \c NULL to the expression. */ extern -void bt_current_thread_move_error(const bt_error *error); +void bt_current_thread_move_error(const bt_error *error) __BT_NOEXCEPT; /*! @brief @@ -511,7 +513,7 @@ bt_error_release(bt_current_thread_take_error()); library to the caller. */ extern -void bt_current_thread_clear_error(void); +void bt_current_thread_clear_error(void) __BT_NOEXCEPT; /*! @} */ @@ -616,7 +618,8 @@ extern __BT_ATTR_FORMAT_PRINTF(4, 5) bt_current_thread_error_append_cause_status bt_current_thread_error_append_cause_from_component( bt_self_component *self_component, const char *file_name, - uint64_t line_number, const char *message_format, ...); + uint64_t line_number, + const char *message_format, ...) __BT_NOEXCEPT; /*! @brief @@ -716,7 +719,7 @@ bt_current_thread_error_append_cause_status bt_current_thread_error_append_cause_from_message_iterator( bt_self_message_iterator *self_message_iterator, const char *file_name, uint64_t line_number, - const char *message_format, ...); + const char *message_format, ...) __BT_NOEXCEPT; /*! @brief @@ -808,7 +811,7 @@ bt_current_thread_error_append_cause_status bt_current_thread_error_append_cause_from_component_class( bt_self_component_class *self_component_class, const char *file_name, uint64_t line_number, - const char *message_format, ...); + const char *message_format, ...) __BT_NOEXCEPT; /*! @brief @@ -871,7 +874,8 @@ extern __BT_ATTR_FORMAT_PRINTF(4, 5) bt_current_thread_error_append_cause_status bt_current_thread_error_append_cause_from_unknown( const char *module_name, const char *file_name, - uint64_t line_number, const char *message_format, ...); + uint64_t line_number, + const char *message_format, ...) __BT_NOEXCEPT; /*! @brief @@ -913,7 +917,7 @@ with \c __FILE__ and \c __LINE__ as its @bt_pre_not_null{error} */ extern -uint64_t bt_error_get_cause_count(const bt_error *error); +uint64_t bt_error_get_cause_count(const bt_error *error) __BT_NOEXCEPT; /*! @brief @@ -940,7 +944,7 @@ uint64_t bt_error_get_cause_count(const bt_error *error); */ extern const bt_error_cause *bt_error_borrow_cause_by_index( - const bt_error *error, uint64_t index); + const bt_error *error, uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -971,7 +975,7 @@ corresponds to catching an exception and rethrowing it. Moves an error's ownership to the library. */ extern -void bt_error_release(const bt_error *error); +void bt_error_release(const bt_error *error) __BT_NOEXCEPT; /*! @} */ @@ -1025,7 +1029,7 @@ typedef enum bt_error_cause_actor_type { */ extern bt_error_cause_actor_type bt_error_cause_get_actor_type( - const bt_error_cause *error_cause); + const bt_error_cause *error_cause) __BT_NOEXCEPT; /*! @brief @@ -1045,7 +1049,8 @@ bt_error_cause_actor_type bt_error_cause_get_actor_type( @bt_pre_not_null{error_cause} */ extern -const char *bt_error_cause_get_message(const bt_error_cause *error_cause); +const char *bt_error_cause_get_message( + const bt_error_cause *error_cause) __BT_NOEXCEPT; /*! @brief @@ -1065,7 +1070,8 @@ const char *bt_error_cause_get_message(const bt_error_cause *error_cause); @bt_pre_not_null{error_cause} */ extern -const char *bt_error_cause_get_module_name(const bt_error_cause *error_cause); +const char *bt_error_cause_get_module_name( + const bt_error_cause *error_cause) __BT_NOEXCEPT; /*! @brief @@ -1087,7 +1093,8 @@ const char *bt_error_cause_get_module_name(const bt_error_cause *error_cause); @bt_pre_not_null{error_cause} */ extern -const char *bt_error_cause_get_file_name(const bt_error_cause *error_cause); +const char *bt_error_cause_get_file_name( + const bt_error_cause *error_cause) __BT_NOEXCEPT; /*! @brief @@ -1104,7 +1111,8 @@ const char *bt_error_cause_get_file_name(const bt_error_cause *error_cause); @bt_pre_not_null{error_cause} */ extern -uint64_t bt_error_cause_get_line_number(const bt_error_cause *error_cause); +uint64_t bt_error_cause_get_line_number( + const bt_error_cause *error_cause) __BT_NOEXCEPT; /*! @} */ @@ -1137,7 +1145,7 @@ uint64_t bt_error_cause_get_line_number(const bt_error_cause *error_cause); */ extern const char *bt_error_cause_component_actor_get_component_name( - const bt_error_cause *error_cause); + const bt_error_cause *error_cause) __BT_NOEXCEPT; /*! @brief @@ -1158,7 +1166,7 @@ const char *bt_error_cause_component_actor_get_component_name( */ extern bt_component_class_type bt_error_cause_component_actor_get_component_class_type( - const bt_error_cause *error_cause); + const bt_error_cause *error_cause) __BT_NOEXCEPT; /*! @brief @@ -1184,7 +1192,7 @@ bt_component_class_type bt_error_cause_component_actor_get_component_class_type( */ extern const char *bt_error_cause_component_actor_get_component_class_name( - const bt_error_cause *error_cause); + const bt_error_cause *error_cause) __BT_NOEXCEPT; /*! @brief @@ -1215,7 +1223,7 @@ component class. */ extern const char *bt_error_cause_component_actor_get_plugin_name( - const bt_error_cause *error_cause); + const bt_error_cause *error_cause) __BT_NOEXCEPT; /*! @} */ @@ -1249,7 +1257,7 @@ const char *bt_error_cause_component_actor_get_plugin_name( */ extern const char *bt_error_cause_message_iterator_actor_get_component_output_port_name( - const bt_error_cause *error_cause); + const bt_error_cause *error_cause) __BT_NOEXCEPT; /*! @brief @@ -1275,7 +1283,7 @@ const char *bt_error_cause_message_iterator_actor_get_component_output_port_name */ extern const char *bt_error_cause_message_iterator_actor_get_component_name( - const bt_error_cause *error_cause); + const bt_error_cause *error_cause) __BT_NOEXCEPT; /*! @brief @@ -1297,7 +1305,7 @@ const char *bt_error_cause_message_iterator_actor_get_component_name( extern bt_component_class_type bt_error_cause_message_iterator_actor_get_component_class_type( - const bt_error_cause *error_cause); + const bt_error_cause *error_cause) __BT_NOEXCEPT; /*! @brief @@ -1323,7 +1331,7 @@ bt_error_cause_message_iterator_actor_get_component_class_type( */ extern const char *bt_error_cause_message_iterator_actor_get_component_class_name( - const bt_error_cause *error_cause); + const bt_error_cause *error_cause) __BT_NOEXCEPT; /*! @brief @@ -1355,7 +1363,7 @@ component class. */ extern const char *bt_error_cause_message_iterator_actor_get_plugin_name( - const bt_error_cause *error_cause); + const bt_error_cause *error_cause) __BT_NOEXCEPT; /*! @} */ @@ -1384,7 +1392,7 @@ const char *bt_error_cause_message_iterator_actor_get_plugin_name( extern bt_component_class_type bt_error_cause_component_class_actor_get_component_class_type( - const bt_error_cause *error_cause); + const bt_error_cause *error_cause) __BT_NOEXCEPT; /*! @brief @@ -1410,7 +1418,7 @@ bt_error_cause_component_class_actor_get_component_class_type( */ extern const char *bt_error_cause_component_class_actor_get_component_class_name( - const bt_error_cause *error_cause); + const bt_error_cause *error_cause) __BT_NOEXCEPT; /*! @brief @@ -1441,7 +1449,7 @@ component class. */ extern const char *bt_error_cause_component_class_actor_get_plugin_name( - const bt_error_cause *error_cause); + const bt_error_cause *error_cause) __BT_NOEXCEPT; /*! @} */ diff --git a/include/babeltrace2/func-status.h b/include/babeltrace2/func-status.h index bba3882a..806e4bcb 100644 --- a/include/babeltrace2/func-status.h +++ b/include/babeltrace2/func-status.h @@ -4,6 +4,8 @@ * Copyright (C) 2010-2019 EfficiOS Inc. and Linux Foundation */ +/* IWYU pragma: private, include */ + /* * No include guards here: it is safe to include this file multiple * times. diff --git a/include/babeltrace2/graph/component-class-dev.h b/include/babeltrace2/graph/component-class-dev.h index 20ac581a..7267e62f 100644 --- a/include/babeltrace2/graph/component-class-dev.h +++ b/include/babeltrace2/graph/component-class-dev.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_GRAPH_COMPONENT_CLASS_DEV_H #define BABELTRACE2_GRAPH_COMPONENT_CLASS_DEV_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -31,7 +33,7 @@ A component class is the class of a \bt_comp: @attention This module (component class development API) offers functions to - programatically create component classes. To get the properties of + programmatically create component classes. To get the properties of an existing component class, see \ref api-comp-cls. A component class has methods. This module essentially @@ -1474,7 +1476,8 @@ property values: extern bt_component_class_source *bt_component_class_source_create( const char *name, - bt_message_iterator_class *message_iterator_class); + bt_message_iterator_class *message_iterator_class) + __BT_NOEXCEPT; /*! @brief @@ -1518,7 +1521,8 @@ property values: extern bt_component_class_filter *bt_component_class_filter_create( const char *name, - bt_message_iterator_class *message_iterator_class); + bt_message_iterator_class *message_iterator_class) + __BT_NOEXCEPT; /*! @brief @@ -1558,7 +1562,8 @@ property values: extern bt_component_class_sink *bt_component_class_sink_create( const char *name, - bt_component_class_sink_consume_method consume_method); + bt_component_class_sink_consume_method consume_method) + __BT_NOEXCEPT; /*! @} */ @@ -1612,7 +1617,7 @@ See the \ref api-comp-cls-prop-descr "description" property. */ extern bt_component_class_set_description_status bt_component_class_set_description(bt_component_class *component_class, - const char *description); + const char *description) __BT_NOEXCEPT; /*! @brief @@ -1659,7 +1664,7 @@ See the \ref api-comp-cls-prop-help "help text" property. */ extern bt_component_class_set_help_status bt_component_class_set_help( bt_component_class *component_class, - const char *help_text); + const char *help_text) __BT_NOEXCEPT; /*! @} */ @@ -1704,7 +1709,7 @@ See the \ref api-comp-cls-dev-meth-fini "finalize" method. extern bt_component_class_set_method_status bt_component_class_source_set_finalize_method( bt_component_class_source *component_class, - bt_component_class_source_finalize_method method); + bt_component_class_source_finalize_method method) __BT_NOEXCEPT; /*! @brief @@ -1729,7 +1734,7 @@ See the \ref api-comp-cls-dev-meth-fini "finalize" method. extern bt_component_class_set_method_status bt_component_class_filter_set_finalize_method( bt_component_class_filter *component_class, - bt_component_class_filter_finalize_method method); + bt_component_class_filter_finalize_method method) __BT_NOEXCEPT; /*! @brief @@ -1755,7 +1760,7 @@ extern bt_component_class_set_method_status bt_component_class_sink_set_finalize_method( bt_component_class_sink *component_class, - bt_component_class_sink_finalize_method method); + bt_component_class_sink_finalize_method method) __BT_NOEXCEPT; /*! @brief @@ -1781,7 +1786,8 @@ method. extern bt_component_class_set_method_status bt_component_class_source_set_get_supported_mip_versions_method( bt_component_class_source *component_class, - bt_component_class_source_get_supported_mip_versions_method method); + bt_component_class_source_get_supported_mip_versions_method method) + __BT_NOEXCEPT; /*! @brief @@ -1807,7 +1813,8 @@ method. extern bt_component_class_set_method_status bt_component_class_filter_set_get_supported_mip_versions_method( bt_component_class_filter *component_class, - bt_component_class_filter_get_supported_mip_versions_method method); + bt_component_class_filter_get_supported_mip_versions_method method) + __BT_NOEXCEPT; /*! @brief @@ -1833,7 +1840,8 @@ method. extern bt_component_class_set_method_status bt_component_class_sink_set_get_supported_mip_versions_method( bt_component_class_sink *component_class, - bt_component_class_sink_get_supported_mip_versions_method method); + bt_component_class_sink_get_supported_mip_versions_method method) + __BT_NOEXCEPT; /*! @brief @@ -1861,7 +1869,8 @@ extern bt_component_class_set_method_status bt_component_class_sink_set_graph_is_configured_method( bt_component_class_sink *component_class, - bt_component_class_sink_graph_is_configured_method method); + bt_component_class_sink_graph_is_configured_method method) + __BT_NOEXCEPT; /*! @brief @@ -1886,7 +1895,8 @@ See the \ref api-comp-cls-dev-meth-init "initialize" method. extern bt_component_class_set_method_status bt_component_class_source_set_initialize_method( bt_component_class_source *component_class, - bt_component_class_source_initialize_method method); + bt_component_class_source_initialize_method method) + __BT_NOEXCEPT; /*! @brief @@ -1911,7 +1921,8 @@ See the \ref api-comp-cls-dev-meth-init "initialize" method. extern bt_component_class_set_method_status bt_component_class_filter_set_initialize_method( bt_component_class_filter *component_class, - bt_component_class_filter_initialize_method method); + bt_component_class_filter_initialize_method method) + __BT_NOEXCEPT; /*! @brief @@ -1937,7 +1948,7 @@ extern bt_component_class_set_method_status bt_component_class_sink_set_initialize_method( bt_component_class_sink *component_class, - bt_component_class_sink_initialize_method method); + bt_component_class_sink_initialize_method method) __BT_NOEXCEPT; /*! @brief @@ -1964,7 +1975,8 @@ method. extern bt_component_class_set_method_status bt_component_class_source_set_output_port_connected_method( bt_component_class_source *component_class, - bt_component_class_source_output_port_connected_method method); + bt_component_class_source_output_port_connected_method method) + __BT_NOEXCEPT; /*! @brief @@ -1991,7 +2003,8 @@ method. extern bt_component_class_set_method_status bt_component_class_filter_set_input_port_connected_method( bt_component_class_filter *component_class, - bt_component_class_filter_input_port_connected_method method); + bt_component_class_filter_input_port_connected_method method) + __BT_NOEXCEPT; /*! @brief @@ -2018,7 +2031,8 @@ method. extern bt_component_class_set_method_status bt_component_class_filter_set_output_port_connected_method( bt_component_class_filter *component_class, - bt_component_class_filter_output_port_connected_method method); + bt_component_class_filter_output_port_connected_method method) + __BT_NOEXCEPT; /*! @brief @@ -2046,7 +2060,8 @@ extern bt_component_class_set_method_status bt_component_class_sink_set_input_port_connected_method( bt_component_class_sink *component_class, - bt_component_class_sink_input_port_connected_method method); + bt_component_class_sink_input_port_connected_method method) + __BT_NOEXCEPT; /*! @brief @@ -2071,7 +2086,7 @@ See the \ref api-comp-cls-dev-meth-query "query" method. extern bt_component_class_set_method_status bt_component_class_source_set_query_method( bt_component_class_source *component_class, - bt_component_class_source_query_method method); + bt_component_class_source_query_method method) __BT_NOEXCEPT; /*! @brief @@ -2096,7 +2111,7 @@ See the \ref api-comp-cls-dev-meth-query "query" method. extern bt_component_class_set_method_status bt_component_class_filter_set_query_method( bt_component_class_filter *component_class, - bt_component_class_filter_query_method method); + bt_component_class_filter_query_method method) __BT_NOEXCEPT; /*! @brief @@ -2122,7 +2137,7 @@ extern bt_component_class_set_method_status bt_component_class_sink_set_query_method( bt_component_class_sink *component_class, - bt_component_class_sink_query_method method); + bt_component_class_sink_query_method method) __BT_NOEXCEPT; /*! @} */ @@ -2148,7 +2163,7 @@ bt_component_class_sink_set_query_method( */ static inline bt_component_class *bt_component_class_source_as_component_class( - bt_component_class_source *component_class) + bt_component_class_source *component_class) __BT_NOEXCEPT { return __BT_UPCAST(bt_component_class, component_class); } @@ -2170,7 +2185,7 @@ bt_component_class *bt_component_class_source_as_component_class( */ static inline bt_component_class *bt_component_class_filter_as_component_class( - bt_component_class_filter *component_class) + bt_component_class_filter *component_class) __BT_NOEXCEPT { return __BT_UPCAST(bt_component_class, component_class); } @@ -2192,7 +2207,7 @@ bt_component_class *bt_component_class_filter_as_component_class( */ static inline bt_component_class *bt_component_class_sink_as_component_class( - bt_component_class_sink *component_class) + bt_component_class_sink *component_class) __BT_NOEXCEPT { return __BT_UPCAST(bt_component_class, component_class); } diff --git a/include/babeltrace2/graph/component-class.h b/include/babeltrace2/graph/component-class.h index 66036c22..4fe692f2 100644 --- a/include/babeltrace2/graph/component-class.h +++ b/include/babeltrace2/graph/component-class.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_GRAPH_COMPONENT_CLASS_H #define BABELTRACE2_GRAPH_COMPONENT_CLASS_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -39,7 +41,7 @@ initialization parameters, to create many components with the There are two ways to obtain a component class: -- Create one programatically: see \ref api-comp-cls-dev. +- Create one programmatically: see \ref api-comp-cls-dev. - Borrow one from a \bt_plugin. @@ -236,7 +238,7 @@ typedef enum bt_component_class_type { Returns whether or not a component class is a \bt_sink_comp_cls. */ extern bt_component_class_type bt_component_class_get_type( - const bt_component_class *component_class); + const bt_component_class *component_class) __BT_NOEXCEPT; /*! @brief @@ -256,7 +258,7 @@ extern bt_component_class_type bt_component_class_get_type( */ static inline bt_bool bt_component_class_is_source( - const bt_component_class *component_class) + const bt_component_class *component_class) __BT_NOEXCEPT { return bt_component_class_get_type(component_class) == BT_COMPONENT_CLASS_TYPE_SOURCE; @@ -280,7 +282,7 @@ bt_bool bt_component_class_is_source( */ static inline bt_bool bt_component_class_is_filter( - const bt_component_class *component_class) + const bt_component_class *component_class) __BT_NOEXCEPT { return bt_component_class_get_type(component_class) == BT_COMPONENT_CLASS_TYPE_FILTER; @@ -304,7 +306,7 @@ bt_bool bt_component_class_is_filter( */ static inline bt_bool bt_component_class_is_sink( - const bt_component_class *component_class) + const bt_component_class *component_class) __BT_NOEXCEPT { return bt_component_class_get_type(component_class) == BT_COMPONENT_CLASS_TYPE_SINK; @@ -337,7 +339,7 @@ See the \ref api-comp-cls-prop-name "name" property. @bt_pre_not_null{component_class} */ extern const char *bt_component_class_get_name( - const bt_component_class *component_class); + const bt_component_class *component_class) __BT_NOEXCEPT; /*! @brief @@ -360,7 +362,7 @@ See the \ref api-comp-cls-prop-descr "description" property. @bt_pre_not_null{component_class} */ extern const char *bt_component_class_get_description( - const bt_component_class *component_class); + const bt_component_class *component_class) __BT_NOEXCEPT; /*! @brief @@ -382,7 +384,7 @@ See the \ref api-comp-cls-prop-help "help text" property. @bt_pre_not_null{component_class} */ extern const char *bt_component_class_get_help( - const bt_component_class *component_class); + const bt_component_class *component_class) __BT_NOEXCEPT; /*! @} */ @@ -407,7 +409,7 @@ extern const char *bt_component_class_get_help( Decrements the reference count of a component class. */ extern void bt_component_class_get_ref( - const bt_component_class *component_class); + const bt_component_class *component_class) __BT_NOEXCEPT; /*! @brief @@ -425,7 +427,7 @@ extern void bt_component_class_get_ref( Increments the reference count of a component class. */ extern void bt_component_class_put_ref( - const bt_component_class *component_class); + const bt_component_class *component_class) __BT_NOEXCEPT; /*! @brief @@ -507,7 +509,7 @@ expression static inline const bt_component_class * bt_component_class_source_as_component_class_const( - const bt_component_class_source *component_class) + const bt_component_class_source *component_class) __BT_NOEXCEPT { return __BT_UPCAST_CONST(bt_component_class, component_class); } @@ -535,7 +537,7 @@ bt_component_class_source_as_component_class_const( Decrements the reference count of a source component class. */ extern void bt_component_class_source_get_ref( - const bt_component_class_source *component_class); + const bt_component_class_source *component_class) __BT_NOEXCEPT; /*! @brief @@ -553,7 +555,7 @@ extern void bt_component_class_source_get_ref( Increments the reference count of a source component class. */ extern void bt_component_class_source_put_ref( - const bt_component_class_source *component_class); + const bt_component_class_source *component_class) __BT_NOEXCEPT; /*! @brief @@ -634,7 +636,7 @@ existing \bt_p{_dst} reference. static inline const bt_component_class * bt_component_class_filter_as_component_class_const( - const bt_component_class_filter *component_class) + const bt_component_class_filter *component_class) __BT_NOEXCEPT { return __BT_UPCAST_CONST(bt_component_class, component_class); } @@ -662,7 +664,7 @@ bt_component_class_filter_as_component_class_const( Decrements the reference count of a filter component class. */ extern void bt_component_class_filter_get_ref( - const bt_component_class_filter *component_class); + const bt_component_class_filter *component_class) __BT_NOEXCEPT; /*! @brief @@ -680,7 +682,7 @@ extern void bt_component_class_filter_get_ref( Increments the reference count of a filter component class. */ extern void bt_component_class_filter_put_ref( - const bt_component_class_filter *component_class); + const bt_component_class_filter *component_class) __BT_NOEXCEPT; /*! @brief @@ -761,7 +763,7 @@ existing \bt_p{_dst} reference. static inline const bt_component_class * bt_component_class_sink_as_component_class_const( - const bt_component_class_sink *component_class) + const bt_component_class_sink *component_class) __BT_NOEXCEPT { return __BT_UPCAST_CONST(bt_component_class, component_class); } @@ -789,7 +791,7 @@ bt_component_class_sink_as_component_class_const( Decrements the reference count of a sink component class. */ extern void bt_component_class_sink_get_ref( - const bt_component_class_sink *component_class); + const bt_component_class_sink *component_class) __BT_NOEXCEPT; /*! @brief @@ -807,7 +809,7 @@ extern void bt_component_class_sink_get_ref( Increments the reference count of a sink component class. */ extern void bt_component_class_sink_put_ref( - const bt_component_class_sink *component_class); + const bt_component_class_sink *component_class) __BT_NOEXCEPT; /*! @brief diff --git a/include/babeltrace2/graph/component-descriptor-set.h b/include/babeltrace2/graph/component-descriptor-set.h index 41e132bf..918bff40 100644 --- a/include/babeltrace2/graph/component-descriptor-set.h +++ b/include/babeltrace2/graph/component-descriptor-set.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_GRAPH_COMPONENT_DESCRIPTOR_SET_H #define BABELTRACE2_GRAPH_COMPONENT_DESCRIPTOR_SET_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -93,7 +95,8 @@ bt_component_descriptor_set_add_descriptor_with_initialize_method_data(). @returns New component descriptor set reference, or \c NULL on memory error. */ -extern bt_component_descriptor_set *bt_component_descriptor_set_create(void); +extern bt_component_descriptor_set *bt_component_descriptor_set_create(void) + __BT_NOEXCEPT; /*! @brief @@ -132,7 +135,7 @@ extern bt_component_descriptor_set_add_descriptor_status bt_component_descriptor_set_add_descriptor( bt_component_descriptor_set *component_descriptor_set, const bt_component_class *component_class, - const bt_value *params); + const bt_value *params) __BT_NOEXCEPT; /*! @brief @@ -178,7 +181,8 @@ extern bt_component_descriptor_set_add_descriptor_status bt_component_descriptor_set_add_descriptor_with_initialize_method_data( bt_component_descriptor_set *component_descriptor_set, const bt_component_class *component_class, - const bt_value *params, void *initialize_method_data); + const bt_value *params, + void *initialize_method_data) __BT_NOEXCEPT; /*! @} */ @@ -203,7 +207,8 @@ bt_component_descriptor_set_add_descriptor_with_initialize_method_data( Decrements the reference count of a component descriptor set. */ extern void bt_component_descriptor_set_get_ref( - const bt_component_descriptor_set *component_descriptor_set); + const bt_component_descriptor_set *component_descriptor_set) + __BT_NOEXCEPT; /*! @brief @@ -221,7 +226,8 @@ extern void bt_component_descriptor_set_get_ref( Increments the reference count of a component descriptor set. */ extern void bt_component_descriptor_set_put_ref( - const bt_component_descriptor_set *component_descriptor_set); + const bt_component_descriptor_set *component_descriptor_set) + __BT_NOEXCEPT; /*! @brief diff --git a/include/babeltrace2/graph/component.h b/include/babeltrace2/graph/component.h index 7999d524..1b192590 100644 --- a/include/babeltrace2/graph/component.h +++ b/include/babeltrace2/graph/component.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_GRAPH_COMPONENT_H #define BABELTRACE2_GRAPH_COMPONENT_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -238,7 +240,7 @@ A component has the following common properties: Returns whether or not a component is a \bt_sink_comp. */ extern bt_component_class_type bt_component_get_class_type( - const bt_component *component); + const bt_component *component) __BT_NOEXCEPT; /*! @brief @@ -257,7 +259,7 @@ extern bt_component_class_type bt_component_get_class_type( Returns the type enumerator of a component's class. */ static inline -bt_bool bt_component_is_source(const bt_component *component) +bt_bool bt_component_is_source(const bt_component *component) __BT_NOEXCEPT { return bt_component_get_class_type(component) == BT_COMPONENT_CLASS_TYPE_SOURCE; @@ -280,7 +282,7 @@ bt_bool bt_component_is_source(const bt_component *component) Returns the type enumerator of a component's class. */ static inline -bt_bool bt_component_is_filter(const bt_component *component) +bt_bool bt_component_is_filter(const bt_component *component) __BT_NOEXCEPT { return bt_component_get_class_type(component) == BT_COMPONENT_CLASS_TYPE_FILTER; @@ -303,7 +305,7 @@ bt_bool bt_component_is_filter(const bt_component *component) Returns the type enumerator of a component's class. */ static inline -bt_bool bt_component_is_sink(const bt_component *component) +bt_bool bt_component_is_sink(const bt_component *component) __BT_NOEXCEPT { return bt_component_get_class_type(component) == BT_COMPONENT_CLASS_TYPE_SINK; @@ -330,7 +332,7 @@ bt_bool bt_component_is_sink(const bt_component *component) @bt_pre_not_null{component} */ extern const bt_component_class *bt_component_borrow_class_const( - const bt_component *component); + const bt_component *component) __BT_NOEXCEPT; /*! @} */ @@ -358,7 +360,8 @@ See the \ref api-comp-prop-name "name" property. @bt_pre_not_null{component} */ -extern const char *bt_component_get_name(const bt_component *component); +extern const char *bt_component_get_name(const bt_component *component) + __BT_NOEXCEPT; /*! @brief @@ -376,7 +379,7 @@ See the \ref api-comp-prop-log-lvl "logging level" property. @bt_pre_not_null{component} */ extern bt_logging_level bt_component_get_logging_level( - const bt_component *component); + const bt_component *component) __BT_NOEXCEPT; /*! @} */ @@ -400,7 +403,7 @@ extern bt_logging_level bt_component_get_logging_level( @sa bt_component_put_ref() — Decrements the reference count of a component. */ -extern void bt_component_get_ref(const bt_component *component); +extern void bt_component_get_ref(const bt_component *component) __BT_NOEXCEPT; /*! @brief @@ -417,7 +420,7 @@ extern void bt_component_get_ref(const bt_component *component); @sa bt_component_get_ref() — Increments the reference count of a component. */ -extern void bt_component_put_ref(const bt_component *component); +extern void bt_component_put_ref(const bt_component *component) __BT_NOEXCEPT; /*! @brief @@ -493,7 +496,7 @@ This macro effectively moves a component reference from the expression */ extern const bt_component_class_source * bt_component_source_borrow_class_const( - const bt_component_source *component); + const bt_component_source *component) __BT_NOEXCEPT; /*! @} */ @@ -519,7 +522,7 @@ bt_component_source_borrow_class_const( */ static inline const bt_component *bt_component_source_as_component_const( - const bt_component_source *component) + const bt_component_source *component) __BT_NOEXCEPT { return __BT_UPCAST_CONST(bt_component, component); } @@ -545,7 +548,7 @@ const bt_component *bt_component_source_as_component_const( @bt_pre_not_null{component} */ extern uint64_t bt_component_source_get_output_port_count( - const bt_component_source *component); + const bt_component_source *component) __BT_NOEXCEPT; /*! @brief @@ -578,7 +581,8 @@ extern uint64_t bt_component_source_get_output_port_count( */ extern const bt_port_output * bt_component_source_borrow_output_port_by_index_const( - const bt_component_source *component, uint64_t index); + const bt_component_source *component, + uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -608,7 +612,8 @@ returns \c NULL. */ extern const bt_port_output * bt_component_source_borrow_output_port_by_name_const( - const bt_component_source *component, const char *name); + const bt_component_source *component, + const char *name) __BT_NOEXCEPT; /*! @} */ @@ -633,7 +638,7 @@ bt_component_source_borrow_output_port_by_name_const( Decrements the reference count of a source component. */ extern void bt_component_source_get_ref( - const bt_component_source *component); + const bt_component_source *component) __BT_NOEXCEPT; /*! @brief @@ -651,7 +656,7 @@ extern void bt_component_source_get_ref( Increments the reference count of a source component. */ extern void bt_component_source_put_ref( - const bt_component_source *component); + const bt_component_source *component) __BT_NOEXCEPT; /*! @brief @@ -727,7 +732,7 @@ existing \bt_p{_dst} reference. */ extern const bt_component_class_filter * bt_component_filter_borrow_class_const( - const bt_component_filter *component); + const bt_component_filter *component) __BT_NOEXCEPT; /*! @} */ @@ -753,7 +758,7 @@ bt_component_filter_borrow_class_const( */ static inline const bt_component *bt_component_filter_as_component_const( - const bt_component_filter *component) + const bt_component_filter *component) __BT_NOEXCEPT { return __BT_UPCAST_CONST(bt_component, component); } @@ -779,7 +784,7 @@ const bt_component *bt_component_filter_as_component_const( @bt_pre_not_null{component} */ extern uint64_t bt_component_filter_get_input_port_count( - const bt_component_filter *component); + const bt_component_filter *component) __BT_NOEXCEPT; /*! @brief @@ -812,7 +817,8 @@ extern uint64_t bt_component_filter_get_input_port_count( */ extern const bt_port_input * bt_component_filter_borrow_input_port_by_index_const( - const bt_component_filter *component, uint64_t index); + const bt_component_filter *component, uint64_t index) + __BT_NOEXCEPT; /*! @brief @@ -842,7 +848,8 @@ returns \c NULL. */ extern const bt_port_input * bt_component_filter_borrow_input_port_by_name_const( - const bt_component_filter *component, const char *name); + const bt_component_filter *component, const char *name) + __BT_NOEXCEPT; /*! @brief @@ -858,7 +865,7 @@ bt_component_filter_borrow_input_port_by_name_const( @bt_pre_not_null{component} */ extern uint64_t bt_component_filter_get_output_port_count( - const bt_component_filter *component); + const bt_component_filter *component) __BT_NOEXCEPT; /*! @brief @@ -891,7 +898,8 @@ extern uint64_t bt_component_filter_get_output_port_count( */ extern const bt_port_output * bt_component_filter_borrow_output_port_by_index_const( - const bt_component_filter *component, uint64_t index); + const bt_component_filter *component, uint64_t index) + __BT_NOEXCEPT; /*! @brief @@ -921,7 +929,8 @@ returns \c NULL. */ extern const bt_port_output * bt_component_filter_borrow_output_port_by_name_const( - const bt_component_filter *component, const char *name); + const bt_component_filter *component, const char *name) + __BT_NOEXCEPT; /*! @} */ @@ -946,7 +955,7 @@ bt_component_filter_borrow_output_port_by_name_const( Decrements the reference count of a filter component. */ extern void bt_component_filter_get_ref( - const bt_component_filter *component); + const bt_component_filter *component) __BT_NOEXCEPT; /*! @brief @@ -964,7 +973,7 @@ extern void bt_component_filter_get_ref( Increments the reference count of a filter component. */ extern void bt_component_filter_put_ref( - const bt_component_filter *component); + const bt_component_filter *component) __BT_NOEXCEPT; /*! @brief @@ -1040,7 +1049,7 @@ existing \bt_p{_dst} reference. */ extern const bt_component_class_sink * bt_component_sink_borrow_class_const( - const bt_component_sink *component); + const bt_component_sink *component) __BT_NOEXCEPT; /*! @} */ @@ -1066,7 +1075,7 @@ bt_component_sink_borrow_class_const( */ static inline const bt_component *bt_component_sink_as_component_const( - const bt_component_sink *component) + const bt_component_sink *component) __BT_NOEXCEPT { return __BT_UPCAST_CONST(bt_component, component); } @@ -1092,7 +1101,7 @@ const bt_component *bt_component_sink_as_component_const( @bt_pre_not_null{component} */ extern uint64_t bt_component_sink_get_input_port_count( - const bt_component_sink *component); + const bt_component_sink *component) __BT_NOEXCEPT; /*! @brief @@ -1125,7 +1134,8 @@ extern uint64_t bt_component_sink_get_input_port_count( */ extern const bt_port_input * bt_component_sink_borrow_input_port_by_index_const( - const bt_component_sink *component, uint64_t index); + const bt_component_sink *component, uint64_t index) + __BT_NOEXCEPT; /*! @brief @@ -1155,7 +1165,8 @@ returns \c NULL. */ extern const bt_port_input * bt_component_sink_borrow_input_port_by_name_const( - const bt_component_sink *component, const char *name); + const bt_component_sink *component, const char *name) + __BT_NOEXCEPT; /*! @} */ @@ -1180,7 +1191,7 @@ bt_component_sink_borrow_input_port_by_name_const( Decrements the reference count of a sink component. */ extern void bt_component_sink_get_ref( - const bt_component_sink *component); + const bt_component_sink *component) __BT_NOEXCEPT; /*! @brief @@ -1198,7 +1209,7 @@ extern void bt_component_sink_get_ref( Increments the reference count of a sink component. */ extern void bt_component_sink_put_ref( - const bt_component_sink *component); + const bt_component_sink *component) __BT_NOEXCEPT; /*! @brief diff --git a/include/babeltrace2/graph/connection.h b/include/babeltrace2/graph/connection.h index 3e6d45fe..8400522f 100644 --- a/include/babeltrace2/graph/connection.h +++ b/include/babeltrace2/graph/connection.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_GRAPH_CONNECTION_H #define BABELTRACE2_GRAPH_CONNECTION_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -72,7 +74,7 @@ bt_connection_borrow_downstream_port_const(). @bt_pre_not_null{connection} */ extern const bt_port_input *bt_connection_borrow_downstream_port_const( - const bt_connection *connection); + const bt_connection *connection) __BT_NOEXCEPT; /*! @brief @@ -88,7 +90,7 @@ extern const bt_port_input *bt_connection_borrow_downstream_port_const( @bt_pre_not_null{connection} */ extern const bt_port_output *bt_connection_borrow_upstream_port_const( - const bt_connection *connection); + const bt_connection *connection) __BT_NOEXCEPT; /*! @} */ @@ -112,7 +114,8 @@ extern const bt_port_output *bt_connection_borrow_upstream_port_const( @sa bt_connection_put_ref() — Decrements the reference count of a connection. */ -extern void bt_connection_get_ref(const bt_connection *connection); +extern void bt_connection_get_ref(const bt_connection *connection) + __BT_NOEXCEPT; /*! @brief @@ -129,7 +132,8 @@ extern void bt_connection_get_ref(const bt_connection *connection); @sa bt_connection_get_ref() — Increments the reference count of a connection. */ -extern void bt_connection_put_ref(const bt_connection *connection); +extern void bt_connection_put_ref(const bt_connection *connection) + __BT_NOEXCEPT; /*! @brief diff --git a/include/babeltrace2/graph/graph.h b/include/babeltrace2/graph/graph.h index f3d0ffb5..0f80a1e1 100644 --- a/include/babeltrace2/graph/graph.h +++ b/include/babeltrace2/graph/graph.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_GRAPH_GRAPH_H #define BABELTRACE2_GRAPH_GRAPH_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -558,7 +560,7 @@ default interrupter with bt_graph_borrow_default_interrupter(). @pre \bt_p{mip_version} is 0. */ -extern bt_graph *bt_graph_create(uint64_t mip_version); +extern bt_graph *bt_graph_create(uint64_t mip_version) __BT_NOEXCEPT; /*! @} */ @@ -602,7 +604,7 @@ bt_graph_add_source_component(bt_graph *graph, const bt_component_class_source *component_class, const char *name, const bt_value *params, bt_logging_level logging_level, - const bt_component_source **component); + const bt_component_source **component) __BT_NOEXCEPT; /*! @brief @@ -683,7 +685,7 @@ bt_graph_add_source_component_with_initialize_method_data( const bt_component_class_source *component_class, const char *name, const bt_value *params, void *initialize_method_data, bt_logging_level logging_level, - const bt_component_source **component); + const bt_component_source **component) __BT_NOEXCEPT; /*! @brief @@ -695,7 +697,7 @@ bt_graph_add_filter_component(bt_graph *graph, const bt_component_class_filter *component_class, const char *name, const bt_value *params, bt_logging_level logging_level, - const bt_component_filter **component); + const bt_component_filter **component) __BT_NOEXCEPT; /*! @brief @@ -776,7 +778,7 @@ bt_graph_add_filter_component_with_initialize_method_data( const bt_component_class_filter *component_class, const char *name, const bt_value *params, void *initialize_method_data, bt_logging_level logging_level, - const bt_component_filter **component); + const bt_component_filter **component) __BT_NOEXCEPT; /*! @brief @@ -788,7 +790,7 @@ bt_graph_add_sink_component( bt_graph *graph, const bt_component_class_sink *component_class, const char *name, const bt_value *params, bt_logging_level logging_level, - const bt_component_sink **component); + const bt_component_sink **component) __BT_NOEXCEPT; /*! @brief @@ -868,7 +870,7 @@ bt_graph_add_sink_component_with_initialize_method_data( bt_graph *graph, const bt_component_class_sink *component_class, const char *name, const bt_value *params, void *initialize_method_data, bt_logging_level logging_level, - const bt_component_sink **component); + const bt_component_sink **component) __BT_NOEXCEPT; /*! @} */ @@ -1128,7 +1130,7 @@ bt_graph_add_simple_sink_component(bt_graph *graph, const char *name, bt_graph_simple_sink_component_initialize_func initialize_func, bt_graph_simple_sink_component_consume_func consume_func, bt_graph_simple_sink_component_finalize_func finalize_func, - void *user_data, const bt_component_sink **component); + void *user_data, const bt_component_sink **component) __BT_NOEXCEPT; /*! @} */ @@ -1217,7 +1219,7 @@ this function. extern bt_graph_connect_ports_status bt_graph_connect_ports(bt_graph *graph, const bt_port_output *upstream_port, const bt_port_input *downstream_port, - const bt_connection **connection); + const bt_connection **connection) __BT_NOEXCEPT; /*! @} */ @@ -1333,7 +1335,7 @@ and what you can and cannot do with a configured graph. Calls a single trace processing graph's sink component's consuming method once. */ -extern bt_graph_run_status bt_graph_run(bt_graph *graph); +extern bt_graph_run_status bt_graph_run(bt_graph *graph) __BT_NOEXCEPT; /*! @brief @@ -1441,7 +1443,7 @@ and what you can and cannot do with a configured graph. Runs a trace processing graph, making all its sink components consume in a round robin fashion. */ -extern bt_graph_run_once_status bt_graph_run_once(bt_graph *graph); +extern bt_graph_run_once_status bt_graph_run_once(bt_graph *graph) __BT_NOEXCEPT; /*! @} */ @@ -1515,7 +1517,7 @@ graph's interrupters is set. If so, bt_graph_run() returns Borrows the default interrupter from a trace processing graph. */ extern bt_graph_add_interrupter_status bt_graph_add_interrupter(bt_graph *graph, - const bt_interrupter *interrupter); + const bt_interrupter *interrupter) __BT_NOEXCEPT; /*! @brief @@ -1537,7 +1539,8 @@ extern bt_graph_add_interrupter_status bt_graph_add_interrupter(bt_graph *graph, @sa bt_graph_add_interrupter() — Adds an interrupter to a trace processing graph. */ -extern bt_interrupter *bt_graph_borrow_default_interrupter(bt_graph *graph); +extern bt_interrupter *bt_graph_borrow_default_interrupter(bt_graph *graph) + __BT_NOEXCEPT; /*! @} */ @@ -1666,7 +1669,7 @@ extern bt_graph_add_listener_status bt_graph_add_filter_component_input_port_added_listener( bt_graph *graph, bt_graph_filter_component_input_port_added_listener_func user_func, - void *user_data, bt_listener_id *listener_id); + void *user_data, bt_listener_id *listener_id) __BT_NOEXCEPT; /*! @brief @@ -1742,7 +1745,7 @@ extern bt_graph_add_listener_status bt_graph_add_sink_component_input_port_added_listener( bt_graph *graph, bt_graph_sink_component_input_port_added_listener_func user_func, - void *user_data, bt_listener_id *listener_id); + void *user_data, bt_listener_id *listener_id) __BT_NOEXCEPT; /*! @brief @@ -1818,7 +1821,7 @@ extern bt_graph_add_listener_status bt_graph_add_source_component_output_port_added_listener( bt_graph *graph, bt_graph_source_component_output_port_added_listener_func user_func, - void *user_data, bt_listener_id *listener_id); + void *user_data, bt_listener_id *listener_id) __BT_NOEXCEPT; /*! @brief @@ -1894,7 +1897,7 @@ extern bt_graph_add_listener_status bt_graph_add_filter_component_output_port_added_listener( bt_graph *graph, bt_graph_filter_component_output_port_added_listener_func user_func, - void *user_data, bt_listener_id *listener_id); + void *user_data, bt_listener_id *listener_id) __BT_NOEXCEPT; /*! @} */ @@ -1918,7 +1921,7 @@ bt_graph_add_filter_component_output_port_added_listener( @sa bt_graph_put_ref() — Decrements the reference count of a trace processing graph. */ -extern void bt_graph_get_ref(const bt_graph *graph); +extern void bt_graph_get_ref(const bt_graph *graph) __BT_NOEXCEPT; /*! @brief @@ -1935,7 +1938,7 @@ extern void bt_graph_get_ref(const bt_graph *graph); @sa bt_graph_get_ref() — Increments the reference count of a trace processing graph. */ -extern void bt_graph_put_ref(const bt_graph *graph); +extern void bt_graph_put_ref(const bt_graph *graph) __BT_NOEXCEPT; /*! @brief diff --git a/include/babeltrace2/graph/interrupter.h b/include/babeltrace2/graph/interrupter.h index 00b9512f..1c8729b4 100644 --- a/include/babeltrace2/graph/interrupter.h +++ b/include/babeltrace2/graph/interrupter.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_GRAPH_INTERRUPTER_H #define BABELTRACE2_GRAPH_INTERRUPTER_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -106,7 +108,7 @@ On success, the returned interrupter is \em not set @returns New interrupter reference, or \c NULL on memory error. */ -extern bt_interrupter *bt_interrupter_create(void); +extern bt_interrupter *bt_interrupter_create(void) __BT_NOEXCEPT; /*! @} */ @@ -132,7 +134,7 @@ After you call this function, bt_interrupter_is_set() returns @sa bt_interrupter_is_set() — Returns whether or not an interrupter is set. */ -extern void bt_interrupter_set(bt_interrupter *interrupter); +extern void bt_interrupter_set(bt_interrupter *interrupter) __BT_NOEXCEPT; /*! @brief @@ -151,7 +153,7 @@ After you call this function, bt_interrupter_is_set() returns @sa bt_interrupter_is_set() — Returns whether or not an interrupter is set. */ -extern void bt_interrupter_reset(bt_interrupter *interrupter); +extern void bt_interrupter_reset(bt_interrupter *interrupter) __BT_NOEXCEPT; /*! @brief @@ -170,7 +172,8 @@ extern void bt_interrupter_reset(bt_interrupter *interrupter); @sa bt_interrupter_reset() — Resets an interrupter. */ -extern bt_bool bt_interrupter_is_set(const bt_interrupter *interrupter); +extern bt_bool bt_interrupter_is_set(const bt_interrupter *interrupter) + __BT_NOEXCEPT; /*! @} */ @@ -194,7 +197,8 @@ extern bt_bool bt_interrupter_is_set(const bt_interrupter *interrupter); @sa bt_interrupter_put_ref() — Decrements the reference count of an interrupter. */ -extern void bt_interrupter_get_ref(const bt_interrupter *interrupter); +extern void bt_interrupter_get_ref(const bt_interrupter *interrupter) + __BT_NOEXCEPT; /*! @brief @@ -211,7 +215,8 @@ extern void bt_interrupter_get_ref(const bt_interrupter *interrupter); @sa bt_interrupter_get_ref() — Increments the reference count of an interrupter. */ -extern void bt_interrupter_put_ref(const bt_interrupter *interrupter); +extern void bt_interrupter_put_ref(const bt_interrupter *interrupter) + __BT_NOEXCEPT; /*! @brief diff --git a/include/babeltrace2/graph/message-iterator-class.h b/include/babeltrace2/graph/message-iterator-class.h index 05c58987..82ee1f2d 100644 --- a/include/babeltrace2/graph/message-iterator-class.h +++ b/include/babeltrace2/graph/message-iterator-class.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_GRAPH_MESSAGE_ITERATOR_CLASS_H #define BABELTRACE2_GRAPH_MESSAGE_ITERATOR_CLASS_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -417,21 +419,21 @@ The available message iterator class methods to implement are: this method, then the next time your \link api-msg-iter-cls-meth-next "next" method\endlink is called: - - For each "active" \bt_stream at the seeked time point, you must + - For each "active" \bt_stream at the sought time point, you must emit a \bt_sb_msg for this stream before you emit any other message for this stream. The stream beginning message must have a \ref api-msg-sb-prop-cs "default clock snapshot" which corresponds - to the seeked time point. + to the sought time point. - - For each "active" \bt_pkt at the seeked time point, you must + - For each "active" \bt_pkt at the sought time point, you must emit a \bt_pb_msg for this packet before you emit any other message for this packet. The packet beginning message must have a \ref api-msg-pb-prop-cs "default clock snapshot" which corresponds - to the seeked time point. + to the sought time point. The \bt_name project recommends that this method executes fast enough so as not to block an interactive application running on the @@ -975,7 +977,8 @@ typedef bt_message_iterator_class_seek_ns_from_origin_method_status */ extern bt_message_iterator_class * bt_message_iterator_class_create( - bt_message_iterator_class_next_method next_method); + bt_message_iterator_class_next_method next_method) + __BT_NOEXCEPT; /*! @} */ @@ -1020,7 +1023,7 @@ See the \ref api-msg-iter-cls-meth-fini "finalize" method. extern bt_message_iterator_class_set_method_status bt_message_iterator_class_set_finalize_method( bt_message_iterator_class *message_iterator_class, - bt_message_iterator_class_finalize_method method); + bt_message_iterator_class_finalize_method method) __BT_NOEXCEPT; /*! @brief @@ -1045,7 +1048,8 @@ See the \ref api-msg-iter-cls-meth-init "initialize" method. extern bt_message_iterator_class_set_method_status bt_message_iterator_class_set_initialize_method( bt_message_iterator_class *message_iterator_class, - bt_message_iterator_class_initialize_method method); + bt_message_iterator_class_initialize_method method) + __BT_NOEXCEPT; /*! @brief @@ -1082,7 +1086,8 @@ extern bt_message_iterator_class_set_method_status bt_message_iterator_class_set_seek_beginning_methods( bt_message_iterator_class *message_iterator_class, bt_message_iterator_class_seek_beginning_method seek_method, - bt_message_iterator_class_can_seek_beginning_method can_seek_method); + bt_message_iterator_class_can_seek_beginning_method can_seek_method) + __BT_NOEXCEPT; /*! @brief @@ -1121,7 +1126,8 @@ extern bt_message_iterator_class_set_method_status bt_message_iterator_class_set_seek_ns_from_origin_methods( bt_message_iterator_class *message_iterator_class, bt_message_iterator_class_seek_ns_from_origin_method seek_method, - bt_message_iterator_class_can_seek_ns_from_origin_method can_seek_method); + bt_message_iterator_class_can_seek_ns_from_origin_method can_seek_method) + __BT_NOEXCEPT; /*! @} */ @@ -1146,7 +1152,8 @@ bt_message_iterator_class_set_seek_ns_from_origin_methods( Decrements the reference count of a message iterator class. */ extern void bt_message_iterator_class_get_ref( - const bt_message_iterator_class *message_iterator_class); + const bt_message_iterator_class *message_iterator_class) + __BT_NOEXCEPT; /*! @brief @@ -1164,7 +1171,8 @@ extern void bt_message_iterator_class_get_ref( Increments the reference count of a message iterator class. */ extern void bt_message_iterator_class_put_ref( - const bt_message_iterator_class *message_iterator_class); + const bt_message_iterator_class *message_iterator_class) + __BT_NOEXCEPT; /*! @brief diff --git a/include/babeltrace2/graph/message-iterator.h b/include/babeltrace2/graph/message-iterator.h index 123e4771..1a39dfc5 100644 --- a/include/babeltrace2/graph/message-iterator.h +++ b/include/babeltrace2/graph/message-iterator.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_GRAPH_MESSAGE_ITERATOR_H #define BABELTRACE2_GRAPH_MESSAGE_ITERATOR_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -262,7 +264,7 @@ extern bt_message_iterator_create_from_message_iterator_status bt_message_iterator_create_from_message_iterator( bt_self_message_iterator *self_message_iterator, bt_self_component_port_input *port, - bt_message_iterator **message_iterator); + bt_message_iterator **message_iterator) __BT_NOEXCEPT; /*! @brief @@ -326,7 +328,7 @@ extern bt_message_iterator_create_from_sink_component_status bt_message_iterator_create_from_sink_component( bt_self_component_sink *self_component_sink, bt_self_component_port_input *port, - bt_message_iterator **message_iterator); + bt_message_iterator **message_iterator) __BT_NOEXCEPT; /*! @} */ @@ -351,7 +353,7 @@ bt_message_iterator_create_from_sink_component( */ extern bt_component * bt_message_iterator_borrow_component( - bt_message_iterator *message_iterator); + bt_message_iterator *message_iterator) __BT_NOEXCEPT; /*! @} */ @@ -452,7 +454,8 @@ messages. */ extern bt_message_iterator_next_status bt_message_iterator_next(bt_message_iterator *message_iterator, - bt_message_array_const *messages, uint64_t *count); + bt_message_array_const *messages, uint64_t *count) + __BT_NOEXCEPT; /*! @} */ @@ -528,7 +531,7 @@ call bt_message_iterator_seek_beginning(). extern bt_message_iterator_can_seek_beginning_status bt_message_iterator_can_seek_beginning( bt_message_iterator *message_iterator, - bt_bool *can_seek_beginning); + bt_bool *can_seek_beginning) __BT_NOEXCEPT; /*! @brief @@ -594,7 +597,7 @@ without performing any other \ref api-msg-iter-ops "operation" on */ extern bt_message_iterator_seek_beginning_status bt_message_iterator_seek_beginning( - bt_message_iterator *message_iterator); + bt_message_iterator *message_iterator) __BT_NOEXCEPT; /*! @brief @@ -671,7 +674,8 @@ call bt_message_iterator_seek_ns_from_origin(). extern bt_message_iterator_can_seek_ns_from_origin_status bt_message_iterator_can_seek_ns_from_origin( bt_message_iterator *message_iterator, - int64_t ns_from_origin, bt_bool *can_seek_ns_from_origin); + int64_t ns_from_origin, bt_bool *can_seek_ns_from_origin) + __BT_NOEXCEPT; /*! @brief @@ -743,7 +747,7 @@ without performing any other \ref api-msg-iter-ops "operation" on extern bt_message_iterator_seek_ns_from_origin_status bt_message_iterator_seek_ns_from_origin( bt_message_iterator *message_iterator, - int64_t ns_from_origin); + int64_t ns_from_origin) __BT_NOEXCEPT; /*! @} */ @@ -771,7 +775,7 @@ message sequence have some \bt_cs. */ extern bt_bool bt_message_iterator_can_seek_forward( - bt_message_iterator *message_iterator); + bt_message_iterator *message_iterator) __BT_NOEXCEPT; /*! @} */ @@ -796,7 +800,7 @@ bt_message_iterator_can_seek_forward( Decrements the reference count of a message iterator. */ extern void bt_message_iterator_get_ref( - const bt_message_iterator *message_iterator); + const bt_message_iterator *message_iterator) __BT_NOEXCEPT; /*! @brief @@ -814,7 +818,7 @@ extern void bt_message_iterator_get_ref( Increments the reference count of a message iterator. */ extern void bt_message_iterator_put_ref( - const bt_message_iterator *message_iterator); + const bt_message_iterator *message_iterator) __BT_NOEXCEPT; /*! @brief diff --git a/include/babeltrace2/graph/message.h b/include/babeltrace2/graph/message.h index c5a75bda..a73d6e1c 100644 --- a/include/babeltrace2/graph/message.h +++ b/include/babeltrace2/graph/message.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_GRAPH_MESSAGE_H #define BABELTRACE2_GRAPH_MESSAGE_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -790,7 +792,7 @@ A message iterator inactivity message has the following property:

\anchor api-msg-mip Message Interchange Protocol

The Message Interchange Protocol (MIP) is the system of rules -used by \bt_p_comp and \bt_p_msg_iter to exchance messages within a +used by \bt_p_comp and \bt_p_msg_iter to exchange messages within a trace processing graph. The MIP covers everything related to messages and what they contain, as @@ -1023,7 +1025,8 @@ typedef enum bt_message_type { @bt_pre_not_null{message} */ -extern bt_message_type bt_message_get_type(const bt_message *message); +extern bt_message_type bt_message_get_type(const bt_message *message) + __BT_NOEXCEPT; /*! @} */ @@ -1097,7 +1100,7 @@ property values: extern bt_message *bt_message_stream_beginning_create( bt_self_message_iterator *self_message_iterator, - const bt_stream *stream); + const bt_stream *stream) __BT_NOEXCEPT; /*! @brief @@ -1122,7 +1125,7 @@ See the \ref api-msg-sb-prop-stream "stream" property. \c const version of this function. */ extern bt_stream *bt_message_stream_beginning_borrow_stream( - bt_message *message); + bt_message *message) __BT_NOEXCEPT; /*! @brief @@ -1132,7 +1135,7 @@ extern bt_stream *bt_message_stream_beginning_borrow_stream( See bt_message_stream_beginning_borrow_stream(). */ extern const bt_stream *bt_message_stream_beginning_borrow_stream_const( - const bt_message *message); + const bt_message *message) __BT_NOEXCEPT; /*! @brief @@ -1160,7 +1163,7 @@ See the \ref api-msg-sb-prop-cs "default clock snapshot" property. */ extern void bt_message_stream_beginning_set_default_clock_snapshot( - bt_message *message, uint64_t value); + bt_message *message, uint64_t value) __BT_NOEXCEPT; /*! @brief @@ -1196,7 +1199,7 @@ See the \ref api-msg-sb-prop-cs "default clock snapshot" property. extern bt_message_stream_clock_snapshot_state bt_message_stream_beginning_borrow_default_clock_snapshot_const( const bt_message *message, - const bt_clock_snapshot **clock_snapshot); + const bt_clock_snapshot **clock_snapshot) __BT_NOEXCEPT; /*! @brief @@ -1228,7 +1231,7 @@ bt_stream_class_borrow_default_clock_class_const( */ extern const bt_clock_class * bt_message_stream_beginning_borrow_stream_class_default_clock_class_const( - const bt_message *message); + const bt_message *message) __BT_NOEXCEPT; /*! @} */ @@ -1274,7 +1277,7 @@ property values: extern bt_message *bt_message_stream_end_create( bt_self_message_iterator *self_message_iterator, - const bt_stream *stream); + const bt_stream *stream) __BT_NOEXCEPT; /*! @brief @@ -1299,7 +1302,7 @@ See the \ref api-msg-se-prop-stream "stream" property. \c const version of this function. */ extern bt_stream *bt_message_stream_end_borrow_stream( - bt_message *message); + bt_message *message) __BT_NOEXCEPT; /*! @brief @@ -1309,7 +1312,7 @@ extern bt_stream *bt_message_stream_end_borrow_stream( See bt_message_stream_end_borrow_stream(). */ extern const bt_stream *bt_message_stream_end_borrow_stream_const( - const bt_message *message); + const bt_message *message) __BT_NOEXCEPT; /*! @brief @@ -1337,7 +1340,7 @@ See the \ref api-msg-se-prop-cs "default clock snapshot" property. */ extern void bt_message_stream_end_set_default_clock_snapshot( - bt_message *message, uint64_t value); + bt_message *message, uint64_t value) __BT_NOEXCEPT; /*! @brief @@ -1373,7 +1376,7 @@ See the \ref api-msg-se-prop-cs "default clock snapshot" property. extern bt_message_stream_clock_snapshot_state bt_message_stream_end_borrow_default_clock_snapshot_const( const bt_message *message, - const bt_clock_snapshot **clock_snapshot); + const bt_clock_snapshot **clock_snapshot) __BT_NOEXCEPT; /*! @brief @@ -1405,7 +1408,7 @@ bt_stream_class_borrow_default_clock_class_const( */ extern const bt_clock_class * bt_message_stream_end_borrow_stream_class_default_clock_class_const( - const bt_message *message); + const bt_message *message) __BT_NOEXCEPT; /*! @} */ @@ -1492,7 +1495,7 @@ extern bt_message *bt_message_event_create( bt_self_message_iterator *self_message_iterator, const bt_event_class *event_class, - const bt_stream *stream); + const bt_stream *stream) __BT_NOEXCEPT; /*! @brief @@ -1576,7 +1579,8 @@ extern bt_message *bt_message_event_create_with_default_clock_snapshot( bt_self_message_iterator *self_message_iterator, const bt_event_class *event_class, - const bt_stream *stream, uint64_t clock_snapshot_value); + const bt_stream *stream, uint64_t clock_snapshot_value) + __BT_NOEXCEPT; /*! @brief @@ -1661,7 +1665,7 @@ extern bt_message *bt_message_event_create_with_packet( bt_self_message_iterator *self_message_iterator, const bt_event_class *event_class, - const bt_packet *packet); + const bt_packet *packet) __BT_NOEXCEPT; /*! @brief @@ -1750,7 +1754,8 @@ extern bt_message *bt_message_event_create_with_packet_and_default_clock_snapshot( bt_self_message_iterator *self_message_iterator, const bt_event_class *event_class, - const bt_packet *packet, uint64_t clock_snapshot_value); + const bt_packet *packet, uint64_t clock_snapshot_value) + __BT_NOEXCEPT; /*! @brief @@ -1774,8 +1779,8 @@ See the \ref api-msg-ev-prop-ev "event" property. @sa bt_message_event_borrow_event_const() — \c const version of this function. */ -extern bt_event *bt_message_event_borrow_event( - bt_message *message); +extern bt_event *bt_message_event_borrow_event(bt_message *message) + __BT_NOEXCEPT; /*! @brief @@ -1785,7 +1790,7 @@ extern bt_event *bt_message_event_borrow_event( See bt_message_event_borrow_event(). */ extern const bt_event *bt_message_event_borrow_event_const( - const bt_message *message); + const bt_message *message) __BT_NOEXCEPT; /*! @brief @@ -1806,7 +1811,8 @@ See the \ref api-msg-ev-prop-cs "default clock snapshot" property. \ref api-tir-stream-cls-prop-def-clock-cls "default clock class". */ extern const bt_clock_snapshot * -bt_message_event_borrow_default_clock_snapshot_const(const bt_message *message); +bt_message_event_borrow_default_clock_snapshot_const(const bt_message *message) + __BT_NOEXCEPT; /*! @brief @@ -1839,7 +1845,7 @@ bt_stream_class_borrow_default_clock_class_const( */ extern const bt_clock_class * bt_message_event_borrow_stream_class_default_clock_class_const( - const bt_message *message); + const bt_message *message) __BT_NOEXCEPT; /*! @} */ @@ -1907,7 +1913,7 @@ property values: extern bt_message *bt_message_packet_beginning_create( bt_self_message_iterator *self_message_iterator, - const bt_packet *packet); + const bt_packet *packet) __BT_NOEXCEPT; /*! @brief @@ -1972,7 +1978,8 @@ property values: extern bt_message *bt_message_packet_beginning_create_with_default_clock_snapshot( bt_self_message_iterator *self_message_iterator, - const bt_packet *packet, uint64_t clock_snapshot_value); + const bt_packet *packet, uint64_t clock_snapshot_value) + __BT_NOEXCEPT; /*! @brief @@ -1997,7 +2004,7 @@ See the \ref api-msg-pb-prop-pkt "packet" property. \c const version of this function. */ extern bt_packet *bt_message_packet_beginning_borrow_packet( - bt_message *message); + bt_message *message) __BT_NOEXCEPT; /*! @brief @@ -2007,7 +2014,7 @@ extern bt_packet *bt_message_packet_beginning_borrow_packet( See bt_message_packet_beginning_borrow_packet(). */ extern const bt_packet *bt_message_packet_beginning_borrow_packet_const( - const bt_message *message); + const bt_message *message) __BT_NOEXCEPT; /*! @brief @@ -2030,7 +2037,7 @@ See the \ref api-msg-pb-prop-cs "default clock snapshot" property. */ extern const bt_clock_snapshot * bt_message_packet_beginning_borrow_default_clock_snapshot_const( - const bt_message *message); + const bt_message *message) __BT_NOEXCEPT; /*! @brief @@ -2063,7 +2070,7 @@ bt_stream_class_borrow_default_clock_class_const( */ extern const bt_clock_class * bt_message_packet_beginning_borrow_stream_class_default_clock_class_const( - const bt_message *message); + const bt_message *message) __BT_NOEXCEPT; /*! @} */ @@ -2130,7 +2137,7 @@ property values: extern bt_message *bt_message_packet_end_create( bt_self_message_iterator *self_message_iterator, - const bt_packet *packet); + const bt_packet *packet) __BT_NOEXCEPT; /*! @brief @@ -2195,7 +2202,8 @@ property values: extern bt_message *bt_message_packet_end_create_with_default_clock_snapshot( bt_self_message_iterator *self_message_iterator, - const bt_packet *packet, uint64_t clock_snapshot_value); + const bt_packet *packet, uint64_t clock_snapshot_value) + __BT_NOEXCEPT; /*! @brief @@ -2220,7 +2228,7 @@ See the \ref api-msg-pe-prop-pkt "packet" property. \c const version of this function. */ extern bt_packet *bt_message_packet_end_borrow_packet( - bt_message *message); + bt_message *message) __BT_NOEXCEPT; /*! @brief @@ -2230,7 +2238,7 @@ extern bt_packet *bt_message_packet_end_borrow_packet( See bt_message_packet_end_borrow_packet(). */ extern const bt_packet *bt_message_packet_end_borrow_packet_const( - const bt_message *message); + const bt_message *message) __BT_NOEXCEPT; /*! @brief @@ -2253,7 +2261,7 @@ See the \ref api-msg-pe-prop-cs "default clock snapshot" property. */ extern const bt_clock_snapshot * bt_message_packet_end_borrow_default_clock_snapshot_const( - const bt_message *message); + const bt_message *message) __BT_NOEXCEPT; /*! @brief @@ -2286,7 +2294,7 @@ bt_stream_class_borrow_default_clock_class_const( */ extern const bt_clock_class * bt_message_packet_end_borrow_stream_class_default_clock_class_const( - const bt_message *message); + const bt_message *message) __BT_NOEXCEPT; /*! @} */ @@ -2355,7 +2363,7 @@ property values: */ extern bt_message *bt_message_discarded_events_create( bt_self_message_iterator *self_message_iterator, - const bt_stream *stream); + const bt_stream *stream) __BT_NOEXCEPT; /*! @brief @@ -2428,7 +2436,8 @@ extern bt_message *bt_message_discarded_events_create_with_default_clock_snapsho bt_self_message_iterator *self_message_iterator, const bt_stream *stream, uint64_t beginning_clock_snapshot_value, - uint64_t end_clock_snapshot_value); + uint64_t end_clock_snapshot_value) + __BT_NOEXCEPT; /*! @brief @@ -2453,7 +2462,7 @@ See the \ref api-msg-disc-ev-prop-stream "stream" property. \c const version of this function. */ extern bt_stream *bt_message_discarded_events_borrow_stream( - bt_message *message); + bt_message *message) __BT_NOEXCEPT; /*! @brief @@ -2463,7 +2472,8 @@ extern bt_stream *bt_message_discarded_events_borrow_stream( See bt_message_discarded_events_borrow_stream(). */ extern const bt_stream * -bt_message_discarded_events_borrow_stream_const(const bt_message *message); +bt_message_discarded_events_borrow_stream_const(const bt_message *message) + __BT_NOEXCEPT; /*! @brief @@ -2490,7 +2500,7 @@ property. */ extern const bt_clock_snapshot * bt_message_discarded_events_borrow_beginning_default_clock_snapshot_const( - const bt_message *message); + const bt_message *message) __BT_NOEXCEPT; /*! @brief @@ -2517,7 +2527,7 @@ property. */ extern const bt_clock_snapshot * bt_message_discarded_events_borrow_end_default_clock_snapshot_const( - const bt_message *message); + const bt_message *message) __BT_NOEXCEPT; /*! @brief @@ -2549,7 +2559,7 @@ bt_stream_class_borrow_default_clock_class_const( */ extern const bt_clock_class * bt_message_discarded_events_borrow_stream_class_default_clock_class_const( - const bt_message *message); + const bt_message *message) __BT_NOEXCEPT; /*! @brief @@ -2576,7 +2586,7 @@ property. message. */ extern void bt_message_discarded_events_set_count(bt_message *message, - uint64_t count); + uint64_t count) __BT_NOEXCEPT; /*! @brief @@ -2607,7 +2617,7 @@ property. Sets the number of discarded events of a discarded events message. */ extern bt_property_availability bt_message_discarded_events_get_count( - const bt_message *message, uint64_t *count); + const bt_message *message, uint64_t *count) __BT_NOEXCEPT; /*! @} */ @@ -2676,7 +2686,7 @@ property values: */ extern bt_message *bt_message_discarded_packets_create( bt_self_message_iterator *self_message_iterator, - const bt_stream *stream); + const bt_stream *stream) __BT_NOEXCEPT; /*! @brief @@ -2748,7 +2758,7 @@ property values: extern bt_message *bt_message_discarded_packets_create_with_default_clock_snapshots( bt_self_message_iterator *self_message_iterator, const bt_stream *stream, uint64_t beginning_clock_snapshot_value, - uint64_t end_clock_snapshot_value); + uint64_t end_clock_snapshot_value) __BT_NOEXCEPT; /*! @brief @@ -2773,7 +2783,7 @@ See the \ref api-msg-disc-ev-prop-stream "stream" property. \c const version of this function. */ extern bt_stream *bt_message_discarded_packets_borrow_stream( - bt_message *message); + bt_message *message) __BT_NOEXCEPT; /*! @brief @@ -2783,7 +2793,8 @@ extern bt_stream *bt_message_discarded_packets_borrow_stream( See bt_message_discarded_packets_borrow_stream(). */ extern const bt_stream * -bt_message_discarded_packets_borrow_stream_const(const bt_message *message); +bt_message_discarded_packets_borrow_stream_const(const bt_message *message) + __BT_NOEXCEPT; /*! @brief @@ -2810,7 +2821,7 @@ property. */ extern const bt_clock_snapshot * bt_message_discarded_packets_borrow_beginning_default_clock_snapshot_const( - const bt_message *message); + const bt_message *message) __BT_NOEXCEPT; /*! @brief @@ -2837,7 +2848,7 @@ property. */ extern const bt_clock_snapshot * bt_message_discarded_packets_borrow_end_default_clock_snapshot_const( - const bt_message *message); + const bt_message *message) __BT_NOEXCEPT; /*! @brief @@ -2869,7 +2880,7 @@ bt_stream_class_borrow_default_clock_class_const( */ extern const bt_clock_class * bt_message_discarded_packets_borrow_stream_class_default_clock_class_const( - const bt_message *message); + const bt_message *message) __BT_NOEXCEPT; /*! @brief @@ -2896,7 +2907,7 @@ property. message. */ extern void bt_message_discarded_packets_set_count(bt_message *message, - uint64_t count); + uint64_t count) __BT_NOEXCEPT; /*! @brief @@ -2927,7 +2938,7 @@ property. Sets the number of discarded packets of a discarded packets message. */ extern bt_property_availability bt_message_discarded_packets_get_count( - const bt_message *message, uint64_t *count); + const bt_message *message, uint64_t *count) __BT_NOEXCEPT; /*! @} */ @@ -2979,7 +2990,7 @@ extern bt_message *bt_message_message_iterator_inactivity_create( bt_self_message_iterator *self_message_iterator, const bt_clock_class *clock_class, - uint64_t clock_snapshot_value); + uint64_t clock_snapshot_value) __BT_NOEXCEPT; /*! @brief @@ -2999,7 +3010,7 @@ See the \ref api-msg-inac-prop-cs "clock snapshot" property. */ extern const bt_clock_snapshot * bt_message_message_iterator_inactivity_borrow_clock_snapshot_const( - const bt_message *message); + const bt_message *message) __BT_NOEXCEPT; /*! @} */ @@ -3023,7 +3034,7 @@ bt_message_message_iterator_inactivity_borrow_clock_snapshot_const( @sa bt_message_put_ref() — Decrements the reference count of a message. */ -extern void bt_message_get_ref(const bt_message *message); +extern void bt_message_get_ref(const bt_message *message) __BT_NOEXCEPT; /*! @brief @@ -3040,7 +3051,7 @@ extern void bt_message_get_ref(const bt_message *message); @sa bt_message_get_ref() — Increments the reference count of a message. */ -extern void bt_message_put_ref(const bt_message *message); +extern void bt_message_put_ref(const bt_message *message) __BT_NOEXCEPT; /*! @brief @@ -3186,7 +3197,8 @@ component descriptors of \bt_p{component_descriptors}, it returns extern bt_get_greatest_operative_mip_version_status bt_get_greatest_operative_mip_version( const bt_component_descriptor_set *component_descriptors, - bt_logging_level logging_level, uint64_t *mip_version); + bt_logging_level logging_level, uint64_t *mip_version) + __BT_NOEXCEPT; /*! @brief @@ -3199,7 +3211,7 @@ As of \bt_name_version_min_maj, this function returns @returns Maximal available MIP version (\bt_max_mip_version). */ -extern uint64_t bt_get_maximal_mip_version(void); +extern uint64_t bt_get_maximal_mip_version(void) __BT_NOEXCEPT; /*! @} */ diff --git a/include/babeltrace2/graph/port.h b/include/babeltrace2/graph/port.h index 3b210f2d..b25395ee 100644 --- a/include/babeltrace2/graph/port.h +++ b/include/babeltrace2/graph/port.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_GRAPH_PORT_H #define BABELTRACE2_GRAPH_PORT_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -191,7 +193,7 @@ typedef enum bt_port_type { @sa bt_port_is_output() — Returns whether or not a port is an \bt_oport. */ -extern bt_port_type bt_port_get_type(const bt_port *port); +extern bt_port_type bt_port_get_type(const bt_port *port) __BT_NOEXCEPT; /*! @brief @@ -209,7 +211,7 @@ extern bt_port_type bt_port_get_type(const bt_port *port); Returns the type enumerator of a port. */ static inline -bt_bool bt_port_is_input(const bt_port *port) +bt_bool bt_port_is_input(const bt_port *port) __BT_NOEXCEPT { return bt_port_get_type(port) == BT_PORT_TYPE_INPUT; } @@ -230,7 +232,7 @@ bt_bool bt_port_is_input(const bt_port *port) Returns the type enumerator of a port. */ static inline -bt_bool bt_port_is_output(const bt_port *port) +bt_bool bt_port_is_output(const bt_port *port) __BT_NOEXCEPT { return bt_port_get_type(port) == BT_PORT_TYPE_OUTPUT; } @@ -258,7 +260,7 @@ This function returns \c NULL if \bt_p{port} is unconnected @bt_pre_not_null{port} */ extern const bt_connection *bt_port_borrow_connection_const( - const bt_port *port); + const bt_port *port) __BT_NOEXCEPT; /*! @} */ @@ -280,7 +282,7 @@ extern const bt_connection *bt_port_borrow_connection_const( @bt_pre_not_null{port} */ extern const bt_component *bt_port_borrow_component_const( - const bt_port *port); + const bt_port *port) __BT_NOEXCEPT; /*! @} */ @@ -307,7 +309,7 @@ See the \ref api-port-prop-name "name" property. @bt_pre_not_null{port} */ -extern const char *bt_port_get_name(const bt_port *port); +extern const char *bt_port_get_name(const bt_port *port) __BT_NOEXCEPT; /*! @brief @@ -323,7 +325,7 @@ See the \ref api-port-prop-is-connected "is connected?" property. @bt_pre_not_null{port} */ -extern bt_bool bt_port_is_connected(const bt_port *port); +extern bt_bool bt_port_is_connected(const bt_port *port) __BT_NOEXCEPT; /*! @} */ @@ -347,7 +349,7 @@ extern bt_bool bt_port_is_connected(const bt_port *port); @sa bt_port_put_ref() — Decrements the reference count of a port. */ -extern void bt_port_get_ref(const bt_port *port); +extern void bt_port_get_ref(const bt_port *port) __BT_NOEXCEPT; /*! @brief @@ -364,7 +366,7 @@ extern void bt_port_get_ref(const bt_port *port); @sa bt_port_get_ref() — Increments the reference count of a port. */ -extern void bt_port_put_ref(const bt_port *port); +extern void bt_port_put_ref(const bt_port *port) __BT_NOEXCEPT; /*! @brief @@ -441,7 +443,8 @@ existing \bt_p{_dst} reference. \bt_p{port} as a common port. */ static inline -const bt_port *bt_port_input_as_port_const(const bt_port_input *port) +const bt_port *bt_port_input_as_port_const( + const bt_port_input *port) __BT_NOEXCEPT { return __BT_UPCAST_CONST(bt_port, port); } @@ -461,7 +464,7 @@ const bt_port *bt_port_input_as_port_const(const bt_port_input *port) @sa bt_port_input_put_ref() — Decrements the reference count of an input port. */ -extern void bt_port_input_get_ref(const bt_port_input *port); +extern void bt_port_input_get_ref(const bt_port_input *port) __BT_NOEXCEPT; /*! @brief @@ -478,7 +481,7 @@ extern void bt_port_input_get_ref(const bt_port_input *port); @sa bt_port_input_get_ref() — Increments the reference count of an input port. */ -extern void bt_port_input_put_ref(const bt_port_input *port); +extern void bt_port_input_put_ref(const bt_port_input *port) __BT_NOEXCEPT; /*! @brief @@ -555,7 +558,8 @@ existing \bt_p{_dst} reference. \bt_p{port} as a common port. */ static inline -const bt_port *bt_port_output_as_port_const(const bt_port_output *port) +const bt_port *bt_port_output_as_port_const( + const bt_port_output *port) __BT_NOEXCEPT { return __BT_UPCAST_CONST(bt_port, port); } @@ -575,7 +579,7 @@ const bt_port *bt_port_output_as_port_const(const bt_port_output *port) @sa bt_port_output_put_ref() — Decrements the reference count of a \bt_oport. */ -extern void bt_port_output_get_ref(const bt_port_output *port); +extern void bt_port_output_get_ref(const bt_port_output *port) __BT_NOEXCEPT; /*! @brief @@ -592,7 +596,7 @@ extern void bt_port_output_get_ref(const bt_port_output *port); @sa bt_port_output_get_ref() — Increments the reference count of a \bt_oport. */ -extern void bt_port_output_put_ref(const bt_port_output *port); +extern void bt_port_output_put_ref(const bt_port_output *port) __BT_NOEXCEPT; /*! @brief diff --git a/include/babeltrace2/graph/private-query-executor.h b/include/babeltrace2/graph/private-query-executor.h index 9c6e97c4..81a0daeb 100644 --- a/include/babeltrace2/graph/private-query-executor.h +++ b/include/babeltrace2/graph/private-query-executor.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_GRAPH_PRIVATE_QUERY_EXECUTOR_H #define BABELTRACE2_GRAPH_PRIVATE_QUERY_EXECUTOR_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -77,7 +79,7 @@ bt_private_query_executor_as_query_executor_const() function to static inline const bt_query_executor * bt_private_query_executor_as_query_executor_const( - bt_private_query_executor *query_executor) + bt_private_query_executor *query_executor) __BT_NOEXCEPT { return __BT_UPCAST_CONST(bt_query_executor, query_executor); } diff --git a/include/babeltrace2/graph/query-executor.h b/include/babeltrace2/graph/query-executor.h index d4ef58f9..0d4757a5 100644 --- a/include/babeltrace2/graph/query-executor.h +++ b/include/babeltrace2/graph/query-executor.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_GRAPH_QUERY_EXECUTOR_H #define BABELTRACE2_GRAPH_QUERY_EXECUTOR_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -143,7 +145,8 @@ A query executor has the following property: extern bt_query_executor *bt_query_executor_create( const bt_component_class *component_class, - const char *object_name, const bt_value *params); + const char *object_name, const bt_value *params) + __BT_NOEXCEPT; /*! @brief @@ -173,7 +176,7 @@ executor, the query method of \bt_p{component_class} receives: to create. Unlike the \bt_p{params} parameter of - the bt_graph_add_*_component_*_port_added_listener() + the bt_graph_add_*_component*() functions (see \ref api-graph), this parameter does not need to be a \bt_map_val. @@ -196,7 +199,7 @@ extern bt_query_executor *bt_query_executor_create_with_method_data( const bt_component_class *component_class, const char *object_name, const bt_value *params, - void *method_data); + void *method_data) __BT_NOEXCEPT; /*! @} */ @@ -285,7 +288,8 @@ bt_query_executor_create_with_method_data(). */ extern bt_query_executor_query_status bt_query_executor_query( - bt_query_executor *query_executor, const bt_value **result); + bt_query_executor *query_executor, const bt_value **result) + __BT_NOEXCEPT; /*! @} */ @@ -329,7 +333,7 @@ See the \ref api-qexec-prop-log-lvl "logging level" property. */ extern bt_query_executor_set_logging_level_status bt_query_executor_set_logging_level(bt_query_executor *query_executor, - bt_logging_level logging_level); + bt_logging_level logging_level) __BT_NOEXCEPT; /*! @brief @@ -350,7 +354,7 @@ See the \ref api-qexec-prop-log-lvl "logging level" property. Sets the logging level of a query executor. */ extern bt_logging_level bt_query_executor_get_logging_level( - const bt_query_executor *query_executor); + const bt_query_executor *query_executor) __BT_NOEXCEPT; /*! @} */ @@ -418,7 +422,7 @@ is set) with bt_query_executor_is_interrupted(). */ extern bt_query_executor_add_interrupter_status bt_query_executor_add_interrupter(bt_query_executor *query_executor, - const bt_interrupter *interrupter); + const bt_interrupter *interrupter) __BT_NOEXCEPT; /*! @brief @@ -443,7 +447,7 @@ bt_query_executor_add_interrupter(bt_query_executor *query_executor, Adds an interrupter to a query executor. */ extern bt_interrupter *bt_query_executor_borrow_default_interrupter( - bt_query_executor *query_executor); + bt_query_executor *query_executor) __BT_NOEXCEPT; /*! @brief @@ -461,7 +465,7 @@ extern bt_interrupter *bt_query_executor_borrow_default_interrupter( @bt_pre_not_null{query_executor} */ extern bt_bool bt_query_executor_is_interrupted( - const bt_query_executor *query_executor); + const bt_query_executor *query_executor) __BT_NOEXCEPT; /*! @} */ @@ -485,7 +489,8 @@ extern bt_bool bt_query_executor_is_interrupted( @sa bt_query_executor_put_ref() — Decrements the reference count of a query executor. */ -extern void bt_query_executor_get_ref(const bt_query_executor *query_executor); +extern void bt_query_executor_get_ref(const bt_query_executor *query_executor) + __BT_NOEXCEPT; /*! @brief @@ -502,7 +507,8 @@ extern void bt_query_executor_get_ref(const bt_query_executor *query_executor); @sa bt_query_executor_get_ref() — Increments the reference count of a query executor. */ -extern void bt_query_executor_put_ref(const bt_query_executor *query_executor); +extern void bt_query_executor_put_ref(const bt_query_executor *query_executor) + __BT_NOEXCEPT; /*! @brief diff --git a/include/babeltrace2/graph/self-component-class.h b/include/babeltrace2/graph/self-component-class.h index c5de3037..366f7146 100644 --- a/include/babeltrace2/graph/self-component-class.h +++ b/include/babeltrace2/graph/self-component-class.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_GRAPH_SELF_COMPONENT_CLASS_H #define BABELTRACE2_GRAPH_SELF_COMPONENT_CLASS_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -86,7 +88,7 @@ public #bt_component_class, #bt_component_class_source, */ static inline const bt_component_class *bt_self_component_class_as_component_class( - bt_self_component_class *self_component_class) + bt_self_component_class *self_component_class) __BT_NOEXCEPT { return __BT_UPCAST(bt_component_class, self_component_class); } @@ -111,6 +113,7 @@ static inline const bt_component_class_source * bt_self_component_class_source_as_component_class_source( bt_self_component_class_source *self_component_class) + __BT_NOEXCEPT { return __BT_UPCAST_CONST(bt_component_class_source, self_component_class); @@ -136,6 +139,7 @@ static inline const bt_component_class_filter * bt_self_component_class_filter_as_component_class_filter( bt_self_component_class_filter *self_component_class) + __BT_NOEXCEPT { return __BT_UPCAST_CONST(bt_component_class_filter, self_component_class); @@ -161,6 +165,7 @@ static inline const bt_component_class_sink * bt_self_component_class_sink_as_component_class_sink( bt_self_component_class_sink *self_component_class) + __BT_NOEXCEPT { return __BT_UPCAST_CONST(bt_component_class_sink, self_component_class); } @@ -192,6 +197,7 @@ static inline bt_self_component_class* bt_self_component_class_source_as_self_component_class( bt_self_component_class_source *self_component_class) + __BT_NOEXCEPT { return __BT_UPCAST(bt_self_component_class, self_component_class); } @@ -216,6 +222,7 @@ static inline bt_self_component_class* bt_self_component_class_filter_as_self_component_class( bt_self_component_class_filter *self_component_class) + __BT_NOEXCEPT { return __BT_UPCAST(bt_self_component_class, self_component_class); } @@ -240,6 +247,7 @@ static inline bt_self_component_class* bt_self_component_class_sink_as_self_component_class( bt_self_component_class_sink *self_component_class) + __BT_NOEXCEPT { return __BT_UPCAST(bt_self_component_class, self_component_class); } diff --git a/include/babeltrace2/graph/self-component-port.h b/include/babeltrace2/graph/self-component-port.h index 8532d270..5cb500b2 100644 --- a/include/babeltrace2/graph/self-component-port.h +++ b/include/babeltrace2/graph/self-component-port.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_GRAPH_SELF_COMPONENT_PORT_H #define BABELTRACE2_GRAPH_SELF_COMPONENT_PORT_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -84,7 +86,7 @@ functions. @bt_pre_not_null{self_component_port} */ extern bt_self_component *bt_self_component_port_borrow_component( - bt_self_component_port *self_component_port); + bt_self_component_port *self_component_port) __BT_NOEXCEPT; /*! @} */ @@ -112,7 +114,8 @@ bt_self_component_sink_add_input_port(). @bt_pre_not_null{self_component_port} */ extern void *bt_self_component_port_get_data( - const bt_self_component_port *self_component_port); + const bt_self_component_port *self_component_port) + __BT_NOEXCEPT; /*! @} */ @@ -138,7 +141,7 @@ extern void *bt_self_component_port_get_data( */ static inline const bt_port *bt_self_component_port_as_port( - bt_self_component_port *self_component_port) + bt_self_component_port *self_component_port) __BT_NOEXCEPT { return __BT_UPCAST_CONST(bt_port, self_component_port); } @@ -161,6 +164,7 @@ const bt_port *bt_self_component_port_as_port( static inline const bt_port_input *bt_self_component_port_input_as_port_input( const bt_self_component_port_input *self_component_port) + __BT_NOEXCEPT { return __BT_UPCAST_CONST(bt_port_input, self_component_port); } @@ -183,6 +187,7 @@ const bt_port_input *bt_self_component_port_input_as_port_input( static inline const bt_port_output *bt_self_component_port_output_as_port_output( bt_self_component_port_output *self_component_port) + __BT_NOEXCEPT { return __BT_UPCAST_CONST(bt_port_output, self_component_port); } @@ -214,6 +219,7 @@ static inline bt_self_component_port * bt_self_component_port_input_as_self_component_port( bt_self_component_port_input *self_component_port) + __BT_NOEXCEPT { return __BT_UPCAST(bt_self_component_port, self_component_port); } @@ -238,6 +244,7 @@ static inline bt_self_component_port * bt_self_component_port_output_as_self_component_port( bt_self_component_port_output *self_component_port) + __BT_NOEXCEPT { return __BT_UPCAST(bt_self_component_port, self_component_port); } diff --git a/include/babeltrace2/graph/self-component.h b/include/babeltrace2/graph/self-component.h index f37346d1..77e299af 100644 --- a/include/babeltrace2/graph/self-component.h +++ b/include/babeltrace2/graph/self-component.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_GRAPH_SELF_COMPONENT_H #define BABELTRACE2_GRAPH_SELF_COMPONENT_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -184,7 +186,8 @@ extern bt_self_component_add_port_status bt_self_component_source_add_output_port( bt_self_component_source *self_component, const char *name, void *user_data, - bt_self_component_port_output **self_component_port); + bt_self_component_port_output **self_component_port) + __BT_NOEXCEPT; /*! @brief @@ -228,7 +231,8 @@ extern bt_self_component_add_port_status bt_self_component_filter_add_input_port( bt_self_component_filter *self_component, const char *name, void *user_data, - bt_self_component_port_input **self_component_port); + bt_self_component_port_input **self_component_port) + __BT_NOEXCEPT; /*! @brief @@ -272,7 +276,8 @@ extern bt_self_component_add_port_status bt_self_component_filter_add_output_port( bt_self_component_filter *self_component, const char *name, void *user_data, - bt_self_component_port_output **self_component_port); + bt_self_component_port_output **self_component_port) + __BT_NOEXCEPT; /*! @brief @@ -317,7 +322,8 @@ extern bt_self_component_add_port_status bt_self_component_sink_add_input_port( bt_self_component_sink *self_component, const char *name, void *user_data, - bt_self_component_port_input **self_component_port); + bt_self_component_port_input **self_component_port) + __BT_NOEXCEPT; /*! @} */ @@ -357,7 +363,7 @@ bt_self_component_sink_add_input_port( extern bt_self_component_port_output * bt_self_component_source_borrow_output_port_by_index( bt_self_component_source *self_component, - uint64_t index); + uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -390,7 +396,7 @@ bt_self_component_source_borrow_output_port_by_index( extern bt_self_component_port_input * bt_self_component_filter_borrow_input_port_by_index( bt_self_component_filter *self_component, - uint64_t index); + uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -423,7 +429,7 @@ bt_self_component_filter_borrow_input_port_by_index( extern bt_self_component_port_output * bt_self_component_filter_borrow_output_port_by_index( bt_self_component_filter *self_component, - uint64_t index); + uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -455,7 +461,8 @@ bt_self_component_filter_borrow_output_port_by_index( */ extern bt_self_component_port_input * bt_self_component_sink_borrow_input_port_by_index( - bt_self_component_sink *self_component, uint64_t index); + bt_self_component_sink *self_component, uint64_t index) + __BT_NOEXCEPT; /*! @brief @@ -485,7 +492,7 @@ function returns \c NULL. extern bt_self_component_port_output * bt_self_component_source_borrow_output_port_by_name( bt_self_component_source *self_component, - const char *name); + const char *name) __BT_NOEXCEPT; /*! @brief @@ -515,7 +522,7 @@ function returns \c NULL. extern bt_self_component_port_input * bt_self_component_filter_borrow_input_port_by_name( bt_self_component_filter *self_component, - const char *name); + const char *name) __BT_NOEXCEPT; /*! @brief @@ -545,7 +552,7 @@ function returns \c NULL. extern bt_self_component_port_output * bt_self_component_filter_borrow_output_port_by_name( bt_self_component_filter *self_component, - const char *name); + const char *name) __BT_NOEXCEPT; /*! @brief @@ -575,7 +582,7 @@ function returns \c NULL. extern bt_self_component_port_input * bt_self_component_sink_borrow_input_port_by_name( bt_self_component_sink *self_component, - const char *name); + const char *name) __BT_NOEXCEPT; /*! @} */ @@ -600,7 +607,8 @@ bt_self_component_sink_borrow_input_port_by_name( Returns the user data of a component. */ extern void bt_self_component_set_data( - bt_self_component *self_component, void *user_data); + bt_self_component *self_component, void *user_data) + __BT_NOEXCEPT; /*! @brief @@ -618,7 +626,7 @@ extern void bt_self_component_set_data( Sets the user data of a component. */ extern void *bt_self_component_get_data( - const bt_self_component *self_component); + const bt_self_component *self_component) __BT_NOEXCEPT; /*! @} */ @@ -647,7 +655,7 @@ extern void *bt_self_component_get_data( */ extern uint64_t bt_self_component_get_graph_mip_version( - bt_self_component *self_component); + bt_self_component *self_component) __BT_NOEXCEPT; /*! @} */ @@ -677,7 +685,7 @@ uint64_t bt_self_component_get_graph_mip_version( Adds an interrupter to a graph. */ extern bt_bool bt_self_component_sink_is_interrupted( - const bt_self_component_sink *self_component); + const bt_self_component_sink *self_component) __BT_NOEXCEPT; /*! @} */ @@ -703,7 +711,7 @@ extern bt_bool bt_self_component_sink_is_interrupted( */ static inline const bt_component *bt_self_component_as_component( - bt_self_component *self_component) + bt_self_component *self_component) __BT_NOEXCEPT { return __BT_UPCAST(bt_component, self_component); } @@ -727,7 +735,7 @@ const bt_component *bt_self_component_as_component( static inline const bt_component_source * bt_self_component_source_as_component_source( - bt_self_component_source *self_component) + bt_self_component_source *self_component) __BT_NOEXCEPT { return __BT_UPCAST_CONST(bt_component_source, self_component); } @@ -751,7 +759,7 @@ bt_self_component_source_as_component_source( static inline const bt_component_filter * bt_self_component_filter_as_component_filter( - bt_self_component_filter *self_component) + bt_self_component_filter *self_component) __BT_NOEXCEPT { return __BT_UPCAST_CONST(bt_component_filter, self_component); } @@ -775,7 +783,7 @@ bt_self_component_filter_as_component_filter( static inline const bt_component_sink * bt_self_component_sink_as_component_sink( - bt_self_component_sink *self_component) + bt_self_component_sink *self_component) __BT_NOEXCEPT { return __BT_UPCAST_CONST(bt_component_sink, self_component); } @@ -805,7 +813,7 @@ bt_self_component_sink_as_component_sink( */ static inline bt_self_component *bt_self_component_source_as_self_component( - bt_self_component_source *self_component) + bt_self_component_source *self_component) __BT_NOEXCEPT { return __BT_UPCAST(bt_self_component, self_component); } @@ -828,7 +836,7 @@ bt_self_component *bt_self_component_source_as_self_component( */ static inline bt_self_component *bt_self_component_filter_as_self_component( - bt_self_component_filter *self_component) + bt_self_component_filter *self_component) __BT_NOEXCEPT { return __BT_UPCAST(bt_self_component, self_component); } @@ -851,7 +859,7 @@ bt_self_component *bt_self_component_filter_as_self_component( */ static inline bt_self_component *bt_self_component_sink_as_self_component( - bt_self_component_sink *self_component) + bt_self_component_sink *self_component) __BT_NOEXCEPT { return __BT_UPCAST(bt_self_component, self_component); } diff --git a/include/babeltrace2/graph/self-message-iterator.h b/include/babeltrace2/graph/self-message-iterator.h index 452f33a9..556a172f 100644 --- a/include/babeltrace2/graph/self-message-iterator.h +++ b/include/babeltrace2/graph/self-message-iterator.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_GRAPH_SELF_MESSAGE_ITERATOR_H #define BABELTRACE2_GRAPH_SELF_MESSAGE_ITERATOR_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -83,7 +85,7 @@ bt_self_message_iterator_configuration_set_can_seek_forward(). */ extern bt_self_component * bt_self_message_iterator_borrow_component( - bt_self_message_iterator *self_message_iterator); + bt_self_message_iterator *self_message_iterator) __BT_NOEXCEPT; /*! @} */ @@ -107,7 +109,8 @@ bt_self_message_iterator_borrow_component( */ extern bt_self_component_port_output * bt_self_message_iterator_borrow_port( - bt_self_message_iterator *self_message_iterator); + bt_self_message_iterator *self_message_iterator) + __BT_NOEXCEPT; /*! @} */ @@ -133,7 +136,7 @@ bt_self_message_iterator_borrow_port( */ extern void bt_self_message_iterator_set_data( bt_self_message_iterator *self_message_iterator, - void *user_data); + void *user_data) __BT_NOEXCEPT; /*! @brief @@ -153,7 +156,8 @@ extern void bt_self_message_iterator_set_data( */ extern void *bt_self_message_iterator_get_data( - const bt_self_message_iterator *self_message_iterator); + const bt_self_message_iterator *self_message_iterator) + __BT_NOEXCEPT; /*! @} */ @@ -183,7 +187,8 @@ void *bt_self_message_iterator_get_data( Adds an interrupter to a graph. */ extern bt_bool bt_self_message_iterator_is_interrupted( - const bt_self_message_iterator *self_message_iterator); + const bt_self_message_iterator *self_message_iterator) + __BT_NOEXCEPT; /*! @} */ @@ -219,7 +224,7 @@ message sequence have some \bt_cs. */ extern void bt_self_message_iterator_configuration_set_can_seek_forward( bt_self_message_iterator_configuration *configuration, - bt_bool can_seek_forward); + bt_bool can_seek_forward) __BT_NOEXCEPT; /*! @} */ diff --git a/include/babeltrace2/integer-range-set.h b/include/babeltrace2/integer-range-set.h index 7e87fe9d..d3aff20e 100644 --- a/include/babeltrace2/integer-range-set.h +++ b/include/babeltrace2/integer-range-set.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_INTEGER_RANGE_SET_H #define BABELTRACE2_INTEGER_RANGE_SET_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -147,7 +149,7 @@ The returned lower value is included in \bt_p{int_range}. @bt_pre_is_bool_val{int_range} */ extern uint64_t bt_integer_range_unsigned_get_lower( - const bt_integer_range_unsigned *int_range); + const bt_integer_range_unsigned *int_range) __BT_NOEXCEPT; /*! @brief @@ -166,7 +168,7 @@ The returned upper value is included in \bt_p{int_range}. @bt_pre_is_bool_val{int_range} */ extern uint64_t bt_integer_range_unsigned_get_upper( - const bt_integer_range_unsigned *int_range); + const bt_integer_range_unsigned *int_range) __BT_NOEXCEPT; /*! @brief @@ -190,7 +192,7 @@ lower and upper values. */ extern bt_bool bt_integer_range_unsigned_is_equal( const bt_integer_range_unsigned *a_int_range, - const bt_integer_range_unsigned *b_int_range); + const bt_integer_range_unsigned *b_int_range) __BT_NOEXCEPT; /*! @} */ @@ -216,7 +218,7 @@ The returned lower value is included in \bt_p{int_range}. @bt_pre_is_bool_val{int_range} */ extern int64_t bt_integer_range_signed_get_lower( - const bt_integer_range_signed *int_range); + const bt_integer_range_signed *int_range) __BT_NOEXCEPT; /*! @brief @@ -235,7 +237,7 @@ The returned upper value is included in \bt_p{int_range}. @bt_pre_is_bool_val{int_range} */ extern int64_t bt_integer_range_signed_get_upper( - const bt_integer_range_signed *int_range); + const bt_integer_range_signed *int_range) __BT_NOEXCEPT; /*! @brief @@ -259,7 +261,7 @@ lower and upper values. */ extern bt_bool bt_integer_range_signed_is_equal( const bt_integer_range_signed *a_int_range, - const bt_integer_range_signed *b_int_range); + const bt_integer_range_signed *b_int_range) __BT_NOEXCEPT; /*! @} */ @@ -309,7 +311,7 @@ typedef enum bt_integer_range_set_add_range_status { @bt_pre_not_null{int_range_set} */ extern uint64_t bt_integer_range_set_get_range_count( - const bt_integer_range_set *int_range_set); + const bt_integer_range_set *int_range_set) __BT_NOEXCEPT; /*! @} */ @@ -325,7 +327,8 @@ extern uint64_t bt_integer_range_set_get_range_count( @returns New unsigned integer range set, or \c NULL on memory error. */ -extern bt_integer_range_set_unsigned *bt_integer_range_set_unsigned_create(void); +extern bt_integer_range_set_unsigned *bt_integer_range_set_unsigned_create( + void) __BT_NOEXCEPT; /*! @brief @@ -360,7 +363,7 @@ integer range to add to \bt_p{int_range_set}. extern bt_integer_range_set_add_range_status bt_integer_range_set_unsigned_add_range( bt_integer_range_set_unsigned *int_range_set, - uint64_t lower, uint64_t upper); + uint64_t lower, uint64_t upper) __BT_NOEXCEPT; /*! @brief @@ -392,7 +395,7 @@ bt_integer_range_set_unsigned_add_range( extern const bt_integer_range_unsigned * bt_integer_range_set_unsigned_borrow_range_by_index_const( const bt_integer_range_set_unsigned *int_range_set, - uint64_t index); + uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -418,7 +421,8 @@ is \em not equal to an unsigned integer range containing [2, 15]. */ extern bt_bool bt_integer_range_set_unsigned_is_equal( const bt_integer_range_set_unsigned *int_range_set_a, - const bt_integer_range_set_unsigned *int_range_set_b); + const bt_integer_range_set_unsigned *int_range_set_b) + __BT_NOEXCEPT; /*! @brief @@ -438,6 +442,7 @@ extern bt_bool bt_integer_range_set_unsigned_is_equal( static inline const bt_integer_range_set *bt_integer_range_set_unsigned_as_range_set_const( const bt_integer_range_set_unsigned *int_range_set) + __BT_NOEXCEPT { return __BT_UPCAST_CONST(bt_integer_range_set, int_range_set); } @@ -459,7 +464,8 @@ const bt_integer_range_set *bt_integer_range_set_unsigned_as_range_set_const( Decrements the reference count of an unsigned integer range set. */ extern void bt_integer_range_set_unsigned_get_ref( - const bt_integer_range_set_unsigned *int_range_set); + const bt_integer_range_set_unsigned *int_range_set) + __BT_NOEXCEPT; /*! @brief @@ -478,7 +484,8 @@ extern void bt_integer_range_set_unsigned_get_ref( Increments the reference count of an unsigned integer range set. */ extern void bt_integer_range_set_unsigned_put_ref( - const bt_integer_range_set_unsigned *int_range_set); + const bt_integer_range_set_unsigned *int_range_set) + __BT_NOEXCEPT; /*! @brief @@ -549,7 +556,8 @@ the existing \bt_p{_dst} reference. @returns New signed integer range set, or \c NULL on memory error. */ -extern bt_integer_range_set_signed *bt_integer_range_set_signed_create(void); +extern bt_integer_range_set_signed *bt_integer_range_set_signed_create( + void) __BT_NOEXCEPT; /*! @brief @@ -584,7 +592,7 @@ integer range to add to \bt_p{int_range_set}. extern bt_integer_range_set_add_range_status bt_integer_range_set_signed_add_range( bt_integer_range_set_signed *int_range_set, - int64_t lower, int64_t upper); + int64_t lower, int64_t upper) __BT_NOEXCEPT; /*! @brief @@ -615,7 +623,8 @@ bt_integer_range_set_signed_add_range( */ extern const bt_integer_range_signed * bt_integer_range_set_signed_borrow_range_by_index_const( - const bt_integer_range_set_signed *int_range_set, uint64_t index); + const bt_integer_range_set_signed *int_range_set, + uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -641,7 +650,8 @@ is \em not equal to a signed integer range containing [−57, 42]. */ extern bt_bool bt_integer_range_set_signed_is_equal( const bt_integer_range_set_signed *int_range_set_a, - const bt_integer_range_set_signed *int_range_set_b); + const bt_integer_range_set_signed *int_range_set_b) + __BT_NOEXCEPT; /*! @brief @@ -661,6 +671,7 @@ extern bt_bool bt_integer_range_set_signed_is_equal( static inline const bt_integer_range_set *bt_integer_range_set_signed_as_range_set_const( const bt_integer_range_set_signed *int_range_set) + __BT_NOEXCEPT { return __BT_UPCAST_CONST(bt_integer_range_set, int_range_set); } @@ -682,7 +693,7 @@ const bt_integer_range_set *bt_integer_range_set_signed_as_range_set_const( Decrements the reference count of a signed integer range set. */ extern void bt_integer_range_set_signed_get_ref( - const bt_integer_range_set_signed *int_range_set); + const bt_integer_range_set_signed *int_range_set) __BT_NOEXCEPT; /*! @brief @@ -701,7 +712,7 @@ extern void bt_integer_range_set_signed_get_ref( Increments the reference count of a signed integer range set. */ extern void bt_integer_range_set_signed_put_ref( - const bt_integer_range_set_signed *int_range_set); + const bt_integer_range_set_signed *int_range_set) __BT_NOEXCEPT; /*! @brief diff --git a/include/babeltrace2/logging-defs.h b/include/babeltrace2/logging-defs.h index acb75303..884957ef 100644 --- a/include/babeltrace2/logging-defs.h +++ b/include/babeltrace2/logging-defs.h @@ -9,6 +9,8 @@ * times. */ +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif diff --git a/include/babeltrace2/logging.h b/include/babeltrace2/logging.h index 2b5da45c..14660186 100644 --- a/include/babeltrace2/logging.h +++ b/include/babeltrace2/logging.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_LOGGING_H #define BABELTRACE2_LOGGING_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -187,7 +189,8 @@ individual components and query operations. @sa bt_logging_get_global_level() — Returns the current library's global logging level. */ -extern void bt_logging_set_global_level(bt_logging_level logging_level); +extern void bt_logging_set_global_level(bt_logging_level logging_level) + __BT_NOEXCEPT; /*! @brief @@ -199,7 +202,7 @@ extern void bt_logging_set_global_level(bt_logging_level logging_level); @sa bt_logging_set_global_level() — Sets the current library's global logging level. */ -extern bt_logging_level bt_logging_get_global_level(void); +extern bt_logging_level bt_logging_get_global_level(void) __BT_NOEXCEPT; /*! @brief @@ -218,7 +221,7 @@ are not built. @sa bt_logging_get_global_level() — Returns the current library's global logging level. */ -extern bt_logging_level bt_logging_get_minimal_level(void); +extern bt_logging_level bt_logging_get_minimal_level(void) __BT_NOEXCEPT; /*! @} */ diff --git a/include/babeltrace2/plugin/plugin-dev.h b/include/babeltrace2/plugin/plugin-dev.h index 1c8d0154..42420d8e 100644 --- a/include/babeltrace2/plugin/plugin-dev.h +++ b/include/babeltrace2/plugin/plugin-dev.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_PLUGIN_PLUGIN_DEV_H #define BABELTRACE2_PLUGIN_PLUGIN_DEV_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -28,6 +30,15 @@ #define _BT_HIDDEN __attribute__((visibility("hidden"))) #endif +/* + * _BT_EXPORT: set the visibility for exported functions. + */ +#if defined(_WIN32) || defined(__CYGWIN__) +#define _BT_EXPORT +#else +#define _BT_EXPORT __attribute__((visibility("default"))) +#endif + #ifdef __cplusplus extern "C" { #endif @@ -316,8 +327,8 @@ BT_PLUGIN_SOURCE_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID(my_plugin_id, @brief Defines a plugin module. -In a plugin define C file, you must use this macro before you use any -other BT_PLUGIN*() macro. +In a plugin definition C file, you must use this macro before you use +any other BT_PLUGIN*() macro. */ #define BT_PLUGIN_MODULE() \ static struct __bt_plugin_descriptor const * const __bt_plugin_descriptor_dummy __BT_PLUGIN_DESCRIPTOR_ATTRS = NULL; \ @@ -336,35 +347,35 @@ other BT_PLUGIN*() macro. _BT_HIDDEN extern struct __bt_plugin_component_class_descriptor_attribute const *__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_EXTRA; \ _BT_HIDDEN extern struct __bt_plugin_component_class_descriptor_attribute const *__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_SYMBOL __BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_EXTRA; \ \ - struct __bt_plugin_descriptor const * const *__bt_get_begin_section_plugin_descriptors(void) \ + _BT_EXPORT struct __bt_plugin_descriptor const * const *__bt_get_begin_section_plugin_descriptors(void) \ { \ return &__BT_PLUGIN_DESCRIPTOR_BEGIN_SYMBOL; \ } \ - struct __bt_plugin_descriptor const * const *__bt_get_end_section_plugin_descriptors(void) \ + _BT_EXPORT struct __bt_plugin_descriptor const * const *__bt_get_end_section_plugin_descriptors(void) \ { \ return &__BT_PLUGIN_DESCRIPTOR_END_SYMBOL; \ } \ - struct __bt_plugin_descriptor_attribute const * const *__bt_get_begin_section_plugin_descriptor_attributes(void) \ + _BT_EXPORT struct __bt_plugin_descriptor_attribute const * const *__bt_get_begin_section_plugin_descriptor_attributes(void) \ { \ return &__BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL; \ } \ - struct __bt_plugin_descriptor_attribute const * const *__bt_get_end_section_plugin_descriptor_attributes(void) \ + _BT_EXPORT struct __bt_plugin_descriptor_attribute const * const *__bt_get_end_section_plugin_descriptor_attributes(void) \ { \ return &__BT_PLUGIN_DESCRIPTOR_ATTRIBUTES_END_SYMBOL; \ } \ - struct __bt_plugin_component_class_descriptor const * const *__bt_get_begin_section_component_class_descriptors(void) \ + _BT_EXPORT struct __bt_plugin_component_class_descriptor const * const *__bt_get_begin_section_component_class_descriptors(void) \ { \ return &__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_BEGIN_SYMBOL; \ } \ - struct __bt_plugin_component_class_descriptor const * const *__bt_get_end_section_component_class_descriptors(void) \ + _BT_EXPORT struct __bt_plugin_component_class_descriptor const * const *__bt_get_end_section_component_class_descriptors(void) \ { \ return &__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_END_SYMBOL; \ } \ - struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_begin_section_component_class_descriptor_attributes(void) \ + _BT_EXPORT struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_begin_section_component_class_descriptor_attributes(void) \ { \ return &__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_BEGIN_SYMBOL; \ } \ - struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_end_section_component_class_descriptor_attributes(void) \ + _BT_EXPORT struct __bt_plugin_component_class_descriptor_attribute const * const *__bt_get_end_section_component_class_descriptor_attributes(void) \ { \ return &__BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTES_END_SYMBOL; \ } diff --git a/include/babeltrace2/plugin/plugin-loading.h b/include/babeltrace2/plugin/plugin-loading.h index b3836436..9bb598a0 100644 --- a/include/babeltrace2/plugin/plugin-loading.h +++ b/include/babeltrace2/plugin/plugin-loading.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_PLUGIN_PLUGIN_LOADING_H #define BABELTRACE2_PLUGIN_PLUGIN_LOADING_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -375,7 +377,8 @@ If this function doesn't find any plugin, it returns extern bt_plugin_find_status bt_plugin_find(const char *plugin_name, bt_bool find_in_std_env_var, bt_bool find_in_user_dir, bt_bool find_in_sys_dir, bt_bool find_in_static, - bt_bool fail_on_load_error, const bt_plugin **plugin); + bt_bool fail_on_load_error, const bt_plugin **plugin) + __BT_NOEXCEPT; /*! @brief @@ -499,7 +502,7 @@ If this function doesn't find any plugin, it returns bt_plugin_find_all_status bt_plugin_find_all(bt_bool find_in_std_env_var, bt_bool find_in_user_dir, bt_bool find_in_sys_dir, bt_bool find_in_static, bt_bool fail_on_load_error, - const bt_plugin_set **plugins); + const bt_plugin_set **plugins) __BT_NOEXCEPT; /*! @brief @@ -586,7 +589,7 @@ If this function doesn't find any plugin, it returns */ extern bt_plugin_find_all_from_file_status bt_plugin_find_all_from_file( const char *path, bt_bool fail_on_load_error, - const bt_plugin_set **plugins); + const bt_plugin_set **plugins) __BT_NOEXCEPT; /*! @brief @@ -681,7 +684,7 @@ If this function doesn't find any plugin, it returns */ extern bt_plugin_find_all_from_dir_status bt_plugin_find_all_from_dir( const char *path, bt_bool recurse, bt_bool fail_on_load_error, - const bt_plugin_set **plugins); + const bt_plugin_set **plugins) __BT_NOEXCEPT; /*! @brief @@ -757,7 +760,8 @@ If this function doesn't find any plugin, it returns @bt_pre_not_null{plugins} */ extern bt_plugin_find_all_from_static_status bt_plugin_find_all_from_static( - bt_bool fail_on_load_error, const bt_plugin_set **plugins); + bt_bool fail_on_load_error, const bt_plugin_set **plugins) + __BT_NOEXCEPT; /*! @} */ @@ -784,7 +788,7 @@ See the \ref api-plugin-prop-name "name" property. @bt_pre_not_null{plugin} */ -extern const char *bt_plugin_get_name(const bt_plugin *plugin); +extern const char *bt_plugin_get_name(const bt_plugin *plugin) __BT_NOEXCEPT; /*! @brief @@ -804,7 +808,8 @@ See the \ref api-plugin-prop-descr "description" property. @bt_pre_not_null{plugin} */ -extern const char *bt_plugin_get_description(const bt_plugin *plugin); +extern const char *bt_plugin_get_description(const bt_plugin *plugin) + __BT_NOEXCEPT; /*! @brief @@ -824,7 +829,7 @@ See the \ref api-plugin-prop-author "author name(s)" property. @bt_pre_not_null{plugin} */ -extern const char *bt_plugin_get_author(const bt_plugin *plugin); +extern const char *bt_plugin_get_author(const bt_plugin *plugin) __BT_NOEXCEPT; /*! @brief @@ -845,7 +850,7 @@ See the \ref api-plugin-prop-license "license" property. @bt_pre_not_null{plugin} */ -extern const char *bt_plugin_get_license(const bt_plugin *plugin); +extern const char *bt_plugin_get_license(const bt_plugin *plugin) __BT_NOEXCEPT; /*! @brief @@ -870,7 +875,7 @@ because a static plugin has no path property. @bt_pre_not_null{plugin} */ -extern const char *bt_plugin_get_path(const bt_plugin *plugin); +extern const char *bt_plugin_get_path(const bt_plugin *plugin) __BT_NOEXCEPT; /*! @brief @@ -913,7 +918,8 @@ See the \ref api-plugin-prop-version "version" property. */ extern bt_property_availability bt_plugin_get_version( const bt_plugin *plugin, unsigned int *major, - unsigned int *minor, unsigned int *patch, const char **extra); + unsigned int *minor, unsigned int *patch, const char **extra) + __BT_NOEXCEPT; /*! @} */ @@ -937,7 +943,7 @@ extern bt_property_availability bt_plugin_get_version( @bt_pre_not_null{plugin} */ extern uint64_t bt_plugin_get_source_component_class_count( - const bt_plugin *plugin); + const bt_plugin *plugin) __BT_NOEXCEPT; /*! @brief @@ -954,7 +960,7 @@ extern uint64_t bt_plugin_get_source_component_class_count( @bt_pre_not_null{plugin} */ extern uint64_t bt_plugin_get_filter_component_class_count( - const bt_plugin *plugin); + const bt_plugin *plugin) __BT_NOEXCEPT; /*! @brief @@ -971,7 +977,7 @@ extern uint64_t bt_plugin_get_filter_component_class_count( @bt_pre_not_null{plugin} */ extern uint64_t bt_plugin_get_sink_component_class_count( - const bt_plugin *plugin); + const bt_plugin *plugin) __BT_NOEXCEPT; /*! @brief @@ -1003,7 +1009,7 @@ extern uint64_t bt_plugin_get_sink_component_class_count( */ extern const bt_component_class_source * bt_plugin_borrow_source_component_class_by_index_const( - const bt_plugin *plugin, uint64_t index); + const bt_plugin *plugin, uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -1035,7 +1041,7 @@ bt_plugin_borrow_source_component_class_by_index_const( */ extern const bt_component_class_filter * bt_plugin_borrow_filter_component_class_by_index_const( - const bt_plugin *plugin, uint64_t index); + const bt_plugin *plugin, uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -1067,7 +1073,7 @@ bt_plugin_borrow_filter_component_class_by_index_const( */ extern const bt_component_class_sink * bt_plugin_borrow_sink_component_class_by_index_const( - const bt_plugin *plugin, uint64_t index); + const bt_plugin *plugin, uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -1100,7 +1106,7 @@ If no source component class has the name \bt_p{name} within */ extern const bt_component_class_source * bt_plugin_borrow_source_component_class_by_name_const( - const bt_plugin *plugin, const char *name); + const bt_plugin *plugin, const char *name) __BT_NOEXCEPT; /*! @brief @@ -1133,7 +1139,7 @@ If no filter component class has the name \bt_p{name} within */ extern const bt_component_class_filter * bt_plugin_borrow_filter_component_class_by_name_const( - const bt_plugin *plugin, const char *name); + const bt_plugin *plugin, const char *name) __BT_NOEXCEPT; /*! @brief @@ -1166,7 +1172,7 @@ If no sink component class has the name \bt_p{name} within */ extern const bt_component_class_sink * bt_plugin_borrow_sink_component_class_by_name_const( - const bt_plugin *plugin, const char *name); + const bt_plugin *plugin, const char *name) __BT_NOEXCEPT; /*! @} */ @@ -1190,7 +1196,7 @@ bt_plugin_borrow_sink_component_class_by_name_const( @sa bt_plugin_put_ref() — Decrements the reference count of a plugin. */ -extern void bt_plugin_get_ref(const bt_plugin *plugin); +extern void bt_plugin_get_ref(const bt_plugin *plugin) __BT_NOEXCEPT; /*! @brief @@ -1207,7 +1213,7 @@ extern void bt_plugin_get_ref(const bt_plugin *plugin); @sa bt_plugin_get_ref() — Increments the reference count of a plugin. */ -extern void bt_plugin_put_ref(const bt_plugin *plugin); +extern void bt_plugin_put_ref(const bt_plugin *plugin) __BT_NOEXCEPT; /*! @brief @@ -1282,7 +1288,7 @@ This macro effectively moves a plugin reference from the expression @bt_pre_not_null{plugin} */ extern uint64_t bt_plugin_set_get_plugin_count( - const bt_plugin_set *plugin_set); + const bt_plugin_set *plugin_set) __BT_NOEXCEPT; /*! @brief @@ -1309,7 +1315,7 @@ extern uint64_t bt_plugin_set_get_plugin_count( \bt_p{plugin_set} (as returned by bt_plugin_set_get_plugin_count()). */ extern const bt_plugin *bt_plugin_set_borrow_plugin_by_index_const( - const bt_plugin_set *plugin_set, uint64_t index); + const bt_plugin_set *plugin_set, uint64_t index) __BT_NOEXCEPT; /*! @} */ @@ -1333,7 +1339,8 @@ extern const bt_plugin *bt_plugin_set_borrow_plugin_by_index_const( @sa bt_plugin_set_put_ref() — Decrements the reference count of a plugin set. */ -extern void bt_plugin_set_get_ref(const bt_plugin_set *plugin_set); +extern void bt_plugin_set_get_ref(const bt_plugin_set *plugin_set) + __BT_NOEXCEPT; /*! @brief @@ -1350,7 +1357,8 @@ extern void bt_plugin_set_get_ref(const bt_plugin_set *plugin_set); @sa bt_plugin_set_get_ref() — Increments the reference count of a plugin set. */ -extern void bt_plugin_set_put_ref(const bt_plugin_set *plugin_set); +extern void bt_plugin_set_put_ref(const bt_plugin_set *plugin_set) + __BT_NOEXCEPT; /*! @brief diff --git a/include/babeltrace2/trace-ir/clock-class.h b/include/babeltrace2/trace-ir/clock-class.h index b28a6c5e..a54e8b89 100644 --- a/include/babeltrace2/trace-ir/clock-class.h +++ b/include/babeltrace2/trace-ir/clock-class.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_TRACE_IR_CLOCK_CLASS_H #define BABELTRACE2_TRACE_IR_CLOCK_CLASS_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -324,7 +326,8 @@ On success, the returned clock class has the following property values: @bt_pre_not_null{self_component} */ -extern bt_clock_class *bt_clock_class_create(bt_self_component *self_component); +extern bt_clock_class *bt_clock_class_create(bt_self_component *self_component) + __BT_NOEXCEPT; /*! @} */ @@ -359,7 +362,7 @@ See the \ref api-tir-clock-cls-prop-freq "frequency" property. Returns the frequency of a clock class. */ extern void bt_clock_class_set_frequency(bt_clock_class *clock_class, - uint64_t frequency); + uint64_t frequency) __BT_NOEXCEPT; /*! @brief @@ -379,7 +382,7 @@ See the \ref api-tir-clock-cls-prop-freq "frequency" property. Sets the frequency of a clock class. */ extern uint64_t bt_clock_class_get_frequency( - const bt_clock_class *clock_class); + const bt_clock_class *clock_class) __BT_NOEXCEPT; /*! @brief @@ -407,7 +410,7 @@ See the \ref api-tir-clock-cls-prop-offset "offset" property. Returns the offset of a clock class. */ extern void bt_clock_class_set_offset(bt_clock_class *clock_class, - int64_t offset_seconds, uint64_t offset_cycles); + int64_t offset_seconds, uint64_t offset_cycles) __BT_NOEXCEPT; /*! @brief @@ -434,7 +437,7 @@ See the \ref api-tir-clock-cls-prop-offset "offset" property. Sets the offset of a clock class. */ extern void bt_clock_class_get_offset(const bt_clock_class *clock_class, - int64_t *offset_seconds, uint64_t *offset_cycles); + int64_t *offset_seconds, uint64_t *offset_cycles) __BT_NOEXCEPT; /*! @brief @@ -455,7 +458,7 @@ See the \ref api-tir-clock-cls-prop-precision "precision" property. Returns the precision of a clock class. */ extern void bt_clock_class_set_precision(bt_clock_class *clock_class, - uint64_t precision); + uint64_t precision) __BT_NOEXCEPT; /*! @brief @@ -476,7 +479,7 @@ See the \ref api-tir-clock-cls-prop-precision "precision" property. Sets the precision of a clock class. */ extern uint64_t bt_clock_class_get_precision( - const bt_clock_class *clock_class); + const bt_clock_class *clock_class) __BT_NOEXCEPT; /*! @brief @@ -501,7 +504,7 @@ property. Unix epoch. */ extern void bt_clock_class_set_origin_is_unix_epoch(bt_clock_class *clock_class, - bt_bool origin_is_unix_epoch); + bt_bool origin_is_unix_epoch) __BT_NOEXCEPT; /*! @brief @@ -525,7 +528,7 @@ property. Sets whether or not the origin of a clock class is the Unix epoch. */ extern bt_bool bt_clock_class_origin_is_unix_epoch( - const bt_clock_class *clock_class); + const bt_clock_class *clock_class) __BT_NOEXCEPT; /*! @brief @@ -570,7 +573,7 @@ See the \ref api-tir-clock-cls-prop-name "name" property. Returns the name of a clock class. */ extern bt_clock_class_set_name_status bt_clock_class_set_name( - bt_clock_class *clock_class, const char *name); + bt_clock_class *clock_class, const char *name) __BT_NOEXCEPT; /*! @brief @@ -597,7 +600,7 @@ If \bt_p{clock_class} has no name, this function returns \c NULL. Sets the name of a clock class. */ extern const char *bt_clock_class_get_name( - const bt_clock_class *clock_class); + const bt_clock_class *clock_class) __BT_NOEXCEPT; /*! @brief @@ -642,7 +645,8 @@ See the \ref api-tir-clock-cls-prop-descr "description" property. Returns the description of a clock class. */ extern bt_clock_class_set_description_status bt_clock_class_set_description( - bt_clock_class *clock_class, const char *description); + bt_clock_class *clock_class, const char *description) + __BT_NOEXCEPT; /*! @brief @@ -669,7 +673,7 @@ If \bt_p{clock_class} has no description, this function returns \c NULL. Sets the description of a clock class. */ extern const char *bt_clock_class_get_description( - const bt_clock_class *clock_class); + const bt_clock_class *clock_class) __BT_NOEXCEPT; /*! @brief @@ -692,7 +696,7 @@ See the \ref api-tir-clock-cls-prop-uuid "UUID" property. Returns the UUID of a clock class. */ extern void bt_clock_class_set_uuid(bt_clock_class *clock_class, - bt_uuid uuid); + bt_uuid uuid) __BT_NOEXCEPT; /*! @brief @@ -719,7 +723,7 @@ If \bt_p{clock_class} has no UUID, this function returns \c NULL. Sets the UUID of a clock class. */ extern bt_uuid bt_clock_class_get_uuid( - const bt_clock_class *clock_class); + const bt_clock_class *clock_class) __BT_NOEXCEPT; /*! @brief @@ -751,7 +755,8 @@ property. Borrows the user attributes of a clock class. */ extern void bt_clock_class_set_user_attributes( - bt_clock_class *clock_class, const bt_value *user_attributes); + bt_clock_class *clock_class, const bt_value *user_attributes) + __BT_NOEXCEPT; /*! @brief @@ -778,7 +783,7 @@ property. \c const version of this function. */ extern bt_value *bt_clock_class_borrow_user_attributes( - bt_clock_class *clock_class); + bt_clock_class *clock_class) __BT_NOEXCEPT; /*! @brief @@ -788,7 +793,7 @@ extern bt_value *bt_clock_class_borrow_user_attributes( See bt_clock_class_borrow_user_attributes(). */ extern const bt_value *bt_clock_class_borrow_user_attributes_const( - const bt_clock_class *clock_class); + const bt_clock_class *clock_class) __BT_NOEXCEPT; /*! @} */ @@ -868,7 +873,7 @@ code if any step of the computation process causes an integer overflow. extern bt_clock_class_cycles_to_ns_from_origin_status bt_clock_class_cycles_to_ns_from_origin( const bt_clock_class *clock_class, - uint64_t value, int64_t *ns_from_origin); + uint64_t value, int64_t *ns_from_origin) __BT_NOEXCEPT; /*! @} */ @@ -892,7 +897,8 @@ bt_clock_class_cycles_to_ns_from_origin( @sa bt_clock_class_put_ref() — Decrements the reference count of a clock class. */ -extern void bt_clock_class_get_ref(const bt_clock_class *clock_class); +extern void bt_clock_class_get_ref( + const bt_clock_class *clock_class) __BT_NOEXCEPT; /*! @brief @@ -909,7 +915,8 @@ extern void bt_clock_class_get_ref(const bt_clock_class *clock_class); @sa bt_clock_class_get_ref() — Increments the reference count of a clock class. */ -extern void bt_clock_class_put_ref(const bt_clock_class *clock_class); +extern void bt_clock_class_put_ref( + const bt_clock_class *clock_class) __BT_NOEXCEPT; /*! @brief diff --git a/include/babeltrace2/trace-ir/clock-snapshot.h b/include/babeltrace2/trace-ir/clock-snapshot.h index 554131c0..79bf17fc 100644 --- a/include/babeltrace2/trace-ir/clock-snapshot.h +++ b/include/babeltrace2/trace-ir/clock-snapshot.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_TRACE_IR_CLOCK_SNAPSHOT_H #define BABELTRACE2_TRACE_IR_CLOCK_SNAPSHOT_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -105,7 +107,7 @@ properties of its class. @bt_pre_not_null{clock_snapshot} */ extern const bt_clock_class *bt_clock_snapshot_borrow_clock_class_const( - const bt_clock_snapshot *clock_snapshot); + const bt_clock_snapshot *clock_snapshot) __BT_NOEXCEPT; /*! @brief @@ -125,7 +127,7 @@ extern const bt_clock_class *bt_clock_snapshot_borrow_clock_class_const( clock snapshot's value. */ extern uint64_t bt_clock_snapshot_get_value( - const bt_clock_snapshot *clock_snapshot); + const bt_clock_snapshot *clock_snapshot) __BT_NOEXCEPT; /*! @brief @@ -201,7 +203,7 @@ code if any step of the computation process causes an integer overflow. extern bt_clock_snapshot_get_ns_from_origin_status bt_clock_snapshot_get_ns_from_origin( const bt_clock_snapshot *clock_snapshot, - int64_t *ns_from_origin); + int64_t *ns_from_origin) __BT_NOEXCEPT; /*! @} */ diff --git a/include/babeltrace2/trace-ir/event-class.h b/include/babeltrace2/trace-ir/event-class.h index 845b64f1..f4e815d5 100644 --- a/include/babeltrace2/trace-ir/event-class.h +++ b/include/babeltrace2/trace-ir/event-class.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_TRACE_IR_EVENT_CLASS_H #define BABELTRACE2_TRACE_IR_EVENT_CLASS_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -257,7 +259,7 @@ On success, the returned event class has the following property values: stream class. */ extern bt_event_class *bt_event_class_create( - bt_stream_class *stream_class); + bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @brief @@ -330,7 +332,7 @@ On success, the returned event class has the following property values: stream class. */ extern bt_event_class *bt_event_class_create_with_id( - bt_stream_class *stream_class, uint64_t id); + bt_stream_class *stream_class, uint64_t id) __BT_NOEXCEPT; /*! @} */ @@ -356,7 +358,7 @@ extern bt_event_class *bt_event_class_create_with_id( \c const version of this function. */ extern bt_stream_class *bt_event_class_borrow_stream_class( - bt_event_class *event_class); + bt_event_class *event_class) __BT_NOEXCEPT; /*! @brief @@ -366,7 +368,7 @@ extern bt_stream_class *bt_event_class_borrow_stream_class( See bt_event_class_borrow_stream_class(). */ extern const bt_stream_class *bt_event_class_borrow_stream_class_const( - const bt_event_class *event_class); + const bt_event_class *event_class) __BT_NOEXCEPT; /*! @} */ @@ -393,7 +395,8 @@ See the \ref api-tir-ev-cls-prop-id "numeric ID" property. Creates an event class with a specific numeric ID and adds it to a stream class. */ -extern uint64_t bt_event_class_get_id(const bt_event_class *event_class); +extern uint64_t bt_event_class_get_id( + const bt_event_class *event_class) __BT_NOEXCEPT; /*! @brief @@ -438,7 +441,7 @@ See the \ref api-tir-ev-cls-prop-name "name" property. Returns the name of an event class. */ extern bt_event_class_set_name_status bt_event_class_set_name( - bt_event_class *event_class, const char *name); + bt_event_class *event_class, const char *name) __BT_NOEXCEPT; /*! @brief @@ -464,7 +467,8 @@ If \bt_p{event_class} has no name, this function returns \c NULL. @sa bt_event_class_set_name() — Sets the name of an event class. */ -extern const char *bt_event_class_get_name(const bt_event_class *event_class); +extern const char *bt_event_class_get_name( + const bt_event_class *event_class) __BT_NOEXCEPT; /*! @brief @@ -586,7 +590,7 @@ See the \ref api-tir-ev-cls-prop-log-lvl "log level" property. Returns the log level of an event class. */ extern void bt_event_class_set_log_level(bt_event_class *event_class, - bt_event_class_log_level log_level); + bt_event_class_log_level log_level) __BT_NOEXCEPT; /*! @brief @@ -614,7 +618,7 @@ See the \ref api-tir-ev-cls-prop-log-lvl "log level" property. */ extern bt_property_availability bt_event_class_get_log_level( const bt_event_class *event_class, - bt_event_class_log_level *log_level); + bt_event_class_log_level *log_level) __BT_NOEXCEPT; /*! @brief @@ -659,7 +663,7 @@ See the \ref api-tir-ev-cls-prop-emf-uri "EMF URI" property. Returns the EMF URI of an event class. */ extern bt_event_class_set_emf_uri_status bt_event_class_set_emf_uri( - bt_event_class *event_class, const char *emf_uri); + bt_event_class *event_class, const char *emf_uri) __BT_NOEXCEPT; /*! @brief @@ -687,7 +691,7 @@ If \bt_p{event_class} has no EMF URI, this function returns \c NULL. Sets the EMF URI of an event class. */ extern const char *bt_event_class_get_emf_uri( - const bt_event_class *event_class); + const bt_event_class *event_class) __BT_NOEXCEPT; /*! @brief @@ -749,7 +753,7 @@ See the \ref api-tir-ev-cls-prop-p-fc "payload field class" property. */ extern bt_event_class_set_field_class_status bt_event_class_set_payload_field_class(bt_event_class *event_class, - bt_field_class *field_class); + bt_field_class *field_class) __BT_NOEXCEPT; /*! @brief @@ -775,7 +779,7 @@ returns \c NULL. \c const version of this function. */ extern bt_field_class *bt_event_class_borrow_payload_field_class( - bt_event_class *event_class); + bt_event_class *event_class) __BT_NOEXCEPT; /*! @brief @@ -785,7 +789,7 @@ extern bt_field_class *bt_event_class_borrow_payload_field_class( See bt_event_class_borrow_payload_field_class(). */ extern const bt_field_class *bt_event_class_borrow_payload_field_class_const( - const bt_event_class *event_class); + const bt_event_class *event_class) __BT_NOEXCEPT; /*! @brief @@ -829,7 +833,7 @@ property. */ extern bt_event_class_set_field_class_status bt_event_class_set_specific_context_field_class(bt_event_class *event_class, - bt_field_class *field_class); + bt_field_class *field_class) __BT_NOEXCEPT; /*! @brief @@ -857,7 +861,8 @@ returns \c NULL. \c const version of this function. */ extern bt_field_class * -bt_event_class_borrow_specific_context_field_class(bt_event_class *event_class); +bt_event_class_borrow_specific_context_field_class( + bt_event_class *event_class) __BT_NOEXCEPT; /*! @brief @@ -868,7 +873,7 @@ See bt_event_class_borrow_specific_context_field_class(). */ extern const bt_field_class * bt_event_class_borrow_specific_context_field_class_const( - const bt_event_class *event_class); + const bt_event_class *event_class) __BT_NOEXCEPT; /*! @brief @@ -899,7 +904,8 @@ See the \ref api-tir-ev-cls-prop-user-attrs "user attributes" property. Borrows the user attributes of an event class. */ extern void bt_event_class_set_user_attributes( - bt_event_class *event_class, const bt_value *user_attributes); + bt_event_class *event_class, const bt_value *user_attributes) + __BT_NOEXCEPT; /*! @brief @@ -926,7 +932,7 @@ See the \ref api-tir-ev-cls-prop-user-attrs "user attributes" property. \c const version of this function. */ extern bt_value *bt_event_class_borrow_user_attributes( - bt_event_class *event_class); + bt_event_class *event_class) __BT_NOEXCEPT; /*! @brief @@ -936,7 +942,7 @@ extern bt_value *bt_event_class_borrow_user_attributes( See bt_event_class_borrow_user_attributes(). */ extern const bt_value *bt_event_class_borrow_user_attributes_const( - const bt_event_class *event_class); + const bt_event_class *event_class) __BT_NOEXCEPT; /*! @} */ @@ -960,7 +966,8 @@ extern const bt_value *bt_event_class_borrow_user_attributes_const( @sa bt_event_class_put_ref() — Decrements the reference count of an event class. */ -extern void bt_event_class_get_ref(const bt_event_class *event_class); +extern void bt_event_class_get_ref( + const bt_event_class *event_class) __BT_NOEXCEPT; /*! @brief @@ -977,7 +984,8 @@ extern void bt_event_class_get_ref(const bt_event_class *event_class); @sa bt_event_class_get_ref() — Increments the reference count of an event class. */ -extern void bt_event_class_put_ref(const bt_event_class *event_class); +extern void bt_event_class_put_ref( + const bt_event_class *event_class) __BT_NOEXCEPT; /*! @brief diff --git a/include/babeltrace2/trace-ir/event.h b/include/babeltrace2/trace-ir/event.h index 474f0c9c..bcb2af3d 100644 --- a/include/babeltrace2/trace-ir/event.h +++ b/include/babeltrace2/trace-ir/event.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_TRACE_IR_EVENT_H #define BABELTRACE2_TRACE_IR_EVENT_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -167,7 +169,7 @@ An event has the following properties: @sa bt_event_borrow_class_const() — \c const version of this function. */ -extern bt_event_class *bt_event_borrow_class(bt_event *event); +extern bt_event_class *bt_event_borrow_class(bt_event *event) __BT_NOEXCEPT; /*! @brief @@ -177,7 +179,7 @@ extern bt_event_class *bt_event_borrow_class(bt_event *event); See bt_event_borrow_class(). */ extern const bt_event_class *bt_event_borrow_class_const( - const bt_event *event); + const bt_event *event) __BT_NOEXCEPT; /*! @} */ @@ -203,7 +205,7 @@ extern const bt_event_class *bt_event_borrow_class_const( @sa bt_event_borrow_stream_const() — \c const version of this function. */ -extern bt_stream *bt_event_borrow_stream(bt_event *event); +extern bt_stream *bt_event_borrow_stream(bt_event *event) __BT_NOEXCEPT; /*! @brief @@ -213,7 +215,7 @@ extern bt_stream *bt_event_borrow_stream(bt_event *event); See bt_event_borrow_stream(). */ extern const bt_stream *bt_event_borrow_stream_const( - const bt_event *event); + const bt_event *event) __BT_NOEXCEPT; /*! @} */ @@ -243,7 +245,7 @@ extern const bt_stream *bt_event_borrow_stream_const( @sa bt_event_borrow_packet_const() — \c const version of this function. */ -extern bt_packet *bt_event_borrow_packet(bt_event *event); +extern bt_packet *bt_event_borrow_packet(bt_event *event) __BT_NOEXCEPT; /*! @brief @@ -253,7 +255,7 @@ extern bt_packet *bt_event_borrow_packet(bt_event *event); See bt_event_borrow_packet(). */ extern const bt_packet *bt_event_borrow_packet_const( - const bt_event *event); + const bt_event *event) __BT_NOEXCEPT; /*! @} */ @@ -280,7 +282,7 @@ See the \ref api-tir-ev-prop-payload "payload field" property. @sa bt_event_borrow_payload_field_const() — \c const version of this function. */ -extern bt_field *bt_event_borrow_payload_field(bt_event *event); +extern bt_field *bt_event_borrow_payload_field(bt_event *event) __BT_NOEXCEPT; /*! @brief @@ -290,7 +292,7 @@ extern bt_field *bt_event_borrow_payload_field(bt_event *event); See bt_event_borrow_payload_field(). */ extern const bt_field *bt_event_borrow_payload_field_const( - const bt_event *event); + const bt_event *event) __BT_NOEXCEPT; /*! @brief @@ -311,7 +313,7 @@ See the \ref api-tir-ev-prop-spec-ctx "specific context field" property. \c const version of this function. */ extern bt_field * -bt_event_borrow_specific_context_field(bt_event *event); +bt_event_borrow_specific_context_field(bt_event *event) __BT_NOEXCEPT; /*! @brief @@ -321,7 +323,7 @@ bt_event_borrow_specific_context_field(bt_event *event); See bt_event_borrow_specific_context_field(). */ extern const bt_field *bt_event_borrow_specific_context_field_const( - const bt_event *event); + const bt_event *event) __BT_NOEXCEPT; /*! @brief @@ -342,7 +344,7 @@ See the \ref api-tir-ev-prop-common-ctx "common context field" property. \c const version of this function. */ extern bt_field * -bt_event_borrow_common_context_field(bt_event *event); +bt_event_borrow_common_context_field(bt_event *event) __BT_NOEXCEPT; /*! @brief @@ -352,7 +354,7 @@ bt_event_borrow_common_context_field(bt_event *event); See bt_event_borrow_common_context_field(). */ extern const bt_field *bt_event_borrow_common_context_field_const( - const bt_event *event); + const bt_event *event) __BT_NOEXCEPT; /*! @} */ diff --git a/include/babeltrace2/trace-ir/field-class.h b/include/babeltrace2/trace-ir/field-class.h index 4d862482..fdd20995 100644 --- a/include/babeltrace2/trace-ir/field-class.h +++ b/include/babeltrace2/trace-ir/field-class.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_TRACE_IR_FIELD_CLASS_H #define BABELTRACE2_TRACE_IR_FIELD_CLASS_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -1495,7 +1497,7 @@ typedef enum bt_field_class_type { given type. */ extern bt_field_class_type bt_field_class_get_type( - const bt_field_class *field_class); + const bt_field_class *field_class) __BT_NOEXCEPT; /*! @brief @@ -1524,7 +1526,7 @@ returns #BT_TRUE. */ static inline bt_bool bt_field_class_type_is(const bt_field_class_type type, - const bt_field_class_type other_type) + const bt_field_class_type other_type) __BT_NOEXCEPT { return (type & other_type) == other_type; } @@ -1565,7 +1567,8 @@ See the \ref api-tir-fc-prop-user-attrs "user attributes" property. Borrows the user attributes of a field class. */ extern void bt_field_class_set_user_attributes( - bt_field_class *field_class, const bt_value *user_attributes); + bt_field_class *field_class, + const bt_value *user_attributes) __BT_NOEXCEPT; /*! @brief @@ -1592,7 +1595,7 @@ See the \ref api-tir-fc-prop-user-attrs "user attributes" property. \c const version of this function. */ extern bt_value *bt_field_class_borrow_user_attributes( - bt_field_class *field_class); + bt_field_class *field_class) __BT_NOEXCEPT; /*! @brief @@ -1602,7 +1605,7 @@ extern bt_value *bt_field_class_borrow_user_attributes( See bt_field_class_borrow_user_attributes(). */ extern const bt_value *bt_field_class_borrow_user_attributes_const( - const bt_field_class *field_class); + const bt_field_class *field_class) __BT_NOEXCEPT; /*! @} */ @@ -1636,7 +1639,7 @@ property value: @bt_pre_not_null{trace_class} */ extern bt_field_class *bt_field_class_bool_create( - bt_trace_class *trace_class); + bt_trace_class *trace_class) __BT_NOEXCEPT; /*! @} @@ -1681,7 +1684,7 @@ property values: 0 < \bt_p{length} ≤ 64. */ extern bt_field_class *bt_field_class_bit_array_create( - bt_trace_class *trace_class, uint64_t length); + bt_trace_class *trace_class, uint64_t length) __BT_NOEXCEPT; /*! @brief @@ -1699,7 +1702,7 @@ See the \ref api-tir-fc-ba-prop-len "length" property. @bt_pre_is_ba_fc{field_class} */ extern uint64_t bt_field_class_bit_array_get_length( - const bt_field_class *field_class); + const bt_field_class *field_class) __BT_NOEXCEPT; /*! @} @@ -1743,7 +1746,7 @@ See the \ref api-tir-fc-int-prop-size "field value range" property. Returns the field value range of an integer field class. */ extern void bt_field_class_integer_set_field_value_range( - bt_field_class *field_class, uint64_t n); + bt_field_class *field_class, uint64_t n) __BT_NOEXCEPT; /*! @brief @@ -1774,7 +1777,7 @@ See the \ref api-tir-fc-int-prop-size "field value range" property. Sets the field value range of an integer field class. */ extern uint64_t bt_field_class_integer_get_field_value_range( - const bt_field_class *field_class); + const bt_field_class *field_class) __BT_NOEXCEPT; /*! @brief @@ -1828,7 +1831,8 @@ See the \ref api-tir-fc-int-prop-base "preferred display base" property. */ extern void bt_field_class_integer_set_preferred_display_base( bt_field_class *field_class, - bt_field_class_integer_preferred_display_base preferred_display_base); + bt_field_class_integer_preferred_display_base preferred_display_base) + __BT_NOEXCEPT; /*! @brief @@ -1857,7 +1861,7 @@ See the \ref api-tir-fc-int-prop-base "preferred display base" property. */ extern bt_field_class_integer_preferred_display_base bt_field_class_integer_get_preferred_display_base( - const bt_field_class *field_class); + const bt_field_class *field_class) __BT_NOEXCEPT; /*! @} */ @@ -1897,7 +1901,7 @@ property values: @bt_pre_not_null{trace_class} */ extern bt_field_class *bt_field_class_integer_unsigned_create( - bt_trace_class *trace_class); + bt_trace_class *trace_class) __BT_NOEXCEPT; /*! @} */ @@ -1937,7 +1941,7 @@ property values: @bt_pre_not_null{trace_class} */ extern bt_field_class *bt_field_class_integer_signed_create( - bt_trace_class *trace_class); + bt_trace_class *trace_class) __BT_NOEXCEPT; /*! @} */ @@ -1974,7 +1978,7 @@ following property value: @bt_pre_not_null{trace_class} */ extern bt_field_class *bt_field_class_real_single_precision_create( - bt_trace_class *trace_class); + bt_trace_class *trace_class) __BT_NOEXCEPT; /*! @} */ @@ -2011,7 +2015,7 @@ following property value: @bt_pre_not_null{trace_class} */ extern bt_field_class *bt_field_class_real_double_precision_create( - bt_trace_class *trace_class); + bt_trace_class *trace_class) __BT_NOEXCEPT; /*! @} */ @@ -2101,7 +2105,7 @@ See the \ref api-tir-fc-enum-prop-mappings "mappings" property. @bt_pre_is_enum_fc{field_class} */ extern uint64_t bt_field_class_enumeration_get_mapping_count( - const bt_field_class *field_class); + const bt_field_class *field_class) __BT_NOEXCEPT; /*! @brief @@ -2122,7 +2126,8 @@ See the \ref api-tir-fc-enum-prop-mappings "mappings" property. @bt_pre_not_null{mapping} */ extern const char *bt_field_class_enumeration_mapping_get_label( - const bt_field_class_enumeration_mapping *mapping); + const bt_field_class_enumeration_mapping *mapping) + __BT_NOEXCEPT; /*! @} */ @@ -2167,7 +2172,7 @@ following property values: @bt_pre_not_null{trace_class} */ extern bt_field_class *bt_field_class_enumeration_unsigned_create( - bt_trace_class *trace_class); + bt_trace_class *trace_class) __BT_NOEXCEPT; /*! @brief @@ -2203,7 +2208,7 @@ See the \ref api-tir-fc-enum-prop-mappings "mappings" property. extern bt_field_class_enumeration_add_mapping_status bt_field_class_enumeration_unsigned_add_mapping( bt_field_class *field_class, const char *label, - const bt_integer_range_set_unsigned *ranges); + const bt_integer_range_set_unsigned *ranges) __BT_NOEXCEPT; /*! @brief @@ -2240,7 +2245,8 @@ See the \ref api-tir-fc-enum-prop-mappings "mappings" property. */ extern const bt_field_class_enumeration_unsigned_mapping * bt_field_class_enumeration_unsigned_borrow_mapping_by_index_const( - const bt_field_class *field_class, uint64_t index); + const bt_field_class *field_class, uint64_t index) + __BT_NOEXCEPT; /*! @brief @@ -2274,7 +2280,8 @@ If there's no mapping having the label \bt_p{label} in */ extern const bt_field_class_enumeration_unsigned_mapping * bt_field_class_enumeration_unsigned_borrow_mapping_by_label_const( - const bt_field_class *field_class, const char *label); + const bt_field_class *field_class, const char *label) + __BT_NOEXCEPT; /*! @brief @@ -2327,7 +2334,7 @@ extern bt_field_class_enumeration_get_mapping_labels_for_value_status bt_field_class_enumeration_unsigned_get_mapping_labels_for_value( const bt_field_class *field_class, uint64_t value, bt_field_class_enumeration_mapping_label_array *labels, - uint64_t *count); + uint64_t *count) __BT_NOEXCEPT; /*! @} */ @@ -2361,7 +2368,8 @@ See the \ref api-tir-fc-enum-prop-mappings "mappings" property. */ extern const bt_integer_range_set_unsigned * bt_field_class_enumeration_unsigned_mapping_borrow_ranges_const( - const bt_field_class_enumeration_unsigned_mapping *mapping); + const bt_field_class_enumeration_unsigned_mapping *mapping) + __BT_NOEXCEPT; /*! @brief @@ -2385,6 +2393,7 @@ static inline const bt_field_class_enumeration_mapping * bt_field_class_enumeration_unsigned_mapping_as_mapping_const( const bt_field_class_enumeration_unsigned_mapping *mapping) + __BT_NOEXCEPT { return __BT_UPCAST_CONST(bt_field_class_enumeration_mapping, mapping); } @@ -2432,7 +2441,7 @@ following property values: @bt_pre_not_null{trace_class} */ extern bt_field_class *bt_field_class_enumeration_signed_create( - bt_trace_class *trace_class); + bt_trace_class *trace_class) __BT_NOEXCEPT; /*! @brief @@ -2468,7 +2477,7 @@ See the \ref api-tir-fc-enum-prop-mappings "mappings" property. extern bt_field_class_enumeration_add_mapping_status bt_field_class_enumeration_signed_add_mapping( bt_field_class *field_class, const char *label, - const bt_integer_range_set_signed *ranges); + const bt_integer_range_set_signed *ranges) __BT_NOEXCEPT; /*! @brief @@ -2505,7 +2514,8 @@ See the \ref api-tir-fc-enum-prop-mappings "mappings" property. */ extern const bt_field_class_enumeration_signed_mapping * bt_field_class_enumeration_signed_borrow_mapping_by_index_const( - const bt_field_class *field_class, uint64_t index); + const bt_field_class *field_class, uint64_t index) + __BT_NOEXCEPT; /*! @brief @@ -2539,7 +2549,8 @@ If there's no mapping having the label \bt_p{label} in */ extern const bt_field_class_enumeration_signed_mapping * bt_field_class_enumeration_signed_borrow_mapping_by_label_const( - const bt_field_class *field_class, const char *label); + const bt_field_class *field_class, const char *label) + __BT_NOEXCEPT; /*! @brief @@ -2592,7 +2603,7 @@ extern bt_field_class_enumeration_get_mapping_labels_for_value_status bt_field_class_enumeration_signed_get_mapping_labels_for_value( const bt_field_class *field_class, int64_t value, bt_field_class_enumeration_mapping_label_array *labels, - uint64_t *count); + uint64_t *count) __BT_NOEXCEPT; /*! @} */ @@ -2626,7 +2637,8 @@ See the \ref api-tir-fc-enum-prop-mappings "mappings" property. */ extern const bt_integer_range_set_signed * bt_field_class_enumeration_signed_mapping_borrow_ranges_const( - const bt_field_class_enumeration_signed_mapping *mapping); + const bt_field_class_enumeration_signed_mapping *mapping) + __BT_NOEXCEPT; /*! @brief @@ -2650,6 +2662,7 @@ static inline const bt_field_class_enumeration_mapping * bt_field_class_enumeration_signed_mapping_as_mapping_const( const bt_field_class_enumeration_signed_mapping *mapping) + __BT_NOEXCEPT { return __BT_UPCAST_CONST(bt_field_class_enumeration_mapping, mapping); } @@ -2686,7 +2699,7 @@ value: @bt_pre_not_null{trace_class} */ extern bt_field_class *bt_field_class_string_create( - bt_trace_class *trace_class); + bt_trace_class *trace_class) __BT_NOEXCEPT; /*! @} */ @@ -2716,7 +2729,7 @@ property. \c const version of this function. */ extern bt_field_class *bt_field_class_array_borrow_element_field_class( - bt_field_class *field_class); + bt_field_class *field_class) __BT_NOEXCEPT; /*! @brief @@ -2727,7 +2740,7 @@ See bt_field_class_array_borrow_element_field_class(). */ extern const bt_field_class * bt_field_class_array_borrow_element_field_class_const( - const bt_field_class *field_class); + const bt_field_class *field_class) __BT_NOEXCEPT; /*! @} */ @@ -2779,7 +2792,8 @@ bt_pre_fc_not_in_tc{element_field_class} */ extern bt_field_class *bt_field_class_array_static_create( bt_trace_class *trace_class, - bt_field_class *element_field_class, uint64_t length); + bt_field_class *element_field_class, uint64_t length) + __BT_NOEXCEPT; /*! @brief @@ -2797,7 +2811,7 @@ See the \ref api-tir-fc-sarray-prop-len "length" property. @bt_pre_is_sarray_fc{field_class} */ extern uint64_t bt_field_class_array_static_get_length( - const bt_field_class *field_class); + const bt_field_class *field_class) __BT_NOEXCEPT; /*! @} */ @@ -2867,7 +2881,7 @@ property values: extern bt_field_class *bt_field_class_array_dynamic_create( bt_trace_class *trace_class, bt_field_class *element_field_class, - bt_field_class *length_field_class); + bt_field_class *length_field_class) __BT_NOEXCEPT; /*! @} */ @@ -2905,7 +2919,7 @@ In the meantime, this function returns \c NULL. */ extern const bt_field_path * bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const( - const bt_field_class *field_class); + const bt_field_class *field_class) __BT_NOEXCEPT; /*! @} */ @@ -2942,7 +2956,7 @@ property values: @bt_pre_not_null{trace_class} */ extern bt_field_class *bt_field_class_structure_create( - bt_trace_class *trace_class); + bt_trace_class *trace_class) __BT_NOEXCEPT; /*! @brief @@ -2995,8 +3009,9 @@ See the \ref api-tir-fc-struct-prop-members "members" property. */ extern bt_field_class_structure_append_member_status bt_field_class_structure_append_member( - bt_field_class *field_class, - const char *name, bt_field_class *member_field_class); + bt_field_class *field_class, + const char *name, bt_field_class *member_field_class) + __BT_NOEXCEPT; /*! @brief @@ -3016,7 +3031,7 @@ See the \ref api-tir-fc-struct-prop-members "members" property. @bt_pre_is_struct_fc{field_class} */ extern uint64_t bt_field_class_structure_get_member_count( - const bt_field_class *field_class); + const bt_field_class *field_class) __BT_NOEXCEPT; /*! @brief @@ -3054,7 +3069,7 @@ See the \ref api-tir-fc-struct-prop-members "members" property. */ extern bt_field_class_structure_member * bt_field_class_structure_borrow_member_by_index( - bt_field_class *field_class, uint64_t index); + bt_field_class *field_class, uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -3065,7 +3080,8 @@ See bt_field_class_structure_borrow_member_by_index(). */ extern const bt_field_class_structure_member * bt_field_class_structure_borrow_member_by_index_const( - const bt_field_class *field_class, uint64_t index); + const bt_field_class *field_class, uint64_t index) + __BT_NOEXCEPT; /*! @brief @@ -3102,7 +3118,7 @@ If there's no member having the name \bt_p{name} in */ extern bt_field_class_structure_member * bt_field_class_structure_borrow_member_by_name( - bt_field_class *field_class, const char *name); + bt_field_class *field_class, const char *name) __BT_NOEXCEPT; /*! @brief @@ -3113,7 +3129,8 @@ See bt_field_class_structure_borrow_member_by_name(). */ extern const bt_field_class_structure_member * bt_field_class_structure_borrow_member_by_name_const( - const bt_field_class *field_class, const char *name); + const bt_field_class *field_class, const char *name) + __BT_NOEXCEPT; /*! @} */ @@ -3148,7 +3165,7 @@ See the \ref api-tir-fc-struct-prop-members "members" property. @bt_pre_not_null{member} */ extern const char *bt_field_class_structure_member_get_name( - const bt_field_class_structure_member *member); + const bt_field_class_structure_member *member) __BT_NOEXCEPT; /*! @brief @@ -3170,7 +3187,7 @@ See the \ref api-tir-fc-struct-prop-members "members" property. */ extern bt_field_class * bt_field_class_structure_member_borrow_field_class( - bt_field_class_structure_member *member); + bt_field_class_structure_member *member) __BT_NOEXCEPT; /*! @brief @@ -3181,7 +3198,7 @@ See bt_field_class_structure_member_borrow_field_class(). */ extern const bt_field_class * bt_field_class_structure_member_borrow_field_class_const( - const bt_field_class_structure_member *member); + const bt_field_class_structure_member *member) __BT_NOEXCEPT; /*! @brief @@ -3213,8 +3230,8 @@ See the \ref api-tir-fc-struct-prop-members "members" property. Borrows the user attributes of a structure field class member. */ extern void bt_field_class_structure_member_set_user_attributes( - bt_field_class_structure_member *member, - const bt_value *user_attributes); + bt_field_class_structure_member *member, + const bt_value *user_attributes) __BT_NOEXCEPT; /*! @brief @@ -3244,7 +3261,7 @@ See the \ref api-tir-fc-struct-prop-members "members" property. */ extern bt_value * bt_field_class_structure_member_borrow_user_attributes( - bt_field_class_structure_member *member); + bt_field_class_structure_member *member) __BT_NOEXCEPT; /*! @brief @@ -3255,7 +3272,7 @@ See bt_field_class_structure_member_borrow_user_attributes(). */ extern const bt_value * bt_field_class_structure_member_borrow_user_attributes_const( - const bt_field_class_structure_member *member); + const bt_field_class_structure_member *member) __BT_NOEXCEPT; /*! @} */ @@ -3284,7 +3301,7 @@ See the \ref api-tir-fc-opt-prop-fc "optional field class" property. \c const version of this function. */ extern bt_field_class *bt_field_class_option_borrow_field_class( - bt_field_class *field_class); + bt_field_class *field_class) __BT_NOEXCEPT; /*! @brief @@ -3295,7 +3312,7 @@ See bt_field_class_option_borrow_field_class(). */ extern const bt_field_class * bt_field_class_option_borrow_field_class_const( - const bt_field_class *field_class); + const bt_field_class *field_class) __BT_NOEXCEPT; /*! @} */ @@ -3342,7 +3359,7 @@ values: */ extern bt_field_class *bt_field_class_option_without_selector_create( bt_trace_class *trace_class, - bt_field_class *optional_field_class); + bt_field_class *optional_field_class) __BT_NOEXCEPT; /*! @} */ @@ -3379,7 +3396,7 @@ In the meantime, this function returns \c NULL. */ extern const bt_field_path * bt_field_class_option_with_selector_field_borrow_selector_field_path_const( - const bt_field_class *field_class); + const bt_field_class *field_class) __BT_NOEXCEPT; /*! @} */ @@ -3441,7 +3458,7 @@ values: extern bt_field_class *bt_field_class_option_with_selector_field_bool_create( bt_trace_class *trace_class, bt_field_class *optional_field_class, - bt_field_class *selector_field_class); + bt_field_class *selector_field_class) __BT_NOEXCEPT; /*! @brief @@ -3467,7 +3484,8 @@ property. */ extern void bt_field_class_option_with_selector_field_bool_set_selector_is_reversed( - bt_field_class *field_class, bt_bool selector_is_reversed); + bt_field_class *field_class, bt_bool selector_is_reversed) + __BT_NOEXCEPT; /*! @brief @@ -3493,7 +3511,7 @@ property. */ extern bt_bool bt_field_class_option_with_selector_field_bool_selector_is_reversed( - const bt_field_class *field_class); + const bt_field_class *field_class) __BT_NOEXCEPT; /*! @} */ @@ -3564,7 +3582,8 @@ bt_field_class_option_with_selector_field_integer_unsigned_create( bt_trace_class *trace_class, bt_field_class *optional_field_class, bt_field_class *selector_field_class, - const bt_integer_range_set_unsigned *ranges); + const bt_integer_range_set_unsigned *ranges) + __BT_NOEXCEPT; /*! @brief @@ -3586,7 +3605,7 @@ property. */ extern const bt_integer_range_set_unsigned * bt_field_class_option_with_selector_field_integer_unsigned_borrow_selector_ranges_const( - const bt_field_class *field_class); + const bt_field_class *field_class) __BT_NOEXCEPT; /*! @} */ @@ -3657,7 +3676,7 @@ bt_field_class_option_with_selector_field_integer_signed_create( bt_trace_class *trace_class, bt_field_class *optional_field_class, bt_field_class *selector_field_class, - const bt_integer_range_set_signed *ranges); + const bt_integer_range_set_signed *ranges) __BT_NOEXCEPT; /*! @brief @@ -3679,7 +3698,7 @@ property. */ extern const bt_integer_range_set_signed * bt_field_class_option_with_selector_field_integer_signed_borrow_selector_ranges_const( - const bt_field_class *field_class); + const bt_field_class *field_class) __BT_NOEXCEPT; /*! @} */ @@ -3741,7 +3760,7 @@ property values: */ extern bt_field_class *bt_field_class_variant_create( bt_trace_class *trace_class, - bt_field_class *selector_field_class); + bt_field_class *selector_field_class) __BT_NOEXCEPT; /*! @brief @@ -3761,7 +3780,7 @@ See the \ref api-tir-fc-var-prop-opts "options" property. @bt_pre_is_var_fc{field_class} */ extern uint64_t bt_field_class_variant_get_option_count( - const bt_field_class *field_class); + const bt_field_class *field_class) __BT_NOEXCEPT; /*! @brief @@ -3799,7 +3818,7 @@ See the \ref api-tir-fc-var-prop-opts "options" property. */ extern bt_field_class_variant_option * bt_field_class_variant_borrow_option_by_index( - bt_field_class *field_class, uint64_t index); + bt_field_class *field_class, uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -3810,7 +3829,8 @@ See bt_field_class_variant_borrow_option_by_index(). */ extern const bt_field_class_variant_option * bt_field_class_variant_borrow_option_by_index_const( - const bt_field_class *field_class, uint64_t index); + const bt_field_class *field_class, uint64_t index) + __BT_NOEXCEPT; /*! @brief @@ -3847,7 +3867,7 @@ If there's no option having the name \bt_p{name} in */ extern bt_field_class_variant_option * bt_field_class_variant_borrow_option_by_name( - bt_field_class *field_class, const char *name); + bt_field_class *field_class, const char *name) __BT_NOEXCEPT; /*! @brief @@ -3858,7 +3878,8 @@ See bt_field_class_variant_borrow_option_by_name(). */ extern const bt_field_class_variant_option * bt_field_class_variant_borrow_option_by_name_const( - const bt_field_class *field_class, const char *name); + const bt_field_class *field_class, const char *name) + __BT_NOEXCEPT; /*! @} */ @@ -3893,7 +3914,7 @@ See the \ref api-tir-fc-var-prop-opts "options" property. @bt_pre_not_null{option} */ extern const char *bt_field_class_variant_option_get_name( - const bt_field_class_variant_option *option); + const bt_field_class_variant_option *option) __BT_NOEXCEPT; /*! @brief @@ -3914,7 +3935,7 @@ See the \ref api-tir-fc-var-prop-opts "options" property. \c const version of this function. */ extern bt_field_class *bt_field_class_variant_option_borrow_field_class( - bt_field_class_variant_option *option); + bt_field_class_variant_option *option) __BT_NOEXCEPT; /*! @brief @@ -3925,7 +3946,7 @@ See bt_field_class_variant_option_borrow_field_class(). */ extern const bt_field_class * bt_field_class_variant_option_borrow_field_class_const( - const bt_field_class_variant_option *option); + const bt_field_class_variant_option *option) __BT_NOEXCEPT; /*! @brief @@ -3961,7 +3982,7 @@ See the \ref api-tir-fc-var-prop-opts "options" property. */ extern void bt_field_class_variant_option_set_user_attributes( bt_field_class_variant_option *option, - const bt_value *user_attributes); + const bt_value *user_attributes) __BT_NOEXCEPT; /*! @brief @@ -3992,7 +4013,7 @@ See the \ref api-tir-fc-var-prop-opts "options" property. \c const version of this function. */ extern bt_value *bt_field_class_variant_option_borrow_user_attributes( - bt_field_class_variant_option *option); + bt_field_class_variant_option *option) __BT_NOEXCEPT; /*! @brief @@ -4002,7 +4023,7 @@ extern bt_value *bt_field_class_variant_option_borrow_user_attributes( See bt_field_class_variant_option_borrow_user_attributes(). */ extern const bt_value *bt_field_class_variant_option_borrow_user_attributes_const( - const bt_field_class_variant_option *option); + const bt_field_class_variant_option *option) __BT_NOEXCEPT; /*! @} */ @@ -4065,7 +4086,7 @@ See the \ref api-tir-fc-var-prop-opts "options" property. extern bt_field_class_variant_without_selector_append_option_status bt_field_class_variant_without_selector_append_option( bt_field_class *field_class, const char *name, - bt_field_class *option_field_class); + bt_field_class *option_field_class) __BT_NOEXCEPT; /*! @} */ @@ -4123,7 +4144,7 @@ In the meantime, this function returns \c NULL. */ extern const bt_field_path * bt_field_class_variant_with_selector_field_borrow_selector_field_path_const( - const bt_field_class *field_class); + const bt_field_class *field_class) __BT_NOEXCEPT; /*! @} */ @@ -4180,7 +4201,7 @@ extern bt_field_class_variant_with_selector_field_integer_append_option_status bt_field_class_variant_with_selector_field_integer_unsigned_append_option( bt_field_class *field_class, const char *name, bt_field_class *option_field_class, - const bt_integer_range_set_unsigned *ranges); + const bt_integer_range_set_unsigned *ranges) __BT_NOEXCEPT; /*! @brief @@ -4217,7 +4238,8 @@ See the \ref api-tir-fc-var-prop-opts "options" property. */ extern const bt_field_class_variant_with_selector_field_integer_unsigned_option * bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_index_const( - const bt_field_class *field_class, uint64_t index); + const bt_field_class *field_class, uint64_t index) + __BT_NOEXCEPT; /*! @brief @@ -4255,7 +4277,8 @@ If there's no option having the name \bt_p{name} in */ extern const bt_field_class_variant_with_selector_field_integer_unsigned_option * bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_name_const( - const bt_field_class *field_class, const char *name); + const bt_field_class *field_class, const char *name) + __BT_NOEXCEPT; /*! @} */ @@ -4289,7 +4312,8 @@ See the \ref api-tir-fc-var-prop-opts "options" property. */ extern const bt_integer_range_set_unsigned * bt_field_class_variant_with_selector_field_integer_unsigned_option_borrow_ranges_const( - const bt_field_class_variant_with_selector_field_integer_unsigned_option *option); + const bt_field_class_variant_with_selector_field_integer_unsigned_option *option) + __BT_NOEXCEPT; /*! @brief @@ -4313,6 +4337,7 @@ static inline const bt_field_class_variant_option * bt_field_class_variant_with_selector_field_integer_unsigned_option_as_option_const( const bt_field_class_variant_with_selector_field_integer_unsigned_option *option) + __BT_NOEXCEPT { return __BT_UPCAST_CONST(bt_field_class_variant_option, option); } @@ -4372,7 +4397,8 @@ extern bt_field_class_variant_with_selector_field_integer_append_option_status bt_field_class_variant_with_selector_field_integer_signed_append_option( bt_field_class *field_class, const char *name, bt_field_class *option_field_class, - const bt_integer_range_set_signed *ranges); + const bt_integer_range_set_signed *ranges) + __BT_NOEXCEPT; /*! @brief @@ -4409,7 +4435,8 @@ See the \ref api-tir-fc-var-prop-opts "options" property. */ extern const bt_field_class_variant_with_selector_field_integer_signed_option * bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_index_const( - const bt_field_class *field_class, uint64_t index); + const bt_field_class *field_class, uint64_t index) + __BT_NOEXCEPT; /*! @brief @@ -4447,7 +4474,8 @@ If there's no option having the name \bt_p{name} in */ extern const bt_field_class_variant_with_selector_field_integer_signed_option * bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_name_const( - const bt_field_class *field_class, const char *name); + const bt_field_class *field_class, const char *name) + __BT_NOEXCEPT; /*! @} */ @@ -4481,7 +4509,8 @@ See the \ref api-tir-fc-var-prop-opts "options" property. */ extern const bt_integer_range_set_signed * bt_field_class_variant_with_selector_field_integer_signed_option_borrow_ranges_const( - const bt_field_class_variant_with_selector_field_integer_signed_option *option); + const bt_field_class_variant_with_selector_field_integer_signed_option *option) + __BT_NOEXCEPT; /*! @brief @@ -4505,6 +4534,7 @@ static inline const bt_field_class_variant_option * bt_field_class_variant_with_selector_field_integer_signed_option_as_option_const( const bt_field_class_variant_with_selector_field_integer_signed_option *option) + __BT_NOEXCEPT { return __BT_UPCAST_CONST(bt_field_class_variant_option, option); } @@ -4531,7 +4561,8 @@ bt_field_class_variant_with_selector_field_integer_signed_option_as_option_const @sa bt_field_class_put_ref() — Decrements the reference count of a field class. */ -extern void bt_field_class_get_ref(const bt_field_class *field_class); +extern void bt_field_class_get_ref( + const bt_field_class *field_class) __BT_NOEXCEPT; /*! @brief @@ -4548,7 +4579,8 @@ extern void bt_field_class_get_ref(const bt_field_class *field_class); @sa bt_field_class_get_ref() — Increments the reference count of a field class. */ -extern void bt_field_class_put_ref(const bt_field_class *field_class); +extern void bt_field_class_put_ref( + const bt_field_class *field_class) __BT_NOEXCEPT; /*! @brief diff --git a/include/babeltrace2/trace-ir/field-path.h b/include/babeltrace2/trace-ir/field-path.h index f58a454c..039ceb50 100644 --- a/include/babeltrace2/trace-ir/field-path.h +++ b/include/babeltrace2/trace-ir/field-path.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_TRACE_IR_FIELD_PATH_H #define BABELTRACE2_TRACE_IR_FIELD_PATH_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -228,7 +230,7 @@ See the \ref api-tir-field-path-prop-root "root scope" property. @bt_pre_not_null{field_path} */ extern bt_field_path_scope bt_field_path_get_root_scope( - const bt_field_path *field_path); + const bt_field_path *field_path) __BT_NOEXCEPT; /*! @brief @@ -246,7 +248,7 @@ See the \ref api-tir-field-path-prop-items "items" property. @bt_pre_not_null{field_path} */ extern uint64_t bt_field_path_get_item_count( - const bt_field_path *field_path); + const bt_field_path *field_path) __BT_NOEXCEPT; /*! @brief @@ -278,7 +280,7 @@ See the \ref api-tir-field-path-prop-items "items" property. Returns the number of items contained in a field path. */ extern const bt_field_path_item *bt_field_path_borrow_item_by_index_const( - const bt_field_path *field_path, uint64_t index); + const bt_field_path *field_path, uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -295,7 +297,8 @@ extern const bt_field_path_item *bt_field_path_borrow_item_by_index_const( @sa bt_field_path_put_ref() — Decrements the reference count of a field path. */ -extern void bt_field_path_get_ref(const bt_field_path *field_path); +extern void bt_field_path_get_ref(const bt_field_path *field_path) + __BT_NOEXCEPT; /*! @brief @@ -312,7 +315,8 @@ extern void bt_field_path_get_ref(const bt_field_path *field_path); @sa bt_field_path_get_ref() — Increments the reference count of a field path. */ -extern void bt_field_path_put_ref(const bt_field_path *field_path); +extern void bt_field_path_put_ref(const bt_field_path *field_path) + __BT_NOEXCEPT; /*! @brief @@ -420,7 +424,7 @@ See the \ref api-tir-field-path-prop-items "items" property. @bt_pre_not_null{item} */ extern bt_field_path_item_type bt_field_path_item_get_type( - const bt_field_path_item *item); + const bt_field_path_item *item) __BT_NOEXCEPT; /*! @brief @@ -442,7 +446,7 @@ See the \ref api-tir-field-path-prop-items "items" property. #BT_FIELD_PATH_ITEM_TYPE_INDEX). */ extern uint64_t bt_field_path_item_index_get_index( - const bt_field_path_item *item); + const bt_field_path_item *item) __BT_NOEXCEPT; /*! @} */ diff --git a/include/babeltrace2/trace-ir/field.h b/include/babeltrace2/trace-ir/field.h index 1f7847d5..dc393439 100644 --- a/include/babeltrace2/trace-ir/field.h +++ b/include/babeltrace2/trace-ir/field.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_TRACE_IR_FIELD_H #define BABELTRACE2_TRACE_IR_FIELD_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -442,7 +444,7 @@ bt_field_class_get_type(bt_field_borrow_class(field)) Returns the type enumerator of a \bt_fc. */ extern bt_field_class_type bt_field_get_class_type( - const bt_field *field); + const bt_field *field) __BT_NOEXCEPT; /*! @} */ @@ -466,7 +468,7 @@ extern bt_field_class_type bt_field_get_class_type( @sa bt_field_borrow_class_const() — \c const version of this function. */ -extern bt_field_class *bt_field_borrow_class(bt_field *field); +extern bt_field_class *bt_field_borrow_class(bt_field *field) __BT_NOEXCEPT; /*! @brief @@ -476,7 +478,7 @@ extern bt_field_class *bt_field_borrow_class(bt_field *field); See bt_field_borrow_class(). */ extern const bt_field_class *bt_field_borrow_class_const( - const bt_field *field); + const bt_field *field) __BT_NOEXCEPT; /*! @} */ @@ -502,7 +504,8 @@ extern const bt_field_class *bt_field_borrow_class_const( @sa bt_field_bool_get_value() — Returns the value of a boolean field. */ -extern void bt_field_bool_set_value(bt_field *field, bt_bool value); +extern void bt_field_bool_set_value(bt_field *field, bt_bool value) + __BT_NOEXCEPT; /*! @brief @@ -520,7 +523,7 @@ extern void bt_field_bool_set_value(bt_field *field, bt_bool value); @sa bt_field_bool_set_value() — Sets the value of a boolean field. */ -extern bt_bool bt_field_bool_get_value(const bt_field *field); +extern bt_bool bt_field_bool_get_value(const bt_field *field) __BT_NOEXCEPT; /*! @} */ @@ -551,7 +554,7 @@ See \bt_c_ba_field to learn more. Returns the bits of a bit array field as an integer. */ extern void bt_field_bit_array_set_value_as_integer(bt_field *field, - uint64_t bits); + uint64_t bits) __BT_NOEXCEPT; /*! @brief @@ -575,7 +578,7 @@ See \bt_c_ba_field to learn more. Sets the bits of a bit array field from an integer. */ extern uint64_t bt_field_bit_array_get_value_as_integer( - const bt_field *field); + const bt_field *field) __BT_NOEXCEPT; /*! @} */ @@ -606,7 +609,7 @@ extern uint64_t bt_field_bit_array_get_value_as_integer( Returns the value of an unsigned integer field. */ extern void bt_field_integer_unsigned_set_value(bt_field *field, - uint64_t value); + uint64_t value) __BT_NOEXCEPT; /*! @brief @@ -625,7 +628,7 @@ extern void bt_field_integer_unsigned_set_value(bt_field *field, Sets the value of an unsigned integer field. */ extern uint64_t bt_field_integer_unsigned_get_value( - const bt_field *field); + const bt_field *field) __BT_NOEXCEPT; /*! @brief @@ -649,7 +652,7 @@ extern uint64_t bt_field_integer_unsigned_get_value( Returns the value of an signed integer field. */ extern void bt_field_integer_signed_set_value(bt_field *field, - int64_t value); + int64_t value) __BT_NOEXCEPT; /*! @brief @@ -667,7 +670,8 @@ extern void bt_field_integer_signed_set_value(bt_field *field, @sa bt_field_integer_signed_set_value() — Sets the value of an signed integer field. */ -extern int64_t bt_field_integer_signed_get_value(const bt_field *field); +extern int64_t bt_field_integer_signed_get_value( + const bt_field *field) __BT_NOEXCEPT; /*! @} */ @@ -737,7 +741,7 @@ bt_field_class_enumeration_unsigned_get_mapping_labels_for_value( extern bt_field_enumeration_get_mapping_labels_status bt_field_enumeration_unsigned_get_mapping_labels(const bt_field *field, bt_field_class_enumeration_mapping_label_array *labels, - uint64_t *count); + uint64_t *count) __BT_NOEXCEPT; /*! @brief @@ -780,7 +784,7 @@ bt_field_class_enumeration_signed_get_mapping_labels_for_value( extern bt_field_enumeration_get_mapping_labels_status bt_field_enumeration_signed_get_mapping_labels(const bt_field *field, bt_field_class_enumeration_mapping_label_array *labels, - uint64_t *count); + uint64_t *count) __BT_NOEXCEPT; /*! @} */ @@ -808,7 +812,7 @@ bt_field_enumeration_signed_get_mapping_labels(const bt_field *field, Returns the value of a single-precision real field. */ extern void bt_field_real_single_precision_set_value(bt_field *field, - float value); + float value) __BT_NOEXCEPT; /*! @brief @@ -826,7 +830,8 @@ extern void bt_field_real_single_precision_set_value(bt_field *field, @sa bt_field_real_single_precision_set_value() — Sets the value of a single-precision real field. */ -extern float bt_field_real_single_precision_get_value(const bt_field *field); +extern float bt_field_real_single_precision_get_value( + const bt_field *field) __BT_NOEXCEPT; /*! @brief @@ -847,7 +852,7 @@ extern float bt_field_real_single_precision_get_value(const bt_field *field); Returns the value of a double-precision real field. */ extern void bt_field_real_double_precision_set_value(bt_field *field, - double value); + double value) __BT_NOEXCEPT; /*! @brief @@ -865,7 +870,8 @@ extern void bt_field_real_double_precision_set_value(bt_field *field, @sa bt_field_real_double_precision_set_value() — Sets the value of a double-precision real field. */ -extern double bt_field_real_double_precision_get_value(const bt_field *field); +extern double bt_field_real_double_precision_get_value( + const bt_field *field) __BT_NOEXCEPT; /*! @} */ @@ -920,7 +926,7 @@ typedef enum bt_field_string_set_value_status { Clears a string field. */ extern bt_field_string_set_value_status bt_field_string_set_value( - bt_field *field, const char *value); + bt_field *field, const char *value) __BT_NOEXCEPT; /*! @brief @@ -935,7 +941,7 @@ extern bt_field_string_set_value_status bt_field_string_set_value( @bt_pre_not_null{field} @bt_pre_is_string_field{field} */ -extern uint64_t bt_field_string_get_length(const bt_field *field); +extern uint64_t bt_field_string_get_length(const bt_field *field) __BT_NOEXCEPT; /*! @brief @@ -957,7 +963,8 @@ extern uint64_t bt_field_string_get_length(const bt_field *field); @sa bt_field_string_set_value() — Sets the value of a string field. */ -extern const char *bt_field_string_get_value(const bt_field *field); +extern const char *bt_field_string_get_value( + const bt_field *field) __BT_NOEXCEPT; /*! @brief @@ -1008,7 +1015,7 @@ typedef enum bt_field_string_append_status { Sets the value of a string field. */ extern bt_field_string_append_status bt_field_string_append( - bt_field *field, const char *value); + bt_field *field, const char *value) __BT_NOEXCEPT; /*! @brief @@ -1045,7 +1052,8 @@ extern bt_field_string_append_status bt_field_string_append( Sets the value of a string field. */ extern bt_field_string_append_status bt_field_string_append_with_length( - bt_field *field, const char *value, uint64_t length); + bt_field *field, const char *value, uint64_t length) + __BT_NOEXCEPT; /*! @brief @@ -1062,7 +1070,7 @@ extern bt_field_string_append_status bt_field_string_append_with_length( @sa bt_field_string_set_value() — Sets the value of a string field. */ -extern void bt_field_string_clear(bt_field *field); +extern void bt_field_string_clear(bt_field *field) __BT_NOEXCEPT; /*! @} */ @@ -1084,7 +1092,7 @@ extern void bt_field_string_clear(bt_field *field); @bt_pre_not_null{field} @bt_pre_is_array_field{field} */ -extern uint64_t bt_field_array_get_length(const bt_field *field); +extern uint64_t bt_field_array_get_length(const bt_field *field) __BT_NOEXCEPT; /*! @brief @@ -1119,7 +1127,7 @@ extern uint64_t bt_field_array_get_length(const bt_field *field); \c const version of this function. */ extern bt_field *bt_field_array_borrow_element_field_by_index( - bt_field *field, uint64_t index); + bt_field *field, uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -1130,7 +1138,7 @@ See bt_field_array_borrow_element_field_by_index(). */ extern const bt_field * bt_field_array_borrow_element_field_by_index_const( - const bt_field *field, uint64_t index); + const bt_field *field, uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -1169,7 +1177,8 @@ typedef enum bt_field_array_dynamic_set_length_status { @bt_pre_hot{field} */ extern bt_field_array_dynamic_set_length_status -bt_field_array_dynamic_set_length(bt_field *field, uint64_t length); +bt_field_array_dynamic_set_length(bt_field *field, uint64_t length) + __BT_NOEXCEPT; /*! @} */ @@ -1209,7 +1218,7 @@ bt_field_array_dynamic_set_length(bt_field *field, uint64_t length); \c const version of this function. */ extern bt_field *bt_field_structure_borrow_member_field_by_index( - bt_field *field, uint64_t index); + bt_field *field, uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -1220,7 +1229,7 @@ See bt_field_structure_borrow_member_field_by_index(). */ extern const bt_field * bt_field_structure_borrow_member_field_by_index_const( - const bt_field *field, uint64_t index); + const bt_field *field, uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -1253,7 +1262,7 @@ returns \c NULL. \c const version of this function. */ extern bt_field *bt_field_structure_borrow_member_field_by_name( - bt_field *field, const char *name); + bt_field *field, const char *name) __BT_NOEXCEPT; /*! @brief @@ -1264,7 +1273,7 @@ See bt_field_structure_borrow_member_field_by_name(). */ extern const bt_field * bt_field_structure_borrow_member_field_by_name_const( - const bt_field *field, const char *name); + const bt_field *field, const char *name) __BT_NOEXCEPT; /*! @} */ @@ -1286,7 +1295,8 @@ bt_field_structure_borrow_member_field_by_name_const( @bt_pre_not_null{field} @bt_pre_is_opt_field{field} */ -extern void bt_field_option_set_has_field(bt_field *field, bt_bool has_field); +extern void bt_field_option_set_has_field(bt_field *field, bt_bool has_field) + __BT_NOEXCEPT; /*! @brief @@ -1317,7 +1327,7 @@ If \bt_p{field} has no field, this function returns \c NULL. @sa bt_field_option_borrow_field_const() — \c const version of this function. */ -extern bt_field *bt_field_option_borrow_field(bt_field *field); +extern bt_field *bt_field_option_borrow_field(bt_field *field) __BT_NOEXCEPT; /*! @brief @@ -1327,7 +1337,7 @@ extern bt_field *bt_field_option_borrow_field(bt_field *field); See bt_field_option_borrow_field(). */ extern const bt_field * -bt_field_option_borrow_field_const(const bt_field *field); +bt_field_option_borrow_field_const(const bt_field *field) __BT_NOEXCEPT; /*! @} */ @@ -1370,7 +1380,7 @@ typedef enum bt_field_variant_select_option_by_index_status { */ extern bt_field_variant_select_option_by_index_status bt_field_variant_select_option_by_index( - bt_field *field, uint64_t index); + bt_field *field, uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -1403,7 +1413,7 @@ bt_field_variant_select_option_by_index( \c const version of this function. */ extern bt_field *bt_field_variant_borrow_selected_option_field( - bt_field *field); + bt_field *field) __BT_NOEXCEPT; /*! @brief @@ -1414,7 +1424,7 @@ See bt_field_variant_borrow_selected_option_field(). */ extern const bt_field * bt_field_variant_borrow_selected_option_field_const( - const bt_field *field); + const bt_field *field) __BT_NOEXCEPT; /*! @brief @@ -1434,7 +1444,7 @@ bt_field_variant_borrow_selected_option_field_const( Borrows the field of a variant field's selected option. */ extern uint64_t bt_field_variant_get_selected_option_index( - const bt_field *field); + const bt_field *field) __BT_NOEXCEPT; /*! @brief @@ -1459,7 +1469,7 @@ bt_field_class_variant_borrow_option_by_index( */ extern const bt_field_class_variant_option * bt_field_variant_borrow_selected_option_class_const( - const bt_field *field); + const bt_field *field) __BT_NOEXCEPT; /*! @brief @@ -1484,7 +1494,7 @@ bt_field_class_variant_with_selector_field_integer_unsigned_borrow_option_by_ind */ extern const bt_field_class_variant_with_selector_field_integer_unsigned_option * bt_field_variant_with_selector_field_integer_unsigned_borrow_selected_option_class_const( - const bt_field *field); + const bt_field *field) __BT_NOEXCEPT; /*! @brief @@ -1509,7 +1519,7 @@ bt_field_class_variant_with_selector_field_integer_signed_borrow_option_by_index */ extern const bt_field_class_variant_with_selector_field_integer_signed_option * bt_field_variant_with_selector_field_integer_signed_borrow_selected_option_class_const( - const bt_field *field); + const bt_field *field) __BT_NOEXCEPT; /*! @} */ diff --git a/include/babeltrace2/trace-ir/packet.h b/include/babeltrace2/trace-ir/packet.h index 813d75ef..80fd0de6 100644 --- a/include/babeltrace2/trace-ir/packet.h +++ b/include/babeltrace2/trace-ir/packet.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_TRACE_IR_PACKET_H #define BABELTRACE2_TRACE_IR_PACKET_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -145,7 +147,7 @@ On success, the returned packet has the following property value: bt_stream_class_supports_packets(bt_stream_borrow_class_const(stream)) returns #BT_TRUE. */ -extern bt_packet *bt_packet_create(const bt_stream *stream); +extern bt_packet *bt_packet_create(const bt_stream *stream) __BT_NOEXCEPT; /*! @} */ @@ -171,7 +173,7 @@ extern bt_packet *bt_packet_create(const bt_stream *stream); @sa bt_packet_borrow_stream_const() — \c const version of this function. */ -extern bt_stream *bt_packet_borrow_stream(bt_packet *packet); +extern bt_stream *bt_packet_borrow_stream(bt_packet *packet) __BT_NOEXCEPT; /*! @brief @@ -181,7 +183,7 @@ extern bt_stream *bt_packet_borrow_stream(bt_packet *packet); See bt_packet_borrow_stream(). */ extern const bt_stream *bt_packet_borrow_stream_const( - const bt_packet *packet); + const bt_packet *packet) __BT_NOEXCEPT; /*! @} */ @@ -209,7 +211,7 @@ See the \ref api-tir-pkt-prop-ctx "context field" property. \c const version of this function. */ extern -bt_field *bt_packet_borrow_context_field(bt_packet *packet); +bt_field *bt_packet_borrow_context_field(bt_packet *packet) __BT_NOEXCEPT; /*! @brief @@ -220,7 +222,7 @@ See bt_packet_borrow_context_field(). */ extern const bt_field *bt_packet_borrow_context_field_const( - const bt_packet *packet); + const bt_packet *packet) __BT_NOEXCEPT; /*! @} */ @@ -244,7 +246,7 @@ const bt_field *bt_packet_borrow_context_field_const( @sa bt_packet_put_ref() — Decrements the reference count of a packet. */ -extern void bt_packet_get_ref(const bt_packet *packet); +extern void bt_packet_get_ref(const bt_packet *packet) __BT_NOEXCEPT; /*! @brief @@ -261,7 +263,7 @@ extern void bt_packet_get_ref(const bt_packet *packet); @sa bt_packet_get_ref() — Increments the reference count of a packet. */ -extern void bt_packet_put_ref(const bt_packet *packet); +extern void bt_packet_put_ref(const bt_packet *packet) __BT_NOEXCEPT; /*! @brief diff --git a/include/babeltrace2/trace-ir/stream-class.h b/include/babeltrace2/trace-ir/stream-class.h index 92df5159..e74d3cc3 100644 --- a/include/babeltrace2/trace-ir/stream-class.h +++ b/include/babeltrace2/trace-ir/stream-class.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_TRACE_IR_STREAM_CLASS_H #define BABELTRACE2_TRACE_IR_STREAM_CLASS_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -559,7 +561,7 @@ On success, the returned stream class has the following property values: trace class. */ extern bt_stream_class *bt_stream_class_create( - bt_trace_class *trace_class); + bt_trace_class *trace_class) __BT_NOEXCEPT; /*! @brief @@ -656,7 +658,7 @@ On success, the returned stream class has the following property values: trace class. */ extern bt_stream_class *bt_stream_class_create_with_id( - bt_trace_class *trace_class, uint64_t id); + bt_trace_class *trace_class, uint64_t id) __BT_NOEXCEPT; /*! @} */ @@ -682,7 +684,7 @@ extern bt_stream_class *bt_stream_class_create_with_id( \c const version of this function. */ extern bt_trace_class *bt_stream_class_borrow_trace_class( - bt_stream_class *stream_class); + bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @brief @@ -692,7 +694,7 @@ extern bt_trace_class *bt_stream_class_borrow_trace_class( See bt_stream_class_borrow_trace_class(). */ extern const bt_trace_class *bt_stream_class_borrow_trace_class_const( - const bt_stream_class *stream_class); + const bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @} */ @@ -715,7 +717,7 @@ extern const bt_trace_class *bt_stream_class_borrow_trace_class_const( @bt_pre_not_null{stream_class} */ extern uint64_t bt_stream_class_get_event_class_count( - const bt_stream_class *stream_class); + const bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @brief @@ -750,7 +752,7 @@ extern uint64_t bt_stream_class_get_event_class_count( */ extern bt_event_class * bt_stream_class_borrow_event_class_by_index( - bt_stream_class *stream_class, uint64_t index); + bt_stream_class *stream_class, uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -761,7 +763,8 @@ See bt_stream_class_borrow_event_class_by_index(). */ extern const bt_event_class * bt_stream_class_borrow_event_class_by_index_const( - const bt_stream_class *stream_class, uint64_t index); + const bt_stream_class *stream_class, uint64_t index) + __BT_NOEXCEPT; /*! @brief @@ -794,7 +797,7 @@ If there's no event class having the numeric ID \bt_p{id} in */ extern bt_event_class * bt_stream_class_borrow_event_class_by_id( - bt_stream_class *stream_class, uint64_t id); + bt_stream_class *stream_class, uint64_t id) __BT_NOEXCEPT; /*! @brief @@ -805,7 +808,7 @@ See bt_stream_class_borrow_event_class_by_id(). */ extern const bt_event_class * bt_stream_class_borrow_event_class_by_id_const( - const bt_stream_class *stream_class, uint64_t id); + const bt_stream_class *stream_class, uint64_t id) __BT_NOEXCEPT; /*! @} */ @@ -833,7 +836,7 @@ See the \ref api-tir-stream-cls-prop-id "numeric ID" property. trace class. */ extern uint64_t bt_stream_class_get_id( - const bt_stream_class *stream_class); + const bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @brief @@ -878,7 +881,7 @@ See the \ref api-tir-stream-cls-prop-name "name" property. Returns the name of a stream class. */ extern bt_stream_class_set_name_status bt_stream_class_set_name( - bt_stream_class *stream_class, const char *name); + bt_stream_class *stream_class, const char *name) __BT_NOEXCEPT; /*! @brief @@ -905,7 +908,7 @@ If \bt_p{stream_class} has no name, this function returns \c NULL. Sets the name of a stream class. */ extern const char *bt_stream_class_get_name( - const bt_stream_class *stream_class); + const bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @brief @@ -948,7 +951,7 @@ property. extern bt_stream_class_set_default_clock_class_status bt_stream_class_set_default_clock_class( bt_stream_class *stream_class, - bt_clock_class *clock_class); + bt_clock_class *clock_class) __BT_NOEXCEPT; /*! @brief @@ -976,7 +979,7 @@ returns \c NULL. \c const version of this function. */ extern bt_clock_class *bt_stream_class_borrow_default_clock_class( - bt_stream_class *stream_class); + bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @brief @@ -987,7 +990,7 @@ See bt_stream_class_borrow_default_clock_class(). */ extern const bt_clock_class * bt_stream_class_borrow_default_clock_class_const( - const bt_stream_class *stream_class); + const bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @brief @@ -1062,7 +1065,7 @@ bt_stream_class_set_supports_packets()). extern bt_stream_class_set_field_class_status bt_stream_class_set_packet_context_field_class( bt_stream_class *stream_class, - bt_field_class *field_class); + bt_field_class *field_class) __BT_NOEXCEPT; /*! @brief @@ -1091,7 +1094,7 @@ returns \c NULL. */ extern bt_field_class * bt_stream_class_borrow_packet_context_field_class( - bt_stream_class *stream_class); + bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @brief @@ -1102,7 +1105,7 @@ See bt_stream_class_borrow_packet_context_field_class(). */ extern const bt_field_class * bt_stream_class_borrow_packet_context_field_class_const( - const bt_stream_class *stream_class); + const bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @brief @@ -1147,7 +1150,7 @@ property. extern bt_stream_class_set_field_class_status bt_stream_class_set_event_common_context_field_class( bt_stream_class *stream_class, - bt_field_class *field_class); + bt_field_class *field_class) __BT_NOEXCEPT; /*! @brief @@ -1178,7 +1181,7 @@ function returns \c NULL. extern bt_field_class * bt_stream_class_borrow_event_common_context_field_class( - bt_stream_class *stream_class); + bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @brief @@ -1189,7 +1192,7 @@ See bt_stream_class_borrow_event_common_context_field_class(). */ extern const bt_field_class * bt_stream_class_borrow_event_common_context_field_class_const( - const bt_stream_class *stream_class); + const bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @brief @@ -1216,7 +1219,7 @@ property. */ extern void bt_stream_class_set_assigns_automatic_event_class_id( bt_stream_class *stream_class, - bt_bool assigns_automatic_event_class_id); + bt_bool assigns_automatic_event_class_id) __BT_NOEXCEPT; /*! @brief @@ -1242,7 +1245,7 @@ property. event class IDs. */ extern bt_bool bt_stream_class_assigns_automatic_event_class_id( - const bt_stream_class *stream_class); + const bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @brief @@ -1268,7 +1271,8 @@ property. stream IDs. */ extern void bt_stream_class_set_assigns_automatic_stream_id( - bt_stream_class *stream_class, bt_bool assigns_automatic_stream_id); + bt_stream_class *stream_class, + bt_bool assigns_automatic_stream_id) __BT_NOEXCEPT; /*! @brief @@ -1293,7 +1297,7 @@ property. stream IDs. */ extern bt_bool bt_stream_class_assigns_automatic_stream_id( - const bt_stream_class *stream_class); + const bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @brief @@ -1349,7 +1353,7 @@ properties. extern void bt_stream_class_set_supports_packets( bt_stream_class *stream_class, bt_bool supports_packets, bt_bool with_beginning_default_clock_snapshot, - bt_bool with_end_default_clock_snapshot); + bt_bool with_end_default_clock_snapshot) __BT_NOEXCEPT; /*! @brief @@ -1372,7 +1376,7 @@ property. Sets whether or not a stream class's streams have packets. */ extern bt_bool bt_stream_class_supports_packets( - const bt_stream_class *stream_class); + const bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @brief @@ -1401,7 +1405,7 @@ property. have an end default clock snapshot. */ extern bt_bool bt_stream_class_packets_have_beginning_default_clock_snapshot( - const bt_stream_class *stream_class); + const bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @brief @@ -1430,7 +1434,7 @@ property. have a beginning default clock snapshot. */ extern bt_bool bt_stream_class_packets_have_end_default_clock_snapshot( - const bt_stream_class *stream_class); + const bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @brief @@ -1476,7 +1480,7 @@ properties. extern void bt_stream_class_set_supports_discarded_events( bt_stream_class *stream_class, bt_bool supports_discarded_events, - bt_bool with_default_clock_snapshots); + bt_bool with_default_clock_snapshots) __BT_NOEXCEPT; /*! @brief @@ -1502,7 +1506,7 @@ property. events. */ extern bt_bool bt_stream_class_supports_discarded_events( - const bt_stream_class *stream_class); + const bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @brief @@ -1529,7 +1533,7 @@ property. events. */ extern bt_bool bt_stream_class_discarded_events_have_default_clock_snapshots( - const bt_stream_class *stream_class); + const bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @brief @@ -1581,7 +1585,7 @@ bt_stream_class_set_supports_packets()). extern void bt_stream_class_set_supports_discarded_packets( bt_stream_class *stream_class, bt_bool supports_discarded_packets, - bt_bool with_default_clock_snapshots); + bt_bool with_default_clock_snapshots) __BT_NOEXCEPT; /*! @brief @@ -1607,7 +1611,7 @@ property. packets. */ extern bt_bool bt_stream_class_supports_discarded_packets( - const bt_stream_class *stream_class); + const bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @brief @@ -1634,7 +1638,7 @@ property. packets. */ extern bt_bool bt_stream_class_discarded_packets_have_default_clock_snapshots( - const bt_stream_class *stream_class); + const bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @brief @@ -1666,7 +1670,8 @@ property. Borrows the user attributes of a stream class. */ extern void bt_stream_class_set_user_attributes( - bt_stream_class *stream_class, const bt_value *user_attributes); + bt_stream_class *stream_class, + const bt_value *user_attributes) __BT_NOEXCEPT; /*! @brief @@ -1694,7 +1699,7 @@ property. \c const version of this function. */ extern bt_value *bt_stream_class_borrow_user_attributes( - bt_stream_class *stream_class); + bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @brief @@ -1704,7 +1709,7 @@ extern bt_value *bt_stream_class_borrow_user_attributes( See bt_stream_class_borrow_user_attributes(). */ extern const bt_value *bt_stream_class_borrow_user_attributes_const( - const bt_stream_class *stream_class); + const bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @} */ @@ -1728,7 +1733,8 @@ extern const bt_value *bt_stream_class_borrow_user_attributes_const( @sa bt_stream_class_put_ref() — Decrements the reference count of a stream class. */ -extern void bt_stream_class_get_ref(const bt_stream_class *stream_class); +extern void bt_stream_class_get_ref( + const bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @brief @@ -1745,7 +1751,8 @@ extern void bt_stream_class_get_ref(const bt_stream_class *stream_class); @sa bt_stream_class_get_ref() — Increments the reference count of a stream class. */ -extern void bt_stream_class_put_ref(const bt_stream_class *stream_class); +extern void bt_stream_class_put_ref( + const bt_stream_class *stream_class) __BT_NOEXCEPT; /*! @brief diff --git a/include/babeltrace2/trace-ir/stream.h b/include/babeltrace2/trace-ir/stream.h index 95f17a7f..70628359 100644 --- a/include/babeltrace2/trace-ir/stream.h +++ b/include/babeltrace2/trace-ir/stream.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_TRACE_IR_STREAM_H #define BABELTRACE2_TRACE_IR_STREAM_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -241,7 +243,7 @@ On success, the returned stream has the following property values: trace. */ extern bt_stream *bt_stream_create(bt_stream_class *stream_class, - bt_trace *trace); + bt_trace *trace) __BT_NOEXCEPT; /*! @brief @@ -309,7 +311,7 @@ On success, the returned stream has the following property values: */ extern bt_stream *bt_stream_create_with_id( bt_stream_class *stream_class, - bt_trace *trace, uint64_t id); + bt_trace *trace, uint64_t id) __BT_NOEXCEPT; /*! @} */ @@ -334,7 +336,7 @@ extern bt_stream *bt_stream_create_with_id( @sa bt_stream_borrow_class_const() — \c const version of this function. */ -extern bt_stream_class *bt_stream_borrow_class(bt_stream *stream); +extern bt_stream_class *bt_stream_borrow_class(bt_stream *stream) __BT_NOEXCEPT; /*! @brief @@ -344,7 +346,7 @@ extern bt_stream_class *bt_stream_borrow_class(bt_stream *stream); See bt_stream_borrow_class(). */ extern const bt_stream_class *bt_stream_borrow_class_const( - const bt_stream *stream); + const bt_stream *stream) __BT_NOEXCEPT; /*! @} */ @@ -368,7 +370,7 @@ extern const bt_stream_class *bt_stream_borrow_class_const( @sa bt_stream_borrow_trace_const() — \c const version of this function. */ -extern bt_trace *bt_stream_borrow_trace(bt_stream *stream); +extern bt_trace *bt_stream_borrow_trace(bt_stream *stream) __BT_NOEXCEPT; /*! @brief @@ -378,7 +380,7 @@ extern bt_trace *bt_stream_borrow_trace(bt_stream *stream); See bt_stream_borrow_trace(). */ extern const bt_trace *bt_stream_borrow_trace_const( - const bt_stream *stream); + const bt_stream *stream) __BT_NOEXCEPT; /*! @} */ @@ -405,7 +407,7 @@ See the \ref api-tir-stream-prop-id "numeric ID" property. Creates a stream with a specific numeric ID and adds it to a trace. */ -extern uint64_t bt_stream_get_id(const bt_stream *stream); +extern uint64_t bt_stream_get_id(const bt_stream *stream) __BT_NOEXCEPT; /*! @brief @@ -450,7 +452,7 @@ See the \ref api-tir-stream-prop-name "name" property. Returns the name of a stream. */ extern bt_stream_set_name_status bt_stream_set_name(bt_stream *stream, - const char *name); + const char *name) __BT_NOEXCEPT; /*! @brief @@ -476,7 +478,7 @@ If \bt_p{stream} has no name, this function returns \c NULL. @sa bt_stream_class_set_name() — Sets the name of a stream. */ -extern const char *bt_stream_get_name(const bt_stream *stream); +extern const char *bt_stream_get_name(const bt_stream *stream) __BT_NOEXCEPT; /*! @brief @@ -508,7 +510,8 @@ property. Borrows the user attributes of a stream. */ extern void bt_stream_set_user_attributes( - bt_stream *stream, const bt_value *user_attributes); + bt_stream *stream, const bt_value *user_attributes) + __BT_NOEXCEPT; /*! @brief @@ -535,7 +538,8 @@ property. @sa bt_stream_borrow_user_attributes_const() — \c const version of this function. */ -extern bt_value *bt_stream_borrow_user_attributes(bt_stream *stream); +extern bt_value *bt_stream_borrow_user_attributes(bt_stream *stream) + __BT_NOEXCEPT; /*! @brief @@ -545,7 +549,7 @@ extern bt_value *bt_stream_borrow_user_attributes(bt_stream *stream); See bt_stream_borrow_user_attributes(). */ extern const bt_value *bt_stream_borrow_user_attributes_const( - const bt_stream *stream); + const bt_stream *stream) __BT_NOEXCEPT; /*! @} */ @@ -569,7 +573,7 @@ extern const bt_value *bt_stream_borrow_user_attributes_const( @sa bt_stream_put_ref() — Decrements the reference count of a stream. */ -extern void bt_stream_get_ref(const bt_stream *stream); +extern void bt_stream_get_ref(const bt_stream *stream) __BT_NOEXCEPT; /*! @brief @@ -586,7 +590,7 @@ extern void bt_stream_get_ref(const bt_stream *stream); @sa bt_stream_get_ref() — Increments the reference count of a stream. */ -extern void bt_stream_put_ref(const bt_stream *stream); +extern void bt_stream_put_ref(const bt_stream *stream) __BT_NOEXCEPT; /*! @brief diff --git a/include/babeltrace2/trace-ir/trace-class.h b/include/babeltrace2/trace-ir/trace-class.h index fd01d32b..4a50b311 100644 --- a/include/babeltrace2/trace-ir/trace-class.h +++ b/include/babeltrace2/trace-ir/trace-class.h @@ -4,9 +4,11 @@ * Copyright (C) 2010-2019 EfficiOS Inc. and Linux Foundation */ - #ifndef BABELTRACE2_TRACE_IR_TRACE_CLASS_H +#ifndef BABELTRACE2_TRACE_IR_TRACE_CLASS_H #define BABELTRACE2_TRACE_IR_TRACE_CLASS_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -164,7 +166,8 @@ On success, the returned trace class has the following property values: @returns New trace class reference, or \c NULL on memory error. */ -extern bt_trace_class *bt_trace_class_create(bt_self_component *self_component); +extern bt_trace_class *bt_trace_class_create(bt_self_component *self_component) + __BT_NOEXCEPT; /*! @} */ @@ -187,7 +190,7 @@ extern bt_trace_class *bt_trace_class_create(bt_self_component *self_component); @bt_pre_not_null{trace_class} */ extern uint64_t bt_trace_class_get_stream_class_count( - const bt_trace_class *trace_class); + const bt_trace_class *trace_class) __BT_NOEXCEPT; /*! @brief @@ -221,7 +224,7 @@ extern uint64_t bt_trace_class_get_stream_class_count( \c const version of this function. */ extern bt_stream_class *bt_trace_class_borrow_stream_class_by_index( - bt_trace_class *trace_class, uint64_t index); + bt_trace_class *trace_class, uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -232,7 +235,8 @@ See bt_trace_class_borrow_stream_class_by_index(). */ extern const bt_stream_class * bt_trace_class_borrow_stream_class_by_index_const( - const bt_trace_class *trace_class, uint64_t index); + const bt_trace_class *trace_class, + uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -264,7 +268,7 @@ If there's no stream class having the numeric ID \bt_p{id} in \c const version of this function. */ extern bt_stream_class *bt_trace_class_borrow_stream_class_by_id( - bt_trace_class *trace_class, uint64_t id); + bt_trace_class *trace_class, uint64_t id) __BT_NOEXCEPT; /*! @brief @@ -274,7 +278,7 @@ extern bt_stream_class *bt_trace_class_borrow_stream_class_by_id( See bt_trace_class_borrow_stream_class_by_id(). */ extern const bt_stream_class *bt_trace_class_borrow_stream_class_by_id_const( - const bt_trace_class *trace_class, uint64_t id); + const bt_trace_class *trace_class, uint64_t id) __BT_NOEXCEPT; /*! @} */ @@ -307,7 +311,7 @@ property. */ extern void bt_trace_class_set_assigns_automatic_stream_class_id( bt_trace_class *trace_class, - bt_bool assigns_automatic_stream_class_id); + bt_bool assigns_automatic_stream_class_id) __BT_NOEXCEPT; /*! @brief @@ -333,7 +337,7 @@ property. stream class IDs. */ extern bt_bool bt_trace_class_assigns_automatic_stream_class_id( - const bt_trace_class *trace_class); + const bt_trace_class *trace_class) __BT_NOEXCEPT; /*! @brief @@ -365,7 +369,8 @@ property. Borrows the user attributes of a trace class. */ extern void bt_trace_class_set_user_attributes( - bt_trace_class *trace_class, const bt_value *user_attributes); + bt_trace_class *trace_class, + const bt_value *user_attributes) __BT_NOEXCEPT; /*! @brief @@ -393,7 +398,7 @@ property. \c const version of this function. */ extern bt_value *bt_trace_class_borrow_user_attributes( - bt_trace_class *trace_class); + bt_trace_class *trace_class) __BT_NOEXCEPT; /*! @brief @@ -403,7 +408,7 @@ extern bt_value *bt_trace_class_borrow_user_attributes( See bt_trace_class_borrow_user_attributes(). */ extern const bt_value *bt_trace_class_borrow_user_attributes_const( - const bt_trace_class *trace_class); + const bt_trace_class *trace_class) __BT_NOEXCEPT; /*! @} */ @@ -496,7 +501,7 @@ extern bt_trace_class_add_listener_status bt_trace_class_add_destruction_listener( const bt_trace_class *trace_class, bt_trace_class_destruction_listener_func user_func, - void *user_data, bt_listener_id *listener_id); + void *user_data, bt_listener_id *listener_id) __BT_NOEXCEPT; /*! @brief @@ -548,7 +553,8 @@ You can call this function when \bt_p{trace_class} is */ extern bt_trace_class_remove_listener_status bt_trace_class_remove_destruction_listener( - const bt_trace_class *trace_class, bt_listener_id listener_id); + const bt_trace_class *trace_class, bt_listener_id listener_id) + __BT_NOEXCEPT; /*! @} */ @@ -572,7 +578,8 @@ bt_trace_class_remove_destruction_listener( @sa bt_trace_class_put_ref() — Decrements the reference count of a trace class. */ -extern void bt_trace_class_get_ref(const bt_trace_class *trace_class); +extern void bt_trace_class_get_ref( + const bt_trace_class *trace_class) __BT_NOEXCEPT; /*! @brief @@ -589,7 +596,8 @@ extern void bt_trace_class_get_ref(const bt_trace_class *trace_class); @sa bt_trace_class_get_ref() — Increments the reference count of a trace class. */ -extern void bt_trace_class_put_ref(const bt_trace_class *trace_class); +extern void bt_trace_class_put_ref( + const bt_trace_class *trace_class) __BT_NOEXCEPT; /*! @brief diff --git a/include/babeltrace2/trace-ir/trace.h b/include/babeltrace2/trace-ir/trace.h index e36a5fd3..954a4387 100644 --- a/include/babeltrace2/trace-ir/trace.h +++ b/include/babeltrace2/trace-ir/trace.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_TRACE_IR_TRACE_H #define BABELTRACE2_TRACE_IR_TRACE_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -186,7 +188,7 @@ On success, the returned trace has the following property values: @returns New trace reference, or \c NULL on memory error. */ -extern bt_trace *bt_trace_create(bt_trace_class *trace_class); +extern bt_trace *bt_trace_create(bt_trace_class *trace_class) __BT_NOEXCEPT; /*! @} */ @@ -211,7 +213,7 @@ extern bt_trace *bt_trace_create(bt_trace_class *trace_class); @sa bt_trace_borrow_class_const() — \c const version of this function. */ -extern bt_trace_class *bt_trace_borrow_class(bt_trace *trace); +extern bt_trace_class *bt_trace_borrow_class(bt_trace *trace) __BT_NOEXCEPT; /*! @brief @@ -221,7 +223,7 @@ extern bt_trace_class *bt_trace_borrow_class(bt_trace *trace); See bt_trace_borrow_class(). */ extern const bt_trace_class *bt_trace_borrow_class_const( - const bt_trace *trace); + const bt_trace *trace) __BT_NOEXCEPT; /*! @} */ @@ -243,7 +245,7 @@ extern const bt_trace_class *bt_trace_borrow_class_const( @bt_pre_not_null{trace} */ -extern uint64_t bt_trace_get_stream_count(const bt_trace *trace); +extern uint64_t bt_trace_get_stream_count(const bt_trace *trace) __BT_NOEXCEPT; /*! @brief @@ -277,7 +279,7 @@ extern uint64_t bt_trace_get_stream_count(const bt_trace *trace); \c const version of this function. */ extern bt_stream *bt_trace_borrow_stream_by_index(bt_trace *trace, - uint64_t index); + uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -287,7 +289,7 @@ extern bt_stream *bt_trace_borrow_stream_by_index(bt_trace *trace, See bt_trace_borrow_stream_by_index(). */ extern const bt_stream *bt_trace_borrow_stream_by_index_const( - const bt_trace *trace, uint64_t index); + const bt_trace *trace, uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -319,7 +321,7 @@ If there's no stream having the numeric ID \bt_p{id} in \c const version of this function. */ extern bt_stream *bt_trace_borrow_stream_by_id(bt_trace *trace, - uint64_t id); + uint64_t id) __BT_NOEXCEPT; /*! @brief @@ -329,7 +331,7 @@ extern bt_stream *bt_trace_borrow_stream_by_id(bt_trace *trace, See bt_trace_borrow_stream_by_id(). */ extern const bt_stream *bt_trace_borrow_stream_by_id_const( - const bt_trace *trace, uint64_t id); + const bt_trace *trace, uint64_t id) __BT_NOEXCEPT; /*! @} */ @@ -380,7 +382,7 @@ See the \ref api-tir-trace-prop-name "name" property. Returns the name of a trace. */ extern bt_trace_set_name_status bt_trace_set_name(bt_trace *trace, - const char *name); + const char *name) __BT_NOEXCEPT; /*! @brief @@ -406,7 +408,7 @@ If \bt_p{trace} has no name, this function returns \c NULL. @sa bt_trace_set_name() — Sets the name of a trace. */ -extern const char *bt_trace_get_name(const bt_trace *trace); +extern const char *bt_trace_get_name(const bt_trace *trace) __BT_NOEXCEPT; /*! @brief @@ -428,7 +430,7 @@ See the \ref api-tir-trace-prop-uuid "UUID" property. @sa bt_trace_get_uuid() — Returns the UUID of a trace. */ -extern void bt_trace_set_uuid(bt_trace *trace, bt_uuid uuid); +extern void bt_trace_set_uuid(bt_trace *trace, bt_uuid uuid) __BT_NOEXCEPT; /*! @brief @@ -454,7 +456,7 @@ If \bt_p{trace} has no UUID, this function returns \c NULL. @sa bt_trace_set_uuid() — Sets the UUID of a trace. */ -extern bt_uuid bt_trace_get_uuid(const bt_trace *trace); +extern bt_uuid bt_trace_get_uuid(const bt_trace *trace) __BT_NOEXCEPT; /*! @brief @@ -507,7 +509,7 @@ On success, if \bt_p{trace} already contains an environment entry named */ extern bt_trace_set_environment_entry_status bt_trace_set_environment_entry_integer(bt_trace *trace, const char *name, - int64_t value); + int64_t value) __BT_NOEXCEPT; /*! @brief @@ -543,7 +545,7 @@ On success, if \bt_p{trace} already contains an environment entry named */ extern bt_trace_set_environment_entry_status bt_trace_set_environment_entry_string(bt_trace *trace, const char *name, - const char *value); + const char *value) __BT_NOEXCEPT; /*! @brief @@ -560,7 +562,8 @@ See the \ref api-tir-trace-prop-env "environment" property. @bt_pre_not_null{trace} */ -extern uint64_t bt_trace_get_environment_entry_count(const bt_trace *trace); +extern uint64_t bt_trace_get_environment_entry_count( + const bt_trace *trace) __BT_NOEXCEPT; /*! @brief @@ -610,7 +613,7 @@ See the \ref api-tir-trace-prop-env "environment" property. */ extern void bt_trace_borrow_environment_entry_by_index_const( const bt_trace *trace, uint64_t index, - const char **name, const bt_value **value); + const char **name, const bt_value **value) __BT_NOEXCEPT; /*! @brief @@ -645,7 +648,7 @@ function returns \c NULL. @bt_pre_not_null{name} */ extern const bt_value *bt_trace_borrow_environment_entry_value_by_name_const( - const bt_trace *trace, const char *name); + const bt_trace *trace, const char *name) __BT_NOEXCEPT; /*! @brief @@ -675,7 +678,7 @@ property. Borrows the user attributes of a trace. */ extern void bt_trace_set_user_attributes( - bt_trace *trace, const bt_value *user_attributes); + bt_trace *trace, const bt_value *user_attributes) __BT_NOEXCEPT; /*! @brief @@ -701,7 +704,7 @@ property. @sa bt_trace_borrow_user_attributes_const() — \c const version of this function. */ -extern bt_value *bt_trace_borrow_user_attributes(bt_trace *trace); +extern bt_value *bt_trace_borrow_user_attributes(bt_trace *trace) __BT_NOEXCEPT; /*! @brief @@ -711,7 +714,7 @@ extern bt_value *bt_trace_borrow_user_attributes(bt_trace *trace); See bt_trace_borrow_user_attributes(). */ extern const bt_value *bt_trace_borrow_user_attributes_const( - const bt_trace *trace); + const bt_trace *trace) __BT_NOEXCEPT; /*! @} */ @@ -802,7 +805,7 @@ added destruction listener with bt_trace_remove_destruction_listener(). extern bt_trace_add_listener_status bt_trace_add_destruction_listener( const bt_trace *trace, bt_trace_destruction_listener_func user_func, - void *user_data, bt_listener_id *listener_id); + void *user_data, bt_listener_id *listener_id) __BT_NOEXCEPT; /*! @brief @@ -853,7 +856,8 @@ You can call this function when \bt_p{trace} is Adds a destruction listener to a trace. */ extern bt_trace_remove_listener_status bt_trace_remove_destruction_listener( - const bt_trace *trace, bt_listener_id listener_id); + const bt_trace *trace, bt_listener_id listener_id) + __BT_NOEXCEPT; /*! @} */ @@ -877,7 +881,7 @@ extern bt_trace_remove_listener_status bt_trace_remove_destruction_listener( @sa bt_trace_put_ref() — Decrements the reference count of a trace. */ -extern void bt_trace_get_ref(const bt_trace *trace); +extern void bt_trace_get_ref(const bt_trace *trace) __BT_NOEXCEPT; /*! @brief @@ -894,7 +898,7 @@ extern void bt_trace_get_ref(const bt_trace *trace); @sa bt_trace_get_ref() — Increments the reference count of a trace. */ -extern void bt_trace_put_ref(const bt_trace *trace); +extern void bt_trace_put_ref(const bt_trace *trace) __BT_NOEXCEPT; /*! @brief diff --git a/include/babeltrace2/types.h b/include/babeltrace2/types.h index 2f9e6496..42e6bd48 100644 --- a/include/babeltrace2/types.h +++ b/include/babeltrace2/types.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_TYPES_H #define BABELTRACE2_TYPES_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -33,7 +35,6 @@ typedef struct bt_error bt_error; typedef struct bt_error_cause bt_error_cause; typedef struct bt_event bt_event; typedef struct bt_event_class bt_event_class; -typedef struct bt_event_header_field bt_event_header_field; typedef struct bt_field bt_field; typedef struct bt_field_class bt_field_class; typedef struct bt_field_class_enumeration_mapping bt_field_class_enumeration_mapping; @@ -59,7 +60,6 @@ typedef struct bt_object bt_object; typedef struct bt_packet bt_packet; typedef struct bt_plugin bt_plugin; typedef struct bt_plugin_set bt_plugin_set; -typedef struct bt_plugin_so_shared_lib_handle bt_plugin_so_shared_lib_handle; typedef struct bt_port bt_port; typedef struct bt_port_input bt_port_input; typedef struct bt_port_output bt_port_output; diff --git a/include/babeltrace2/util.h b/include/babeltrace2/util.h index 8426a0ad..80c0e66b 100644 --- a/include/babeltrace2/util.h +++ b/include/babeltrace2/util.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_UTIL_H #define BABELTRACE2_UTIL_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -121,7 +123,7 @@ code if any step of the computation process causes an integer overflow. bt_util_clock_cycles_to_ns_from_origin_status bt_util_clock_cycles_to_ns_from_origin(uint64_t cycles, uint64_t frequency, int64_t offset_seconds, - uint64_t offset_cycles, int64_t *ns_from_origin); + uint64_t offset_cycles, int64_t *ns_from_origin) __BT_NOEXCEPT; /*! @} */ diff --git a/include/babeltrace2/value.h b/include/babeltrace2/value.h index ae60e652..10638bd6 100644 --- a/include/babeltrace2/value.h +++ b/include/babeltrace2/value.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_VALUE_H #define BABELTRACE2_VALUE_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -323,7 +325,7 @@ typedef enum bt_value_type { @sa bt_value_is_map() — Returns whether or not a value is a map value. */ -extern bt_value_type bt_value_get_type(const bt_value *value); +extern bt_value_type bt_value_get_type(const bt_value *value) __BT_NOEXCEPT; /*! @brief @@ -368,7 +370,7 @@ returns #BT_TRUE. */ static inline bt_bool bt_value_type_is(const bt_value_type type, - const bt_value_type other_type) + const bt_value_type other_type) __BT_NOEXCEPT { return (type & other_type) == other_type; } @@ -399,7 +401,7 @@ bt_bool bt_value_type_is(const bt_value_type type, The null value singleton. */ static inline -bt_bool bt_value_is_null(const bt_value *value) +bt_bool bt_value_is_null(const bt_value *value) __BT_NOEXCEPT { return bt_value_get_type(value) == BT_VALUE_TYPE_NULL; } @@ -423,7 +425,7 @@ bt_bool bt_value_is_null(const bt_value *value) type. */ static inline -bt_bool bt_value_is_bool(const bt_value *value) +bt_bool bt_value_is_bool(const bt_value *value) __BT_NOEXCEPT { return bt_value_get_type(value) == BT_VALUE_TYPE_BOOL; } @@ -448,7 +450,7 @@ bt_bool bt_value_is_bool(const bt_value *value) type. */ static inline -bt_bool bt_value_is_unsigned_integer(const bt_value *value) +bt_bool bt_value_is_unsigned_integer(const bt_value *value) __BT_NOEXCEPT { return bt_value_get_type(value) == BT_VALUE_TYPE_UNSIGNED_INTEGER; } @@ -473,7 +475,7 @@ bt_bool bt_value_is_unsigned_integer(const bt_value *value) type. */ static inline -bt_bool bt_value_is_signed_integer(const bt_value *value) +bt_bool bt_value_is_signed_integer(const bt_value *value) __BT_NOEXCEPT { return bt_value_get_type(value) == BT_VALUE_TYPE_SIGNED_INTEGER; } @@ -497,7 +499,7 @@ bt_bool bt_value_is_signed_integer(const bt_value *value) type. */ static inline -bt_bool bt_value_is_real(const bt_value *value) +bt_bool bt_value_is_real(const bt_value *value) __BT_NOEXCEPT { return bt_value_get_type(value) == BT_VALUE_TYPE_REAL; } @@ -521,7 +523,7 @@ bt_bool bt_value_is_real(const bt_value *value) type. */ static inline -bt_bool bt_value_is_string(const bt_value *value) +bt_bool bt_value_is_string(const bt_value *value) __BT_NOEXCEPT { return bt_value_get_type(value) == BT_VALUE_TYPE_STRING; } @@ -545,7 +547,7 @@ bt_bool bt_value_is_string(const bt_value *value) type. */ static inline -bt_bool bt_value_is_array(const bt_value *value) +bt_bool bt_value_is_array(const bt_value *value) __BT_NOEXCEPT { return bt_value_get_type(value) == BT_VALUE_TYPE_ARRAY; } @@ -569,7 +571,7 @@ bt_bool bt_value_is_array(const bt_value *value) type. */ static inline -bt_bool bt_value_is_map(const bt_value *value) +bt_bool bt_value_is_map(const bt_value *value) __BT_NOEXCEPT { return bt_value_get_type(value) == BT_VALUE_TYPE_MAP; } @@ -631,7 +633,7 @@ The returned value has the type #BT_VALUE_TYPE_BOOL. @sa bt_value_bool_create_init() — Creates a boolean value with a given initial raw value. */ -extern bt_value *bt_value_bool_create(void); +extern bt_value *bt_value_bool_create(void) __BT_NOEXCEPT; /*! @brief @@ -648,7 +650,7 @@ The returned value has the type #BT_VALUE_TYPE_BOOL. @sa bt_value_bool_create() — Creates a boolean value initialized to #BT_FALSE. */ -extern bt_value *bt_value_bool_create_init(bt_bool raw_value); +extern bt_value *bt_value_bool_create_init(bt_bool raw_value) __BT_NOEXCEPT; /*! @brief @@ -667,7 +669,7 @@ extern bt_value *bt_value_bool_create_init(bt_bool raw_value); @sa bt_value_bool_get() — Returns the raw value of a boolean value. */ -extern void bt_value_bool_set(bt_value *value, bt_bool raw_value); +extern void bt_value_bool_set(bt_value *value, bt_bool raw_value) __BT_NOEXCEPT; /*! @brief @@ -685,7 +687,7 @@ extern void bt_value_bool_set(bt_value *value, bt_bool raw_value); @sa bt_value_bool_set() — Sets the raw value of a boolean value. */ -extern bt_bool bt_value_bool_get(const bt_value *value); +extern bt_bool bt_value_bool_get(const bt_value *value) __BT_NOEXCEPT; /*! @} */ @@ -706,7 +708,7 @@ The returned value has the type #BT_VALUE_TYPE_UNSIGNED_INTEGER. @sa bt_value_integer_unsigned_create_init() — Creates an unsigned integer value with a given initial raw value. */ -extern bt_value *bt_value_integer_unsigned_create(void); +extern bt_value *bt_value_integer_unsigned_create(void) __BT_NOEXCEPT; /*! @brief @@ -724,7 +726,7 @@ The returned value has the type #BT_VALUE_TYPE_UNSIGNED_INTEGER. @sa bt_value_bool_create() — Creates an unsigned integer value initialized to 0. */ -extern bt_value *bt_value_integer_unsigned_create_init(uint64_t raw_value); +extern bt_value *bt_value_integer_unsigned_create_init(uint64_t raw_value) __BT_NOEXCEPT; /*! @brief @@ -745,7 +747,7 @@ extern bt_value *bt_value_integer_unsigned_create_init(uint64_t raw_value); Returns the raw value of an unsigned integer value. */ extern void bt_value_integer_unsigned_set(bt_value *value, - uint64_t raw_value); + uint64_t raw_value) __BT_NOEXCEPT; /*! @brief @@ -763,7 +765,7 @@ extern void bt_value_integer_unsigned_set(bt_value *value, @sa bt_value_integer_unsigned_set() — Sets the raw value of an unsigned integer value. */ -extern uint64_t bt_value_integer_unsigned_get(const bt_value *value); +extern uint64_t bt_value_integer_unsigned_get(const bt_value *value) __BT_NOEXCEPT; /*! @} */ @@ -784,7 +786,7 @@ The returned value has the type #BT_VALUE_TYPE_SIGNED_INTEGER. @sa bt_value_integer_signed_create_init() — Creates a signed integer value with a given initial raw value. */ -extern bt_value *bt_value_integer_signed_create(void); +extern bt_value *bt_value_integer_signed_create(void) __BT_NOEXCEPT; /*! @brief @@ -802,7 +804,7 @@ The returned value has the type #BT_VALUE_TYPE_SIGNED_INTEGER. @sa bt_value_bool_create() — Creates a signed integer value initialized to 0. */ -extern bt_value *bt_value_integer_signed_create_init(int64_t raw_value); +extern bt_value *bt_value_integer_signed_create_init(int64_t raw_value) __BT_NOEXCEPT; /*! @brief @@ -822,7 +824,7 @@ extern bt_value *bt_value_integer_signed_create_init(int64_t raw_value); @sa bt_value_integer_signed_get() — Returns the raw value of a signed integer value. */ -extern void bt_value_integer_signed_set(bt_value *value, int64_t raw_value); +extern void bt_value_integer_signed_set(bt_value *value, int64_t raw_value) __BT_NOEXCEPT; /*! @brief @@ -840,7 +842,7 @@ extern void bt_value_integer_signed_set(bt_value *value, int64_t raw_value); @sa bt_value_integer_signed_set() — Sets the raw value of a signed integer value. */ -extern int64_t bt_value_integer_signed_get(const bt_value *value); +extern int64_t bt_value_integer_signed_get(const bt_value *value) __BT_NOEXCEPT; /*! @} */ @@ -861,7 +863,7 @@ The returned value has the type #BT_VALUE_TYPE_REAL. @sa bt_value_real_create_init() — Creates a real value with a given initial raw value. */ -extern bt_value *bt_value_real_create(void); +extern bt_value *bt_value_real_create(void) __BT_NOEXCEPT; /*! @brief @@ -878,7 +880,7 @@ The returned value has the type #BT_VALUE_TYPE_REAL. @sa bt_value_real_create() — Creates a real value initialized to 0. */ -extern bt_value *bt_value_real_create_init(double raw_value); +extern bt_value *bt_value_real_create_init(double raw_value) __BT_NOEXCEPT; /*! @brief @@ -897,7 +899,7 @@ extern bt_value *bt_value_real_create_init(double raw_value); @sa bt_value_real_get() — Returns the raw value of a real value. */ -extern void bt_value_real_set(bt_value *value, double raw_value); +extern void bt_value_real_set(bt_value *value, double raw_value) __BT_NOEXCEPT; /*! @brief @@ -915,7 +917,7 @@ extern void bt_value_real_set(bt_value *value, double raw_value); @sa bt_value_real_set() — Sets the raw value of a real value. */ -extern double bt_value_real_get(const bt_value *value); +extern double bt_value_real_get(const bt_value *value) __BT_NOEXCEPT; /*! @} */ @@ -936,7 +938,7 @@ The returned value has the type #BT_VALUE_TYPE_STRING. @sa bt_value_string_create_init() — Creates a string value with a given initial raw value. */ -extern bt_value *bt_value_string_create(void); +extern bt_value *bt_value_string_create(void) __BT_NOEXCEPT; /*! @brief @@ -956,7 +958,7 @@ The returned value has the type #BT_VALUE_TYPE_STRING. @sa bt_value_string_create() — Creates an empty string value. */ -extern bt_value *bt_value_string_create_init(const char *raw_value); +extern bt_value *bt_value_string_create_init(const char *raw_value) __BT_NOEXCEPT; /*! @brief @@ -1001,7 +1003,7 @@ typedef enum bt_value_string_set_status { Returns the raw value of a string value. */ extern bt_value_string_set_status bt_value_string_set(bt_value *value, - const char *raw_value); + const char *raw_value) __BT_NOEXCEPT; /*! @brief @@ -1023,7 +1025,7 @@ extern bt_value_string_set_status bt_value_string_set(bt_value *value, @sa bt_value_string_set() — Sets the raw value of a string value. */ -extern const char *bt_value_string_get(const bt_value *value); +extern const char *bt_value_string_get(const bt_value *value) __BT_NOEXCEPT; /*! @} */ @@ -1041,7 +1043,7 @@ The returned value has the type #BT_VALUE_TYPE_ARRAY. @returns New array value reference, or \c NULL on memory error. */ -extern bt_value *bt_value_array_create(void); +extern bt_value *bt_value_array_create(void) __BT_NOEXCEPT; /*! @brief @@ -1105,7 +1107,7 @@ To append a null value, pass #bt_value_null as \bt_p{element_value}. Creates and appends an empty map value to an array value. */ extern bt_value_array_append_element_status bt_value_array_append_element( - bt_value *value, bt_value *element_value); + bt_value *value, bt_value *element_value) __BT_NOEXCEPT; /*! @brief @@ -1134,7 +1136,7 @@ extern bt_value_array_append_element_status bt_value_array_append_element( Appends an existing value to an array value. */ extern bt_value_array_append_element_status -bt_value_array_append_bool_element(bt_value *value, bt_bool raw_value); +bt_value_array_append_bool_element(bt_value *value, bt_bool raw_value) __BT_NOEXCEPT; /*! @brief @@ -1165,7 +1167,7 @@ bt_value_array_append_bool_element(bt_value *value, bt_bool raw_value); */ extern bt_value_array_append_element_status bt_value_array_append_unsigned_integer_element(bt_value *value, - uint64_t raw_value); + uint64_t raw_value) __BT_NOEXCEPT; /*! @brief @@ -1196,7 +1198,7 @@ bt_value_array_append_unsigned_integer_element(bt_value *value, */ extern bt_value_array_append_element_status bt_value_array_append_signed_integer_element(bt_value *value, - int64_t raw_value); + int64_t raw_value) __BT_NOEXCEPT; /*! @brief @@ -1225,7 +1227,7 @@ bt_value_array_append_signed_integer_element(bt_value *value, Appends an existing value to an array value. */ extern bt_value_array_append_element_status -bt_value_array_append_real_element(bt_value *value, double raw_value); +bt_value_array_append_real_element(bt_value *value, double raw_value) __BT_NOEXCEPT; /*! @brief @@ -1255,7 +1257,7 @@ bt_value_array_append_real_element(bt_value *value, double raw_value); Appends an existing value to an array value. */ extern bt_value_array_append_element_status -bt_value_array_append_string_element(bt_value *value, const char *raw_value); +bt_value_array_append_string_element(bt_value *value, const char *raw_value) __BT_NOEXCEPT; /*! @brief @@ -1290,7 +1292,7 @@ array value. */ extern bt_value_array_append_element_status bt_value_array_append_empty_array_element(bt_value *value, - bt_value **element_value); + bt_value **element_value) __BT_NOEXCEPT; /*! @brief @@ -1325,7 +1327,7 @@ map value. */ extern bt_value_array_append_element_status bt_value_array_append_empty_map_element(bt_value *value, - bt_value **element_value); + bt_value **element_value) __BT_NOEXCEPT; /*! @brief @@ -1384,7 +1386,7 @@ at index \bt_p{index}. */ extern bt_value_array_set_element_by_index_status bt_value_array_set_element_by_index(bt_value *value, uint64_t index, - bt_value *element_value); + bt_value *element_value) __BT_NOEXCEPT; /*! @brief @@ -1414,7 +1416,7 @@ bt_value_array_set_element_by_index(bt_value *value, uint64_t index, \c const version of this function. */ extern bt_value *bt_value_array_borrow_element_by_index(bt_value *value, - uint64_t index); + uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -1424,7 +1426,7 @@ extern bt_value *bt_value_array_borrow_element_by_index(bt_value *value, See bt_value_array_borrow_element_by_index(). */ extern const bt_value *bt_value_array_borrow_element_by_index_const( - const bt_value *value, uint64_t index); + const bt_value *value, uint64_t index) __BT_NOEXCEPT; /*! @brief @@ -1442,7 +1444,7 @@ extern const bt_value *bt_value_array_borrow_element_by_index_const( @sa bt_value_array_is_empty() — Returns whether or not an array value is empty. */ -extern uint64_t bt_value_array_get_length(const bt_value *value); +extern uint64_t bt_value_array_get_length(const bt_value *value) __BT_NOEXCEPT; /*! @brief @@ -1461,7 +1463,7 @@ extern uint64_t bt_value_array_get_length(const bt_value *value); Returns the length of an array value. */ static inline -bt_bool bt_value_array_is_empty(const bt_value *value) +bt_bool bt_value_array_is_empty(const bt_value *value) __BT_NOEXCEPT { return bt_value_array_get_length(value) == 0; } @@ -1482,7 +1484,7 @@ The returned value has the type #BT_VALUE_TYPE_MAP. @returns New map value reference, or \c NULL on memory error. */ -extern bt_value *bt_value_map_create(void); +extern bt_value *bt_value_map_create(void) __BT_NOEXCEPT; /*! @brief @@ -1556,7 +1558,8 @@ On success, if \bt_p{value} already contains an entry with key Creates a map value and uses it to insert an entry in a map value. */ extern bt_value_map_insert_entry_status bt_value_map_insert_entry( - bt_value *value, const char *key, bt_value *entry_value); + bt_value *value, const char *key, + bt_value *entry_value) __BT_NOEXCEPT; /*! @brief @@ -1590,7 +1593,8 @@ created boolean value. Inserts an entry with an existing value in a map value. */ extern bt_value_map_insert_entry_status bt_value_map_insert_bool_entry( - bt_value *value, const char *key, bt_bool raw_value); + bt_value *value, const char *key, bt_bool raw_value) + __BT_NOEXCEPT; /*! @brief @@ -1625,7 +1629,7 @@ created unsigned integer value. */ extern bt_value_map_insert_entry_status bt_value_map_insert_unsigned_integer_entry(bt_value *value, const char *key, - uint64_t raw_value); + uint64_t raw_value) __BT_NOEXCEPT; /*! @brief @@ -1660,7 +1664,7 @@ created signed integer value. */ extern bt_value_map_insert_entry_status bt_value_map_insert_signed_integer_entry(bt_value *value, const char *key, - int64_t raw_value); + int64_t raw_value) __BT_NOEXCEPT; /*! @brief @@ -1694,7 +1698,8 @@ created real value. Inserts an entry with an existing value in a map value. */ extern bt_value_map_insert_entry_status bt_value_map_insert_real_entry( - bt_value *value, const char *key, double raw_value); + bt_value *value, const char *key, double raw_value) + __BT_NOEXCEPT; /*! @brief @@ -1729,7 +1734,7 @@ created string value. */ extern bt_value_map_insert_entry_status bt_value_map_insert_string_entry(bt_value *value, const char *key, - const char *raw_value); + const char *raw_value) __BT_NOEXCEPT; /*! @brief @@ -1768,7 +1773,7 @@ created empty array value. */ extern bt_value_map_insert_entry_status bt_value_map_insert_empty_array_entry(bt_value *value, const char *key, - bt_value **entry_value); + bt_value **entry_value) __BT_NOEXCEPT; /*! @brief @@ -1807,7 +1812,7 @@ created empty map value. */ extern bt_value_map_insert_entry_status bt_value_map_insert_empty_map_entry(bt_value *value, const char *key, - bt_value **entry_value); + bt_value **entry_value) __BT_NOEXCEPT; /*! @brief @@ -1832,7 +1837,7 @@ returns \c NULL. @endparblock @bt_pre_not_null{value} -@bt_pre_is_array_val{value} +@bt_pre_is_map_val{value} @bt_pre_not_null{key} @sa bt_value_map_borrow_entry_value_const() — @@ -1841,7 +1846,7 @@ returns \c NULL. Returns whether or not a map value has an entry with a given key. */ extern bt_value *bt_value_map_borrow_entry_value( - bt_value *value, const char *key); + bt_value *value, const char *key) __BT_NOEXCEPT; /*! @brief @@ -1851,7 +1856,7 @@ extern bt_value *bt_value_map_borrow_entry_value( See bt_value_map_borrow_entry_value(). */ extern const bt_value *bt_value_map_borrow_entry_value_const( - const bt_value *value, const char *key); + const bt_value *value, const char *key) __BT_NOEXCEPT; /*! @brief @@ -2006,7 +2011,7 @@ The iteration process stops when one of: */ extern bt_value_map_foreach_entry_status bt_value_map_foreach_entry( bt_value *value, bt_value_map_foreach_entry_func user_func, - void *user_data); + void *user_data) __BT_NOEXCEPT; /*! @brief @@ -2121,7 +2126,7 @@ See bt_value_map_foreach_entry(). extern bt_value_map_foreach_entry_const_status bt_value_map_foreach_entry_const( const bt_value *value, bt_value_map_foreach_entry_const_func user_func, - void *user_data); + void *user_data) __BT_NOEXCEPT; /*! @brief @@ -2139,7 +2144,7 @@ extern bt_value_map_foreach_entry_const_status bt_value_map_foreach_entry_const( @sa bt_value_map_is_empty() — Returns whether or not a map value is empty. */ -extern uint64_t bt_value_map_get_size(const bt_value *value); +extern uint64_t bt_value_map_get_size(const bt_value *value) __BT_NOEXCEPT; /*! @brief @@ -2158,7 +2163,7 @@ extern uint64_t bt_value_map_get_size(const bt_value *value); Returns the size of a map value. */ static inline -bt_bool bt_value_map_is_empty(const bt_value *value) +bt_bool bt_value_map_is_empty(const bt_value *value) __BT_NOEXCEPT { return bt_value_map_get_size(value) == 0; } @@ -2184,7 +2189,7 @@ bt_bool bt_value_map_is_empty(const bt_value *value) Borrows the value of a specific map value entry. */ extern bt_bool bt_value_map_has_entry(const bt_value *value, - const char *key); + const char *key) __BT_NOEXCEPT; /*! @brief @@ -2270,7 +2275,7 @@ The map value \bt_p{value} becomes: Deep-copies a value. */ extern bt_value_map_extend_status bt_value_map_extend( - bt_value *value, const bt_value *extension_value); + bt_value *value, const bt_value *extension_value) __BT_NOEXCEPT; /*! @} */ @@ -2323,7 +2328,7 @@ identical. @bt_pre_not_null{copy_value} */ extern bt_value_copy_status bt_value_copy(const bt_value *value, - bt_value **copy_value); + bt_value **copy_value) __BT_NOEXCEPT; /*! @brief @@ -2346,7 +2351,7 @@ extern bt_value_copy_status bt_value_copy(const bt_value *value, @bt_pre_not_null{b_value} */ extern bt_bool bt_value_is_equal(const bt_value *a_value, - const bt_value *b_value); + const bt_value *b_value) __BT_NOEXCEPT; /*! @} */ @@ -2370,7 +2375,7 @@ extern bt_bool bt_value_is_equal(const bt_value *a_value, @sa bt_value_put_ref() — Decrements the reference count of a value. */ -extern void bt_value_get_ref(const bt_value *value); +extern void bt_value_get_ref(const bt_value *value) __BT_NOEXCEPT; /*! @brief @@ -2387,7 +2392,7 @@ extern void bt_value_get_ref(const bt_value *value); @sa bt_value_get_ref() — Increments the reference count of a value. */ -extern void bt_value_put_ref(const bt_value *value); +extern void bt_value_put_ref(const bt_value *value) __BT_NOEXCEPT; /*! @brief diff --git a/include/babeltrace2/version.h b/include/babeltrace2/version.h index 06742712..66ad5415 100644 --- a/include/babeltrace2/version.h +++ b/include/babeltrace2/version.h @@ -7,6 +7,8 @@ #ifndef BABELTRACE2_VERSION_H #define BABELTRACE2_VERSION_H +/* IWYU pragma: private, include */ + #ifndef __BT_IN_BABELTRACE_H # error "Please include instead." #endif @@ -66,7 +68,7 @@ version: @returns Major version of the library. */ -extern unsigned int bt_version_get_major(void); +extern unsigned int bt_version_get_major(void) __BT_NOEXCEPT; /*! @brief @@ -75,7 +77,7 @@ extern unsigned int bt_version_get_major(void); @returns Minor version of the library. */ -extern unsigned int bt_version_get_minor(void); +extern unsigned int bt_version_get_minor(void) __BT_NOEXCEPT; /*! @brief @@ -84,7 +86,7 @@ extern unsigned int bt_version_get_minor(void); @returns Patch version of the library. */ -extern unsigned int bt_version_get_patch(void); +extern unsigned int bt_version_get_patch(void) __BT_NOEXCEPT; /*! @brief @@ -96,7 +98,7 @@ The development stage \em can contain a version suffix such as @returns Development stage of the library's version, or \c NULL if none. */ -extern const char *bt_version_get_development_stage(void); +extern const char *bt_version_get_development_stage(void) __BT_NOEXCEPT; /*! @brief @@ -110,7 +112,7 @@ of the library. Version control system revision's description of the library's version, or \c NULL if none. */ -extern const char *bt_version_get_vcs_revision_description(void); +extern const char *bt_version_get_vcs_revision_description(void) __BT_NOEXCEPT; /*! @brief @@ -125,7 +127,7 @@ development build, this function returns \c NULL. @sa bt_version_get_name_description() — Returns the description of libbabeltrace2's release name. */ -extern const char *bt_version_get_name(void); +extern const char *bt_version_get_name(void) __BT_NOEXCEPT; /*! @brief @@ -140,7 +142,7 @@ case for a development build, this function returns \c NULL. @sa bt_version_get_name() — Returns libbabeltrace2's release name. */ -extern const char *bt_version_get_name_description(void); +extern const char *bt_version_get_name_description(void) __BT_NOEXCEPT; /*! @brief @@ -152,7 +154,7 @@ custom build. @returns Library's version extra name, or \c NULL if not available. */ -extern const char *bt_version_get_extra_name(void); +extern const char *bt_version_get_extra_name(void) __BT_NOEXCEPT; /*! @brief @@ -168,7 +170,7 @@ for a custom build. Can contain newlines. @endparblock */ -extern const char *bt_version_get_extra_description(void); +extern const char *bt_version_get_extra_description(void) __BT_NOEXCEPT; /*! @brief @@ -185,7 +187,7 @@ for a custom build. applied to Babeltrace's source tree for a custom build. @endparblock */ -extern const char *bt_version_get_extra_patch_names(void); +extern const char *bt_version_get_extra_patch_names(void) __BT_NOEXCEPT; /*! @} */ diff --git a/m4/ax_append_compile_flags.m4 b/m4/ax_append_compile_flags.m4 index 9c856356..29d86e0f 100644 --- a/m4/ax_append_compile_flags.m4 +++ b/m4/ax_append_compile_flags.m4 @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: FSFAP # ============================================================================ # https://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html # ============================================================================ diff --git a/m4/ax_append_flag.m4 b/m4/ax_append_flag.m4 index dd6d8b61..e1ea0fc4 100644 --- a/m4/ax_append_flag.m4 +++ b/m4/ax_append_flag.m4 @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: FSFAP # =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_append_flag.html # =========================================================================== diff --git a/m4/ax_c___attribute__.m4 b/m4/ax_c___attribute__.m4 index 6a1ede15..98999e11 100644 --- a/m4/ax_c___attribute__.m4 +++ b/m4/ax_c___attribute__.m4 @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-or-later WITH LicenseRef-Autoconf-exception-macro # =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_c___attribute__.html # =========================================================================== diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4 index bd753b34..8f62565e 100644 --- a/m4/ax_check_compile_flag.m4 +++ b/m4/ax_check_compile_flag.m4 @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: FSFAP # =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html # =========================================================================== diff --git a/m4/ax_cxx_compile_stdcxx.m4 b/m4/ax_cxx_compile_stdcxx.m4 index 43087b2e..c081ffac 100644 --- a/m4/ax_cxx_compile_stdcxx.m4 +++ b/m4/ax_cxx_compile_stdcxx.m4 @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: FSFAP # =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html # =========================================================================== @@ -10,13 +11,13 @@ # # Check for baseline language coverage in the compiler for the specified # version of the C++ standard. If necessary, add switches to CXX and -# CXXCPP to enable support. VERSION may be '11' (for the C++11 standard) -# or '14' (for the C++14 standard). +# CXXCPP to enable support. VERSION may be '11', '14', '17', or '20' for +# the respective C++ standard version. # # The second argument, if specified, indicates whether you insist on an # extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. # -std=c++11). If neither is specified, you get whatever works, with -# preference for an extended mode. +# preference for no added switch, and then for an extended mode. # # The third argument, if specified 'mandatory' or if left unspecified, # indicates that baseline support for the specified C++ standard is @@ -35,13 +36,15 @@ # Copyright (c) 2015 Moritz Klammler # Copyright (c) 2016, 2018 Krzesimir Nowak # Copyright (c) 2019 Enji Cooper +# Copyright (c) 2020 Jason Merrill +# Copyright (c) 2021 Jörn Heusipp # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 11 +#serial 18 dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro dnl (serial version number 13). @@ -50,6 +53,7 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl m4_if([$1], [11], [ax_cxx_compile_alternatives="11 0x"], [$1], [14], [ax_cxx_compile_alternatives="14 1y"], [$1], [17], [ax_cxx_compile_alternatives="17 1z"], + [$1], [20], [ax_cxx_compile_alternatives="20"], [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl m4_if([$2], [], [], [$2], [ext], [], @@ -62,6 +66,16 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl AC_LANG_PUSH([C++])dnl ac_success=no + m4_if([$2], [], [dnl + AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, + ax_cv_cxx_compile_cxx$1, + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], + [ax_cv_cxx_compile_cxx$1=yes], + [ax_cv_cxx_compile_cxx$1=no])]) + if test x$ax_cv_cxx_compile_cxx$1 = xyes; then + ac_success=yes + fi]) + m4_if([$2], [noext], [], [dnl if test x$ac_success = xno; then for alternative in ${ax_cxx_compile_alternatives}; do @@ -91,9 +105,18 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl dnl HP's aCC needs +std=c++11 according to: dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf dnl Cray's crayCC needs "-h std=c++11" + dnl MSVC needs -std:c++NN for C++17 and later (default is C++14) for alternative in ${ax_cxx_compile_alternatives}; do - for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}"; do - cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) + for switch in -std=c++${alternative} +std=c++${alternative} "-h std=c++${alternative}" MSVC; do + if test x"$switch" = xMSVC; then + dnl AS_TR_SH maps both `:` and `=` to `_` so -std:c++17 would collide + dnl with -std=c++17. We suffix the cache variable name with _MSVC to + dnl avoid this. + switch=-std:c++${alternative} + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_${switch}_MSVC]) + else + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) + fi AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, $cachevar, [ac_save_CXX="$CXX" @@ -140,7 +163,6 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11], _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 ) - dnl Test body for checking C++14 support m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], @@ -148,12 +170,24 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 ) +dnl Test body for checking C++17 support + m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17], _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 ) +dnl Test body for checking C++20 support + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_20], + _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_20 +) + + dnl Tests for new features in C++11 m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[ @@ -165,7 +199,11 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[ #error "This is not a C++ compiler" -#elif __cplusplus < 201103L +// MSVC always sets __cplusplus to 199711L in older versions; newer versions +// only set it correctly if /Zc:__cplusplus is specified as well as a +// /std:c++NN switch: +// https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ +#elif __cplusplus < 201103L && !defined _MSC_VER #error "This is not a C++11 compiler" @@ -456,7 +494,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[ #error "This is not a C++ compiler" -#elif __cplusplus < 201402L +#elif __cplusplus < 201402L && !defined _MSC_VER #error "This is not a C++14 compiler" @@ -580,7 +618,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[ #error "This is not a C++ compiler" -#elif __cplusplus < 201703L +#elif __cplusplus < 201703L && !defined _MSC_VER #error "This is not a C++17 compiler" @@ -946,6 +984,36 @@ namespace cxx17 } // namespace cxx17 -#endif // __cplusplus < 201703L +#endif // __cplusplus < 201703L && !defined _MSC_VER + +]]) + + +dnl Tests for new features in C++20 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_20], [[ + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 202002L && !defined _MSC_VER + +#error "This is not a C++20 compiler" + +#else + +#include + +namespace cxx20 +{ + +// As C++20 supports feature test macros in the standard, there is no +// immediate need to actually test for feature availability on the +// Autoconf side. + +} // namespace cxx20 + +#endif // __cplusplus < 202002L && !defined _MSC_VER ]]) diff --git a/m4/ax_pkg_swig.m4 b/m4/ax_pkg_swig.m4 index 1d467de3..7a4196ff 100644 --- a/m4/ax_pkg_swig.m4 +++ b/m4/ax_pkg_swig.m4 @@ -36,6 +36,8 @@ # Copyright (c) 2008 Rafael Laboissiere # Copyright (c) 2008 Andrew Collier # Copyright (c) 2011 Murray Cumming +# Copyright (c) 2018 Reini Urban +# Copyright (c) 2021 Vincent Danjean # # This program is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the @@ -63,14 +65,16 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 13 +#serial 15 AC_DEFUN([AX_PKG_SWIG],[ # Find path to the "swig" executable. AC_PATH_PROGS([SWIG],[swig swig3.0 swig2.0]) if test -z "$SWIG" ; then m4_ifval([$3],[$3],[:]) - elif test -n "$1" ; then + elif test -z "$1" ; then + m4_ifval([$2],[$2],[:]) + else AC_MSG_CHECKING([SWIG version]) [swig_version=`$SWIG -version 2>&1 | grep 'SWIG Version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`] AC_MSG_RESULT([$swig_version]) @@ -81,12 +85,12 @@ AC_DEFUN([AX_PKG_SWIG],[ if test -z "$required_major" ; then [required_major=0] fi - [required=`echo $required | sed 's/[0-9]*[^0-9]//'`] + [required=`echo $required. | sed 's/[0-9]*[^0-9]//'`] [required_minor=`echo $required | sed 's/[^0-9].*//'`] if test -z "$required_minor" ; then [required_minor=0] fi - [required=`echo $required | sed 's/[0-9]*[^0-9]//'`] + [required=`echo $required. | sed 's/[0-9]*[^0-9]//'`] [required_patch=`echo $required | sed 's/[^0-9].*//'`] if test -z "$required_patch" ; then [required_patch=0] @@ -121,7 +125,7 @@ AC_DEFUN([AX_PKG_SWIG],[ m4_ifval([$3],[$3],[]) else AC_MSG_CHECKING([for SWIG library]) - SWIG_LIB=`$SWIG -swiglib` + SWIG_LIB=`$SWIG -swiglib | tr '\r\n' ' '` AC_MSG_RESULT([$SWIG_LIB]) m4_ifval([$2],[$2],[]) fi diff --git a/m4/ax_pthread.m4 b/m4/ax_pthread.m4 index 507f182a..db15ab98 100644 --- a/m4/ax_pthread.m4 +++ b/m4/ax_pthread.m4 @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0-or-later WITH LicenseRef-Autoconf-exception-macro # =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_pthread.html # =========================================================================== @@ -14,20 +15,24 @@ # flags that are needed. (The user can also force certain compiler # flags/libs to be tested by setting these environment variables.) # -# Also sets PTHREAD_CC to any special C compiler that is needed for -# multi-threaded programs (defaults to the value of CC otherwise). (This -# is necessary on AIX to use the special cc_r compiler alias.) +# Also sets PTHREAD_CC and PTHREAD_CXX to any special C compiler that is +# needed for multi-threaded programs (defaults to the value of CC +# respectively CXX otherwise). (This is necessary on e.g. AIX to use the +# special cc_r/CC_r compiler alias.) # # NOTE: You are assumed to not only compile your program with these flags, # but also to link with them as well. For example, you might link with # $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS +# $PTHREAD_CXX $CXXFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS # # If you are only building threaded programs, you may wish to use these # variables in your default LIBS, CFLAGS, and CC: # # LIBS="$PTHREAD_LIBS $LIBS" # CFLAGS="$CFLAGS $PTHREAD_CFLAGS" +# CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS" # CC="$PTHREAD_CC" +# CXX="$PTHREAD_CXX" # # In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant # has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to @@ -83,7 +88,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 27 +#serial 31 AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) AC_DEFUN([AX_PTHREAD], [ @@ -105,6 +110,7 @@ if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then ax_pthread_save_CFLAGS="$CFLAGS" ax_pthread_save_LIBS="$LIBS" AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"]) + AS_IF([test "x$PTHREAD_CXX" != "x"], [CXX="$PTHREAD_CXX"]) CFLAGS="$CFLAGS $PTHREAD_CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS]) @@ -482,18 +488,28 @@ if test "x$ax_pthread_ok" = "xyes"; then [#handle absolute path differently from PATH based program lookup AS_CASE(["x$CC"], [x/*], - [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])], - [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])]) + [ + AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"]) + AS_IF([test "x${CXX}" != "x"], [AS_IF([AS_EXECUTABLE_P([${CXX}_r])],[PTHREAD_CXX="${CXX}_r"])]) + ], + [ + AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC]) + AS_IF([test "x${CXX}" != "x"], [AC_CHECK_PROGS([PTHREAD_CXX],[${CXX}_r],[$CXX])]) + ] + ) + ]) ;; esac fi fi test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" +test -n "$PTHREAD_CXX" || PTHREAD_CXX="$CXX" AC_SUBST([PTHREAD_LIBS]) AC_SUBST([PTHREAD_CFLAGS]) AC_SUBST([PTHREAD_CC]) +AC_SUBST([PTHREAD_CXX]) # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test "x$ax_pthread_ok" = "xyes"; then diff --git a/m4/ax_require_defined.m4 b/m4/ax_require_defined.m4 index 17c3eab7..6de1b2a5 100644 --- a/m4/ax_require_defined.m4 +++ b/m4/ax_require_defined.m4 @@ -1,3 +1,4 @@ +# SPDX-License-Identifier: FSFAP # =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_require_defined.html # =========================================================================== diff --git a/pyproject.toml b/pyproject.toml index 39d5b4a3..fb033ec7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,18 @@ | src/bindings/python/bt2/setup\.py$ | src/bindings/python/bt2/bt2/native_bt\.py$ | src/bindings/python/bt2/bt2/version\.py$ + | tests/utils/python/normand\.py$ + | tests/utils/python/typing/typing\.py$ | tests/utils/python/tap ) ''' + +[tool.isort] +profile = "black" +extend_skip_glob = [ + "tests/utils/python/tap", + "tests/utils/python/normand.py", + "tests/utils/python/typing/typing.py", +] +length_sort = true diff --git a/setup.cfg b/setup.cfg index 9a58dd3c..02702a12 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,10 +2,16 @@ # E501: line too long # W503: line break before binary operator (conflicts with black's way of # formatting) -ignore = E501,W503 +# E203: Whitespace before ':' (conclicts with black's way of formatting) +ignore = E501,W503,E203 -# __init__.py has a bunch of (expectedly) unused imports, so disable that -# warning for this file. -per-file-ignores = src/bindings/python/bt2/bt2/__init__.py:F401 +# Disabled warnings for `bt2/__init__.py`: +# +# F401: +# Has a bunch of (expectedly) unused imports. +# +# E402: +# Has code to set up the DLL search path before imports. +per-file-ignores = src/bindings/python/bt2/bt2/__init__.py:F401,E402 -exclude = tests/utils/python/tap +exclude = tests/utils/python/normand.py tests/utils/python/tap tests/utils/python/typing/typing.py diff --git a/src/Makefile.am b/src/Makefile.am index 6e01a12d..05feb3e7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,23 +1,784 @@ +# SPDX-FileCopyrightText: 2019-2023 EfficiOS, Inc. # SPDX-License-Identifier: MIT +# Build the current dir containing the library and plugins before the cli and +# bindings. SUBDIRS = \ - common \ - py-common \ - cpp-common \ - autodisc \ - argpar \ - ctfser \ - fd-cache \ - compat \ - logging \ - ctf-writer \ - lib \ - string-format \ - python-plugin-provider \ - plugins \ - param-parse \ - cli \ - bindings + . \ + cli + +if ENABLE_PYTHON_BINDINGS +SUBDIRS += bindings/python/bt2 +endif + +## This target generates an include file that contains the git version +## string of the current branch, it must be continuously updated when +## we build in the git repo and shipped in dist tarballs to reflect the +## status of the tree when it was generated. If the tree is clean and +## the current commit is a tag starting with "v", consider this a +## release version and set an empty git version. + +version_verbose = $(version_verbose_@AM_V@) +version_verbose_ = $(version_verbose_@AM_DEFAULT_V@) +version_verbose_0 = @echo " GEN " $@; + +common/version.i: + $(version_verbose)GREP=$(GREP) SED=$(SED) TOP_SRCDIR="$(top_srcdir)" $(SHELL) $(srcdir)/gen-version-i.sh + +dist_noinst_SCRIPTS = gen-version-i.sh + +# Ensure version.i is generated before any code is built. +BUILT_SOURCES = common/version.i + +## +## version.i is defined as a .PHONY target even if it's a real file, +## we want the target to be re-run on every make. +## +.PHONY: common/version.i + +CLEANFILES = common/version.i.tmp + +## +## Only clean "version.i" on dist-clean, we need to keep it on regular +## clean when it's part of a dist tarball. +## +DISTCLEANFILES = common/version.i + +# +# Convenience libraries +# + +noinst_LTLIBRARIES = \ + argpar/libargpar.la \ + autodisc/libautodisc.la \ + clock-correlation-validator/libclock-correlation-validator.la \ + common/libcommon.la \ + compat/libcompat.la \ + cpp-common/libcpp-common.la \ + cpp-common/vendor/fmt/libfmt.la \ + ctfser/libctfser.la \ + fd-cache/libfd-cache.la \ + logging/liblogging.la \ + param-parse/libparam-parse.la \ + plugins/common/muxing/libmuxing.la \ + plugins/common/param-validation/libparam-validation.la \ + plugins/ctf/common/metadata/libctf-ast.la \ + plugins/ctf/common/metadata/libctf-parser.la \ + string-format/libstring-format.la + + +argpar_libargpar_la_SOURCES = \ + argpar/argpar.c \ + argpar/argpar.h + +autodisc_libautodisc_la_SOURCES = \ + autodisc/autodisc.c \ + autodisc/autodisc.h + +clock_correlation_validator_libclock_correlation_validator_la_SOURCES = \ + clock-correlation-validator/clock-correlation-validator.cpp \ + clock-correlation-validator/clock-correlation-validator.h \ + clock-correlation-validator/clock-correlation-validator.hpp + +common_libcommon_la_SOURCES = \ + common/align.h \ + common/assert.c \ + common/assert.h \ + common/common.c \ + common/common.h \ + common/list.h \ + common/macros.h \ + common/mmap-align.h \ + common/safe.h \ + common/uuid.c \ + common/uuid.h \ + common/version.h \ + common/version.i + +common_libcommon_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -DBABELTRACE_PLUGINS_DIR=\"$(BABELTRACE_PLUGINS_DIR)\" + +compat_libcompat_la_SOURCES = \ + compat/bitfield.h \ + compat/compiler.h \ + compat/endian.h \ + compat/fcntl.h \ + compat/glib.h \ + compat/limits.h \ + compat/memstream.h \ + compat/mman.c \ + compat/mman.h \ + compat/socket.hpp \ + compat/stdio.h \ + compat/stdlib.h \ + compat/string.h \ + compat/time.h \ + compat/unistd.h \ + compat/utc.h + +cpp_common_libcpp_common_la_SOURCES = \ + cpp-common/bt2/borrowed-object-iterator.hpp \ + cpp-common/bt2/borrowed-object-proxy.hpp \ + cpp-common/bt2/borrowed-object.hpp \ + cpp-common/bt2/clock-class.hpp \ + cpp-common/bt2/clock-snapshot.hpp \ + cpp-common/bt2/component-class-dev.hpp \ + cpp-common/bt2/component-class.hpp \ + cpp-common/bt2/component-port.hpp \ + cpp-common/bt2/graph.hpp \ + cpp-common/bt2/error.hpp \ + cpp-common/bt2/exc.hpp \ + cpp-common/bt2/field-class.hpp \ + cpp-common/bt2/field-path.hpp \ + cpp-common/bt2/field.hpp \ + cpp-common/bt2/integer-range-set.hpp \ + cpp-common/bt2/integer-range.hpp \ + cpp-common/bt2/internal/comp-cls-bridge.hpp \ + cpp-common/bt2/internal/utils.hpp \ + cpp-common/bt2/logging.hpp \ + cpp-common/bt2/message-array.hpp \ + cpp-common/bt2/message-iterator.hpp \ + cpp-common/bt2/message.hpp \ + cpp-common/bt2/optional-borrowed-object.hpp \ + cpp-common/bt2/plugin-dev.hpp \ + cpp-common/bt2/plugin-load.hpp \ + cpp-common/bt2/plugin-set.hpp \ + cpp-common/bt2/plugin.hpp \ + cpp-common/bt2/private-query-executor.hpp \ + cpp-common/bt2/query-executor.hpp \ + cpp-common/bt2/raw-value-proxy.hpp \ + cpp-common/bt2/self-component-class.hpp \ + cpp-common/bt2/self-component-port.hpp \ + cpp-common/bt2/self-message-iterator-configuration.hpp \ + cpp-common/bt2/self-message-iterator.hpp \ + cpp-common/bt2/shared-object.hpp \ + cpp-common/bt2/trace-ir.hpp \ + cpp-common/bt2/type-traits.hpp \ + cpp-common/bt2/value.hpp \ + cpp-common/bt2/wrap.hpp \ + cpp-common/bt2c/align.hpp \ + cpp-common/bt2c/c-string-view.hpp \ + cpp-common/bt2c/call.hpp \ + cpp-common/bt2c/contains.hpp \ + cpp-common/bt2c/data-len.hpp \ + cpp-common/bt2c/dummy.cpp \ + cpp-common/bt2c/endian.hpp \ + cpp-common/bt2c/exc.hpp \ + cpp-common/bt2c/file-utils.cpp \ + cpp-common/bt2c/file-utils.hpp \ + cpp-common/bt2c/fmt.hpp \ + cpp-common/bt2c/glib-up.hpp \ + cpp-common/bt2c/libc-up.hpp \ + cpp-common/bt2c/logging.hpp \ + cpp-common/bt2c/prio-heap.hpp \ + cpp-common/bt2c/read-fixed-len-int.hpp \ + cpp-common/bt2c/safe-ops.hpp \ + cpp-common/bt2c/span.hpp \ + cpp-common/bt2c/std-int.hpp \ + cpp-common/bt2c/type-traits.hpp \ + cpp-common/bt2c/uuid.hpp \ + cpp-common/bt2c/vector.hpp \ + cpp-common/bt2s/make-unique.hpp \ + cpp-common/bt2s/optional.hpp \ + cpp-common/bt2s/span.hpp \ + cpp-common/bt2s/string-view.hpp \ + cpp-common/vendor/nlohmann/json.hpp \ + cpp-common/vendor/optional-lite/optional.hpp \ + cpp-common/vendor/span-lite/span.hpp \ + cpp-common/vendor/string-view-lite/string_view.hpp \ + cpp-common/vendor/wise-enum/optional.h \ + cpp-common/vendor/wise-enum/optional_common.h \ + cpp-common/vendor/wise-enum/wise_enum.h \ + cpp-common/vendor/wise-enum/wise_enum_detail.h \ + cpp-common/vendor/wise-enum/wise_enum_generated.h + +cpp_common_vendor_fmt_libfmt_la_SOURCES = \ + cpp-common/vendor/fmt/args.h \ + cpp-common/vendor/fmt/chrono.h \ + cpp-common/vendor/fmt/color.h \ + cpp-common/vendor/fmt/compile.h \ + cpp-common/vendor/fmt/core.h \ + cpp-common/vendor/fmt/format-inl.h \ + cpp-common/vendor/fmt/format.cc \ + cpp-common/vendor/fmt/format.h \ + cpp-common/vendor/fmt/os.cc \ + cpp-common/vendor/fmt/os.h \ + cpp-common/vendor/fmt/ostream.h \ + cpp-common/vendor/fmt/printf.h \ + cpp-common/vendor/fmt/ranges.h \ + cpp-common/vendor/fmt/std.h \ + cpp-common/vendor/fmt/xchar.h + +cpp_common_vendor_fmt_libfmt_la_CXXFLAGS = \ + $(AM_CXXFLAGS) -Wno-missing-noreturn + +ctfser_libctfser_la_SOURCES = \ + ctfser/ctfser.c \ + ctfser/ctfser.h + +fd_cache_libfd_cache_la_SOURCES = \ + fd-cache/fd-cache.c \ + fd-cache/fd-cache.h + +logging_liblogging_la_SOURCES = \ + logging/comp-logging.h \ + logging/log-api.c \ + logging/log-api.h \ + logging/log.h + +param_parse_libparam_parse_la_SOURCES = \ + param-parse/param-parse.c \ + param-parse/param-parse.h + +string_format_libstring_format_la_SOURCES = \ + string-format/format-plugin-comp-cls-name.c \ + string-format/format-plugin-comp-cls-name.h \ + string-format/format-error.c \ + string-format/format-error.h + +plugins_common_muxing_libmuxing_la_SOURCES = \ + plugins/common/muxing/muxing.c \ + plugins/common/muxing/muxing.h + +plugins_common_param_validation_libparam_validation_la_SOURCES = \ + plugins/common/param-validation/param-validation.c \ + plugins/common/param-validation/param-validation.h + +# Set flags for the Bison based metadata parser +# -t : instrument the parser +# -d : produce a header +# -v : verbose +# -Wno-yacc : disable POSIX Yacc incompatibilities warnings +AM_YFLAGS = \ + -t -d -v -Wno-yacc + +plugins_ctf_common_metadata_libctf_parser_la_SOURCES = \ + plugins/ctf/common/src/metadata/tsdl/lexer.lpp \ + plugins/ctf/common/src/metadata/tsdl/parser.ypp \ + plugins/ctf/common/src/metadata/tsdl/objstack.cpp + +# scanner-symbols.h is included to prefix generated yy_* symbols with bt_. +plugins_ctf_common_metadata_libctf_parser_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + -include $(srcdir)/plugins/ctf/common/src/metadata/tsdl/scanner-symbols.hpp + +# This library contains (mostly) generated code, silence some warnings that it +# produces. +plugins_ctf_common_metadata_libctf_parser_la_CXXFLAGS = \ + $(AM_CXXFLAGS) \ + -Wno-unused-function \ + -Wno-null-dereference \ + -Wno-missing-field-initializers \ + -Wno-unused-parameter + +plugins_ctf_common_metadata_libctf_ast_la_SOURCES = \ + plugins/ctf/common/src/metadata/tsdl/visitor-generate-ir.cpp \ + plugins/ctf/common/src/metadata/tsdl/visitor-semantic-validator.cpp \ + plugins/ctf/common/src/metadata/tsdl/visitor-parent-links.cpp \ + plugins/ctf/common/src/metadata/tsdl/ast.hpp \ + plugins/ctf/common/src/metadata/tsdl/objstack.hpp \ + plugins/ctf/common/src/metadata/tsdl/parser.hpp \ + plugins/ctf/common/src/metadata/tsdl/parser-wrap.hpp \ + plugins/ctf/common/src/metadata/tsdl/scanner.hpp \ + plugins/ctf/common/src/metadata/tsdl/scanner-symbols.hpp \ + plugins/ctf/common/src/metadata/tsdl/decoder.cpp \ + plugins/ctf/common/src/metadata/tsdl/decoder.hpp \ + plugins/ctf/common/src/metadata/tsdl/decoder-packetized-file-stream-to-buf.cpp \ + plugins/ctf/common/src/metadata/tsdl/decoder-packetized-file-stream-to-buf.hpp \ + plugins/ctf/common/src/metadata/tsdl/logging.hpp \ + plugins/ctf/common/src/metadata/tsdl/ctf-meta.hpp \ + plugins/ctf/common/src/metadata/tsdl/ctf-meta-visitors.hpp \ + plugins/ctf/common/src/metadata/tsdl/ctf-meta-validate.cpp \ + plugins/ctf/common/src/metadata/tsdl/ctf-meta-update-meanings.cpp \ + plugins/ctf/common/src/metadata/tsdl/ctf-meta-update-in-ir.cpp \ + plugins/ctf/common/src/metadata/tsdl/ctf-meta-update-default-clock-classes.cpp \ + plugins/ctf/common/src/metadata/tsdl/ctf-meta-update-text-array-sequence.cpp \ + plugins/ctf/common/src/metadata/tsdl/ctf-meta-update-alignments.cpp \ + plugins/ctf/common/src/metadata/tsdl/ctf-meta-update-value-storing-indexes.cpp \ + plugins/ctf/common/src/metadata/tsdl/ctf-meta-update-stream-class-config.cpp \ + plugins/ctf/common/src/metadata/tsdl/ctf-meta-warn-meaningless-header-fields.cpp \ + plugins/ctf/common/src/metadata/tsdl/ctf-meta-translate.cpp \ + plugins/ctf/common/src/metadata/tsdl/ctf-meta-resolve.cpp \ + plugins/ctf/common/src/metadata/tsdl/ctf-meta-configure-ir-trace.cpp \ + plugins/ctf/common/src/metadata/tsdl/ctf-meta-configure-ir-trace.hpp + +if BABELTRACE_BUILD_WITH_MINGW +plugins_ctf_common_metadata_libctf_ast_la_LIBADD = -lintl -liconv -lole32 +endif + +BUILT_SOURCES += \ + plugins/ctf/common/src/metadata/tsdl/parser.hpp + +ALL_LOCAL = + +if HAVE_BISON +# We have bison: we can clean the generated parser files +CLEANFILES += \ + plugins/ctf/common/src/metadata/tsdl/parser.cpp \ + plugins/ctf/common/src/metadata/tsdl/parser.hpp \ + plugins/ctf/common/src/metadata/tsdl/parser.output +else # HAVE_BISON +# Create target used to stop the build if we want to build the parser, +# but we don't have the necessary tool to do so +plugins/ctf/common/metadata/parser.cpp plugins/ctf/common/metadata/parser.hpp: plugins/ctf/common/metadata/parser.ypp + @echo "Error: Cannot build target because bison is missing." + @echo "Make sure bison is installed and run the configure script again." + @false + +ALL_LOCAL += \ + plugins/ctf/common/metadata/parser.cpp \ + plugins/ctf/common/metadata/parser.hpp +endif # HAVE_BISON + +if HAVE_FLEX +# We have flex: we can clean the generated lexer files +CLEANFILES += plugins/ctf/common/metadata/lexer.cpp +else # HAVE_FLEX +# Create target used to stop the build if we want to build the lexer, +# but we don't have the necessary tool to do so +plugins/ctf/common/metadata/lexer.cpp: plugins/ctf/common/metadata/lexer.lpp + @echo "Error: Cannot build target because flex is missing." + @echo "Make sure flex is installed and run the configure script again." + @false + +ALL_LOCAL += plugins/ctf/common/metadata/lexer.cpp +endif # HAVE_FLEX + +all-local: $(ALL_LOCAL) + +if ENABLE_PYTHON_COMMON_DEPS +noinst_LTLIBRARIES += py-common/libpy-common.la + +py_common_libpy_common_la_SOURCES = \ + py-common/py-common.c \ + py-common/py-common.h + +py_common_libpy_common_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + $(PYTHON_INCLUDE) + +endif # ENABLE_PYTHON_COMMON_DEPS + +if ENABLE_DEBUG_INFO +noinst_LTLIBRARIES += plugins/lttng-utils/debug-info/libdebug-info.la + +plugins_lttng_utils_debug_info_libdebug_info_la_SOURCES = \ + plugins/lttng-utils/debug-info/bin-info.c \ + plugins/lttng-utils/debug-info/bin-info.h \ + plugins/lttng-utils/debug-info/crc32.c \ + plugins/lttng-utils/debug-info/crc32.h \ + plugins/lttng-utils/debug-info/debug-info.c \ + plugins/lttng-utils/debug-info/debug-info.h \ + plugins/lttng-utils/debug-info/dwarf.c \ + plugins/lttng-utils/debug-info/dwarf.h \ + plugins/lttng-utils/debug-info/trace-ir-data-copy.c \ + plugins/lttng-utils/debug-info/trace-ir-data-copy.h \ + plugins/lttng-utils/debug-info/trace-ir-mapping.c \ + plugins/lttng-utils/debug-info/trace-ir-mapping.h \ + plugins/lttng-utils/debug-info/trace-ir-metadata-copy.c \ + plugins/lttng-utils/debug-info/trace-ir-metadata-copy.h \ + plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.c \ + plugins/lttng-utils/debug-info/trace-ir-metadata-field-class-copy.h \ + plugins/lttng-utils/debug-info/utils.c \ + plugins/lttng-utils/debug-info/utils.h + +plugins_lttng_utils_debug_info_libdebug_info_la_LIBADD = \ + fd-cache/libfd-cache.la + +endif # ENABLE_DEBUG_INFO + + +# +# Public libraries +# + +lib_LTLIBRARIES = \ + ctf-writer/libbabeltrace2-ctf-writer.la \ + lib/libbabeltrace2.la + +lib_libbabeltrace2_la_SOURCES = \ + lib/graph/message/discarded-items.c \ + lib/graph/message/discarded-items.h \ + lib/graph/message/event.c \ + lib/graph/message/event.h \ + lib/graph/message-iterator-class.c \ + lib/graph/message-iterator-class.h \ + lib/graph/message/message.c \ + lib/graph/message/message.h \ + lib/graph/message/message-iterator-inactivity.c \ + lib/graph/message/message-iterator-inactivity.h \ + lib/graph/message/packet.c \ + lib/graph/message/packet.h \ + lib/graph/message/stream.c \ + lib/graph/message/stream.h \ + lib/graph/component.c \ + lib/graph/component-class.c \ + lib/graph/component-class.h \ + lib/graph/component-class-sink-simple.c \ + lib/graph/component-class-sink-simple.h \ + lib/graph/component-descriptor-set.c \ + lib/graph/component-descriptor-set.h \ + lib/graph/component-filter.c \ + lib/graph/component-filter.h \ + lib/graph/component.h \ + lib/graph/component-sink.c \ + lib/graph/component-sink.h \ + lib/graph/component-source.c \ + lib/graph/component-source.h \ + lib/graph/connection.c \ + lib/graph/connection.h \ + lib/graph/graph.c \ + lib/graph/graph.h \ + lib/graph/interrupter.c \ + lib/graph/interrupter.h \ + lib/graph/iterator.c \ + lib/graph/iterator.h \ + lib/graph/mip.c \ + lib/graph/port.c \ + lib/graph/port.h \ + lib/graph/query-executor.c \ + lib/graph/query-executor.h \ + lib/plugin/plugin.c \ + lib/plugin/plugin.h \ + lib/plugin/plugin-so.c \ + lib/plugin/plugin-so.h \ + lib/trace-ir/attributes.c \ + lib/trace-ir/attributes.h \ + lib/trace-ir/clock-class.c \ + lib/trace-ir/clock-class.h \ + lib/trace-ir/clock-snapshot.c \ + lib/trace-ir/clock-snapshot.h \ + lib/trace-ir/event.c \ + lib/trace-ir/event-class.c \ + lib/trace-ir/event-class.h \ + lib/trace-ir/event.h \ + lib/trace-ir/field.c \ + lib/trace-ir/field-class.c \ + lib/trace-ir/field-class.h \ + lib/trace-ir/field.h \ + lib/trace-ir/field-path.c \ + lib/trace-ir/field-path.h \ + lib/trace-ir/field-wrapper.c \ + lib/trace-ir/field-wrapper.h \ + lib/trace-ir/packet.c \ + lib/trace-ir/packet.h \ + lib/trace-ir/resolve-field-path.c \ + lib/trace-ir/resolve-field-path.h \ + lib/trace-ir/stream.c \ + lib/trace-ir/stream-class.c \ + lib/trace-ir/stream-class.h \ + lib/trace-ir/stream.h \ + lib/trace-ir/trace.c \ + lib/trace-ir/trace-class.c \ + lib/trace-ir/trace-class.h \ + lib/trace-ir/trace.h \ + lib/trace-ir/utils.c \ + lib/trace-ir/utils.h \ + lib/assert-cond-base.h \ + lib/assert-cond.h \ + lib/assert-cond.c \ + lib/babeltrace2.c \ + lib/current-thread.c \ + lib/error.c \ + lib/error.h \ + lib/func-status.h \ + lib/integer-range-set.c \ + lib/integer-range-set.h \ + lib/lib-logging.c \ + lib/logging.c \ + lib/logging.h \ + lib/object-pool.c \ + lib/object-pool.h \ + lib/object.h \ + lib/property.h \ + lib/util.c \ + lib/value.c \ + lib/value.h + +lib_libbabeltrace2_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + $(LT_NO_UNDEFINED) \ + -version-info $(BABELTRACE_LIBRARY_VERSION) + +lib_libbabeltrace2_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + '-DBABELTRACE_PLUGIN_PROVIDERS_DIR="$(BABELTRACE_PLUGIN_PROVIDERS_DIR)"' + +lib_libbabeltrace2_la_LIBADD = \ + logging/liblogging.la \ + common/libcommon.la \ + compat/libcompat.la \ + clock-correlation-validator/libclock-correlation-validator.la + +nodist_EXTRA_lib_libbabeltrace2_la_SOURCES = dummy.cpp + +ctf_writer_libbabeltrace2_ctf_writer_la_SOURCES = \ + ctf-writer/assert-pre.h \ + ctf-writer/attributes.c \ + ctf-writer/attributes.h \ + ctf-writer/clock.c \ + ctf-writer/clock-class.c \ + ctf-writer/clock-class.h \ + ctf-writer/clock.h \ + ctf-writer/event.c \ + ctf-writer/event-class.c \ + ctf-writer/event-class.h \ + ctf-writer/event.h \ + ctf-writer/field-path.c \ + ctf-writer/field-path.h \ + ctf-writer/fields.c \ + ctf-writer/fields.h \ + ctf-writer/field-types.c \ + ctf-writer/field-types.h \ + ctf-writer/field-wrapper.c \ + ctf-writer/field-wrapper.h \ + ctf-writer/functor.c \ + ctf-writer/functor.h \ + ctf-writer/logging.c \ + ctf-writer/logging.h \ + ctf-writer/object.c \ + ctf-writer/object.h \ + ctf-writer/object-pool.c \ + ctf-writer/object-pool.h \ + ctf-writer/resolve.c \ + ctf-writer/resolve.h \ + ctf-writer/stream.c \ + ctf-writer/stream-class.c \ + ctf-writer/stream-class.h \ + ctf-writer/stream.h \ + ctf-writer/trace.c \ + ctf-writer/trace.h \ + ctf-writer/utils.c \ + ctf-writer/utils.h \ + ctf-writer/validation.c \ + ctf-writer/validation.h \ + ctf-writer/values.c \ + ctf-writer/values.h \ + ctf-writer/visitor.c \ + ctf-writer/visitor.h \ + ctf-writer/writer.c \ + ctf-writer/writer.h + +ctf_writer_libbabeltrace2_ctf_writer_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + $(LT_NO_UNDEFINED) \ + -version-info $(BABELTRACE_LIBRARY_VERSION) + +ctf_writer_libbabeltrace2_ctf_writer_la_LIBADD = \ + logging/liblogging.la \ + common/libcommon.la \ + ctfser/libctfser.la \ + compat/libcompat.la pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = babeltrace2.pc babeltrace2-ctf-writer.pc +pkgconfig_DATA = \ + babeltrace2-ctf-writer.pc \ + babeltrace2.pc + +# +# Python plugin provider +# + +if ENABLE_PYTHON_PLUGINS +pluginproviderdir = "$(BABELTRACE_PLUGIN_PROVIDERS_DIR)" +pluginprovider_LTLIBRARIES = python-plugin-provider/babeltrace2-python-plugin-provider.la + +python_plugin_provider_babeltrace2_python_plugin_provider_la_SOURCES = \ + python-plugin-provider/python-plugin-provider.c \ + python-plugin-provider/python-plugin-provider.h + +python_plugin_provider_babeltrace2_python_plugin_provider_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + $(LT_NO_UNDEFINED) \ + -avoid-version -module \ + $(PYTHON_LDFLAGS) + +python_plugin_provider_babeltrace2_python_plugin_provider_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + $(PYTHON_INCLUDE) + +python_plugin_provider_babeltrace2_python_plugin_provider_la_LIBADD = + +# Link the Python plugin provider library with libbabeltrace2 +# when it's not built-in the babeltrace2 executable. +if !ENABLE_BUILT_IN_PLUGINS +python_plugin_provider_babeltrace2_python_plugin_provider_la_LIBADD += \ + logging/liblogging.la \ + common/libcommon.la \ + py-common/libpy-common.la \ + lib/libbabeltrace2.la +endif +endif # ENABLE_PYTHON_PLUGINS + +# +# Plugins +# + +plugindir = "$(BABELTRACE_PLUGINS_DIR)" +plugin_LTLIBRARIES = \ + plugins/ctf/babeltrace-plugin-ctf.la \ + plugins/text/babeltrace-plugin-text.la \ + plugins/utils/babeltrace-plugin-utils.la + + +# utils plugin +plugins_utils_babeltrace_plugin_utils_la_SOURCES = \ + plugins/utils/counter/counter.c \ + plugins/utils/counter/counter.h \ + plugins/utils/dummy/dummy.c \ + plugins/utils/dummy/dummy.h \ + plugins/utils/muxer/comp.cpp \ + plugins/utils/muxer/comp.hpp \ + plugins/utils/muxer/msg-iter.cpp \ + plugins/utils/muxer/msg-iter.hpp \ + plugins/utils/muxer/upstream-msg-iter.cpp \ + plugins/utils/muxer/upstream-msg-iter.hpp \ + plugins/utils/trimmer/trimmer.c \ + plugins/utils/trimmer/trimmer.h \ + plugins/utils/plugin.cpp + +plugins_utils_babeltrace_plugin_utils_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + $(LT_NO_UNDEFINED) \ + -avoid-version -module $(LD_NOTEXT) + +plugins_utils_babeltrace_plugin_utils_la_LIBADD = \ + plugins/common/muxing/libmuxing.la + +if !ENABLE_BUILT_IN_PLUGINS +plugins_utils_babeltrace_plugin_utils_la_LIBADD += \ + lib/libbabeltrace2.la \ + common/libcommon.la \ + cpp-common/vendor/fmt/libfmt.la \ + logging/liblogging.la \ + plugins/common/param-validation/libparam-validation.la \ + clock-correlation-validator/libclock-correlation-validator.la +endif + +# ctf plugin +plugins_ctf_babeltrace_plugin_ctf_la_SOURCES = \ + plugins/ctf/common/src/bfcr/bfcr.cpp \ + plugins/ctf/common/src/bfcr/bfcr.hpp \ + plugins/ctf/common/src/clk-cls-cfg.hpp \ + plugins/ctf/common/src/msg-iter/msg-iter.cpp \ + plugins/ctf/common/src/msg-iter/msg-iter.hpp \ + plugins/ctf/fs-sink/fs-sink.cpp \ + plugins/ctf/fs-sink/fs-sink-ctf-meta.hpp \ + plugins/ctf/fs-sink/fs-sink.hpp \ + plugins/ctf/fs-sink/fs-sink-stream.cpp \ + plugins/ctf/fs-sink/fs-sink-stream.hpp \ + plugins/ctf/fs-sink/fs-sink-trace.cpp \ + plugins/ctf/fs-sink/fs-sink-trace.hpp \ + plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.cpp \ + plugins/ctf/fs-sink/translate-ctf-ir-to-tsdl.hpp \ + plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.cpp \ + plugins/ctf/fs-sink/translate-trace-ir-to-ctf-ir.hpp \ + plugins/ctf/fs-src/data-stream-file.cpp \ + plugins/ctf/fs-src/data-stream-file.hpp \ + plugins/ctf/fs-src/file.cpp \ + plugins/ctf/fs-src/file.hpp \ + plugins/ctf/fs-src/fs.cpp \ + plugins/ctf/fs-src/fs.hpp \ + plugins/ctf/fs-src/lttng-index.hpp \ + plugins/ctf/fs-src/metadata.cpp \ + plugins/ctf/fs-src/metadata.hpp \ + plugins/ctf/fs-src/query.cpp \ + plugins/ctf/fs-src/query.hpp \ + plugins/ctf/lttng-live/data-stream.cpp \ + plugins/ctf/lttng-live/data-stream.hpp \ + plugins/ctf/lttng-live/lttng-live.cpp \ + plugins/ctf/lttng-live/lttng-live.hpp \ + plugins/ctf/lttng-live/lttng-viewer-abi.hpp \ + plugins/ctf/lttng-live/metadata.cpp \ + plugins/ctf/lttng-live/metadata.hpp \ + plugins/ctf/lttng-live/viewer-connection.cpp \ + plugins/ctf/lttng-live/viewer-connection.hpp \ + plugins/ctf/plugin.cpp + +plugins_ctf_babeltrace_plugin_ctf_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + $(LT_NO_UNDEFINED) \ + -avoid-version -module $(LD_NOTEXT) + +plugins_ctf_babeltrace_plugin_ctf_la_LIBADD = \ + plugins/ctf/common/metadata/libctf-parser.la \ + plugins/ctf/common/metadata/libctf-ast.la \ + plugins/common/param-validation/libparam-validation.la + +if BABELTRACE_BUILD_WITH_MINGW +plugins_ctf_babeltrace_plugin_ctf_la_LIBADD += -lws2_32 +endif + +if !ENABLE_BUILT_IN_PLUGINS +plugins_ctf_babeltrace_plugin_ctf_la_LIBADD += \ + lib/libbabeltrace2.la \ + logging/liblogging.la \ + plugins/common/muxing/libmuxing.la \ + common/libcommon.la \ + ctfser/libctfser.la \ + cpp-common/vendor/fmt/libfmt.la +endif + +# text plugin +plugins_text_babeltrace_plugin_text_la_SOURCES = \ + plugins/text/details/colors.h \ + plugins/text/details/details.c \ + plugins/text/details/details.h \ + plugins/text/details/obj-lifetime-mgmt.c \ + plugins/text/details/obj-lifetime-mgmt.h \ + plugins/text/details/write.c \ + plugins/text/details/write.h \ + plugins/text/dmesg/dmesg.c \ + plugins/text/dmesg/dmesg.h \ + plugins/text/pretty/pretty.c \ + plugins/text/pretty/pretty.h \ + plugins/text/pretty/print.c \ + plugins/text/plugin.c + +plugins_text_babeltrace_plugin_text_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + $(LT_NO_UNDEFINED) \ + -avoid-version -module $(LD_NOTEXT) + +plugins_text_babeltrace_plugin_text_la_LIBADD = + +if !ENABLE_BUILT_IN_PLUGINS +plugins_text_babeltrace_plugin_text_la_LIBADD += \ + lib/libbabeltrace2.la \ + common/libcommon.la \ + logging/liblogging.la \ + compat/libcompat.la \ + plugins/common/param-validation/libparam-validation.la +endif + +# lttng-utils plugin +if ENABLE_DEBUG_INFO +plugin_LTLIBRARIES += \ + plugins/lttng-utils/babeltrace-plugin-lttng-utils.la + +plugins_lttng_utils_babeltrace_plugin_lttng_utils_la_SOURCES = \ + plugins/lttng-utils/plugin.c + +plugins_lttng_utils_babeltrace_plugin_lttng_utils_la_LDFLAGS = \ + $(AM_LDFLAGS) \ + $(LT_NO_UNDEFINED) \ + -avoid-version -module $(LD_NOTEXT) \ + $(ELFUTILS_LIBS) + +plugins_lttng_utils_babeltrace_plugin_lttng_utils_la_LIBADD = \ + plugins/lttng-utils/debug-info/libdebug-info.la + +if !ENABLE_BUILT_IN_PLUGINS +plugins_lttng_utils_babeltrace_plugin_lttng_utils_la_LIBADD += \ + lib/libbabeltrace2.la \ + common/libcommon.la \ + logging/liblogging.la \ + plugins/common/param-validation/libparam-validation.la +endif # !ENABLE_BUILT_IN_PLUGINS +endif # ENABLE_DEBUG_INFO + +EXTRA_DIST = \ + cpp-common/vendor/optional-lite/optional.hpp.license \ + cpp-common/vendor/span-lite/span.hpp.license \ + cpp-common/vendor/string-view-lite/string_view.hpp.license diff --git a/src/Makefile.common.inc b/src/Makefile.common.inc new file mode 100644 index 00000000..0d71e95f --- /dev/null +++ b/src/Makefile.common.inc @@ -0,0 +1,21 @@ +# SPDX-FileCopyrightText: 2017-2024 EfficiOS, Inc. +# SPDX-License-Identifier: MIT + +# Path to the plugins build directory. +PLUGINS_PATH = $(abs_top_builddir)/src/plugins + +# Takes a plugin name and outputs the needed LDFLAGS to embed it. +# +# The --whole-archive option is important here. From the GNU linker's +# documentation: +# +# For each archive mentioned on the command line after the +# --whole-archive option, include every object file in the archive in +# the link, rather than searching the archive for the required object +# files. +# +# In our case, we find the plugins thanks to special sections in the +# binary that are filled by plugin objects. If the linker discards those +# symbols because the CLI does not use them directly, the CLI reports +# no plugins found (plugins are effectively not embedded). +pluginarchive = $(LD_WHOLE_ARCHIVE)$(PLUGINS_PATH)/$(1)/.libs/babeltrace-plugin-$(1).a$(LD_NO_WHOLE_ARCHIVE) diff --git a/src/argpar/Makefile.am b/src/argpar/Makefile.am deleted file mode 100644 index 385d19b5..00000000 --- a/src/argpar/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -# SPDX-License-Identifier: MIT - -noinst_LTLIBRARIES = libargpar.la - -libargpar_la_SOURCES = argpar.c argpar.h diff --git a/src/argpar/argpar.h b/src/argpar/argpar.h index 27503c56..e34b209a 100644 --- a/src/argpar/argpar.h +++ b/src/argpar/argpar.h @@ -243,7 +243,7 @@ For example, with the following command line (all options have no argument): @code{.unparsed} --f -m meow --jus mix --kilo +-f -m meow --just mix --kilo @endcode The original argument index of \c meow is 2 while the original @@ -278,7 +278,7 @@ For example, with the following command line (all options have no argument): @code{.unparsed} --f -m meow --jus mix --kilo +-f -m meow --just mix --kilo @endcode The non-option index of \c meow is 0 while the original diff --git a/src/autodisc/Makefile.am b/src/autodisc/Makefile.am deleted file mode 100644 index addff745..00000000 --- a/src/autodisc/Makefile.am +++ /dev/null @@ -1,7 +0,0 @@ -# SPDX-License-Identifier: MIT - -noinst_LTLIBRARIES = libbabeltrace2-autodisc.la - -libbabeltrace2_autodisc_la_SOURCES = \ - autodisc.c \ - autodisc.h diff --git a/src/autodisc/autodisc.c b/src/autodisc/autodisc.c index 1a4f07dc..d171a33d 100644 --- a/src/autodisc/autodisc.c +++ b/src/autodisc/autodisc.c @@ -5,7 +5,7 @@ */ #define BT_LOG_TAG "CLI-CFG-SRC-AUTO-DISC" -#define BT_LOG_OUTPUT_LEVEL log_level +#define BT_LOG_OUTPUT_LEVEL ((enum bt_log_level) log_level) #include "logging/log.h" #include @@ -14,9 +14,9 @@ #include "common/common.h" #define BT_AUTODISC_LOG_AND_APPEND(_lvl, _fmt, ...) \ - do { \ - BT_LOG_WRITE(_lvl, BT_LOG_TAG, _fmt, ##__VA_ARGS__); \ - (void) BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN( \ + do { \ + BT_LOG_WRITE_PRINTF(_lvl, BT_LOG_TAG, _fmt, ##__VA_ARGS__); \ + (void) BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN( \ "Source auto-discovery", _fmt, ##__VA_ARGS__); \ } while (0) @@ -347,7 +347,7 @@ auto_source_discovery_internal_status support_info_query_all_sources( const bt_component_class_source *source; const bt_plugin *plugin; const bt_value *group; - double weigth; + double weight; } winner = { NULL, NULL, NULL, 0 }; if (interrupter && bt_interrupter_is_set(interrupter)) { @@ -479,7 +479,7 @@ auto_source_discovery_internal_status support_info_query_all_sources( bt_plugin_get_name(plugin), bt_component_class_get_name(cc), input, input_type, weight, group_value ? bt_value_string_get(group_value) : "(none)"); - if (weight > winner.weigth) { + if (weight > winner.weight) { winner.source = source_cc; winner.plugin = plugin; @@ -487,7 +487,7 @@ auto_source_discovery_internal_status support_info_query_all_sources( winner.group = group_value; bt_value_get_ref(winner.group); - winner.weigth = weight; + winner.weight = weight; } } else if (query_status == BT_QUERY_EXECUTOR_QUERY_STATUS_ERROR) { BT_AUTODISC_LOGE_APPEND_CAUSE("babeltrace.support-info query failed."); @@ -516,7 +516,7 @@ auto_source_discovery_internal_status support_info_query_all_sources( group = winner.group ? bt_value_string_get(winner.group) : NULL; BT_LOGI("Input awarded: input=%s, type=%s, component-class-name=source.%s.%s, weight=%f, group=%s", - input, input_type, plugin_name, source_name, winner.weigth, group ? group : "(none)"); + input, input_type, plugin_name, source_name, winner.weight, group ? group : "(none)"); status = auto_source_discovery_add(auto_disc, plugin_name, source_name, group, input, original_input_index, log_level); @@ -579,6 +579,7 @@ auto_source_discovery_internal_status auto_discover_source_for_input_as_dir_or_f { auto_source_discovery_internal_status status; GError *error = NULL; + GDir *dir = NULL; if (g_file_test(input->str, G_FILE_TEST_IS_REGULAR)) { /* It's a file. */ @@ -587,7 +588,6 @@ auto_source_discovery_internal_status auto_discover_source_for_input_as_dir_or_f component_class_restrict, log_level, auto_disc, interrupter); } else if (g_file_test(input->str, G_FILE_TEST_IS_DIR)) { - GDir *dir; const gchar *dirent; gsize saved_input_len; int dir_status = AUTO_SOURCE_DISCOVERY_INTERNAL_STATUS_NO_MATCH; @@ -658,8 +658,6 @@ auto_source_discovery_internal_status auto_discover_source_for_input_as_dir_or_f } while (dirent); status = dir_status; - - g_dir_close(dir); } else { BT_LOGD("Skipping %s, not a file or directory", input->str); status = AUTO_SOURCE_DISCOVERY_INTERNAL_STATUS_NO_MATCH; @@ -671,6 +669,9 @@ error: status = AUTO_SOURCE_DISCOVERY_INTERNAL_STATUS_ERROR; end: + if (dir) { + g_dir_close(dir); + } if (error) { g_error_free(error); diff --git a/src/babeltrace2-ctf-writer.pc.in b/src/babeltrace2-ctf-writer.pc.in index 960f5b47..f3514f7a 100644 --- a/src/babeltrace2-ctf-writer.pc.in +++ b/src/babeltrace2-ctf-writer.pc.in @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: 2019 EfficiOS, Inc. +# SPDX-License-Identifier: MIT + prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ diff --git a/src/babeltrace2.pc.in b/src/babeltrace2.pc.in index 8d812a5b..0cdf11f8 100644 --- a/src/babeltrace2.pc.in +++ b/src/babeltrace2.pc.in @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: 2019 EfficiOS, Inc. +# SPDX-License-Identifier: MIT + prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ diff --git a/src/bindings/Makefile.am b/src/bindings/Makefile.am deleted file mode 100644 index d8ee190a..00000000 --- a/src/bindings/Makefile.am +++ /dev/null @@ -1,5 +0,0 @@ -# SPDX-License-Identifier: MIT - -if ENABLE_PYTHON_BINDINGS -SUBDIRS = python -endif diff --git a/src/bindings/python/Makefile.am b/src/bindings/python/Makefile.am deleted file mode 100644 index cc6c233b..00000000 --- a/src/bindings/python/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -# SPDX-License-Identifier: MIT - -SUBDIRS = bt2 diff --git a/src/bindings/python/bt2/.gitignore b/src/bindings/python/bt2/.gitignore index ab27d64e..fc7a23f1 100644 --- a/src/bindings/python/bt2/.gitignore +++ b/src/bindings/python/bt2/.gitignore @@ -1,3 +1,6 @@ +# SPDX-FileCopyrightText: 2019-2020 EfficiOS, Inc. +# SPDX-License-Identifier: MIT + bt2/native_bt.py bt2/native_bt.c bt2/native_bt.d diff --git a/src/bindings/python/bt2/Makefile.am b/src/bindings/python/bt2/Makefile.am index c8e3eb44..77b3bec5 100644 --- a/src/bindings/python/bt2/Makefile.am +++ b/src/bindings/python/bt2/Makefile.am @@ -1,3 +1,4 @@ +# SPDX-FileCopyrightText: 2019-2023 EfficiOS, Inc. # SPDX-License-Identifier: MIT # Since the shared object used by the python bindings is not built with @@ -94,11 +95,11 @@ STATIC_BINDINGS_DEPS = \ # Convenience static libraries on which the Python bindings library depends. # These are listed in the setup.py(.in) file. STATIC_LIBRARIES_DEPS = \ - $(top_builddir)/src/autodisc/libbabeltrace2-autodisc.la \ - $(top_builddir)/src/logging/libbabeltrace2-logging.la \ - $(top_builddir)/src/common/libbabeltrace2-common.la \ - $(top_builddir)/src/py-common/libbabeltrace2-py-common.la \ - $(top_builddir)/src/string-format/libbabeltrace2-string-format.la + $(top_builddir)/src/autodisc/libautodisc.la \ + $(top_builddir)/src/logging/liblogging.la \ + $(top_builddir)/src/common/libcommon.la \ + $(top_builddir)/src/py-common/libpy-common.la \ + $(top_builddir)/src/string-format/libstring-format.la GENERATED_BINDINGS_DEPS = \ bt2/native_bt.c \ @@ -119,6 +120,21 @@ WARN_CFLAGS += -Wno-null-dereference # code. WARN_CFLAGS += -Wno-deprecated-declarations +# Python 3.11 + gcc 12.2.0 gave warnings of this kind in Python.h. +WARN_CFLAGS += -Wno-redundant-decls + +# For SWIG generated code +WARN_CFLAGS += -Wno-missing-field-initializers +WARN_CFLAGS += -Wno-unused-parameter + +# SWIG 4.2.0 generates: +# +# #if __cplusplus >=201103L +# +# ... leading to some `-Wundef` warnings when building the extension as C, where +# `__cplusplus` is not defined. +WARN_CFLAGS += -Wno-undef + BUILD_FLAGS=CC="$(CC)" \ CFLAGS="$(GLIB_CFLAGS) $(AM_CFLAGS) $(CFLAGS) $(WARN_CFLAGS)" \ CPPFLAGS="$(AM_CPPFLAGS) $(CPPFLAGS) -I$(srcdir)/bt2" \ @@ -148,12 +164,25 @@ $(builddir)/bt2/native_bt.c: $(SWIG_INTERFACE_FILES) -include bt2/native_bt.d +pyinstall_verbose = $(pyinstall_verbose_@AM_V@) +pyinstall_verbose_ = $(pyinstall_verbose_@AM_DEFAULT_V@) +pyinstall_verbose_0 = @ + +# For Python < 3.12, force the use of distutils even if setuptools is +# installed. For Python >= 3.12, set the externally managed option to allow +# installation in a directory which isn't in the current PYTHONPATH. +if HAVE_PYTHON_312_OR_GREATER +PY_INSTALL_OPTS = --single-version-externally-managed +else +export SETUPTOOLS_USE_DISTUTILS=stdlib +endif + install-exec-local: build-python-bindings.stamp - @opts="--prefix=$(prefix) --record $(INSTALLED_FILES) --verbose --no-compile $(DISTSETUPOPTS)"; \ + $(pyinstall_verbose)opts="--prefix=$(prefix) --exec-prefix=$(exec_prefix) --record $(INSTALLED_FILES) --verbose --no-compile $(DISTSETUPOPTS)"; \ if [ "$(DESTDIR)" != "" ]; then \ opts="$$opts --root=$(DESTDIR)"; \ fi; \ - $(PYTHON) $(builddir)/setup.py install $$opts; + $(PYTHON) $(builddir)/setup.py install $(PY_INSTALL_OPTS) $$opts; clean-local: rm -rf $(builddir)/build diff --git a/src/bindings/python/bt2/bt2/__init__.py b/src/bindings/python/bt2/bt2/__init__.py index 38bb9b17..2dd7dc36 100644 --- a/src/bindings/python/bt2/bt2/__init__.py +++ b/src/bindings/python/bt2/bt2/__init__.py @@ -2,182 +2,217 @@ # # Copyright (c) 2017 Philippe Proulx +import os import sys +# With Python ≥ 3.8 on Windows, the DLL lookup mechanism to load native +# modules doesn't search the `PATH` environment variable like everything +# else on this platform. +# +# See . +# +# Restore this behaviour by doing it manually. +if os.name == "nt" and sys.version_info >= (3, 8): + for path in os.getenv("PATH", "").split(os.pathsep): + if os.path.exists(path) and path != ".": + os.add_dll_directory(path) + +del os + + +from bt2.mip import get_maximal_mip_version, get_greatest_operative_mip_version +from bt2.error import ( + ComponentClassType, + _Error, + _ErrorCause, + _MemoryError, + _ComponentErrorCause, + _ComponentClassErrorCause, + _MessageIteratorErrorCause, +) +from bt2.field import ( + _BoolField, + _RealField, + _ArrayField, + _OptionField, + _StringField, + _IntegerField, + _VariantField, + _BitArrayField, + _BoolFieldConst, + _RealFieldConst, + _StructureField, + _ArrayFieldConst, + _EnumerationField, + _OptionFieldConst, + _StaticArrayField, + _StringFieldConst, + _DynamicArrayField, + _IntegerFieldConst, + _VariantFieldConst, + _BitArrayFieldConst, + _SignedIntegerField, + _StructureFieldConst, + _UnsignedIntegerField, + _EnumerationFieldConst, + _StaticArrayFieldConst, + _DynamicArrayFieldConst, + _SignedEnumerationField, + _SignedIntegerFieldConst, + _DoublePrecisionRealField, + _SinglePrecisionRealField, + _UnsignedEnumerationField, + _UnsignedIntegerFieldConst, + _SignedEnumerationFieldConst, + _DoublePrecisionRealFieldConst, + _SinglePrecisionRealFieldConst, + _UnsignedEnumerationFieldConst, +) +from bt2.graph import Graph +from bt2.utils import Stop, TryAgain, UnknownObject, _OverflowError +from bt2.value import ( + MapValue, + BoolValue, + RealValue, + ArrayValue, + StringValue, + SignedIntegerValue, + UnsignedIntegerValue, + create_value, + _IntegerValue, + _MapValueConst, + _BoolValueConst, + _RealValueConst, + _ArrayValueConst, + _StringValueConst, + _IntegerValueConst, + _SignedIntegerValueConst, + _UnsignedIntegerValueConst, +) +from bt2.plugin import find_plugin, find_plugins, find_plugins_in_path +from bt2.logging import ( + LoggingLevel, + get_global_logging_level, + set_global_logging_level, + get_minimal_logging_level, +) +from bt2.message import ( + _EventMessage, + _PacketEndMessage, + _StreamEndMessage, + _EventMessageConst, + _PacketEndMessageConst, + _StreamEndMessageConst, + _DiscardedEventsMessage, + _PacketBeginningMessage, + _StreamBeginningMessage, + _DiscardedPacketsMessage, + _DiscardedEventsMessageConst, + _PacketBeginningMessageConst, + _StreamBeginningMessageConst, + _DiscardedPacketsMessageConst, + _MessageIteratorInactivityMessage, + _MessageIteratorInactivityMessageConst, +) +from bt2.version import __version__ +from bt2.component import ( + _UserSinkComponent, + _SinkComponentConst, + _IncompleteUserClass, + _UserFilterComponent, + _UserSourceComponent, + _FilterComponentConst, + _SourceComponentConst, + _SinkComponentClassConst, + _FilterComponentClassConst, + _SourceComponentClassConst, +) +from bt2.py_plugin import register_plugin, plugin_component_class +from bt2.field_path import ( + FieldPathScope, + _IndexFieldPathItem, + _CurrentArrayElementFieldPathItem, + _CurrentOptionContentFieldPathItem, +) + # import all public names from bt2.clock_class import ClockClassOffset -from bt2.clock_snapshot import _ClockSnapshotConst -from bt2.clock_snapshot import _UnknownClockSnapshot -from bt2.component import _SourceComponentClassConst -from bt2.component import _FilterComponentClassConst -from bt2.component import _SinkComponentClassConst -from bt2.component import _SourceComponentConst -from bt2.component import _FilterComponentConst -from bt2.component import _SinkComponentConst -from bt2.component import _UserSourceComponent -from bt2.component import _UserFilterComponent -from bt2.component import _UserSinkComponent -from bt2.component_descriptor import ComponentDescriptor -from bt2.error import ComponentClassType -from bt2.error import _ErrorCause -from bt2.error import _ComponentErrorCause -from bt2.error import _ComponentClassErrorCause -from bt2.error import _MessageIteratorErrorCause -from bt2.error import _Error from bt2.event_class import EventClassLogLevel -from bt2.field import _BoolField -from bt2.field import _BitArrayField -from bt2.field import _IntegerField -from bt2.field import _UnsignedIntegerField -from bt2.field import _SignedIntegerField -from bt2.field import _RealField -from bt2.field import _SinglePrecisionRealField -from bt2.field import _DoublePrecisionRealField -from bt2.field import _EnumerationField -from bt2.field import _UnsignedEnumerationField -from bt2.field import _SignedEnumerationField -from bt2.field import _StringField -from bt2.field import _StructureField -from bt2.field import _OptionField -from bt2.field import _VariantField -from bt2.field import _ArrayField -from bt2.field import _StaticArrayField -from bt2.field import _DynamicArrayField -from bt2.field import _BoolFieldConst -from bt2.field import _BitArrayFieldConst -from bt2.field import _IntegerFieldConst -from bt2.field import _UnsignedIntegerFieldConst -from bt2.field import _SignedIntegerFieldConst -from bt2.field import _RealFieldConst -from bt2.field import _SinglePrecisionRealFieldConst -from bt2.field import _DoublePrecisionRealFieldConst -from bt2.field import _EnumerationFieldConst -from bt2.field import _UnsignedEnumerationFieldConst -from bt2.field import _SignedEnumerationFieldConst -from bt2.field import _StringFieldConst -from bt2.field import _StructureFieldConst -from bt2.field import _OptionFieldConst -from bt2.field import _VariantFieldConst -from bt2.field import _ArrayFieldConst -from bt2.field import _StaticArrayFieldConst -from bt2.field import _DynamicArrayFieldConst -from bt2.field_class import IntegerDisplayBase -from bt2.field_class import _BoolFieldClass -from bt2.field_class import _BitArrayFieldClass -from bt2.field_class import _IntegerFieldClass -from bt2.field_class import _UnsignedIntegerFieldClass -from bt2.field_class import _SignedIntegerFieldClass -from bt2.field_class import _RealFieldClass -from bt2.field_class import _EnumerationFieldClass -from bt2.field_class import _UnsignedEnumerationFieldClass -from bt2.field_class import _SignedEnumerationFieldClass -from bt2.field_class import _StringFieldClass -from bt2.field_class import _StructureFieldClass -from bt2.field_class import _OptionFieldClass -from bt2.field_class import _OptionWithSelectorFieldClass -from bt2.field_class import _OptionWithBoolSelectorFieldClass -from bt2.field_class import _OptionWithIntegerSelectorFieldClass -from bt2.field_class import _OptionWithUnsignedIntegerSelectorFieldClass -from bt2.field_class import _OptionWithSignedIntegerSelectorFieldClass -from bt2.field_class import _VariantFieldClass -from bt2.field_class import _VariantFieldClassWithoutSelector -from bt2.field_class import _VariantFieldClassWithIntegerSelector -from bt2.field_class import _VariantFieldClassWithUnsignedIntegerSelector -from bt2.field_class import _VariantFieldClassWithSignedIntegerSelector -from bt2.field_class import _ArrayFieldClass -from bt2.field_class import _StaticArrayFieldClass -from bt2.field_class import _DynamicArrayFieldClass -from bt2.field_class import _DynamicArrayWithLengthFieldFieldClass -from bt2.field_class import _BoolFieldClassConst -from bt2.field_class import _BitArrayFieldClassConst -from bt2.field_class import _IntegerFieldClassConst -from bt2.field_class import _UnsignedIntegerFieldClassConst -from bt2.field_class import _SignedIntegerFieldClassConst -from bt2.field_class import _RealFieldClassConst -from bt2.field_class import _EnumerationFieldClassConst -from bt2.field_class import _UnsignedEnumerationFieldClassConst -from bt2.field_class import _SignedEnumerationFieldClassConst -from bt2.field_class import _StringFieldClassConst -from bt2.field_class import _StructureFieldClassConst -from bt2.field_class import _OptionFieldClassConst -from bt2.field_class import _OptionWithSelectorFieldClassConst -from bt2.field_class import _OptionWithBoolSelectorFieldClassConst -from bt2.field_class import _OptionWithIntegerSelectorFieldClassConst -from bt2.field_class import _OptionWithUnsignedIntegerSelectorFieldClassConst -from bt2.field_class import _OptionWithSignedIntegerSelectorFieldClassConst -from bt2.field_class import _VariantFieldClassConst -from bt2.field_class import _VariantFieldClassWithoutSelectorConst -from bt2.field_class import _VariantFieldClassWithIntegerSelectorConst -from bt2.field_class import _VariantFieldClassWithUnsignedIntegerSelectorConst -from bt2.field_class import _VariantFieldClassWithSignedIntegerSelectorConst -from bt2.field_class import _ArrayFieldClassConst -from bt2.field_class import _StaticArrayFieldClassConst -from bt2.field_class import _DynamicArrayFieldClassConst -from bt2.field_class import _DynamicArrayWithLengthFieldFieldClassConst -from bt2.field_path import FieldPathScope -from bt2.field_path import _IndexFieldPathItem -from bt2.field_path import _CurrentArrayElementFieldPathItem -from bt2.field_path import _CurrentOptionContentFieldPathItem -from bt2.graph import Graph -from bt2.integer_range_set import SignedIntegerRange -from bt2.integer_range_set import UnsignedIntegerRange -from bt2.integer_range_set import SignedIntegerRangeSet -from bt2.integer_range_set import UnsignedIntegerRangeSet -from bt2.integer_range_set import _SignedIntegerRangeConst -from bt2.integer_range_set import _UnsignedIntegerRangeConst -from bt2.integer_range_set import _SignedIntegerRangeSetConst -from bt2.integer_range_set import _UnsignedIntegerRangeSetConst +from bt2.field_class import ( + IntegerDisplayBase, + _BoolFieldClass, + _RealFieldClass, + _ArrayFieldClass, + _OptionFieldClass, + _StringFieldClass, + _IntegerFieldClass, + _VariantFieldClass, + _BitArrayFieldClass, + _BoolFieldClassConst, + _RealFieldClassConst, + _StructureFieldClass, + _ArrayFieldClassConst, + _EnumerationFieldClass, + _OptionFieldClassConst, + _StaticArrayFieldClass, + _StringFieldClassConst, + _DynamicArrayFieldClass, + _IntegerFieldClassConst, + _VariantFieldClassConst, + _BitArrayFieldClassConst, + _SignedIntegerFieldClass, + _StructureFieldClassConst, + _UnsignedIntegerFieldClass, + _EnumerationFieldClassConst, + _StaticArrayFieldClassConst, + _DynamicArrayFieldClassConst, + _SignedEnumerationFieldClass, + _OptionWithSelectorFieldClass, + _SignedIntegerFieldClassConst, + _UnsignedEnumerationFieldClass, + _UnsignedIntegerFieldClassConst, + _OptionWithBoolSelectorFieldClass, + _SignedEnumerationFieldClassConst, + _VariantFieldClassWithoutSelector, + _OptionWithSelectorFieldClassConst, + _UnsignedEnumerationFieldClassConst, + _OptionWithIntegerSelectorFieldClass, + _VariantFieldClassWithIntegerSelector, + _DynamicArrayWithLengthFieldFieldClass, + _OptionWithBoolSelectorFieldClassConst, + _VariantFieldClassWithoutSelectorConst, + _OptionWithIntegerSelectorFieldClassConst, + _OptionWithSignedIntegerSelectorFieldClass, + _VariantFieldClassWithIntegerSelectorConst, + _DynamicArrayWithLengthFieldFieldClassConst, + _VariantFieldClassWithSignedIntegerSelector, + _OptionWithUnsignedIntegerSelectorFieldClass, + _VariantFieldClassWithUnsignedIntegerSelector, + _OptionWithSignedIntegerSelectorFieldClassConst, + _VariantFieldClassWithSignedIntegerSelectorConst, + _OptionWithUnsignedIntegerSelectorFieldClassConst, + _VariantFieldClassWithUnsignedIntegerSelectorConst, +) from bt2.interrupter import Interrupter -from bt2.logging import LoggingLevel -from bt2.logging import get_minimal_logging_level -from bt2.logging import get_global_logging_level -from bt2.logging import set_global_logging_level -from bt2.message import _EventMessage -from bt2.message import _PacketBeginningMessage -from bt2.message import _PacketEndMessage -from bt2.message import _StreamBeginningMessage -from bt2.message import _StreamEndMessage -from bt2.message import _MessageIteratorInactivityMessage -from bt2.message import _DiscardedEventsMessage -from bt2.message import _DiscardedPacketsMessage -from bt2.message import _EventMessageConst -from bt2.message import _PacketBeginningMessageConst -from bt2.message import _PacketEndMessageConst -from bt2.message import _StreamBeginningMessageConst -from bt2.message import _StreamEndMessageConst -from bt2.message import _MessageIteratorInactivityMessageConst -from bt2.message import _DiscardedEventsMessageConst -from bt2.message import _DiscardedPacketsMessageConst -from bt2.message_iterator import _UserMessageIterator -from bt2.mip import get_greatest_operative_mip_version -from bt2.mip import get_maximal_mip_version -from bt2.plugin import find_plugins_in_path -from bt2.plugin import find_plugins -from bt2.plugin import find_plugin -from bt2.py_plugin import plugin_component_class -from bt2.py_plugin import register_plugin +from bt2.clock_snapshot import _ClockSnapshotConst, _UnknownClockSnapshot from bt2.query_executor import QueryExecutor -from bt2.trace_collection_message_iterator import AutoSourceComponentSpec -from bt2.trace_collection_message_iterator import ComponentSpec -from bt2.trace_collection_message_iterator import TraceCollectionMessageIterator -from bt2.value import create_value -from bt2.value import BoolValue -from bt2.value import _IntegerValue -from bt2.value import UnsignedIntegerValue -from bt2.value import SignedIntegerValue -from bt2.value import RealValue -from bt2.value import StringValue -from bt2.value import ArrayValue -from bt2.value import MapValue -from bt2.value import _BoolValueConst -from bt2.value import _IntegerValueConst -from bt2.value import _UnsignedIntegerValueConst -from bt2.value import _SignedIntegerValueConst -from bt2.value import _RealValueConst -from bt2.value import _StringValueConst -from bt2.value import _ArrayValueConst -from bt2.value import _MapValueConst -from bt2.version import __version__ +from bt2.message_iterator import _UserMessageIterator +from bt2.integer_range_set import ( + SignedIntegerRange, + UnsignedIntegerRange, + SignedIntegerRangeSet, + UnsignedIntegerRangeSet, + _SignedIntegerRangeConst, + _UnsignedIntegerRangeConst, + _SignedIntegerRangeSetConst, + _UnsignedIntegerRangeSetConst, +) +from bt2.component_descriptor import ComponentDescriptor +from bt2.trace_collection_message_iterator import ( + ComponentSpec, + AutoSourceComponentSpec, + TraceCollectionMessageIterator, +) if (sys.version_info.major, sys.version_info.minor) != (3, 4): @@ -227,39 +262,11 @@ if (sys.version_info.major, sys.version_info.minor) != (3, 4): del sys -class _MemoryError(_Error): - """Raised when an operation fails due to memory issues.""" - - -class UnknownObject(Exception): - """ - Raised when a component class handles a query for an object it doesn't - know about. - """ - - pass - - -class _OverflowError(_Error, OverflowError): - pass - - -class TryAgain(Exception): - pass - - -class Stop(StopIteration): - pass - - -class _IncompleteUserClass(Exception): - pass - - def _init_and_register_exit(): - from bt2 import native_bt import atexit + from bt2 import native_bt + atexit.register(native_bt.bt2_exit_handler) native_bt.bt2_init_from_bt2() diff --git a/src/bindings/python/bt2/bt2/clock_class.py b/src/bindings/python/bt2/bt2/clock_class.py index 4cdea396..c7527c77 100644 --- a/src/bindings/python/bt2/bt2/clock_class.py +++ b/src/bindings/python/bt2/bt2/clock_class.py @@ -2,15 +2,18 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt, object, utils -from bt2 import value as bt2_value import uuid as uuidp +from bt2 import utils as bt2_utils +from bt2 import value as bt2_value +from bt2 import object as bt2_object +from bt2 import native_bt + class ClockClassOffset: def __init__(self, seconds=0, cycles=0): - utils._check_int64(seconds) - utils._check_int64(cycles) + bt2_utils._check_int64(seconds) + bt2_utils._check_int64(cycles) self._seconds = seconds self._cycles = cycles @@ -30,9 +33,15 @@ class ClockClassOffset: return (self.seconds, self.cycles) == (other.seconds, other.cycles) -class _ClockClassConst(object._SharedObject): - _get_ref = staticmethod(native_bt.clock_class_get_ref) - _put_ref = staticmethod(native_bt.clock_class_put_ref) +class _ClockClassConst(bt2_object._SharedObject): + @staticmethod + def _get_ref(ptr): + native_bt.clock_class_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.clock_class_put_ref(ptr) + _create_value_from_ptr_and_get_ref = staticmethod( bt2_value._create_from_const_ptr_and_get_ref ) @@ -82,10 +91,10 @@ class _ClockClassConst(object._SharedObject): return uuidp.UUID(bytes=uuid_bytes) def cycles_to_ns_from_origin(self, cycles): - utils._check_uint64(cycles) + bt2_utils._check_uint64(cycles) status, ns = native_bt.clock_class_cycles_to_ns_from_origin(self._ptr, cycles) error_msg = "cannot convert clock value to nanoseconds from origin for given clock class" - utils._handle_func_status(status, error_msg) + bt2_utils._handle_func_status(status, error_msg) return ns @@ -99,45 +108,47 @@ class _ClockClass(_ClockClassConst): def _user_attributes(self, user_attributes): value = bt2_value.create_value(user_attributes) - utils._check_type(value, bt2_value.MapValue) + bt2_utils._check_type(value, bt2_value.MapValue) native_bt.clock_class_set_user_attributes(self._ptr, value._ptr) _user_attributes = property(fset=_user_attributes) def _name(self, name): - utils._check_str(name) + bt2_utils._check_str(name) status = native_bt.clock_class_set_name(self._ptr, name) - utils._handle_func_status(status, "cannot set clock class object's name") + bt2_utils._handle_func_status(status, "cannot set clock class object's name") _name = property(fset=_name) def _description(self, description): - utils._check_str(description) + bt2_utils._check_str(description) status = native_bt.clock_class_set_description(self._ptr, description) - utils._handle_func_status(status, "cannot set clock class object's description") + bt2_utils._handle_func_status( + status, "cannot set clock class object's description" + ) _description = property(fset=_description) def _frequency(self, frequency): - utils._check_uint64(frequency) + bt2_utils._check_uint64(frequency) native_bt.clock_class_set_frequency(self._ptr, frequency) _frequency = property(fset=_frequency) def _precision(self, precision): - utils._check_uint64(precision) + bt2_utils._check_uint64(precision) native_bt.clock_class_set_precision(self._ptr, precision) _precision = property(fset=_precision) def _offset(self, offset): - utils._check_type(offset, ClockClassOffset) + bt2_utils._check_type(offset, ClockClassOffset) native_bt.clock_class_set_offset(self._ptr, offset.seconds, offset.cycles) _offset = property(fset=_offset) def _origin_is_unix_epoch(self, origin_is_unix_epoch): - utils._check_bool(origin_is_unix_epoch) + bt2_utils._check_bool(origin_is_unix_epoch) native_bt.clock_class_set_origin_is_unix_epoch( self._ptr, int(origin_is_unix_epoch) ) @@ -145,7 +156,7 @@ class _ClockClass(_ClockClassConst): _origin_is_unix_epoch = property(fset=_origin_is_unix_epoch) def _uuid(self, uuid): - utils._check_type(uuid, uuidp.UUID) + bt2_utils._check_type(uuid, uuidp.UUID) native_bt.clock_class_set_uuid(self._ptr, uuid.bytes) _uuid = property(fset=_uuid) diff --git a/src/bindings/python/bt2/bt2/clock_snapshot.py b/src/bindings/python/bt2/bt2/clock_snapshot.py index 6c2e3285..82591463 100644 --- a/src/bindings/python/bt2/bt2/clock_snapshot.py +++ b/src/bindings/python/bt2/bt2/clock_snapshot.py @@ -2,14 +2,17 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt, object, utils import numbers -from bt2 import clock_class as bt2_clock_class import functools +from bt2 import utils as bt2_utils +from bt2 import object as bt2_object +from bt2 import native_bt +from bt2 import clock_class as bt2_clock_class + @functools.total_ordering -class _ClockSnapshotConst(object._UniqueObject): +class _ClockSnapshotConst(bt2_object._UniqueObject): @property def clock_class(self): cc_ptr = native_bt.clock_snapshot_borrow_clock_class_const(self._ptr) @@ -23,7 +26,7 @@ class _ClockSnapshotConst(object._UniqueObject): @property def ns_from_origin(self): status, ns = native_bt.clock_snapshot_get_ns_from_origin(self._ptr) - utils._handle_func_status( + bt2_utils._handle_func_status( status, "cannot get clock snapshot's nanoseconds from origin" ) return ns diff --git a/src/bindings/python/bt2/bt2/component.py b/src/bindings/python/bt2/bt2/component.py index 7ae6fe25..30f0849c 100644 --- a/src/bindings/python/bt2/bt2/component.py +++ b/src/bindings/python/bt2/bt2/component.py @@ -2,16 +2,24 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt, object, utils -from bt2 import message_iterator as bt2_message_iterator +import sys import collections.abc + +from bt2 import port as bt2_port +from bt2 import error as bt2_error +from bt2 import utils as bt2_utils from bt2 import value as bt2_value -from bt2 import trace_class as bt2_trace_class +from bt2 import object as bt2_object +from bt2 import native_bt from bt2 import clock_class as bt2_clock_class +from bt2 import trace_class as bt2_trace_class from bt2 import query_executor as bt2_query_executor -from bt2 import port as bt2_port -import sys -import bt2 +from bt2 import message_iterator as bt2_message_iterator +from bt2 import integer_range_set as bt2_integer_range_set + + +class _IncompleteUserClass(Exception): + pass # This class wraps a component class pointer. This component class could @@ -25,7 +33,7 @@ import bt2 # pointer to a 'bt_component_class *'. -class _ComponentClassConst(object._SharedObject): +class _ComponentClassConst(bt2_object._SharedObject): @property def name(self): ptr = self._bt_as_component_class_ptr(self._ptr) @@ -58,24 +66,42 @@ class _ComponentClassConst(object._SharedObject): class _SourceComponentClassConst(_ComponentClassConst): - _get_ref = staticmethod(native_bt.component_class_source_get_ref) - _put_ref = staticmethod(native_bt.component_class_source_put_ref) + @staticmethod + def _get_ref(ptr): + native_bt.component_class_source_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.component_class_source_put_ref(ptr) + _bt_as_component_class_ptr = staticmethod( native_bt.component_class_source_as_component_class ) class _FilterComponentClassConst(_ComponentClassConst): - _get_ref = staticmethod(native_bt.component_class_filter_get_ref) - _put_ref = staticmethod(native_bt.component_class_filter_put_ref) + @staticmethod + def _get_ref(ptr): + native_bt.component_class_filter_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.component_class_filter_put_ref(ptr) + _bt_as_component_class_ptr = staticmethod( native_bt.component_class_filter_as_component_class ) class _SinkComponentClassConst(_ComponentClassConst): - _get_ref = staticmethod(native_bt.component_class_sink_get_ref) - _put_ref = staticmethod(native_bt.component_class_sink_put_ref) + @staticmethod + def _get_ref(ptr): + native_bt.component_class_sink_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.component_class_sink_put_ref(ptr) + _bt_as_component_class_ptr = staticmethod( native_bt.component_class_sink_as_component_class ) @@ -104,7 +130,6 @@ class _PortIterator(collections.abc.Iterator): class _ComponentPorts(collections.abc.Mapping): - # component_ptr is a bt_component_source *, bt_component_filter * or # bt_component_sink *. Its type must match the type expected by the # functions passed as arguments. @@ -124,7 +149,7 @@ class _ComponentPorts(collections.abc.Mapping): self._port_pycls = port_pycls def __getitem__(self, key): - utils._check_str(key) + bt2_utils._check_str(key) port_ptr = self._borrow_port_ptr_by_name(self._component_ptr, key) if port_ptr is None: @@ -218,9 +243,14 @@ class _SinkComponentConst(_ComponentConst): # This is analogous to _SourceComponentClassConst, but for source # component objects. -class _GenericSourceComponentConst(object._SharedObject, _SourceComponentConst): - _get_ref = staticmethod(native_bt.component_source_get_ref) - _put_ref = staticmethod(native_bt.component_source_put_ref) +class _GenericSourceComponentConst(bt2_object._SharedObject, _SourceComponentConst): + @staticmethod + def _get_ref(ptr): + native_bt.component_source_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.component_source_put_ref(ptr) @property def output_ports(self): @@ -235,9 +265,14 @@ class _GenericSourceComponentConst(object._SharedObject, _SourceComponentConst): # This is analogous to _FilterComponentClassConst, but for filter # component objects. -class _GenericFilterComponentConst(object._SharedObject, _FilterComponentConst): - _get_ref = staticmethod(native_bt.component_filter_get_ref) - _put_ref = staticmethod(native_bt.component_filter_put_ref) +class _GenericFilterComponentConst(bt2_object._SharedObject, _FilterComponentConst): + @staticmethod + def _get_ref(ptr): + native_bt.component_filter_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.component_filter_put_ref(ptr) @property def output_ports(self): @@ -262,9 +297,14 @@ class _GenericFilterComponentConst(object._SharedObject, _FilterComponentConst): # This is analogous to _SinkComponentClassConst, but for sink # component objects. -class _GenericSinkComponentConst(object._SharedObject, _SinkComponentConst): - _get_ref = staticmethod(native_bt.component_sink_get_ref) - _put_ref = staticmethod(native_bt.component_sink_put_ref) +class _GenericSinkComponentConst(bt2_object._SharedObject, _SinkComponentConst): + @staticmethod + def _get_ref(ptr): + native_bt.component_sink_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.component_sink_put_ref(ptr) @property def input_ports(self): @@ -448,12 +488,12 @@ class _UserComponentType(type): return comp_cls_name = kwargs.get("name", class_name) - utils._check_str(comp_cls_name) + bt2_utils._check_str(comp_cls_name) comp_cls_descr = None comp_cls_help = None if hasattr(cls, "__doc__") and cls.__doc__ is not None: - utils._check_str(cls.__doc__) + bt2_utils._check_str(cls.__doc__) docstring = _trim_docstring(cls.__doc__) lines = docstring.splitlines() @@ -477,7 +517,7 @@ class _UserComponentType(type): ) elif _UserSinkComponent in bases: if not hasattr(cls, "_user_consume"): - raise bt2._IncompleteUserClass( + raise _IncompleteUserClass( "cannot create component class '{}': missing a _user_consume() method".format( class_name ) @@ -487,14 +527,14 @@ class _UserComponentType(type): cls, comp_cls_name, comp_cls_descr, comp_cls_help ) else: - raise bt2._IncompleteUserClass( + raise _IncompleteUserClass( "cannot find a known component class base in the bases of '{}'".format( class_name ) ) if cc_ptr is None: - raise bt2._MemoryError( + raise bt2_error._MemoryError( "cannot create component class '{}'".format(class_name) ) @@ -527,21 +567,21 @@ class _UserComponentType(type): @staticmethod def _bt_set_iterator_class(cls, iter_cls): if iter_cls is None: - raise bt2._IncompleteUserClass( + raise _IncompleteUserClass( "cannot create component class '{}': missing message iterator class".format( cls.__name__ ) ) if not issubclass(iter_cls, bt2_message_iterator._UserMessageIterator): - raise bt2._IncompleteUserClass( + raise _IncompleteUserClass( "cannot create component class '{}': message iterator class does not inherit bt2._UserMessageIterator".format( cls.__name__ ) ) if not hasattr(iter_cls, "__next__"): - raise bt2._IncompleteUserClass( + raise _IncompleteUserClass( "cannot create component class '{}': message iterator class is missing a __next__() method".format( cls.__name__ ) @@ -550,7 +590,7 @@ class _UserComponentType(type): if hasattr(iter_cls, "_user_can_seek_ns_from_origin") and not hasattr( iter_cls, "_user_seek_ns_from_origin" ): - raise bt2._IncompleteUserClass( + raise _IncompleteUserClass( "cannot create component class '{}': message iterator class implements _user_can_seek_ns_from_origin but not _user_seek_ns_from_origin".format( cls.__name__ ) @@ -559,7 +599,7 @@ class _UserComponentType(type): if hasattr(iter_cls, "_user_can_seek_beginning") and not hasattr( iter_cls, "_user_seek_beginning" ): - raise bt2._IncompleteUserClass( + raise _IncompleteUserClass( "cannot create component class '{}': message iterator class implements _user_can_seek_beginning but not _user_seek_beginning".format( cls.__name__ ) @@ -596,9 +636,9 @@ class _UserComponentType(type): # this can raise, but the native side checks the exception range_set = cls._user_get_supported_mip_versions(params, obj, log_level) - if type(range_set) is not bt2.UnsignedIntegerRangeSet: + if type(range_set) is not bt2_integer_range_set.UnsignedIntegerRangeSet: # this can raise, but the native side checks the exception - range_set = bt2.UnsignedIntegerRangeSet(range_set) + range_set = bt2_integer_range_set.UnsignedIntegerRangeSet(range_set) # return new reference range_set._get_ref(range_set._ptr) @@ -631,7 +671,7 @@ class _UserComponentType(type): priv_query_exec._invalidate() # this can raise, but the native side checks the exception - results = bt2.create_value(results) + results = bt2_value.create_value(results) if results is None: results_ptr = native_bt.value_null @@ -643,7 +683,7 @@ class _UserComponentType(type): return int(results_ptr) def _user_query(cls, priv_query_executor, object_name, params, method_obj): - raise bt2.UnknownObject + raise bt2_utils.UnknownObject def _bt_component_class_ptr(self): return self._bt_as_component_class_ptr(self._bt_cc_ptr) @@ -753,7 +793,7 @@ class _UserComponent(metaclass=_UserComponentType): tc_ptr = native_bt.trace_class_create(ptr) if tc_ptr is None: - raise bt2._MemoryError("could not create trace class") + raise bt2_error._MemoryError("could not create trace class") tc = bt2_trace_class._TraceClass._create_from_ptr(tc_ptr) tc._assigns_automatic_stream_class_id = assigns_automatic_stream_class_id @@ -778,7 +818,7 @@ class _UserComponent(metaclass=_UserComponentType): cc_ptr = native_bt.clock_class_create(ptr) if cc_ptr is None: - raise bt2._MemoryError("could not create clock class") + raise bt2_error._MemoryError("could not create clock class") cc = bt2_clock_class._ClockClass._create_from_ptr(cc_ptr) @@ -832,7 +872,7 @@ class _UserSourceComponent(_UserComponent, _SourceComponentConst): ) def _add_output_port(self, name, user_data=None): - utils._check_str(name) + bt2_utils._check_str(name) if name in self._output_ports: raise ValueError( @@ -843,7 +883,7 @@ class _UserSourceComponent(_UserComponent, _SourceComponentConst): fn = native_bt.self_component_source_add_output_port comp_status, self_port_ptr = fn(self._bt_ptr, name, user_data) - utils._handle_func_status( + bt2_utils._handle_func_status( comp_status, "cannot add output port to source component object" ) assert self_port_ptr is not None @@ -890,7 +930,7 @@ class _UserFilterComponent(_UserComponent, _FilterComponentConst): ) def _add_output_port(self, name, user_data=None): - utils._check_str(name) + bt2_utils._check_str(name) if name in self._output_ports: raise ValueError( @@ -901,7 +941,7 @@ class _UserFilterComponent(_UserComponent, _FilterComponentConst): fn = native_bt.self_component_filter_add_output_port comp_status, self_port_ptr = fn(self._bt_ptr, name, user_data) - utils._handle_func_status( + bt2_utils._handle_func_status( comp_status, "cannot add output port to filter component object" ) assert self_port_ptr @@ -910,7 +950,7 @@ class _UserFilterComponent(_UserComponent, _FilterComponentConst): ) def _add_input_port(self, name, user_data=None): - utils._check_str(name) + bt2_utils._check_str(name) if name in self._input_ports: raise ValueError( @@ -921,7 +961,7 @@ class _UserFilterComponent(_UserComponent, _FilterComponentConst): fn = native_bt.self_component_filter_add_input_port comp_status, self_port_ptr = fn(self._bt_ptr, name, user_data) - utils._handle_func_status( + bt2_utils._handle_func_status( comp_status, "cannot add input port to filter component object" ) assert self_port_ptr @@ -960,7 +1000,7 @@ class _UserSinkComponent(_UserComponent, _SinkComponentConst): ) def _add_input_port(self, name, user_data=None): - utils._check_str(name) + bt2_utils._check_str(name) if name in self._input_ports: raise ValueError( @@ -971,7 +1011,7 @@ class _UserSinkComponent(_UserComponent, _SinkComponentConst): fn = native_bt.self_component_sink_add_input_port comp_status, self_port_ptr = fn(self._bt_ptr, name, user_data) - utils._handle_func_status( + bt2_utils._handle_func_status( comp_status, "cannot add input port to sink component object" ) assert self_port_ptr @@ -980,7 +1020,7 @@ class _UserSinkComponent(_UserComponent, _SinkComponentConst): ) def _create_message_iterator(self, input_port): - utils._check_type(input_port, bt2_port._UserComponentInputPort) + bt2_utils._check_type(input_port, bt2_port._UserComponentInputPort) if not input_port.is_connected: raise ValueError("input port is not connected") @@ -991,7 +1031,7 @@ class _UserSinkComponent(_UserComponent, _SinkComponentConst): ) = native_bt.bt2_message_iterator_create_from_sink_component( self._bt_ptr, input_port._ptr ) - utils._handle_func_status(status, "cannot create message iterator object") + bt2_utils._handle_func_status(status, "cannot create message iterator object") assert msg_iter_ptr is not None return bt2_message_iterator._UserComponentInputPortMessageIterator(msg_iter_ptr) diff --git a/src/bindings/python/bt2/bt2/component_descriptor.py b/src/bindings/python/bt2/bt2/component_descriptor.py index c09c98ef..35179ab7 100644 --- a/src/bindings/python/bt2/bt2/component_descriptor.py +++ b/src/bindings/python/bt2/bt2/component_descriptor.py @@ -2,9 +2,9 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt +from bt2 import value as bt2_value from bt2 import component as bt2_component -import bt2 +from bt2 import native_bt def _is_source_comp_cls(comp_cls): @@ -56,7 +56,7 @@ class ComponentDescriptor: raise ValueError("cannot pass a Python object to a non-Python component") self._comp_cls = component_class - self._params = bt2.create_value(params) + self._params = bt2_value.create_value(params) self._obj = obj @property diff --git a/src/bindings/python/bt2/bt2/connection.py b/src/bindings/python/bt2/bt2/connection.py index 0f1fce65..cdbe271e 100644 --- a/src/bindings/python/bt2/bt2/connection.py +++ b/src/bindings/python/bt2/bt2/connection.py @@ -2,14 +2,19 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt from bt2 import port as bt2_port from bt2 import object as bt2_object +from bt2 import native_bt class _ConnectionConst(bt2_object._SharedObject): - _get_ref = staticmethod(native_bt.connection_get_ref) - _put_ref = staticmethod(native_bt.connection_put_ref) + @staticmethod + def _get_ref(ptr): + native_bt.connection_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.connection_put_ref(ptr) @property def downstream_port(self): diff --git a/src/bindings/python/bt2/bt2/error.py b/src/bindings/python/bt2/bt2/error.py index e07a3f90..b6d0e9e1 100644 --- a/src/bindings/python/bt2/bt2/error.py +++ b/src/bindings/python/bt2/bt2/error.py @@ -2,9 +2,10 @@ # # Copyright (c) 2019 Simon Marchi -from bt2 import native_bt from collections import abc +from bt2 import native_bt + class ComponentClassType: SOURCE = native_bt.COMPONENT_CLASS_TYPE_SOURCE @@ -219,3 +220,7 @@ class _Error(Exception, abc.Sequence): def __str__(self): return self._str + + +class _MemoryError(_Error): + """Raised when an operation fails due to memory issues.""" diff --git a/src/bindings/python/bt2/bt2/event.py b/src/bindings/python/bt2/bt2/event.py index 81215a20..3ff934fd 100644 --- a/src/bindings/python/bt2/bt2/event.py +++ b/src/bindings/python/bt2/bt2/event.py @@ -2,15 +2,18 @@ # # Copyright (c) 2016-2017 Philippe Proulx -from bt2 import native_bt, object, utils -from bt2 import event_class as bt2_event_class +import collections.abc + +from bt2 import field as bt2_field +from bt2 import utils as bt2_utils +from bt2 import object as bt2_object from bt2 import packet as bt2_packet from bt2 import stream as bt2_stream -from bt2 import field as bt2_field -import collections.abc +from bt2 import native_bt +from bt2 import event_class as bt2_event_class -class _EventConst(object._UniqueObject, collections.abc.Mapping): +class _EventConst(bt2_object._UniqueObject, collections.abc.Mapping): _borrow_class_ptr = staticmethod(native_bt.event_borrow_class_const) _borrow_packet_ptr = staticmethod(native_bt.event_borrow_packet_const) _borrow_stream_ptr = staticmethod(native_bt.event_borrow_stream_const) @@ -90,7 +93,7 @@ class _EventConst(object._UniqueObject, collections.abc.Mapping): ) def __getitem__(self, key): - utils._check_str(key) + bt2_utils._check_str(key) payload_field = self.payload_field if payload_field is not None and key in payload_field: diff --git a/src/bindings/python/bt2/bt2/event_class.py b/src/bindings/python/bt2/bt2/event_class.py index cbbd807c..54ca10a6 100644 --- a/src/bindings/python/bt2/bt2/event_class.py +++ b/src/bindings/python/bt2/bt2/event_class.py @@ -2,9 +2,11 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt, object, utils -from bt2 import field_class as bt2_field_class +from bt2 import utils as bt2_utils from bt2 import value as bt2_value +from bt2 import object as bt2_object +from bt2 import native_bt +from bt2 import field_class as bt2_field_class def _bt2_stream_class(): @@ -31,9 +33,15 @@ class EventClassLogLevel: DEBUG = native_bt.EVENT_CLASS_LOG_LEVEL_DEBUG -class _EventClassConst(object._SharedObject): - _get_ref = staticmethod(native_bt.event_class_get_ref) - _put_ref = staticmethod(native_bt.event_class_put_ref) +class _EventClassConst(bt2_object._SharedObject): + @staticmethod + def _get_ref(ptr): + native_bt.event_class_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.event_class_put_ref(ptr) + _borrow_stream_class_ptr = staticmethod( native_bt.event_class_borrow_stream_class_const ) @@ -145,7 +153,7 @@ class _EventClass(_EventClassConst): def _emf_uri(self, emf_uri): status = native_bt.event_class_set_emf_uri(self._ptr, emf_uri) - utils._handle_func_status(status, "cannot set event class object's EMF URI") + bt2_utils._handle_func_status(status, "cannot set event class object's EMF URI") _emf_uri = property(fset=_emf_uri) @@ -153,7 +161,7 @@ class _EventClass(_EventClassConst): status = native_bt.event_class_set_specific_context_field_class( self._ptr, context_field_class._ptr ) - utils._handle_func_status( + bt2_utils._handle_func_status( status, "cannot set event class object's context field class" ) @@ -163,7 +171,7 @@ class _EventClass(_EventClassConst): status = native_bt.event_class_set_payload_field_class( self._ptr, payload_field_class._ptr ) - utils._handle_func_status( + bt2_utils._handle_func_status( status, "cannot set event class object's payload field class" ) @@ -179,11 +187,11 @@ class _EventClass(_EventClassConst): payload_field_class, ): if name is not None: - utils._check_str(name) + bt2_utils._check_str(name) if user_attributes is not None: value = bt2_value.create_value(user_attributes) - utils._check_type(value, bt2_value.MapValue) + bt2_utils._check_type(value, bt2_value.MapValue) if log_level is not None: log_levels = ( @@ -208,15 +216,17 @@ class _EventClass(_EventClassConst): raise ValueError("'{}' is not a valid log level".format(log_level)) if emf_uri is not None: - utils._check_str(emf_uri) + bt2_utils._check_str(emf_uri) if specific_context_field_class is not None: - utils._check_type( + bt2_utils._check_type( specific_context_field_class, bt2_field_class._StructureFieldClass ) if payload_field_class is not None: - utils._check_type(payload_field_class, bt2_field_class._StructureFieldClass) + bt2_utils._check_type( + payload_field_class, bt2_field_class._StructureFieldClass + ) _EVENT_CLASS_LOG_LEVEL_TO_OBJ = { diff --git a/src/bindings/python/bt2/bt2/field.py b/src/bindings/python/bt2/bt2/field.py index 40ce52c5..b3bdcd54 100644 --- a/src/bindings/python/bt2/bt2/field.py +++ b/src/bindings/python/bt2/bt2/field.py @@ -2,18 +2,20 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt, object, utils -from bt2 import field_class as bt2_field_class -import collections.abc -import functools -import numbers import math +import numbers +import functools +import collections.abc + +from bt2 import utils as bt2_utils +from bt2 import object as bt2_object +from bt2 import native_bt +from bt2 import field_class as bt2_field_class def _create_field_from_ptr_template( object_map, ptr, owner_ptr, owner_get_ref, owner_put_ref ): - field_class_ptr = native_bt.field_borrow_class_const(ptr) typeid = native_bt.field_class_get_type(field_class_ptr) field = object_map[typeid]._create_from_ptr_and_get_ref( @@ -50,7 +52,7 @@ def _get_leaf_field(field): return field -class _FieldConst(object._UniqueObject): +class _FieldConst(bt2_object._UniqueObject): _create_field_from_ptr = staticmethod(_create_field_from_const_ptr) _create_field_class_from_ptr_and_get_ref = staticmethod( bt2_field_class._create_field_class_from_const_ptr_and_get_ref @@ -109,7 +111,7 @@ class _BitArrayField(_BitArrayFieldConst, _Field): _NAME = "Bit array" def _value_as_integer(self, value): - utils._check_uint64(value) + bt2_utils._check_uint64(value) native_bt.field_bit_array_set_value_as_integer(self._ptr, value) value_as_integer = property( @@ -451,7 +453,7 @@ class _EnumerationFieldConst(_IntegerFieldConst): @property def labels(self): status, labels = self._get_mapping_labels(self._ptr) - utils._handle_func_status(status, "cannot get label for enumeration field") + bt2_utils._handle_func_status(status, "cannot get label for enumeration field") assert labels is not None return labels @@ -547,7 +549,7 @@ class _StringField(_StringFieldConst, _Field): def __iadd__(self, value): value = self._value_to_str(value) status = native_bt.field_string_append(self._ptr, value) - utils._handle_func_status( + bt2_utils._handle_func_status( status, "cannot append to string field object's value" ) return self @@ -621,7 +623,7 @@ class _StructureFieldConst(_ContainerFieldConst, collections.abc.Mapping): return "{{{}}}".format(", ".join(items)) def __getitem__(self, key): - utils._check_str(key) + bt2_utils._check_str(key) field_ptr = self._borrow_member_field_ptr_by_name(self._ptr, key) if field_ptr is None: @@ -632,7 +634,7 @@ class _StructureFieldConst(_ContainerFieldConst, collections.abc.Mapping): ) def member_at_index(self, index): - utils._check_uint64(index) + bt2_utils._check_uint64(index) if index >= len(self): raise IndexError @@ -709,7 +711,7 @@ class _OptionField(_OptionFieldConst, _Field): _borrow_field_ptr = staticmethod(native_bt.field_option_borrow_field) def _has_field(self, value): - utils._check_bool(value) + bt2_utils._check_bool(value) native_bt.field_option_set_has_field(self._ptr, value) has_field = property(fget=_OptionFieldConst.has_field.fget, fset=_has_field) @@ -887,9 +889,9 @@ class _DynamicArrayField(_DynamicArrayFieldConst, _ArrayField, _Field): _NAME = "Dynamic array" def _set_length(self, length): - utils._check_uint64(length) + bt2_utils._check_uint64(length) status = native_bt.field_array_dynamic_set_length(self._ptr, length) - utils._handle_func_status(status, "cannot set dynamic array length") + bt2_utils._handle_func_status(status, "cannot set dynamic array length") length = property(fget=_ArrayField._get_length, fset=_set_length) diff --git a/src/bindings/python/bt2/bt2/field_class.py b/src/bindings/python/bt2/bt2/field_class.py index eed50140..8594b496 100644 --- a/src/bindings/python/bt2/bt2/field_class.py +++ b/src/bindings/python/bt2/bt2/field_class.py @@ -2,12 +2,15 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt, object, utils import collections.abc + +from bt2 import error as bt2_error +from bt2 import utils as bt2_utils +from bt2 import value as bt2_value +from bt2 import object as bt2_object +from bt2 import native_bt from bt2 import field_path as bt2_field_path from bt2 import integer_range_set as bt2_integer_range_set -from bt2 import value as bt2_value -import bt2 def _obj_type_from_field_class_ptr_template(type_map, ptr): @@ -44,9 +47,15 @@ class IntegerDisplayBase: HEXADECIMAL = native_bt.FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL -class _FieldClassConst(object._SharedObject): - _get_ref = staticmethod(native_bt.field_class_get_ref) - _put_ref = staticmethod(native_bt.field_class_put_ref) +class _FieldClassConst(bt2_object._SharedObject): + @staticmethod + def _get_ref(ptr): + native_bt.field_class_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.field_class_put_ref(ptr) + _borrow_user_attributes_ptr = staticmethod( native_bt.field_class_borrow_user_attributes_const ) @@ -56,7 +65,7 @@ class _FieldClassConst(object._SharedObject): def _check_create_status(self, ptr): if ptr is None: - raise bt2._MemoryError( + raise bt2_error._MemoryError( "cannot create {} field class object".format(self._NAME.lower()) ) @@ -77,7 +86,7 @@ class _FieldClass(_FieldClassConst): def _user_attributes(self, user_attributes): value = bt2_value.create_value(user_attributes) - utils._check_type(value, bt2_value.MapValue) + bt2_utils._check_type(value, bt2_value.MapValue) native_bt.field_class_set_user_attributes(self._ptr, value._ptr) _user_attributes = property(fset=_user_attributes) @@ -128,7 +137,7 @@ class _IntegerFieldClass(_FieldClass, _IntegerFieldClassConst): _field_value_range = property(fset=_field_value_range) def _preferred_display_base(self, base): - utils._check_uint64(base) + bt2_utils._check_uint64(base) if base not in ( IntegerDisplayBase.BINARY, @@ -239,7 +248,7 @@ class _EnumerationFieldClassConst(_IntegerFieldClassConst, collections.abc.Mappi self._check_int_type(value) status, labels = self._get_mapping_labels_for_value(self._ptr, value) - utils._handle_func_status( + bt2_utils._handle_func_status( status, "cannot get mapping labels for value {}".format(value) ) return [self[label] for label in labels] @@ -250,7 +259,7 @@ class _EnumerationFieldClassConst(_IntegerFieldClassConst, collections.abc.Mappi yield self._mapping_pycls(mapping_ptr).label def __getitem__(self, label): - utils._check_str(label) + bt2_utils._check_str(label) mapping_ptr = self._borrow_mapping_ptr_by_label(self._ptr, label) if mapping_ptr is None: @@ -261,14 +270,14 @@ class _EnumerationFieldClassConst(_IntegerFieldClassConst, collections.abc.Mappi class _EnumerationFieldClass(_EnumerationFieldClassConst, _IntegerFieldClass): def add_mapping(self, label, ranges): - utils._check_str(label) - utils._check_type(ranges, self._range_set_pycls) + bt2_utils._check_str(label) + bt2_utils._check_type(ranges, self._range_set_pycls) if label in self: raise ValueError("duplicate mapping label '{}'".format(label)) status = self._add_mapping(self._ptr, label, ranges._ptr) - utils._handle_func_status( + bt2_utils._handle_func_status( status, "cannot add mapping to enumeration field class object" ) @@ -293,7 +302,7 @@ class _UnsignedEnumerationFieldClassConst( _get_mapping_labels_for_value = staticmethod( native_bt.field_class_enumeration_unsigned_get_mapping_labels_for_value ) - _check_int_type = staticmethod(utils._check_uint64) + _check_int_type = staticmethod(bt2_utils._check_uint64) class _UnsignedEnumerationFieldClass( @@ -320,7 +329,7 @@ class _SignedEnumerationFieldClassConst( _get_mapping_labels_for_value = staticmethod( native_bt.field_class_enumeration_signed_get_mapping_labels_for_value ) - _check_int_type = staticmethod(utils._check_int64) + _check_int_type = staticmethod(bt2_utils._check_int64) class _SignedEnumerationFieldClass( @@ -394,7 +403,7 @@ class _StructureFieldClassMember(_StructureFieldClassMemberConst): def _user_attributes(self, user_attributes): value = bt2_value.create_value(user_attributes) - utils._check_type(value, bt2_value.MapValue) + bt2_utils._check_type(value, bt2_value.MapValue) native_bt.field_class_structure_member_set_user_attributes( self._ptr, value._ptr ) @@ -439,7 +448,7 @@ class _StructureFieldClassConst(_FieldClassConst, collections.abc.Mapping): yield native_bt.field_class_structure_member_get_name(member_ptr) def member_at_index(self, index): - utils._check_uint64(index) + bt2_utils._check_uint64(index) if index >= len(self): raise IndexError @@ -460,8 +469,8 @@ class _StructureFieldClass(_StructureFieldClassConst, _FieldClass): _structure_member_field_class_pycls = property(lambda _: _StructureFieldClassMember) def append_member(self, name, field_class, user_attributes=None): - utils._check_str(name) - utils._check_type(field_class, _FieldClass) + bt2_utils._check_str(name) + bt2_utils._check_type(field_class, _FieldClass) if name in self: raise ValueError("duplicate member name '{}'".format(name)) @@ -470,12 +479,12 @@ class _StructureFieldClass(_StructureFieldClassConst, _FieldClass): if user_attributes is not None: # check now that user attributes are valid - user_attributes_value = bt2.create_value(user_attributes) + user_attributes_value = bt2_value.create_value(user_attributes) status = native_bt.field_class_structure_append_member( self._ptr, name, field_class._ptr ) - utils._handle_func_status( + bt2_utils._handle_func_status( status, "cannot append member to structure field class object" ) @@ -582,7 +591,7 @@ class _OptionWithBoolSelectorFieldClass( _NAME = "Option (with boolean selector)" def _selector_is_reversed(self, selector_is_reversed): - utils._check_bool(selector_is_reversed) + bt2_utils._check_bool(selector_is_reversed) native_bt.field_class_option_with_selector_field_bool_set_selector_is_reversed( self._ptr, selector_is_reversed ) @@ -665,7 +674,7 @@ class _VariantFieldClassOption(_VariantFieldClassOptionConst): def _user_attributes(self, user_attributes): value = bt2_value.create_value(user_attributes) - utils._check_type(value, bt2_value.MapValue) + bt2_utils._check_type(value, bt2_value.MapValue) native_bt.field_class_variant_option_set_user_attributes(self._ptr, value._ptr) _user_attributes = property(fset=_user_attributes) @@ -770,7 +779,7 @@ class _VariantFieldClassConst(_FieldClassConst, collections.abc.Mapping): yield native_bt.field_class_variant_option_get_name(base_opt_ptr) def option_at_index(self, index): - utils._check_uint64(index) + bt2_utils._check_uint64(index) if index >= len(self): raise IndexError @@ -801,8 +810,8 @@ class _VariantFieldClassWithoutSelector( _NAME = "Variant (without selector)" def append_option(self, name, field_class, user_attributes=None): - utils._check_str(name) - utils._check_type(field_class, _FieldClass) + bt2_utils._check_str(name) + bt2_utils._check_type(field_class, _FieldClass) if name in self: raise ValueError("duplicate option name '{}'".format(name)) @@ -811,12 +820,12 @@ class _VariantFieldClassWithoutSelector( if user_attributes is not None: # check now that user attributes are valid - user_attributes_value = bt2.create_value(user_attributes) + user_attributes_value = bt2_value.create_value(user_attributes) status = native_bt.field_class_variant_without_selector_append_option( self._ptr, name, field_class._ptr ) - utils._handle_func_status( + bt2_utils._handle_func_status( status, "cannot append option to variant field class object" ) @@ -851,9 +860,9 @@ class _VariantFieldClassWithIntegerSelector( _NAME = "Variant (with selector)" def append_option(self, name, field_class, ranges, user_attributes=None): - utils._check_str(name) - utils._check_type(field_class, _FieldClass) - utils._check_type(ranges, self._variant_option_pycls._range_set_pycls) + bt2_utils._check_str(name) + bt2_utils._check_type(field_class, _FieldClass) + bt2_utils._check_type(ranges, self._variant_option_pycls._range_set_pycls) if name in self: raise ValueError("duplicate option name '{}'".format(name)) @@ -865,12 +874,12 @@ class _VariantFieldClassWithIntegerSelector( if user_attributes is not None: # check now that user attributes are valid - user_attributes_value = bt2.create_value(user_attributes) + user_attributes_value = bt2_value.create_value(user_attributes) # TODO: check overlaps (precondition of self._append_option()) status = self._append_option(self._ptr, name, field_class._ptr, ranges._ptr) - utils._handle_func_status( + bt2_utils._handle_func_status( status, "cannot append option to variant field class object" ) diff --git a/src/bindings/python/bt2/bt2/field_path.py b/src/bindings/python/bt2/bt2/field_path.py index a2d39629..d64d2286 100644 --- a/src/bindings/python/bt2/bt2/field_path.py +++ b/src/bindings/python/bt2/bt2/field_path.py @@ -3,7 +3,9 @@ # Copyright (c) 2018 Francis Deslauriers import collections -from bt2 import native_bt, object + +from bt2 import object as bt2_object +from bt2 import native_bt class FieldPathScope: @@ -34,9 +36,14 @@ class _CurrentOptionContentFieldPathItem(_FieldPathItem): pass -class _FieldPathConst(object._SharedObject, collections.abc.Iterable): - _get_ref = staticmethod(native_bt.field_path_get_ref) - _put_ref = staticmethod(native_bt.field_path_put_ref) +class _FieldPathConst(bt2_object._SharedObject, collections.abc.Iterable): + @staticmethod + def _get_ref(ptr): + native_bt.field_path_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.field_path_put_ref(ptr) @property def root_scope(self): diff --git a/src/bindings/python/bt2/bt2/graph.py b/src/bindings/python/bt2/bt2/graph.py index ed99ef07..6bd4e1e7 100644 --- a/src/bindings/python/bt2/bt2/graph.py +++ b/src/bindings/python/bt2/bt2/graph.py @@ -2,14 +2,19 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt, object, utils -from bt2 import interrupter as bt2_interrupter -from bt2 import connection as bt2_connection -from bt2 import component as bt2_component import functools + +from bt2 import mip as bt2_mip from bt2 import port as bt2_port +from bt2 import error as bt2_error +from bt2 import utils as bt2_utils +from bt2 import value as bt2_value +from bt2 import object as bt2_object from bt2 import logging as bt2_logging -import bt2 +from bt2 import component as bt2_component +from bt2 import native_bt +from bt2 import connection as bt2_connection +from bt2 import interrupter as bt2_interrupter def _graph_port_added_listener_from_native( @@ -22,20 +27,25 @@ def _graph_port_added_listener_from_native( user_listener(component, port) -class Graph(object._SharedObject): - _get_ref = staticmethod(native_bt.graph_get_ref) - _put_ref = staticmethod(native_bt.graph_put_ref) +class Graph(bt2_object._SharedObject): + @staticmethod + def _get_ref(ptr): + native_bt.graph_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.graph_put_ref(ptr) def __init__(self, mip_version=0): - utils._check_uint64(mip_version) + bt2_utils._check_uint64(mip_version) - if mip_version > bt2.get_maximal_mip_version(): + if mip_version > bt2_mip.get_maximal_mip_version(): raise ValueError("unknown MIP version {}".format(mip_version)) ptr = native_bt.graph_create(mip_version) if ptr is None: - raise bt2._MemoryError("cannot create graph object") + raise bt2_error._MemoryError("cannot create graph object") super().__init__(ptr) @@ -82,36 +92,38 @@ class Graph(object._SharedObject): ) ) - utils._check_str(name) - utils._check_log_level(logging_level) + bt2_utils._check_str(name) + bt2_utils._check_log_level(logging_level) base_cc_ptr = component_class._bt_component_class_ptr() if obj is not None and not native_bt.bt2_is_python_component_class(base_cc_ptr): raise ValueError("cannot pass a Python object to a non-Python component") - if params is not None and not isinstance(params, (dict, bt2.MapValue)): + if params is not None and not isinstance(params, (dict, bt2_value.MapValue)): raise TypeError("'params' parameter is not a 'dict' or a 'bt2.MapValue'.") - params = bt2.create_value(params) + params = bt2_value.create_value(params) params_ptr = params._ptr if params is not None else None status, comp_ptr = add_fn( self._ptr, cc_ptr, name, params_ptr, obj, logging_level ) - utils._handle_func_status(status, "cannot add component to graph") + bt2_utils._handle_func_status(status, "cannot add component to graph") assert comp_ptr return bt2_component._create_component_from_const_ptr_and_get_ref( comp_ptr, cc_type ) def connect_ports(self, upstream_port, downstream_port): - utils._check_type(upstream_port, bt2_port._OutputPortConst) - utils._check_type(downstream_port, bt2_port._InputPortConst) + bt2_utils._check_type(upstream_port, bt2_port._OutputPortConst) + bt2_utils._check_type(downstream_port, bt2_port._InputPortConst) status, conn_ptr = native_bt.graph_connect_ports( self._ptr, upstream_port._ptr, downstream_port._ptr ) - utils._handle_func_status(status, "cannot connect component ports within graph") + bt2_utils._handle_func_status( + status, "cannot connect component ports within graph" + ) assert conn_ptr return bt2_connection._ConnectionConst._create_from_ptr_and_get_ref(conn_ptr) @@ -126,21 +138,21 @@ class Graph(object._SharedObject): listener_ids = fn(self._ptr, listener_from_native) if listener_ids is None: - raise bt2._Error("cannot add listener to graph object") + raise bt2_error._Error("cannot add listener to graph object") # keep the partial's reference self._listener_partials.append(listener_from_native) def run_once(self): status = native_bt.graph_run_once(self._ptr) - utils._handle_func_status(status, "graph object could not run once") + bt2_utils._handle_func_status(status, "graph object could not run once") def run(self): status = native_bt.graph_run(self._ptr) - utils._handle_func_status(status, "graph object stopped running") + bt2_utils._handle_func_status(status, "graph object stopped running") def add_interrupter(self, interrupter): - utils._check_type(interrupter, bt2_interrupter.Interrupter) + bt2_utils._check_type(interrupter, bt2_interrupter.Interrupter) native_bt.graph_add_interrupter(self._ptr, interrupter._ptr) @property diff --git a/src/bindings/python/bt2/bt2/integer_range_set.py b/src/bindings/python/bt2/bt2/integer_range_set.py index 79006f33..86bfd467 100644 --- a/src/bindings/python/bt2/bt2/integer_range_set.py +++ b/src/bindings/python/bt2/bt2/integer_range_set.py @@ -2,9 +2,12 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt, object, utils import collections.abc -import bt2 + +from bt2 import error as bt2_error +from bt2 import utils as bt2_utils +from bt2 import object as bt2_object +from bt2 import native_bt class _IntegerRangeConst: @@ -51,8 +54,8 @@ class _IntegerRange(_IntegerRangeConst): class _SignedIntegerRangeConst(_IntegerRangeConst): - _is_type = staticmethod(utils._is_int64) - _check_type = staticmethod(utils._check_int64) + _is_type = staticmethod(bt2_utils._is_int64) + _check_type = staticmethod(bt2_utils._check_int64) class SignedIntegerRange(_SignedIntegerRangeConst, _IntegerRange): @@ -60,15 +63,15 @@ class SignedIntegerRange(_SignedIntegerRangeConst, _IntegerRange): class _UnsignedIntegerRangeConst(_IntegerRangeConst): - _is_type = staticmethod(utils._is_uint64) - _check_type = staticmethod(utils._check_uint64) + _is_type = staticmethod(bt2_utils._is_uint64) + _check_type = staticmethod(bt2_utils._check_uint64) class UnsignedIntegerRange(_UnsignedIntegerRangeConst, _IntegerRange): pass -class _IntegerRangeSetConst(object._SharedObject, collections.abc.Set): +class _IntegerRangeSetConst(bt2_object._SharedObject, collections.abc.Set): def __len__(self): range_set_ptr = self._as_range_set_ptr(self._ptr) count = native_bt.integer_range_set_get_range_count(range_set_ptr) @@ -91,7 +94,6 @@ class _IntegerRangeSetConst(object._SharedObject, collections.abc.Set): yield self._range_pycls(lower, upper) def __eq__(self, other): - if not isinstance(other, _IntegerRangeSetConst): return False @@ -110,7 +112,7 @@ class _IntegerRangeSet(_IntegerRangeSetConst, collections.abc.MutableSet): ptr = self._create_range_set() if ptr is None: - raise bt2._MemoryError("cannot create range set object") + raise bt2_error._MemoryError("cannot create range set object") super().__init__(ptr) @@ -128,15 +130,21 @@ class _IntegerRangeSet(_IntegerRangeSetConst, collections.abc.MutableSet): rg = self._range_pycls(rg[0], rg[1]) status = self._add_range(self._ptr, rg.lower, rg.upper) - utils._handle_func_status(status, "cannot add range to range set object") + bt2_utils._handle_func_status(status, "cannot add range to range set object") def discard(self, rg): raise NotImplementedError class _SignedIntegerRangeSetConst(_IntegerRangeSetConst): - _get_ref = staticmethod(native_bt.integer_range_set_signed_get_ref) - _put_ref = staticmethod(native_bt.integer_range_set_signed_put_ref) + @staticmethod + def _get_ref(ptr): + native_bt.integer_range_set_signed_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.integer_range_set_signed_put_ref(ptr) + _as_range_set_ptr = staticmethod( native_bt.integer_range_set_signed_as_range_set_const ) @@ -156,8 +164,14 @@ class SignedIntegerRangeSet(_SignedIntegerRangeSetConst, _IntegerRangeSet): class _UnsignedIntegerRangeSetConst(_IntegerRangeSetConst): - _get_ref = staticmethod(native_bt.integer_range_set_unsigned_get_ref) - _put_ref = staticmethod(native_bt.integer_range_set_unsigned_put_ref) + @staticmethod + def _get_ref(ptr): + native_bt.integer_range_set_unsigned_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.integer_range_set_unsigned_put_ref(ptr) + _as_range_set_ptr = staticmethod( native_bt.integer_range_set_unsigned_as_range_set_const ) diff --git a/src/bindings/python/bt2/bt2/interrupter.py b/src/bindings/python/bt2/bt2/interrupter.py index 39c22883..cd7ef806 100644 --- a/src/bindings/python/bt2/bt2/interrupter.py +++ b/src/bindings/python/bt2/bt2/interrupter.py @@ -2,19 +2,25 @@ # # Copyright (c) 2019 Philippe Proulx -from bt2 import native_bt, object -import bt2 +from bt2 import error as bt2_error +from bt2 import object as bt2_object +from bt2 import native_bt -class Interrupter(object._SharedObject): - _get_ref = staticmethod(native_bt.interrupter_get_ref) - _put_ref = staticmethod(native_bt.interrupter_put_ref) +class Interrupter(bt2_object._SharedObject): + @staticmethod + def _get_ref(ptr): + native_bt.interrupter_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.interrupter_put_ref(ptr) def __init__(self): ptr = native_bt.interrupter_create() if ptr is None: - raise bt2._MemoryError("cannot create interrupter object") + raise bt2_error._MemoryError("cannot create interrupter object") super().__init__(ptr) diff --git a/src/bindings/python/bt2/bt2/message.py b/src/bindings/python/bt2/bt2/message.py index 5039d923..c56f6961 100644 --- a/src/bindings/python/bt2/bt2/message.py +++ b/src/bindings/python/bt2/bt2/message.py @@ -2,11 +2,13 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt, object, utils -from bt2 import clock_snapshot as bt2_clock_snapshot +from bt2 import event as bt2_event +from bt2 import utils as bt2_utils +from bt2 import object as bt2_object from bt2 import packet as bt2_packet from bt2 import stream as bt2_stream -from bt2 import event as bt2_event +from bt2 import native_bt +from bt2 import clock_snapshot as bt2_clock_snapshot def _create_from_ptr(ptr): @@ -14,9 +16,14 @@ def _create_from_ptr(ptr): return _MESSAGE_TYPE_TO_CLS[msg_type]._create_from_ptr(ptr) -class _MessageConst(object._SharedObject): - _get_ref = staticmethod(native_bt.message_get_ref) - _put_ref = staticmethod(native_bt.message_put_ref) +class _MessageConst(bt2_object._SharedObject): + @staticmethod + def _get_ref(ptr): + native_bt.message_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.message_put_ref(ptr) @staticmethod def _check_has_default_clock_class(clock_class): @@ -134,7 +141,7 @@ class _StreamMessageConst(_MessageConst, _MessageWithDefaultClockSnapshot): class _StreamMessage(_StreamMessageConst, _Message): def _default_clock_snapshot(self, raw_value): - utils._check_uint64(raw_value) + bt2_utils._check_uint64(raw_value) self._set_default_clock_snapshot(self._ptr, raw_value) _default_clock_snapshot = property( @@ -232,7 +239,7 @@ class _DiscardedMessage(_DiscardedMessageConst, _Message): _stream_pycls = property(lambda _: bt2_stream._Stream) def _set_count(self, count): - utils._check_uint64(count) + bt2_utils._check_uint64(count) if count == 0: raise ValueError("discarded {} count is 0".format(self._item_name)) diff --git a/src/bindings/python/bt2/bt2/message_iterator.py b/src/bindings/python/bt2/bt2/message_iterator.py index e2efa732..8703e90b 100644 --- a/src/bindings/python/bt2/bt2/message_iterator.py +++ b/src/bindings/python/bt2/bt2/message_iterator.py @@ -2,15 +2,18 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt, object, utils -from bt2 import message as bt2_message import collections.abc -from bt2 import stream as bt2_stream -from bt2 import event_class as bt2_event_class -from bt2 import packet as bt2_packet + from bt2 import port as bt2_port +from bt2 import error as bt2_error +from bt2 import utils as bt2_utils +from bt2 import object as bt2_object +from bt2 import packet as bt2_packet +from bt2 import stream as bt2_stream +from bt2 import message as bt2_message +from bt2 import native_bt from bt2 import clock_class as bt2_clock_class -import bt2 +from bt2 import event_class as bt2_event_class class _MessageIterator(collections.abc.Iterator): @@ -18,9 +21,16 @@ class _MessageIterator(collections.abc.Iterator): raise NotImplementedError -class _UserComponentInputPortMessageIterator(object._SharedObject, _MessageIterator): - _get_ref = staticmethod(native_bt.message_iterator_get_ref) - _put_ref = staticmethod(native_bt.message_iterator_put_ref) +class _UserComponentInputPortMessageIterator( + bt2_object._SharedObject, _MessageIterator +): + @staticmethod + def _get_ref(ptr): + native_bt.message_iterator_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.message_iterator_put_ref(ptr) def __init__(self, ptr): self._current_msgs = [] @@ -32,7 +42,7 @@ class _UserComponentInputPortMessageIterator(object._SharedObject, _MessageItera status, msgs = native_bt.bt2_self_component_port_input_get_msg_range( self._ptr ) - utils._handle_func_status( + bt2_utils._handle_func_status( status, "unexpected error: cannot advance the message iterator" ) self._current_msgs = msgs @@ -45,7 +55,7 @@ class _UserComponentInputPortMessageIterator(object._SharedObject, _MessageItera def can_seek_beginning(self): (status, res) = native_bt.message_iterator_can_seek_beginning(self._ptr) - utils._handle_func_status( + bt2_utils._handle_func_status( status, "cannot check whether or not message iterator can seek its beginning", ) @@ -57,21 +67,21 @@ class _UserComponentInputPortMessageIterator(object._SharedObject, _MessageItera self._at = 0 status = native_bt.message_iterator_seek_beginning(self._ptr) - utils._handle_func_status(status, "cannot seek message iterator beginning") + bt2_utils._handle_func_status(status, "cannot seek message iterator beginning") def can_seek_ns_from_origin(self, ns_from_origin): - utils._check_int64(ns_from_origin) + bt2_utils._check_int64(ns_from_origin) (status, res) = native_bt.message_iterator_can_seek_ns_from_origin( self._ptr, ns_from_origin ) - utils._handle_func_status( + bt2_utils._handle_func_status( status, "cannot check whether or not message iterator can seek given ns from origin", ) return res != 0 def seek_ns_from_origin(self, ns_from_origin): - utils._check_int64(ns_from_origin) + bt2_utils._check_int64(ns_from_origin) # Forget about buffered messages, they won't be valid after seeking. self._current_msgs.clear() @@ -80,7 +90,7 @@ class _UserComponentInputPortMessageIterator(object._SharedObject, _MessageItera status = native_bt.message_iterator_seek_ns_from_origin( self._ptr, ns_from_origin ) - utils._handle_func_status( + bt2_utils._handle_func_status( status, "message iterator cannot seek given ns from origin" ) @@ -94,7 +104,7 @@ class _MessageIteratorConfiguration: self._ptr = ptr def can_seek_forward(self, value): - utils._check_bool(value) + bt2_utils._check_bool(value) native_bt.self_message_iterator_configuration_set_can_seek_forward( self._ptr, value ) @@ -158,18 +168,18 @@ class _UserMessageIterator(_MessageIterator): pass def __next__(self): - raise bt2.Stop + raise bt2_utils.Stop def _bt_next_from_native(self): - # this can raise anything: it's catched by the native part + # this can raise anything: it's caught by the native part try: msg = next(self) except StopIteration: - raise bt2.Stop + raise bt2_utils.Stop except Exception: raise - utils._check_type(msg, bt2_message._MessageConst) + bt2_utils._check_type(msg, bt2_message._MessageConst) # The reference we return will be given to the message array. # However, the `msg` Python object may stay alive, if the user has kept @@ -186,7 +196,7 @@ class _UserMessageIterator(_MessageIterator): # method indicates whether the iterator can seek beginning. if hasattr(self, "_user_can_seek_beginning"): can_seek_beginning = self._user_can_seek_beginning() - utils._check_bool(can_seek_beginning) + bt2_utils._check_bool(can_seek_beginning) return can_seek_beginning else: return hasattr(self, "_user_seek_beginning") @@ -206,7 +216,7 @@ class _UserMessageIterator(_MessageIterator): if hasattr(self, "_user_can_seek_ns_from_origin"): can_seek_ns_from_origin = self._user_can_seek_ns_from_origin(ns_from_origin) - utils._check_bool(can_seek_ns_from_origin) + bt2_utils._check_bool(can_seek_ns_from_origin) return can_seek_ns_from_origin else: return hasattr(self, "_user_seek_ns_from_origin") @@ -215,7 +225,7 @@ class _UserMessageIterator(_MessageIterator): self._user_seek_ns_from_origin(ns_from_origin) def _create_message_iterator(self, input_port): - utils._check_type(input_port, bt2_port._UserComponentInputPort) + bt2_utils._check_type(input_port, bt2_port._UserComponentInputPort) if not input_port.is_connected: raise ValueError("input port is not connected") @@ -226,18 +236,18 @@ class _UserMessageIterator(_MessageIterator): ) = native_bt.bt2_message_iterator_create_from_message_iterator( self._bt_ptr, input_port._ptr ) - utils._handle_func_status(status, "cannot create message iterator object") + bt2_utils._handle_func_status(status, "cannot create message iterator object") assert msg_iter_ptr is not None return _UserComponentInputPortMessageIterator(msg_iter_ptr) def _create_event_message(self, event_class, parent, default_clock_snapshot=None): - utils._check_type(event_class, bt2_event_class._EventClass) + bt2_utils._check_type(event_class, bt2_event_class._EventClass) if event_class.stream_class.supports_packets: - utils._check_type(parent, bt2_packet._Packet) + bt2_utils._check_type(parent, bt2_packet._Packet) else: - utils._check_type(parent, bt2_stream._Stream) + bt2_utils._check_type(parent, bt2_stream._Stream) if default_clock_snapshot is not None: if event_class.stream_class.default_clock_class is None: @@ -245,7 +255,7 @@ class _UserMessageIterator(_MessageIterator): "event messages in this stream must not have a default clock snapshot" ) - utils._check_uint64(default_clock_snapshot) + bt2_utils._check_uint64(default_clock_snapshot) if event_class.stream_class.supports_packets: ptr = native_bt.message_event_create_with_packet_and_default_clock_snapshot( @@ -271,27 +281,29 @@ class _UserMessageIterator(_MessageIterator): ) if ptr is None: - raise bt2._MemoryError("cannot create event message object") + raise bt2_error._MemoryError("cannot create event message object") return bt2_message._EventMessage(ptr) def _create_message_iterator_inactivity_message(self, clock_class, clock_snapshot): - utils._check_type(clock_class, bt2_clock_class._ClockClass) + bt2_utils._check_type(clock_class, bt2_clock_class._ClockClass) ptr = native_bt.message_message_iterator_inactivity_create( self._bt_ptr, clock_class._ptr, clock_snapshot ) if ptr is None: - raise bt2._MemoryError("cannot create inactivity message object") + raise bt2_error._MemoryError("cannot create inactivity message object") return bt2_message._MessageIteratorInactivityMessage(ptr) def _create_stream_beginning_message(self, stream, default_clock_snapshot=None): - utils._check_type(stream, bt2_stream._Stream) + bt2_utils._check_type(stream, bt2_stream._Stream) ptr = native_bt.message_stream_beginning_create(self._bt_ptr, stream._ptr) if ptr is None: - raise bt2._MemoryError("cannot create stream beginning message object") + raise bt2_error._MemoryError( + "cannot create stream beginning message object" + ) msg = bt2_message._StreamBeginningMessage(ptr) @@ -301,11 +313,11 @@ class _UserMessageIterator(_MessageIterator): return msg def _create_stream_end_message(self, stream, default_clock_snapshot=None): - utils._check_type(stream, bt2_stream._Stream) + bt2_utils._check_type(stream, bt2_stream._Stream) ptr = native_bt.message_stream_end_create(self._bt_ptr, stream._ptr) if ptr is None: - raise bt2._MemoryError("cannot create stream end message object") + raise bt2_error._MemoryError("cannot create stream end message object") msg = bt2_message._StreamEndMessage(ptr) @@ -315,7 +327,7 @@ class _UserMessageIterator(_MessageIterator): return msg def _create_packet_beginning_message(self, packet, default_clock_snapshot=None): - utils._check_type(packet, bt2_packet._Packet) + bt2_utils._check_type(packet, bt2_packet._Packet) if packet.stream.cls.packets_have_beginning_default_clock_snapshot: if default_clock_snapshot is None: @@ -323,7 +335,7 @@ class _UserMessageIterator(_MessageIterator): "packet beginning messages in this stream must have a default clock snapshot" ) - utils._check_uint64(default_clock_snapshot) + bt2_utils._check_uint64(default_clock_snapshot) ptr = native_bt.message_packet_beginning_create_with_default_clock_snapshot( self._bt_ptr, packet._ptr, default_clock_snapshot ) @@ -336,12 +348,14 @@ class _UserMessageIterator(_MessageIterator): ptr = native_bt.message_packet_beginning_create(self._bt_ptr, packet._ptr) if ptr is None: - raise bt2._MemoryError("cannot create packet beginning message object") + raise bt2_error._MemoryError( + "cannot create packet beginning message object" + ) return bt2_message._PacketBeginningMessage(ptr) def _create_packet_end_message(self, packet, default_clock_snapshot=None): - utils._check_type(packet, bt2_packet._Packet) + bt2_utils._check_type(packet, bt2_packet._Packet) if packet.stream.cls.packets_have_end_default_clock_snapshot: if default_clock_snapshot is None: @@ -349,7 +363,7 @@ class _UserMessageIterator(_MessageIterator): "packet end messages in this stream must have a default clock snapshot" ) - utils._check_uint64(default_clock_snapshot) + bt2_utils._check_uint64(default_clock_snapshot) ptr = native_bt.message_packet_end_create_with_default_clock_snapshot( self._bt_ptr, packet._ptr, default_clock_snapshot ) @@ -362,14 +376,14 @@ class _UserMessageIterator(_MessageIterator): ptr = native_bt.message_packet_end_create(self._bt_ptr, packet._ptr) if ptr is None: - raise bt2._MemoryError("cannot create packet end message object") + raise bt2_error._MemoryError("cannot create packet end message object") return bt2_message._PacketEndMessage(ptr) def _create_discarded_events_message( self, stream, count=None, beg_clock_snapshot=None, end_clock_snapshot=None ): - utils._check_type(stream, bt2_stream._Stream) + bt2_utils._check_type(stream, bt2_stream._Stream) if not stream.cls.supports_discarded_events: raise ValueError("stream class does not support discarded events") @@ -380,8 +394,8 @@ class _UserMessageIterator(_MessageIterator): "discarded events have default clock snapshots for this stream class" ) - utils._check_uint64(beg_clock_snapshot) - utils._check_uint64(end_clock_snapshot) + bt2_utils._check_uint64(beg_clock_snapshot) + bt2_utils._check_uint64(end_clock_snapshot) if beg_clock_snapshot > end_clock_snapshot: raise ValueError( @@ -404,7 +418,7 @@ class _UserMessageIterator(_MessageIterator): ptr = native_bt.message_discarded_events_create(self._bt_ptr, stream._ptr) if ptr is None: - raise bt2._MemoryError("cannot discarded events message object") + raise bt2_error._MemoryError("cannot discarded events message object") msg = bt2_message._DiscardedEventsMessage(ptr) @@ -416,7 +430,7 @@ class _UserMessageIterator(_MessageIterator): def _create_discarded_packets_message( self, stream, count=None, beg_clock_snapshot=None, end_clock_snapshot=None ): - utils._check_type(stream, bt2_stream._Stream) + bt2_utils._check_type(stream, bt2_stream._Stream) if not stream.cls.supports_discarded_packets: raise ValueError("stream class does not support discarded packets") @@ -427,8 +441,8 @@ class _UserMessageIterator(_MessageIterator): "discarded packets have default clock snapshots for this stream class" ) - utils._check_uint64(beg_clock_snapshot) - utils._check_uint64(end_clock_snapshot) + bt2_utils._check_uint64(beg_clock_snapshot) + bt2_utils._check_uint64(end_clock_snapshot) if beg_clock_snapshot > end_clock_snapshot: raise ValueError( @@ -451,7 +465,7 @@ class _UserMessageIterator(_MessageIterator): ptr = native_bt.message_discarded_packets_create(self._bt_ptr, stream._ptr) if ptr is None: - raise bt2._MemoryError("cannot discarded packets message object") + raise bt2_error._MemoryError("cannot discarded packets message object") msg = bt2_message._DiscardedPacketsMessage(ptr) diff --git a/src/bindings/python/bt2/bt2/mip.py b/src/bindings/python/bt2/bt2/mip.py index 552c7b2a..21cb0c61 100644 --- a/src/bindings/python/bt2/bt2/mip.py +++ b/src/bindings/python/bt2/bt2/mip.py @@ -2,25 +2,28 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt, utils -import bt2 +from bt2 import error as bt2_error +from bt2 import utils as bt2_utils +from bt2 import logging as bt2_logging +from bt2 import native_bt +from bt2 import component_descriptor as bt2_component_descriptor def get_greatest_operative_mip_version( - component_descriptors, log_level=bt2.LoggingLevel.NONE + component_descriptors, log_level=bt2_logging.LoggingLevel.NONE ): - utils._check_log_level(log_level) + bt2_utils._check_log_level(log_level) comp_descr_set_ptr = native_bt.component_descriptor_set_create() if comp_descr_set_ptr is None: - raise bt2._MemoryError("cannot create component descriptor set object") + raise bt2_error._MemoryError("cannot create component descriptor set object") if len(component_descriptors) == 0: raise ValueError("no component descriptors") try: for descr in component_descriptors: - if type(descr) is not bt2.ComponentDescriptor: + if type(descr) is not bt2_component_descriptor.ComponentDescriptor: raise TypeError("'{}' is not a component descriptor".format(descr)) base_cc_ptr = descr.component_class._bt_component_class_ptr() @@ -32,7 +35,7 @@ def get_greatest_operative_mip_version( status = native_bt.bt2_component_descriptor_set_add_descriptor_with_initialize_method_data( comp_descr_set_ptr, base_cc_ptr, params_ptr, descr.obj ) - utils._handle_func_status( + bt2_utils._handle_func_status( status, "cannot add descriptor to component descriptor set" ) @@ -43,7 +46,9 @@ def get_greatest_operative_mip_version( if status == native_bt.__BT_FUNC_STATUS_NO_MATCH: return None - utils._handle_func_status(status, "cannot get greatest operative MIP version") + bt2_utils._handle_func_status( + status, "cannot get greatest operative MIP version" + ) return version finally: native_bt.component_descriptor_set_put_ref(comp_descr_set_ptr) diff --git a/src/bindings/python/bt2/bt2/native_bt.i b/src/bindings/python/bt2/bt2/native_bt.i index 21a869e6..b4b5e904 100644 --- a/src/bindings/python/bt2/bt2/native_bt.i +++ b/src/bindings/python/bt2/bt2/native_bt.i @@ -199,10 +199,11 @@ void bt_bt2_exit_handler(void); #define __BT_IN_BABELTRACE_H /* - * Define `__BT_ATTR_FORMAT_PRINTF` to nothing, otherwise SWIG fails to parse - * the included header files that use it. + * Define `__BT_ATTR_FORMAT_PRINTF` and `__BT_NOEXCEPT` to nothing, + * otherwise SWIG fails to parse the included header files that use it. */ #define __BT_ATTR_FORMAT_PRINTF(_string_index, _first_to_check) +#define __BT_NOEXCEPT /* Common types */ %include diff --git a/src/bindings/python/bt2/bt2/native_bt_autodisc.i.h b/src/bindings/python/bt2/bt2/native_bt_autodisc.i.h index d6a4d24b..9b12e8c3 100644 --- a/src/bindings/python/bt2/bt2/native_bt_autodisc.i.h +++ b/src/bindings/python/bt2/bt2/native_bt_autodisc.i.h @@ -86,7 +86,7 @@ bt_value *bt_bt2_auto_discover_source_components(const bt_value *inputs, plugins, plugin_count, NULL, - bt_python_bindings_bt2_log_level, + (bt_logging_level) bt_python_bindings_bt2_log_level, &auto_disc, NULL); if (status != 0) { diff --git a/src/bindings/python/bt2/bt2/native_bt_component_class.i.h b/src/bindings/python/bt2/bt2/native_bt_component_class.i.h index 8e284c04..628d5867 100644 --- a/src/bindings/python/bt2/bt2/native_bt_component_class.i.h +++ b/src/bindings/python/bt2/bt2/native_bt_component_class.i.h @@ -298,7 +298,8 @@ component_class_get_supported_mip_versions( py_cls = lookup_cc_ptr_to_py_cls(component_class); if (!py_cls) { - BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG, + BT_LOG_WRITE_PRINTF_CUR_LVL(BT_LOG_ERROR, + (enum bt_log_level) log_level, BT_LOG_TAG, "Cannot find Python class associated to native component class: " "comp-cls-addr=%p", component_class); goto error; @@ -307,7 +308,8 @@ component_class_get_supported_mip_versions( py_params_ptr = SWIG_NewPointerObj(SWIG_as_voidptr(params), SWIGTYPE_p_bt_value, 0); if (!py_params_ptr) { - BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG, + BT_LOG_WRITE_PRINTF_CUR_LVL(BT_LOG_ERROR, + (enum bt_log_level) log_level, BT_LOG_TAG, BT_FMT_SWIG_ALLOC_FAILED); goto error; } @@ -324,7 +326,8 @@ component_class_get_supported_mip_versions( py_params_ptr, init_method_data ? init_method_data : Py_None, (int) log_level); if (!py_range_set_addr) { - BT_LOG_WRITE_CUR_LVL(BT_LOG_WARNING, log_level, BT_LOG_TAG, + BT_LOG_WRITE_PRINTF_CUR_LVL(BT_LOG_WARNING, + (enum bt_log_level) log_level, BT_LOG_TAG, "Failed to call Python class's _bt_get_supported_mip_versions_from_native() method: " "py-cls-addr=%p", py_cls); status = py_exc_to_status_component_class_clear(self_component_class, @@ -355,7 +358,8 @@ component_class_get_supported_mip_versions( bt_integer_range_unsigned_get_lower(range), bt_integer_range_unsigned_get_upper(range)); if (add_range_status) { - BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG, + BT_LOG_WRITE_PRINTF_CUR_LVL(BT_LOG_ERROR, + (enum bt_log_level) log_level, BT_LOG_TAG, "Failed to add range to supported MIP versions range set."); goto error; } @@ -939,7 +943,8 @@ bt_component_class_query_method_status component_class_query( py_cls = lookup_cc_ptr_to_py_cls(component_class); if (!py_cls) { - BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG, + BT_LOG_WRITE_PRINTF_CUR_LVL(BT_LOG_ERROR, + (enum bt_log_level) log_level, BT_LOG_TAG, "Cannot find Python class associated to native component class: " "comp-cls-addr=%p", component_class); goto error; @@ -948,7 +953,8 @@ bt_component_class_query_method_status component_class_query( py_params_ptr = SWIG_NewPointerObj(SWIG_as_voidptr(params), SWIGTYPE_p_bt_value, 0); if (!py_params_ptr) { - BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG, + BT_LOG_WRITE_PRINTF_CUR_LVL(BT_LOG_ERROR, + (enum bt_log_level) log_level, BT_LOG_TAG, BT_FMT_SWIG_ALLOC_FAILED); goto error; } @@ -957,14 +963,16 @@ bt_component_class_query_method_status component_class_query( SWIG_as_voidptr(priv_query_executor), SWIGTYPE_p_bt_private_query_executor, 0); if (!py_priv_query_exec_ptr) { - BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG, + BT_LOG_WRITE_PRINTF_CUR_LVL(BT_LOG_ERROR, + (enum bt_log_level) log_level, BT_LOG_TAG, BT_FMT_SWIG_ALLOC_FAILED); goto error; } py_object = SWIG_FromCharPtr(object); if (!py_object) { - BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG, + BT_LOG_WRITE_PRINTF_CUR_LVL(BT_LOG_ERROR, + (enum bt_log_level) log_level, BT_LOG_TAG, "Failed to create a Python string."); goto error; } @@ -985,8 +993,9 @@ bt_component_class_query_method_status component_class_query( log_level); if (status < 0) { #define BT_FMT "Failed to call Python class's _bt_query_from_native() method: py-cls-addr=%p" - BT_LOG_WRITE_CUR_LVL(BT_LOG_WARNING, log_level, BT_LOG_TAG, - BT_FMT, py_cls); + BT_LOG_WRITE_PRINTF_CUR_LVL(BT_LOG_WARNING, + (enum bt_log_level) log_level, + BT_LOG_TAG, BT_FMT, py_cls); BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_COMPONENT_CLASS( self_component_class, BT_FMT, py_cls); #undef BT_FMT diff --git a/src/bindings/python/bt2/bt2/native_bt_error.i.h b/src/bindings/python/bt2/bt2/native_bt_error.i.h index 05394151..78eeb28a 100644 --- a/src/bindings/python/bt2/bt2/native_bt_error.i.h +++ b/src/bindings/python/bt2/bt2/native_bt_error.i.h @@ -13,7 +13,8 @@ PyObject *bt_bt2_format_bt_error_cause(const bt_error_cause *error_cause) PyObject *py_error_cause_str = NULL; error_cause_str = format_bt_error_cause(error_cause, 80, - bt_python_bindings_bt2_log_level, BT_COMMON_COLOR_WHEN_NEVER); + (bt_logging_level) bt_python_bindings_bt2_log_level, + BT_COMMON_COLOR_WHEN_NEVER); BT_ASSERT(error_cause_str); py_error_cause_str = PyString_FromString(error_cause_str); @@ -30,7 +31,8 @@ PyObject *bt_bt2_format_bt_error(const bt_error *error) PyObject *py_error_str = NULL; error_str = format_bt_error(error, 80, - bt_python_bindings_bt2_log_level, BT_COMMON_COLOR_WHEN_NEVER); + (bt_logging_level) bt_python_bindings_bt2_log_level, + BT_COMMON_COLOR_WHEN_NEVER); BT_ASSERT(error_str); py_error_str = PyString_FromString(error_str); diff --git a/src/bindings/python/bt2/bt2/object.py b/src/bindings/python/bt2/bt2/object.py index fed138ec..dcff667f 100644 --- a/src/bindings/python/bt2/bt2/object.py +++ b/src/bindings/python/bt2/bt2/object.py @@ -3,6 +3,9 @@ # Copyright (c) 2017 Philippe Proulx +import abc + + class _BaseObject: # Ensure that the object always has _ptr set, even if it throws during # construction. @@ -42,7 +45,6 @@ class _BaseObject: class _UniqueObject(_BaseObject): - # Create a _UniqueObject. # # - ptr: SWIG Object, pointer to the unique object. @@ -69,14 +71,14 @@ class _UniqueObject(_BaseObject): # Python object that owns a reference to a Babeltrace object. -class _SharedObject(_BaseObject): - +class _SharedObject(_BaseObject, abc.ABC): # Get a new reference on ptr. # # This must be implemented by subclasses to work correctly with a pointer # of the native type they wrap. @staticmethod + @abc.abstractmethod def _get_ref(ptr): raise NotImplementedError @@ -86,6 +88,7 @@ class _SharedObject(_BaseObject): # of the native type they wrap. @staticmethod + @abc.abstractmethod def _put_ref(ptr): raise NotImplementedError diff --git a/src/bindings/python/bt2/bt2/packet.py b/src/bindings/python/bt2/bt2/packet.py index 9325a7d6..0e7605f1 100644 --- a/src/bindings/python/bt2/bt2/packet.py +++ b/src/bindings/python/bt2/bt2/packet.py @@ -2,8 +2,9 @@ # # Copyright (c) 2016-2017 Philippe Proulx -from bt2 import native_bt, object from bt2 import field as bt2_field +from bt2 import object as bt2_object +from bt2 import native_bt def _bt2_stream(): @@ -12,9 +13,15 @@ def _bt2_stream(): return bt2_stream -class _PacketConst(object._SharedObject): - _get_ref = staticmethod(native_bt.packet_get_ref) - _put_ref = staticmethod(native_bt.packet_put_ref) +class _PacketConst(bt2_object._SharedObject): + @staticmethod + def _get_ref(ptr): + native_bt.packet_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.packet_put_ref(ptr) + _borrow_stream_ptr = staticmethod(native_bt.packet_borrow_stream_const) _borrow_context_field_ptr = staticmethod( native_bt.packet_borrow_context_field_const diff --git a/src/bindings/python/bt2/bt2/plugin.py b/src/bindings/python/bt2/bt2/plugin.py index 6888cb12..0c990667 100644 --- a/src/bindings/python/bt2/bt2/plugin.py +++ b/src/bindings/python/bt2/bt2/plugin.py @@ -2,16 +2,19 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt, object, utils +import os.path import collections.abc + +from bt2 import utils as bt2_utils +from bt2 import object as bt2_object from bt2 import component as bt2_component -import os.path +from bt2 import native_bt def find_plugins_in_path(path, recurse=True, fail_on_load_error=False): - utils._check_str(path) - utils._check_bool(recurse) - utils._check_bool(fail_on_load_error) + bt2_utils._check_str(path) + bt2_utils._check_bool(recurse) + bt2_utils._check_bool(fail_on_load_error) plugin_set_ptr = None if os.path.isfile(path): @@ -28,7 +31,7 @@ def find_plugins_in_path(path, recurse=True, fail_on_load_error=False): if status == native_bt.__BT_FUNC_STATUS_NOT_FOUND: return - utils._handle_func_status(status, "failed to find plugins") + bt2_utils._handle_func_status(status, "failed to find plugins") assert plugin_set_ptr is not None return _PluginSet._create_from_ptr(plugin_set_ptr) @@ -40,11 +43,11 @@ def find_plugins( find_in_static=True, fail_on_load_error=False, ): - utils._check_bool(find_in_std_env_var) - utils._check_bool(find_in_user_dir) - utils._check_bool(find_in_sys_dir) - utils._check_bool(find_in_static) - utils._check_bool(fail_on_load_error) + bt2_utils._check_bool(find_in_std_env_var) + bt2_utils._check_bool(find_in_user_dir) + bt2_utils._check_bool(find_in_sys_dir) + bt2_utils._check_bool(find_in_static) + bt2_utils._check_bool(fail_on_load_error) plugin_set_ptr = None status, plugin_set_ptr = native_bt.bt2_plugin_find_all( @@ -58,7 +61,7 @@ def find_plugins( if status == native_bt.__BT_FUNC_STATUS_NOT_FOUND: return - utils._handle_func_status(status, "failed to find plugins") + bt2_utils._handle_func_status(status, "failed to find plugins") assert plugin_set_ptr is not None return _PluginSet._create_from_ptr(plugin_set_ptr) @@ -71,8 +74,8 @@ def find_plugin( find_in_static=True, fail_on_load_error=False, ): - utils._check_str(name) - utils._check_bool(fail_on_load_error) + bt2_utils._check_str(name) + bt2_utils._check_bool(fail_on_load_error) status, ptr = native_bt.bt2_plugin_find( name, int(find_in_std_env_var), @@ -85,14 +88,19 @@ def find_plugin( if status == native_bt.__BT_FUNC_STATUS_NOT_FOUND: return - utils._handle_func_status(status, "failed to find plugin") + bt2_utils._handle_func_status(status, "failed to find plugin") assert ptr is not None return _Plugin._create_from_ptr(ptr) -class _PluginSet(object._SharedObject, collections.abc.Sequence): - _put_ref = staticmethod(native_bt.plugin_set_put_ref) - _get_ref = staticmethod(native_bt.plugin_set_get_ref) +class _PluginSet(bt2_object._SharedObject, collections.abc.Sequence): + @staticmethod + def _put_ref(ptr): + native_bt.plugin_set_put_ref(ptr) + + @staticmethod + def _get_ref(ptr): + native_bt.plugin_set_get_ref(ptr) def __len__(self): count = native_bt.plugin_set_get_plugin_count(self._ptr) @@ -100,7 +108,7 @@ class _PluginSet(object._SharedObject, collections.abc.Sequence): return count def __getitem__(self, index): - utils._check_uint64(index) + bt2_utils._check_uint64(index) if index >= len(self): raise IndexError @@ -175,7 +183,7 @@ class _PluginComponentClasses(collections.abc.Mapping): self._plugin = plugin def __getitem__(self, key): - utils._check_str(key) + bt2_utils._check_str(key) cc_ptr = self._borrow_component_class_by_name(self._plugin._ptr, key) if cc_ptr is None: @@ -231,9 +239,14 @@ class _PluginSinkComponentClasses(_PluginComponentClasses): _comp_cls_type = native_bt.COMPONENT_CLASS_TYPE_SINK -class _Plugin(object._SharedObject): - _put_ref = staticmethod(native_bt.plugin_put_ref) - _get_ref = staticmethod(native_bt.plugin_get_ref) +class _Plugin(bt2_object._SharedObject): + @staticmethod + def _put_ref(ptr): + native_bt.plugin_put_ref(ptr) + + @staticmethod + def _get_ref(ptr): + native_bt.plugin_get_ref(ptr) @property def name(self): diff --git a/src/bindings/python/bt2/bt2/port.py b/src/bindings/python/bt2/bt2/port.py index 0d648478..b9a5529a 100644 --- a/src/bindings/python/bt2/bt2/port.py +++ b/src/bindings/python/bt2/bt2/port.py @@ -2,7 +2,8 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt, object +from bt2 import object as bt2_object +from bt2 import native_bt def _bt2_connection(): @@ -29,7 +30,7 @@ def _create_self_from_ptr_and_get_ref(ptr, port_type): return cls._create_from_ptr_and_get_ref(ptr) -class _PortConst(object._SharedObject): +class _PortConst(bt2_object._SharedObject): @classmethod def _get_ref(cls, ptr): ptr = cls._as_port_ptr(ptr) diff --git a/src/bindings/python/bt2/bt2/py_plugin.py b/src/bindings/python/bt2/bt2/py_plugin.py index 6f067e8b..2a7414bb 100644 --- a/src/bindings/python/bt2/bt2/py_plugin.py +++ b/src/bindings/python/bt2/bt2/py_plugin.py @@ -2,10 +2,10 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import utils -from bt2 import component as bt2_component import sys +from bt2 import utils as bt2_utils +from bt2 import component as bt2_component # Python plugin path to `_PluginInfo` (cache) _plugin_infos = {} @@ -27,16 +27,16 @@ def register_plugin( "cannot find module '{}' in loaded modules".format(module_name) ) - utils._check_str(name) + bt2_utils._check_str(name) if description is not None: - utils._check_str(description) + bt2_utils._check_str(description) if author is not None: - utils._check_str(author) + bt2_utils._check_str(author) if license is not None: - utils._check_str(license) + bt2_utils._check_str(license) if version is not None: if not _validate_version(version): @@ -91,9 +91,9 @@ def _try_load_plugin_module(path): # do not load module and create plugin info twice for this path return _plugin_infos[path] - import importlib.machinery - import inspect import hashlib + import inspect + import importlib.machinery if path is None: raise TypeError("missing path") @@ -105,8 +105,18 @@ def _try_load_plugin_module(path): h.update(path.encode()) module_name = "bt_plugin_{}".format(h.hexdigest()) assert module_name not in sys.modules - # try loading the module: any raised exception is catched by the caller - mod = importlib.machinery.SourceFileLoader(module_name, path).load_module() + + # try loading the module: any raised exception is caught by the caller + if sys.version_info < (3, 5): + mod = importlib.machinery.SourceFileLoader(module_name, path).load_module() + else: + import importlib.util + + loader = importlib.machinery.SourceFileLoader(module_name, path) + spec = importlib.util.spec_from_file_location(module_name, path, loader=loader) + mod = importlib.util.module_from_spec(spec) + sys.modules[mod.__name__] = mod + loader.exec_module(mod) # we have the module: look for its plugin info first if not hasattr(mod, "_bt_plugin_info"): diff --git a/src/bindings/python/bt2/bt2/query_executor.py b/src/bindings/python/bt2/bt2/query_executor.py index 354404a6..de6f4441 100644 --- a/src/bindings/python/bt2/bt2/query_executor.py +++ b/src/bindings/python/bt2/bt2/query_executor.py @@ -2,10 +2,12 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt, object, utils -from bt2 import interrupter as bt2_interrupter +from bt2 import error as bt2_error +from bt2 import utils as bt2_utils from bt2 import value as bt2_value -import bt2 +from bt2 import object as bt2_object +from bt2 import native_bt +from bt2 import interrupter as bt2_interrupter def _bt2_component(): @@ -29,9 +31,14 @@ class _QueryExecutorCommon: return native_bt.query_executor_get_logging_level(self._common_ptr) -class QueryExecutor(object._SharedObject, _QueryExecutorCommon): - _get_ref = staticmethod(native_bt.query_executor_get_ref) - _put_ref = staticmethod(native_bt.query_executor_put_ref) +class QueryExecutor(bt2_object._SharedObject, _QueryExecutorCommon): + @staticmethod + def _get_ref(ptr): + native_bt.query_executor_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.query_executor_put_ref(ptr) def _as_query_executor_ptr(self): return self._ptr @@ -50,12 +57,12 @@ class QueryExecutor(object._SharedObject, _QueryExecutorCommon): o = component_class raise TypeError("'{}' is not a component class object".format(o)) - utils._check_str(object_name) + bt2_utils._check_str(object_name) if params is None: params_ptr = native_bt.value_null else: - params = bt2.create_value(params) + params = bt2_value.create_value(params) params_ptr = params._ptr cc_ptr = component_class._bt_component_class_ptr() @@ -73,7 +80,7 @@ class QueryExecutor(object._SharedObject, _QueryExecutorCommon): ) if ptr is None: - raise bt2._MemoryError("cannot create query executor object") + raise bt2_error._MemoryError("cannot create query executor object") super().__init__(ptr) @@ -83,7 +90,7 @@ class QueryExecutor(object._SharedObject, _QueryExecutorCommon): self._method_obj = method_obj def add_interrupter(self, interrupter): - utils._check_type(interrupter, bt2_interrupter.Interrupter) + bt2_utils._check_type(interrupter, bt2_interrupter.Interrupter) native_bt.query_executor_add_interrupter(self._ptr, interrupter._ptr) @property @@ -92,9 +99,11 @@ class QueryExecutor(object._SharedObject, _QueryExecutorCommon): return bt2_interrupter.Interrupter._create_from_ptr_and_get_ref(ptr) def _set_logging_level(self, log_level): - utils._check_log_level(log_level) + bt2_utils._check_log_level(log_level) status = native_bt.query_executor_set_logging_level(self._ptr, log_level) - utils._handle_func_status(status, "cannot set query executor's logging level") + bt2_utils._handle_func_status( + status, "cannot set query executor's logging level" + ) logging_level = property( fget=_QueryExecutorCommon.logging_level, fset=_set_logging_level @@ -107,7 +116,7 @@ class QueryExecutor(object._SharedObject, _QueryExecutorCommon): def query(self): status, result_ptr = native_bt.query_executor_query(self._ptr) - utils._handle_func_status(status, "cannot query component class") + bt2_utils._handle_func_status(status, "cannot query component class") assert result_ptr is not None return bt2_value._create_from_const_ptr(result_ptr) diff --git a/src/bindings/python/bt2/bt2/stream.py b/src/bindings/python/bt2/bt2/stream.py index f1329623..9d8d1ae9 100644 --- a/src/bindings/python/bt2/bt2/stream.py +++ b/src/bindings/python/bt2/bt2/stream.py @@ -2,12 +2,13 @@ # # Copyright (c) 2016-2017 Philippe Proulx -from bt2 import native_bt, utils +from bt2 import error as bt2_error +from bt2 import utils as bt2_utils +from bt2 import value as bt2_value from bt2 import object as bt2_object from bt2 import packet as bt2_packet +from bt2 import native_bt from bt2 import stream_class as bt2_stream_class -from bt2 import value as bt2_value -import bt2 def _bt2_trace(): @@ -17,8 +18,14 @@ def _bt2_trace(): class _StreamConst(bt2_object._SharedObject): - _get_ref = staticmethod(native_bt.stream_get_ref) - _put_ref = staticmethod(native_bt.stream_put_ref) + @staticmethod + def _get_ref(ptr): + native_bt.stream_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.stream_put_ref(ptr) + _borrow_class_ptr = staticmethod(native_bt.stream_borrow_class_const) _borrow_user_attributes_ptr = staticmethod( native_bt.stream_borrow_user_attributes_const @@ -77,13 +84,13 @@ class _Stream(_StreamConst): packet_ptr = native_bt.packet_create(self._ptr) if packet_ptr is None: - raise bt2._MemoryError("cannot create packet object") + raise bt2_error._MemoryError("cannot create packet object") return bt2_packet._Packet._create_from_ptr(packet_ptr) def _user_attributes(self, user_attributes): value = bt2_value.create_value(user_attributes) - utils._check_type(value, bt2_value.MapValue) + bt2_utils._check_type(value, bt2_value.MapValue) native_bt.stream_set_user_attributes(self._ptr, value._ptr) _user_attributes = property( @@ -91,7 +98,7 @@ class _Stream(_StreamConst): ) def _name(self, name): - utils._check_str(name) + bt2_utils._check_str(name) native_bt.stream_set_name(self._ptr, name) _name = property(fget=_StreamConst.name.fget, fset=_name) diff --git a/src/bindings/python/bt2/bt2/stream_class.py b/src/bindings/python/bt2/bt2/stream_class.py index 885ba746..5c6faa07 100644 --- a/src/bindings/python/bt2/bt2/stream_class.py +++ b/src/bindings/python/bt2/bt2/stream_class.py @@ -2,13 +2,16 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt, object, utils -from bt2 import field_class as bt2_field_class -from bt2 import event_class as bt2_event_class -from bt2 import clock_class as bt2_clock_class -from bt2 import value as bt2_value import collections.abc +from bt2 import utils as bt2_utils +from bt2 import value as bt2_value +from bt2 import object as bt2_object +from bt2 import native_bt +from bt2 import clock_class as bt2_clock_class +from bt2 import event_class as bt2_event_class +from bt2 import field_class as bt2_field_class + def _bt2_trace_class(): from bt2 import trace_class as bt2_trace_class @@ -16,9 +19,15 @@ def _bt2_trace_class(): return bt2_trace_class -class _StreamClassConst(object._SharedObject, collections.abc.Mapping): - _get_ref = staticmethod(native_bt.stream_class_get_ref) - _put_ref = staticmethod(native_bt.stream_class_put_ref) +class _StreamClassConst(bt2_object._SharedObject, collections.abc.Mapping): + @staticmethod + def _get_ref(ptr): + native_bt.stream_class_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.stream_class_put_ref(ptr) + _borrow_event_class_ptr_by_id = staticmethod( native_bt.stream_class_borrow_event_class_by_id_const ) @@ -46,7 +55,7 @@ class _StreamClassConst(object._SharedObject, collections.abc.Mapping): _clock_class_cls = property(lambda _: bt2_clock_class._ClockClassConst) def __getitem__(self, key): - utils._check_int64(key) + bt2_utils._check_int64(key) ec_ptr = self._borrow_event_class_ptr_by_id(self._ptr, key) if ec_ptr is None: @@ -165,8 +174,14 @@ class _StreamClassConst(object._SharedObject, collections.abc.Mapping): class _StreamClass(_StreamClassConst): - _get_ref = staticmethod(native_bt.stream_class_get_ref) - _put_ref = staticmethod(native_bt.stream_class_put_ref) + @staticmethod + def _get_ref(ptr): + native_bt.stream_class_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.stream_class_put_ref(ptr) + _borrow_event_class_ptr_by_id = staticmethod( native_bt.stream_class_borrow_event_class_by_id ) @@ -224,7 +239,7 @@ class _StreamClass(_StreamClassConst): "id not provided, but stream class does not assign automatic event class ids" ) - utils._check_uint64(id) + bt2_utils._check_uint64(id) ec_ptr = native_bt.event_class_create_with_id(self._ptr, id) event_class = bt2_event_class._EventClass._create_from_ptr(ec_ptr) @@ -257,7 +272,7 @@ class _StreamClass(_StreamClassConst): def _name(self, name): status = native_bt.stream_class_set_name(self._ptr, name) - utils._handle_func_status(status, "cannot set stream class object's name") + bt2_utils._handle_func_status(status, "cannot set stream class object's name") _name = property(fset=_name) @@ -294,7 +309,7 @@ class _StreamClass(_StreamClassConst): status = native_bt.stream_class_set_packet_context_field_class( self._ptr, packet_context_field_class._ptr ) - utils._handle_func_status( + bt2_utils._handle_func_status( status, "cannot set stream class' packet context field class" ) @@ -303,7 +318,7 @@ class _StreamClass(_StreamClassConst): def _event_common_context_field_class(self, event_common_context_field_class): set_context_fn = native_bt.stream_class_set_event_common_context_field_class status = set_context_fn(self._ptr, event_common_context_field_class._ptr) - utils._handle_func_status( + bt2_utils._handle_func_status( status, "cannot set stream class' event context field type" ) @@ -334,12 +349,12 @@ class _StreamClass(_StreamClassConst): ): # Name if name is not None: - utils._check_str(name) + bt2_utils._check_str(name) # User attributes if user_attributes is not None: value = bt2_value.create_value(user_attributes) - utils._check_type(value, bt2_value.MapValue) + bt2_utils._check_type(value, bt2_value.MapValue) # Packet context field class if packet_context_field_class is not None: @@ -348,30 +363,30 @@ class _StreamClass(_StreamClassConst): "cannot have a packet context field class without supporting packets" ) - utils._check_type( + bt2_utils._check_type( packet_context_field_class, bt2_field_class._StructureFieldClass ) # Event common context field class if event_common_context_field_class is not None: - utils._check_type( + bt2_utils._check_type( event_common_context_field_class, bt2_field_class._StructureFieldClass ) # Default clock class if default_clock_class is not None: - utils._check_type(default_clock_class, bt2_clock_class._ClockClass) + bt2_utils._check_type(default_clock_class, bt2_clock_class._ClockClass) # Assigns automatic event class id - utils._check_bool(assigns_automatic_event_class_id) + bt2_utils._check_bool(assigns_automatic_event_class_id) # Assigns automatic stream id - utils._check_bool(assigns_automatic_stream_id) + bt2_utils._check_bool(assigns_automatic_stream_id) # Packets - utils._check_bool(supports_packets) - utils._check_bool(packets_have_beginning_default_clock_snapshot) - utils._check_bool(packets_have_end_default_clock_snapshot) + bt2_utils._check_bool(supports_packets) + bt2_utils._check_bool(packets_have_beginning_default_clock_snapshot) + bt2_utils._check_bool(packets_have_end_default_clock_snapshot) if not supports_packets: if packets_have_beginning_default_clock_snapshot: @@ -384,8 +399,8 @@ class _StreamClass(_StreamClassConst): ) # Discarded events - utils._check_bool(supports_discarded_events) - utils._check_bool(discarded_events_have_default_clock_snapshots) + bt2_utils._check_bool(supports_discarded_events) + bt2_utils._check_bool(discarded_events_have_default_clock_snapshots) if discarded_events_have_default_clock_snapshots: if not supports_discarded_events: @@ -399,8 +414,8 @@ class _StreamClass(_StreamClassConst): ) # Discarded packets - utils._check_bool(supports_discarded_packets) - utils._check_bool(discarded_packets_have_default_clock_snapshots) + bt2_utils._check_bool(supports_discarded_packets) + bt2_utils._check_bool(discarded_packets_have_default_clock_snapshots) if supports_discarded_packets and not supports_packets: raise ValueError( diff --git a/src/bindings/python/bt2/bt2/trace.py b/src/bindings/python/bt2/bt2/trace.py index 1c56b034..a7038b28 100644 --- a/src/bindings/python/bt2/bt2/trace.py +++ b/src/bindings/python/bt2/bt2/trace.py @@ -2,14 +2,17 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt, object, utils +import uuid as uuidp +import functools import collections.abc + +from bt2 import error as bt2_error +from bt2 import utils as bt2_utils from bt2 import value as bt2_value +from bt2 import object as bt2_object from bt2 import stream as bt2_stream +from bt2 import native_bt from bt2 import stream_class as bt2_stream_class -import bt2 -import functools -import uuid as uuidp def _bt2_trace_class(): @@ -27,7 +30,7 @@ class _TraceEnvironmentConst(collections.abc.Mapping): self._trace = trace def __getitem__(self, key): - utils._check_str(key) + bt2_utils._check_str(key) borrow_entry_fn = native_bt.trace_borrow_environment_entry_value_by_name_const value_ptr = borrow_entry_fn(self._trace._ptr, key) @@ -66,15 +69,23 @@ class _TraceEnvironment(_TraceEnvironmentConst, collections.abc.MutableMapping): raise TypeError("expected str or int, got {}".format(type(value))) status = set_env_entry_fn(self._trace._ptr, key, value) - utils._handle_func_status(status, "cannot set trace object's environment entry") + bt2_utils._handle_func_status( + status, "cannot set trace object's environment entry" + ) def __delitem__(self, key): raise NotImplementedError -class _TraceConst(object._SharedObject, collections.abc.Mapping): - _get_ref = staticmethod(native_bt.trace_get_ref) - _put_ref = staticmethod(native_bt.trace_put_ref) +class _TraceConst(bt2_object._SharedObject, collections.abc.Mapping): + @staticmethod + def _get_ref(ptr): + native_bt.trace_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.trace_put_ref(ptr) + _borrow_stream_ptr_by_id = staticmethod(native_bt.trace_borrow_stream_by_id_const) _borrow_stream_ptr_by_index = staticmethod( native_bt.trace_borrow_stream_by_index_const @@ -96,7 +107,7 @@ class _TraceConst(object._SharedObject, collections.abc.Mapping): return count def __getitem__(self, id): - utils._check_uint64(id) + bt2_utils._check_uint64(id) stream_ptr = self._borrow_stream_ptr_by_id(self._ptr, id) @@ -148,7 +159,7 @@ class _TraceConst(object._SharedObject, collections.abc.Mapping): if not callable(listener): raise TypeError("'listener' parameter is not callable") - handle = utils._ListenerHandle(self.addr) + handle = bt2_utils._ListenerHandle(self.addr) fn = native_bt.bt2_trace_add_destruction_listener listener_from_native = functools.partial( @@ -156,7 +167,7 @@ class _TraceConst(object._SharedObject, collections.abc.Mapping): ) status, listener_id = fn(self._ptr, listener_from_native) - utils._handle_func_status( + bt2_utils._handle_func_status( status, "cannot add destruction listener to trace object" ) @@ -165,7 +176,7 @@ class _TraceConst(object._SharedObject, collections.abc.Mapping): return handle def remove_destruction_listener(self, listener_handle): - utils._check_type(listener_handle, utils._ListenerHandle) + bt2_utils._check_type(listener_handle, bt2_utils._ListenerHandle) if listener_handle._addr != self.addr: raise ValueError( @@ -178,7 +189,7 @@ class _TraceConst(object._SharedObject, collections.abc.Mapping): status = native_bt.trace_remove_destruction_listener( self._ptr, listener_handle._listener_id ) - utils._handle_func_status(status) + bt2_utils._handle_func_status(status) listener_handle._invalidate() @@ -195,27 +206,27 @@ class _Trace(_TraceConst): _trace_env_pycls = property(lambda _: _TraceEnvironment) def _name(self, name): - utils._check_str(name) + bt2_utils._check_str(name) status = native_bt.trace_set_name(self._ptr, name) - utils._handle_func_status(status, "cannot set trace class object's name") + bt2_utils._handle_func_status(status, "cannot set trace class object's name") _name = property(fset=_name) def _user_attributes(self, user_attributes): value = bt2_value.create_value(user_attributes) - utils._check_type(value, bt2_value.MapValue) + bt2_utils._check_type(value, bt2_value.MapValue) native_bt.trace_set_user_attributes(self._ptr, value._ptr) _user_attributes = property(fset=_user_attributes) def _uuid(self, uuid): - utils._check_type(uuid, uuidp.UUID) + bt2_utils._check_type(uuid, uuidp.UUID) native_bt.trace_set_uuid(self._ptr, uuid.bytes) _uuid = property(fset=_uuid) def create_stream(self, stream_class, id=None, name=None, user_attributes=None): - utils._check_type(stream_class, bt2_stream_class._StreamClass) + bt2_utils._check_type(stream_class, bt2_stream_class._StreamClass) if stream_class.assigns_automatic_stream_id: if id is not None: @@ -230,13 +241,13 @@ class _Trace(_TraceConst): "id not provided, but stream class does not assign automatic stream ids" ) - utils._check_uint64(id) + bt2_utils._check_uint64(id) stream_ptr = native_bt.stream_create_with_id( stream_class._ptr, self._ptr, id ) if stream_ptr is None: - raise bt2._MemoryError("cannot create stream object") + raise bt2_error._MemoryError("cannot create stream object") stream = bt2_stream._Stream._create_from_ptr(stream_ptr) diff --git a/src/bindings/python/bt2/bt2/trace_class.py b/src/bindings/python/bt2/bt2/trace_class.py index f66f3855..a691da30 100644 --- a/src/bindings/python/bt2/bt2/trace_class.py +++ b/src/bindings/python/bt2/bt2/trace_class.py @@ -4,28 +4,37 @@ # Copyright (c) 2018 Francis Deslauriers # Copyright (c) 2019 Simon Marchi -from bt2 import native_bt, utils, object -from bt2 import stream_class as bt2_stream_class -from bt2 import field_class as bt2_field_class -from bt2 import integer_range_set as bt2_integer_range_set +import functools +import collections.abc + +from bt2 import error as bt2_error from bt2 import trace as bt2_trace +from bt2 import utils as bt2_utils from bt2 import value as bt2_value -import collections.abc -import functools -import bt2 +from bt2 import object as bt2_object +from bt2 import native_bt +from bt2 import field_class as bt2_field_class +from bt2 import stream_class as bt2_stream_class +from bt2 import integer_range_set as bt2_integer_range_set def _trace_class_destruction_listener_from_native( user_listener, handle, trace_class_ptr ): - trace_class = _TraceClass._create_from_ptr_and_get_ref(trace_class_ptr) + trace_class = _TraceClassConst._create_from_ptr_and_get_ref(trace_class_ptr) user_listener(trace_class) handle._invalidate() -class _TraceClassConst(object._SharedObject, collections.abc.Mapping): - _get_ref = staticmethod(native_bt.trace_class_get_ref) - _put_ref = staticmethod(native_bt.trace_class_put_ref) +class _TraceClassConst(bt2_object._SharedObject, collections.abc.Mapping): + @staticmethod + def _get_ref(ptr): + native_bt.trace_class_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.trace_class_put_ref(ptr) + _borrow_stream_class_ptr_by_index = staticmethod( native_bt.trace_class_borrow_stream_class_by_index_const ) @@ -56,7 +65,7 @@ class _TraceClassConst(object._SharedObject, collections.abc.Mapping): # Get a stream class by stream id. def __getitem__(self, key): - utils._check_uint64(key) + bt2_utils._check_uint64(key) sc_ptr = self._borrow_stream_class_ptr_by_id(self._ptr, key) if sc_ptr is None: @@ -81,11 +90,10 @@ class _TraceClassConst(object._SharedObject, collections.abc.Mapping): # Add a listener to be called when the trace class is destroyed. def add_destruction_listener(self, listener): - if not callable(listener): raise TypeError("'listener' parameter is not callable") - handle = utils._ListenerHandle(self.addr) + handle = bt2_utils._ListenerHandle(self.addr) listener_from_native = functools.partial( _trace_class_destruction_listener_from_native, listener, handle @@ -93,7 +101,7 @@ class _TraceClassConst(object._SharedObject, collections.abc.Mapping): fn = native_bt.bt2_trace_class_add_destruction_listener status, listener_id = fn(self._ptr, listener_from_native) - utils._handle_func_status( + bt2_utils._handle_func_status( status, "cannot add destruction listener to trace class object" ) @@ -102,7 +110,7 @@ class _TraceClassConst(object._SharedObject, collections.abc.Mapping): return handle def remove_destruction_listener(self, listener_handle): - utils._check_type(listener_handle, utils._ListenerHandle) + bt2_utils._check_type(listener_handle, bt2_utils._ListenerHandle) if listener_handle._addr != self.addr: raise ValueError( @@ -117,7 +125,7 @@ class _TraceClassConst(object._SharedObject, collections.abc.Mapping): status = native_bt.trace_class_remove_destruction_listener( self._ptr, listener_handle._listener_id ) - utils._handle_func_status(status) + bt2_utils._handle_func_status(status) listener_handle._invalidate() @@ -142,7 +150,7 @@ class _TraceClass(_TraceClassConst): trace_ptr = native_bt.trace_create(self._ptr) if trace_ptr is None: - raise bt2._MemoryError("cannot create trace class object") + raise bt2_error._MemoryError("cannot create trace class object") trace = bt2_trace._Trace._create_from_ptr(trace_ptr) @@ -210,7 +218,7 @@ class _TraceClass(_TraceClassConst): "id not provided, but trace class does not assign automatic stream class ids" ) - utils._check_uint64(id) + bt2_utils._check_uint64(id) sc_ptr = native_bt.stream_class_create_with_id(self._ptr, id) sc = bt2_stream_class._StreamClass._create_from_ptr(sc_ptr) @@ -255,13 +263,13 @@ class _TraceClass(_TraceClassConst): def _user_attributes(self, user_attributes): value = bt2_value.create_value(user_attributes) - utils._check_type(value, bt2_value.MapValue) + bt2_utils._check_type(value, bt2_value.MapValue) native_bt.trace_class_set_user_attributes(self._ptr, value._ptr) _user_attributes = property(fset=_user_attributes) def _assigns_automatic_stream_class_id(self, auto_id): - utils._check_bool(auto_id) + bt2_utils._check_bool(auto_id) return native_bt.trace_class_set_assigns_automatic_stream_class_id( self._ptr, auto_id ) @@ -274,7 +282,9 @@ class _TraceClass(_TraceClassConst): def _check_field_class_create_status(self, ptr, type_name): if ptr is None: - raise bt2._MemoryError("cannot create {} field class".format(type_name)) + raise bt2_error._MemoryError( + "cannot create {} field class".format(type_name) + ) @staticmethod def _set_field_class_user_attrs(fc, user_attributes): @@ -289,7 +299,7 @@ class _TraceClass(_TraceClassConst): return fc def create_bit_array_field_class(self, length, user_attributes=None): - utils._check_uint64(length) + bt2_utils._check_uint64(length) if length < 1 or length > 64: raise ValueError( @@ -414,8 +424,8 @@ class _TraceClass(_TraceClassConst): return fc def create_static_array_field_class(self, elem_fc, length, user_attributes=None): - utils._check_type(elem_fc, bt2_field_class._FieldClass) - utils._check_uint64(length) + bt2_utils._check_type(elem_fc, bt2_field_class._FieldClass) + bt2_utils._check_uint64(length) ptr = native_bt.field_class_array_static_create(self._ptr, elem_fc._ptr, length) self._check_field_class_create_status(ptr, "static array") fc = bt2_field_class._StaticArrayFieldClass._create_from_ptr(ptr) @@ -425,11 +435,11 @@ class _TraceClass(_TraceClassConst): def create_dynamic_array_field_class( self, elem_fc, length_fc=None, user_attributes=None ): - utils._check_type(elem_fc, bt2_field_class._FieldClass) + bt2_utils._check_type(elem_fc, bt2_field_class._FieldClass) length_fc_ptr = None if length_fc is not None: - utils._check_type(length_fc, bt2_field_class._UnsignedIntegerFieldClass) + bt2_utils._check_type(length_fc, bt2_field_class._UnsignedIntegerFieldClass) length_fc_ptr = length_fc._ptr ptr = native_bt.field_class_array_dynamic_create( @@ -443,7 +453,7 @@ class _TraceClass(_TraceClassConst): def create_option_without_selector_field_class( self, content_fc, user_attributes=None ): - utils._check_type(content_fc, bt2_field_class._FieldClass) + bt2_utils._check_type(content_fc, bt2_field_class._FieldClass) ptr = native_bt.field_class_option_without_selector_create( self._ptr, content_fc._ptr ) @@ -455,9 +465,9 @@ class _TraceClass(_TraceClassConst): def create_option_with_bool_selector_field_class( self, content_fc, selector_fc, selector_is_reversed=False, user_attributes=None ): - utils._check_type(content_fc, bt2_field_class._FieldClass) - utils._check_bool(selector_is_reversed) - utils._check_type(selector_fc, bt2_field_class._BoolFieldClass) + bt2_utils._check_type(content_fc, bt2_field_class._FieldClass) + bt2_utils._check_bool(selector_is_reversed) + bt2_utils._check_type(selector_fc, bt2_field_class._BoolFieldClass) ptr = native_bt.field_class_option_with_selector_field_bool_create( self._ptr, content_fc._ptr, selector_fc._ptr ) @@ -470,19 +480,19 @@ class _TraceClass(_TraceClassConst): def create_option_with_integer_selector_field_class( self, content_fc, selector_fc, ranges, user_attributes=None ): - utils._check_type(content_fc, bt2_field_class._FieldClass) - utils._check_type(selector_fc, bt2_field_class._IntegerFieldClass) + bt2_utils._check_type(content_fc, bt2_field_class._FieldClass) + bt2_utils._check_type(selector_fc, bt2_field_class._IntegerFieldClass) if len(ranges) == 0: raise ValueError("integer range set is empty") if isinstance(selector_fc, bt2_field_class._UnsignedIntegerFieldClass): - utils._check_type(ranges, bt2_integer_range_set.UnsignedIntegerRangeSet) + bt2_utils._check_type(ranges, bt2_integer_range_set.UnsignedIntegerRangeSet) ptr = native_bt.field_class_option_with_selector_field_integer_unsigned_create( self._ptr, content_fc._ptr, selector_fc._ptr, ranges._ptr ) else: - utils._check_type(ranges, bt2_integer_range_set.SignedIntegerRangeSet) + bt2_utils._check_type(ranges, bt2_integer_range_set.SignedIntegerRangeSet) ptr = ( native_bt.field_class_option_with_selector_field_integer_signed_create( self._ptr, content_fc._ptr, selector_fc._ptr, ranges._ptr @@ -498,7 +508,7 @@ class _TraceClass(_TraceClassConst): selector_fc_ptr = None if selector_fc is not None: - utils._check_type(selector_fc, bt2_field_class._IntegerFieldClass) + bt2_utils._check_type(selector_fc, bt2_field_class._IntegerFieldClass) selector_fc_ptr = selector_fc._ptr ptr = native_bt.field_class_variant_create(self._ptr, selector_fc_ptr) diff --git a/src/bindings/python/bt2/bt2/trace_collection_message_iterator.py b/src/bindings/python/bt2/bt2/trace_collection_message_iterator.py index ed474cd0..3a6b9521 100644 --- a/src/bindings/python/bt2/bt2/trace_collection_message_iterator.py +++ b/src/bindings/python/bt2/bt2/trace_collection_message_iterator.py @@ -2,18 +2,24 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import utils, native_bt -import bt2 +import numbers +import datetime import itertools -from bt2 import message_iterator as bt2_message_iterator +from collections import namedtuple + +from bt2 import mip as bt2_mip from bt2 import port as bt2_port -from bt2 import component as bt2_component +from bt2 import error as bt2_error +from bt2 import graph as bt2_graph +from bt2 import utils as bt2_utils from bt2 import value as bt2_value from bt2 import plugin as bt2_plugin -import datetime -from collections import namedtuple -import numbers - +from bt2 import logging as bt2_logging +from bt2 import component as bt2_component +from bt2 import native_bt +from bt2 import query_executor as bt2_query_executor +from bt2 import message_iterator as bt2_message_iterator +from bt2 import component_descriptor as bt2_component_descriptor # a pair of component and ComponentSpec _ComponentAndSpec = namedtuple("_ComponentAndSpec", ["comp", "spec"]) @@ -24,9 +30,9 @@ class _BaseComponentSpec: # TraceCollectionMessageIterator. def __init__(self, params, obj, logging_level): if logging_level is not None: - utils._check_log_level(logging_level) + bt2_utils._check_log_level(logging_level) - self._params = bt2.create_value(params) + self._params = bt2_value.create_value(params) self._obj = obj self._logging_level = logging_level @@ -50,7 +56,7 @@ class ComponentSpec(_BaseComponentSpec): component_class, params=None, obj=None, - logging_level=bt2.LoggingLevel.NONE, + logging_level=bt2_logging.LoggingLevel.NONE, ): if type(params) is str: params = {"inputs": [params]} @@ -59,12 +65,16 @@ class ComponentSpec(_BaseComponentSpec): is_cc_object = isinstance( component_class, - (bt2._SourceComponentClassConst, bt2._FilterComponentClassConst), + ( + bt2_component._SourceComponentClassConst, + bt2_component._FilterComponentClassConst, + ), ) is_user_cc_type = isinstance( component_class, bt2_component._UserComponentType ) and issubclass( - component_class, (bt2._UserSourceComponent, bt2._UserFilterComponent) + component_class, + (bt2_component._UserSourceComponent, bt2_component._UserFilterComponent), ) if not is_cc_object and not is_user_cc_type: @@ -87,9 +97,9 @@ class ComponentSpec(_BaseComponentSpec): component_class_name, params=None, obj=None, - logging_level=bt2.LoggingLevel.NONE, + logging_level=bt2_logging.LoggingLevel.NONE, ): - plugin = bt2.find_plugin(plugin_name) + plugin = bt2_plugin.find_plugin(plugin_name) if plugin is None: raise ValueError("no such plugin: {}".format(plugin_name)) @@ -124,54 +134,54 @@ class AutoSourceComponentSpec(_BaseComponentSpec): def _auto_discover_source_component_specs(auto_source_comp_specs, plugin_set): # Transform a list of `AutoSourceComponentSpec` in a list of `ComponentSpec` # using the automatic source discovery mechanism. - inputs = bt2.ArrayValue([spec.input for spec in auto_source_comp_specs]) + inputs = bt2_value.ArrayValue([spec.input for spec in auto_source_comp_specs]) if plugin_set is None: - plugin_set = bt2.find_plugins() + plugin_set = bt2_plugin.find_plugins() else: - utils._check_type(plugin_set, bt2_plugin._PluginSet) + bt2_utils._check_type(plugin_set, bt2_plugin._PluginSet) res_ptr = native_bt.bt2_auto_discover_source_components( inputs._ptr, plugin_set._ptr ) if res_ptr is None: - raise bt2._MemoryError("cannot auto discover source components") + raise bt2_error._MemoryError("cannot auto discover source components") res = bt2_value._create_from_ptr(res_ptr) - assert type(res) == bt2.MapValue + assert type(res) is bt2_value.MapValue assert "status" in res status = res["status"] - utils._handle_func_status(status, "cannot auto-discover source components") + bt2_utils._handle_func_status(status, "cannot auto-discover source components") comp_specs = [] comp_specs_raw = res["results"] - assert type(comp_specs_raw) == bt2.ArrayValue + assert type(comp_specs_raw) is bt2_value.ArrayValue used_input_indices = set() for comp_spec_raw in comp_specs_raw: - assert type(comp_spec_raw) == bt2.ArrayValue + assert type(comp_spec_raw) is bt2_value.ArrayValue assert len(comp_spec_raw) == 4 plugin_name = comp_spec_raw[0] - assert type(plugin_name) == bt2.StringValue + assert type(plugin_name) is bt2_value.StringValue plugin_name = str(plugin_name) class_name = comp_spec_raw[1] - assert type(class_name) == bt2.StringValue + assert type(class_name) is bt2_value.StringValue class_name = str(class_name) comp_inputs = comp_spec_raw[2] - assert type(comp_inputs) == bt2.ArrayValue + assert type(comp_inputs) is bt2_value.ArrayValue comp_orig_indices = comp_spec_raw[3] assert type(comp_orig_indices) - params = bt2.MapValue() - logging_level = bt2.LoggingLevel.NONE + params = bt2_value.MapValue() + logging_level = bt2_logging.LoggingLevel.NONE obj = None # Compute `params` for this component by piling up params given to all @@ -264,7 +274,7 @@ class TraceCollectionMessageIterator(bt2_message_iterator._MessageIterator): end=None, plugin_set=None, ): - utils._check_bool(stream_intersection_mode) + bt2_utils._check_bool(stream_intersection_mode) self._stream_intersection_mode = stream_intersection_mode self._begin_ns = _get_ns(begin) self._end_ns = _get_ns(end) @@ -329,7 +339,7 @@ class TraceCollectionMessageIterator(bt2_message_iterator._MessageIterator): # Query the port's component for the `babeltrace.trace-infos` # object which contains the range for each stream, from which we can # compute the intersection of the streams in each trace. - query_exec = bt2.QueryExecutor( + query_exec = bt2_query_executor.QueryExecutor( src_comp_and_spec.spec.component_class, "babeltrace.trace-infos", src_comp_and_spec.spec.params, @@ -391,7 +401,7 @@ class TraceCollectionMessageIterator(bt2_message_iterator._MessageIterator): return self._create_trimmer(begin, end, name) def _create_muxer(self): - plugin = bt2.find_plugin("utils") + plugin = bt2_plugin.find_plugin("utils") if plugin is None: raise RuntimeError('cannot find "utils" plugin (needed for the muxer)') @@ -405,7 +415,7 @@ class TraceCollectionMessageIterator(bt2_message_iterator._MessageIterator): return self._graph.add_component(comp_cls, "muxer") def _create_trimmer(self, begin_ns, end_ns, name): - plugin = bt2.find_plugin("utils") + plugin = bt2_plugin.find_plugin("utils") if plugin is None: raise RuntimeError('cannot find "utils" plugin (needed for the trimmer)') @@ -491,7 +501,7 @@ class TraceCollectionMessageIterator(bt2_message_iterator._MessageIterator): def append_comp_specs_descriptors(descriptors, comp_specs): for comp_spec in comp_specs: descriptors.append( - bt2.ComponentDescriptor( + bt2_component_descriptor.ComponentDescriptor( comp_spec.component_class, comp_spec.params, comp_spec.obj ) ) @@ -507,7 +517,7 @@ class TraceCollectionMessageIterator(bt2_message_iterator._MessageIterator): ) append_comp_specs_descriptors(descriptors, [comp_spec]) - mip_version = bt2.get_greatest_operative_mip_version(descriptors) + mip_version = bt2_mip.get_greatest_operative_mip_version(descriptors) if mip_version is None: msg = "failed to find an operative message interchange protocol version (components are not interoperable)" @@ -516,7 +526,7 @@ class TraceCollectionMessageIterator(bt2_message_iterator._MessageIterator): return mip_version def _build_graph(self): - self._graph = bt2.Graph(self._get_greatest_operative_mip_version()) + self._graph = bt2_graph.Graph(self._get_greatest_operative_mip_version()) self._graph.add_port_added_listener(self._graph_port_added) self._muxer_comp = self._create_muxer() diff --git a/src/bindings/python/bt2/bt2/utils.py b/src/bindings/python/bt2/bt2/utils.py index 393f7ed8..fc6d24ce 100644 --- a/src/bindings/python/bt2/bt2/utils.py +++ b/src/bindings/python/bt2/bt2/utils.py @@ -2,11 +2,33 @@ # # Copyright (c) 2017 Philippe Proulx -import bt2 + +from bt2 import error as bt2_error from bt2 import logging as bt2_logging from bt2 import native_bt +class UnknownObject(Exception): + """ + Raised when a component class handles a query for an object it doesn't + know about. + """ + + pass + + +class _OverflowError(bt2_error._Error, OverflowError): + pass + + +class TryAgain(Exception): + pass + + +class Stop(StopIteration): + pass + + def _check_bool(o): if not isinstance(o, bool): raise TypeError("'{}' is not a 'bool' object".format(o.__class__.__name__)) @@ -119,30 +141,27 @@ def _handle_func_status(status, msg=None): if status == native_bt.__BT_FUNC_STATUS_ERROR: assert msg is not None - raise bt2._Error(msg) + raise bt2_error._Error(msg) elif status == native_bt.__BT_FUNC_STATUS_MEMORY_ERROR: assert msg is not None - raise bt2._MemoryError(msg) + raise bt2_error._MemoryError(msg) elif status == native_bt.__BT_FUNC_STATUS_END: if msg is None: - raise bt2.Stop + raise Stop else: - raise bt2.Stop(msg) + raise Stop(msg) elif status == native_bt.__BT_FUNC_STATUS_AGAIN: if msg is None: - raise bt2.TryAgain + raise TryAgain else: - raise bt2.TryAgain(msg) + raise TryAgain(msg) elif status == native_bt.__BT_FUNC_STATUS_OVERFLOW_ERROR: - if msg is None: - raise bt2._OverflowError - else: - raise bt2._OverflowError(msg) + raise _OverflowError(msg) elif status == native_bt.__BT_FUNC_STATUS_UNKNOWN_OBJECT: if msg is None: - raise bt2.UnknownObject + raise UnknownObject else: - raise bt2.UnknownObject(msg) + raise UnknownObject(msg) else: assert False diff --git a/src/bindings/python/bt2/bt2/value.py b/src/bindings/python/bt2/bt2/value.py index 04016dec..c938ff90 100644 --- a/src/bindings/python/bt2/bt2/value.py +++ b/src/bindings/python/bt2/bt2/value.py @@ -2,13 +2,16 @@ # # Copyright (c) 2017 Philippe Proulx -from bt2 import native_bt, object, utils -import collections.abc -import functools -import numbers -import math import abc -import bt2 +import math +import numbers +import functools +import collections.abc + +from bt2 import error as bt2_error +from bt2 import utils as bt2_utils +from bt2 import object as bt2_object +from bt2 import native_bt def _create_from_ptr_template(ptr, object_map): @@ -81,9 +84,15 @@ def create_value(value): ) -class _ValueConst(object._SharedObject, metaclass=abc.ABCMeta): - _get_ref = staticmethod(native_bt.value_get_ref) - _put_ref = staticmethod(native_bt.value_put_ref) +class _ValueConst(bt2_object._SharedObject, metaclass=abc.ABCMeta): + @staticmethod + def _get_ref(ptr): + native_bt.value_get_ref(ptr) + + @staticmethod + def _put_ref(ptr): + native_bt.value_put_ref(ptr) + _create_value_from_ptr = staticmethod(_create_from_const_ptr) _create_value_from_ptr_and_get_ref = staticmethod( _create_from_const_ptr_and_get_ref @@ -94,7 +103,7 @@ class _ValueConst(object._SharedObject, metaclass=abc.ABCMeta): def _check_create_status(self, ptr): if ptr is None: - raise bt2._MemoryError( + raise bt2_error._MemoryError( "cannot create {} value object".format(self._NAME.lower()) ) @@ -331,7 +340,7 @@ class _UnsignedIntegerValueConst(_IntegerValueConst): class UnsignedIntegerValue(_UnsignedIntegerValueConst, _IntegerValue): _NAME = "Unsigned integer" - _check_int_range = staticmethod(utils._check_uint64) + _check_int_range = staticmethod(bt2_utils._check_uint64) _create_default_value = staticmethod(native_bt.value_integer_unsigned_create) _create_value = staticmethod(native_bt.value_integer_unsigned_create_init) _set_value = staticmethod(native_bt.value_integer_unsigned_set) @@ -344,7 +353,7 @@ class _SignedIntegerValueConst(_IntegerValueConst): class SignedIntegerValue(_SignedIntegerValueConst, _IntegerValue): _NAME = "Signed integer" - _check_int_range = staticmethod(utils._check_int64) + _check_int_range = staticmethod(bt2_utils._check_int64) _create_default_value = staticmethod(native_bt.value_integer_signed_create) _create_value = staticmethod(native_bt.value_integer_signed_create_init) _set_value = staticmethod(native_bt.value_integer_signed_set) @@ -393,7 +402,7 @@ class _StringValueConst(collections.abc.Sequence, _Value): if isinstance(value, _StringValueConst): value = value._value - utils._check_str(value) + bt2_utils._check_str(value) return value @property @@ -442,7 +451,7 @@ class StringValue(_StringValueConst, _Value): def _set_value(self, value): status = native_bt.value_string_set(self._ptr, self._value_to_str(value)) - utils._handle_func_status(status) + bt2_utils._handle_func_status(status) value = property(fset=_set_value) @@ -540,7 +549,7 @@ class ArrayValue(_ArrayValueConst, _Container, collections.abc.MutableSequence, ptr = value._ptr status = native_bt.value_array_set_element_by_index(self._ptr, index, ptr) - utils._handle_func_status(status) + bt2_utils._handle_func_status(status) def append(self, value): value = create_value(value) @@ -551,7 +560,7 @@ class ArrayValue(_ArrayValueConst, _Container, collections.abc.MutableSequence, ptr = value._ptr status = native_bt.value_array_append_element(self._ptr, ptr) - utils._handle_func_status(status) + bt2_utils._handle_func_status(status) def __iadd__(self, iterable): # Python will raise a TypeError if there's anything wrong with @@ -619,7 +628,7 @@ class _MapValueConst(_ContainerConst, collections.abc.Mapping, _ValueConst): return native_bt.value_map_has_entry(self._ptr, key) def _check_key_type(self, key): - utils._check_str(key) + bt2_utils._check_str(key) def _check_key(self, key): if key not in self: @@ -664,7 +673,7 @@ class MapValue(_MapValueConst, _Container, collections.abc.MutableMapping, _Valu ptr = value._ptr status = native_bt.value_map_insert_entry(self._ptr, key, ptr) - utils._handle_func_status(status) + bt2_utils._handle_func_status(status) _TYPE_TO_OBJ = { diff --git a/src/bindings/python/bt2/setup.py.in b/src/bindings/python/bt2/setup.py.in index 44b1dc67..3c81447e 100644 --- a/src/bindings/python/bt2/setup.py.in +++ b/src/bindings/python/bt2/setup.py.in @@ -5,9 +5,39 @@ import sys import os -import distutils.sysconfig +import shutil +import subprocess + +# Distutils was removed in Python 3.12, use setuptools as an alternative. +if sys.version_info >= (3, 12): + from setuptools import setup, Extension +else: + from distutils.core import setup, Extension + +# Starting with Debian's Python 3.10, the default install scheme is +# 'posix_local' which is a Debian specific scheme based on 'posix_prefix' but +# with an added 'local' prefix. This is the default so users doing system wide +# manual installations of python modules end up in '/usr/local'. This +# interferes with our autotools based install which already defaults to +# '/usr/local' and expect a provided prefix to be used verbatim. +# +# Monkeypatch sysconfig to override this scheme and use 'posix_prefix' instead. +if sys.version_info >= (3, 10): + import sysconfig + + original_get_preferred_scheme = sysconfig.get_preferred_scheme + + def our_get_preferred_scheme(key): + scheme = original_get_preferred_scheme(key) + if scheme == "posix_local": + return "posix_prefix" + else: + return scheme + + sysconfig.get_preferred_scheme = our_get_preferred_scheme -from distutils.core import setup, Extension +else: + import distutils.sysconfig as sysconfig PY_PATH_WARN_MSG = """ -------------------------------------WARNING------------------------------------ @@ -19,7 +49,7 @@ following command to your .bashrc/.zshrc: -------------------------------------------------------------------------------- """ -original_get_config_vars = distutils.sysconfig.get_config_vars +original_get_config_vars = sysconfig.get_config_vars def get_cflags(): @@ -32,12 +62,12 @@ def get_cflags(): # distutils performs a similar transformation step on LDSHARED on -# darwin to use the overriden CC as the default command for LDSHARED +# darwin to use the overridden CC as the default command for LDSHARED # (see distutils' customize_compiler() step in the sysconfig module). # # This takes it a step further by using our own LDFLAGS (when available) -# along with the overriden compiler and ensure that flags that are unsupported -# by either the Python interprter's CC or the overriden CC don't cause a +# along with the overridden compiler and ensure that flags that are unsupported +# by either the Python interprter's CC or the overridden CC don't cause a # build failure. def get_ldshared(): cc = os.environ.get("CC") @@ -59,43 +89,78 @@ def get_ldshared(): def our_get_config_vars(*args): - overridden_config_vars = { - "CFLAGS": get_cflags(), - "LDSHARED": get_ldshared(), + overridden_config_vars_funcs = { + "CFLAGS": get_cflags, + "LDSHARED": get_ldshared, } if len(args) == 0: + # Return a dict with all config vars. all_config_vars = original_get_config_vars() - for name in overridden_config_vars: - all_config_vars[name] = overridden_config_vars[name] + for name in overridden_config_vars_funcs: + all_config_vars[name] = overridden_config_vars_funcs[name]() + return all_config_vars + else: + # Return a list with the requested config vars. + subset_config_vars = [] + for name in args: + if name in overridden_config_vars_funcs: + subset_config_vars.append(overridden_config_vars_funcs[name]()) + else: + subset_config_vars.append(original_get_config_vars(name)[0]) + + return subset_config_vars - subset_config_vars = [] - for name in args: - if name not in overridden_config_vars: - [var] = original_get_config_vars(name) - subset_config_vars.append(var) - continue - subset_config_vars.append(overridden_config_vars[name]) +sysconfig.get_config_vars = our_get_config_vars - return subset_config_vars +# Returns 'True' when running on a MinGW system. +def is_mingw(): + return sys.platform == "win32" and shutil.which("cygpath") != None -distutils.sysconfig.get_config_vars = our_get_config_vars + +# On MinGW systems run 'cygpath -m' on 'path', on other systems return 'path' as-is. +def cygpath_m(path: str): + if is_mingw(): + return subprocess.check_output( + 'cygpath -m "{}"'.format(path), shell=True, encoding="utf-8" + ).strip("\n") + + return path + + +# On MinGW systems, check CFLAGS and CPPFLAGS for absolute include paths +# (starts with '-I/') and convert them to valid Windows paths using cygpath. +if is_mingw(): + for flagvar in ["CFLAGS", "CPPFLAGS"]: + cur_flags = os.getenv(flagvar) + if cur_flags != None: + new_flags = "" + for flag in cur_flags.split(): + if flag.startswith("-I/"): + flag = "-I{}".format(cygpath_m(flag[2:])) + + new_flags += " {}".format(flag) + + os.environ[flagvar] = new_flags def main(): babeltrace_ext = Extension( "bt2._native_bt", - sources=["bt2/native_bt.c", "@srcdir@/bt2/logging.c"], + sources=[ + "bt2/native_bt.c", + cygpath_m("@srcdir@/bt2/logging.c"), + ], libraries=["babeltrace2", "glib-2.0"], extra_objects=[ - "@top_builddir@/src/autodisc/.libs/libbabeltrace2-autodisc.a", - "@top_builddir@/src/logging/.libs/libbabeltrace2-logging.a", - "@top_builddir@/src/common/.libs/libbabeltrace2-common.a", - "@top_builddir@/src/py-common/.libs/libbabeltrace2-py-common.a", - "@top_builddir@/src/string-format/.libs/libbabeltrace2-string-format.a", + "@top_builddir@/src/autodisc/.libs/libautodisc.a", + "@top_builddir@/src/logging/.libs/liblogging.a", + "@top_builddir@/src/common/.libs/libcommon.a", + "@top_builddir@/src/py-common/.libs/libpy-common.a", + "@top_builddir@/src/string-format/.libs/libstring-format.a", ], ) diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am index adbf2bb0..45254878 100644 --- a/src/cli/Makefile.am +++ b/src/cli/Makefile.am @@ -1,6 +1,8 @@ +# SPDX-FileCopyrightText: 2019-2023 EfficiOS, Inc. # SPDX-License-Identifier: MIT -PLUGINS_PATH = $(abs_top_builddir)/src/plugins +include $(top_srcdir)/src/Makefile.common.inc + LTTNG_UTILS_PLUGIN_PATH = if ENABLE_DEBUG_INFO @@ -38,7 +40,7 @@ babeltrace2_bin_SOURCES = \ babeltrace2-plugins.h \ babeltrace2-query.c \ babeltrace2-query.h \ - logging.c \ + logging.cpp \ logging.h # -Wl,--no-as-needed is needed for recent gold linker who seems to think @@ -57,31 +59,17 @@ EXTRA_babeltrace2_bin_DEPENDENCIES = # directly). babeltrace2_bin_LDADD = \ $(top_builddir)/src/argpar/libargpar.la \ - $(top_builddir)/src/autodisc/libbabeltrace2-autodisc.la \ - $(top_builddir)/src/param-parse/libbabeltrace2-param-parse.la \ - $(top_builddir)/src/string-format/libbabeltrace2-string-format.la \ + $(top_builddir)/src/autodisc/libautodisc.la \ + $(top_builddir)/src/param-parse/libparam-parse.la \ + $(top_builddir)/src/string-format/libstring-format.la \ $(top_builddir)/src/lib/libbabeltrace2.la \ $(top_builddir)/src/compat/libcompat.la \ - $(top_builddir)/src/common/libbabeltrace2-common.la \ - $(top_builddir)/src/logging/libbabeltrace2-logging.la \ - $(top_builddir)/src/ctfser/libbabeltrace2-ctfser.la + $(top_builddir)/src/common/libcommon.la \ + $(top_builddir)/src/cpp-common/vendor/fmt/libfmt.la \ + $(top_builddir)/src/logging/liblogging.la \ + $(top_builddir)/src/ctfser/libctfser.la if ENABLE_BUILT_IN_PLUGINS -# Takes a plugin name and outputs the needed LDFLAGS to embed it. -# -# The --whole-archive option is important here. From the GNU linker's -# documentation: -# -# For each archive mentioned on the command line after the -# --whole-archive option, include every object file in the archive in -# the link, rather than searching the archive for the required object -# files. -# -# In our case, we find the plugins thanks to special sections in the -# binary that are filled by plugin objects. If the linker discards those -# symbols because the CLI does not use them directly, the CLI reports -# no plugins found (plugins are effectively not embedded). -pluginarchive = $(LD_WHOLE_ARCHIVE)$(PLUGINS_PATH)/$(1)/.libs/babeltrace-plugin-$(1).a$(LD_NO_WHOLE_ARCHIVE) # Built-in plugins babeltrace2_bin_LDFLAGS += $(call pluginarchive,ctf) diff --git a/src/cli/babeltrace2-cfg-cli-args-connect.h b/src/cli/babeltrace2-cfg-cli-args-connect.h index 580a50cc..48a442e7 100644 --- a/src/cli/babeltrace2-cfg-cli-args-connect.h +++ b/src/cli/babeltrace2-cfg-cli-args-connect.h @@ -9,7 +9,6 @@ #include #include -#include #include #include "babeltrace2-cfg.h" diff --git a/src/cli/babeltrace2-cfg-cli-args-default.c b/src/cli/babeltrace2-cfg-cli-args-default.c index 0e657720..e8cb2e1d 100644 --- a/src/cli/babeltrace2-cfg-cli-args-default.c +++ b/src/cli/babeltrace2-cfg-cli-args-default.c @@ -42,7 +42,7 @@ enum bt_config_cli_args_status bt_config_cli_args_create_with_default(int argc, g_setenv("LIBBABELTRACE2_PLUGIN_PROVIDER_DIR", CONFIG_IN_TREE_PROVIDER_DIR, 0); #else /* - * If the Pyhton plugin provider is disabled, use a non-exitent path to avoid + * If the Python plugin provider is disabled, use a non-exitent path to avoid * loading the system installed provider if it exit, if the env variable is * already set, do not overwrite it. */ diff --git a/src/cli/babeltrace2-cfg-cli-args.c b/src/cli/babeltrace2-cfg-cli-args.c index 6c187b4f..2fdadf21 100644 --- a/src/cli/babeltrace2-cfg-cli-args.c +++ b/src/cli/babeltrace2-cfg-cli-args.c @@ -132,17 +132,14 @@ void plugin_comp_cls_names(const char *arg, char **name, char **plugin, *name = NULL; g_string_free(gs_name, TRUE); } else { - *name = gs_name->str; - g_string_free(gs_name, FALSE); + *name = g_string_free(gs_name, FALSE); } } else { g_string_free(gs_name, TRUE); } - *plugin = gs_plugin->str; - *comp_cls = gs_comp_cls->str; - g_string_free(gs_plugin, FALSE); - g_string_free(gs_comp_cls, FALSE); + *plugin = g_string_free(gs_plugin, FALSE); + *comp_cls = g_string_free(gs_comp_cls, FALSE); gs_name = NULL; gs_plugin = NULL; gs_comp_cls = NULL; @@ -2425,7 +2422,6 @@ const struct argpar_opt_descr convert_options[] = { { OPT_OUTPUT, 'w', "output", true }, { OPT_OUTPUT_FORMAT, 'o', "output-format", true }, { OPT_PARAMS, 'p', "params", true }, - { OPT_PLUGIN_PATH, '\0', "plugin-path", true }, { OPT_RETRY_DURATION, '\0', "retry-duration", true }, { OPT_RUN_ARGS, '\0', "run-args", false }, { OPT_RUN_ARGS_0, '\0', "run-args-0", false }, @@ -3088,10 +3084,8 @@ int split_timerange(const char *arg, char **begin, char **end) BT_ASSERT(begin); BT_ASSERT(end); - *begin = g_begin->str; - *end = g_end->str; - g_string_free(g_begin, FALSE); - g_string_free(g_end, FALSE); + *begin = g_string_free(g_begin, FALSE); + *end = g_string_free(g_end, FALSE); g_begin = NULL; g_end = NULL; goto end; diff --git a/src/cli/babeltrace2-cfg-cli-args.h b/src/cli/babeltrace2-cfg-cli-args.h index 92f49995..1ceded7e 100644 --- a/src/cli/babeltrace2-cfg-cli-args.h +++ b/src/cli/babeltrace2-cfg-cli-args.h @@ -10,10 +10,8 @@ #include #include #include -#include #include "lib/object.h" #include "compat/compiler.h" -#include #include #include "babeltrace2-cfg.h" diff --git a/src/cli/babeltrace2-cfg.h b/src/cli/babeltrace2-cfg.h index f9e0ce93..79e11610 100644 --- a/src/cli/babeltrace2-cfg.h +++ b/src/cli/babeltrace2-cfg.h @@ -12,10 +12,8 @@ #include #include #include -#include #include "lib/object.h" #include "compat/compiler.h" -#include #include enum bt_config_command { diff --git a/src/cli/babeltrace2-plugins.h b/src/cli/babeltrace2-plugins.h index c3f59b6c..c95eda90 100644 --- a/src/cli/babeltrace2-plugins.h +++ b/src/cli/babeltrace2-plugins.h @@ -12,15 +12,15 @@ #include #include "common/macros.h" -BT_HIDDEN void init_loaded_plugins(void); -BT_HIDDEN void fini_loaded_plugins(void); +void init_loaded_plugins(void); +void fini_loaded_plugins(void); -BT_HIDDEN int require_loaded_plugins(const bt_value *plugin_paths); +int require_loaded_plugins(const bt_value *plugin_paths); -BT_HIDDEN size_t get_loaded_plugins_count(void); -BT_HIDDEN const bt_plugin **borrow_loaded_plugins(void); -BT_HIDDEN const bt_plugin *borrow_loaded_plugin_by_index(size_t index); -BT_HIDDEN const bt_plugin *borrow_loaded_plugin_by_name(const char *name); +size_t get_loaded_plugins_count(void); +const bt_plugin **borrow_loaded_plugins(void); +const bt_plugin *borrow_loaded_plugin_by_index(size_t index); +const bt_plugin *borrow_loaded_plugin_by_name(const char *name); #endif /* CLI_BABELTRACE_PLUGINS_H */ diff --git a/src/cli/babeltrace2-query.c b/src/cli/babeltrace2-query.c index 38f42b58..4493b21a 100644 --- a/src/cli/babeltrace2-query.c +++ b/src/cli/babeltrace2-query.c @@ -21,7 +21,6 @@ void set_fail_reason(const char **fail_reason, const char *reason) } } -BT_HIDDEN bt_query_executor_query_status cli_query(const bt_component_class *comp_cls, const char *obj, const bt_value *params, bt_logging_level log_level, const bt_interrupter *interrupter, diff --git a/src/cli/babeltrace2-query.h b/src/cli/babeltrace2-query.h index 2b4f55f4..c128bb6c 100644 --- a/src/cli/babeltrace2-query.h +++ b/src/cli/babeltrace2-query.h @@ -10,7 +10,6 @@ #include #include "common/macros.h" -BT_HIDDEN bt_query_executor_query_status cli_query(const bt_component_class *comp_cls, const char *obj, const bt_value *params, bt_logging_level log_level, const bt_interrupter *interrupter, diff --git a/src/cli/babeltrace2.c b/src/cli/babeltrace2.c index bf6c49d5..fbe38a87 100644 --- a/src/cli/babeltrace2.c +++ b/src/cli/babeltrace2.c @@ -59,7 +59,7 @@ static bt_interrupter *the_interrupter; #include static -BOOL WINAPI signal_handler(DWORD signal) { +BOOL WINAPI signal_handler(DWORD signal __attribute__((unused))) { if (the_interrupter) { bt_interrupter_set(the_interrupter); } @@ -253,7 +253,9 @@ end: static bt_value_map_foreach_entry_const_func_status collect_map_keys( - const char *key, const bt_value *object, void *data) + const char *key, + const bt_value *object __attribute__((unused)), + void *data) { GPtrArray *map_keys = data; @@ -1647,7 +1649,7 @@ end: static bt_graph_listener_func_status graph_source_output_port_added_listener( - const bt_component_source *component, + const bt_component_source *component __attribute__((unused)), const bt_port_output *port, void *data) { return graph_output_port_added_listener(data, port); @@ -1655,7 +1657,7 @@ bt_graph_listener_func_status graph_source_output_port_added_listener( static bt_graph_listener_func_status graph_filter_output_port_added_listener( - const bt_component_filter *component, + const bt_component_filter *component __attribute__((unused)), const bt_port_output *port, void *data) { return graph_output_port_added_listener(data, port); @@ -1811,7 +1813,7 @@ bt_get_greatest_operative_mip_version_status get_greatest_operative_mip_version( } status = bt_get_greatest_operative_mip_version(comp_descr_set, - bt_cli_log_level, mip_version); + (bt_logging_level) bt_cli_log_level, mip_version); end: bt_component_descriptor_set_put_ref(comp_descr_set); @@ -2563,7 +2565,7 @@ void warn_command_name_and_directory_clash(struct bt_config *cfg) if (g_file_test(cfg->command_name, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) { - _bt_log_write_d(_BT_LOG_SRCLOC_FUNCTION, __FILE__, __LINE__, + bt_log_write_printf(__FILE__, __func__, __LINE__, BT_LOG_WARNING, BT_LOG_TAG, "The `%s` command was executed. " "If you meant to convert a trace located in " @@ -2606,8 +2608,8 @@ void print_error_causes(void) */ fputc('\n', stderr); - error_str = format_bt_error(error, columns, bt_cli_log_level, - BT_COMMON_COLOR_WHEN_AUTO); + error_str = format_bt_error(error, columns, + (bt_logging_level) bt_cli_log_level, BT_COMMON_COLOR_WHEN_AUTO); BT_ASSERT(error_str); fprintf(stderr, "%s\n", error_str); diff --git a/src/cli/logging.c b/src/cli/logging.c deleted file mode 100644 index 329cb70a..00000000 --- a/src/cli/logging.c +++ /dev/null @@ -1,10 +0,0 @@ -/* - * SPDX-License-Identifier: MIT - * - * Copyright (c) 2017 Philippe Proulx - */ - -#define BT_LOG_OUTPUT_LEVEL bt_cli_log_level -#include "logging/log.h" - -BT_LOG_INIT_LOG_LEVEL(bt_cli_log_level, "BABELTRACE_CLI_LOG_LEVEL"); diff --git a/src/cli/logging.cpp b/src/cli/logging.cpp new file mode 100644 index 00000000..36d59bf1 --- /dev/null +++ b/src/cli/logging.cpp @@ -0,0 +1,10 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright (c) 2017 Philippe Proulx + */ + +#define BT_LOG_OUTPUT_LEVEL bt_cli_log_level +#include "logging/log-api.h" + +BT_LOG_INIT_LOG_LEVEL(bt_cli_log_level, "BABELTRACE_CLI_LOG_LEVEL"); diff --git a/src/cli/logging.h b/src/cli/logging.h index 59c93619..967b2382 100644 --- a/src/cli/logging.h +++ b/src/cli/logging.h @@ -14,7 +14,7 @@ BT_LOG_LEVEL_EXTERN_SYMBOL(bt_cli_log_level); #define BT_CLI_LOG_AND_APPEND(_lvl, _fmt, ...) \ do { \ - BT_LOG_WRITE(_lvl, BT_LOG_TAG, _fmt, ##__VA_ARGS__); \ + BT_LOG_WRITE_PRINTF(_lvl, BT_LOG_TAG, _fmt, ##__VA_ARGS__); \ (void) BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN( \ "Babeltrace CLI", _fmt, ##__VA_ARGS__); \ } while (0) diff --git a/src/clock-correlation-validator/clock-correlation-validator.cpp b/src/clock-correlation-validator/clock-correlation-validator.cpp new file mode 100644 index 00000000..4bb1a725 --- /dev/null +++ b/src/clock-correlation-validator/clock-correlation-validator.cpp @@ -0,0 +1,197 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright 2024 EfficiOS, Inc. + */ + +#include "cpp-common/bt2/clock-class.hpp" +#include "cpp-common/bt2/message.hpp" +#include "cpp-common/bt2/wrap.hpp" + +#include "clock-correlation-validator.h" +#include "clock-correlation-validator.hpp" + +namespace bt2ccv { + +void ClockCorrelationValidator::_validate(const bt2::ConstMessage msg) +{ + bt2::OptionalBorrowedObject clockCls; + bt2::OptionalBorrowedObject streamCls; + + switch (msg.type()) { + case bt2::MessageType::StreamBeginning: + streamCls = msg.asStreamBeginning().stream().cls(); + clockCls = streamCls->defaultClockClass(); + break; + + case bt2::MessageType::MessageIteratorInactivity: + clockCls = msg.asMessageIteratorInactivity().clockSnapshot().clockClass(); + break; + + default: + bt_common_abort(); + } + + switch (_mExpectation) { + case PropsExpectation::Unset: + /* + * This is the first analysis of a message with a clock + * snapshot: record the properties of that clock, against which + * we'll compare the clock properties of the following messages. + */ + if (!clockCls) { + _mExpectation = PropsExpectation::None; + } else if (clockCls->originIsUnixEpoch()) { + _mExpectation = PropsExpectation::OriginUnix; + } else if (const auto uuid = clockCls->uuid()) { + _mExpectation = PropsExpectation::OriginOtherUuid; + _mUuid = *uuid; + } else { + _mExpectation = PropsExpectation::OriginOtherNoUuid; + _mClockClass = clockCls->shared(); + } + + break; + + case PropsExpectation::None: + if (clockCls) { + throw ClockCorrelationError {ClockCorrelationError::Type::ExpectingNoClockClassGotOne, + bt2s::nullopt, + *clockCls, + {}, + streamCls}; + } + + break; + + case PropsExpectation::OriginUnix: + if (!clockCls) { + throw ClockCorrelationError {ClockCorrelationError::Type::ExpectingOriginUnixGotNone, + bt2s::nullopt, + {}, + {}, + streamCls}; + } + + if (!clockCls->originIsUnixEpoch()) { + throw ClockCorrelationError {ClockCorrelationError::Type::ExpectingOriginUnixGotOther, + bt2s::nullopt, + *clockCls, + {}, + streamCls}; + } + + break; + + case PropsExpectation::OriginOtherUuid: + { + if (!clockCls) { + throw ClockCorrelationError {ClockCorrelationError::Type::ExpectingOriginUuidGotNone, + bt2s::nullopt, + {}, + {}, + streamCls}; + } + + if (clockCls->originIsUnixEpoch()) { + throw ClockCorrelationError {ClockCorrelationError::Type::ExpectingOriginUuidGotUnix, + bt2s::nullopt, + *clockCls, + {}, + streamCls}; + } + + const auto uuid = clockCls->uuid(); + + if (!uuid) { + throw ClockCorrelationError {ClockCorrelationError::Type::ExpectingOriginUuidGotNoUuid, + bt2s::nullopt, + *clockCls, + {}, + streamCls}; + } + + if (*uuid != _mUuid) { + throw ClockCorrelationError { + ClockCorrelationError::Type::ExpectingOriginUuidGotOtherUuid, + _mUuid, + *clockCls, + {}, + streamCls}; + } + + break; + } + + case PropsExpectation::OriginOtherNoUuid: + if (!clockCls) { + throw ClockCorrelationError {ClockCorrelationError::Type::ExpectingOriginNoUuidGotNone, + bt2s::nullopt, + {}, + {}, + streamCls}; + } + + if (clockCls->libObjPtr() != _mClockClass->libObjPtr()) { + throw ClockCorrelationError {ClockCorrelationError::Type::ExpectingOriginNoUuidGotOther, + bt2s::nullopt, *clockCls, *_mClockClass, streamCls}; + } + + break; + + default: + bt_common_abort(); + } +} + +} /* namespace bt2ccv */ + +bt_clock_correlation_validator *bt_clock_correlation_validator_create() noexcept +{ + try { + return reinterpret_cast( + new bt2ccv::ClockCorrelationValidator); + } catch (const std::bad_alloc&) { + return nullptr; + } +} + +bool bt_clock_correlation_validator_validate_message( + bt_clock_correlation_validator * const validator, const bt_message * const msg, + bt_clock_correlation_validator_error_type * const type, bt_uuid * const expectedUuidOut, + const bt_clock_class ** const actualClockClsOut, + const bt_clock_class ** const expectedClockClsOut) noexcept +{ + try { + reinterpret_cast(validator)->validate(bt2::wrap(msg)); + return true; + } catch (const bt2ccv::ClockCorrelationError& error) { + *type = static_cast(error.type()); + + if (error.expectedUuid()) { + *expectedUuidOut = error.expectedUuid()->data(); + } else { + *expectedUuidOut = nullptr; + } + + if (error.actualClockCls()) { + *actualClockClsOut = error.actualClockCls()->libObjPtr(); + } else { + *actualClockClsOut = nullptr; + } + + if (error.expectedClockCls()) { + *expectedClockClsOut = error.expectedClockCls()->libObjPtr(); + } else { + *expectedClockClsOut = nullptr; + } + + return false; + } +} + +void bt_clock_correlation_validator_destroy( + bt_clock_correlation_validator * const validator) noexcept +{ + delete reinterpret_cast(validator); +} diff --git a/src/clock-correlation-validator/clock-correlation-validator.h b/src/clock-correlation-validator/clock-correlation-validator.h new file mode 100644 index 00000000..4ccb7598 --- /dev/null +++ b/src/clock-correlation-validator/clock-correlation-validator.h @@ -0,0 +1,54 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright 2024 EfficiOS, Inc. + */ + +#ifndef CLOCK_CORRELATION_VALIDATOR_CLOCK_CORRELATION_VALIDATOR_H +#define CLOCK_CORRELATION_VALIDATOR_CLOCK_CORRELATION_VALIDATOR_H + +#include +#include +#include + +#include "common/macros.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct bt_clock_class; +struct bt_message; + +enum bt_clock_correlation_validator_error_type +{ + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_NO_CLOCK_CLASS_GOT_ONE, + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNIX_GOT_NONE, + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNIX_GOT_OTHER, + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UUID_GOT_NONE, + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UUID_GOT_UNIX, + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UUID_GOT_NO_UUID, + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UUID_GOT_OTHER_UUID, + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_NO_UUID_GOT_NONE, + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_NO_UUID_GOT_OTHER, +}; + +struct bt_clock_correlation_validator *bt_clock_correlation_validator_create( + void) BT_NOEXCEPT; + +bool bt_clock_correlation_validator_validate_message( + struct bt_clock_correlation_validator *validator, + const struct bt_message *msg, + enum bt_clock_correlation_validator_error_type *type, + bt_uuid *expected_uuid, + const struct bt_clock_class ** const actual_clock_cls, + const struct bt_clock_class ** const expected_clock_cls) BT_NOEXCEPT; + +void bt_clock_correlation_validator_destroy( + struct bt_clock_correlation_validator *validator) BT_NOEXCEPT; + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* CLOCK_CORRELATION_VALIDATOR_CLOCK_CORRELATION_VALIDATOR_H */ diff --git a/src/clock-correlation-validator/clock-correlation-validator.hpp b/src/clock-correlation-validator/clock-correlation-validator.hpp new file mode 100644 index 00000000..314551c3 --- /dev/null +++ b/src/clock-correlation-validator/clock-correlation-validator.hpp @@ -0,0 +1,151 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright 2024 EfficiOS, Inc. + */ + +#ifndef CLOCK_CORRELATION_VALIDATOR_CLOCK_CORRELATION_VALIDATOR_HPP +#define CLOCK_CORRELATION_VALIDATOR_CLOCK_CORRELATION_VALIDATOR_HPP + +#include "cpp-common/bt2/message.hpp" + +#include "clock-correlation-validator/clock-correlation-validator.h" + +namespace bt2ccv { + +class ClockCorrelationError final : public std::runtime_error +{ +public: + enum class Type + { + ExpectingNoClockClassGotOne = + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_NO_CLOCK_CLASS_GOT_ONE, + ExpectingOriginUnixGotNone = + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNIX_GOT_NONE, + ExpectingOriginUnixGotOther = + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UNIX_GOT_OTHER, + ExpectingOriginUuidGotNone = + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UUID_GOT_NONE, + ExpectingOriginUuidGotUnix = + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UUID_GOT_UNIX, + ExpectingOriginUuidGotNoUuid = + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UUID_GOT_NO_UUID, + ExpectingOriginUuidGotOtherUuid = + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_UUID_GOT_OTHER_UUID, + ExpectingOriginNoUuidGotNone = + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_NO_UUID_GOT_NONE, + ExpectingOriginNoUuidGotOther = + BT_CLOCK_CORRELATION_VALIDATOR_ERROR_TYPE_EXPECTING_ORIGIN_NO_UUID_GOT_OTHER, + }; + + explicit ClockCorrelationError( + Type type, const bt2s::optional expectedUuid, + const bt2::OptionalBorrowedObject actualClockCls, + const bt2::OptionalBorrowedObject expectedClockCls, + const bt2::OptionalBorrowedObject streamCls) noexcept : + std::runtime_error {"Clock classes are not correlatable"}, + _mType {type}, _mExpectedUuid {expectedUuid}, _mActualClockCls {actualClockCls}, + _mExpectedClockCls {expectedClockCls}, _mStreamCls {streamCls} + + { + } + + Type type() const noexcept + { + return _mType; + } + + bt2s::optional expectedUuid() const noexcept + { + return _mExpectedUuid; + } + + bt2::OptionalBorrowedObject actualClockCls() const noexcept + { + return _mActualClockCls; + } + + bt2::OptionalBorrowedObject expectedClockCls() const noexcept + { + return _mExpectedClockCls; + } + + bt2::OptionalBorrowedObject streamCls() const noexcept + { + return _mStreamCls; + } + +private: + Type _mType; + bt2s::optional _mExpectedUuid; + bt2::OptionalBorrowedObject _mActualClockCls; + bt2::OptionalBorrowedObject _mExpectedClockCls; + bt2::OptionalBorrowedObject _mStreamCls; +}; + +class ClockCorrelationValidator final +{ +private: + enum class PropsExpectation + { + /* We haven't recorded clock properties yet. */ + Unset, + + /* Expect to have no clock. */ + None, + + /* Expect a clock with a Unix epoch origin. */ + OriginUnix, + + /* Expect a clock without a Unix epoch origin, but with a UUID. */ + OriginOtherUuid, + + /* Expect a clock without a Unix epoch origin and without a UUID. */ + OriginOtherNoUuid, + }; + +public: + void validate(const bt2::ConstMessage msg) + { + if (!msg.isStreamBeginning() && !msg.isMessageIteratorInactivity()) { + return; + } + + this->_validate(msg); + } + +private: + void _validate(const bt2::ConstMessage msg); + + PropsExpectation _mExpectation = PropsExpectation::Unset; + + /* + * Expected UUID of the clock, if `_mExpectation` is + * `PropsExpectation::ORIGIN_OTHER_UUID`. + * + * If the origin of the clock is the Unix epoch, then the UUID is + * irrelevant because the clock will have a correlation with other + * clocks having the same origin. + */ + bt2c::Uuid _mUuid; + + /* + * Expected clock class, if `_mExpectation` is + * `ClockExpectation::ORIGIN_OTHER_NO_UUID`. + * + * If the first analyzed clock class has an unknown origin and no + * UUID, then all subsequent analyzed clock classes must be the same + * instance. + * + * To make sure that the clock class pointed to by this member + * doesn't get freed and another one reallocated at the same + * address, which could potentially bypass the clock expectation + * check, we keep a strong reference, ensuring that the clock class + * lives at least as long as the owner of this validator. + */ + bt2::ConstClockClass::Shared _mClockClass; +}; + +} /* namespace bt2ccv */ + +#endif /* CLOCK_CORRELATION_VALIDATOR_CLOCK_CORRELATION_VALIDATOR_HPP */ diff --git a/src/common/Makefile.am b/src/common/Makefile.am deleted file mode 100644 index cc17ad76..00000000 --- a/src/common/Makefile.am +++ /dev/null @@ -1,121 +0,0 @@ -# SPDX-License-Identifier: MIT - -AM_CPPFLAGS += -DBABELTRACE_PLUGINS_DIR=\"$(BABELTRACE_PLUGINS_DIR)\" - -noinst_LTLIBRARIES = libbabeltrace2-common.la - -libbabeltrace2_common_la_SOURCES = \ - assert.c \ - assert.h \ - common.c \ - common.h \ - uuid.c \ - uuid.h - -noinst_HEADERS = \ - align.h \ - list.h \ - macros.h \ - mmap-align.h \ - safe.h - -# The following section is based on a similar feature in LTTng-tools. - -## -## This target generates an include file that contains the git version -## string of the current branch, it must be continuously updated when -## we build in the git repo and shipped in dist tarballs to reflect the -## status of the tree when it was generated. If the tree is clean and -## the current commit is tag a starting with "v", consider this a -## release version and set an empty git version. -## -## Here is what the inline script does: -## -## First, delete any stale "version.i.tmp" file. -## -## If "bootstrap" and ".git" exists in the top source directory and the git -## executable is available, get the current git version string in the form: -## -## "latest_tag"(-"number_of_commits_on_top")(-g"latest_commit_hash")(-dirty) -## -## And store it in "version.i.tmp", if the current commit is tagged, the tag -## starts with "v" and the tree is clean, consider this a release version and -## overwrite the git version with an empty string in "version.i.tmp". -## -## If we don't have a "version.i.tmp" nor a "version.i", generate an empty -## string as a failover. If a "version.i" is present, for example when building -## from a distribution tarball, get the git_version using grep. -## -## Fetch the BT_VERSION_EXTRA_NAME define from "version/extra_version_name" and output it -## to "version.i.tmp". -## -## Fetch the BT_VERSION_EXTRA_DESCRIPTION define from "version/extra_version_description", -## sanitize and format it with a sed script to replace all non-alpha-numeric values -## with "-" and join all lines by replacing "\n" with litteral string c-style "\n" and -## output it to "version.i.tmp". -## -## Repeat the same logic for the "version/extra_patches" directory. -## Data fetched from "version/extra_patches" must be sanitized and -## formatted. -## The data is fetched using "ls" with an ignore pattern for the README.adoc file. -## The sanitize step uses sed with a script to replace all -## non-alpha-numeric values, except " " (space), to "-". -## The formatting step uses sed with a script to join all lines -## by replacing "\n" with litteral string c-style "\n". -## -## If we don't have a "version.i" or we have both files (version.i, version.i.tmp) -## and they are different, copy "version.i.tmp" over "version.i". -## This way the dependent targets are only rebuilt when the git version -## string or either one of extra version string change. -## -version_verbose = $(version_verbose_@AM_V@) -version_verbose_ = $(version_verbose_@AM_DEFAULT_V@) -version_verbose_0 = @echo " GEN " $@; - -version.i: - $(version_verbose)rm -f version.i.tmp; \ - if (test ! -f version.i && test -f "$(top_srcdir)/include/version.i"); then \ - cp "$(top_srcdir)/include/version.i" version.i; \ - fi; \ - if (test -r "$(top_srcdir)/bootstrap" && test -r "$(top_srcdir)/.git") && \ - test -x "`which git 2>&1;true`"; then \ - GIT_VERSION_STR="`cd "$(top_srcdir)" && git describe --tags --dirty`"; \ - GIT_CURRENT_TAG="`cd "$(top_srcdir)" && git describe --tags --exact-match --match="v[0-9]*" HEAD 2> /dev/null`"; \ - echo "#define BT_VERSION_GIT \"$$GIT_VERSION_STR\"" > version.i.tmp; \ - if ! $(GREP) -- "-dirty" version.i.tmp > /dev/null && \ - test "x$$GIT_CURRENT_TAG" != "x"; then \ - echo "#define BT_VERSION_GIT \"\"" > version.i.tmp; \ - fi; \ - fi; \ - if test ! -f version.i.tmp; then \ - if test -f version.i; then \ - $(GREP) "^#define \bBT_VERSION_GIT\b.*" version.i > version.i.tmp; \ - else \ - echo '#define BT_VERSION_GIT ""' > version.i.tmp; \ - fi; \ - fi; \ - echo "#define BT_VERSION_EXTRA_NAME \"`$(SED) -n '1p' "$(top_srcdir)/version/extra_version_name" 2> /dev/null`\"" >> version.i.tmp; \ - echo "#define BT_VERSION_EXTRA_DESCRIPTION \"`$(SED) -E ':a ; N ; $$!ba ; s/[^a-zA-Z0-9 \n\t\.,]/-/g ; s/\r{0,1}\n/\\\n/g' "$(top_srcdir)/version/extra_version_description" 2> /dev/null`\"" >> version.i.tmp; \ - echo "#define BT_VERSION_EXTRA_PATCHES \"`ls -1 "$(top_srcdir)/version/extra_patches" | $(GREP) -v '^README.adoc' | $(SED) -E ':a ; N ; $$!ba ; s/[^a-zA-Z0-9 \n\t\.]/-/g ; s/\r{0,1}\n/\\\n/g' 2> /dev/null`\"" >> version.i.tmp; \ - if test ! -f version.i || \ - test x"`cat version.i.tmp`" != x"`cat version.i`"; then \ - mv version.i.tmp version.i; \ - fi; \ - rm -f version.i.tmp; \ - true - -## -## version.i is defined as a .PHONY target even if it's a real file, -## we want the target to be re-run on every make. -## -.PHONY: version.i - -CLEANFILES = version.i.tmp - -## -## Only clean "version.i" on dist-clean, we need to keep it on regular -## clean when it's part of a dist tarball. -## -DISTCLEANFILES = version.i - -noinst_HEADERS += version.h version.i diff --git a/src/common/align.h b/src/common/align.h index 0d4c0150..01004c67 100644 --- a/src/common/align.h +++ b/src/common/align.h @@ -19,41 +19,4 @@ ((__typeof__(p)) BT_ALIGN_FLOOR((unsigned long) (p), a)) #define BT_IS_ALIGNED(x, a) (((x) & ((__typeof__(x)) (a) - 1)) == 0) -/* - * Align pointer on natural object alignment. - */ -#define bt_object_align(obj) BT_PTR_ALIGN(obj, __alignof__(*(obj))) -#define bt_object_align_floor(obj) BT_PTR_ALIGN_FLOOR(obj, __alignof__(*(obj))) - -/** - * bt_offset_align - Calculate the offset needed to align an object on its - * natural alignment towards higher addresses. - * @align_drift: object offset from an "alignment"-aligned address. - * @alignment: natural object alignment. Must be non-zero, power of 2. - * - * Returns the offset that must be added to align towards higher - * addresses. - */ -#define offset_align(align_drift, alignment) \ - ({ \ - MAYBE_BUILD_BUG_ON((alignment) == 0 \ - || ((alignment) & ((alignment) - 1))); \ - (((alignment) - (align_drift)) & ((alignment) - 1)); \ - }) - -/** - * bt_offset_align_floor - Calculate the offset needed to align an object - * on its natural alignment towards lower addresses. - * @align_drift: object offset from an "alignment"-aligned address. - * @alignment: natural object alignment. Must be non-zero, power of 2. - * - * Returns the offset that must be substracted to align towards lower addresses. - */ -#define bt_offset_align_floor(align_drift, alignment) \ - ({ \ - MAYBE_BUILD_BUG_ON((alignment) == 0 \ - || ((alignment) & ((alignment) - 1))); \ - (((align_drift) - (alignment)) & ((alignment) - 1)); \ - }) - #endif /* _BABELTRACE_ALIGN_H */ diff --git a/src/common/assert.h b/src/common/assert.h index dd9b9127..52349e64 100644 --- a/src/common/assert.h +++ b/src/common/assert.h @@ -17,7 +17,6 @@ extern "C" { #endif -BT_HIDDEN extern void bt_common_assert_failed(const char *file, int line, const char *func, const char *assertion) __attribute__((noreturn)); diff --git a/src/common/common.c b/src/common/common.c index c82bee33..e28836dd 100644 --- a/src/common/common.c +++ b/src/common/common.c @@ -221,20 +221,17 @@ void __attribute__((constructor)) bt_common_color_ctor(void) color_codes.bg_light_gray = BT_COMMON_COLOR_BG_LIGHT_GRAY; } -BT_HIDDEN const char *bt_common_get_system_plugin_path(void) { return SYSTEM_PLUGIN_PATH; } #ifdef __MINGW32__ -BT_HIDDEN bool bt_common_is_setuid_setgid(void) { return false; } #else /* __MINGW32__ */ -BT_HIDDEN bool bt_common_is_setuid_setgid(void) { return (geteuid() != getuid() || getegid() != getgid()); @@ -243,13 +240,13 @@ bool bt_common_is_setuid_setgid(void) #ifdef __MINGW32__ static -const char *bt_get_home_dir(int log_level) +const char *bt_get_home_dir(int log_level __attribute__((unused))) { return g_get_home_dir(); } #else /* __MINGW32__ */ static -char *bt_secure_getenv(const char *name, int log_level) +char *bt_secure_getenv(const char *name, int log_level __attribute__((unused))) { if (bt_common_is_setuid_setgid()) { BT_LOGD("Disregarding environment variable for setuid/setgid binary: " @@ -280,7 +277,6 @@ end: } #endif /* __MINGW32__ */ -BT_HIDDEN char *bt_common_get_home_plugin_path(int log_level) { char *path = NULL; @@ -312,7 +308,6 @@ end: return path; } -BT_HIDDEN int bt_common_append_plugin_path_dirs(const char *paths, GPtrArray *dirs) { int ret = 0; @@ -396,7 +391,6 @@ end: return istty; } -BT_HIDDEN bool bt_common_colors_supported(void) { static bool supports_colors = false; @@ -452,157 +446,131 @@ end: return supports_colors; } -BT_HIDDEN const char *bt_common_color_reset(void) { return bt_common_color_code_reset; } -BT_HIDDEN const char *bt_common_color_bold(void) { return bt_common_color_code_bold; } -BT_HIDDEN const char *bt_common_color_fg_default(void) { return bt_common_color_code_fg_default; } -BT_HIDDEN const char *bt_common_color_fg_red(void) { return bt_common_color_code_fg_red; } -BT_HIDDEN const char *bt_common_color_fg_green(void) { return bt_common_color_code_fg_green; } -BT_HIDDEN const char *bt_common_color_fg_yellow(void) { return bt_common_color_code_fg_yellow; } -BT_HIDDEN const char *bt_common_color_fg_blue(void) { return bt_common_color_code_fg_blue; } -BT_HIDDEN const char *bt_common_color_fg_magenta(void) { return bt_common_color_code_fg_magenta; } -BT_HIDDEN const char *bt_common_color_fg_cyan(void) { return bt_common_color_code_fg_cyan; } -BT_HIDDEN const char *bt_common_color_fg_light_gray(void) { return bt_common_color_code_fg_light_gray; } -BT_HIDDEN const char *bt_common_color_fg_bright_red(void) { return bt_common_color_code_fg_bright_red; } -BT_HIDDEN const char *bt_common_color_fg_bright_green(void) { return bt_common_color_code_fg_bright_green; } -BT_HIDDEN const char *bt_common_color_fg_bright_yellow(void) { return bt_common_color_code_fg_bright_yellow; } -BT_HIDDEN const char *bt_common_color_fg_bright_blue(void) { return bt_common_color_code_fg_bright_blue; } -BT_HIDDEN const char *bt_common_color_fg_bright_magenta(void) { return bt_common_color_code_fg_bright_magenta; } -BT_HIDDEN const char *bt_common_color_fg_bright_cyan(void) { return bt_common_color_code_fg_bright_cyan; } -BT_HIDDEN const char *bt_common_color_fg_bright_light_gray(void) { return bt_common_color_code_fg_bright_light_gray; } -BT_HIDDEN const char *bt_common_color_bg_default(void) { return bt_common_color_code_bg_default; } -BT_HIDDEN const char *bt_common_color_bg_red(void) { return bt_common_color_code_bg_red; } -BT_HIDDEN const char *bt_common_color_bg_green(void) { return bt_common_color_code_bg_green; } -BT_HIDDEN const char *bt_common_color_bg_yellow(void) { return bt_common_color_code_bg_yellow; } -BT_HIDDEN const char *bt_common_color_bg_blue(void) { return bt_common_color_code_bg_blue; } -BT_HIDDEN const char *bt_common_color_bg_magenta(void) { return bt_common_color_code_bg_magenta; } -BT_HIDDEN const char *bt_common_color_bg_cyan(void) { return bt_common_color_code_bg_cyan; } -BT_HIDDEN const char *bt_common_color_bg_light_gray(void) { return bt_common_color_code_bg_light_gray; } -BT_HIDDEN void bt_common_color_get_codes(struct bt_common_color_codes *codes, enum bt_common_color_when use_colors) { @@ -621,7 +589,6 @@ void bt_common_color_get_codes(struct bt_common_color_codes *codes, } } -BT_HIDDEN GString *bt_common_string_until(const char *input, const char *escapable_chars, const char *end_chars, size_t *end_pos) { @@ -704,7 +671,6 @@ end: return output; } -BT_HIDDEN GString *bt_common_shell_quote(const char *input, bool with_single_quotes) { GString *output = g_string_new(NULL); @@ -760,7 +726,6 @@ end: return output; } -BT_HIDDEN bool bt_common_string_is_printable(const char *input) { const char *ch; @@ -779,7 +744,6 @@ end: return printable; } -BT_HIDDEN void bt_common_destroy_lttng_live_url_parts( struct bt_common_lttng_live_url_parts *parts) { @@ -811,7 +775,6 @@ end: return; } -BT_HIDDEN struct bt_common_lttng_live_url_parts bt_common_parse_lttng_live_url( const char *url, char *error_buf, size_t error_buf_size) { @@ -990,7 +953,6 @@ end: return parts; } -BT_HIDDEN void bt_common_normalize_star_glob_pattern(char *pattern) { const char *p; @@ -1050,7 +1012,6 @@ bool at_end_of_pattern(const char *p, const char *pattern, size_t pattern_len) * string length of `pattern` or `candidate` if the string is * null-terminated. */ -BT_HIDDEN bool bt_common_star_glob_match(const char *pattern, size_t pattern_len, const char *candidate, size_t candidate_len) { const char *retry_c = candidate, *retry_p = pattern, *c, *p; @@ -1285,8 +1246,8 @@ end_of_pattern: } #ifdef __MINGW32__ -BT_HIDDEN -GString *bt_common_normalize_path(const char *path, const char *wd) +GString *bt_common_normalize_path(const char *path, + const char *wd __attribute__((unused))) { char *tmp; GString *norm_path = NULL; @@ -1347,7 +1308,6 @@ void destroy_gstring(void *gstring) (void) g_string_free(gstring, TRUE); } -BT_HIDDEN GString *bt_common_normalize_path(const char *path, const char *wd) { size_t i; @@ -1432,7 +1392,6 @@ end: } #endif -BT_HIDDEN size_t bt_common_get_page_size(int log_level) { int page_size; @@ -1707,7 +1666,6 @@ update_rw_fmt: *out_fmt_ch = fmt_ch; } -BT_HIDDEN void bt_common_custom_vsnprintf(char *buf, size_t buf_size, char intro, bt_common_handle_custom_specifier_func handle_specifier, @@ -1751,20 +1709,6 @@ void bt_common_custom_vsnprintf(char *buf, size_t buf_size, *buf_ch = '\0'; } -BT_HIDDEN -void bt_common_custom_snprintf(char *buf, size_t buf_size, - char intro, - bt_common_handle_custom_specifier_func handle_specifier, - void *priv_data, const char *fmt, ...) -{ - va_list args; - va_start(args, fmt); - bt_common_custom_vsnprintf(buf, buf_size, intro, handle_specifier, - priv_data, fmt, &args); - va_end(args); -} - -BT_HIDDEN void bt_common_sep_digits(char *str, unsigned int digits_per_group, char sep) { const char *rd; @@ -1867,7 +1811,6 @@ void bt_common_sep_digits(char *str, unsigned int digits_per_group, char sep) } } -BT_HIDDEN GString *bt_common_fold(const char *str, unsigned int total_length, unsigned int indent) { @@ -1986,14 +1929,13 @@ end: } #ifdef __MINGW32__ -BT_HIDDEN -int bt_common_get_term_size(unsigned int *width, unsigned int *height) +int bt_common_get_term_size(unsigned int *width __attribute__((unused)), + unsigned int *height __attribute__((unused))) { /* Not supported on Windows yet */ return -1; } #else /* __MINGW32__ */ -BT_HIDDEN int bt_common_get_term_size(unsigned int *width, unsigned int *height) { int ret = 0; @@ -2017,7 +1959,6 @@ end: } #endif /* __MINGW32__ */ -BT_HIDDEN int bt_common_g_string_append_printf(GString *str, const char *fmt, ...) { va_list ap; @@ -2041,7 +1982,7 @@ int bt_common_g_string_append_printf(GString *str, const char *fmt, ...) /* Resize. */ g_string_set_size(str, len + print_len); va_start(ap, fmt); - print_len = vsprintf(str->str + len, fmt, ap); + print_len = vsnprintf(str->str + len, print_len + 1, fmt, ap); va_end(ap); } else { str->len = len + print_len; @@ -2049,7 +1990,6 @@ int bt_common_g_string_append_printf(GString *str, const char *fmt, ...) return print_len; } -BT_HIDDEN int bt_common_append_file_content_to_g_string(GString *str, FILE *fp) { const size_t chunk_size = 4096; @@ -2090,7 +2030,6 @@ end: return ret; } -BT_HIDDEN void bt_common_abort(void) { static const char * const exec_on_abort_env_name = diff --git a/src/common/common.h b/src/common/common.h index 2c9ef382..fd9da4e7 100644 --- a/src/common/common.h +++ b/src/common/common.h @@ -113,14 +113,12 @@ struct bt_common_lttng_live_url_parts { * Checks if the current process has setuid or setgid access rights. * Returns `true` if so. */ -BT_HIDDEN bool bt_common_is_setuid_setgid(void); /* * Returns the system-wide plugin path, e.g. * `/usr/lib/babeltrace2/plugins`. Do not free the return value. */ -BT_HIDDEN const char *bt_common_get_system_plugin_path(void); /* @@ -128,7 +126,6 @@ const char *bt_common_get_system_plugin_path(void); * `/home/user/.local/lib/babeltrace2/plugins`. You need to free the * return value. */ -BT_HIDDEN char *bt_common_get_home_plugin_path(int log_level); /* @@ -136,92 +133,64 @@ char *bt_common_get_home_plugin_path(int log_level); * `paths` is a list of directories separated by `:`. Returns 0 on * success. */ -BT_HIDDEN int bt_common_append_plugin_path_dirs(const char *paths, GPtrArray *dirs); /* * Returns `true` if terminal color codes are supported for this * process. */ -BT_HIDDEN bool bt_common_colors_supported(void); -BT_HIDDEN const char *bt_common_color_reset(void); -BT_HIDDEN const char *bt_common_color_bold(void); -BT_HIDDEN const char *bt_common_color_fg_default(void); -BT_HIDDEN const char *bt_common_color_fg_red(void); -BT_HIDDEN const char *bt_common_color_fg_green(void); -BT_HIDDEN const char *bt_common_color_fg_yellow(void); -BT_HIDDEN const char *bt_common_color_fg_blue(void); -BT_HIDDEN const char *bt_common_color_fg_magenta(void); -BT_HIDDEN const char *bt_common_color_fg_cyan(void); -BT_HIDDEN const char *bt_common_color_fg_light_gray(void); -BT_HIDDEN const char *bt_common_color_fg_bright_red(void); -BT_HIDDEN const char *bt_common_color_fg_bright_green(void); -BT_HIDDEN const char *bt_common_color_fg_bright_yellow(void); -BT_HIDDEN const char *bt_common_color_fg_bright_blue(void); -BT_HIDDEN const char *bt_common_color_fg_bright_magenta(void); -BT_HIDDEN const char *bt_common_color_fg_bright_cyan(void); -BT_HIDDEN const char *bt_common_color_fg_bright_light_gray(void); -BT_HIDDEN const char *bt_common_color_bg_default(void); -BT_HIDDEN const char *bt_common_color_bg_red(void); -BT_HIDDEN const char *bt_common_color_bg_green(void); -BT_HIDDEN const char *bt_common_color_bg_yellow(void); -BT_HIDDEN const char *bt_common_color_bg_blue(void); -BT_HIDDEN const char *bt_common_color_bg_magenta(void); -BT_HIDDEN const char *bt_common_color_bg_cyan(void); -BT_HIDDEN const char *bt_common_color_bg_light_gray(void); -BT_HIDDEN void bt_common_color_get_codes(struct bt_common_color_codes *codes, enum bt_common_color_when use_colors); @@ -231,7 +200,6 @@ void bt_common_color_get_codes(struct bt_common_color_codes *codes, * found in `escapable_chars`, and sets `*end_pos` to the position of * the end (from `input`). The caller owns the returned GString. */ -BT_HIDDEN GString *bt_common_string_until(const char *input, const char *escapable_chars, const char *end_chars, size_t *end_pos); @@ -242,21 +210,18 @@ GString *bt_common_string_until(const char *input, const char *escapable_chars, * prepend and append them manually, although they are not always * required. The caller owns the returned GString. */ -BT_HIDDEN GString *bt_common_shell_quote(const char *input, bool with_single_quotes); /* * Returns `true` if `input` is a string made only of printable * characters. */ -BT_HIDDEN bool bt_common_string_is_printable(const char *input); /* * Destroys the parts of an LTTng live URL as returned by * bt_common_parse_lttng_live_url(). */ -BT_HIDDEN void bt_common_destroy_lttng_live_url_parts( struct bt_common_lttng_live_url_parts *parts); @@ -266,7 +231,6 @@ void bt_common_destroy_lttng_live_url_parts( * up to `error_buf_size` bytes. You must destroy the returned value * with bt_common_destroy_lttng_live_url_parts(). */ -BT_HIDDEN struct bt_common_lttng_live_url_parts bt_common_parse_lttng_live_url( const char *url, char *error_buf, size_t error_buf_size); @@ -274,14 +238,12 @@ struct bt_common_lttng_live_url_parts bt_common_parse_lttng_live_url( * Normalizes (in place) a star globbing pattern to be used with * bt_common_star_glob_match(). This function always succeeds. */ -BT_HIDDEN void bt_common_normalize_star_glob_pattern(char *pattern); /* * Returns `true` if `candidate` (of size `candidate_len`) matches * the star globbing pattern `pattern` (of size `pattern_len`). */ -BT_HIDDEN bool bt_common_star_glob_match(const char *pattern, size_t pattern_len, const char *candidate, size_t candidate_len); @@ -297,7 +259,6 @@ bool bt_common_star_glob_match(const char *pattern, size_t pattern_len, * * The caller owns the returned GString. */ -BT_HIDDEN GString *bt_common_normalize_path(const char *path, const char *wd); typedef void (* bt_common_handle_custom_specifier_func)(void *priv_data, @@ -352,31 +313,20 @@ typedef void (* bt_common_handle_custom_specifier_func)(void *priv_data, * do not return error codes: they abort when there's any error (bad * format string, for example). */ -BT_HIDDEN void bt_common_custom_vsnprintf(char *buf, size_t buf_size, char intro, bt_common_handle_custom_specifier_func handle_specifier, void *priv_data, const char *fmt, va_list *args); -/* - * Variadic form of bt_common_custom_vsnprintf(). - */ -BT_HIDDEN -void bt_common_custom_snprintf(char *buf, size_t buf_size, - char intro, - bt_common_handle_custom_specifier_func handle_specifier, - void *priv_data, const char *fmt, ...); - /* * Returns the system page size. */ -BT_HIDDEN size_t bt_common_get_page_size(int log_level); /* * Adds the digit separator `sep` as many times as needed to form groups * of `digits_per_group` digits within `str`. `str` must have enough - * room to accomodate the new separators, that is: + * room to accommodate the new separators, that is: * * strlen(str) + (strlen(str) / digits_per_group) + 1 * @@ -386,7 +336,6 @@ size_t bt_common_get_page_size(int log_level); * `strlen(str)` must not be 0. `digits_per_group` must not be 0. `sep` * must not be `\0`. */ -BT_HIDDEN void bt_common_sep_digits(char *str, unsigned int digits_per_group, char sep); /* @@ -402,7 +351,6 @@ void bt_common_sep_digits(char *str, unsigned int digits_per_group, char sep); * * The returned string, on success, is owned by the caller. */ -BT_HIDDEN GString *bt_common_fold(const char *str, unsigned int total_length, unsigned int indent); @@ -410,7 +358,6 @@ GString *bt_common_fold(const char *str, unsigned int total_length, * Writes the terminal's width to `*width`, its height to `*height`, * and returns 0 on success, or returns -1 on error. */ -BT_HIDDEN int bt_common_get_term_size(unsigned int *width, unsigned int *height); /* @@ -419,64 +366,10 @@ int bt_common_get_term_size(unsigned int *width, unsigned int *height); * * This function does NOT rewind `fp` once it's done or on error. */ -BT_HIDDEN int bt_common_append_file_content_to_g_string(GString *str, FILE *fp); -BT_HIDDEN void bt_common_abort(void) __attribute__((noreturn)); -/* - * Wraps read() function to handle EINTR and partial reads. - * On success, it returns `count` received as parameter. On error, it returns a - * value smaller than the requested `count`. - */ -static inline -ssize_t bt_common_read(int fd, void *buf, size_t count, int log_level) -{ - size_t i = 0; - ssize_t ret; - - BT_ASSERT_DBG(buf); - - /* Never return an overflow value. */ - BT_ASSERT_DBG(count <= SSIZE_MAX); - - do { - ret = read(fd, ((char *) buf) + i, count - i); - if (ret < 0) { - if (errno == EINTR) { -#ifdef BT_LOG_WRITE_CUR_LVL - BT_LOG_WRITE_CUR_LVL(BT_LOG_DEBUG, log_level, - BT_LOG_TAG, - "read() call interrupted; retrying..."); -#endif - /* retry operation */ - continue; - } else { -#ifdef BT_LOG_WRITE_ERRNO_CUR_LVL - BT_LOG_WRITE_ERRNO_CUR_LVL(BT_LOG_ERROR, - log_level, BT_LOG_TAG, - "Error while reading", ": fd=%d", fd); -#endif - goto end; - } - } - i += ret; - BT_ASSERT_DBG(i <= count); - } while (count - i > 0 && ret > 0); - -end: - if (ret >= 0) { - if (i == 0) { - ret = -1; - } else { - ret = i; - } - } - - return ret; -} - static inline const char *bt_common_field_class_type_string(enum bt_field_class_type class_type) { @@ -651,44 +544,6 @@ const char *bt_common_value_type_string(enum bt_value_type type) bt_common_abort(); }; -static inline -GString *bt_common_field_path_string(struct bt_field_path *path) -{ - GString *str = g_string_new(NULL); - uint64_t i; - - BT_ASSERT_DBG(path); - - if (!str) { - goto end; - } - - g_string_append_printf(str, "[%s", bt_common_scope_string( - bt_field_path_get_root_scope(path))); - - for (i = 0; i < bt_field_path_get_item_count(path); i++) { - const struct bt_field_path_item *fp_item = - bt_field_path_borrow_item_by_index_const(path, i); - - switch (bt_field_path_item_get_type(fp_item)) { - case BT_FIELD_PATH_ITEM_TYPE_INDEX: - g_string_append_printf(str, ", %" PRIu64, - bt_field_path_item_index_get_index(fp_item)); - break; - case BT_FIELD_PATH_ITEM_TYPE_CURRENT_ARRAY_ELEMENT: - g_string_append(str, ", "); - break; - default: - bt_common_abort(); - } - } - - g_string_append(str, "]"); - -end: - return str; -} - static inline const char *bt_common_logging_level_string( enum bt_logging_level level) @@ -839,7 +694,7 @@ end: * bt_g_string_append_printf cannot be inlined because it expects a * variadic argument list. */ -BT_HIDDEN __BT_ATTR_FORMAT_PRINTF(2, 3) +__BT_ATTR_FORMAT_PRINTF(2, 3) int bt_common_g_string_append_printf(GString *str, const char *fmt, ...); static inline diff --git a/src/common/list.h b/src/common/list.h index 193bf2d7..fd1f471c 100644 --- a/src/common/list.h +++ b/src/common/list.h @@ -1,7 +1,7 @@ /* + * SPDX-FileCopyrightText: 2002 Free Software Foundation, Inc. * SPDX-License-Identifier: LGPL-2.1-only * - * Copyright (C) 2002 Free Software Foundation, Inc. * This file is part of the GNU C Library. * Contributed by Ulrich Drepper , 2002. */ diff --git a/src/common/macros.h b/src/common/macros.h index 34ac393f..8120515c 100644 --- a/src/common/macros.h +++ b/src/common/macros.h @@ -21,14 +21,28 @@ extern "C" { ((type) (a) > (type) (b) ? (type) (a) : (type) (b)) /* - * BT_HIDDEN: set the hidden attribute for internal functions - * On Windows, symbols are local unless explicitly exported, - * see https://gcc.gnu.org/wiki/Visibility + * BT_EXPORT: set the visibility for exported functions. */ #if defined(_WIN32) || defined(__CYGWIN__) -#define BT_HIDDEN +#define BT_EXPORT #else -#define BT_HIDDEN __attribute__((visibility("hidden"))) +#define BT_EXPORT __attribute__((visibility("default"))) +#endif + +/* + * BT_NOEXCEPT: defined to `noexcept` if compiling as C++, else empty. + */ +#if defined(__cplusplus) +#define BT_NOEXCEPT noexcept +#else +#define BT_NOEXCEPT +#endif + +/* Enable `txt` if developer mode is enabled. */ +#ifdef BT_DEV_MODE +#define BT_IF_DEV_MODE(txt) txt +#else +#define BT_IF_DEV_MODE(txt) #endif /* @@ -54,6 +68,10 @@ extern "C" { _ref; \ }) +/* Wrapper for g_array_index that adds bound checking. */ +#define bt_g_array_index(a, t, i) \ + g_array_index((a), t, ({ BT_ASSERT_DBG((i) < (a)->len); (i); })) + /* * Copied from: * : @@ -81,6 +99,22 @@ extern "C" { ((void) sizeof((void) (_expr1), (void) (_expr2), \ (void) (_expr3), (void) (_expr4), (void) (_expr5), 0)) +#define BT_DIAG_PUSH _Pragma ("GCC diagnostic push") +#define BT_DIAG_POP _Pragma ("GCC diagnostic push") + +#define BT_DIAG_IGNORE_SHADOW _Pragma("GCC diagnostic ignored \"-Wshadow\"") + +#if defined __clang__ +# if __has_warning("-Wunused-but-set-variable") +# define BT_DIAG_IGNORE_UNUSED_BUT_SET_VARIABLE \ + _Pragma("GCC diagnostic ignored \"-Wunused-but-set-variable\"") +# endif +#endif + +#if !defined BT_DIAG_IGNORE_UNUSED_BUT_SET_VARIABLE +# define BT_DIAG_IGNORE_UNUSED_BUT_SET_VARIABLE +#endif + #ifdef __cplusplus } #endif diff --git a/src/common/mmap-align.h b/src/common/mmap-align.h index 7c164935..4d81b257 100644 --- a/src/common/mmap-align.h +++ b/src/common/mmap-align.h @@ -58,7 +58,7 @@ struct mmap_align_data *mmap_align(size_t length, int prot, * boundary. */ mma->page_aligned_length = BT_ALIGN(length + offset - page_aligned_offset, page_size); - mma->page_aligned_addr = bt_mmap(NULL, mma->page_aligned_length, + mma->page_aligned_addr = bt_mmap(mma->page_aligned_length, prot, flags, fd, page_aligned_offset, log_level); if (mma->page_aligned_addr == MAP_FAILED) { free(mma); diff --git a/src/common/prio-heap.c b/src/common/prio-heap.c new file mode 100644 index 00000000..55ed5e81 --- /dev/null +++ b/src/common/prio-heap.c @@ -0,0 +1,220 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright 2011 Mathieu Desnoyers + * + * Static-sized priority heap containing pointers. Based on CLRS, + * chapter 6. + */ + +#include "common/macros.h" +#include "common/assert.h" +#include +#include +#include + +#include "common/prio-heap.h" + +#ifdef DEBUG_HEAP +void check_heap(const struct ptr_heap *heap) +{ + size_t i; + + if (!heap->len) + return; + + for (i = 1; i < heap->len; i++) + BT_ASSERT_DBG(!heap->gt(heap->ptrs[i], heap->ptrs[0])); +} +#endif + +static +size_t parent(size_t i) +{ + return (i - 1) >> 1; +} + +static +size_t left(size_t i) +{ + return (i << 1) + 1; +} + +static +size_t right(size_t i) +{ + return (i << 1) + 2; +} + +/* + * Copy of heap->ptrs pointer is invalid after heap_grow. + */ +static +int heap_grow(struct ptr_heap *heap, size_t new_len) +{ + void **new_ptrs; + + if (G_LIKELY(heap->alloc_len >= new_len)) + return 0; + + heap->alloc_len = bt_max_t(size_t, new_len, heap->alloc_len << 1); + new_ptrs = calloc(heap->alloc_len, sizeof(void *)); + if (G_UNLIKELY(!new_ptrs)) + return -ENOMEM; + if (G_LIKELY(heap->ptrs)) + memcpy(new_ptrs, heap->ptrs, heap->len * sizeof(void *)); + free(heap->ptrs); + heap->ptrs = new_ptrs; + return 0; +} + +static +int heap_set_len(struct ptr_heap *heap, size_t new_len) +{ + int ret; + + ret = heap_grow(heap, new_len); + if (G_UNLIKELY(ret)) + return ret; + heap->len = new_len; + return 0; +} + +int bt_heap_init(struct ptr_heap *heap, size_t alloc_len, + int gt(void *a, void *b)) +{ + heap->ptrs = NULL; + heap->len = 0; + heap->alloc_len = 0; + heap->gt = gt; + /* + * Minimum size allocated is 1 entry to ensure memory allocation + * never fails within bt_heap_replace_max. + */ + return heap_grow(heap, bt_max_t(size_t, 1, alloc_len)); +} + +void bt_heap_free(struct ptr_heap *heap) +{ + free(heap->ptrs); +} + +static void heapify(struct ptr_heap *heap, size_t i) +{ + void **ptrs = heap->ptrs; + size_t l, r, largest; + + for (;;) { + void *tmp; + + l = left(i); + r = right(i); + if (l < heap->len && heap->gt(ptrs[l], ptrs[i])) + largest = l; + else + largest = i; + if (r < heap->len && heap->gt(ptrs[r], ptrs[largest])) + largest = r; + if (G_UNLIKELY(largest == i)) + break; + tmp = ptrs[i]; + ptrs[i] = ptrs[largest]; + ptrs[largest] = tmp; + i = largest; + } + check_heap(heap); +} + +void *bt_heap_replace_max(struct ptr_heap *heap, void *p) +{ + void *res; + + if (G_UNLIKELY(!heap->len)) { + (void) heap_set_len(heap, 1); + heap->ptrs[0] = p; + check_heap(heap); + return NULL; + } + + /* Replace the current max and heapify */ + res = heap->ptrs[0]; + heap->ptrs[0] = p; + heapify(heap, 0); + return res; +} + +int bt_heap_insert(struct ptr_heap *heap, void *p) +{ + void **ptrs; + size_t pos; + int ret; + + ret = heap_set_len(heap, heap->len + 1); + if (G_UNLIKELY(ret)) + return ret; + ptrs = heap->ptrs; + pos = heap->len - 1; + while (pos > 0 && heap->gt(p, ptrs[parent(pos)])) { + /* Move parent down until we find the right spot */ + ptrs[pos] = ptrs[parent(pos)]; + pos = parent(pos); + } + ptrs[pos] = p; + check_heap(heap); + return 0; +} + +void *bt_heap_remove(struct ptr_heap *heap) +{ + switch (heap->len) { + case 0: + return NULL; + case 1: + (void) heap_set_len(heap, 0); + return heap->ptrs[0]; + } + /* Shrink, replace the current max by previous last entry and heapify */ + heap_set_len(heap, heap->len - 1); + /* len changed. previous last entry is at heap->len */ + return bt_heap_replace_max(heap, heap->ptrs[heap->len]); +} + +void *bt_heap_cherrypick(struct ptr_heap *heap, void *p) +{ + size_t pos, len = heap->len; + + for (pos = 0; pos < len; pos++) + if (G_UNLIKELY(heap->ptrs[pos] == p)) + goto found; + return NULL; +found: + if (G_UNLIKELY(heap->len == 1)) { + (void) heap_set_len(heap, 0); + check_heap(heap); + return heap->ptrs[0]; + } + /* Replace p with previous last entry and heapify. */ + heap_set_len(heap, heap->len - 1); + /* len changed. previous last entry is at heap->len */ + heap->ptrs[pos] = heap->ptrs[heap->len]; + heapify(heap, pos); + return p; +} + +int bt_heap_copy(struct ptr_heap *dst, struct ptr_heap *src) +{ + int ret; + + ret = bt_heap_init(dst, src->alloc_len, src->gt); + if (ret < 0) + goto end; + + ret = heap_set_len(dst, src->len); + if (ret < 0) + goto end; + + memcpy(dst->ptrs, src->ptrs, src->len * sizeof(void *)); + +end: + return ret; +} diff --git a/src/common/prio-heap.h b/src/common/prio-heap.h new file mode 100644 index 00000000..7e56521b --- /dev/null +++ b/src/common/prio-heap.h @@ -0,0 +1,116 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright 2011 Mathieu Desnoyers + * + * Static-sized priority heap containing pointers. Based on CLRS, + * chapter 6. + */ + +#ifndef BABELTRACE_COMMON_PRIO_HEAP_H +#define BABELTRACE_COMMON_PRIO_HEAP_H + +#include +#include "common/macros.h" + +struct ptr_heap { + size_t len, alloc_len; + void **ptrs; + int (*gt)(void *a, void *b); +}; + +#ifdef DEBUG_HEAP +void check_heap(const struct ptr_heap *heap); +#else +static inline +void check_heap(const struct ptr_heap *heap __attribute__((unused))) +{ +} +#endif + +/** + * bt_heap_maximum - return the largest element in the heap + * @heap: the heap to be operated on + * + * Returns the largest element in the heap, without performing any modification + * to the heap structure. Returns NULL if the heap is empty. + */ +static inline void *bt_heap_maximum(const struct ptr_heap *heap) +{ + check_heap(heap); + return G_LIKELY(heap->len) ? heap->ptrs[0] : NULL; +} + +/** + * bt_heap_init - initialize the heap + * @heap: the heap to initialize + * @alloc_len: number of elements initially allocated + * @gt: function to compare the elements + * + * Returns -ENOMEM if out of memory. + */ +extern int bt_heap_init(struct ptr_heap *heap, + size_t alloc_len, + int gt(void *a, void *b)); + +/** + * bt_heap_free - free the heap + * @heap: the heap to free + */ +extern void bt_heap_free(struct ptr_heap *heap); + +/** + * bt_heap_insert - insert an element into the heap + * @heap: the heap to be operated on + * @p: the element to add + * + * Insert an element into the heap. + * + * Returns -ENOMEM if out of memory. + */ +extern int bt_heap_insert(struct ptr_heap *heap, void *p); + +/** + * bt_heap_remove - remove the largest element from the heap + * @heap: the heap to be operated on + * + * Returns the largest element in the heap. It removes this element from the + * heap. Returns NULL if the heap is empty. + */ +extern void *bt_heap_remove(struct ptr_heap *heap); + +/** + * bt_heap_cherrypick - remove a given element from the heap + * @heap: the heap to be operated on + * @p: the element + * + * Remove the given element from the heap. Return the element if present, else + * return NULL. This algorithm has a complexity of O(n), which is higher than + * O(log(n)) provided by the rest of this API. + */ +extern void *bt_heap_cherrypick(struct ptr_heap *heap, void *p); + +/** + * bt_heap_replace_max - replace the the largest element from the heap + * @heap: the heap to be operated on + * @p: the pointer to be inserted as topmost element replacement + * + * Returns the largest element in the heap. It removes this element from the + * heap. The heap is rebalanced only once after the insertion. Returns NULL if + * the heap is empty. + * + * This is the equivalent of calling bt_heap_remove() and then bt_heap_insert(), but + * it only rebalances the heap once. It never allocates memory. + */ +extern void *bt_heap_replace_max(struct ptr_heap *heap, void *p); + +/** + * bt_heap_copy - copy a heap + * @dst: the destination heap (must be allocated) + * @src: the source heap + * + * Returns -ENOMEM if out of memory. + */ +extern int bt_heap_copy(struct ptr_heap *dst, struct ptr_heap *src); + +#endif /* BABELTRACE_COMMON_PRIO_HEAP_H */ diff --git a/src/common/uuid.c b/src/common/uuid.c index a0af2bc0..5c709f73 100644 --- a/src/common/uuid.c +++ b/src/common/uuid.c @@ -16,7 +16,6 @@ /* * Generate a random UUID according to RFC4122, section 4.4. */ -BT_HIDDEN void bt_uuid_generate(bt_uuid_t uuid_out) { int i; @@ -51,16 +50,14 @@ void bt_uuid_generate(bt_uuid_t uuid_out) g_rand_free(rand); } -BT_HIDDEN void bt_uuid_to_str(const bt_uuid_t uuid_in, char *str_out) { BT_ASSERT_DBG(uuid_in); BT_ASSERT_DBG(str_out); - sprintf(str_out, BT_UUID_FMT, BT_UUID_FMT_VALUES(uuid_in)); + snprintf(str_out, BT_UUID_STR_LEN + 1, BT_UUID_FMT, BT_UUID_FMT_VALUES(uuid_in)); } -BT_HIDDEN int bt_uuid_from_str(const char *str_in, bt_uuid_t uuid_out) { int ret = 0; @@ -84,13 +81,11 @@ end: return ret; } -BT_HIDDEN int bt_uuid_compare(const bt_uuid_t uuid_a, const bt_uuid_t uuid_b) { return memcmp(uuid_a, uuid_b, BT_UUID_LEN); } -BT_HIDDEN void bt_uuid_copy(bt_uuid_t uuid_dest, const bt_uuid_t uuid_src) { BT_ASSERT(uuid_dest); diff --git a/src/common/uuid.h b/src/common/uuid.h index 73ae1d8a..c8418a67 100644 --- a/src/common/uuid.h +++ b/src/common/uuid.h @@ -7,6 +7,7 @@ #ifndef _BABELTRACE_COMMON_UUID_H #define _BABELTRACE_COMMON_UUID_H +#include #include #include "common/macros.h" @@ -36,11 +37,11 @@ extern "C" { typedef uint8_t bt_uuid_t[BT_UUID_LEN]; -BT_HIDDEN void bt_uuid_generate(bt_uuid_t uuid_out); -BT_HIDDEN void bt_uuid_to_str(const bt_uuid_t uuid_in, char *str_out); -BT_HIDDEN int bt_uuid_from_str(const char *str_in, bt_uuid_t uuid_out); -BT_HIDDEN int bt_uuid_compare(const bt_uuid_t uuid_a, const bt_uuid_t uuid_b); -BT_HIDDEN void bt_uuid_copy(bt_uuid_t uuid_dest, const bt_uuid_t uuid_src); +void bt_uuid_generate(bt_uuid_t uuid_out); +void bt_uuid_to_str(const bt_uuid_t uuid_in, char *str_out); +int bt_uuid_from_str(const char *str_in, bt_uuid_t uuid_out); +int bt_uuid_compare(const bt_uuid_t uuid_a, const bt_uuid_t uuid_b); +void bt_uuid_copy(bt_uuid_t uuid_dest, const bt_uuid_t uuid_src); #ifdef __cplusplus } diff --git a/src/compat/Makefile.am b/src/compat/Makefile.am deleted file mode 100644 index c857372a..00000000 --- a/src/compat/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -# SPDX-License-Identifier: MIT - -noinst_LTLIBRARIES = libcompat.la - -libcompat_la_SOURCES = \ - mman.c \ - mman.h - -libcompat_la_LDFLAGS = \ - $(AM_LDFLAGS) \ - $(LD_NO_AS_NEEDED) - -noinst_HEADERS = \ - bitfield.h \ - compiler.h \ - endian.h \ - fcntl.h \ - glib.h \ - limits.h \ - memstream.h \ - socket.h \ - stdio.h \ - stdlib.h \ - string.h \ - time.h \ - unistd.h \ - utc.h diff --git a/src/compat/memstream.h b/src/compat/memstream.h index dcadf048..374a5e72 100644 --- a/src/compat/memstream.h +++ b/src/compat/memstream.h @@ -174,7 +174,10 @@ FILE *bt_open_memstream(char **ptr, size_t *sizeloc) } static inline -int bt_close_memstream(char **buf, size_t *size, FILE *fp) +int bt_close_memstream( + char **buf __attribute__((unused)), + size_t *size __attribute__((unused)), + FILE *fp) { return fclose(fp); } @@ -194,7 +197,8 @@ int bt_close_memstream(char **buf, size_t *size, FILE *fp) * into the buffer (which we allocate). */ static inline -FILE *bt_open_memstream(char **ptr, size_t *sizeloc) +FILE *bt_open_memstream(char **ptr __attribute__((unused)), + size_t *sizeloc __attribute__((unused))) { char *tmpname; FILE *fp; @@ -233,7 +237,8 @@ error_free: * into the buffer (which we allocate). */ static inline -FILE *bt_open_memstream(char **ptr, size_t *sizeloc) +FILE *bt_open_memstream(char **ptr __attribute__((unused)), + size_t *sizeloc __attribute__((unused))) { char *tmpname; int ret; diff --git a/src/compat/mman.c b/src/compat/mman.c index 7cd7a6fd..251e8735 100644 --- a/src/compat/mman.c +++ b/src/compat/mman.c @@ -20,7 +20,6 @@ * On macOS, we need a dummy symbol so that the linker won't * complain of an empty table of contents. */ -BT_HIDDEN int bt_mman_dummy_symbol; #endif /* __APPLE__ */ @@ -153,9 +152,8 @@ DWORD map_prot_flags(int prot, DWORD *dwDesiredAccess) return 0; } -BT_HIDDEN -void *bt_mmap(void *addr, size_t length, int prot, int flags, int fd, - off_t offset, int log_level) +void *bt_mmap(size_t length, int prot, int flags, int fd, off_t offset, + int log_level) { struct mmap_mapping *mapping = NULL; void *mapping_addr; @@ -254,8 +252,7 @@ error: return MAP_FAILED; } -BT_HIDDEN -int bt_munmap(void *addr, size_t length) +int bt_munmap(void *addr, size_t length __attribute__((unused))) { int ret = 0; struct mmap_mapping *mapping = addr; @@ -283,13 +280,12 @@ end: return ret; } -BT_HIDDEN size_t bt_mmap_get_offset_align_size(int log_level) { SYSTEM_INFO sysinfo; GetNativeSystemInfo(&sysinfo); - BT_LOG_WRITE_CUR_LVL(BT_LOG_DEBUG, log_level, BT_LOG_TAG, + BT_LOG_WRITE_PRINTF_CUR_LVL(BT_LOG_DEBUG, log_level, BT_LOG_TAG, "Allocator granularity is %lu.", sysinfo.dwAllocationGranularity); diff --git a/src/compat/mman.h b/src/compat/mman.h index a9568c6b..33febccb 100644 --- a/src/compat/mman.h +++ b/src/compat/mman.h @@ -10,6 +10,7 @@ #ifdef __MINGW32__ #include +#include "common/macros.h" #define PROT_NONE 0x0 #define PROT_READ 0x1 @@ -29,7 +30,7 @@ * Note that some platforms (e.g. Windows) do not allow read-only * mappings to exceed the file's size (even within a page). */ -BT_EXTERN_C void *bt_mmap(void *addr, size_t length, int prot, int flags, int fd, +BT_EXTERN_C void *bt_mmap(size_t length, int prot, int flags, int fd, off_t offset, int log_level); BT_EXTERN_C int bt_munmap(void *addr, size_t length); @@ -46,10 +47,10 @@ BT_EXTERN_C size_t bt_mmap_get_offset_align_size(int log_level); #include "common/common.h" static inline -void *bt_mmap(void *addr, size_t length, int prot, int flags, int fd, - off_t offset, int log_level) +void *bt_mmap(size_t length, int prot, int flags, int fd, + off_t offset, int log_level __attribute__((unused))) { - return (void *) mmap(addr, length, prot, flags, fd, offset); + return (void *) mmap(NULL, length, prot, flags, fd, offset); } static inline diff --git a/src/compat/socket.h b/src/compat/socket.h deleted file mode 100644 index 7a57678b..00000000 --- a/src/compat/socket.h +++ /dev/null @@ -1,410 +0,0 @@ -/* - * SPDX-License-Identifier: MIT - * - * Copyright (C) 2015-2017 Michael Jeanson - * Copyright (C) 2015 Mathieu Desnoyers - */ - -#ifndef _BABELTRACE_COMPAT_SOCKET_H -#define _BABELTRACE_COMPAT_SOCKET_H - -#include - -#ifdef __MINGW32__ - -#include - -#define BT_INVALID_SOCKET INVALID_SOCKET -#define BT_SOCKET_ERROR SOCKET_ERROR -#define BT_SOCKET SOCKET - -static inline -int bt_socket_init(int log_level) -{ - WORD verreq; - WSADATA wsa; - int ret; - - /* Request winsock 2.2 support */ - verreq = MAKEWORD(2, 2); - - ret = WSAStartup(verreq, &wsa); - if (ret != 0) { -#ifdef BT_LOG_WRITE_CUR_LVL - BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG, - "Winsock init failed with error: %d", ret); -#endif - goto end; - } - - if (LOBYTE(wsa.wVersion) != 2 || HIBYTE(wsa.wVersion) != 2) { -#ifdef BT_LOG_WRITE_CUR_LVL - BT_LOG_WRITE_CUR_LVL(BT_LOG_ERROR, log_level, BT_LOG_TAG, - "Could not init winsock 2.2 support"); -#endif - WSACleanup(); - ret = -1; - } - -end: - return ret; -} - -static inline -int bt_socket_fini(void) -{ - return WSACleanup(); -} - -static inline -int bt_socket_send(int sockfd, const void *buf, size_t len, int flags) -{ - return send(sockfd, (const char *) buf, len, flags); -} - -static inline -int bt_socket_recv(int sockfd, void *buf, size_t len, int flags) -{ - return recv(sockfd, (char *) buf, len, flags); -} - -static inline -int bt_socket_close(int fd) -{ - return closesocket(fd); -} - -static inline -bool bt_socket_interrupted(void) -{ - /* There is no equivalent to EINTR in winsock 2.2 */ - return false; -} - -static inline -const char *bt_socket_errormsg(void) -{ - const char *errstr; - int error = WSAGetLastError(); - - switch (error) { - case WSAEINTR: - errstr = "Call interrupted"; - break; - case WSAEBADF: - errstr = "Bad file"; - break; - case WSAEACCES: - errstr = "Bad access"; - break; - case WSAEFAULT: - errstr = "Bad argument"; - break; - case WSAEINVAL: - errstr = "Invalid arguments"; - break; - case WSAEMFILE: - errstr = "Out of file descriptors"; - break; - case WSAEWOULDBLOCK: - errstr = "Call would block"; - break; - case WSAEINPROGRESS: - case WSAEALREADY: - errstr = "Blocking call in progress"; - break; - case WSAENOTSOCK: - errstr = "Descriptor is not a socket"; - break; - case WSAEDESTADDRREQ: - errstr = "Need destination address"; - break; - case WSAEMSGSIZE: - errstr = "Bad message size"; - break; - case WSAEPROTOTYPE: - errstr = "Bad protocol"; - break; - case WSAENOPROTOOPT: - errstr = "Protocol option is unsupported"; - break; - case WSAEPROTONOSUPPORT: - errstr = "Protocol is unsupported"; - break; - case WSAESOCKTNOSUPPORT: - errstr = "Socket is unsupported"; - break; - case WSAEOPNOTSUPP: - errstr = "Operation not supported"; - break; - case WSAEAFNOSUPPORT: - errstr = "Address family not supported"; - break; - case WSAEPFNOSUPPORT: - errstr = "Protocol family not supported"; - break; - case WSAEADDRINUSE: - errstr = "Address already in use"; - break; - case WSAEADDRNOTAVAIL: - errstr = "Address not available"; - break; - case WSAENETDOWN: - errstr = "Network down"; - break; - case WSAENETUNREACH: - errstr = "Network unreachable"; - break; - case WSAENETRESET: - errstr = "Network has been reset"; - break; - case WSAECONNABORTED: - errstr = "Connection was aborted"; - break; - case WSAECONNRESET: - errstr = "Connection was reset"; - break; - case WSAENOBUFS: - errstr = "No buffer space"; - break; - case WSAEISCONN: - errstr = "Socket is already connected"; - break; - case WSAENOTCONN: - errstr = "Socket is not connected"; - break; - case WSAESHUTDOWN: - errstr = "Socket has been shut down"; - break; - case WSAETOOMANYREFS: - errstr = "Too many references"; - break; - case WSAETIMEDOUT: - errstr = "Timed out"; - break; - case WSAECONNREFUSED: - errstr = "Connection refused"; - break; - case WSAELOOP: - errstr = "Loop??"; - break; - case WSAENAMETOOLONG: - errstr = "Name too long"; - break; - case WSAEHOSTDOWN: - errstr = "Host down"; - break; - case WSAEHOSTUNREACH: - errstr = "Host unreachable"; - break; - case WSAENOTEMPTY: - errstr = "Not empty"; - break; - case WSAEPROCLIM: - errstr = "Process limit reached"; - break; - case WSAEUSERS: - errstr = "Too many users"; - break; - case WSAEDQUOT: - errstr = "Bad quota"; - break; - case WSAESTALE: - errstr = "Something is stale"; - break; - case WSAEREMOTE: - errstr = "Remote error"; - break; - case WSAEDISCON: - errstr = "Disconnected"; - break; - - /* Extended Winsock errors */ - case WSASYSNOTREADY: - errstr = "Winsock library is not ready"; - break; - case WSANOTINITIALISED: - errstr = "Winsock library not initialised"; - break; - case WSAVERNOTSUPPORTED: - errstr = "Winsock version not supported"; - break; - - /* getXbyY() errors (already handled in herrmsg): - * Authoritative Answer: Host not found */ - case WSAHOST_NOT_FOUND: - errstr = "Host not found"; - break; - - /* Non-Authoritative: Host not found, or SERVERFAIL */ - case WSATRY_AGAIN: - errstr = "Host not found, try again"; - break; - - /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ - case WSANO_RECOVERY: - errstr = "Unrecoverable error in call to nameserver"; - break; - - /* Valid name, no data record of requested type */ - case WSANO_DATA: - errstr = "No data record of requested type"; - break; - - default: - errstr = "Unknown error"; - } - - return errstr; -} - -#else /* __MINGW32__ */ - -#include -#include -#include -#include -#include - -#include - -#define BT_INVALID_SOCKET -1 -#define BT_SOCKET_ERROR -1 -#define BT_SOCKET int - -static inline -int bt_socket_init(int log_level) -{ - return 0; -} - -static inline -int bt_socket_fini(void) -{ - return 0; -} - -static inline -int bt_socket_send(int sockfd, const void *buf, size_t len, int flags) -{ - return send(sockfd, buf, len, flags); -} - -static inline -int bt_socket_recv(int sockfd, void *buf, size_t len, int flags) -{ - return recv(sockfd, buf, len, flags); -} - -static inline -int bt_socket_close(int fd) -{ - return close(fd); -} - -static inline -bool bt_socket_interrupted(void) -{ - return (errno == EINTR); -} - -static inline -const char *bt_socket_errormsg(void) -{ - return g_strerror(errno); -} -#endif - - -/* - * This wrapper is used on platforms that have no way of ignoring SIGPIPE - * during a send(). - */ - -#ifndef MSG_NOSIGNAL -# ifdef SO_NOSIGPIPE -# define MSG_NOSIGNAL SO_NOSIGPIPE -# elif defined(__MINGW32__) -# define MSG_NOSIGNAL 0 -# endif -#endif - -#if defined(MSG_NOSIGNAL) -static inline -ssize_t bt_socket_send_nosigpipe(int fd, const void *buffer, size_t size) -{ - return bt_socket_send(fd, buffer, size, MSG_NOSIGNAL); -} -#else - -#include - -static inline -ssize_t bt_socket_send_nosigpipe(int fd, const void *buffer, size_t size) -{ - ssize_t sent; - int saved_err; - sigset_t sigpipe_set, pending_set, old_set; - int sigpipe_was_pending; - - /* - * Discard the SIGPIPE from send(), not disturbing any SIGPIPE - * that might be already pending. If a bogus SIGPIPE is sent to - * the entire process concurrently by a malicious user, it may - * be simply discarded. - */ - if (sigemptyset(&pending_set)) { - return -1; - } - /* - * sigpending returns the mask of signals that are _both_ - * blocked for the thread _and_ pending for either the thread or - * the entire process. - */ - if (sigpending(&pending_set)) { - return -1; - } - sigpipe_was_pending = sigismember(&pending_set, SIGPIPE); - /* - * If sigpipe was pending, it means it was already blocked, so - * no need to block it. - */ - if (!sigpipe_was_pending) { - if (sigemptyset(&sigpipe_set)) { - return -1; - } - if (sigaddset(&sigpipe_set, SIGPIPE)) { - return -1; - } - if (pthread_sigmask(SIG_BLOCK, &sigpipe_set, &old_set)) { - return -1; - } - } - - /* Send and save errno. */ - sent = bt_socket_send(fd, buffer, size, 0); - saved_err = errno; - - if (sent == -1 && errno == EPIPE && !sigpipe_was_pending) { - struct timespec timeout = { 0, 0 }; - int ret; - - do { - ret = sigtimedwait(&sigpipe_set, NULL, - &timeout); - } while (ret == -1 && errno == EINTR); - } - if (!sigpipe_was_pending) { - if (pthread_sigmask(SIG_SETMASK, &old_set, NULL)) { - return -1; - } - } - /* Restore send() errno */ - errno = saved_err; - - return sent; -} -#endif - - -#endif /* _BABELTRACE_COMPAT_SOCKET_H */ diff --git a/src/compat/socket.hpp b/src/compat/socket.hpp new file mode 100644 index 00000000..972f6929 --- /dev/null +++ b/src/compat/socket.hpp @@ -0,0 +1,386 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright (C) 2015-2017 Michael Jeanson + * Copyright (C) 2015 Mathieu Desnoyers + */ + +#ifndef BABELTRACE_COMPAT_SOCKET_HPP +#define BABELTRACE_COMPAT_SOCKET_HPP + +#include + +#include "cpp-common/bt2c/logging.hpp" + +#ifdef __MINGW32__ + +# include + +# define BT_INVALID_SOCKET INVALID_SOCKET +# define BT_SOCKET_ERROR SOCKET_ERROR +# define BT_SOCKET SOCKET + +static inline int bt_socket_init(const bt2c::Logger& logger) +{ + WORD verreq; + WSADATA wsa; + int ret; + + /* Request winsock 2.2 support */ + verreq = MAKEWORD(2, 2); + + ret = WSAStartup(verreq, &wsa); + if (ret != 0) { + BT_CPPLOGE_SPEC(logger, "Winsock init failed with error: {}", ret); + goto end; + } + + if (LOBYTE(wsa.wVersion) != 2 || HIBYTE(wsa.wVersion) != 2) { + BT_CPPLOGE_SPEC(logger, "Could not init winsock 2.2 support"); + WSACleanup(); + ret = -1; + } + +end: + return ret; +} + +static inline int bt_socket_fini(void) +{ + return WSACleanup(); +} + +static inline int bt_socket_send(int sockfd, const void *buf, size_t len, int flags) +{ + return send(sockfd, (const char *) buf, len, flags); +} + +static inline int bt_socket_recv(int sockfd, void *buf, size_t len, int flags) +{ + return recv(sockfd, (char *) buf, len, flags); +} + +static inline int bt_socket_close(int fd) +{ + return closesocket(fd); +} + +static inline bool bt_socket_interrupted(void) +{ + /* There is no equivalent to EINTR in winsock 2.2 */ + return false; +} + +static inline const char *bt_socket_errormsg(void) +{ + const char *errstr; + int error = WSAGetLastError(); + + switch (error) { + case WSAEINTR: + errstr = "Call interrupted"; + break; + case WSAEBADF: + errstr = "Bad file"; + break; + case WSAEACCES: + errstr = "Bad access"; + break; + case WSAEFAULT: + errstr = "Bad argument"; + break; + case WSAEINVAL: + errstr = "Invalid arguments"; + break; + case WSAEMFILE: + errstr = "Out of file descriptors"; + break; + case WSAEWOULDBLOCK: + errstr = "Call would block"; + break; + case WSAEINPROGRESS: + case WSAEALREADY: + errstr = "Blocking call in progress"; + break; + case WSAENOTSOCK: + errstr = "Descriptor is not a socket"; + break; + case WSAEDESTADDRREQ: + errstr = "Need destination address"; + break; + case WSAEMSGSIZE: + errstr = "Bad message size"; + break; + case WSAEPROTOTYPE: + errstr = "Bad protocol"; + break; + case WSAENOPROTOOPT: + errstr = "Protocol option is unsupported"; + break; + case WSAEPROTONOSUPPORT: + errstr = "Protocol is unsupported"; + break; + case WSAESOCKTNOSUPPORT: + errstr = "Socket is unsupported"; + break; + case WSAEOPNOTSUPP: + errstr = "Operation not supported"; + break; + case WSAEAFNOSUPPORT: + errstr = "Address family not supported"; + break; + case WSAEPFNOSUPPORT: + errstr = "Protocol family not supported"; + break; + case WSAEADDRINUSE: + errstr = "Address already in use"; + break; + case WSAEADDRNOTAVAIL: + errstr = "Address not available"; + break; + case WSAENETDOWN: + errstr = "Network down"; + break; + case WSAENETUNREACH: + errstr = "Network unreachable"; + break; + case WSAENETRESET: + errstr = "Network has been reset"; + break; + case WSAECONNABORTED: + errstr = "Connection was aborted"; + break; + case WSAECONNRESET: + errstr = "Connection was reset"; + break; + case WSAENOBUFS: + errstr = "No buffer space"; + break; + case WSAEISCONN: + errstr = "Socket is already connected"; + break; + case WSAENOTCONN: + errstr = "Socket is not connected"; + break; + case WSAESHUTDOWN: + errstr = "Socket has been shut down"; + break; + case WSAETOOMANYREFS: + errstr = "Too many references"; + break; + case WSAETIMEDOUT: + errstr = "Timed out"; + break; + case WSAECONNREFUSED: + errstr = "Connection refused"; + break; + case WSAELOOP: + errstr = "Loop??"; + break; + case WSAENAMETOOLONG: + errstr = "Name too long"; + break; + case WSAEHOSTDOWN: + errstr = "Host down"; + break; + case WSAEHOSTUNREACH: + errstr = "Host unreachable"; + break; + case WSAENOTEMPTY: + errstr = "Not empty"; + break; + case WSAEPROCLIM: + errstr = "Process limit reached"; + break; + case WSAEUSERS: + errstr = "Too many users"; + break; + case WSAEDQUOT: + errstr = "Bad quota"; + break; + case WSAESTALE: + errstr = "Something is stale"; + break; + case WSAEREMOTE: + errstr = "Remote error"; + break; + case WSAEDISCON: + errstr = "Disconnected"; + break; + + /* Extended Winsock errors */ + case WSASYSNOTREADY: + errstr = "Winsock library is not ready"; + break; + case WSANOTINITIALISED: + errstr = "Winsock library not initialised"; + break; + case WSAVERNOTSUPPORTED: + errstr = "Winsock version not supported"; + break; + + /* getXbyY() errors (already handled in herrmsg): + * Authoritative Answer: Host not found */ + case WSAHOST_NOT_FOUND: + errstr = "Host not found"; + break; + + /* Non-Authoritative: Host not found, or SERVERFAIL */ + case WSATRY_AGAIN: + errstr = "Host not found, try again"; + break; + + /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */ + case WSANO_RECOVERY: + errstr = "Unrecoverable error in call to nameserver"; + break; + + /* Valid name, no data record of requested type */ + case WSANO_DATA: + errstr = "No data record of requested type"; + break; + + default: + errstr = "Unknown error"; + } + + return errstr; +} + +#else /* __MINGW32__ */ + +# include +# include +# include +# include +# include +# include + +# define BT_INVALID_SOCKET -1 +# define BT_SOCKET_ERROR -1 +# define BT_SOCKET int + +static inline int bt_socket_init(const bt2c::Logger&) +{ + return 0; +} + +static inline int bt_socket_fini(void) +{ + return 0; +} + +static inline int bt_socket_send(int sockfd, const void *buf, size_t len, int flags) +{ + return send(sockfd, buf, len, flags); +} + +static inline int bt_socket_recv(int sockfd, void *buf, size_t len, int flags) +{ + return recv(sockfd, buf, len, flags); +} + +static inline int bt_socket_close(int fd) +{ + return close(fd); +} + +static inline bool bt_socket_interrupted(void) +{ + return (errno == EINTR); +} + +static inline const char *bt_socket_errormsg(void) +{ + return g_strerror(errno); +} +#endif + +/* + * This wrapper is used on platforms that have no way of ignoring SIGPIPE + * during a send(). + */ + +#ifndef MSG_NOSIGNAL +# ifdef SO_NOSIGPIPE +# define MSG_NOSIGNAL SO_NOSIGPIPE +# elif defined(__MINGW32__) +# define MSG_NOSIGNAL 0 +# endif +#endif + +#if defined(MSG_NOSIGNAL) +static inline ssize_t bt_socket_send_nosigpipe(int fd, const void *buffer, size_t size) +{ + return bt_socket_send(fd, buffer, size, MSG_NOSIGNAL); +} +#else + +# include + +static inline ssize_t bt_socket_send_nosigpipe(int fd, const void *buffer, size_t size) +{ + ssize_t sent; + int saved_err; + sigset_t sigpipe_set, pending_set, old_set; + int sigpipe_was_pending; + + /* + * Discard the SIGPIPE from send(), not disturbing any SIGPIPE + * that might be already pending. If a bogus SIGPIPE is sent to + * the entire process concurrently by a malicious user, it may + * be simply discarded. + */ + if (sigemptyset(&pending_set)) { + return -1; + } + /* + * sigpending returns the mask of signals that are _both_ + * blocked for the thread _and_ pending for either the thread or + * the entire process. + */ + if (sigpending(&pending_set)) { + return -1; + } + sigpipe_was_pending = sigismember(&pending_set, SIGPIPE); + /* + * If sigpipe was pending, it means it was already blocked, so + * no need to block it. + */ + if (!sigpipe_was_pending) { + if (sigemptyset(&sigpipe_set)) { + return -1; + } + if (sigaddset(&sigpipe_set, SIGPIPE)) { + return -1; + } + if (pthread_sigmask(SIG_BLOCK, &sigpipe_set, &old_set)) { + return -1; + } + } + + /* Send and save errno. */ + sent = bt_socket_send(fd, buffer, size, 0); + saved_err = errno; + + if (sent == -1 && errno == EPIPE && !sigpipe_was_pending) { + struct timespec timeout = {0, 0}; + int ret; + + do { + ret = sigtimedwait(&sigpipe_set, NULL, &timeout); + } while (ret == -1 && errno == EINTR); + } + if (!sigpipe_was_pending) { + if (pthread_sigmask(SIG_SETMASK, &old_set, NULL)) { + return -1; + } + } + /* Restore send() errno */ + errno = saved_err; + + return sent; +} +#endif + +#endif /* BABELTRACE_COMPAT_SOCKET_HPP */ diff --git a/src/cpp-common/Makefile.am b/src/cpp-common/Makefile.am deleted file mode 100644 index a61c1d16..00000000 --- a/src/cpp-common/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -# SPDX-License-Identifier: MIT - -EXTRA_DIST = bt2 optional.hpp string_view.hpp diff --git a/src/cpp-common/bt2/borrowed-object-iterator.hpp b/src/cpp-common/bt2/borrowed-object-iterator.hpp new file mode 100644 index 00000000..3602a4e9 --- /dev/null +++ b/src/cpp-common/bt2/borrowed-object-iterator.hpp @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2022 Francis Deslauriers + * Copyright (c) 2023 Philippe Proulx + * + * SPDX-License-Identifier: MIT + */ + +#ifndef BABELTRACE_CPP_COMMON_BT2_BORROWED_OBJECT_ITERATOR_HPP +#define BABELTRACE_CPP_COMMON_BT2_BORROWED_OBJECT_ITERATOR_HPP + +#include +#include +#include + +#include "common/assert.h" + +#include "borrowed-object-proxy.hpp" + +namespace bt2 { + +/* + * An iterator class to iterate an instance of a borrowed object + * container of type `ContainerT`. + * + * `ContainerT` must implement: + * + * // Returns the number of contained borrowed objects. + * std::uint64_t length() const noexcept; + * + * // Returns the borrowed object at index `i`. + * SomeObject operator[](std::uint64_t i) const noexcept; + */ +template +class BorrowedObjectIterator final +{ + friend ContainerT; + +public: + using Object = typename std::remove_reference< + decltype(std::declval()[std::declval()])>::type; + +private: + explicit BorrowedObjectIterator(const ContainerT container, const uint64_t idx) : + _mContainer {container}, _mIdx {idx} + { + } + +public: + BorrowedObjectIterator& operator++() noexcept + { + ++_mIdx; + return *this; + } + + BorrowedObjectIterator operator++(int) noexcept + { + const auto tmp = *this; + + ++(*this); + return tmp; + } + + bool operator==(const BorrowedObjectIterator& other) const noexcept + { + BT_ASSERT_DBG(_mContainer.isSame(other._mContainer)); + return _mIdx == other._mIdx; + } + + bool operator!=(const BorrowedObjectIterator& other) const noexcept + { + return !(*this == other); + } + + Object operator*() const noexcept + { + return _mContainer[_mIdx]; + } + + BorrowedObjectProxy operator->() const noexcept + { + return BorrowedObjectProxy {(**this).libObjPtr()}; + } + +private: + ContainerT _mContainer; + std::uint64_t _mIdx; +}; + +} /* namespace bt2 */ + +#endif /* BABELTRACE_CPP_COMMON_BT2_BORROWED_OBJECT_ITERATOR_HPP */ diff --git a/src/cpp-common/bt2/borrowed-object-proxy.hpp b/src/cpp-common/bt2/borrowed-object-proxy.hpp new file mode 100644 index 00000000..1b20cc89 --- /dev/null +++ b/src/cpp-common/bt2/borrowed-object-proxy.hpp @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2023 Philippe Proulx + * + * SPDX-License-Identifier: MIT + */ + +#ifndef BABELTRACE_CPP_COMMON_BT2_BORROWED_OBJECT_PROXY_HPP +#define BABELTRACE_CPP_COMMON_BT2_BORROWED_OBJECT_PROXY_HPP + +namespace bt2 { + +/* + * A proxy containing a valid borrowed object instance of `ObjT` to make + * Something::operator->() work when only a libbabeltrace2 object + * pointer is available. + */ +template +class BorrowedObjectProxy final +{ +public: + explicit BorrowedObjectProxy(typename ObjT::LibObjPtr libObjPtr) noexcept : _mObj {libObjPtr} + { + } + + const ObjT *operator->() const noexcept + { + return &_mObj; + } + +private: + ObjT _mObj; +}; + +} /* namespace bt2 */ + +#endif /* BABELTRACE_CPP_COMMON_BT2_BORROWED_OBJECT_PROXY_HPP */ diff --git a/src/cpp-common/bt2/borrowed-object.hpp b/src/cpp-common/bt2/borrowed-object.hpp new file mode 100644 index 00000000..fbfd5b10 --- /dev/null +++ b/src/cpp-common/bt2/borrowed-object.hpp @@ -0,0 +1,173 @@ +/* + * Copyright 2019-2020 (c) Philippe Proulx + * + * SPDX-License-Identifier: MIT + */ + +#ifndef BABELTRACE_CPP_COMMON_BT2_BORROWED_OBJECT_HPP +#define BABELTRACE_CPP_COMMON_BT2_BORROWED_OBJECT_HPP + +#include +#include + +#include "common/assert.h" + +namespace bt2 { + +/* + * An instance of this class wraps a pointer to a libbabeltrace2 object + * of type `LibObjT` without managing any reference counting. + * + * This is an abstract base class for any libbabeltrace2 object wrapper. + * + * `LibObjT` is the direct libbabeltrace2 object type, for example + * `bt_stream_class` or `const bt_value`. + * + * The user of a borrowed object, including methods of a derived class, + * can call libObjPtr() to access the libbabeltrace2 object pointer. + * + * You may only build a borrowed object with a pointer which isn't + * `nullptr`. See `bt2::OptionalBorrowedObject` for an optional version. + */ +template +class BorrowedObject +{ + static_assert(!std::is_pointer::value, "`LibObjT` must not be a pointer"); + + /* + * This makes it possible for a `BorrowedObject` + * instance to get assigned an instance of + * `BorrowedObject` ("copy" constructor and + * "assignment" operator). + * + * C++ forbids the other way around. + */ + template + friend class BorrowedObject; + +private: + /* + * Provides `val` which indicates whether or not you can assign this + * object from a borrowed object of type `OtherLibObjT`. + */ + template + struct _AssignableFromConst final + { + /* + * If `LibObjT` is const (for example, `const bt_value`), then + * you may always assign from its non-const equivalent (for + * example, `bt_value`). In C (correct): + * + * bt_value * const meow = bt_value_bool_create_init(BT_TRUE); + * const bt_value * const mix = meow; + * + * If `LibObjT` is non-const, then you may not assign from its + * const equivalent. In C (not correct): + * + * const bt_value * const meow = + * bt_value_array_borrow_element_by_index_const(some_val, 17); + * bt_value * const mix = meow; + */ + static constexpr bool val = + std::is_const::value || !std::is_const::value; + }; + +protected: + /* This complete borrowed object */ + using _ThisBorrowedObject = BorrowedObject; + +public: + /* libbabeltrace2 object */ + using LibObj = LibObjT; + + /* libbabeltrace2 object pointer */ + using LibObjPtr = LibObjT *; + +protected: + /* + * Builds a borrowed object to wrap the libbabeltrace2 object + * pointer `libObjPtr`. + * + * `libObjPtr` must not be `nullptr`. + */ + explicit BorrowedObject(const LibObjPtr libObjPtr) noexcept : _mLibObjPtr {libObjPtr} + { + BT_ASSERT_DBG(libObjPtr); + } + + /* + * Generic "copy" constructor. + * + * This converting constructor accepts both an instance of + * `_ThisBorrowedObject` and an instance (`other`) of + * `BorrowedObject`, where `ConstLibObjT` is the + * `const` version of `LibObjT`, if applicable. + * + * This makes it possible for a `BorrowedObject` + * instance to be built from an instance of + * `BorrowedObject`. C++ forbids the other way around. + */ + template + BorrowedObject(const BorrowedObject& other) noexcept : + BorrowedObject {other._mLibObjPtr} + { + static_assert(_AssignableFromConst::val, + "Don't assign a non-const wrapper from a const wrapper."); + } + + /* + * Generic "assignment" operator. + * + * This operator accepts both an instance of + * `_ThisBorrowedObject` and an instance (`other`) of + * `BorrowedObject`, where `ConstLibObjT` is the + * `const` version of `LibObjT`, if applicable. + * + * This makes it possible for a `BorrowedObject` + * instance to get assigned an instance of + * `BorrowedObject`. C++ forbids the other way around, + * therefore we use `_EnableIfAssignableT` to show a more relevant + * context in the compiler error message. + */ + template + _ThisBorrowedObject operator=(const BorrowedObject& other) noexcept + { + static_assert(_AssignableFromConst::val, + "Don't assign a non-const wrapper from a const wrapper."); + + _mLibObjPtr = other._mLibObjPtr; + return *this; + } + +public: + /* + * Returns a hash of this object, solely based on its raw + * libbabeltrace2 pointer. + */ + std::size_t hash() const noexcept + { + return std::hash {}(_mLibObjPtr); + } + + /* + * Returns whether or not this object is the exact same as `other`, + * solely based on the raw libbabeltrace2 pointers. + */ + bool isSame(const _ThisBorrowedObject& other) const noexcept + { + return _mLibObjPtr == other._mLibObjPtr; + } + + /* Wrapped libbabeltrace2 object pointer */ + LibObjPtr libObjPtr() const noexcept + { + return _mLibObjPtr; + } + +private: + LibObjPtr _mLibObjPtr; +}; + +} /* namespace bt2 */ + +#endif /* BABELTRACE_CPP_COMMON_BT2_BORROWED_OBJECT_HPP */ diff --git a/src/cpp-common/bt2/clock-class.hpp b/src/cpp-common/bt2/clock-class.hpp index e5522096..5b80890d 100644 --- a/src/cpp-common/bt2/clock-class.hpp +++ b/src/cpp-common/bt2/clock-class.hpp @@ -7,31 +7,32 @@ #ifndef BABELTRACE_CPP_COMMON_BT2_CLOCK_CLASS_HPP #define BABELTRACE_CPP_COMMON_BT2_CLOCK_CLASS_HPP -#include #include -#include +#include + #include -#include "internal/borrowed-obj.hpp" -#include "internal/shared-obj.hpp" -#include "cpp-common/optional.hpp" -#include "cpp-common/string_view.hpp" -#include "cpp-common/uuid-view.hpp" -#include "lib-error.hpp" +#include "cpp-common/bt2c/c-string-view.hpp" +#include "cpp-common/bt2c/uuid.hpp" +#include "cpp-common/bt2s/optional.hpp" + +#include "borrowed-object.hpp" +#include "exc.hpp" +#include "internal/utils.hpp" +#include "shared-object.hpp" #include "value.hpp" namespace bt2 { - namespace internal { struct ClockClassRefFuncs final { - static void get(const bt_clock_class * const libObjPtr) + static void get(const bt_clock_class * const libObjPtr) noexcept { bt_clock_class_get_ref(libObjPtr); } - static void put(const bt_clock_class * const libObjPtr) + static void put(const bt_clock_class * const libObjPtr) noexcept { bt_clock_class_put_ref(libObjPtr); } @@ -40,7 +41,7 @@ struct ClockClassRefFuncs final template struct CommonClockClassSpec; -// Functions specific to mutable clock classes +/* Functions specific to mutable clock classes */ template <> struct CommonClockClassSpec final { @@ -50,7 +51,7 @@ struct CommonClockClassSpec final } }; -// Functions specific to constant clock classes +/* Functions specific to constant clock classes */ template <> struct CommonClockClassSpec final { @@ -60,19 +61,16 @@ struct CommonClockClassSpec final } }; -} // namespace internal +} /* namespace internal */ -class ClockClassOffset final +class ClockOffset final { public: - explicit ClockClassOffset(const std::int64_t seconds, const std::uint64_t cycles) : + explicit ClockOffset(const std::int64_t seconds, const std::uint64_t cycles) : _mSeconds {seconds}, _mCycles {cycles} { } - ClockClassOffset(const ClockClassOffset&) noexcept = default; - ClockClassOffset& operator=(const ClockClassOffset&) noexcept = default; - std::int64_t seconds() const noexcept { return _mSeconds; @@ -89,188 +87,174 @@ private: }; template -class CommonClockClass final : public internal::BorrowedObj +class CommonClockClass final : public BorrowedObject { private: - using typename internal::BorrowedObj::_ThisBorrowedObj; - using typename internal::BorrowedObj::_LibObjPtr; - using _ThisCommonClockClass = CommonClockClass; + using typename BorrowedObject::_ThisBorrowedObject; public: - using Shared = - internal::SharedObj<_ThisCommonClockClass, LibObjT, internal::ClockClassRefFuncs>; + using typename BorrowedObject::LibObjPtr; + using Shared = SharedObject; + using UserAttributes = internal::DepUserAttrs; - using UserAttributes = - typename std::conditional::value, ConstMapValue, MapValue>::type; - - explicit CommonClockClass(const _LibObjPtr libObjPtr) noexcept : _ThisBorrowedObj {libObjPtr} + explicit CommonClockClass(const LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr} { } template - CommonClockClass(const CommonClockClass& clkClass) noexcept : - _ThisBorrowedObj {clkClass} + CommonClockClass(const CommonClockClass clkClass) noexcept : + _ThisBorrowedObject {clkClass} { } template - _ThisCommonClockClass& operator=(const CommonClockClass& clkClass) noexcept + CommonClockClass& operator=(const CommonClockClass clkClass) noexcept { - _ThisBorrowedObj::operator=(clkClass); + _ThisBorrowedObject::operator=(clkClass); return *this; } - void frequency(const std::uint64_t frequency) noexcept + CommonClockClass asConst() const noexcept + { + return CommonClockClass {*this}; + } + + CommonClockClass frequency(const std::uint64_t frequency) const noexcept { - static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); + static_assert(!std::is_const::value, "Not available with `bt2::ConstClockClass`."); - bt_clock_class_set_frequency(this->_libObjPtr(), frequency); + bt_clock_class_set_frequency(this->libObjPtr(), frequency); + return *this; } std::uint64_t frequency() const noexcept { - return bt_clock_class_get_frequency(this->_libObjPtr()); + return bt_clock_class_get_frequency(this->libObjPtr()); } - void offset(const ClockClassOffset& offset) noexcept + CommonClockClass offsetFromOrigin(const ClockOffset& offsetFromOrigin) const noexcept { - static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); + static_assert(!std::is_const::value, "Not available with `bt2::ConstClockClass`."); - bt_clock_class_set_offset(this->_libObjPtr(), offset.seconds(), offset.cycles()); + bt_clock_class_set_offset(this->libObjPtr(), offsetFromOrigin.seconds(), + offsetFromOrigin.cycles()); + return *this; } - ClockClassOffset offset() const noexcept + ClockOffset offsetFromOrigin() const noexcept { std::int64_t seconds; std::uint64_t cycles; - bt_clock_class_get_offset(this->_libObjPtr(), &seconds, &cycles); - return ClockClassOffset {seconds, cycles}; + bt_clock_class_get_offset(this->libObjPtr(), &seconds, &cycles); + return ClockOffset {seconds, cycles}; } - void precision(const std::uint64_t precision) noexcept + CommonClockClass precision(const std::uint64_t precision) const noexcept { - static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); + static_assert(!std::is_const::value, "Not available with `bt2::ConstClockClass`."); - bt_clock_class_set_precision(this->_libObjPtr(), precision); + bt_clock_class_set_precision(this->libObjPtr(), precision); + return *this; } std::uint64_t precision() const noexcept { - return bt_clock_class_get_precision(this->_libObjPtr()); + return bt_clock_class_get_precision(this->libObjPtr()); } - void originIsUnixEpoch(const bool originIsUnixEpoch) noexcept + CommonClockClass originIsUnixEpoch(const bool originIsUnixEpoch) const noexcept { - static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); + static_assert(!std::is_const::value, "Not available with `bt2::ConstClockClass`."); - bt_clock_class_set_origin_is_unix_epoch(this->_libObjPtr(), + bt_clock_class_set_origin_is_unix_epoch(this->libObjPtr(), static_cast(originIsUnixEpoch)); + return *this; } bool originIsUnixEpoch() const noexcept { - return static_cast(bt_clock_class_origin_is_unix_epoch(this->_libObjPtr())); + return static_cast(bt_clock_class_origin_is_unix_epoch(this->libObjPtr())); } - void name(const char * const name) + CommonClockClass name(const bt2c::CStringView name) const { - static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); + static_assert(!std::is_const::value, "Not available with `bt2::ConstClockClass`."); - const auto status = bt_clock_class_set_name(this->_libObjPtr(), name); + const auto status = bt_clock_class_set_name(this->libObjPtr(), name); if (status == BT_CLOCK_CLASS_SET_NAME_STATUS_MEMORY_ERROR) { - throw LibMemoryError {}; + throw MemoryError {}; } - } - void name(const std::string& name) - { - this->name(name.data()); + return *this; } - nonstd::optional name() const noexcept + bt2c::CStringView name() const noexcept { - const auto name = bt_clock_class_get_name(this->_libObjPtr()); - - if (name) { - return name; - } - - return nonstd::nullopt; + return bt_clock_class_get_name(this->libObjPtr()); } - void description(const char * const description) + CommonClockClass description(const bt2c::CStringView description) const { - static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); + static_assert(!std::is_const::value, "Not available with `bt2::ConstClockClass`."); - const auto status = bt_clock_class_set_description(this->_libObjPtr(), description); + const auto status = bt_clock_class_set_description(this->libObjPtr(), description); if (status == BT_CLOCK_CLASS_SET_DESCRIPTION_STATUS_MEMORY_ERROR) { - throw LibMemoryError {}; + throw MemoryError {}; } - } - void description(const std::string& description) - { - this->description(description.data()); + return *this; } - nonstd::optional description() const noexcept + bt2c::CStringView description() const noexcept { - const auto description = bt_clock_class_get_description(this->_libObjPtr()); - - if (description) { - return description; - } - - return nonstd::nullopt; + return bt_clock_class_get_description(this->libObjPtr()); } - void uuid(const std::uint8_t * const uuid) noexcept + CommonClockClass uuid(const bt2c::UuidView uuid) const noexcept { - bt_clock_class_set_uuid(this->_libObjPtr(), uuid); + static_assert(!std::is_const::value, "Not available with `bt2::ConstClockClass`."); + + bt_clock_class_set_uuid(this->libObjPtr(), uuid.data()); + return *this; } - nonstd::optional uuid() const noexcept + bt2s::optional uuid() const noexcept { - const auto uuid = bt_clock_class_get_uuid(this->_libObjPtr()); + const auto uuid = bt_clock_class_get_uuid(this->libObjPtr()); if (uuid) { - return bt2_common::UuidView {uuid}; + return bt2c::UuidView {uuid}; } - return nonstd::nullopt; + return bt2s::nullopt; } template - void userAttributes(const CommonMapValue& userAttrs) + CommonClockClass userAttributes(const CommonMapValue userAttrs) const noexcept { - static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); + static_assert(!std::is_const::value, "Not available with `bt2::ConstClockClass`."); - bt_clock_class_set_user_attributes(this->_libObjPtr(), userAttrs._libObjPtr()); - } - - ConstMapValue userAttributes() const noexcept - { - return ConstMapValue {internal::CommonClockClassSpec::userAttributes( - this->_libObjPtr())}; + bt_clock_class_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr()); + return *this; } - UserAttributes userAttributes() noexcept + UserAttributes userAttributes() const noexcept { return UserAttributes { - internal::CommonClockClassSpec::userAttributes(this->_libObjPtr())}; + internal::CommonClockClassSpec::userAttributes(this->libObjPtr())}; } std::int64_t cyclesToNsFromOrigin(const std::uint64_t value) const { std::int64_t nsFromOrigin; const auto status = - bt_clock_class_cycles_to_ns_from_origin(this->_libObjPtr(), value, &nsFromOrigin); + bt_clock_class_cycles_to_ns_from_origin(this->libObjPtr(), value, &nsFromOrigin); if (status == BT_CLOCK_CLASS_CYCLES_TO_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR) { - throw LibOverflowError {}; + throw OverflowError {}; } return nsFromOrigin; @@ -278,13 +262,32 @@ public: Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; using ClockClass = CommonClockClass; using ConstClockClass = CommonClockClass; -} // namespace bt2 +namespace internal { + +struct ClockClassTypeDescr +{ + using Const = ConstClockClass; + using NonConst = ClockClass; +}; + +template <> +struct TypeDescr : public ClockClassTypeDescr +{ +}; + +template <> +struct TypeDescr : public ClockClassTypeDescr +{ +}; + +} /* namespace internal */ +} /* namespace bt2 */ -#endif // BABELTRACE_CPP_COMMON_BT2_CLOCK_CLASS_HPP +#endif /* BABELTRACE_CPP_COMMON_BT2_CLOCK_CLASS_HPP */ diff --git a/src/cpp-common/bt2/clock-snapshot.hpp b/src/cpp-common/bt2/clock-snapshot.hpp index 26ec9e83..38ea940b 100644 --- a/src/cpp-common/bt2/clock-snapshot.hpp +++ b/src/cpp-common/bt2/clock-snapshot.hpp @@ -8,34 +8,31 @@ #define BABELTRACE_CPP_COMMON_BT2_CLOCK_SNAPSHOT_HPP #include + #include -#include "internal/borrowed-obj.hpp" -#include "lib-error.hpp" +#include "borrowed-object.hpp" +#include "clock-class.hpp" +#include "exc.hpp" namespace bt2 { -class ConstClockSnapshot final : public internal::BorrowedObj +class ConstClockSnapshot final : public BorrowedObject { public: - explicit ConstClockSnapshot(const _LibObjPtr libObjPtr) noexcept : _ThisBorrowedObj {libObjPtr} - { - } - - ConstClockSnapshot(const ConstClockSnapshot& clkSnapshot) noexcept : - _ThisBorrowedObj {clkSnapshot} + explicit ConstClockSnapshot(const LibObjPtr libObjPtr) noexcept : + _ThisBorrowedObject {libObjPtr} { } - ConstClockSnapshot& operator=(const ConstClockSnapshot& clkSnapshot) noexcept + ConstClockClass clockClass() const noexcept { - _ThisBorrowedObj::operator=(clkSnapshot); - return *this; + return ConstClockClass {bt_clock_snapshot_borrow_clock_class_const(this->libObjPtr())}; } std::uint64_t value() const noexcept { - return bt_clock_snapshot_get_value(this->_libObjPtr()); + return bt_clock_snapshot_get_value(this->libObjPtr()); } operator std::uint64_t() const noexcept @@ -46,16 +43,16 @@ public: std::int64_t nsFromOrigin() const { std::int64_t nsFromOrigin; - const auto status = bt_clock_snapshot_get_ns_from_origin(this->_libObjPtr(), &nsFromOrigin); + const auto status = bt_clock_snapshot_get_ns_from_origin(this->libObjPtr(), &nsFromOrigin); if (status == BT_CLOCK_SNAPSHOT_GET_NS_FROM_ORIGIN_STATUS_OVERFLOW_ERROR) { - throw LibOverflowError {}; + throw OverflowError {}; } return nsFromOrigin; } }; -} // namespace bt2 +} /* namespace bt2 */ -#endif // BABELTRACE_CPP_COMMON_BT2_CLOCK_SNAPSHOT_HPP +#endif /* BABELTRACE_CPP_COMMON_BT2_CLOCK_SNAPSHOT_HPP */ diff --git a/src/cpp-common/bt2/component-class-dev.hpp b/src/cpp-common/bt2/component-class-dev.hpp new file mode 100644 index 00000000..e0d45d6b --- /dev/null +++ b/src/cpp-common/bt2/component-class-dev.hpp @@ -0,0 +1,962 @@ +/* + * Copyright (c) 2024 EfficiOS, Inc. + * + * SPDX-License-Identifier: MIT + */ + +#ifndef BABELTRACE_CPP_COMMON_BT2_COMPONENT_CLASS_DEV_HPP +#define BABELTRACE_CPP_COMMON_BT2_COMPONENT_CLASS_DEV_HPP + +#include + +#include + +#include "cpp-common/bt2c/c-string-view.hpp" +#include "cpp-common/bt2c/logging.hpp" +#include "cpp-common/vendor/fmt/core.h" + +#include "exc.hpp" +#include "internal/comp-cls-bridge.hpp" +#include "private-query-executor.hpp" +#include "self-component-port.hpp" + +namespace bt2 { + +template +class UserMessageIterator; + +/* + * Base class of any user component. + * + * See the specific `bt2::UserSourceComponent`, + * `bt2::UserFilterComponent`, and `bt2::UserSinkComponent`. + */ +template +class UserComponent +{ + /* Give a related message iterator access to this logger */ + template + friend class UserMessageIterator; + +public: + using InitData = InitDataT; + using QueryData = QueryDataT; + + static constexpr auto description = nullptr; + static constexpr auto help = nullptr; + +protected: + explicit UserComponent(const SelfCompT selfComp, const std::string& logTag) : + _mLogger {selfComp, fmt::format("{}/[{}]", logTag, selfComp.name())}, _mSelfComp {selfComp} + { + } + + bt2c::CStringView _name() const noexcept + { + return _mSelfComp.name(); + } + + LoggingLevel _loggingLevel() const noexcept + { + return _mSelfComp.loggingLevel(); + } + + std::uint64_t _graphMipVersion() const noexcept + { + return _mSelfComp.graphMipVersion(); + } + + SelfCompT _selfComp() noexcept + { + return _mSelfComp; + } + + bt2c::Logger _mLogger; + +private: + SelfCompT _mSelfComp; +}; + +/* + * Base class of a user source component `UserComponentT` (CRTP). + * + * `UserComponentT` must define a static member `name` of type + * `const char *` to provide the name of the component class. + * + * `UserComponentT` may define the static members `description` and/or + * `help` of type `const char *` to provide the description and/or help + * of the component class. + * + * UserComponentT::UserComponentT() must accept, in this order: + * + * 1. A `bt2::SelfSourceComponent` parameter, which it needs to forward + * to bt2::UserSourceComponent::UserSourceComponent(). + * + * 2. A `bt2::ConstValue` parameter (the initialization parameters). + * + * 3. An `InitDataT *` parameter (the initialization method data). + * + * `UserMessageIteratorT`, the message iterator class to use, must inherit + * `UserMessageIterator`. + * + * UserComponentT::_query() receives a query method data pointer of type + * `QueryDataT *` as its last parameter. + */ +template +class UserSourceComponent : public UserComponent +{ + static_assert(std::is_base_of, + UserMessageIteratorT>::value, + "`UserMessageIteratorT` inherits `UserMessageIterator`"); + +public: + using MessageIterator = UserMessageIteratorT; + +protected: + using _OutputPorts = SelfSourceComponent::OutputPorts; + + explicit UserSourceComponent(const SelfSourceComponent selfComp, const std::string& logTag) : + UserComponent {selfComp, logTag} + { + } + +public: + static Value::Shared query(const SelfComponentClass selfCompCls, + const PrivateQueryExecutor privQueryExec, + const bt2c::CStringView obj, const ConstValue params, + QueryDataT * const data) + { + return UserComponentT::_query(selfCompCls, privQueryExec, obj, params, data); + } + + static void getSupportedMipVersions(const SelfComponentClass selfCompCls, + const ConstMapValue params, const LoggingLevel loggingLevel, + const UnsignedIntegerRangeSet ranges) + { + UserComponentT::_getSupportedMipVersions(selfCompCls, params, loggingLevel, ranges); + } + + void outputPortConnected(const SelfComponentOutputPort outputPort, + const ConstInputPort inputPort) + { + static_cast(*this)._outputPortConnected(outputPort, inputPort); + } + +protected: + /* Overloadable */ + static Value::Shared _query(SelfComponentClass, PrivateQueryExecutor, bt2c::CStringView, + ConstValue, QueryDataT *) + { + throw UnknownObject {}; + } + + /* Overloadable */ + static void _getSupportedMipVersions(SelfComponentClass, ConstMapValue, LoggingLevel, + const UnsignedIntegerRangeSet ranges) + { + ranges.addRange(0, 0); + } + + /* Overloadable */ + void _outputPortConnected(SelfComponentOutputPort, ConstInputPort) + { + } + + template + _OutputPorts::Port _addOutputPort(const bt2c::CStringView name, DataT& data) + { + return this->_selfComp().addOutputPort(name, data); + } + + _OutputPorts::Port _addOutputPort(const bt2c::CStringView name) + { + return this->_selfComp().addOutputPort(name); + } + + _OutputPorts _outputPorts() noexcept + { + return this->_selfComp().outputPorts(); + } +}; + +/* + * Base class of a user filter component `UserComponentT` (CRTP). + * + * `UserComponentT` must define a static member `name` of type + * `const char *` to provide the name of the component class. + * + * `UserComponentT` may define the static members `description` and/or + * `help` of type `const char *` to provide the description and/or help + * of the component class. + * + * UserComponentT::UserComponentT() must accept, in this order: + * + * 1. A `bt2::SelfFilterComponent` parameter, which it needs to forward + * to bt2::UserFilterComponent::UserFilterComponent(). + * + * 2. A `bt2::ConstValue` parameter (the initialization parameters). + * + * 3. An `InitDataT *` parameter (the initialization method data). + * + * `UserMessageIteratorT`, the message iterator class to use, must inherit + * `UserMessageIterator`. + * + * UserComponentT::_query() receives a query method data pointer of type + * `QueryDataT *` as its last parameter. + */ +template +class UserFilterComponent : public UserComponent +{ + static_assert(std::is_base_of, + UserMessageIteratorT>::value, + "`UserMessageIteratorT` inherits `UserMessageIterator`"); + +public: + using MessageIterator = UserMessageIteratorT; + +protected: + using _InputPorts = SelfFilterComponent::InputPorts; + using _OutputPorts = SelfFilterComponent::OutputPorts; + + explicit UserFilterComponent(const SelfFilterComponent selfComp, const std::string& logTag) : + UserComponent {selfComp, logTag} + { + } + +public: + static Value::Shared query(const SelfComponentClass selfCompCls, + const PrivateQueryExecutor privQueryExec, + const bt2c::CStringView obj, const ConstValue params, + QueryDataT * const data) + { + return UserComponentT::_query(selfCompCls, privQueryExec, obj, params, data); + } + + static void getSupportedMipVersions(const SelfComponentClass selfCompCls, + const ConstMapValue params, const LoggingLevel loggingLevel, + const UnsignedIntegerRangeSet ranges) + { + UserComponentT::_getSupportedMipVersions(selfCompCls, params, loggingLevel, ranges); + } + + void inputPortConnected(const SelfComponentInputPort inputPort, + const ConstOutputPort outputPort) + { + static_cast(*this)._inputPortConnected(inputPort, outputPort); + } + + void outputPortConnected(const SelfComponentOutputPort outputPort, + const ConstInputPort inputPort) + { + static_cast(*this)._outputPortConnected(outputPort, inputPort); + } + +protected: + /* Overloadable */ + static Value::Shared _query(SelfComponentClass, PrivateQueryExecutor, bt2c::CStringView, + ConstValue, QueryDataT *) + { + throw UnknownObject {}; + } + + /* Overloadable */ + static void _getSupportedMipVersions(SelfComponentClass, ConstMapValue, LoggingLevel, + const UnsignedIntegerRangeSet ranges) + { + ranges.addRange(0, 0); + } + + /* Overloadable */ + void _inputPortConnected(SelfComponentInputPort, ConstOutputPort) + { + } + + /* Overloadable */ + void _outputPortConnected(SelfComponentOutputPort, ConstInputPort) + { + } + + template + _OutputPorts::Port _addInputPort(const bt2c::CStringView name, DataT& data) + { + return this->_selfComp().addInputPort(name, data); + } + + _InputPorts::Port _addInputPort(const bt2c::CStringView name) + { + return this->_selfComp().addInputPort(name); + } + + _InputPorts _inputPorts() noexcept + { + return this->_selfComp().inputPorts(); + } + + template + _OutputPorts::Port _addOutputPort(const bt2c::CStringView name, DataT& data) + { + return this->_selfComp().addOutputPort(name, data); + } + + _OutputPorts::Port _addOutputPort(const bt2c::CStringView name) + { + return this->_selfComp().addOutputPort(name); + } + + _OutputPorts _outputPorts() noexcept + { + return this->_selfComp().outputPorts(); + } +}; + +/* + * Base class of a user sink component `UserComponentT` (CRTP). + * + * `UserComponentT` must define a static member `name` of type + * `const char *` to provide the name of the component class. + * + * `UserComponentT` may define the static members `description` and/or + * `help` of type `const char *` to provide the description and/or help + * of the component class. + * + * UserComponentT::UserComponentT() must accept, in this order: + * + * 1. A `bt2::SelfSinkComponent` parameter, which it needs to forward + * to bt2::UserSinkComponent::UserSinkComponent(). + * + * 2. A `bt2::ConstValue` parameter (the initialization parameters). + * + * 3. An `InitDataT *` parameter (the initialization method data). + * + * `UserComponentT` must implement: + * + * bool _consume(); + * + * This method returns `true` if the sink component still needs to + * consume, or `false` if it's finished. + * + * UserComponentT::_query() receives a query method data pointer of type + * `QueryDataT *` as its last parameter. + + */ +template +class UserSinkComponent : public UserComponent +{ +protected: + using _InputPorts = SelfSinkComponent::InputPorts; + + explicit UserSinkComponent(const SelfSinkComponent selfComp, const std::string& logTag) : + UserComponent {selfComp, logTag} + { + } + +public: + static Value::Shared query(const SelfComponentClass selfCompCls, + const PrivateQueryExecutor privQueryExec, + const bt2c::CStringView obj, const ConstValue params, + QueryDataT * const data) + { + return UserComponentT::_query(selfCompCls, privQueryExec, obj, params, data); + } + + static void getSupportedMipVersions(const SelfComponentClass selfCompCls, + const ConstMapValue params, const LoggingLevel loggingLevel, + const UnsignedIntegerRangeSet ranges) + { + UserComponentT::_getSupportedMipVersions(selfCompCls, params, loggingLevel, ranges); + } + + void graphIsConfigured() + { + static_cast(*this)._graphIsConfigured(); + } + + void inputPortConnected(const SelfComponentInputPort inputPort, + const ConstOutputPort outputPort) + { + static_cast(*this)._inputPortConnected(inputPort, outputPort); + } + + bool consume() + { + return static_cast(*this)._consume(); + } + +protected: + /* Overloadable */ + static Value::Shared _query(SelfComponentClass, PrivateQueryExecutor, bt2c::CStringView, + ConstValue, QueryDataT *) + { + throw UnknownObject {}; + } + + /* Overloadable */ + static void _getSupportedMipVersions(SelfComponentClass, ConstMapValue, LoggingLevel, + const UnsignedIntegerRangeSet ranges) + { + ranges.addRange(0, 0); + } + + /* Overloadable */ + void _graphIsConfigured() + { + } + + /* Overloadable */ + void _inputPortConnected(SelfComponentInputPort, ConstOutputPort) + { + } + + MessageIterator::Shared _createMessageIterator(const _InputPorts::Port port) + { + return this->_selfComp().createMessageIterator(port); + } + + template + _InputPorts::Port _addInputPort(const bt2c::CStringView name, DataT& data) + { + return this->_selfComp().addInputPort(name, data); + } + + _InputPorts::Port _addInputPort(const bt2c::CStringView name) + { + return this->_selfComp().addInputPort(name); + } + + _InputPorts _inputPorts() noexcept + { + return this->_selfComp().inputPorts(); + } +}; + +/* + * Base class of a user message iterator `UserMessageIteratorT` (CRTP) + * of which the parent user component class is `UserComponentT`. + * + * `UserMessageIteratorT::UserMessageIteratorT()` must accept a + * `bt2::SelfMessageIterator` parameter, which it needs to forward to + * bt2::UserMessageIterator::UserMessageIterator(). + * + * The public next() method below (called by the bridge) implements the + * very common pattern of appending messages into the output array, and, + * meanwhile: + * + * If it catches a `bt2::TryAgain` exception: + * If the message array isn't empty, transform this into a success + * (don't throw). + * + * Otherwise rethrow. + * + * If it catches an error: + * If the message array isn't empty, transform this into a success + * (don't throw), but save the error of the current thread and the + * type of error to throw the next time the user calls next(). + * + * Otherwise rethrow. + * + * `UserMessageIteratorT` must implement: + * + * void _next(bt2::ConstMessageArray& messages); + * + * This method fills `messages` with at most `messages.capacity()` + * messages and may throw `bt2::TryAgain` or a valid error whenever. + * Leaving an empty `messages` means the end of iteration. + */ +template +class UserMessageIterator +{ +private: + /* Type of `_mExcToThrowType` */ + enum class _ExcToThrowType + { + None, + Error, + MemError, + }; + +protected: + explicit UserMessageIterator(const SelfMessageIterator selfMsgIter, + const std::string& logTagSuffix) : + _mSelfMsgIter {selfMsgIter}, + _mLogger {selfMsgIter, + fmt::format("{}/{}", this->_component()._mLogger.tag(), logTagSuffix)} + { + } + +public: + void next(ConstMessageArray& messages) + { + /* Any saved error? Now is the time to throw */ + if (G_UNLIKELY(_mExcToThrowType != _ExcToThrowType::None)) { + /* Move `_mSavedLibError`, if any, as current thread error */ + if (_mSavedLibError) { + bt_current_thread_move_error(_mSavedLibError.release()); + } + + /* Throw the corresponding exception */ + if (_mExcToThrowType == _ExcToThrowType::Error) { + throw Error {}; + } else { + BT_ASSERT(_mExcToThrowType == _ExcToThrowType::MemError); + throw MemoryError {}; + } + } + + /* + * When catching some exception below, if our message array + * isn't empty, then return immediately before throwing to + * provide those messages to downstream. + * + * When catching an error, also save the current thread error, + * if any, so that we can restore it later (see the beginning of + * this method). + */ + BT_ASSERT_DBG(_mExcToThrowType == _ExcToThrowType::None); + + try { + this->_userObj()._next(messages); + + /* We're done: everything below is exception handling */ + return; + } catch (const TryAgain&) { + if (messages.isEmpty()) { + throw; + } + } catch (const std::bad_alloc&) { + if (messages.isEmpty()) { + throw; + } + + _mExcToThrowType = _ExcToThrowType::MemError; + } catch (const Error&) { + if (messages.isEmpty()) { + throw; + } + + _mExcToThrowType = _ExcToThrowType::Error; + } + + if (_mExcToThrowType != _ExcToThrowType::None) { + BT_CPPLOGE( + "An error occurred, but there are {} messages to return: delaying the error reporting.", + messages.length()); + BT_ASSERT(!_mSavedLibError); + _mSavedLibError.reset(bt_current_thread_take_error()); + } + } + + bool canSeekBeginning() + { + this->_resetError(); + return this->_userObj()._canSeekBeginning(); + } + + void seekBeginning() + { + this->_resetError(); + return this->_userObj()._seekBeginning(); + } + + bool canSeekNsFromOrigin(const std::int64_t nsFromOrigin) + { + this->_resetError(); + return this->_userObj()._canSeekNsFromOrigin(nsFromOrigin); + } + + void seekNsFromOrigin(const std::int64_t nsFromOrigin) + { + this->_resetError(); + this->_userObj()._seekNsFromOrigin(nsFromOrigin); + } + +protected: + /* Overloadable */ + bool _canSeekBeginning() noexcept + { + return false; + } + + /* Overloadable */ + void _seekBeginning() noexcept + { + } + + /* Overloadable */ + bool _canSeekNsFromOrigin(std::int64_t) noexcept + { + return false; + } + + /* Overloadable */ + void _seekNsFromOrigin(std::int64_t) noexcept + { + } + + MessageIterator::Shared _createMessageIterator(const SelfComponentInputPort port) + { + return _mSelfMsgIter.createMessageIterator(port); + } + + StreamBeginningMessage::Shared _createStreamBeginningMessage(const ConstStream stream) const + { + return _mSelfMsgIter.createStreamBeginningMessage(stream); + } + + StreamEndMessage::Shared _createStreamEndMessage(const ConstStream stream) const + { + return _mSelfMsgIter.createStreamEndMessage(stream); + } + + EventMessage::Shared _createEventMessage(const ConstEventClass eventCls, + const ConstStream stream) const + { + return _mSelfMsgIter.createEventMessage(eventCls, stream); + } + + EventMessage::Shared _createEventMessage(const ConstEventClass eventCls, + const ConstStream stream, + const std::uint64_t clockSnapshotValue) const + { + return _mSelfMsgIter.createEventMessage(eventCls, stream, clockSnapshotValue); + } + + EventMessage::Shared _createEventMessage(const ConstEventClass eventCls, + const ConstPacket packet) const + { + return _mSelfMsgIter.createEventMessage(eventCls, packet); + } + + EventMessage::Shared _createEventMessage(const ConstEventClass eventCls, + const ConstPacket packet, + const std::uint64_t clockSnapshotValue) const + { + return _mSelfMsgIter.createEventMessage(eventCls, packet, clockSnapshotValue); + } + + PacketBeginningMessage::Shared _createPacketBeginningMessage(const ConstPacket packet) const + { + return _mSelfMsgIter.createPacketBeginningMessage(packet); + } + + PacketBeginningMessage::Shared + _createPacketBeginningMessage(const ConstPacket packet, + const std::uint64_t clockSnapshotValue) const + { + return _mSelfMsgIter.createPacketBeginningMessage(packet, clockSnapshotValue); + } + + PacketEndMessage::Shared _createPacketEndMessage(const ConstPacket packet) const + { + return _mSelfMsgIter.createPacketEndMessage(packet); + } + + PacketEndMessage::Shared _createPacketEndMessage(const ConstPacket packet, + const std::uint64_t clockSnapshotValue) const + { + return _mSelfMsgIter.createPacketEndMessage(packet, clockSnapshotValue); + } + + DiscardedEventsMessage::Shared _createDiscardedEventsMessage(const ConstStream stream) + { + return _mSelfMsgIter.createDiscardedEventsMessage(stream); + } + + DiscardedEventsMessage::Shared + _createDiscardedEventsMessage(const ConstStream stream, + const std::uint64_t beginningClockSnapshotValue, + const std::uint64_t endClockSnapshotValue) + { + return _mSelfMsgIter.createDiscardedEventsMessage(stream, beginningClockSnapshotValue, + endClockSnapshotValue); + } + + DiscardedPacketsMessage::Shared _createDiscardedPacketsMessage(const ConstStream stream) + { + return _mSelfMsgIter.createDiscardedPacketsMessage(stream); + } + + DiscardedPacketsMessage::Shared + _createDiscardedPacketsMessage(const ConstStream stream, + const std::uint64_t beginningClockSnapshotValue, + const std::uint64_t endClockSnapshotValue) + { + return _mSelfMsgIter.createDiscardedPacketsMessage(stream, beginningClockSnapshotValue, + endClockSnapshotValue); + } + + MessageIteratorInactivityMessage::Shared + _createMessageIteratorInactivityMessage(const ConstClockClass clockClass, + const std::uint64_t clockSnapshotValue) + { + return _mSelfMsgIter.createMessageIteratorInactivityMessage(clockClass, clockSnapshotValue); + } + + UserComponentT& _component() noexcept + { + return _mSelfMsgIter.component().template data(); + } + + SelfComponentOutputPort _port() noexcept + { + return _mSelfMsgIter.port(); + } + + bool _isInterrupted() const noexcept + { + return _mSelfMsgIter.isInterrupted(); + } + +private: + UserMessageIteratorT& _userObj() noexcept + { + return static_cast(*this); + } + + void _resetError() noexcept + { + _mExcToThrowType = _ExcToThrowType::None; + _mSavedLibError.reset(); + } + + SelfMessageIterator _mSelfMsgIter; + + /* + * next() may accumulate messages, and then catch an error before + * returning. In that case, it saves the error of the current thread + * here so that it can return its accumulated messages and throw the + * next time. + * + * It also saves the type of the exception to throw the next time. + */ + _ExcToThrowType _mExcToThrowType = _ExcToThrowType::None; + + struct LibErrorDeleter final + { + void operator()(const bt_error * const error) const noexcept + { + bt_error_release(error); + } + }; + + std::unique_ptr _mSavedLibError; + +protected: + bt2c::Logger _mLogger; +}; + +namespace internal { + +template +void setCompClsCommonProps( + LibSpecCompClsPtrT * const libSpecCompClsPtr, AsCompClsFuncT&& asCompClsFunc, + SetInitMethodFuncT&& setInitMethodFunc, SetFinalizeMethodFuncT&& setFinalizeMethodFunc, + SetGetSupportedMipVersionsMethodFuncT&& setGetSupportedMipVersionsMethodFunc, + SetQueryMethodFuncT&& setQueryMethodFunc) +{ + const auto libCompClsPtr = asCompClsFunc(libSpecCompClsPtr); + + if (UserComponentT::description != nullptr) { + const auto status = + bt_component_class_set_description(libCompClsPtr, UserComponentT::description); + + if (status == BT_COMPONENT_CLASS_SET_DESCRIPTION_STATUS_MEMORY_ERROR) { + throw MemoryError {}; + } + } + + if (UserComponentT::help != nullptr) { + const auto status = bt_component_class_set_help(libCompClsPtr, UserComponentT::help); + + if (status == BT_COMPONENT_CLASS_SET_HELP_STATUS_MEMORY_ERROR) { + throw MemoryError {}; + } + } + + { + const auto status = setInitMethodFunc(libSpecCompClsPtr, CompClsBridgeT::init); + + BT_ASSERT(status == BT_COMPONENT_CLASS_SET_METHOD_STATUS_OK); + } + + { + const auto status = setFinalizeMethodFunc(libSpecCompClsPtr, CompClsBridgeT::finalize); + + BT_ASSERT(status == BT_COMPONENT_CLASS_SET_METHOD_STATUS_OK); + } + + { + const auto status = setGetSupportedMipVersionsMethodFunc( + libSpecCompClsPtr, CompClsBridgeT::getSupportedMipVersions); + + BT_ASSERT(status == BT_COMPONENT_CLASS_SET_METHOD_STATUS_OK); + } + + { + const auto status = setQueryMethodFunc(libSpecCompClsPtr, CompClsBridgeT::query); + + BT_ASSERT(status == BT_COMPONENT_CLASS_SET_METHOD_STATUS_OK); + } +} + +template +bt_message_iterator_class *createLibMsgIterCls() +{ + const auto libMsgIterClsPtr = bt_message_iterator_class_create(MsgIterClsBridgeT::next); + + if (!libMsgIterClsPtr) { + throw MemoryError {}; + } + + { + const auto status = bt_message_iterator_class_set_initialize_method( + libMsgIterClsPtr, MsgIterClsBridgeT::init); + + BT_ASSERT(status == BT_MESSAGE_ITERATOR_CLASS_SET_METHOD_STATUS_OK); + } + + { + const auto status = bt_message_iterator_class_set_finalize_method( + libMsgIterClsPtr, MsgIterClsBridgeT::finalize); + + BT_ASSERT(status == BT_MESSAGE_ITERATOR_CLASS_SET_METHOD_STATUS_OK); + } + + return libMsgIterClsPtr; +} + +template +bt_component_class_source *createSourceCompCls() +{ + static_assert( + std::is_base_of, + UserComponentT>::value, + "`UserComponentT` inherits `UserSourceComponent`"); + + using CompClsBridge = internal::SrcCompClsBridge; + using MsgIterClsBridge = internal::MsgIterClsBridge; + + const auto libMsgIterClsPtr = createLibMsgIterCls(); + const auto libCompClsPtr = + bt_component_class_source_create(UserComponentT::name, libMsgIterClsPtr); + + bt_message_iterator_class_put_ref(libMsgIterClsPtr); + + if (!libCompClsPtr) { + throw MemoryError {}; + } + + setCompClsCommonProps( + libCompClsPtr, bt_component_class_source_as_component_class, + bt_component_class_source_set_initialize_method, + bt_component_class_source_set_finalize_method, + bt_component_class_source_set_get_supported_mip_versions_method, + bt_component_class_source_set_query_method); + + { + const auto status = bt_component_class_source_set_output_port_connected_method( + libCompClsPtr, CompClsBridge::outputPortConnected); + + BT_ASSERT(status == BT_COMPONENT_CLASS_SET_METHOD_STATUS_OK); + } + + return libCompClsPtr; +} + +template +bt_component_class_filter *createFilterCompCls() +{ + static_assert( + std::is_base_of, + UserComponentT>::value, + "`UserComponentT` inherits `UserFilterComponent`"); + + using CompClsBridge = internal::FltCompClsBridge; + using MsgIterClsBridge = internal::MsgIterClsBridge; + + const auto libMsgIterClsPtr = createLibMsgIterCls(); + const auto libCompClsPtr = + bt_component_class_filter_create(UserComponentT::name, libMsgIterClsPtr); + + bt_message_iterator_class_put_ref(libMsgIterClsPtr); + + if (!libCompClsPtr) { + throw MemoryError {}; + } + + setCompClsCommonProps( + libCompClsPtr, bt_component_class_filter_as_component_class, + bt_component_class_filter_set_initialize_method, + bt_component_class_filter_set_finalize_method, + bt_component_class_filter_set_get_supported_mip_versions_method, + bt_component_class_filter_set_query_method); + + { + const auto status = bt_component_class_filter_set_input_port_connected_method( + libCompClsPtr, CompClsBridge::inputPortConnected); + + BT_ASSERT(status == BT_COMPONENT_CLASS_SET_METHOD_STATUS_OK); + } + + { + const auto status = bt_component_class_filter_set_output_port_connected_method( + libCompClsPtr, CompClsBridge::outputPortConnected); + + BT_ASSERT(status == BT_COMPONENT_CLASS_SET_METHOD_STATUS_OK); + } + + return libCompClsPtr; +} + +template +bt_component_class_sink *createSinkCompCls() +{ + static_assert( + std::is_base_of, + UserComponentT>::value, + "`UserComponentT` inherits `UserSinkComponent`"); + + using CompClsBridge = internal::SinkCompClsBridge; + + const auto libCompClsPtr = + bt_component_class_sink_create(UserComponentT::name, CompClsBridge::consume); + + if (!libCompClsPtr) { + throw MemoryError {}; + } + + setCompClsCommonProps( + libCompClsPtr, bt_component_class_sink_as_component_class, + bt_component_class_sink_set_initialize_method, bt_component_class_sink_set_finalize_method, + bt_component_class_sink_set_get_supported_mip_versions_method, + bt_component_class_sink_set_query_method); + + { + const auto status = bt_component_class_sink_set_graph_is_configured_method( + libCompClsPtr, CompClsBridge::graphIsConfigured); + + BT_ASSERT(status == BT_COMPONENT_CLASS_SET_METHOD_STATUS_OK); + } + + { + const auto status = bt_component_class_sink_set_input_port_connected_method( + libCompClsPtr, CompClsBridge::inputPortConnected); + + BT_ASSERT(status == BT_COMPONENT_CLASS_SET_METHOD_STATUS_OK); + } + + return libCompClsPtr; +} + +} /* namespace internal */ +} /* namespace bt2 */ + +#endif /* BABELTRACE_CPP_COMMON_BT2_COMPONENT_CLASS_DEV_HPP */ diff --git a/src/cpp-common/bt2/component-class.hpp b/src/cpp-common/bt2/component-class.hpp new file mode 100644 index 00000000..2933d74f --- /dev/null +++ b/src/cpp-common/bt2/component-class.hpp @@ -0,0 +1,475 @@ +/* + * Copyright (c) 2024 EfficiOS, Inc. + * + * SPDX-License-Identifier: MIT + */ + +#ifndef BABELTRACE_CPP_COMMON_BT2_COMPONENT_CLASS_HPP +#define BABELTRACE_CPP_COMMON_BT2_COMPONENT_CLASS_HPP + +#include + +#include "cpp-common/bt2c/c-string-view.hpp" + +#include "borrowed-object.hpp" +#include "component-class-dev.hpp" +#include "shared-object.hpp" + +namespace bt2 { +namespace internal { + +struct ComponentClassRefFuncs final +{ + static void get(const bt_component_class * const libObjPtr) noexcept + { + bt_component_class_get_ref(libObjPtr); + } + + static void put(const bt_component_class * const libObjPtr) noexcept + { + bt_component_class_put_ref(libObjPtr); + } +}; + +} /* namespace internal */ + +enum class ComponentClassType +{ + Source = BT_COMPONENT_CLASS_TYPE_SOURCE, + Filter = BT_COMPONENT_CLASS_TYPE_FILTER, + Sink = BT_COMPONENT_CLASS_TYPE_SINK, +}; + +template +class CommonSourceComponentClass; + +template +class CommonFilterComponentClass; + +template +class CommonSinkComponentClass; + +template +class CommonComponentClass : public BorrowedObject +{ +private: + using _ThisBorrowedObject = BorrowedObject; + +public: + using typename _ThisBorrowedObject::LibObjPtr; + using Shared = SharedObject; + + explicit CommonComponentClass(const LibObjPtr libObjPtr) noexcept : + _ThisBorrowedObject {libObjPtr} + { + } + + template + CommonComponentClass(const CommonComponentClass compCls) noexcept : + _ThisBorrowedObject {compCls} + { + } + + template + CommonComponentClass operator=(const CommonComponentClass compCls) noexcept + { + _ThisBorrowedObject::operator=(compCls); + return *this; + } + + /* Not `explicit` to make them behave like copy constructors */ + CommonComponentClass( + const CommonSourceComponentClass other) noexcept; + CommonComponentClass( + const CommonSourceComponentClass other) noexcept; + CommonComponentClass( + const CommonFilterComponentClass other) noexcept; + CommonComponentClass( + const CommonFilterComponentClass other) noexcept; + CommonComponentClass( + const CommonSinkComponentClass other) noexcept; + CommonComponentClass(const CommonSinkComponentClass other) noexcept; + + CommonComponentClass + operator=(CommonSourceComponentClass other) noexcept; + CommonComponentClass + operator=(CommonSourceComponentClass other) noexcept; + CommonComponentClass + operator=(CommonFilterComponentClass other) noexcept; + CommonComponentClass + operator=(CommonFilterComponentClass other) noexcept; + CommonComponentClass + operator=(CommonSinkComponentClass other) noexcept; + CommonComponentClass + operator=(CommonSinkComponentClass other) noexcept; + + bool isSource() const noexcept + { + return static_cast(bt_component_class_is_source(this->libObjPtr())); + } + + bool isFilter() const noexcept + { + return static_cast(bt_component_class_is_filter(this->libObjPtr())); + } + + bool isSink() const noexcept + { + return static_cast(bt_component_class_is_sink(this->libObjPtr())); + } + + bt2c::CStringView name() const noexcept + { + return bt_component_class_get_name(this->libObjPtr()); + } + + bt2c::CStringView description() const noexcept + { + return bt_component_class_get_description(this->libObjPtr()); + } + + bt2c::CStringView help() const noexcept + { + return bt_component_class_get_help(this->libObjPtr()); + } +}; + +using ComponentClass = CommonComponentClass; +using ConstComponentClass = CommonComponentClass; + +namespace internal { + +struct SourceComponentClassRefFuncs final +{ + static void get(const bt_component_class_source * const libObjPtr) noexcept + { + bt_component_class_source_get_ref(libObjPtr); + } + + static void put(const bt_component_class_source * const libObjPtr) noexcept + { + bt_component_class_source_put_ref(libObjPtr); + } +}; + +} /* namespace internal */ + +template +class CommonSourceComponentClass final : public BorrowedObject +{ +private: + using _ThisBorrowedObject = BorrowedObject; + +public: + using typename _ThisBorrowedObject::LibObjPtr; + using Shared = + SharedObject; + + CommonSourceComponentClass(const LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr} + { + } + + template + CommonSourceComponentClass(const CommonSourceComponentClass compCls) noexcept : + _ThisBorrowedObject {compCls} + { + } + + template + CommonSourceComponentClass + operator=(const CommonSourceComponentClass compCls) noexcept + { + _ThisBorrowedObject::operator=(compCls); + return *this; + } + + template + static CommonSourceComponentClass::Shared create() + { + return CommonSourceComponentClass::Shared::createWithoutRef( + internal::createSourceCompCls()); + } + + bt2c::CStringView name() const noexcept + { + return this->_constComponentClass().name(); + } + + bt2c::CStringView description() const noexcept + { + return this->_constComponentClass().description(); + } + + bt2c::CStringView help() const noexcept + { + return this->_constComponentClass().help(); + } + +private: + ConstComponentClass _constComponentClass() const noexcept + { + return ConstComponentClass { + bt_component_class_source_as_component_class_const(this->libObjPtr())}; + } +}; + +template +CommonComponentClass::CommonComponentClass( + const CommonSourceComponentClass other) noexcept : + _ThisBorrowedObject {bt_component_class_source_as_component_class_const(other.libObjPtr())} +{ +} + +template +CommonComponentClass::CommonComponentClass( + const CommonSourceComponentClass other) noexcept : + _ThisBorrowedObject {bt_component_class_source_as_component_class(other.libObjPtr())} +{ +} + +template +CommonComponentClass CommonComponentClass::operator=( + const CommonSourceComponentClass other) noexcept +{ + BorrowedObject::operator=(ConstComponentClass { + bt_component_class_source_as_component_class_const(other.libObjPtr())}); + return *this; +} + +template +CommonComponentClass CommonComponentClass::operator=( + const CommonSourceComponentClass other) noexcept +{ + BorrowedObject::operator=( + ComponentClass {bt_component_class_source_as_component_class(other.libObjPtr())}); + return *this; +} + +using SourceComponentClass = CommonSourceComponentClass; +using ConstSourceComponentClass = CommonSourceComponentClass; + +namespace internal { + +struct FilterComponentClassRefFuncs final +{ + static void get(const bt_component_class_filter * const libObjPtr) noexcept + { + bt_component_class_filter_get_ref(libObjPtr); + } + + static void put(const bt_component_class_filter * const libObjPtr) noexcept + { + bt_component_class_filter_put_ref(libObjPtr); + } +}; + +} /* namespace internal */ + +template +class CommonFilterComponentClass final : public BorrowedObject +{ +private: + using _ThisBorrowedObject = BorrowedObject; + +public: + using typename _ThisBorrowedObject::LibObjPtr; + using Shared = + SharedObject; + + CommonFilterComponentClass(const LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr} + { + } + + template + CommonFilterComponentClass(const CommonFilterComponentClass compCls) noexcept : + _ThisBorrowedObject {compCls} + { + } + + template + CommonFilterComponentClass + operator=(const CommonFilterComponentClass compCls) noexcept + { + _ThisBorrowedObject::operator=(compCls); + return *this; + } + + template + static CommonFilterComponentClass::Shared create() + { + return CommonFilterComponentClass::Shared::createWithoutRef( + internal::createFilterCompCls()); + } + + bt2c::CStringView name() const noexcept + { + return this->_constComponentClass().name(); + } + + bt2c::CStringView description() const noexcept + { + return this->_constComponentClass().description(); + } + + bt2c::CStringView help() const noexcept + { + return this->_constComponentClass().help(); + } + +private: + ConstComponentClass _constComponentClass() const noexcept + { + return ConstComponentClass { + bt_component_class_filter_as_component_class_const(this->libObjPtr())}; + } +}; + +template +CommonComponentClass::CommonComponentClass( + const CommonFilterComponentClass other) noexcept : + _ThisBorrowedObject {bt_component_class_filter_as_component_class_const(other.libObjPtr())} +{ +} + +template +CommonComponentClass::CommonComponentClass( + const CommonFilterComponentClass other) noexcept : + _ThisBorrowedObject {bt_component_class_filter_as_component_class(other.libObjPtr())} +{ +} + +template +CommonComponentClass CommonComponentClass::operator=( + const CommonFilterComponentClass other) noexcept +{ + BorrowedObject::operator=(ConstComponentClass { + bt_component_class_filter_as_component_class_const(other.libObjPtr())}); + return *this; +} + +template +CommonComponentClass CommonComponentClass::operator=( + const CommonFilterComponentClass other) noexcept +{ + BorrowedObject::operator=( + ComponentClass {bt_component_class_filter_as_component_class(other.libObjPtr())}); + return *this; +} + +using FilterComponentClass = CommonFilterComponentClass; +using ConstFilterComponentClass = CommonFilterComponentClass; + +namespace internal { + +struct SinkComponentClassRefFuncs final +{ + static void get(const bt_component_class_sink * const libObjPtr) noexcept + { + bt_component_class_sink_get_ref(libObjPtr); + } + + static void put(const bt_component_class_sink * const libObjPtr) noexcept + { + bt_component_class_sink_put_ref(libObjPtr); + } +}; + +} /* namespace internal */ + +template +class CommonSinkComponentClass final : public BorrowedObject +{ +private: + using _ThisBorrowedObject = BorrowedObject; + +public: + using typename _ThisBorrowedObject::LibObjPtr; + using Shared = + SharedObject; + + CommonSinkComponentClass(const LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr} + { + } + + template + CommonSinkComponentClass(const CommonSinkComponentClass compCls) noexcept : + _ThisBorrowedObject {compCls} + { + } + + template + CommonSinkComponentClass + operator=(const CommonSinkComponentClass compCls) noexcept + { + _ThisBorrowedObject::operator=(compCls); + return *this; + } + + template + static CommonSinkComponentClass::Shared create() + { + return CommonSinkComponentClass::Shared::createWithoutRef( + internal::createSinkCompCls()); + } + + bt2c::CStringView name() const noexcept + { + return this->_constComponentClass().name(); + } + + bt2c::CStringView description() const noexcept + { + return this->_constComponentClass().description(); + } + + bt2c::CStringView help() const noexcept + { + return this->_constComponentClass().help(); + } + +private: + ConstComponentClass _constComponentClass() const noexcept + { + return ConstComponentClass { + bt_component_class_sink_as_component_class_const(this->libObjPtr())}; + } +}; + +template +CommonComponentClass::CommonComponentClass( + const CommonSinkComponentClass other) noexcept : + _ThisBorrowedObject {bt_component_class_sink_as_component_class_const(other.libObjPtr())} +{ +} + +template +CommonComponentClass::CommonComponentClass( + const CommonSinkComponentClass other) noexcept : + _ThisBorrowedObject {bt_component_class_sink_as_component_class(other.libObjPtr())} +{ +} + +template +CommonComponentClass CommonComponentClass::operator=( + const CommonSinkComponentClass other) noexcept +{ + BorrowedObject::operator=( + ConstComponentClass {bt_component_class_sink_as_component_class_const(other.libObjPtr())}); + return *this; +} + +template +CommonComponentClass CommonComponentClass::operator=( + const CommonSinkComponentClass other) noexcept +{ + BorrowedObject::operator=( + ComponentClass {bt_component_class_sink_as_component_class(other.libObjPtr())}); + return *this; +} + +using SinkComponentClass = CommonSinkComponentClass; +using ConstSinkComponentClass = CommonSinkComponentClass; + +} /* namespace bt2 */ + +#endif /* BABELTRACE_CPP_COMMON_BT2_COMPONENT_CLASS_HPP */ diff --git a/src/cpp-common/bt2/component-port.hpp b/src/cpp-common/bt2/component-port.hpp new file mode 100644 index 00000000..930b2e6f --- /dev/null +++ b/src/cpp-common/bt2/component-port.hpp @@ -0,0 +1,550 @@ +/* + * Copyright (c) 2023 Philippe Proulx + * + * SPDX-License-Identifier: MIT + */ + +#ifndef BABELTRACE_CPP_COMMON_BT2_COMPONENT_PORT_HPP +#define BABELTRACE_CPP_COMMON_BT2_COMPONENT_PORT_HPP + +#include + +#include + +#include "logging.hpp" + +#include "cpp-common/bt2c/c-string-view.hpp" + +#include "borrowed-object-iterator.hpp" +#include "borrowed-object.hpp" +#include "shared-object.hpp" + +namespace bt2 { +namespace internal { + +struct ConstComponentRefFuncs final +{ + static void get(const bt_component * const libObjPtr) noexcept + { + bt_component_get_ref(libObjPtr); + } + + static void put(const bt_component * const libObjPtr) noexcept + { + bt_component_put_ref(libObjPtr); + } +}; + +} /* namespace internal */ + +class ConstSourceComponent; +class ConstFilterComponent; +class ConstSinkComponent; + +class ConstComponent final : public BorrowedObject +{ +private: + using typename BorrowedObject::_ThisBorrowedObject; + +public: + using Shared = + SharedObject; + + explicit ConstComponent(const bt_component * const libObjPtr) noexcept : + _ThisBorrowedObject {libObjPtr} + { + } + + explicit ConstComponent(const bt_component_source * const libObjPtr) noexcept : + _ThisBorrowedObject {bt_component_source_as_component_const(libObjPtr)} + { + } + + explicit ConstComponent(const bt_component_filter * const libObjPtr) noexcept : + _ThisBorrowedObject {bt_component_filter_as_component_const(libObjPtr)} + { + } + + explicit ConstComponent(const bt_component_sink * const libObjPtr) noexcept : + _ThisBorrowedObject {bt_component_sink_as_component_const(libObjPtr)} + { + } + + /* Not `explicit` to make them behave like copy constructors */ + ConstComponent(ConstSourceComponent other) noexcept; + ConstComponent(ConstFilterComponent other) noexcept; + ConstComponent(ConstSinkComponent other) noexcept; + + ConstComponent operator=(ConstSourceComponent other) noexcept; + ConstComponent operator=(ConstFilterComponent other) noexcept; + ConstComponent operator=(ConstSinkComponent other) noexcept; + + bool isSource() const noexcept + { + return static_cast(bt_component_is_source(this->libObjPtr())); + } + + bool isFilter() const noexcept + { + return static_cast(bt_component_is_filter(this->libObjPtr())); + } + + bool isSink() const noexcept + { + return static_cast(bt_component_is_sink(this->libObjPtr())); + } + + bt2c::CStringView name() const noexcept + { + return bt_component_get_name(this->libObjPtr()); + } + + LoggingLevel loggingLevel() const noexcept + { + return static_cast(bt_component_get_logging_level(this->libObjPtr())); + } + + Shared shared() const noexcept + { + return Shared::createWithRef(*this); + } +}; + +template +class ConstSpecificComponent : public BorrowedObject +{ +public: + using typename BorrowedObject::LibObjPtr; + +protected: + explicit ConstSpecificComponent(const LibObjPtr libObjPtr) noexcept : + BorrowedObject {libObjPtr} + { + } + +public: + bt2c::CStringView name() const noexcept + { + return this->_constComponent().name(); + } + + LoggingLevel loggingLevel() const noexcept + { + return this->_constComponent().loggingLevel(); + } + + ConstComponent::Shared sharedComponent() const noexcept + { + return this->_constComponent().shared(); + } + +private: + ConstComponent _constComponent() const noexcept + { + return ConstComponent {this->libObjPtr()}; + } +}; + +namespace internal { + +template +struct ConstComponentPortsSpec; + +template <> +struct ConstComponentPortsSpec final +{ + static std::uint64_t portCount(const bt_component_source * const libCompPtr) noexcept + { + return bt_component_source_get_output_port_count(libCompPtr); + } + + static const bt_port_output *portByIndex(const bt_component_source * const libCompPtr, + const std::uint64_t index) noexcept + { + return bt_component_source_borrow_output_port_by_index_const(libCompPtr, index); + } + + static const bt_port_output *portByName(const bt_component_source * const libCompPtr, + const char * const name) noexcept + { + return bt_component_source_borrow_output_port_by_name_const(libCompPtr, name); + } +}; + +template <> +struct ConstComponentPortsSpec final +{ + static std::uint64_t portCount(const bt_component_filter * const libCompPtr) noexcept + { + return bt_component_filter_get_output_port_count(libCompPtr); + } + + static const bt_port_output *portByIndex(const bt_component_filter * const libCompPtr, + const std::uint64_t index) noexcept + { + return bt_component_filter_borrow_output_port_by_index_const(libCompPtr, index); + } + + static const bt_port_output *portByName(const bt_component_filter * const libCompPtr, + const char * const name) noexcept + { + return bt_component_filter_borrow_output_port_by_name_const(libCompPtr, name); + } +}; + +template <> +struct ConstComponentPortsSpec final +{ + static std::uint64_t portCount(const bt_component_filter * const libCompPtr) noexcept + { + return bt_component_filter_get_input_port_count(libCompPtr); + } + + static const bt_port_input *portByIndex(const bt_component_filter * const libCompPtr, + const std::uint64_t index) noexcept + { + return bt_component_filter_borrow_input_port_by_index_const(libCompPtr, index); + } + + static const bt_port_input *portByName(const bt_component_filter * const libCompPtr, + const char * const name) noexcept + { + return bt_component_filter_borrow_input_port_by_name_const(libCompPtr, name); + } +}; + +template <> +struct ConstComponentPortsSpec final +{ + static std::uint64_t portCount(const bt_component_sink * const libCompPtr) noexcept + { + return bt_component_sink_get_input_port_count(libCompPtr); + } + + static const bt_port_input *portByIndex(const bt_component_sink * const libCompPtr, + const std::uint64_t index) noexcept + { + return bt_component_sink_borrow_input_port_by_index_const(libCompPtr, index); + } + + static const bt_port_input *portByName(const bt_component_sink * const libCompPtr, + const char * const name) noexcept + { + return bt_component_sink_borrow_input_port_by_name_const(libCompPtr, name); + } +}; + +} /* namespace internal */ + +template +class ConstPort; + +template +class ConstComponentPorts final : public BorrowedObject +{ +private: + using _Spec = internal::ConstComponentPortsSpec; + +public: + using typename BorrowedObject::LibObjPtr; + using Port = ConstPort; + using Iterator = BorrowedObjectIterator; + + explicit ConstComponentPorts(const LibObjPtr libObjPtr) noexcept : + BorrowedObject {libObjPtr} + { + } + + std::uint64_t length() const noexcept + { + return _Spec::portCount(this->libObjPtr()); + } + + Port operator[](std::uint64_t index) const noexcept; + OptionalBorrowedObject operator[](bt2c::CStringView name) const noexcept; + Iterator begin() const noexcept; + Iterator end() const noexcept; +}; + +namespace internal { + +struct ConstSourceComponentRefFuncs final +{ + static void get(const bt_component_source * const libObjPtr) noexcept + { + bt_component_source_get_ref(libObjPtr); + } + + static void put(const bt_component_source * const libObjPtr) noexcept + { + bt_component_source_put_ref(libObjPtr); + } +}; + +} /* namespace internal */ + +class ConstSourceComponent final : public ConstSpecificComponent +{ +public: + using Shared = SharedObject; + + using OutputPorts = ConstComponentPorts; + + explicit ConstSourceComponent(const bt_component_source * const libObjPtr) noexcept : + ConstSpecificComponent {libObjPtr} + { + } + + OutputPorts outputPorts() const noexcept; + + Shared shared() const noexcept + { + return Shared::createWithRef(*this); + } +}; + +namespace internal { + +struct ConstFilterComponentRefFuncs final +{ + static void get(const bt_component_filter * const libObjPtr) noexcept + { + bt_component_filter_get_ref(libObjPtr); + } + + static void put(const bt_component_filter * const libObjPtr) noexcept + { + bt_component_filter_put_ref(libObjPtr); + } +}; + +} /* namespace internal */ + +class ConstFilterComponent final : public ConstSpecificComponent +{ +public: + using Shared = SharedObject; + + using InputPorts = ConstComponentPorts; + using OutputPorts = ConstComponentPorts; + + explicit ConstFilterComponent(const bt_component_filter * const libObjPtr) noexcept : + ConstSpecificComponent {libObjPtr} + { + } + + InputPorts inputPorts() const noexcept; + OutputPorts outputPorts() const noexcept; + + Shared shared() const noexcept + { + return Shared::createWithRef(*this); + } +}; + +namespace internal { + +struct ConstSinkComponentRefFuncs final +{ + static void get(const bt_component_sink * const libObjPtr) noexcept + { + bt_component_sink_get_ref(libObjPtr); + } + + static void put(const bt_component_sink * const libObjPtr) noexcept + { + bt_component_sink_put_ref(libObjPtr); + } +}; + +} /* namespace internal */ + +class ConstSinkComponent final : public ConstSpecificComponent +{ +public: + using Shared = SharedObject; + + using InputPorts = ConstComponentPorts; + + explicit ConstSinkComponent(const bt_component_sink * const libObjPtr) noexcept : + ConstSpecificComponent {libObjPtr} + { + } + + InputPorts inputPorts() const noexcept; + + Shared shared() const noexcept + { + return Shared::createWithRef(*this); + } +}; + +inline ConstComponent::ConstComponent(const ConstSourceComponent other) noexcept : + ConstComponent {other.libObjPtr()} +{ +} + +inline ConstComponent::ConstComponent(const ConstFilterComponent other) noexcept : + ConstComponent {other.libObjPtr()} +{ +} + +inline ConstComponent::ConstComponent(const ConstSinkComponent other) noexcept : + ConstComponent {other.libObjPtr()} +{ +} + +inline ConstComponent ConstComponent::operator=(const ConstSourceComponent other) noexcept +{ + *this = ConstComponent {other.libObjPtr()}; + return *this; +} + +inline ConstComponent ConstComponent::operator=(const ConstFilterComponent other) noexcept +{ + *this = ConstComponent {other.libObjPtr()}; + return *this; +} + +inline ConstComponent ConstComponent::operator=(const ConstSinkComponent other) noexcept +{ + *this = ConstComponent {other.libObjPtr()}; + return *this; +} + +namespace internal { + +template +struct ConstPortSpec; + +/* Functions specific to constant input ports */ +template <> +struct ConstPortSpec final +{ + static const bt_port *asPort(const bt_port_input * const libObjPtr) noexcept + { + return bt_port_input_as_port_const(libObjPtr); + } +}; + +/* Functions specific to constant output ports */ +template <> +struct ConstPortSpec final +{ + static const bt_port *asPort(const bt_port_output * const libObjPtr) noexcept + { + return bt_port_output_as_port_const(libObjPtr); + } +}; + +template +struct ConstPortRefFuncs final +{ + static void get(LibObjT * const libObjPtr) noexcept + { + bt_port_get_ref(ConstPortSpec::port(libObjPtr)); + } + + static void put(LibObjT * const libObjPtr) noexcept + { + bt_port_put_ref(ConstPortSpec::port(libObjPtr)); + } +}; + +} /* namespace internal */ + +template +class ConstPort final : public BorrowedObject +{ +public: + using typename BorrowedObject::LibObjPtr; + using Shared = SharedObject>; + + explicit ConstPort(const LibObjPtr libObjPtr) noexcept : BorrowedObject {libObjPtr} + { + } + + bt2c::CStringView name() const noexcept + { + return bt_port_get_name(this->_libConstPortPtr()); + } + + bool isConnected() const noexcept + { + return static_cast(bt_port_is_connected(this->_libConstPortPtr())); + } + + ConstComponent component() const noexcept + { + return ConstComponent {bt_port_borrow_component_const(this->_libConstPortPtr())}; + } + + Shared shared() const noexcept + { + return Shared::createWithRef(*this); + } + +private: + const bt_port *_libConstPortPtr() const noexcept + { + return internal::ConstPortSpec::asPort(this->libObjPtr()); + } +}; + +template +typename ConstComponentPorts::Port +ConstComponentPorts::operator[](const std::uint64_t index) const noexcept +{ + return Port {_Spec::portByIndex(this->libObjPtr(), index)}; +} + +template +OptionalBorrowedObject::Port> +ConstComponentPorts::operator[](const bt2c::CStringView name) const noexcept +{ + return _Spec::portByName(this->libObjPtr(), name); +} + +template +typename ConstComponentPorts::Iterator +ConstComponentPorts::begin() const noexcept +{ + return Iterator {*this, 0}; +} + +template +typename ConstComponentPorts::Iterator +ConstComponentPorts::end() const noexcept +{ + return Iterator {*this, this->length()}; +} + +using ConstInputPort = ConstPort; +using ConstOutputPort = ConstPort; + +inline ConstSourceComponent::OutputPorts ConstSourceComponent::outputPorts() const noexcept +{ + return OutputPorts {this->libObjPtr()}; +} + +inline ConstFilterComponent::OutputPorts ConstFilterComponent::outputPorts() const noexcept +{ + return OutputPorts {this->libObjPtr()}; +} + +inline ConstFilterComponent::InputPorts ConstFilterComponent::inputPorts() const noexcept +{ + return InputPorts {this->libObjPtr()}; +} + +inline ConstSinkComponent::InputPorts ConstSinkComponent::inputPorts() const noexcept +{ + return InputPorts {this->libObjPtr()}; +} + +} /* namespace bt2 */ + +#endif /* BABELTRACE_CPP_COMMON_BT2_COMPONENT_PORT_HPP */ diff --git a/src/cpp-common/bt2/error.hpp b/src/cpp-common/bt2/error.hpp new file mode 100644 index 00000000..d4dfeaac --- /dev/null +++ b/src/cpp-common/bt2/error.hpp @@ -0,0 +1,339 @@ +/* + * Copyright (c) 2024 EfficiOS Inc. + * + * SPDX-License-Identifier: MIT + */ + +#ifndef BABELTRACE_CPP_COMMON_BT2_ERROR_HPP +#define BABELTRACE_CPP_COMMON_BT2_ERROR_HPP + +#include +#include + +#include + +#include "common/assert.h" +#include "cpp-common/bt2c/c-string-view.hpp" +#include "cpp-common/vendor/fmt/format.h" /* IWYU pragma: keep */ + +#include "borrowed-object.hpp" +#include "component-class.hpp" + +namespace bt2 { + +class ConstComponentClassErrorCause; +class ConstComponentErrorCause; +class ConstMessageIteratorErrorCause; + +enum class ErrorCauseActorType +{ + Unknown = BT_ERROR_CAUSE_ACTOR_TYPE_UNKNOWN, + Component = BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT, + ComponentClass = BT_ERROR_CAUSE_ACTOR_TYPE_COMPONENT_CLASS, + MessageIterator = BT_ERROR_CAUSE_ACTOR_TYPE_MESSAGE_ITERATOR, +}; + +class ConstErrorCause : public BorrowedObject +{ +public: + explicit ConstErrorCause(const LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr} + { + } + + ErrorCauseActorType actorType() const noexcept + { + return static_cast(bt_error_cause_get_actor_type(this->libObjPtr())); + } + + bool actorTypeIsComponentClass() const noexcept + { + return this->actorType() == ErrorCauseActorType::ComponentClass; + } + + bool actorTypeIsComponent() const noexcept + { + return this->actorType() == ErrorCauseActorType::Component; + } + + bool actorTypeIsMessageIterator() const noexcept + { + return this->actorType() == ErrorCauseActorType::MessageIterator; + } + + ConstComponentClassErrorCause asComponentClass() const noexcept; + ConstComponentErrorCause asComponent() const noexcept; + ConstMessageIteratorErrorCause asMessageIterator() const noexcept; + + bt2c::CStringView message() const noexcept + { + return bt_error_cause_get_message(this->libObjPtr()); + } + + bt2c::CStringView moduleName() const noexcept + { + return bt_error_cause_get_module_name(this->libObjPtr()); + } + + bt2c::CStringView fileName() const noexcept + { + return bt_error_cause_get_file_name(this->libObjPtr()); + } + + std::uint64_t lineNumber() const noexcept + { + return bt_error_cause_get_line_number(this->libObjPtr()); + } +}; + +class ConstComponentClassErrorCause final : public ConstErrorCause +{ +public: + explicit ConstComponentClassErrorCause(const LibObjPtr libObjPtr) : ConstErrorCause {libObjPtr} + { + BT_ASSERT(this->actorTypeIsComponentClass()); + } + + bt2::ComponentClassType componentClassType() const noexcept + { + return static_cast( + bt_error_cause_component_class_actor_get_component_class_type(this->libObjPtr())); + } + + bt2c::CStringView componentClassName() const noexcept + { + return bt_error_cause_component_class_actor_get_component_class_name(this->libObjPtr()); + } + + bt2c::CStringView pluginName() const noexcept + { + return bt_error_cause_component_class_actor_get_plugin_name(this->libObjPtr()); + } +}; + +inline ConstComponentClassErrorCause ConstErrorCause::asComponentClass() const noexcept +{ + return ConstComponentClassErrorCause {this->libObjPtr()}; +} + +class ConstComponentErrorCause final : public ConstErrorCause +{ +public: + explicit ConstComponentErrorCause(const LibObjPtr libObjPtr) : ConstErrorCause {libObjPtr} + { + BT_ASSERT(this->actorTypeIsComponent()); + } + + bt2c::CStringView componentName() const noexcept + { + return bt_error_cause_component_actor_get_component_name(this->libObjPtr()); + } + + bt2::ComponentClassType componentClassType() const noexcept + { + return static_cast( + bt_error_cause_component_actor_get_component_class_type(this->libObjPtr())); + } + + bt2c::CStringView componentClassName() const noexcept + { + return bt_error_cause_component_actor_get_component_class_name(this->libObjPtr()); + } + + bt2c::CStringView pluginName() const noexcept + { + return bt_error_cause_component_actor_get_plugin_name(this->libObjPtr()); + } +}; + +inline ConstComponentErrorCause ConstErrorCause::asComponent() const noexcept +{ + return ConstComponentErrorCause {this->libObjPtr()}; +} + +class ConstMessageIteratorErrorCause final : public ConstErrorCause +{ +public: + explicit ConstMessageIteratorErrorCause(const LibObjPtr libObjPtr) : ConstErrorCause {libObjPtr} + { + BT_ASSERT(this->actorTypeIsMessageIterator()); + } + + bt2c::CStringView componentOutputPortName() const noexcept + { + return bt_error_cause_message_iterator_actor_get_component_name(this->libObjPtr()); + } + + bt2c::CStringView componentName() const noexcept + { + return bt_error_cause_message_iterator_actor_get_component_name(this->libObjPtr()); + } + + bt2::ComponentClassType componentClassType() const noexcept + { + return static_cast( + bt_error_cause_message_iterator_actor_get_component_class_type(this->libObjPtr())); + } + + bt2c::CStringView componentClassName() const noexcept + { + return bt_error_cause_message_iterator_actor_get_component_class_name(this->libObjPtr()); + } + + bt2c::CStringView pluginName() const noexcept + { + return bt_error_cause_message_iterator_actor_get_plugin_name(this->libObjPtr()); + } +}; + +inline ConstMessageIteratorErrorCause ConstErrorCause::asMessageIterator() const noexcept +{ + return ConstMessageIteratorErrorCause {this->libObjPtr()}; +} + +class ConstErrorIterator; + +class ConstErrorCauseProxy final +{ + friend ConstErrorIterator; + +private: + explicit ConstErrorCauseProxy(const ConstErrorCause cause) noexcept : _mCause {cause} + { + } + +public: + const ConstErrorCause *operator->() const noexcept + { + return &_mCause; + } + +private: + ConstErrorCause _mCause; +}; + +class UniqueConstError; + +class ConstErrorIterator final +{ + friend UniqueConstError; + +private: + explicit ConstErrorIterator(const UniqueConstError& error, const std::uint64_t index) noexcept : + _mError {&error}, _mIndex {index} + { + } + +public: + bool operator==(const ConstErrorIterator& other) const noexcept + { + BT_ASSERT(&other._mError == &_mError); + return other._mIndex == _mIndex; + } + + bool operator!=(const ConstErrorIterator& other) const noexcept + { + return !(*this == other); + } + + ConstErrorIterator& operator++() noexcept + { + ++_mIndex; + return *this; + } + + ConstErrorIterator operator++(int) noexcept + { + const auto ret = *this; + + ++_mIndex; + return ret; + } + + ConstErrorCause operator*() const noexcept; + + ConstErrorCauseProxy operator->() const noexcept + { + return ConstErrorCauseProxy {**this}; + } + +private: + const UniqueConstError *_mError; + std::uint64_t _mIndex; +}; + +class UniqueConstError final +{ +public: + using LibObjPtr = const bt_error *; + + explicit UniqueConstError(const LibObjPtr libError) noexcept : _mLibError {libError} + { + } + + explicit operator bool() const noexcept + { + return this->libObjPtr(); + } + + LibObjPtr libObjPtr() const noexcept + { + return _mLibError.get(); + } + + LibObjPtr release() noexcept + { + return _mLibError.release(); + } + + std::uint64_t length() const noexcept + { + return bt_error_get_cause_count(this->libObjPtr()); + } + + ConstErrorCause operator[](const std::uint64_t index) const noexcept + { + return ConstErrorCause {bt_error_borrow_cause_by_index(this->libObjPtr(), index)}; + } + + ConstErrorIterator begin() const noexcept + { + BT_ASSERT(_mLibError); + return ConstErrorIterator {*this, 0}; + } + + ConstErrorIterator end() const noexcept + { + BT_ASSERT(_mLibError); + return ConstErrorIterator {*this, this->length()}; + } + +private: + struct _LibErrorDeleter final + { + void operator()(const LibObjPtr libError) const noexcept + { + bt_error_release(libError); + } + }; + + std::unique_ptr::type, _LibErrorDeleter> _mLibError; +}; + +inline ConstErrorCause ConstErrorIterator::operator*() const noexcept +{ + return (*_mError)[_mIndex]; +} + +inline UniqueConstError takeCurrentThreadError() noexcept +{ + return UniqueConstError {bt_current_thread_take_error()}; +} + +inline void moveErrorToCurrentThread(UniqueConstError error) noexcept +{ + bt_current_thread_move_error(error.release()); +} + +} /* namespace bt2 */ + +#endif /* BABELTRACE_CPP_COMMON_BT2_ERROR_HPP */ diff --git a/src/cpp-common/bt2/exc.hpp b/src/cpp-common/bt2/exc.hpp new file mode 100644 index 00000000..126d35a4 --- /dev/null +++ b/src/cpp-common/bt2/exc.hpp @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2020-2022 Philippe Proulx + * + * SPDX-License-Identifier: MIT + */ + +#ifndef BABELTRACE_CPP_COMMON_BT2_EXC_HPP +#define BABELTRACE_CPP_COMMON_BT2_EXC_HPP + +#include "cpp-common/bt2c/exc.hpp" + +namespace bt2 { + +using Error = bt2c::Error; +using OverflowError = bt2c::OverflowError; +using MemoryError = bt2c::MemoryError; +using TryAgain = bt2c::TryAgain; + +/* + * Unknown query object. + */ +class UnknownObject : public std::exception +{ +public: + explicit UnknownObject() noexcept = default; +}; + +} /* namespace bt2 */ + +#endif /* BABELTRACE_CPP_COMMON_BT2_EXC_HPP */ diff --git a/src/cpp-common/bt2/field-class.hpp b/src/cpp-common/bt2/field-class.hpp index 787a8cb3..83cd5215 100644 --- a/src/cpp-common/bt2/field-class.hpp +++ b/src/cpp-common/bt2/field-class.hpp @@ -7,43 +7,45 @@ #ifndef BABELTRACE_CPP_COMMON_BT2_FIELD_CLASS_HPP #define BABELTRACE_CPP_COMMON_BT2_FIELD_CLASS_HPP -#include #include +#include + #include #include "common/assert.h" -#include "internal/borrowed-obj.hpp" -#include "internal/shared-obj.hpp" -#include "cpp-common/optional.hpp" -#include "cpp-common/string_view.hpp" -#include "lib-error.hpp" -#include "integer-range-set.hpp" +#include "cpp-common/bt2c/c-string-view.hpp" +#include "cpp-common/bt2s/optional.hpp" + +#include "borrowed-object-iterator.hpp" +#include "borrowed-object.hpp" +#include "exc.hpp" #include "field-path.hpp" +#include "integer-range-set.hpp" +#include "internal/utils.hpp" +#include "optional-borrowed-object.hpp" +#include "shared-object.hpp" +#include "value.hpp" namespace bt2 { - namespace internal { struct FieldClassRefFuncs final { - static void get(const bt_field_class * const libObjPtr) + static void get(const bt_field_class * const libObjPtr) noexcept { bt_field_class_get_ref(libObjPtr); } - static void put(const bt_field_class * const libObjPtr) + static void put(const bt_field_class * const libObjPtr) noexcept { bt_field_class_put_ref(libObjPtr); } }; -template -using SharedFieldClass = internal::SharedObj; - template struct CommonFieldClassSpec; -// Functions specific to mutable field classes +/* Functions specific to mutable field classes */ template <> struct CommonFieldClassSpec final { @@ -53,7 +55,7 @@ struct CommonFieldClassSpec final } }; -// Functions specific to constant field classes +/* Functions specific to constant field classes */ template <> struct CommonFieldClassSpec final { @@ -63,7 +65,10 @@ struct CommonFieldClassSpec final } }; -} // namespace internal +} /* namespace internal */ + +template +using SharedFieldClass = SharedObject; template class CommonBitArrayFieldClass; @@ -74,6 +79,9 @@ class CommonIntegerFieldClass; template class ConstEnumerationFieldClassMapping; +template +class CommonBaseEnumerationFieldClass; + template class CommonEnumerationFieldClass; @@ -107,6 +115,9 @@ class CommonOptionWithIntegerSelectorFieldClass; template class CommonVariantWithoutSelectorFieldClass; +template +class CommonVariantWithSelectorFieldClass; + template class ConstVariantWithIntegerSelectorFieldClassOption; @@ -124,90 +135,69 @@ class CommonTraceClass; enum class FieldClassType { - BOOL = BT_FIELD_CLASS_TYPE_BOOL, - BIT_ARRAY = BT_FIELD_CLASS_TYPE_BIT_ARRAY, - UNSIGNED_INTEGER = BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER, - SIGNED_INTEGER = BT_FIELD_CLASS_TYPE_SIGNED_INTEGER, - UNSIGNED_ENUMERATION = BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION, - SIGNED_ENUMERATION = BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, - SINGLE_PRECISION_REAL = BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL, - DOUBLE_PRECISION_REAL = BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL, - STRING = BT_FIELD_CLASS_TYPE_STRING, - STRUCTURE = BT_FIELD_CLASS_TYPE_STRUCTURE, - STATIC_ARRAY = BT_FIELD_CLASS_TYPE_STATIC_ARRAY, - DYNAMIC_ARRAY_WITHOUT_LENGTH = BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD, - DYNAMIC_ARRAY_WITH_LENGTH = BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD, - OPTION_WITHOUT_SELECTOR = BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD, - OPTION_WITH_BOOL_SELECTOR = BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD, - OPTION_WITH_UNSIGNED_INTEGER_SELECTOR = + Bool = BT_FIELD_CLASS_TYPE_BOOL, + BitArray = BT_FIELD_CLASS_TYPE_BIT_ARRAY, + UnsignedInteger = BT_FIELD_CLASS_TYPE_UNSIGNED_INTEGER, + SignedInteger = BT_FIELD_CLASS_TYPE_SIGNED_INTEGER, + UnsignedEnumeration = BT_FIELD_CLASS_TYPE_UNSIGNED_ENUMERATION, + SignedEnumeration = BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION, + SinglePrecisionReal = BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL, + DoublePrecisionReal = BT_FIELD_CLASS_TYPE_DOUBLE_PRECISION_REAL, + String = BT_FIELD_CLASS_TYPE_STRING, + Structure = BT_FIELD_CLASS_TYPE_STRUCTURE, + StaticArray = BT_FIELD_CLASS_TYPE_STATIC_ARRAY, + DynamicArrayWithoutLength = BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITHOUT_LENGTH_FIELD, + DynamicArrayWithLength = BT_FIELD_CLASS_TYPE_DYNAMIC_ARRAY_WITH_LENGTH_FIELD, + OptionWithoutSelector = BT_FIELD_CLASS_TYPE_OPTION_WITHOUT_SELECTOR_FIELD, + OptionWithBoolSelector = BT_FIELD_CLASS_TYPE_OPTION_WITH_BOOL_SELECTOR_FIELD, + OptionWithUnsignedIntegerSelector = BT_FIELD_CLASS_TYPE_OPTION_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD, - OPTION_WITH_SIGNED_INTEGER_SELECTOR = - BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD, - VARIANT_WITHOUT_SELECTOR = BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD, - VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR = + OptionWithSignedIntegerSelector = BT_FIELD_CLASS_TYPE_OPTION_WITH_SIGNED_INTEGER_SELECTOR_FIELD, + VariantWithoutSelector = BT_FIELD_CLASS_TYPE_VARIANT_WITHOUT_SELECTOR_FIELD, + VariantWithUnsignedIntegerSelector = BT_FIELD_CLASS_TYPE_VARIANT_WITH_UNSIGNED_INTEGER_SELECTOR_FIELD, - VARIANT_WITH_SIGNED_INTEGER_SELECTOR = + VariantWithSignedIntegerSelector = BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD, }; template -class CommonFieldClass : public internal::BorrowedObj +class CommonFieldClass : public BorrowedObject { - // Allow appendMember() to call `fc._libObjPtr()` - friend class CommonStructureFieldClass; - - // Allow appendOption() to call `fc._libObjPtr()` - friend class CommonVariantWithoutSelectorFieldClass; - - friend class CommonVariantWithIntegerSelectorFieldClass< - bt_field_class, - ConstVariantWithIntegerSelectorFieldClassOption< - const bt_field_class_variant_with_selector_field_integer_unsigned_option>>; - - friend class CommonVariantWithIntegerSelectorFieldClass< - bt_field_class, - ConstVariantWithIntegerSelectorFieldClassOption< - const bt_field_class_variant_with_selector_field_integer_signed_option>>; - - // Allow *FieldClass() to call `fc._libObjPtr()` - friend class CommonEventClass; - friend class CommonStreamClass; - - // Allow create*FieldClass() to call `fc._libObjPtr()` - friend class CommonTraceClass; - private: - using typename internal::BorrowedObj::_ThisBorrowedObj; + using typename BorrowedObject::_ThisBorrowedObject; protected: - using typename internal::BorrowedObj::_LibObjPtr; using _ThisCommonFieldClass = CommonFieldClass; public: - using Shared = internal::SharedFieldClass, LibObjT>; - - using UserAttributes = - typename std::conditional::value, ConstMapValue, MapValue>::type; + using typename BorrowedObject::LibObjPtr; + using Shared = SharedFieldClass, LibObjT>; + using UserAttributes = internal::DepUserAttrs; - explicit CommonFieldClass(const _LibObjPtr libObjPtr) noexcept : _ThisBorrowedObj {libObjPtr} + explicit CommonFieldClass(const LibObjPtr libObjPtr) noexcept : _ThisBorrowedObject {libObjPtr} { } template - CommonFieldClass(const CommonFieldClass& fc) noexcept : _ThisBorrowedObj {fc} + CommonFieldClass(const CommonFieldClass fc) noexcept : _ThisBorrowedObject {fc} { } template - _ThisCommonFieldClass& operator=(const CommonFieldClass& fc) noexcept + CommonFieldClass operator=(const CommonFieldClass fc) noexcept { - _ThisBorrowedObj::operator=(fc); + _ThisBorrowedObject::operator=(fc); return *this; } + CommonFieldClass asConst() const noexcept + { + return CommonFieldClass {*this}; + } + FieldClassType type() const noexcept { - return static_cast(bt_field_class_get_type(this->_libObjPtr())); + return static_cast(bt_field_class_get_type(this->libObjPtr())); } bool isBool() const noexcept @@ -250,6 +240,11 @@ public: return this->_libTypeIs(BT_FIELD_CLASS_TYPE_SIGNED_ENUMERATION); } + bool isReal() const noexcept + { + return this->_libTypeIs(BT_FIELD_CLASS_TYPE_REAL); + } + bool isSinglePrecisionReal() const noexcept { return this->_libTypeIs(BT_FIELD_CLASS_TYPE_SINGLE_PRECISION_REAL); @@ -360,9 +355,15 @@ public: return this->_libTypeIs(BT_FIELD_CLASS_TYPE_VARIANT_WITH_SIGNED_INTEGER_SELECTOR_FIELD); } + template + FieldClassT as() const noexcept + { + return FieldClassT {this->libObjPtr()}; + } + CommonBitArrayFieldClass asBitArray() const noexcept; CommonIntegerFieldClass asInteger() const noexcept; - + CommonBaseEnumerationFieldClass asEnumeration() const noexcept; CommonEnumerationFieldClass> asUnsignedEnumeration() const noexcept; @@ -387,6 +388,7 @@ public: CommonVariantFieldClass asVariant() const noexcept; CommonVariantWithoutSelectorFieldClass asVariantWithoutSelector() const noexcept; + CommonVariantWithSelectorFieldClass asVariantWithSelector() const noexcept; CommonVariantWithIntegerSelectorFieldClass< LibObjT, ConstVariantWithIntegerSelectorFieldClassOption< @@ -399,90 +401,130 @@ public: asVariantWithSignedIntegerSelector() const noexcept; template - void userAttributes(const CommonMapValue& userAttrs) + CommonFieldClass userAttributes(const CommonMapValue userAttrs) const noexcept { - static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); + static_assert(!std::is_const::value, "Not available with `bt2::ConstFieldClass`."); - bt_field_class_set_user_attributes(this->_libObjPtr(), userAttrs._libObjPtr()); - } - - ConstMapValue userAttributes() const noexcept - { - return ConstMapValue {internal::CommonFieldClassSpec::userAttributes( - this->_libObjPtr())}; + bt_field_class_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr()); + return *this; } - UserAttributes userAttributes() noexcept + UserAttributes userAttributes() const noexcept { return UserAttributes { - internal::CommonFieldClassSpec::userAttributes(this->_libObjPtr())}; + internal::CommonFieldClassSpec::userAttributes(this->libObjPtr())}; } Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } protected: bool _libTypeIs(const bt_field_class_type type) const noexcept { - return bt_field_class_type_is(bt_field_class_get_type(this->_libObjPtr()), type); + return bt_field_class_type_is(bt_field_class_get_type(this->libObjPtr()), type); } }; using FieldClass = CommonFieldClass; using ConstFieldClass = CommonFieldClass; +namespace internal { + +struct FieldClassTypeDescr +{ + using Const = ConstFieldClass; + using NonConst = FieldClass; +}; + +template <> +struct TypeDescr : public FieldClassTypeDescr +{ +}; + +template <> +struct TypeDescr : public FieldClassTypeDescr +{ +}; + +} /* namespace internal */ + template class CommonBitArrayFieldClass final : public CommonFieldClass { private: - using typename CommonFieldClass::_LibObjPtr; using typename CommonFieldClass::_ThisCommonFieldClass; public: - using Shared = internal::SharedFieldClass, LibObjT>; + using typename CommonFieldClass::LibObjPtr; + using Shared = SharedFieldClass, LibObjT>; - explicit CommonBitArrayFieldClass(const _LibObjPtr libObjPtr) noexcept : + explicit CommonBitArrayFieldClass(const LibObjPtr libObjPtr) noexcept : _ThisCommonFieldClass {libObjPtr} { BT_ASSERT_DBG(this->isBitArray()); } template - CommonBitArrayFieldClass(const CommonBitArrayFieldClass& fc) noexcept : + CommonBitArrayFieldClass(const CommonBitArrayFieldClass fc) noexcept : _ThisCommonFieldClass {fc} { } template - CommonBitArrayFieldClass& - operator=(const CommonBitArrayFieldClass& fc) noexcept + CommonBitArrayFieldClass + operator=(const CommonBitArrayFieldClass fc) noexcept { _ThisCommonFieldClass::operator=(fc); return *this; } + CommonBitArrayFieldClass asConst() const noexcept + { + return CommonBitArrayFieldClass {*this}; + } + std::uint64_t length() const noexcept { - return bt_field_class_bit_array_get_length(this->_libObjPtr()); + return bt_field_class_bit_array_get_length(this->libObjPtr()); } Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; using BitArrayFieldClass = CommonBitArrayFieldClass; using ConstBitArrayFieldClass = CommonBitArrayFieldClass; +namespace internal { + +struct BitArrayFieldClassTypeDescr +{ + using Const = ConstBitArrayFieldClass; + using NonConst = BitArrayFieldClass; +}; + +template <> +struct TypeDescr : public BitArrayFieldClassTypeDescr +{ +}; + +template <> +struct TypeDescr : public BitArrayFieldClassTypeDescr +{ +}; + +} /* namespace internal */ + enum class DisplayBase { - BINARY = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY, - OCTAL = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL, - DECIMAL = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL, - HEXADECIMAL = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL, + Binary = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_BINARY, + Octal = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_OCTAL, + Decimal = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_DECIMAL, + Hexadecimal = BT_FIELD_CLASS_INTEGER_PREFERRED_DISPLAY_BASE_HEXADECIMAL, }; template @@ -492,61 +534,69 @@ private: using typename CommonFieldClass::_ThisCommonFieldClass; protected: - using typename CommonFieldClass::_LibObjPtr; using _ThisCommonIntegerFieldClass = CommonIntegerFieldClass; public: - using Shared = internal::SharedFieldClass, LibObjT>; + using typename CommonFieldClass::LibObjPtr; + using Shared = SharedFieldClass, LibObjT>; - explicit CommonIntegerFieldClass(const _LibObjPtr libObjPtr) noexcept : + explicit CommonIntegerFieldClass(const LibObjPtr libObjPtr) noexcept : _ThisCommonFieldClass {libObjPtr} { BT_ASSERT_DBG(this->isInteger()); } template - CommonIntegerFieldClass(const CommonIntegerFieldClass& fc) noexcept : + CommonIntegerFieldClass(const CommonIntegerFieldClass fc) noexcept : _ThisCommonFieldClass {fc} { } template - _ThisCommonIntegerFieldClass& - operator=(const CommonIntegerFieldClass& fc) noexcept + CommonIntegerFieldClass operator=(const CommonIntegerFieldClass fc) noexcept { _ThisCommonFieldClass::operator=(fc); return *this; } - void fieldValueRange(const std::uint64_t n) noexcept + CommonIntegerFieldClass asConst() const noexcept { - static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); + return CommonIntegerFieldClass {*this}; + } + + CommonIntegerFieldClass fieldValueRange(const std::uint64_t n) const noexcept + { + static_assert(!std::is_const::value, + "Not available with `bt2::ConstIntegerFieldClass`."); - bt_field_class_integer_get_field_value_range(this->_libObjPtr(), n); + bt_field_class_integer_set_field_value_range(this->libObjPtr(), n); + return *this; } std::uint64_t fieldValueRange() const noexcept { - return bt_field_class_integer_get_field_value_range(this->_libObjPtr()); + return bt_field_class_integer_get_field_value_range(this->libObjPtr()); } - void preferredDisplayBase(const DisplayBase base) noexcept + CommonIntegerFieldClass preferredDisplayBase(const DisplayBase base) const noexcept { - static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); + static_assert(!std::is_const::value, + "Not available with `bt2::ConstIntegerFieldClass`."); bt_field_class_integer_set_preferred_display_base( - this->_libObjPtr(), static_cast(base)); + this->libObjPtr(), static_cast(base)); + return *this; } DisplayBase preferredDisplayBase() const noexcept { return static_cast( - bt_field_class_integer_get_preferred_display_base(this->_libObjPtr())); + bt_field_class_integer_get_preferred_display_base(this->libObjPtr())); } Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; @@ -555,10 +605,26 @@ using ConstIntegerFieldClass = CommonIntegerFieldClass; namespace internal { +struct IntegerFieldClassTypeDescr +{ + using Const = ConstIntegerFieldClass; + using NonConst = IntegerFieldClass; +}; + +template <> +struct TypeDescr : public IntegerFieldClassTypeDescr +{ +}; + +template <> +struct TypeDescr : public IntegerFieldClassTypeDescr +{ +}; + template struct ConstEnumerationFieldClassMappingSpec; -// Functions specific to unsigned enumeration field class mappings +/* Functions specific to unsigned enumeration field class mappings */ template <> struct ConstEnumerationFieldClassMappingSpec final @@ -577,7 +643,7 @@ struct ConstEnumerationFieldClassMappingSpec struct ConstEnumerationFieldClassMappingSpec final { @@ -595,48 +661,47 @@ struct ConstEnumerationFieldClassMappingSpec -class ConstEnumerationFieldClassMapping final : public internal::BorrowedObj +class ConstEnumerationFieldClassMapping final : public BorrowedObject { private: - using typename internal::BorrowedObj::_ThisBorrowedObj; - using typename internal::BorrowedObj::_LibObjPtr; - using _ThisConstEnumerationFieldClassMapping = ConstEnumerationFieldClassMapping; + using typename BorrowedObject::_ThisBorrowedObject; public: + using typename BorrowedObject::LibObjPtr; + using RangeSet = typename std::conditional< std::is_same::value, ConstUnsignedIntegerRangeSet, ConstSignedIntegerRangeSet>::type; - explicit ConstEnumerationFieldClassMapping(const _LibObjPtr libObjPtr) noexcept : - _ThisBorrowedObj {libObjPtr} + explicit ConstEnumerationFieldClassMapping(const LibObjPtr libObjPtr) noexcept : + _ThisBorrowedObject {libObjPtr} { } - ConstEnumerationFieldClassMapping( - const _ThisConstEnumerationFieldClassMapping& mapping) noexcept : - _ThisBorrowedObj {mapping} + ConstEnumerationFieldClassMapping(const ConstEnumerationFieldClassMapping& mapping) noexcept : + _ThisBorrowedObject {mapping} { } - _ThisConstEnumerationFieldClassMapping& - operator=(const _ThisConstEnumerationFieldClassMapping& mapping) noexcept + ConstEnumerationFieldClassMapping + operator=(const ConstEnumerationFieldClassMapping& mapping) noexcept { - _ThisBorrowedObj::operator=(mapping); + _ThisBorrowedObject::operator=(mapping); return *this; } RangeSet ranges() const noexcept { return RangeSet { - internal::ConstEnumerationFieldClassMappingSpec::ranges(this->_libObjPtr())}; + internal::ConstEnumerationFieldClassMappingSpec::ranges(this->libObjPtr())}; } - bpstd::string_view label() const noexcept + bt2c::CStringView label() const noexcept { - return internal::ConstEnumerationFieldClassMappingSpec::label(this->_libObjPtr()); + return internal::ConstEnumerationFieldClassMappingSpec::label(this->libObjPtr()); } }; @@ -651,7 +716,7 @@ namespace internal { template struct CommonEnumerationFieldClassSpec; -// Functions specific to unsigned enumeration field classes +/* Functions specific to unsigned enumeration field classes */ template <> struct CommonEnumerationFieldClassSpec final { @@ -666,9 +731,16 @@ struct CommonEnumerationFieldClassSpec struct CommonEnumerationFieldClassSpec final { @@ -683,77 +755,144 @@ struct CommonEnumerationFieldClassSpec { return bt_field_class_enumeration_signed_borrow_mapping_by_label_const(libObjPtr, label); } + + static bt_field_class_enumeration_add_mapping_status + addMapping(bt_field_class * const libObjPtr, const char * const label, + const bt_integer_range_set_signed * const libRanges) noexcept + { + return bt_field_class_enumeration_signed_add_mapping(libObjPtr, label, libRanges); + } }; -} // namespace internal +} /* namespace internal */ -template -class CommonEnumerationFieldClass final : public CommonIntegerFieldClass +template +class CommonBaseEnumerationFieldClass : public CommonIntegerFieldClass { private: - using typename CommonFieldClass::_LibObjPtr; using typename CommonIntegerFieldClass::_ThisCommonIntegerFieldClass; - using _ThisCommonEnumerationFieldClass = CommonEnumerationFieldClass; + +protected: + using _ThisCommonBaseEnumerationFieldClass = CommonBaseEnumerationFieldClass; public: - using Shared = internal::SharedFieldClass<_ThisCommonEnumerationFieldClass, LibObjT>; - using Mapping = MappingT; + using typename CommonFieldClass::LibObjPtr; + using Shared = SharedFieldClass<_ThisCommonBaseEnumerationFieldClass, LibObjT>; - explicit CommonEnumerationFieldClass(const _LibObjPtr libObjPtr) noexcept : + explicit CommonBaseEnumerationFieldClass(const LibObjPtr libObjPtr) noexcept : _ThisCommonIntegerFieldClass {libObjPtr} { BT_ASSERT_DBG(this->isEnumeration()); } template - CommonEnumerationFieldClass( - const CommonEnumerationFieldClass& fc) noexcept : + CommonBaseEnumerationFieldClass(const CommonBaseEnumerationFieldClass fc) noexcept + : _ThisCommonIntegerFieldClass {fc} { } template - _ThisCommonEnumerationFieldClass& - operator=(const CommonEnumerationFieldClass& fc) noexcept + CommonBaseEnumerationFieldClass + operator=(const CommonBaseEnumerationFieldClass fc) noexcept { _ThisCommonIntegerFieldClass::operator=(fc); return *this; } - std::uint64_t size() const noexcept + CommonBaseEnumerationFieldClass asConst() const noexcept + { + return CommonBaseEnumerationFieldClass {*this}; + } + + std::uint64_t length() const noexcept + { + return bt_field_class_enumeration_get_mapping_count(this->libObjPtr()); + } + + Shared shared() const noexcept { - return bt_field_class_enumeration_get_mapping_count(this->_libObjPtr()); + return Shared::createWithRef(*this); + } +}; + +template +class CommonEnumerationFieldClass final : public CommonBaseEnumerationFieldClass +{ +private: + using typename CommonBaseEnumerationFieldClass::_ThisCommonBaseEnumerationFieldClass; + +public: + using typename CommonFieldClass::LibObjPtr; + using Shared = SharedFieldClass; + using Iterator = BorrowedObjectIterator; + using Mapping = MappingT; + + explicit CommonEnumerationFieldClass(const LibObjPtr libObjPtr) noexcept : + _ThisCommonBaseEnumerationFieldClass {libObjPtr} + { + BT_ASSERT_DBG(this->isEnumeration()); + } + + template + CommonEnumerationFieldClass( + const CommonEnumerationFieldClass fc) noexcept : + CommonEnumerationFieldClass {fc} + { + } + + template + CommonEnumerationFieldClass + operator=(const CommonEnumerationFieldClass fc) noexcept + { + CommonEnumerationFieldClass::operator=(fc); + return *this; } Mapping operator[](const std::uint64_t index) const noexcept { return Mapping {internal::CommonEnumerationFieldClassSpec::mappingByIndex( - this->_libObjPtr(), index)}; + this->libObjPtr(), index)}; + } + + OptionalBorrowedObject operator[](const bt2c::CStringView label) const noexcept + { + return internal::CommonEnumerationFieldClassSpec::mappingByLabel( + this->libObjPtr(), label); } - nonstd::optional operator[](const char * const label) const noexcept + CommonEnumerationFieldClass addMapping(const bt2c::CStringView label, + const typename Mapping::RangeSet ranges) const { - const auto libObjPtr = internal::CommonEnumerationFieldClassSpec::mappingByLabel( - this->_libObjPtr(), label); + const auto status = internal::CommonEnumerationFieldClassSpec::addMapping( + this->libObjPtr(), label, ranges.libObjPtr()); - if (libObjPtr) { - return Mapping {libObjPtr}; + if (status == BT_FIELD_CLASS_ENUMERATION_ADD_MAPPING_STATUS_MEMORY_ERROR) { + throw MemoryError {}; } - return nonstd::nullopt; + return *this; + } + + Iterator begin() const noexcept + { + return Iterator {*this, 0}; } - nonstd::optional operator[](const std::string& label) const noexcept + Iterator end() const noexcept { - return (*this)[label.data()]; + return Iterator {*this, this->length()}; } Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; +using EnumerationFieldClass = CommonBaseEnumerationFieldClass; +using ConstEnumerationFieldClass = CommonBaseEnumerationFieldClass; + using UnsignedEnumerationFieldClass = CommonEnumerationFieldClass; @@ -768,10 +907,42 @@ using ConstSignedEnumerationFieldClass = namespace internal { +struct UnsignedEnumerationFieldClassTypeDescr +{ + using Const = ConstUnsignedEnumerationFieldClass; + using NonConst = UnsignedEnumerationFieldClass; +}; + +template <> +struct TypeDescr : public UnsignedEnumerationFieldClassTypeDescr +{ +}; + +template <> +struct TypeDescr : public UnsignedEnumerationFieldClassTypeDescr +{ +}; + +struct SignedEnumerationFieldClassTypeDescr +{ + using Const = ConstSignedEnumerationFieldClass; + using NonConst = SignedEnumerationFieldClass; +}; + +template <> +struct TypeDescr : public SignedEnumerationFieldClassTypeDescr +{ +}; + +template <> +struct TypeDescr : public SignedEnumerationFieldClassTypeDescr +{ +}; + template struct CommonStructureFieldClassMemberSpec; -// Functions specific to mutable structure field class members +/* Functions specific to mutable structure field class members */ template <> struct CommonStructureFieldClassMemberSpec final { @@ -779,9 +950,14 @@ struct CommonStructureFieldClassMemberSpec fina { return bt_field_class_structure_member_borrow_field_class(libObjPtr); } + + static bt_value *userAttributes(bt_field_class_structure_member * const libObjPtr) noexcept + { + return bt_field_class_structure_member_borrow_user_attributes(libObjPtr); + } }; -// Functions specific to constant structure field class members +/* Functions specific to constant structure field class members */ template <> struct CommonStructureFieldClassMemberSpec final { @@ -790,56 +966,80 @@ struct CommonStructureFieldClassMemberSpec -class CommonStructureFieldClassMember final : public internal::BorrowedObj +class CommonStructureFieldClassMember final : public BorrowedObject { private: - using typename internal::BorrowedObj::_LibObjPtr; - using typename internal::BorrowedObj::_ThisBorrowedObj; - - using _FieldClass = - typename std::conditional::value, ConstFieldClass, FieldClass>::type; + using typename BorrowedObject::_ThisBorrowedObject; + using _FieldClass = internal::DepFc; public: - explicit CommonStructureFieldClassMember(const _LibObjPtr libObjPtr) noexcept : - _ThisBorrowedObj {libObjPtr} + using typename BorrowedObject::LibObjPtr; + using UserAttributes = internal::DepUserAttrs; + + explicit CommonStructureFieldClassMember(const LibObjPtr libObjPtr) noexcept : + _ThisBorrowedObject {libObjPtr} { } template - CommonStructureFieldClassMember( - const CommonStructureFieldClassMember& fc) noexcept : - _ThisBorrowedObj {fc} + CommonStructureFieldClassMember(const CommonStructureFieldClassMember fc) noexcept + : + _ThisBorrowedObject {fc} { } template - CommonStructureFieldClassMember& - operator=(const CommonStructureFieldClassMember& fc) noexcept + CommonStructureFieldClassMember + operator=(const CommonStructureFieldClassMember fc) noexcept { - _ThisBorrowedObj::operator=(fc); + _ThisBorrowedObject::operator=(fc); return *this; } - bpstd::string_view name() const noexcept + CommonStructureFieldClassMember asConst() const noexcept { - return bt_field_class_structure_member_get_name(this->_libObjPtr()); + return CommonStructureFieldClassMember {*this}; } - ConstFieldClass fieldClass() const noexcept + bt2c::CStringView name() const noexcept { - return ConstFieldClass {internal::CommonStructureFieldClassMemberSpec< - const bt_field_class_structure_member>::fieldClass(this->_libObjPtr())}; + return bt_field_class_structure_member_get_name(this->libObjPtr()); } - _FieldClass fieldClass() noexcept + _FieldClass fieldClass() const noexcept { return _FieldClass { - internal::CommonStructureFieldClassMemberSpec::fieldClass(this->_libObjPtr())}; + internal::CommonStructureFieldClassMemberSpec::fieldClass(this->libObjPtr())}; + } + + template + CommonStructureFieldClassMember + userAttributes(const CommonMapValue userAttrs) const noexcept + { + static_assert(!std::is_const::value, + "Not available with `bt2::ConstStructureFieldClassMember`."); + + bt_field_class_structure_member_set_user_attributes(this->libObjPtr(), + userAttrs.libObjPtr()); + return *this; + } + + UserAttributes userAttributes() const noexcept + { + return UserAttributes { + internal::CommonStructureFieldClassMemberSpec::userAttributes( + this->libObjPtr())}; } }; @@ -850,10 +1050,26 @@ using ConstStructureFieldClassMember = namespace internal { +struct StructureFieldClassMemberTypeDescr +{ + using Const = ConstStructureFieldClassMember; + using NonConst = StructureFieldClassMember; +}; + +template <> +struct TypeDescr : public StructureFieldClassMemberTypeDescr +{ +}; + +template <> +struct TypeDescr : public StructureFieldClassMemberTypeDescr +{ +}; + template struct CommonStructureFieldClassSpec; -// Functions specific to mutable structure field classes +/* Functions specific to mutable structure field classes */ template <> struct CommonStructureFieldClassSpec final { @@ -870,7 +1086,7 @@ struct CommonStructureFieldClassSpec final } }; -// Functions specific to constant structure field classes +/* Functions specific to constant structure field classes */ template <> struct CommonStructureFieldClassSpec final { @@ -887,117 +1103,91 @@ struct CommonStructureFieldClassSpec final } }; -} // namespace internal +} /* namespace internal */ template class CommonStructureFieldClass final : public CommonFieldClass { private: - using typename CommonFieldClass::_LibObjPtr; using typename CommonFieldClass::_ThisCommonFieldClass; public: - using Shared = internal::SharedFieldClass, LibObjT>; + using typename CommonFieldClass::LibObjPtr; + using Shared = SharedFieldClass, LibObjT>; + using Iterator = BorrowedObjectIterator>; using Member = - typename std::conditional::value, ConstStructureFieldClassMember, - StructureFieldClassMember>::type; + internal::DepType; - explicit CommonStructureFieldClass(const _LibObjPtr libObjPtr) noexcept : + explicit CommonStructureFieldClass(const LibObjPtr libObjPtr) noexcept : _ThisCommonFieldClass {libObjPtr} { BT_ASSERT_DBG(this->isStructure()); } template - CommonStructureFieldClass(const CommonStructureFieldClass& fc) noexcept : + CommonStructureFieldClass(const CommonStructureFieldClass fc) noexcept : _ThisCommonFieldClass {fc} { } template - CommonStructureFieldClass& - operator=(const CommonStructureFieldClass& fc) noexcept + CommonStructureFieldClass operator=(const CommonStructureFieldClass fc) noexcept { _ThisCommonFieldClass::operator=(fc); return *this; } - void appendMember(const char * const name, const FieldClass& fc) + CommonStructureFieldClass asConst() const noexcept + { + return CommonStructureFieldClass {*this}; + } + + CommonStructureFieldClass appendMember(const bt2c::CStringView name, const FieldClass fc) const { - static_assert(!std::is_const::value, "`LibObjT` must NOT be `const`."); + static_assert(!std::is_const::value, + "Not available with `bt2::ConstStructureFieldClass`."); const auto status = - bt_field_class_structure_append_member(this->_libObjPtr(), name, fc._libObjPtr()); + bt_field_class_structure_append_member(this->libObjPtr(), name, fc.libObjPtr()); if (status == BT_FIELD_CLASS_STRUCTURE_APPEND_MEMBER_STATUS_MEMORY_ERROR) { - throw LibMemoryError {}; + throw MemoryError {}; } - } - - void appendMember(const std::string& name, const FieldClass& fc) - { - this->appendMember(name.data(), fc); - } - - std::uint64_t size() const noexcept - { - return bt_field_class_structure_get_member_count(this->_libObjPtr()); - } - ConstStructureFieldClassMember operator[](const std::uint64_t index) const noexcept - { - return ConstStructureFieldClassMember { - internal::CommonStructureFieldClassSpec::memberByIndex( - this->_libObjPtr(), index)}; + return *this; } - Member operator[](const std::uint64_t index) noexcept + std::uint64_t length() const noexcept { - return Member {internal::CommonStructureFieldClassSpec::memberByIndex( - this->_libObjPtr(), index)}; + return bt_field_class_structure_get_member_count(this->libObjPtr()); } - nonstd::optional - operator[](const char * const name) const noexcept + Iterator begin() const noexcept { - const auto libObjPtr = - internal::CommonStructureFieldClassSpec::memberByName( - this->_libObjPtr(), name); - - if (libObjPtr) { - return ConstStructureFieldClassMember {libObjPtr}; - } - - return nonstd::nullopt; + return Iterator {*this, 0}; } - nonstd::optional - operator[](const std::string& name) const noexcept + Iterator end() const noexcept { - return (*this)[name.data()]; + return Iterator {*this, this->length()}; } - nonstd::optional operator[](const char * const name) noexcept + Member operator[](const std::uint64_t index) const noexcept { - const auto libObjPtr = internal::CommonStructureFieldClassSpec::memberByName( - this->_libObjPtr(), name); - - if (libObjPtr) { - return Member {libObjPtr}; - } - - return nonstd::nullopt; + return Member {internal::CommonStructureFieldClassSpec::memberByIndex( + this->libObjPtr(), index)}; } - nonstd::optional operator[](const std::string& name) noexcept + OptionalBorrowedObject operator[](const bt2c::CStringView name) const noexcept { - return (*this)[name.data()]; + return internal::CommonStructureFieldClassSpec::memberByName(this->libObjPtr(), + name); } Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; @@ -1006,10 +1196,26 @@ using ConstStructureFieldClass = CommonStructureFieldClass namespace internal { +struct StructureFieldClassTypeDescr +{ + using Const = ConstStructureFieldClass; + using NonConst = StructureFieldClass; +}; + +template <> +struct TypeDescr : public StructureFieldClassTypeDescr +{ +}; + +template <> +struct TypeDescr : public StructureFieldClassTypeDescr +{ +}; + template struct CommonArrayFieldClassSpec; -// Functions specific to mutable array field classes +/* Functions specific to mutable array field classes */ template <> struct CommonArrayFieldClassSpec final { @@ -1019,7 +1225,7 @@ struct CommonArrayFieldClassSpec final } }; -// Functions specific to constant array field classes +/* Functions specific to constant array field classes */ template <> struct CommonArrayFieldClassSpec final { @@ -1029,121 +1235,161 @@ struct CommonArrayFieldClassSpec final } }; -} // namespace internal +} /* namespace internal */ template class CommonArrayFieldClass : public CommonFieldClass { private: using typename CommonFieldClass::_ThisCommonFieldClass; - - using _FieldClass = - typename std::conditional::value, ConstFieldClass, FieldClass>::type; + using _FieldClass = internal::DepFc; protected: - using typename CommonFieldClass::_LibObjPtr; using _ThisCommonArrayFieldClass = CommonArrayFieldClass; public: - using Shared = internal::SharedFieldClass, LibObjT>; + using typename CommonFieldClass::LibObjPtr; + using Shared = SharedFieldClass, LibObjT>; - explicit CommonArrayFieldClass(const _LibObjPtr libObjPtr) noexcept : + explicit CommonArrayFieldClass(const LibObjPtr libObjPtr) noexcept : _ThisCommonFieldClass {libObjPtr} { BT_ASSERT_DBG(this->isArray()); } template - CommonArrayFieldClass(const CommonArrayFieldClass& fc) noexcept : + CommonArrayFieldClass(const CommonArrayFieldClass fc) noexcept : _ThisCommonFieldClass {fc} { } template - _ThisCommonArrayFieldClass& operator=(const CommonArrayFieldClass& fc) noexcept + CommonArrayFieldClass operator=(const CommonArrayFieldClass fc) noexcept { _ThisCommonFieldClass::operator=(fc); return *this; } - ConstFieldClass elementFieldClass() const noexcept + CommonArrayFieldClass asConst() const noexcept { - return ConstFieldClass { - internal::CommonArrayFieldClassSpec::elementFieldClass( - this->_libObjPtr())}; + return CommonArrayFieldClass {*this}; } - _FieldClass elementFieldClass() noexcept + _FieldClass elementFieldClass() const noexcept { return _FieldClass { - internal::CommonArrayFieldClassSpec::elementFieldClass(this->_libObjPtr())}; + internal::CommonArrayFieldClassSpec::elementFieldClass(this->libObjPtr())}; } Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; using ArrayFieldClass = CommonArrayFieldClass; using ConstArrayFieldClass = CommonArrayFieldClass; +namespace internal { + +struct ArrayFieldClassTypeDescr +{ + using Const = ConstArrayFieldClass; + using NonConst = ArrayFieldClass; +}; + +template <> +struct TypeDescr : public ArrayFieldClassTypeDescr +{ +}; + +template <> +struct TypeDescr : public ArrayFieldClassTypeDescr +{ +}; + +} /* namespace internal */ + template class CommonStaticArrayFieldClass final : public CommonArrayFieldClass { private: using typename CommonArrayFieldClass::_ThisCommonArrayFieldClass; - using typename CommonFieldClass::_LibObjPtr; public: - using Shared = internal::SharedFieldClass, LibObjT>; + using typename CommonFieldClass::LibObjPtr; + using Shared = SharedFieldClass, LibObjT>; - explicit CommonStaticArrayFieldClass(const _LibObjPtr libObjPtr) noexcept : + explicit CommonStaticArrayFieldClass(const LibObjPtr libObjPtr) noexcept : _ThisCommonArrayFieldClass {libObjPtr} { BT_ASSERT_DBG(this->isStaticArray()); } template - CommonStaticArrayFieldClass(const CommonStaticArrayFieldClass& fc) noexcept : + CommonStaticArrayFieldClass(const CommonStaticArrayFieldClass fc) noexcept : _ThisCommonArrayFieldClass {fc} { } template - CommonStaticArrayFieldClass& - operator=(const CommonStaticArrayFieldClass& fc) noexcept + CommonStaticArrayFieldClass + operator=(const CommonStaticArrayFieldClass fc) noexcept { _ThisCommonArrayFieldClass::operator=(fc); return *this; } + CommonStaticArrayFieldClass asConst() const noexcept + { + return CommonStaticArrayFieldClass {*this}; + } + std::uint64_t length() const noexcept { - return bt_field_class_array_static_get_length(this->_libObjPtr()); + return bt_field_class_array_static_get_length(this->libObjPtr()); } Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; using StaticArrayFieldClass = CommonStaticArrayFieldClass; using ConstStaticArrayFieldClass = CommonStaticArrayFieldClass; +namespace internal { + +struct StaticArrayFieldClassTypeDescr +{ + using Const = ConstStaticArrayFieldClass; + using NonConst = StaticArrayFieldClass; +}; + +template <> +struct TypeDescr : public StaticArrayFieldClassTypeDescr +{ +}; + +template <> +struct TypeDescr : public StaticArrayFieldClassTypeDescr +{ +}; + +} /* namespace internal */ + template class CommonDynamicArrayWithLengthFieldClass final : public CommonArrayFieldClass { private: using typename CommonArrayFieldClass::_ThisCommonArrayFieldClass; - using typename CommonFieldClass::_LibObjPtr; public: - using Shared = - internal::SharedFieldClass, LibObjT>; + using typename CommonFieldClass::LibObjPtr; + using Shared = SharedFieldClass, LibObjT>; - explicit CommonDynamicArrayWithLengthFieldClass(const _LibObjPtr libObjPtr) noexcept : + explicit CommonDynamicArrayWithLengthFieldClass(const LibObjPtr libObjPtr) noexcept : _ThisCommonArrayFieldClass {libObjPtr} { BT_ASSERT_DBG(this->isDynamicArrayWithLength()); @@ -1151,29 +1397,34 @@ public: template CommonDynamicArrayWithLengthFieldClass( - const CommonDynamicArrayWithLengthFieldClass& fc) noexcept : + const CommonDynamicArrayWithLengthFieldClass fc) noexcept : _ThisCommonArrayFieldClass {fc} { } template - CommonDynamicArrayWithLengthFieldClass& - operator=(const CommonDynamicArrayWithLengthFieldClass& fc) noexcept + CommonDynamicArrayWithLengthFieldClass + operator=(const CommonDynamicArrayWithLengthFieldClass fc) noexcept { _ThisCommonArrayFieldClass::operator=(fc); return *this; } + CommonDynamicArrayWithLengthFieldClass asConst() const noexcept + { + return CommonDynamicArrayWithLengthFieldClass {*this}; + } + ConstFieldPath lengthFieldPath() const noexcept { return ConstFieldPath { bt_field_class_array_dynamic_with_length_field_borrow_length_field_path_const( - this->_libObjPtr())}; + this->libObjPtr())}; } Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; @@ -1184,10 +1435,28 @@ using ConstDynamicArrayWithLengthFieldClass = namespace internal { +struct DynamicArrayWithLengthFieldClassTypeDescr +{ + using Const = ConstDynamicArrayWithLengthFieldClass; + using NonConst = DynamicArrayWithLengthFieldClass; +}; + +template <> +struct TypeDescr : + public DynamicArrayWithLengthFieldClassTypeDescr +{ +}; + +template <> +struct TypeDescr : + public DynamicArrayWithLengthFieldClassTypeDescr +{ +}; + template struct CommonOptionFieldClassSpec; -// Functions specific to mutable option field classes +/* Functions specific to mutable option field classes */ template <> struct CommonOptionFieldClassSpec final { @@ -1197,7 +1466,7 @@ struct CommonOptionFieldClassSpec final } }; -// Functions specific to constant option field classes +/* Functions specific to constant option field classes */ template <> struct CommonOptionFieldClassSpec final { @@ -1207,65 +1476,81 @@ struct CommonOptionFieldClassSpec final } }; -} // namespace internal +} /* namespace internal */ template class CommonOptionFieldClass : public CommonFieldClass { private: using typename CommonFieldClass::_ThisCommonFieldClass; - - using _FieldClass = - typename std::conditional::value, ConstFieldClass, FieldClass>::type; + using _FieldClass = internal::DepFc; protected: - using typename CommonFieldClass::_LibObjPtr; using _ThisCommonOptionFieldClass = CommonOptionFieldClass; public: - using Shared = internal::SharedFieldClass, LibObjT>; + using typename CommonFieldClass::LibObjPtr; + using Shared = SharedFieldClass, LibObjT>; - explicit CommonOptionFieldClass(const _LibObjPtr libObjPtr) noexcept : + explicit CommonOptionFieldClass(const LibObjPtr libObjPtr) noexcept : _ThisCommonFieldClass {libObjPtr} { BT_ASSERT_DBG(this->isOption()); } template - CommonOptionFieldClass(const CommonOptionFieldClass& fc) noexcept : + CommonOptionFieldClass(const CommonOptionFieldClass fc) noexcept : _ThisCommonFieldClass {fc} { } template - _ThisCommonOptionFieldClass& operator=(const CommonOptionFieldClass& fc) noexcept + CommonOptionFieldClass operator=(const CommonOptionFieldClass fc) noexcept { _ThisCommonFieldClass::operator=(fc); return *this; } - ConstFieldClass fieldClass() const noexcept + CommonOptionFieldClass asConst() const noexcept { - return ConstFieldClass { - internal::CommonOptionFieldClassSpec::fieldClass( - this->_libObjPtr())}; + return CommonOptionFieldClass {*this}; } - _FieldClass fieldClass() noexcept + _FieldClass fieldClass() const noexcept { return _FieldClass { - internal::CommonOptionFieldClassSpec::fieldClass(this->_libObjPtr())}; + internal::CommonOptionFieldClassSpec::fieldClass(this->libObjPtr())}; } Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; using OptionFieldClass = CommonOptionFieldClass; using ConstOptionFieldClass = CommonOptionFieldClass; +namespace internal { + +struct OptionFieldClassTypeDescr +{ + using Const = ConstOptionFieldClass; + using NonConst = OptionFieldClass; +}; + +template <> +struct TypeDescr : public OptionFieldClassTypeDescr +{ +}; + +template <> +struct TypeDescr : public OptionFieldClassTypeDescr +{ +}; + +} /* namespace internal */ + template class CommonOptionWithSelectorFieldClass : public CommonOptionFieldClass { @@ -1273,13 +1558,13 @@ private: using typename CommonOptionFieldClass::_ThisCommonOptionFieldClass; protected: - using typename CommonFieldClass::_LibObjPtr; using _ThisCommonOptionWithSelectorFieldClass = CommonOptionWithSelectorFieldClass; public: - using Shared = internal::SharedFieldClass, LibObjT>; + using typename CommonFieldClass::LibObjPtr; + using Shared = SharedFieldClass, LibObjT>; - explicit CommonOptionWithSelectorFieldClass(const _LibObjPtr libObjPtr) noexcept : + explicit CommonOptionWithSelectorFieldClass(const LibObjPtr libObjPtr) noexcept : _ThisCommonOptionFieldClass {libObjPtr} { BT_ASSERT_DBG(this->isOptionWithSelector()); @@ -1287,49 +1572,72 @@ public: template CommonOptionWithSelectorFieldClass( - const CommonOptionWithSelectorFieldClass& fc) noexcept : + const CommonOptionWithSelectorFieldClass fc) noexcept : _ThisCommonOptionFieldClass {fc} { } template - _ThisCommonOptionWithSelectorFieldClass& - operator=(const CommonOptionWithSelectorFieldClass& fc) noexcept + CommonOptionWithSelectorFieldClass + operator=(const CommonOptionWithSelectorFieldClass fc) noexcept { _ThisCommonOptionFieldClass::operator=(fc); return *this; } + CommonOptionWithSelectorFieldClass asConst() const noexcept + { + return CommonOptionWithSelectorFieldClass {*this}; + } + ConstFieldPath selectorFieldPath() const noexcept { return ConstFieldPath { bt_field_class_option_with_selector_field_borrow_selector_field_path_const( - this->_libObjPtr())}; + this->libObjPtr())}; } Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; using OptionWithSelectorFieldClass = CommonOptionWithSelectorFieldClass; using ConstOptionWithSelectorFieldClass = CommonOptionWithSelectorFieldClass; +namespace internal { + +struct OptionWithSelectorFieldClassTypeDescr +{ + using Const = ConstOptionWithSelectorFieldClass; + using NonConst = OptionWithSelectorFieldClass; +}; + +template <> +struct TypeDescr : public OptionWithSelectorFieldClassTypeDescr +{ +}; + +template <> +struct TypeDescr : public OptionWithSelectorFieldClassTypeDescr +{ +}; + +} /* namespace internal */ + template class CommonOptionWithBoolSelectorFieldClass : public CommonOptionWithSelectorFieldClass { private: - using typename CommonFieldClass::_LibObjPtr; - using typename CommonOptionWithSelectorFieldClass< LibObjT>::_ThisCommonOptionWithSelectorFieldClass; public: - using Shared = - internal::SharedFieldClass, LibObjT>; + using typename CommonFieldClass::LibObjPtr; + using Shared = SharedFieldClass, LibObjT>; - explicit CommonOptionWithBoolSelectorFieldClass(const _LibObjPtr libObjPtr) noexcept : + explicit CommonOptionWithBoolSelectorFieldClass(const LibObjPtr libObjPtr) noexcept : _ThisCommonOptionWithSelectorFieldClass {libObjPtr} { BT_ASSERT_DBG(this->isOptionWithBoolSelector()); @@ -1337,28 +1645,33 @@ public: template CommonOptionWithBoolSelectorFieldClass( - const CommonOptionWithBoolSelectorFieldClass& fc) noexcept : + const CommonOptionWithBoolSelectorFieldClass fc) noexcept : _ThisCommonOptionWithSelectorFieldClass {fc} { } template - CommonOptionWithBoolSelectorFieldClass& - operator=(const CommonOptionWithBoolSelectorFieldClass& fc) noexcept + CommonOptionWithBoolSelectorFieldClass + operator=(const CommonOptionWithBoolSelectorFieldClass fc) noexcept { _ThisCommonOptionWithSelectorFieldClass::operator=(fc); return *this; } + CommonOptionWithBoolSelectorFieldClass asConst() const noexcept + { + return CommonOptionWithBoolSelectorFieldClass {*this}; + } + bool selectorIsReversed() const noexcept { return bt_field_class_option_with_selector_field_bool_selector_is_reversed( - this->_libObjPtr()); + this->libObjPtr()); } Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; @@ -1369,10 +1682,28 @@ using ConstOptionWithBoolSelectorFieldClass = namespace internal { +struct OptionWithBoolSelectorFieldClassTypeDescr +{ + using Const = ConstOptionWithBoolSelectorFieldClass; + using NonConst = OptionWithBoolSelectorFieldClass; +}; + +template <> +struct TypeDescr : + public OptionWithBoolSelectorFieldClassTypeDescr +{ +}; + +template <> +struct TypeDescr : + public OptionWithBoolSelectorFieldClassTypeDescr +{ +}; + template struct CommonOptionWithIntegerSelectorFieldClassSpec; -// Functions specific to option field classes with unsigned integer ranges +/* Functions specific to option field classes with unsigned integer ranges */ template <> struct CommonOptionWithIntegerSelectorFieldClassSpec final { @@ -1384,7 +1715,7 @@ struct CommonOptionWithIntegerSelectorFieldClassSpec struct CommonOptionWithIntegerSelectorFieldClassSpec final { @@ -1396,27 +1727,21 @@ struct CommonOptionWithIntegerSelectorFieldClassSpec } }; -} // namespace internal +} /* namespace internal */ template class CommonOptionWithIntegerSelectorFieldClass : public CommonOptionWithSelectorFieldClass { private: - using typename CommonFieldClass::_LibObjPtr; - using typename CommonOptionWithSelectorFieldClass< LibObjT>::_ThisCommonOptionWithSelectorFieldClass; - using _ThisCommonOptionWithIntegerSelectorFieldClass = - CommonOptionWithIntegerSelectorFieldClass; - public: - using Shared = - internal::SharedFieldClass<_ThisCommonOptionWithIntegerSelectorFieldClass, LibObjT>; - + using typename CommonFieldClass::LibObjPtr; + using Shared = SharedFieldClass; using RangeSet = RangeSetT; - explicit CommonOptionWithIntegerSelectorFieldClass(const _LibObjPtr libObjPtr) noexcept : + explicit CommonOptionWithIntegerSelectorFieldClass(const LibObjPtr libObjPtr) noexcept : _ThisCommonOptionWithSelectorFieldClass {libObjPtr} { BT_ASSERT_DBG(this->isOptionWithIntegerSelector()); @@ -1424,14 +1749,14 @@ public: template CommonOptionWithIntegerSelectorFieldClass( - const CommonOptionWithIntegerSelectorFieldClass& fc) noexcept : + const CommonOptionWithIntegerSelectorFieldClass fc) noexcept : _ThisCommonOptionWithSelectorFieldClass {fc} { } template - _ThisCommonOptionWithIntegerSelectorFieldClass& - operator=(const CommonOptionWithIntegerSelectorFieldClass& fc) noexcept + CommonOptionWithIntegerSelectorFieldClass + operator=(const CommonOptionWithIntegerSelectorFieldClass fc) noexcept { _ThisCommonOptionWithSelectorFieldClass::operator=(fc); return *this; @@ -1440,12 +1765,12 @@ public: RangeSet ranges() const noexcept { return RangeSet {internal::CommonOptionWithIntegerSelectorFieldClassSpec::ranges( - this->_libObjPtr())}; + this->libObjPtr())}; } Shared shared() const noexcept { - return Shared {*this}; + return Shared::createWithRef(*this); } }; @@ -1463,10 +1788,46 @@ using ConstOptionWithSignedIntegerSelectorFieldClass = namespace internal { +struct OptionWithUnsignedIntegerSelectorFieldClassTypeDescr +{ + using Const = ConstOptionWithUnsignedIntegerSelectorFieldClass; + using NonConst = OptionWithUnsignedIntegerSelectorFieldClass; +}; + +template <> +struct TypeDescr : + public OptionWithUnsignedIntegerSelectorFieldClassTypeDescr +{ +}; + +template <> +struct TypeDescr : + public OptionWithUnsignedIntegerSelectorFieldClassTypeDescr +{ +}; + +struct OptionWithSignedIntegerSelectorFieldClassTypeDescr +{ + using Const = ConstOptionWithSignedIntegerSelectorFieldClass; + using NonConst = OptionWithSignedIntegerSelectorFieldClass; +}; + +template <> +struct TypeDescr : + public OptionWithSignedIntegerSelectorFieldClassTypeDescr +{ +}; + +template <> +struct TypeDescr : + public OptionWithSignedIntegerSelectorFieldClassTypeDescr +{ +}; + template struct CommonVariantFieldClassOptionSpec; -// Functions specific to mutable variant field class options +/* Functions specific to mutable variant field class options */ template <> struct CommonVariantFieldClassOptionSpec final { @@ -1474,9 +1835,14 @@ struct CommonVariantFieldClassOptionSpec final { return bt_field_class_variant_option_borrow_field_class(libObjPtr); } + + static bt_value *userAttributes(bt_field_class_variant_option * const libObjPtr) noexcept + { + return bt_field_class_variant_option_borrow_user_attributes(libObjPtr); + } }; -// Functions specific to constant variant field class options +/* Functions specific to constant variant field class options */ template <> struct CommonVariantFieldClassOptionSpec final { @@ -1485,55 +1851,77 @@ struct CommonVariantFieldClassOptionSpec fi { return bt_field_class_variant_option_borrow_field_class_const(libObjPtr); } + + static const bt_value * + userAttributes(const bt_field_class_variant_option * const libObjPtr) noexcept + { + return bt_field_class_variant_option_borrow_user_attributes_const(libObjPtr); + } }; -} // namespace internal +} /* namespace internal */ template -class CommonVariantFieldClassOption : public internal::BorrowedObj +class CommonVariantFieldClassOption : public BorrowedObject { private: - using typename internal::BorrowedObj::_ThisBorrowedObj; - using typename internal::BorrowedObj::_LibObjPtr; - - using _FieldClass = - typename std::conditional::value, ConstFieldClass, FieldClass>::type; + using typename BorrowedObject::_ThisBorrowedObject; + using _FieldClass = internal::DepFc; public: - explicit CommonVariantFieldClassOption(const _LibObjPtr libObjPtr) noexcept : - _ThisBorrowedObj {libObjPtr} + using typename BorrowedObject::LibObjPtr; + using UserAttributes = internal::DepUserAttrs; + + explicit CommonVariantFieldClassOption(const LibObjPtr libObjPtr) noexcept : + _ThisBorrowedObject {libObjPtr} { } template - CommonVariantFieldClassOption(const CommonVariantFieldClassOption& fc) noexcept : - _ThisBorrowedObj {fc} + CommonVariantFieldClassOption(const CommonVariantFieldClassOption fc) noexcept : + _ThisBorrowedObject {fc} { } template - CommonVariantFieldClassOption& - operator=(const CommonVariantFieldClassOption& fc) noexcept + CommonVariantFieldClassOption + operator=(const CommonVariantFieldClassOption fc) noexcept { - _ThisBorrowedObj::operator=(fc); + _ThisBorrowedObject::operator=(fc); return *this; } - bpstd::string_view name() const noexcept + CommonVariantFieldClassOption asConst() const noexcept { - return bt_field_class_variant_option_get_name(this->_libObjPtr()); + return CommonVariantFieldClassOption {*this}; } - ConstFieldClass fieldClass() const noexcept + bt2c::CStringView name() const noexcept { - return ConstFieldClass {internal::CommonVariantFieldClassOptionSpec< - const bt_field_class_variant_option>::fieldClass(this->_libObjPtr())}; + return bt_field_class_variant_option_get_name(this->libObjPtr()); } - _FieldClass fieldClass() noexcept + _FieldClass fieldClass() const noexcept { return _FieldClass { - internal::CommonVariantFieldClassOptionSpec::fieldClass(this->_libObjPtr())}; + internal::CommonVariantFieldClassOptionSpec::fieldClass(this->libObjPtr())}; + } + + template + CommonVariantFieldClassOption + userAttributes(const CommonMapValue userAttrs) const noexcept + { + static_assert(!std::is_const::value, + "Not available with `bt2::ConstVariantFieldClassOption`."); + + bt_field_class_variant_option_set_user_attributes(this->libObjPtr(), userAttrs.libObjPtr()); + return *this; + } + + UserAttributes userAttributes() const noexcept + { + return UserAttributes {internal::CommonVariantFieldClassOptionSpec::userAttributes( + this->libObjPtr())}; } }; @@ -1544,10 +1932,26 @@ using ConstVariantFieldClassOption = namespace internal { +struct VariantFieldClassOptionTypeDescr +{ + using Const = ConstVariantFieldClassOption; + using NonConst = VariantFieldClassOption; +}; + +template <> +struct TypeDescr : public VariantFieldClassOptionTypeDescr +{ +}; + +template <> +struct TypeDescr : public VariantFieldClassOptionTypeDescr +{ +}; + template struct ConstVariantWithIntegerSelectorFieldClassOptionSpec; -// Functions specific to variant field class options with unsigned integer selector +/* Functions specific to variant field class options with unsigned integer selector */ template <> struct ConstVariantWithIntegerSelectorFieldClassOptionSpec< const bt_field_class_variant_with_selector_field_integer_unsigned_option> @@ -1570,7 +1974,7 @@ struct ConstVariantWithIntegerSelectorFieldClassOptionSpec< } }; -// Functions specific to variant field class options with signed integer selector +/* Functions specific to variant field class options with signed integer selector */ template <> struct ConstVariantWithIntegerSelectorFieldClassOptionSpec< const bt_field_class_variant_with_selector_field_integer_signed_option> @@ -1593,49 +1997,50 @@ struct ConstVariantWithIntegerSelectorFieldClassOptionSpec< } }; -} // namespace internal +} /* namespace internal */ template -class ConstVariantWithIntegerSelectorFieldClassOption : public internal::BorrowedObj +class ConstVariantWithIntegerSelectorFieldClassOption : public BorrowedObject { private: - using typename internal::BorrowedObj::_ThisBorrowedObj; - using typename internal::BorrowedObj::_LibObjPtr; + using typename BorrowedObject::_ThisBorrowedObject; using _Spec = internal::ConstVariantWithIntegerSelectorFieldClassOptionSpec; public: + using typename BorrowedObject::LibObjPtr; + using RangeSet = typename std::conditional< std::is_same< LibObjT, const bt_field_class_variant_with_selector_field_integer_unsigned_option>::value, ConstUnsignedIntegerRangeSet, ConstSignedIntegerRangeSet>::type; - explicit ConstVariantWithIntegerSelectorFieldClassOption(const _LibObjPtr libObjPtr) noexcept : - _ThisBorrowedObj {libObjPtr} + explicit ConstVariantWithIntegerSelectorFieldClassOption(const LibObjPtr libObjPtr) noexcept : + _ThisBorrowedObject {libObjPtr} { } template ConstVariantWithIntegerSelectorFieldClassOption( - const ConstVariantWithIntegerSelectorFieldClassOption& fc) noexcept : - _ThisBorrowedObj {fc} + const ConstVariantWithIntegerSelectorFieldClassOption fc) noexcept : + _ThisBorrowedObject {fc} { } template - ConstVariantWithIntegerSelectorFieldClassOption& - operator=(const ConstVariantWithIntegerSelectorFieldClassOption& fc) noexcept + ConstVariantWithIntegerSelectorFieldClassOption + operator=(const ConstVariantWithIntegerSelectorFieldClassOption fc) noexcept { - _ThisBorrowedObj::operator=(fc); + _ThisBorrowedObject::operator=(fc); return *this; } ConstVariantFieldClassOption asBaseOption() const noexcept { - return ConstVariantFieldClassOption {_Spec::asBaseOption(this->_libObjPtr())}; + return ConstVariantFieldClassOption {_Spec::asBaseOption(this->libObjPtr())}; } - bpstd::string_view name() const noexcept + bt2c::CStringView name() const noexcept { return this->asBaseOption().name(); } @@ -1647,7 +2052,7 @@ public: RangeSet ranges() const noexcept { - return RangeSet {_Spec::ranges(this->_libObjPtr())}; + return RangeSet {_Spec::ranges(this->libObjPtr())}; } }; @@ -1664,7 +2069,7 @@ namespace internal { template struct CommonVariantFieldClassSpec; -// Functions specific to mutable variant field classes +/* Functions specific to mutable variant field classes */ template <> struct CommonVariantFieldClassSpec final { @@ -1681,7 +2086,7 @@ struct CommonVariantFieldClassSpec final } }; -// Functions specific to constant variant field classes +/* Functions specific to constant variant field classes */ template <> struct CommonVariantFieldClassSpec final { @@ -1698,7 +2103,7 @@ struct CommonVariantFieldClassSpec final } }; -} // namespace internal +} /* namespace internal */ template class CommonVariantFieldClass : public CommonFieldClass @@ -1707,112 +2112,107 @@ private: using typename CommonFieldClass::_ThisCommonFieldClass; protected: - using typename CommonFieldClass::_LibObjPtr; using _ThisCommonVariantFieldClass = CommonVariantFieldClass; public: - using Shared = internal::SharedFieldClass, LibObjT>; + using typename CommonFieldClass::LibObjPtr; + using Shared = SharedFieldClass, LibObjT>; + using Iterator = BorrowedObjectIterator; using Option = - typename std::conditional::value, ConstVariantFieldClassOption, - VariantFieldClassOption>::type; + internal::DepType; - explicit CommonVariantFieldClass(const _LibObjPtr libObjPtr) noexcept : + explicit CommonVariantFieldClass(const LibObjPtr libObjPtr) noexcept : _ThisCommonFieldClass {libObjPtr} { BT_ASSERT_DBG(this->isVariant()); } template - CommonVariantFieldClass(const CommonVariantFieldClass& fc) noexcept : + CommonVariantFieldClass(const CommonVariantFieldClass fc) noexcept : _ThisCommonFieldClass {fc} { } template - _ThisCommonVariantFieldClass& - operator=(const CommonVariantFieldClass& fc) noexcept + CommonVariantFieldClass operator=(const CommonVariantFieldClass fc) noexcept { _ThisCommonFieldClass::operator=(fc); return *this; } - std::uint64_t size() const noexcept - { - return bt_field_class_variant_get_option_count(this->_libObjPtr()); - } - - ConstVariantFieldClassOption operator[](const std::uint64_t index) const noexcept + CommonVariantFieldClass asConst() const noexcept { - return ConstVariantFieldClassOption { - internal::CommonVariantFieldClassSpec::optionByIndex( - this->_libObjPtr(), index)}; + return CommonVariantFieldClass {*this}; } - Option operator[](const std::uint64_t index) noexcept + std::uint64_t length() const noexcept { - return Option {internal::CommonVariantFieldClassSpec::optionByIndex( - this->_libObjPtr(), index)}; + return bt_field_class_variant_get_option_count(this->libObjPtr()); } - nonstd::optional - operator[](const char * const name) const noexcept + Iterator begin() const noexcept { - const auto libObjPtr = - internal::CommonVariantFieldClassSpec::optionByName( - this->_libObjPtr(), name); - - if (libObjPtr) { - return ConstVariantFieldClassOption {libObjPtr}; - } - - return nonstd::nullopt; + return Iterator {*this, 0}; } - nonstd::optional - operator[](const std::string& name) const noexcept + Iterator end() const noexcept { - return (*this)[name.data()]; + return Iterator {*this, this->length()}; } - nonstd::optional