[libcxx-commits] [PATCH] D99213: [libcxx] Avoid pulling in xlocinfo.h in public headers

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Mar 23 13:34:11 PDT 2021


mstorsjo created this revision.
mstorsjo added reviewers: rnk, pcc, amccarth.
mstorsjo requested review of this revision.
Herald added a project: libc++.
Herald added a reviewer: libc++.

Including xlocinfo.h is a bit of a layering violation; locale.h is
the C library header we should use, while xlocinfo.h is essentially
part of the MS C++ library. Including xlocinfo.h brings in yvals.h,
which brings in yvals_core.h, which defines the MS STL's version
support macros, overriding what libc++'s <version> had defined.

Instead just include locale.h, and provide the few defines we need
for locale categories manually.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99213

Files:
  libcxx/include/__support/win32/locale_win32.h
  libcxx/test/std/language.support/support.limits/support.limits.general/complex.version.pass.cpp
  libcxx/test/std/language.support/support.limits/support.limits.general/filesystem.version.pass.cpp
  libcxx/test/std/language.support/support.limits/support.limits.general/istream.version.pass.cpp
  libcxx/test/std/language.support/support.limits/support.limits.general/locale.version.pass.cpp
  libcxx/test/std/language.support/support.limits/support.limits.general/ostream.version.pass.cpp


Index: libcxx/test/std/language.support/support.limits/support.limits.general/ostream.version.pass.cpp
===================================================================
--- libcxx/test/std/language.support/support.limits/support.limits.general/ostream.version.pass.cpp
+++ libcxx/test/std/language.support/support.limits/support.limits.general/ostream.version.pass.cpp
@@ -12,7 +12,6 @@
 // clang-format off
 
 // UNSUPPORTED: libcpp-has-no-localization
-// XFAIL: LIBCXX-WINDOWS-FIXME
 
 // <ostream>
 
Index: libcxx/test/std/language.support/support.limits/support.limits.general/locale.version.pass.cpp
===================================================================
--- libcxx/test/std/language.support/support.limits/support.limits.general/locale.version.pass.cpp
+++ libcxx/test/std/language.support/support.limits/support.limits.general/locale.version.pass.cpp
@@ -12,7 +12,6 @@
 // clang-format off
 
 // UNSUPPORTED: libcpp-has-no-localization
-// XFAIL: LIBCXX-WINDOWS-FIXME
 
 // <locale>
 
Index: libcxx/test/std/language.support/support.limits/support.limits.general/istream.version.pass.cpp
===================================================================
--- libcxx/test/std/language.support/support.limits/support.limits.general/istream.version.pass.cpp
+++ libcxx/test/std/language.support/support.limits/support.limits.general/istream.version.pass.cpp
@@ -12,7 +12,6 @@
 // clang-format off
 
 // UNSUPPORTED: libcpp-has-no-localization
-// XFAIL: LIBCXX-WINDOWS-FIXME
 
 // <istream>
 
Index: libcxx/test/std/language.support/support.limits/support.limits.general/filesystem.version.pass.cpp
===================================================================
--- libcxx/test/std/language.support/support.limits/support.limits.general/filesystem.version.pass.cpp
+++ libcxx/test/std/language.support/support.limits/support.limits.general/filesystem.version.pass.cpp
@@ -12,7 +12,6 @@
 // clang-format off
 
 // UNSUPPORTED: libcpp-has-no-filesystem-library
-// XFAIL: LIBCXX-WINDOWS-FIXME
 
 // <filesystem>
 
Index: libcxx/test/std/language.support/support.limits/support.limits.general/complex.version.pass.cpp
===================================================================
--- libcxx/test/std/language.support/support.limits/support.limits.general/complex.version.pass.cpp
+++ libcxx/test/std/language.support/support.limits/support.limits.general/complex.version.pass.cpp
@@ -13,8 +13,6 @@
 
 // <complex>
 
-// XFAIL: LIBCXX-WINDOWS-FIXME
-
 // Test the feature test macros defined by <complex>
 
 /*  Constant                       Value
Index: libcxx/include/__support/win32/locale_win32.h
===================================================================
--- libcxx/include/__support/win32/locale_win32.h
+++ libcxx/include/__support/win32/locale_win32.h
@@ -12,9 +12,28 @@
 
 #include <__config>
 #include <stdio.h>
-#include <xlocinfo.h> // _locale_t
+#include <locale.h> // _locale_t
 #include <__nullptr>
 
+#define _X_ALL LC_ALL
+#define _X_COLLATE LC_COLLATE
+#define _X_CTYPE LC_CTYPE
+#define _X_MONETARY LC_MONETARY
+#define _X_NUMERIC LC_NUMERIC
+#define _X_TIME LC_TIME
+#define _X_MAX LC_MAX
+#define _X_MESSAGES 6
+#define _NCAT 7
+
+#define _CATMASK(n) ((1 << (n)) >> 1)
+#define _M_COLLATE _CATMASK(_X_COLLATE)
+#define _M_CTYPE _CATMASK(_X_CTYPE)
+#define _M_MONETARY _CATMASK(_X_MONETARY)
+#define _M_NUMERIC _CATMASK(_X_NUMERIC)
+#define _M_TIME _CATMASK(_X_TIME)
+#define _M_MESSAGES _CATMASK(_X_MESSAGES)
+#define _M_ALL (_CATMASK(_NCAT) - 1)
+
 #define LC_COLLATE_MASK _M_COLLATE
 #define LC_CTYPE_MASK _M_CTYPE
 #define LC_MONETARY_MASK _M_MONETARY


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99213.332776.patch
Type: text/x-patch
Size: 3614 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210323/c8883d6f/attachment-0001.bin>


More information about the libcxx-commits mailing list