iPXE
Functions
__udivmoddi4.c File Reference
#include "libgcc.h"

Go to the source code of this file.

Functions

__libgcc uint64_t __udivmoddi4 (uint64_t num, uint64_t den, uint64_t *rem_p)
 

Function Documentation

◆ __udivmoddi4()

__libgcc uint64_t __udivmoddi4 ( uint64_t  num,
uint64_t  den,
uint64_t rem_p 
)

Definition at line 3 of file __udivmoddi4.c.

4 {
5  uint64_t quot = 0, qbit = 1;
6 
7  if ( den == 0 ) {
8  return 1/((unsigned)den); /* Intentional divide by zero, without
9  triggering a compiler warning which
10  would abort the build */
11  }
12 
13  /* Left-justify denominator and count shift */
14  while ( (int64_t)den >= 0 ) {
15  den <<= 1;
16  qbit <<= 1;
17  }
18 
19  while ( qbit ) {
20  if ( den <= num ) {
21  num -= den;
22  quot += qbit;
23  }
24  den >>= 1;
25  qbit >>= 1;
26  }
27 
28  if ( rem_p )
29  *rem_p = num;
30 
31  return quot;
32 }
unsigned long long uint64_t
Definition: stdint.h:13
signed long long int64_t
Definition: stdint.h:18
char unsigned long * num
Definition: xenstore.h:17

References num.

Referenced by __divmoddi4(), __udivdi3(), and __umoddi3().