From aa29888fcabc827704b1c99716917cdc6d88a1e7 Mon Sep 17 00:00:00 2001 From: Liu Hao Date: Sat, 27 Jan 2018 14:24:44 +0800 Subject: [PATCH] FastMemcpy{,_Avx}.c: Mark `memcpy()` as `dllimport` on MinGW and mingw-w64 targets. On MinGW and mingw-w64 targets, `memcpy()` is imported from MSVCRT.DLL. With regard to benchmarking purposes, we have to eliminate the overhead of implicit importation by specifying `dllexport` explicitly. Reference: https://gcc.gnu.org/onlinedocs/gcc/Microsoft-Windows-Function-Attributes.html#index-dllimport-function-attribute Signed-off-by: Liu Hao --- FastMemcpy.c | 10 ++++++++++ FastMemcpy_Avx.c | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/FastMemcpy.c b/FastMemcpy.c index 5021bcc..f6b5ee7 100644 --- a/FastMemcpy.c +++ b/FastMemcpy.c @@ -24,6 +24,16 @@ #error it can only be compiled under windows or unix #endif +#ifdef __MINGW32__ +/* On MinGW and mingw-w64 targets, `memcpy()` is imported from MSVCRT.DLL. + * With regard to benchmarking purposes, we have to eliminate the overhead + * of implicit importation by specifying `dllexport` explicitly. + * + * Reference: https://gcc.gnu.org/onlinedocs/gcc/Microsoft-Windows-Function-Attributes.html#index-dllimport-function-attribute + */ +__declspec(dllimport) extern void * memcpy(void *, const void *, size_t); +#endif + #include "FastMemcpy.h" unsigned int gettime() diff --git a/FastMemcpy_Avx.c b/FastMemcpy_Avx.c index 6538c6b..fefdca0 100644 --- a/FastMemcpy_Avx.c +++ b/FastMemcpy_Avx.c @@ -25,6 +25,16 @@ #error it can only be compiled under windows or unix #endif +#ifdef __MINGW32__ +/* On MinGW and mingw-w64 targets, `memcpy()` is imported from MSVCRT.DLL. + * With regard to benchmarking purposes, we have to eliminate the overhead + * of implicit importation by specifying `dllexport` explicitly. + * + * Reference: https://gcc.gnu.org/onlinedocs/gcc/Microsoft-Windows-Function-Attributes.html#index-dllimport-function-attribute + */ +__declspec(dllimport) extern void * memcpy(void *, const void *, size_t); +#endif + #include "FastMemcpy_Avx.h"