pymath.c 478 B

12345678910111213141516171819
  1. #include "Python.h"
  2. #ifdef HAVE_GCC_ASM_FOR_X87
  3. // Inline assembly for getting and setting the 387 FPU control word on
  4. // GCC/x86.
  5. #ifdef _Py_MEMORY_SANITIZER
  6. __attribute__((no_sanitize_memory))
  7. #endif
  8. unsigned short _Py_get_387controlword(void) {
  9. unsigned short cw;
  10. __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
  11. return cw;
  12. }
  13. void _Py_set_387controlword(unsigned short cw) {
  14. __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
  15. }
  16. #endif // HAVE_GCC_ASM_FOR_X87