diff mbox

[40/90] assembler: Make sure nobody adds a field back to struct brw_instruction

Message ID 1359991705-5254-41-git-send-email-damien.lespiau@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Lespiau, Damien Feb. 4, 2013, 3:27 p.m. UTC
Adding something there will break the library, so we might as check for
it.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
---
 assembler/gen4asm.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/assembler/gen4asm.h b/assembler/gen4asm.h
index aeb2b9c..388cc75 100644
--- a/assembler/gen4asm.h
+++ b/assembler/gen4asm.h
@@ -55,6 +55,15 @@  extern long int gen_level;
 
 void yyerror (char *msg);
 
+#define STRUCT_SIZE_ASSERT(TYPE, SIZE) \
+typedef struct { \
+          char compile_time_assert_ ## TYPE ## _size[ \
+              (sizeof (struct TYPE) == (SIZE)) ? 1 : -1]; \
+        } _ ## TYPE ## SizeCheck
+
+/* ensure nobody changes the size of struct brw_instruction */
+STRUCT_SIZE_ASSERT(brw_instruction, 16);
+
 /**
  * This structure is the internal representation of directly-addressed
  * registers in the parser.