From 71e6b5bcf5564ecc59a96fdf2939537e4ccf0004 Mon Sep 17 00:00:00 2001
From: expnkx <unlvsur@live.com>
Date: Wed, 14 Apr 2021 00:17:53 -0400
Subject: [PATCH] Fix build errors on several platforms. [PR100057,PR100012,PR99499,PR99306]

[PATCH] libstdc++: Fix build errors with --disable-hosted-libstdcxx [PR100057]
[PATCH] Fix build errors with MSDOS djgpp hosted [PR100012]
[PATCH] Fix build errors with MSDOS djgpp target [PR99306]
[PATCH] Fix build errors for Android Bionic target [PR99499]
[PATCH] Add no red-zone multilib support for x86_64-elf target [PR100057]

1. The script of --disable-hosted-libstdcxx does not work correctly
since libstdc++ always assumes the header file like stdio.h exists
even in freestanding environment.

This patch is to fix C++ freestanding, to make C++ being self-host.

By the way, I add red-zone multilib support by default since OSdev
has done that for a very long time.
See:https://wiki.osdev.org/Libgcc_without_red_zone
We just add this target by default.

2. Fix libcody and resolver on DOS host because djgpp always defines
unix macro even it is not unix.

3. Fix Android Bionic build. Though Google does not support GCC any more,
some of us still want to use GCC to write android programs. This patch
fixes build error on bionic too by defining macros like _GLIBCXX_U by
ourselves.

The patch has been tested on target x86_64-elf and bootstrapped
successfully on x86_64-linux-gnu with all languages enabled.


gcc/ChangeLog:
  PR gcc/100057
  * gcc/config.gcc, gcc/config/i386/t-x86_64-elf: Add x86_64-elf redzone multilib
  * gcc/ginclude/stdint-wrap.h: Force #include"stdint-gcc.h" when _GLIBCXX_HOSTED == 0
  * gcc/ggc-common.c: Fix build errors with MSDOS host

libcody/ChangeLog:
  PR gcc/100012
  * libcody/cody.hh: Fix build errors with MSDOS host

libstdc++-v3/ChangeLog:
  PR libstdc++/100057
  * libstdc++-v3/configure: Fix build errors with --disable-hosted-libstdcxx
  PR gcc/99306
  * libstdc++-v3/config/os/djgpp/os_defines.h: Fix build errors with MSDOS target
  * libstdc++-v3/src/c++11/shared_ptr.cc: Fix build errors with MSDOS target
  PR gcc/99499
  * libstdc++-v3/config/os/bionic/ctype_base.h: Fix build errors for Android Bionic target

---
 c++tools/resolver.cc                       |   2 +
 gcc/config.gcc                             |   1 +
 gcc/config/i386/t-x86_64-elf               |   4 +
 gcc/ggc-common.c                           |   5 +-
 gcc/ginclude/stdint-wrap.h                 |   2 +-
 libcody/cody.hh                            |   2 +-
 libstdc++-v3/config/os/bionic/ctype_base.h |  39 +++--
 libstdc++-v3/config/os/djgpp/os_defines.h  |   3 +
 libstdc++-v3/configure                     | 158 ++++++++++++++++-----
 libstdc++-v3/src/c++11/shared_ptr.cc       |   6 +
 10 files changed, 167 insertions(+), 55 deletions(-)
 create mode 100644 gcc/config/i386/t-x86_64-elf

diff --git a/c++tools/resolver.cc b/c++tools/resolver.cc
index ef08de53072..720d25fb25a 100644
--- a/c++tools/resolver.cc
+++ b/c++tools/resolver.cc
@@ -30,6 +30,8 @@ along with GCC; see the file COPYING3.  If not see
 #include <unistd.h>
 #if 0 // 1 for testing no mmap
 #define MAPPED_READING 0
