iPXE
Functions
libgcc.h File Reference
#include <stdint.h>
#include <stddef.h>

Go to the source code of this file.

Functions

__libgcc uint64_t __udivmoddi4 (uint64_t num, uint64_t den, uint64_t *rem)
__libgcc uint64_t __udivdi3 (uint64_t num, uint64_t den)
__libgcc uint64_t __umoddi3 (uint64_t num, uint64_t den)
__libgcc int64_t __divmoddi4 (int64_t num, int64_t den, int64_t *rem)
__libgcc int64_t __divdi3 (int64_t num, int64_t den)
__libgcc int64_t __moddi3 (int64_t num, int64_t den)

Function Documentation

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

Definition at line 3 of file __udivmoddi4.c.

References num.

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

{
  uint64_t quot = 0, qbit = 1;

  if ( den == 0 ) {
    return 1/((unsigned)den); /* Intentional divide by zero, without
                                 triggering a compiler warning which
                                 would abort the build */
  }

  /* Left-justify denominator and count shift */
  while ( (int64_t)den >= 0 ) {
    den <<= 1;
    qbit <<= 1;
  }

  while ( qbit ) {
    if ( den <= num ) {
      num -= den;
      quot += qbit;
    }
    den >>= 1;
    qbit >>= 1;
  }

  if ( rem_p )
    *rem_p = num;

  return quot;
}

Definition at line 7 of file __udivdi3.c.

References __udivmoddi4(), and NULL.

{
  return __udivmoddi4(num, den, NULL);
}

Definition at line 7 of file __umoddi3.c.

References __udivmoddi4().

{
  uint64_t v;

  (void) __udivmoddi4(num, den, &v);
  return v;
}
__libgcc int64_t __divmoddi4 ( int64_t  num,
int64_t  den,
int64_t rem 
)

Definition at line 3 of file __divmoddi4.c.

References __udivmoddi4(), and num.

Referenced by __divdi3(), and __moddi3().

{
  int minus = 0;
  int64_t v;

  if ( num < 0 ) {
    num = -num;
    minus = 1;
  }
  if ( den < 0 ) {
    den = -den;
    minus ^= 1;
  }

  v = __udivmoddi4(num, den, (uint64_t *)rem_p);
  if ( minus ) {
    v = -v;
    if ( rem_p )
      *rem_p = -(*rem_p);
  }

  return v;
}
__libgcc int64_t __divdi3 ( int64_t  num,
int64_t  den 
)

Definition at line 7 of file __divdi3.c.

References __divmoddi4(), and NULL.

{
  return __divmoddi4(num, den, NULL);
}
__libgcc int64_t __moddi3 ( int64_t  num,
int64_t  den 
)

Definition at line 7 of file __moddi3.c.

References __divmoddi4().

{
  int64_t v;

  (void) __divmoddi4(num, den, &v);
  return v;
}