X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Fx86%2Flib.c;h=5fa9d12e66524aeba7332df51b0a458a48121810;hb=9d85201216cb35e1b1e051b1d7cdc38eaa5befa4;hp=796baa43f98370ba88e5c7c7a80ad962bbb6e771;hpb=9143c184873d0b55444dc1c1084f3e9f3f2614bf;p=tpg%2Facess2.git diff --git a/Kernel/arch/x86/lib.c b/Kernel/arch/x86/lib.c index 796baa43..5fa9d12e 100644 --- a/Kernel/arch/x86/lib.c +++ b/Kernel/arch/x86/lib.c @@ -8,11 +8,16 @@ #define TRACE_LOCKS 0 #if TRACE_LOCKS -struct sShortSpinlock glDebug_Lock; +extern struct sShortSpinlock glDebug_Lock; #endif +// === IMPRORTS === extern int GetCPUNum(void); +// === PROTOTYPES == +Uint64 __udivdi3(Uint64 Num, Uint64 Den); +Uint64 __umoddi3(Uint64 Num, Uint64 Den); + // === CODE === /** * \brief Determine if a short spinlock is locked @@ -216,14 +221,16 @@ void *memsetd(void *Dest, Uint32 Val, size_t Num) */ int memcmp(const void *m1, const void *m2, size_t Num) { + const Uint8 *d1 = m1; + const Uint8 *d2 = m2; if( Num == 0 ) return 0; // No bytes are always identical while(Num--) { - if(*(Uint8*)m1 != *(Uint8*)m2) - return *(Uint8*)m1 - *(Uint8*)m2; - m1 ++; - m2 ++; + if(*d1 != *d2) + return *d1 - *d2; + d1 ++; + d2 ++; } return 0; } @@ -282,6 +289,21 @@ Uint64 __udivdi3(Uint64 Num, Uint64 Den) if(Num < Den*2) return 1; if(Num == Den*2) return 2; + #if 1 + i = 0; // Shut up + P[0] = Num; + P[1] = Den; + __asm__ __volatile__ ( + "fildq %2\n\t" // Num + "fildq %1\n\t" // Den + "fdivp\n\t" + "fistpq %0" + : "=m" (q) + : "m" (P[0]), "m" (P[1]) + ); + + //Log("%llx / %llx = %llx\n", Num, Den, q); + #else // Restoring division, from wikipedia // http://en.wikipedia.org/wiki/Division_(digital) P[0] = Num; P[1] = 0; @@ -303,6 +325,7 @@ Uint64 __udivdi3(Uint64 Num, Uint64 Den) P[1] += Den; } } + #endif return q; }