+#elif defined (__MSDOS__)
+#define MAPPED_READING 0
 #else
 #ifdef IN_GCC
 #if HAVE_MMAP_FILE && _POSIX_MAPPED_FILES > 0
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 357b0bed067..ce93cb962b8 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1897,6 +1897,7 @@ i[34567]86-*-elf*)
 	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h"
 	;;
 x86_64-*-elf*)
+	tmake_file="${tmake_file} i386/t-x86_64-elf"
 	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h newlib-stdint.h i386/i386elf.h i386/x86-64.h"
 	;;
 x86_64-*-rtems*)
diff --git a/gcc/config/i386/t-x86_64-elf b/gcc/config/i386/t-x86_64-elf
new file mode 100644
index 00000000000..30f86983f5b
--- /dev/null
+++ b/gcc/config/i386/t-x86_64-elf
@@ -0,0 +1,4 @@
+# Add libgcc multilib variant without red-zone requirement
+
+MULTILIB_OPTIONS += mno-red-zone
+MULTILIB_DIRNAMES += no-red-zone
diff --git a/gcc/ggc-common.c b/gcc/ggc-common.c
index 357bda13f97..b4e94714cc7 100644
--- a/gcc/ggc-common.c
+++ b/gcc/ggc-common.c
@@ -1013,7 +1013,10 @@ ggc_prune_overhead_list (void)
 void
 report_heap_memory_use ()
 {
-#if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2)
+#ifdef __MSDOS__
+  if (!quiet_flag)
+    fputs (" {heap oom for ??? size}",stderr);
+#elif defined (HAVE_MALLINFO) || defined (HAVE_MALLINFO2)
 #ifdef HAVE_MALLINFO2
   #define MALLINFO_FN mallinfo2
 #else
diff --git a/gcc/ginclude/stdint-wrap.h b/gcc/ginclude/stdint-wrap.h
index 83b6f70c837..b3ea260e64d 100644
--- a/gcc/ginclude/stdint-wrap.h
+++ b/gcc/ginclude/stdint-wrap.h
@@ -1,5 +1,5 @@
 #ifndef _GCC_WRAP_STDINT_H
-#if __STDC_HOSTED__
+#if __STDC_HOSTED__ && (!defined (_GLIBCXX_HOSTED) || _GLIBCXX_HOSTED == 1)
 # if defined __cplusplus && __cplusplus >= 201103L
 #  undef __STDC_LIMIT_MACROS
 #  define __STDC_LIMIT_MACROS
diff --git a/libcody/cody.hh b/libcody/cody.hh
index 789ce9e70b7..8a0da7fb66c 100644
--- a/libcody/cody.hh
+++ b/libcody/cody.hh
@@ -9,7 +9,7 @@
 // generally only good for requesting no networking
 #if !defined (CODY_NETWORKING)
 // Have a known-good list of networking systems
-#if defined (__unix__) || defined (__MACH__)
+#if (defined (__unix__) && !defined (__MSDOS__)) || defined (__MACH__)
 #define CODY_NETWORKING 1
 #else
 #define CODY_NETWORKING 0
diff --git a/libstdc++-v3/config/os/bionic/ctype_base.h b/libstdc++-v3/config/os/bionic/ctype_base.h
index e169cec8055..b190e01f84d 100644
--- a/libstdc++-v3/config/os/bionic/ctype_base.h
+++ b/libstdc++-v3/config/os/bionic/ctype_base.h
@@ -27,6 +27,20 @@
 //
 
 // Information as gleaned from /usr/include/ctype.h
+// Define macros by ourselves so we do not get into more troubles.
+#define _GLIBCXX_U 0x01
+#define _GLIBCXX_L 0x02
+#define _GLIBCXX_D 0x04
+#define _GLIBCXX_S 0x08
+#define _GLIBCXX_P 0x10
+#define _GLIBCXX_C 0x20
+#define _GLIBCXX_X 0x40
+#define _GLIBCXX_B 0x80
+#define _GLIBCXX_R (_GLIBCXX_P|_GLIBCXX_U|\
+_GLIBCXX_L|_GLIBCXX_D|_GLIBCXX_B)
+
+#define _GLIBCXX_A (_GLIBCXX_L|_GLIBCXX_U)
+#define _GLIBCXX_N _GLIBCXX_D
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -41,20 +55,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     // NB: Offsets into ctype<char>::_M_table force a particular size
     // on the mask type. Because of this, we don't use an enum.
     typedef char 		mask;
