aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--src/optionroms.c2
-rw-r--r--src/util.c18
-rw-r--r--src/util.h7
4 files changed, 9 insertions, 21 deletions
diff --git a/Makefile b/Makefile
index 1cf7ba2..19e63d4 100644
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,8 @@ cc-option = $(shell if test -z "`$(1) $(2) -S -o /dev/null -xc \
COMMONCFLAGS = -Wall -Os -MD -m32 -march=i386 -mregparm=3 \
-mpreferred-stack-boundary=2 -mrtd -freg-struct-return \
-ffreestanding -fwhole-program -fomit-frame-pointer \
- -fno-delete-null-pointer-checks -Wno-strict-aliasing
+ -fno-delete-null-pointer-checks -Wno-strict-aliasing \
+ -minline-all-stringops
COMMONCFLAGS += $(call cc-option,$(CC),-nopie,)
COMMONCFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
COMMONCFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,)
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;
}
diff --git a/src/util.c b/src/util.c
index a39668b..3c7117c 100644
--- a/src/util.c
+++ b/src/util.c
@@ -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 *
diff --git a/src/util.h b/src/util.h
index ceb775e..bb1a445 100644
--- a/src/util.h
+++ b/src/util.h
@@ -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);