Mesa (master): main/get: Converted type conversion macros to inline functions
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Feb 19 19:05:19 UTC 2020
Module: Mesa
Branch: master
Commit: 360ffdf4e23464879748051e57587aff938bd50d
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=360ffdf4e23464879748051e57587aff938bd50d
Author: Kristian H. Kristensen <hoegsberg at google.com>
Date: Tue Feb 18 14:41:38 2020 -0800
main/get: Converted type conversion macros to inline functions
Quiet warnings when called with a GLubyte:
src/mesa/main/get.c:3215:19: warning: result of comparison of constant 32767 with expression of type 'GLubyte' (aka 'unsigned char') is always false [-Wtautological-constant-out-of-range-compare]
params[0] = INT_TO_FIXED(((GLubyte *) p)[0]);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/mesa/main/get.c:78:38: note: expanded from macro 'INT_TO_FIXED'
~~~ ^ ~~~~~~~~
Delete ENUM_TO_INT64, ENUM_TO_FIXED and BOOLEAN_TO_INT64 which aren't
used.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3866>
---
src/mesa/main/get.c | 78 +++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 58 insertions(+), 20 deletions(-)
diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c
index 765c0e4ae2c..261eaf37323 100644
--- a/src/mesa/main/get.c
+++ b/src/mesa/main/get.c
@@ -69,26 +69,64 @@
* is about as concise as the specification in the old python script.
*/
-#define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE )
-#define FLOAT_TO_FIXED(F) ( ((F) * 65536.0f > INT_MAX) ? INT_MAX : \
- ((F) * 65536.0f < INT_MIN) ? INT_MIN : \
- (GLint) ((F) * 65536.0f) )
-
-#define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
-#define INT_TO_FIXED(I) ( ((I) > SHRT_MAX) ? INT_MAX : \
- ((I) < SHRT_MIN) ? INT_MIN : \
- (GLint) ((I) * 65536) )
-
-#define INT64_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
-#define INT64_TO_INT(I) ( (GLint)((I > INT_MAX) ? INT_MAX : ((I < INT_MIN) ? INT_MIN : (I))) )
-
-#define BOOLEAN_TO_INT(B) ( (GLint) (B) )
-#define BOOLEAN_TO_INT64(B) ( (GLint64) (B) )
-#define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F )
-#define BOOLEAN_TO_FIXED(B) ( (GLint) ((B) ? 1 : 0) << 16 )
-
-#define ENUM_TO_INT64(E) ( (GLint64) (E) )
-#define ENUM_TO_FIXED(E) (E)
+static inline GLboolean
+FLOAT_TO_BOOLEAN(GLfloat X)
+{
+ return ( (X) ? GL_TRUE : GL_FALSE );
+}
+
+static inline GLint
+FLOAT_TO_FIXED(GLfloat F)
+{
+ return ( ((F) * 65536.0f > INT_MAX) ? INT_MAX :
+ ((F) * 65536.0f < INT_MIN) ? INT_MIN :
+ (GLint) ((F) * 65536.0f) );
+}
+
+static inline GLboolean
+INT_TO_BOOLEAN(GLint I)
+{
+ return ( (I) ? GL_TRUE : GL_FALSE );
+}
+
+static inline GLfixed
+INT_TO_FIXED(GLint I)
+{
+ return (((I) > SHRT_MAX) ? INT_MAX :
+ ((I) < SHRT_MIN) ? INT_MIN :
+ (GLint) ((I) * 65536) );
+}
+
+
+static inline GLboolean
+INT64_TO_BOOLEAN(GLint64 I)
+{
+ return ( (I) ? GL_TRUE : GL_FALSE );
+}
+
+static inline GLint
+INT64_TO_INT(GLint64 I)
+{
+ return ( (GLint)((I > INT_MAX) ? INT_MAX : ((I < INT_MIN) ? INT_MIN : (I))) );
+}
+
+static inline GLint
+BOOLEAN_TO_INT(GLboolean B)
+{
+ return ( (GLint) (B) );
+}
+
+static inline GLfloat
+BOOLEAN_TO_FLOAT(GLboolean B)
+{
+ return ( (B) ? 1.0F : 0.0F );
+}
+
+static inline GLfixed
+BOOLEAN_TO_FIXED(GLboolean B)
+{
+ return ( (GLint) ((B) ? 1 : 0) << 16 );
+}
enum value_type {
TYPE_INVALID,
More information about the mesa-commit
mailing list