root/memdump/__udivmoddi4.c

Revision 19346b78495e5315cd4bdcbceb600196e55d6a70, 490 bytes (checked in by H. Peter Anvin <hpa@…>, 3 years ago)

Run Nindent on memdump/udivmoddi4.c

Automatically reformat memdump/udivmoddi4.c using Nindent.

Do this for all files except HDT, gPXE and externally maintained
libraries (zlib, tinyjpeg, libpng).

Signed-off-by: H. Peter Anvin <hpa@…>

  • Property mode set to 100644
Line 
1#include <stdint.h>
2
3uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t * rem_p)
4{
5    uint64_t quot = 0, qbit = 1;
6
7    if (den == 0) {
8        asm volatile ("int $0");
9        return 0;               /* If trap returns... */
10    }
11
12    /* Left-justify denominator and count shift */
13    while ((int64_t) den >= 0) {
14        den <<= 1;
15        qbit <<= 1;
16    }
17
18    while (qbit) {
19        if (den <= num) {
20            num -= den;
21            quot += qbit;
22        }
23        den >>= 1;
24        qbit >>= 1;
25    }
26
27    if (rem_p)
28        *rem_p = num;
29
30    return quot;
31}
Note: See TracBrowser for help on using the browser.