1*8feb0f0bSmrg /* Copyright (C) 2000-2020 Free Software Foundation, Inc.
21debfc3dSmrg
31debfc3dSmrg This file is part of GCC.
41debfc3dSmrg
51debfc3dSmrg GCC is free software; you can redistribute it and/or modify it under
61debfc3dSmrg the terms of the GNU General Public License as published by the Free
71debfc3dSmrg Software Foundation; either version 3, or (at your option) any later
81debfc3dSmrg version.
91debfc3dSmrg
101debfc3dSmrg GCC is distributed in the hope that it will be useful, but WITHOUT ANY
111debfc3dSmrg WARRANTY; without even the implied warranty of MERCHANTABILITY or
121debfc3dSmrg FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
131debfc3dSmrg for more details.
141debfc3dSmrg
151debfc3dSmrg Under Section 7 of GPL version 3, you are granted additional
161debfc3dSmrg permissions described in the GCC Runtime Library Exception, version
171debfc3dSmrg 3.1, as published by the Free Software Foundation.
181debfc3dSmrg
191debfc3dSmrg You should have received a copy of the GNU General Public License and
201debfc3dSmrg a copy of the GCC Runtime Library Exception along with this program;
211debfc3dSmrg see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
221debfc3dSmrg <http://www.gnu.org/licenses/>. */
231debfc3dSmrg
241debfc3dSmrg unsigned long
__udivmodsi4(unsigned long num,unsigned long den,int modwanted)25c0a68be4Smrg __udivmodsi4(unsigned long num, unsigned long den, int modwanted)
261debfc3dSmrg {
271debfc3dSmrg unsigned long bit = 1;
281debfc3dSmrg unsigned long res = 0;
291debfc3dSmrg
301debfc3dSmrg while (den < num && bit && !(den & (1L<<31)))
311debfc3dSmrg {
321debfc3dSmrg den <<=1;
331debfc3dSmrg bit <<=1;
341debfc3dSmrg }
351debfc3dSmrg while (bit)
361debfc3dSmrg {
371debfc3dSmrg if (num >= den)
381debfc3dSmrg {
391debfc3dSmrg num -= den;
401debfc3dSmrg res |= bit;
411debfc3dSmrg }
421debfc3dSmrg bit >>=1;
431debfc3dSmrg den >>=1;
441debfc3dSmrg }
451debfc3dSmrg if (modwanted) return num;
461debfc3dSmrg return res;
471debfc3dSmrg }
48