Re: sincos opcode (issue205045)


Blair Zajac <bl...@...>
 

Solaris provides sincos as part of math.h.

Given that OSL is now an open-source project, probably at some point it'll need to grow a configure based solution to find functions.

If configure was used, then it would build a config.h that would define or not define HAVE_SINCOS and then the code could just rely upon that, instead of trusting a developer to include headers in the correct order or checking if it was a particular platform.

Regards,
Blair

On 02/08/2010 03:48 PM, Larry Gritz wrote:
1. At the top of fmath.h, before #include<cmath>:

#ifndef __MATH_H__
#define _GNU_SOURCE
#endif


2. In fmath.h, define sincos

#if !defined(_GNU_SOURCE) || !defined(__GNUC__) || !defined(__linux__)
inline void sincos (...) {...}
#endif

3. Tough luck for users who #include<math.h> BEFORE fmath.h and don't define _GNU_SOURCE, they'll get the backup definition, that calls sin and cos separately.

This will work for everybody and never be slower than using sin and cos separately. But users who care enough to do the right #defines and #includes will get something faster.


On Feb 8, 2010, at 3:31 PM,<cku...@...> wrote:

Its more complicated than that. The symbol doesn't show up by default.
You need to do:

#define _GNU_SOURCE
#include<math.h>

And of course, its hard to know where math.h (or cmath) is first
included (this can change depending on the order of inclusion of the
headers).

This only works on linux by the way, os x does not support this
extension as far as I can tell.


http://codereview.appspot.com/205045/show

Join osl-dev@lists.aswf.io to automatically receive all group messages.