summaryrefslogtreecommitdiffstats
path: root/arith.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-02-26 22:34:14 -0800
committerKaz Kylheku <kaz@kylheku.com>2016-02-26 22:34:14 -0800
commit875c0c2d16fbcaa61bfc46da58533ab0890bf513 (patch)
treedcc2c644127dc38c3b2a6b4cfda12491c8368399 /arith.h
parenta9e1bec854f6c0343dfb2cb32879cdb31d84f209 (diff)
downloadtxr-875c0c2d16fbcaa61bfc46da58533ab0890bf513.tar.gz
txr-875c0c2d16fbcaa61bfc46da58533ab0890bf513.tar.bz2
txr-875c0c2d16fbcaa61bfc46da58533ab0890bf513.zip
Functions for converting between buffers and integers.
These functions convert between positive integers, and fixed-size memory buffers representing pure binary numbers in big endian byte order. This functionality will be used in some upcoming networking code. * arith.c (num_from_buffer, num_to_buffer): New functions. * arith.h (num_from_buffer, num_to_buffer): Declared. * mpi/mpi.c (mp_to_unsigned_buf): New function. * mpi/mpi.h (mp_to_unsigned_buf): Declared.
Diffstat (limited to 'arith.h')
-rw-r--r--arith.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/arith.h b/arith.h
index 083a8a19..bc3a0568 100644
--- a/arith.h
+++ b/arith.h
@@ -28,6 +28,8 @@ val make_bignum(void);
val bignum(cnum cn);
val bignum_from_long(long l);
val bignum_from_uintptr(uint_ptr_t u);
+val num_from_buffer(mem_t *buf, int bytes);
+int num_to_buffer(val num, mem_t *buf, int bytes);
int highest_bit(int_ptr_t n);
val normalize(val bignum);
val in_int_ptr_range(val bignum);