From 9daaf5775cf3157bc1942a391d366fc6ab9277ff Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Thu, 16 May 2013 17:13:40 +0000 Subject: Glen: This patch gets the string conversion functions working on Windows. It also refactors repetitive code in string.cpp do greatly reduce the repetitiveness, increasing maintainability. llvm-svn: 182026 --- libcxx/include/support/win32/support.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'libcxx/include/support/win32') diff --git a/libcxx/include/support/win32/support.h b/libcxx/include/support/win32/support.h index 0b8a912ac17..81cb13a99c5 100644 --- a/libcxx/include/support/win32/support.h +++ b/libcxx/include/support/win32/support.h @@ -15,26 +15,23 @@ Functions and constants used in libc++ that are missing from the Windows C library. */ -#include <__config> -#include // mbstate_t -#include // _snwprintf +#include // mbstate_t +#include // va_ macros #define swprintf _snwprintf #define vswprintf _vsnwprintf -#define vfscnaf fscanf -int vasprintf( char **sptr, const char *__restrict fmt , va_list ap ); -int asprintf( char **sptr, const char *__restrict fmt, ...); -//int vfscanf( FILE *__restrict stream, const char *__restrict format, -// va_list arg); +extern "C" { +int vasprintf( char **sptr, const char *__restrict fmt, va_list ap ); +int asprintf( char **sptr, const char *__restrict fmt, ...); size_t mbsnrtowcs( wchar_t *__restrict dst, const char **__restrict src, size_t nmc, size_t len, mbstate_t *__restrict ps ); size_t wcsnrtombs( char *__restrict dst, const wchar_t **__restrict src, size_t nwc, size_t len, mbstate_t *__restrict ps ); +} #if defined(_MSC_VER) #define snprintf _snprintf - #include #define atoll _atoi64 #define strtoll _strtoi64 @@ -85,9 +82,11 @@ _LIBCPP_ALWAYS_INLINE int __builtin_ctz( unsigned int x ) _BitScanReverse(&r, x); return static_cast(r); } + // sizeof(long) == sizeof(int) on Windows _LIBCPP_ALWAYS_INLINE int __builtin_ctzl( unsigned long x ) { return __builtin_ctz( static_cast(x) ); } + _LIBCPP_ALWAYS_INLINE int __builtin_ctzll( unsigned long long x ) { DWORD r = 0; -- cgit v1.2.3