summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-06-26 06:39:24 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-06-26 06:39:24 -0700
commit86d5c1a3fcf5f9fcbcbf312eea3d6fad7f6bd10d (patch)
tree8221e9e8446b7ec862bfabbed849cf6b440a804b /lib.c
parentabd32610d0c1b75226e0edb6a34c54723de83eb6 (diff)
downloadtxr-86d5c1a3fcf5f9fcbcbf312eea3d6fad7f6bd10d.tar.gz
txr-86d5c1a3fcf5f9fcbcbf312eea3d6fad7f6bd10d.tar.bz2
txr-86d5c1a3fcf5f9fcbcbf312eea3d6fad7f6bd10d.zip
New cptr functions cptr-cast and int-cptr.
* eval.c (eval_init): Register new intrinsics cptr-cast and int-cptr. * lib.c (cptr_cast, int_cptr): New functions. * lib.h (cptr_cast, int_cptr): Declared. * txr.1: Documented.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib.c b/lib.c
index 80d056b4..fc70090a 100644
--- a/lib.c
+++ b/lib.c
@@ -7558,6 +7558,17 @@ val cptr_free(val cptr)
return cptr;
}
+val cptr_cast(val to_type, val cptr)
+{
+ mem_t *ptr = cptr_handle(cptr, nil, lit("cptr-cast"));
+ return cptr_typed(ptr, to_type, 0);
+}
+
+val int_cptr(val cptr)
+{
+ return num(coerce(cnum, cptr_handle(cptr, nil, lit("int-cptr"))));
+}
+
mem_t *cptr_handle(val cptr, val type_sym, val self)
{
if (type(cptr) != CPTR)