• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tstack / lnav / 23080696680-2839

14 Mar 2026 04:45AM UTC coverage: 69.02% (+0.03%) from 68.988%
23080696680-2839

push

github

tstack
[date_time_scanner] the scan() result should match the precision of the input

Related to #1643

20 of 21 new or added lines in 2 files covered. (95.24%)

843 existing lines in 6 files now uncovered.

52636 of 76262 relevant lines covered (69.02%)

520629.08 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.67
/src/base/distributed_slice.hh
1
/**
2
 * Copyright (c) 2025, Timothy Stack
3
 *
4
 * All rights reserved.
5
 *
6
 * Redistribution and use in source and binary forms, with or without
7
 * modification, are permitted provided that the following conditions are met:
8
 *
9
 * * Redistributions of source code must retain the above copyright notice, this
10
 * list of conditions and the following disclaimer.
11
 * * Redistributions in binary form must reproduce the above copyright notice,
12
 * this list of conditions and the following disclaimer in the documentation
13
 * and/or other materials provided with the distribution.
14
 * * Neither the name of Timothy Stack nor the names of its contributors
15
 * may be used to endorse or promote products derived from this software
16
 * without specific prior written permission.
17
 *
18
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ''AS IS'' AND ANY
19
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
22
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 */
29

30
#ifndef lnav_distributed_slice
31
#define lnav_distributed_slice
32

33
#include <vector>
34

35
#define DS_STRINGIZE(A) #A
36

37
#if defined(__has_feature)
38
#  if __has_feature(address_sanitizer)
39
#    define NO_ASAN no_sanitize_address,
40
#  else
41
#    define NO_ASAN
42
#  endif
43
#else
44
#  define NO_ASAN
45
#endif
46

47
#if defined(__APPLE__)
48
#    define DIST_SLICE(id) \
49
        __attribute__((NO_ASAN \
50
                       used, \
51
                       section("__DATA,__ds_" DS_STRINGIZE( \
52
                           id) ",regular,no_dead_strip")))
53
#    define DIST_SLICE_BEGIN(id) \
54
        __asm("section$start$__DATA$__ds_" DS_STRINGIZE(id))
55
#    define DIST_SLICE_END(id) \
56
        __asm("section$end$__DATA$__ds_" DS_STRINGIZE(id))
57
#else
58
#    define DIST_SLICE(id) \
59
        __attribute__(( \
60
            no_sanitize_address, used, section("ds_" DS_STRINGIZE(id))))
61
#    define DIST_SLICE_BEGIN(id) __asm("__start_ds_" DS_STRINGIZE(id))
62
#    define DIST_SLICE_END(id)   __asm("__stop_ds_" DS_STRINGIZE(id))
63
#endif
64

65
template<typename T>
66
struct dist_slice_container {
67
    using iterator = T*;
68
    using const_iterator = const T*;
69

70
    constexpr dist_slice_container(iterator start, iterator end)
71
        : ds_start(start), ds_end(end)
72
    {
73
    }
74

75
    constexpr iterator begin() { return this->ds_start; }
1,775✔
76

77
    constexpr const_iterator begin() const { return this->ds_start; }
96,855✔
78

79
    constexpr iterator end() { return this->ds_end; }
1,775✔
80

81
    constexpr const_iterator end() const { return this->ds_end; }
1,329✔
82

83
    size_t size() const { return this->ds_end - this->ds_start; }
26,074✔
84

85
    template<typename U>
86
    struct slice_indexed_array {
87
        using iterator = typename std::vector<U>::iterator;
88

89
        explicit slice_indexed_array(const dist_slice_container& slices)
26,073✔
90
            : sia_slices(slices), sia_array(std::vector<U>(slices.size()))
52,146✔
91
        {
92
        }
26,073✔
93

94
        U& operator[](const T* slice)
90,914✔
95
        {
96
            auto index = std::distance(this->sia_slices.begin(), slice);
90,914✔
97
            return this->sia_array[index];
90,914✔
98
        }
99

100
        const U& operator[](const T* slice) const
4,612✔
101
        {
102
            auto index = std::distance(this->sia_slices.begin(), slice);
4,612✔
103
            return this->sia_array[index];
4,612✔
104
        }
105

106
        iterator begin() { return this->sia_array.begin(); }
550✔
107

108
        iterator end() { return this->sia_array.end(); }
550✔
109

110
        void clear()
18,479✔
111
        {
112
            for (auto& elem : this->sia_array) {
184,790✔
113
                elem.clear();
166,311✔
114
            }
115
        }
18,479✔
116

UNCOV
117
        void swap(slice_indexed_array& other)
×
118
        {
UNCOV
119
            this->sia_array.swap(other.sia_array);
×
120
        }
121

122
    private:
123
        const dist_slice_container& sia_slices;
124
        std::vector<U> sia_array;
125
    };
126

127
    template<typename U>
128
    slice_indexed_array<U> create_array_indexed_by() const
26,073✔
129
    {
130
        return slice_indexed_array<U>(*this);
26,073✔
131
    }
132

133
private:
134
    iterator ds_start;
135
    iterator ds_end;
136
};
137

138
#define DIST_SLICE_CONTAINER(T, id) \
139
    (+[]() -> auto { \
140
        extern T start DIST_SLICE_BEGIN(id); \
141
        extern T end DIST_SLICE_END(id); \
142
\
143
        return dist_slice_container<T>(&start, &end); \
144
    })()
145

146
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc