Cleanup (debug statements removed)
[tpg/acess2.git] / Kernel / arch / x86 / lib.c
index 86117cc..3d951d4 100644 (file)
@@ -5,6 +5,12 @@
 #include <acess.h>
 #include <threads.h>
 
+#define TRACE_LOCKS    0
+
+#if TRACE_LOCKS
+extern struct sShortSpinlock   glDebug_Lock;
+#endif
+
 extern int     GetCPUNum(void);
 
 // === CODE ===
@@ -103,13 +109,21 @@ void SHORTLOCK(struct sShortSpinlock *Lock)
        __ASM__("cli");
        Lock->IF = IF;
        #endif
+       
+       #if TRACE_LOCKS
+       if( Lock != &glDebug_Lock )
+       {
+               //Log_Log("LOCK", "%p locked by %p", Lock, __builtin_return_address(0));
+               LogF("Lock %p locked by %p\n", Lock, __builtin_return_address(0));
+       }
+       #endif
 }
 /**
  * \brief Release a short lock
  * \param Lock Lock pointer
  */
 void SHORTREL(struct sShortSpinlock *Lock)
-{
+{      
        #if STACKED_LOCKS
        if( Lock->Depth ) {
                Lock->Depth --;
@@ -117,6 +131,14 @@ void SHORTREL(struct sShortSpinlock *Lock)
        }
        #endif
        
+       #if TRACE_LOCKS
+       if( Lock != &glDebug_Lock )
+       {
+               //Log_Log("LOCK", "%p released by %p", Lock, __builtin_return_address(0));
+               LogF("Lock %p released by %p\n", Lock, __builtin_return_address(0));
+       }
+       #endif
+       
        #if LOCK_DISABLE_INTS
        // Lock->IF can change anytime once Lock->Lock is zeroed
        if(Lock->IF) {
@@ -260,6 +282,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;
@@ -281,6 +318,7 @@ Uint64 __udivdi3(Uint64 Num, Uint64 Den)
                        P[1] += Den;
                }
        }
+       #endif
        
        return q;
 }

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