[PATCH] ntdll: Implement NtFlushInstructionCache using __clear_cache where available
Martin Storsjo
martin at martin.st
Sun Jan 21 16:05:09 CST 2018
The configure check needs to be done with a more elaborate test than
just AC_CHECK_FUNC, since it's a built-in function in clang and errors
out if invoked with no parameters.
Signed-off-by: Martin Storsjo <martin at martin.st>
---
configure.ac | 8 ++++++++
dlls/ntdll/process.c | 12 ++++++++++++
2 files changed, 20 insertions(+)
diff --git a/configure.ac b/configure.ac
index 223c985..25d88d8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2717,6 +2717,14 @@ then
AC_DEFINE(HAVE___BUILTIN_POPCOUNT, 1, [Define to 1 if you have the `__builtin_popcount' built-in function.])
fi
+AC_CACHE_CHECK([for __clear_cache], ac_cv_have___clear_cache,
+ AC_LINK_IFELSE([AC_LANG_PROGRAM(,[[__clear_cache((void*)0, (void*)0); return 0;]])],
+ [ac_cv_have___clear_cache="yes"], [ac_cv_have___clear_cache="no"]))
+if test "$ac_cv_have___clear_cache" = "yes"
+then
+ AC_DEFINE(HAVE___CLEAR_CACHE, 1, [Define to 1 if you have the `__clear_cache' (potentially built-in) function.])
+fi
+
dnl *** check for the need to define platform-specific symbols
case $host_cpu in
diff --git a/dlls/ntdll/process.c b/dlls/ntdll/process.c
index f615ce2..47a389a 100644
--- a/dlls/ntdll/process.c
+++ b/dlls/ntdll/process.c
@@ -658,6 +658,17 @@ NTSTATUS WINAPI NtFlushInstructionCache(
IN LPCVOID BaseAddress,
IN SIZE_T Size)
{
+#ifdef HAVE___CLEAR_CACHE
+ if (ProcessHandle == GetCurrentProcess())
+ {
+ __clear_cache(BaseAddress, (char*)BaseAddress + Size);
+ }
+ else
+ {
+ FIXME("%p %p %ld - Flush for other process not supported\n",
+ ProcessHandle, BaseAddress, Size);
+ }
+#else
static int once;
if (!once++)
{
@@ -667,6 +678,7 @@ NTSTATUS WINAPI NtFlushInstructionCache(
FIXME("%p %p %ld\n", ProcessHandle, BaseAddress, Size );
#endif
}
+#endif
return STATUS_SUCCESS;
}
--
2.7.4
More information about the wine-devel
mailing list