This is the mail archive of the libstdc++@sourceware.cygnus.com mailing list for the libstdc++ project.


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

Re: Patch for missing sinf, cosf, ...


Steven King wrote:
> While I think the basic thrust here is correct, I dont believe the replacement
> functions are neccessary;  I think it should be sufficient instead to just tweek
> bits/std_cmath.h and shadow/bits/std_cmath.h.
> 
> s/BUILTIN_\([A-Z0-9]\+\)/s//BUILTIN_\1 \&\& _GLIBCPP_HAVE_\1/g
> 
> or perhaps
> 
> s/BUILTIN_\([A-Z0-9]\+\)/s//BUILTIN_\1 \&\& (_GLIBCPP_HAVE_\1 || _GLIBCPP_HAVE__\1)/g
> 
> this would have the advantage of inlining the call to the replacement (and
> would handle all the other *f and *l that are found).

But this would also preclude using any of the builtins if the
library function isn't present. The out-of-line call isn't always
generated. Here's the relevant snippet from gcc/builtins.c:

  if (arglist == 0
      /* Arg could be wrong type if user redeclared this fcn wrong.  */
      || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != REAL_TYPE)
    return 0;

and later:

  /* Compute into TARGET.
     Set TARGET to wherever the result comes back.  */
  target = expand_unop (TYPE_MODE (TREE_TYPE (TREE_VALUE (arglist))),
   builtin_optab, op0, target, 0);

  /* If we were unable to expand via the builtin, stop the
     sequence (without outputting the insns) and return 0, causing
     a call to the library function.  */
  if (target == 0)
    {
      end_sequence ();
      return 0;
    }


And here's a snippet from my bootstrap log:

/home/brane/eval/gcc/build/OBJ/gcc/xgcc -B/home/brane/eval/gcc/build/OBJ/gcc/ -B/home/brane/eval/gcc/inst/sparc-sun-solaris2.6/bin/ -DHAVE_CONFIG_H -I. -I../../../../../gcc/libstdc++-v3/math -I.. -I.. -I/home/brane/eval/gcc/inst/include -g -O2 -c  -fPIC -DPIC ../../../../../gcc/libstdc++-v3/math/ccoshf.c -o .libs/ccoshf.lo
../../../../../gcc/libstdc++-v3/math/ccoshf.c: In function `ccoshf':
../../../../../gcc/libstdc++-v3/math/ccoshf.c:47: warning: type mismatch in implicit declaration for built-in function `sinf'
../../../../../gcc/libstdc++-v3/math/ccoshf.c:48: warning: type mismatch in implicit declaration for built-in function `cosf'


Hmmm... there are 18 such warnings. Now I wonder what would happen if
we managed to get rid of them? Perhaps math/mathconf.h should be fixed,
not {shadow/}bits/std_cmath.h?

    Brane

-- 
Branko Čibej                 <branko.cibej@hermes.si>
HERMES SoftLab, Litijska 51, 1000 Ljubljana, Slovenia
voice: (+386 1) 586 53 49     fax: (+386 1) 586 52 70

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