Topic
1 reply Latest Post - ‏2010-12-14T16:59:49Z by Ulrich.Weigand
PedroGonnet
PedroGonnet
12 Posts
ACCEPTED ANSWER

Pinned topic No fminf when using ppu-gcc

‏2010-12-14T16:03:46Z |
I get warnings of the type

codewarning: implicit declaration of function 'fmaxf'[/code]

when compiling sources with ppu-gcc as the math.h header does not define them. The math.h used by spu-gcc, however, does. Was this function somehow forgotten?

Cheers, Pedro
Updated on 2010-12-14T16:59:49Z at 2010-12-14T16:59:49Z by Ulrich.Weigand
  • Ulrich.Weigand
    Ulrich.Weigand
    35 Posts
    ACCEPTED ANSWER

    Re: No fminf when using ppu-gcc

    ‏2010-12-14T16:59:49Z  in response to PedroGonnet
    Functions fmin(f) and fmax(f) are provided only with C99, they are not yet in older C standards. This is handled somewhat differently by the two C library implementations on PPU and SPU.

    On the PPU side, we have the main system library (glibc), which precisely reflects the C standard currently used to compile. That is, if you the compiler you're using supports C99, fmin(f) and fmax(f) will be available, but if the compiler you're using supports an older C standard, they will not be available.

    Note that by default, GCC provides C89 plus some GNU extensions. To enable C99 language support, you need to build your application with -std=c99 (or -std=gnu99) -- then the fmin(f) and fmax(f) routines will also be provided by glibc.

    On the SPU side, however, we're not using glibc but newlib. This library does not attempt to reflect the C standard used by the compiler, but will always make available the full set of functions it supports -- which is (a subset of) C99. This means fmin(f) and fmax(f) are always visible.

    If you build SPU code using C99 features, however, it would still be preferable to use -std=c99 as well -- this way, the compiler is able to recognize those functions as language-defined, which may enable extra optimizations.