Usermode/libc - Fix strchr and strrchr behavior
[tpg/acess2.git] / KernelLand / Kernel / arch / helpers.h
1 /*
2  * Acess2 Kernel
3  * - By John Hodge (thePowersGang)
4  *
5  * arch/helpers.h
6  * - Misc helper functions for the arch code
7  */
8 #ifndef _ARCH_HELPERS_H_
9 #define _ARCH_HELPERS_H_
10
11 // Divide
12 // - Find what power of two times Den is > Num
13 // - Iterate down in bit significance
14 //  > If the `N` value is greater than `D`, we can set this bit
15 #define DEF_DIVMOD(s) Uint##s __divmod##s(Uint##s N, Uint##s D, Uint##s*Rem){\
16         Uint##s ret=0,add=1;\
17         while(N/2>=D&&add) {D<<=1;add<<=1;}\
18         while(add>0){\
19                 if(N>=D){ret+=add;N-=D;}\
20                 add>>=1;D>>=1;\
21         }\
22         if(Rem)*Rem = N;\
23         return ret;\
24 }
25
26 #endif
27

UCC git Repository :: git.ucc.asn.au