diff --git a/sysdeps/sparc/fpu/bits/fenv.h b/sysdeps/sparc/fpu/bits/fenv.h
index 4935208a41..d34fcac4c5 100644
--- a/sysdeps/sparc/fpu/bits/fenv.h
+++ b/sysdeps/sparc/fpu/bits/fenv.h
@@ -83,15 +83,6 @@ typedef unsigned long int fenv_t;
 # define FE_NOMASK_ENV	((const fenv_t *) -2)
 #endif
 
-/* For internal use only: access the fp state register.  */
-#if __WORDSIZE == 64
-# define __fenv_stfsr(X)   __asm__ __volatile__ ("stx %%fsr,%0" : "=m" (X))
-# define __fenv_ldfsr(X)   __asm__ __volatile__ ("ldx %0,%%fsr" : : "m" (X))
-#else
-# define __fenv_stfsr(X)   __asm__ __volatile__ ("st %%fsr,%0" : "=m" (X))
-# define __fenv_ldfsr(X)   __asm__ __volatile__ ("ld %0,%%fsr" : : "m" (X))
-#endif
-
 #if __GLIBC_USE (IEC_60559_BFP_EXT_C2X)
 /* Type representing floating-point control modes.  */
 typedef unsigned long int femode_t;
diff --git a/sysdeps/sparc/fpu/fclrexcpt.c b/sysdeps/sparc/fpu/fclrexcpt.c
index b11734f057..5af20d1f7a 100644
--- a/sysdeps/sparc/fpu/fclrexcpt.c
+++ b/sysdeps/sparc/fpu/fclrexcpt.c
@@ -17,6 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <fenv.h>
+#include <fenv_private.h>
 #include <shlib-compat.h>
 
 int
diff --git a/sysdeps/sparc/fpu/fedisblxcpt.c b/sysdeps/sparc/fpu/fedisblxcpt.c
index 86688ab533..9b832a82ce 100644
--- a/sysdeps/sparc/fpu/fedisblxcpt.c
+++ b/sysdeps/sparc/fpu/fedisblxcpt.c
@@ -18,6 +18,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <fenv.h>
+#include <fenv_private.h>
 
 int
 fedisableexcept (int excepts)
diff --git a/sysdeps/sparc/fpu/feenablxcpt.c b/sysdeps/sparc/fpu/feenablxcpt.c
index 647093cebc..06ec14cee5 100644
--- a/sysdeps/sparc/fpu/feenablxcpt.c
+++ b/sysdeps/sparc/fpu/feenablxcpt.c
@@ -18,6 +18,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <fenv.h>
+#include <fenv_private.h>
 
 int
 feenableexcept (int excepts)
diff --git a/sysdeps/sparc/fpu/fegetenv.c b/sysdeps/sparc/fpu/fegetenv.c
index edde6ae5b2..00c0bc72b5 100644
--- a/sysdeps/sparc/fpu/fegetenv.c
+++ b/sysdeps/sparc/fpu/fegetenv.c
@@ -17,6 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <fenv.h>
+#include <fenv_private.h>
 #include <shlib-compat.h>
 
 int
diff --git a/sysdeps/sparc/fpu/fegetexcept.c b/sysdeps/sparc/fpu/fegetexcept.c
index f549a90190..4d9746dd57 100644
--- a/sysdeps/sparc/fpu/fegetexcept.c
+++ b/sysdeps/sparc/fpu/fegetexcept.c
@@ -18,6 +18,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <fenv.h>
+#include <fenv_private.h>
 
 int
 fegetexcept (void)
diff --git a/sysdeps/sparc/fpu/fegetmode.c b/sysdeps/sparc/fpu/fegetmode.c
index 18c932d520..aa160bd19a 100644
--- a/sysdeps/sparc/fpu/fegetmode.c
+++ b/sysdeps/sparc/fpu/fegetmode.c
@@ -17,6 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <fenv.h>
+#include <fenv_private.h>
 
 int
 fegetmode (femode_t *modep)
diff --git a/sysdeps/sparc/fpu/fegetround.c b/sysdeps/sparc/fpu/fegetround.c
index 1eae341fc4..6ca7d5c0dc 100644
--- a/sysdeps/sparc/fpu/fegetround.c
+++ b/sysdeps/sparc/fpu/fegetround.c
@@ -17,6 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <fenv.h>
+#include <fenv_private.h>
 
 int
 __fegetround (void)
diff --git a/sysdeps/sparc/fpu/feholdexcpt.c b/sysdeps/sparc/fpu/feholdexcpt.c
index 7a1a3e33ed..bb612402f0 100644
--- a/sysdeps/sparc/fpu/feholdexcpt.c
+++ b/sysdeps/sparc/fpu/feholdexcpt.c
@@ -17,6 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <fenv.h>
+#include <fenv_private.h>
 
 int
 __feholdexcept (fenv_t *envp)
