diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp
--- a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_fr_FR.pass.cpp
@@ -54,10 +54,9 @@
 // this function converts the spaces in string inputs to that character if need
 // be.
 static std::wstring convert_thousands_sep(std::wstring const& in) {
-#ifndef TEST_GLIBC_PREREQ
-#define TEST_GLIBC_PREREQ(x, y) 0
-#endif
-#if TEST_GLIBC_PREREQ(2,27)
+#if defined(_CS_GNU_LIBC_VERSION)
+  if (glibc_version_less_than("2.27"))
+    return in;
   std::wstring out;
   unsigned I = 0;
   bool seen_decimal = false;
diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp
--- a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_fr_FR.pass.cpp
@@ -54,10 +54,9 @@
 // this function converts the spaces in string inputs to that character if need
 // be.
 static std::wstring convert_thousands_sep(std::wstring const& in) {
-#ifndef TEST_GLIBC_PREREQ
-#define TEST_GLIBC_PREREQ(x, y) 0
-#endif
-#if TEST_GLIBC_PREREQ(2,27)
+#if defined(_CS_GNU_LIBC_VERSION)
+  if (glibc_version_less_than("2.27"))
+    return in;
   std::wstring out;
   unsigned I = 0;
   bool seen_num_start = false;
diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
--- a/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/curr_symbol.pass.cpp
@@ -61,20 +61,6 @@
         : std::moneypunct_byname<wchar_t, true>(nm, refs) {}
 };
 
-#if defined(_CS_GNU_LIBC_VERSION)
-static bool glibc_version_less_than(char const* version) {
-    std::string test_version = std::string("glibc ") + version;
-
-    size_t n = confstr(_CS_GNU_LIBC_VERSION, nullptr, (size_t)0);
-    char *current_version = new char[n];
-    confstr(_CS_GNU_LIBC_VERSION, current_version, n);
-
-    bool result = strverscmp(current_version, test_version.c_str()) < 0;
-    delete[] current_version;
-    return result;
-}
-#endif
-
 int main(int, char**)
 {
     {
diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp
--- a/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/decimal_point.pass.cpp
@@ -110,15 +110,12 @@
     }
 // GLIBC 2.23 uses '.' as the decimal point while other C libraries use ','
 // GLIBC 2.27 corrects this
-#ifndef TEST_GLIBC_PREREQ
-#define TEST_GLIBC_PREREQ(x, y) 0
-#endif
-#if !defined(TEST_HAS_GLIBC) || TEST_GLIBC_PREREQ(2, 27)
+#if defined(_CS_GNU_LIBC_VERSION)
+    const char sep = glibc_version_less_than("2.27") ? '.' : ',';
+    const wchar_t wsep = glibc_version_less_than("2.27") ? L'.' : L',';
+#else
     const char sep = ',';
     const wchar_t wsep = L',';
-#else
-    const char sep = '.';
-    const wchar_t wsep = L'.';
 #endif
     {
         Fnf f(LOCALE_ru_RU_UTF_8, 1);
diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
--- a/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/category.monetary/locale.moneypunct.byname/thousands_sep.pass.cpp
@@ -103,11 +103,8 @@
         assert(f.thousands_sep() == ' ');
     }
 // The below tests work around GLIBC's use of U202F as mon_thousands_sep.
-#ifndef TEST_GLIBC_PREREQ
-#define TEST_GLIBC_PREREQ(x, y) 0
-#endif
-#if defined(TEST_HAS_GLIBC) && TEST_GLIBC_PREREQ(2, 27)
-    const wchar_t fr_sep = L'\u202F';
+#if defined(_CS_GNU_LIBC_VERSION)
+    const wchar_t fr_sep = glibc_version_less_than("2.27") ? L' ' : L'\u202F';
 #else
     const wchar_t fr_sep = L' ';
 #endif
@@ -123,18 +120,15 @@
 // and U002E as mon_decimal_point.
 // TODO: Fix thousands_sep for 'char'.
 // related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=16006
-#ifndef TEST_HAS_GLIBC
+#if defined(_CS_GNU_LIBC_VERSION)
     const char sep = ' ';
-    const wchar_t wsep = L' ';
-#elif TEST_GLIBC_PREREQ(2, 27)
     // FIXME libc++ specifically works around \u00A0 by translating it into
     // a regular space.
-    const char sep = ' ';
-    const wchar_t wsep = L'\u202F';
+    const wchar_t wsep = glibc_version_less_than("2.27") ? L'\u00A0' : L'\u202F';
 #else
+    const char sep = ' ';
     // FIXME libc++ specifically works around \u00A0 by translating it into
     // a regular space.
-    const char sep = ' ';
     const wchar_t wsep = L'\u00A0';
 #endif
     {
diff --git a/libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp b/libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
--- a/libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
+++ b/libcxx/test/std/localization/locale.categories/facet.numpunct/locale.numpunct.byname/thousands_sep.pass.cpp
@@ -56,14 +56,10 @@
     }
     {
         std::locale l(LOCALE_fr_FR_UTF_8);
-#if defined(TEST_HAS_GLIBC)
-        const char sep = ' ';
 // The below tests work around GLIBC's use of U202F as LC_NUMERIC thousands_sep.
-# if TEST_GLIBC_PREREQ(2, 27)
-        const wchar_t wsep = L'\u202f';
-# else
-        const wchar_t wsep = L' ';
-# endif
+#if defined(_CS_GNU_LIBC_VERSION)
+        const char sep = ' ';
+        const wchar_t wsep = glibc_version_less_than("2.27") ? L' ' : L'\u202f';
 #else
         const char sep = ',';
         const wchar_t wsep = L',';
diff --git a/libcxx/test/support/platform_support.h b/libcxx/test/support/platform_support.h
--- a/libcxx/test/support/platform_support.h
+++ b/libcxx/test/support/platform_support.h
@@ -110,4 +110,18 @@
 
 #endif // __CloudABI__
 
+#if defined(_CS_GNU_LIBC_VERSION)
+inline bool glibc_version_less_than(char const* version) {
+  std::string test_version = std::string("glibc ") + version;
+
+  size_t n = confstr(_CS_GNU_LIBC_VERSION, nullptr, (size_t)0);
+  char *current_version = new char[n];
+  confstr(_CS_GNU_LIBC_VERSION, current_version, n);
+
+  bool result = strverscmp(current_version, test_version.c_str()) < 0;
+  delete[] current_version;
+  return result;
+}
+#endif // _CS_GNU_LIBC_VERSION
+
 #endif // PLATFORM_SUPPORT_H