[libc-commits] [PATCH] D95637: [libc] set the ES bit when raising FP exceptions on x86

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Thu Jan 28 12:42:16 PST 2021


sivachandra added inline comments.


================
Comment at: libc/utils/FPUtil/x86_64/FEnv.h:199
 
+static inline int isEnabled(int excepts) {
+  uint16_t x87CW = internal::getX87ControlWord();
----------------
Add a comment here explaining that this functions returns a bit map of all enabled exceptions.


================
Comment at: libc/utils/FPUtil/x86_64/FEnv.h:202
+  return excepts & (~x87CW);
+  // since we want each bit where excepts is 1 and x87CW is 0
+  // (since 0 means enabled) I just and excepts and the inverse of the CW state.
----------------
We usually try to be formal in multi-line comments. So, I would suggest a wording like this:

```
// The exceptions are enabled if the bit is zero (unmasked), 
// so that is why the negation before the & operation.
```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D95637/new/

https://reviews.llvm.org/D95637



More information about the libc-commits mailing list