Kernel - Fixing bugs exposed by enabling -O3
authorJohn Hodge <[email protected]>
Fri, 11 Nov 2011 11:22:34 +0000 (19:22 +0800)
committerJohn Hodge <[email protected]>
Fri, 11 Nov 2011 11:22:34 +0000 (19:22 +0800)
Kernel/Makefile
Kernel/arch/x86/lib.c
Kernel/threads.c
Kernel/vfs/select.c

index 287d01a..900a46e 100644 (file)
@@ -23,6 +23,7 @@ CPPFLAGS      += -DARCH=$(ARCH) -DARCHDIR=$(ARCHDIR) -DARCHDIR_IS_$(ARCHDIR)=1
 CPPFLAGS       += -DKERNEL_VERSION=$(KERNEL_VERSION)
 CFLAGS         += -Wall -Werror -fno-stack-protector -Wstrict-prototypes -g
 CFLAGS         += -Wshadow -Wpointer-arith -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wnested-externs -Winline -Wuninitialized
+CFLAGS          += -O3
 LDFLAGS                += -T arch/$(ARCHDIR)/link.ld -g
 
 OBJDIR := obj-$(ARCH)/
index 0b802d1..db05d93 100644 (file)
@@ -324,11 +324,45 @@ int memcmp(const void *m1, const void *m2, size_t Num)
  */
 void *memcpy(void *Dest, const void *Src, size_t Num)
 {
-       if( ((Uint)Dest & 3) || ((Uint)Src & 3) ) {
-               __asm__ __volatile__ ("rep movsb" :: "D" (Dest), "S" (Src), "c" (Num));
+       tVAddr  dst = (tVAddr)Dest;
+       tVAddr  src = (tVAddr)Src;
+       if( (dst & 3) != (src & 3) )
+       {
+               __asm__ __volatile__ ("rep movsb" :: "D" (dst), "S" (src), "c" (Num));
 //             Debug("\nmemcpy:Num=0x%x by %p (UA)", Num, __builtin_return_address(0));
        }
-       else {
+       #if 1
+       else if( Num > 128 && (dst & 15) == (src & 15) )
+       {
+                int    count = 16 - (dst & 15);
+//             Debug("\nmemcpy:Num=0x%x by %p (SSE)", Num, __builtin_return_address(0));
+               if( count < 16 )
+               {
+                       Num -= count;
+//                     Debug("dst = %p, src = %p, count = %i (Num=0x%x) (head)", dst, src, count, Num);
+                       __asm__ __volatile__ ("rep movsb" : "=D"(dst),"=S"(src): "0"(dst), "1"(src), "c"(count));
+               }
+               
+               count = Num / 16;
+//             Debug("dst = %p, src = %p, count = %i (bulk)", dst, src, count);
+               __asm__ __volatile__ (
+                       "1:\n\t"
+                       "movdqa 0(%1), %%xmm0;\n\t"
+                       "movdqa %%xmm0, 0(%0);\n\t"
+                       "add $16,%0;\n\t"
+                       "add $16,%1;\n\t"
+                       "loop 1b;\n\t"
+                       : "=r"(dst),"=r"(src) : "0"(dst), "1"(src), "c"(count)
+                       );
+
+               count = Num & 15;
+//             Debug("dst = %p, src = %p, count = %i (tail)", dst, src, count);
+               if(count)
+                       __asm__ __volatile__ ("rep movsb" :: "D"(dst), "S"(src), "c"(count));
+       }
+       #endif
+       else
+       {
 //             Debug("\nmemcpy:Num=0x%x by %p", Num, __builtin_return_address(0));
                __asm__ __volatile__ (
                        "rep movsl;\n\t"
index 6933dd6..879fbdd 100644 (file)
@@ -26,7 +26,7 @@
 #define        DEFAULT_QUANTUM 5
 #define        DEFAULT_PRIORITY        5
 #define MIN_PRIORITY           10
-const enum eConfigTypes        cCONFIG_TYPES[] = {
+const enum eConfigTypes        cCONFIG_TYPES[NUM_CFG_ENTRIES] = {
        CFGT_HEAPSTR,   // e.g. CFG_VFS_CWD
        CFGT_INT,       // e.g. CFG_VFS_MAXFILES
        CFGT_NULL
index 18fdab7..bbca547 100644 (file)
@@ -430,7 +430,7 @@ int VFS_int_Select_AddThread(tVFS_SelectList *List, tVFS_SelectThread *Thread, i
 void VFS_int_Select_RemThread(tVFS_SelectList *List, tVFS_SelectThread *Thread)
 {
         int    i;
-       tVFS_SelectListEnt      *block, *prev;
+       tVFS_SelectListEnt      *block, *prev = NULL;
        
        ENTER("pList pThread", List, Thread);
        

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