[libc-commits] [PATCH] D106386: [libc] Exclude few unused bits from x86 state for Windows

Hedin GarcĂ­a via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Jul 20 12:15:21 PDT 2021


hedingarcia created this revision.
hedingarcia added reviewers: sivachandra, aeubanks.
Herald added subscribers: libc-commits, ecnelises, tschuett.
Herald added a project: libc-project.
hedingarcia requested review of this revision.

Windows fenv_t does not include the MXCSR register and
the unused bits at the end of the x87 status. So we
exclude them in our struct definitions to make it
easy to read/write the state. getEnv and setEnv
were also excluded to avoid using MXCSR, but a
forthcoming patch will handle these functions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D106386

Files:
  libc/utils/FPUtil/x86_64/FEnv.h


Index: libc/utils/FPUtil/x86_64/FEnv.h
===================================================================
--- libc/utils/FPUtil/x86_64/FEnv.h
+++ libc/utils/FPUtil/x86_64/FEnv.h
@@ -91,12 +91,16 @@
   uint16_t StatusWord;
   uint16_t Unused2;
   // TODO: Elaborate the remaining 20 bytes as required.
+  #if !(defined(_WIN32) || defined(_WIN64))
   uint32_t _[5];
+  #endif
 };
 
 struct FPState {
   X87StateDescriptor X87Status;
+  #if !(defined(_WIN32) || defined(_WIN64))
   uint32_t MXCSR;
+  #endif
 };
 
 static_assert(
@@ -346,6 +350,7 @@
   return 0;
 }
 
+#if !(defined(_WIN32) || defined(_WIN64))
 static inline int getEnv(fenv_t *envp) {
   internal::FPState *state = reinterpret_cast<internal::FPState *>(envp);
   internal::getX87StateDescriptor(state->X87Status);
@@ -360,6 +365,7 @@
   internal::writeMXCSR(state->MXCSR);
   return 0;
 }
+#endif
 
 } // namespace fputil
 } // namespace __llvm_libc


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D106386.360228.patch
Type: text/x-patch
Size: 916 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20210720/3e7d1733/attachment.bin>


More information about the libc-commits mailing list