From: John Hodge Date: Fri, 11 Nov 2011 11:22:34 +0000 (+0800) Subject: Kernel - Fixing bugs exposed by enabling -O3 X-Git-Tag: rel0.14~116 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=d3359db4d5b4cb6f1c2758dc03e74edf4427a769;p=tpg%2Facess2.git Kernel - Fixing bugs exposed by enabling -O3 --- diff --git a/Kernel/Makefile b/Kernel/Makefile index 287d01a9..900a46e6 100644 --- a/Kernel/Makefile +++ b/Kernel/Makefile @@ -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)/ diff --git a/Kernel/arch/x86/lib.c b/Kernel/arch/x86/lib.c index 0b802d1e..db05d936 100644 --- a/Kernel/arch/x86/lib.c +++ b/Kernel/arch/x86/lib.c @@ -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" diff --git a/Kernel/threads.c b/Kernel/threads.c index 6933dd60..879fbdda 100644 --- a/Kernel/threads.c +++ b/Kernel/threads.c @@ -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 diff --git a/Kernel/vfs/select.c b/Kernel/vfs/select.c index 18fdab76..bbca5471 100644 --- a/Kernel/vfs/select.c +++ b/Kernel/vfs/select.c @@ -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);