[libcxx] r190837 - G M: Restore the ability for libcxx to compile again on mingw 64.

Howard Hinnant hhinnant at apple.com
Mon Sep 16 18:34:48 PDT 2013


Author: hhinnant
Date: Mon Sep 16 20:34:47 2013
New Revision: 190837

URL: http://llvm.org/viewvc/llvm-project?rev=190837&view=rev
Log:
G M:  Restore the ability for libcxx to compile again on mingw 64.

Modified:
    libcxx/trunk/include/__config
    libcxx/trunk/include/__locale
    libcxx/trunk/include/algorithm
    libcxx/trunk/include/cstdio
    libcxx/trunk/include/cwchar
    libcxx/trunk/include/locale
    libcxx/trunk/include/support/win32/limits_win32.h
    libcxx/trunk/include/support/win32/locale_win32.h
    libcxx/trunk/include/support/win32/math_win32.h
    libcxx/trunk/include/support/win32/support.h
    libcxx/trunk/src/locale.cpp

Modified: libcxx/trunk/include/__config
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=190837&r1=190836&r2=190837&view=diff
==============================================================================
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Mon Sep 16 20:34:47 2013
@@ -80,7 +80,10 @@
 #  if defined(_MSC_VER) && !defined(__clang__)
 #    define _LIBCPP_MSVC // Using Microsoft Visual C++ compiler
 #  endif
-#  define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
+#  // If mingw not explicitly detected, assume using MS C runtime only.
+#  ifndef __MINGW32__
+#    define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
+#  endif
 #endif  // _WIN32
 
 #ifdef __linux__

Modified: libcxx/trunk/include/__locale
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__locale?rev=190837&r1=190836&r2=190837&view=diff
==============================================================================
--- libcxx/trunk/include/__locale (original)
+++ libcxx/trunk/include/__locale Mon Sep 16 20:34:47 2013
@@ -19,7 +19,7 @@
 #include <cstdint>
 #include <cctype>
 #include <locale.h>
-#ifdef _LIBCPP_MSVCRT
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
 # include <support/win32/locale_win32.h>
 #elif _AIX
 # include <support/ibm/xlocale.h>

Modified: libcxx/trunk/include/algorithm
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=190837&r1=190836&r2=190837&view=diff
==============================================================================
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Mon Sep 16 20:34:47 2013
@@ -631,6 +631,9 @@ template <class BidirectionalIterator, c
 #if defined(__IBMCPP__)
 #include "support/ibm/support.h"
 #endif
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+#include "support/win32/support.h"
+#endif
 
 #include <__undef_min_max>
 

Modified: libcxx/trunk/include/cstdio
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstdio?rev=190837&r1=190836&r2=190837&view=diff
==============================================================================
--- libcxx/trunk/include/cstdio (original)
+++ libcxx/trunk/include/cstdio Mon Sep 16 20:34:47 2013
@@ -103,6 +103,11 @@ void perror(const char* s);
 #pragma GCC system_header
 #endif
 
+// snprintf
+#if defined(_LIBCPP_MSVCRT)
+#include "support/win32/support.h"
+#endif
+
 #ifdef getc
 inline _LIBCPP_INLINE_VISIBILITY int __libcpp_getc(FILE* __stream) {return getc(__stream);}
 #undef getc

