<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 26, 2015 at 3:27 PM, Ian Romanick <span dir="ltr"><<a href="mailto:idr@freedesktop.org" target="_blank">idr@freedesktop.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I think the functions in the header file need to be 'static inline'.<br>
Otherwise linking will fail platforms that don't have fpclassify...<br>
which defeats the purpose. :)<br></blockquote><div><br></div><div>done <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
On 01/26/2015 02:22 PM, Jason Ekstrand wrote:<br>
> ---<br>
> src/mesa/main/querymatrix.c | 51 +-------------------------------------------<br>
> src/util/macros.h | 52 +++++++++++++++++++++++++++++++++++++++++++++<br>
> 2 files changed, 53 insertions(+), 50 deletions(-)<br>
><br>
> diff --git a/src/mesa/main/querymatrix.c b/src/mesa/main/querymatrix.c<br>
> index ef85175..d2d643b 100644<br>
> --- a/src/mesa/main/querymatrix.c<br>
> +++ b/src/mesa/main/querymatrix.c<br>
> @@ -17,6 +17,7 @@<br>
> #include "glheader.h"<br>
> #include "querymatrix.h"<br>
> #include "main/get.h"<br>
> +#include "util/macros.h"<br>
><br>
><br>
> /**<br>
> @@ -37,56 +38,6 @@<br>
> #define INT_TO_FIXED(x) ((GLfixed) ((x) << 16))<br>
> #define FLOAT_TO_FIXED(x) ((GLfixed) ((x) * 65536.0))<br>
><br>
> -#if defined(fpclassify)<br>
> -/* ISO C99 says that fpclassify is a macro. Assume that any implementation<br>
> - * of fpclassify, whether it's in a C99 compiler or not, will be a macro.<br>
> - */<br>
> -#elif defined(_MSC_VER)<br>
> -/* Not required on VS2013 and above. */<br>
> -/* Oddly, the fpclassify() function doesn't exist in such a form<br>
> - * on MSVC. This is an implementation using slightly different<br>
> - * lower-level Windows functions.<br>
> - */<br>
> -#include <float.h><br>
> -<br>
> -enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL}<br>
> -fpclassify(double x)<br>
> -{<br>
> - switch(_fpclass(x)) {<br>
> - case _FPCLASS_SNAN: /* signaling NaN */<br>
> - case _FPCLASS_QNAN: /* quiet NaN */<br>
> - return FP_NAN;<br>
> - case _FPCLASS_NINF: /* negative infinity */<br>
> - case _FPCLASS_PINF: /* positive infinity */<br>
> - return FP_INFINITE;<br>
> - case _FPCLASS_NN: /* negative normal */<br>
> - case _FPCLASS_PN: /* positive normal */<br>
> - return FP_NORMAL;<br>
> - case _FPCLASS_ND: /* negative denormalized */<br>
> - case _FPCLASS_PD: /* positive denormalized */<br>
> - return FP_SUBNORMAL;<br>
> - case _FPCLASS_NZ: /* negative zero */<br>
> - case _FPCLASS_PZ: /* positive zero */<br>
> - return FP_ZERO;<br>
> - default:<br>
> - /* Should never get here; but if we do, this will guarantee<br>
> - * that the pattern is not treated like a number.<br>
> - */<br>
> - return FP_NAN;<br>
> - }<br>
> -}<br>
> -<br>
> -#else<br>
> -<br>
> -enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL}<br>
> -fpclassify(double x)<br>
> -{<br>
> - /* XXX do something better someday */<br>
> - return FP_NORMAL;<br>
> -}<br>
> -<br>
> -#endif<br>
> -<br>
> GLbitfield GLAPIENTRY _mesa_QueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16])<br>
> {<br>
> GLfloat matrix[16];<br>
> diff --git a/src/util/macros.h b/src/util/macros.h<br>
> index eec8b93..a0c3ecf 100644<br>
> --- a/src/util/macros.h<br>
> +++ b/src/util/macros.h<br>
> @@ -24,6 +24,8 @@<br>
> #ifndef UTIL_MACROS_H<br>
> #define UTIL_MACROS_H<br>
><br>
> +#include <math.h><br>
> +<br>
> /* Compute the size of an array */<br>
> #ifndef ARRAY_SIZE<br>
> # define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))<br>
> @@ -156,4 +158,54 @@ do { \<br>
> # endif<br>
> #endif<br>
><br>
> +#if defined(fpclassify)<br>
> +/* ISO C99 says that fpclassify is a macro. Assume that any implementation<br>
> + * of fpclassify, whether it's in a C99 compiler or not, will be a macro.<br>
> + */<br>
> +#elif defined(_MSC_VER)<br>
> +/* Not required on VS2013 and above. */<br>
> +/* Oddly, the fpclassify() function doesn't exist in such a form<br>
> + * on MSVC. This is an implementation using slightly different<br>
> + * lower-level Windows functions.<br>
> + */<br>
> +#include <float.h><br>
> +<br>
> +enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL}<br>
> +fpclassify(double x)<br>
> +{<br>
> + switch(_fpclass(x)) {<br>
> + case _FPCLASS_SNAN: /* signaling NaN */<br>
> + case _FPCLASS_QNAN: /* quiet NaN */<br>
> + return FP_NAN;<br>
> + case _FPCLASS_NINF: /* negative infinity */<br>
> + case _FPCLASS_PINF: /* positive infinity */<br>
> + return FP_INFINITE;<br>
> + case _FPCLASS_NN: /* negative normal */<br>
> + case _FPCLASS_PN: /* positive normal */<br>
> + return FP_NORMAL;<br>
> + case _FPCLASS_ND: /* negative denormalized */<br>
> + case _FPCLASS_PD: /* positive denormalized */<br>
> + return FP_SUBNORMAL;<br>
> + case _FPCLASS_NZ: /* negative zero */<br>
> + case _FPCLASS_PZ: /* positive zero */<br>
> + return FP_ZERO;<br>
> + default:<br>
> + /* Should never get here; but if we do, this will guarantee<br>
> + * that the pattern is not treated like a number.<br>
> + */<br>
> + return FP_NAN;<br>
> + }<br>
> +}<br>
> +<br>
> +#else<br>
> +<br>
> +enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL}<br>
> +fpclassify(double x)<br>
> +{<br>
> + /* XXX do something better someday */<br>
> + return FP_NORMAL;<br>
> +}<br>
> +<br>
> +#endif<br>
> +<br>
> #endif /* UTIL_MACROS_H */<br>
><br>
<br>
</div></div></blockquote></div><br></div></div>