Branch data Line data Source code
1 : : // SPDX-License-Identifier: MIT
2 : : #ifndef SIGNAL_LAYOUT_H
3 : : #define SIGNAL_LAYOUT_H
4 : :
5 : : #include <cstdint>
6 : :
7 : : /** Linear coordinate in the signal's bit order, widened before arithmetic. */
8 : 352521 : inline std::uint64_t SignalStartCoordinate(std::uint32_t startBit, bool littleEndian) {
9 [ + + ]: 352521 : return littleEndian ? std::uint64_t(startBit)
10 : 352521 : : std::uint64_t(startBit / 8U) * 8U + 7U - startBit % 8U;
11 : : }
12 : :
13 : 360851 : inline bool IsValidSignalLayout(std::uint32_t startBit, std::uint32_t length,
14 : : bool littleEndian, std::uint8_t dlc) {
15 [ + + + + ]: 711008 : return length >= 1U && length <= 64U &&
16 [ + + ]: 711008 : SignalStartCoordinate(startBit, littleEndian) + length <= std::uint64_t(dlc) * 8U;
17 : : }
18 : :
19 : : #endif
|