From 21762bb4a1bd0c88c38eead03f59e8d994349e83 Mon Sep 17 00:00:00 2001 From: Earnie Boyd Date: Tue, 16 Oct 2012 10:13:14 -0400 Subject: [PATCH] Correct value of _WIN32_WINNT. * include/sdkddkver.h (WINNTVER): New macro. (_WIN32_WINNT): Correct default value based on NTDDI_VERSION. * include/stdio.h (_get_output_format): Base declaration or define on VISTA. (_set_output_format): Ditto. (_get_printf_count_output): Ditto. (_set_printf_count_output): Ditto. * misc/src/libcrt/stdio/pformat.c: Remove needless code since we only care about Windows. --- ChangeLog | 12 ++++++ include/sdkddkver.h | 3 +- include/stdio.h | 13 ++++-- misc/src/libcrt/stdio/pformat.c | 93 ----------------------------------------- 4 files changed, 24 insertions(+), 97 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0a33c38..6185af9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2012-10-16 Earnie Boyd + + * include/sdkddkver.h (WINNTVER): New macro. + (_WIN32_WINNT): Correct default value based on NTDDI_VERSION. + * include/stdio.h (_get_output_format): Base declaration or define on + VISTA. + (_set_output_format): Ditto. + (_get_printf_count_output): Ditto. + (_set_printf_count_output): Ditto. + * misc/src/libcrt/stdio/pformat.c: Remove needless code since we only + care about Windows. + 2012-10-08 Earnie Boyd * Makefile.in (dist-mingwrt-src, dist-mingw32-src, dist-wsl-src): diff --git a/include/sdkddkver.h b/include/sdkddkver.h index 8323eeb..a9d2fd1 100644 --- a/include/sdkddkver.h +++ b/include/sdkddkver.h @@ -44,6 +44,7 @@ #define OSVER(ver) ((ver) & OSVERSION_MASK) #define SPVER(ver) (((ver) & SPVERSION_MASK) >> 8) #define SUBVER(ver) ((ver) & SUBVERSION_MASK) +#define WINNTVER(ver) ((ver) / 0x00010000) /** * Macros to create the minimal NTDDI version from _WIN32_WINNT value. @@ -135,7 +136,7 @@ # error The _WIN32_WINNT value does not match NTDDI_VERSION # endif # else -# define _WIN32_WINNT OSVER(NTDDI_VERSION) +# define _WIN32_WINNT WINNTVER(NTDDI_VERSION) # ifndef WINVER # define WINVER _WIN32_WINNT # endif diff --git a/include/stdio.h b/include/stdio.h index fd830fa..bb186d7 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -489,14 +489,21 @@ _CRTIMP FILE* __cdecl __MINGW_NOTHROW _fsopen (const char*, const char*, int); _CRTIMP int __cdecl __MINGW_NOTHROW _getmaxstdio (void); _CRTIMP int __cdecl __MINGW_NOTHROW _setmaxstdio (int); +#if (_WIN32_WINNT >= _WIN32_WINNT_VISTA) || defined(HAVE_GET_OUTPUT_FORMAT) _CRTIMP unsigned int __cdecl __MINGW_NOTHROW _get_output_format (void); _CRTIMP unsigned int __cdecl __MINGW_NOTHROW _set_output_format (unsigned int); - -#define _TWO_DIGIT_EXPONENT 1 - _CRTIMP int __cdecl __MINGW_NOTHROW _get_printf_count_output (void); _CRTIMP int __cdecl __MINGW_NOTHROW _set_printf_count_output (int); +#else +#define _get_output_format() 0 +#define _set_output_format(x) 0 +#define _get_printf_count_output() 0 +#define _set_printf_count_output(x) 0 +#endif /* (_WIN32_WINNT >= _WIN32_WINNT_VISTA) || defined(HAVE_GET_OUTPUT_FORMAT) */ + +#define _TWO_DIGIT_EXPONENT 1 + #ifndef _NO_OLDNAMES _CRTIMP int __cdecl __MINGW_NOTHROW fgetchar (void); _CRTIMP int __cdecl __MINGW_NOTHROW fputchar (int); diff --git a/misc/src/libcrt/stdio/pformat.c b/misc/src/libcrt/stdio/pformat.c index cc63800..f351807 100644 --- a/misc/src/libcrt/stdio/pformat.c +++ b/misc/src/libcrt/stdio/pformat.c @@ -2,7 +2,6 @@ * prepared to support the POSIX-XSI additions to the C99 standard. */ #undef WITH_XSI_FEATURES -#define __MSVCRT_VERSION__ 0x0800 /* pformat.c * @@ -141,7 +140,6 @@ */ #define PFORMAT_INFNAN -32768 -#ifdef _WIN32 /* * The Microsoft standard for printing `%e' format exponents is * with a minimum of three digits, unless explicitly set otherwise, @@ -150,22 +148,6 @@ * The following macro allows us to replicate this behaviour. */ # define PFORMAT_MINEXP __pformat_exponent_digits() - /* - * However, this feature is unsupported for versions of the - * MSVC runtime library prior to msvcr80.dll, and by default, - * MinGW uses an earlier version, (equivalent to msvcr60.dll), - * for which `_TWO_DIGIT_EXPONENT' will be undefined. - */ -# ifndef _TWO_DIGIT_EXPONENT - /* - * This hack works around the lack of the `_set_output_format()' - * feature, when supporting versions of the MSVC runtime library - * prior to msvcr80.dll; it simply enforces Microsoft's original - * convention, for all cases where the feature is unsupported. - */ -# define _get_output_format() 0 -# define _TWO_DIGIT_EXPONENT 1 -# endif /* * Irrespective of the MSVCRT version supported, *we* will add * an additional capability, through the following inline function, @@ -183,13 +165,6 @@ int __pformat_exponent_digits( void ) : 3 ; } -#else -/* - * When we don't care to mimic Microsoft's standard behaviour, - * we adopt the C99/POSIX standard of two digit exponents. - */ -# define PFORMAT_MINEXP 2 -#endif typedef union { @@ -722,10 +697,6 @@ typedef union unsigned long __pformat_fpreg_bits; } __pformat_fpreg_t; -#ifdef _WIN32 -/* TODO: make this unconditional in final release... - * (see note at head of associated `#else' block. - */ #include "gdtoa.h" static @@ -807,61 +778,6 @@ char *__pformat_fcvt( long double x, int precision, int *dp, int *sign ) #define __pformat_ecvt_release( value ) __freedtoa( value ) #define __pformat_fcvt_release( value ) __freedtoa( value ) -#else -/* - * TODO: remove this before final release; it is included here as a - * convenience for testing, without requiring a working `__gdtoa()'. - */ -static __inline__ -char *__pformat_ecvt( long double x, int precision, int *dp, int *sign ) -{ - /* Define in terms of `ecvt()'... - */ - char *retval = ecvt( (double)(x), precision, dp, sign ); - if( isinf( x ) || isnan( x ) ) - { - /* emulating `__gdtoa()' reporting for infinities and NaN. - */ - *dp = PFORMAT_INFNAN; - if( *retval == '-' ) - { - /* Need to force the `sign' flag, (particularly for NaN). - */ - ++retval; *sign = 1; - } - } - return retval; -} - -static __inline__ -char *__pformat_fcvt( long double x, int precision, int *dp, int *sign ) -{ - /* Define in terms of `fcvt()'... - */ - char *retval = fcvt( (double)(x), precision, dp, sign ); - if( isinf( x ) || isnan( x ) ) - { - /* emulating `__gdtoa()' reporting for infinities and NaN. - */ - *dp = PFORMAT_INFNAN; - if( *retval == '-' ) - { - /* Need to force the `sign' flag, (particularly for NaN). - */ - ++retval; *sign = 1; - } - } - return retval; -} - -/* No memory pool clean up needed, for these emulated cases... - */ -#define __pformat_ecvt_release( value ) /* nothing to be done */ -#define __pformat_fcvt_release( value ) /* nothing to be done */ - -/* TODO: end of conditional to be removed. */ -#endif - static __inline__ void __pformat_emit_radix_point( __pformat_t *stream ) { @@ -2175,8 +2091,6 @@ int __pformat( int flags, void *dest, int max, const char *fmt, va_list argv ) state = PFORMAT_END; break; -# ifdef _WIN32 - case 'I': /* * The MSVCRT implementation of the printf() family of @@ -2210,8 +2124,6 @@ int __pformat( int flags, void *dest, int max, const char *fmt, va_list argv ) state = PFORMAT_END; break; -# endif - case 'l': /* * Interpret the argument as explicitly of a @@ -2231,7 +2143,6 @@ int __pformat( int flags, void *dest, int max, const char *fmt, va_list argv ) */ length = PFORMAT_LENGTH_LONG; -# ifndef _WIN32 /* * Microsoft's MSVCRT implementation also uses `l' * as a modifier for `long double'; if we don't want @@ -2240,10 +2151,6 @@ int __pformat( int flags, void *dest, int max, const char *fmt, va_list argv ) state = PFORMAT_END; break; - /* otherwise, we simply fall through... - */ -# endif - case 'L': /* * Identify the appropriate argument as a `long double', -- 2.11.0