Skip to content

Commit 555035a

Browse files
committed
runtime: fix warnings in GCC
1 parent 4cd89c1 commit 555035a

12 files changed

+34
-46
lines changed

runtime/CMakeLists.txt

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# add_link_options("-fuse-ld=lld")
22

3-
set(WARNINGS "-Wall -Wextra -Wno-cast-qual -Wno-format -Wno-unused-function -Wno-ignored-attributes -Wno-unused-parameter -Wno-unused-variable -fno-omit-frame-pointer -Wno-sign-compare -Wno-implicit-fallthrough -Wno-unused-private-field -Wno-covered-switch-default -Wno-attributes -Wno-cast-function-type ")
3+
set(WARNINGS "-Wall -Werror -Wno-multichar -Wno-unused-function -Wno-attributes ")
44

55
# Compile the runtime with some special flags
66
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -gdwarf-4 ${WARNINGS} ")
@@ -63,8 +63,10 @@ set(CORE_SOURCES
6363
find_library(LIBUNWIND_LIBRARIES NAMES unwind )
6464
message(STATUS "UNWIND: ${LIBUNWIND_LIBRARIES}")
6565

66-
add_library(alaska_core SHARED ${CORE_SOURCES})
67-
target_compile_options(alaska_core PRIVATE -nostdlib++ -nostdinc++)
66+
add_library(alaska_core STATIC ${CORE_SOURCES})
67+
68+
target_compile_options(alaska_core PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-nostdlib++ -nostdinc++>)
69+
6870
set_target_properties(alaska_core PROPERTIES LINKER_LANGUAGE C)
6971
set_target_properties(alaska_core PROPERTIES SOVERSION ${ALASKA_VERSION})
7072
target_link_libraries(alaska_core ${LIBUNWIND_LIBRARIES})
@@ -104,7 +106,7 @@ if(NOT ALASKA_CORE_ONLY) # -----------------------------------------------------
104106
set_target_properties(alaska PROPERTIES SOVERSION ${ALASKA_VERSION})
105107
target_link_libraries(alaska alaska_core dl pthread ${LIBUNWIND_LIBRARIES})
106108

107-
target_compile_options(alaska PUBLIC -nostdlib++ -nostdinc++)
109+
target_compile_options(alaska PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-nostdlib++ -nostdinc++>)
108110

109111
install(
110112
TARGETS alaska

runtime/core/HandleTable.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ namespace alaska {
125125
ck::scoped_lock lk(this->lock);
126126

127127
log_trace("Getting slab %d", idx);
128-
if (idx >= m_slabs.size()) {
128+
if (idx >= (slabidx_t)m_slabs.size()) {
129129
log_trace("Invalid slab requeset!");
130130
return nullptr;
131131
}
@@ -154,8 +154,8 @@ namespace alaska {
154154
void HandleTable::put(Mapping *m, alaska::ThreadCache *owner) {
155155
log_trace("Putting handle %p", m);
156156
// Validate that the handle is in this table
157-
ALASKA_ASSERT(
158-
mapping_slab_idx(m) < m_slabs.size(), "attempted to put a handle into the wrong table")
157+
ALASKA_ASSERT(mapping_slab_idx(m) < (slabidx_t)m_slabs.size(),
158+
"attempted to put a handle into the wrong table")
159159

160160
// Get the slab that the handle is in
161161
auto *slab = m_slabs[mapping_slab_idx(m)];
@@ -256,12 +256,12 @@ namespace alaska {
256256

257257

258258
void HandleSlab::dump(FILE *stream) {
259-
fprintf(stream, "Slab %4d | ", idx);
259+
fprintf(stream, "Slab %4zu | ", idx);
260260
fprintf(stream, "st %d | ", state);
261261

262262
auto owner = this->get_owner();
263263
fprintf(stream, "owner: %4d | ", owner ? owner->get_id() : -1);
264-
fprintf(stream, "free %4d | ", allocator.num_free());
264+
fprintf(stream, "free %4zu | ", allocator.num_free());
265265

266266
fprintf(stream, "\n");
267267
}

runtime/core/Heap.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,15 @@ namespace alaska {
216216
out("sc %d: %zu heaps\n", cls, mag.size());
217217

218218

219-
int page_ind = 0;
219+
unsigned long page_ind = 0;
220220
mag.foreach ([&](HeapPage *hp) {
221221
SizedPage *sp = static_cast<SizedPage *>(hp);
222222
int id = -1;
223223
auto owner = sp->get_owner();
224224
if (owner != NULL) {
225225
id = owner->get_id();
226226
}
227-
out("SizedPage %016p-%016p owner:%3d avail:%7zu\n", sp->start(), sp->end(), id, sp->available());
227+
out("SizedPage %016zx-%016zx owner:%3d avail:%7zu\n", (uintptr_t)sp->start(), (uintptr_t)sp->end(), id, sp->available());
228228
page_ind++;
229229
if (page_ind > mag.size()) return false;
230230
return true;

runtime/core/LocalityPage.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ namespace alaska {
6161

6262
// Grab the guess metadata
6363
auto guess_ptr = get_ptr(guess_off);
64-
auto original_guess_off = guess_off;
6564

6665
// Go left or right to find the right one.
6766
if (ptr > guess_ptr) {

runtime/core/barrier.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ static bool in_might_block_function(uintptr_t start_addr) {
241241
msg = "\e[32m(managed)\e[0m";
242242
}
243243

244-
printf("%016lx %s\n", buffer[i], msg);
244+
printf("%016lx %s\n", (uintptr_t)buffer[i], msg);
245245
}
246246
printf("\n");
247247

@@ -566,7 +566,7 @@ void alaska::barrier::remove_self_thread(void) {
566566
}
567567

568568
if (!found) {
569-
fprintf(stderr, "Failed to remove non-added thread, %p\n", self);
569+
fprintf(stderr, "Failed to remove non-added thread\n");
570570
abort();
571571
}
572572

@@ -673,8 +673,6 @@ void alaska_blob_init(struct alaska_blob_config* cfg) {
673673
size_t size = round_up(cfg->code_end - cfg->code_start, 4096);
674674
mprotect(patch_page, size + 4096, PROT_EXEC | PROT_READ | PROT_WRITE);
675675

676-
printf("%p %p\n", cfg->code_start, cfg->code_end);
677-
678676
if (cfg->stackmap) parse_stack_map((uint8_t*)cfg->stackmap);
679677
}
680678

runtime/core/glue.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
#include <stdlib.h>
22

3-
4-
#define ALASKA_PRIVATE __attribute__((visibility("hidden")))
5-
6-
ALASKA_PRIVATE
73
extern "C" void __cxa_pure_virtual() {
84
while (1)
95
;
106
}
11-
12-
// void *operator new(size_t size) { return malloc(size); }
13-
// void *operator new[](size_t size) { return malloc(size); }
14-
// void operator delete(void *ptr) noexcept { free(ptr); }
15-
// void operator delete[](void *ptr) noexcept { free(ptr); }
16-
// void operator delete(void *ptr, size_t s) noexcept { free(ptr); }
17-
// void operator delete[](void *ptr, size_t s) noexcept { free(ptr); }

runtime/core/translate.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void *alaska_translate_escape(void *ptr) {
6666
}
6767

6868

69-
static __attribute_noinline__ void track(uintptr_t handle) { fprintf(stderr, "tr %p\n", handle); }
69+
static __attribute_noinline__ void track(uintptr_t handle) { fprintf(stderr, "tr %016zx\n", handle); }
7070

7171
void *alaska_translate(void *ptr) {
7272
int64_t bits = (int64_t)ptr;

runtime/extra/lifetime.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void free(void *p) {
122122
md_t *m = (md_t *)p - 1;
123123
if (m->magic != MAGIC) return;
124124
ssize_t dur = timestamp() - m->time_allocated_ns;
125-
fprintf(lifetime_output, "%zu,%zd\n", m->size, dur);
125+
fprintf(lifetime_output, "%d,%zd\n", m->size, dur);
126126
}
127127

128128
// real_free(m);

runtime/include/alaska/HandleTable.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
namespace alaska {
2424

25-
using slabidx_t = uint64_t;
25+
using slabidx_t = size_t;
2626

2727
class HandleTable;
2828
class HandleSlabQueue;

runtime/include/alaska/LocalityPage.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ namespace alaska {
4949

5050
inline alaska::Mapping *get_mapping(uint32_t offset) { return get_md(offset)->mapping; }
5151

52-
inline int64_t get_free_space() const { return (off_t)md_bump_next - (off_t)data_bump_next; }
53-
inline int64_t used_space() const { return (off_t)data_bump_next - (off_t)data; }
52+
inline size_t get_free_space() const { return (off_t)md_bump_next - (off_t)data_bump_next; }
53+
inline size_t used_space() const { return (off_t)data_bump_next - (off_t)data; }
5454

5555
void *data = nullptr;
5656
void *data_bump_next = nullptr;

runtime/include/ck/utility.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -857,13 +857,13 @@ namespace ck {
857857
"template argument must be a complete class or an unbounded array");
858858
};
859859

860-
/// is_trivially_destructible
861-
template <typename _Tp>
862-
struct is_trivially_destructible
863-
: public __and_<__is_destructible_safe<_Tp>, __bool_constant<__is_trivially_destructible(_Tp)>> {
864-
static_assert(ck::__is_complete_or_unbounded(__type_identity<_Tp>{}),
865-
"template argument must be a complete class or an unbounded array");
866-
};
860+
// /// is_trivially_destructible
861+
// template <typename _Tp>
862+
// struct is_trivially_destructible
863+
// : public __and_<__is_destructible_safe<_Tp>, __bool_constant<__is_trivially_destructible(_Tp)>> {
864+
// static_assert(ck::__is_complete_or_unbounded(__type_identity<_Tp>{}),
865+
// "template argument must be a complete class or an unbounded array");
866+
// };
867867

868868

869869
/// has_virtual_destructor

runtime/test/runtime_test.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ TEST_F(RuntimeTest, UniqueSlabAllocations) {
100100

101101
TEST_F(RuntimeTest, CapacityGrowth) {
102102
// Allocate a large number of slabs
103-
for (int i = 0; i < alaska::HandleTable::initial_capacity * 2; i++) {
103+
for (size_t i = 0; i < alaska::HandleTable::initial_capacity * 2; i++) {
104104
auto* slab = runtime.handle_table.fresh_slab(DUMMY_THREADCACHE);
105105
ASSERT_NE(slab, nullptr);
106106
}
@@ -149,7 +149,7 @@ TEST_F(RuntimeTest, SlabNFreeOnInitialAllocation) {
149149
// Make sure that for many slabs, get_slab returns the right one
150150
TEST_F(RuntimeTest, SlabGetSlab) {
151151
// Allocate a large number of slabs
152-
for (int i = 0; i < alaska::HandleTable::initial_capacity * 2; i++) {
152+
for (size_t i = 0; i < alaska::HandleTable::initial_capacity * 2; i++) {
153153
auto* slab = runtime.handle_table.fresh_slab(DUMMY_THREADCACHE);
154154
ASSERT_NE(slab, nullptr);
155155
// Check that get_slab returns the right slab
@@ -162,7 +162,7 @@ TEST_F(RuntimeTest, SlabGetReturnsNullWhenOutOfCapacity) {
162162
// Allocate a fresh slab from the handle table
163163
auto* slab = runtime.handle_table.fresh_slab(DUMMY_THREADCACHE);
164164
// Fill up the slab with handles
165-
for (int i = 0; i < alaska::HandleTable::slab_capacity; i++) {
165+
for (size_t i = 0; i < alaska::HandleTable::slab_capacity; i++) {
166166
auto handle = slab->alloc();
167167
ASSERT_NE(handle, nullptr);
168168
}
@@ -180,7 +180,7 @@ TEST_F(RuntimeTest, SlabUniqueHandles) {
180180
// Create a set to store the handles
181181
std::set<alaska::Mapping*> handles;
182182
// Fill up the slab with handles
183-
for (int i = 0; i < alaska::HandleTable::slab_capacity; i++) {
183+
for (size_t i = 0; i < alaska::HandleTable::slab_capacity; i++) {
184184
auto handle = slab->alloc();
185185
ASSERT_NE(handle, nullptr);
186186
// Check that the handle is unique
@@ -215,7 +215,7 @@ TEST_F(RuntimeTest, SlabMappingIndex) {
215215
// Allocate a fresh slab from the handle table
216216
auto* slab = runtime.handle_table.fresh_slab(DUMMY_THREADCACHE);
217217
// Fill up the slab with handles
218-
for (int i = 0; i < alaska::HandleTable::slab_capacity; i++) {
218+
for (size_t i = 0; i < alaska::HandleTable::slab_capacity; i++) {
219219
auto handle = slab->alloc();
220220
ASSERT_NE(handle, nullptr);
221221
// Check that the handle is in the right index
@@ -238,7 +238,7 @@ TEST_F(RuntimeTest, HandleSlabQueuePop) {
238238
// Create a vector to store the slabs
239239
std::vector<alaska::HandleSlab*> slabs;
240240
// For a few iterations...
241-
for (int i = 0; i < 10; i++) {
241+
for (size_t i = 0; i < 10; i++) {
242242
// Allocate a fresh slab from the handle table
243243
auto* slab = runtime.handle_table.fresh_slab(DUMMY_THREADCACHE);
244244
// Push the slab to the queue
@@ -248,7 +248,7 @@ TEST_F(RuntimeTest, HandleSlabQueuePop) {
248248
}
249249

250250
// Pop all the slabs from the queue
251-
for (int i = 0; i < 10; i++) {
251+
for (size_t i = 0; i < 10; i++) {
252252
auto* slab = queue.pop();
253253
// Check that the slab is the same as the one that was pushed
254254
ASSERT_EQ(slab, slabs[i]);

0 commit comments

Comments
 (0)