summaryrefslogtreecommitdiffstats
path: root/arith.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2017-04-21 21:26:19 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-04-21 21:26:19 -0700
commitb1726e0878b679508dda20166b04cac12213729b (patch)
tree208cc17ff9ebb6ce5862341675cf6d27749a1724 /arith.c
parentb4d9e01b4c68a995d39f7c01c43ba2aed02c968b (diff)
downloadtxr-b1726e0878b679508dda20166b04cac12213729b.tar.gz
txr-b1726e0878b679508dda20166b04cac12213729b.tar.bz2
txr-b1726e0878b679508dda20166b04cac12213729b.zip
Buffers implementation, part three: get functions.
* arith.c (unum): New function. * arith.h (unum): Declared. * buf.c (buf_get_bytes): New static function. (buf_get_i8, buf_get_u8, buf_get_i16, buf_get_u16, buf_get_i32, buf_get_u32, buf_get_i64, buf_get_u64, buf_get_char, buf_get_uchar, buf_get_short, buf_get_ushort, buf_get_int, buf_get_uint, buf_get_long, buf_get_ulong, buf_get_double): Stubs implemented.
Diffstat (limited to 'arith.c')
-rw-r--r--arith.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/arith.c b/arith.c
index 5678453d..c17ab743 100644
--- a/arith.c
+++ b/arith.c
@@ -179,6 +179,17 @@ ucnum c_unum(val num)
}
}
+val unum(ucnum u)
+{
+ if (u <= INT_PTR_MAX) {
+ return num(u);
+ } else {
+ val n = make_bignum();
+ mp_set_uintptr(mp(n), u);
+ return n;
+ }
+}
+
int highest_bit(int_ptr_t n)
{
#if SIZEOF_PTR == 8