diff --git a/build_config.rb b/build_config.rb index d379c7c..40f3b12 100644 --- a/build_config.rb +++ b/build_config.rb @@ -2,6 +2,7 @@ MRuby::CrossBuild.new ENV.fetch 'BUILD_NAME' do |conf| conf.toolchain :gcc conf.gem core: 'mruby-compiler' + conf.gem core: 'mruby-enumerator' conf.cc.flags << '-Wall' << diff --git a/src/main.c b/src/main.c index 429f9ba..71a70c6 100644 --- a/src/main.c +++ b/src/main.c @@ -40,6 +40,8 @@ void main( const uint32_t multiboot2_info_magic, const struct KernAux_Multiboot2_Info *const multiboot2_info ) { + kernaux_drivers_console_puts("========================================"); + kernaux_assert_cb = assert; ASSERT(multiboot2_info_magic == KERNAUX_MULTIBOOT2_INFO_MAGIC); @@ -97,22 +99,41 @@ void assert(const char *const file, const int line, const char *const str) void *my_calloc(size_t nmemb, size_t size) { - return KernAux_Malloc_calloc(&allocator.malloc, nmemb, size); + void *const result = KernAux_Malloc_calloc(&allocator.malloc, nmemb, size); + if (result) { + kernaux_drivers_console_printf("calloc(%lu, %lu) = %p\n", nmemb, size, result); + } else if (nmemb * size != 0) { + kernaux_drivers_console_printf("!calloc(%lu, %lu)\n", nmemb, size); + } + return result; } void my_free(void *ptr) { + kernaux_drivers_console_printf("free(%p)\n", ptr); KernAux_Malloc_free(&allocator.malloc, ptr); } void *my_malloc(size_t size) { - return KernAux_Malloc_malloc(&allocator.malloc, size); + void *const result = KernAux_Malloc_malloc(&allocator.malloc, size); + if (result) { + kernaux_drivers_console_printf("malloc(%lu) = %p\n", size, result); + } else if (size != 0) { + kernaux_drivers_console_printf("!malloc(%lu)\n", size); + } + return result; } void *my_realloc(void *ptr, size_t size) { - return KernAux_Malloc_realloc(&allocator.malloc, ptr, size); + void *const result = KernAux_Malloc_realloc(&allocator.malloc, ptr, size); + if (result) { + kernaux_drivers_console_printf("realloc(%p, %lu) = %p\n", ptr, size, result); + } else if (size != 0) { + kernaux_drivers_console_printf("!realloc(%p, %lu)\n", ptr, size); + } + return result; } bool load_module(