headers/locale: Make result of `localeconv()` accord to GCC's `-funsigned-char` option

This enables the old behavior when `-funsigned-char` is specified.

The `selectany` attribute is assumed to be supported since GCC 4.2, and
probably by Clang as well.

This test program should print 127 when `char` is signed and 255 when it
is unsigned:

  #include <stdio.h>
  #include <locale.h>

  int main(void)
    {
      struct lconv* lc = localeconv();
      printf("frac_digits = %d\n", lc->frac_digits);
    }

Reference: https://sourceforge.net/p/mingw-w64/mailman/message/37300502/
Reference: https://gcc.gnu.org/onlinedocs/gcc-4.2.4/gcc/Variable-Attributes.html
Signed-off-by: Liu Hao <lh_mouse@126.com>
diff --git a/mingw-w64-headers/crt/_mingw_mac.h b/mingw-w64-headers/crt/_mingw_mac.h
index ca7c897..ee44fc3 100644
--- a/mingw-w64-headers/crt/_mingw_mac.h
+++ b/mingw-w64-headers/crt/_mingw_mac.h
@@ -301,6 +301,8 @@
 #  define __mingw_attribute_artificial
 #endif
 
+#define __MINGW_SELECTANY  __attribute__((__selectany__))
+
 #if _FORTIFY_SOURCE > 0 && __OPTIMIZE__ > 0 && __MINGW_GNUC_PREREQ(4, 1)
 #  if _FORTIFY_SOURCE > 1
 #    define __MINGW_FORTIFY_LEVEL 2
diff --git a/mingw-w64-headers/crt/locale.h b/mingw-w64-headers/crt/locale.h
index 6b1893b..9b695e3 100644
--- a/mingw-w64-headers/crt/locale.h
+++ b/mingw-w64-headers/crt/locale.h
@@ -103,6 +103,12 @@
   _CRTIMP wchar_t *__cdecl _wsetlocale(int _Category,const wchar_t *_Locale);
 #endif
 
+#ifdef __CHAR_UNSIGNED__
+/* Pull in the constructor from 'charmax.c'.  */
+extern int __mingw_initcharmax;
+__MINGW_SELECTANY int* __mingw_reference_charmax = &__mingw_initcharmax;
+#endif
+
 #ifdef __cplusplus
 }
 #endif