Chameleon

Chameleon Svn Source Tree

Root/branches/meklort/i386/modules/klibc/__udivmoddi4.c

Source at commit 655 created 13 years 4 months ago.
By meklort, Modules update. removed hardcoding for dyld_stub_bunder in modules.c Added a subset of klibc for a more complete c library implimentation. Added a subset of uclibc++ for an initial c++ implimentation. Note: cout / cin / file io has been disabled. Also note that exceptions and rtti is disabled. Modified the helow world code foa small c++ test.
1#include "libsaio.h"
2
3extern void __divide_error();
4
5uint64_t __udivmoddi4(uint64_t num, uint64_t den, uint64_t * rem_p)
6{
7uint64_t quot = 0, qbit = 1;
8
9if (den == 0) {
10__divide_error();
11return 0;/* If trap returns... */
12}
13
14/* Left-justify denominator and count shift */
15while ((int64_t) den >= 0) {
16den <<= 1;
17qbit <<= 1;
18}
19
20while (qbit) {
21if (den <= num) {
22num -= den;
23quot += qbit;
24}
25den >>= 1;
26qbit >>= 1;
27}
28
29if (rem_p)
30*rem_p = num;
31
32return quot;
33}
34

Archive Download this file

Revision: 655