commit c5ca583356dcc6e624992c018ff8cff0383e311d
parent 8559a84deee94e434389d90adc0035b969a76fce
Author: Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
Date: Tue, 31 May 2022 00:29:55 +0430
toctave.jitter: Remove memcpy
Diffstat:
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/toctave.jitter b/toctave.jitter
@@ -19,7 +19,6 @@ end
wrapped-functions
pow
- memcpy
toctave_var
toctave_var_set
end
@@ -85,19 +84,19 @@ printer-c
static void
double_literal_printer(jitter_print_context ctx, uintptr_t n)
{
- double d;
+ union double_uint64 x;
- memcpy(&d, &n, sizeof(n));
- jitter_print_double(ctx, d);
+ x.u64 = n;
+ jitter_print_double(ctx, x.d);
}
static void
var_literal_printer(jitter_print_context ctx, uintptr_t n)
{
- double d;
+ union double_uint64 x;
- memcpy(&d, &n, sizeof(n));
- n = nan_unbox(d); // reusing `n`
+ x.u64 = n;
+ n = nan_unbox(x.d); // reusing `n`
jitter_print_char_star(ctx, (const char*)n);
}
@@ -110,11 +109,10 @@ end
# Stack: ( -- a)
instruction push (?n double_literal_printer)
code
- uintptr_t n = JITTER_ARGN0;
- double d;
+ union double_uint64 x;
- memcpy(&d, &n, sizeof(n));
- TOCTAVE_PUSH_MAINSTACK(d);
+ x.u64 = JITTER_ARGN0;
+ TOCTAVE_PUSH_MAINSTACK(x.d);
end
end