-    static const mask upper    	= _U;
-    static const mask lower 	= _L;
-    static const mask alpha 	= _U | _L;
-    static const mask digit 	= _N;
-    static const mask xdigit 	= _X | _N;
-    static const mask space 	= _S;
-    static const mask print 	= _P | _U | _L | _N | _B;
-    static const mask graph 	= _P | _U | _L | _N;
-    static const mask cntrl 	= _C;
-    static const mask punct 	= _P;
-    static const mask alnum 	= _U | _L | _N;
-#if __cplusplus >= 201103L
+    static const mask upper 	= _GLIBCXX_U;
+    static const mask lower 	= _GLIBCXX_L;
+    static const mask alpha 	= _GLIBCXX_A;
+    static const mask digit 	= _GLIBCXX_N;
+    static const mask xdigit	= _GLIBCXX_X | _GLIBCXX_N;
+    static const mask space 	= _GLIBCXX_S;
+    static const mask print 	= _GLIBCXX_R;
+    static const mask graph 	= _GLIBCXX_P | _GLIBCXX_U
+|_GLIBCXX_L | _GLIBCXX_N;
+    static const mask cntrl 	= _GLIBCXX_C;
+    static const mask punct 	= _GLIBCXX_P;
+    static const mask alnum 	= _GLIBCXX_A | _GLIBCXX_N;
     static const mask blank 	= space;
-#endif
   };
 
 _GLIBCXX_END_NAMESPACE_VERSION
diff --git a/libstdc++-v3/config/os/djgpp/os_defines.h b/libstdc++-v3/config/os/djgpp/os_defines.h
index 11c783871ac..5a82eec6e28 100644
--- a/libstdc++-v3/config/os/djgpp/os_defines.h
+++ b/libstdc++-v3/config/os/djgpp/os_defines.h
@@ -35,6 +35,9 @@
 
 // FIXME: should there be '#undef POSIX_SOURCE'?
 
+// See libstdc++/99306
+#define _GLIBCXX_SHARED_PTR_MUTEX_NO_INCREASED_ALIGNMENT 1
+
 #endif
 
 
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 13f2e697ed2..0bd53ca681d 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -595,7 +595,9 @@ PACKAGE_URL=''
 ac_unique_file="src/shared/hashtable-aux.cc"
 # Factoring default headers for most tests.
 ac_includes_default="\
-#include <stdio.h>
+#ifdef HAVE_STDIO_H
+# include <stdio.h>
+#endif
 #ifdef HAVE_SYS_TYPES_H
 # include <sys/types.h>
 #endif
@@ -603,8 +605,12 @@ ac_includes_default="\
 # include <sys/stat.h>
 #endif
 #ifdef STDC_HEADERS
+#ifdef HAVE_STDLIB_H
 # include <stdlib.h>
+#endif
+#ifdef HAVE_STDDEF_H
 # include <stddef.h>
+#endif
 #else
 # ifdef HAVE_STDLIB_H
 #  include <stdlib.h>
@@ -8602,8 +8608,8 @@ $as_echo "#define STDC_HEADERS 1" >>confdefs.h
 fi
 
 # On IRIX 5.3, sys/types and inttypes.h are conflicting.
-for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
-		  inttypes.h stdint.h unistd.h
+for ac_header in stdio.h sys/types.h sys/stat.h stdlib.h string.h memory.h \
+		  strings.h inttypes.h stdint.h unistd.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
@@ -20315,10 +20321,13 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-
-
 # For the EOF, SEEK_CUR, and SEEK_END integer constants.
