From c74c80c9a5d2d84c55ba373d2d56ada635467ee6 Mon Sep 17 00:00:00 2001 From: Damien Lespiau Date: Mon, 21 Jan 2013 22:12:10 +0000 Subject: assembler: Make sure nobody adds a field back to struct brw_instruction Adding something there will break the library, so we might as check for it. Signed-off-by: Damien Lespiau --- assembler/gen4asm.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'assembler/gen4asm.h') diff --git a/assembler/gen4asm.h b/assembler/gen4asm.h index aeb2b9cc..388cc756 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. -- cgit v1.2.3