Modified: libcxx/trunk/include/cwchar
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cwchar?rev=190837&r1=190836&r2=190837&view=diff
==============================================================================
--- libcxx/trunk/include/cwchar (original)
+++ libcxx/trunk/include/cwchar Mon Sep 16 20:34:47 2013
@@ -106,7 +106,7 @@ size_t wcsrtombs(char* restrict dst, con
 #include <__config>
 #include <cwctype>
 #include <wchar.h>
-#ifdef _LIBCPP_MSVCRT
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
 #include <support/win32/support.h> // pull in *swprintf defines
 #endif // _LIBCPP_MSVCRT
 

Modified: libcxx/trunk/include/locale
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/locale?rev=190837&r1=190836&r2=190837&view=diff
==============================================================================
--- libcxx/trunk/include/locale (original)
+++ libcxx/trunk/include/locale Mon Sep 16 20:34:47 2013
@@ -191,7 +191,7 @@ template <class charT> class messages_by
 #endif
 #include <cstdlib>
 #include <ctime>
-#ifdef _LIBCPP_MSVCRT
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
 #include <support/win32/locale_win32.h>
 #else // _LIBCPP_MSVCRT
 #include <nl_types.h>

Modified: libcxx/trunk/include/support/win32/limits_win32.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/win32/limits_win32.h?rev=190837&r1=190836&r2=190837&view=diff
==============================================================================
--- libcxx/trunk/include/support/win32/limits_win32.h (original)
+++ libcxx/trunk/include/support/win32/limits_win32.h Mon Sep 16 20:34:47 2013
@@ -12,16 +12,15 @@
 #define _LIBCPP_SUPPORT_WIN32_LIMITS_WIN32_H
 
 #if !defined(_LIBCPP_MSVCRT)
-#error "This header complements Microsoft's C Runtime library, and should not be included otherwise."
+#error "This header complements the Microsoft C Runtime library, and should not be included otherwise."
 #else
 
-#ifndef NOMINMAX
-#define NOMINMAX
-#endif
-#include <windows.h> // ymath.h works correctly
-
+#include <limits.h> // CHAR_BIT
 #include <float.h> // limit constants
 
+#if ! defined(__clang__)
+#define __CHAR_BIT__       CHAR_BIT
+
 #define __FLT_MANT_DIG__   FLT_MANT_DIG
 #define __FLT_DIG__        FLT_DIG
 #define __FLT_RADIX__      FLT_RADIX
@@ -73,6 +72,7 @@
 #define __builtin_nans(__dummy)  _Snan._Double
 #define __builtin_nansf(__dummy) _FSnan._Float
 #define __builtin_nansl(__dummy) _LSnan._Long_double
+#endif ! defined(__clang__)
 
 #endif // _LIBCPP_MSVCRT
 

Modified: libcxx/trunk/include/support/win32/locale_win32.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/win32/locale_win32.h?rev=190837&r1=190836&r2=190837&view=diff
==============================================================================
--- libcxx/trunk/include/support/win32/locale_win32.h (original)
+++ libcxx/trunk/include/support/win32/locale_win32.h Mon Sep 16 20:34:47 2013
@@ -15,6 +15,7 @@
 extern "C" unsigned short  __declspec(dllimport) _ctype[];
 
 #include "support/win32/support.h"
+#include <stdio.h>
 #include <memory>
 #include <xlocinfo.h> // _locale_t
 #define locale_t _locale_t
@@ -35,18 +36,18 @@ extern "C" unsigned short  __declspec(dl
 locale_t newlocale( int mask, const char * locale, locale_t base );
 locale_t uselocale( locale_t newloc );
 lconv *localeconv_l( locale_t loc );
-size_t mbrlen_l( const char *__restrict__ s, size_t n,
-                 mbstate_t *__restrict__ ps, locale_t loc);
-size_t mbsrtowcs_l( wchar_t *__restrict__ dst, const char **__restrict__ src,
-                    size_t len, mbstate_t *__restrict__ ps, locale_t loc );
-size_t wcrtomb_l( char *__restrict__ s, wchar_t wc, mbstate_t *__restrict__ ps,
+size_t mbrlen_l( const char *__restrict s, size_t n,
+                 mbstate_t *__restrict ps, locale_t loc);
+size_t mbsrtowcs_l( wchar_t *__restrict dst, const char **__restrict src,
+                    size_t len, mbstate_t *__restrict ps, locale_t loc );
+size_t wcrtomb_l( char *__restrict s, wchar_t wc, mbstate_t *__restrict ps,
                   locale_t loc);
-size_t mbrtowc_l( wchar_t *__restrict__ pwc, const char *__restrict__ s,
-                  size_t n, mbstate_t *__restrict__ ps, locale_t loc);
-size_t mbsnrtowcs_l( wchar_t *__restrict__ dst, const char **__restrict__ src,
-                     size_t nms, size_t len, mbstate_t *__restrict__ ps, locale_t loc);
-size_t wcsnrtombs_l( char *__restrict__ dst, const wchar_t **__restrict__ src,
-                     size_t nwc, size_t len, mbstate_t *__restrict__ ps, locale_t loc);
+size_t mbrtowc_l( wchar_t *__restrict pwc, const char *__restrict s,
+                  size_t n, mbstate_t *__restrict ps, locale_t loc);
+size_t mbsnrtowcs_l( wchar_t *__restrict dst, const char **__restrict src,
+                     size_t nms, size_t len, mbstate_t *__restrict ps, locale_t loc);
+size_t wcsnrtombs_l( char *__restrict dst, const wchar_t **__restrict src,
+                     size_t nwc, size_t len, mbstate_t *__restrict ps, locale_t loc);
 wint_t btowc_l( int c, locale_t loc );
 int wctob_l( wint_t c, locale_t loc );
 typedef _VSTD::remove_pointer<locale_t>::type __locale_struct;
@@ -59,7 +60,6 @@ decltype(MB_CUR_MAX) MB_CUR_MAX_L( local
 }
 
 // the *_l functions are prefixed on Windows, only available for msvcr80+, VS2005+
-#include <stdio.h>
 #define mbtowc_l _mbtowc_l
 #define strtoll_l _strtoi64_l
 #define strtoull_l _strtoui64_l
@@ -120,10 +120,10 @@ inline int iswblank_l( wint_t c, locale_
     return ( c == L' ' || c == L'\t' );
 }
 
-#ifdef _MSC_VER
+#if defined(_LIBCPP_MSVCRT)
 inline int isblank( int c, locale_t /*loc*/ )
 { return ( c == ' ' || c == '\t' ); }
 inline int iswblank( wint_t c, locale_t /*loc*/ )
 { return ( c == L' ' || c == L'\t' ); }
-#endif // _MSC_VER
+#endif // _LIBCPP_MSVCRT
 #endif // _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H

Modified: libcxx/trunk/include/support/win32/math_win32.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/win32/math_win32.h?rev=190837&r1=190836&r2=190837&view=diff
==============================================================================
--- libcxx/trunk/include/support/win32/math_win32.h (original)
+++ libcxx/trunk/include/support/win32/math_win32.h Mon Sep 16 20:34:47 2013
@@ -16,7 +16,9 @@
 #else
 
 #include <math.h>
+#include <float.h> // _FPCLASS_PN etc.
 
+// Necessary?
 typedef float float_t;
 typedef double double_t;
 

Modified: libcxx/trunk/include/support/win32/support.h
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/support/win32/support.h?rev=190837&r1=190836&r2=190837&view=diff
==============================================================================
--- libcxx/trunk/include/support/win32/support.h (original)
+++ libcxx/trunk/include/support/win32/support.h Mon Sep 16 20:34:47 2013
@@ -15,11 +15,16 @@
    Functions and constants used in libc++ that are missing from the Windows C library.
   */
 
-#include <cwchar>  // mbstate_t
+#include <wchar.h>  // mbstate_t
 #include <cstdarg> // va_ macros
 #define swprintf _snwprintf
 #define vswprintf _vsnwprintf
 
+#ifndef NOMINMAX
+#define NOMINMAX
+#endif
+#include <Windows.h>
+
 extern "C" {
 
 int vasprintf( char **sptr, const char *__restrict fmt, va_list ap );

Modified: libcxx/trunk/src/locale.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/locale.cpp?rev=190837&r1=190836&r2=190837&view=diff
==============================================================================
--- libcxx/trunk/src/locale.cpp (original)
+++ libcxx/trunk/src/locale.cpp Mon Sep 16 20:34:47 2013
@@ -28,7 +28,7 @@
 #include "cstring"
 #include "cwctype"
 #include "__sso_allocator"
-#ifdef _LIBCPP_MSVCRT
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
 #include <support/win32/locale_win32.h>
 #else // _LIBCPP_MSVCRT
 #include <langinfo.h>
@@ -1016,7 +1016,7 @@ ctype<char>::classic_table()  _NOEXCEPT
     return __cloc()->__ctype_b;
 #elif __sun__
     return __ctype_mask;
-#elif defined(_LIBCPP_MSVCRT)
+#elif defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
     return _ctype+1; // internal ctype mask table defined in msvcrt.dll
 // This is assumed to be safe, which is a nonsense assumption because we're
 // going to end up dereferencing it later...
@@ -5857,7 +5857,7 @@ moneypunct_byname<char, true>::init(cons
         __frac_digits_ = lc->int_frac_digits;
     else
         __frac_digits_ = base::do_frac_digits();
-#ifdef _LIBCPP_MSVCRT
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
     if (lc->p_sign_posn == 0)
 #else // _LIBCPP_MSVCRT
     if (lc->int_p_sign_posn == 0)
@@ -5865,7 +5865,7 @@ moneypunct_byname<char, true>::init(cons
         __positive_sign_ = "()";
     else
         __positive_sign_ = lc->positive_sign;
-#ifdef _LIBCPP_MSVCRT
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
     if(lc->n_sign_posn == 0)
 #else // _LIBCPP_MSVCRT
     if (lc->int_n_sign_posn == 0)
@@ -5877,7 +5877,7 @@ moneypunct_byname<char, true>::init(cons
     // the same places in curr_symbol since there's no way to
     // represent anything else.
     string_type __dummy_curr_symbol = __curr_symbol_;
-#ifdef _LIBCPP_MSVCRT
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
     __init_pat(__pos_format_, __dummy_curr_symbol, true,
                lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, ' ');
     __init_pat(__neg_format_, __curr_symbol_, true,
@@ -6016,7 +6016,7 @@ moneypunct_byname<wchar_t, true>::init(c
         __frac_digits_ = lc->int_frac_digits;
     else
         __frac_digits_ = base::do_frac_digits();
-#ifdef _LIBCPP_MSVCRT
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
     if (lc->p_sign_posn == 0)
 #else // _LIBCPP_MSVCRT
     if (lc->int_p_sign_posn == 0)
@@ -6036,7 +6036,7 @@ moneypunct_byname<wchar_t, true>::init(c
         wbe = wbuf + j;
         __positive_sign_.assign(wbuf, wbe);
     }
-#ifdef _LIBCPP_MSVCRT
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
     if (lc->n_sign_posn == 0)
 #else // _LIBCPP_MSVCRT
     if (lc->int_n_sign_posn == 0)
@@ -6060,7 +6060,7 @@ moneypunct_byname<wchar_t, true>::init(c
     // the same places in curr_symbol since there's no way to
     // represent anything else.
     string_type __dummy_curr_symbol = __curr_symbol_;
-#ifdef _LIBCPP_MSVCRT
+#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
     __init_pat(__pos_format_, __dummy_curr_symbol, true,
                lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, L' ');
     __init_pat(__neg_format_, __curr_symbol_, true,





More information about the cfe-commits mailing list