-
+# in freestanding environment, of course there is no stdio.
+# You are writing operating system.
+# Why do you have stdio.h??? Chicken egg problem.
+# But we would still define these macros to make bootstrapping happy
+# We use fast_io library's value which is also used in
+# all mainstream platforms
 
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the value of EOF" >&5
 $as_echo_n "checking for the value of EOF... " >&6; }
@@ -20328,12 +20337,15 @@ else
 
   if ac_fn_c_compute_int "$LINENO" "EOF" "glibcxx_cv_stdio_eof"        "#include <stdio.h>"; then :
 
-else
-  as_fn_error $? "computing EOF failed" "$LINENO" 5
+  elif test x$enable_hosted_libstdcxx = x"no"; then :
+    glibcxx_cv_stdio_eof="-1"
+    $as_echo "EOF does not exist but we are building freestanding." >&6;
+    $as_echo "#define _GLIBCXX_STDIO_EOF -1" >&6;
+  else
+    as_fn_error $? "computing EOF failed" "$LINENO" 5
+  fi
 fi
 
-
-fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_stdio_eof" >&5
 $as_echo "$glibcxx_cv_stdio_eof" >&6; }
 
@@ -20341,21 +20353,22 @@ cat >>confdefs.h <<_ACEOF
 #define _GLIBCXX_STDIO_EOF $glibcxx_cv_stdio_eof
 _ACEOF
 
-
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the value of SEEK_CUR" >&5
 $as_echo_n "checking for the value of SEEK_CUR... " >&6; }
 if ${glibcxx_cv_stdio_seek_cur+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-
   if ac_fn_c_compute_int "$LINENO" "SEEK_CUR" "glibcxx_cv_stdio_seek_cur"        "#include <stdio.h>"; then :
 
-else
-  as_fn_error $? "computing SEEK_CUR failed" "$LINENO" 5
+  elif test x$enable_hosted_libstdcxx = x"no"; then :
+    glibcxx_cv_stdio_seek_cur="1"
+    $as_echo "SEEK_CUR does not exist but we are building freestanding." >&6;
+    $as_echo "#define _GLIBCXX_STDIO_SEEK_CUR 1" >&6;
+  else
+    as_fn_error $? "computing SEEK_CUR failed" "$LINENO" 5
+  fi
 fi
 
-
-fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_stdio_seek_cur" >&5
 $as_echo "$glibcxx_cv_stdio_seek_cur" >&6; }
 
@@ -20363,21 +20376,21 @@ cat >>confdefs.h <<_ACEOF
 #define _GLIBCXX_STDIO_SEEK_CUR $glibcxx_cv_stdio_seek_cur
 _ACEOF
 
-
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the value of SEEK_END" >&5
 $as_echo_n "checking for the value of SEEK_END... " >&6; }
 if ${glibcxx_cv_stdio_seek_end+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-
   if ac_fn_c_compute_int "$LINENO" "SEEK_END" "glibcxx_cv_stdio_seek_end"        "#include <stdio.h>"; then :
-
-else
-  as_fn_error $? "computing SEEK_END failed" "$LINENO" 5
+  elif test x$enable_hosted_libstdcxx = x"no"; then :
+    glibcxx_cv_stdio_seek_end="2"
+    $as_echo "SEEK_END does not exist but we are building freestanding." >&6;
+    $as_echo "#define _GLIBCXX_STDIO_SEEK_END 2" >&6;
+  else
+    as_fn_error $? "computing SEEK_END failed" "$LINENO" 5
+  fi
 fi
 
-
-fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_cv_stdio_seek_end" >&5
 $as_echo "$glibcxx_cv_stdio_seek_end" >&6; }
 
@@ -20386,7 +20399,6 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
-
 # For gettimeofday support.
 
 
