You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@stdcxx.apache.org by Travis Vitek <tv...@roguewave.com> on 2007/10/18 02:34:54 UTC
[PATCH] __rw_dbl_infinity ABI change with MSVC
This patch attempts to fix the binary incompatibility of
__rw_dbl_infinity when compiled with MSVC on Windows, introduced while
fixing STDCXX-509 (MSVC mangles the access specifier into the names of
class members):
https://issues.apache.org/jira/browse/STDCXX-509
As with Martin's patch, I've opted to just enable the workaround when
_MSC_VER is defined.
Travis
Index: include/limits
===================================================================
--- include/limits (revision 585687)
+++ include/limits (working copy)
@@ -88,7 +88,9 @@
_RWSTD_NAMESPACE (__rw) {
+#ifndef _MSC_VER
extern "C" {
+#endif // _MSC_VER
_RWSTD_EXPORT extern const float __rw_flt_infinity;
_RWSTD_EXPORT extern const double __rw_dbl_infinity;
@@ -111,7 +113,9 @@
#endif // _RWSTD_NO_LONG_DOUBLE
+#ifndef _MSC_VER
} // extern "C"
+#endif // _MSC_VER
} // namespace __rw
Index: src/limits_bits.cpp
===================================================================
--- src/limits_bits.cpp (revision 585687)
+++ src/limits_bits.cpp (working copy)
@@ -69,43 +69,50 @@
# endif // _RWSTD_NO_LONG_DOUBLE
+#ifndef _MSC_VER
extern "C" {
+#endif // _MSC_VER
// The constants below are declared in <limits> but with a different
// type. C linkage is used to defeat MSVC and other "clever" compilers
// that mangle the type of objects into their names.
+#ifdef _MSC_VER
+# define _RWSTD_BITS_NAME(b) _RWSTD_PASTE(b,_bits)
+#else
+# define _RWSTD_BITS_NAME(b) b
+#endif // _MSC_VER
+
// infinity computed at config time
_RWSTD_EXPORT extern const _DblBits
-__rw_dbl_infinity = { _RWSTD_DBL_INF_BITS };
+_RWSTD_BITS_NAME(__rw_dbl_infinity) = { _RWSTD_DBL_INF_BITS };
_RWSTD_EXPORT extern const _FltBits
-__rw_flt_infinity = { _RWSTD_FLT_INF_BITS };
+_RWSTD_BITS_NAME(__rw_flt_infinity) = { _RWSTD_FLT_INF_BITS };
# ifndef _RWSTD_NO_LONG_DOUBLE
_RWSTD_EXPORT extern const _LDblBits
-__rw_ldbl_infinity = { _RWSTD_LDBL_INF_BITS };
+_RWSTD_BITS_NAME(__rw_ldbl_infinity) = { _RWSTD_LDBL_INF_BITS };
-
# endif // _RWSTD_NO_LONG_DOUBLE
// quiet NaN computed at config time
_RWSTD_EXPORT extern const _DblBits
-__rw_dbl_qNaN = { _RWSTD_DBL_QNAN_BITS };
+_RWSTD_BITS_NAME(__rw_dbl_qNaN) = { _RWSTD_DBL_QNAN_BITS };
_RWSTD_EXPORT extern const _FltBits
-__rw_flt_qNaN = { _RWSTD_FLT_QNAN_BITS };
+_RWSTD_BITS_NAME(__rw_flt_qNaN) = { _RWSTD_FLT_QNAN_BITS };
# ifndef _RWSTD_NO_LONG_DOUBLE
_RWSTD_EXPORT extern const _LDblBits
-__rw_ldbl_qNaN = { _RWSTD_LDBL_QNAN_BITS };
+_RWSTD_BITS_NAME(__rw_ldbl_qNaN) = { _RWSTD_LDBL_QNAN_BITS };
# endif // _RWSTD_NO_LONG_DOUBLE
@@ -113,17 +120,17 @@
// signaling NaN computed at config time
_RWSTD_EXPORT extern const _DblBits
-__rw_dbl_sNaN = { _RWSTD_DBL_SNAN_BITS };
+_RWSTD_BITS_NAME(__rw_dbl_sNaN) = { _RWSTD_DBL_SNAN_BITS };
_RWSTD_EXPORT extern const _FltBits
-__rw_flt_sNaN = { _RWSTD_FLT_SNAN_BITS };
+_RWSTD_BITS_NAME(__rw_flt_sNaN) = { _RWSTD_FLT_SNAN_BITS };
# ifndef _RWSTD_NO_LONG_DOUBLE
_RWSTD_EXPORT extern const _LDblBits
-__rw_ldbl_sNaN = { _RWSTD_LDBL_SNAN_BITS };
+_RWSTD_BITS_NAME(__rw_ldbl_sNaN) = { _RWSTD_LDBL_SNAN_BITS };
# endif // _RWSTD_NO_LONG_DOUBLE
@@ -131,22 +138,70 @@
// denormalized minima computed at config time
_RWSTD_EXPORT extern const _DblBits
-__rw_dbl_denorm_min = { _RWSTD_DBL_DENORM_MIN_BITS };
+_RWSTD_BITS_NAME(__rw_dbl_denorm_min) = { _RWSTD_DBL_DENORM_MIN_BITS };
_RWSTD_EXPORT extern const _FltBits
-__rw_flt_denorm_min = { _RWSTD_FLT_DENORM_MIN_BITS };
+_RWSTD_BITS_NAME(__rw_flt_denorm_min) = { _RWSTD_FLT_DENORM_MIN_BITS };
# ifndef _RWSTD_NO_LONG_DOUBLE
_RWSTD_EXPORT extern const _LDblBits
-__rw_ldbl_denorm_min = { _RWSTD_LDBL_DENORM_MIN_BITS };
+_RWSTD_BITS_NAME(__rw_ldbl_denorm_min) = { _RWSTD_LDBL_DENORM_MIN_BITS
};
# endif // _RWSTD_NO_LONG_DOUBLE
+
+#ifdef _MSC_VER
+
+_RWSTD_EXPORT extern const float
+__rw_flt_infinity = _RWSTD_BITS_NAME(__rw_flt_infinity)._C_val;
+
+_RWSTD_EXPORT extern const double
+__rw_dbl_infinity = _RWSTD_BITS_NAME(__rw_dbl_infinity)._C_val;
+
+_RWSTD_EXPORT extern const float
+__rw_flt_qNaN = _RWSTD_BITS_NAME(__rw_flt_qNaN)._C_val;
+
+_RWSTD_EXPORT extern const double
+__rw_dbl_qNaN = _RWSTD_BITS_NAME(__rw_dbl_qNaN)._C_val;
+
+_RWSTD_EXPORT extern const float
+__rw_flt_sNaN = _RWSTD_BITS_NAME(__rw_flt_sNaN)._C_val;
+
+_RWSTD_EXPORT extern const double
+__rw_dbl_sNaN = _RWSTD_BITS_NAME(__rw_dbl_sNaN)._C_val;
+
+_RWSTD_EXPORT extern const float
+__rw_flt_denorm_min = _RWSTD_BITS_NAME(__rw_flt_denorm_min)._C_val;
+
+_RWSTD_EXPORT extern const double
+__rw_dbl_denorm_min = _RWSTD_BITS_NAME(__rw_dbl_denorm_min)._C_val;
+
+
+# ifndef _RWSTD_NO_LONG_DOUBLE
+
+_RWSTD_EXPORT extern const long double
+__rw_ldbl_infinity = _RWSTD_BITS_NAME(__rw_ldbl_infinity)._C_val;
+
+_RWSTD_EXPORT extern const long double
+__rw_ldbl_qNaN = _RWSTD_BITS_NAME(__rw_ldbl_qNaN)._C_val;
+
+_RWSTD_EXPORT extern const long double
+__rw_ldbl_sNaN = _RWSTD_BITS_NAME(__rw_ldbl_sNaN)._C_val;
+
+_RWSTD_EXPORT extern const long double
+__rw_ldbl_denorm_min = _RWSTD_BITS_NAME(__rw_ldbl_denorm_min)._C_val;
+
+# endif // _RWSTD_NO_LONG_DOUBLE
+
+#endif // _MSC_VER
+
+#ifndef _MSC_VER
} // extern "C"
+#endif // _MSC_VER
#else // if defined (_RWSTD_NO_INFINITY)
Index: src/num_get.cpp
===================================================================
--- src/num_get.cpp (revision 585687)
+++ src/num_get.cpp (working copy)
@@ -83,8 +83,9 @@
typedef unsigned char UChar;
-
+#ifndef _MSC_VER
extern "C" {
+#endif // _MSC_VER
extern const float __rw_flt_infinity;
extern const double __rw_dbl_infinity;
@@ -95,7 +96,9 @@
#endif // _RWSTD_NO_LONG_DOUBLE
+#ifndef _MSC_VER
} // extern "C"
+#endif // _MSC_VER
const char*
RE: [PATCH] __rw_dbl_infinity ABI change with MSVC
Posted by Travis Vitek <tv...@roguewave.com>.
Farid Zaripov wrote:
>
>> -----Original Message-----
>> From: Martin Sebor [mailto:sebor@roguewave.com]
>> Sent: Thursday, October 18, 2007 5:43 PM
>> To: stdcxx-dev@incubator.apache.org
>> Subject: Re: [PATCH] __rw_dbl_infinity ABI change with MSVC
>>
>> Thanks!
>>
>> Farid, does this patch look okay to you?
>
> The patch looks good, but I can't apply it to the HEAD
>revision of the
>4.2.0 branch.
>Seem that patch created with previous revision.
>
>Farid.
>
Sorry, the patch was built off of 4.2.0-rc-5. The new patch is based on
stdcxx-trunk
Re: [PATCH] __rw_dbl_infinity ABI change with MSVC
Posted by Martin Sebor <se...@roguewave.com>.
Travis, while testing your updated patch, I wonder if it would be
possible to quickly and easily fix STDCXX-509 even for MSVC in
a binary compatible way by using #pragma init_seg to initialize
the constants before any user-defined objects?
http://msdn2.microsoft.com/en-us/library/7977wcck(VS.71).aspx
http://msdn2.microsoft.com/en-us/library/7977wcck(VS.80).aspx
Martin
Farid Zaripov wrote:
>> -----Original Message-----
>> From: Martin Sebor [mailto:sebor@roguewave.com]
>> Sent: Thursday, October 18, 2007 5:43 PM
>> To: stdcxx-dev@incubator.apache.org
>> Subject: Re: [PATCH] __rw_dbl_infinity ABI change with MSVC
>>
>> Thanks!
>>
>> Farid, does this patch look okay to you?
>
> The patch looks good, but I can't apply it to the HEAD revision of the
> 4.2.0 branch.
> Seem that patch created with previous revision.
>
> Farid.
RE: [PATCH] __rw_dbl_infinity ABI change with MSVC
Posted by Farid Zaripov <Fa...@epam.com>.
> -----Original Message-----
> From: Martin Sebor [mailto:sebor@roguewave.com]
> Sent: Thursday, October 18, 2007 5:43 PM
> To: stdcxx-dev@incubator.apache.org
> Subject: Re: [PATCH] __rw_dbl_infinity ABI change with MSVC
>
> Thanks!
>
> Farid, does this patch look okay to you?
The patch looks good, but I can't apply it to the HEAD revision of the
4.2.0 branch.
Seem that patch created with previous revision.
Farid.
Re: [PATCH] __rw_dbl_infinity ABI change with MSVC
Posted by Martin Sebor <se...@roguewave.com>.
Thanks!
Farid, does this patch look okay to you?
Travis, please double-check the patch for missing whitespace
and post a ChangeLog entry. Unless there are objections from
Farid or anyone else, I'll go ahead and commit it as soon as
I get it.
Martin
Travis Vitek wrote:
> This patch attempts to fix the binary incompatibility of
> __rw_dbl_infinity when compiled with MSVC on Windows, introduced while
> fixing STDCXX-509 (MSVC mangles the access specifier into the names of
> class members):
>
> https://issues.apache.org/jira/browse/STDCXX-509
>
> As with Martin's patch, I've opted to just enable the workaround when
> _MSC_VER is defined.
>
> Travis
>
>
>
>
> Index: include/limits
> ===================================================================
> --- include/limits (revision 585687)
> +++ include/limits (working copy)
> @@ -88,7 +88,9 @@
>
> _RWSTD_NAMESPACE (__rw) {
>
> +#ifndef _MSC_VER
> extern "C" {
> +#endif // _MSC_VER
>
> _RWSTD_EXPORT extern const float __rw_flt_infinity;
> _RWSTD_EXPORT extern const double __rw_dbl_infinity;
> @@ -111,7 +113,9 @@
>
> #endif // _RWSTD_NO_LONG_DOUBLE
>
> +#ifndef _MSC_VER
> } // extern "C"
> +#endif // _MSC_VER
>
> } // namespace __rw
>
> Index: src/limits_bits.cpp
> ===================================================================
> --- src/limits_bits.cpp (revision 585687)
> +++ src/limits_bits.cpp (working copy)
> @@ -69,43 +69,50 @@
>
> # endif // _RWSTD_NO_LONG_DOUBLE
>
> +#ifndef _MSC_VER
> extern "C" {
> +#endif // _MSC_VER
>
> // The constants below are declared in <limits> but with a different
> // type. C linkage is used to defeat MSVC and other "clever" compilers
> // that mangle the type of objects into their names.
>
> +#ifdef _MSC_VER
> +# define _RWSTD_BITS_NAME(b) _RWSTD_PASTE(b,_bits)
> +#else
> +# define _RWSTD_BITS_NAME(b) b
> +#endif // _MSC_VER
> +
> // infinity computed at config time
> _RWSTD_EXPORT extern const _DblBits
> -__rw_dbl_infinity = { _RWSTD_DBL_INF_BITS };
> +_RWSTD_BITS_NAME(__rw_dbl_infinity) = { _RWSTD_DBL_INF_BITS };
>
>
> _RWSTD_EXPORT extern const _FltBits
> -__rw_flt_infinity = { _RWSTD_FLT_INF_BITS };
> +_RWSTD_BITS_NAME(__rw_flt_infinity) = { _RWSTD_FLT_INF_BITS };
>
>
> # ifndef _RWSTD_NO_LONG_DOUBLE
>
> _RWSTD_EXPORT extern const _LDblBits
> -__rw_ldbl_infinity = { _RWSTD_LDBL_INF_BITS };
> +_RWSTD_BITS_NAME(__rw_ldbl_infinity) = { _RWSTD_LDBL_INF_BITS };
>
> -
> # endif // _RWSTD_NO_LONG_DOUBLE
>
>
> // quiet NaN computed at config time
> _RWSTD_EXPORT extern const _DblBits
> -__rw_dbl_qNaN = { _RWSTD_DBL_QNAN_BITS };
> +_RWSTD_BITS_NAME(__rw_dbl_qNaN) = { _RWSTD_DBL_QNAN_BITS };
>
>
> _RWSTD_EXPORT extern const _FltBits
> -__rw_flt_qNaN = { _RWSTD_FLT_QNAN_BITS };
> +_RWSTD_BITS_NAME(__rw_flt_qNaN) = { _RWSTD_FLT_QNAN_BITS };
>
>
> # ifndef _RWSTD_NO_LONG_DOUBLE
>
> _RWSTD_EXPORT extern const _LDblBits
> -__rw_ldbl_qNaN = { _RWSTD_LDBL_QNAN_BITS };
> +_RWSTD_BITS_NAME(__rw_ldbl_qNaN) = { _RWSTD_LDBL_QNAN_BITS };
>
>
> # endif // _RWSTD_NO_LONG_DOUBLE
> @@ -113,17 +120,17 @@
>
> // signaling NaN computed at config time
> _RWSTD_EXPORT extern const _DblBits
> -__rw_dbl_sNaN = { _RWSTD_DBL_SNAN_BITS };
> +_RWSTD_BITS_NAME(__rw_dbl_sNaN) = { _RWSTD_DBL_SNAN_BITS };
>
>
> _RWSTD_EXPORT extern const _FltBits
> -__rw_flt_sNaN = { _RWSTD_FLT_SNAN_BITS };
> +_RWSTD_BITS_NAME(__rw_flt_sNaN) = { _RWSTD_FLT_SNAN_BITS };
>
>
> # ifndef _RWSTD_NO_LONG_DOUBLE
>
> _RWSTD_EXPORT extern const _LDblBits
> -__rw_ldbl_sNaN = { _RWSTD_LDBL_SNAN_BITS };
> +_RWSTD_BITS_NAME(__rw_ldbl_sNaN) = { _RWSTD_LDBL_SNAN_BITS };
>
>
> # endif // _RWSTD_NO_LONG_DOUBLE
> @@ -131,22 +138,70 @@
>
> // denormalized minima computed at config time
> _RWSTD_EXPORT extern const _DblBits
> -__rw_dbl_denorm_min = { _RWSTD_DBL_DENORM_MIN_BITS };
> +_RWSTD_BITS_NAME(__rw_dbl_denorm_min) = { _RWSTD_DBL_DENORM_MIN_BITS };
>
>
> _RWSTD_EXPORT extern const _FltBits
> -__rw_flt_denorm_min = { _RWSTD_FLT_DENORM_MIN_BITS };
> +_RWSTD_BITS_NAME(__rw_flt_denorm_min) = { _RWSTD_FLT_DENORM_MIN_BITS };
>
>
> # ifndef _RWSTD_NO_LONG_DOUBLE
>
> _RWSTD_EXPORT extern const _LDblBits
> -__rw_ldbl_denorm_min = { _RWSTD_LDBL_DENORM_MIN_BITS };
> +_RWSTD_BITS_NAME(__rw_ldbl_denorm_min) = { _RWSTD_LDBL_DENORM_MIN_BITS
> };
>
>
> # endif // _RWSTD_NO_LONG_DOUBLE
>
> +
> +#ifdef _MSC_VER
> +
> +_RWSTD_EXPORT extern const float
> +__rw_flt_infinity = _RWSTD_BITS_NAME(__rw_flt_infinity)._C_val;
> +
> +_RWSTD_EXPORT extern const double
> +__rw_dbl_infinity = _RWSTD_BITS_NAME(__rw_dbl_infinity)._C_val;
> +
> +_RWSTD_EXPORT extern const float
> +__rw_flt_qNaN = _RWSTD_BITS_NAME(__rw_flt_qNaN)._C_val;
> +
> +_RWSTD_EXPORT extern const double
> +__rw_dbl_qNaN = _RWSTD_BITS_NAME(__rw_dbl_qNaN)._C_val;
> +
> +_RWSTD_EXPORT extern const float
> +__rw_flt_sNaN = _RWSTD_BITS_NAME(__rw_flt_sNaN)._C_val;
> +
> +_RWSTD_EXPORT extern const double
> +__rw_dbl_sNaN = _RWSTD_BITS_NAME(__rw_dbl_sNaN)._C_val;
> +
> +_RWSTD_EXPORT extern const float
> +__rw_flt_denorm_min = _RWSTD_BITS_NAME(__rw_flt_denorm_min)._C_val;
> +
> +_RWSTD_EXPORT extern const double
> +__rw_dbl_denorm_min = _RWSTD_BITS_NAME(__rw_dbl_denorm_min)._C_val;
> +
> +
> +# ifndef _RWSTD_NO_LONG_DOUBLE
> +
> +_RWSTD_EXPORT extern const long double
> +__rw_ldbl_infinity = _RWSTD_BITS_NAME(__rw_ldbl_infinity)._C_val;
> +
> +_RWSTD_EXPORT extern const long double
> +__rw_ldbl_qNaN = _RWSTD_BITS_NAME(__rw_ldbl_qNaN)._C_val;
> +
> +_RWSTD_EXPORT extern const long double
> +__rw_ldbl_sNaN = _RWSTD_BITS_NAME(__rw_ldbl_sNaN)._C_val;
> +
> +_RWSTD_EXPORT extern const long double
> +__rw_ldbl_denorm_min = _RWSTD_BITS_NAME(__rw_ldbl_denorm_min)._C_val;
> +
> +# endif // _RWSTD_NO_LONG_DOUBLE
> +
> +#endif // _MSC_VER
> +
> +#ifndef _MSC_VER
> } // extern "C"
> +#endif // _MSC_VER
>
> #else // if defined (_RWSTD_NO_INFINITY)
>
> Index: src/num_get.cpp
> ===================================================================
> --- src/num_get.cpp (revision 585687)
> +++ src/num_get.cpp (working copy)
> @@ -83,8 +83,9 @@
>
> typedef unsigned char UChar;
>
> -
> +#ifndef _MSC_VER
> extern "C" {
> +#endif // _MSC_VER
>
> extern const float __rw_flt_infinity;
> extern const double __rw_dbl_infinity;
> @@ -95,7 +96,9 @@
>
> #endif // _RWSTD_NO_LONG_DOUBLE
>
> +#ifndef _MSC_VER
> } // extern "C"
> +#endif // _MSC_VER
>
>
> const char*