aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/imports.h
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2012-09-03 09:54:39 +0200
committermarha <marha@users.sourceforge.net>2012-09-03 09:54:39 +0200
commitb86e8562b1ddca2a8bc29f22a79451a041bf5293 (patch)
tree60fead0638fce6922b4043767fa991ff1f0e3488 /mesalib/src/mesa/main/imports.h
parent53192e17e55aa9ed3e3721bf4fdcb2b01a595202 (diff)
downloadvcxsrv-b86e8562b1ddca2a8bc29f22a79451a041bf5293.tar.gz
vcxsrv-b86e8562b1ddca2a8bc29f22a79451a041bf5293.tar.bz2
vcxsrv-b86e8562b1ddca2a8bc29f22a79451a041bf5293.zip
mesa xkeyboard-config git update 3 sep 2012
Diffstat (limited to 'mesalib/src/mesa/main/imports.h')
-rw-r--r--mesalib/src/mesa/main/imports.h153
1 files changed, 46 insertions, 107 deletions
diff --git a/mesalib/src/mesa/main/imports.h b/mesalib/src/mesa/main/imports.h
index 73913b5ab..2f854e574 100644
--- a/mesalib/src/mesa/main/imports.h
+++ b/mesalib/src/mesa/main/imports.h
@@ -156,44 +156,47 @@ static inline int isblank(int ch) { return ch == ' ' || ch == '\t'; }
#endif
/*@}*/
+#if defined(__SUNPRO_C)
+#define sqrtf(f) ((float) sqrt(f))
+#endif
+
+
/***
*** LOG2: Log base 2 of float
***/
-#ifdef USE_IEEE
-#if 0
-/* This is pretty fast, but not accurate enough (only 2 fractional bits).
- * Based on code from http://www.stereopsis.com/log2.html
- */
static inline GLfloat LOG2(GLfloat x)
{
+#ifdef USE_IEEE
+#if 0
+ /* This is pretty fast, but not accurate enough (only 2 fractional bits).
+ * Based on code from http://www.stereopsis.com/log2.html
+ */
const GLfloat y = x * x * x * x;
const GLuint ix = *((GLuint *) &y);
const GLuint exp = (ix >> 23) & 0xFF;
const GLint log2 = ((GLint) exp) - 127;
return (GLfloat) log2 * (1.0 / 4.0); /* 4, because of x^4 above */
-}
#endif
-/* Pretty fast, and accurate.
- * Based on code from http://www.flipcode.com/totd/
- */
-static inline GLfloat LOG2(GLfloat val)
-{
+ /* Pretty fast, and accurate.
+ * Based on code from http://www.flipcode.com/totd/
+ */
fi_type num;
GLint log_2;
- num.f = val;
+ num.f = x;
log_2 = ((num.i >> 23) & 255) - 128;
num.i &= ~(255 << 23);
num.i += 127 << 23;
num.f = ((-1.0f/3) * num.f + 2) * num.f - 2.0f/3;
return num.f + log_2;
-}
#else
-/*
- * NOTE: log_base_2(x) = log(x) / log(2)
- * NOTE: 1.442695 = 1/log(2).
- */
-#define LOG2(x) ((GLfloat) (log(x) * 1.442695F))
+ /*
+ * NOTE: log_base_2(x) = log(x) / log(2)
+ * NOTE: 1.442695 = 1/log(2).
+ */
+ return (GLfloat) (log(x) * 1.442695F);
#endif
+}
+
/***
@@ -220,35 +223,6 @@ static inline int IS_INF_OR_NAN( float x )
/***
- *** IS_NEGATIVE: test if float is negative
- ***/
-#if defined(USE_IEEE)
-static inline int GET_FLOAT_BITS( float x )
-{
- fi_type fi;
- fi.f = x;
- return fi.i;
-}
-#define IS_NEGATIVE(x) (GET_FLOAT_BITS(x) < 0)
-#else
-#define IS_NEGATIVE(x) (x < 0.0F)
-#endif
-
-
-/***
- *** DIFFERENT_SIGNS: test if two floats have opposite signs
- ***/
-#if defined(USE_IEEE)
-#define DIFFERENT_SIGNS(x,y) ((GET_FLOAT_BITS(x) ^ GET_FLOAT_BITS(y)) & (1<<31))
-#else
-/* Could just use (x*y<0) except for the flatshading requirements.
- * Maybe there's a better way?
- */
-#define DIFFERENT_SIGNS(x,y) ((x) * (y) <= 0.0F && (x) - (y) != 0.0F)
-#endif
-
-
-/***
*** CEILF: ceiling of float
*** FLOORF: floor of float
*** FABSF: absolute value of float
@@ -309,50 +283,36 @@ static inline int IROUND_POS(float f)
* Convert float to int using a fast method. The rounding mode may vary.
* XXX We could use an x86-64/SSE2 version here.
*/
-#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
static inline int F_TO_I(float f)
{
+#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
int r;
__asm__ ("fistpl %0" : "=m" (r) : "t" (f) : "st");
return r;
-}
#elif defined(USE_X86_ASM) && defined(_MSC_VER)
-static inline int F_TO_I(float f)
-{
int r;
_asm {
fld f
fistp r
}
return r;
-}
-#elif defined(__WATCOMC__) && defined(__386__)
-long F_TO_I(float f);
-#pragma aux iround = \
- "push eax" \
- "fistp dword ptr [esp]" \
- "pop eax" \
- parm [8087] \
- value [eax] \
- modify exact [eax];
#else
-#define F_TO_I(f) IROUND(f)
+ return IROUND(f);
#endif
+}
-/***
- *** IFLOOR: return (as an integer) floor of float
- ***/
-#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
-/*
- * IEEE floor for computers that round to nearest or even.
- * 'f' must be between -4194304 and 4194303.
- * This floor operation is done by "(iround(f + .5) + iround(f - .5)) >> 1",
- * but uses some IEEE specific tricks for better speed.
- * Contributed by Josh Vanderhoof
- */
-static inline int ifloor(float f)
+/** Return (as an integer) floor of float */
+static inline int IFLOOR(float f)
{
+#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
+ /*
+ * IEEE floor for computers that round to nearest or even.
+ * 'f' must be between -4194304 and 4194303.
+ * This floor operation is done by "(iround(f + .5) + iround(f - .5)) >> 1",
+ * but uses some IEEE specific tricks for better speed.
+ * Contributed by Josh Vanderhoof
+ */
int ai, bi;
double af, bf;
af = (3 << 22) + 0.5 + (double)f;
@@ -361,45 +321,33 @@ static inline int ifloor(float f)
__asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st");
__asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st");
return (ai - bi) >> 1;
-}
-#define IFLOOR(x) ifloor(x)
#elif defined(USE_IEEE)
-static inline int ifloor(float f)
-{
int ai, bi;
double af, bf;
fi_type u;
-
af = (3 << 22) + 0.5 + (double)f;
bf = (3 << 22) + 0.5 - (double)f;
u.f = (float) af; ai = u.i;
u.f = (float) bf; bi = u.i;
return (ai - bi) >> 1;
-}
-#define IFLOOR(x) ifloor(x)
#else
-static inline int ifloor(float f)
-{
int i = IROUND(f);
return (i > f) ? i - 1 : i;
-}
-#define IFLOOR(x) ifloor(x)
#endif
+}
-/***
- *** ICEIL: return (as an integer) ceiling of float
- ***/
-#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
-/*
- * IEEE ceil for computers that round to nearest or even.
- * 'f' must be between -4194304 and 4194303.
- * This ceil operation is done by "(iround(f + .5) + iround(f - .5) + 1) >> 1",
- * but uses some IEEE specific tricks for better speed.
- * Contributed by Josh Vanderhoof
- */
-static inline int iceil(float f)
+/** Return (as an integer) ceiling of float */
+static inline int ICEIL(float f)
{
+#if defined(USE_X86_ASM) && defined(__GNUC__) && defined(__i386__)
+ /*
+ * IEEE ceil for computers that round to nearest or even.
+ * 'f' must be between -4194304 and 4194303.
+ * This ceil operation is done by "(iround(f + .5) + iround(f - .5) + 1) >> 1",
+ * but uses some IEEE specific tricks for better speed.
+ * Contributed by Josh Vanderhoof
+ */
int ai, bi;
double af, bf;
af = (3 << 22) + 0.5 + (double)f;
@@ -408,11 +356,7 @@ static inline int iceil(float f)
__asm__ ("fstps %0" : "=m" (ai) : "t" (af) : "st");
__asm__ ("fstps %0" : "=m" (bi) : "t" (bf) : "st");
return (ai - bi + 1) >> 1;
-}
-#define ICEIL(x) iceil(x)
#elif defined(USE_IEEE)
-static inline int iceil(float f)
-{
int ai, bi;
double af, bf;
fi_type u;
@@ -421,16 +365,11 @@ static inline int iceil(float f)
u.f = (float) af; ai = u.i;
u.f = (float) bf; bi = u.i;
return (ai - bi + 1) >> 1;
-}
-#define ICEIL(x) iceil(x)
#else
-static inline int iceil(float f)
-{
int i = IROUND(f);
return (i < f) ? i + 1 : i;
-}
-#define ICEIL(x) iceil(x)
#endif
+}
/**