summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorToomas Soome <tsoome@me.com>2017-07-15 01:42:13 +0300
committerRichard Lowe <richlowe@richlowe.net>2017-10-16 09:35:10 -0400
commitd8b4f927017620c0d78dc3b4fd238ed58bbb4b42 (patch)
treeb531cdd4d26db9b1b5a1640776992f3ff16254ac /usr/src
parent859472da62d5df230117a53edc3cfcc61d5896ac (diff)
downloadillumos-gate-d8b4f927017620c0d78dc3b4fd238ed58bbb4b42.tar.gz
8500 loader: need __divmoddi4 and __udivmoddi4
Reviewed by: Dan McDonald <danmcd@joyent.com> Reviewed by: Yuri Pankov <yuripv@gmx.com> Reviewed by: Igor Kozhukhov <igor@dilos.org> Reviewed by: Robert Mustacchi <rm@joyent.com> Approved by: Richard Lowe <richlowe@richlowe.net>
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/boot/lib/libstand/qdivrem.c38
-rw-r--r--usr/src/boot/lib/libstand/quad.h2
2 files changed, 23 insertions, 17 deletions
diff --git a/usr/src/boot/lib/libstand/qdivrem.c b/usr/src/boot/lib/libstand/qdivrem.c
index bde3b0d56e..9437794be4 100644
--- a/usr/src/boot/lib/libstand/qdivrem.c
+++ b/usr/src/boot/lib/libstand/qdivrem.c
@@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+#include <sys/stddef.h>
/*
* Multiprecision divide. This algorithm is from Knuth vol. 2 (2nd ed),
@@ -70,7 +70,7 @@ shl(digit *p, int len, int sh)
}
/*
- * __qdivrem(u, v, rem) returns u/v and, optionally, sets *rem to u%v.
+ * __udivmoddi4(u, v, rem) returns u/v and, optionally, sets *rem to u%v.
*
* We do this in base 2-sup-HALF_BITS, so that all intermediate products
* fit within u_int. As a consequence, the maximum length dividend and
@@ -78,8 +78,7 @@ shl(digit *p, int len, int sh)
* leading zeros).
*/
u_quad_t
-__qdivrem(uq, vq, arq)
- u_quad_t uq, vq, *arq;
+__udivmoddi4(u_quad_t uq, u_quad_t vq, u_quad_t *arq)
{
union uu tmp;
digit *u, *v, *q;
@@ -279,23 +278,21 @@ __qdivrem(uq, vq, arq)
*/
u_quad_t
-__udivdi3(a, b)
- u_quad_t a, b;
+__udivdi3(u_quad_t a, u_quad_t b)
{
- return (__qdivrem(a, b, (u_quad_t *)0));
+ return (__udivmoddi4(a, b, NULL));
}
/*
* Return remainder after dividing two unsigned quads.
*/
u_quad_t
-__umoddi3(a, b)
- u_quad_t a, b;
+__umoddi3(u_quad_t a, u_quad_t b)
{
u_quad_t r;
- (void)__qdivrem(a, b, &r);
+ (void)__udivmoddi4(a, b, &r);
return (r);
}
@@ -304,8 +301,7 @@ __umoddi3(a, b)
* ??? if -1/2 should produce -1 on this machine, this code is wrong
*/
quad_t
-__divdi3(a, b)
- quad_t a, b;
+__divdi3(quad_t a, quad_t b)
{
u_quad_t ua, ub, uq;
int neg;
@@ -318,7 +314,7 @@ __divdi3(a, b)
ub = -(u_quad_t)b, neg ^= 1;
else
ub = b;
- uq = __qdivrem(ua, ub, (u_quad_t *)0);
+ uq = __udivmoddi4(ua, ub, NULL);
return (neg ? -uq : uq);
}
@@ -329,8 +325,7 @@ __divdi3(a, b)
* If -1/2 should produce -1 on this machine, this code is wrong.
*/
quad_t
-__moddi3(a, b)
- quad_t a, b;
+__moddi3(quad_t a, quad_t b)
{
u_quad_t ua, ub, ur;
int neg;
@@ -343,6 +338,17 @@ __moddi3(a, b)
ub = -(u_quad_t)b;
else
ub = b;
- (void)__qdivrem(ua, ub, &ur);
+ (void)__udivmoddi4(ua, ub, &ur);
return (neg ? -ur : ur);
}
+
+quad_t
+__divmoddi4(quad_t a, quad_t b, quad_t *r)
+{
+ quad_t d;
+
+ d = __divdi3(a, b);
+ *r = a - (b * d);
+
+ return (d);
+}
diff --git a/usr/src/boot/lib/libstand/quad.h b/usr/src/boot/lib/libstand/quad.h
index 349540a1e9..1e76207775 100644
--- a/usr/src/boot/lib/libstand/quad.h
+++ b/usr/src/boot/lib/libstand/quad.h
@@ -97,7 +97,7 @@ union uu {
quad_t __divdi3(quad_t a, quad_t b);
quad_t __moddi3(quad_t a, quad_t b);
-u_quad_t __qdivrem(u_quad_t u, u_quad_t v, u_quad_t *rem);
+u_quad_t __udivmoddi4(u_quad_t u, u_quad_t v, u_quad_t *rem);
u_quad_t __udivdi3(u_quad_t a, u_quad_t b);
u_quad_t __umoddi3(u_quad_t a, u_quad_t b);