mirror of
https://github.com/justinian/jsix.git
synced 2025-12-09 16:04:32 -08:00
[libj6] Fix a memcpy return address bug
My `REP.MOVSB` `memcpy` implementation had marked its C++ variable constraints as output instead of input, causing the compiler to emit code to copy the values of `$rsi` and `$rdi` back into the `src` and `dst` pointers, so after the copy `dst` pointed to the memory just beyond what had been copied. Very few places actually used the return value from `memcpy`, so this went unnoticed for a bit..
This commit is contained in:
@@ -7,9 +7,12 @@
|
||||
using namespace j6;
|
||||
using namespace __j6libc;
|
||||
|
||||
void *memcpy(void * restrict s1, const void * restrict s2, size_t n) {
|
||||
asm volatile ("rep movsb" : "+D"(s1), "+S"(s2), "+c"(n) :: "memory");
|
||||
return s1;
|
||||
void *memcpy(void * restrict dst, const void * restrict src, size_t n) {
|
||||
asm volatile ("rep movsb"
|
||||
:
|
||||
: "D"(dst), "S"(src), "c"(n)
|
||||
: "memory");
|
||||
return dst;
|
||||
}
|
||||
|
||||
static void memmove_dispatch(char *s1, const char *s2, size_t n) {
|
||||
|
||||
Reference in New Issue
Block a user