os_parse_float

This commit is contained in:
krzosa
2025-01-03 09:09:26 +01:00
parent 3cdfbd1957
commit da3fceb19f
5 changed files with 10 additions and 20 deletions

View File

@@ -9,23 +9,6 @@ struct date_t {
u16 year;
};
#if 0
typedef struct core_funcs_t core_funcs_t;
struct core_funcs_t {
void (*error_box)(char *str);
void (*console_log)(char *str);
date_t (*date_now)(void);
f64 (*milliseconds_now)(void);
void *(*reserve)(usize size);
b32 (*commit)(void *p, usize size);
b32 (*release)(void *p);
b32 (*decommit)(void *p, usize size);
};
#endif
fn void os_error_box(char *str);
fn void os_console_log(char *str);
fn date_t os_date_now(void);

View File

@@ -53,5 +53,9 @@ fn void os_console_log(char *str) {
puts(str);
}
fn f64 os_parse_float(char *str) {
return strtod(str, NULL);
}
fn void core_init(void) {
}

View File

@@ -34,8 +34,7 @@ fn void os_console_log(char *str) {
wasm_write_to_console((isize)str, str_len(str));
}
fn double strtod(const char *str, char **end_unused) {
assert(end_unused == NULL);
fn f64 os_parse_float(char *str) {
return wasm_parse_float((isize)str, str_len((char *)str));
}

View File

@@ -62,5 +62,9 @@ fn void os_console_log(char *str) {
puts(str);
}
fn f64 os_parse_float(char *str) {
return strtod(str, NULL);
}
fn void core_init(void) {
}

View File

@@ -483,7 +483,7 @@ fn u64 u64_from_s8(s8_t s, u64 base) {
fn f64 f64_from_s8(s8_t string) {
ma_temp_t scratch = ma_begin_scratch();
s8_t num_string = s8_copy(scratch.arena, string);
f64 result = strtod(num_string.str, NULL);
f64 result = os_parse_float(num_string.str);
ma_end_scratch(scratch);
return result;
}