Skip to content

Commit 0e0b677

Browse files
committed
Added armv7 fpu support
1 parent 782217f commit 0e0b677

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed

Python/pymath.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,20 @@ void _Py_set_387controlword(unsigned short cw) {
1717
__asm__ __volatile__ ("fldcw %0" : : "m" (cw));
1818
}
1919
#endif // HAVE_GCC_ASM_FOR_X87
20+
21+
#ifdef HAVE_GCC_ASM_FOR_ARMV7
22+
// Inline assembly for getting and setting the ARMv7-FPSCR control/status word on
23+
// GCC/arm.
24+
#ifdef _Py_MEMORY_SANITIZER
25+
__attribute__((no_sanitize_memory))
26+
#endif
27+
int32_t _Py_get_fpscr(void) {
28+
int32_t fpscr;
29+
__asm__ __volatile__ ("vmrs %0, fpscr" : "=m" (cw));
30+
return fpscr;
31+
}
32+
33+
void _Py_set_fpscr(int32_t cw) {
34+
__asm__ __volatile__ ("vmsr fpscr, %0" : : "m" (cw));
35+
}
36+
#endif // HAVE_GCC_ASM_FOR_ARMV7

configure

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5954,6 +5954,18 @@ AS_VAR_IF([ac_cv_gcc_asm_for_x87], [yes], [
59545954
[Define if we can use gcc inline assembler to get and set x87 control word])
59555955
])
59565956

5957+
AC_CACHE_CHECK([whether we can use gcc inline assembler to get and set armv7-fpscr control/status word], [ac_cv_gcc_asm_for_armv7], [
5958+
AC_LINK_IFELSE( [AC_LANG_PROGRAM([[]], [[
5959+
unsigned int cw;
5960+
__asm__ __volatile__ ("vmrs %0, fpscr" : "=m" (cw));
5961+
__asm__ __volatile__ ("vmsr fpscr, %0" : : "m" (cw));
5962+
]])],[ac_cv_gcc_asm_for_armv7=yes],[ac_cv_gcc_asm_for_armv7=no])
5963+
])
5964+
AS_VAR_IF([ac_cv_gcc_asm_for_armv7], [yes], [
5965+
AC_DEFINE([HAVE_GCC_ASM_FOR_ARMV7], [1],
5966+
[Define if we can use gcc inline assembler to get and set fpscr control/status word])
5967+
])
5968+
59575969
AC_CACHE_CHECK([whether we can use gcc inline assembler to get and set mc68881 fpcr], [ac_cv_gcc_asm_for_mc68881], [
59585970
AC_LINK_IFELSE( [AC_LANG_PROGRAM([[]], [[
59595971
unsigned int fpcr;

pyconfig.h.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,10 @@
443443
/* Define to 1 if you have the `gai_strerror' function. */
444444
#undef HAVE_GAI_STRERROR
445445

446+
/* Define if we can use gcc inline assembler to get and set fpscr
447+
control/status word */
448+
#undef HAVE_GCC_ASM_FOR_ARMV7
449+
446450
/* Define if we can use gcc inline assembler to get and set mc68881 fpcr */
447451
#undef HAVE_GCC_ASM_FOR_MC68881
448452

0 commit comments

Comments
 (0)