[Mesa-dev] [PATCH 05/18] glsl: consistently use ifndef guards over pragma once

Emil Velikov emil.l.velikov at gmail.com
Mon Mar 20 16:12:55 UTC 2017


Through the glsl headers we had an odd mix of guards be that
"ifndef", "pragma once" neither or both.

Simplify things by using the more common ones (ifndef) and annotating
all the sources, barring the generated builting header -
builtin_int64.h.

The final header - udivmod64.h - is [seemingly] unused and on its way
out (patch purge it is on the mailing list).

Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 src/compiler/glsl/ast.h                               | 1 -
 src/compiler/glsl/blob.h                              | 1 -
 src/compiler/glsl/glsl_parser_extras.h                | 1 -
 src/compiler/glsl/glsl_symbol_table.h                 | 1 -
 src/compiler/glsl/glsl_to_nir.h                       | 5 +++++
 src/compiler/glsl/ir.h                                | 1 -
 src/compiler/glsl/ir_array_refcount.h                 | 5 +++++
 src/compiler/glsl/ir_basic_block.h                    | 5 +++++
 src/compiler/glsl/ir_builder_print_visitor.h          | 1 -
 src/compiler/glsl/ir_expression_flattening.h          | 5 +++++
 src/compiler/glsl/ir_function_inlining.h              | 5 +++++
 src/compiler/glsl/ir_hierarchical_visitor.h           | 1 -
 src/compiler/glsl/ir_optimization.h                   | 6 +++++-
 src/compiler/glsl/ir_print_visitor.h                  | 1 -
 src/compiler/glsl/ir_reader.h                         | 1 -
 src/compiler/glsl/ir_rvalue_visitor.h                 | 5 +++++
 src/compiler/glsl/ir_uniform.h                        | 1 -
 src/compiler/glsl/ir_variable_refcount.h              | 5 +++++
 src/compiler/glsl/ir_visitor.h                        | 1 -
 src/compiler/glsl/link_uniform_block_active_visitor.h | 1 -
 src/compiler/glsl/link_varyings.h                     | 1 -
 src/compiler/glsl/linker.h                            | 1 -
 src/compiler/glsl/list.h                              | 1 -
 src/compiler/glsl/loop_analysis.h                     | 1 -
 src/compiler/glsl/lower_buffer_access.h               | 1 -
 src/compiler/glsl/program.h                           | 4 ++++
 src/compiler/glsl/s_expression.h                      | 1 -
 src/compiler/glsl/shader_cache.h                      | 1 -
 src/compiler/glsl/standalone_scaffolding.h            | 1 -
 src/compiler/glsl/test_optpass.h                      | 1 -
 src/compiler/glsl/tests/uniform_initializer_utils.h   | 5 ++++-
 31 files changed, 48 insertions(+), 23 deletions(-)

diff --git a/src/compiler/glsl/ast.h b/src/compiler/glsl/ast.h
index 55cc5df8f31..455cb8113cd 100644
--- a/src/compiler/glsl/ast.h
+++ b/src/compiler/glsl/ast.h
@@ -22,7 +22,6 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#pragma once
 #ifndef AST_H
 #define AST_H
 
diff --git a/src/compiler/glsl/blob.h b/src/compiler/glsl/blob.h
index 6d21ffdefe3..9de12e6eb82 100644
--- a/src/compiler/glsl/blob.h
+++ b/src/compiler/glsl/blob.h
@@ -21,7 +21,6 @@
  * IN THE SOFTWARE.
  */
 
-#pragma once
 #ifndef BLOB_H
 #define BLOB_H
 
diff --git a/src/compiler/glsl/glsl_parser_extras.h b/src/compiler/glsl/glsl_parser_extras.h
index 66ed2fa64b4..af08bb27170 100644
--- a/src/compiler/glsl/glsl_parser_extras.h
+++ b/src/compiler/glsl/glsl_parser_extras.h
@@ -21,7 +21,6 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#pragma once
 #ifndef GLSL_PARSER_EXTRAS_H
 #define GLSL_PARSER_EXTRAS_H
 
