diff --git a/libgfortran/acinclude.m4 b/libgfortran/acinclude.m4
index 7585df13fd71509b31bc60b05b1c837ba0279b29..b4cc0bdde1251d4d2eea9271468477a72d5d94c2 100644
--- a/libgfortran/acinclude.m4
+++ b/libgfortran/acinclude.m4
@@ -537,8 +537,8 @@ AC_DEFUN([LIBGFOR_CHECK_MATH_IEEE128],
   AC_REQUIRE([GCC_CHECK_MATH_HEADERS])
   AC_CACHE_CHECK([for $1], [gcc_cv_math_func_$1],
 		 [AC_LINK_IFELSE([AC_LANG_SOURCE([
-__float128 $1 (__float128);
-__float128 (*ptr)(__float128) = $1;
+_Float128 $1 (_Float128);
+_Float128 (*ptr)(_Float128) = $1;
 
 int
 main ()
diff --git a/libgfortran/configure b/libgfortran/configure
index c440721d1fd0d206e7129a8fd90b3c54d1158303..581f1dc52d291bd1d933dd635a2b6439adb882f1 100755
--- a/libgfortran/configure
+++ b/libgfortran/configure
@@ -25862,8 +25862,8 @@ fi
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-__float128 __acoshieee128 (__float128);
-__float128 (*ptr)(__float128) = __acoshieee128;
+_Float128 __acoshieee128 (_Float128);
+_Float128 (*ptr)(_Float128) = __acoshieee128;
 
 int
 main ()
@@ -25904,8 +25904,8 @@ fi
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-__float128 __acosieee128 (__float128);
-__float128 (*ptr)(__float128) = __acosieee128;
+_Float128 __acosieee128 (_Float128);
+_Float128 (*ptr)(_Float128) = __acosieee128;
 
 int
 main ()
@@ -25946,8 +25946,8 @@ fi
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-__float128 __asinhieee128 (__float128);
-__float128 (*ptr)(__float128) = __asinhieee128;
+_Float128 __asinhieee128 (_Float128);
+_Float128 (*ptr)(_Float128) = __asinhieee128;
 
 int
 main ()
@@ -25988,8 +25988,8 @@ fi
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-__float128 __asinieee128 (__float128);
-__float128 (*ptr)(__float128) = __asinieee128;
+_Float128 __asinieee128 (_Float128);
+_Float128 (*ptr)(_Float128) = __asinieee128;
 
 int
 main ()
@@ -26030,8 +26030,8 @@ fi
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-__float128 __atan2ieee128 (__float128);
-__float128 (*ptr)(__float128) = __atan2ieee128;
+_Float128 __atan2ieee128 (_Float128);
+_Float128 (*ptr)(_Float128) = __atan2ieee128;
 
 int
 main ()
@@ -26072,8 +26072,8 @@ fi
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-__float128 __atanhieee128 (__float128);
-__float128 (*ptr)(__float128) = __atanhieee128;
+_Float128 __atanhieee128 (_Float128);
+_Float128 (*ptr)(_Float128) = __atanhieee128;
 
 int
 main ()
@@ -26114,8 +26114,8 @@ fi
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-__float128 __atanieee128 (__float128);
-__float128 (*ptr)(__float128) = __atanieee128;
+_Float128 __atanieee128 (_Float128);
+_Float128 (*ptr)(_Float128) = __atanieee128;
 
 int
 main ()
@@ -26156,8 +26156,8 @@ fi
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-__float128 __coshieee128 (__float128);
-__float128 (*ptr)(__float128) = __coshieee128;
+_Float128 __coshieee128 (_Float128);
+_Float128 (*ptr)(_Float128) = __coshieee128;
 
 int
 main ()
@@ -26198,8 +26198,8 @@ fi
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-__float128 __cosieee128 (__float128);
-__float128 (*ptr)(__float128) = __cosieee128;
+_Float128 __cosieee128 (_Float128);
+_Float128 (*ptr)(_Float128) = __cosieee128;
 
 int
 main ()
@@ -26240,8 +26240,8 @@ fi
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-__float128 __erfieee128 (__float128);
-__float128 (*ptr)(__float128) = __erfieee128;
+_Float128 __erfieee128 (_Float128);
+_Float128 (*ptr)(_Float128) = __erfieee128;
 
 int
 main ()
@@ -26282,8 +26282,8 @@ fi
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-__float128 __expieee128 (__float128);
-__float128 (*ptr)(__float128) = __expieee128;
+_Float128 __expieee128 (_Float128);
+_Float128 (*ptr)(_Float128) = __expieee128;
 
 int
 main ()
@@ -26324,8 +26324,8 @@ fi
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-__float128 __fabsieee128 (__float128);
-__float128 (*ptr)(__float128) = __fabsieee128;
+_Float128 __fabsieee128 (_Float128);
+_Float128 (*ptr)(_Float128) = __fabsieee128;
 
 int
 main ()
@@ -26366,8 +26366,8 @@ fi
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-__float128 __jnieee128 (__float128);
-__float128 (*ptr)(__float128) = __jnieee128;
+_Float128 __jnieee128 (_Float128);
+_Float128 (*ptr)(_Float128) = __jnieee128;
 
 int
 main ()
@@ -26408,8 +26408,8 @@ fi
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-__float128 __log10ieee128 (__float128);
-__float128 (*ptr)(__float128) = __log10ieee128;
+_Float128 __log10ieee128 (_Float128);
+_Float128 (*ptr)(_Float128) = __log10ieee128;
 
 int
 main ()
@@ -26450,8 +26450,8 @@ fi
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-__float128 __logieee128 (__float128);
-__float128 (*ptr)(__float128) = __logieee128;
+_Float128 __logieee128 (_Float128);
+_Float128 (*ptr)(_Float128) = __logieee128;
 
 int
 main ()
@@ -26492,8 +26492,8 @@ fi
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-__float128 __powieee128 (__float128);
-__float128 (*ptr)(__float128) = __powieee128;
+_Float128 __powieee128 (_Float128);
+_Float128 (*ptr)(_Float128) = __powieee128;
 
 int
 main ()
@@ -26534,8 +26534,8 @@ fi
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-__float128 __sinhieee128 (__float128);
-__float128 (*ptr)(__float128) = __sinhieee128;
+_Float128 __sinhieee128 (_Float128);
+_Float128 (*ptr)(_Float128) = __sinhieee128;
 
 int
 main ()
@@ -26576,8 +26576,8 @@ fi
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-__float128 __sinieee128 (__float128);
-__float128 (*ptr)(__float128) = __sinieee128;
+_Float128 __sinieee128 (_Float128);
+_Float128 (*ptr)(_Float128) = __sinieee128;
 
 int
 main ()
@@ -26618,8 +26618,8 @@ fi
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-__float128 __sqrtieee128 (__float128);
-__float128 (*ptr)(__float128) = __sqrtieee128;
+_Float128 __sqrtieee128 (_Float128);
+_Float128 (*ptr)(_Float128) = __sqrtieee128;
 
 int
 main ()
@@ -26660,8 +26660,8 @@ fi
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-__float128 __tanhieee128 (__float128);
-__float128 (*ptr)(__float128) = __tanhieee128;
+_Float128 __tanhieee128 (_Float128);
+_Float128 (*ptr)(_Float128) = __tanhieee128;
 
 int
 main ()
@@ -26702,8 +26702,8 @@ fi
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-__float128 __tanieee128 (__float128);
-__float128 (*ptr)(__float128) = __tanieee128;
+_Float128 __tanieee128 (_Float128);
+_Float128 (*ptr)(_Float128) = __tanieee128;
 
 int
 main ()
@@ -26744,8 +26744,8 @@ fi
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-__float128 __ynieee128 (__float128);
-__float128 (*ptr)(__float128) = __ynieee128;
+_Float128 __ynieee128 (_Float128);
+_Float128 (*ptr)(_Float128) = __ynieee128;
 
 int
 main ()
diff --git a/libgfortran/libgfortran.h b/libgfortran/libgfortran.h
index c21224539ebe6e724c27480e05a248180717eebe..0db3a35031f03a7f407a7277944d4cfa5ba5d619 100644
--- a/libgfortran/libgfortran.h
+++ b/libgfortran/libgfortran.h
@@ -247,7 +247,7 @@ extern int __mingw_snprintf (char *, size_t, const char *, ...)
 
    Another advantage for GCC's builtins for these type-generic macros
    is that it handles floating-point types that the system headers
-   may not support (like __float128).  */
+   may not support (like _Float128).  */
 
 #undef isnan
 #define isnan(x) __builtin_isnan(x)
@@ -1960,59 +1960,59 @@ internal_proto(cshift1_16_c17);
 
 /* Prototypes for the POWER __ieee128 functions.  */
 #ifdef POWER_IEEE128
-extern __float128 __acoshieee128 (__float128)
+extern _Float128 __acoshieee128 (_Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __acosieee128 (__float128)
+extern _Float128 __acosieee128 (_Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __asinhieee128 (__float128)
+extern _Float128 __asinhieee128 (_Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __asinieee128 (__float128)
+extern _Float128 __asinieee128 (_Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __atan2ieee128 (__float128)
+extern _Float128 __atan2ieee128 (_Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __atanhieee128 (__float128)
+extern _Float128 __atanhieee128 (_Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __atanieee128 (__float128)
+extern _Float128 __atanieee128 (_Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __copysignieee128 (__float128, __float128)
+extern _Float128 __copysignieee128 (_Float128, _Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __coshieee128 (__float128)
+extern _Float128 __coshieee128 (_Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __cosieee128 (__float128)
+extern _Float128 __cosieee128 (_Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __erfcieee128 (__float128)
+extern _Float128 __erfcieee128 (_Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __erfieee128 (__float128)
+extern _Float128 __erfieee128 (_Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __expieee128 (__float128)
+extern _Float128 __expieee128 (_Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __fabsieee128 (__float128)
+extern _Float128 __fabsieee128 (_Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __fmaieee128 (__float128, __float128, __float128)
+extern _Float128 __fmaieee128 (_Float128, _Float128, _Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __fmodieee128 (__float128, __float128)
+extern _Float128 __fmodieee128 (_Float128, _Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __jnieee128 (int, __float128)
+extern _Float128 __jnieee128 (int, _Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __log10ieee128 (__float128)
+extern _Float128 __log10ieee128 (_Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __logieee128 (__float128)
+extern _Float128 __logieee128 (_Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __powieee128 (__float128)
+extern _Float128 __powieee128 (_Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __sinhieee128 (__float128)
+extern _Float128 __sinhieee128 (_Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __sinieee128 (__float128)
+extern _Float128 __sinieee128 (_Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __sqrtieee128 (__float128)
+extern _Float128 __sqrtieee128 (_Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __tanhieee128 (__float128)
+extern _Float128 __tanhieee128 (_Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __tanieee128 (__float128)
+extern _Float128 __tanieee128 (_Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __ynieee128 (int , __float128)
+extern _Float128 __ynieee128 (int , _Float128)
   __attribute__ ((__nothrow__, __leaf__));
-extern __float128 __strtoieee128 (const char *, char **)
+extern _Float128 __strtoieee128 (const char *, char **)
   __attribute__ ((__nothrow__, __leaf__));
 extern int __snprintfieee128 (char *, size_t, const char *, ...)
   __attribute__ ((__nothrow__));
diff --git a/libgfortran/mk-kinds-h.sh b/libgfortran/mk-kinds-h.sh
index be4a6325b88736e88bbf3a466b105637103965ee..0e0ec195875a8aa952fbfef265960d32d81ecad1 100755
--- a/libgfortran/mk-kinds-h.sh
+++ b/libgfortran/mk-kinds-h.sh
@@ -67,7 +67,7 @@ for k in $possible_real_kinds; do
       8) ctype="double" ; cplxtype="complex double" ; suffix="" ;;
       # If we have a REAL(KIND=10), it is always long double
       10) ctype="long double" ; cplxtype="complex long double" ; suffix="l" ;;
-      # If we have a REAL(KIND=16), it is either long double or __float128
+      # If we have a REAL(KIND=16), it is either long double or _Float128
       16) if [ $long_double_kind -ne 16 ]; then
 	    ctype="_Float128"
 	    cplxtype="_Complex _Float128"