File:  [Qemu by Fabrice Bellard] / qemu / roms / openbios / libgcc / __udivmodti4.c
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 19:19:39 2018 UTC (8 years, 1 month ago) by root
Branches: qemu, MAIN
CVS tags: qemu1101, qemu1001, HEAD
qemu 1.0.1

#include "libgcc.h"

__uint128_t __udivmodti4(__uint128_t num, __uint128_t den, __uint128_t *rem_p)
{
  __uint128_t quot = 0, qbit = 1;

  if ( den == 0 ) {
    __divide_error();
    return 0;			/* If trap returns... */
  }

  /* Left-justify denominator and count shift */
  while ( (__int128_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;
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.