summaryrefslogtreecommitdiff
path: root/src/libbiguint
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-02-21 12:05:07 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-02-21 12:05:07 +0000
commit49d8fa1058aaf23c29e074b2314492ae40d2f557 (patch)
tree393f884d5a99f984e992a0f35f1b02ac43536217 /src/libbiguint
parentfdffefb8032922ce7ffe4c00816072a8ff2148fc (diff)
downloadskalibs-49d8fa1058aaf23c29e074b2314492ae40d2f557.tar.xz
Types change: big pass on libstddjb and libunixonacid
libdatastruct still missing, library still not functional
Diffstat (limited to 'src/libbiguint')
-rw-r--r--src/libbiguint/bu_addc.c10
-rw-r--r--src/libbiguint/bu_cmp.c2
-rw-r--r--src/libbiguint/bu_copy.c2
-rw-r--r--src/libbiguint/bu_copy_internal.c2
-rw-r--r--src/libbiguint/bu_div.c2
-rw-r--r--src/libbiguint/bu_divmod_internal.c8
-rw-r--r--src/libbiguint/bu_fmt.c7
-rw-r--r--src/libbiguint/bu_gcd.c6
-rw-r--r--src/libbiguint/bu_len.c2
-rw-r--r--src/libbiguint/bu_mul.c8
-rw-r--r--src/libbiguint/bu_pack.c2
-rw-r--r--src/libbiguint/bu_pack_big.c2
-rw-r--r--src/libbiguint/bu_scan.c2
-rw-r--r--src/libbiguint/bu_scan_internal.c7
-rw-r--r--src/libbiguint/bu_slbc.c6
-rw-r--r--src/libbiguint/bu_srbc.c4
-rw-r--r--src/libbiguint/bu_subc.c10
-rw-r--r--src/libbiguint/bu_unpack.c2
-rw-r--r--src/libbiguint/bu_unpack_big.c2
-rw-r--r--src/libbiguint/bu_zero.c2
20 files changed, 43 insertions, 45 deletions
diff --git a/src/libbiguint/bu_addc.c b/src/libbiguint/bu_addc.c
index 20a2740..1a7f164 100644
--- a/src/libbiguint/bu_addc.c
+++ b/src/libbiguint/bu_addc.c
@@ -9,14 +9,14 @@
#include <errno.h>
#include <skalibs/biguint.h>
-int bu_addc (uint32_t *c, unsigned int cn, uint32_t const *a, unsigned int an, uint32_t const *b, unsigned int bn, register int carry)
+int bu_addc (uint32_t *c, unsigned int cn, uint32_t const *a, unsigned int an, uint32_t const *b, unsigned int bn, int carry)
{
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
for (; i < cn ; i++)
{
- register uint32_t ai = (i < an) ? a[i] : 0 ;
- register uint32_t bi = (i < bn) ? b[i] : 0 ;
- register uint32_t ci = ai + bi + carry ;
+ uint32_t ai = (i < an) ? a[i] : 0 ;
+ uint32_t bi = (i < bn) ? b[i] : 0 ;
+ uint32_t ci = ai + bi + carry ;
carry = (carry || bi) && (ci < ai) ;
c[i] = ci ;
}
diff --git a/src/libbiguint/bu_cmp.c b/src/libbiguint/bu_cmp.c
index 033c61c..f0363b7 100644
--- a/src/libbiguint/bu_cmp.c
+++ b/src/libbiguint/bu_cmp.c
@@ -3,7 +3,7 @@
#include <stdint.h>
#include <skalibs/biguint.h>
-int bu_cmp (register uint32_t const *a, register unsigned int an, register uint32_t const *b, register unsigned int bn)
+int bu_cmp (uint32_t const *a, unsigned int an, uint32_t const *b, unsigned int bn)
{
an = bu_len(a, an) ;
bn = bu_len(b, bn) ;
diff --git a/src/libbiguint/bu_copy.c b/src/libbiguint/bu_copy.c
index b975577..2822569 100644
--- a/src/libbiguint/bu_copy.c
+++ b/src/libbiguint/bu_copy.c
@@ -11,7 +11,7 @@
int bu_copy (uint32_t *b, unsigned int bn, uint32_t const *a, unsigned int an)
{
- register unsigned int alen = bu_len(a, an) ;
+ unsigned int alen = bu_len(a, an) ;
if (bn < alen)
{
bu_copy_internal(b, a, bn) ;
diff --git a/src/libbiguint/bu_copy_internal.c b/src/libbiguint/bu_copy_internal.c
index a869ea2..41fe205 100644
--- a/src/libbiguint/bu_copy_internal.c
+++ b/src/libbiguint/bu_copy_internal.c
@@ -3,7 +3,7 @@
#include <stdint.h>
#include <skalibs/biguint.h>
-void bu_copy_internal (register uint32_t *b, register uint32_t const *a, register unsigned int n)
+void bu_copy_internal (uint32_t *b, uint32_t const *a, unsigned int n)
{
while (n--) b[n] = a[n] ;
}
diff --git a/src/libbiguint/bu_div.c b/src/libbiguint/bu_div.c
index 47c48f8..7f2a6c0 100644
--- a/src/libbiguint/bu_div.c
+++ b/src/libbiguint/bu_div.c
@@ -13,7 +13,7 @@ int bu_div (uint32_t const *a, unsigned int an, uint32_t const *b, unsigned int
{
uint32_t qq[alen] ;
uint32_t rr[alen] ;
- register int qh, rh ;
+ int qh, rh ;
bu_copy_internal(rr, a, alen) ;
bu_div_internal(rr, alen, b, blen, qq, alen) ;
qh = bu_copy(q, qn, qq, alen) ;
diff --git a/src/libbiguint/bu_divmod_internal.c b/src/libbiguint/bu_divmod_internal.c
index ad0f277..13e60b0 100644
--- a/src/libbiguint/bu_divmod_internal.c
+++ b/src/libbiguint/bu_divmod_internal.c
@@ -9,10 +9,10 @@
Original idea: see http://research.sun.com/techrep/2001/abstract-95.html
*/
-void bu_divmod_internal (register uint32_t *u, register uint32_t *a, register uint32_t const *m, unsigned int n)
+void bu_divmod_internal (uint32_t *u, uint32_t *a, uint32_t const *m, unsigned int n)
{
- uint32_t bb[n] ; register uint32_t *b = bb ;
- uint32_t vv[n] ; register uint32_t *v = vv ;
+ uint32_t bb[n] ; uint32_t *b = bb ;
+ uint32_t vv[n] ; uint32_t *v = vv ;
bu_copy_internal(b, m, n) ;
bu_zero(v, n) ;
@@ -28,7 +28,7 @@ void bu_divmod_internal (register uint32_t *u, register uint32_t *a, register ui
if ((a[0] == 1) && (bu_len(a, n) == 1)) break ;
if (bu_cmp(a, n, b, n) < 0)
{
- register uint32_t *t = a ; a = b ; b = t ;
+ uint32_t *t = a ; a = b ; b = t ;
t = u ; u = v ; v = t ;
}
bu_add(a, n, a, n, b, n) ;
diff --git a/src/libbiguint/bu_fmt.c b/src/libbiguint/bu_fmt.c
index 8e5dda1..4c3e7e7 100644
--- a/src/libbiguint/bu_fmt.c
+++ b/src/libbiguint/bu_fmt.c
@@ -1,9 +1,8 @@
/* ISC license. */
-#include <sys/types.h>
#include <stdint.h>
+#include <string.h>
#include <skalibs/uint32.h>
-#include <skalibs/bytestr.h>
#include <skalibs/biguint.h>
size_t bu_fmt (char *s, uint32_t const *x, unsigned int n)
@@ -13,8 +12,8 @@ size_t bu_fmt (char *s, uint32_t const *x, unsigned int n)
{
char fmt[8] ;
size_t i = uint32_xfmt(fmt, x[n]) ;
- byte_copy(s+len, 8-i, "00000000") ;
- byte_copy(s+len+8-i, i, fmt) ;
+ memcpy(s+len, "00000000", 8-i) ;
+ memcpy(s+len+8-i, fmt, i) ;
len += 8 ;
}
return len ;
diff --git a/src/libbiguint/bu_gcd.c b/src/libbiguint/bu_gcd.c
index 919c868..11c14e0 100644
--- a/src/libbiguint/bu_gcd.c
+++ b/src/libbiguint/bu_gcd.c
@@ -7,8 +7,8 @@ int bu_gcd (uint32_t *r, unsigned int rn, uint32_t const *a, unsigned int an, ui
{
if (bu_cmp(a, an, b, bn) < 0)
{
- register uint32_t const *t = a ;
- register unsigned int tn = an ;
+ uint32_t const *t = a ;
+ unsigned int tn = an ;
a = b ; an = bn ;
b = t ; bn = tn ;
}
@@ -23,7 +23,7 @@ int bu_gcd (uint32_t *r, unsigned int rn, uint32_t const *a, unsigned int an, ui
while (bu_len(bbb, an))
{
- register uint32_t *ttt = aaa ;
+ uint32_t *ttt = aaa ;
bu_div_internal(aaa, an, bbb, an, trash, an) ;
aaa = bbb ;
bbb = ttt ;
diff --git a/src/libbiguint/bu_len.c b/src/libbiguint/bu_len.c
index b6be726..fb63cef 100644
--- a/src/libbiguint/bu_len.c
+++ b/src/libbiguint/bu_len.c
@@ -3,7 +3,7 @@
#include <stdint.h>
#include <skalibs/biguint.h>
-unsigned int bu_len (register uint32_t const *a, register unsigned int n)
+unsigned int bu_len (uint32_t const *a, unsigned int n)
{
while (n--) if (a[n]) return n+1 ;
return 0 ;
diff --git a/src/libbiguint/bu_mul.c b/src/libbiguint/bu_mul.c
index 45d0efe..16043fd 100644
--- a/src/libbiguint/bu_mul.c
+++ b/src/libbiguint/bu_mul.c
@@ -11,15 +11,15 @@ int bu_mul (uint32_t *x, unsigned int xn, uint32_t const *a, unsigned int an, ui
unsigned int alen = bu_len(a, an) ;
unsigned int blen = bu_len(b, bn) ;
uint32_t c[alen + blen] ;
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
bu_zero(c, alen + blen) ;
for (; i < alen ; i++)
{
- register uint32_t carry = 0 ;
- register unsigned int j = 0 ;
+ uint32_t carry = 0 ;
+ unsigned int j = 0 ;
for (; j < blen ; j++)
{
- register uint64 t = a[i] ;
+ uint64_t t = a[i] ;
t *= b[j] ;
t += c[i+j] ;
t += carry ;
diff --git a/src/libbiguint/bu_pack.c b/src/libbiguint/bu_pack.c
index a71cec9..a2d37dc 100644
--- a/src/libbiguint/bu_pack.c
+++ b/src/libbiguint/bu_pack.c
@@ -4,7 +4,7 @@
#include <skalibs/uint32.h>
#include <skalibs/biguint.h>
-void bu_pack (char *s, uint32_t const *a, register unsigned int n)
+void bu_pack (char *s, uint32_t const *a, unsigned int n)
{
while (n--) uint32_pack(s + (n<<2), a[n]) ;
}
diff --git a/src/libbiguint/bu_pack_big.c b/src/libbiguint/bu_pack_big.c
index 41a6694..d5c5d48 100644
--- a/src/libbiguint/bu_pack_big.c
+++ b/src/libbiguint/bu_pack_big.c
@@ -6,6 +6,6 @@
void bu_pack_big (char *s, uint32_t const *a, unsigned int n)
{
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
for (; i < n ; i++) uint32_pack_big(s + (i<<2), a[n-1-i]) ;
}
diff --git a/src/libbiguint/bu_scan.c b/src/libbiguint/bu_scan.c
index 76c4b4e..c5deb82 100644
--- a/src/libbiguint/bu_scan.c
+++ b/src/libbiguint/bu_scan.c
@@ -13,7 +13,7 @@
int bu_scan (char const *s, size_t len, uint32_t *x, unsigned int xn, size_t zeron)
{
- register size_t n = bitarray_div8(zeron) ;
+ size_t n = bitarray_div8(zeron) ;
if (xn < n) return (errno = EOVERFLOW, 0) ;
bu_scan_internal(s, len, x) ;
bu_zero(x + n, xn - n) ;
diff --git a/src/libbiguint/bu_scan_internal.c b/src/libbiguint/bu_scan_internal.c
index 49388cf..15c2f0f 100644
--- a/src/libbiguint/bu_scan_internal.c
+++ b/src/libbiguint/bu_scan_internal.c
@@ -1,9 +1,8 @@
/* ISC license. */
-#include <sys/types.h>
#include <stdint.h>
+#include <string.h>
#include <skalibs/uint32.h>
-#include <skalibs/bytestr.h>
#include <skalibs/biguint.h>
void bu_scan_internal (char const *s, size_t len, uint32_t *x)
@@ -12,12 +11,12 @@ void bu_scan_internal (char const *s, size_t len, uint32_t *x)
size_t i = 0 ;
if (len & 7)
{
- byte_copy(fmt, len & 7, s) ;
+ memcpy(fmt, s, len & 7) ;
uint32_xscan(fmt, x + (len >> 3)) ;
}
for (; i < (len >> 3) ; i++)
{
- byte_copy(fmt, 8, s + len - 8 - (i << 3)) ;
+ memcpy(fmt, s + len - 8 - (i << 3), 8) ;
uint32_xscan(fmt, x + i) ;
}
}
diff --git a/src/libbiguint/bu_slbc.c b/src/libbiguint/bu_slbc.c
index d87af36..a39ef15 100644
--- a/src/libbiguint/bu_slbc.c
+++ b/src/libbiguint/bu_slbc.c
@@ -3,13 +3,13 @@
#include <stdint.h>
#include <skalibs/biguint.h>
-int bu_slbc (register uint32_t *a, register unsigned int n, register int carry)
+int bu_slbc (uint32_t *a, unsigned int n, int carry)
{
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
carry = !!carry ;
for (; i < n ; i++)
{
- register int c = a[i] >> 31 ;
+ int c = a[i] >> 31 ;
a[i] = (a[i] << 1) | carry ;
carry = c ;
}
diff --git a/src/libbiguint/bu_srbc.c b/src/libbiguint/bu_srbc.c
index a2dbab5..5e1fbc4 100644
--- a/src/libbiguint/bu_srbc.c
+++ b/src/libbiguint/bu_srbc.c
@@ -3,11 +3,11 @@
#include <stdint.h>
#include <skalibs/biguint.h>
-int bu_srbc (register uint32_t *a, register unsigned int n, register int carry)
+int bu_srbc (uint32_t *a, unsigned int n, int carry)
{
while (n--)
{
- register int c = a[n] & 1 ;
+ int c = a[n] & 1 ;
a[n] = (a[n] >> 1) | (carry ? 0x80000000U : 0) ;
carry = c ;
}
diff --git a/src/libbiguint/bu_subc.c b/src/libbiguint/bu_subc.c
index cff2a05..b5b6da5 100644
--- a/src/libbiguint/bu_subc.c
+++ b/src/libbiguint/bu_subc.c
@@ -9,14 +9,14 @@
#include <stdint.h>
#include <skalibs/biguint.h>
-int bu_subc (uint32_t *c, unsigned int cn, uint32_t const *a, unsigned int an, uint32_t const *b, unsigned int bn, register int carry)
+int bu_subc (uint32_t *c, unsigned int cn, uint32_t const *a, unsigned int an, uint32_t const *b, unsigned int bn, int carry)
{
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
for (; i < cn ; i++)
{
- register uint32_t ai = (i < an) ? a[i] : 0 ;
- register uint32_t bi = (i < bn) ? b[i] : 0 ;
- register uint32_t ci = ai - bi - carry ;
+ uint32_t ai = (i < an) ? a[i] : 0 ;
+ uint32_t bi = (i < bn) ? b[i] : 0 ;
+ uint32_t ci = ai - bi - carry ;
carry = (carry || bi) && (ci > ai) ;
c[i] = ci ;
}
diff --git a/src/libbiguint/bu_unpack.c b/src/libbiguint/bu_unpack.c
index 8100037..6542d30 100644
--- a/src/libbiguint/bu_unpack.c
+++ b/src/libbiguint/bu_unpack.c
@@ -4,7 +4,7 @@
#include <skalibs/uint32.h>
#include <skalibs/biguint.h>
-void bu_unpack (char const *s, uint32_t *a, register unsigned int n)
+void bu_unpack (char const *s, uint32_t *a, unsigned int n)
{
while (n--) uint32_unpack(s + (n<<2), a + n) ;
}
diff --git a/src/libbiguint/bu_unpack_big.c b/src/libbiguint/bu_unpack_big.c
index 83cf805..52037ea 100644
--- a/src/libbiguint/bu_unpack_big.c
+++ b/src/libbiguint/bu_unpack_big.c
@@ -6,6 +6,6 @@
void bu_unpack_big (char const *s, uint32_t *a, unsigned int n)
{
- register unsigned int i = 0 ;
+ unsigned int i = 0 ;
for (; i < n ; i++) uint32_unpack_big(s + (i<<2), a + n - 1 - i) ;
}
diff --git a/src/libbiguint/bu_zero.c b/src/libbiguint/bu_zero.c
index 0d512bf..8033740 100644
--- a/src/libbiguint/bu_zero.c
+++ b/src/libbiguint/bu_zero.c
@@ -3,7 +3,7 @@
#include <stdint.h>
#include <skalibs/biguint.h>
-void bu_zero (register uint32_t *z, register unsigned int n)
+void bu_zero (uint32_t *z, unsigned int n)
{
while (n--) z[n] = 0 ;
}