From a3e6d6aab61f4a24324ebb02ccff41e5cb56509d Mon Sep 17 00:00:00 2001 From: Baptiste Wicht Date: Mon, 4 Nov 2013 15:01:46 +0100 Subject: [PATCH] Improve compiling Use cross compiler instead of normal G++ Improve compiler options --- kernel/Makefile | 31 +++++++++------- kernel/include/ata.hpp | 2 +- kernel/include/console.hpp | 4 +- kernel/include/memory.hpp | 22 +++++------ kernel/include/thor.hpp | 4 +- kernel/include/timer.hpp | 8 ++-- kernel/include/types.hpp | 9 +++-- kernel/include/utils.hpp | 4 +- kernel/src/ata.cpp | 2 +- kernel/src/console.cpp | 19 +++++----- kernel/src/memory.cpp | 76 +++++++++++++++++++------------------- kernel/src/shell.cpp | 45 +++++++++++----------- kernel/src/thor.cpp | 4 +- kernel/src/timer.cpp | 14 +++---- kernel/src/utils.cpp | 6 +-- 15 files changed, 125 insertions(+), 125 deletions(-) diff --git a/kernel/Makefile b/kernel/Makefile index 89db49de..9e401229 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -1,5 +1,9 @@ -KERNEL_FLAGS=-masm=intel -Iinclude/ -O1 -std=c++11 -Wall -Wextra -pedantic -Wold-style-cast -Wshadow -fno-exceptions -fno-rtti -ffreestanding -fno-builtin -KERNEL_LINK_FLAGS=-std=c++11 -T linker.ld -ffreestanding -O1 -nostdlib +CC=x86_64-elf-g++ + +WARNING_FLAGS=-Wall -Wextra -pedantic -Wold-style-cast -Wshadow +CPP_FLAGS=-masm=intel -Iinclude/ -nostdlib -O1 -std=c++11 -fno-exceptions -fno-rtti -ffreestanding -lgcc -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow $(WARNING_FLAGS) +KERNEL_FLAGS=$(CPP_FLAGS) +KERNEL_LINK_FLAGS=-T linker.ld $(CPP_FLAGS) KERNEL_O_FILES=kernel.o keyboard.o console.o kernel_utils.o timer.o shell.o utils.o memory.o ata.o thor.o @@ -8,39 +12,40 @@ CRTEND_OBJ:=$(shell $(CC) $(CFLAGS) -print-file-name=crtend.o) LINK_O_FILES=$(KERNEL_O_FILES) + kernel.bin: $(LINK_O_FILES) - g++ $(KERNEL_LINK_FLAGS) -o kernel.bin.o $(LINK_O_FILES) + $(CC) $(KERNEL_LINK_FLAGS) -o kernel.bin.o $(LINK_O_FILES) objcopy -R .note -R .comment -S -O binary kernel.bin.o kernel.bin kernel.o: src/kernel.cpp - g++ $(KERNEL_FLAGS) -c src/kernel.cpp -o kernel.o + $(CC) $(KERNEL_FLAGS) -c src/kernel.cpp -o kernel.o keyboard.o: src/keyboard.cpp - g++ $(KERNEL_FLAGS) -c src/keyboard.cpp -o keyboard.o + $(CC) $(KERNEL_FLAGS) -c src/keyboard.cpp -o keyboard.o console.o: src/console.cpp - g++ $(KERNEL_FLAGS) -c src/console.cpp -o console.o + $(CC) $(KERNEL_FLAGS) -c src/console.cpp -o console.o kernel_utils.o: src/kernel_utils.cpp - g++ $(KERNEL_FLAGS) -c src/kernel_utils.cpp -o kernel_utils.o + $(CC) $(KERNEL_FLAGS) -c src/kernel_utils.cpp -o kernel_utils.o timer.o: src/timer.cpp - g++ $(KERNEL_FLAGS) -c src/timer.cpp -o timer.o + $(CC) $(KERNEL_FLAGS) -c src/timer.cpp -o timer.o shell.o: src/shell.cpp - g++ $(KERNEL_FLAGS) -c src/shell.cpp -o shell.o + $(CC) $(KERNEL_FLAGS) -c src/shell.cpp -o shell.o utils.o: src/utils.cpp - g++ $(KERNEL_FLAGS) -c src/utils.cpp -o utils.o + $(CC) $(KERNEL_FLAGS) -c src/utils.cpp -o utils.o memory.o: src/memory.cpp - g++ $(KERNEL_FLAGS) -c src/memory.cpp -o memory.o + $(CC) $(KERNEL_FLAGS) -c src/memory.cpp -o memory.o ata.o: src/ata.cpp - g++ $(KERNEL_FLAGS) -c src/ata.cpp -o ata.o + $(CC) $(KERNEL_FLAGS) -c src/ata.cpp -o ata.o thor.o: src/thor.cpp - g++ $(KERNEL_FLAGS) -c src/thor.cpp -o thor.o + $(CC) $(KERNEL_FLAGS) -c src/thor.cpp -o thor.o clean: rm -f *.o diff --git a/kernel/include/ata.hpp b/kernel/include/ata.hpp index 3e83efa1..d50056cf 100644 --- a/kernel/include/ata.hpp +++ b/kernel/include/ata.hpp @@ -14,6 +14,6 @@ void detect_disks(); uint8_t number_of_disks(); drive_descriptor& drive(uint8_t disk); -bool ata_read_sectors(drive_descriptor& drive, std::size_t start, uint8_t count, void* destination); +bool ata_read_sectors(drive_descriptor& drive, uint64_t start, uint8_t count, void* destination); #endif diff --git a/kernel/include/console.hpp b/kernel/include/console.hpp index 9b058440..16db8f6a 100644 --- a/kernel/include/console.hpp +++ b/kernel/include/console.hpp @@ -1,7 +1,7 @@ #ifndef CONSOLE_H #define CONSOLE_H -#include +#include "types.hpp" void set_column(long column); long get_column(); @@ -12,7 +12,7 @@ long get_line(); void wipeout(); void k_print(char key); void k_print(const char* string); -void k_print(std::size_t number); +void k_print(uint64_t number); void k_print_line(); void k_print_line(const char* string); void k_printf(const char* fmt, ...); diff --git a/kernel/include/memory.hpp b/kernel/include/memory.hpp index a0d69844..572d4193 100644 --- a/kernel/include/memory.hpp +++ b/kernel/include/memory.hpp @@ -4,29 +4,29 @@ #include "types.hpp" struct mmapentry { - std::size_t base; - std::size_t size; - std::size_t type; + uint64_t base; + uint64_t size; + uint64_t type; }; void load_memory_map(); bool mmap_failed(); -std::size_t mmap_entry_count(); -const mmapentry& mmap_entry(std::size_t i); -const char* str_e820_type(std::size_t type); +uint64_t mmap_entry_count(); +const mmapentry& mmap_entry(uint64_t i); +const char* str_e820_type(uint64_t type); void init_memory_manager(); -std::size_t* k_malloc(std::size_t bytes); -void k_free(std::size_t* block); +uint64_t* k_malloc(uint64_t bytes); +void k_free(uint64_t* block); template T* k_malloc(){ return reinterpret_cast(k_malloc(sizeof(T))); } -std::size_t available_memory(); -std::size_t free_memory(); -std::size_t used_memory(); +uint64_t available_memory(); +uint64_t free_memory(); +uint64_t used_memory(); #endif diff --git a/kernel/include/thor.hpp b/kernel/include/thor.hpp index 45bb687f..96905c1c 100644 --- a/kernel/include/thor.hpp +++ b/kernel/include/thor.hpp @@ -1,11 +1,9 @@ #ifndef THOR_H #define THOR_H -#include - #include "memory.hpp" -void* operator new (size_t size); +void* operator new (uint64_t size); void operator delete (void *p); #endif diff --git a/kernel/include/timer.hpp b/kernel/include/timer.hpp index a0281e1d..9d660628 100644 --- a/kernel/include/timer.hpp +++ b/kernel/include/timer.hpp @@ -1,12 +1,12 @@ #ifndef TIMER_H #define TIMER_H -#include +#include "types.hpp" void install_timer(); -void sleep_ms(std::size_t delay); +void sleep_ms(uint64_t delay); -std::size_t timer_ticks(); -std::size_t timer_seconds(); +uint64_t timer_ticks(); +uint64_t timer_seconds(); #endif diff --git a/kernel/include/types.hpp b/kernel/include/types.hpp index 7beda1e2..fda0a67f 100644 --- a/kernel/include/types.hpp +++ b/kernel/include/types.hpp @@ -1,17 +1,18 @@ #ifndef TYPES_H #define TYPES_H -#include - typedef unsigned int uint8_t __attribute__((__mode__(__QI__))); typedef unsigned int uint16_t __attribute__ ((__mode__ (__HI__))); typedef unsigned int uint32_t __attribute__ ((__mode__ (__SI__))); +typedef unsigned int uint32_t __attribute__ ((__mode__ (__SI__))); +typedef unsigned int uint64_t __attribute__ ((__mode__ (__DI__))); -typedef std::size_t uintptr_t; +typedef uint64_t uintptr_t; static_assert(sizeof(uint8_t) == 1, "uint32_t must be 1 byte long"); static_assert(sizeof(uint16_t) == 2, "uint32_t must be 2 bytes long"); static_assert(sizeof(uint32_t) == 4, "uint32_t must be 4 bytes long"); -static_assert(sizeof(uintptr_t) == sizeof(std::size_t*), "uintptr_t must have the same size as a pointer"); +static_assert(sizeof(uint64_t) == 8, "uint64_t must be 8 bytes long"); +static_assert(sizeof(uintptr_t) == sizeof(uint64_t*), "uintptr_t must have the same size as a pointer"); #endif diff --git a/kernel/include/utils.hpp b/kernel/include/utils.hpp index 834c2494..4e98a3d4 100644 --- a/kernel/include/utils.hpp +++ b/kernel/include/utils.hpp @@ -1,9 +1,9 @@ #ifndef UTILS_H #define UTILS_H -#include +#include "types.hpp" -std::size_t parse(const char* str); +uint64_t parse(const char* str); bool str_equals(const char* a, const char* b); bool str_contains(const char* a, char c); diff --git a/kernel/src/ata.cpp b/kernel/src/ata.cpp index a5d86da0..cbc78bb8 100644 --- a/kernel/src/ata.cpp +++ b/kernel/src/ata.cpp @@ -147,7 +147,7 @@ drive_descriptor& drive(uint8_t disk){ return drives[disk]; } -bool ata_read_sectors(drive_descriptor& drive, std::size_t start, uint8_t count, void* destination){ +bool ata_read_sectors(drive_descriptor& drive, uint64_t start, uint8_t count, void* destination){ //Select the device if(!select_device(drive)){ return false; diff --git a/kernel/src/console.cpp b/kernel/src/console.cpp index b440114c..477fd7d9 100644 --- a/kernel/src/console.cpp +++ b/kernel/src/console.cpp @@ -1,5 +1,4 @@ -#include -#include +#include #include "console.hpp" #include "types.hpp" @@ -68,7 +67,7 @@ void k_print_line(const char* string){ ++current_line; } -std::size_t digits(std::size_t number){ +uint64_t digits(uint64_t number){ if(number < 10){ return 1; } @@ -83,7 +82,7 @@ std::size_t digits(std::size_t number){ return i; } -void k_print(std::size_t number){ +void k_print(uint64_t number){ if(number == 0){ k_print('0'); return; @@ -130,7 +129,7 @@ void wipeout(){ current_column = 0; for(int line = 0; line < 25; ++line){ - for(std::size_t column = 0; column < 80; ++column){ + for(uint64_t column = 0; column < 80; ++column){ k_print(' '); } } @@ -151,13 +150,13 @@ void k_printf(const char* fmt, ...){ } else { ch = *(fmt++); - std::size_t min_width = 0; + uint64_t min_width = 0; while(ch >= '0' && ch <= '9'){ min_width = 10 * min_width + (ch - '0'); ch = *(fmt++); } - std::size_t min_digits = 0; + uint64_t min_digits = 0; if(ch == '.'){ ch = *(fmt++); @@ -171,7 +170,7 @@ void k_printf(const char* fmt, ...){ //Decimal if(ch == 'd'){ - auto arg = va_arg(va, std::size_t); + auto arg = va_arg(va, uint64_t); if(min_digits > 0){ auto d = digits(arg); @@ -194,7 +193,7 @@ void k_printf(const char* fmt, ...){ uint8_t buffer[20]; - auto arg = va_arg(va, std::size_t); + auto arg = va_arg(va, uint64_t); int i = 0; while(arg / 16 != 0){ @@ -245,7 +244,7 @@ void k_printf(const char* fmt, ...){ } //Memory else if(ch == 'm'){ - auto memory= va_arg(va, std::size_t); + auto memory= va_arg(va, uint64_t); if(memory > 1024 * 1024 * 1024){ k_print(memory / (1024 * 1024 * 1024)); diff --git a/kernel/src/memory.cpp b/kernel/src/memory.cpp index 8eca3b82..9cc97ab6 100644 --- a/kernel/src/memory.cpp +++ b/kernel/src/memory.cpp @@ -12,63 +12,63 @@ struct bios_mmap_entry { uint32_t damn_padding; } __attribute__((packed)); -std::size_t e820_failed = 0; -std::size_t entry_count = 0; +uint64_t e820_failed = 0; +uint64_t entry_count = 0; bios_mmap_entry* e820_address = 0; mmapentry e820_mmap[32]; -void mmap_query(std::size_t cmd, std::size_t* result){ - std::size_t tmp; +void mmap_query(uint64_t cmd, uint64_t* result){ + uint64_t tmp; __asm__ __volatile__ ("mov r8, %0; int 62; mov %1, rax" : : "dN" (cmd), "a" (tmp)); *result = tmp; } -std::size_t _available_memory; -std::size_t _used_memory; +uint64_t _available_memory; +uint64_t _used_memory; struct malloc_header_chunk { - std::size_t size; + uint64_t size; malloc_header_chunk* next; malloc_header_chunk* prev; }; struct malloc_footer_chunk { - std::size_t size; + uint64_t size; }; struct fake_head { - std::size_t size; + uint64_t size; malloc_header_chunk* next; malloc_header_chunk* prev; - std::size_t size_2; + uint64_t size_2; }; -const std::size_t META_SIZE = sizeof(malloc_header_chunk) + sizeof(malloc_footer_chunk); -const std::size_t MIN_SPLIT = 32; -const std::size_t BLOCK_SIZE = 4096; -const std::size_t MIN_BLOCKS = 4; +const uint64_t META_SIZE = sizeof(malloc_header_chunk) + sizeof(malloc_footer_chunk); +const uint64_t MIN_SPLIT = 32; +const uint64_t BLOCK_SIZE = 4096; +const uint64_t MIN_BLOCKS = 4; fake_head head; malloc_header_chunk* malloc_head = 0; -typedef std::size_t* page_entry; +typedef uint64_t* page_entry; typedef page_entry* pt_t; typedef pt_t* pdt_t; typedef pdt_t* pdpt_t; typedef pdpt_t* pml4t_t; mmapentry* current_mmap_entry = nullptr; -std::size_t current_mmap_entry_position; +uint64_t current_mmap_entry_position; -std::size_t pml4t_index = 0; -std::size_t pdpt_index = 0; -std::size_t pdt_index = 0; -std::size_t pt_index = 256; +uint64_t pml4t_index = 0; +uint64_t pdpt_index = 0; +uint64_t pdt_index = 0; +uint64_t pt_index = 256; -std::size_t* allocate_block(std::size_t blocks){ +uint64_t* allocate_block(uint64_t blocks){ if(!current_mmap_entry){ - for(std::size_t i = 0; i < entry_count; ++i){ + for(uint64_t i = 0; i < entry_count; ++i){ auto& entry = e820_mmap[i]; if(entry.type == 1 && entry.base >= 0x100000 && entry.size >= 16384){ @@ -92,11 +92,11 @@ std::size_t* allocate_block(std::size_t blocks){ //TODO Go to a new page table } - for(std::size_t i = 0; i < blocks; ++i){ + for(uint64_t i = 0; i < blocks; ++i){ pt[pt_index + i] = reinterpret_cast((current_mmap_entry_position + i * BLOCK_SIZE) | 0x3); } - auto block = reinterpret_cast(current_mmap_entry_position); + auto block = reinterpret_cast(current_mmap_entry_position); pt_index += blocks; current_mmap_entry_position += blocks * BLOCK_SIZE; @@ -130,14 +130,14 @@ void init_memory_manager(){ malloc_head->prev = header; } -std::size_t* k_malloc(std::size_t bytes){ +uint64_t* k_malloc(uint64_t bytes){ auto current = malloc_head->next; while(true){ if(current == malloc_head){ //There are no blocks big enough to hold this request - std::size_t* block = allocate_block(MIN_BLOCKS); + uint64_t* block = allocate_block(MIN_BLOCKS); auto header = reinterpret_cast(block); header->size = MIN_BLOCKS * BLOCK_SIZE - META_SIZE; @@ -196,11 +196,11 @@ std::size_t* k_malloc(std::size_t bytes){ current->prev = nullptr; current->next = nullptr; - return reinterpret_cast( + return reinterpret_cast( reinterpret_cast(current) + sizeof(malloc_header_chunk)); } -void k_free(std::size_t* block){ +void k_free(uint64_t* block){ auto free_header = reinterpret_cast( reinterpret_cast(block) - sizeof(malloc_header_chunk)); @@ -218,15 +218,15 @@ void k_free(std::size_t* block){ void load_memory_map(){ mmap_query(0, &e820_failed); mmap_query(1, &entry_count); - mmap_query(2, reinterpret_cast(&e820_address)); + mmap_query(2, reinterpret_cast(&e820_address)); if(!e820_failed && e820_address){ - for(std::size_t i = 0; i < entry_count; ++i){ + for(uint64_t i = 0; i < entry_count; ++i){ auto& bios_entry = e820_address[i]; auto& os_entry = e820_mmap[i]; - std::size_t base = bios_entry.base_low + (static_cast(bios_entry.base_high) << 32); - std::size_t length = bios_entry.length_low + (static_cast(bios_entry.length_high) << 32); + uint64_t base = bios_entry.base_low + (static_cast(bios_entry.base_high) << 32); + uint64_t length = bios_entry.length_low + (static_cast(bios_entry.length_high) << 32); os_entry.base = base; os_entry.size = length; @@ -243,7 +243,7 @@ void load_memory_map(){ } } -std::size_t mmap_entry_count(){ +uint64_t mmap_entry_count(){ return entry_count; } @@ -251,11 +251,11 @@ bool mmap_failed(){ return e820_failed; } -const mmapentry& mmap_entry(std::size_t i){ +const mmapentry& mmap_entry(uint64_t i){ return e820_mmap[i]; } -const char* str_e820_type(std::size_t type){ +const char* str_e820_type(uint64_t type){ switch(type){ case 1: return "Free"; @@ -275,14 +275,14 @@ const char* str_e820_type(std::size_t type){ } } -std::size_t available_memory(){ +uint64_t available_memory(){ return _available_memory; } -std::size_t used_memory(){ +uint64_t used_memory(){ return _used_memory; } -std::size_t free_memory(){ +uint64_t free_memory(){ return _available_memory - _used_memory; } diff --git a/kernel/src/shell.cpp b/kernel/src/shell.cpp index 6ad7188a..fc99ffd0 100644 --- a/kernel/src/shell.cpp +++ b/kernel/src/shell.cpp @@ -1,6 +1,3 @@ -#include -#include - #include "types.hpp" #include "keyboard.hpp" #include "kernel_utils.hpp" @@ -31,7 +28,7 @@ struct command_definition { void (*function)(const char*); }; -std::array commands = {{ +command_definition commands[10] = { {"reboot", reboot_command}, {"help", help_command}, {"uptime", uptime_command}, @@ -42,9 +39,9 @@ std::array commands = {{ {"mmap", mmap_command}, {"memory", memory_command}, {"disks", disks_command}, -}}; +}; -std::size_t current_input_length = 0; +uint64_t current_input_length = 0; char current_input[50]; void exec_command(); @@ -148,20 +145,20 @@ uint8_t get_RTC_register(int reg) { } void date_command(const char*){ - std::size_t second; - std::size_t minute; - std::size_t hour; - std::size_t day; - std::size_t month; - std::size_t year; + uint64_t second; + uint64_t minute; + uint64_t hour; + uint64_t day; + uint64_t month; + uint64_t year; - std::size_t last_second; - std::size_t last_minute; - std::size_t last_hour; - std::size_t last_day; - std::size_t last_month; - std::size_t last_year; - std::size_t registerB; + uint64_t last_second; + uint64_t last_minute; + uint64_t last_hour; + uint64_t last_day; + uint64_t last_month; + uint64_t last_year; + uint64_t registerB; //TODO When ACPI gets supported, get the address //of the century register and use it to make @@ -242,7 +239,7 @@ void mmap_command(const char*){ k_printf("There are %d mmap entry\n", mmap_entry_count()); k_print_line("Base End Size Type"); - for(std::size_t i = 0; i < mmap_entry_count(); ++i){ + for(uint64_t i = 0; i < mmap_entry_count(); ++i){ auto& entry = mmap_entry(i); k_printf("%.10h %.10h %.10h %8m %s\n", @@ -267,18 +264,18 @@ void memory_command(const char*){ } else { for(int i = 0; i < 80; i += 8){ k_printf("%.4h %.4h %.4h %.4h %.4h %.4h %.4h %.4h\n", - (std::size_t) buffer[i+0], (std::size_t) buffer[i+1], (std::size_t) buffer[i+2], (std::size_t) buffer[i+3], - (std::size_t) buffer[i+4], (std::size_t) buffer[i+5], (std::size_t) buffer[i+6], (std::size_t) buffer[i+7]); + (uint64_t) buffer[i+0], (uint64_t) buffer[i+1], (uint64_t) buffer[i+2], (uint64_t) buffer[i+3], + (uint64_t) buffer[i+4], (uint64_t) buffer[i+5], (uint64_t) buffer[i+6], (uint64_t) buffer[i+7]); } - k_free(reinterpret_cast(buffer)); + k_free(reinterpret_cast(buffer)); } } void disks_command(const char*){ k_print_line("Controller Drive Present"); - for(std::size_t i = 0; i < number_of_disks(); ++i){ + for(uint64_t i = 0; i < number_of_disks(); ++i){ auto& descriptor = drive(i); k_printf("%12h %8h %s\n", descriptor.controller, descriptor.drive, descriptor.present ? "Yes" : "No"); diff --git a/kernel/src/thor.cpp b/kernel/src/thor.cpp index f035e6f8..c18b3220 100644 --- a/kernel/src/thor.cpp +++ b/kernel/src/thor.cpp @@ -1,10 +1,10 @@ #include "thor.hpp" #include "memory.hpp" -void* operator new (size_t size){ +void* operator new (uint64_t size){ return k_malloc(size); } void operator delete (void* p){ - k_free(reinterpret_cast(p)); + k_free(reinterpret_cast(p)); } diff --git a/kernel/src/timer.cpp b/kernel/src/timer.cpp index b5a70bf6..68baa861 100644 --- a/kernel/src/timer.cpp +++ b/kernel/src/timer.cpp @@ -4,10 +4,10 @@ namespace { -std::size_t _timer_ticks = 0; -std::size_t _timer_seconds = 0; +uint64_t _timer_ticks = 0; +uint64_t _timer_seconds = 0; -volatile std::size_t _timer_countdown = 0; +volatile uint64_t _timer_countdown = 0; void timer_handler(){ ++_timer_ticks; @@ -24,7 +24,7 @@ void timer_handler(){ } void install_timer(){ - std::size_t divisor = 1193180 / 1000; + uint64_t divisor = 1193180 / 1000; out_byte(0x43, 0x36); out_byte(0x40, static_cast(divisor)); @@ -33,7 +33,7 @@ void install_timer(){ register_irq_handler<0>(timer_handler); } -void sleep_ms(std::size_t delay){ +void sleep_ms(uint64_t delay){ _timer_countdown = delay; while(true){ @@ -54,10 +54,10 @@ void sleep_ms(std::size_t delay){ __asm__ __volatile__ ("sti"); } -std::size_t timer_ticks(){ +uint64_t timer_ticks(){ return _timer_ticks; } -std::size_t timer_seconds(){ +uint64_t timer_seconds(){ return _timer_seconds; } diff --git a/kernel/src/utils.cpp b/kernel/src/utils.cpp index 3eb2c8b1..e60bd508 100644 --- a/kernel/src/utils.cpp +++ b/kernel/src/utils.cpp @@ -9,7 +9,7 @@ bool str_equals(const char* a, const char* b){ return *a == *b; } -std::size_t parse(const char* str){ +uint64_t parse(const char* str){ int i = 0; const char* it = str; @@ -17,8 +17,8 @@ std::size_t parse(const char* str){ ++i; } - std::size_t factor = 1; - std::size_t acc = 0; + uint64_t factor = 1; + uint64_t acc = 0; for(; i >= 0; --i){ acc += (str[i] - '0') * factor;