@@ -74131,10 +74143,7 @@ $as_echo "#define HAVE_LINUX_FUTEX 1" >>confdefs.h
 
 fi
 
-
-
-
-inttype_headers=`echo inttypes.h sys/inttypes.h  | sed -e 's/,/ /g'`
+inttype_headers=`echo inttypes.h sys/inttypes.h stddef.h | sed -e 's/,/ /g'`
 
 acx_cv_header_stdint=stddef.h
 acx_cv_header_stdint_kind="(already complete)"
@@ -74151,7 +74160,15 @@ for i in stdint.h $inttype_headers; do
 if test "x$ac_cv_type_uintmax_t" = xyes; then :
   acx_cv_header_stdint=$i
 else
-  continue
+  unset ac_cv_type_uintmax_t
+  ac_fn_c_check_type "$LINENO" "uintmax_t" "ac_cv_type_uintmax_t" "
+#include <$i>
+"
+  if test "x$ac_cv_type_uintmax_t" = xyes; then :
+    acx_cv_header_stdint=$i
+  else
+    continue
+  fi
 fi
 
   ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "#include <sys/types.h>
@@ -74160,7 +74177,14 @@ fi
 if test "x$ac_cv_type_uintptr_t" = xyes; then :
 
 else
-  acx_cv_header_stdint_kind="(mostly complete)"
+  unset ac_cv_type_uintptr_t
+  ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "
+#include <$i>
+"
+  if test "x$ac_cv_type_uintptr_t" = xyes; then :
+  else
+    acx_cv_header_stdint_kind="(mostly complete)"
+  fi
 fi
 
   ac_fn_c_check_type "$LINENO" "int_least32_t" "ac_cv_type_int_least32_t" "#include <sys/types.h>
@@ -74169,7 +74193,14 @@ fi
 if test "x$ac_cv_type_int_least32_t" = xyes; then :
 
 else
-  acx_cv_header_stdint_kind="(mostly complete)"
+  unset ac_cv_type_int_least32_t
+  ac_fn_c_check_type "$LINENO" "int_least32_t" "ac_cv_type_int_least32_t" "
+#include <$i>
+"
+  if test "x$ac_cv_type_int_least32_t" = xyes; then :
+  else
+    acx_cv_header_stdint_kind="(mostly complete)"
+  fi
 fi
 
   ac_fn_c_check_type "$LINENO" "int_fast32_t" "ac_cv_type_int_fast32_t" "#include <sys/types.h>
@@ -74178,7 +74209,14 @@ fi
 if test "x$ac_cv_type_int_fast32_t" = xyes; then :
 
 else
-  acx_cv_header_stdint_kind="(mostly complete)"
+  unset ac_cv_type_int_fast32_t
+  ac_fn_c_check_type "$LINENO" "int_fast32_t" "ac_cv_type_int_fast32_t" "
+#include <$i>
+"
+  if test "x$ac_cv_type_int_fast32_t" = xyes; then :
+  else
+    acx_cv_header_stdint_kind="(mostly complete)"
+  fi
 fi
 
   ac_fn_c_check_type "$LINENO" "uint64_t" "ac_cv_type_uint64_t" "#include <sys/types.h>
@@ -74187,7 +74225,14 @@ fi
 if test "x$ac_cv_type_uint64_t" = xyes; then :
 
 else
-  acx_cv_header_stdint_kind="(lacks uint64_t)"
+  unset ac_cv_type_uint64_t
+  ac_fn_c_check_type "$LINENO" "uint64_t" "ac_cv_type_uint64_t" "
+#include <$i>
+"
+  if test "x$ac_cv_type_uint64_t" = xyes; then :
+  else
+    acx_cv_header_stdint_kind="(lacks uint64_t)"
+  fi
 fi
 
   break
@@ -74205,7 +74250,17 @@ if test "$acx_cv_header_stdint" = stddef.h; then
 if test "x$ac_cv_type_uint32_t" = xyes; then :
   acx_cv_header_stdint=$i
 else
