From bcc104ce79f153cd853920ff924e13f84793b61c Mon Sep 17 00:00:00 2001 From: Lindsey Kuper Date: Thu, 24 Mar 2011 18:20:49 -0700 Subject: A first stab at the 'nbody' demo, with support for calling C sqrt(). --- src/rt/rust_builtin.cpp | 5 +++++ src/rt/rust_internal.h | 1 + src/rt/rustrt.def.in | 2 ++ 3 files changed, 8 insertions(+) (limited to 'src/rt') diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp index 98333774..2de9d7f4 100644 --- a/src/rt/rust_builtin.cpp +++ b/src/rt/rust_builtin.cpp @@ -51,6 +51,11 @@ last_os_error(rust_task *task) { return st; } +extern "C" CDECL +void squareroot(rust_task *task, double *input, double *output) { + *output = sqrt(*input); +} + extern "C" CDECL size_t size_of(rust_task *task, type_desc *t) { return t->size; diff --git a/src/rt/rust_internal.h b/src/rt/rust_internal.h index 5bd62d2b..a1cc8e51 100644 --- a/src/rt/rust_internal.h +++ b/src/rt/rust_internal.h @@ -16,6 +16,7 @@ #include #include #include +#include #include "rust.h" #include "rand.h" diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in index f8ac1ed4..df9e26af 100644 --- a/src/rt/rustrt.def.in +++ b/src/rt/rustrt.def.in @@ -20,6 +20,7 @@ rust_get_stdout rust_run_program rust_start size_of +squareroot str_alloc str_buf str_byte_len @@ -39,6 +40,7 @@ upcall_get_type_desc upcall_grow_task upcall_join upcall_kill +upcall_log_double upcall_log_int upcall_log_str upcall_malloc -- cgit v1.2.3