xref: /csrg-svn/lib/libc/quad/umoddi3.c (revision 53447)
1*53447Sbostic /*-
2*53447Sbostic  * Copyright (c) 1992 The Regents of the University of California.
3*53447Sbostic  * All rights reserved.
4*53447Sbostic  *
5*53447Sbostic  * %sccs.include.redist.c%
6*53447Sbostic  */
7*53447Sbostic 
8*53447Sbostic #if defined(LIBC_SCCS) && !defined(lint)
9*53447Sbostic static char sccsid[] = "@(#)umoddi3.c	5.1 (Berkeley) 05/12/92";
10*53447Sbostic #endif /* LIBC_SCCS and not lint */
11*53447Sbostic 
12*53447Sbostic #include "longlong.h"
13*53447Sbostic 
14*53447Sbostic extern void __bdiv ();
15*53447Sbostic 
16*53447Sbostic long long
17*53447Sbostic __umoddi3 (u, v)
18*53447Sbostic      long long u, v;
19*53447Sbostic {
20*53447Sbostic   unsigned long a[2][2], b[2], q[2], r[2];
21*53447Sbostic   long_long w;
22*53447Sbostic   long_long uu, vv;
23*53447Sbostic 
24*53447Sbostic   uu.ll = u;
25*53447Sbostic   vv.ll = v;
26*53447Sbostic 
27*53447Sbostic   a[HIGH][HIGH] = 0;
28*53447Sbostic   a[HIGH][LOW] = 0;
29*53447Sbostic   a[LOW][HIGH] = uu.s.high;
30*53447Sbostic   a[LOW][LOW] = uu.s.low;
31*53447Sbostic   b[HIGH] = vv.s.high;
32*53447Sbostic   b[LOW] = vv.s.low;
33*53447Sbostic 
34*53447Sbostic   __bdiv (a, b, q, r, sizeof a, sizeof b);
35*53447Sbostic 
36*53447Sbostic   w.s.high = r[HIGH];
37*53447Sbostic   w.s.low = r[LOW];
38*53447Sbostic   return w.ll;
39*53447Sbostic }
40