summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2010-02-10 12:48:17 -0800
committerIan Romanick <ian.d.romanick@intel.com>2010-02-10 12:51:47 -0800
commit4666b21a00643d34ded839fdc882f66e0ebbfec3 (patch)
tree70d9e8416fcc0b0b301efa4aa503d1feb883cdea
parent2aff688a72f59172ad3411ebaeeb03d42cde39a8 (diff)
Ensure that functions are inlined
When optimizations are disabled, functions that only exist in header files ended up being undefined. The desired behavior is to force the function to be inlined, and never compile it stand-alone. None of the C or C++ standards give a way to do this, but every compiler seems to have a way.
-rw-r--r--include/glu3_scalar.h80
1 files changed, 44 insertions, 36 deletions
diff --git a/include/glu3_scalar.h b/include/glu3_scalar.h
index 3e87b8c..d3fb0c3 100644
--- a/include/glu3_scalar.h
+++ b/include/glu3_scalar.h
@@ -24,7 +24,15 @@
#include <math.h>
#include <string.h>
-extern inline void gluMult4v_4v(GLUvec4 *result,
+#ifdef _MSC_VER
+# define INLINE __forceinline
+#elif defined(__GNUC_GNU_INLINE__) || defined(__GNUC_STDC_INLINE__)
+# define INLINE inline __attribute__((gnu_inline))
+#else
+# define INLINE inline
+#endif
+
+extern INLINE void gluMult4v_4v(GLUvec4 *result,
const GLUvec4 *v1, const GLUvec4 *v2)
{
result->values[0] = v1->values[0] * v2->values[0];
@@ -34,7 +42,7 @@ extern inline void gluMult4v_4v(GLUvec4 *result,
}
-extern inline void gluDiv4v_4v(GLUvec4 *result,
+extern INLINE void gluDiv4v_4v(GLUvec4 *result,
const GLUvec4 *v1, const GLUvec4 *v2)
{
result->values[0] = v1->values[0] / v2->values[0];
@@ -44,7 +52,7 @@ extern inline void gluDiv4v_4v(GLUvec4 *result,
}
-extern inline void gluAdd4v_4v(GLUvec4 *result,
+extern INLINE void gluAdd4v_4v(GLUvec4 *result,
const GLUvec4 *v1, const GLUvec4 *v2)
{
result->values[0] = v1->values[0] + v2->values[0];
@@ -54,7 +62,7 @@ extern inline void gluAdd4v_4v(GLUvec4 *result,
}
-extern inline void gluSub4v_4v(GLUvec4 *result,
+extern INLINE void gluSub4v_4v(GLUvec4 *result,
const GLUvec4 *v1, const GLUvec4 *v2)
{
result->values[0] = v1->values[0] - v2->values[0];
@@ -64,7 +72,7 @@ extern inline void gluSub4v_4v(GLUvec4 *result,
}
-extern inline void gluMult4v_f(GLUvec4 *result,
+extern INLINE void gluMult4v_f(GLUvec4 *result,
const GLUvec4 *v1, GLfloat f)
{
result->values[0] = v1->values[0] * f;
@@ -74,7 +82,7 @@ extern inline void gluMult4v_f(GLUvec4 *result,
}
-extern inline void gluDiv4v_f(GLUvec4 *result,
+extern INLINE void gluDiv4v_f(GLUvec4 *result,
const GLUvec4 *v1, GLfloat f)
{
result->values[0] = v1->values[0] / f;
@@ -84,7 +92,7 @@ extern inline void gluDiv4v_f(GLUvec4 *result,
}
-extern inline void gluAdd4v_f(GLUvec4 *result,
+extern INLINE void gluAdd4v_f(GLUvec4 *result,
const GLUvec4 *v1, GLfloat f)
{
result->values[0] = v1->values[0] + f;
@@ -94,7 +102,7 @@ extern inline void gluAdd4v_f(GLUvec4 *result,
}
-extern inline void gluSub4v_f(GLUvec4 *result,
+extern INLINE void gluSub4v_f(GLUvec4 *result,
const GLUvec4 *v1, GLfloat f)
{
result->values[0] = v1->values[0] - f;
@@ -104,7 +112,7 @@ extern inline void gluSub4v_f(GLUvec4 *result,
}
-extern inline void gluMult4m_f(GLUmat4 *result,
+extern INLINE void gluMult4m_f(GLUmat4 *result,
const GLUmat4 *m, GLfloat f)
{
GLUmat4 temp;
@@ -117,7 +125,7 @@ extern inline void gluMult4m_f(GLUmat4 *result,
}
-extern inline void gluMult4m_4v(GLUvec4 *result,
+extern INLINE void gluMult4m_4v(GLUvec4 *result,
const GLUmat4 *m, const GLUvec4 *v)
{
GLUvec4 temp[6];
@@ -133,7 +141,7 @@ extern inline void gluMult4m_4v(GLUvec4 *result,
}
-extern inline void gluAdd4m_4m(GLUmat4 *result,
+extern INLINE void gluAdd4m_4m(GLUmat4 *result,
const GLUmat4 *m1, const GLUmat4 *m2)
{
GLUmat4 temp;
@@ -145,7 +153,7 @@ extern inline void gluAdd4m_4m(GLUmat4 *result,
*result = temp;
}
-extern inline void gluSub4m_4m(GLUmat4 *result,
+extern INLINE void gluSub4m_4m(GLUmat4 *result,
const GLUmat4 *m1, const GLUmat4 *m2)
{
GLUmat4 temp;
@@ -157,7 +165,7 @@ extern inline void gluSub4m_4m(GLUmat4 *result,
*result = temp;
}
-extern inline GLfloat gluDot4_4v(const GLUvec4 *v1, const GLUvec4 *v2)
+extern INLINE GLfloat gluDot4_4v(const GLUvec4 *v1, const GLUvec4 *v2)
{
return v1->values[0] * v2->values[0]
+ v1->values[1] * v2->values[1]
@@ -166,7 +174,7 @@ extern inline GLfloat gluDot4_4v(const GLUvec4 *v1, const GLUvec4 *v2)
}
-extern inline GLfloat gluDot3_4v(const GLUvec4 *v1, const GLUvec4 *v2)
+extern INLINE GLfloat gluDot3_4v(const GLUvec4 *v1, const GLUvec4 *v2)
{
return v1->values[0] * v2->values[0]
+ v1->values[1] * v2->values[1]
@@ -174,14 +182,14 @@ extern inline GLfloat gluDot3_4v(const GLUvec4 *v1, const GLUvec4 *v2)
}
-extern inline GLfloat gluDot2_4v(const GLUvec4 *v1, const GLUvec4 *v2)
+extern INLINE GLfloat gluDot2_4v(const GLUvec4 *v1, const GLUvec4 *v2)
{
return v1->values[0] * v2->values[0]
+ v1->values[1] * v2->values[1];
}
-extern inline void gluCross4v(GLUvec4 *result,
+extern INLINE void gluCross4v(GLUvec4 *result,
const GLUvec4 *v1, const GLUvec4 *v2)
{
GLUvec4 temp;
@@ -197,7 +205,7 @@ extern inline void gluCross4v(GLUvec4 *result,
}
-extern inline void gluOuter4v(GLUmat4 *result,
+extern INLINE void gluOuter4v(GLUmat4 *result,
const GLUvec4 *v1, const GLUvec4 *v2)
{
GLUmat4 temp;
@@ -210,26 +218,26 @@ extern inline void gluOuter4v(GLUmat4 *result,
}
-extern inline GLfloat gluLengthSqr4v(const GLUvec4 *v)
+extern INLINE GLfloat gluLengthSqr4v(const GLUvec4 *v)
{
return gluDot4_4v(v, v);
}
-extern inline GLfloat gluLength4v(const GLUvec4 *v)
+extern INLINE GLfloat gluLength4v(const GLUvec4 *v)
{
return sqrt(gluLengthSqr4v(v));
}
-extern inline void gluNormalize4v(GLUvec4 *result, const GLUvec4 *v)
+extern INLINE void gluNormalize4v(GLUvec4 *result, const GLUvec4 *v)
{
gluDiv4v_f(result, v, gluLength4v(v));
}
-extern inline void gluTranspose4m(GLUmat4 *result, const GLUmat4 *m)
+extern INLINE void gluTranspose4m(GLUmat4 *result, const GLUmat4 *m)
{
unsigned i;
unsigned j;
@@ -245,7 +253,7 @@ extern inline void gluTranspose4m(GLUmat4 *result, const GLUmat4 *m)
}
-extern inline void gluMult4m_4m(GLUmat4 *result,
+extern INLINE void gluMult4m_4m(GLUmat4 *result,
const GLUmat4 *m1, const GLUmat4 *m2)
{
GLUmat4 temp;
@@ -260,7 +268,7 @@ extern inline void gluMult4m_4m(GLUmat4 *result,
-extern inline void gluTranslate3f(GLUmat4 *result,
+extern INLINE void gluTranslate3f(GLUmat4 *result,
GLfloat x, GLfloat y, GLfloat z)
{
memcpy(result, & gluIdentityMatrix, sizeof(gluIdentityMatrix));
@@ -271,7 +279,7 @@ extern inline void gluTranslate3f(GLUmat4 *result,
#ifdef __cplusplus
-extern inline GLfloat gluDot4(const GLUvec4 &v1, const GLUvec4 &v2)
+extern INLINE GLfloat gluDot4(const GLUvec4 &v1, const GLUvec4 &v2)
{
return v1.values[0] * v2.values[0]
+ v1.values[1] * v2.values[1]
@@ -280,7 +288,7 @@ extern inline GLfloat gluDot4(const GLUvec4 &v1, const GLUvec4 &v2)
}
-extern inline GLfloat gluDot3(const GLUvec4 &v1, const GLUvec4 &v2)
+extern INLINE GLfloat gluDot3(const GLUvec4 &v1, const GLUvec4 &v2)
{
return v1.values[0] * v2.values[0]
+ v1.values[1] * v2.values[1]
@@ -288,14 +296,14 @@ extern inline GLfloat gluDot3(const GLUvec4 &v1, const GLUvec4 &v2)
}
-extern inline GLfloat gluDot2(const GLUvec4 &v1, const GLUvec4 &v2)
+extern INLINE GLfloat gluDot2(const GLUvec4 &v1, const GLUvec4 &v2)
{
return v1.values[0] * v2.values[0]
+ v1.values[1] * v2.values[1];
}
-inline GLUvec4 GLUvec4::operator+(const GLUvec4 &v) const
+INLINE GLUvec4 GLUvec4::operator+(const GLUvec4 &v) const
{
return GLUvec4(values[0] + v.values[0],
values[1] + v.values[1],
@@ -304,7 +312,7 @@ inline GLUvec4 GLUvec4::operator+(const GLUvec4 &v) const
}
-inline GLUvec4 GLUvec4::operator-(const GLUvec4 &v) const
+INLINE GLUvec4 GLUvec4::operator-(const GLUvec4 &v) const
{
return GLUvec4(values[0] - v.values[0],
values[1] - v.values[1],
@@ -313,7 +321,7 @@ inline GLUvec4 GLUvec4::operator-(const GLUvec4 &v) const
}
-inline GLUvec4 GLUvec4::operator*(const GLUvec4 &v) const
+INLINE GLUvec4 GLUvec4::operator*(const GLUvec4 &v) const
{
return GLUvec4(values[0] * v.values[0],
values[1] * v.values[1],
@@ -322,7 +330,7 @@ inline GLUvec4 GLUvec4::operator*(const GLUvec4 &v) const
}
-inline GLUvec4 GLUvec4::operator*(GLfloat f) const
+INLINE GLUvec4 GLUvec4::operator*(GLfloat f) const
{
return GLUvec4(values[0] * f,
values[1] * f,
@@ -331,7 +339,7 @@ inline GLUvec4 GLUvec4::operator*(GLfloat f) const
}
-inline GLUvec4 GLUvec4::operator*(const GLUmat4 &m) const
+INLINE GLUvec4 GLUvec4::operator*(const GLUmat4 &m) const
{
return GLUvec4(gluDot4(*this, m.col[0]),
gluDot4(*this, m.col[1]),
@@ -340,7 +348,7 @@ inline GLUvec4 GLUvec4::operator*(const GLUmat4 &m) const
}
-inline GLUmat4 GLUmat4::operator+(const GLUmat4 &m) const
+INLINE GLUmat4 GLUmat4::operator+(const GLUmat4 &m) const
{
GLUmat4 temp;
@@ -349,7 +357,7 @@ inline GLUmat4 GLUmat4::operator+(const GLUmat4 &m) const
}
-inline GLUmat4 GLUmat4::operator-(const GLUmat4 &m) const
+INLINE GLUmat4 GLUmat4::operator-(const GLUmat4 &m) const
{
return GLUmat4(col[0] - m.col[0],
col[1] - m.col[1],
@@ -358,7 +366,7 @@ inline GLUmat4 GLUmat4::operator-(const GLUmat4 &m) const
}
-inline GLUmat4 GLUmat4::operator*(GLfloat f) const
+INLINE GLUmat4 GLUmat4::operator*(GLfloat f) const
{
GLUmat4 temp;
@@ -367,7 +375,7 @@ inline GLUmat4 GLUmat4::operator*(GLfloat f) const
}
-inline GLUvec4 GLUmat4::operator*(const GLUvec4 &v) const
+INLINE GLUvec4 GLUmat4::operator*(const GLUvec4 &v) const
{
return (col[0] * v.values[0])
+ (col[1] * v.values[1])
@@ -376,7 +384,7 @@ inline GLUvec4 GLUmat4::operator*(const GLUvec4 &v) const
}
-inline GLUmat4 GLUmat4::operator*(const GLUmat4 &m) const
+INLINE GLUmat4 GLUmat4::operator*(const GLUmat4 &m) const
{
GLUmat4 temp;