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 <kb.h>
|
||||||
#include <liballoc.h>
|
#include <liballoc.h>
|
||||||
#include <path.h>
|
#include <path.h>
|
||||||
|
#include <printf.h>
|
||||||
#include <process.h>
|
#include <process.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <str_status.h>
|
#include <str_status.h>
|
||||||
@@ -24,6 +25,26 @@ bool interp_is_running (void) { return run; }
|
|||||||
|
|
||||||
void interp_shutdown (void) { run = false; }
|
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) {
|
static void echo (struct context* context, char** strings, size_t strings_count) {
|
||||||
for (size_t i = 0; i < strings_count; i++)
|
for (size_t i = 0; i < strings_count; i++)
|
||||||
cprintf (context, "%s ", strings[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);
|
read_dir_entry (path, &entry, entry_num);
|
||||||
describe (entry.path, &desc);
|
describe (entry.path, &desc);
|
||||||
|
|
||||||
cprintf (context, "%c %-40s %-40zu\n", (desc.type == FS_DIR ? 'D' : 'F'), entry.path,
|
char* hs_string;
|
||||||
desc.size);
|
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 ();
|
volume_close ();
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ cflags += -nostdinc \
|
|||||||
-Wextra
|
-Wextra
|
||||||
|
|
||||||
ifeq ($(buildtype),debug)
|
ifeq ($(buildtype),debug)
|
||||||
cflags += -O0 -g
|
cflags += -O0 -g3
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(buildtype),release)
|
ifeq ($(buildtype),release)
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ cflags += -DPRINTF_INCLUDE_CONFIG_H=1 \
|
|||||||
-DXXH_NAMESPACE=LZ4_
|
-DXXH_NAMESPACE=LZ4_
|
||||||
|
|
||||||
ifeq ($(buildtype),debug)
|
ifeq ($(buildtype),debug)
|
||||||
cflags += -O0 -g
|
cflags += -O0 -g3
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(buildtype),release)
|
ifeq ($(buildtype),release)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#define _KERNEL_LIBK_PRINTF_CONFIG_H
|
#define _KERNEL_LIBK_PRINTF_CONFIG_H
|
||||||
|
|
||||||
#define PRINTF_ALIAS_STANDARD_FUNCTION_NAMES_HARD 1
|
#define PRINTF_ALIAS_STANDARD_FUNCTION_NAMES_HARD 1
|
||||||
#define PRINTF_SUPPORT_DECIMAL_SPECIFIERS 0
|
#define PRINTF_SUPPORT_DECIMAL_SPECIFIERS 1
|
||||||
#define PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS 0
|
#define PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS 1
|
||||||
|
|
||||||
#endif // _KERNEL_LIBK_PRINTF_CONFIG_H
|
#endif // _KERNEL_LIBK_PRINTF_CONFIG_H
|
||||||
|
|||||||
@@ -3,6 +3,5 @@ _start:
|
|||||||
xorq %rbp, %rbp
|
xorq %rbp, %rbp
|
||||||
movq %rsp, %rbp
|
movq %rsp, %rbp
|
||||||
andq $-16, %rsp
|
andq $-16, %rsp
|
||||||
subq $8, %rsp
|
|
||||||
|
|
||||||
callq __premain
|
callq __premain
|
||||||
|
|||||||
Reference in New Issue
Block a user