Skip to content

Commit 9f613cf

Browse files
Fixing build.
1 parent 13cd80a commit 9f613cf

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/DwarfParser.hpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#include <stdint.h>
1717
#include <stdio.h>
1818
#include <stdlib.h>
19-
#include <stdatomic.h>
19+
#include <atomic>
2020

2121
#include "libunwind.h"
2222
#include "dwarf2.h"
@@ -85,29 +85,29 @@ class StackBuffer
8585
static constexpr size_t entrySize = sizeof(FreeListEntry);
8686
static constexpr size_t buffer_size = LIBUNWIND_MAX_STACK_SIZE * entrySize;
8787
static char buffer[buffer_size];
88-
static _Atomic size_t next_not_allocated_entry;
89-
static void * _Atomic next_allocated_entry;
88+
static std::atomic<size_t> next_not_allocated_entry;
89+
static std::atomic<FreeListEntry *> next_allocated_entry;
9090

9191
public:
9292
static FreeListEntry * alloc()
9393
{
9494
/// At first, try to get element from free list.
9595
{
96-
void * expected = nullptr;
97-
void * desired = nullptr;
98-
while (!atomic_compare_exchange_weak(&next_allocated_entry, &expected, desired))
96+
FreeListEntry * expected = nullptr;
97+
FreeListEntry * desired = nullptr;
98+
while (!next_allocated_entry.compare_exchange_weak(expected, desired))
9999
{
100100
if (expected == nullptr)
101101
break;
102102

103-
desired = static_cast<FreeListEntry *>(expected)->next;
103+
desired = expected->next;
104104
}
105105

106106
if (expected)
107-
return static_cast<FreeListEntry *>(expected);
107+
return expected;
108108
}
109109

110-
size_t prev = atomic_fetch_add(&next_not_allocated_entry, 1);
110+
size_t prev = next_not_allocated_entry.fetch_add(1);
111111
if (prev >= buffer_size)
112112
abort();
113113

@@ -116,12 +116,12 @@ class StackBuffer
116116

117117
static void free(FreeListEntry * entry)
118118
{
119-
void * expected = nullptr;
120-
entry->next = nullptr;
119+
FreeListEntry * expected = nullptr;
120+
entry->next = expected;
121121

122-
while (!atomic_compare_exchange_weak(&next_allocated_entry, &expected, entry))
122+
while (!next_allocated_entry.compare_exchange_weak(expected, entry))
123123
{
124-
entry->next = static_cast<FreeListEntry *>(expected);
124+
entry->next = expected;
125125
}
126126
}
127127
};

src/libunwind.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,8 @@ int unw_backtrace(void **buffer, int size) {
306306
}
307307

308308
char StackBuffer::buffer[];
309-
size_t _Atomic StackBuffer::next_not_allocated_entry = 0;
310-
void * _Atomic StackBuffer::next_allocated_entry = nullptr;
309+
std::atomic<size_t> StackBuffer::next_not_allocated_entry = 0;
310+
std::atomic<StackBuffer::FreeListEntry *> StackBuffer::next_allocated_entry = nullptr;
311311

312312

313313
// Add logging hooks in Debug builds only

0 commit comments

Comments
 (0)