From bf99bedfc59a11434f07736e3b476bc9a963809f Mon Sep 17 00:00:00 2001 From: kamkow1 Date: Sat, 7 Mar 2026 19:56:59 +0100 Subject: [PATCH] Floating point numbers work, _start.S fix stack alignment, fix debug info --- ce/interp.c | 33 +++++++++++++++++++++++++++++++-- generic/flags.mk | 2 +- kernel/generic/flags.mk | 2 +- libaux/printf_config.h | 4 ++-- libsystem/amd64/_start.S | 1 - 5 files changed, 35 insertions(+), 7 deletions(-) diff --git a/ce/interp.c b/ce/interp.c index 78a0d92..bc8c0bb 100644 --- a/ce/interp.c +++ b/ce/interp.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -24,6 +25,26 @@ bool interp_is_running (void) { return run; } void interp_shutdown (void) { run = false; } +static void human_size (double size, double* out, char** str) { + if (size >= 1024.0f && size < 1024.0f * 1024.0f) { + *out = (double)size / 1024.0f; + *str = "KiB"; + } else if (size >= 1024.0f * 1024.0f && size < 1024.0f * 1024.0f * 1024.0f) { + *out = (double)size / (1024.0f * 1024.0f); + *str = "MiB"; + } else if (size >= 1024.0f * 1024.0f * 1024.0f && size < 1024.0f * 1024.0f * 1024.0f * 1024.0f) { + *out = (double)size / (1024.0f * 1024.0f * 1024.0f); + *str = "GiB"; + } else if (size >= 1024.0f * 1024.0f * 1024.0f * 1024.0f && + size < 1024.0f * 1024.0f * 1024.0f * 1024.0f * 1024.0f) { + *out = (double)size / (1024.0f * 1024.0f * 1024.0f * 1024.0f); + *str = "TiB"; + } else { + *out = 0.0f; + *str = "???"; + } +} + static void echo (struct context* context, char** strings, size_t strings_count) { for (size_t i = 0; i < strings_count; i++) cprintf (context, "%s ", strings[i]); @@ -192,8 +213,16 @@ static void ls (struct context* context, const char* path_string) { read_dir_entry (path, &entry, entry_num); describe (entry.path, &desc); - cprintf (context, "%c %-40s %-40zu\n", (desc.type == FS_DIR ? 'D' : 'F'), entry.path, - desc.size); + char* hs_string; + double hs; + human_size ((double)desc.size, &hs, &hs_string); + + char size_buf[64]; + snprintf (size_buf, sizeof (size_buf), "%.2f %s", hs, hs_string); + + char type = (desc.type == FS_DIR ? 'D' : 'F'); + + cprintf (context, "%c %-40s %-40s\n", type, entry.path, size_buf); } volume_close (); diff --git a/generic/flags.mk b/generic/flags.mk index 20b5014..563f98b 100644 --- a/generic/flags.mk +++ b/generic/flags.mk @@ -9,7 +9,7 @@ cflags += -nostdinc \ -Wextra ifeq ($(buildtype),debug) - cflags += -O0 -g + cflags += -O0 -g3 endif ifeq ($(buildtype),release) diff --git a/kernel/generic/flags.mk b/kernel/generic/flags.mk index 109308b..de7e652 100644 --- a/kernel/generic/flags.mk +++ b/kernel/generic/flags.mk @@ -17,7 +17,7 @@ cflags += -DPRINTF_INCLUDE_CONFIG_H=1 \ -DXXH_NAMESPACE=LZ4_ ifeq ($(buildtype),debug) - cflags += -O0 -g + cflags += -O0 -g3 endif ifeq ($(buildtype),release) diff --git a/libaux/printf_config.h b/libaux/printf_config.h index 7380110..27c24da 100644 --- a/libaux/printf_config.h +++ b/libaux/printf_config.h @@ -2,7 +2,7 @@ #define _KERNEL_LIBK_PRINTF_CONFIG_H #define PRINTF_ALIAS_STANDARD_FUNCTION_NAMES_HARD 1 -#define PRINTF_SUPPORT_DECIMAL_SPECIFIERS 0 -#define PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS 0 +#define PRINTF_SUPPORT_DECIMAL_SPECIFIERS 1 +#define PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS 1 #endif // _KERNEL_LIBK_PRINTF_CONFIG_H diff --git a/libsystem/amd64/_start.S b/libsystem/amd64/_start.S index f3ffee1..409721c 100644 --- a/libsystem/amd64/_start.S +++ b/libsystem/amd64/_start.S @@ -3,6 +3,5 @@ _start: xorq %rbp, %rbp movq %rsp, %rbp andq $-16, %rsp - subq $8, %rsp callq __premain