From 1a117c9edb8d860d359e551bd658b536b8f0e9fc Mon Sep 17 00:00:00 2001 From: "Mike D. Lowis" Date: Thu, 2 Apr 2015 10:03:18 -0400 Subject: [PATCH] Added coverage and profiling options fo rthe build and enabled warnings as errors --- build.rb | 19 +++++++++++++++++++ modules/atf | 2 +- source/runtime/gc.c | 14 +++++++++++--- source/runtime/gc.h | 4 +++- source/runtime/heap.c | 2 +- tests/test_segment.c | 2 +- 6 files changed, 36 insertions(+), 7 deletions(-) diff --git a/build.rb b/build.rb index 7508bde..bae9118 100755 --- a/build.rb +++ b/build.rb @@ -13,6 +13,25 @@ base_env = BuildEnv.new do |env| env.build_dir('modules', 'build/obj/modules') # Setup include paths env['CPPPATH'] += Dir['source/**/', 'modules/atf/source/'] + # Turn on all warnings and treat them as errors, Also C99 strict mode + env['CFLAGS'] += ['-Wall', '-Wextra', '-Werror'] + # Enable debug symbols for test + if Opts[:profile].include? "test" + env['CFLAGS'] += ['-g', '-O0'] + else + env['CFLAGS'] += ['-O3'] + end + # Enable profiling info + if Opts[:profile].include? "profile" + env['CFLAGS'] += ['-pg'] + env['LDFLAGS'] += ['-pg'] + end + + # Enable coverage info + if Opts[:profile].include? "coverage" + env['CFLAGS'] += ['--coverage'] + env['LDFLAGS'] += ['--coverage'] + end end #------------------------------------------------------------------------------ diff --git a/modules/atf b/modules/atf index 0110dca..04d4571 160000 --- a/modules/atf +++ b/modules/atf @@ -1 +1 @@ -Subproject commit 0110dca83199322915e157fc1278ee6b58dfb4f8 +Subproject commit 04d4571218dbef83a4321209c21b383defb9dc16 diff --git a/source/runtime/gc.c b/source/runtime/gc.c index 49e1410..da1a32d 100644 --- a/source/runtime/gc.c +++ b/source/runtime/gc.c @@ -10,14 +10,24 @@ static heap_t* heap = NULL; void gc_init(void* stack_bottom) { + (void)stack_bottom; heap = heap_create(); } -void* gc_alloc(uint64_t objmap, size_t num_slots) +void* gc_object(uint64_t objmap, size_t num_slots) { + (void)objmap; return heap_allocate(heap, num_slots+1); } +void* gc_allocate(size_t size) +{ + size_t slot_sz = sizeof(uintptr_t); + size_t remainder = size % slot_sz; + size_t num_slots = (size / slot_sz) + ((remainder == 0) ? 0 : (slot_sz - remainder)); + return heap_allocate(heap, num_slots + 1); +} + void gc_collect(void) { } @@ -27,5 +37,3 @@ void gc_shutdown(void) heap_destroy(heap); } -/*****************************************************************************/ - diff --git a/source/runtime/gc.h b/source/runtime/gc.h index dd14cc4..1e43fef 100644 --- a/source/runtime/gc.h +++ b/source/runtime/gc.h @@ -10,7 +10,9 @@ void gc_init(void* stack_bottom); -void* gc_alloc(uint64_t objmap, size_t size); +void* gc_object(uint64_t objmap, size_t num_slots); + +void* gc_allocate(size_t size); void gc_collect(void); diff --git a/source/runtime/heap.c b/source/runtime/heap.c index 2757725..4378d7d 100644 --- a/source/runtime/heap.c +++ b/source/runtime/heap.c @@ -12,7 +12,7 @@ heap_t* heap_create(void) void heap_destroy(heap_t* heap) { - int i; + unsigned int i; block_t* current = heap->blocks; /* Free all the large blocks */ while (NULL != current) { diff --git a/tests/test_segment.c b/tests/test_segment.c index f0e01ac..016e455 100644 --- a/tests/test_segment.c +++ b/tests/test_segment.c @@ -5,7 +5,7 @@ TEST_SUITE(Segment) { /* Verify: segment_create *************************************************************************/ TEST(Verify_Create_allocates_and_initializes_a_segment) { - int i; + unsigned int i; segment_t* seg = segment_create(2u, NULL); CHECK(seg->blocksize == 2u); CHECK(seg->start != NULL); -- 2.54.0