diff options
author | Howard Hinnant <hhinnant@apple.com> | 2011-10-22 20:59:45 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2011-10-22 20:59:45 +0000 |
commit | e4383379aea7783e11f2229f27fa81b52751e4f4 (patch) | |
tree | 4f369dabb74c0a9b6d1059d801b4e41607e2157d /libcxx/include/support | |
parent | a6674c7fc965ef39b97d2faf518587e02cc23d56 (diff) | |
download | bcm5719-llvm-e4383379aea7783e11f2229f27fa81b52751e4f4.tar.gz bcm5719-llvm-e4383379aea7783e11f2229f27fa81b52751e4f4.zip |
More windows port work by Ruben Van Boxem
llvm-svn: 142732
Diffstat (limited to 'libcxx/include/support')
-rw-r--r-- | libcxx/include/support/win32/limits_win32.h | 24 | ||||
-rw-r--r-- | libcxx/include/support/win32/support.h | 76 |
2 files changed, 85 insertions, 15 deletions
diff --git a/libcxx/include/support/win32/limits_win32.h b/libcxx/include/support/win32/limits_win32.h index 91cdcf156af..671631df2f9 100644 --- a/libcxx/include/support/win32/limits_win32.h +++ b/libcxx/include/support/win32/limits_win32.h @@ -15,6 +15,11 @@ #error "This header is MSVC specific, Clang and GCC should not include it" #else +#ifndef NOMINMAX +#define NOMINMAX +#endif +#include <windows.h> // ymath.h works correctly + #include <float.h> // limit constants #define __FLT_MANT_DIG__ FLT_MANT_DIG @@ -57,16 +62,17 @@ #define __LDBL_DENORM_MIN__ 3.64519953188247460253e-4951L // __builtin replacements/workarounds +#include <math.h> // HUGE_VAL #include <ymath.h> // internal MSVC header providing the needed functionality -#define __builtin_huge_val() HUGE_VAL -#define __builtin_huge_valf() _FInf -#define __builtin_huge_vall() _LInf -#define __builtin_nan() _Nan -#define __builtin_nanf() _FNan -#define __builtin_nanl() _LNan -#define __builtin_nans() _Snan -#define __builtin_nansf() _FSnan -#define __builtin_nansl() _LSnan +#define __builtin_huge_val() HUGE_VAL +#define __builtin_huge_valf() _FInf._Float +#define __builtin_huge_vall() _LInf._Long_double +#define __builtin_nan(__dummy) _Nan._Double +#define __builtin_nanf(__dummy) _FNan._Float +#define __builtin_nanl(__dummmy) _LNan._Long_double +#define __builtin_nans(__dummy) _Snan._Double +#define __builtin_nansf(__dummy) _FSnan._Float +#define __builtin_nansl(__dummy) _LSnan._Long_double #endif // _MSC_VER diff --git a/libcxx/include/support/win32/support.h b/libcxx/include/support/win32/support.h index 8ce947a16a3..dcc45fc3956 100644 --- a/libcxx/include/support/win32/support.h +++ b/libcxx/include/support/win32/support.h @@ -15,17 +15,81 @@ Functions and constants used in libc++ that are missing from the Windows C library. */ +#include <__config> #include <wchar.h> // mbstate_t #include <stdio.h> // _snwprintf #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 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); -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 ); +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 +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' ); } +#include <xlocinfo.h> +#define atoll _atoi64 +#define strtoll _strtoi64 +#define strtoull _strtoui64 +#define wcstoll _wcstoi64 +#define wcstoull _wcstoui64 +_LIBCPP_ALWAYS_INLINE float strtof( const char *nptr, char **endptr ) +{ return _Stof(nptr, endptr, 0); } +_LIBCPP_ALWAYS_INLINE double strtod( const char *nptr, char **endptr ) +{ return _Stod(nptr, endptr, 0); } +_LIBCPP_ALWAYS_INLINE long double strtold( const char *nptr, char **endptr ) +{ return _Stold(nptr, endptr, 0); } +_LIBCPP_ALWAYS_INLINE float wcstof( const wchar_t *nptr, char** endptr ) + +#define _Exit _exit + +#include <intrin.h> +#define __builtin_popcount __popcnt +#define __builtin_popcountl __popcnt +#define __builtin_popcountll(__i) static_cast<int>(__popcnt64(__i)) + +_LIBCPP_ALWAYS_INLINE int __builtin_ctz( unsigned int x ) +{ + DWORD r = 0; + _BitScanReverse(&r, x); + return static_cast<int>(r); +} +// sizeof(long) == sizeof(int) on Windows +_LIBCPP_ALWAYS_INLINE int __builtin_ctzl( unsigned long x ) +{ return __builtin_ctz( static_cast<int>(x) ); } +_LIBCPP_ALWAYS_INLINE int __builtin_ctzll( unsigned long long x ) +{ + DWORD r = 0; + _BitScanReverse64(&r, x); + return static_cast<int>(r); +} +_LIBCPP_ALWAYS_INLINE int __builtin_clz( unsigned int x ) +{ + DWORD r = 0; + _BitScanForward(&r, x); + return static_cast<int>(r); +} +// sizeof(long) == sizeof(int) on Windows +_LIBCPP_ALWAYS_INLINE int __builtin_clzl( unsigned long x ) +{ return __builtin_clz( static_cast<int>(x) ); } +_LIBCPP_ALWAYS_INLINE int __builtin_clzll( unsigned long long x ) +{ + DWORD r = 0; + _BitScanForward64(&r, x); + return static_cast<int>(r); +} + +#endif #endif // _LIBCPP_SUPPORT_WIN32_SUPPORT_H
\ No newline at end of file |