aboutsummaryrefslogtreecommitdiff
path: root/c/core.c
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-04-17 21:49:07 -0500
committerJoel Martin <github@martintribe.org>2014-04-17 21:49:07 -0500
commitdb4c329aff4621e05b92a55be4f18173f5a4f655 (patch)
tree92baaa6d88246e509cfd6a7d03d8fab997e0b935 /c/core.c
parent8cb5cda46cf3aef847ae3926dc53a5e5f87fe261 (diff)
downloadmal-db4c329aff4621e05b92a55be4f18173f5a4f655.tar.gz
mal-db4c329aff4621e05b92a55be4f18173f5a4f655.zip
All: perf test, Makefile refactor, add *host-language*
Other: - bash,make,postscript: quasiquote of vectors - Fix Java slurp - add time function to core.mal - switches on *host-language* for make time-secs vs time-ms - Ignore */experiments directories
Diffstat (limited to 'c/core.c')
-rw-r--r--c/core.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/c/core.c b/c/core.c
index 2c76a95..10c9fc9 100644
--- a/c/core.c
+++ b/c/core.c
@@ -135,6 +135,15 @@ WRAP_INTEGER_CMP_OP(gte,>=)
WRAP_INTEGER_CMP_OP(lt,<)
WRAP_INTEGER_CMP_OP(lte,<=)
+MalVal *time_ms(MalVal *_) {
+ struct timeval tv;
+ long msecs;
+ gettimeofday(&tv, NULL);
+ msecs = tv.tv_sec * 1000 + tv.tv_usec/1000.0 + 0.5;
+
+ return malval_new_integer(msecs);
+}
+
// List functions
@@ -422,7 +431,7 @@ MalVal *swap_BANG(MalVal *args) {
-core_ns_entry core_ns[53] = {
+core_ns_entry core_ns[54] = {
{"=", (void*(*)(void*))equal_Q, 2},
{"throw", (void*(*)(void*))throw, 1},
{"nil?", (void*(*)(void*))nil_Q, 1},
@@ -446,6 +455,7 @@ core_ns_entry core_ns[53] = {
{"-", (void*(*)(void*))int_minus, 2},
{"*", (void*(*)(void*))int_multiply, 2},
{"/", (void*(*)(void*))int_divide, 2},
+ {"time-ms", (void*(*)(void*))time_ms, 0},
{"list", (void*(*)(void*))list, -1},
{"list?", (void*(*)(void*))list_Q, 1},