Merge pull request #253 from haneefmubarak/memcpy-rep-movsb-windows-201

resolve #201 with a platform-selective REP MOVSB implementation
This commit is contained in:
Daan 2021-01-29 16:00:00 -08:00 committed by GitHub
commit 9b966c3492
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 29 additions and 10 deletions

View file

@ -172,6 +172,25 @@ bool _mi_page_is_valid(mi_page_t* page);
#define EOVERFLOW (75)
#endif
// ------------------------------------------------------
// Fast `memcpy()` on x86(_64) platforms unavailable
// on Windows, use REP MOVSB if necessary
// ------------------------------------------------------
#if defined(_M_IX86) || defined(_M_X64)
#include <intrin.h>
#define _mi_memcpy _mi_memcpy_rep_movsb
static inline void _mi_memcpy_rep_movsb (void *d, const void *s, size_t n) {
unsigned char* Destination = (unsigned char*) d;
unsigned const char* Source = (unsigned const char*) s;
size_t Count = n;
__movsb(Destination, Source, Count);
return;
}
#else
#define _mi_memcpy memcpy
#endif
/* -----------------------------------------------------------
Inlined definitions