Floating point numbers work, _start.S fix stack alignment, fix debug info
This commit is contained in:
33
ce/interp.c
33
ce/interp.c
@@ -11,6 +11,7 @@
|
||||
#include <kb.h>
|
||||
#include <liballoc.h>
|
||||
#include <path.h>
|
||||
#include <printf.h>
|
||||
#include <process.h>
|
||||
#include <stddef.h>
|
||||
#include <str_status.h>
|
||||
@@ -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 ();
|
||||
|
||||
@@ -9,7 +9,7 @@ cflags += -nostdinc \
|
||||
-Wextra
|
||||
|
||||
ifeq ($(buildtype),debug)
|
||||
cflags += -O0 -g
|
||||
cflags += -O0 -g3
|
||||
endif
|
||||
|
||||
ifeq ($(buildtype),release)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -3,6 +3,5 @@ _start:
|
||||
xorq %rbp, %rbp
|
||||
movq %rsp, %rbp
|
||||
andq $-16, %rsp
|
||||
subq $8, %rsp
|
||||
|
||||
callq __premain
|
||||
|
||||
Reference in New Issue
Block a user