You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
20
+
fail-fast: false
21
+
22
+
# Set up a matrix to run the following 3 configurations:
23
+
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
24
+
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
25
+
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
26
+
#
27
+
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
28
+
matrix:
29
+
os: [ubuntu-latest]
30
+
build_type: [Release]
31
+
c_compiler: [gcc, clang, cl]
32
+
include:
33
+
- os: ubuntu-latest
34
+
c_compiler: gcc
35
+
cpp_compiler: g++
36
+
- os: ubuntu-latest
37
+
c_compiler: clang
38
+
cpp_compiler: clang++
39
+
exclude:
40
+
- os: ubuntu-latest
41
+
c_compiler: cl
42
+
43
+
steps:
44
+
- uses: actions/checkout@v4
45
+
46
+
- name: Set reusable strings
47
+
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
70
+
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
# required to fetch internal or private CodeQL packs
19
+
packages: read
20
+
21
+
strategy:
22
+
fail-fast: false
23
+
matrix:
24
+
include:
25
+
- language: actions
26
+
build-mode: none
27
+
- language: c-cpp
28
+
build-mode: autobuild
29
+
steps:
30
+
- name: Checkout repository
31
+
uses: actions/checkout@v4
32
+
33
+
# Add any setup steps before running the `github/codeql-action/init` action.
34
+
# This includes steps like installing compilers or runtimes (`actions/setup-node`
35
+
# or others). This is typically only required for manual builds.
36
+
# - name: Setup runtime (example)
37
+
# uses: actions/setup-example@v1
38
+
39
+
# Initializes the CodeQL tools for scanning.
40
+
- name: Initialize CodeQL
41
+
uses: github/codeql-action/init@v3
42
+
with:
43
+
languages: ${{ matrix.language }}
44
+
build-mode: ${{ matrix.build-mode }}
45
+
# If you wish to specify custom queries, you can do so here or in a config file.
46
+
# By default, queries listed here will override any specified in a config file.
47
+
# Prefix the list here with "+" to use these queries and those in the config file.
48
+
49
+
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
@@ -34,7 +42,7 @@ struct nextgen : public bitfilled::host<std::uint8_t>
34
42
35
43
Our `nextgen` type's bit-fields work with the exact same syntax as their `legacy` counterparts.
36
44
The difference here is that a `nextgen` object can be converted to and from any `uint8_t` type,
37
-
no more sketchy casting necessary to get the underlying integer type.
45
+
no more explicit casting necessary to get the underlying integer type.
38
46
One thing to note is that the nextgen fields have absolute bit offsets, as opposed to the legacy
39
47
fields (which in turn only have a bit size specifier).
40
48
This characteristic of the behavior also means that nextgen's bit-fields can be made to overlap one another.
@@ -44,21 +52,25 @@ This characteristic of the behavior also means that nextgen's bit-fields can be
44
52
The bitfilled logic consists of two building blocks, that work in tandem to provide the desired functionality:
45
53
1. The bitfilled member variables hold the bit-field's **properties** (`props`): the position of the bits and the access rights,
46
54
and also - indirectly - the memory location of the bits (more on that later).
47
-
2. The encapsulating object type provides the **operators** (`ops`), which are used by the bitfilled members
55
+
2. The encapsulating object type defines the **operators** (`ops`), which are used by the bitfilled members
48
56
to perform the memory access and bit operations needed to read or modify the bit-field.
49
57
50
58
The term "property" is used to refer to the bitfilled members due to them functioning as [properties][property wiki]
51
59
as known in other programming languages (C# and Python to name a few):
52
60
- they don't increase the size of the encapsulating type [(achieved with `[[no_unique_address]]`)](https://en.cppreference.com/w/cpp/language/attributes/no_unique_address)
53
61
- their value is derived from the encapsulating type's state
54
62
63
+
Note that `[[no_unique_address]]` isn't effective when two bitfields with the same type parameters are defined,
64
+
(i.e. same value type, access, operations, bit position) as the C++ core rule of unique identity would be violated
65
+
(this applies even if the two bitfield types are distinct, but inherit the same base class).
66
+
55
67
The key point to understand, and the reason for the design requiring the *operators* in the tandem, is this:
56
68
By dereferencing their address, the bitfilled members provide access to memory that is not theirs,
57
69
but rather whichever member is preceeding them in the encapsulating type layout.
58
70
Therefore the encapsulating type must have a preceeding member variable for bit-field use,
59
71
and the bitfilled members must be made aware of this member variable's type - this is what the operators are achieving.
60
72
Mismatches between the storage member variable and the operators type is impossible to catch at compile time,
61
-
therefore it is recommended to use predefined helper base classes such as `bitfilled::host` and `bitfilled::mmr`,
73
+
therefore it is recommended to use predefined helper base classes such as `bitfilled::host_integer` and `bitfilled::mmreg`,
62
74
instead of defining the storage member variable and the operators independently.
0 commit comments