Adds patch files for 64 bit safety fixes

TRAC #23274

Authored-by: Shannon Woods
Signed-off-by: Jamie Madill
Signed-off-by: Nicolas Capens
diff --git a/src/compiler/64bit-lexer-safety.patch b/src/compiler/64bit-lexer-safety.patch
new file mode 100644
index 0000000..7af91f5
--- /dev/null
+++ b/src/compiler/64bit-lexer-safety.patch
@@ -0,0 +1,177 @@
+--- a/src/compiler/glslang_lex.cpp
++++ b/src/compiler/glslang_lex.cpp
+@@ -68,6 +68,7 @@ typedef int16_t flex_int16_t;
+ typedef uint16_t flex_uint16_t;
+ typedef int32_t flex_int32_t;
+ typedef uint32_t flex_uint32_t;
++typedef uint64_t flex_uint64_t;
+ #else
+ typedef signed char flex_int8_t;
+ typedef short int flex_int16_t;
+@@ -191,6 +192,11 @@ typedef void* yyscan_t;
+ typedef struct yy_buffer_state *YY_BUFFER_STATE;
+ #endif
+ 
++#ifndef YY_TYPEDEF_YY_SIZE_T
++#define YY_TYPEDEF_YY_SIZE_T
++typedef size_t yy_size_t;
++#endif
++
+ #define EOB_ACT_CONTINUE_SCAN 0
+ #define EOB_ACT_END_OF_FILE 1
+ #define EOB_ACT_LAST_MATCH 2
+@@ -204,7 +210,7 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
+      */
+     #define  YY_LESS_LINENO(n) \
+             do { \
+-                int yyl;\
++                yy_size_t yyl;\
+                 for ( yyl = n; yyl < yyleng; ++yyl )\
+                     if ( yytext[yyl] == '\n' )\
+                         --yylineno;\
+@@ -226,11 +232,6 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
+ 
+ #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
+ 
+-#ifndef YY_TYPEDEF_YY_SIZE_T
+-#define YY_TYPEDEF_YY_SIZE_T
+-typedef size_t yy_size_t;
+-#endif
+-
+ #ifndef YY_STRUCT_YY_BUFFER_STATE
+ #define YY_STRUCT_YY_BUFFER_STATE
+ struct yy_buffer_state
+@@ -248,7 +249,7 @@ struct yy_buffer_state
+ 	/* Number of characters read into yy_ch_buf, not including EOB
+ 	 * characters.
+ 	 */
+-	int yy_n_chars;
++	yy_size_t yy_n_chars;
+ 
+ 	/* Whether we "own" the buffer - i.e., we know we created it,
+ 	 * and can realloc() it to grow it, and should free() it to
+@@ -327,7 +328,7 @@ static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
+ 
+ YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
+ YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
+-YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
++YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner );
+ 
+ void *yyalloc (yy_size_t ,yyscan_t yyscanner );
+ void *yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
+@@ -378,7 +379,7 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
+  */
+ #define YY_DO_BEFORE_ACTION \
+ 	yyg->yytext_ptr = yy_bp; \
+-	yyleng = (size_t) (yy_cp - yy_bp); \
++	yyleng = (yy_size_t) (yy_cp - yy_bp); \
+ 	yyg->yy_hold_char = *yy_cp; \
+ 	*yy_cp = '\0'; \
+ 	yyg->yy_c_buf_p = yy_cp;
+@@ -1035,8 +1036,8 @@ struct yyguts_t
+     size_t yy_buffer_stack_max; /**< capacity of stack. */
+     YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
+     char yy_hold_char;
+-    int yy_n_chars;
+-    int yyleng_r;
++    yy_size_t yy_n_chars;
++    yy_size_t yyleng_r;
+     char *yy_c_buf_p;
+     int yy_init;
+     int yy_start;
+@@ -1089,7 +1090,7 @@ FILE *yyget_out (yyscan_t yyscanner );
+ 
+ void yyset_out  (FILE * out_str ,yyscan_t yyscanner );
+ 
+-int yyget_leng (yyscan_t yyscanner );
++yy_size_t yyget_leng (yyscan_t yyscanner );
+ 
+ char *yyget_text (yyscan_t yyscanner );
+ 
+@@ -1158,7 +1159,7 @@ static int input (yyscan_t yyscanner );
+ 	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
+ 		{ \
+ 		int c = '*'; \
+-		int n; \
++		yy_size_t n; \
+ 		for ( n = 0; n < max_size && \
+ 			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
+ 			buf[n] = (char) c; \
+@@ -1317,7 +1318,7 @@ yy_find_action:
+ 
+ 		if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
+ 			{
+-			int yyl;
++			yy_size_t yyl;
+ 			for ( yyl = 0; yyl < yyleng; ++yyl )
+ 				if ( yytext[yyl] == '\n' )
+ 					   
+@@ -2203,7 +2204,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
+ 
+ 	else
+ 		{
+-			int num_to_read =
++			yy_size_t num_to_read =
+ 			YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
+ 
+ 		while ( num_to_read <= 0 )
+@@ -2217,7 +2218,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
+ 
+ 			if ( b->yy_is_our_buffer )
+ 				{
+-				int new_size = b->yy_buf_size * 2;
++				yy_size_t new_size = b->yy_buf_size * 2;
+ 
+ 				if ( new_size <= 0 )
+ 					b->yy_buf_size += b->yy_buf_size / 8;
+@@ -2248,7 +2249,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
+ 
+ 		/* Read in more data. */
+ 		YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
+-			yyg->yy_n_chars, (size_t) num_to_read );
++			yyg->yy_n_chars, num_to_read );
+ 
+ 		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
+ 		}
+@@ -2373,7 +2374,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
+ 
+ 		else
+ 			{ /* need more input */
+-			int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
++			yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
+ 			++yyg->yy_c_buf_p;
+ 
+ 			switch ( yy_get_next_buffer( yyscanner ) )
+@@ -2660,7 +2661,7 @@ void yypop_buffer_state (yyscan_t yyscanner)
+  */
+ static void yyensure_buffer_stack (yyscan_t yyscanner)
+ {
+-	int num_to_alloc;
++	yy_size_t num_to_alloc;
+     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ 
+ 	if (!yyg->yy_buffer_stack) {
+@@ -2758,12 +2759,11 @@ YY_BUFFER_STATE yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)
+  * @param yyscanner The scanner object.
+  * @return the newly allocated buffer state object.
+  */
+-YY_BUFFER_STATE yy_scan_bytes  (yyconst char * yybytes, int  _yybytes_len , yyscan_t yyscanner)
++YY_BUFFER_STATE yy_scan_bytes  (yyconst char * yybytes, yy_size_t  _yybytes_len , yyscan_t yyscanner)
+ {
+ 	YY_BUFFER_STATE b;
+ 	char *buf;
+-	yy_size_t n;
+-	int i;
++	yy_size_t n, i;
+     
+ 	/* Get memory for full buffer, including space for trailing EOB's. */
+ 	n = _yybytes_len + 2;
+@@ -2913,7 +2913,7 @@ FILE *yyget_out  (yyscan_t yyscanner)
+ /** Get the length of the current token.
+  * @param yyscanner The scanner object.
+  */
+-int yyget_leng  (yyscan_t yyscanner)
++yy_size_t yyget_leng  (yyscan_t yyscanner)
+ {
+     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+     return yyleng;
diff --git a/src/compiler/preprocessor/64bit-tokenizer-safety.patch b/src/compiler/preprocessor/64bit-tokenizer-safety.patch
new file mode 100644
index 0000000..7cb0616
--- /dev/null
+++ b/src/compiler/preprocessor/64bit-tokenizer-safety.patch
@@ -0,0 +1,159 @@
+--- a/src/compiler/preprocessor/Tokenizer.cpp
++++ b/src/compiler/preprocessor/Tokenizer.cpp
+@@ -56,6 +56,7 @@ typedef int16_t flex_int16_t;
+ typedef uint16_t flex_uint16_t;
+ typedef int32_t flex_int32_t;
+ typedef uint32_t flex_uint32_t;
++typedef uint64_t flex_uint64_t;
+ #else
+ typedef signed char flex_int8_t;
+ typedef short int flex_int16_t;
+@@ -179,6 +180,11 @@ typedef void* yyscan_t;
+ typedef struct yy_buffer_state *YY_BUFFER_STATE;
+ #endif
+ 
++#ifndef YY_TYPEDEF_YY_SIZE_T
++#define YY_TYPEDEF_YY_SIZE_T
++typedef size_t yy_size_t;
++#endif
++
+ #define EOB_ACT_CONTINUE_SCAN 0
+ #define EOB_ACT_END_OF_FILE 1
+ #define EOB_ACT_LAST_MATCH 2
+@@ -201,11 +207,6 @@ typedef struct yy_buffer_state *YY_BUFFER_STATE;
+ 
+ #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
+ 
+-#ifndef YY_TYPEDEF_YY_SIZE_T
+-#define YY_TYPEDEF_YY_SIZE_T
+-typedef size_t yy_size_t;
+-#endif
+-
+ #ifndef YY_STRUCT_YY_BUFFER_STATE
+ #define YY_STRUCT_YY_BUFFER_STATE
+ struct yy_buffer_state
+@@ -223,7 +224,7 @@ struct yy_buffer_state
+ 	/* Number of characters read into yy_ch_buf, not including EOB
+ 	 * characters.
+ 	 */
+-	int yy_n_chars;
++	yy_size_t yy_n_chars;
+ 
+ 	/* Whether we "own" the buffer - i.e., we know we created it,
+ 	 * and can realloc() it to grow it, and should free() it to
+@@ -302,7 +303,7 @@ static void pp_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
+ 
+ YY_BUFFER_STATE pp_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
+ YY_BUFFER_STATE pp_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
+-YY_BUFFER_STATE pp_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
++YY_BUFFER_STATE pp_scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner );
+ 
+ void *ppalloc (yy_size_t ,yyscan_t yyscanner );
+ void *pprealloc (void *,yy_size_t ,yyscan_t yyscanner );
+@@ -353,7 +354,7 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
+  */
+ #define YY_DO_BEFORE_ACTION \
+ 	yyg->yytext_ptr = yy_bp; \
+-	yyleng = (size_t) (yy_cp - yy_bp); \
++	yyleng = (yy_size_t) (yy_cp - yy_bp); \
+ 	yyg->yy_hold_char = *yy_cp; \
+ 	*yy_cp = '\0'; \
+ 	yyg->yy_c_buf_p = yy_cp;
+@@ -579,8 +580,8 @@ struct yyguts_t
+     size_t yy_buffer_stack_max; /**< capacity of stack. */
+     YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
+     char yy_hold_char;
+-    int yy_n_chars;
+-    int yyleng_r;
++    yy_size_t yy_n_chars;
++    yy_size_t yyleng_r;
+     char *yy_c_buf_p;
+     int yy_init;
+     int yy_start;
+@@ -637,7 +638,7 @@ FILE *ppget_out (yyscan_t yyscanner );
+ 
+ void ppset_out  (FILE * out_str ,yyscan_t yyscanner );
+ 
+-int ppget_leng (yyscan_t yyscanner );
++yy_size_t ppget_leng (yyscan_t yyscanner );
+ 
+ char *ppget_text (yyscan_t yyscanner );
+ 
+@@ -704,7 +705,7 @@ static int input (yyscan_t yyscanner );
+ 	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
+ 		{ \
+ 		int c = '*'; \
+-		int n; \
++		yy_size_t n; \
+ 		for ( n = 0; n < max_size && \
+ 			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
+ 			buf[n] = (char) c; \
+@@ -1338,7 +1339,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
+ 
+ 	else
+ 		{
+-			int num_to_read =
++			yy_size_t num_to_read =
+ 			YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
+ 
+ 		while ( num_to_read <= 0 )
+@@ -1352,7 +1353,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
+ 
+ 			if ( b->yy_is_our_buffer )
+ 				{
+-				int new_size = b->yy_buf_size * 2;
++				yy_size_t new_size = b->yy_buf_size * 2;
+ 
+ 				if ( new_size <= 0 )
+ 					b->yy_buf_size += b->yy_buf_size / 8;
+@@ -1383,7 +1384,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
+ 
+ 		/* Read in more data. */
+ 		YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
+-			yyg->yy_n_chars, (size_t) num_to_read );
++			yyg->yy_n_chars, num_to_read );
+ 
+ 		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
+ 		}
+@@ -1508,7 +1509,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
+ 
+ 		else
+ 			{ /* need more input */
+-			int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
++			yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
+ 			++yyg->yy_c_buf_p;
+ 
+ 			switch ( yy_get_next_buffer( yyscanner ) )
+@@ -1788,7 +1789,7 @@ void pppop_buffer_state (yyscan_t yyscanner)
+  */
+ static void ppensure_buffer_stack (yyscan_t yyscanner)
+ {
+-	int num_to_alloc;
++	yy_size_t num_to_alloc;
+     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+ 
+ 	if (!yyg->yy_buffer_stack) {
+@@ -1886,12 +1887,11 @@ YY_BUFFER_STATE pp_scan_string (yyconst char * yystr , yyscan_t yyscanner)
+  * @param yyscanner The scanner object.
+  * @return the newly allocated buffer state object.
+  */
+-YY_BUFFER_STATE pp_scan_bytes  (yyconst char * yybytes, int  _yybytes_len , yyscan_t yyscanner)
++YY_BUFFER_STATE pp_scan_bytes  (yyconst char * yybytes, yy_size_t  _yybytes_len , yyscan_t yyscanner)
+ {
+ 	YY_BUFFER_STATE b;
+ 	char *buf;
+-	yy_size_t n;
+-	int i;
++	yy_size_t n, i;
+     
+ 	/* Get memory for full buffer, including space for trailing EOB's. */
+ 	n = _yybytes_len + 2;
+@@ -2001,7 +2001,7 @@ FILE *ppget_out  (yyscan_t yyscanner)
+ /** Get the length of the current token.
+  * @param yyscanner The scanner object.
+  */
+-int ppget_leng  (yyscan_t yyscanner)
++yy_size_t ppget_leng  (yyscan_t yyscanner)
+ {
+     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
+     return yyleng;