diff --git a/src/compiler/glsl/glsl_symbol_table.h b/src/compiler/glsl/glsl_symbol_table.h
index be910b4170c..c8ab690eb51 100644
--- a/src/compiler/glsl/glsl_symbol_table.h
+++ b/src/compiler/glsl/glsl_symbol_table.h
@@ -22,7 +22,6 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#pragma once
 #ifndef GLSL_SYMBOL_TABLE
 #define GLSL_SYMBOL_TABLE
 
diff --git a/src/compiler/glsl/glsl_to_nir.h b/src/compiler/glsl/glsl_to_nir.h
index c63382ea92d..8e38e0e1c9c 100644
--- a/src/compiler/glsl/glsl_to_nir.h
+++ b/src/compiler/glsl/glsl_to_nir.h
@@ -25,6 +25,9 @@
  *
  */
 
+#ifndef GLSL_TO_NIR_H
+#define GLSL_TO_NIR_H
+
 #include "compiler/nir/nir.h"
 
 #ifdef __cplusplus
@@ -40,3 +43,5 @@ nir_shader *glsl_to_nir(const struct gl_shader_program *shader_prog,
 #ifdef __cplusplus
 }
 #endif
+
+#endif /* GLSL_TO_NIR_H */
diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h
index 3544161105e..d7a81c5196d 100644
--- a/src/compiler/glsl/ir.h
+++ b/src/compiler/glsl/ir.h
@@ -22,7 +22,6 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#pragma once
 #ifndef IR_H
 #define IR_H
 
diff --git a/src/compiler/glsl/ir_array_refcount.h b/src/compiler/glsl/ir_array_refcount.h
index 46ba36cbaa0..ef3fbaa368d 100644
--- a/src/compiler/glsl/ir_array_refcount.h
+++ b/src/compiler/glsl/ir_array_refcount.h
@@ -27,6 +27,9 @@
  * Provides a visitor which produces a list of variables referenced.
  */
 
+#ifndef GLSL_IR_ARRAY_REFCOUNT_H
+#define GLSL_IR_ARRAY_REFCOUNT_H
+
 #include "ir.h"
 #include "ir_visitor.h"
 #include "compiler/glsl_types.h"
@@ -181,3 +184,5 @@ private:
    unsigned derefs_size;
    /*@}*/
 };
+
+#endif /* GLSL_IR_ARRAY_REFCOUNT_H */
diff --git a/src/compiler/glsl/ir_basic_block.h b/src/compiler/glsl/ir_basic_block.h
index dbd678b5c4f..3d32e4e110d 100644
--- a/src/compiler/glsl/ir_basic_block.h
+++ b/src/compiler/glsl/ir_basic_block.h
@@ -21,8 +21,13 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
+#ifndef GLSL_IR_BASIC_BLOCK_H
+#define GLSL_IR_BASIC_BLOCK_H
+
 void call_for_basic_blocks(exec_list *instructions,
 			   void (*callback)(ir_instruction *first,
 					    ir_instruction *last,
 					    void *data),
 			   void *data);
+
+#endif /* GLSL_IR_BASIC_BLOCK_H */
diff --git a/src/compiler/glsl/ir_builder_print_visitor.h b/src/compiler/glsl/ir_builder_print_visitor.h
index a2deab234f6..bd540151df1 100644
--- a/src/compiler/glsl/ir_builder_print_visitor.h
+++ b/src/compiler/glsl/ir_builder_print_visitor.h
@@ -22,7 +22,6 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#pragma once
 #ifndef IR_BUILDER_PRINT_VISITOR_H
 #define IR_BUILDER_PRINT_VISITOR_H
 
diff --git a/src/compiler/glsl/ir_expression_flattening.h b/src/compiler/glsl/ir_expression_flattening.h
index 2eda1590001..e75bdfd8420 100644
--- a/src/compiler/glsl/ir_expression_flattening.h
+++ b/src/compiler/glsl/ir_expression_flattening.h
@@ -34,5 +34,10 @@
  * instruction stream.
  */
 
+#ifndef GLSL_IR_EXPRESSION_FLATTENING_H
+#define GLSL_IR_EXPRESSION_FLATTENING_H
+
 void do_expression_flattening(exec_list *instructions,
 			      bool (*predicate)(ir_instruction *ir));
