PATCH: Apply Nathan's macro trick
Loren James Rittle
rittle@latour.rsch.comm.mot.com
Thu Apr 17 10:03:00 GMT 2003
This is the final form of <cmath> for the time being (related to
dynamic visible) and the binding form I will use in <cstdio>,
<cstdlib>, <cwchar>. I thought a few moments about actually combining
both macro-enabled paths in __c99_binding together, ala:
_GLIBCXX_C99_BIND (_GLIBCPP_HAVE_ACOSF, acosf, float (acosf)(float));
But I couldn't convince myself the extra complexity was worth it. I
also fixed an oversight with dynamic C99 FP macro capture (related to
the dynamic wrapper I added, not the original code). If someone says
not to capture, then we shouldn't touch the C99 FP macro names. Also,
this might allow for a practical workaround to getting old code to
compile without having to edit the user's source. No regressions
(hand-checked -E output with various hand-setup cases). I will commit
next time I have access.
* include/c_std/std_cmath.h (__gnu_cxx::__c99_binding): Rework
to use Nathan's macro trick.
(C99 FP capture): Only undefine, if captured.
Index: libstdc++-v3/include/c_std/std_cmath.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/c_std/std_cmath.h,v
retrieving revision 1.7
diff -c -r1.7 std_cmath.h
*** libstdc++-v3/include/c_std/std_cmath.h 15 Apr 2003 07:27:54 -0000 1.7
--- libstdc++-v3/include/c_std/std_cmath.h 17 Apr 2003 09:33:08 -0000
***************
*** 76,81 ****
--- 76,86 ----
#undef tan
#undef tanh
+ #define _GLIBCXX_C99_USING_0(__b, __c) __c
+ #define _GLIBCXX_C99_USING_1(__b, __c) __b
+ #define _GLIBCXX_C99_USING(__a,__b,__c) _GLIBCXX_C99_USING_ ## __a(__b, __c)
+ #define _GLIBCXX_C99_BIND(__a,__b) _GLIBCXX_C99_USING(__a, using ::__b;, )
+
// ...and in the darkness bind them...
namespace __gnu_cxx
{
***************
*** 103,162 ****
extern "C" float (tanhf)(float);
#endif
#if !_GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC
! #if _GLIBCPP_HAVE_ACOSF
! using ::acosf;
! #endif
! #if _GLIBCPP_HAVE_ASINF
! using ::asinf;
! #endif
! #if _GLIBCPP_HAVE_ATANF
! using ::atanf;
! #endif
! #if _GLIBCPP_HAVE_ATAN2F
! using ::atan2f;
! #endif
! #if _GLIBCPP_HAVE_CEILF
! using ::ceilf;
! #endif
! #if _GLIBCPP_HAVE_COSHF
! using ::coshf;
! #endif
! #if _GLIBCPP_HAVE_EXPF
! using ::expf;
! #endif
! #if _GLIBCPP_HAVE_FLOORF
! using ::floorf;
! #endif
! #if _GLIBCPP_HAVE_FMODF
! using ::fmodf;
! #endif
! #if _GLIBCPP_HAVE_FREXPF
! using ::frexpf;
! #endif
! #if _GLIBCPP_HAVE_LDEXPF
! using ::ldexpf;
! #endif
! #if _GLIBCPP_HAVE_LOGF
! using ::logf;
! #endif
! #if _GLIBCPP_HAVE_LOG10F
! using ::log10f;
! #endif
! #if _GLIBCPP_HAVE_MODFF
! using ::modff;
! #endif
! #if _GLIBCPP_HAVE_POWF
! using ::powf;
! #endif
! #if _GLIBCPP_HAVE_SINHF
! using ::sinhf;
! #endif
! #if _GLIBCPP_HAVE_TANF
! using ::tanf;
! #endif
! #if _GLIBCPP_HAVE_TANHF
! using ::tanhf;
! #endif
#endif /* _GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC */
}
}
--- 108,131 ----
extern "C" float (tanhf)(float);
#endif
#if !_GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC
! _GLIBCXX_C99_BIND (_GLIBCPP_HAVE_ACOSF, acosf)
! _GLIBCXX_C99_BIND (_GLIBCPP_HAVE_ASINF, asinf)
! _GLIBCXX_C99_BIND (_GLIBCPP_HAVE_ATANF, atanf)
! _GLIBCXX_C99_BIND (_GLIBCPP_HAVE_ATAN2F, atan2f)
! _GLIBCXX_C99_BIND (_GLIBCPP_HAVE_CEILF, ceilf)
! _GLIBCXX_C99_BIND (_GLIBCPP_HAVE_COSHF, coshf)
! _GLIBCXX_C99_BIND (_GLIBCPP_HAVE_EXPF, expf)
! _GLIBCXX_C99_BIND (_GLIBCPP_HAVE_FLOORF, floorf)
! _GLIBCXX_C99_BIND (_GLIBCPP_HAVE_FMODF, fmodf)
! _GLIBCXX_C99_BIND (_GLIBCPP_HAVE_FREXPF, frexpf)
! _GLIBCXX_C99_BIND (_GLIBCPP_HAVE_LDEXPF, ldexpf)
! _GLIBCXX_C99_BIND (_GLIBCPP_HAVE_LOGF, logf)
! _GLIBCXX_C99_BIND (_GLIBCPP_HAVE_LOG10F, log10f)
! _GLIBCXX_C99_BIND (_GLIBCPP_HAVE_MODFF, modff)
! _GLIBCXX_C99_BIND (_GLIBCPP_HAVE_POWF, powf)
! _GLIBCXX_C99_BIND (_GLIBCPP_HAVE_SINHF, sinhf)
! _GLIBCXX_C99_BIND (_GLIBCPP_HAVE_TANF, tanf)
! _GLIBCXX_C99_BIND (_GLIBCPP_HAVE_TANHF, tanhf)
#endif /* _GLIBCPP_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC */
}
}
***************
*** 646,655 ****
int
__capture_isunordered(_Tp __f1, _Tp __f2)
{ return isunordered(__f1, __f2); }
! }
! #endif /* _GLIBCPP_USE_C99_FP_MACROS_DYNAMIC */
! #endif
#undef fpclassify
#undef isfinite
#undef isinf
--- 615,623 ----
int
__capture_isunordered(_Tp __f1, _Tp __f2)
{ return isunordered(__f1, __f2); }
! }
+ // Only undefine the C99 FP macros, if actually captured for namespace movement
#undef fpclassify
#undef isfinite
#undef isinf
***************
*** 662,667 ****
--- 630,637 ----
#undef islessequal
#undef islessgreater
#undef isunordered
+ #endif /* _GLIBCPP_USE_C99_FP_MACROS_DYNAMIC */
+ #endif
#if _GLIBCPP_USE_C99
#if !_GLIBCPP_USE_C99_FP_MACROS_DYNAMIC
More information about the Libstdc++
mailing list