Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cmake project for benchmark, fix tests compile warning on msvc #110

Merged
merged 3 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,6 @@ out/*

# visual studio metadata
.vs/*

# visual studio cmake settings
CMakeSettings.json
16 changes: 8 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
cmake_minimum_required(VERSION 3.10)
project(buddy_alloc)
set(C_STANDARD C99)

# Compile C tests
project(buddy_tests)
set(C_STANDARD C99)

# Add tests.c
set(SOURCE_FILES tests.c)

# Add executable target with source files listed in SOURCE_FILES variable
add_executable(buddy_tests ${SOURCE_FILES})

# Compile CPP translation unit
project(buddy_cpp_translation_unit)

# Add test_cpp.cpp
set(CXX_STANDARD C++11)
set(SOURCE_FILES testcxx.cpp)
add_executable(buddy_cpp_translation_unit ${SOURCE_FILES})

# Add executable target with source files listed in SOURCE_FILES variable
add_executable(buddy_cpp_translation_unit ${SOURCE_FILES})
# Compile benchmark
project(buddy_bench)
set(C_STANDARD C99)
set(SOURCE_FILES bench.c)
add_executable(buddy_bench ${SOURCE_FILES})
4 changes: 3 additions & 1 deletion tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -1795,6 +1795,7 @@ void test_buddy_is_full(void) {
void test_buddy_slot_alignment(void) {
size_t arena_size = 4096;
size_t max_alignment = 4096;
size_t slot_alignment;
void *arena, *alloc, *slot;
struct buddy *buddy;
start_test;
Expand All @@ -1805,7 +1806,8 @@ void test_buddy_slot_alignment(void) {

for(size_t i = 0; i < (arena_size/alignment); i++) {
slot = buddy_malloc(buddy, alignment);
assert((((uintptr_t) slot) % alignment) == 0);
slot_alignment = ((uintptr_t)slot) % alignment;
assert(slot_alignment == 0);
}

assert(buddy_arena_free_size(buddy) == 0);
Expand Down