+
+#endif /* GLSL_IR_EXPRESSION_FLATTENING_H */
diff --git a/src/compiler/glsl/ir_function_inlining.h b/src/compiler/glsl/ir_function_inlining.h
index 6db011bbcae..2af33fac668 100644
--- a/src/compiler/glsl/ir_function_inlining.h
+++ b/src/compiler/glsl/ir_function_inlining.h
@@ -27,4 +27,9 @@
  * Replaces calls to functions with the body of the function.
  */
 
+#ifndef GLSL_IR_FUNCTION_INLINING_H
+#define GLSL_IR_FUNCTION_INLINING_H
+
 bool can_inline(ir_call *call);
+
+#endif /* GLSL_IR_FUNCTION_INLINING_H */
diff --git a/src/compiler/glsl/ir_hierarchical_visitor.h b/src/compiler/glsl/ir_hierarchical_visitor.h
index 28517b6e4f4..824b05e73d8 100644
--- a/src/compiler/glsl/ir_hierarchical_visitor.h
+++ b/src/compiler/glsl/ir_hierarchical_visitor.h
@@ -22,7 +22,6 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#pragma once
 #ifndef IR_HIERARCHICAL_VISITOR_H
 #define IR_HIERARCHICAL_VISITOR_H
 
diff --git a/src/compiler/glsl/ir_optimization.h b/src/compiler/glsl/ir_optimization.h
index 67a7514c7db..485e8e01eef 100644
--- a/src/compiler/glsl/ir_optimization.h
+++ b/src/compiler/glsl/ir_optimization.h
@@ -21,13 +21,15 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-
 /**
  * \file ir_optimization.h
  *
  * Prototypes for optimization passes to be called by the compiler and drivers.
  */
 
+#ifndef GLSL_IR_OPTIMIZATION_H
+#define GLSL_IR_OPTIMIZATION_H
+
 /* Operations for lower_instructions() */
 #define SUB_TO_ADD_NEG     0x01
 #define FDIV_TO_MUL_RCP    0x02
@@ -173,3 +175,5 @@ compare_index_block(exec_list *instructions, ir_variable *index,
 
 bool lower_64bit_integer_instructions(exec_list *instructions,
                                       unsigned what_to_lower);
+
+#endif /* GLSL_IR_OPTIMIZATION_H */
diff --git a/src/compiler/glsl/ir_print_visitor.h b/src/compiler/glsl/ir_print_visitor.h
index 858fe97b4f2..652cd90bc00 100644
--- a/src/compiler/glsl/ir_print_visitor.h
+++ b/src/compiler/glsl/ir_print_visitor.h
@@ -22,7 +22,6 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#pragma once
 #ifndef IR_PRINT_VISITOR_H
 #define IR_PRINT_VISITOR_H
 
diff --git a/src/compiler/glsl/ir_reader.h b/src/compiler/glsl/ir_reader.h
index aef2ca23bd2..89b0392a6c6 100644
--- a/src/compiler/glsl/ir_reader.h
+++ b/src/compiler/glsl/ir_reader.h
@@ -22,7 +22,6 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#pragma once
 #ifndef IR_READER_H
 #define IR_READER_H
 
diff --git a/src/compiler/glsl/ir_rvalue_visitor.h b/src/compiler/glsl/ir_rvalue_visitor.h
index 185c72a5ba1..73d1885a25e 100644
--- a/src/compiler/glsl/ir_rvalue_visitor.h
+++ b/src/compiler/glsl/ir_rvalue_visitor.h
@@ -30,6 +30,9 @@
  * a pointer to each rvalue in the tree.
  */
 
+#ifndef GLSL_IR_RVALUE_VISITOR_H
+#define GLSL_IR_RVALUE_VISITOR_H
+
 class ir_rvalue_base_visitor : public ir_hierarchical_visitor {
 public:
    ir_visitor_status rvalue_visit(ir_assignment *);
@@ -81,3 +84,5 @@ public:
    virtual ir_visitor_status visit_enter(ir_emit_vertex *);
    virtual ir_visitor_status visit_enter(ir_end_primitive *);
 };
+
+#endif /* GLSL_IR_RVALUE_VISITOR_H */
diff --git a/src/compiler/glsl/ir_uniform.h b/src/compiler/glsl/ir_uniform.h
index e72e7b42c57..b6aec7fc4af 100644
--- a/src/compiler/glsl/ir_uniform.h
+++ b/src/compiler/glsl/ir_uniform.h
@@ -21,7 +21,6 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#pragma once
 #ifndef IR_UNIFORM_H
 #define IR_UNIFORM_H
 
diff --git a/src/compiler/glsl/ir_variable_refcount.h b/src/compiler/glsl/ir_variable_refcount.h
index 0a8eec7a269..4a90f08c91f 100644
--- a/src/compiler/glsl/ir_variable_refcount.h
+++ b/src/compiler/glsl/ir_variable_refcount.h
@@ -29,6 +29,9 @@
  * were defined in the scope.
  */
 
+#ifndef GLSL_IR_VARIABLE_REFCOUNT_H
+#define GLSL_IR_VARIABLE_REFCOUNT_H
+
 #include "ir.h"
 #include "ir_visitor.h"
 #include "compiler/glsl_types.h"
@@ -84,3 +87,5 @@ public:
 
    void *mem_ctx;
 };
