[llvm] [Support] Handle delete_pending case for Windows fs::status (PR #90655)
Alexandre Ganea via llvm-commits
llvm-commits at lists.llvm.org
Thu May 2 14:29:16 PDT 2024
================
@@ -22,12 +22,22 @@
#include <sys/stat.h>
#include <sys/types.h>
-// These two headers must be included last, and make sure shlobj is required
+// These headers must be included last, and make sure shlobj is required
// after Windows.h to make sure it picks up our definition of _WIN32_WINNT
+#define WIN32_NO_STATUS
#include "llvm/Support/Windows/WindowsSupport.h"
+#undef WIN32_NO_STATUS
+
+#include <ntstatus.h>
#include <shellapi.h>
#include <shlobj.h>
+// This is equivalent to NtCurrentTeb()->LastStatusValue, but the public
+// _TEB definition does not expose the LastStatusValue field directly.
+// Avoid offsetting into this structure by calling RtlGetLastNtStatus
+// from ntdll.dll.
+extern "C" NTSYSAPI NTSTATUS NTAPI RtlGetLastNtStatus();
----------------
aganea wrote:
For future readers who would like a more in-depth description I would add maybe a link to https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/api/pebteb/teb/index.htm and mention this is a an internal NT API which (in theory) should map what `GetLastError()` returns, but at a lower level. It is not immediately clear below why we're calling this instead of `GetLastError()`.
https://github.com/llvm/llvm-project/pull/90655
More information about the llvm-commits
mailing list