Chameleon

Chameleon Svn Source Tree

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

Source at commit 1406 created 12 years 10 months ago.
By meklort, Revert drivers.c so that kexts are only loaded when OSBundleRequired is set and that value is not safe mode. Added some comments about it too.
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: 1406