Skip to content

Commit 5bc8fd8

Browse files
committed
Fix stl
1 parent 098b1c4 commit 5bc8fd8

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

src/snmalloc/ds_core/stats.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ namespace snmalloc
1818
public:
1919
void increase(size_t amount)
2020
{
21-
size_t c = (curr += amount);
22-
size_t p = peak.load(std::memory_order_relaxed);
21+
size_t old = curr.fetch_add(amount);
22+
size_t c = old + amount;
23+
size_t p = peak.load(stl::memory_order_relaxed);
2324
while (c > p)
2425
{
2526
if (peak.compare_exchange_strong(p, c))
@@ -37,12 +38,12 @@ namespace snmalloc
3738

3839
size_t get_curr()
3940
{
40-
return curr.load(std::memory_order_relaxed);
41+
return curr.load(stl::memory_order_relaxed);
4142
}
4243

4344
size_t get_peak()
4445
{
45-
return peak.load(std::memory_order_relaxed);
46+
return peak.load(stl::memory_order_relaxed);
4647
}
4748

4849
void operator+=(size_t amount)
@@ -71,28 +72,28 @@ namespace snmalloc
7172
*/
7273
class MonotoneLocalStat
7374
{
74-
std::atomic<size_t> value{0};
75+
stl::Atomic<size_t> value{0};
7576

7677
public:
7778
void operator++(int)
7879
{
79-
value.fetch_add(1, std::memory_order_relaxed);
80+
value.fetch_add(1, stl::memory_order_relaxed);
8081
}
8182

8283
void operator+=(const MonotoneLocalStat& other)
8384
{
84-
auto v = other.value.load(std::memory_order_relaxed);
85-
value.fetch_add(v, std::memory_order_relaxed);
85+
auto v = other.value.load(stl::memory_order_relaxed);
86+
value.fetch_add(v, stl::memory_order_relaxed);
8687
}
8788

8889
void operator+=(size_t v)
8990
{
90-
value.fetch_add(v, std::memory_order_relaxed);
91+
value.fetch_add(v, stl::memory_order_relaxed);
9192
}
9293

9394
size_t operator*()
9495
{
95-
return value.load(std::memory_order_relaxed);
96+
return value.load(stl::memory_order_relaxed);
9697
}
9798
};
9899
} // namespace snmalloc

src/snmalloc/global/globalalloc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ namespace snmalloc
147147
template<SNMALLOC_CONCEPT(IsConfig) Config_ = Config>
148148
inline static void print_alloc_stats()
149149
{
150-
static std::atomic<size_t> dump{0};
150+
static stl::Atomic<size_t> dump{0};
151151

152152
auto l_dump = dump++;
153153
if (l_dump == 0)

src/snmalloc/mem/pool.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ namespace snmalloc
3232

3333
FlagWord lock{};
3434
capptr::Alloc<T> list{nullptr};
35-
std::atomic<size_t> count{0};
35+
stl::Atomic<size_t> count{0};
3636

3737
public:
3838
constexpr PoolState() = default;
3939

4040
size_t get_count()
4141
{
42-
return count.load(std::memory_order_relaxed);
42+
return count.load(stl::memory_order_relaxed);
4343
}
4444
};
4545

src/snmalloc/stl/gnu/atomic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ namespace snmalloc
8989
return load();
9090
}
9191

92-
SNMALLOC_FAST_PATH T load(MemoryOrder mem_ord = MemoryOrder::SEQ_CST)
92+
SNMALLOC_FAST_PATH T load(MemoryOrder mem_ord = MemoryOrder::SEQ_CST) const
9393
{
9494
T res;
9595
__atomic_load(addressof(val), addressof(res), order(mem_ord));

0 commit comments

Comments
 (0)