1diff -c -r Mesa-7.9/include/GL/gl.h MesaLib/include/GL/gl.h
2*** Mesa-7.9/include/GL/gl.h	Tue Apr 27 14:41:21 2010
3--- MesaLib/include/GL/gl.h	Thu Oct 14 14:41:53 2010
4***************
5*** 55,61 ****
6  #  if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */
7  #    define GLAPI __declspec(dllexport)
8  #  elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
9! #    define GLAPI __declspec(dllimport)
10  #  else /* for use with static link lib build of Win32 edition only */
11  #    define GLAPI extern
12  #  endif /* _STATIC_MESA support */
13--- 55,65 ----
14  #  if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */
15  #    define GLAPI __declspec(dllexport)
16  #  elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
17! // We always retrieve the entry points dynamically via GetProcAddress or
18! // OSMesaGetProcAddress. This works around an issue where using the MSVC
19! // multi-threaded runtime library, which defines _DLL.
20! //#    define GLAPI __declspec(dllimport)
21! #    define GLAPI
22  #  else /* for use with static link lib build of Win32 edition only */
23  #    define GLAPI extern
24  #  endif /* _STATIC_MESA support */
25***************
26*** 72,80 ****
27  #  define GLAPIENTRY
28  #endif /* WIN32 && !CYGWIN */
29  
30! #if (defined(__BEOS__) && defined(__POWERPC__)) || defined(__QUICKDRAW__)
31! #  define PRAGMA_EXPORT_SUPPORTED		1
32! #endif
33  
34  /*
35   * WINDOWS: Include windows.h here to define APIENTRY.
36--- 76,86 ----
37  #  define GLAPIENTRY
38  #endif /* WIN32 && !CYGWIN */
39  
40! // Disabled this because __QUICKDRAW__ is defined on Mac and gcc does not
41! // support the pragma.
42! //#if (defined(__BEOS__) && defined(__POWERPC__)) || defined(__QUICKDRAW__)
43! //#  define PRAGMA_EXPORT_SUPPORTED		1
44! //#endif
45  
46  /*
47   * WINDOWS: Include windows.h here to define APIENTRY.
48diff -c -r Mesa-7.9/include/GL/glext.h MesaLib/include/GL/glext.h
49*** Mesa-7.9/include/GL/glext.h	Fri Oct  1 15:51:28 2010
50--- MesaLib/include/GL/glext.h	Thu Oct 14 14:50:37 2010
51***************
52*** 5030,5043 ****
53  
54  #ifndef GL_VERSION_1_5
55  /* GL types for handling large vertex buffer objects */
56! typedef ptrdiff_t GLintptr;
57! typedef ptrdiff_t GLsizeiptr;
58  #endif
59  
60  #ifndef GL_ARB_vertex_buffer_object
61  /* GL types for handling large vertex buffer objects */
62! typedef ptrdiff_t GLintptrARB;
63! typedef ptrdiff_t GLsizeiptrARB;
64  #endif
65  
66  #ifndef GL_ARB_shader_objects
67--- 5030,5043 ----
68  
69  #ifndef GL_VERSION_1_5
70  /* GL types for handling large vertex buffer objects */
71! typedef signed long int GLintptr;
72! typedef signed long int GLsizeiptr;
73  #endif
74  
75  #ifndef GL_ARB_vertex_buffer_object
76  /* GL types for handling large vertex buffer objects */
77! typedef signed long int GLintptrARB;
78! typedef signed long int GLsizeiptrARB;
79  #endif
80  
81  #ifndef GL_ARB_shader_objects
82diff -c -r Mesa-7.9/include/GL/osmesa.h MesaLib/include/GL/osmesa.h
83*** Mesa-7.9/include/GL/osmesa.h	Thu Feb  4 16:10:39 2010
84--- MesaLib/include/GL/osmesa.h	Thu Oct 14 14:47:08 2010
85***************
86*** 101,109 ****
87  typedef struct osmesa_context *OSMesaContext;
88  
89  
90! #if defined(__BEOS__) || defined(__QUICKDRAW__)
91! #pragma export on
92! #endif
93  
94  
95  /*
96--- 101,111 ----
97  typedef struct osmesa_context *OSMesaContext;
98  
99  
100! // Disabled this because __QUICKDRAW__ is defined on Mac and gcc does not
101! // support the pragma.
102! //#if defined(__BEOS__) || defined(__QUICKDRAW__)
103! //#pragma export on
104! //#endif
105  
106  
107  /*
108***************
109*** 276,284 ****
110  OSMesaColorClamp(GLboolean enable);
111  
112  
113! #if defined(__BEOS__) || defined(__QUICKDRAW__)
114! #pragma export off
115! #endif
116  
117  
118  #ifdef __cplusplus
119--- 278,288 ----
120  OSMesaColorClamp(GLboolean enable);
121  
122  
123! // Disabled this because __QUICKDRAW__ is defined on Mac and gcc does not
124! // support the pragma.
125! //#if defined(__BEOS__) || defined(__QUICKDRAW__)
126! //#pragma export off
127! //#endif
128  
129  
130  #ifdef __cplusplus
131diff -c -r Mesa-7.9/src/glsl/ast_to_hir.cpp MesaLib/src/glsl/ast_to_hir.cpp
132*** Mesa-7.9/src/glsl/ast_to_hir.cpp	Fri Oct  1 15:51:28 2010
133--- MesaLib/src/glsl/ast_to_hir.cpp	Fri Oct 22 15:28:47 2010
134***************
135*** 55,60 ****
136--- 55,61 ----
137  #include "ast.h"
138  #include "glsl_types.h"
139  #include "ir.h"
140+ #include "safe_strcmp.h"
141  
142  void
143  _mesa_ast_to_hir(exec_list *instructions, struct _mesa_glsl_parse_state *state)
144***************
145*** 1615,1621 ****
146     var->pixel_center_integer = qual->pixel_center_integer;
147     var->origin_upper_left = qual->origin_upper_left;
148     if ((qual->origin_upper_left || qual->pixel_center_integer)
149!        && (strcmp(var->name, "gl_FragCoord") != 0)) {
150        const char *const qual_string = (qual->origin_upper_left)
151  	 ? "origin_upper_left" : "pixel_center_integer";
152  
153--- 1616,1622 ----
154     var->pixel_center_integer = qual->pixel_center_integer;
155     var->origin_upper_left = qual->origin_upper_left;
156     if ((qual->origin_upper_left || qual->pixel_center_integer)
157!        && (safe_strcmp(var->name, "gl_FragCoord") != 0)) {
158        const char *const qual_string = (qual->origin_upper_left)
159  	 ? "origin_upper_left" : "pixel_center_integer";
160  
161***************
162*** 2003,2009 ****
163  	     *     gl_MaxTextureCoords."
164  	     */
165  	    const unsigned size = unsigned(var->type->array_size());
166! 	    if ((strcmp("gl_TexCoord", var->name) == 0)
167  		&& (size > state->Const.MaxTextureCoords)) {
168  	       YYLTYPE loc = this->get_location();
169  
170--- 2004,2010 ----
171  	     *     gl_MaxTextureCoords."
172  	     */
173  	    const unsigned size = unsigned(var->type->array_size());
174! 	    if ((safe_strcmp("gl_TexCoord", var->name) == 0)
175  		&& (size > state->Const.MaxTextureCoords)) {
176  	       YYLTYPE loc = this->get_location();
177  
178***************
179*** 2022,2028 ****
180  	    delete var;
181  	    var = NULL;
182  	 } else if (state->extensions->ARB_fragment_coord_conventions
183! 		    && strcmp(var->name, "gl_FragCoord") == 0
184  		    && earlier->type == var->type
185  		    && earlier->mode == var->mode) {
186  	    /* Allow redeclaration of gl_FragCoord for ARB_fcc layout
187--- 2023,2029 ----
188  	    delete var;
189  	    var = NULL;
190  	 } else if (state->extensions->ARB_fragment_coord_conventions
191! 		    && safe_strcmp(var->name, "gl_FragCoord") == 0
192  		    && earlier->type == var->type
193  		    && earlier->mode == var->mode) {
194  	    /* Allow redeclaration of gl_FragCoord for ARB_fcc layout
195***************
196*** 2336,2342 ****
197     }
198  
199     /* Verify the return type of main() */
200!    if (strcmp(name, "main") == 0) {
201        if (! return_type->is_void()) {
202  	 YYLTYPE loc = this->get_location();
203  
204--- 2337,2343 ----
205     }
206  
207     /* Verify the return type of main() */
208!    if (safe_strcmp(name, "main") == 0) {
209        if (! return_type->is_void()) {
210  	 YYLTYPE loc = this->get_location();
211  
212diff -c -r Mesa-7.9/src/glsl/glcpp/glcpp-parse.c MesaLib/src/glsl/glcpp/glcpp-parse.c
213*** Mesa-7.9/src/glsl/glcpp/glcpp-parse.c	Fri Oct  1 15:51:28 2010
214--- MesaLib/src/glsl/glcpp/glcpp-parse.c	Fri Oct 22 15:30:59 2010
215***************
216*** 96,106 ****
217--- 96,114 ----
218  #include <stdlib.h>
219  #include <string.h>
220  #include <assert.h>
221+ /* The #include of inttypes.h causes problems on Windows */
222+ #ifndef _MSC_VER
223  #include <inttypes.h>
224+ #endif
225+ /* Windows headers do not define PRIiMAX */
226+ #ifdef _MSC_VER
227+ #define PRIiMAX "I64i"
228+ #endif
229  
230  #include "glcpp.h"
231  #include "main/core.h" /* for struct gl_extensions */
232  #include "main/mtypes.h" /* for gl_api enum */
233+ #include "safe_strcmp.h"
234  
235  #define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str)
236  #define glcpp_printf(stream, fmt, args, ...) \
237***************
238*** 2915,2921 ****
239  		return 0;
240  
241  	for (i = 0, node = list->head; node; i++, node = node->next) {
242! 		if (strcmp (node->str, member) == 0) {
243  			if (index)
244  				*index = i;
245  			return 1;
246--- 2923,2929 ----
247  		return 0;
248  
249  	for (i = 0, node = list->head; node; i++, node = node->next) {
250! 		if (safe_strcmp (node->str, member) == 0) {
251  			if (index)
252  				*index = i;
253  			return 1;
254***************
255*** 2955,2961 ****
256  	     node_a && node_b;
257  	     node_a = node_a->next, node_b = node_b->next)
258  	{
259! 		if (strcmp (node_a->str, node_b->str))
260  			return 0;
261  	}
262  
263--- 2963,2969 ----
264  	     node_a && node_b;
265  	     node_a = node_a->next, node_b = node_b->next)
266  	{
267! 		if (safe_strcmp (node_a->str, node_b->str))
268  			return 0;
269  	}
270  
271***************
272*** 3182,3189 ****
273  		case IDENTIFIER:
274  		case INTEGER_STRING:
275  		case OTHER:
276! 			if (strcmp (node_a->token->value.str,
277! 				    node_b->token->value.str))
278  			{
279  				return 0;
280  			}
281--- 3190,3197 ----
282  		case IDENTIFIER:
283  		case INTEGER_STRING:
284  		case OTHER:
285! 			if (safe_strcmp (node_a->token->value.str,
286! 					 node_b->token->value.str))
287  			{
288  				return 0;
289  			}
290***************
291*** 3832,3838 ****
292  		return 0;
293  
294  	for (node = list; node; node = node->next)
295! 		if (strcmp (node->identifier, identifier) == 0)
296  			return 1;
297  
298  	return 0;
299--- 3840,3846 ----
300  		return 0;
301  
302  	for (node = list; node; node = node->next)
303! 		if (safe_strcmp (node->identifier, identifier) == 0)
304  			return 1;
305  
306  	return 0;
307diff -c -r Mesa-7.9/src/glsl/glcpp/glcpp-parse.y MesaLib/src/glsl/glcpp/glcpp-parse.y
308*** Mesa-7.9/src/glsl/glcpp/glcpp-parse.y	Fri Oct  1 15:51:28 2010
309--- MesaLib/src/glsl/glcpp/glcpp-parse.y	Fri Oct 22 15:30:47 2010
310***************
311*** 26,36 ****
312--- 26,44 ----
313  #include <stdlib.h>
314  #include <string.h>
315  #include <assert.h>
316+ /* The #include of inttypes.h causes problems on Windows */
317+ #ifndef _MSC_VER
318  #include <inttypes.h>
319+ #endif
320+ /* Windows headers do not define PRIiMAX */
321+ #ifdef _MSC_VER
322+ #define PRIiMAX "I64i"
323+ #endif
324  
325  #include "glcpp.h"
326  #include "main/core.h" /* for struct gl_extensions */
327  #include "main/mtypes.h" /* for gl_api enum */
328+ #include "safe_strcmp.h"
329  
330  #define glcpp_print(stream, str) stream = talloc_strdup_append(stream, str)
331  #define glcpp_printf(stream, fmt, args, ...) \
332***************
333*** 590,596 ****
334  		return 0;
335  
336  	for (i = 0, node = list->head; node; i++, node = node->next) {
337! 		if (strcmp (node->str, member) == 0) {
338  			if (index)
339  				*index = i;
340  			return 1;
341--- 598,604 ----
342  		return 0;
343  
344  	for (i = 0, node = list->head; node; i++, node = node->next) {
345! 		if (safe_strcmp (node->str, member) == 0) {
346  			if (index)
347  				*index = i;
348  			return 1;
349***************
350*** 630,636 ****
351  	     node_a && node_b;
352  	     node_a = node_a->next, node_b = node_b->next)
353  	{
354! 		if (strcmp (node_a->str, node_b->str))
355  			return 0;
356  	}
357  
358--- 638,644 ----
359  	     node_a && node_b;
360  	     node_a = node_a->next, node_b = node_b->next)
361  	{
362! 		if (safe_strcmp (node_a->str, node_b->str))
363  			return 0;
364  	}
365  
366***************
367*** 857,864 ****
368  		case IDENTIFIER:
369  		case INTEGER_STRING:
370  		case OTHER:
371! 			if (strcmp (node_a->token->value.str,
372! 				    node_b->token->value.str))
373  			{
374  				return 0;
375  			}
376--- 865,872 ----
377  		case IDENTIFIER:
378  		case INTEGER_STRING:
379  		case OTHER:
380! 			if (safe_strcmp (node_a->token->value.str,
381! 					 node_b->token->value.str))
382  			{
383  				return 0;
384  			}
385***************
386*** 1507,1513 ****
387  		return 0;
388  
389  	for (node = list; node; node = node->next)
390! 		if (strcmp (node->identifier, identifier) == 0)
391  			return 1;
392  
393  	return 0;
394--- 1515,1521 ----
395  		return 0;
396  
397  	for (node = list; node; node = node->next)
398! 		if (safe_strcmp (node->identifier, identifier) == 0)
399  			return 1;
400  
401  	return 0;
402diff -c -r Mesa-7.9/src/glsl/glcpp/glcpp.c MesaLib/src/glsl/glcpp/glcpp.c
403*** Mesa-7.9/src/glsl/glcpp/glcpp.c	Fri Oct  1 15:51:28 2010
404--- MesaLib/src/glsl/glcpp/glcpp.c	Fri Oct 22 15:31:25 2010
405***************
406*** 29,34 ****
407--- 29,35 ----
408  #include <errno.h>
409  #include "glcpp.h"
410  #include "main/mtypes.h"
411+ #include "safe_strcmp.h"
412  
413  extern int yydebug;
414  
415***************
416*** 78,84 ****
417  	char *text;
418  	int fd;
419  
420! 	if (filename == NULL || strcmp (filename, "-") == 0)
421  		return load_text_fd (ctx, STDIN_FILENO);
422  
423  	fd = open (filename, O_RDONLY);
424--- 79,85 ----
425  	char *text;
426  	int fd;
427  
428! 	if (filename == NULL || safe_strcmp (filename, "-") == 0)
429  		return load_text_fd (ctx, STDIN_FILENO);
430  
431  	fd = open (filename, O_RDONLY);
432diff -c -r Mesa-7.9/src/glsl/glcpp/glcpp.h MesaLib/src/glsl/glcpp/glcpp.h
433*** Mesa-7.9/src/glsl/glcpp/glcpp.h	Fri Oct  1 15:51:28 2010
434--- MesaLib/src/glsl/glcpp/glcpp.h	Fri Oct 22 15:32:43 2010
435***************
436*** 24,30 ****
437--- 24,33 ----
438  #ifndef GLCPP_H
439  #define GLCPP_H
440  
441+ /* Windows does not currently have stdint.h. */
442+ #ifndef _MSC_VER
443  #include <stdint.h>
444+ #endif
445  
446  #include <talloc.h>
447  
448***************
449*** 49,55 ****
450--- 52,62 ----
451  
452  typedef union YYSTYPE
453  {
454+ #ifndef _MSC_VER
455  	intmax_t ival;
456+ #else
457+         __int64 ival;
458+ #endif
459  	char *str;
460  	string_list_t *string_list;
461  	token_t *token;
462diff -c -r Mesa-7.9/src/glsl/glsl_parser.cpp MesaLib/src/glsl/glsl_parser.cpp
463*** Mesa-7.9/src/glsl/glsl_parser.cpp	Fri Oct  1 15:51:28 2010
464--- MesaLib/src/glsl/glsl_parser.cpp	Fri Oct 22 15:33:24 2010
465***************
466*** 107,112 ****
467--- 107,113 ----
468  #include "ast.h"
469  #include "glsl_parser_extras.h"
470  #include "glsl_types.h"
471+ #include "safe_strcmp.h"
472  
473  #define YYLEX_PARAM state->scanner
474  
475***************
476*** 3966,3975 ****
477  	   if (state->ARB_fragment_coord_conventions_enable) {
478  	      bool got_one = false;
479  
480! 	      if (strcmp((yyvsp[(1) - (1)].identifier), "origin_upper_left") == 0) {
481  		 got_one = true;
482  		 (yyval.type_qualifier).q.origin_upper_left = 1;
483! 	      } else if (strcmp((yyvsp[(1) - (1)].identifier), "pixel_center_integer") == 0) {
484  		 got_one = true;
485  		 (yyval.type_qualifier).q.pixel_center_integer = 1;
486  	      }
487--- 3967,3976 ----
488  	   if (state->ARB_fragment_coord_conventions_enable) {
489  	      bool got_one = false;
490  
491! 	      if (safe_strcmp((yyvsp[(1) - (1)].identifier), "origin_upper_left") == 0) {
492  		 got_one = true;
493  		 (yyval.type_qualifier).q.origin_upper_left = 1;
494! 	      } else if (safe_strcmp((yyvsp[(1) - (1)].identifier), "pixel_center_integer") == 0) {
495  		 got_one = true;
496  		 (yyval.type_qualifier).q.pixel_center_integer = 1;
497  	      }
498diff -c -r Mesa-7.9/src/glsl/glsl_parser_extras.cpp MesaLib/src/glsl/glsl_parser_extras.cpp
499*** Mesa-7.9/src/glsl/glsl_parser_extras.cpp	Fri Oct  1 15:51:28 2010
500--- MesaLib/src/glsl/glsl_parser_extras.cpp	Fri Oct 22 15:33:37 2010
501***************
502*** 35,40 ****
503--- 35,41 ----
504  #include "glsl_parser.h"
505  #include "ir_optimization.h"
506  #include "loop_analysis.h"
507+ #include "safe_strcmp.h"
508  
509  _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct __GLcontextRec *ctx,
510  					       GLenum target, void *mem_ctx)
511***************
512*** 148,160 ****
513        extension_warn
514     } ext_mode;
515  
516!    if (strcmp(behavior, "warn") == 0) {
517        ext_mode = extension_warn;
518!    } else if (strcmp(behavior, "require") == 0) {
519        ext_mode = extension_require;
520!    } else if (strcmp(behavior, "enable") == 0) {
521        ext_mode = extension_enable;
522!    } else if (strcmp(behavior, "disable") == 0) {
523        ext_mode = extension_disable;
524     } else {
525        _mesa_glsl_error(behavior_locp, state,
526--- 149,161 ----
527        extension_warn
528     } ext_mode;
529  
530!    if (safe_strcmp(behavior, "warn") == 0) {
531        ext_mode = extension_warn;
532!    } else if (safe_strcmp(behavior, "require") == 0) {
533        ext_mode = extension_require;
534!    } else if (safe_strcmp(behavior, "enable") == 0) {
535        ext_mode = extension_enable;
536!    } else if (safe_strcmp(behavior, "disable") == 0) {
537        ext_mode = extension_disable;
538     } else {
539        _mesa_glsl_error(behavior_locp, state,
540***************
541*** 165,178 ****
542  
543     bool unsupported = false;
544  
545!    if (strcmp(name, "all") == 0) {
546        if ((ext_mode == extension_enable) || (ext_mode == extension_require)) {
547  	 _mesa_glsl_error(name_locp, state, "Cannot %s all extensions",
548  			  (ext_mode == extension_enable)
549  			  ? "enable" : "require");
550  	 return false;
551        }
552!    } else if (strcmp(name, "GL_ARB_draw_buffers") == 0) {
553        /* This extension is only supported in fragment shaders.
554         */
555        if (state->target != fragment_shader) {
556--- 166,179 ----
557  
558     bool unsupported = false;
559  
560!    if (safe_strcmp(name, "all") == 0) {
561        if ((ext_mode == extension_enable) || (ext_mode == extension_require)) {
562  	 _mesa_glsl_error(name_locp, state, "Cannot %s all extensions",
563  			  (ext_mode == extension_enable)
564  			  ? "enable" : "require");
565  	 return false;
566        }
567!    } else if (safe_strcmp(name, "GL_ARB_draw_buffers") == 0) {
568        /* This extension is only supported in fragment shaders.
569         */
570        if (state->target != fragment_shader) {
571***************
572*** 181,197 ****
573  	 state->ARB_draw_buffers_enable = (ext_mode != extension_disable);
574  	 state->ARB_draw_buffers_warn = (ext_mode == extension_warn);
575        }
576!    } else if (strcmp(name, "GL_ARB_fragment_coord_conventions") == 0) {
577        state->ARB_fragment_coord_conventions_enable =
578  	 (ext_mode != extension_disable);
579        state->ARB_fragment_coord_conventions_warn =
580  	 (ext_mode == extension_warn);
581  
582        unsupported = !state->extensions->ARB_fragment_coord_conventions;
583!    } else if (strcmp(name, "GL_ARB_texture_rectangle") == 0) {
584        state->ARB_texture_rectangle_enable = (ext_mode != extension_disable);
585        state->ARB_texture_rectangle_warn = (ext_mode == extension_warn);
586!    } else if (strcmp(name, "GL_EXT_texture_array") == 0) {
587        state->EXT_texture_array_enable = (ext_mode != extension_disable);
588        state->EXT_texture_array_warn = (ext_mode == extension_warn);
589  
590--- 182,198 ----
591  	 state->ARB_draw_buffers_enable = (ext_mode != extension_disable);
592  	 state->ARB_draw_buffers_warn = (ext_mode == extension_warn);
593        }
594!    } else if (safe_strcmp(name, "GL_ARB_fragment_coord_conventions") == 0) {
595        state->ARB_fragment_coord_conventions_enable =
596  	 (ext_mode != extension_disable);
597        state->ARB_fragment_coord_conventions_warn =
598  	 (ext_mode == extension_warn);
599  
600        unsupported = !state->extensions->ARB_fragment_coord_conventions;
601!    } else if (safe_strcmp(name, "GL_ARB_texture_rectangle") == 0) {
602        state->ARB_texture_rectangle_enable = (ext_mode != extension_disable);
603        state->ARB_texture_rectangle_warn = (ext_mode == extension_warn);
604!    } else if (safe_strcmp(name, "GL_EXT_texture_array") == 0) {
605        state->EXT_texture_array_enable = (ext_mode != extension_disable);
606        state->EXT_texture_array_warn = (ext_mode == extension_warn);
607  
608diff -c -r Mesa-7.9/src/glsl/glsl_types.cpp MesaLib/src/glsl/glsl_types.cpp
609*** Mesa-7.9/src/glsl/glsl_types.cpp	Fri Oct  1 15:51:28 2010
610--- MesaLib/src/glsl/glsl_types.cpp	Fri Oct 22 15:33:51 2010
611***************
612*** 27,32 ****
613--- 27,33 ----
614  #include "glsl_symbol_table.h"
615  #include "glsl_parser_extras.h"
616  #include "glsl_types.h"
617+ #include "safe_strcmp.h"
618  #include "builtin_types.h"
619  extern "C" {
620  #include "program/hash_table.h"
621***************
622*** 374,380 ****
623     /* Return zero is the types match (there is zero difference) or non-zero
624      * otherwise.
625      */
626!    if (strcmp(key1->name, key2->name) != 0)
627        return 1;
628  
629     if (key1->length != key2->length)
630--- 375,381 ----
631     /* Return zero is the types match (there is zero difference) or non-zero
632      * otherwise.
633      */
634!    if (safe_strcmp(key1->name, key2->name) != 0)
635        return 1;
636  
637     if (key1->length != key2->length)
638***************
639*** 383,389 ****
640     for (unsigned i = 0; i < key1->length; i++) {
641        if (key1->fields.structure[i].type != key2->fields.structure[i].type)
642  	 return 1;
643!       if (strcmp(key1->fields.structure[i].name,
644  		 key2->fields.structure[i].name) != 0)
645  	 return 1;
646     }
647--- 384,390 ----
648     for (unsigned i = 0; i < key1->length; i++) {
649        if (key1->fields.structure[i].type != key2->fields.structure[i].type)
650  	 return 1;
651!       if (safe_strcmp(key1->fields.structure[i].name,
652  		 key2->fields.structure[i].name) != 0)
653  	 return 1;
654     }
655***************
656*** 433,439 ****
657  
658     assert(t->base_type == GLSL_TYPE_STRUCT);
659     assert(t->length == num_fields);
660!    assert(strcmp(t->name, name) == 0);
661  
662     return t;
663  }
664--- 434,440 ----
665  
666     assert(t->base_type == GLSL_TYPE_STRUCT);
667     assert(t->length == num_fields);
668!    assert(safe_strcmp(t->name, name) == 0);
669  
670     return t;
671  }
672***************
673*** 446,452 ****
674        return error_type;
675  
676     for (unsigned i = 0; i < this->length; i++) {
677!       if (strcmp(name, this->fields.structure[i].name) == 0)
678  	 return this->fields.structure[i].type;
679     }
680  
681--- 447,453 ----
682        return error_type;
683  
684     for (unsigned i = 0; i < this->length; i++) {
685!       if (safe_strcmp(name, this->fields.structure[i].name) == 0)
686  	 return this->fields.structure[i].type;
687     }
688  
689***************
690*** 461,467 ****
691        return -1;
692  
693     for (unsigned i = 0; i < this->length; i++) {
694!       if (strcmp(name, this->fields.structure[i].name) == 0)
695  	 return i;
696     }
697  
698--- 462,468 ----
699        return -1;
700  
701     for (unsigned i = 0; i < this->length; i++) {
702!       if (safe_strcmp(name, this->fields.structure[i].name) == 0)
703  	 return i;
704     }
705  
706diff -c -r Mesa-7.9/src/glsl/hir_field_selection.cpp MesaLib/src/glsl/hir_field_selection.cpp
707*** Mesa-7.9/src/glsl/hir_field_selection.cpp	Fri Oct  1 15:51:28 2010
708--- MesaLib/src/glsl/hir_field_selection.cpp	Fri Oct 22 15:34:11 2010
709***************
710*** 26,31 ****
711--- 26,32 ----
712  #include "glsl_parser_extras.h"
713  #include "ast.h"
714  #include "glsl_types.h"
715+ #include "safe_strcmp.h"
716  
717  ir_rvalue *
718  _mesa_ast_field_selection_to_hir(const ast_expression *expr,
719***************
720*** 81,87 ****
721        const char *method;
722        method = call->subexpressions[0]->primary_expression.identifier;
723  
724!       if (op->type->is_array() && strcmp(method, "length") == 0) {
725  	 if (!call->expressions.is_empty())
726  	    _mesa_glsl_error(&loc, state, "length method takes no arguments.");
727  
728--- 82,88 ----
729        const char *method;
730        method = call->subexpressions[0]->primary_expression.identifier;
731  
732!       if (op->type->is_array() && safe_strcmp(method, "length") == 0) {
733  	 if (!call->expressions.is_empty())
734  	    _mesa_glsl_error(&loc, state, "length method takes no arguments.");
735  
736diff -c -r Mesa-7.9/src/glsl/ir.cpp MesaLib/src/glsl/ir.cpp
737*** Mesa-7.9/src/glsl/ir.cpp	Fri Oct  1 15:51:28 2010
738--- MesaLib/src/glsl/ir.cpp	Fri Oct 22 15:34:20 2010
739***************
740*** 25,30 ****
741--- 25,31 ----
742  #include "ir.h"
743  #include "ir_visitor.h"
744  #include "glsl_types.h"
745+ #include "safe_strcmp.h"
746  
747  ir_rvalue::ir_rvalue()
748  {
749***************
750*** 338,344 ****
751  {
752     const int operator_count = sizeof(operator_strs) / sizeof(operator_strs[0]);
753     for (int op = 0; op < operator_count; op++) {
754!       if (strcmp(str, operator_strs[op]) == 0)
755  	 return (ir_expression_operation) op;
756     }
757     return (ir_expression_operation) -1;
758--- 339,345 ----
759  {
760     const int operator_count = sizeof(operator_strs) / sizeof(operator_strs[0]);
761     for (int op = 0; op < operator_count; op++) {
762!       if (safe_strcmp(str, operator_strs[op]) == 0)
763  	 return (ir_expression_operation) op;
764     }
765     return (ir_expression_operation) -1;
766***************
767*** 878,884 ****
768  {
769     const int count = sizeof(tex_opcode_strs) / sizeof(tex_opcode_strs[0]);
770     for (int op = 0; op < count; op++) {
771!       if (strcmp(str, tex_opcode_strs[op]) == 0)
772  	 return (ir_texture_opcode) op;
773     }
774     return (ir_texture_opcode) -1;
775--- 879,885 ----
776  {
777     const int count = sizeof(tex_opcode_strs) / sizeof(tex_opcode_strs[0]);
778     for (int op = 0; op < count; op++) {
779!       if (safe_strcmp(str, tex_opcode_strs[op]) == 0)
780  	 return (ir_texture_opcode) op;
781     }
782     return (ir_texture_opcode) -1;
783diff -c -r Mesa-7.9/src/glsl/ir_constant_expression.cpp MesaLib/src/glsl/ir_constant_expression.cpp
784*** Mesa-7.9/src/glsl/ir_constant_expression.cpp	Fri Oct  1 15:51:28 2010
785--- MesaLib/src/glsl/ir_constant_expression.cpp	Fri Oct 22 15:34:40 2010
786***************
787*** 38,43 ****
788--- 38,44 ----
789  #include "ir.h"
790  #include "ir_visitor.h"
791  #include "glsl_types.h"
792+ #include "safe_strcmp.h"
793  
794  static float
795  dot(ir_constant *op0, ir_constant *op1)
796***************
797*** 850,880 ****
798     memset(&data, 0, sizeof(data));
799  
800     const char *callee = this->callee_name();
801!    if (strcmp(callee, "abs") == 0) {
802        expr = new(mem_ctx) ir_expression(ir_unop_abs, type, op[0], NULL);
803!    } else if (strcmp(callee, "all") == 0) {
804        assert(op[0]->type->is_boolean());
805        for (unsigned c = 0; c < op[0]->type->components(); c++) {
806  	 if (!op[0]->value.b[c])
807  	    return new(mem_ctx) ir_constant(false);
808        }
809        return new(mem_ctx) ir_constant(true);
810!    } else if (strcmp(callee, "any") == 0) {
811        assert(op[0]->type->is_boolean());
812        for (unsigned c = 0; c < op[0]->type->components(); c++) {
813  	 if (op[0]->value.b[c])
814  	    return new(mem_ctx) ir_constant(true);
815        }
816        return new(mem_ctx) ir_constant(false);
817!    } else if (strcmp(callee, "acos") == 0) {
818        assert(op[0]->type->is_float());
819        for (unsigned c = 0; c < op[0]->type->components(); c++)
820  	 data.f[c] = acosf(op[0]->value.f[c]);
821!    } else if (strcmp(callee, "asin") == 0) {
822        assert(op[0]->type->is_float());
823        for (unsigned c = 0; c < op[0]->type->components(); c++)
824  	 data.f[c] = asinf(op[0]->value.f[c]);
825!    } else if (strcmp(callee, "atan") == 0) {
826        assert(op[0]->type->is_float());
827        if (num_parameters == 2) {
828  	 assert(op[1]->type->is_float());
829--- 851,881 ----
830     memset(&data, 0, sizeof(data));
831  
832     const char *callee = this->callee_name();
833!    if (safe_strcmp(callee, "abs") == 0) {
834        expr = new(mem_ctx) ir_expression(ir_unop_abs, type, op[0], NULL);
835!    } else if (safe_strcmp(callee, "all") == 0) {
836        assert(op[0]->type->is_boolean());
837        for (unsigned c = 0; c < op[0]->type->components(); c++) {
838  	 if (!op[0]->value.b[c])
839  	    return new(mem_ctx) ir_constant(false);
840        }
841        return new(mem_ctx) ir_constant(true);
842!    } else if (safe_strcmp(callee, "any") == 0) {
843        assert(op[0]->type->is_boolean());
844        for (unsigned c = 0; c < op[0]->type->components(); c++) {
845  	 if (op[0]->value.b[c])
846  	    return new(mem_ctx) ir_constant(true);
847        }
848        return new(mem_ctx) ir_constant(false);
849!    } else if (safe_strcmp(callee, "acos") == 0) {
850        assert(op[0]->type->is_float());
851        for (unsigned c = 0; c < op[0]->type->components(); c++)
852  	 data.f[c] = acosf(op[0]->value.f[c]);
853!    } else if (safe_strcmp(callee, "asin") == 0) {
854        assert(op[0]->type->is_float());
855        for (unsigned c = 0; c < op[0]->type->components(); c++)
856  	 data.f[c] = asinf(op[0]->value.f[c]);
857!    } else if (safe_strcmp(callee, "atan") == 0) {
858        assert(op[0]->type->is_float());
859        if (num_parameters == 2) {
860  	 assert(op[1]->type->is_float());
861***************
862*** 884,894 ****
863  	 for (unsigned c = 0; c < op[0]->type->components(); c++)
864  	    data.f[c] = atanf(op[0]->value.f[c]);
865        }
866!    } else if (strcmp(callee, "dFdx") == 0 || strcmp(callee, "dFdy") == 0) {
867        return ir_constant::zero(mem_ctx, this->type);
868!    } else if (strcmp(callee, "ceil") == 0) {
869        expr = new(mem_ctx) ir_expression(ir_unop_ceil, type, op[0], NULL);
870!    } else if (strcmp(callee, "clamp") == 0) {
871        assert(num_parameters == 3);
872        unsigned c1_inc = op[1]->type->is_scalar() ? 0 : 1;
873        unsigned c2_inc = op[2]->type->is_scalar() ? 0 : 1;
874--- 885,895 ----
875  	 for (unsigned c = 0; c < op[0]->type->components(); c++)
876  	    data.f[c] = atanf(op[0]->value.f[c]);
877        }
878!    } else if (safe_strcmp(callee, "dFdx") == 0 || safe_strcmp(callee, "dFdy") == 0) {
879        return ir_constant::zero(mem_ctx, this->type);
880!    } else if (safe_strcmp(callee, "ceil") == 0) {
881        expr = new(mem_ctx) ir_expression(ir_unop_ceil, type, op[0], NULL);
882!    } else if (safe_strcmp(callee, "clamp") == 0) {
883        assert(num_parameters == 3);
884        unsigned c1_inc = op[1]->type->is_scalar() ? 0 : 1;
885        unsigned c2_inc = op[2]->type->is_scalar() ? 0 : 1;
886***************
887*** 913,931 ****
888  	    assert(!"Should not get here.");
889  	 }
890        }
891!    } else if (strcmp(callee, "cos") == 0) {
892        expr = new(mem_ctx) ir_expression(ir_unop_cos, type, op[0], NULL);
893!    } else if (strcmp(callee, "cosh") == 0) {
894        assert(op[0]->type->is_float());
895        for (unsigned c = 0; c < op[0]->type->components(); c++)
896  	 data.f[c] = coshf(op[0]->value.f[c]);
897!    } else if (strcmp(callee, "cross") == 0) {
898        expr = new(mem_ctx) ir_expression(ir_binop_cross, type, op[0], op[1]);
899!    } else if (strcmp(callee, "degrees") == 0) {
900        assert(op[0]->type->is_float());
901        for (unsigned c = 0; c < op[0]->type->components(); c++)
902  	 data.f[c] = 180.0/M_PI * op[0]->value.f[c];
903!    } else if (strcmp(callee, "distance") == 0) {
904        assert(op[0]->type->is_float() && op[1]->type->is_float());
905        float length_squared = 0.0;
906        for (unsigned c = 0; c < op[0]->type->components(); c++) {
907--- 914,932 ----
908  	    assert(!"Should not get here.");
909  	 }
910        }
911!    } else if (safe_strcmp(callee, "cos") == 0) {
912        expr = new(mem_ctx) ir_expression(ir_unop_cos, type, op[0], NULL);
913!    } else if (safe_strcmp(callee, "cosh") == 0) {
914        assert(op[0]->type->is_float());
915        for (unsigned c = 0; c < op[0]->type->components(); c++)
916  	 data.f[c] = coshf(op[0]->value.f[c]);
917!    } else if (safe_strcmp(callee, "cross") == 0) {
918        expr = new(mem_ctx) ir_expression(ir_binop_cross, type, op[0], op[1]);
919!    } else if (safe_strcmp(callee, "degrees") == 0) {
920        assert(op[0]->type->is_float());
921        for (unsigned c = 0; c < op[0]->type->components(); c++)
922  	 data.f[c] = 180.0/M_PI * op[0]->value.f[c];
923!    } else if (safe_strcmp(callee, "distance") == 0) {
924        assert(op[0]->type->is_float() && op[1]->type->is_float());
925        float length_squared = 0.0;
926        for (unsigned c = 0; c < op[0]->type->components(); c++) {
927***************
928*** 933,941 ****
929  	 length_squared += t * t;
930        }
931        return new(mem_ctx) ir_constant(sqrtf(length_squared));
932!    } else if (strcmp(callee, "dot") == 0) {
933        return new(mem_ctx) ir_constant(dot(op[0], op[1]));
934!    } else if (strcmp(callee, "equal") == 0) {
935        assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
936        for (unsigned c = 0; c < op[0]->type->components(); c++) {
937  	 switch (op[0]->type->base_type) {
938--- 934,942 ----
939  	 length_squared += t * t;
940        }
941        return new(mem_ctx) ir_constant(sqrtf(length_squared));
942!    } else if (safe_strcmp(callee, "dot") == 0) {
943        return new(mem_ctx) ir_constant(dot(op[0], op[1]));
944!    } else if (safe_strcmp(callee, "equal") == 0) {
945        assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
946        for (unsigned c = 0; c < op[0]->type->components(); c++) {
947  	 switch (op[0]->type->base_type) {
948***************
949*** 955,976 ****
950  	    assert(!"Should not get here.");
951  	 }
952        }
953!    } else if (strcmp(callee, "exp") == 0) {
954        expr = new(mem_ctx) ir_expression(ir_unop_exp, type, op[0], NULL);
955!    } else if (strcmp(callee, "exp2") == 0) {
956        expr = new(mem_ctx) ir_expression(ir_unop_exp2, type, op[0], NULL);
957!    } else if (strcmp(callee, "faceforward") == 0) {
958        if (dot(op[2], op[1]) < 0)
959  	 return op[0];
960        for (unsigned c = 0; c < op[0]->type->components(); c++)
961  	 data.f[c] = -op[0]->value.f[c];
962!    } else if (strcmp(callee, "floor") == 0) {
963        expr = new(mem_ctx) ir_expression(ir_unop_floor, type, op[0], NULL);
964!    } else if (strcmp(callee, "fract") == 0) {
965        expr = new(mem_ctx) ir_expression(ir_unop_fract, type, op[0], NULL);
966!    } else if (strcmp(callee, "fwidth") == 0) {
967        return ir_constant::zero(mem_ctx, this->type);
968!    } else if (strcmp(callee, "greaterThan") == 0) {
969        assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
970        for (unsigned c = 0; c < op[0]->type->components(); c++) {
971  	 switch (op[0]->type->base_type) {
972--- 956,977 ----
973  	    assert(!"Should not get here.");
974  	 }
975        }
976!    } else if (safe_strcmp(callee, "exp") == 0) {
977        expr = new(mem_ctx) ir_expression(ir_unop_exp, type, op[0], NULL);
978!    } else if (safe_strcmp(callee, "exp2") == 0) {
979        expr = new(mem_ctx) ir_expression(ir_unop_exp2, type, op[0], NULL);
980!    } else if (safe_strcmp(callee, "faceforward") == 0) {
981        if (dot(op[2], op[1]) < 0)
982  	 return op[0];
983        for (unsigned c = 0; c < op[0]->type->components(); c++)
984  	 data.f[c] = -op[0]->value.f[c];
985!    } else if (safe_strcmp(callee, "floor") == 0) {
986        expr = new(mem_ctx) ir_expression(ir_unop_floor, type, op[0], NULL);
987!    } else if (safe_strcmp(callee, "fract") == 0) {
988        expr = new(mem_ctx) ir_expression(ir_unop_fract, type, op[0], NULL);
989!    } else if (safe_strcmp(callee, "fwidth") == 0) {
990        return ir_constant::zero(mem_ctx, this->type);
991!    } else if (safe_strcmp(callee, "greaterThan") == 0) {
992        assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
993        for (unsigned c = 0; c < op[0]->type->components(); c++) {
994  	 switch (op[0]->type->base_type) {
995***************
996*** 987,993 ****
997  	    assert(!"Should not get here.");
998  	 }
999        }
1000!    } else if (strcmp(callee, "greaterThanEqual") == 0) {
1001        assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
1002        for (unsigned c = 0; c < op[0]->type->components(); c++) {
1003  	 switch (op[0]->type->base_type) {
1004--- 988,994 ----
1005  	    assert(!"Should not get here.");
1006  	 }
1007        }
1008!    } else if (safe_strcmp(callee, "greaterThanEqual") == 0) {
1009        assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
1010        for (unsigned c = 0; c < op[0]->type->components(); c++) {
1011  	 switch (op[0]->type->base_type) {
1012***************
1013*** 1004,1014 ****
1014  	    assert(!"Should not get here.");
1015  	 }
1016        }
1017!    } else if (strcmp(callee, "inversesqrt") == 0) {
1018        expr = new(mem_ctx) ir_expression(ir_unop_rsq, type, op[0], NULL);
1019!    } else if (strcmp(callee, "length") == 0) {
1020        return new(mem_ctx) ir_constant(sqrtf(dot(op[0], op[0])));
1021!    } else if (strcmp(callee, "lessThan") == 0) {
1022        assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
1023        for (unsigned c = 0; c < op[0]->type->components(); c++) {
1024  	 switch (op[0]->type->base_type) {
1025--- 1005,1015 ----
1026  	    assert(!"Should not get here.");
1027  	 }
1028        }
1029!    } else if (safe_strcmp(callee, "inversesqrt") == 0) {
1030        expr = new(mem_ctx) ir_expression(ir_unop_rsq, type, op[0], NULL);
1031!    } else if (safe_strcmp(callee, "length") == 0) {
1032        return new(mem_ctx) ir_constant(sqrtf(dot(op[0], op[0])));
1033!    } else if (safe_strcmp(callee, "lessThan") == 0) {
1034        assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
1035        for (unsigned c = 0; c < op[0]->type->components(); c++) {
1036  	 switch (op[0]->type->base_type) {
1037***************
1038*** 1025,1031 ****
1039  	    assert(!"Should not get here.");
1040  	 }
1041        }
1042!    } else if (strcmp(callee, "lessThanEqual") == 0) {
1043        assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
1044        for (unsigned c = 0; c < op[0]->type->components(); c++) {
1045  	 switch (op[0]->type->base_type) {
1046--- 1026,1032 ----
1047  	    assert(!"Should not get here.");
1048  	 }
1049        }
1050!    } else if (safe_strcmp(callee, "lessThanEqual") == 0) {
1051        assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
1052        for (unsigned c = 0; c < op[0]->type->components(); c++) {
1053  	 switch (op[0]->type->base_type) {
1054***************
1055*** 1042,1060 ****
1056  	    assert(!"Should not get here.");
1057  	 }
1058        }
1059!    } else if (strcmp(callee, "log") == 0) {
1060        expr = new(mem_ctx) ir_expression(ir_unop_log, type, op[0], NULL);
1061!    } else if (strcmp(callee, "log2") == 0) {
1062        expr = new(mem_ctx) ir_expression(ir_unop_log2, type, op[0], NULL);
1063!    } else if (strcmp(callee, "matrixCompMult") == 0) {
1064        assert(op[0]->type->is_float() && op[1]->type->is_float());
1065        for (unsigned c = 0; c < op[0]->type->components(); c++)
1066  	 data.f[c] = op[0]->value.f[c] * op[1]->value.f[c];
1067!    } else if (strcmp(callee, "max") == 0) {
1068        expr = new(mem_ctx) ir_expression(ir_binop_max, type, op[0], op[1]);
1069!    } else if (strcmp(callee, "min") == 0) {
1070        expr = new(mem_ctx) ir_expression(ir_binop_min, type, op[0], op[1]);
1071!    } else if (strcmp(callee, "mix") == 0) {
1072        assert(op[0]->type->is_float() && op[1]->type->is_float());
1073        if (op[2]->type->is_float()) {
1074  	 unsigned c2_inc = op[2]->type->is_scalar() ? 0 : 1;
1075--- 1043,1061 ----
1076  	    assert(!"Should not get here.");
1077  	 }
1078        }
1079!    } else if (safe_strcmp(callee, "log") == 0) {
1080        expr = new(mem_ctx) ir_expression(ir_unop_log, type, op[0], NULL);
1081!    } else if (safe_strcmp(callee, "log2") == 0) {
1082        expr = new(mem_ctx) ir_expression(ir_unop_log2, type, op[0], NULL);
1083!    } else if (safe_strcmp(callee, "matrixCompMult") == 0) {
1084        assert(op[0]->type->is_float() && op[1]->type->is_float());
1085        for (unsigned c = 0; c < op[0]->type->components(); c++)
1086  	 data.f[c] = op[0]->value.f[c] * op[1]->value.f[c];
1087!    } else if (safe_strcmp(callee, "max") == 0) {
1088        expr = new(mem_ctx) ir_expression(ir_binop_max, type, op[0], op[1]);
1089!    } else if (safe_strcmp(callee, "min") == 0) {
1090        expr = new(mem_ctx) ir_expression(ir_binop_min, type, op[0], op[1]);
1091!    } else if (safe_strcmp(callee, "mix") == 0) {
1092        assert(op[0]->type->is_float() && op[1]->type->is_float());
1093        if (op[2]->type->is_float()) {
1094  	 unsigned c2_inc = op[2]->type->is_scalar() ? 0 : 1;
1095***************
1096*** 1068,1076 ****
1097  	 for (unsigned c = 0; c < op[0]->type->components(); c++)
1098  	    data.f[c] = op[op[2]->value.b[c] ? 1 : 0]->value.f[c];
1099        }
1100!    } else if (strcmp(callee, "mod") == 0) {
1101        expr = new(mem_ctx) ir_expression(ir_binop_mod, type, op[0], op[1]);
1102!    } else if (strcmp(callee, "normalize") == 0) {
1103        assert(op[0]->type->is_float());
1104        float length = sqrtf(dot(op[0], op[0]));
1105  
1106--- 1069,1077 ----
1107  	 for (unsigned c = 0; c < op[0]->type->components(); c++)
1108  	    data.f[c] = op[op[2]->value.b[c] ? 1 : 0]->value.f[c];
1109        }
1110!    } else if (safe_strcmp(callee, "mod") == 0) {
1111        expr = new(mem_ctx) ir_expression(ir_binop_mod, type, op[0], op[1]);
1112!    } else if (safe_strcmp(callee, "normalize") == 0) {
1113        assert(op[0]->type->is_float());
1114        float length = sqrtf(dot(op[0], op[0]));
1115  
1116***************
1117*** 1079,1087 ****
1118  
1119        for (unsigned c = 0; c < op[0]->type->components(); c++)
1120  	 data.f[c] = op[0]->value.f[c] / length;
1121!    } else if (strcmp(callee, "not") == 0) {
1122        expr = new(mem_ctx) ir_expression(ir_unop_logic_not, type, op[0], NULL);
1123!    } else if (strcmp(callee, "notEqual") == 0) {
1124        assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
1125        for (unsigned c = 0; c < op[0]->type->components(); c++) {
1126  	 switch (op[0]->type->base_type) {
1127--- 1080,1088 ----
1128  
1129        for (unsigned c = 0; c < op[0]->type->components(); c++)
1130  	 data.f[c] = op[0]->value.f[c] / length;
1131!    } else if (safe_strcmp(callee, "not") == 0) {
1132        expr = new(mem_ctx) ir_expression(ir_unop_logic_not, type, op[0], NULL);
1133!    } else if (safe_strcmp(callee, "notEqual") == 0) {
1134        assert(op[0]->type->is_vector() && op[1] && op[1]->type->is_vector());
1135        for (unsigned c = 0; c < op[0]->type->components(); c++) {
1136  	 switch (op[0]->type->base_type) {
1137***************
1138*** 1101,1107 ****
1139  	    assert(!"Should not get here.");
1140  	 }
1141        }
1142!    } else if (strcmp(callee, "outerProduct") == 0) {
1143        assert(op[0]->type->is_vector() && op[1]->type->is_vector());
1144        const unsigned m = op[0]->type->vector_elements;
1145        const unsigned n = op[1]->type->vector_elements;
1146--- 1102,1108 ----
1147  	    assert(!"Should not get here.");
1148  	 }
1149        }
1150!    } else if (safe_strcmp(callee, "outerProduct") == 0) {
1151        assert(op[0]->type->is_vector() && op[1]->type->is_vector());
1152        const unsigned m = op[0]->type->vector_elements;
1153        const unsigned n = op[1]->type->vector_elements;
1154***************
1155*** 1110,1127 ****
1156  	    data.f[i+m*j] = op[0]->value.f[i] * op[1]->value.f[j];
1157  	 }
1158        }
1159!    } else if (strcmp(callee, "pow") == 0) {
1160        expr = new(mem_ctx) ir_expression(ir_binop_pow, type, op[0], op[1]);
1161!    } else if (strcmp(callee, "radians") == 0) {
1162        assert(op[0]->type->is_float());
1163        for (unsigned c = 0; c < op[0]->type->components(); c++)
1164  	 data.f[c] = M_PI/180.0 * op[0]->value.f[c];
1165!    } else if (strcmp(callee, "reflect") == 0) {
1166        assert(op[0]->type->is_float());
1167        float dot_NI = dot(op[1], op[0]);
1168        for (unsigned c = 0; c < op[0]->type->components(); c++)
1169  	 data.f[c] = op[0]->value.f[c] - 2 * dot_NI * op[1]->value.f[c];
1170!    } else if (strcmp(callee, "refract") == 0) {
1171        const float eta = op[2]->value.f[0];
1172        const float dot_NI = dot(op[1], op[0]);
1173        const float k = 1.0 - eta * eta * (1.0 - dot_NI * dot_NI);
1174--- 1111,1128 ----
1175  	    data.f[i+m*j] = op[0]->value.f[i] * op[1]->value.f[j];
1176  	 }
1177        }
1178!    } else if (safe_strcmp(callee, "pow") == 0) {
1179        expr = new(mem_ctx) ir_expression(ir_binop_pow, type, op[0], op[1]);
1180!    } else if (safe_strcmp(callee, "radians") == 0) {
1181        assert(op[0]->type->is_float());
1182        for (unsigned c = 0; c < op[0]->type->components(); c++)
1183  	 data.f[c] = M_PI/180.0 * op[0]->value.f[c];
1184!    } else if (safe_strcmp(callee, "reflect") == 0) {
1185        assert(op[0]->type->is_float());
1186        float dot_NI = dot(op[1], op[0]);
1187        for (unsigned c = 0; c < op[0]->type->components(); c++)
1188  	 data.f[c] = op[0]->value.f[c] - 2 * dot_NI * op[1]->value.f[c];
1189!    } else if (safe_strcmp(callee, "refract") == 0) {
1190        const float eta = op[2]->value.f[0];
1191        const float dot_NI = dot(op[1], op[0]);
1192        const float k = 1.0 - eta * eta * (1.0 - dot_NI * dot_NI);
1193***************
1194*** 1133,1147 ****
1195  			    * op[1]->value.f[c];
1196  	 }
1197        }
1198!    } else if (strcmp(callee, "sign") == 0) {
1199        expr = new(mem_ctx) ir_expression(ir_unop_sign, type, op[0], NULL);
1200!    } else if (strcmp(callee, "sin") == 0) {
1201        expr = new(mem_ctx) ir_expression(ir_unop_sin, type, op[0], NULL);
1202!    } else if (strcmp(callee, "sinh") == 0) {
1203        assert(op[0]->type->is_float());
1204        for (unsigned c = 0; c < op[0]->type->components(); c++)
1205  	 data.f[c] = sinhf(op[0]->value.f[c]);
1206!    } else if (strcmp(callee, "smoothstep") == 0) {
1207        assert(num_parameters == 3);
1208        assert(op[1]->type == op[0]->type);
1209        unsigned edge_inc = op[0]->type->is_scalar() ? 0 : 1;
1210--- 1134,1148 ----
1211  			    * op[1]->value.f[c];
1212  	 }
1213        }
1214!    } else if (safe_strcmp(callee, "sign") == 0) {
1215        expr = new(mem_ctx) ir_expression(ir_unop_sign, type, op[0], NULL);
1216!    } else if (safe_strcmp(callee, "sin") == 0) {
1217        expr = new(mem_ctx) ir_expression(ir_unop_sin, type, op[0], NULL);
1218!    } else if (safe_strcmp(callee, "sinh") == 0) {
1219        assert(op[0]->type->is_float());
1220        for (unsigned c = 0; c < op[0]->type->components(); c++)
1221  	 data.f[c] = sinhf(op[0]->value.f[c]);
1222!    } else if (safe_strcmp(callee, "smoothstep") == 0) {
1223        assert(num_parameters == 3);
1224        assert(op[1]->type == op[0]->type);
1225        unsigned edge_inc = op[0]->type->is_scalar() ? 0 : 1;
1226***************
1227*** 1157,1179 ****
1228  	    data.f[c] = t * t * (3 - 2 * t);
1229  	 }
1230        }
1231!    } else if (strcmp(callee, "sqrt") == 0) {
1232        expr = new(mem_ctx) ir_expression(ir_unop_sqrt, type, op[0], NULL);
1233!    } else if (strcmp(callee, "step") == 0) {
1234        assert(op[0]->type->is_float() && op[1]->type->is_float());
1235        /* op[0] (edge) may be either a scalar or a vector */
1236        const unsigned c0_inc = op[0]->type->is_scalar() ? 0 : 1;
1237        for (unsigned c = 0, c0 = 0; c < type->components(); c0 += c0_inc, c++)
1238  	 data.f[c] = (op[1]->value.f[c] < op[0]->value.f[c0]) ? 0.0 : 1.0;
1239!    } else if (strcmp(callee, "tan") == 0) {
1240        assert(op[0]->type->is_float());
1241        for (unsigned c = 0; c < op[0]->type->components(); c++)
1242  	 data.f[c] = tanf(op[0]->value.f[c]);
1243!    } else if (strcmp(callee, "tanh") == 0) {
1244        assert(op[0]->type->is_float());
1245        for (unsigned c = 0; c < op[0]->type->components(); c++)
1246  	 data.f[c] = tanhf(op[0]->value.f[c]);
1247!    } else if (strcmp(callee, "transpose") == 0) {
1248        assert(op[0]->type->is_matrix());
1249        const unsigned n = op[0]->type->vector_elements;
1250        const unsigned m = op[0]->type->matrix_columns;
1251--- 1158,1180 ----
1252  	    data.f[c] = t * t * (3 - 2 * t);
1253  	 }
1254        }
1255!    } else if (safe_strcmp(callee, "sqrt") == 0) {
1256        expr = new(mem_ctx) ir_expression(ir_unop_sqrt, type, op[0], NULL);
1257!    } else if (safe_strcmp(callee, "step") == 0) {
1258        assert(op[0]->type->is_float() && op[1]->type->is_float());
1259        /* op[0] (edge) may be either a scalar or a vector */
1260        const unsigned c0_inc = op[0]->type->is_scalar() ? 0 : 1;
1261        for (unsigned c = 0, c0 = 0; c < type->components(); c0 += c0_inc, c++)
1262  	 data.f[c] = (op[1]->value.f[c] < op[0]->value.f[c0]) ? 0.0 : 1.0;
1263!    } else if (safe_strcmp(callee, "tan") == 0) {
1264        assert(op[0]->type->is_float());
1265        for (unsigned c = 0; c < op[0]->type->components(); c++)
1266  	 data.f[c] = tanf(op[0]->value.f[c]);
1267!    } else if (safe_strcmp(callee, "tanh") == 0) {
1268        assert(op[0]->type->is_float());
1269        for (unsigned c = 0; c < op[0]->type->components(); c++)
1270  	 data.f[c] = tanhf(op[0]->value.f[c]);
1271!    } else if (safe_strcmp(callee, "transpose") == 0) {
1272        assert(op[0]->type->is_matrix());
1273        const unsigned n = op[0]->type->vector_elements;
1274        const unsigned m = op[0]->type->matrix_columns;
1275diff -c -r Mesa-7.9/src/glsl/ir_dead_functions.cpp MesaLib/src/glsl/ir_dead_functions.cpp
1276*** Mesa-7.9/src/glsl/ir_dead_functions.cpp	Fri Oct  1 15:51:28 2010
1277--- MesaLib/src/glsl/ir_dead_functions.cpp	Fri Oct 22 15:34:54 2010
1278***************
1279*** 31,36 ****
1280--- 31,37 ----
1281   #include "ir_visitor.h"
1282   #include "ir_expression_flattening.h"
1283   #include "glsl_types.h"
1284+  #include "safe_strcmp.h"
1285  
1286   class signature_entry : public exec_node
1287   {
1288***************
1289*** 90,96 ****
1290   {
1291      signature_entry *entry = this->get_signature_entry(ir);
1292  
1293!     if (strcmp(ir->function_name(), "main") == 0) {
1294         entry->used = true;
1295      }
1296  
1297--- 91,97 ----
1298   {
1299      signature_entry *entry = this->get_signature_entry(ir);
1300  
1301!     if (safe_strcmp(ir->function_name(), "main") == 0) {
1302         entry->used = true;
1303      }
1304  
1305diff -c -r Mesa-7.9/src/glsl/ir_function_inlining.cpp MesaLib/src/glsl/ir_function_inlining.cpp
1306*** Mesa-7.9/src/glsl/ir_function_inlining.cpp	Fri Oct  1 15:51:28 2010
1307--- MesaLib/src/glsl/ir_function_inlining.cpp	Fri Oct 22 15:35:58 2010
1308***************
1309*** 27,33 ****
1310   * Replaces calls to functions with the body of the function.
1311   */
1312  
1313! #include <inttypes.h>
1314  #include "ir.h"
1315  #include "ir_visitor.h"
1316  #include "ir_function_inlining.h"
1317--- 27,34 ----
1318   * Replaces calls to functions with the body of the function.
1319   */
1320  
1321! /* The use of inttypes.h seems to be unnecessary and causes problems on Windows. */
1322! /* #include <inttypes.h> */
1323  #include "ir.h"
1324  #include "ir_visitor.h"
1325  #include "ir_function_inlining.h"
1326diff -c -r Mesa-7.9/src/glsl/ir_lower_jumps.cpp MesaLib/src/glsl/ir_lower_jumps.cpp
1327*** Mesa-7.9/src/glsl/ir_lower_jumps.cpp	Fri Oct  1 15:51:28 2010
1328--- MesaLib/src/glsl/ir_lower_jumps.cpp	Fri Oct 22 15:36:16 2010
1329***************
1330*** 28,33 ****
1331--- 28,34 ----
1332  #include "glsl_types.h"
1333  #include <string.h>
1334  #include "ir.h"
1335+ #include "safe_strcmp.h"
1336  
1337  enum jump_strength
1338  {
1339***************
1340*** 125,131 ****
1341        this->return_flag = 0;
1342        this->return_value = 0;
1343        this->nesting_depth = 0;
1344!       this->is_main = this->signature && (strcmp(this->signature->function_name(), "main") == 0);
1345     }
1346  
1347     ir_variable* get_return_flag()
1348--- 126,132 ----
1349        this->return_flag = 0;
1350        this->return_value = 0;
1351        this->nesting_depth = 0;
1352!       this->is_main = this->signature && (safe_strcmp(this->signature->function_name(), "main") == 0);
1353     }
1354  
1355     ir_variable* get_return_flag()
1356diff -c -r Mesa-7.9/src/glsl/ir_reader.cpp MesaLib/src/glsl/ir_reader.cpp
1357*** Mesa-7.9/src/glsl/ir_reader.cpp	Fri Oct  1 15:51:28 2010
1358--- MesaLib/src/glsl/ir_reader.cpp	Fri Oct 22 15:36:27 2010
1359***************
1360*** 31,36 ****
1361--- 31,37 ----
1362  #include "glsl_parser_extras.h"
1363  #include "glsl_types.h"
1364  #include "s_expression.h"
1365+ #include "safe_strcmp.h"
1366  
1367  const static bool debug = false;
1368  
1369***************
1370*** 128,134 ****
1371  	 ir_read_error(st, expr, "expected type (array ...) or (struct ...)");
1372  	 return NULL;
1373        }
1374!       if (strcmp(type_sym->value(), "array") == 0) {
1375  	 if (list->length() != 3) {
1376  	    ir_read_error(st, expr, "expected type (array <type> <int>)");
1377  	    return NULL;
1378--- 129,135 ----
1379  	 ir_read_error(st, expr, "expected type (array ...) or (struct ...)");
1380  	 return NULL;
1381        }
1382!       if (safe_strcmp(type_sym->value(), "array") == 0) {
1383  	 if (list->length() != 3) {
1384  	    ir_read_error(st, expr, "expected type (array <type> <int>)");
1385  	    return NULL;
1386***************
1387*** 150,156 ****
1388  	 }
1389  
1390  	 return glsl_type::get_array_instance(base_type, size->value());
1391!       } else if (strcmp(type_sym->value(), "struct") == 0) {
1392  	 assert(false); // FINISHME
1393        } else {
1394  	 ir_read_error(st, expr, "expected (array ...) or (struct ...); "
1395--- 151,157 ----
1396  	 }
1397  
1398  	 return glsl_type::get_array_instance(base_type, size->value());
1399!       } else if (safe_strcmp(type_sym->value(), "struct") == 0) {
1400  	 assert(false); // FINISHME
1401        } else {
1402  	 ir_read_error(st, expr, "expected (array ...) or (struct ...); "
1403***************
1404*** 189,195 ****
1405  	 continue; // not a (function ...); ignore it.
1406  
1407        s_symbol *tag = SX_AS_SYMBOL(sub->subexpressions.get_head());
1408!       if (tag == NULL || strcmp(tag->value(), "function") != 0)
1409  	 continue; // not a (function ...); ignore it.
1410  
1411        ir_function *f = read_function(st, sub, true);
1412--- 190,196 ----
1413  	 continue; // not a (function ...); ignore it.
1414  
1415        s_symbol *tag = SX_AS_SYMBOL(sub->subexpressions.get_head());
1416!       if (tag == NULL || safe_strcmp(tag->value(), "function") != 0)
1417  	 continue; // not a (function ...); ignore it.
1418  
1419        ir_function *f = read_function(st, sub, true);
1420***************
1421*** 233,239 ****
1422        }
1423  
1424        s_symbol *tag = SX_AS_SYMBOL(siglist->subexpressions.get_head());
1425!       if (tag == NULL || strcmp(tag->value(), "signature") != 0) {
1426  	 ir_read_error(st, siglist, "Expected (signature ...)");
1427  	 return NULL;
1428        }
1429--- 234,240 ----
1430        }
1431  
1432        s_symbol *tag = SX_AS_SYMBOL(siglist->subexpressions.get_head());
1433!       if (tag == NULL || safe_strcmp(tag->value(), "signature") != 0) {
1434  	 ir_read_error(st, siglist, "Expected (signature ...)");
1435  	 return NULL;
1436        }
1437***************
1438*** 267,273 ****
1439        return;
1440     }
1441     s_symbol *paramtag = SX_AS_SYMBOL(paramlist->subexpressions.get_head());
1442!    if (paramtag == NULL || strcmp(paramtag->value(), "parameters") != 0) {
1443        ir_read_error(st, paramlist, "Expected (parameters ...)");
1444        return;
1445     }
1446--- 268,274 ----
1447        return;
1448     }
1449     s_symbol *paramtag = SX_AS_SYMBOL(paramlist->subexpressions.get_head());
1450!    if (paramtag == NULL || safe_strcmp(paramtag->value(), "parameters") != 0) {
1451        ir_read_error(st, paramlist, "Expected (parameters ...)");
1452        return;
1453     }
1454***************
1455*** 364,372 ****
1456     void *ctx = st;
1457     s_symbol *symbol = SX_AS_SYMBOL(expr);
1458     if (symbol != NULL) {
1459!       if (strcmp(symbol->value(), "break") == 0 && loop_ctx != NULL)
1460  	 return new(ctx) ir_loop_jump(ir_loop_jump::jump_break);
1461!       if (strcmp(symbol->value(), "continue") == 0 && loop_ctx != NULL)
1462  	 return new(ctx) ir_loop_jump(ir_loop_jump::jump_continue);
1463     }
1464  
1465--- 365,373 ----
1466     void *ctx = st;
1467     s_symbol *symbol = SX_AS_SYMBOL(expr);
1468     if (symbol != NULL) {
1469!       if (safe_strcmp(symbol->value(), "break") == 0 && loop_ctx != NULL)
1470  	 return new(ctx) ir_loop_jump(ir_loop_jump::jump_break);
1471!       if (safe_strcmp(symbol->value(), "continue") == 0 && loop_ctx != NULL)
1472  	 return new(ctx) ir_loop_jump(ir_loop_jump::jump_continue);
1473     }
1474  
1475***************
1476*** 383,399 ****
1477     }
1478  
1479     ir_instruction *inst = NULL;
1480!    if (strcmp(tag->value(), "declare") == 0) {
1481        inst = read_declaration(st, list);
1482!    } else if (strcmp(tag->value(), "assign") == 0) {
1483        inst = read_assignment(st, list);
1484!    } else if (strcmp(tag->value(), "if") == 0) {
1485        inst = read_if(st, list, loop_ctx);
1486!    } else if (strcmp(tag->value(), "loop") == 0) {
1487        inst = read_loop(st, list);
1488!    } else if (strcmp(tag->value(), "return") == 0) {
1489        inst = read_return(st, list);
1490!    } else if (strcmp(tag->value(), "function") == 0) {
1491        inst = read_function(st, list, false);
1492     } else {
1493        inst = read_rvalue(st, list);
1494--- 384,400 ----
1495     }
1496  
1497     ir_instruction *inst = NULL;
1498!    if (safe_strcmp(tag->value(), "declare") == 0) {
1499        inst = read_declaration(st, list);
1500!    } else if (safe_strcmp(tag->value(), "assign") == 0) {
1501        inst = read_assignment(st, list);
1502!    } else if (safe_strcmp(tag->value(), "if") == 0) {
1503        inst = read_if(st, list, loop_ctx);
1504!    } else if (safe_strcmp(tag->value(), "loop") == 0) {
1505        inst = read_loop(st, list);
1506!    } else if (safe_strcmp(tag->value(), "return") == 0) {
1507        inst = read_return(st, list);
1508!    } else if (safe_strcmp(tag->value(), "function") == 0) {
1509        inst = read_function(st, list, false);
1510     } else {
1511        inst = read_rvalue(st, list);
1512***************
1513*** 443,467 ****
1514        }
1515  
1516        // FINISHME: Check for duplicate/conflicting qualifiers.
1517!       if (strcmp(qualifier->value(), "centroid") == 0) {
1518  	 var->centroid = 1;
1519!       } else if (strcmp(qualifier->value(), "invariant") == 0) {
1520  	 var->invariant = 1;
1521!       } else if (strcmp(qualifier->value(), "uniform") == 0) {
1522  	 var->mode = ir_var_uniform;
1523!       } else if (strcmp(qualifier->value(), "auto") == 0) {
1524  	 var->mode = ir_var_auto;
1525!       } else if (strcmp(qualifier->value(), "in") == 0) {
1526  	 var->mode = ir_var_in;
1527!       } else if (strcmp(qualifier->value(), "out") == 0) {
1528  	 var->mode = ir_var_out;
1529!       } else if (strcmp(qualifier->value(), "inout") == 0) {
1530  	 var->mode = ir_var_inout;
1531!       } else if (strcmp(qualifier->value(), "smooth") == 0) {
1532  	 var->interpolation = ir_var_smooth;
1533!       } else if (strcmp(qualifier->value(), "flat") == 0) {
1534  	 var->interpolation = ir_var_flat;
1535!       } else if (strcmp(qualifier->value(), "noperspective") == 0) {
1536  	 var->interpolation = ir_var_noperspective;
1537        } else {
1538  	 ir_read_error(st, list, "unknown qualifier: %s", qualifier->value());
1539--- 444,468 ----
1540        }
1541  
1542        // FINISHME: Check for duplicate/conflicting qualifiers.
1543!       if (safe_strcmp(qualifier->value(), "centroid") == 0) {
1544  	 var->centroid = 1;
1545!       } else if (safe_strcmp(qualifier->value(), "invariant") == 0) {
1546  	 var->invariant = 1;
1547!       } else if (safe_strcmp(qualifier->value(), "uniform") == 0) {
1548  	 var->mode = ir_var_uniform;
1549!       } else if (safe_strcmp(qualifier->value(), "auto") == 0) {
1550  	 var->mode = ir_var_auto;
1551!       } else if (safe_strcmp(qualifier->value(), "in") == 0) {
1552  	 var->mode = ir_var_in;
1553!       } else if (safe_strcmp(qualifier->value(), "out") == 0) {
1554  	 var->mode = ir_var_out;
1555!       } else if (safe_strcmp(qualifier->value(), "inout") == 0) {
1556  	 var->mode = ir_var_inout;
1557!       } else if (safe_strcmp(qualifier->value(), "smooth") == 0) {
1558  	 var->interpolation = ir_var_smooth;
1559!       } else if (safe_strcmp(qualifier->value(), "flat") == 0) {
1560  	 var->interpolation = ir_var_flat;
1561!       } else if (safe_strcmp(qualifier->value(), "noperspective") == 0) {
1562  	 var->interpolation = ir_var_noperspective;
1563        } else {
1564  	 ir_read_error(st, list, "unknown qualifier: %s", qualifier->value());
1565***************
1566*** 574,586 ****
1567     ir_rvalue *rvalue = read_dereference(st, list);
1568     if (rvalue != NULL || st->error)
1569        return rvalue;
1570!    else if (strcmp(tag->value(), "swiz") == 0) {
1571        rvalue = read_swizzle(st, list);
1572!    } else if (strcmp(tag->value(), "expression") == 0) {
1573        rvalue = read_expression(st, list);
1574!    } else if (strcmp(tag->value(), "call") == 0) {
1575        rvalue = read_call(st, list);
1576!    } else if (strcmp(tag->value(), "constant") == 0) {
1577        rvalue = read_constant(st, list);
1578     } else {
1579        rvalue = read_texture(st, list);
1580--- 575,587 ----
1581     ir_rvalue *rvalue = read_dereference(st, list);
1582     if (rvalue != NULL || st->error)
1583        return rvalue;
1584!    else if (safe_strcmp(tag->value(), "swiz") == 0) {
1585        rvalue = read_swizzle(st, list);
1586!    } else if (safe_strcmp(tag->value(), "expression") == 0) {
1587        rvalue = read_expression(st, list);
1588!    } else if (safe_strcmp(tag->value(), "call") == 0) {
1589        rvalue = read_call(st, list);
1590!    } else if (safe_strcmp(tag->value(), "constant") == 0) {
1591        rvalue = read_constant(st, list);
1592     } else {
1593        rvalue = read_texture(st, list);
1594***************
1595*** 921,931 ****
1596     s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.head);
1597     assert(tag != NULL);
1598  
1599!    if (strcmp(tag->value(), "var_ref") == 0)
1600        return read_var_ref(st, list);
1601!    if (strcmp(tag->value(), "array_ref") == 0)
1602        return read_array_ref(st, list);
1603!    if (strcmp(tag->value(), "record_ref") == 0)
1604        return read_record_ref(st, list);
1605     return NULL;
1606  }
1607--- 922,932 ----
1608     s_symbol *tag = SX_AS_SYMBOL(list->subexpressions.head);
1609     assert(tag != NULL);
1610  
1611!    if (safe_strcmp(tag->value(), "var_ref") == 0)
1612        return read_var_ref(st, list);
1613!    if (safe_strcmp(tag->value(), "array_ref") == 0)
1614        return read_array_ref(st, list);
1615!    if (safe_strcmp(tag->value(), "record_ref") == 0)
1616        return read_record_ref(st, list);
1617     return NULL;
1618  }
1619diff -c -r Mesa-7.9/src/glsl/ir_structure_splitting.cpp MesaLib/src/glsl/ir_structure_splitting.cpp
1620*** Mesa-7.9/src/glsl/ir_structure_splitting.cpp	Fri Oct  1 15:51:28 2010
1621--- MesaLib/src/glsl/ir_structure_splitting.cpp	Fri Oct 22 15:36:52 2010
1622***************
1623*** 37,42 ****
1624--- 37,43 ----
1625  #include "ir_print_visitor.h"
1626  #include "ir_rvalue_visitor.h"
1627  #include "glsl_types.h"
1628+ #include "safe_strcmp.h"
1629  
1630  static bool debug = false;
1631  
1632***************
1633*** 228,235 ****
1634  
1635     unsigned int i;
1636     for (i = 0; i < entry->var->type->length; i++) {
1637!       if (strcmp(deref_record->field,
1638! 		 entry->var->type->fields.structure[i].name) == 0)
1639  	 break;
1640     }
1641     assert(i != entry->var->type->length);
1642--- 229,236 ----
1643  
1644     unsigned int i;
1645     for (i = 0; i < entry->var->type->length; i++) {
1646!       if (safe_strcmp(deref_record->field,
1647! 		      entry->var->type->fields.structure[i].name) == 0)
1648  	 break;
1649     }
1650     assert(i != entry->var->type->length);
1651diff -c -r Mesa-7.9/src/glsl/ir_validate.cpp MesaLib/src/glsl/ir_validate.cpp
1652*** Mesa-7.9/src/glsl/ir_validate.cpp	Mon Oct  4 18:58:00 2010
1653--- MesaLib/src/glsl/ir_validate.cpp	Fri Oct 22 15:37:24 2010
1654***************
1655*** 33,39 ****
1656   * a dereference chain.
1657   */
1658  
1659! #include <inttypes.h>
1660  #include "ir.h"
1661  #include "ir_hierarchical_visitor.h"
1662  #include "program/hash_table.h"
1663--- 33,40 ----
1664   * a dereference chain.
1665   */
1666  
1667! /* The use of inttypes.h seems to be unnecessary and causes problems on Windows. */
1668! /* #include <inttypes.h> */
1669  #include "ir.h"
1670  #include "ir_hierarchical_visitor.h"
1671  #include "program/hash_table.h"
1672diff -c -r Mesa-7.9/src/glsl/linker.cpp MesaLib/src/glsl/linker.cpp
1673*** Mesa-7.9/src/glsl/linker.cpp	Fri Oct  1 15:51:28 2010
1674--- MesaLib/src/glsl/linker.cpp	Fri Oct 22 15:38:08 2010
1675***************
1676*** 79,84 ****
1677--- 79,85 ----
1678  #include "program/hash_table.h"
1679  #include "linker.h"
1680  #include "ir_optimization.h"
1681+ #include "safe_strcmp.h"
1682  
1683  /**
1684   * Visitor that determines whether or not a variable is ever written.
1685***************
1686*** 95,101 ****
1687     {
1688        ir_variable *const var = ir->lhs->variable_referenced();
1689  
1690!       if (strcmp(name, var->name) == 0) {
1691  	 found = true;
1692  	 return visit_stop;
1693        }
1694--- 96,102 ----
1695     {
1696        ir_variable *const var = ir->lhs->variable_referenced();
1697  
1698!       if (safe_strcmp(name, var->name) == 0) {
1699  	 found = true;
1700  	 return visit_stop;
1701        }
1702***************
1703*** 113,119 ****
1704  	 if (sig_param->mode == ir_var_out ||
1705  	     sig_param->mode == ir_var_inout) {
1706  	    ir_variable *var = param_rval->variable_referenced();
1707! 	    if (var && strcmp(name, var->name) == 0) {
1708  	       found = true;
1709  	       return visit_stop;
1710  	    }
1711--- 114,120 ----
1712  	 if (sig_param->mode == ir_var_out ||
1713  	     sig_param->mode == ir_var_inout) {
1714  	    ir_variable *var = param_rval->variable_referenced();
1715! 	    if (var && safe_strcmp(name, var->name) == 0) {
1716  	       found = true;
1717  	       return visit_stop;
1718  	    }
1719***************
1720*** 148,154 ****
1721  
1722     virtual ir_visitor_status visit(ir_dereference_variable *ir)
1723     {
1724!       if (strcmp(this->name, ir->var->name) == 0) {
1725  	 this->found = true;
1726  	 return visit_stop;
1727        }
1728--- 149,155 ----
1729  
1730     virtual ir_visitor_status visit(ir_dereference_variable *ir)
1731     {
1732!       if (safe_strcmp(this->name, ir->var->name) == 0) {
1733  	 this->found = true;
1734  	 return visit_stop;
1735        }
1736***************
1737*** 876,882 ****
1738  	       if (!other_var)
1739  		  continue;
1740  
1741! 	       if (strcmp(var->name, other_var->name) == 0 &&
1742  		   other_var->max_array_access > size) {
1743  		  size = other_var->max_array_access;
1744  	       }
1745--- 877,883 ----
1746  	       if (!other_var)
1747  		  continue;
1748  
1749! 	       if (safe_strcmp(var->name, other_var->name) == 0 &&
1750  		   other_var->max_array_access > size) {
1751  		  size = other_var->max_array_access;
1752  	       }
1753diff -c -r Mesa-7.9/src/mapi/glapi/glapi_nop.c MesaLib/src/mapi/glapi/glapi_nop.c
1754*** Mesa-7.9/src/mapi/glapi/glapi_nop.c	Fri Oct  1 15:51:28 2010
1755--- MesaLib/src/mapi/glapi/glapi_nop.c	Fri Oct 22 15:41:35 2010
1756***************
1757*** 107,113 ****
1758     return 0;
1759  }
1760  
1761! #define TABLE_ENTRY(name) (_glapi_proc) NoOpGeneric
1762  
1763  #endif
1764  
1765--- 107,138 ----
1766     return 0;
1767  }
1768  
1769! /**
1770!  * This is called if the user somehow calls an unassigned GL dispatch function.
1771!  */
1772! static GLint
1773! NoOpUnused(void)
1774! {
1775!    return NoOpGeneric();
1776! }
1777! 
1778! /*
1779!  * It is necessary to generate custom no-op entry points at least on
1780!  * Windows, where the __stdcall calling convention is used (callee
1781!  * cleans the stack). This calling convention can not tolerate a
1782!  * mismatch between the numbers of arguments in caller and callee.
1783!  */
1784! #define KEYWORD1 static
1785! #define KEYWORD1_ALT static
1786! #define KEYWORD2 GLAPIENTRY
1787! #define NAME(func)  NoOp##func
1788! #define DISPATCH(func, args, msg)  NoOpGeneric();
1789! #define RETURN_DISPATCH(func, args, msg)  return NoOpGeneric();
1790! 
1791! /*
1792!  * Defines for the table of no-op entry points.
1793!  */
1794! #define TABLE_ENTRY(name) (_glapi_proc) NoOp##name
1795  
1796  #endif
1797  
1798diff -c -r Mesa-7.9/src/mesa/main/compiler.h MesaLib/src/mesa/main/compiler.h
1799*** Mesa-7.9/src/mesa/main/compiler.h	Fri Oct  1 15:51:28 2010
1800--- MesaLib/src/mesa/main/compiler.h	Fri Oct 22 15:44:23 2010
1801***************
1802*** 175,181 ****
1803--- 175,183 ----
1804  #  define PUBLIC __attribute__((visibility("default")))
1805  #  define USED __attribute__((used))
1806  #else
1807+ # ifndef PUBLIC
1808  #  define PUBLIC
1809+ # endif
1810  #  define USED
1811  #endif
1812  
1813diff -c -r Mesa-7.9/src/mesa/main/histogram.c MesaLib/src/mesa/main/histogram.c
1814*** Mesa-7.9/src/mesa/main/histogram.c	Mon Oct  4 18:58:00 2010
1815--- MesaLib/src/mesa/main/histogram.c	Tue Oct 26 11:17:37 2010
1816***************
1817*** 32,37 ****
1818--- 32,40 ----
1819  #include "macros.h"
1820  #include "main/dispatch.h"
1821  
1822+ #if defined(_MSC_VER)
1823+ #pragma optimize("", off)
1824+ #endif
1825  
1826  #if FEATURE_histogram
1827  
1828diff -c -r Mesa-7.9/src/mesa/main/image.c MesaLib/src/mesa/main/image.c
1829*** Mesa-7.9/src/mesa/main/image.c	Mon Oct  4 18:58:00 2010
1830--- MesaLib/src/mesa/main/image.c	Tue Oct 26 11:17:45 2010
1831***************
1832*** 37,42 ****
1833--- 37,45 ----
1834  #include "imports.h"
1835  #include "macros.h"
1836  
1837+ #if defined(_MSC_VER)
1838+ #pragma optimize("", off)
1839+ #endif
1840  
1841  /**
1842   * NOTE:
1843diff -c -r Mesa-7.9/src/mesa/main/mipmap.c MesaLib/src/mesa/main/mipmap.c
1844*** Mesa-7.9/src/mesa/main/mipmap.c	Fri Oct  1 15:51:28 2010
1845--- MesaLib/src/mesa/main/mipmap.c	Tue Oct 26 11:17:52 2010
1846***************
1847*** 34,40 ****
1848  #include "texstore.h"
1849  #include "image.h"
1850  
1851! 
1852  
1853  static GLint
1854  bytes_per_pixel(GLenum datatype, GLuint comps)
1855--- 34,42 ----
1856  #include "texstore.h"
1857  #include "image.h"
1858  
1859! #if defined(_MSC_VER)
1860! #pragma optimize("", off)
1861! #endif
1862  
1863  static GLint
1864  bytes_per_pixel(GLenum datatype, GLuint comps)
1865diff -c -r Mesa-7.9/src/mesa/main/querymatrix.c MesaLib/src/mesa/main/querymatrix.c
1866*** Mesa-7.9/src/mesa/main/querymatrix.c	Mon Oct  4 18:58:00 2010
1867--- MesaLib/src/mesa/main/querymatrix.c	Wed Oct  6 16:36:08 2010
1868***************
1869*** 73,79 ****
1870  #elif defined(__APPLE__) || defined(__CYGWIN__) || defined(__FreeBSD__) || \
1871       defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \
1872       (defined(__sun) && defined(__C99FEATURES__)) || defined(__MINGW32__) || \
1873!      (defined(__sun) && defined(__GNUC__))
1874  
1875  /* fpclassify is available. */
1876  
1877--- 73,80 ----
1878  #elif defined(__APPLE__) || defined(__CYGWIN__) || defined(__FreeBSD__) || \
1879       defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || \
1880       (defined(__sun) && defined(__C99FEATURES__)) || defined(__MINGW32__) || \
1881!      (defined(__sun) && defined(__GNUC__)) || \
1882!      (defined(__linux) && defined(__GNUC__))
1883  
1884  /* fpclassify is available. */
1885  
1886diff -c -r Mesa-7.9/src/mesa/math/m_eval.c MesaLib/src/mesa/math/m_eval.c
1887*** Mesa-7.9/src/mesa/math/m_eval.c	Thu Feb  4 16:10:40 2010
1888--- MesaLib/src/mesa/math/m_eval.c	Tue Oct 26 11:18:00 2010
1889***************
1890*** 41,46 ****
1891--- 41,50 ----
1892  #include "main/config.h"
1893  #include "m_eval.h"
1894  
1895+ #if defined(_MSC_VER)
1896+ #pragma optimize("", off)
1897+ #endif
1898+ 
1899  static GLfloat inv_tab[MAX_EVAL_ORDER];
1900  
1901  
1902diff -c -r Mesa-7.9/src/mesa/swrast/s_texcombine.c MesaLib/src/mesa/swrast/s_texcombine.c
1903*** Mesa-7.9/src/mesa/swrast/s_texcombine.c	Fri Oct  1 15:51:28 2010
1904--- MesaLib/src/mesa/swrast/s_texcombine.c	Tue Oct 26 11:01:39 2010
1905***************
1906*** 34,39 ****
1907--- 34,42 ----
1908  #include "s_context.h"
1909  #include "s_texcombine.h"
1910  
1911+ #if defined(_MSC_VER)
1912+ #pragma optimize("", off)
1913+ #endif
1914  
1915  /**
1916   * Pointer to array of float[4]
1917diff -c -r Mesa-7.9/src/mapi/glapi/gen/gl_apitemp.py MesaLib/src/mapi/glapi/gen/gl_apitemp.py
1918*** Mesa-7.9/src/mapi/glapi/gen/gl_apitemp.py	Mon Aug 15 09:14:29 2011
1919--- MesaLib/src/mapi/glapi/gen/gl_apitemp.py	Thu Aug 11 21:23:47 2011
1920***************
1921*** 79,89 ****
1922  			comma = ", "
1923  
1924  
1925- 		if f.return_type != 'void':
1926- 			dispatch = "RETURN_DISPATCH"
1927- 		else:
1928- 			dispatch = "DISPATCH"
1929- 
1930  		need_proto = False
1931  		if not f.is_static_entry_point(name):
1932  			need_proto = True
1933--- 79,84 ----
1934***************
1935*** 97,108 ****
1936  
1937  		print '%s %s KEYWORD2 NAME(%s)(%s)' % (keyword, f.return_type, n, f.get_parameter_string(name))
1938  		print '{'
1939! 		if p_string == "":
1940! 			print '   %s(%s, (), (F, "gl%s();\\n"));' \
1941! 				% (dispatch, f.name, name)
1942  		else:
1943! 			print '   %s(%s, (%s), (F, "gl%s(%s);\\n", %s));' \
1944! 				% (dispatch, f.name, p_string, name, t_string, o_string)
1945  		print '}'
1946  		print ''
1947  		return
1948--- 92,113 ----
1949  
1950  		print '%s %s KEYWORD2 NAME(%s)(%s)' % (keyword, f.return_type, n, f.get_parameter_string(name))
1951  		print '{'
1952! 		if f.return_type != 'void':
1953! 			dispatch = "RETURN_DISPATCH"
1954! 			if p_string == "":
1955! 				print '   %s(%s, %s, (), (F, "gl%s();\\n"));' \
1956! 					% (dispatch, f.return_type, f.name, name)
1957! 			else:
1958! 				print '   %s(%s, %s, (%s), (F, "gl%s(%s);\\n", %s));' \
1959! 					% (dispatch, f.return_type, f.name, p_string, name, t_string, o_string)
1960  		else:
1961! 			dispatch = "DISPATCH"
1962! 			if p_string == "":
1963! 				print '   %s(%s, (), (F, "gl%s();\\n"));' \
1964! 					% (dispatch, f.name, name)
1965! 			else:
1966! 				print '   %s(%s, (%s), (F, "gl%s(%s);\\n", %s));' \
1967! 					% (dispatch, f.name, p_string, name, t_string, o_string)
1968  		print '}'
1969  		print ''
1970  		return
1971***************
1972*** 120,126 ****
1973   *   NAME(n)  - builds the final function name (usually add "gl" prefix)
1974   *   DISPATCH(func, args, msg) - code to do dispatch of named function.
1975   *                               msg is a printf-style debug message.
1976!  *   RETURN_DISPATCH(func, args, msg) - code to do dispatch with a return value
1977   *
1978   * Here is an example which generates the usual OpenGL functions:
1979   *   #define KEYWORD1
1980--- 125,132 ----
1981   *   NAME(n)  - builds the final function name (usually add "gl" prefix)
1982   *   DISPATCH(func, args, msg) - code to do dispatch of named function.
1983   *                               msg is a printf-style debug message.
1984!  *   RETURN_DISPATCH(type, func, args, msg) - code to do dispatch with a
1985!  *                                            return value of type.
1986   *
1987   * Here is an example which generates the usual OpenGL functions:
1988   *   #define KEYWORD1
1989diff -c -r Mesa-7.9/src/mapi/glapi/glapi_dispatch.c MesaLib/src/mapi/glapi/glapi_dispatch.c
1990*** Mesa-7.9/src/mapi/glapi/glapi_dispatch.c	Mon Aug 15 09:14:30 2011
1991--- MesaLib/src/mapi/glapi/glapi_dispatch.c	Thu Aug 11 21:25:55 2011
1992***************
1993*** 65,71 ****
1994     fprintf MESSAGE;				\
1995     CALL_ ## FUNC(GET_DISPATCH(), ARGS);
1996  
1997! #define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) 	\
1998     fprintf MESSAGE;				\
1999     return CALL_ ## FUNC(GET_DISPATCH(), ARGS);
2000  
2001--- 65,71 ----
2002     fprintf MESSAGE;				\
2003     CALL_ ## FUNC(GET_DISPATCH(), ARGS);
2004  
2005! #define RETURN_DISPATCH(TYPE, FUNC, ARGS, MESSAGE) 	\
2006     fprintf MESSAGE;				\
2007     return CALL_ ## FUNC(GET_DISPATCH(), ARGS);
2008  
2009***************
2010*** 74,80 ****
2011  #define DISPATCH(FUNC, ARGS, MESSAGE)		\
2012     CALL_ ## FUNC(GET_DISPATCH(), ARGS);
2013  
2014! #define RETURN_DISPATCH(FUNC, ARGS, MESSAGE) 	\
2015     return CALL_ ## FUNC(GET_DISPATCH(), ARGS);
2016  
2017  #endif /* logging */
2018--- 74,80 ----
2019  #define DISPATCH(FUNC, ARGS, MESSAGE)		\
2020     CALL_ ## FUNC(GET_DISPATCH(), ARGS);
2021  
2022! #define RETURN_DISPATCH(TYPE, FUNC, ARGS, MESSAGE) 	\
2023     return CALL_ ## FUNC(GET_DISPATCH(), ARGS);
2024  
2025  #endif /* logging */
2026diff -c -r Mesa-7.9/src/mapi/glapi/glapi_nop.c MesaLib/src/mapi/glapi/glapi_nop.c
2027*** Mesa-7.9/src/mapi/glapi/glapi_nop.c	Mon Aug 15 09:14:30 2011
2028--- MesaLib/src/mapi/glapi/glapi_nop.c	Thu Aug 11 21:29:46 2011
2029***************
2030*** 86,92 ****
2031  #define KEYWORD2 GLAPIENTRY
2032  #define NAME(func)  NoOp##func
2033  #define DISPATCH(func, args, msg)  Warn(#func);
2034! #define RETURN_DISPATCH(func, args, msg)  Warn(#func); return 0
2035  
2036  
2037  /*
2038--- 86,92 ----
2039  #define KEYWORD2 GLAPIENTRY
2040  #define NAME(func)  NoOp##func
2041  #define DISPATCH(func, args, msg)  Warn(#func);
2042! #define RETURN_DISPATCH(type, func, args, msg)  Warn(#func); return (type)0
2043  
2044  
2045  /*
2046***************
2047*** 96,102 ****
2048  
2049  #else
2050  
2051! static int
2052  NoOpGeneric(void)
2053  {
2054  #if !defined(_WIN32_WCE)
2055--- 96,102 ----
2056  
2057  #else
2058  
2059! void
2060  NoOpGeneric(void)
2061  {
2062  #if !defined(_WIN32_WCE)
2063***************
2064*** 104,110 ****
2065        fprintf(stderr, "GL User Error: calling GL function without a rendering context\n");
2066     }
2067  #endif
2068-    return 0;
2069  }
2070  
2071  /**
2072--- 104,109 ----
2073***************
2074*** 113,119 ****
2075  static GLint
2076  NoOpUnused(void)
2077  {
2078!    return NoOpGeneric();
2079  }
2080  
2081  /*
2082--- 112,119 ----
2083  static GLint
2084  NoOpUnused(void)
2085  {
2086!    NoOpGeneric();
2087!    return 0;
2088  }
2089  
2090  /*
2091***************
2092*** 127,133 ****
2093  #define KEYWORD2 GLAPIENTRY
2094  #define NAME(func)  NoOp##func
2095  #define DISPATCH(func, args, msg)  NoOpGeneric();
2096! #define RETURN_DISPATCH(func, args, msg)  return NoOpGeneric();
2097  
2098  /*
2099   * Defines for the table of no-op entry points.
2100--- 127,133 ----
2101  #define KEYWORD2 GLAPIENTRY
2102  #define NAME(func)  NoOp##func
2103  #define DISPATCH(func, args, msg)  NoOpGeneric();
2104! #define RETURN_DISPATCH(type, func, args, msg)  NoOpGeneric(); return (type)0
2105  
2106  /*
2107   * Defines for the table of no-op entry points.
2108