lkml.org 
[lkml]   [1999]   [Nov]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch] string.h speedup, cld-2.3.30-C1

On Sat, 27 Nov 1999, Garst R. Reese wrote:

> There is a small typo in the apm.c part which prevents linking.
> cld; should be ; cld
> Seems to run ok once fixed.

thanks. I've attached cld-2.3.30-C1:

- apm.c fix (Garst R. Reese)

- namespace cleanup, cpy(x,y) => struct_cpy(x,y) (Artur Skawina)

- string.h is enclosed into #ifdef __KERNEL__, to
make sure nothing from user-space includes it. (Artur Skawina)

-- mingo
--- linux/include/asm-i386/string.h.orig Sat Nov 27 05:44:12 1999
+++ linux/include/asm-i386/string.h Sun Nov 28 04:46:36 1999
@@ -1,6 +1,7 @@
#ifndef _I386_STRING_H_
#define _I386_STRING_H_

+#ifdef __KERNEL__
/*
* On a 486 or Pentium, we are better off not using the
* byte string operations. But on a 386 or a PPro the
@@ -32,7 +33,6 @@
{
int d0, d1, d2;
__asm__ __volatile__(
- "cld\n"
"1:\tlodsb\n\t"
"stosb\n\t"
"testb %%al,%%al\n\t"
@@ -47,7 +47,6 @@
{
int d0, d1, d2, d3;
__asm__ __volatile__(
- "cld\n"
"1:\tdecl %2\n\t"
"js 2f\n\t"
"lodsb\n\t"
@@ -67,7 +66,6 @@
{
int d0, d1, d2, d3;
__asm__ __volatile__(
- "cld\n\t"
"repne\n\t"
"scasb\n\t"
"decl %1\n"
@@ -85,7 +83,6 @@
{
int d0, d1, d2, d3;
__asm__ __volatile__(
- "cld\n\t"
"repne\n\t"
"scasb\n\t"
"decl %1\n\t"
@@ -110,7 +107,6 @@
int d0, d1;
register int __res;
__asm__ __volatile__(
- "cld\n"
"1:\tlodsb\n\t"
"scasb\n\t"
"jne 2f\n\t"
@@ -132,7 +128,6 @@
register int __res;
int d0, d1, d2;
__asm__ __volatile__(
- "cld\n"
"1:\tdecl %3\n\t"
"js 2f\n\t"
"lodsb\n\t"
@@ -156,7 +151,6 @@
int d0;
register char * __res;
__asm__ __volatile__(
- "cld\n\t"
"movb %%al,%%ah\n"
"1:\tlodsb\n\t"
"cmpb %%ah,%%al\n\t"
@@ -176,7 +170,6 @@
int d0, d1;
register char * __res;
__asm__ __volatile__(
- "cld\n\t"
"movb %%al,%%ah\n"
"1:\tlodsb\n\t"
"cmpb %%ah,%%al\n\t"
@@ -194,7 +187,6 @@
int d0;
register int __res;
__asm__ __volatile__(
- "cld\n\t"
"repne\n\t"
"scasb\n\t"
"notl %0\n\t"
@@ -207,7 +199,6 @@
{
int d0, d1, d2;
__asm__ __volatile__(
- "cld\n\t"
"rep ; movsl\n\t"
"testb $2,%b4\n\t"
"je 1f\n\t"
@@ -273,7 +264,6 @@
}
#define COMMON(x) \
__asm__ __volatile__( \
- "cld\n\t" \
"rep ; movsl" \
x \
: "=&c" (d0), "=&D" (d1), "=&S" (d2) \
@@ -343,13 +333,28 @@

#endif

+/*
+ * struct_cpy(x,y), copy structure *x into (matching structure) *y.
+ *
+ * We get link-time errors if the structure sizes do not match.
+ * There is no runtime overhead, it's all optimized away at
+ * compile time.
+ */
+extern void __struct_cpy_bug (void);
+
+#define struct_cpy(x,y) \
+({ \
+ if (sizeof(*(x)) != sizeof(*(y))) \
+ __struct_cpy_bug; \
+ memcpy(x, y, sizeof(*(x))); \
+})
+
#define __HAVE_ARCH_MEMMOVE
extern inline void * memmove(void * dest,const void * src, size_t n)
{
int d0, d1, d2;
if (dest<src)
__asm__ __volatile__(
- "cld\n\t"
"rep\n\t"
"movsb"
: "=&c" (d0), "=&S" (d1), "=&D" (d2)
@@ -379,7 +384,6 @@
if (!count)
return NULL;
__asm__ __volatile__(
- "cld\n\t"
"repne\n\t"
"scasb\n\t"
"je 1f\n\t"
@@ -393,7 +397,6 @@
{
int d0, d1;
__asm__ __volatile__(
- "cld\n\t"
"rep\n\t"
"stosb"
: "=&c" (d0), "=&D" (d1)
@@ -414,7 +417,6 @@
{
int d0, d1;
__asm__ __volatile__(
- "cld\n\t"
"rep ; stosl\n\t"
"testb $2,%b3\n\t"
"je 1f\n\t"
@@ -475,7 +477,7 @@
return s;
}
#define COMMON(x) \
-__asm__ __volatile__("cld\n\t" \
+__asm__ __volatile__( \
"rep ; stosl" \
x \
: "=&c" (d0), "=&D" (d1) \
@@ -518,8 +520,7 @@
{
if (!size)
return addr;
- __asm__("cld
- repnz; scasb
+ __asm__("repnz; scasb
jnz 1f
dec %%edi
1: "
@@ -527,6 +528,8 @@
: "0" (addr), "1" (size), "a" (c));
return addr;
}
+
+#endif /* __KERNEL__ */

#endif
#endif
--- linux/include/asm-i386/string-486.h.orig Sat Nov 27 05:45:53 1999
+++ linux/include/asm-i386/string-486.h Sat Nov 27 05:58:05 1999
@@ -187,7 +187,6 @@
int d0, d1;
register char * __res;
__asm__ __volatile__(
- "cld\n\t"
"movb %%al,%%ah\n"
"1:\tlodsb\n\t"
"cmpb %%ah,%%al\n\t"
@@ -206,7 +205,6 @@
int d0, d1;
register char * __res;
__asm__ __volatile__(
- "cld\n\t"
"movl %6,%%edi\n\t"
"repne\n\t"
"scasb\n\t"
@@ -234,7 +232,6 @@
int d0, d1;
register char * __res;
__asm__ __volatile__(
- "cld\n\t"
"movl %6,%%edi\n\t"
"repne\n\t"
"scasb\n\t"
@@ -263,7 +260,6 @@
int d0, d1;
register char * __res;
__asm__ __volatile__(
- "cld\n\t"
"movl %6,%%edi\n\t"
"repne\n\t"
"scasb\n\t"
@@ -296,7 +292,6 @@
int d0, d1;
register char * __res;
__asm__ __volatile__(
- "cld\n\t" \
"movl %6,%%edi\n\t"
"repne\n\t"
"scasb\n\t"
@@ -378,7 +373,6 @@
"1:\txorl %0,%0\n\t"
"movl $-1,%%ecx\n\t"
"xorl %%eax,%%eax\n\t"
- "cld\n\t"
"movl %4,%%edi\n\t"
"repne\n\t"
"scasb\n\t"
@@ -474,7 +468,6 @@
int d0, d1, d2;
register void *tmp = (void *)to;
__asm__ __volatile__ (
- "cld\n\t"
"shrl $1,%%ecx\n\t"
"jnc 1f\n\t"
"movsb\n"
@@ -554,7 +547,6 @@
register void *tmp = (void *)dest;
if (dest<src)
__asm__ __volatile__ (
- "cld\n\t"
"rep\n\t"
"movsb"
:"=&c" (d0), "=&S" (d1), "=&D" (d2)
@@ -577,7 +569,6 @@
int d0, d1, d2;
register int __res;
__asm__ __volatile__(
- "cld\n\t"
"repe\n\t"
"cmpsb\n\t"
"je 1f\n\t"
@@ -597,7 +588,6 @@
if (!count)
return NULL;
__asm__ __volatile__(
- "cld\n\t"
"repne\n\t"
"scasb\n\t"
"je 1f\n\t"
@@ -753,8 +743,7 @@
{
if (!size)
return addr;
- __asm__("cld
- repnz; scasb
+ __asm__("repnz; scasb
jnz 1f
dec %%edi
1: "
--- linux/include/asm-i386/io.h.orig Sat Nov 27 05:46:43 1999
+++ linux/include/asm-i386/io.h Sun Nov 28 04:49:04 1999
@@ -71,12 +71,12 @@

#define __INS(s) \
extern inline void ins##s(unsigned short port, void * addr, unsigned long count) \
-{ __asm__ __volatile__ ("cld ; rep ; ins" #s \
+{ __asm__ __volatile__ ("rep ; ins" #s \
: "=D" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }

#define __OUTS(s) \
extern inline void outs##s(unsigned short port, const void * addr, unsigned long count) \
-{ __asm__ __volatile__ ("cld ; rep ; outs" #s \
+{ __asm__ __volatile__ ("rep ; outs" #s \
: "=S" (addr), "=c" (count) : "d" (port),"0" (addr),"1" (count)); }

#define RETURN_TYPE unsigned char
--- linux/include/asm-i386/bitops.h.orig Sat Nov 27 05:46:55 1999
+++ linux/include/asm-i386/bitops.h Sat Nov 27 05:47:09 1999
@@ -132,8 +132,7 @@

if (!size)
return 0;
- __asm__("cld\n\t"
- "movl $-1,%%eax\n\t"
+ __asm__("movl $-1,%%eax\n\t"
"xorl %%edx,%%edx\n\t"
"repe; scasl\n\t"
"je 1f\n\t"
--- linux/arch/i386/kernel/apm.c.orig Sat Nov 27 05:47:49 1999
+++ linux/arch/i386/kernel/apm.c Sun Nov 28 04:46:49 1999
@@ -380,7 +380,7 @@
__asm__ __volatile__(APM_DO_ZERO_SEGS
"pushl %%edi\n\t"
"pushl %%ebp\n\t"
- "lcall %%cs:" SYMBOL_NAME_STR(apm_bios_entry) "\n\t"
+ "lcall %%cs:" SYMBOL_NAME_STR(apm_bios_entry) "; cld\n\t"
"setc %%al\n\t"
"popl %%ebp\n\t"
"popl %%edi\n\t"
@@ -413,7 +413,7 @@
__asm__ __volatile__(APM_DO_ZERO_SEGS
"pushl %%edi\n\t"
"pushl %%ebp\n\t"
- "lcall %%cs:" SYMBOL_NAME_STR(apm_bios_entry) "\n\t"
+ "lcall %%cs:" SYMBOL_NAME_STR(apm_bios_entry)"; cld\n\t"
"setc %%bl\n\t"
"popl %%ebp\n\t"
"popl %%edi\n\t"
--- linux/arch/i386/kernel/pci-pc.c.orig Sat Nov 27 05:49:53 1999
+++ linux/arch/i386/kernel/pci-pc.c Sat Nov 27 05:51:44 1999
@@ -342,7 +342,7 @@
unsigned long flags;

__save_flags(flags); __cli();
- __asm__("lcall (%%edi)"
+ __asm__("lcall (%%edi); cld"
: "=a" (return_code),
"=b" (address),
"=c" (length),
@@ -383,7 +383,7 @@

__save_flags(flags); __cli();
__asm__(
- "lcall (%%edi)\n\t"
+ "lcall (%%edi); cld\n\t"
"jc 1f\n\t"
"xor %%ah, %%ah\n"
"1:"
@@ -427,7 +427,7 @@
unsigned short bx;
unsigned short ret;

- __asm__("lcall (%%edi)\n\t"
+ __asm__("lcall (%%edi); cld\n\t"
"jc 1f\n\t"
"xor %%ah, %%ah\n"
"1:"
@@ -448,7 +448,7 @@
unsigned long ret;
unsigned long bx = (dev->bus->number << 8) | dev->devfn;

- __asm__("lcall (%%esi)\n\t"
+ __asm__("lcall (%%esi); cld\n\t"
"jc 1f\n\t"
"xor %%ah, %%ah\n"
"1:"
@@ -466,7 +466,7 @@
unsigned long ret;
unsigned long bx = (dev->bus->number << 8) | dev->devfn;

- __asm__("lcall (%%esi)\n\t"
+ __asm__("lcall (%%esi); cld\n\t"
"jc 1f\n\t"
"xor %%ah, %%ah\n"
"1:"
@@ -484,7 +484,7 @@
unsigned long ret;
unsigned long bx = (dev->bus->number << 8) | dev->devfn;

- __asm__("lcall (%%esi)\n\t"
+ __asm__("lcall (%%esi); cld\n\t"
"jc 1f\n\t"
"xor %%ah, %%ah\n"
"1:"
@@ -502,7 +502,7 @@
unsigned long ret;
unsigned long bx = (dev->bus->number << 8) | dev->devfn;

- __asm__("lcall (%%esi)\n\t"
+ __asm__("lcall (%%esi); cld\n\t"
"jc 1f\n\t"
"xor %%ah, %%ah\n"
"1:"
@@ -520,7 +520,7 @@
unsigned long ret;
unsigned long bx = (dev->bus->number << 8) | dev->devfn;

- __asm__("lcall (%%esi)\n\t"
+ __asm__("lcall (%%esi); cld\n\t"
"jc 1f\n\t"
"xor %%ah, %%ah\n"
"1:"
@@ -538,7 +538,7 @@
unsigned long ret;
unsigned long bx = (dev->bus->number << 8) | dev->devfn;

- __asm__("lcall (%%esi)\n\t"
+ __asm__("lcall (%%esi); cld\n\t"
"jc 1f\n\t"
"xor %%ah, %%ah\n"
"1:"
@@ -702,7 +702,7 @@
__asm__("push %%es\n\t"
"push %%ds\n\t"
"pop %%es\n\t"
- "lcall (%%esi)\n\t"
+ "lcall (%%esi); cld\n\t"
"pop %%es\n\t"
"jc 1f\n\t"
"xor %%ah, %%ah\n"
--- linux/arch/i386/kernel/process.c.orig Sat Nov 27 06:00:12 1999
+++ linux/arch/i386/kernel/process.c Sun Nov 28 04:48:04 1999
@@ -462,7 +462,7 @@
struct pt_regs * childregs;

childregs = ((struct pt_regs *) (THREAD_SIZE + (unsigned long) p)) - 1;
- *childregs = *regs;
+ struct_cpy(childregs, regs);
childregs->eax = 0;
childregs->esp = esp;

@@ -475,7 +475,7 @@
savesegment(gs,p->thread.gs);

unlazy_fpu(current);
- p->thread.i387 = current->thread.i387;
+ struct_cpy(&p->thread.i387, &current->thread.i387);

return 0;
}
\
 
 \ /
  Last update: 2005-03-22 13:55    [W:0.057 / U:2.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site