-  continue
+  unset ac_cv_type_uintptr_t
+  unset ac_cv_type_uint32_t
+  unset ac_cv_type_uint64_t
+  ac_fn_c_check_type "$LINENO" "uint32_t" "ac_cv_type_uint32_t" "
+#include <$i>
+"
+  if test "x$ac_cv_type_uint32_t" = xyes; then :
+    acx_cv_header_stdint=$i
+  else
+    continue
+  fi
 fi
 
     ac_fn_c_check_type "$LINENO" "uint64_t" "ac_cv_type_uint64_t" "#include <sys/types.h>
@@ -74213,13 +74268,26 @@ fi
 "
 if test "x$ac_cv_type_uint64_t" = xyes; then :
 
+else
+  unset ac_cv_type_uint64_t
+  ac_fn_c_check_type "$LINENO" "uint64_t" "ac_cv_type_uint64_t" "
+#include <$i>
+"
+  if test "x$ac_cv_type_uint64_t" = xyes; then :
+  fi
 fi
 
     ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "#include <sys/types.h>
 #include <$i>
 "
 if test "x$ac_cv_type_uintptr_t" = xyes; then :
-
+else
+  unset ac_cv_type_uintptr_t
+  ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "
+#include <$i>
+"
+  if test "x$ac_cv_type_uintptr_t" = xyes; then :
+  fi
 fi
 
     break
@@ -74237,7 +74305,15 @@ if test "$acx_cv_header_stdint" = stddef.h; then
 if test "x$ac_cv_type_u_int32_t" = xyes; then :
   acx_cv_header_stdint=$i
 else
-  continue
+  unset ac_cv_type_u_int32_t
+  unset ac_cv_type_u_int64_t
+    ac_fn_c_check_type "$LINENO" "u_int32_t" "ac_cv_type_u_int32_t" "
+#include <$i>
+"
+  if test "x$ac_cv_type_u_int32_t" = xyes; then :
+  else
+    continue
+  fi
 fi
 
     ac_fn_c_check_type "$LINENO" "u_int64_t" "ac_cv_type_u_int64_t" "#include <sys/types.h>
@@ -74245,6 +74321,13 @@ fi
 "
 if test "x$ac_cv_type_u_int64_t" = xyes; then :
 
+else
+  unset ac_cv_type_u_int64_t
+  ac_fn_c_check_type "$LINENO" "u_int64_t" "ac_cv_type_u_int64_t" "
+#include <$i>
+"
+  if test "x$ac_cv_type_u_int64_t" = xyes; then :
+  fi
 fi
 
     break
@@ -74532,9 +74615,6 @@ fi
 ac_config_commands="$ac_config_commands include/gstdint.h"
 
 
-
-
-
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU c++filt" >&5
 $as_echo_n "checking for GNU c++filt... " >&6; }
 if ${ac_cv_path_CXXFILT+:} false; then :
diff --git a/libstdc++-v3/src/c++11/shared_ptr.cc b/libstdc++-v3/src/c++11/shared_ptr.cc
index 4678fbeffe2..77e0e9e1220 100644
--- a/libstdc++-v3/src/c++11/shared_ptr.cc
+++ b/libstdc++-v3/src/c++11/shared_ptr.cc
@@ -34,10 +34,16 @@ namespace __gnu_internal _GLIBCXX_VISIBILITY(hidden)
   __gnu_cxx::__mutex&
   get_mutex(unsigned char i)
   {
+#ifdef _GLIBCXX_SHARED_PTR_MUTEX_NO_INCREASED_ALIGNMENT
+    // See libstdc++/99306
+    static __gnu_cxx::__mutex m[mask + 1];
+    return m[i];
+#else
     // increase alignment to put each lock on a separate cache line
     struct alignas(64) M : __gnu_cxx::__mutex { };
     static M m[mask + 1];
     return m[i];
+#endif
   }
 }
 
-- 
2.25.1

