This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [libstdc++ patch] Check for __builtins in std_cmath.h



Hi Gaby,
> | This patch was originally developed as a possible solution to the
> | high priority PR libstdc++/3184.  Just my luck, PR 3184 was closed
> | earlier today whilst this patch was being regression tested.  It
> | does however protect against using __builtin functions on targets
> | that don't support them.
>
> I think we already discussed that matter in the past.  If a target
> does not support a __builtin_xxx, then it falls back to a library xxx
> definition. libmath/stubs.c is the right place to put missing xxx
> definitions.

Wow!  I hadn't appreciated that libstc++-v3 provided its own stub
implementations for missing libm functions.  I agree this is a much
better place to fix the problem.  It allows the builtin implementations
to be used even when a linkage is not provided by the system.

The hopefully obvious patch below fixes the cosf and sinf cases in
libstdc++-v3/libmath/stubs.c to reflect that strategy.  This approach
also allows significant simplification in c_shadow/bits/std_cmath.h
where we can/should always call the __builtin function, this matches
how things are done in c_std/bits/std_cmath.h.  Alas this independent
(and possibly controversial?) change is not so trivial so I'll run a
bootstrap (together with this patch) before submitting it.

Gaby, is this what you had in mind?

Roger
--

2001-12-29  Roger Sayle <roger@eyesopen.com>
	* libmath/stubs.c (sinf,cosf): Implement stubs to enable the
	equivalent __builtin_ versions.


*** gcc/libstdc++-v3/libmath/stubs.c	Tue Aug 14 00:50:58 2001
--- patch2/libstdc++-v3/libmath/stubs.c	Sat Dec 29 08:43:10 2001
*************** atan2l(long double x, long double y)
*** 51,57 ****
  #endif


! #if !defined(HAVE_COSF) && !defined(HAVE___BUILTIN_COSF)
  float
  cosf(float x)
  {
--- 51,57 ----
  #endif


! #ifndef HAVE_COSF
  float
  cosf(float x)
  {
*************** powl(long double x, long double y)
*** 186,192 ****
  #endif


! #if !defined(HAVE_SINF) && !defined(HAVE___BUILTIN_SINF)
  float
  sinf(float x)
  {
--- 186,192 ----
  #endif


! #ifndef HAVE_SINF
  float
  sinf(float x)
  {

--
Roger Sayle,                         E-mail: roger@eyesopen.com
OpenEye Scientific Software,         WWW: http://www.eyesopen.com/
Suite 1107, 3600 Cerrillos Road,     Tel: (+1) 505-473-7385
Santa Fe, New Mexico, 87507.         Fax: (+1) 505-438-3470


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]