diff --git a/sysdeps/sparc/fpu/fenv_private.h b/sysdeps/sparc/fpu/fenv_private.h
index dbd1001ccb..da7c7fe332 100644
--- a/sysdeps/sparc/fpu/fenv_private.h
+++ b/sysdeps/sparc/fpu/fenv_private.h
@@ -3,6 +3,15 @@
 
 #include <fenv.h>
 
+/* For internal use only: access the fp state register.  */
+#if __WORDSIZE == 64
+# define __fenv_stfsr(X)   __asm__ __volatile__ ("stx %%fsr,%0" : "=m" (X))
+# define __fenv_ldfsr(X)   __asm__ __volatile__ ("ldx %0,%%fsr" : : "m" (X))
+#else
+# define __fenv_stfsr(X)   __asm__ __volatile__ ("st %%fsr,%0" : "=m" (X))
+# define __fenv_ldfsr(X)   __asm__ __volatile__ ("ld %0,%%fsr" : : "m" (X))
+#endif
+
 static __always_inline void
 libc_feholdexcept (fenv_t *e)
 {
diff --git a/sysdeps/sparc/fpu/fesetenv.c b/sysdeps/sparc/fpu/fesetenv.c
index 82c03c6760..d536abd344 100644
--- a/sysdeps/sparc/fpu/fesetenv.c
+++ b/sysdeps/sparc/fpu/fesetenv.c
@@ -17,6 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <fenv.h>
+#include <fenv_private.h>
 #include <shlib-compat.h>
 
 int
diff --git a/sysdeps/sparc/fpu/fesetexcept.c b/sysdeps/sparc/fpu/fesetexcept.c
index 6740ece5b4..fbc21c0477 100644
--- a/sysdeps/sparc/fpu/fesetexcept.c
+++ b/sysdeps/sparc/fpu/fesetexcept.c
@@ -17,6 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <fenv.h>
+#include <fenv_private.h>
 
 int
 fesetexcept (int excepts)
diff --git a/sysdeps/sparc/fpu/fesetmode.c b/sysdeps/sparc/fpu/fesetmode.c
index 6fe5d337ad..24148e0fd3 100644
--- a/sysdeps/sparc/fpu/fesetmode.c
+++ b/sysdeps/sparc/fpu/fesetmode.c
@@ -17,6 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <fenv.h>
+#include <fenv_private.h>
 #include <fpu_control.h>
 
 #define FPU_CONTROL_BITS 0xcfc00000UL
diff --git a/sysdeps/sparc/fpu/fesetround.c b/sysdeps/sparc/fpu/fesetround.c
index 9a944322d7..b259474d2c 100644
--- a/sysdeps/sparc/fpu/fesetround.c
+++ b/sysdeps/sparc/fpu/fesetround.c
@@ -17,6 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <fenv.h>
+#include <fenv_private.h>
 
 int
 __fesetround (int round)
diff --git a/sysdeps/sparc/fpu/feupdateenv.c b/sysdeps/sparc/fpu/feupdateenv.c
index 7e2399bfa2..7721f822ea 100644
--- a/sysdeps/sparc/fpu/feupdateenv.c
+++ b/sysdeps/sparc/fpu/feupdateenv.c
@@ -17,6 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <fenv.h>
+#include <fenv_private.h>
 #include <shlib-compat.h>
 
 int
diff --git a/sysdeps/sparc/fpu/fgetexcptflg.c b/sysdeps/sparc/fpu/fgetexcptflg.c
index f95d9bbf1b..ab8fa1bb76 100644
--- a/sysdeps/sparc/fpu/fgetexcptflg.c
+++ b/sysdeps/sparc/fpu/fgetexcptflg.c
@@ -17,6 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <fenv.h>
+#include <fenv_private.h>
 #include <shlib-compat.h>
 
 int
diff --git a/sysdeps/sparc/fpu/fsetexcptflg.c b/sysdeps/sparc/fpu/fsetexcptflg.c
index 077dfc9953..34eb789a94 100644
--- a/sysdeps/sparc/fpu/fsetexcptflg.c
+++ b/sysdeps/sparc/fpu/fsetexcptflg.c
@@ -17,6 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <fenv.h>
+#include <fenv_private.h>
 #include <math.h>
 #include <shlib-compat.h>
 
diff --git a/sysdeps/sparc/fpu/ftestexcept.c b/sysdeps/sparc/fpu/ftestexcept.c
index a8c8e06ef6..44367ab4fd 100644
--- a/sysdeps/sparc/fpu/ftestexcept.c
+++ b/sysdeps/sparc/fpu/ftestexcept.c
@@ -17,6 +17,7 @@
    <https://www.gnu.org/licenses/>.  */
 
 #include <fenv.h>
+#include <fenv_private.h>
 
 int
 fetestexcept (int excepts)
