summaryrefslogtreecommitdiff
path: root/src/vm/common.h
diff options
context:
space:
mode:
authorWilliam Godbe <william.godbe@comcast.net>2015-12-30 14:16:10 -0800
committerWilliam Godbe <william.godbe@comcast.net>2016-01-06 17:17:03 -0800
commit17b6b066cf8cebe40ce9b6f219d3b8fb74fe8ad1 (patch)
tree93b49eb4d0371a13e16bdaf6ca5ed112c6f0878f /src/vm/common.h
parentb74cd1d74e7c968f8a8368498ad37fc6a5dd8577 (diff)
downloadcoreclr-17b6b066cf8cebe40ce9b6f219d3b8fb74fe8ad1.tar.gz
coreclr-17b6b066cf8cebe40ce9b6f219d3b8fb74fe8ad1.tar.bz2
coreclr-17b6b066cf8cebe40ce9b6f219d3b8fb74fe8ad1.zip
Audit usage of memcpy in PAL for Debug
Diffstat (limited to 'src/vm/common.h')
-rw-r--r--src/vm/common.h23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/vm/common.h b/src/vm/common.h
index 2d23f8c471..2fe1e0137d 100644
--- a/src/vm/common.h
+++ b/src/vm/common.h
@@ -22,7 +22,7 @@
#if defined(_MSC_VER) && defined(_X86_) && !defined(FPO_ON)
-#pragma optimize("y", on) // Small critical routines, don't put in EBP frame
+#pragma optimize("y", on) // Small critical routines, don't put in EBP frame
#define FPO_ON 1
#define COMMON_TURNED_FPO_ON 1
#endif
@@ -89,6 +89,7 @@
#include <math.h>
#include <time.h>
#include <limits.h>
+#include <assert.h>
#include <olectl.h>
@@ -256,12 +257,26 @@ FORCEINLINE void* memcpyUnsafe(void *dest, const void *src, size_t len)
//
#if defined(_DEBUG) && !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE)
+ //If memcpy has been defined to PAL_memcpy, we undefine it so that this case
+ //can be covered by the if !defined(memcpy) block below
+ #ifdef FEATURE_PAL
+ #if IS_REDEFINED_IN_PAL(memcpy)
+ #undef memcpy
+ #endif //IS_REDEFINED_IN_PAL
+ #endif //FEATURE_PAL
+
// You should be using CopyValueClass if you are doing an memcpy
// in the CG heap.
- #if !defined(memcpy)
+ #if !defined(memcpy)
FORCEINLINE void* memcpyNoGCRefs(void * dest, const void * src, size_t len) {
WRAPPER_NO_CONTRACT;
- return memcpy(dest, src, len);
+
+ #ifndef FEATURE_PAL
+ return memcpy(dest, src, len);
+ #else //FEATURE_PAL
+ return PAL_memcpy(dest, src, len);
+ #endif //FEATURE_PAL
+
}
extern "C" void * __cdecl GCSafeMemCpy(void *, const void *, size_t);
#define memcpy(dest, src, len) GCSafeMemCpy(dest, src, len)
@@ -517,7 +532,7 @@ inline HRESULT CreateConfigStreamHelper(LPCWSTR filename, IStream** pOutStream)
#if defined(COMMON_TURNED_FPO_ON)
-#pragma optimize("", on) // Go back to command line default optimizations
+#pragma optimize("", on) // Go back to command line default optimizations
#undef COMMON_TURNED_FPO_ON
#undef FPO_ON
#endif