aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-09-23 09:49:27 +0200
committermarha <marha@users.sourceforge.net>2013-09-23 09:49:27 +0200
commitb299d73bb416e2a26a642a54d5a15ea9fa30df33 (patch)
tree4cff827d4348e99d516ee2f1051f92ad5fa3ef8d /mesalib/src/glsl
parenta5179a42a3376f0d8c1d01456235b044854d8bdc (diff)
parente4d5a2996e4a03f55bc7d21c493ba1bcbef35aae (diff)
downloadvcxsrv-b299d73bb416e2a26a642a54d5a15ea9fa30df33.tar.gz
vcxsrv-b299d73bb416e2a26a642a54d5a15ea9fa30df33.tar.bz2
vcxsrv-b299d73bb416e2a26a642a54d5a15ea9fa30df33.zip
Merge remote-tracking branch 'origin/released'
* origin/released: mesa xserver git update 23 Sep 2013 Conflicts: mesalib/src/glsl/ast.h mesalib/src/glsl/glsl_parser_extras.h mesalib/src/glsl/glsl_symbol_table.cpp mesalib/src/glsl/ir_constant_expression.cpp mesalib/src/glsl/list.h
Diffstat (limited to 'mesalib/src/glsl')
-rwxr-xr-x[-rw-r--r--]mesalib/src/glsl/ast.h38
-rwxr-xr-x[-rw-r--r--]mesalib/src/glsl/glsl_parser_extras.h17
-rwxr-xr-xmesalib/src/glsl/glsl_symbol_table.cpp15
-rwxr-xr-x[-rw-r--r--]mesalib/src/glsl/ir_constant_expression.cpp25
-rw-r--r--mesalib/src/glsl/ir_function_detect_recursion.cpp20
-rwxr-xr-x[-rw-r--r--]mesalib/src/glsl/list.h38
-rw-r--r--mesalib/src/glsl/ralloc.h26
7 files changed, 45 insertions, 134 deletions
diff --git a/mesalib/src/glsl/ast.h b/mesalib/src/glsl/ast.h
index e6d8afef3..242ee4883 100644..100755
--- a/mesalib/src/glsl/ast.h
+++ b/mesalib/src/glsl/ast.h
@@ -49,28 +49,11 @@ struct YYLTYPE;
*/
class ast_node {
public:
- /* Callers of this ralloc-based new need not call delete. It's
- * easier to just ralloc_free 'ctx' (or any of its ancestors). */
- static void* operator new(size_t size, void *ctx)
- {
- void *node;
-
- node = rzalloc_size(ctx, size);
- assert(node != NULL);
-
- return node;
- }
-
- /* If the user *does* call delete, that's OK, we will just
- * ralloc_free in that case. */
+ DECLARE_RZALLOC_CXX_OPERATORS(ast_node);
static void operator delete(void *table, void *ctx)
{
ralloc_free(table);
}
- static void operator delete(void *table)
- {
- ralloc_free(table);
- }
/**
* Print an AST node in something approximating the original GLSL code
@@ -367,24 +350,7 @@ enum {
};
struct ast_type_qualifier {
- /* Callers of this ralloc-based new need not call delete. It's
- * easier to just ralloc_free 'ctx' (or any of its ancestors). */
- static void* operator new(size_t size, void *ctx)
- {
- void *node;
-
- node = rzalloc_size(ctx, size);
- assert(node != NULL);
-
- return node;
- }
-
- /* If the user *does* call delete, that's OK, we will just
- * ralloc_free in that case. */
- static void operator delete(void *table)
- {
- ralloc_free(table);
- }
+ DECLARE_RZALLOC_CXX_OPERATORS(ast_type_qualifier);
union {
struct {
diff --git a/mesalib/src/glsl/glsl_parser_extras.h b/mesalib/src/glsl/glsl_parser_extras.h
index 6e3b0282d..597e5427b 100644..100755
--- a/mesalib/src/glsl/glsl_parser_extras.h
+++ b/mesalib/src/glsl/glsl_parser_extras.h
@@ -73,26 +73,11 @@ struct _mesa_glsl_parse_state {
_mesa_glsl_parse_state(struct gl_context *_ctx, GLenum target,
void *mem_ctx);
- /* Callers of this ralloc-based new need not call delete. It's
- * easier to just ralloc_free 'ctx' (or any of its ancestors). */
- static void* operator new(size_t size, void *ctx)
- {
- void *mem = rzalloc_size(ctx, size);
- assert(mem != NULL);
-
- return mem;
- }
-
- /* If the user *does* call delete, that's OK, we will just
- * ralloc_free in that case. */
+ DECLARE_RZALLOC_CXX_OPERATORS(_mesa_glsl_parse_state);
static void operator delete(void *mem, void *ctx)
{
ralloc_free(mem);
}
- static void operator delete(void *mem)
- {
- ralloc_free(mem);
- }
/**
* Generate a string representing the GLSL version currently being compiled
diff --git a/mesalib/src/glsl/glsl_symbol_table.cpp b/mesalib/src/glsl/glsl_symbol_table.cpp
index 99057bced..0eabc23d8 100755
--- a/mesalib/src/glsl/glsl_symbol_table.cpp
+++ b/mesalib/src/glsl/glsl_symbol_table.cpp
@@ -26,24 +26,11 @@
class symbol_table_entry {
public:
- /* Callers of this ralloc-based new need not call delete. It's
- * easier to just ralloc_free 'ctx' (or any of its ancestors). */
- static void* operator new(size_t size, void *ctx)
- {
- void *entry = ralloc_size(ctx, size);
- assert(entry != NULL);
- return entry;
- }
-
- /* If the user *does* call delete, that's OK, we will just ralloc_free. */
+ DECLARE_RALLOC_CXX_OPERATORS(symbol_table_entry);
static void operator delete(void *entry, void *ctx)
{
ralloc_free(entry);
}
- static void operator delete(void *entry)
- {
- ralloc_free(entry);
- }
bool add_interface(const glsl_type *i, enum ir_variable_mode mode)
{
diff --git a/mesalib/src/glsl/ir_constant_expression.cpp b/mesalib/src/glsl/ir_constant_expression.cpp
index 3e30510a6..215c4a0ff 100644..100755
--- a/mesalib/src/glsl/ir_constant_expression.cpp
+++ b/mesalib/src/glsl/ir_constant_expression.cpp
@@ -40,19 +40,18 @@
#include "glsl_types.h"
#include "program/hash_table.h"
-#ifdef _MSC_VER
-#include <limits>
-
-inline bool isnormal(float x)
-{
- if(x < 0) x = -x;
- return x >= (std::numeric_limits<float>::min)()
- && x <= (std::numeric_limits<float>::max)();
-}
-inline float copysign(const float& x, const float& y)
-{
- return fabs(x) * ((y<0) ? -1 : 1);
-}
+#if defined(_MSC_VER) && (_MSC_VER < 1800)
+static int isnormal(double x)
+{
+ return _fpclass(x) == _FPCLASS_NN || _fpclass(x) == _FPCLASS_PN;
+}
+#endif
+
+#if defined(_MSC_VER)
+static double copysign(double x, double y)
+{
+ return _copysign(x, y);
+}
#endif
static float
diff --git a/mesalib/src/glsl/ir_function_detect_recursion.cpp b/mesalib/src/glsl/ir_function_detect_recursion.cpp
index 280c4734a..b02c32518 100644
--- a/mesalib/src/glsl/ir_function_detect_recursion.cpp
+++ b/mesalib/src/glsl/ir_function_detect_recursion.cpp
@@ -139,25 +139,7 @@ public:
/* empty */
}
-
- /* Callers of this ralloc-based new need not call delete. It's
- * easier to just ralloc_free 'ctx' (or any of its ancestors). */
- static void* operator new(size_t size, void *ctx)
- {
- void *node;
-
- node = ralloc_size(ctx, size);
- assert(node != NULL);
-
- return node;
- }
-
- /* If the user *does* call delete, that's OK, we will just
- * ralloc_free in that case. */
- static void operator delete(void *node)
- {
- ralloc_free(node);
- }
+ DECLARE_RALLOC_CXX_OPERATORS(function)
ir_function_signature *sig;
diff --git a/mesalib/src/glsl/list.h b/mesalib/src/glsl/list.h
index fb6f0fbba..2934539fe 100644..100755
--- a/mesalib/src/glsl/list.h
+++ b/mesalib/src/glsl/list.h
@@ -76,28 +76,11 @@ struct exec_node {
struct exec_node *prev;
#ifdef __cplusplus
- /* Callers of this ralloc-based new need not call delete. It's
- * easier to just ralloc_free 'ctx' (or any of its ancestors). */
- static void* operator new(size_t size, void *ctx)
- {
- void *node;
-
- node = ralloc_size(ctx, size);
- assert(node != NULL);
-
- return node;
- }
-
- /* If the user *does* call delete, that's OK, we will just
- * ralloc_free in that case. */
+ DECLARE_RALLOC_CXX_OPERATORS(exec_node)
static void operator delete(void *node, void *ctx)
{
ralloc_free(node);
}
- static void operator delete(void *node)
- {
- ralloc_free(node);
- }
exec_node() : next(NULL), prev(NULL)
{
@@ -289,28 +272,11 @@ struct exec_list {
struct exec_node *tail_pred;
#ifdef __cplusplus
- /* Callers of this ralloc-based new need not call delete. It's
- * easier to just ralloc_free 'ctx' (or any of its ancestors). */
- static void* operator new(size_t size, void *ctx)
- {
- void *node;
-
- node = ralloc_size(ctx, size);
- assert(node != NULL);
-
- return node;
- }
-
- /* If the user *does* call delete, that's OK, we will just
- * ralloc_free in that case. */
+ DECLARE_RALLOC_CXX_OPERATORS(exec_list)
static void operator delete(void *node, void *ctx)
{
ralloc_free(node);
}
- static void operator delete(void *node)
- {
- ralloc_free(node);
- }
exec_list()
{
diff --git a/mesalib/src/glsl/ralloc.h b/mesalib/src/glsl/ralloc.h
index 67eb93833..799d3a9b8 100644
--- a/mesalib/src/glsl/ralloc.h
+++ b/mesalib/src/glsl/ralloc.h
@@ -404,4 +404,30 @@ bool ralloc_vasprintf_append(char **str, const char *fmt, va_list args);
} /* end of extern "C" */
#endif
+#define _RALLOC_OPS(ALLOC, TYPE) \
+ static void* operator new(size_t size, void *mem_ctx) \
+ { \
+ void *p = ALLOC(mem_ctx, size); \
+ assert(p != NULL); \
+ return p; \
+ } \
+ \
+ static void operator delete(void *p) \
+ { \
+ ralloc_free(p); \
+ }
+
+/**
+ * Declare C++ new and delete operators which use ralloc.
+ *
+ * Placing one of these macros in the body of a class makes it possible to do:
+ *
+ * TYPE *var = new(mem_ctx) TYPE(...);
+ * delete var;
+ *
+ * which is more idiomatic in C++ than calling ralloc or rzalloc.
+ */
+#define DECLARE_RALLOC_CXX_OPERATORS(TYPE) _RALLOC_OPS(ralloc_size, TYPE)
+#define DECLARE_RZALLOC_CXX_OPERATORS(TYPE) _RALLOC_OPS(rzalloc_size, TYPE)
+
#endif