GCC Code Coverage Report


Directory: ./
File: firmware/libfirmware/util/include/rusefi/fragments.h
Date: 2025-10-03 00:57:22
Coverage Exec Excl Total
Lines: 100.0% 237 0 237
Functions: 100.0% 48 0 48
Branches: -% 0 0 0
Decisions: -% 0 - 0

Line Branch Decision Exec Source
1 /*
2 * FragmentEntry.h
3 *
4 * Created on: Jan 5, 2022
5 * @author Andrey Belomutskiy, (c) 2012-2022
6 */
7
8 #pragma once
9
10 #include <cstddef>
11 #include <cstdint>
12
13 // Implement overloads of this function in your project for each live data
14 // struct you want to fetch
15 // for example:
16 // struct myData { };
17 //
18 // template<>
19 // const myData* getLiveDataStruct(size_t index) { return ...; }
20 template <typename TStruct>
21 const TStruct* getLiveData(size_t index);
22
23 template <typename TValue, int TIndex = 0>
24 struct decl_frag { };
25
26 struct FragmentEntry {
27 template <typename TData, int TIndex>
28 48 FragmentEntry(decl_frag<TData, TIndex>)
29 48 : func((const uint8_t*(*)(size_t))getLiveData<TData>)
30 48 , index(TIndex)
31 48 , size(sizeof(TData))
32 {
33 48 }
34
35 43 const uint8_t* get() const {
36 43 return func(index);
37 }
38
39 const uint8_t *(*const func)(size_t);
40 const size_t index;
41
42 const size_t size;
43 };
44
45 struct FragmentList {
46 const FragmentEntry* fragments;
47 const size_t count;
48 };
49
50 // copy `size` of fragmented outputs in to destination, skipping the first `skip` bytes
51 size_t copyRange(uint8_t* destination, FragmentList src, size_t skip, size_t size);
52 // returns pointer to actual data and size of contiguous data
53 // if data is located in more than one fragmnet - returned value will be size available in first fragment
54 size_t getRangePtr(uint8_t **ptr, FragmentList src, size_t offset, size_t size);
55