+
+#endif /* GLSL_IR_VARIABLE_REFCOUNT_H */
diff --git a/src/compiler/glsl/ir_visitor.h b/src/compiler/glsl/ir_visitor.h
index 7c38481cd53..117b5bc6ae8 100644
--- a/src/compiler/glsl/ir_visitor.h
+++ b/src/compiler/glsl/ir_visitor.h
@@ -22,7 +22,6 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#pragma once
 #ifndef IR_VISITOR_H
 #define IR_VISITOR_H
 
diff --git a/src/compiler/glsl/link_uniform_block_active_visitor.h b/src/compiler/glsl/link_uniform_block_active_visitor.h
index afb52c14a37..fbac65d5b67 100644
--- a/src/compiler/glsl/link_uniform_block_active_visitor.h
+++ b/src/compiler/glsl/link_uniform_block_active_visitor.h
@@ -21,7 +21,6 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#pragma once
 #ifndef LINK_UNIFORM_BLOCK_ACTIVE_VISITOR_H
 #define LINK_UNIFORM_BLOCK_ACTIVE_VISITOR_H
 
diff --git a/src/compiler/glsl/link_varyings.h b/src/compiler/glsl/link_varyings.h
index 6793c3e967c..4e1f6d2e42a 100644
--- a/src/compiler/glsl/link_varyings.h
+++ b/src/compiler/glsl/link_varyings.h
@@ -21,7 +21,6 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#pragma once
 #ifndef GLSL_LINK_VARYINGS_H
 #define GLSL_LINK_VARYINGS_H
 
diff --git a/src/compiler/glsl/linker.h b/src/compiler/glsl/linker.h
index abcfdb15971..d06f419cf6e 100644
--- a/src/compiler/glsl/linker.h
+++ b/src/compiler/glsl/linker.h
@@ -22,7 +22,6 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#pragma once
 #ifndef GLSL_LINKER_H
 #define GLSL_LINKER_H
 
diff --git a/src/compiler/glsl/list.h b/src/compiler/glsl/list.h
index 47f53b865b3..f77fe12991c 100644
--- a/src/compiler/glsl/list.h
+++ b/src/compiler/glsl/list.h
@@ -40,7 +40,6 @@
  * exec_list or any structure in which an \c exec_list is embedded.
  */
 
-#pragma once
 #ifndef LIST_CONTAINER_H
 #define LIST_CONTAINER_H
 
diff --git a/src/compiler/glsl/loop_analysis.h b/src/compiler/glsl/loop_analysis.h
index 727a91c2723..2894c6359be 100644
--- a/src/compiler/glsl/loop_analysis.h
+++ b/src/compiler/glsl/loop_analysis.h
@@ -22,7 +22,6 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#pragma once
 #ifndef LOOP_ANALYSIS_H
 #define LOOP_ANALYSIS_H
 
