summaryrefslogtreecommitdiff
path: root/src/libbiguint
diff options
context:
space:
mode:
Diffstat (limited to 'src/libbiguint')
-rw-r--r--src/libbiguint/bu_addc.c10
-rw-r--r--src/libbiguint/bu_addmod.c4
-rw-r--r--src/libbiguint/bu_cmp.c4
-rw-r--r--src/libbiguint/bu_copy.c4
-rw-r--r--src/libbiguint/bu_copy_internal.c4
-rw-r--r--src/libbiguint/bu_div.c8
-rw-r--r--src/libbiguint/bu_div_internal.c6
-rw-r--r--src/libbiguint/bu_divmod.c10
-rw-r--r--src/libbiguint/bu_divmod_internal.c10
-rw-r--r--src/libbiguint/bu_fmt.c8
-rw-r--r--src/libbiguint/bu_gcd.c16
-rw-r--r--src/libbiguint/bu_invmod.c6
-rw-r--r--src/libbiguint/bu_len.c4
-rw-r--r--src/libbiguint/bu_mod.c6
-rw-r--r--src/libbiguint/bu_mul.c12
-rw-r--r--src/libbiguint/bu_mulmod.c6
-rw-r--r--src/libbiguint/bu_pack.c3
-rw-r--r--src/libbiguint/bu_pack_big.c3
-rw-r--r--src/libbiguint/bu_scan.c7
-rw-r--r--src/libbiguint/bu_scan_internal.c6
-rw-r--r--src/libbiguint/bu_scanlen.c4
-rw-r--r--src/libbiguint/bu_slbc.c4
-rw-r--r--src/libbiguint/bu_srbc.c6
-rw-r--r--src/libbiguint/bu_subc.c10
-rw-r--r--src/libbiguint/bu_submod.c6
-rw-r--r--src/libbiguint/bu_unpack.c3
-rw-r--r--src/libbiguint/bu_unpack_big.c3
-rw-r--r--src/libbiguint/bu_zero.c4
28 files changed, 93 insertions, 84 deletions
diff --git a/src/libbiguint/bu_addc.c b/src/libbiguint/bu_addc.c
index cccc7a8..20a2740 100644
--- a/src/libbiguint/bu_addc.c
+++ b/src/libbiguint/bu_addc.c
@@ -5,18 +5,18 @@
#define _BSD_SOURCE
#endif
+#include <stdint.h>
#include <errno.h>
-#include <skalibs/uint32.h>
#include <skalibs/biguint.h>
-int bu_addc (uint32 *c, unsigned int cn, uint32 const *a, unsigned int an, uint32 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, register int carry)
{
register unsigned int i = 0 ;
for (; i < cn ; i++)
{
- register uint32 ai = (i < an) ? a[i] : 0 ;
- register uint32 bi = (i < bn) ? b[i] : 0 ;
- register uint32 ci = ai + bi + carry ;
+ 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 ;
carry = (carry || bi) && (ci < ai) ;
c[i] = ci ;
}
diff --git a/src/libbiguint/bu_addmod.c b/src/libbiguint/bu_addmod.c
index c997897..de3badc 100644
--- a/src/libbiguint/bu_addmod.c
+++ b/src/libbiguint/bu_addmod.c
@@ -1,9 +1,9 @@
/* ISC license. */
-#include <skalibs/uint32.h>
+#include <stdint.h>
#include <skalibs/biguint.h>
-int bu_addmod (uint32 *c, unsigned int cn, uint32 const *a, unsigned int an, uint32 const *b, unsigned int bn, uint32 const *m, unsigned int mn)
+int bu_addmod (uint32_t *c, unsigned int cn, uint32_t const *a, unsigned int an, uint32_t const *b, unsigned int bn, uint32_t const *m, unsigned int mn)
{
if (!bu_add(c, cn, a, an, b, bn)) return 0 ;
if (bu_cmp(c, cn, m, mn) >= 0) bu_sub(c, cn, c, cn, m, mn) ;
diff --git a/src/libbiguint/bu_cmp.c b/src/libbiguint/bu_cmp.c
index a6bfaeb..033c61c 100644
--- a/src/libbiguint/bu_cmp.c
+++ b/src/libbiguint/bu_cmp.c
@@ -1,9 +1,9 @@
/* ISC license. */
-#include <skalibs/uint32.h>
+#include <stdint.h>
#include <skalibs/biguint.h>
-int bu_cmp (register uint32 const *a, register unsigned int an, register uint32 const *b, register unsigned int bn)
+int bu_cmp (register uint32_t const *a, register unsigned int an, register uint32_t const *b, register 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 aff6e51..b975577 100644
--- a/src/libbiguint/bu_copy.c
+++ b/src/libbiguint/bu_copy.c
@@ -5,11 +5,11 @@
#define _BSD_SOURCE
#endif
+#include <stdint.h>
#include <errno.h>
-#include <skalibs/uint32.h>
#include <skalibs/biguint.h>
-int bu_copy (uint32 *b, unsigned int bn, uint32 const *a, unsigned int an)
+int bu_copy (uint32_t *b, unsigned int bn, uint32_t const *a, unsigned int an)
{
register unsigned int alen = bu_len(a, an) ;
if (bn < alen)
diff --git a/src/libbiguint/bu_copy_internal.c b/src/libbiguint/bu_copy_internal.c
index 919929b..a869ea2 100644
--- a/src/libbiguint/bu_copy_internal.c
+++ b/src/libbiguint/bu_copy_internal.c
@@ -1,9 +1,9 @@
/* ISC license. */
-#include <skalibs/uint32.h>
+#include <stdint.h>
#include <skalibs/biguint.h>
-void bu_copy_internal (register uint32 *b, register uint32 const *a, register unsigned int n)
+void bu_copy_internal (register uint32_t *b, register uint32_t const *a, register unsigned int n)
{
while (n--) b[n] = a[n] ;
}
diff --git a/src/libbiguint/bu_div.c b/src/libbiguint/bu_div.c
index c7718e2..47c48f8 100644
--- a/src/libbiguint/bu_div.c
+++ b/src/libbiguint/bu_div.c
@@ -1,18 +1,18 @@
/* ISC license. */
+#include <stdint.h>
#include <errno.h>
-#include <skalibs/uint32.h>
#include <skalibs/biguint.h>
-int bu_div (uint32 const *a, unsigned int an, uint32 const *b, unsigned int bn, uint32 *q, unsigned int qn, uint32 *r, unsigned int rn)
+int bu_div (uint32_t const *a, unsigned int an, uint32_t const *b, unsigned int bn, uint32_t *q, unsigned int qn, uint32_t *r, unsigned int rn)
{
unsigned int alen = bu_len(a, an) ;
unsigned int blen = bu_len(b, bn) ;
if (!blen) return (errno = EDOM, 0) ;
else
{
- uint32 qq[alen] ;
- uint32 rr[alen] ;
+ uint32_t qq[alen] ;
+ uint32_t rr[alen] ;
register int qh, rh ;
bu_copy_internal(rr, a, alen) ;
bu_div_internal(rr, alen, b, blen, qq, alen) ;
diff --git a/src/libbiguint/bu_div_internal.c b/src/libbiguint/bu_div_internal.c
index d1be789..9a0942c 100644
--- a/src/libbiguint/bu_div_internal.c
+++ b/src/libbiguint/bu_div_internal.c
@@ -1,21 +1,21 @@
/* ISC license. */
+#include <stdint.h>
#include <errno.h>
-#include <skalibs/uint32.h>
#include <skalibs/biguint.h>
/*
q = a/b, a = a mod b. Assumes b != 0 and qn >= alen - blen + 1.
*/
-void bu_div_internal (uint32 *a, unsigned int an, uint32 const *b, unsigned int bn, uint32 *q, unsigned int qn)
+void bu_div_internal (uint32_t *a, unsigned int an, uint32_t const *b, unsigned int bn, uint32_t *q, unsigned int qn)
{
unsigned int alen = bu_len(a, an) ;
unsigned int blen = bu_len(b, bn) ;
bu_zero(q, qn) ;
if (alen < blen) return ;
{
- uint32 bb[alen + 1] ;
+ uint32_t bb[alen + 1] ;
unsigned int i = 1 + ((alen - blen) << 5) ;
bu_zero(bb, alen - blen) ;
bu_copy_internal(bb + alen - blen, b, blen) ;
diff --git a/src/libbiguint/bu_divmod.c b/src/libbiguint/bu_divmod.c
index 5d5802f..80bcb6a 100644
--- a/src/libbiguint/bu_divmod.c
+++ b/src/libbiguint/bu_divmod.c
@@ -1,14 +1,14 @@
/* ISC license. */
+#include <stdint.h>
#include <errno.h>
-#include <skalibs/uint32.h>
#include <skalibs/biguint.h>
/*
q = y/x mod m.
*/
-int bu_divmod (uint32 *q, unsigned int qn, uint32 const *y, unsigned int yn, uint32 const *x, unsigned int xn, uint32 const *m, unsigned int mn)
+int bu_divmod (uint32_t *q, unsigned int qn, uint32_t const *y, unsigned int yn, uint32_t const *x, unsigned int xn, uint32_t const *m, unsigned int mn)
{
unsigned int ylen = bu_len(y, yn) ;
unsigned int xlen = bu_len(x, xn) ;
@@ -18,9 +18,9 @@ int bu_divmod (uint32 *q, unsigned int qn, uint32 const *y, unsigned int yn, uin
if (n < mlen) n = mlen ;
if (!n) return (errno = EDOM, 0) ;
{
- uint32 yy[n] ;
- uint32 xx[n] ;
- uint32 mm[n] ;
+ uint32_t yy[n] ;
+ uint32_t xx[n] ;
+ uint32_t mm[n] ;
bu_gcd(xx, n, x, xlen, m, mlen) ;
if ((xx[0] != 1) || (bu_len(xx, n) != 1)) return (errno = EDOM, 0) ;
bu_copy_internal(yy, y, ylen) ; bu_zero(yy+ylen, n-ylen) ;
diff --git a/src/libbiguint/bu_divmod_internal.c b/src/libbiguint/bu_divmod_internal.c
index 46d3335..ad0f277 100644
--- a/src/libbiguint/bu_divmod_internal.c
+++ b/src/libbiguint/bu_divmod_internal.c
@@ -1,6 +1,6 @@
/* ISC license. */
-#include <skalibs/uint32.h>
+#include <stdint.h>
#include <skalibs/biguint.h>
/*
@@ -9,10 +9,10 @@
Original idea: see http://research.sun.com/techrep/2001/abstract-95.html
*/
-void bu_divmod_internal (register uint32 *u, register uint32 *a, register uint32 const *m, unsigned int n)
+void bu_divmod_internal (register uint32_t *u, register uint32_t *a, register uint32_t const *m, unsigned int n)
{
- uint32 bb[n] ; register uint32 *b = bb ;
- uint32 vv[n] ; register uint32 *v = vv ;
+ uint32_t bb[n] ; register uint32_t *b = bb ;
+ uint32_t vv[n] ; register uint32_t *v = vv ;
bu_copy_internal(b, m, n) ;
bu_zero(v, n) ;
@@ -28,7 +28,7 @@ void bu_divmod_internal (register uint32 *u, register uint32 *a, register uint32
if ((a[0] == 1) && (bu_len(a, n) == 1)) break ;
if (bu_cmp(a, n, b, n) < 0)
{
- register uint32 *t = a ; a = b ; b = t ;
+ register 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 31fa706..8e5dda1 100644
--- a/src/libbiguint/bu_fmt.c
+++ b/src/libbiguint/bu_fmt.c
@@ -1,16 +1,18 @@
/* ISC license. */
+#include <sys/types.h>
+#include <stdint.h>
#include <skalibs/uint32.h>
#include <skalibs/bytestr.h>
#include <skalibs/biguint.h>
-unsigned int bu_fmt (char *s, uint32 const *x, unsigned int n)
+size_t bu_fmt (char *s, uint32_t const *x, unsigned int n)
{
- unsigned int len = 0 ;
+ size_t len = 0 ;
while (n--)
{
char fmt[8] ;
- unsigned int i = uint32_xfmt(fmt, x[n]) ;
+ size_t i = uint32_xfmt(fmt, x[n]) ;
byte_copy(s+len, 8-i, "00000000") ;
byte_copy(s+len+8-i, i, fmt) ;
len += 8 ;
diff --git a/src/libbiguint/bu_gcd.c b/src/libbiguint/bu_gcd.c
index d6c5791..919c868 100644
--- a/src/libbiguint/bu_gcd.c
+++ b/src/libbiguint/bu_gcd.c
@@ -1,29 +1,29 @@
/* ISC license. */
-#include <skalibs/uint32.h>
+#include <stdint.h>
#include <skalibs/biguint.h>
-int bu_gcd (uint32 *r, unsigned int rn, uint32 const *a, unsigned int an, uint32 const *b, unsigned int bn)
+int bu_gcd (uint32_t *r, unsigned int rn, uint32_t const *a, unsigned int an, uint32_t const *b, unsigned int bn)
{
if (bu_cmp(a, an, b, bn) < 0)
{
- register uint32 const *t = a ;
+ register uint32_t const *t = a ;
register unsigned int tn = an ;
a = b ; an = bn ;
b = t ; bn = tn ;
}
{
- uint32 trash[an] ;
- uint32 aa[an] ;
- uint32 bb[an] ;
- uint32 *aaa = aa, *bbb = bb ;
+ uint32_t trash[an] ;
+ uint32_t aa[an] ;
+ uint32_t bb[an] ;
+ uint32_t *aaa = aa, *bbb = bb ;
bu_copy_internal(aa, a, an) ;
bu_copy_internal(bb, b, bn) ;
bu_zero(bb+bn, an-bn) ;
while (bu_len(bbb, an))
{
- register uint32 *ttt = aaa ;
+ register uint32_t *ttt = aaa ;
bu_div_internal(aaa, an, bbb, an, trash, an) ;
aaa = bbb ;
bbb = ttt ;
diff --git a/src/libbiguint/bu_invmod.c b/src/libbiguint/bu_invmod.c
index ff209e7..7bd8fee 100644
--- a/src/libbiguint/bu_invmod.c
+++ b/src/libbiguint/bu_invmod.c
@@ -1,12 +1,12 @@
/* ISC license. */
-#include <skalibs/uint32.h>
+#include <stdint.h>
#include <skalibs/biguint.h>
/* x^-1 mod m. */
-int bu_invmod (uint32 *x, unsigned int xn, uint32 const *m, unsigned int mn)
+int bu_invmod (uint32_t *x, unsigned int xn, uint32_t const *m, unsigned int mn)
{
- uint32 const one = 1 ;
+ uint32_t const one = 1 ;
return bu_divmod(x, xn, &one, 1, x, xn, m, mn) ;
}
diff --git a/src/libbiguint/bu_len.c b/src/libbiguint/bu_len.c
index 0f6ec10..b6be726 100644
--- a/src/libbiguint/bu_len.c
+++ b/src/libbiguint/bu_len.c
@@ -1,9 +1,9 @@
/* ISC license. */
-#include <skalibs/uint32.h>
+#include <stdint.h>
#include <skalibs/biguint.h>
-unsigned int bu_len (register uint32 const *a, register unsigned int n)
+unsigned int bu_len (register uint32_t const *a, register unsigned int n)
{
while (n--) if (a[n]) return n+1 ;
return 0 ;
diff --git a/src/libbiguint/bu_mod.c b/src/libbiguint/bu_mod.c
index 2050320..ba021fb 100644
--- a/src/libbiguint/bu_mod.c
+++ b/src/libbiguint/bu_mod.c
@@ -1,10 +1,10 @@
/* ISC license. */
-#include <skalibs/uint32.h>
+#include <stdint.h>
#include <skalibs/biguint.h>
-int bu_mod (uint32 *a, unsigned int an, uint32 const *b, unsigned int bn)
+int bu_mod (uint32_t *a, unsigned int an, uint32_t const *b, unsigned int bn)
{
- uint32 q[an] ;
+ uint32_t q[an] ;
return bu_div(a, an, b, bn, q, an, a, an) ;
}
diff --git a/src/libbiguint/bu_mul.c b/src/libbiguint/bu_mul.c
index 184d652..45d0efe 100644
--- a/src/libbiguint/bu_mul.c
+++ b/src/libbiguint/bu_mul.c
@@ -1,21 +1,21 @@
/* ISC license. */
-#include <skalibs/uint32.h>
+#include <stdint.h>
#include <skalibs/uint64.h>
#include <skalibs/biguint.h>
/* No Karatsuba. Keep it simple, stupid. */
-int bu_mul (uint32 *x, unsigned int xn, uint32 const *a, unsigned int an, uint32 const *b, unsigned int bn)
+int bu_mul (uint32_t *x, unsigned int xn, uint32_t const *a, unsigned int an, uint32_t const *b, unsigned int bn)
{
unsigned int alen = bu_len(a, an) ;
unsigned int blen = bu_len(b, bn) ;
- uint32 c[alen + blen] ;
+ uint32_t c[alen + blen] ;
register unsigned int i = 0 ;
bu_zero(c, alen + blen) ;
for (; i < alen ; i++)
{
- register uint32 carry = 0 ;
+ register uint32_t carry = 0 ;
register unsigned int j = 0 ;
for (; j < blen ; j++)
{
@@ -23,8 +23,8 @@ int bu_mul (uint32 *x, unsigned int xn, uint32 const *a, unsigned int an, uint32
t *= b[j] ;
t += c[i+j] ;
t += carry ;
- c[i+j] = (uint32)t ;
- carry = (uint32)(t >> 32) ;
+ c[i+j] = (uint32_t)t ;
+ carry = (uint32_t)(t >> 32) ;
}
c[i+j] += carry ;
}
diff --git a/src/libbiguint/bu_mulmod.c b/src/libbiguint/bu_mulmod.c
index 18e5a1c..f44d209 100644
--- a/src/libbiguint/bu_mulmod.c
+++ b/src/libbiguint/bu_mulmod.c
@@ -1,15 +1,15 @@
/* ISC license. */
-#include <skalibs/uint32.h>
+#include <stdint.h>
#include <skalibs/biguint.h>
/* Nope, no Montgomery either. */
-int bu_mulmod (uint32 *c, unsigned int cn, uint32 const *a, unsigned int an, uint32 const *b, unsigned int bn, uint32 const *m, unsigned int mn)
+int bu_mulmod (uint32_t *c, unsigned int cn, uint32_t const *a, unsigned int an, uint32_t const *b, unsigned int bn, uint32_t const *m, unsigned int mn)
{
unsigned int alen = bu_len(a, an) ;
unsigned int blen = bu_len(b, bn) ;
- uint32 x[alen+blen] ;
+ uint32_t x[alen+blen] ;
if (!bu_mul(x, alen+blen, a, alen, b, blen)) return 0 ;
if (!bu_mod(x, alen+blen, m, mn)) return 0 ;
return bu_copy(c, cn, x, mn) ;
diff --git a/src/libbiguint/bu_pack.c b/src/libbiguint/bu_pack.c
index 0145b9f..a71cec9 100644
--- a/src/libbiguint/bu_pack.c
+++ b/src/libbiguint/bu_pack.c
@@ -1,9 +1,10 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/uint32.h>
#include <skalibs/biguint.h>
-void bu_pack (char *s, uint32 const *a, register unsigned int n)
+void bu_pack (char *s, uint32_t const *a, register 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 8340fd7..41a6694 100644
--- a/src/libbiguint/bu_pack_big.c
+++ b/src/libbiguint/bu_pack_big.c
@@ -1,9 +1,10 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/uint32.h>
#include <skalibs/biguint.h>
-void bu_pack_big (char *s, uint32 const *a, unsigned int n)
+void bu_pack_big (char *s, uint32_t const *a, unsigned int n)
{
register 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 42d4530..76c4b4e 100644
--- a/src/libbiguint/bu_scan.c
+++ b/src/libbiguint/bu_scan.c
@@ -5,14 +5,15 @@
#define _BSD_SOURCE
#endif
+#include <sys/types.h>
+#include <stdint.h>
#include <errno.h>
-#include <skalibs/uint32.h>
#include <skalibs/bitarray.h>
#include <skalibs/biguint.h>
-int bu_scan (char const *s, unsigned int len, uint32 *x, unsigned int xn, unsigned int zeron)
+int bu_scan (char const *s, size_t len, uint32_t *x, unsigned int xn, size_t zeron)
{
- register unsigned int n = bitarray_div8(zeron) ;
+ register 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 696880a..49388cf 100644
--- a/src/libbiguint/bu_scan_internal.c
+++ b/src/libbiguint/bu_scan_internal.c
@@ -1,13 +1,15 @@
/* ISC license. */
+#include <sys/types.h>
+#include <stdint.h>
#include <skalibs/uint32.h>
#include <skalibs/bytestr.h>
#include <skalibs/biguint.h>
-void bu_scan_internal (char const *s, unsigned int len, uint32 *x)
+void bu_scan_internal (char const *s, size_t len, uint32_t *x)
{
char fmt[9] = "\0\0\0\0\0\0\0\0" ;
- unsigned int i = 0 ;
+ size_t i = 0 ;
if (len & 7)
{
byte_copy(fmt, len & 7, s) ;
diff --git a/src/libbiguint/bu_scanlen.c b/src/libbiguint/bu_scanlen.c
index 88c6aee..ed93fa3 100644
--- a/src/libbiguint/bu_scanlen.c
+++ b/src/libbiguint/bu_scanlen.c
@@ -3,9 +3,9 @@
#include <skalibs/fmtscan.h>
#include <skalibs/biguint.h>
-unsigned int bu_scanlen (char const *s, unsigned int *zeron)
+size_t bu_scanlen (char const *s, size_t *zeron)
{
- unsigned int n = ucharn_findlen(s) ;
+ size_t n = ucharn_findlen(s) ;
*zeron = n ;
while (*s == '0') { s++ ; (*zeron)-- ; }
return n ;
diff --git a/src/libbiguint/bu_slbc.c b/src/libbiguint/bu_slbc.c
index 081c599..d87af36 100644
--- a/src/libbiguint/bu_slbc.c
+++ b/src/libbiguint/bu_slbc.c
@@ -1,9 +1,9 @@
/* ISC license. */
-#include <skalibs/uint32.h>
+#include <stdint.h>
#include <skalibs/biguint.h>
-int bu_slbc (register uint32 *a, register unsigned int n, register int carry)
+int bu_slbc (register uint32_t *a, register unsigned int n, register int carry)
{
register unsigned int i = 0 ;
carry = !!carry ;
diff --git a/src/libbiguint/bu_srbc.c b/src/libbiguint/bu_srbc.c
index 87196b1..a2dbab5 100644
--- a/src/libbiguint/bu_srbc.c
+++ b/src/libbiguint/bu_srbc.c
@@ -1,14 +1,14 @@
/* ISC license. */
-#include <skalibs/uint32.h>
+#include <stdint.h>
#include <skalibs/biguint.h>
-int bu_srbc (register uint32 *a, register unsigned int n, register int carry)
+int bu_srbc (register uint32_t *a, register unsigned int n, register int carry)
{
while (n--)
{
register int c = a[n] & 1 ;
- a[n] = (a[n] >> 1) | (carry ? 0x80000000UL : 0) ;
+ a[n] = (a[n] >> 1) | (carry ? 0x80000000U : 0) ;
carry = c ;
}
return carry ;
diff --git a/src/libbiguint/bu_subc.c b/src/libbiguint/bu_subc.c
index a5d0037..cff2a05 100644
--- a/src/libbiguint/bu_subc.c
+++ b/src/libbiguint/bu_subc.c
@@ -6,17 +6,17 @@
#endif
#include <errno.h>
-#include <skalibs/uint32.h>
+#include <stdint.h>
#include <skalibs/biguint.h>
-int bu_subc (uint32 *c, unsigned int cn, uint32 const *a, unsigned int an, uint32 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, register int carry)
{
register unsigned int i = 0 ;
for (; i < cn ; i++)
{
- register uint32 ai = (i < an) ? a[i] : 0 ;
- register uint32 bi = (i < bn) ? b[i] : 0 ;
- register uint32 ci = ai - bi - carry ;
+ 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 ;
carry = (carry || bi) && (ci > ai) ;
c[i] = ci ;
}
diff --git a/src/libbiguint/bu_submod.c b/src/libbiguint/bu_submod.c
index f988a50..7eb065f 100644
--- a/src/libbiguint/bu_submod.c
+++ b/src/libbiguint/bu_submod.c
@@ -1,12 +1,12 @@
/* ISC license. */
+#include <stdint.h>
#include <errno.h>
-#include <skalibs/uint32.h>
#include <skalibs/biguint.h>
-int bu_submod (uint32 *c, unsigned int cn, uint32 const *a, unsigned int an, uint32 const *b, unsigned int bn, uint32 const *m, unsigned int mn)
+int bu_submod (uint32_t *c, unsigned int cn, uint32_t const *a, unsigned int an, uint32_t const *b, unsigned int bn, uint32_t const *m, unsigned int mn)
{
if (!bu_sub(c, cn, a, an, b, bn) && bu_add(c, cn, c, cn, m, mn))
return (errno = EDOM, 0) ;
- return (errno = 0, 1) ;
+ return 1 ;
}
diff --git a/src/libbiguint/bu_unpack.c b/src/libbiguint/bu_unpack.c
index d4f4130..8100037 100644
--- a/src/libbiguint/bu_unpack.c
+++ b/src/libbiguint/bu_unpack.c
@@ -1,9 +1,10 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/uint32.h>
#include <skalibs/biguint.h>
-void bu_unpack (char const *s, uint32 *a, register unsigned int n)
+void bu_unpack (char const *s, uint32_t *a, register 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 ef79029..83cf805 100644
--- a/src/libbiguint/bu_unpack_big.c
+++ b/src/libbiguint/bu_unpack_big.c
@@ -1,9 +1,10 @@
/* ISC license. */
+#include <stdint.h>
#include <skalibs/uint32.h>
#include <skalibs/biguint.h>
-void bu_unpack_big (char const *s, uint32 *a, unsigned int n)
+void bu_unpack_big (char const *s, uint32_t *a, unsigned int n)
{
register 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 07efd69..0d512bf 100644
--- a/src/libbiguint/bu_zero.c
+++ b/src/libbiguint/bu_zero.c
@@ -1,9 +1,9 @@
/* ISC license. */
-#include <skalibs/uint32.h>
+#include <stdint.h>
#include <skalibs/biguint.h>
-void bu_zero (register uint32 *z, register unsigned int n)
+void bu_zero (register uint32_t *z, register unsigned int n)
{
while (n--) z[n] = 0 ;
}