diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2009-04-19 23:18:54 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2009-04-19 23:18:54 -0400 |
commit | d94411414754b65d9d745987db1ed84b92765f61 (patch) | |
tree | 014f7da79beba992130ccc6cff6ce53601bae4ee /src | |
parent | ff82b24f0096b022e1071670ed5c886fc223b588 (diff) | |
download | seabios-hppa-d94411414754b65d9d745987db1ed84b92765f61.zip seabios-hppa-d94411414754b65d9d745987db1ed84b92765f61.tar.gz seabios-hppa-d94411414754b65d9d745987db1ed84b92765f61.tar.bz2 |
Fixup previous memcpy optimization.
Different gcc versions handle __builtin_memcpy differently.
Add -minline-all-string to force inlining of memcpy on old gcc.
Always use __builtin_memcpy for all memcpy calls.
Use memcpy4() for the option rom case where 4-byte accesses is important.
Diffstat (limited to 'src')
-rw-r--r-- | src/optionroms.c | 2 | ||||
-rw-r--r-- | src/util.c | 18 | ||||
-rw-r--r-- | src/util.h | 7 |
3 files changed, 7 insertions, 20 deletions
diff --git a/src/optionroms.c b/src/optionroms.c index def3feb..32fb44b 100644 --- a/src/optionroms.c +++ b/src/optionroms.c @@ -171,7 +171,7 @@ copy_rom(struct rom_header *rom) } dprintf(4, "Copying option rom (size %d) from %p to %x\n" , romsize, rom, next_rom); - memcpy((void*)next_rom, rom, romsize); + memcpy4((void*)next_rom, rom, romsize); return (struct rom_header *)next_rom; } @@ -181,25 +181,15 @@ memcpy_far(u16 d_seg, void *d_far, u16 s_seg, const void *s_far, size_t len) : "cc", "memory"); } -noinline void * -__memcpy(void *d1, const void *s1, size_t len) +// Memcpy that uses 4-byte accesses +void +memcpy4(void *d1, const void *s1, size_t len) { - void *d = d1; - if (((u32)d1 | (u32)s1 | len) & 3) { - // non-aligned memcpy - asm volatile( - "rep movsb (%%esi),%%es:(%%edi)\n" - : "+c"(len), "+S"(s1), "+D"(d) - : : "cc", "memory"); - return d1; - } - // Common case - use 4-byte copy len /= 4; asm volatile( "rep movsl (%%esi),%%es:(%%edi)\n" - : "+c"(len), "+S"(s1), "+D"(d) + : "+c"(len), "+S"(s1), "+D"(d1) : : "cc", "memory"); - return d1; } void * @@ -73,11 +73,8 @@ int memcmp(const void *s1, const void *s2, size_t n); size_t strlen(const char *s); int strcmp(const char *s1, const char *s2); void *memset(void *s, int c, size_t n); -void *__memcpy(void *d1, const void *s1, size_t len); -#define memcpy(d1, s1, len) ( \ - (__builtin_constant_p(len) && (len) <= 20) \ - ? __builtin_memcpy((d1), (s1), (len)) \ - : __memcpy((d1), (s1), (len))) +void memcpy4(void *d1, const void *s1, size_t len); +#define memcpy(d1, s1, len) __builtin_memcpy((d1), (s1), (len)) inline void memcpy_far(u16 d_seg, void *d_far , u16 s_seg, const void *s_far, size_t len); void *memmove(void *d, const void *s, size_t len); |