diff --git a/src/compiler/glsl/lower_buffer_access.h b/src/compiler/glsl/lower_buffer_access.h
index a2e3e7d8284..cb186f0dcf6 100644
--- a/src/compiler/glsl/lower_buffer_access.h
+++ b/src/compiler/glsl/lower_buffer_access.h
@@ -31,7 +31,6 @@
  * shared variables.
  */
 
-#pragma once
 #ifndef LOWER_BUFFER_ACCESS_H
 #define LOWER_BUFFER_ACCESS_H
 
diff --git a/src/compiler/glsl/program.h b/src/compiler/glsl/program.h
index 58a7069d479..480379b10b8 100644
--- a/src/compiler/glsl/program.h
+++ b/src/compiler/glsl/program.h
@@ -22,6 +22,8 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
+#ifndef GLSL_PROGRAM_H
+#define GLSL_PROGRAM_H
 
 #ifdef __cplusplus
 extern "C" {
@@ -57,3 +59,5 @@ linker_warning(struct gl_shader_program *prog, const char *fmt, ...)
 extern long
 parse_program_resource_name(const GLchar *name,
                             const GLchar **out_base_name_end);
+
+#endif /* GLSL_PROGRAM_H */
diff --git a/src/compiler/glsl/s_expression.h b/src/compiler/glsl/s_expression.h
index f0dffb1b2f8..5456b6bab21 100644
--- a/src/compiler/glsl/s_expression.h
+++ b/src/compiler/glsl/s_expression.h
@@ -22,7 +22,6 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#pragma once
 #ifndef S_EXPRESSION_H
 #define S_EXPRESSION_H
 
diff --git a/src/compiler/glsl/shader_cache.h b/src/compiler/glsl/shader_cache.h
index 8bd0a3ce282..c0598f37e80 100644
--- a/src/compiler/glsl/shader_cache.h
+++ b/src/compiler/glsl/shader_cache.h
@@ -21,7 +21,6 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#pragma once
 #ifndef SHADER_CACHE
 #define SHADER_CACHE
 
diff --git a/src/compiler/glsl/standalone_scaffolding.h b/src/compiler/glsl/standalone_scaffolding.h
index 5d179191fbf..7532d0836f7 100644
--- a/src/compiler/glsl/standalone_scaffolding.h
+++ b/src/compiler/glsl/standalone_scaffolding.h
@@ -27,7 +27,6 @@
  * compiling builtins).
  */
 
-#pragma once
 #ifndef STANDALONE_SCAFFOLDING_H
 #define STANDALONE_SCAFFOLDING_H
 
diff --git a/src/compiler/glsl/test_optpass.h b/src/compiler/glsl/test_optpass.h
index 923ccf3dece..477a8f21133 100644
--- a/src/compiler/glsl/test_optpass.h
+++ b/src/compiler/glsl/test_optpass.h
@@ -21,7 +21,6 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#pragma once
 #ifndef TEST_OPTPASS_H
 #define TEST_OPTPASS_H
 
diff --git a/src/compiler/glsl/tests/uniform_initializer_utils.h b/src/compiler/glsl/tests/uniform_initializer_utils.h
index b4d0c10220f..f65254cdc88 100644
--- a/src/compiler/glsl/tests/uniform_initializer_utils.h
+++ b/src/compiler/glsl/tests/uniform_initializer_utils.h
@@ -21,7 +21,8 @@
  * DEALINGS IN THE SOFTWARE.
  */
 
-#pragma once
+#ifndef GLSL_UNIFORM_INITIALIZER_UTILS_H
+#define GLSL_UNIFORM_INITIALIZER_UTILS_H
 
 #include "program/prog_parameter.h"
 #include "ir.h"
@@ -46,3 +47,5 @@ extern void
 verify_data(gl_constant_value *storage, unsigned storage_array_size,
             ir_constant *val, unsigned red_zone_size,
             unsigned int boolean_true);
+
+#endif /* GLSL_UNIFORM_INITIALIZER_UTILS_H */
-- 
2.11.1



More information about the mesa-dev mailing list