Chameleon

Chameleon Svn Source Tree

Root/branches/xZenu/src/modules/klibc/__udivmodsi4.c

Source at commit 1308 created 12 years 8 months ago.
By meklort, Add a few placeholders for file io
1#include <stdint.h>
2
3extern void __divide_error();
4uint32_t __udivmodsi4(uint32_t num, uint32_t den, uint32_t * rem_p)
5{
6uint32_t quot = 0, qbit = 1;
7
8if (den == 0) {
9__divide_error();
10return 0;/* If trap returns... */
11}
12
13/* Left-justify denominator and count shift */
14while ((int32_t) den >= 0) {
15den <<= 1;
16qbit <<= 1;
17}
18
19while (qbit) {
20if (den <= num) {
21num -= den;
22quot += qbit;
23}
24den >>= 1;
25qbit >>= 1;
26}
27
28if (rem_p)
29*rem_p = num;
30
31return quot;
32}
33

Archive Download this file

Revision: 1308