aboutsummaryrefslogtreecommitdiff
path: root/mesalib
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib')
-rw-r--r--mesalib/configure.ac6
-rw-r--r--mesalib/src/glsl/ast.h38
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.h17
-rw-r--r--mesalib/src/glsl/glsl_symbol_table.cpp15
-rw-r--r--mesalib/src/glsl/ir_constant_expression.cpp14
-rw-r--r--mesalib/src/glsl/ir_function_detect_recursion.cpp20
-rw-r--r--mesalib/src/glsl/list.h38
-rw-r--r--mesalib/src/glsl/ralloc.h26
-rw-r--r--mesalib/src/mesa/program/ir_to_mesa.cpp12
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp12
10 files changed, 55 insertions, 143 deletions
diff --git a/mesalib/configure.ac b/mesalib/configure.ac
index ca9228cf9..d280e389a 100644
--- a/mesalib/configure.ac
+++ b/mesalib/configure.ac
@@ -1969,6 +1969,12 @@ dnl Restore LDFLAGS and CPPFLAGS
LDFLAGS="$_SAVE_LDFLAGS"
CPPFLAGS="$_SAVE_CPPFLAGS"
+dnl Suppress clang's warnings about unused CFLAGS and CXXFLAGS
+if test "x$acv_mesa_CLANG" = xyes; then
+ CFLAGS="$CFLAGS -Qunused-arguments"
+ CXXFLAGS="$CXXFLAGS -Qunused-arguments"
+fi
+
dnl Add user CFLAGS and CXXFLAGS
CFLAGS="$CFLAGS $USER_CFLAGS"
CXXFLAGS="$CXXFLAGS $USER_CXXFLAGS"
diff --git a/mesalib/src/glsl/ast.h b/mesalib/src/glsl/ast.h
index 1c7fc63ac..c3361a106 100644
--- a/mesalib/src/glsl/ast.h
+++ b/mesalib/src/glsl/ast.h
@@ -49,24 +49,7 @@ 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. */
- static void operator delete(void *table)
- {
- ralloc_free(table);
- }
+ DECLARE_RZALLOC_CXX_OPERATORS(ast_node);
/**
* Print an AST node in something approximating the original GLSL code
@@ -363,24 +346,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 2e2440a9e..364a98345 100644
--- a/mesalib/src/glsl/glsl_parser_extras.h
+++ b/mesalib/src/glsl/glsl_parser_extras.h
@@ -73,22 +73,7 @@ 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. */
- static void operator delete(void *mem)
- {
- ralloc_free(mem);
- }
+ DECLARE_RZALLOC_CXX_OPERATORS(_mesa_glsl_parse_state);
/**
* 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 4c96620bf..6e916b458 100644
--- a/mesalib/src/glsl/glsl_symbol_table.cpp
+++ b/mesalib/src/glsl/glsl_symbol_table.cpp
@@ -26,20 +26,7 @@
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. */
- static void operator delete(void *entry)
- {
- ralloc_free(entry);
- }
+ DECLARE_RALLOC_CXX_OPERATORS(symbol_table_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 4579ef209..12641e5df 100644
--- a/mesalib/src/glsl/ir_constant_expression.cpp
+++ b/mesalib/src/glsl/ir_constant_expression.cpp
@@ -40,6 +40,20 @@
#include "glsl_types.h"
#include "program/hash_table.h"
+#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
dot(ir_constant *op0, ir_constant *op1)
{
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 1d46365fa..5ac17cb37 100644
--- a/mesalib/src/glsl/list.h
+++ b/mesalib/src/glsl/list.h
@@ -76,24 +76,7 @@ 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. */
- static void operator delete(void *node)
- {
- ralloc_free(node);
- }
+ DECLARE_RALLOC_CXX_OPERATORS(exec_node)
exec_node() : next(NULL), prev(NULL)
{
@@ -285,24 +268,7 @@ 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. */
- static void operator delete(void *node)
- {
- ralloc_free(node);
- }
+ DECLARE_RALLOC_CXX_OPERATORS(exec_list)
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
diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp
index cef32dc07..c46a3d005 100644
--- a/mesalib/src/mesa/program/ir_to_mesa.cpp
+++ b/mesalib/src/mesa/program/ir_to_mesa.cpp
@@ -149,17 +149,7 @@ dst_reg::dst_reg(src_reg reg)
class ir_to_mesa_instruction : public exec_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;
- }
+ DECLARE_RZALLOC_CXX_OPERATORS(ir_to_mesa_instruction)
enum prog_opcode op;
dst_reg dst;
diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 0a1837f69..271cf0523 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -217,17 +217,7 @@ st_dst_reg::st_dst_reg(st_src_reg reg)
class glsl_to_tgsi_instruction : public exec_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;
- }
+ DECLARE_RZALLOC_CXX_OPERATORS(glsl_to_tgsi_instruction)
unsigned op;
st_dst_reg dst;