xref: /csrg-svn/lib/libc/quad/umoddi3.c (revision 53459)
153447Sbostic /*-
253447Sbostic  * Copyright (c) 1992 The Regents of the University of California.
353447Sbostic  * All rights reserved.
453447Sbostic  *
553447Sbostic  * %sccs.include.redist.c%
653447Sbostic  */
753447Sbostic 
853447Sbostic #if defined(LIBC_SCCS) && !defined(lint)
9*53459Sbostic static char sccsid[] = "@(#)umoddi3.c	5.2 (Berkeley) 05/12/92";
1053447Sbostic #endif /* LIBC_SCCS and not lint */
1153447Sbostic 
12*53459Sbostic /* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
13*53459Sbostic 
14*53459Sbostic This file is part of GNU CC.
15*53459Sbostic 
16*53459Sbostic GNU CC is free software; you can redistribute it and/or modify
17*53459Sbostic it under the terms of the GNU General Public License as published by
18*53459Sbostic the Free Software Foundation; either version 2, or (at your option)
19*53459Sbostic any later version.
20*53459Sbostic 
21*53459Sbostic GNU CC is distributed in the hope that it will be useful,
22*53459Sbostic but WITHOUT ANY WARRANTY; without even the implied warranty of
23*53459Sbostic MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24*53459Sbostic GNU General Public License for more details.
25*53459Sbostic 
26*53459Sbostic You should have received a copy of the GNU General Public License
27*53459Sbostic along with GNU CC; see the file COPYING.  If not, write to
28*53459Sbostic the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
29*53459Sbostic 
30*53459Sbostic /* As a special exception, if you link this library with files
31*53459Sbostic    compiled with GCC to produce an executable, this does not cause
32*53459Sbostic    the resulting executable to be covered by the GNU General Public License.
33*53459Sbostic    This exception does not however invalidate any other reasons why
34*53459Sbostic    the executable file might be covered by the GNU General Public License.  */
35*53459Sbostic 
3653447Sbostic #include "longlong.h"
3753447Sbostic 
3853447Sbostic extern void __bdiv ();
3953447Sbostic 
4053447Sbostic long long
4153447Sbostic __umoddi3 (u, v)
4253447Sbostic      long long u, v;
4353447Sbostic {
4453447Sbostic   unsigned long a[2][2], b[2], q[2], r[2];
4553447Sbostic   long_long w;
4653447Sbostic   long_long uu, vv;
4753447Sbostic 
4853447Sbostic   uu.ll = u;
4953447Sbostic   vv.ll = v;
5053447Sbostic 
5153447Sbostic   a[HIGH][HIGH] = 0;
5253447Sbostic   a[HIGH][LOW] = 0;
5353447Sbostic   a[LOW][HIGH] = uu.s.high;
5453447Sbostic   a[LOW][LOW] = uu.s.low;
5553447Sbostic   b[HIGH] = vv.s.high;
5653447Sbostic   b[LOW] = vv.s.low;
5753447Sbostic 
5853447Sbostic   __bdiv (a, b, q, r, sizeof a, sizeof b);
5953447Sbostic 
6053447Sbostic   w.s.high = r[HIGH];
6153447Sbostic   w.s.low = r[LOW];
6253447Sbostic   return w.ll;
6353447Sbostic }
64