X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fmain%2Fmacros.h;h=7b7fd1b6d760f04691b5345ab0315676cd4d8780;hb=d012e6d8fe2f4f1139af9e47a684960e8cde103e;hp=411b16d464e3eef5fe069392964900f5cda8d2e1;hpb=fd9afb87d81f922ea3c13a5bf2d6b17d06b43424;p=mesa.git diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h index 411b16d464e..7b7fd1b6d76 100644 --- a/src/mesa/main/macros.h +++ b/src/mesa/main/macros.h @@ -200,11 +200,16 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256]; (a)[3] == (b)[3]) /** Test for equality (unsigned bytes) */ +static inline GLboolean +TEST_EQ_4UBV(const GLubyte a[4], const GLubyte b[4]) +{ #if defined(__i386__) -#define TEST_EQ_4UBV(DST, SRC) *((GLuint*)(DST)) == *((GLuint*)(SRC)) + return *((const GLuint *) a) == *((const GLuint *) b); #else -#define TEST_EQ_4UBV(DST, SRC) TEST_EQ_4V(DST, SRC) + return TEST_EQ_4V(a, b); #endif +} + /** Copy a 4-element vector */ #define COPY_4V( DST, SRC ) \ @@ -215,40 +220,25 @@ do { \ (DST)[3] = (SRC)[3]; \ } while (0) -/** Copy a 4-element vector with cast */ -#define COPY_4V_CAST( DST, SRC, CAST ) \ -do { \ - (DST)[0] = (CAST)(SRC)[0]; \ - (DST)[1] = (CAST)(SRC)[1]; \ - (DST)[2] = (CAST)(SRC)[2]; \ - (DST)[3] = (CAST)(SRC)[3]; \ -} while (0) - /** Copy a 4-element unsigned byte vector */ +static inline void +COPY_4UBV(GLubyte dst[4], const GLubyte src[4]) +{ #if defined(__i386__) -#define COPY_4UBV(DST, SRC) \ -do { \ - *((GLuint*)(DST)) = *((GLuint*)(SRC)); \ -} while (0) + *((GLuint *) dst) = *((GLuint *) src); #else -/* The GLuint cast might fail if DST or SRC are not dword-aligned (RISC) */ -#define COPY_4UBV(DST, SRC) \ -do { \ - (DST)[0] = (SRC)[0]; \ - (DST)[1] = (SRC)[1]; \ - (DST)[2] = (SRC)[2]; \ - (DST)[3] = (SRC)[3]; \ -} while (0) + /* The GLuint cast might fail if DST or SRC are not dword-aligned (RISC) */ + COPY_4V(dst, src); #endif +} -/** - * Copy a 4-element float vector - * memcpy seems to be most efficient - */ -#define COPY_4FV( DST, SRC ) \ -do { \ - memcpy(DST, SRC, sizeof(GLfloat) * 4); \ -} while (0) +/** Copy a 4-element float vector */ +static inline void +COPY_4FV(GLfloat dst[4], const GLfloat src[4]) +{ + /* memcpy seems to be most efficient */ + memcpy(dst, src, sizeof(GLfloat) * 4); +} /** Copy \p SZ elements into a 4-element vector */ #define COPY_SZ_4V(DST, SZ, SRC) \ @@ -675,13 +665,13 @@ LEN_SQUARED_2FV(const GLfloat v[2]) static inline GLfloat LEN_3FV(const GLfloat v[3]) { - return SQRTF(LEN_SQUARED_3FV(v)); + return sqrtf(LEN_SQUARED_3FV(v)); } static inline GLfloat LEN_2FV(const GLfloat v[2]) { - return SQRTF(LEN_SQUARED_2FV(v)); + return sqrtf(LEN_SQUARED_2FV(v)); } @@ -699,6 +689,21 @@ NORMALIZE_3FV(GLfloat v[3]) } +/** Is float value negative? */ +static inline GLboolean +IS_NEGATIVE(float x) +{ + return signbit(x) != 0; +} + +/** Test two floats have opposite signs */ +static inline GLboolean +DIFFERENT_SIGNS(GLfloat x, GLfloat y) +{ + return signbit(x) != signbit(y); +} + + /** Compute ceiling of integer quotient of A divided by B. */ #define CEILING( A, B ) ( (A) % (B) == 0 ? (A)/(B) : (A)/(B)+1 )