--- Mesa-7.8.2/src/gallium/auxiliary/indices/u_indices_gen.py.orig	2010-02-05 11:10:39.000000000 +1100
+++ Mesa-7.8.2/src/gallium/auxiliary/indices/u_indices_gen.py	2010-12-06 15:59:36.000000000 +1100
@@ -60,9 +60,9 @@
 
 
 def prolog():
-    print '''/* File automatically generated by indices.py */'''
-    print copyright
-    print r'''
+    print ('''/* File automatically generated by indices.py */''')
+    print (copyright)
+    print (r'''
 
 /**
  * @file
@@ -101,7 +101,7 @@
 static u_generate_func  generate[OUT_COUNT][PV_COUNT][PV_COUNT][PRIM_COUNT];
 
 
-'''
+''')
 
 def vert( intype, outtype, v0 ):
     if intype == GENERATE:
@@ -110,16 +110,16 @@
         return '(' + outtype + ')in[' + v0 + ']'
 
 def point( intype, outtype, ptr, v0 ):
-    print '      (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
+    print ('      (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';')
 
 def line( intype, outtype, ptr, v0, v1 ):
-    print '      (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
-    print '      (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'
+    print ('      (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';')
+    print ('      (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';')
 
 def tri( intype, outtype, ptr, v0, v1, v2 ):
-    print '      (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
-    print '      (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'
-    print '      (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';'
+    print ('      (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';')
+    print ('      (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';')
+    print ('      (' + ptr + ')[2] = ' + vert( intype, outtype, v2 ) + ';')
 
 def do_point( intype, outtype, ptr, v0 ):
     point( intype, outtype, ptr, v0 )
@@ -150,103 +150,103 @@
         return 'translate_' + prim + '_' + intype + '2' + outtype + '_' + inpv + '2' + outpv
 
 def preamble(intype, outtype, inpv, outpv, prim):
-    print 'static void ' + name( intype, outtype, inpv, outpv, prim ) + '('
+    print ('static void ' + name( intype, outtype, inpv, outpv, prim ) + '(')
     if intype != GENERATE:
-        print '    const void * _in,'
-    print '    unsigned nr,'
-    print '    void *_out )'
-    print '{'
+        print ('    const void * _in,')
+    print ('    unsigned nr,')
+    print ('    void *_out )')
+    print ('{')
     if intype != GENERATE:
-        print '  const ' + intype + '*in = (const ' + intype + '*)_in;'
-    print '  ' + outtype + ' *out = (' + outtype + '*)_out;'
-    print '  unsigned i, j;'
-    print '  (void)j;'
+        print ('  const ' + intype + '*in = (const ' + intype + '*)_in;')
+    print ('  ' + outtype + ' *out = (' + outtype + '*)_out;')
+    print ('  unsigned i, j;')
+    print ('  (void)j;')
 
 def postamble():
-    print '}'
+    print ('}')
 
 
 def points(intype, outtype, inpv, outpv):
     preamble(intype, outtype, inpv, outpv, prim='points')
-    print '  for (i = 0; i < nr; i++) { '
+    print ('  for (i = 0; i < nr; i++) { ')
     do_point( intype, outtype, 'out+i',  'i' );
-    print '   }'
+    print ('   }')
     postamble()
 
 def lines(intype, outtype, inpv, outpv):
     preamble(intype, outtype, inpv, outpv, prim='lines')
-    print '  for (i = 0; i < nr; i+=2) { '
+    print ('  for (i = 0; i < nr; i+=2) { ')
     do_line( intype, outtype, 'out+i',  'i', 'i+1', inpv, outpv );
-    print '   }'
+    print ('   }')
     postamble()
 
 def linestrip(intype, outtype, inpv, outpv):
     preamble(intype, outtype, inpv, outpv, prim='linestrip')
-    print '  for (j = i = 0; j < nr; j+=2, i++) { '
+    print ('  for (j = i = 0; j < nr; j+=2, i++) { ')
     do_line( intype, outtype, 'out+j',  'i', 'i+1', inpv, outpv );
-    print '   }'
+    print ('   }')
     postamble()
 
 def lineloop(intype, outtype, inpv, outpv):
     preamble(intype, outtype, inpv, outpv, prim='lineloop')
-    print '  for (j = i = 0; j < nr - 2; j+=2, i++) { '
+    print ('  for (j = i = 0; j < nr - 2; j+=2, i++) { ')
     do_line( intype, outtype, 'out+j',  'i', 'i+1', inpv, outpv );
-    print '   }'
+    print ('   }')
     do_line( intype, outtype, 'out+j',  'i', '0', inpv, outpv );
     postamble()
 
 def tris(intype, outtype, inpv, outpv):
     preamble(intype, outtype, inpv, outpv, prim='tris')
-    print '  for (i = 0; i < nr; i+=3) { '
+    print ('  for (i = 0; i < nr; i+=3) { ')
     do_tri( intype, outtype, 'out+i',  'i', 'i+1', 'i+2', inpv, outpv );
-    print '   }'
+    print ('   }')
     postamble()
 
 
 def tristrip(intype, outtype, inpv, outpv):
     preamble(intype, outtype, inpv, outpv, prim='tristrip')
-    print '  for (j = i = 0; j < nr; j+=3, i++) { '
+    print ('  for (j = i = 0; j < nr; j+=3, i++) { ')
     if inpv == FIRST:
         do_tri( intype, outtype, 'out+j',  'i', 'i+1+(i&1)', 'i+2-(i&1)', inpv, outpv );
     else:
         do_tri( intype, outtype, 'out+j',  'i+(i&1)', 'i+1-(i&1)', 'i+2', inpv, outpv );
-    print '   }'
+    print ('   }')
     postamble()
 
 
 def trifan(intype, outtype, inpv, outpv):
     preamble(intype, outtype, inpv, outpv, prim='trifan')
-    print '  for (j = i = 0; j < nr; j+=3, i++) { '
+    print ('  for (j = i = 0; j < nr; j+=3, i++) { ')
     do_tri( intype, outtype, 'out+j',  '0', 'i+1', 'i+2', inpv, outpv );
-    print '   }'
+    print ('   }')
     postamble()
 
 
 
 def polygon(intype, outtype, inpv, outpv):
     preamble(intype, outtype, inpv, outpv, prim='polygon')
-    print '  for (j = i = 0; j < nr; j+=3, i++) { '
+    print ('  for (j = i = 0; j < nr; j+=3, i++) { ')
     if inpv == FIRST:
         do_tri( intype, outtype, 'out+j',  '0', 'i+1', 'i+2', inpv, outpv );
     else:
         do_tri( intype, outtype, 'out+j',  'i+1', 'i+2', '0', inpv, outpv );
-    print '   }'
+    print ('   }')
     postamble()
 
 
 def quads(intype, outtype, inpv, outpv):
     preamble(intype, outtype, inpv, outpv, prim='quads')
-    print '  for (j = i = 0; j < nr; j+=6, i+=4) { '
+    print ('  for (j = i = 0; j < nr; j+=6, i+=4) { ')
     do_quad( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+2', 'i+3', inpv, outpv );
-    print '   }'
+    print ('   }')
     postamble()
 
 
 def quadstrip(intype, outtype, inpv, outpv):
     preamble(intype, outtype, inpv, outpv, prim='quadstrip')
-    print '  for (j = i = 0; j < nr; j+=6, i+=2) { '
+    print ('  for (j = i = 0; j < nr; j+=6, i+=2) { ')
     do_quad( intype, outtype, 'out+j', 'i+2', 'i+0', 'i+1', 'i+3', inpv, outpv );
-    print '   }'
+    print ('   }')
     postamble()
 
 
@@ -293,19 +293,19 @@
                         init(intype, outtype, inpv, outpv, prim)
 
 def emit_init():
-    print 'void u_index_init( void )'
-    print '{'
-    print '  static int firsttime = 1;'
-    print '  if (!firsttime) return;'
-    print '  firsttime = 0;'
+    print ('void u_index_init( void )')
+    print ('{')
+    print ('  static int firsttime = 1;')
+    print ('  if (!firsttime) return;')
+    print ('  firsttime = 0;')
     emit_all_inits()
-    print '}'
+    print ('}')
 
 
     
 
 def epilog():
-    print '#include "indices/u_indices.c"'
+    print ('#include "indices/u_indices.c"')
 
 
 def main():
--- Mesa-7.8.2/src/gallium/auxiliary/indices/u_unfilled_gen.py.orig	2010-02-05 11:10:39.000000000 +1100
+++ Mesa-7.8.2/src/gallium/auxiliary/indices/u_unfilled_gen.py	2010-12-06 15:58:48.000000000 +1100
@@ -50,9 +50,9 @@
 
 
 def prolog():
-    print '''/* File automatically generated by u_unfilled_gen.py */'''
-    print copyright
-    print r'''
+    print ('''/* File automatically generated by u_unfilled_gen.py */''')
+    print (copyright)
+    print (r'''
 
 /**
  * @file
@@ -90,7 +90,7 @@
 static u_generate_func generate_line[OUT_COUNT][PRIM_COUNT];
 static u_translate_func translate_line[IN_COUNT][OUT_COUNT][PRIM_COUNT];
 
-'''
+''')
 
 def vert( intype, outtype, v0 ):
     if intype == GENERATE:
@@ -99,8 +99,8 @@
         return '(' + outtype + ')in[' + v0 + ']'
 
 def line( intype, outtype, ptr, v0, v1 ):
-    print '      (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';'
-    print '      (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';'
+    print ('      (' + ptr + ')[0] = ' + vert( intype, outtype, v0 ) + ';')
+    print ('      (' + ptr + ')[1] = ' + vert( intype, outtype, v1 ) + ';')
 
 # XXX: have the opportunity here to avoid over-drawing shared lines in
 # tristrips, fans, etc, by integrating this into the calling functions
@@ -124,68 +124,68 @@
         return 'translate_' + prim + '_' + intype + '2' + outtype
 
 def preamble(intype, outtype, prim):
-    print 'static void ' + name( intype, outtype, prim ) + '('
+    print ('static void ' + name( intype, outtype, prim ) + '(')
     if intype != GENERATE:
-        print '    const void * _in,'
-    print '    unsigned nr,'
-    print '    void *_out )'
-    print '{'
+        print ('    const void * _in,')
+    print ('    unsigned nr,')
+    print ('    void *_out )')
+    print ('{')
     if intype != GENERATE:
-        print '  const ' + intype + '*in = (const ' + intype + '*)_in;'
-    print '  ' + outtype + ' *out = (' + outtype + '*)_out;'
-    print '  unsigned i, j;'
-    print '  (void)j;'
+        print ('  const ' + intype + '*in = (const ' + intype + '*)_in;')
+    print ('  ' + outtype + ' *out = (' + outtype + '*)_out;')
+    print ('  unsigned i, j;')
+    print ('  (void)j;')
 
 def postamble():
-    print '}'
+    print ('}')
 
 
 def tris(intype, outtype):
     preamble(intype, outtype, prim='tris')
-    print '  for (j = i = 0; j < nr; j+=6, i+=3) { '
+    print ('  for (j = i = 0; j < nr; j+=6, i+=3) { ')
     do_tri( intype, outtype, 'out+j',  'i', 'i+1', 'i+2' );
-    print '   }'
+    print ('   }')
     postamble()
 
 
 def tristrip(intype, outtype):
     preamble(intype, outtype, prim='tristrip')
-    print '  for (j = i = 0; j < nr; j+=6, i++) { '
+    print ('  for (j = i = 0; j < nr; j+=6, i++) { ')
     do_tri( intype, outtype, 'out+j',  'i', 'i+1/*+(i&1)*/', 'i+2/*-(i&1)*/' );
-    print '   }'
+    print ('   }')
     postamble()
 
 
 def trifan(intype, outtype):
     preamble(intype, outtype, prim='trifan')
-    print '  for (j = i = 0; j < nr; j+=6, i++) { '
+    print ('  for (j = i = 0; j < nr; j+=6, i++) { ')
     do_tri( intype, outtype, 'out+j',  '0', 'i+1', 'i+2' );
-    print '   }'
+    print ('   }')
     postamble()
 
 
 
 def polygon(intype, outtype):
     preamble(intype, outtype, prim='polygon')
-    print '  for (j = i = 0; j < nr; j+=6, i++) { '
+    print ('  for (j = i = 0; j < nr; j+=6, i++) { ')
     do_tri( intype, outtype, 'out+j',  '0', 'i+1', 'i+2' );
-    print '   }'
+    print ('   }')
     postamble()
 
 
 def quads(intype, outtype):
     preamble(intype, outtype, prim='quads')
-    print '  for (j = i = 0; j < nr; j+=8, i+=4) { '
+    print ('  for (j = i = 0; j < nr; j+=8, i+=4) { ')
     do_quad( intype, outtype, 'out+j', 'i+0', 'i+1', 'i+2', 'i+3' );
-    print '   }'
+    print ('   }')
     postamble()
 
 
 def quadstrip(intype, outtype):
     preamble(intype, outtype, prim='quadstrip')
-    print '  for (j = i = 0; j < nr; j+=8, i+=2) { '
+    print ('  for (j = i = 0; j < nr; j+=8, i+=2) { ')
     do_quad( intype, outtype, 'out+j', 'i+2', 'i+0', 'i+1', 'i+3' );
-    print '   }'
+    print ('   }')
     postamble()
 
 
@@ -220,19 +220,19 @@
                 init(intype, outtype, prim)
 
 def emit_init():
-    print 'void u_unfilled_init( void )'
-    print '{'
-    print '  static int firsttime = 1;'
-    print '  if (!firsttime) return;'
-    print '  firsttime = 0;'
+    print ('void u_unfilled_init( void )')
+    print ('{')
+    print ('  static int firsttime = 1;')
+    print ('  if (!firsttime) return;')
+    print ('  firsttime = 0;')
     emit_all_inits()
-    print '}'
+    print ('}')
 
 
     
 
 def epilog():
-    print '#include "indices/u_unfilled_indices.c"'
+    print ('#include "indices/u_unfilled_indices.c"')
 
 
 def main():
--- Mesa-7.8.2/src/gallium/auxiliary/util/u_format_access.py.orig	2010-06-16 03:43:42.000000000 +1000
+++ Mesa-7.8.2/src/gallium/auxiliary/util/u_format_access.py	2010-12-06 15:57:58.000000000 +1100
@@ -96,17 +96,17 @@
 
 
 def generate_srgb_tables():
-    print 'static ubyte srgb_to_linear[256] = {'
+    print ('static ubyte srgb_to_linear[256] = {')
     for i in range(256):
-        print '   %s,' % (int(math.pow((i / 255.0 + 0.055) / 1.055, 2.4) * 255))
-    print '};'
-    print
-    print 'static ubyte linear_to_srgb[256] = {'
-    print '   0,'
+        print ('   %s,' % (int(math.pow((i / 255.0 + 0.055) / 1.055, 2.4) * 255)))
+    print ('};')
+    print ('')
+    print ('static ubyte linear_to_srgb[256] = {')
+    print ('   0,')
     for i in range(1, 256):
-        print '   %s,' % (int((1.055 * math.pow(i / 255.0, 0.41666) - 0.055) * 255))
-    print '};'
-    print
+        print ('   %s,' % (int((1.055 * math.pow(i / 255.0, 0.41666) - 0.055) * 255)))
+    print ('};')
+    print ('')
 
 
 def generate_format_read(format, dst_channel, dst_native_type, dst_suffix):
@@ -116,16 +116,16 @@
 
     src_native_type = native_type(format)
 
-    print 'static void'
-    print 'util_format_%s_read_%s(%s *dst, unsigned dst_stride, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, dst_suffix, dst_native_type)
-    print '{'
-    print '   unsigned x, y;'
-    print '   const uint8_t *src_row = src + y0*src_stride;'
-    print '   %s *dst_row = dst;' % dst_native_type
-    print '   for (y = 0; y < h; ++y) {'
-    print '      const %s *src_pixel = (const %s *)(src_row + x0*%u);' % (src_native_type, src_native_type, format.stride())
-    print '      %s *dst_pixel = dst_row;' %dst_native_type
-    print '      for (x = 0; x < w; ++x) {'
+    print ('static void')
+    print ('util_format_%s_read_%s(%s *dst, unsigned dst_stride, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, dst_suffix, dst_native_type))
+    print ('{')
+    print ('   unsigned x, y;')
+    print ('   const uint8_t *src_row = src + y0*src_stride;')
+    print ('   %s *dst_row = dst;' % dst_native_type)
+    print ('   for (y = 0; y < h; ++y) {')
+    print ('      const %s *src_pixel = (const %s *)(src_row + x0*%u);' % (src_native_type, src_native_type, format.stride()))
+    print ('      %s *dst_pixel = dst_row;' %dst_native_type)
+    print ('      for (x = 0; x < w; ++x) {')
 
     names = ['']*4
     if format.colorspace == 'rgb':
@@ -144,7 +144,7 @@
 
     if format.layout == PLAIN:
         if not format.is_array():
-            print '         %s pixel = *src_pixel++;' % src_native_type
+            print ('         %s pixel = *src_pixel++;' % src_native_type)
             shift = 0;
             for i in range(4):
                 src_channel = format.channels[i]
@@ -157,7 +157,7 @@
                     if shift + width < format.block_size():
                         value = '(%s & 0x%x)' % (value, mask)
                     value = conversion_expr(src_channel, dst_channel, dst_native_type, value)
-                    print '         %s %s = %s;' % (dst_native_type, names[i], value)
+                    print ('         %s %s = %s;' % (dst_native_type, names[i], value))
                 shift += width
         else:
             for i in range(4):
@@ -165,8 +165,8 @@
                 if names[i]:
                     value = 'src_pixel[%u]' % i
                     value = conversion_expr(src_channel, dst_channel, dst_native_type, value)
-                    print '         %s %s = %s;' % (dst_native_type, names[i], value)
-            print '         src_pixel += %u;' % (format.nr_channels())
+                    print ('         %s %s = %s;' % (dst_native_type, names[i], value))
+            print ('         src_pixel += %u;' % (format.nr_channels()))
     else:
         assert False
 
@@ -188,14 +188,14 @@
                 value = get_one(dst_channel)
         else:
             assert False
-        print '         *dst_pixel++ = %s; /* %s */' % (value, 'rgba'[i])
+        print ('         *dst_pixel++ = %s; /* %s */' % (value, 'rgba'[i]))
 
-    print '      }'
-    print '      src_row += src_stride;'
-    print '      dst_row += dst_stride/sizeof(*dst_row);'
-    print '   }'
-    print '}'
-    print
+    print ('      }')
+    print ('      src_row += src_stride;')
+    print ('      dst_row += dst_stride/sizeof(*dst_row);')
+    print ('   }')
+    print ('}')
+    print ('')
     
 
 def generate_format_write(format, src_channel, src_native_type, src_suffix):
@@ -205,22 +205,22 @@
 
     dst_native_type = native_type(format)
 
-    print 'static void'
-    print 'util_format_%s_write_%s(const %s *src, unsigned src_stride, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, src_suffix, src_native_type)
-    print '{'
-    print '   unsigned x, y;'
-    print '   uint8_t *dst_row = dst + y0*dst_stride;'
-    print '   const %s *src_row = src;' % src_native_type
-    print '   for (y = 0; y < h; ++y) {'
-    print '      %s *dst_pixel = (%s *)(dst_row + x0*%u);' % (dst_native_type, dst_native_type, format.stride())
-    print '      const %s *src_pixel = src_row;' %src_native_type
-    print '      for (x = 0; x < w; ++x) {'
+    print ('static void')
+    print ('util_format_%s_write_%s(const %s *src, unsigned src_stride, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, src_suffix, src_native_type))
+    print ('{')
+    print ('   unsigned x, y;')
+    print ('   uint8_t *dst_row = dst + y0*dst_stride;')
+    print ('   const %s *src_row = src;' % src_native_type)
+    print ('   for (y = 0; y < h; ++y) {')
+    print ('      %s *dst_pixel = (%s *)(dst_row + x0*%u);' % (dst_native_type, dst_native_type, format.stride()))
+    print ('      const %s *src_pixel = src_row;' %src_native_type)
+    print ('      for (x = 0; x < w; ++x) {')
 
     inv_swizzle = format.inv_swizzles()
 
     if format.layout == PLAIN:
         if not format.is_array():
-            print '         %s pixel = 0;' % dst_native_type
+            print ('         %s pixel = 0;' % dst_native_type)
             shift = 0;
             for i in range(4):
                 dst_channel = format.channels[i]
@@ -230,26 +230,26 @@
                     value = conversion_expr(src_channel, dst_channel, dst_native_type, value)
                     if shift:
                         value = '(%s << %u)' % (value, shift)
-                    print '         pixel |= %s;' % value
+                    print ('         pixel |= %s;' % value)
                 shift += width
-            print '         *dst_pixel++ = pixel;'
+            print ('         *dst_pixel++ = pixel;')
         else:
             for i in range(4):
                 dst_channel = format.channels[i]
                 if inv_swizzle[i] is not None:
                     value = 'src_pixel[%u]' % inv_swizzle[i]
                     value = conversion_expr(src_channel, dst_channel, dst_native_type, value)
-                    print '         *dst_pixel++ = %s;' % value
+                    print ('         *dst_pixel++ = %s;' % value)
     else:
         assert False
-    print '         src_pixel += 4;'
+    print ('         src_pixel += 4;')
 
-    print '      }'
-    print '      dst_row += dst_stride;'
-    print '      src_row += src_stride/sizeof(*src_row);'
-    print '   }'
-    print '}'
-    print
+    print ('      }')
+    print ('      dst_row += dst_stride;')
+    print ('      src_row += src_stride/sizeof(*src_row);')
+    print ('   }')
+    print ('}')
+    print ('')
     
 
 def generate_read(formats, dst_channel, dst_native_type, dst_suffix):
@@ -259,23 +259,23 @@
         if is_format_supported(format):
             generate_format_read(format, dst_channel, dst_native_type, dst_suffix)
 
-    print 'void'
-    print 'util_format_read_%s(enum pipe_format format, %s *dst, unsigned dst_stride, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (dst_suffix, dst_native_type)
-    print '{'
-    print '   void (*func)(%s *dst, unsigned dst_stride, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % dst_native_type
-    print '   switch(format) {'
+    print ('void')
+    print ('util_format_read_%s(enum pipe_format format, %s *dst, unsigned dst_stride, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (dst_suffix, dst_native_type))
+    print ('{')
+    print ('   void (*func)(%s *dst, unsigned dst_stride, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % dst_native_type)
+    print ('   switch(format) {')
     for format in formats:
         if is_format_supported(format):
-            print '   case %s:' % format.name
-            print '      func = &util_format_%s_read_%s;' % (format.short_name(), dst_suffix)
-            print '      break;'
-    print '   default:'
-    print '      debug_printf("unsupported format\\n");'
-    print '      return;'
-    print '   }'
-    print '   func(dst, dst_stride, (const uint8_t *)src, src_stride, x, y, w, h);'
-    print '}'
-    print
+            print ('   case %s:' % format.name)
+            print ('      func = &util_format_%s_read_%s;' % (format.short_name(), dst_suffix))
+            print ('      break;')
+    print ('   default:')
+    print ('      debug_printf("unsupported format\\n");')
+    print ('      return;')
+    print ('   }')
+    print ('   func(dst, dst_stride, (const uint8_t *)src, src_stride, x, y, w, h);')
+    print ('}')
+    print ('')
 
 
 def generate_write(formats, src_channel, src_native_type, src_suffix):
@@ -285,24 +285,24 @@
         if is_format_supported(format):
             generate_format_write(format, src_channel, src_native_type, src_suffix)
 
-    print 'void'
-    print 'util_format_write_%s(enum pipe_format format, const %s *src, unsigned src_stride, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (src_suffix, src_native_type)
+    print ('void')
+    print ('util_format_write_%s(enum pipe_format format, const %s *src, unsigned src_stride, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (src_suffix, src_native_type))
     
-    print '{'
-    print '   void (*func)(const %s *src, unsigned src_stride, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % src_native_type
-    print '   switch(format) {'
+    print ('{')
+    print ('   void (*func)(const %s *src, unsigned src_stride, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % src_native_type)
+    print ('   switch(format) {')
     for format in formats:
         if is_format_supported(format):
-            print '   case %s:' % format.name
-            print '      func = &util_format_%s_write_%s;' % (format.short_name(), src_suffix)
-            print '      break;'
-    print '   default:'
-    print '      debug_printf("unsupported format\\n");'
-    print '      return;'
-    print '   }'
-    print '   func(src, src_stride, (uint8_t *)dst, dst_stride, x, y, w, h);'
-    print '}'
-    print
+            print ('   case %s:' % format.name)
+            print ('      func = &util_format_%s_write_%s;' % (format.short_name(), src_suffix))
+            print ('      break;')
+    print ('   default:')
+    print ('      debug_printf("unsupported format\\n");')
+    print ('      return;')
+    print ('   }')
+    print ('   func(src, src_stride, (uint8_t *)dst, dst_stride, x, y, w, h);')
+    print ('}')
+    print ('')
 
 
 def main():
@@ -310,15 +310,15 @@
     for arg in sys.argv[1:]:
         formats.extend(parse(arg))
 
-    print '/* This file is autogenerated by u_format_access.py from u_format.csv. Do not edit directly. */'
-    print
+    print ('/* This file is autogenerated by u_format_access.py from u_format.csv. Do not edit directly. */')
+    print ('')
     # This will print the copyright message on the top of this file
-    print __doc__.strip()
-    print
-    print '#include "pipe/p_compiler.h"'
-    print '#include "u_math.h"'
-    print '#include "u_format_pack.h"'
-    print
+    print (__doc__.strip())
+    print ('')
+    print ('#include "pipe/p_compiler.h"')
+    print ('#include "u_math.h"')
+    print ('#include "u_format_pack.h"')
+    print ('')
 
     generate_srgb_tables()
 
--- Mesa-7.8.2/src/gallium/auxiliary/util/u_format_pack.py.orig	2010-06-16 03:43:42.000000000 +1000
+++ Mesa-7.8.2/src/gallium/auxiliary/util/u_format_pack.py	2010-12-06 15:56:12.000000000 +1100
@@ -45,53 +45,53 @@
 def generate_format_type(format):
     '''Generate a structure that describes the format.'''
 
-    print 'union util_format_%s {' % format.short_name()
+    print ('union util_format_%s {' % format.short_name())
     if format.is_bitmask():
-        print '   uint%u_t value;' % (format.block_size(),)
-    print '   struct {'
+        print ('   uint%u_t value;' % (format.block_size(),))
+    print ('   struct {')
     for channel in format.channels:
         if format.is_bitmask() and not format.is_array():
             if channel.type == VOID:
                 if channel.size:
-                    print '      unsigned %s:%u;' % (channel.name, channel.size)
+                    print ('      unsigned %s:%u;' % (channel.name, channel.size))
             elif channel.type == UNSIGNED:
-                print '      unsigned %s:%u;' % (channel.name, channel.size)
+                print ('      unsigned %s:%u;' % (channel.name, channel.size))
             elif channel.type == SIGNED:
-                print '      int %s:%u;' % (channel.name, channel.size)
+                print ('      int %s:%u;' % (channel.name, channel.size))
             else:
                 assert 0
         else:
             assert channel.size % 8 == 0 and is_pot(channel.size)
             if channel.type == VOID:
                 if channel.size:
-                    print '      uint%u_t %s;' % (channel.size, channel.name)
+                    print ('      uint%u_t %s;' % (channel.size, channel.name))
             elif channel.type == UNSIGNED:
-                print '      uint%u_t %s;' % (channel.size, channel.name)
+                print ('      uint%u_t %s;' % (channel.size, channel.name))
             elif channel.type in (SIGNED, FIXED):
-                print '      int%u_t %s;' % (channel.size, channel.name)
+                print ('      int%u_t %s;' % (channel.size, channel.name))
             elif channel.type == FLOAT:
                 if channel.size == 64:
-                    print '      double %s;' % (channel.name)
+                    print ('      double %s;' % (channel.name))
                 elif channel.size == 32:
-                    print '      float %s;' % (channel.name)
+                    print ('      float %s;' % (channel.name))
                 elif channel.size == 16:
-                    print '      uint16_t %s;' % (channel.name)
+                    print ('      uint16_t %s;' % (channel.name))
                 else:
                     assert 0
             else:
                 assert 0
-    print '   } chan;'
-    print '};'
-    print
+    print ('   } chan;')
+    print ('};')
+    print ('')
 
 
 def bswap_format(format):
     '''Generate a structure that describes the format.'''
 
     if format.is_bitmask() and not format.is_array():
-        print '#ifdef PIPE_ARCH_BIG_ENDIAN'
-        print '   pixel.value = util_bswap%u(pixel.value);' % format.block_size()
-        print '#endif'
+        print ('#ifdef PIPE_ARCH_BIG_ENDIAN')
+        print ('   pixel.value = util_bswap%u(pixel.value);' % format.block_size())
+        print ('#endif')
 
 
 def is_format_supported(format):
@@ -192,16 +192,16 @@
         ('ui', 'unsigned int'),
         ('si', 'int'),
     ]:
-        print 'static INLINE %s' % native_type
-        print 'clamp%s(%s value, %s lbound, %s ubound)' % (suffix, native_type, native_type, native_type)
-        print '{'
-        print '   if(value < lbound)'
-        print '      return lbound;'
-        print '   if(value > ubound)'
-        print '      return ubound;'
-        print '   return value;'
-        print '}'
-        print
+        print ('static INLINE %s' % native_type)
+        print ('clamp%s(%s value, %s lbound, %s ubound)' % (suffix, native_type, native_type, native_type))
+        print ('{')
+        print ('   if(value < lbound)')
+        print ('      return lbound;')
+        print ('   if(value > ubound)')
+        print ('      return ubound;')
+        print ('   return value;')
+        print ('}')
+        print ('')
 
 
 def clamp_expr(src_channel, dst_channel, dst_native_type, value):
@@ -311,11 +311,11 @@
 
     src_native_type = native_type(format)
 
-    print 'static INLINE void'
-    print 'util_format_%s_unpack_%s(%s *dst, const void *src)' % (name, dst_suffix, dst_native_type)
-    print '{'
-    print '   union util_format_%s pixel;' % format.short_name()
-    print '   memcpy(&pixel, src, sizeof pixel);'
+    print ('static INLINE void')
+    print ('util_format_%s_unpack_%s(%s *dst, const void *src)' % (name, dst_suffix, dst_native_type))
+    print ('{')
+    print ('   union util_format_%s pixel;' % format.short_name())
+    print ('   memcpy(&pixel, src, sizeof pixel);')
     bswap_format(format)
 
     assert format.layout == PLAIN
@@ -339,10 +339,10 @@
                 value = get_one(dst_channel)
             elif i >= 1:
                 value = 'dst[0]'
-        print '   dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i])
+        print ('   dst[%u] = %s; /* %s */' % (i, value, 'rgba'[i]))
 
-    print '}'
-    print
+    print ('}')
+    print ('')
     
 
 def generate_format_pack(format, src_channel, src_native_type, src_suffix):
@@ -352,10 +352,10 @@
 
     dst_native_type = native_type(format)
 
-    print 'static INLINE void'
-    print 'util_format_%s_pack_%s(void *dst, %s r, %s g, %s b, %s a)' % (name, src_suffix, src_native_type, src_native_type, src_native_type, src_native_type)
-    print '{'
-    print '   union util_format_%s pixel;' % format.short_name()
+    print ('static INLINE void')
+    print ('util_format_%s_pack_%s(void *dst, %s r, %s g, %s b, %s a)' % (name, src_suffix, src_native_type, src_native_type, src_native_type, src_native_type))
+    print ('{')
+    print ('   union util_format_%s pixel;' % format.short_name())
 
     assert format.layout == PLAIN
 
@@ -373,12 +373,12 @@
                 value = get_one(dst_channel)
             elif i >= 1:
                 value = '0'
-        print '   pixel.chan.%s = %s;' % (dst_channel.name, value)
+        print ('   pixel.chan.%s = %s;' % (dst_channel.name, value))
 
     bswap_format(format)
-    print '   memcpy(dst, &pixel, sizeof pixel);'
-    print '}'
-    print
+    print ('   memcpy(dst, &pixel, sizeof pixel);')
+    print ('}')
+    print ('')
     
 
 def generate_unpack(formats, dst_channel, dst_native_type, dst_suffix):
@@ -388,23 +388,23 @@
         if is_format_supported(format):
             generate_format_unpack(format, dst_channel, dst_native_type, dst_suffix)
 
-    print 'static INLINE void'
-    print 'util_format_unpack_%s(enum pipe_format format, %s *dst, const void *src)' % (dst_suffix, dst_native_type)
-    print '{'
-    print '   void (*func)(%s *dst, const void *src);' % dst_native_type
-    print '   switch(format) {'
+    print ('static INLINE void')
+    print ('util_format_unpack_%s(enum pipe_format format, %s *dst, const void *src)' % (dst_suffix, dst_native_type))
+    print ('{')
+    print ('   void (*func)(%s *dst, const void *src);' % dst_native_type)
+    print ('   switch(format) {')
     for format in formats:
         if is_format_supported(format):
-            print '   case %s:' % format.name
-            print '      func = &util_format_%s_unpack_%s;' % (format.short_name(), dst_suffix)
-            print '      break;'
-    print '   default:'
-    print '      debug_printf("unsupported format\\n");'
-    print '      return;'
-    print '   }'
-    print '   func(dst, src);'
-    print '}'
-    print
+            print ('   case %s:' % format.name)
+            print ('      func = &util_format_%s_unpack_%s;' % (format.short_name(), dst_suffix))
+            print ('      break;')
+    print ('   default:')
+    print ('      debug_printf("unsupported format\\n");')
+    print ('      return;')
+    print ('   }')
+    print ('   func(dst, src);')
+    print ('}')
+    print ('')
 
 
 def generate_pack(formats, src_channel, src_native_type, src_suffix):
@@ -414,23 +414,23 @@
         if is_format_supported(format):
             generate_format_pack(format, src_channel, src_native_type, src_suffix)
 
-    print 'static INLINE void'
-    print 'util_format_pack_%s(enum pipe_format format, void *dst, %s r, %s g, %s b, %s a)' % (src_suffix, src_native_type, src_native_type, src_native_type, src_native_type)
-    print '{'
-    print '   void (*func)(void *dst, %s r, %s g, %s b, %s a);' % (src_native_type, src_native_type, src_native_type, src_native_type)
-    print '   switch(format) {'
+    print ('static INLINE void')
+    print ('util_format_pack_%s(enum pipe_format format, void *dst, %s r, %s g, %s b, %s a)' % (src_suffix, src_native_type, src_native_type, src_native_type, src_native_type))
+    print ('{')
+    print ('   void (*func)(void *dst, %s r, %s g, %s b, %s a);' % (src_native_type, src_native_type, src_native_type, src_native_type))
+    print ('   switch(format) {')
     for format in formats:
         if is_format_supported(format):
-            print '   case %s:' % format.name
-            print '      func = &util_format_%s_pack_%s;' % (format.short_name(), src_suffix)
-            print '      break;'
-    print '   default:'
-    print '      debug_printf("%s: unsupported format\\n", __FUNCTION__);'
-    print '      return;'
-    print '   }'
-    print '   func(dst, r, g, b, a);'
-    print '}'
-    print
+            print ('   case %s:' % format.name)
+            print ('      func = &util_format_%s_pack_%s;' % (format.short_name(), src_suffix))
+            print ('      break;')
+    print ('   default:')
+    print ('      debug_printf("%s: unsupported format\\n", __FUNCTION__);')
+    print ('      return;')
+    print ('   }')
+    print ('   func(dst, r, g, b, a);')
+    print ('}')
+    print ('')
 
 
 def main():
@@ -438,19 +438,19 @@
     for arg in sys.argv[1:]:
         formats.extend(parse(arg))
 
-    print '/* This file is autogenerated by u_format_pack.py from u_format.csv. Do not edit directly. */'
-    print
+    print ('/* This file is autogenerated by u_format_pack.py from u_format.csv. Do not edit directly. */')
+    print ('')
     # This will print the copyright message on the top of this file
-    print __doc__.strip()
+    print (__doc__.strip())
 
-    print
-    print '#ifndef U_FORMAT_PACK_H'
-    print '#define U_FORMAT_PACK_H'
-    print
-    print '#include "pipe/p_compiler.h"'
-    print '#include "u_math.h"'
-    print '#include "u_format.h"'
-    print
+    print ('')
+    print ('#ifndef U_FORMAT_PACK_H')
+    print ('#define U_FORMAT_PACK_H')
+    print ('')
+    print ('#include "pipe/p_compiler.h"')
+    print ('#include "u_math.h"')
+    print ('#include "u_format.h"')
+    print ('')
 
     generate_clamp()
 
@@ -472,12 +472,12 @@
     generate_unpack(formats, channel, native_type, suffix)
     generate_pack(formats, channel, native_type, suffix)
 
-    print
-    print '#ifdef __cplusplus'
-    print '}'
-    print '#endif'
-    print
-    print '#endif /* ! U_FORMAT_PACK_H */'
+    print ('')
+    print ('#ifdef __cplusplus')
+    print ('}')
+    print ('#endif')
+    print ('')
+    print ('#endif /* ! U_FORMAT_PACK_H */')
 
 
 if __name__ == '__main__':
--- Mesa-7.8.2/src/gallium/auxiliary/util/u_format_table.py.orig	2010-06-16 03:43:42.000000000 +1000
+++ Mesa-7.8.2/src/gallium/auxiliary/util/u_format_table.py	2010-12-06 15:53:55.000000000 +1100
@@ -79,38 +79,38 @@
 
 
 def write_format_table(formats):
-    print '/* This file is autogenerated by u_format_table.py from u_format.csv. Do not edit directly. */'
-    print
+    print ('/* This file is autogenerated by u_format_table.py from u_format.csv. Do not edit directly. */')
+    print ('')
     # This will print the copyright message on the top of this file
-    print __doc__.strip()
-    print
-    print '#include "u_format.h"'
-    print
-    print 'const struct util_format_description'
-    print 'util_format_none_description = {'
-    print "   PIPE_FORMAT_NONE,"
-    print "   \"PIPE_FORMAT_NONE\","
-    print "   {0, 0, 0},"
-    print "   0,"
-    print "   0,"
-    print "   0,"
-    print "   0,"
-    print "   {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},"
-    print "   {0, 0, 0, 0},"
-    print "   0"
-    print "};"
-    print
+    print (__doc__.strip())
+    print ('')
+    print ('#include "u_format.h"')
+    print ('')
+    print ('const struct util_format_description')
+    print ('util_format_none_description = {')
+    print ("   PIPE_FORMAT_NONE,")
+    print ("   \"PIPE_FORMAT_NONE\",")
+    print ("   {0, 0, 0},")
+    print ("   0,")
+    print ("   0,")
+    print ("   0,")
+    print ("   0,")
+    print ("   {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}},")
+    print ("   {0, 0, 0, 0},")
+    print ("   0")
+    print ("};")
+    print ('')
     for format in formats:
-        print 'const struct util_format_description'
-        print 'util_format_%s_description = {' % (format.short_name(),)
-        print "   %s," % (format.name,)
-        print "   \"%s\"," % (format.name,)
-        print "   {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size())
-        print "   %s," % (layout_map(format.layout),)
-        print "   %u,\t/* nr_channels */" % (format.nr_channels(),)
-        print "   %s,\t/* is_array */" % (bool_map(format.is_array()),)
-        print "   %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),)
-        print "   {"
+        print ('const struct util_format_description')
+        print ('util_format_%s_description = {' % (format.short_name(),))
+        print ("   %s," % (format.name,))
+        print ("   \"%s\"," % (format.name,))
+        print ("   {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size()))
+        print ("   %s," % (layout_map(format.layout),))
+        print ("   %u,\t/* nr_channels */" % (format.nr_channels(),))
+        print ("   %s,\t/* is_array */" % (bool_map(format.is_array()),))
+        print ("   %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),))
+        print ("   {")
         for i in range(4):
             channel = format.channels[i]
             if i < 3:
@@ -118,11 +118,11 @@
             else:
                 sep = ""
             if channel.size:
-                print "      {%s, %s, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), channel.size, sep, "xyzw"[i], channel.name)
+                print ("      {%s, %s, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), channel.size, sep, "xyzw"[i], channel.name))
             else:
-                print "      {0, 0, 0}%s" % (sep,)
-        print "   },"
-        print "   {"
+                print ("      {0, 0, 0}%s" % (sep,))
+        print ("   },")
+        print ("   {")
         for i in range(4):
             swizzle = format.swizzles[i]
             if i < 3:
@@ -133,30 +133,30 @@
                 comment = colorspace_channels_map[format.colorspace][i]
             except (KeyError, IndexError):
                 comment = 'ignored'
-            print "      %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment)
-        print "   },"
-        print "   %s," % (colorspace_map(format.colorspace),)
-        print "};"
-        print
-    print "const struct util_format_description *"
-    print "util_format_description(enum pipe_format format)"
-    print "{"
-    print "   if (format >= PIPE_FORMAT_COUNT) {"
-    print "      return NULL;"
-    print "   }"
-    print
-    print "   switch (format) {"
-    print "   case PIPE_FORMAT_NONE:"
-    print "      return &util_format_none_description;"
+            print ("      %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment))
+        print ("   },")
+        print ("   %s," % (colorspace_map(format.colorspace),))
+        print ("};")
+        print ('')
+    print ("const struct util_format_description *")
+    print ("util_format_description(enum pipe_format format)")
+    print ("{")
+    print ("   if (format >= PIPE_FORMAT_COUNT) {")
+    print ("      return NULL;")
+    print ("   }")
+    print ('')
+    print ("   switch (format) {")
+    print ("   case PIPE_FORMAT_NONE:")
+    print ("      return &util_format_none_description;")
     for format in formats:
-        print "   case %s:" % format.name
-        print "      return &util_format_%s_description;" % (format.short_name(),)
-    print "   default:"
-    print "      assert(0);"
-    print "      return NULL;"
-    print "   }"
-    print "}"
-    print
+        print ("   case %s:" % format.name)
+        print ("      return &util_format_%s_description;" % (format.short_name(),))
+    print ("   default:")
+    print ("      assert(0);")
+    print ("      return NULL;")
+    print ("   }")
+    print ("}")
+    print ('')
 
 
 def main():
--- Mesa-7.8.2/src/gallium/drivers/llvmpipe/lp_tile_soa.py.orig	2010-06-16 03:43:42.000000000 +1000
+++ Mesa-7.8.2/src/gallium/drivers/llvmpipe/lp_tile_soa.py	2010-12-06 15:52:01.000000000 +1100
@@ -52,14 +52,14 @@
 
     src_native_type = native_type(format)
 
-    print 'static void'
-    print 'lp_tile_%s_read_%s(%s *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, dst_suffix, dst_native_type)
-    print '{'
-    print '   unsigned x, y;'
-    print '   const uint8_t *src_row = src + y0*src_stride;'
-    print '   for (y = 0; y < h; ++y) {'
-    print '      const %s *src_pixel = (const %s *)(src_row + x0*%u);' % (src_native_type, src_native_type, format.stride())
-    print '      for (x = 0; x < w; ++x) {'
+    print ('static void')
+    print ('lp_tile_%s_read_%s(%s *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, dst_suffix, dst_native_type))
+    print ('{')
+    print ('   unsigned x, y;')
+    print ('   const uint8_t *src_row = src + y0*src_stride;')
+    print ('   for (y = 0; y < h; ++y) {')
+    print ('      const %s *src_pixel = (const %s *)(src_row + x0*%u);' % (src_native_type, src_native_type, format.stride()))
+    print ('      for (x = 0; x < w; ++x) {')
 
     names = ['']*4
     if format.colorspace == 'rgb':
@@ -78,7 +78,7 @@
 
     if format.layout == PLAIN:
         if not format.is_array():
-            print '         %s pixel = *src_pixel++;' % src_native_type
+            print ('         %s pixel = *src_pixel++;' % src_native_type)
             shift = 0;
             for i in range(4):
                 src_channel = format.channels[i]
@@ -91,7 +91,7 @@
                     if shift + width < format.block_size():
                         value = '(%s & 0x%x)' % (value, mask)
                     value = conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=False)
-                    print '         %s %s = %s;' % (dst_native_type, names[i], value)
+                    print ('         %s %s = %s;' % (dst_native_type, names[i], value))
                 shift += width
         else:
             for i in range(4):
@@ -99,7 +99,7 @@
                 if names[i]:
                     value = '(*src_pixel++)'
                     value = conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=False)
-                    print '         %s %s = %s;' % (dst_native_type, names[i], value)
+                    print ('         %s %s = %s;' % (dst_native_type, names[i], value))
     else:
         assert False
 
@@ -121,13 +121,13 @@
                 value = get_one(dst_channel)
         else:
             assert False
-        print '         TILE_PIXEL(dst, x, y, %u) = %s; /* %s */' % (i, value, 'rgba'[i])
+        print ('         TILE_PIXEL(dst, x, y, %u) = %s; /* %s */' % (i, value, 'rgba'[i]))
 
-    print '      }'
-    print '      src_row += src_stride;'
-    print '   }'
-    print '}'
-    print
+    print ('      }')
+    print ('      src_row += src_stride;')
+    print ('   }')
+    print ('}')
+    print ('')
     
 
 def pack_rgba(format, src_channel, r, g, b, a):
@@ -171,29 +171,29 @@
     This is considerably faster than the TILE_PIXEL-based code below.
     '''
     dst_native_type = 'uint%u_t' % format.block_size()
-    print '   const unsigned dstpix_stride = dst_stride / %d;' % format.stride()
-    print '   %s *dstpix = (%s *) dst;' % (dst_native_type, dst_native_type)
-    print '   unsigned int qx, qy, i;'
-    print
-    print '   for (qy = 0; qy < h; qy += TILE_VECTOR_HEIGHT) {'
-    print '      const unsigned py = y0 + qy;'
-    print '      for (qx = 0; qx < w; qx += TILE_VECTOR_WIDTH) {'
-    print '         const unsigned px = x0 + qx;'
-    print '         const uint8_t *r = src + 0 * TILE_C_STRIDE;'
-    print '         const uint8_t *g = src + 1 * TILE_C_STRIDE;'
-    print '         const uint8_t *b = src + 2 * TILE_C_STRIDE;'
-    print '         const uint8_t *a = src + 3 * TILE_C_STRIDE;'
-    print '         (void) r; (void) g; (void) b; (void) a; /* silence warnings */'
-    print '         for (i = 0; i < TILE_C_STRIDE; i += 2) {'
-    print '            const uint32_t pixel0 = %s;' % pack_rgba(format, src_channel, "r[i+0]", "g[i+0]", "b[i+0]", "a[i+0]")
-    print '            const uint32_t pixel1 = %s;' % pack_rgba(format, src_channel, "r[i+1]", "g[i+1]", "b[i+1]", "a[i+1]")
-    print '            const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]);'
-    print '            dstpix[offset + 0] = pixel0;'
-    print '            dstpix[offset + 1] = pixel1;'
-    print '         }'
-    print '         src += TILE_X_STRIDE;'
-    print '      }'
-    print '   }'
+    print ('   const unsigned dstpix_stride = dst_stride / %d;' % format.stride())
+    print ('   %s *dstpix = (%s *) dst;' % (dst_native_type, dst_native_type))
+    print ('   unsigned int qx, qy, i;')
+    print ('')
+    print ('   for (qy = 0; qy < h; qy += TILE_VECTOR_HEIGHT) {')
+    print ('      const unsigned py = y0 + qy;')
+    print ('      for (qx = 0; qx < w; qx += TILE_VECTOR_WIDTH) {')
+    print ('         const unsigned px = x0 + qx;')
+    print ('         const uint8_t *r = src + 0 * TILE_C_STRIDE;')
+    print ('         const uint8_t *g = src + 1 * TILE_C_STRIDE;')
+    print ('         const uint8_t *b = src + 2 * TILE_C_STRIDE;')
+    print ('         const uint8_t *a = src + 3 * TILE_C_STRIDE;')
+    print ('         (void) r; (void) g; (void) b; (void) a; /* silence warnings */')
+    print ('         for (i = 0; i < TILE_C_STRIDE; i += 2) {')
+    print ('            const uint32_t pixel0 = %s;' % pack_rgba(format, src_channel, "r[i+0]", "g[i+0]", "b[i+0]", "a[i+0]"))
+    print ('            const uint32_t pixel1 = %s;' % pack_rgba(format, src_channel, "r[i+1]", "g[i+1]", "b[i+1]", "a[i+1]"))
+    print ('            const unsigned offset = (py + tile_y_offset[i]) * dstpix_stride + (px + tile_x_offset[i]);')
+    print ('            dstpix[offset + 0] = pixel0;')
+    print ('            dstpix[offset + 1] = pixel1;')
+    print ('         }')
+    print ('         src += TILE_X_STRIDE;')
+    print ('      }')
+    print ('   }')
 
 
 def emit_tile_pixel_write_code(format, src_channel):
@@ -202,15 +202,15 @@
 
     inv_swizzle = format.inv_swizzles()
 
-    print '   unsigned x, y;'
-    print '   uint8_t *dst_row = dst + y0*dst_stride;'
-    print '   for (y = 0; y < h; ++y) {'
-    print '      %s *dst_pixel = (%s *)(dst_row + x0*%u);' % (dst_native_type, dst_native_type, format.stride())
-    print '      for (x = 0; x < w; ++x) {'
+    print ('   unsigned x, y;')
+    print ('   uint8_t *dst_row = dst + y0*dst_stride;')
+    print ('   for (y = 0; y < h; ++y) {')
+    print ('      %s *dst_pixel = (%s *)(dst_row + x0*%u);' % (dst_native_type, dst_native_type, format.stride()))
+    print ('      for (x = 0; x < w; ++x) {')
 
     if format.layout == PLAIN:
         if not format.is_array():
-            print '         %s pixel = 0;' % dst_native_type
+            print ('         %s pixel = 0;' % dst_native_type)
             shift = 0;
             for i in range(4):
                 dst_channel = format.channels[i]
@@ -220,22 +220,22 @@
                     value = conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=False)
                     if shift:
                         value = '(%s << %u)' % (value, shift)
-                    print '         pixel |= %s;' % value
+                    print ('         pixel |= %s;' % value)
                 shift += width
-            print '         *dst_pixel++ = pixel;'
+            print ('         *dst_pixel++ = pixel;')
         else:
             for i in range(4):
                 dst_channel = format.channels[i]
                 if inv_swizzle[i] is not None:
                     value = 'TILE_PIXEL(src, x, y, %u)' % inv_swizzle[i]
                     value = conversion_expr(src_channel, dst_channel, dst_native_type, value, clamp=False)
-                    print '         *dst_pixel++ = %s;' % value
+                    print ('         *dst_pixel++ = %s;' % value)
     else:
         assert False
 
-    print '      }'
-    print '      dst_row += dst_stride;'
-    print '   }'
+    print ('      }')
+    print ('      dst_row += dst_stride;')
+    print ('   }')
 
 
 def generate_format_write(format, src_channel, src_native_type, src_suffix):
@@ -243,9 +243,9 @@
 
     name = format.short_name()
 
-    print 'static void'
-    print 'lp_tile_%s_write_%s(const %s *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, src_suffix, src_native_type)
-    print '{'
+    print ('static void')
+    print ('lp_tile_%s_write_%s(const %s *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h)' % (name, src_suffix, src_native_type))
+    print ('{')
     if format.layout == PLAIN \
         and format.colorspace == 'rgb' \
         and format.block_size() <= 32 \
@@ -255,8 +255,8 @@
         emit_unrolled_write_code(format, src_channel)
     else:
         emit_tile_pixel_write_code(format, src_channel)
-    print '}'
-    print
+    print ('}')
+    print ('')
     
 
 def generate_read(formats, dst_channel, dst_native_type, dst_suffix):
@@ -266,23 +266,23 @@
         if is_format_supported(format):
             generate_format_read(format, dst_channel, dst_native_type, dst_suffix)
 
-    print 'void'
-    print 'lp_tile_read_%s(enum pipe_format format, %s *dst, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (dst_suffix, dst_native_type)
-    print '{'
-    print '   void (*func)(%s *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % dst_native_type
-    print '   switch(format) {'
+    print ('void')
+    print ('lp_tile_read_%s(enum pipe_format format, %s *dst, const void *src, unsigned src_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (dst_suffix, dst_native_type))
+    print ('{')
+    print ('   void (*func)(%s *dst, const uint8_t *src, unsigned src_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % dst_native_type)
+    print ('   switch(format) {')
     for format in formats:
         if is_format_supported(format):
-            print '   case %s:' % format.name
-            print '      func = &lp_tile_%s_read_%s;' % (format.short_name(), dst_suffix)
-            print '      break;'
-    print '   default:'
-    print '      debug_printf("unsupported format\\n");'
-    print '      return;'
-    print '   }'
-    print '   func(dst, (const uint8_t *)src, src_stride, x, y, w, h);'
-    print '}'
-    print
+            print ('   case %s:' % format.name)
+            print ('      func = &lp_tile_%s_read_%s;' % (format.short_name(), dst_suffix))
+            print ('      break;')
+    print ('   default:')
+    print ('      debug_printf("unsupported format\\n");')
+    print ('      return;')
+    print ('   }')
+    print ('   func(dst, (const uint8_t *)src, src_stride, x, y, w, h);')
+    print ('}')
+    print ('')
 
 
 def generate_write(formats, src_channel, src_native_type, src_suffix):
@@ -292,24 +292,24 @@
         if is_format_supported(format):
             generate_format_write(format, src_channel, src_native_type, src_suffix)
 
-    print 'void'
-    print 'lp_tile_write_%s(enum pipe_format format, const %s *src, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (src_suffix, src_native_type)
+    print ('void')
+    print ('lp_tile_write_%s(enum pipe_format format, const %s *src, void *dst, unsigned dst_stride, unsigned x, unsigned y, unsigned w, unsigned h)' % (src_suffix, src_native_type))
     
-    print '{'
-    print '   void (*func)(const %s *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % src_native_type
-    print '   switch(format) {'
+    print ('{')
+    print ('   void (*func)(const %s *src, uint8_t *dst, unsigned dst_stride, unsigned x0, unsigned y0, unsigned w, unsigned h);' % src_native_type)
+    print ('   switch(format) {')
     for format in formats:
         if is_format_supported(format):
-            print '   case %s:' % format.name
-            print '      func = &lp_tile_%s_write_%s;' % (format.short_name(), src_suffix)
-            print '      break;'
-    print '   default:'
-    print '      debug_printf("unsupported format\\n");'
-    print '      return;'
-    print '   }'
-    print '   func(src, (uint8_t *)dst, dst_stride, x, y, w, h);'
-    print '}'
-    print
+            print ('   case %s:' % format.name)
+            print ('      func = &lp_tile_%s_write_%s;' % (format.short_name(), src_suffix))
+            print ('      break;')
+    print ('   default:')
+    print ('      debug_printf("unsupported format\\n");')
+    print ('      return;')
+    print ('   }')
+    print ('   func(src, (uint8_t *)dst, dst_stride, x, y, w, h);')
+    print ('}')
+    print ('')
 
 
 def main():
@@ -317,37 +317,37 @@
     for arg in sys.argv[1:]:
         formats.extend(parse(arg))
 
-    print '/* This file is autogenerated by lp_tile_soa.py from u_format.csv. Do not edit directly. */'
-    print
+    print ('/* This file is autogenerated by lp_tile_soa.py from u_format.csv. Do not edit directly. */')
+    print ('')
     # This will print the copyright message on the top of this file
-    print __doc__.strip()
-    print
-    print '#include "pipe/p_compiler.h"'
-    print '#include "util/u_format.h"'
-    print '#include "util/u_math.h"'
-    print '#include "lp_tile_soa.h"'
-    print
-    print 'const unsigned char'
-    print 'tile_offset[TILE_VECTOR_HEIGHT][TILE_VECTOR_WIDTH] = {'
-    print '   {  0,  1,  4,  5},'
-    print '   {  2,  3,  6,  7},'
-    print '   {  8,  9, 12, 13},'
-    print '   { 10, 11, 14, 15}'
-    print '};'
-    print
-    print '/* Note: these lookup tables could be replaced with some'
-    print ' * bit-twiddling code, but this is a little faster.'
-    print ' */'
-    print 'static unsigned tile_x_offset[TILE_VECTOR_WIDTH * TILE_VECTOR_HEIGHT] = {'
-    print '   0, 1, 0, 1, 2, 3, 2, 3,'
-    print '   0, 1, 0, 1, 2, 3, 2, 3'
-    print '};'
-    print
-    print 'static unsigned tile_y_offset[TILE_VECTOR_WIDTH * TILE_VECTOR_HEIGHT] = {'
-    print '   0, 0, 1, 1, 0, 0, 1, 1,'
-    print '   2, 2, 3, 3, 2, 2, 3, 3'
-    print '};'
-    print
+    print (__doc__.strip())
+    print ('')
+    print ('#include "pipe/p_compiler.h"')
+    print ('#include "util/u_format.h"')
+    print ('#include "util/u_math.h"')
+    print ('#include "lp_tile_soa.h"')
+    print ('')
+    print ('const unsigned char')
+    print ('tile_offset[TILE_VECTOR_HEIGHT][TILE_VECTOR_WIDTH] = {')
+    print ('   {  0,  1,  4,  5},')
+    print ('   {  2,  3,  6,  7},')
+    print ('   {  8,  9, 12, 13},')
+    print ('   { 10, 11, 14, 15}')
+    print ('};')
+    print ('')
+    print ('/* Note: these lookup tables could be replaced with some')
+    print (' * bit-twiddling code, but this is a little faster.')
+    print (' */')
+    print ('static unsigned tile_x_offset[TILE_VECTOR_WIDTH * TILE_VECTOR_HEIGHT] = {')
+    print ('   0, 1, 0, 1, 2, 3, 2, 3,')
+    print ('   0, 1, 0, 1, 2, 3, 2, 3')
+    print ('};')
+    print ('')
+    print ('static unsigned tile_y_offset[TILE_VECTOR_WIDTH * TILE_VECTOR_HEIGHT] = {')
+    print ('   0, 0, 1, 1, 0, 0, 1, 1,')
+    print ('   2, 2, 3, 3, 2, 2, 3, 3')
+    print ('};')
+    print ('')
 
     generate_clamp()
 
--- Mesa-7.8.2/src/gallium/drivers/svga/svgadump/svga_dump.py.orig	2010-04-28 07:41:21.000000000 +1000
+++ Mesa-7.8.2/src/gallium/drivers/svga/svgadump/svga_dump.py	2010-12-06 15:50:00.000000000 +1100
@@ -63,22 +63,22 @@
 
         for variable in class_.variables():
             if variable.name != '':
-                #print 'variable = %r' % variable.name
+                #print ('variable = %r' % variable.name)
                 dump_type(self._instance + '.' + variable.name, variable.type)
 
     def visit_enumeration(self):
         if enums:
-            print '   switch(%s) {' % ("(*cmd)" + self._instance,)
+            print ('   switch(%s) {' % ("(*cmd)" + self._instance,))
             for name, value in self.decl.values:
-                print '   case %s:' % (name,)
-                print '      _debug_printf("\\t\\t%s = %s\\n");' % (self._instance, name)
-                print '      break;'
-            print '   default:'
-            print '      _debug_printf("\\t\\t%s = %%i\\n", %s);' % (self._instance, "(*cmd)" + self._instance)
-            print '      break;'
-            print '   }'
+                print ('   case %s:' % (name,))
+                print ('      _debug_printf("\\t\\t%s = %s\\n");' % (self._instance, name))
+                print ('      break;')
+            print ('   default:')
+            print ('      _debug_printf("\\t\\t%s = %%i\\n", %s);' % (self._instance, "(*cmd)" + self._instance))
+            print ('      break;')
+            print ('   }')
         else:
-            print '   _debug_printf("\\t\\t%s = %%i\\n", %s);' % (self._instance, "(*cmd)" + self._instance)
+            print ('   _debug_printf("\\t\\t%s = %%i\\n", %s);' % (self._instance, "(*cmd)" + self._instance))
 
 
 def dump_decl(instance, decl):
@@ -149,12 +149,12 @@
         self.print_instance('%p')
 
     def visit_declarated(self):
-        #print 'decl = %r' % self.type.decl_string
+        #print ('decl = %r' % self.type.decl_string)
         decl = type_traits.remove_declarated(self.type)
         dump_decl(self.instance, decl)
 
     def print_instance(self, format):
-        print '   _debug_printf("\\t\\t%s = %s\\n", %s);' % (self.instance, format, "(*cmd)" + self.instance)
+        print ('   _debug_printf("\\t\\t%s = %s\\n", %s);' % (self.instance, format, "(*cmd)" + self.instance))
 
 
 def dump_type(instance, type_):
@@ -164,12 +164,12 @@
 
 
 def dump_struct(decls, class_):
-    print 'static void'
-    print 'dump_%s(const %s *cmd)' % (class_.name, class_.name)
-    print '{'
+    print ('static void')
+    print ('dump_%s(const %s *cmd)' % (class_.name, class_.name))
+    print ('{')
     dump_decl('', class_)
-    print '}'
-    print ''
+    print ('}')
+    print ('')
 
 
 cmds = [
@@ -206,48 +206,48 @@
 ]
 
 def dump_cmds():
-    print r'''
+    print (r'''
 void            
 svga_dump_command(uint32_t cmd_id, const void *data, uint32_t size)
 {
    const uint8_t *body = (const uint8_t *)data;
    const uint8_t *next = body + size;
-'''
-    print '   switch(cmd_id) {'
+''')
+    print ('   switch(cmd_id) {')
     indexes = 'ijklmn'
     for id, header, body, footer in cmds:
-        print '   case %s:' % id
-        print '      _debug_printf("\\t%s\\n");' % id
-        print '      {'
-        print '         const %s *cmd = (const %s *)body;' % (header, header)
+        print ('   case %s:' % id)
+        print ('      _debug_printf("\\t%s\\n");' % id)
+        print ('      {')
+        print ('         const %s *cmd = (const %s *)body;' % (header, header))
         if len(body):
-            print '         unsigned ' + ', '.join(indexes[:len(body)]) + ';'
-        print '         dump_%s(cmd);' % header
-        print '         body = (const uint8_t *)&cmd[1];'
+            print ('         unsigned ' + ', '.join(indexes[:len(body)]) + ';')
+        print ('         dump_%s(cmd);' % header)
+        print ('         body = (const uint8_t *)&cmd[1];')
         for i in range(len(body)):
             struct, count = body[i]
             idx = indexes[i]
-            print '         for(%s = 0; %s < cmd->%s; ++%s) {' % (idx, idx, count, idx)
-            print '            dump_%s((const %s *)body);' % (struct, struct)
-            print '            body += sizeof(%s);' % struct
-            print '         }'
+            print ('         for(%s = 0; %s < cmd->%s; ++%s) {' % (idx, idx, count, idx))
+            print ('            dump_%s((const %s *)body);' % (struct, struct))
+            print ('            body += sizeof(%s);' % struct)
+            print ('         }')
         if footer is not None:
-            print '         while(body + sizeof(%s) <= next) {' % footer
-            print '            dump_%s((const %s *)body);' % (footer, footer)
-            print '            body += sizeof(%s);' % footer
-            print '         }'
+            print ('         while(body + sizeof(%s) <= next) {' % footer)
+            print ('            dump_%s((const %s *)body);' % (footer, footer))
+            print ('            body += sizeof(%s);' % footer)
+            print ('         }')
         if id == 'SVGA_3D_CMD_SHADER_DEFINE':
-            print '         svga_shader_dump((const uint32_t *)body,'
-            print '                          (unsigned)(next - body)/sizeof(uint32_t),'
-            print '                          FALSE);'
-            print '         body = next;'
-        print '      }'
-        print '      break;'
-    print '   default:'
-    print '      _debug_printf("\\t0x%08x\\n", cmd_id);'
-    print '      break;'
-    print '   }'
-    print r'''
+            print ('         svga_shader_dump((const uint32_t *)body,')
+            print ('                          (unsigned)(next - body)/sizeof(uint32_t),')
+            print ('                          FALSE);')
+            print ('         body = next;')
+        print ('      }')
+        print ('      break;')
+    print ('   default:')
+    print ('      _debug_printf("\\t0x%08x\\n", cmd_id);')
+    print ('      break;')
+    print ('   }')
+    print (r'''
    while(body + sizeof(uint32_t) <= next) {
       _debug_printf("\t\t0x%08x\n", *(const uint32_t *)body);
       body += sizeof(uint32_t);
@@ -255,8 +255,8 @@
    while(body + sizeof(uint32_t) <= next)
       _debug_printf("\t\t0x%02x\n", *body++);
 }
-'''
-    print r'''
+''')
+    print (r'''
 void            
 svga_dump_commands(const void *commands, uint32_t size)
 {
@@ -289,25 +289,25 @@
       }
    }
 }
-'''
+''')
 
 def main():
-    print copyright.strip()
-    print
-    print '/**'
-    print ' * @file'
-    print ' * Dump SVGA commands.'
-    print ' *'
-    print ' * Generated automatically from svga3d_reg.h by svga_dump.py.'
-    print ' */'
-    print
-    print '#include "svga_types.h"'
-    print '#include "svga_shader_dump.h"'
-    print '#include "svga3d_reg.h"'
-    print
-    print '#include "util/u_debug.h"'
-    print '#include "svga_dump.h"'
-    print
+    print (copyright.strip())
+    print ('')
+    print ('/**')
+    print (' * @file')
+    print (' * Dump SVGA commands.')
+    print (' *')
+    print (' * Generated automatically from svga3d_reg.h by svga_dump.py.')
+    print (' */')
+    print ('')
+    print ('#include "svga_types.h"')
+    print ('#include "svga_shader_dump.h"')
+    print ('#include "svga3d_reg.h"')
+    print ('')
+    print ('#include "util/u_debug.h"')
+    print ('#include "svga_dump.h"')
+    print ('')
 
     config = parser.config_t(
         include_paths = ['../../../include', '../include'],
--- Mesa-7.8.2/src/mesa/es/glapi/gl_compare.py.orig	2010-06-16 03:43:42.000000000 +1000
+++ Mesa-7.8.2/src/mesa/es/glapi/gl_compare.py	2010-12-06 15:47:52.000000000 +1100
@@ -226,10 +226,10 @@
 
     # no child
     if not e.functions:
-        print '%s<enum %s/>' % (spaces(indent), attrs)
+        print ('%s<enum %s/>' % (spaces(indent), attrs))
         return
 
-    print '%s<enum %s>' % (spaces(indent), attrs)
+    print ('%s<enum %s>' % (spaces(indent), attrs))
     for key, val in e.functions.iteritems():
         attrs = 'name="%s"' % key
         if val[0] != e.default_count:
@@ -237,9 +237,9 @@
         if not val[1]:
             attrs += ' mode="get"'
 
-        print '%s<size %s/>' % (spaces(indent * 2), attrs)
+        print ('%s<size %s/>' % (spaces(indent * 2), attrs))
 
-    print '%s</enum>' % spaces(indent)
+    print ('%s</enum>' % spaces(indent))
 
 def output_type(t, indent=0):
     tab = spaces(16, t.name)
@@ -249,7 +249,7 @@
         attrs += ' unsigned="true"'
     elif ctype.find("signed") == -1:
         attrs += ' float="true"'
-    print '%s<type %s/>' % (spaces(indent), attrs)
+    print ('%s<type %s/>' % (spaces(indent), attrs))
 
 def output_function(f, indent=0):
     attrs = 'name="%s"' % f.name
@@ -258,17 +258,17 @@
             attrs += ' offset="assign"'
         else:
             attrs += ' offset="%d"' % f.offset
-    print '%s<function %s>' % (spaces(indent), attrs)
+    print ('%s<function %s>' % (spaces(indent), attrs))
 
     for p in f.parameters:
         attrs = 'name="%s" type="%s"' \
                 % (p.name, p.type_expr.original_string)
-        print '%s<param %s/>' % (spaces(indent * 2), attrs)
+        print ('%s<param %s/>' % (spaces(indent * 2), attrs))
     if f.return_type != "void":
         attrs = 'type="%s"' % f.return_type
-        print '%s<return %s/>' % (spaces(indent * 2), attrs)
+        print ('%s<return %s/>' % (spaces(indent * 2), attrs))
 
-    print '%s</function>' % spaces(indent)
+    print ('%s</function>' % spaces(indent))
 
 def output_category(api, indent=0):
     enums = api.enums_by_name.values()
@@ -281,15 +281,15 @@
     for e in enums:
         output_enum(e, indent)
     if enums and types:
-        print
+        print ('')
     for t in types:
         output_type(t, indent)
     if enums or types:
-        print
+        print ('')
     for f in functions:
         output_function(f, indent)
         if f != functions[-1]:
-            print
+            print ('')
 
 def is_api_empty(api):
     return bool(not api.enums_by_name and
@@ -297,9 +297,9 @@
                 not api.functions_by_name)
 
 def show_usage(ops):
-    print "Usage: %s [-k elts] <%s> <file1> <file2>" % (sys.argv[0], "|".join(ops))
-    print "    -k elts   A comma separated string of types of elements to"
-    print "              skip.  Possible types are enum, type, and function."
+    print ("Usage: %s [-k elts] <%s> <file1> <file2>" % (sys.argv[0], "|".join(ops)))
+    print ("    -k elts   A comma separated string of types of elements to")
+    print ("              skip.  Possible types are enum, type, and function.")
     sys.exit(1)
 
 def main():
@@ -339,16 +339,16 @@
         cat_name = "%s_of_%s_and_%s" \
                 % (op, os.path.basename(file1), os.path.basename(file2))
 
-        print '<?xml version="1.0"?>'
-        print '<!DOCTYPE OpenGLAPI SYSTEM "%s/gl_API.dtd">' % GLAPI
-        print
-        print '<OpenGLAPI>'
-        print
-        print '<category name="%s">' % (cat_name)
+        print ('<?xml version="1.0"?>')
+        print ('<!DOCTYPE OpenGLAPI SYSTEM "%s/gl_API.dtd">' % GLAPI)
+        print ('')
+        print ('<OpenGLAPI>')
+        print ('')
+        print ('<category name="%s">' % (cat_name))
         output_category(result, 4)
-        print '</category>'
-        print
-        print '</OpenGLAPI>'
+        print ('</category>')
+        print ('')
+        print ('</OpenGLAPI>')
 
 if __name__ == "__main__":
     main()
--- Mesa-7.8.2/src/mesa/es/glapi/gl_parse_header.py.orig	2010-06-16 03:43:42.000000000 +1000
+++ Mesa-7.8.2/src/mesa/es/glapi/gl_parse_header.py	2010-12-06 15:46:41.000000000 +1100
@@ -106,7 +106,7 @@
         m = self.DEFINE.search(line)
         if not m:
             if self.verbose and line.find("#define") >= 0:
-                print "ignore %s" % (line)
+                print ("ignore %s" % (line))
             return None
 
         key = m.group("key").strip()
@@ -116,7 +116,7 @@
         if ((not (key.startswith("GL_") and key.isupper())) or
             (self.ignore_enum.match(key) and val == "1")):
             if self.verbose:
-                print "ignore enum %s" % (key)
+                print ("ignore enum %s" % (key))
             return None
 
         return (key, val)
@@ -126,14 +126,14 @@
         m = self.TYPEDEF.search(line)
         if not m:
             if self.verbose and line.find("typedef") >= 0:
-                print "ignore %s" % (line)
+                print ("ignore %s" % (line))
             return None
 
         f = m.group("from").strip()
         t = m.group("to").strip()
         if not t.startswith("GL"):
             if self.verbose:
-                print "ignore type %s" % (t)
+                print ("ignore type %s" % (t))
             return None
         attrs = self._get_ctype_attrs(f)
 
@@ -144,7 +144,7 @@
         m = self.GLAPI.search(line)
         if not m:
             if self.verbose and line.find("APIENTRY") >= 0:
-                print "ignore %s" % (line)
+                print ("ignore %s" % (line))
             return None
 
         rettype = m.group("return")
@@ -213,7 +213,7 @@
             lines = fp.readlines()
             fp.close()
         except IOError, e:
-            print "failed to read %s: %s" % (header, e)
+            print ("failed to read %s: %s" % (header, e))
         return lines
 
     def _cmp_enum(self, enum1, enum2):
@@ -287,7 +287,7 @@
             for i in dup:
                 e = cat["enums"].pop(i)
                 if self.verbose:
-                    print "remove duplicate enum %s" % e[0]
+                    print ("remove duplicate enum %s" % e[0])
 
             cat["types"].sort(self._cmp_type)
             cat["functions"].sort(self._cmp_function)
@@ -305,7 +305,7 @@
         self._reset()
 
         if self.verbose:
-            print "Parsing %s" % (header)
+            print ("Parsing %s" % (header))
 
         hdict = {}
         lines = self._read_header(header)
@@ -347,7 +347,7 @@
 
         if self.need_char:
             if self.verbose:
-                print "define GLchar"
+                print ("define GLchar")
             elem = self._parse_typedef("typedef char GLchar;")
             cat["types"].append(elem)
         return self._postprocess_dict(hdict)
@@ -364,7 +364,7 @@
     for i in xrange(len(hlist)):
         cat_name, cat = hlist[i]
 
-        print '<category name="%s">' % (cat_name)
+        print ('<category name="%s">' % (cat_name))
         indent = 4
 
         for enum in cat["enums"]:
@@ -372,10 +372,10 @@
             value = enum[1]
             tab = spaces(41, name)
             attrs = 'name="%s"%svalue="%s"' % (name, tab, value)
-            print '%s<enum %s/>' % (spaces(indent), attrs)
+            print ('%s<enum %s/>' % (spaces(indent), attrs))
 
         if cat["enums"] and cat["types"]:
-            print
+            print ('')
 
         for type in cat["types"]:
             ctype = type[0]
@@ -388,31 +388,31 @@
             elif not is_signed:
                 attrs += ' unsigned="true"'
 
-            print '%s<type %s/>' % (spaces(indent), attrs)
+            print ('%s<type %s/>' % (spaces(indent), attrs))
 
         for func in cat["functions"]:
-            print
+            print ('')
             ret = func[0]
             name = func[1][2:]
             params = func[2]
 
             attrs = 'name="%s" offset="assign"' % name
-            print '%s<function %s>' % (spaces(indent), attrs)
+            print ('%s<function %s>' % (spaces(indent), attrs))
 
             for param in params:
                 attrs = 'name="%s" type="%s"' % (param[1], param[0])
-                print '%s<param %s/>' % (spaces(indent * 2), attrs)
+                print ('%s<param %s/>' % (spaces(indent * 2), attrs))
             if ret:
                 attrs = 'type="%s"' % ret
-                print '%s<return %s/>' % (spaces(indent * 2), attrs)
+                print ('%s<return %s/>' % (spaces(indent * 2), attrs))
 
-            print '%s</function>' % spaces(indent)
+            print ('%s</function>' % spaces(indent))
 
-        print '</category>'
-        print
+        print ('</category>')
+        print ('')
 
 def show_usage():
-    print "Usage: %s [-v] <header> ..." % sys.argv[0]
+    print ("Usage: %s [-v] <header> ..." % sys.argv[0])
     sys.exit(1)
 
 def main():
@@ -435,16 +435,16 @@
         hlist = parser.parse(h)
 
         if need_xml_header:
-            print '<?xml version="1.0"?>'
-            print '<!DOCTYPE OpenGLAPI SYSTEM "%s/gl_API.dtd">' % GLAPI
+            print ('<?xml version="1.0"?>')
+            print ('<!DOCTYPE OpenGLAPI SYSTEM "%s/gl_API.dtd">' % GLAPI)
             need_xml_header = False
 
-        print
-        print '<!-- %s -->' % (h)
-        print '<OpenGLAPI>'
-        print
+        print ('')
+        print ('<!-- %s -->' % (h))
+        print ('<OpenGLAPI>')
+        print ('')
         output_xml(h, hlist)
-        print '</OpenGLAPI>'
+        print ('</OpenGLAPI>')
 
 if __name__ == '__main__':
     main()
--- Mesa-7.8.2/src/mesa/es/main/APIspec.py.orig	2010-06-16 03:43:42.000000000 +1000
+++ Mesa-7.8.2/src/mesa/es/main/APIspec.py	2010-12-06 15:45:38.000000000 +1100
@@ -431,7 +431,7 @@
         stmts = []
         for name in self.switches.iterkeys():
             c_switch = self._c_switch(name)
-            print "\n".join(c_switch)
+            print ("\n".join(c_switch))
 
 
 class Description(object):
@@ -610,7 +610,7 @@
 
     doc.freeDoc()
 
-    print "%s is successfully parsed" % filename
+    print ("%s is successfully parsed" % filename)
 
 
 if __name__ == "__main__":
--- Mesa-7.8.2/src/mesa/es/main/APIspecutil.py.orig	2010-06-16 03:43:42.000000000 +1000
+++ Mesa-7.8.2/src/mesa/es/main/APIspecutil.py	2010-12-06 15:45:28.000000000 +1100
@@ -61,7 +61,7 @@
         if not alias:
             # external functions are manually dispatched
             if not func.is_external:
-                print >>sys.stderr, "Error: unable to dispatch %s" % func.name
+                sys.stderr.write("Error: unable to dispatch %s\n" % func.name)
             alias = func
             need_conv = False
 
@@ -119,15 +119,15 @@
 
         items = desc.checker.switches.items()
         if len(items) > 1:
-            print >>sys.stderr, "%s: more than one parameter depend on %s" % \
-                    (func.name, desc.name)
+            sys.stderr.write("%s: more than one parameter depend on %s\n" % \
+                    (func.name, desc.name))
         dep_name, dep_switch = items[0]
 
         for dep_desc in dep_switch:
             if dep_desc.index >= 0 and dep_desc.index != 0:
-                print >>sys.stderr, "%s: not first element of a vector" % func.name
+                sys.stderr.write("%s: not first element of a vector\n" % func.name)
             if dep_desc.checker.switches:
-                print >>sys.stderr, "%s: deep nested dependence" % func.name
+                sys.stderr.write("%s: deep nested dependence\n" % func.name)
 
             convert = None if dep_desc.convert else "noconvert"
             for val in desc.values:
@@ -188,9 +188,9 @@
     if not size:
         need_conv = __aliases[func.name][1]
         if need_conv:
-            print >>sys.stderr, \
-                    "Error: unable to dicide the max size of %s in %s" % \
-                    (param.name, func.name)
+            sys.stderr.write( \
+                    "Error: unable to dicide the max size of %s in %s\n" % \
+                    (param.name, func.name))
     return size
 
 
--- Mesa-7.8.2/src/mesa/es/main/es_generator.py.orig	2010-06-16 03:43:42.000000000 +1000
+++ Mesa-7.8.2/src/mesa/es/main/es_generator.py	2010-12-06 15:43:58.000000000 +1100
@@ -70,11 +70,11 @@
     type-converted if necessary."""
 
     if not Converters.has_key(fromType):
-        print >> sys.stderr, "No base converter for type '%s' found.  Ignoring." % fromType
+        sys.stderr.write("No base converter for type '%s' found.  Ignoring.\n" % fromType)
         return value
 
     if not Converters[fromType].has_key(toType):
-        print >> sys.stderr, "No converter found for type '%s' to type '%s'.  Ignoring." % (fromType, toType)
+        sys.stderr.write("No converter found for type '%s' to type '%s'.  Ignoring.\n" % (fromType, toType))
         return value
 
     # This part is simple.  Return the proper conversion.
@@ -175,22 +175,22 @@
 
 allSpecials = apiutil.AllSpecials()
 
-print """/* DO NOT EDIT *************************************************
+print ("""/* DO NOT EDIT *************************************************
  * THIS FILE AUTOMATICALLY GENERATED BY THE %s SCRIPT
  * API specification file:   %s
  * GLES version:             %s
  * date:                     %s
  */
-""" % (program, functionList, version, time.strftime("%Y-%m-%d %H:%M:%S"))
+""" % (program, functionList, version, time.strftime("%Y-%m-%d %H:%M:%S")))
 
 # The headers we choose are version-specific.
-print """
+print ("""
 #include "%s"
 #include "%s"
-""" % (versionHeader, versionExtHeader)
+""" % (versionHeader, versionExtHeader))
 
 # Everyone needs these types.
-print """
+print ("""
 /* These types are needed for the Mesa veneer, but are not defined in
  * the standard GLES headers.
  */
@@ -210,13 +210,13 @@
 #include "main/dispatch.h"
 
 typedef void (*_glapi_proc)(void); /* generic function pointer */
-"""
+""")
 
 # Finally we get to the all-important functions
-print """/*************************************************************
+print ("""/*************************************************************
  * Generated functions begin here
  */
-"""
+""")
 for funcName in keys:
     if verbose > 0: sys.stderr.write("%s: processing function %s\n" % (program, funcName))
 
@@ -569,8 +569,8 @@
     # header files.  The easiest way to manage declarations
     # is to create them ourselves.
     if funcName in allSpecials:
-        print "/* this function is special and is defined elsewhere */"
-    print "extern %s GLAPIENTRY %s(%s);" % (returnType, passthroughFuncName, passthroughDeclarationString)
+        print ("/* this function is special and is defined elsewhere */")
+    print ("extern %s GLAPIENTRY %s(%s);" % (returnType, passthroughFuncName, passthroughDeclarationString))
 
     # A function may be a core function (i.e. it exists in
     # the core specification), a core addition (extension
@@ -612,36 +612,36 @@
         # Now the generated function.  The text used to mark an API-level
         # function, oddly, is version-specific.
         if extensionName:
-            print "/* Extension %s */" % extensionName
+            print ("/* Extension %s */" % extensionName)
 
         if (not variables and
             not switchCode and
             not conversionCodeOutgoing and
             not conversionCodeIncoming):
             # pass through directly
-            print "#define %s %s" % (fullFuncName, passthroughFuncName)
-            print
+            print ("#define %s %s" % (fullFuncName, passthroughFuncName))
+            print ('')
             continue
 
-        print "static %s %s(%s)" % (returnType, fullFuncName, declarationString)
-        print "{"
+        print ("static %s %s(%s)" % (returnType, fullFuncName, declarationString))
+        print ("{")
 
         # Start printing our code pieces.  Start with any local
         # variables we need.  This unusual syntax joins the 
         # lines in the variables[] array with the "\n" separator.
         if len(variables) > 0:
-            print "\n".join(variables) + "\n"
+            print ("\n".join(variables) + "\n")
 
         # If there's any sort of parameter checking or variable
         # array sizing, the switch code will contain it.
         if len(switchCode) > 0:
-            print "\n".join(switchCode) + "\n"
+            print ("\n".join(switchCode) + "\n")
 
         # In the case of an outgoing conversion (i.e. parameters must
         # be converted before calling the underlying Mesa function),
         # use the appropriate code.
         if "get" not in props and len(conversionCodeOutgoing) > 0:
-            print "\n".join(conversionCodeOutgoing) + "\n"
+            print ("\n".join(conversionCodeOutgoing) + "\n")
 
         # Call the Mesa function.  Note that there are very few functions
         # that return a value (i.e. returnType is not "void"), and that
@@ -650,26 +650,26 @@
         # even though it's not completely independent.
 
         if returnType == "void":
-            print "    %s(%s);" % (passthroughFuncName, passthroughCallString)
+            print ("    %s(%s);" % (passthroughFuncName, passthroughCallString))
         else:
-            print "    return %s(%s);" % (passthroughFuncName, passthroughCallString)
+            print ("    return %s(%s);" % (passthroughFuncName, passthroughCallString))
 
         # If the function is one that returns values (i.e. "get" in props),
         # it might return values of a different type than we need, that
         # require conversion before passing back to the application.
         if "get" in props and len(conversionCodeIncoming) > 0:
-            print "\n".join(conversionCodeIncoming)
+            print ("\n".join(conversionCodeIncoming))
 
         # All done.
-        print "}"
-        print
+        print ("}")
+        print ('')
     # end for each category provided for a function
 
 # end for each function
 
-print "void"
-print "_mesa_init_exec_table(struct _glapi_table *exec)"
-print "{"
+print ("void")
+print ("_mesa_init_exec_table(struct _glapi_table *exec)")
+print ("{")
 for func in keys:
     prefix = "_es_" if func not in allSpecials else "_check_"
     for spec in apiutil.Categories(func):
@@ -681,5 +681,5 @@
         if ext:
             suffix = ext[0].split("_")[0]
             entry += suffix
-        print "    SET_%s(exec, %s%s);" % (entry, prefix, entry)
-print "}"
+        print ("    SET_%s(exec, %s%s);" % (entry, prefix, entry))
+print ("}")
--- Mesa-7.8.2/src/mesa/es/main/get_gen.py.orig	2010-06-16 03:43:42.000000000 +1000
+++ Mesa-7.8.2/src/mesa/es/main/get_gen.py	2010-12-06 15:29:50.000000000 +1100
@@ -585,22 +585,22 @@
 	else:
 		abort()
 
-	print "void GLAPIENTRY"
-	print "%s( GLenum pname, %s *params )" % (function, strType)
-	print "{"
-	print "   GET_CURRENT_CONTEXT(ctx);"
-	print "   ASSERT_OUTSIDE_BEGIN_END(ctx);"
-	print ""
-	print "   if (!params)"
-	print "      return;"
-	print ""
-	print "   if (ctx->NewState)"
-	print "      _mesa_update_state(ctx);"
-	print ""
-	print "   switch (pname) {"
+	print ("void GLAPIENTRY")
+	print ("%s( GLenum pname, %s *params )" % (function, strType))
+	print ("{")
+	print ("   GET_CURRENT_CONTEXT(ctx);")
+	print ("   ASSERT_OUTSIDE_BEGIN_END(ctx);")
+	print ("")
+	print ("   if (!params)")
+	print ("      return;")
+	print ("")
+	print ("   if (ctx->NewState)")
+	print ("      _mesa_update_state(ctx);")
+	print ("")
+	print ("   switch (pname) {")
 
 	for (name, varType, state, optionalCode, extensions) in stateVars:
-		print "      case " + name + ":"
+		print ("      case " + name + ":")
 		if extensions:
 			if len(extensions) == 1:
 				print ('         CHECK_EXT1(%s, "%s");' %
@@ -616,31 +616,31 @@
 				print ('         CHECK_EXT4(%s, %s, %s, %s, "%s");' %
 					   (extensions[0], extensions[1], extensions[2], extensions[3], function))
 		if optionalCode:
-			print "         {"
-			print "         " + optionalCode
+			print ("         {")
+			print ("         " + optionalCode)
 		conversion = ConversionFunc(varType, returnType)
 		n = len(state)
 		for i in range(n):
 			if conversion:
-				print "         params[%d] = %s(%s);" % (i, conversion, state[i])
+				print ("         params[%d] = %s(%s);" % (i, conversion, state[i]))
 			else:
-				print "         params[%d] = %s;" % (i, state[i])
+				print ("         params[%d] = %s;" % (i, state[i]))
 		if optionalCode:
-			print "         }"
-		print "         break;"
+			print ("         }")
+		print ("         break;")
 
-	print "      default:"
-	print '         _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(pname=0x%%x)", pname);' % function
-	print "   }"
-	print "}"
-	print ""
+	print ("      default:")
+	print ('         _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(pname=0x%%x)", pname);' % function)
+	print ("   }")
+	print ("}")
+	print ("")
 	return
 
 
 
 def EmitHeader():
 	"""Print the get.c file header."""
-	print """
+	print ("""
 /***
  ***  NOTE!!!  DO NOT EDIT THIS FILE!!!  IT IS GENERATED BY get_gen.py
  ***/
@@ -776,7 +776,7 @@
 void GLAPIENTRY
 _mesa_GetFixedv( GLenum pname, GLfixed *params );
 
-"""
+""")
 	return
 
 
@@ -797,7 +797,7 @@
 		API = 2
 	else:
 		API = 1
-	#print "len args = %d  API = %d" % (len(args), API)
+	#print ("len args = %d  API = %d" % (len(args), API))
 
 	if API == 1:
 		vars = StateVars_common + StateVars_es1
--- Mesa-7.8.2/src/mesa/glapi/gen/extension_helper.py.orig	2010-06-16 03:43:42.000000000 +1000
+++ Mesa-7.8.2/src/mesa/glapi/gen/extension_helper.py	2010-12-06 15:28:35.000000000 +1100
@@ -150,9 +150,9 @@
 
 
 	def printRealHeader(self):
-		print '#include "utils.h"'
-		print '#include "main/dispatch.h"'
-		print ''
+		print ('#include "utils.h"')
+		print ('#include "main/dispatch.h"')
+		print ('')
 		return
 
 
@@ -161,16 +161,16 @@
 
 		category_list = {}
 
-		print '#ifndef NULL'
-		print '# define NULL 0'
-		print '#endif'
-		print ''
+		print ('#ifndef NULL')
+		print ('# define NULL 0')
+		print ('#endif')
+		print ('')
 
 		for f in api.functionIterateAll():
 			condition = condition_for_function(f, abi, 0)
 			if len(condition):
-				print '#if %s' % (string.join(condition, " || "))
-				print 'static const char %s_names[] =' % (f.name)
+				print ('#if %s' % (string.join(condition, " || ")))
+				print ('static const char %s_names[] =' % (f.name))
 
 				parameter_signature = ''
 				for p in f.parameterIterator():
@@ -189,10 +189,10 @@
 					else:
 						parameter_signature += 'd'
 
-				print '    "%s\\0" /* Parameter signature */' % (parameter_signature)
+				print ('    "%s\\0" /* Parameter signature */' % (parameter_signature))
 
 				for n in f.entry_points:
-					print '    "gl%s\\0"' % (n)
+					print ('    "gl%s\\0"' % (n))
 
 					[category, num] = api.get_category_for_name( n )
 					if category not in abi:
@@ -202,16 +202,16 @@
 
 						category_list[ c ].append( f )
 
-				print '    "";'
-				print '#endif'
-				print ''
+				print ('    "";')
+				print ('#endif')
+				print ('')
 
 		keys = category_list.keys()
 		keys.sort()
 
 		for category in keys:
-			print '#if defined(need_%s)' % (category)
-			print 'static const struct dri_extension_function %s_functions[] = {' % (category)
+			print ('#if defined(need_%s)' % (category))
+			print ('static const struct dri_extension_function %s_functions[] = {' % (category))
 			
 			for f in category_list[ category ]:
 				# A function either has an offset that is
@@ -224,13 +224,13 @@
 					index_name = "%s_remap_index" % (f.name)
 					offset = -1
 
-				print '    { %s_names, %s, %d },' % (f.name, index_name, offset)
+				print ('    { %s_names, %s, %d },' % (f.name, index_name, offset))
 
 
-			print '    { NULL, 0, 0 }'
-			print '};'
-			print '#endif'
-			print ''
+			print ('    { NULL, 0, 0 }')
+			print ('};')
+			print ('#endif')
+			print ('')
 		
 		return
 
@@ -258,42 +258,42 @@
 
 			if condition_string != last_condition_string:
 				if last_condition_string:
-					print '#endif /* %s */' % (last_condition_string)
+					print ('#endif /* %s */' % (last_condition_string))
 
 				if condition_string:
-					print '#if %s' % (condition_string)
+					print ('#if %s' % (condition_string))
 				
 			if vtxfmt_only:
-				print '   disp->%s = vfmt->%s;' % (f.name, f.name)
+				print ('   disp->%s = vfmt->%s;' % (f.name, f.name))
 			else:
-				print '   disp->%s = _mesa_%s;' % (f.name, f.name)
+				print ('   disp->%s = _mesa_%s;' % (f.name, f.name))
 
 			last_condition_string = condition_string
 
 		if last_condition_string:
-			print '#endif /* %s */' % (last_condition_string)
+			print ('#endif /* %s */' % (last_condition_string))
 		
 
 
 	def printBody(self, api):
 		abi = [ "1.0", "1.1", "1.2", "GL_ARB_multitexture" ]
 		
-		print 'void driver_init_exec_table(struct _glapi_table *disp)'
-		print '{'
+		print ('void driver_init_exec_table(struct _glapi_table *disp)')
+		print ('{')
 		self.do_function_body(api, abi, 0)
-		print '}'
-		print ''
-		print 'void driver_install_vtxfmt(struct _glapi_table *disp, const GLvertexformat *vfmt)'
-		print '{'
+		print ('}')
+		print ('')
+		print ('void driver_install_vtxfmt(struct _glapi_table *disp, const GLvertexformat *vfmt)')
+		print ('{')
 		self.do_function_body(api, abi, 1)
-		print '}'
+		print ('}')
 
 		return
 
 
 def show_usage():
-	print "Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0]
-	print "    -m output_mode   Output mode can be one of 'extensions' or 'exec_init'."
+	print ("Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0])
+	print ("    -m output_mode   Output mode can be one of 'extensions' or 'exec_init'.")
 	sys.exit(1)
 
 if __name__ == '__main__':
--- Mesa-7.8.2/src/mesa/glapi/gen/gl_apitemp.py.orig	2010-06-16 03:43:43.000000000 +1000
+++ Mesa-7.8.2/src/mesa/glapi/gen/gl_apitemp.py	2010-12-06 15:28:08.000000000 +1100
@@ -92,25 +92,25 @@
 			if (cat.startswith("es") or cat.startswith("GL_OES")):
 				need_proto = True
 		if need_proto:
-			print '%s %s KEYWORD2 NAME(%s)(%s);' % (keyword, f.return_type, n, f.get_parameter_string(name))
-			print ''
+			print ('%s %s KEYWORD2 NAME(%s)(%s);' % (keyword, f.return_type, n, f.get_parameter_string(name)))
+			print ('')
 
-		print '%s %s KEYWORD2 NAME(%s)(%s)' % (keyword, f.return_type, n, f.get_parameter_string(name))
-		print '{'
+		print ('%s %s KEYWORD2 NAME(%s)(%s)' % (keyword, f.return_type, n, f.get_parameter_string(name)))
+		print ('{')
 		if p_string == "":
-			print '   %s(%s, (), (F, "gl%s();\\n"));' \
-				% (dispatch, f.name, name)
+			print ('   %s(%s, (), (F, "gl%s();\\n"));' \
+				% (dispatch, f.name, name))
 		else:
-			print '   %s(%s, (%s), (F, "gl%s(%s);\\n", %s));' \
-				% (dispatch, f.name, p_string, name, t_string, o_string)
-		print '}'
-		print ''
+			print ('   %s(%s, (%s), (F, "gl%s(%s);\\n", %s));' \
+				% (dispatch, f.name, p_string, name, t_string, o_string))
+		print ('}')
+		print ('')
 		return
 
 	def printRealHeader(self):
-		print ''
+		print ('')
 		self.printVisibility( "HIDDEN", "hidden" )
-		print """
+		print ("""
 /*
  * This file is a template which generates the OpenGL API entry point
  * functions.  It should be included by a .c file which first defines
@@ -157,13 +157,13 @@
 #error RETURN_DISPATCH must be defined
 #endif
 
-"""
+""")
 		return
 
     
 
 	def printInitDispatch(self, api):
-		print """
+		print ("""
 #endif /* defined( NAME ) */
 
 /*
@@ -180,31 +180,31 @@
 #error _GLAPI_SKIP_NORMAL_ENTRY_POINTS must not be defined
 #endif
 
-_glapi_proc DISPATCH_TABLE_NAME[] = {"""
+_glapi_proc DISPATCH_TABLE_NAME[] = {""")
 		for f in api.functionIterateByOffset():
-			print '   TABLE_ENTRY(%s),' % (f.dispatch_name())
+			print ('   TABLE_ENTRY(%s),' % (f.dispatch_name()))
 
-		print '   /* A whole bunch of no-op functions.  These might be called'
-		print '    * when someone tries to call a dynamically-registered'
-		print '    * extension function without a current rendering context.'
-		print '    */'
+		print ('   /* A whole bunch of no-op functions.  These might be called')
+		print ('    * when someone tries to call a dynamically-registered')
+		print ('    * extension function without a current rendering context.')
+		print ('    */')
 		for i in range(1, 100):
-			print '   TABLE_ENTRY(Unused),'
+			print ('   TABLE_ENTRY(Unused),')
 
-		print '};'
-		print '#endif /* DISPATCH_TABLE_NAME */'
-		print ''
+		print ('};')
+		print ('#endif /* DISPATCH_TABLE_NAME */')
+		print ('')
 		return
 
 
 	def printAliasedTable(self, api):
-		print """
+		print ("""
 /*
  * This is just used to silence compiler warnings.
  * We list the functions which are not otherwise used.
  */
 #ifdef UNUSED_TABLE_NAME
-_glapi_proc UNUSED_TABLE_NAME[] = {"""
+_glapi_proc UNUSED_TABLE_NAME[] = {""")
 
 		normal_entries = []
 		proto_entries = []
@@ -223,18 +223,18 @@
 			normal_entries.extend(normal_ents)
 			proto_entries.extend(proto_ents)
 
-		print '#ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS'
+		print ('#ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS')
 		for ent in normal_entries:
-			print '   TABLE_ENTRY(%s),' % (ent)
-		print '#endif /* _GLAPI_SKIP_NORMAL_ENTRY_POINTS */'
-		print '#ifndef _GLAPI_SKIP_PROTO_ENTRY_POINTS'
+			print ('   TABLE_ENTRY(%s),' % (ent))
+		print ('#endif /* _GLAPI_SKIP_NORMAL_ENTRY_POINTS */')
+		print ('#ifndef _GLAPI_SKIP_PROTO_ENTRY_POINTS')
 		for ent in proto_entries:
-			print '   TABLE_ENTRY(%s),' % (ent)
-		print '#endif /* _GLAPI_SKIP_PROTO_ENTRY_POINTS */'
+			print ('   TABLE_ENTRY(%s),' % (ent))
+		print ('#endif /* _GLAPI_SKIP_PROTO_ENTRY_POINTS */')
 
-		print '};'
-		print '#endif /*UNUSED_TABLE_NAME*/'
-		print ''
+		print ('};')
+		print ('#endif /*UNUSED_TABLE_NAME*/')
+		print ('')
 		return
 
 
@@ -271,23 +271,23 @@
 			normal_entry_points.append((func, normal_ents))
 			proto_entry_points.append((func, proto_ents))
 
-		print '#ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS'
-		print ''
+		print ('#ifndef _GLAPI_SKIP_NORMAL_ENTRY_POINTS')
+		print ('')
 		for func, ents in normal_entry_points:
 			for ent in ents:
 				self.printFunction(func, ent)
-		print ''
-		print '#endif /* _GLAPI_SKIP_NORMAL_ENTRY_POINTS */'
-		print ''
-		print '/* these entry points might require different protocols */'
-		print '#ifndef _GLAPI_SKIP_PROTO_ENTRY_POINTS'
-		print ''
+		print ('')
+		print ('#endif /* _GLAPI_SKIP_NORMAL_ENTRY_POINTS */')
+		print ('')
+		print ('/* these entry points might require different protocols */')
+		print ('#ifndef _GLAPI_SKIP_PROTO_ENTRY_POINTS')
+		print ('')
 		for func, ents in proto_entry_points:
 			for ent in ents:
 				self.printFunction(func, ent)
-		print ''
-		print '#endif /* _GLAPI_SKIP_PROTO_ENTRY_POINTS */'
-		print ''
+		print ('')
+		print ('#endif /* _GLAPI_SKIP_PROTO_ENTRY_POINTS */')
+		print ('')
 
 		self.printInitDispatch(api)
 		self.printAliasedTable(api)
@@ -295,8 +295,8 @@
 
 
 def show_usage():
-	print "Usage: %s [-f input_file_name] [-c]" % sys.argv[0]
-	print "-c          Enable compatibility with OpenGL ES."
+	print ("Usage: %s [-f input_file_name] [-c]" % sys.argv[0])
+	print ("-c          Enable compatibility with OpenGL ES.")
 	sys.exit(1)
 
 if __name__ == '__main__':
--- Mesa-7.8.2/src/mesa/glapi/gen/gl_enums.py.orig	2010-06-16 03:43:43.000000000 +1000
+++ Mesa-7.8.2/src/mesa/glapi/gen/gl_enums.py	2010-12-06 15:26:22.000000000 +1100
@@ -42,20 +42,20 @@
 
 
 	def printRealHeader(self):
-		print '#include "main/glheader.h"'
-		print '#include "main/mfeatures.h"'
-		print '#include "main/enums.h"'
-		print '#include "main/imports.h"'
-		print ''
-		print 'typedef struct {'
-		print '   size_t offset;'
-		print '   int n;'
-		print '} enum_elt;'
-		print ''
+		print ('#include "main/glheader.h"')
+		print ('#include "main/mfeatures.h"')
+		print ('#include "main/enums.h"')
+		print ('#include "main/imports.h"')
+		print ('')
+		print ('typedef struct {')
+		print ('   size_t offset;')
+		print ('   int n;')
+		print ('} enum_elt;')
+		print ('')
 		return
 
 	def print_code(self):
-		print """
+		print ("""
 typedef int (*cfunc)(const void *, const void *);
 
 /**
@@ -147,7 +147,7 @@
    return (f != NULL) ? f->n : -1;
 }
 
-"""
+""")
 		return
 
 
@@ -174,34 +174,34 @@
 
 		string_offsets = {}
 		i = 0;
-		print 'LONGSTRING static const char enum_string_table[] = '
+		print ('LONGSTRING static const char enum_string_table[] = ')
 		for [name, enum] in name_table:
-			print '   "%s\\0"' % (name)
+			print ('   "%s\\0"' % (name))
 			string_offsets[ name ] = i
 			i += len(name) + 1
 
-		print '   ;'
-		print ''
+		print ('   ;')
+		print ('')
 
 
-		print 'static const enum_elt all_enums[%u] =' % (len(name_table))
-		print '{'
+		print ('static const enum_elt all_enums[%u] =' % (len(name_table)))
+		print ('{')
 		for [name, enum] in name_table:
-			print '   { %5u, 0x%08X }, /* %s */' % (string_offsets[name], enum, name)
-		print '};'
-		print ''
+			print ('   { %5u, 0x%08X }, /* %s */' % (string_offsets[name], enum, name))
+		print ('};')
+		print ('')
 
-		print 'static const unsigned reduced_enums[%u] =' % (len(keys))
-		print '{'
+		print ('static const unsigned reduced_enums[%u] =' % (len(keys)))
+		print ('{')
 		for enum in keys:
 			name = enum_table[ enum ]
 			if [name, enum] not in name_table:
-				print '      /* Error! %s, 0x%04x */ 0,' % (name, enum)
+				print ('      /* Error! %s, 0x%04x */ 0,' % (name, enum))
 			else:
 				i = name_table.index( [name, enum] )
 
-				print '      %4u, /* %s */' % (i, name)
-		print '};'
+				print ('      %4u, /* %s */' % (i, name))
+		print ('};')
 
 
 		self.print_code()
@@ -222,7 +222,7 @@
 
 
 def show_usage():
-	print "Usage: %s [-f input_file_name]" % sys.argv[0]
+	print ("Usage: %s [-f input_file_name]" % sys.argv[0])
 	sys.exit(1)
 
 if __name__ == '__main__':
--- Mesa-7.8.2/src/mesa/glapi/gen/gl_offsets.py.orig	2010-06-16 03:43:43.000000000 +1000
+++ Mesa-7.8.2/src/mesa/glapi/gen/gl_offsets.py	2010-12-06 15:25:29.000000000 +1100
@@ -42,8 +42,8 @@
 		return
 
 	def printBody(self, api):
-		print '/* this file should not be included directly in mesa */'
-		print ''
+		print ('/* this file should not be included directly in mesa */')
+		print ('')
 
 		functions = []
 		abi_functions = []
@@ -62,41 +62,41 @@
 					alias_functions.append(f)
 
 		for f in abi_functions:
-			print '#define _gloffset_%s %d' % (f.name, f.offset)
+			print ('#define _gloffset_%s %d' % (f.name, f.offset))
 			last_static = f.offset
 
-		print ''
-		print '#if !defined(_GLAPI_USE_REMAP_TABLE)'
-		print ''
+		print ('')
+		print ('#if !defined(_GLAPI_USE_REMAP_TABLE)')
+		print ('')
 
 		for [f, index] in functions:
-			print '#define _gloffset_%s %d' % (f.name, f.offset)
+			print ('#define _gloffset_%s %d' % (f.name, f.offset))
 
-		print '#define _gloffset_FIRST_DYNAMIC %d' % (api.next_offset)
+		print ('#define _gloffset_FIRST_DYNAMIC %d' % (api.next_offset))
 
-		print ''
-		print '#else'
-		print ''
+		print ('')
+		print ('#else')
+		print ('')
 
 		for [f, index] in functions:
-			print '#define _gloffset_%s driDispatchRemapTable[%s_remap_index]' % (f.name, f.name)
+			print ('#define _gloffset_%s driDispatchRemapTable[%s_remap_index]' % (f.name, f.name))
 
-		print ''
-		print '#endif /* !defined(_GLAPI_USE_REMAP_TABLE) */'
+		print ('')
+		print ('#endif /* !defined(_GLAPI_USE_REMAP_TABLE) */')
 
 		if alias_functions:
-			print ''
-			print '/* define aliases for compatibility */'
+			print ('')
+			print ('/* define aliases for compatibility */')
 			for f in alias_functions:
 				for name in f.entry_points:
 					if name != f.name:
-						print '#define _gloffset_%s _gloffset_%s' % (name, f.name)
+						print ('#define _gloffset_%s _gloffset_%s' % (name, f.name))
 		return
 
 
 def show_usage():
-	print "Usage: %s [-f input_file_name] [-c]" % sys.argv[0]
-	print "    -c        Enable compatibility with OpenGL ES."
+	print ("Usage: %s [-f input_file_name] [-c]" % sys.argv[0])
+	print ("    -c        Enable compatibility with OpenGL ES.")
 	sys.exit(1)
 
 if __name__ == '__main__':
--- Mesa-7.8.2/src/mesa/glapi/gen/gl_procs.py.orig	2010-06-16 03:43:43.000000000 +1000
+++ Mesa-7.8.2/src/mesa/glapi/gen/gl_procs.py	2010-12-06 15:25:08.000000000 +1100
@@ -42,7 +42,7 @@
 
 
 	def printRealHeader(self):
-		print """
+		print ("""
 /* This file is only included by glapi.c and is used for
  * the GetProcAddress() function
  */
@@ -65,31 +65,31 @@
 #  define NAME_FUNC_OFFSET(n,f1,f2,f3,o) { n , (_glapi_proc) f3 , o }
 #endif
 
-"""
+""")
 		return
 
 	def printRealFooter(self):
-		print ''
-		print '#undef NAME_FUNC_OFFSET'
+		print ('')
+		print ('#undef NAME_FUNC_OFFSET')
 		return
 
 	def printFunctionString(self, name):
 		if self.long_strings:
-			print '    "gl%s\\0"' % (name)
+			print ('    "gl%s\\0"' % (name))
 		else:
-			print "    'g','l',",
+			print ("    'g','l',",)
 			for c in name:
-				print "'%s'," % (c),
+				print ("'%s'," % (c),)
 			
-			print "'\\0',"
+			print ("'\\0',")
 
 
 	def printBody(self, api):
-		print ''
+		print ('')
 		if self.long_strings:
-			print 'static const char gl_string_table[] ='
+			print ('static const char gl_string_table[] =')
 		else:
-			print 'static const char gl_string_table[] = {'
+			print ('static const char gl_string_table[] = {')
 
 		base_offset = 0
 		table = []
@@ -120,26 +120,26 @@
 
 
 		if self.long_strings:
-			print '    ;'
+			print ('    ;')
 		else:
-			print '};'
+			print ('};')
 
-		print ''
-		print ''
-		print "#ifdef USE_MGL_NAMESPACE"
+		print ('')
+		print ('')
+		print ("#ifdef USE_MGL_NAMESPACE")
 		for func in api.functionIterateByOffset():
 			for n in func.entry_points:
 				if (not func.is_static_entry_point(func.name)) or (func.has_different_protocol(n) and not func.is_static_entry_point(n)):
-					print '#define gl_dispatch_stub_%u mgl_dispatch_stub_%u' % (func.offset, func.offset)
+					print ('#define gl_dispatch_stub_%u mgl_dispatch_stub_%u' % (func.offset, func.offset))
 					break
-		print "#endif /* USE_MGL_NAMESPACE */"
-		print ''
-		print ''
-		print '#if defined(NEED_FUNCTION_POINTER) || defined(GLX_INDIRECT_RENDERING)'
+		print ("#endif /* USE_MGL_NAMESPACE */")
+		print ('')
+		print ('')
+		print ('#if defined(NEED_FUNCTION_POINTER) || defined(GLX_INDIRECT_RENDERING)')
 		for func in api.functionIterateByOffset():
 			for n in func.entry_points:
 				if (not func.is_static_entry_point(func.name)) or (func.has_different_protocol(n) and not func.is_static_entry_point(n)):
-					print '%s GLAPIENTRY gl_dispatch_stub_%u(%s);' % (func.return_type, func.offset, func.get_parameter_string())
+					print ('%s GLAPIENTRY gl_dispatch_stub_%u(%s);' % (func.return_type, func.offset, func.get_parameter_string()))
 					break
 
 		if self.es:
@@ -154,37 +154,37 @@
 								% (func.return_type, "gl" + n, func.get_parameter_string(n))
 						categories[cat].append(proto)
 			if categories:
-				print ''
-				print '/* OpenGL ES specific prototypes */'
-				print ''
+				print ('')
+				print ('/* OpenGL ES specific prototypes */')
+				print ('')
 				keys = categories.keys()
 				keys.sort()
 				for key in keys:
-					print '/* category %s */' % key
-					print "\n".join(categories[key])
-				print ''
+					print ('/* category %s */' % key)
+					print ("\n".join(categories[key]))
+				print ('')
 
-		print '#endif /* defined(NEED_FUNCTION_POINTER) || defined(GLX_INDIRECT_RENDERING) */'
+		print ('#endif /* defined(NEED_FUNCTION_POINTER) || defined(GLX_INDIRECT_RENDERING) */')
 
-		print ''
-		print 'static const glprocs_table_t static_functions[] = {'
+		print ('')
+		print ('static const glprocs_table_t static_functions[] = {')
 
 		for info in table:
-			print '    NAME_FUNC_OFFSET(%5u, %s, %s, %s, _gloffset_%s),' % info
+			print ('    NAME_FUNC_OFFSET(%5u, %s, %s, %s, _gloffset_%s),' % info)
 
-		print '    NAME_FUNC_OFFSET(-1, NULL, NULL, NULL, 0)'
-		print '};'
+		print ('    NAME_FUNC_OFFSET(-1, NULL, NULL, NULL, 0)')
+		print ('};')
 		return
 
 
 def show_usage():
-	print "Usage: %s [-f input_file_name] [-m mode] [-c]" % sys.argv[0]
-	print "-c          Enable compatibility with OpenGL ES."
-	print "-m mode     mode can be one of:"
-	print "    long  - Create code for compilers that can handle very"
-	print "            long string constants. (default)"
-	print "    short - Create code for compilers that can only handle"
-	print "            ANSI C89 string constants."
+	print ("Usage: %s [-f input_file_name] [-m mode] [-c]" % sys.argv[0])
+	print ("-c          Enable compatibility with OpenGL ES.")
+	print ("-m mode     mode can be one of:")
+	print ("    long  - Create code for compilers that can handle very")
+	print ("            long string constants. (default)")
+	print ("    short - Create code for compilers that can only handle")
+	print ("            ANSI C89 string constants.")
 	sys.exit(1)
 
 if __name__ == '__main__':
--- Mesa-7.8.2/src/mesa/glapi/gen/gl_SPARC_asm.py.orig	2010-06-16 03:43:42.000000000 +1000
+++ Mesa-7.8.2/src/mesa/glapi/gen/gl_SPARC_asm.py	2010-12-06 15:24:33.000000000 +1100
@@ -39,194 +39,194 @@
 
 
 	def printRealHeader(self):
-		print '#include "glapi/glapioffsets.h"'
-		print ''
-		print '#ifdef __arch64__'
-		print '#define GL_OFF(N)\t((N) * 8)'
-		print '#define GL_LL\t\tldx'
-		print '#define GL_TIE_LD(SYM)\t%tie_ldx(SYM)'
-		print '#define GL_STACK_SIZE\t128'
-		print '#else'
-		print '#define GL_OFF(N)\t((N) * 4)'
-		print '#define GL_LL\t\tld'
-		print '#define GL_TIE_LD(SYM)\t%tie_ld(SYM)'
-		print '#define GL_STACK_SIZE\t64'
-		print '#endif'
-		print ''
-		print '#define GLOBL_FN(x) .globl x ; .type x, @function'
-		print '#define HIDDEN(x) .hidden x'
-		print ''
-		print '\t.register %g2, #scratch'
-		print '\t.register %g3, #scratch'
-		print ''
-		print '\t.text'
-		print ''
-		print '\tGLOBL_FN(__glapi_sparc_icache_flush)'
-		print '\tHIDDEN(__glapi_sparc_icache_flush)'
-		print '\t.type\t__glapi_sparc_icache_flush, @function'
-		print '__glapi_sparc_icache_flush: /* %o0 = insn_addr */'
-		print '\tflush\t%o0'
-		print '\tretl'
-		print '\t nop'
-		print ''
-		print '\t.align\t32'
-		print ''
-		print '\t.type\t__glapi_sparc_get_pc, @function'
-		print '__glapi_sparc_get_pc:'
-		print '\tretl'
-		print '\t add\t%o7, %g2, %g2'
-		print '\t.size\t__glapi_sparc_get_pc, .-__glapi_sparc_get_pc'
-		print ''
-		print '#ifdef GLX_USE_TLS'
-		print ''
-		print '\tGLOBL_FN(__glapi_sparc_get_dispatch)'
-		print '\tHIDDEN(__glapi_sparc_get_dispatch)'
-		print '__glapi_sparc_get_dispatch:'
-		print '\tmov\t%o7, %g1'
-		print '\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2'
-		print '\tcall\t__glapi_sparc_get_pc'
-		print '\tadd\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2'
-		print '\tmov\t%g1, %o7'
-		print '\tsethi\t%tie_hi22(_glapi_tls_Dispatch), %g1'
-		print '\tadd\t%g1, %tie_lo10(_glapi_tls_Dispatch), %g1'
-		print '\tGL_LL\t[%g2 + %g1], %g2, GL_TIE_LD(_glapi_tls_Dispatch)'
-		print '\tretl'
-		print '\t mov\t%g2, %o0'
-		print ''
-		print '\t.data'
-		print '\t.align\t32'
-		print ''
-		print '\t/* --> sethi %hi(_glapi_tls_Dispatch), %g1 */'
-		print '\t/* --> or %g1, %lo(_glapi_tls_Dispatch), %g1 */'
-		print '\tGLOBL_FN(__glapi_sparc_tls_stub)'
-		print '\tHIDDEN(__glapi_sparc_tls_stub)'
-		print '__glapi_sparc_tls_stub: /* Call offset in %g3 */'
-		print '\tmov\t%o7, %g1'
-		print '\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2'
-		print '\tcall\t__glapi_sparc_get_pc'
-		print '\tadd\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2'
-		print '\tmov\t%g1, %o7'
-		print '\tsrl\t%g3, 10, %g3'
-		print '\tsethi\t%tie_hi22(_glapi_tls_Dispatch), %g1'
-		print '\tadd\t%g1, %tie_lo10(_glapi_tls_Dispatch), %g1'
-		print '\tGL_LL\t[%g2 + %g1], %g2, GL_TIE_LD(_glapi_tls_Dispatch)'
-		print '\tGL_LL\t[%g7+%g2], %g1'
-		print '\tGL_LL\t[%g1 + %g3], %g1'
-		print '\tjmp\t%g1'
-		print '\t nop'
-		print '\t.size\t__glapi_sparc_tls_stub, .-__glapi_sparc_tls_stub'
-		print ''
-		print '#define GL_STUB(fn, off)\t\t\t\t\\'
-		print '\tGLOBL_FN(fn);\t\t\t\t\t\\'
-		print 'fn:\tba\t__glapi_sparc_tls_stub;\t\t\t\\'
-		print '\t sethi\tGL_OFF(off), %g3;\t\t\t\\'
-		print '\t.size\tfn,.-fn;'
-		print ''
-		print '#elif defined(PTHREADS)'
-		print ''
-		print '\t/* 64-bit 0x00 --> sethi %hh(_glapi_Dispatch), %g1 */'
-		print '\t/* 64-bit 0x04 --> sethi %lm(_glapi_Dispatch), %g2 */'
-		print '\t/* 64-bit 0x08 --> or %g1, %hm(_glapi_Dispatch), %g1 */'
-		print '\t/* 64-bit 0x0c --> sllx %g1, 32, %g1 */'
-		print '\t/* 64-bit 0x10 --> add %g1, %g2, %g1 */'
-		print '\t/* 64-bit 0x14 --> ldx [%g1 + %lo(_glapi_Dispatch)], %g1 */'
-		print ''
-		print '\t/* 32-bit 0x00 --> sethi %hi(_glapi_Dispatch), %g1 */'
-		print '\t/* 32-bit 0x04 --> ld [%g1 + %lo(_glapi_Dispatch)], %g1 */'
-		print ''
-		print '\t.data'
-		print '\t.align\t32'
-		print ''
-		print '\tGLOBL_FN(__glapi_sparc_pthread_stub)'
-		print '\tHIDDEN(__glapi_sparc_pthread_stub)'
-		print '__glapi_sparc_pthread_stub: /* Call offset in %g3 */'
-		print '\tmov\t%o7, %g1'
-		print '\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2'
-		print '\tcall\t__glapi_sparc_get_pc'
-		print '\t add\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2'
-		print '\tmov\t%g1, %o7'
-		print '\tsethi\t%hi(_glapi_Dispatch), %g1'
-		print '\tor\t%g1, %lo(_glapi_Dispatch), %g1'
-		print '\tsrl\t%g3, 10, %g3'
-		print '\tGL_LL\t[%g2+%g1], %g2'
-		print '\tGL_LL\t[%g2], %g1'
-		print '\tcmp\t%g1, 0'
-		print '\tbe\t2f'
-		print '\t nop'
-		print '1:\tGL_LL\t[%g1 + %g3], %g1'
-		print '\tjmp\t%g1'
-		print '\t nop'
-		print '2:\tsave\t%sp, GL_STACK_SIZE, %sp'
-		print '\tmov\t%g3, %l0'
-		print '\tcall\t_glapi_get_dispatch'
-		print '\t nop'
-		print '\tmov\t%o0, %g1'
-		print '\tmov\t%l0, %g3'
-		print '\tba\t1b'
-		print '\t restore %g0, %g0, %g0'
-		print '\t.size\t__glapi_sparc_pthread_stub, .-__glapi_sparc_pthread_stub'
-		print ''
-		print '#define GL_STUB(fn, off)\t\t\t\\'
-		print '\tGLOBL_FN(fn);\t\t\t\t\\'
-		print 'fn:\tba\t__glapi_sparc_pthread_stub;\t\\'
-		print '\t sethi\tGL_OFF(off), %g3;\t\t\\'
-		print '\t.size\tfn,.-fn;'
-		print ''
-		print '#else /* Non-threaded version. */'
-		print ''
-		print '\t.type	__glapi_sparc_nothread_stub, @function'
-		print '__glapi_sparc_nothread_stub: /* Call offset in %g3 */'
-		print '\tmov\t%o7, %g1'
-		print '\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2'
-		print '\tcall\t__glapi_sparc_get_pc'
-		print '\t add\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2'
-		print '\tmov\t%g1, %o7'
-		print '\tsrl\t%g3, 10, %g3'
-		print '\tsethi\t%hi(_glapi_Dispatch), %g1'
-		print '\tor\t%g1, %lo(_glapi_Dispatch), %g1'
-		print '\tGL_LL\t[%g2+%g1], %g2'
-		print '\tGL_LL\t[%g2], %g1'
-		print '\tGL_LL\t[%g1 + %g3], %g1'
-		print '\tjmp\t%g1'
-		print '\t nop'
-		print '\t.size\t__glapi_sparc_nothread_stub, .-__glapi_sparc_nothread_stub'
-		print ''
-		print '#define GL_STUB(fn, off)\t\t\t\\'
-		print '\tGLOBL_FN(fn);\t\t\t\t\\'
-		print 'fn:\tba\t__glapi_sparc_nothread_stub;\t\\'
-		print '\t sethi\tGL_OFF(off), %g3;\t\t\\'
-		print '\t.size\tfn,.-fn;'
-		print ''
-		print '#endif'
-		print ''
-		print '#define GL_STUB_ALIAS(fn, alias)		\\'
-		print '	.globl	fn;				\\'
-		print '	.set	fn, alias'
-		print ''
-		print '\t.text'
-		print '\t.align\t32'
-		print ''
-		print '\t.globl\tgl_dispatch_functions_start'
-		print '\tHIDDEN(gl_dispatch_functions_start)'
-		print 'gl_dispatch_functions_start:'
-		print ''
+		print ('#include "glapi/glapioffsets.h"')
+		print ('')
+		print ('#ifdef __arch64__')
+		print ('#define GL_OFF(N)\t((N) * 8)')
+		print ('#define GL_LL\t\tldx')
+		print ('#define GL_TIE_LD(SYM)\t%tie_ldx(SYM)')
+		print ('#define GL_STACK_SIZE\t128')
+		print ('#else')
+		print ('#define GL_OFF(N)\t((N) * 4)')
+		print ('#define GL_LL\t\tld')
+		print ('#define GL_TIE_LD(SYM)\t%tie_ld(SYM)')
+		print ('#define GL_STACK_SIZE\t64')
+		print ('#endif')
+		print ('')
+		print ('#define GLOBL_FN(x) .globl x ; .type x, @function')
+		print ('#define HIDDEN(x) .hidden x')
+		print ('')
+		print ('\t.register %g2, #scratch')
+		print ('\t.register %g3, #scratch')
+		print ('')
+		print ('\t.text')
+		print ('')
+		print ('\tGLOBL_FN(__glapi_sparc_icache_flush)')
+		print ('\tHIDDEN(__glapi_sparc_icache_flush)')
+		print ('\t.type\t__glapi_sparc_icache_flush, @function')
+		print ('__glapi_sparc_icache_flush: /* %o0 = insn_addr */')
+		print ('\tflush\t%o0')
+		print ('\tretl')
+		print ('\t nop')
+		print ('')
+		print ('\t.align\t32')
+		print ('')
+		print ('\t.type\t__glapi_sparc_get_pc, @function')
+		print ('__glapi_sparc_get_pc:')
+		print ('\tretl')
+		print ('\t add\t%o7, %g2, %g2')
+		print ('\t.size\t__glapi_sparc_get_pc, .-__glapi_sparc_get_pc')
+		print ('')
+		print ('#ifdef GLX_USE_TLS')
+		print ('')
+		print ('\tGLOBL_FN(__glapi_sparc_get_dispatch)')
+		print ('\tHIDDEN(__glapi_sparc_get_dispatch)')
+		print ('__glapi_sparc_get_dispatch:')
+		print ('\tmov\t%o7, %g1')
+		print ('\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2')
+		print ('\tcall\t__glapi_sparc_get_pc')
+		print ('\tadd\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2')
+		print ('\tmov\t%g1, %o7')
+		print ('\tsethi\t%tie_hi22(_glapi_tls_Dispatch), %g1')
+		print ('\tadd\t%g1, %tie_lo10(_glapi_tls_Dispatch), %g1')
+		print ('\tGL_LL\t[%g2 + %g1], %g2, GL_TIE_LD(_glapi_tls_Dispatch)')
+		print ('\tretl')
+		print ('\t mov\t%g2, %o0')
+		print ('')
+		print ('\t.data')
+		print ('\t.align\t32')
+		print ('')
+		print ('\t/* --> sethi %hi(_glapi_tls_Dispatch), %g1 */')
+		print ('\t/* --> or %g1, %lo(_glapi_tls_Dispatch), %g1 */')
+		print ('\tGLOBL_FN(__glapi_sparc_tls_stub)')
+		print ('\tHIDDEN(__glapi_sparc_tls_stub)')
+		print ('__glapi_sparc_tls_stub: /* Call offset in %g3 */')
+		print ('\tmov\t%o7, %g1')
+		print ('\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2')
+		print ('\tcall\t__glapi_sparc_get_pc')
+		print ('\tadd\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2')
+		print ('\tmov\t%g1, %o7')
+		print ('\tsrl\t%g3, 10, %g3')
+		print ('\tsethi\t%tie_hi22(_glapi_tls_Dispatch), %g1')
+		print ('\tadd\t%g1, %tie_lo10(_glapi_tls_Dispatch), %g1')
+		print ('\tGL_LL\t[%g2 + %g1], %g2, GL_TIE_LD(_glapi_tls_Dispatch)')
+		print ('\tGL_LL\t[%g7+%g2], %g1')
+		print ('\tGL_LL\t[%g1 + %g3], %g1')
+		print ('\tjmp\t%g1')
+		print ('\t nop')
+		print ('\t.size\t__glapi_sparc_tls_stub, .-__glapi_sparc_tls_stub')
+		print ('')
+		print ('#define GL_STUB(fn, off)\t\t\t\t\\')
+		print ('\tGLOBL_FN(fn);\t\t\t\t\t\\')
+		print ('fn:\tba\t__glapi_sparc_tls_stub;\t\t\t\\')
+		print ('\t sethi\tGL_OFF(off), %g3;\t\t\t\\')
+		print ('\t.size\tfn,.-fn;')
+		print ('')
+		print ('#elif defined(PTHREADS)')
+		print ('')
+		print ('\t/* 64-bit 0x00 --> sethi %hh(_glapi_Dispatch), %g1 */')
+		print ('\t/* 64-bit 0x04 --> sethi %lm(_glapi_Dispatch), %g2 */')
+		print ('\t/* 64-bit 0x08 --> or %g1, %hm(_glapi_Dispatch), %g1 */')
+		print ('\t/* 64-bit 0x0c --> sllx %g1, 32, %g1 */')
+		print ('\t/* 64-bit 0x10 --> add %g1, %g2, %g1 */')
+		print ('\t/* 64-bit 0x14 --> ldx [%g1 + %lo(_glapi_Dispatch)], %g1 */')
+		print ('')
+		print ('\t/* 32-bit 0x00 --> sethi %hi(_glapi_Dispatch), %g1 */')
+		print ('\t/* 32-bit 0x04 --> ld [%g1 + %lo(_glapi_Dispatch)], %g1 */')
+		print ('')
+		print ('\t.data')
+		print ('\t.align\t32')
+		print ('')
+		print ('\tGLOBL_FN(__glapi_sparc_pthread_stub)')
+		print ('\tHIDDEN(__glapi_sparc_pthread_stub)')
+		print ('__glapi_sparc_pthread_stub: /* Call offset in %g3 */')
+		print ('\tmov\t%o7, %g1')
+		print ('\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2')
+		print ('\tcall\t__glapi_sparc_get_pc')
+		print ('\t add\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2')
+		print ('\tmov\t%g1, %o7')
+		print ('\tsethi\t%hi(_glapi_Dispatch), %g1')
+		print ('\tor\t%g1, %lo(_glapi_Dispatch), %g1')
+		print ('\tsrl\t%g3, 10, %g3')
+		print ('\tGL_LL\t[%g2+%g1], %g2')
+		print ('\tGL_LL\t[%g2], %g1')
+		print ('\tcmp\t%g1, 0')
+		print ('\tbe\t2f')
+		print ('\t nop')
+		print ('1:\tGL_LL\t[%g1 + %g3], %g1')
+		print ('\tjmp\t%g1')
+		print ('\t nop')
+		print ('2:\tsave\t%sp, GL_STACK_SIZE, %sp')
+		print ('\tmov\t%g3, %l0')
+		print ('\tcall\t_glapi_get_dispatch')
+		print ('\t nop')
+		print ('\tmov\t%o0, %g1')
+		print ('\tmov\t%l0, %g3')
+		print ('\tba\t1b')
+		print ('\t restore %g0, %g0, %g0')
+		print ('\t.size\t__glapi_sparc_pthread_stub, .-__glapi_sparc_pthread_stub')
+		print ('')
+		print ('#define GL_STUB(fn, off)\t\t\t\\')
+		print ('\tGLOBL_FN(fn);\t\t\t\t\\')
+		print ('fn:\tba\t__glapi_sparc_pthread_stub;\t\\')
+		print ('\t sethi\tGL_OFF(off), %g3;\t\t\\')
+		print ('\t.size\tfn,.-fn;')
+		print ('')
+		print ('#else /* Non-threaded version. */')
+		print ('')
+		print ('\t.type	__glapi_sparc_nothread_stub, @function')
+		print ('__glapi_sparc_nothread_stub: /* Call offset in %g3 */')
+		print ('\tmov\t%o7, %g1')
+		print ('\tsethi\t%hi(_GLOBAL_OFFSET_TABLE_-4), %g2')
+		print ('\tcall\t__glapi_sparc_get_pc')
+		print ('\t add\t%g2, %lo(_GLOBAL_OFFSET_TABLE_+4), %g2')
+		print ('\tmov\t%g1, %o7')
+		print ('\tsrl\t%g3, 10, %g3')
+		print ('\tsethi\t%hi(_glapi_Dispatch), %g1')
+		print ('\tor\t%g1, %lo(_glapi_Dispatch), %g1')
+		print ('\tGL_LL\t[%g2+%g1], %g2')
+		print ('\tGL_LL\t[%g2], %g1')
+		print ('\tGL_LL\t[%g1 + %g3], %g1')
+		print ('\tjmp\t%g1')
+		print ('\t nop')
+		print ('\t.size\t__glapi_sparc_nothread_stub, .-__glapi_sparc_nothread_stub')
+		print ('')
+		print ('#define GL_STUB(fn, off)\t\t\t\\')
+		print ('\tGLOBL_FN(fn);\t\t\t\t\\')
+		print ('fn:\tba\t__glapi_sparc_nothread_stub;\t\\')
+		print ('\t sethi\tGL_OFF(off), %g3;\t\t\\')
+		print ('\t.size\tfn,.-fn;')
+		print ('')
+		print ('#endif')
+		print ('')
+		print ('#define GL_STUB_ALIAS(fn, alias)		\\')
+		print ('	.globl	fn;				\\')
+		print ('	.set	fn, alias')
+		print ('')
+		print ('\t.text')
+		print ('\t.align\t32')
+		print ('')
+		print ('\t.globl\tgl_dispatch_functions_start')
+		print ('\tHIDDEN(gl_dispatch_functions_start)')
+		print ('gl_dispatch_functions_start:')
+		print ('')
 		return
 
 	def printRealFooter(self):
-		print ''
-		print '\t.globl\tgl_dispatch_functions_end'
-		print '\tHIDDEN(gl_dispatch_functions_end)'
-		print 'gl_dispatch_functions_end:'
+		print ('')
+		print ('\t.globl\tgl_dispatch_functions_end')
+		print ('\tHIDDEN(gl_dispatch_functions_end)')
+		print ('gl_dispatch_functions_end:')
 		return
 
 	def printBody(self, api):
 		for f in api.functionIterateByOffset():
 			name = f.dispatch_name()
 
-			print '\tGL_STUB(gl%s, _gloffset_%s)' % (name, f.name)
+			print ('\tGL_STUB(gl%s, _gloffset_%s)' % (name, f.name))
 
 			if not f.is_static_entry_point(f.name):
-				print '\tHIDDEN(gl%s)' % (name)
+				print ('\tHIDDEN(gl%s)' % (name))
 
 		for f in api.functionIterateByOffset():
 			name = f.dispatch_name()
@@ -237,17 +237,17 @@
 						text = '\tGL_STUB_ALIAS(gl%s, gl%s)' % (n, f.name)
 
 						if f.has_different_protocol(n):
-							print '#ifndef GLX_INDIRECT_RENDERING'
-							print text
-							print '#endif'
+							print ('#ifndef GLX_INDIRECT_RENDERING')
+							print (text)
+							print ('#endif')
 						else:
-							print text
+							print (text)
 
 		return
 
 
 def show_usage():
-	print "Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0]
+	print ("Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0])
 	sys.exit(1)
 
 if __name__ == '__main__':
@@ -268,7 +268,7 @@
 	if mode == "generic":
 		printer = PrintGenericStubs()
 	else:
-		print "ERROR: Invalid mode \"%s\" specified." % mode
+		print ("ERROR: Invalid mode \"%s\" specified." % mode)
 		show_usage()
 
 	api = gl_XML.parse_GL_API(file_name, glX_XML.glx_item_factory())
--- Mesa-7.8.2/src/mesa/glapi/gen/gl_table.py.orig	2010-06-16 03:43:43.000000000 +1000
+++ Mesa-7.8.2/src/mesa/glapi/gen/gl_table.py	2010-12-06 15:23:46.000000000 +1100
@@ -45,26 +45,26 @@
 	def printBody(self, api):
 		for f in api.functionIterateByOffset():
 			arg_string = f.get_parameter_string()
-			print '   %s (GLAPIENTRYP %s)(%s); /* %d */' % (f.return_type, f.name, arg_string, f.offset)
+			print ('   %s (GLAPIENTRYP %s)(%s); /* %d */' % (f.return_type, f.name, arg_string, f.offset))
 
 
 	def printRealHeader(self):
-		print '#ifndef GLAPIENTRYP'
-		print '# ifndef GLAPIENTRY'
-		print '#  define GLAPIENTRY'
-		print '# endif'
-		print ''
-		print '# define GLAPIENTRYP GLAPIENTRY *'
-		print '#endif'
-		print ''
-		print ''
-		print 'struct _glapi_table'
-		print '{'
+		print ('#ifndef GLAPIENTRYP')
+		print ('# ifndef GLAPIENTRY')
+		print ('#  define GLAPIENTRY')
+		print ('# endif')
+		print ('')
+		print ('# define GLAPIENTRYP GLAPIENTRY *')
+		print ('#endif')
+		print ('')
+		print ('')
+		print ('struct _glapi_table')
+		print ('{')
 		return
 
 
 	def printRealFooter(self):
-		print '};'
+		print ('};')
 		return
 
 
@@ -80,7 +80,7 @@
 
 
 	def printRealHeader(self):
-		print """
+		print ("""
 /* this file should not be included directly in mesa */
 
 /**
@@ -93,27 +93,27 @@
  * can SET_FuncName, are used to get and set the dispatch pointer for the
  * named function in the specified dispatch table.
  */
-"""
+""")
 		
 		return
 
 	def printBody(self, api):
-		print '#define CALL_by_offset(disp, cast, offset, parameters) \\'
-		print '    (*(cast (GET_by_offset(disp, offset)))) parameters'
-		print '#define GET_by_offset(disp, offset) \\'
-		print '    (offset >= 0) ? (((_glapi_proc *)(disp))[offset]) : NULL'
-		print '#define SET_by_offset(disp, offset, fn) \\'
-		print '    do { \\'
-		print '        if ( (offset) < 0 ) { \\'
-		print '            /* fprintf( stderr, "[%s:%u] SET_by_offset(%p, %d, %s)!\\n", */ \\'
-		print '            /*         __func__, __LINE__, disp, offset, # fn); */ \\'
-		print '            /* abort(); */ \\'
-		print '        } \\'
-		print '        else { \\'
-		print '            ( (_glapi_proc *) (disp) )[offset] = (_glapi_proc) fn; \\'
-		print '        } \\'
-		print '    } while(0)'
-		print ''
+		print ('#define CALL_by_offset(disp, cast, offset, parameters) \\')
+		print ('    (*(cast (GET_by_offset(disp, offset)))) parameters')
+		print ('#define GET_by_offset(disp, offset) \\')
+		print ('    (offset >= 0) ? (((_glapi_proc *)(disp))[offset]) : NULL')
+		print ('#define SET_by_offset(disp, offset, fn) \\')
+		print ('    do { \\')
+		print ('        if ( (offset) < 0 ) { \\')
+		print ('            /* fprintf( stderr, "[%s:%u] SET_by_offset(%p, %d, %s)!\\n", */ \\')
+		print ('            /*         __func__, __LINE__, disp, offset, # fn); */ \\')
+		print ('            /* abort(); */ \\')
+		print ('        } \\')
+		print ('        else { \\')
+		print ('            ( (_glapi_proc *) (disp) )[offset] = (_glapi_proc) fn; \\')
+		print ('        } \\')
+		print ('    } while(0)')
+		print ('')
 
 		functions = []
 		abi_functions = []
@@ -133,70 +133,70 @@
 
 
 		for f in abi_functions:
-			print '#define CALL_%s(disp, parameters) (*((disp)->%s)) parameters' % (f.name, f.name)
-			print '#define GET_%s(disp) ((disp)->%s)' % (f.name, f.name)
-			print '#define SET_%s(disp, fn) ((disp)->%s = fn)' % (f.name, f.name)
+			print ('#define CALL_%s(disp, parameters) (*((disp)->%s)) parameters' % (f.name, f.name))
+			print ('#define GET_%s(disp) ((disp)->%s)' % (f.name, f.name))
+			print ('#define SET_%s(disp, fn) ((disp)->%s = fn)' % (f.name, f.name))
 
 
-		print ''
-		print '#if !defined(_GLAPI_USE_REMAP_TABLE)'
-		print ''
+		print ('')
+		print ('#if !defined(_GLAPI_USE_REMAP_TABLE)')
+		print ('')
 
 		for [f, index] in functions:
-			print '#define CALL_%s(disp, parameters) (*((disp)->%s)) parameters' % (f.name, f.name)
-			print '#define GET_%s(disp) ((disp)->%s)' % (f.name, f.name)
-			print '#define SET_%s(disp, fn) ((disp)->%s = fn)' % (f.name, f.name)
-
-		print ''
-		print '#else'
-		print ''
-		print '#define driDispatchRemapTable_size %u' % (count)
-		print 'extern int driDispatchRemapTable[ driDispatchRemapTable_size ];'
-		print ''
+			print ('#define CALL_%s(disp, parameters) (*((disp)->%s)) parameters' % (f.name, f.name))
+			print ('#define GET_%s(disp) ((disp)->%s)' % (f.name, f.name))
+			print ('#define SET_%s(disp, fn) ((disp)->%s = fn)' % (f.name, f.name))
+
+		print ('')
+		print ('#else')
+		print ('')
+		print ('#define driDispatchRemapTable_size %u' % (count))
+		print ('extern int driDispatchRemapTable[ driDispatchRemapTable_size ];')
+		print ('')
 
 		for [f, index] in functions:
-			print '#define %s_remap_index %u' % (f.name, index)
+			print ('#define %s_remap_index %u' % (f.name, index))
 
-		print ''
+		print ('')
 
 		for [f, index] in functions:
 			arg_string = gl_XML.create_parameter_string( f.parameters, 0 )
 			cast = '%s (GLAPIENTRYP)(%s)' % (f.return_type, arg_string)
 
-			print '#define CALL_%s(disp, parameters) CALL_by_offset(disp, (%s), driDispatchRemapTable[%s_remap_index], parameters)' % (f.name, cast, f.name)
-			print '#define GET_%s(disp) GET_by_offset(disp, driDispatchRemapTable[%s_remap_index])' % (f.name, f.name)
-			print '#define SET_%s(disp, fn) SET_by_offset(disp, driDispatchRemapTable[%s_remap_index], fn)' % (f.name, f.name)
+			print ('#define CALL_%s(disp, parameters) CALL_by_offset(disp, (%s), driDispatchRemapTable[%s_remap_index], parameters)' % (f.name, cast, f.name))
+			print ('#define GET_%s(disp) GET_by_offset(disp, driDispatchRemapTable[%s_remap_index])' % (f.name, f.name))
+			print ('#define SET_%s(disp, fn) SET_by_offset(disp, driDispatchRemapTable[%s_remap_index], fn)' % (f.name, f.name))
 
 
-		print ''
-		print '#endif /* !defined(_GLAPI_USE_REMAP_TABLE) */'
+		print ('')
+		print ('#endif /* !defined(_GLAPI_USE_REMAP_TABLE) */')
 
 		if alias_functions:
-			print ''
-			print '/* define aliases for compatibility */'
+			print ('')
+			print ('/* define aliases for compatibility */')
 			for f in alias_functions:
 				for name in f.entry_points:
 					if name != f.name:
-						print '#define CALL_%s(disp, parameters) CALL_%s(disp, parameters)' % (name, f.name)
-						print '#define GET_%s(disp) GET_%s(disp)' % (name, f.name)
-						print '#define SET_%s(disp, fn) SET_%s(disp, fn)' % (name, f.name)
-			print ''
+						print ('#define CALL_%s(disp, parameters) CALL_%s(disp, parameters)' % (name, f.name))
+						print ('#define GET_%s(disp) GET_%s(disp)' % (name, f.name))
+						print ('#define SET_%s(disp, fn) SET_%s(disp, fn)' % (name, f.name))
+			print ('')
 
-			print '#if defined(_GLAPI_USE_REMAP_TABLE)'
+			print ('#if defined(_GLAPI_USE_REMAP_TABLE)')
 			for f in alias_functions:
 				for name in f.entry_points:
 					if name != f.name:
-						print '#define %s_remap_index %s_remap_index' % (name, f.name)
-			print '#endif /* defined(_GLAPI_USE_REMAP_TABLE) */'
-			print ''
+						print ('#define %s_remap_index %s_remap_index' % (name, f.name))
+			print ('#endif /* defined(_GLAPI_USE_REMAP_TABLE) */')
+			print ('')
 
 		return
 
 
 def show_usage():
-	print "Usage: %s [-f input_file_name] [-m mode] [-c]" % sys.argv[0]
-	print "    -m mode   Mode can be 'table' or 'remap_table'."
-	print "    -c        Enable compatibility with OpenGL ES."
+	print ("Usage: %s [-f input_file_name] [-m mode] [-c]" % sys.argv[0])
+	print ("    -m mode   Mode can be 'table' or 'remap_table'.")
+	print ("    -c        Enable compatibility with OpenGL ES.")
 	sys.exit(1)
 
 if __name__ == '__main__':
--- Mesa-7.8.2/src/mesa/glapi/gen/gl_x86-64_asm.py.orig	2010-06-16 03:43:43.000000000 +1000
+++ Mesa-7.8.2/src/mesa/glapi/gen/gl_x86-64_asm.py	2010-12-06 15:23:06.000000000 +1100
@@ -53,7 +53,7 @@
 	adjust_stack = 0
 	if not should_use_push(registers):
 		adjust_stack = local_size(registers)
-		print '\tsubq\t$%u, %%rsp' % (adjust_stack)
+		print ('\tsubq\t$%u, %%rsp' % (adjust_stack))
 
 	for [reg, stack_offset] in registers:
 		save_reg( reg, stack_offset, adjust_stack )
@@ -71,18 +71,18 @@
 		restore_reg(reg, stack_offset, adjust_stack)
 
 	if adjust_stack:
-		print '\taddq\t$%u, %%rsp' % (adjust_stack)
+		print ('\taddq\t$%u, %%rsp' % (adjust_stack))
 	return
 
 
 def save_reg(reg, offset, use_move):
 	if use_move:
 		if offset == 0:
-			print '\tmovq\t%s, (%%rsp)' % (reg)
+			print ('\tmovq\t%s, (%%rsp)' % (reg))
 		else:
-			print '\tmovq\t%s, %u(%%rsp)' % (reg, offset)
+			print ('\tmovq\t%s, %u(%%rsp)' % (reg, offset))
 	else:
-		print '\tpushq\t%s' % (reg)
+		print ('\tpushq\t%s' % (reg))
 
 	return
 
@@ -90,11 +90,11 @@
 def restore_reg(reg, offset, use_move):
 	if use_move:
 		if offset == 0:
-			print '\tmovq\t(%%rsp), %s' % (reg)
+			print ('\tmovq\t(%%rsp), %s' % (reg))
 		else:
-			print '\tmovq\t%u(%%rsp), %s' % (offset, reg)
+			print ('\tmovq\t%u(%%rsp), %s' % (offset, reg))
 	else:
-		print '\tpopq\t%s' % (reg)
+		print ('\tpopq\t%s' % (reg))
 
 	return
 
@@ -118,84 +118,84 @@
 
 
 	def printRealHeader(self):
-		print "/* If we build with gcc's -fvisibility=hidden flag, we'll need to change"
-		print " * the symbol visibility mode to 'default'."
-		print ' */'
-		print ''
-		print '#include "x86/assyntax.h"'
-		print ''
-		print '#ifdef __GNUC__'
-		print '#  pragma GCC visibility push(default)'
-		print '#  define HIDDEN(x) .hidden x'
-		print '#else'
-		print '#  define HIDDEN(x)'
-		print '#endif'
-		print ''
-		print '# if defined(USE_MGL_NAMESPACE)'
-		print '#  define GL_PREFIX(n) GLNAME(CONCAT(mgl,n))'
-		print '#  define _glapi_Dispatch _mglapi_Dispatch'
-		print '# else'
-		print '#  define GL_PREFIX(n) GLNAME(CONCAT(gl,n))'
-		print '# endif'
-		print ''
-		print '#if defined(PTHREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS)'
-		print '#  define THREADS'
-		print '#endif'
-		print ''
-		print '\t.text'
-		print ''
-		print '#ifdef GLX_USE_TLS'
-		print ''
-		print '\t.globl _x86_64_get_get_dispatch; HIDDEN(_x86_64_get_get_dispatch)'
-		print '_x86_64_get_get_dispatch:'
-		print '\tlea\t_x86_64_get_dispatch(%rip), %rax'
-		print '\tret'
-		print ''
-		print '\t.p2align\t4,,15'
-		print '_x86_64_get_dispatch:'
-		print '\tmovq\t_glapi_tls_Dispatch@GOTTPOFF(%rip), %rax'
-		print '\tmovq\t%fs:(%rax), %rax'
-		print '\tret'
-		print '\t.size\t_x86_64_get_dispatch, .-_x86_64_get_dispatch'
-		print ''
-		print '#elif defined(PTHREADS)'
-		print ''
-		print '\t.extern\t_glapi_Dispatch'
-		print '\t.extern\t_gl_DispatchTSD'
-		print '\t.extern\tpthread_getspecific'
-		print ''
-		print '\t.p2align\t4,,15'
-		print '_x86_64_get_dispatch:'
-		print '\tmovq\t_gl_DispatchTSD(%rip), %rdi'
-		print '\tjmp\tpthread_getspecific@PLT'
-		print ''
-		print '#elif defined(THREADS)'
-		print ''
-		print '\t.extern\t_glapi_get_dispatch'
-		print ''
-		print '#endif'
-		print ''
+		print ("/* If we build with gcc's -fvisibility=hidden flag, we'll need to change")
+		print (" * the symbol visibility mode to 'default'.")
+		print (' */')
+		print ('')
+		print ('#include "x86/assyntax.h"')
+		print ('')
+		print ('#ifdef __GNUC__')
+		print ('#  pragma GCC visibility push(default)')
+		print ('#  define HIDDEN(x) .hidden x')
+		print ('#else')
+		print ('#  define HIDDEN(x)')
+		print ('#endif')
+		print ('')
+		print ('# if defined(USE_MGL_NAMESPACE)')
+		print ('#  define GL_PREFIX(n) GLNAME(CONCAT(mgl,n))')
+		print ('#  define _glapi_Dispatch _mglapi_Dispatch')
+		print ('# else')
+		print ('#  define GL_PREFIX(n) GLNAME(CONCAT(gl,n))')
+		print ('# endif')
+		print ('')
+		print ('#if defined(PTHREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS)')
+		print ('#  define THREADS')
+		print ('#endif')
+		print ('')
+		print ('\t.text')
+		print ('')
+		print ('#ifdef GLX_USE_TLS')
+		print ('')
+		print ('\t.globl _x86_64_get_get_dispatch; HIDDEN(_x86_64_get_get_dispatch)')
+		print ('_x86_64_get_get_dispatch:')
+		print ('\tlea\t_x86_64_get_dispatch(%rip), %rax')
+		print ('\tret')
+		print ('')
+		print ('\t.p2align\t4,,15')
+		print ('_x86_64_get_dispatch:')
+		print ('\tmovq\t_glapi_tls_Dispatch@GOTTPOFF(%rip), %rax')
+		print ('\tmovq\t%fs:(%rax), %rax')
+		print ('\tret')
+		print ('\t.size\t_x86_64_get_dispatch, .-_x86_64_get_dispatch')
+		print ('')
+		print ('#elif defined(PTHREADS)')
+		print ('')
+		print ('\t.extern\t_glapi_Dispatch')
+		print ('\t.extern\t_gl_DispatchTSD')
+		print ('\t.extern\tpthread_getspecific')
+		print ('')
+		print ('\t.p2align\t4,,15')
+		print ('_x86_64_get_dispatch:')
+		print ('\tmovq\t_gl_DispatchTSD(%rip), %rdi')
+		print ('\tjmp\tpthread_getspecific@PLT')
+		print ('')
+		print ('#elif defined(THREADS)')
+		print ('')
+		print ('\t.extern\t_glapi_get_dispatch')
+		print ('')
+		print ('#endif')
+		print ('')
 		return
 
 
 	def printRealFooter(self):
-		print ''
-		print '#if defined(GLX_USE_TLS) && defined(__linux__)'
-		print '	.section ".note.ABI-tag", "a"'
-		print '	.p2align 2'
-		print '	.long	1f - 0f   /* name length */'
-		print '	.long	3f - 2f   /* data length */'
-		print '	.long	1         /* note length */'
-		print '0:	.asciz "GNU"      /* vendor name */'
-		print '1:	.p2align 2'
-		print '2:	.long	0         /* note data: the ABI tag */'
-		print '	.long	2,4,20    /* Minimum kernel version w/TLS */'
-		print '3:	.p2align 2        /* pad out section */'
-		print '#endif /* GLX_USE_TLS */'
-		print ''
-		print '#if defined (__ELF__) && defined (__linux__)'
-		print '	.section .note.GNU-stack,"",%progbits'
-		print '#endif'
+		print ('')
+		print ('#if defined(GLX_USE_TLS) && defined(__linux__)')
+		print ('	.section ".note.ABI-tag", "a"')
+		print ('	.p2align 2')
+		print ('	.long	1f - 0f   /* name length */')
+		print ('	.long	3f - 2f   /* data length */')
+		print ('	.long	1         /* note length */')
+		print ('0:	.asciz "GNU"      /* vendor name */')
+		print ('1:	.p2align 2')
+		print ('2:	.long	0         /* note data: the ABI tag */')
+		print ('	.long	2,4,20    /* Minimum kernel version w/TLS */')
+		print ('3:	.p2align 2        /* pad out section */')
+		print ('#endif /* GLX_USE_TLS */')
+		print ('')
+		print ('#if defined (__ELF__) && defined (__linux__)')
+		print ('	.section .note.GNU-stack,"",%progbits')
+		print ('#endif')
 		return
 
 
@@ -240,47 +240,47 @@
 
 		name = f.dispatch_name()
 
-		print '\t.p2align\t4,,15'
-		print '\t.globl\tGL_PREFIX(%s)' % (name)
-		print '\t.type\tGL_PREFIX(%s), @function' % (name)
+		print ('\t.p2align\t4,,15')
+		print ('\t.globl\tGL_PREFIX(%s)' % (name))
+		print ('\t.type\tGL_PREFIX(%s), @function' % (name))
 		if not f.is_static_entry_point(f.name):
-			print '\tHIDDEN(GL_PREFIX(%s))' % (name)
-		print 'GL_PREFIX(%s):' % (name)
-		print '#if defined(GLX_USE_TLS)'
-		print '\tcall\t_x86_64_get_dispatch@PLT'
-		print '\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)
-		print '\tjmp\t*%r11'
-		print '#elif defined(PTHREADS)'
+			print ('\tHIDDEN(GL_PREFIX(%s))' % (name))
+		print ('GL_PREFIX(%s):' % (name))
+		print ('#if defined(GLX_USE_TLS)')
+		print ('\tcall\t_x86_64_get_dispatch@PLT')
+		print ('\tmovq\t%u(%%rax), %%r11' % (f.offset * 8))
+		print ('\tjmp\t*%r11')
+		print ('#elif defined(PTHREADS)')
 		
 		save_all_regs(registers)
-		print '\tcall\t_x86_64_get_dispatch@PLT'
+		print ('\tcall\t_x86_64_get_dispatch@PLT')
 		restore_all_regs(registers)
 
 		if f.offset == 0:
-			print '\tmovq\t(%rax), %r11'
+			print ('\tmovq\t(%rax), %r11')
 		else:
-			print '\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)
+			print ('\tmovq\t%u(%%rax), %%r11' % (f.offset * 8))
 
-		print '\tjmp\t*%r11'
+		print ('\tjmp\t*%r11')
 
-		print '#else'
-		print '\tmovq\t_glapi_Dispatch(%rip), %rax'
-		print '\ttestq\t%rax, %rax'
-		print '\tje\t1f'
-		print '\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)
-		print '\tjmp\t*%r11'
-		print '1:'
+		print ('#else')
+		print ('\tmovq\t_glapi_Dispatch(%rip), %rax')
+		print ('\ttestq\t%rax, %rax')
+		print ('\tje\t1f')
+		print ('\tmovq\t%u(%%rax), %%r11' % (f.offset * 8))
+		print ('\tjmp\t*%r11')
+		print ('1:')
 
 		save_all_regs(registers)
-		print '\tcall\t_glapi_get_dispatch'
+		print ('\tcall\t_glapi_get_dispatch')
 		restore_all_regs(registers)
 
-		print '\tmovq\t%u(%%rax), %%r11' % (f.offset * 8)
-		print '\tjmp\t*%r11'
-		print '#endif /* defined(GLX_USE_TLS) */'
+		print ('\tmovq\t%u(%%rax), %%r11' % (f.offset * 8))
+		print ('\tjmp\t*%r11')
+		print ('#endif /* defined(GLX_USE_TLS) */')
 
-		print '\t.size\tGL_PREFIX(%s), .-GL_PREFIX(%s)' % (name, name)
-		print ''
+		print ('\t.size\tGL_PREFIX(%s), .-GL_PREFIX(%s)' % (name, name))
+		print ('')
 		return
 
 
@@ -297,16 +297,16 @@
 						text = '\t.globl GL_PREFIX(%s) ; .set GL_PREFIX(%s), GL_PREFIX(%s)' % (n, n, dispatch)
 
 						if f.has_different_protocol(n):
-							print '#ifndef GLX_INDIRECT_RENDERING'
-							print text
-							print '#endif'
+							print ('#ifndef GLX_INDIRECT_RENDERING')
+							print (text)
+							print ('#endif')
 						else:
-							print text
+							print (text)
 
 		return
 
 def show_usage():
-	print "Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0]
+	print ("Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0])
 	sys.exit(1)
 
 if __name__ == '__main__':
@@ -327,7 +327,7 @@
 	if mode == "generic":
 		printer = PrintGenericStubs()
 	else:
-		print "ERROR: Invalid mode \"%s\" specified." % mode
+		print ("ERROR: Invalid mode \"%s\" specified." % mode)
 		show_usage()
 
 	api = gl_XML.parse_GL_API(file_name, glX_XML.glx_item_factory())
--- Mesa-7.8.2/src/mesa/glapi/gen/gl_x86_asm.py.orig	2010-06-16 03:43:43.000000000 +1000
+++ Mesa-7.8.2/src/mesa/glapi/gen/gl_x86_asm.py	2010-12-06 15:22:28.000000000 +1100
@@ -53,159 +53,159 @@
 
 
 	def printRealHeader(self):
-		print '#include "x86/assyntax.h"'
-		print '#include "glapi/glapioffsets.h"'
-		print ''
-		print '#if defined(STDCALL_API)'
-		print '# if defined(USE_MGL_NAMESPACE)'
-		print '#  define GL_PREFIX(n,n2) GLNAME(CONCAT(mgl,n2))'
-		print '# else'
-		print '#  define GL_PREFIX(n,n2) GLNAME(CONCAT(gl,n2))'
-		print '# endif'
-		print '#else'
-		print '# if defined(USE_MGL_NAMESPACE)'
-		print '#  define GL_PREFIX(n,n2) GLNAME(CONCAT(mgl,n))'
-		print '#  define _glapi_Dispatch _mglapi_Dispatch'
-		print '# else'
-		print '#  define GL_PREFIX(n,n2) GLNAME(CONCAT(gl,n))'
-		print '# endif'
-		print '#endif'
-		print ''
-		print '#define GL_OFFSET(x) CODEPTR(REGOFF(4 * x, EAX))'
-		print ''
-		print '#if defined(GNU_ASSEMBLER) && !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__)'
-		print '#define GLOBL_FN(x) GLOBL x ; .type x, function'
-		print '#else'
-		print '#define GLOBL_FN(x) GLOBL x'
-		print '#endif'
-		print ''
-		print '#if defined(PTHREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS)'
-		print '#  define THREADS'
-		print '#endif'
-		print ''
-		print '#ifdef GLX_USE_TLS'
-		print ''
-		print '#ifdef GLX_X86_READONLY_TEXT'
-		print '# define CTX_INSNS MOV_L(GS:(EAX), EAX)'
-		print '#else'
-		print '# define CTX_INSNS NOP /* Pad for init_glapi_relocs() */'
-		print '#endif'
-		print ''
-		print '#  define GL_STUB(fn,off,fn_alt)\t\t\t\\'
-		print 'ALIGNTEXT16;\t\t\t\t\t\t\\'
-		print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\'
-		print 'GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\'
-		print '\tCALL(_x86_get_dispatch) ;\t\t\t\\'
-		print '\tCTX_INSNS ;					\\'
-		print '\tJMP(GL_OFFSET(off))'
-		print ''
-		print '#elif defined(PTHREADS)'
-		print '#  define GL_STUB(fn,off,fn_alt)\t\t\t\\'
-		print 'ALIGNTEXT16;\t\t\t\t\t\t\\'
-		print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\'
-		print 'GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\'
-		print '\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\'
-		print '\tTEST_L(EAX, EAX) ;\t\t\t\t\\'
-		print '\tJE(1f) ;\t\t\t\t\t\\'
-		print '\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\'
-		print '1:\tCALL(_x86_get_dispatch) ;\t\t\t\\'
-		print '\tJMP(GL_OFFSET(off))'
-		print '#elif defined(THREADS)'
-		print '#  define GL_STUB(fn,off,fn_alt)\t\t\t\\'
-		print 'ALIGNTEXT16;\t\t\t\t\t\t\\'
-		print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\'
-		print 'GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\'
-		print '\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\'
-		print '\tTEST_L(EAX, EAX) ;\t\t\t\t\\'
-		print '\tJE(1f) ;\t\t\t\t\t\\'
-		print '\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\'
-		print '1:\tCALL(_glapi_get_dispatch) ;\t\t\t\\'
-		print '\tJMP(GL_OFFSET(off))'
-		print '#else /* Non-threaded version. */'
-		print '#  define GL_STUB(fn,off,fn_alt)\t\t\t\\'
-		print 'ALIGNTEXT16;\t\t\t\t\t\t\\'
-		print 'GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\'
-		print 'GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\'
-		print '\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\'
-		print '\tJMP(GL_OFFSET(off))'
-		print '#endif'
-		print ''
-		print '#ifdef HAVE_ALIAS'
-		print '#  define GL_STUB_ALIAS(fn,off,fn_alt,alias,alias_alt)\t\\'
-		print '\t.globl\tGL_PREFIX(fn, fn_alt) ;\t\t\t\\'
-		print '\t.set\tGL_PREFIX(fn, fn_alt), GL_PREFIX(alias, alias_alt)'
-		print '#else'
-		print '#  define GL_STUB_ALIAS(fn,off,fn_alt,alias,alias_alt)\t\\'
-		print '    GL_STUB(fn, off, fn_alt)'
-		print '#endif'
-		print ''
-		print 'SEG_TEXT'
-		print ''
-		print '#ifdef GLX_USE_TLS'
-		print ''
-		print '\tGLOBL\tGLNAME(_x86_get_dispatch)'
-		print '\tHIDDEN(GLNAME(_x86_get_dispatch))'
-		print 'ALIGNTEXT16'
-		print 'GLNAME(_x86_get_dispatch):'
-		print '\tcall	1f'
-		print '1:\tpopl	%eax'
-		print '\taddl	$_GLOBAL_OFFSET_TABLE_+[.-1b], %eax'
-		print '\tmovl	_glapi_tls_Dispatch@GOTNTPOFF(%eax), %eax'
-		print '\tret'
-		print ''
-		print '#elif defined(PTHREADS)'
-		print 'EXTERN GLNAME(_glapi_Dispatch)'
-		print 'EXTERN GLNAME(_gl_DispatchTSD)'
-		print 'EXTERN GLNAME(pthread_getspecific)'
-		print ''
-		print 'ALIGNTEXT16'
-		print 'GLNAME(_x86_get_dispatch):'
-		print '\tSUB_L(CONST(24), ESP)'
-		print '\tPUSH_L(GLNAME(_gl_DispatchTSD))'
-		print '\tCALL(GLNAME(pthread_getspecific))'
-		print '\tADD_L(CONST(28), ESP)'
-		print '\tRET'
-		print '#elif defined(THREADS)'
-		print 'EXTERN GLNAME(_glapi_get_dispatch)'
-		print '#endif'
-		print ''
-
-		print '#if defined( GLX_USE_TLS ) && !defined( GLX_X86_READONLY_TEXT )'
-		print '\t\t.section\twtext, "awx", @progbits'
-		print '#endif /* defined( GLX_USE_TLS ) */'
-
-		print ''
-		print '\t\tALIGNTEXT16'
-		print '\t\tGLOBL GLNAME(gl_dispatch_functions_start)'
-		print '\t\tHIDDEN(GLNAME(gl_dispatch_functions_start))'
-		print 'GLNAME(gl_dispatch_functions_start):'
-		print ''
+		print ('#include "x86/assyntax.h"')
+		print ('#include "glapi/glapioffsets.h"')
+		print ('')
+		print ('#if defined(STDCALL_API)')
+		print ('# if defined(USE_MGL_NAMESPACE)')
+		print ('#  define GL_PREFIX(n,n2) GLNAME(CONCAT(mgl,n2))')
+		print ('# else')
+		print ('#  define GL_PREFIX(n,n2) GLNAME(CONCAT(gl,n2))')
+		print ('# endif')
+		print ('#else')
+		print ('# if defined(USE_MGL_NAMESPACE)')
+		print ('#  define GL_PREFIX(n,n2) GLNAME(CONCAT(mgl,n))')
+		print ('#  define _glapi_Dispatch _mglapi_Dispatch')
+		print ('# else')
+		print ('#  define GL_PREFIX(n,n2) GLNAME(CONCAT(gl,n))')
+		print ('# endif')
+		print ('#endif')
+		print ('')
+		print ('#define GL_OFFSET(x) CODEPTR(REGOFF(4 * x, EAX))')
+		print ('')
+		print ('#if defined(GNU_ASSEMBLER) && !defined(__DJGPP__) && !defined(__MINGW32__) && !defined(__APPLE__)')
+		print ('#define GLOBL_FN(x) GLOBL x ; .type x, function')
+		print ('#else')
+		print ('#define GLOBL_FN(x) GLOBL x')
+		print ('#endif')
+		print ('')
+		print ('#if defined(PTHREADS) || defined(WIN32_THREADS) || defined(BEOS_THREADS)')
+		print ('#  define THREADS')
+		print ('#endif')
+		print ('')
+		print ('#ifdef GLX_USE_TLS')
+		print ('')
+		print ('#ifdef GLX_X86_READONLY_TEXT')
+		print ('# define CTX_INSNS MOV_L(GS:(EAX), EAX)')
+		print ('#else')
+		print ('# define CTX_INSNS NOP /* Pad for init_glapi_relocs() */')
+		print ('#endif')
+		print ('')
+		print ('#  define GL_STUB(fn,off,fn_alt)\t\t\t\\')
+		print ('ALIGNTEXT16;\t\t\t\t\t\t\\')
+		print ('GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\')
+		print ('GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\')
+		print ('\tCALL(_x86_get_dispatch) ;\t\t\t\\')
+		print ('\tCTX_INSNS ;					\\')
+		print ('\tJMP(GL_OFFSET(off))')
+		print ('')
+		print ('#elif defined(PTHREADS)')
+		print ('#  define GL_STUB(fn,off,fn_alt)\t\t\t\\')
+		print ('ALIGNTEXT16;\t\t\t\t\t\t\\')
+		print ('GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\')
+		print ('GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\')
+		print ('\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\')
+		print ('\tTEST_L(EAX, EAX) ;\t\t\t\t\\')
+		print ('\tJE(1f) ;\t\t\t\t\t\\')
+		print ('\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\')
+		print ('1:\tCALL(_x86_get_dispatch) ;\t\t\t\\')
+		print ('\tJMP(GL_OFFSET(off))')
+		print ('#elif defined(THREADS)')
+		print ('#  define GL_STUB(fn,off,fn_alt)\t\t\t\\')
+		print ('ALIGNTEXT16;\t\t\t\t\t\t\\')
+		print ('GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\')
+		print ('GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\')
+		print ('\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\')
+		print ('\tTEST_L(EAX, EAX) ;\t\t\t\t\\')
+		print ('\tJE(1f) ;\t\t\t\t\t\\')
+		print ('\tJMP(GL_OFFSET(off)) ;\t\t\t\t\\')
+		print ('1:\tCALL(_glapi_get_dispatch) ;\t\t\t\\')
+		print ('\tJMP(GL_OFFSET(off))')
+		print ('#else /* Non-threaded version. */')
+		print ('#  define GL_STUB(fn,off,fn_alt)\t\t\t\\')
+		print ('ALIGNTEXT16;\t\t\t\t\t\t\\')
+		print ('GLOBL_FN(GL_PREFIX(fn, fn_alt));\t\t\t\\')
+		print ('GL_PREFIX(fn, fn_alt):\t\t\t\t\t\\')
+		print ('\tMOV_L(CONTENT(GLNAME(_glapi_Dispatch)), EAX) ;\t\\')
+		print ('\tJMP(GL_OFFSET(off))')
+		print ('#endif')
+		print ('')
+		print ('#ifdef HAVE_ALIAS')
+		print ('#  define GL_STUB_ALIAS(fn,off,fn_alt,alias,alias_alt)\t\\')
+		print ('\t.globl\tGL_PREFIX(fn, fn_alt) ;\t\t\t\\')
+		print ('\t.set\tGL_PREFIX(fn, fn_alt), GL_PREFIX(alias, alias_alt)')
+		print ('#else')
+		print ('#  define GL_STUB_ALIAS(fn,off,fn_alt,alias,alias_alt)\t\\')
+		print ('    GL_STUB(fn, off, fn_alt)')
+		print ('#endif')
+		print ('')
+		print ('SEG_TEXT')
+		print ('')
+		print ('#ifdef GLX_USE_TLS')
+		print ('')
+		print ('\tGLOBL\tGLNAME(_x86_get_dispatch)')
+		print ('\tHIDDEN(GLNAME(_x86_get_dispatch))')
+		print ('ALIGNTEXT16')
+		print ('GLNAME(_x86_get_dispatch):')
+		print ('\tcall	1f')
+		print ('1:\tpopl	%eax')
+		print ('\taddl	$_GLOBAL_OFFSET_TABLE_+[.-1b], %eax')
+		print ('\tmovl	_glapi_tls_Dispatch@GOTNTPOFF(%eax), %eax')
+		print ('\tret')
+		print ('')
+		print ('#elif defined(PTHREADS)')
+		print ('EXTERN GLNAME(_glapi_Dispatch)')
+		print ('EXTERN GLNAME(_gl_DispatchTSD)')
+		print ('EXTERN GLNAME(pthread_getspecific)')
+		print ('')
+		print ('ALIGNTEXT16')
+		print ('GLNAME(_x86_get_dispatch):')
+		print ('\tSUB_L(CONST(24), ESP)')
+		print ('\tPUSH_L(GLNAME(_gl_DispatchTSD))')
+		print ('\tCALL(GLNAME(pthread_getspecific))')
+		print ('\tADD_L(CONST(28), ESP)')
+		print ('\tRET')
+		print ('#elif defined(THREADS)')
+		print ('EXTERN GLNAME(_glapi_get_dispatch)')
+		print ('#endif')
+		print ('')
+
+		print ('#if defined( GLX_USE_TLS ) && !defined( GLX_X86_READONLY_TEXT )')
+		print ('\t\t.section\twtext, "awx", @progbits')
+		print ('#endif /* defined( GLX_USE_TLS ) */')
+
+		print ('')
+		print ('\t\tALIGNTEXT16')
+		print ('\t\tGLOBL GLNAME(gl_dispatch_functions_start)')
+		print ('\t\tHIDDEN(GLNAME(gl_dispatch_functions_start))')
+		print ('GLNAME(gl_dispatch_functions_start):')
+		print ('')
 		return
 
 
 	def printRealFooter(self):
-		print ''
-		print '\t\tGLOBL\tGLNAME(gl_dispatch_functions_end)'
-		print '\t\tHIDDEN(GLNAME(gl_dispatch_functions_end))'
-		print '\t\tALIGNTEXT16'
-		print 'GLNAME(gl_dispatch_functions_end):'
-		print ''
-		print '#if defined(GLX_USE_TLS) && defined(__linux__)'
-		print '	.section ".note.ABI-tag", "a"'
-		print '	.p2align 2'
-		print '	.long	1f - 0f   /* name length */'
-		print '	.long	3f - 2f   /* data length */'
-		print '	.long	1         /* note length */'
-		print '0:	.asciz "GNU"      /* vendor name */'
-		print '1:	.p2align 2'
-		print '2:	.long	0         /* note data: the ABI tag */'
-		print '	.long	2,4,20    /* Minimum kernel version w/TLS */'
-		print '3:	.p2align 2        /* pad out section */'
-		print '#endif /* GLX_USE_TLS */'
-		print ''
-		print '#if defined (__ELF__) && defined (__linux__)'
-		print '	.section .note.GNU-stack,"",%progbits'
-		print '#endif'
+		print ('')
+		print ('\t\tGLOBL\tGLNAME(gl_dispatch_functions_end)')
+		print ('\t\tHIDDEN(GLNAME(gl_dispatch_functions_end))')
+		print ('\t\tALIGNTEXT16')
+		print ('GLNAME(gl_dispatch_functions_end):')
+		print ('')
+		print ('#if defined(GLX_USE_TLS) && defined(__linux__)')
+		print ('	.section ".note.ABI-tag", "a"')
+		print ('	.p2align 2')
+		print ('	.long	1f - 0f   /* name length */')
+		print ('	.long	3f - 2f   /* data length */')
+		print ('	.long	1         /* note length */')
+		print ('0:	.asciz "GNU"      /* vendor name */')
+		print ('1:	.p2align 2')
+		print ('2:	.long	0         /* note data: the ABI tag */')
+		print ('	.long	2,4,20    /* Minimum kernel version w/TLS */')
+		print ('3:	.p2align 2        /* pad out section */')
+		print ('#endif /* GLX_USE_TLS */')
+		print ('')
+		print ('#if defined (__ELF__) && defined (__linux__)')
+		print ('	.section .note.GNU-stack,"",%progbits')
+		print ('#endif')
 		return
 
 
@@ -215,10 +215,10 @@
 			stack = self.get_stack_size(f)
 			alt = "%s@%u" % (name, stack)
 
-			print '\tGL_STUB(%s, _gloffset_%s, %s)' % (name, f.name, alt)
+			print ('\tGL_STUB(%s, _gloffset_%s, %s)' % (name, f.name, alt))
 
 			if not f.is_static_entry_point(f.name):
-				print '\tHIDDEN(GL_PREFIX(%s, %s))' % (name, alt)
+				print ('\tHIDDEN(GL_PREFIX(%s, %s))' % (name, alt))
 
 
 		for f in api.functionIterateByOffset():
@@ -233,16 +233,16 @@
 						text = '\tGL_STUB_ALIAS(%s, _gloffset_%s, %s, %s, %s)' % (n, f.name, alt2, name, alt)
 
 						if f.has_different_protocol(n):
-							print '#ifndef GLX_INDIRECT_RENDERING'
-							print text
-							print '#endif'
+							print ('#ifndef GLX_INDIRECT_RENDERING')
+							print (text)
+							print ('#endif')
 						else:
-							print text
+							print (text)
 
 		return
 
 def show_usage():
-	print "Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0]
+	print ("Usage: %s [-f input_file_name] [-m output_mode]" % sys.argv[0])
 	sys.exit(1)
 
 if __name__ == '__main__':
@@ -263,7 +263,7 @@
 	if mode == "generic":
 		printer = PrintGenericStubs()
 	else:
-		print "ERROR: Invalid mode \"%s\" specified." % mode
+		print ("ERROR: Invalid mode \"%s\" specified." % mode)
 		show_usage()
 
 	api = gl_XML.parse_GL_API(file_name, glX_XML.glx_item_factory())
--- Mesa-7.8.2/src/mesa/glapi/gen/gl_XML.py.orig	2010-06-16 03:43:43.000000000 +1000
+++ Mesa-7.8.2/src/mesa/glapi/gen/gl_XML.py	2010-12-06 15:21:44.000000000 +1100
@@ -127,17 +127,17 @@
 	def printHeader(self):
 		"""Print the header associated with all files and call the printRealHeader method."""
 
-		print '/* DO NOT EDIT - This file generated automatically by %s script */' \
+		print ('/* DO NOT EDIT - This file generated automatically by %s script */' \)
 			% (self.name)
-		print ''
-		print '/*'
-		print ' * ' + self.license.replace('\n', '\n * ')
-		print ' */'
-		print ''
+		print ('')
+		print ('/*')
+		print (' * ' + self.license.replace('\n', '\n * '))
+		print (' */')
+		print ('')
 		if self.header_tag:
-		    print '#if !defined( %s )' % (self.header_tag)
-		    print '#  define %s' % (self.header_tag)
-		    print ''
+		    print ('#if !defined( %s )' % (self.header_tag))
+		    print ('#  define %s' % (self.header_tag))
+		    print ('')
 		self.printRealHeader();
 		return
 
@@ -148,13 +148,13 @@
 		self.printRealFooter()
 
 		if self.undef_list:
-			print ''
+			print ('')
 			for u in self.undef_list:
-				print "#  undef %s" % (u)
+				print ("#  undef %s" % (u))
 
 		if self.header_tag:
-			print ''
-			print '#endif /* !defined( %s ) */' % (self.header_tag)
+			print ('')
+			print ('#endif /* !defined( %s ) */' % (self.header_tag))
 
 
 	def printRealHeader(self):
@@ -184,7 +184,7 @@
 		The name is also added to the file's undef_list.
 		"""
 		self.undef_list.append("PURE")
-		print """#  if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
+		print ("""#  if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)))
 #    define PURE __attribute__((pure))
 #  else
 #    define PURE
@@ -204,7 +204,7 @@
 		"""
 
 		self.undef_list.append("FASTCALL")
-		print """#  if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__)
+		print ("""#  if defined(__i386__) && defined(__GNUC__) && !defined(__CYGWIN__) && !defined(__MINGW32__))
 #    define FASTCALL __attribute__((fastcall))
 #  else
 #    define FASTCALL
@@ -224,7 +224,7 @@
 		"""
 
 		self.undef_list.append(S)
-		print """#  if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) && defined(__ELF__)
+		print ("""#  if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) && defined(__ELF__))
 #    define %s  __attribute__((visibility("%s")))
 #  else
 #    define %s
@@ -244,7 +244,7 @@
 		"""
 
 		self.undef_list.append("NOINLINE")
-		print """#  if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590))
+		print ("""#  if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)))
 #    define NOINLINE __attribute__((noinline))
 #  else
 #    define NOINLINE
@@ -435,11 +435,11 @@
 			elements = 0
 
 		#if ts == "GLdouble":
-		#	print '/* stack size -> %s = %u (before)*/' % (self.name, self.type_expr.get_stack_size())
-		#	print '/* # elements = %u */' % (elements)
+		#	print ('/* stack size -> %s = %u (before)*/' % (self.name, self.type_expr.get_stack_size()))
+		#	print ('/* # elements = %u */' % (elements))
 		self.type_expr.set_elements( elements )
 		#if ts == "GLdouble":
-		#	print '/* stack size -> %s = %u (after) */' % (self.name, self.type_expr.get_stack_size())
+		#	print ('/* stack size -> %s = %u (after) */' % (self.name, self.type_expr.get_stack_size()))
 
 		self.is_client_only = is_attr_true( element, 'client_only' )
 		self.is_counter     = is_attr_true( element, 'counter' )
@@ -963,5 +963,5 @@
 		if type_name in self.types_by_name:
 			return self.types_by_name[ type_name ].type_expr
 		else:
-			print "Unable to find base type matching \"%s\"." % (type_name)
+			print ("Unable to find base type matching \"%s\"." % (type_name))
 			return None
--- Mesa-7.8.2/src/mesa/glapi/gen/glX_doc.py.orig	2010-06-16 03:43:42.000000000 +1000
+++ Mesa-7.8.2/src/mesa/glapi/gen/glX_doc.py	2010-12-06 15:21:20.000000000 +1100
@@ -128,8 +128,8 @@
 		else:
 			s = "%u+%s" % (size, size_str)
 
-		print '            2        %-15s rendering command length' % (s)
-		print '            2        %-4u            rendering command opcode' % (f.glx_rop)
+		print ('            2        %-15s rendering command length' % (s))
+		print ('            2        %-4u            rendering command opcode' % (f.glx_rop))
 		return
 
 
@@ -140,8 +140,8 @@
 		if f.glx_vendorpriv != 0:
 			size += 1
 
-		print '            1        CARD8           opcode (X assigned)'
-		print '            1        %-4u            GLX opcode (%s)' % (f.opcode_real_value(), f.opcode_real_name())
+		print ('            1        CARD8           opcode (X assigned)')
+		print ('            1        %-4u            GLX opcode (%s)' % (f.opcode_real_value(), f.opcode_real_name()))
 
 		if size_str == "":
 			s = "%u" % (size)
@@ -150,28 +150,28 @@
 		else:
 			s = "%u+((%s)/4)" % (size, size_str)
 
-		print '            2        %-15s request length' % (s)
+		print ('            2        %-15s request length' % (s))
 
 		if f.glx_vendorpriv != 0:
-			print '            4        %-4u            vendor specific opcode' % (f.opcode_value())
+			print ('            4        %-4u            vendor specific opcode' % (f.opcode_value()))
 			
-		print '            4        GLX_CONTEXT_TAG context tag'
+		print ('            4        GLX_CONTEXT_TAG context tag')
 
 		return
 		
 
 	def print_reply(self, f):
-		print '          =>'
-		print '            1        1               reply'
-		print '            1                        unused'
-		print '            2        CARD16          sequence number'
+		print ('          =>')
+		print ('            1        1               reply')
+		print ('            1                        unused')
+		print ('            2        CARD16          sequence number')
 
 		if f.output == None:
-			print '            4        0               reply length'
+			print ('            4        0               reply length')
 		elif f.reply_always_array:
-			print '            4        m               reply length'
+			print ('            4        m               reply length')
 		else:
-			print '            4        m               reply length, m = (n == 1 ? 0 : n)'
+			print ('            4        m               reply length, m = (n == 1 ? 0 : n)')
 
 
 		output = None
@@ -182,53 +182,53 @@
 
 		unused = 24
 		if f.return_type != 'void':
-			print '            4        %-15s return value' % (f.return_type)
+			print ('            4        %-15s return value' % (f.return_type))
 			unused -= 4
 		elif output != None:
-			print '            4                        unused'
+			print ('            4                        unused')
 			unused -= 4
 
 		if output != None:
-			print '            4        CARD32          n'
+			print ('            4        CARD32          n')
 			unused -= 4
 
 		if output != None:
 			if not f.reply_always_array:
-				print ''
-				print '            if (n = 1) this follows:'
-				print ''
-				print '            4        CARD32          %s' % (output.name)
-				print '            %-2u                       unused' % (unused - 4)
-				print ''
-				print '            otherwise this follows:'
-				print ''
+				print ('')
+				print ('            if (n = 1) this follows:')
+				print ('')
+				print ('            4        CARD32          %s' % (output.name))
+				print ('            %-2u                       unused' % (unused - 4))
+				print ('')
+				print ('            otherwise this follows:')
+				print ('')
 
-			print '            %-2u                       unused' % (unused)
+			print ('            %-2u                       unused' % (unused))
 
 			[s, pad] = output.packet_size()
-			print '            %-8s %-15s %s' % (s, output.packet_type( self.type_map ), output.name)
+			print ('            %-8s %-15s %s' % (s, output.packet_type( self.type_map ), output.name))
 			if pad != None:
 				try:
 					bytes = int(s)
 					bytes = 4 - (bytes & 3)
-					print '            %-8u %-15s unused' % (bytes, "")
+					print ('            %-8u %-15s unused' % (bytes, ""))
 				except Exception,e:
-					print '            %-8s %-15s unused, %s=pad(%s)' % (pad, "", pad, s)
+					print ('            %-8s %-15s unused, %s=pad(%s)' % (pad, "", pad, s))
 		else:
-			print '            %-2u                       unused' % (unused)
+			print ('            %-2u                       unused' % (unused))
 
 
 	def print_body(self, f):
 		for p in f.parameterIterateGlxSend():
 			[s, pad] = p.packet_size()
-			print '            %-8s %-15s %s' % (s, p.packet_type( self.type_map ), p.name)
+			print ('            %-8s %-15s %s' % (s, p.packet_type( self.type_map ), p.name))
 			if pad != None:
 				try:
 					bytes = int(s)
 					bytes = 4 - (bytes & 3)
-					print '            %-8u %-15s unused' % (bytes, "")
+					print ('            %-8u %-15s unused' % (bytes, ""))
 				except Exception,e:
-					print '            %-8s %-15s unused, %s=pad(%s)' % (pad, "", pad, s)
+					print ('            %-8s %-15s unused, %s=pad(%s)' % (pad, "", pad, s))
 
 	def printBody(self, api):
 		self.type_map = {}
@@ -245,10 +245,10 @@
 
 
 			if f.glx_rop:
-				print '        %s' % (f.name)
+				print ('        %s' % (f.name))
 				self.print_render_header(f)
 			elif f.glx_sop or f.glx_vendorpriv:
-				print '        %s' % (f.name)
+				print ('        %s' % (f.name))
 				self.print_single_header(f)
 			else:
 				continue
@@ -258,7 +258,7 @@
 			if f.needs_reply():
 				self.print_reply(f)
 
-			print ''
+			print ('')
 		return
 
 
--- Mesa-7.8.2/src/mesa/glapi/gen/glX_proto_common.py.orig	2010-06-16 03:43:42.000000000 +1000
+++ Mesa-7.8.2/src/mesa/glapi/gen/glX_proto_common.py	2010-12-06 15:20:49.000000000 +1100
@@ -84,12 +84,12 @@
 
 		compsize = self.size_call(f)
 		if compsize:
-			print '    const GLuint compsize = %s;' % (compsize)
+			print ('    const GLuint compsize = %s;' % (compsize))
 
 		if bias:
-			print '    const GLuint cmdlen = %s - %u;' % (f.command_length(), bias)
+			print ('    const GLuint cmdlen = %s - %u;' % (f.command_length(), bias))
 		else:
-			print '    const GLuint cmdlen = %s;' % (f.command_length())
+			print ('    const GLuint cmdlen = %s;' % (f.command_length()))
 
-		#print ''
+		#print ('')
 		return compsize
--- Mesa-7.8.2/src/mesa/glapi/gen/glX_proto_recv.py.orig	2010-06-16 03:43:42.000000000 +1000
+++ Mesa-7.8.2/src/mesa/glapi/gen/glX_proto_recv.py	2010-12-06 15:20:32.000000000 +1100
@@ -42,8 +42,8 @@
 
 	def printRealHeader(self):
 		self.printVisibility( "HIDDEN", "hidden" )
-		print 'struct __GLXclientStateRec;'
-		print ''
+		print ('struct __GLXclientStateRec;')
+		print ('')
 		return
 
 
@@ -51,16 +51,16 @@
 		for func in api.functionIterateAll():
 			if not func.ignore and not func.vectorequiv:
 				if func.glx_rop:
-					print 'extern HIDDEN void __glXDisp_%s(GLbyte * pc);' % (func.name)
-					print 'extern HIDDEN void __glXDispSwap_%s(GLbyte * pc);' % (func.name)
+					print ('extern HIDDEN void __glXDisp_%s(GLbyte * pc);' % (func.name))
+					print ('extern HIDDEN void __glXDispSwap_%s(GLbyte * pc);' % (func.name))
 				elif func.glx_sop or func.glx_vendorpriv:
-					print 'extern HIDDEN int __glXDisp_%s(struct __GLXclientStateRec *, GLbyte *);' % (func.name)
-					print 'extern HIDDEN int __glXDispSwap_%s(struct __GLXclientStateRec *, GLbyte *);' % (func.name)
+					print ('extern HIDDEN int __glXDisp_%s(struct __GLXclientStateRec *, GLbyte *);' % (func.name))
+					print ('extern HIDDEN int __glXDispSwap_%s(struct __GLXclientStateRec *, GLbyte *);' % (func.name))
 
 					if func.glx_sop and func.glx_vendorpriv:
 						n = func.glx_vendorpriv_names[0]
-						print 'extern HIDDEN int __glXDisp_%s(struct __GLXclientStateRec *, GLbyte *);' % (n)
-						print 'extern HIDDEN int __glXDispSwap_%s(struct __GLXclientStateRec *, GLbyte *);' % (n)
+						print ('extern HIDDEN int __glXDisp_%s(struct __GLXclientStateRec *, GLbyte *);' % (n))
+						print ('extern HIDDEN int __glXDispSwap_%s(struct __GLXclientStateRec *, GLbyte *);' % (n))
 
 		return
 
@@ -77,34 +77,34 @@
 
 
 	def printRealHeader(self):
-		print '#include <X11/Xmd.h>'
-		print '#include <GL/gl.h>'
-		print '#include <GL/glxproto.h>'
-
-		print '#include <inttypes.h>'
-		print '#include "indirect_size.h"'
-		print '#include "indirect_size_get.h"'
-		print '#include "indirect_dispatch.h"'
-		print '#include "glxserver.h"'
-		print '#include "glxbyteorder.h"'
-		print '#include "indirect_util.h"'
-		print '#include "singlesize.h"'
-		print '#include "glapi.h"'
-		print '#include "glapitable.h"'
-		print '#include "glthread.h"'
-		print '#include "glapidispatch.h"'
-		print ''
-		print '#define __GLX_PAD(x)  (((x) + 3) & ~3)'
-		print ''
-		print 'typedef struct {'
-		print '    __GLX_PIXEL_3D_HDR;'
-		print '} __GLXpixel3DHeader;'
-		print ''
-		print 'extern GLboolean __glXErrorOccured( void );'
-		print 'extern void __glXClearErrorOccured( void );'
-		print ''
-		print 'static const unsigned dummy_answer[2] = {0, 0};'
-		print ''
+		print ('#include <X11/Xmd.h>')
+		print ('#include <GL/gl.h>')
+		print ('#include <GL/glxproto.h>')
+
+		print ('#include <inttypes.h>')
+		print ('#include "indirect_size.h"')
+		print ('#include "indirect_size_get.h"')
+		print ('#include "indirect_dispatch.h"')
+		print ('#include "glxserver.h"')
+		print ('#include "glxbyteorder.h"')
+		print ('#include "indirect_util.h"')
+		print ('#include "singlesize.h"')
+		print ('#include "glapi.h"')
+		print ('#include "glapitable.h"')
+		print ('#include "glthread.h"')
+		print ('#include "glapidispatch.h"')
+		print ('')
+		print ('#define __GLX_PAD(x)  (((x) + 3) & ~3)')
+		print ('')
+		print ('typedef struct {')
+		print ('    __GLX_PIXEL_3D_HDR;')
+		print ('} __GLXpixel3DHeader;')
+		print ('')
+		print ('extern GLboolean __glXErrorOccured( void );')
+		print ('extern void __glXClearErrorOccured( void );')
+		print ('')
+		print ('static const unsigned dummy_answer[2] = {0, 0};')
+		print ('')
 		return
 
 
@@ -133,11 +133,11 @@
 			base = '__glXDispSwap'
 
 		if f.glx_rop:
-			print 'void %s_%s(GLbyte * pc)' % (base, name)
+			print ('void %s_%s(GLbyte * pc)' % (base, name))
 		else:
-			print 'int %s_%s(__GLXclientState *cl, GLbyte *pc)' % (base, name)
+			print ('int %s_%s(__GLXclientState *cl, GLbyte *pc)' % (base, name))
 
-		print '{'
+		print ('{')
 
 		if f.glx_rop or f.vectorequiv:
 			self.printRenderFunction(f)
@@ -145,10 +145,10 @@
 			if len(f.get_images()) == 0: 
 				self.printSingleFunction(f, name)
 		else:
-			print "/* Missing GLX protocol for %s. */" % (name)
+			print ("/* Missing GLX protocol for %s. */" % (name))
 
-		print '}'
-		print ''
+		print ('}')
+		print ('')
 		return
 
 
@@ -172,30 +172,30 @@
 				if t.glx_name not in already_done:
 					real_name = self.real_types[t_size]
 
-					print 'static %s' % (t_name)
-					print 'bswap_%s( const void * src )' % (t.glx_name)
-					print '{'
-					print '    union { %s dst; %s ret; } x;' % (real_name, t_name)
-					print '    x.dst = bswap_%u( *(%s *) src );' % (t_size * 8, real_name)
-					print '    return x.ret;'
-					print '}'
-					print ''
+					print ('static %s' % (t_name))
+					print ('bswap_%s( const void * src )' % (t.glx_name))
+					print ('{')
+					print ('    union { %s dst; %s ret; } x;' % (real_name, t_name))
+					print ('    x.dst = bswap_%u( *(%s *) src );' % (t_size * 8, real_name))
+					print ('    return x.ret;')
+					print ('}')
+					print ('')
 					already_done.append( t.glx_name )
 
 		for bits in [16, 32, 64]:
-			print 'static void *'
-			print 'bswap_%u_array( uint%u_t * src, unsigned count )' % (bits, bits)
-			print '{'
-			print '    unsigned  i;'
-			print ''
-			print '    for ( i = 0 ; i < count ; i++ ) {'
-			print '        uint%u_t temp = bswap_%u( src[i] );' % (bits, bits)
-			print '        src[i] = temp;'
-			print '    }'
-			print ''
-			print '    return src;'
-			print '}'
-			print ''
+			print ('static void *')
+			print ('bswap_%u_array( uint%u_t * src, unsigned count )' % (bits, bits))
+			print ('{')
+			print ('    unsigned  i;')
+			print ('')
+			print ('    for ( i = 0 ; i < count ; i++ ) {')
+			print ('        uint%u_t temp = bswap_%u( src[i] );' % (bits, bits))
+			print ('        src[i] = temp;')
+			print ('    }')
+			print ('')
+			print ('    return src;')
+			print ('}')
+			print ('')
 			
 
 	def fetch_param(self, param):
@@ -237,11 +237,11 @@
 			
 
 		if len( list ):
-			print '%s    %sCALL_%s( GET_DISPATCH(), (' % (indent, retval_assign, f.name)
-			print string.join( list, ",\n" )
-			print '%s    ) );' % (indent)
+			print ('%s    %sCALL_%s( GET_DISPATCH(), (' % (indent, retval_assign, f.name))
+			print (string.join( list, ",\n" ))
+			print ('%s    ) );' % (indent))
 		else:
-			print '%s    %sCALL_%s( GET_DISPATCH(), () );' % (indent, retval_assign, f.name)
+			print ('%s    %sCALL_%s( GET_DISPATCH(), () );' % (indent, retval_assign, f.name))
 		return
 
 
@@ -266,7 +266,7 @@
 			# FIXME or something similar.
 
 			if param.img_null_flag:
-				print '%s    const CARD32 ptr_is_null = *(CARD32 *)(pc + %s);' % (indent, param.offset - 4)
+				print ('%s    const CARD32 ptr_is_null = *(CARD32 *)(pc + %s);' % (indent, param.offset - 4))
 				cond = '(ptr_is_null != 0) ? NULL : '
 			else:
 				cond = ""
@@ -277,33 +277,33 @@
 			if param.is_image():
 				offset = f.offset_of( param.name )
 
-				print '%s    %s const %s = (%s) (%s(pc + %s));' % (indent, type_string, param.name, type_string, cond, offset)
+				print ('%s    %s const %s = (%s) (%s(pc + %s));' % (indent, type_string, param.name, type_string, cond, offset))
 				
 				if param.depth:
-					print '%s    __GLXpixel3DHeader * const hdr = (__GLXpixel3DHeader *)(pc);' % (indent)
+					print ('%s    __GLXpixel3DHeader * const hdr = (__GLXpixel3DHeader *)(pc);' % (indent))
 				else:
-					print '%s    __GLXpixelHeader * const hdr = (__GLXpixelHeader *)(pc);' % (indent)
+					print ('%s    __GLXpixelHeader * const hdr = (__GLXpixelHeader *)(pc);' % (indent))
 
 				need_blank = 1
 			elif param.is_counter or param.name in f.count_parameter_list:
 				location = self.fetch_param(param)
-				print '%s    const %s %s = %s;' % (indent, type_string, param.name, location)
+				print ('%s    const %s %s = %s;' % (indent, type_string, param.name, location))
 				need_blank = 1
 			elif len(param.count_parameter_list):
 				if param.size() == 1 and not self.do_swap:
 					location = self.fetch_param(param)
-					print '%s    %s %s = %s%s;' % (indent, type_string, param.name, cond, location)
+					print ('%s    %s %s = %s%s;' % (indent, type_string, param.name, cond, location))
 				else:
-					print '%s    %s %s;' % (indent, type_string, param.name)
+					print ('%s    %s %s;' % (indent, type_string, param.name))
 				need_blank = 1
 
 
 
 		if need_blank:
-			print ''
+			print ('')
 
 		if align64:
-			print '#ifdef __GLX_ALIGN64'
+			print ('#ifdef __GLX_ALIGN64')
 
 			if f.has_variable_size_request():
 				self.emit_packet_size_calculation(f, 4)
@@ -311,12 +311,12 @@
 			else:
 				s = str((f.command_fixed_length() + 3) & ~3)
 
-			print '    if ((unsigned long)(pc) & 7) {'
-			print '        (void) memmove(pc-4, pc, %s);' % (s)
-			print '        pc -= 4;'
-			print '    }'
-			print '#endif'
-			print ''
+			print ('    if ((unsigned long)(pc) & 7) {')
+			print ('        (void) memmove(pc-4, pc, %s);' % (s))
+			print ('        pc -= 4;')
+			print ('    }')
+			print ('#endif')
+			print ('')
 
 
 		need_blank = 0
@@ -341,35 +341,35 @@
 						x.append( [2, ['SHORT', 'UNSIGNED_SHORT']] )
 						x.append( [4, ['INT', 'UNSIGNED_INT', 'FLOAT']] )
 
-						print '    switch(%s) {' % (param.count_parameter_list[0])
+						print ('    switch(%s) {' % (param.count_parameter_list[0]))
 						for sub in x:
 							for t_name in sub[1]:
-								print '    case GL_%s:' % (t_name)
+								print ('    case GL_%s:' % (t_name))
 
 							if sub[0] == 1:
-								print '        %s = (%s) (pc + %s); break;' % (param.name, param.type_string(), o)
+								print ('        %s = (%s) (pc + %s); break;' % (param.name, param.type_string(), o))
 							else:
 								swap_func = self.swap_name(sub[0])
-								print '        %s = (%s) %s( (%s *) (pc + %s), %s ); break;' % (param.name, param.type_string(), swap_func, self.real_types[sub[0]], o, count_name)
-						print '    default:'
-						print '        return;'
-						print '    }'
+								print ('        %s = (%s) %s( (%s *) (pc + %s), %s ); break;' % (param.name, param.type_string(), swap_func, self.real_types[sub[0]], o, count_name))
+						print ('    default:')
+						print ('        return;')
+						print ('    }')
 					else:
 						swap_func = self.swap_name(type_size)
 						compsize = self.size_call(f, 1)
-						print '    %s = (%s) %s( (%s *) (pc + %s), %s );' % (param.name, param.type_string(), swap_func, self.real_types[type_size], o, compsize)
+						print ('    %s = (%s) %s( (%s *) (pc + %s), %s );' % (param.name, param.type_string(), swap_func, self.real_types[type_size], o, compsize))
 
 					need_blank = 1
 
 		else:
 			for param in f.parameterIterateGlxSend():
 				if param.count_parameter_list:
-					print '%s    %s = (%s) (pc + %s);' % (indent, param.name, param.type_string(), param.offset)
+					print ('%s    %s = (%s) (pc + %s);' % (indent, param.name, param.type_string(), param.offset))
 					need_blank = 1
 
 
 		if need_blank:
-			print ''
+			print ('')
 
 
 		return
@@ -377,29 +377,29 @@
 
 	def printSingleFunction(self, f, name):
 		if name not in f.glx_vendorpriv_names:
-			print '    xGLXSingleReq * const req = (xGLXSingleReq *) pc;'
+			print ('    xGLXSingleReq * const req = (xGLXSingleReq *) pc;')
 		else:
-			print '    xGLXVendorPrivateReq * const req = (xGLXVendorPrivateReq *) pc;'
+			print ('    xGLXVendorPrivateReq * const req = (xGLXVendorPrivateReq *) pc;')
 
-		print '    int error;'
+		print ('    int error;')
 
 		if self.do_swap:
-		    print '    __GLXcontext * const cx = __glXForceCurrent(cl, bswap_CARD32( &req->contextTag ), &error);'
+		    print ('    __GLXcontext * const cx = __glXForceCurrent(cl, bswap_CARD32( &req->contextTag ), &error);')
 		else:
-		    print '    __GLXcontext * const cx = __glXForceCurrent(cl, req->contextTag, &error);'
+		    print ('    __GLXcontext * const cx = __glXForceCurrent(cl, req->contextTag, &error);')
 
-		print ''
+		print ('')
 		if name not in f.glx_vendorpriv_names:
-			print '    pc += __GLX_SINGLE_HDR_SIZE;'
+			print ('    pc += __GLX_SINGLE_HDR_SIZE;')
 		else:
-			print '    pc += __GLX_VENDPRIV_HDR_SIZE;'
+			print ('    pc += __GLX_VENDPRIV_HDR_SIZE;')
 
-		print '    if ( cx != NULL ) {'
+		print ('    if ( cx != NULL ) {')
 		self.common_func_print_just_start(f, "    ")
 		
 
 		if f.return_type != 'void':
-			print '        %s retval;' % (f.return_type)
+			print ('        %s retval;' % (f.return_type))
 			retval_string = "retval"
 			retval_assign = "retval = "
 		else:
@@ -427,23 +427,23 @@
 
 
 			if param.count_parameter_list:
-				print '        const GLuint compsize = %s;' % (self.size_call(f, 1))
-				print '        %s answerBuffer[200];' %  (answer_type)
-				print '        %s %s = __glXGetAnswerBuffer(cl, compsize%s, answerBuffer, sizeof(answerBuffer), %u);' % (param.type_string(), param.name, size_scale, type_size )
+				print ('        const GLuint compsize = %s;' % (self.size_call(f, 1)))
+				print ('        %s answerBuffer[200];' %  (answer_type))
+				print ('        %s %s = __glXGetAnswerBuffer(cl, compsize%s, answerBuffer, sizeof(answerBuffer), %u);' % (param.type_string(), param.name, size_scale, type_size ))
 				answer_string = param.name
 				answer_count = "compsize"
 
-				print ''
-				print '        if (%s == NULL) return BadAlloc;' % (param.name)
-				print '        __glXClearErrorOccured();'
-				print ''
+				print ('')
+				print ('        if (%s == NULL) return BadAlloc;' % (param.name))
+				print ('        __glXClearErrorOccured();')
+				print ('')
 			elif param.counter:
-				print '        %s answerBuffer[200];' %  (answer_type)
-				print '        %s %s = __glXGetAnswerBuffer(cl, %s%s, answerBuffer, sizeof(answerBuffer), %u);' % (param.type_string(), param.name, param.counter, size_scale, type_size)
+				print ('        %s answerBuffer[200];' %  (answer_type))
+				print ('        %s %s = __glXGetAnswerBuffer(cl, %s%s, answerBuffer, sizeof(answerBuffer), %u);' % (param.type_string(), param.name, param.counter, size_scale, type_size))
 				answer_string = param.name
 				answer_count = param.counter
 			elif c >= 1:
-				print '        %s %s[%u];' % (answer_type, param.name, c)
+				print ('        %s %s[%u];' % (answer_type, param.name, c))
 				answer_string = param.name
 				answer_count = "%u" % (c)
 
@@ -462,21 +462,21 @@
 
 					if type_size > 1:
 						swap_name = self.swap_name( type_size )
-						print '        (void) %s( (uint%u_t *) %s, %s );' % (swap_name, 8 * type_size, param.name, answer_count)
+						print ('        (void) %s( (uint%u_t *) %s, %s );' % (swap_name, 8 * type_size, param.name, answer_count))
 
 
 				reply_func = '__glXSendReplySwap'
 			else:
 				reply_func = '__glXSendReply'
 
-			print '        %s(cl->client, %s, %s, %u, %s, %s);' % (reply_func, answer_string, answer_count, type_size, is_array_string, retval_string)
+			print ('        %s(cl->client, %s, %s, %u, %s, %s);' % (reply_func, answer_string, answer_count, type_size, is_array_string, retval_string))
 		#elif f.note_unflushed:
-		#	print '        cx->hasUnflushedCommands = GL_TRUE;'
+		#	print ('        cx->hasUnflushedCommands = GL_TRUE;')
 
-		print '        error = Success;'
-		print '    }'
-		print ''
-		print '    return error;'
+		print ('        error = Success;')
+		print ('    }')
+		print ('')
+		print ('    return error;')
 		return
 
 
@@ -505,19 +505,19 @@
 			# the must NEVER be byte-swapped.
 
 			if not (img.img_type == "GL_BITMAP" and img.img_format == "GL_COLOR_INDEX"):
-				print '    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SWAP_BYTES,   hdr->swapBytes) );'
+				print ('    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SWAP_BYTES,   hdr->swapBytes) );')
 
-			print '    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_LSB_FIRST,    hdr->lsbFirst) );'
+			print ('    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_LSB_FIRST,    hdr->lsbFirst) );')
 
-			print '    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_ROW_LENGTH,   (GLint) %shdr->rowLength%s) );' % (pre, post)
+			print ('    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_ROW_LENGTH,   (GLint) %shdr->rowLength%s) );' % (pre, post))
 			if img.depth:
-				print '    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_IMAGE_HEIGHT, (GLint) %shdr->imageHeight%s) );' % (pre, post)
-			print '    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_ROWS,    (GLint) %shdr->skipRows%s) );' % (pre, post)
+				print ('    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_IMAGE_HEIGHT, (GLint) %shdr->imageHeight%s) );' % (pre, post))
+			print ('    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_ROWS,    (GLint) %shdr->skipRows%s) );' % (pre, post))
 			if img.depth:
-				print '    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_IMAGES,  (GLint) %shdr->skipImages%s) );' % (pre, post)
-			print '    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_PIXELS,  (GLint) %shdr->skipPixels%s) );' % (pre, post)
-			print '    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_ALIGNMENT,    (GLint) %shdr->alignment%s) );' % (pre, post)
-			print ''
+				print ('    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_IMAGES,  (GLint) %shdr->skipImages%s) );' % (pre, post))
+			print ('    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_SKIP_PIXELS,  (GLint) %shdr->skipPixels%s) );' % (pre, post))
+			print ('    CALL_PixelStorei( GET_DISPATCH(), (GL_UNPACK_ALIGNMENT,    (GLint) %shdr->alignment%s) );' % (pre, post))
+			print ('')
 
 
 		self.emit_function_call(f, "", "")
--- Mesa-7.8.2/src/mesa/glapi/gen/glX_proto_send.py.orig	2010-06-16 03:43:42.000000000 +1000
+++ Mesa-7.8.2/src/mesa/glapi/gen/glX_proto_send.py	2010-12-06 15:18:38.000000000 +1100
@@ -161,40 +161,40 @@
 		return
 
 	def printRealHeader(self):
-		print ''
-		print '#include <GL/gl.h>'
-		print '#include "indirect.h"'
-		print '#include "glxclient.h"'
-		print '#include "indirect_size.h"'
-		print '#include "glapidispatch.h"'
-		print '#include "glapi.h"'
-		print '#include "glthread.h"'
-		print '#include <GL/glxproto.h>'
-		print '#ifdef USE_XCB'
-		print '#include <X11/Xlib-xcb.h>'
-		print '#include <xcb/xcb.h>'
-		print '#include <xcb/glx.h>'
-		print '#endif /* USE_XCB */'
-
-		print ''
-		print '#define __GLX_PAD(n) (((n) + 3) & ~3)'
-		print ''
+		print ('')
+		print ('#include <GL/gl.h>')
+		print ('#include "indirect.h"')
+		print ('#include "glxclient.h"')
+		print ('#include "indirect_size.h"')
+		print ('#include "glapidispatch.h"')
+		print ('#include "glapi.h"')
+		print ('#include "glthread.h"')
+		print ('#include <GL/glxproto.h>')
+		print ('#ifdef USE_XCB')
+		print ('#include <X11/Xlib-xcb.h>')
+		print ('#include <xcb/xcb.h>')
+		print ('#include <xcb/glx.h>')
+		print ('#endif /* USE_XCB */')
+
+		print ('')
+		print ('#define __GLX_PAD(n) (((n) + 3) & ~3)')
+		print ('')
 		self.printFastcall()
 		self.printNoinline()
-		print ''
-		print '#ifndef __GNUC__'
-		print '#  define __builtin_expect(x, y) x'
-		print '#endif'
-		print ''
-		print '/* If the size and opcode values are known at compile-time, this will, on'
-		print ' * x86 at least, emit them with a single instruction.'
-		print ' */'
-		print '#define emit_header(dest, op, size)            \\'
-		print '    do { union { short s[2]; int i; } temp;    \\'
-		print '         temp.s[0] = (size); temp.s[1] = (op); \\'
-		print '         *((int *)(dest)) = temp.i; } while(0)'
-		print ''
-		print """NOINLINE CARD32
+		print ('')
+		print ('#ifndef __GNUC__')
+		print ('#  define __builtin_expect(x, y) x')
+		print ('#endif')
+		print ('')
+		print ('/* If the size and opcode values are known at compile-time, this will, on')
+		print (' * x86 at least, emit them with a single instruction.')
+		print (' */')
+		print ('#define emit_header(dest, op, size)            \\')
+		print ('    do { union { short s[2]; int i; } temp;    \\')
+		print ('         temp.s[0] = (size); temp.s[1] = (op); \\')
+		print ('         *((int *)(dest)) = temp.i; } while(0)')
+		print ('')
+		print ("""NOINLINE CARD32
 __glXReadReply( Display *dpy, size_t size, void * dest, GLboolean reply_is_always_array )
 {
     xGLXSingleReply reply;
@@ -306,7 +306,7 @@
 #define default_pixel_store_3D_size 36
 #define default_pixel_store_4D      (__glXDefaultPixelStore+0)
 #define default_pixel_store_4D_size 36
-"""
+""")
 
 		for size in self.generic_sizes:
 			self.print_generic_function(size)
@@ -357,9 +357,9 @@
 	def printFunction(self, func, name):
 		footer = '}\n'
 		if func.glx_rop == ~0:
-			print 'static %s' % (func.return_type)
-			print '%s( unsigned opcode, unsigned dim, %s )' % (func.name, func.get_parameter_string())
-			print '{'
+			print ('static %s' % (func.return_type))
+			print ('%s( unsigned opcode, unsigned dim, %s )' % (func.name, func.get_parameter_string()))
+			print ('{')
 		else:
 			if func.has_different_protocol(name):
 				if func.return_type == "void":
@@ -368,24 +368,24 @@
 					ret_string = "return "
 
 				func_name = func.static_glx_name(name)
-				print '#define %s %d' % (func.opcode_vendor_name(name), func.glx_vendorpriv)
-				print '%s gl%s(%s)' % (func.return_type, func_name, func.get_parameter_string())
-				print '{'
-				print '    __GLXcontext * const gc = __glXGetCurrentContext();'
-				print ''
-				print '#ifdef GLX_DIRECT_RENDERING'
-				print '    if (gc->driContext) {'
-				print '    %sCALL_%s(GET_DISPATCH(), (%s));' % (ret_string, func.name, func.get_called_parameter_string())
-				print '    } else'
-				print '#endif'
-				print '    {'
+				print ('#define %s %d' % (func.opcode_vendor_name(name), func.glx_vendorpriv))
+				print ('%s gl%s(%s)' % (func.return_type, func_name, func.get_parameter_string()))
+				print ('{')
+				print ('    __GLXcontext * const gc = __glXGetCurrentContext();')
+				print ('')
+				print ('#ifdef GLX_DIRECT_RENDERING')
+				print ('    if (gc->driContext) {')
+				print ('    %sCALL_%s(GET_DISPATCH(), (%s));' % (ret_string, func.name, func.get_called_parameter_string()))
+				print ('    } else')
+				print ('#endif')
+				print ('    {')
 
 				footer = '}\n}\n'
 			else:
-				print '#define %s %d' % (func.opcode_name(), func.opcode_value())
+				print ('#define %s %d' % (func.opcode_name(), func.opcode_value()))
 
-				print '%s __indirect_gl%s(%s)' % (func.return_type, name, func.get_parameter_string())
-				print '{'
+				print ('%s __indirect_gl%s(%s)' % (func.return_type, name, func.get_parameter_string()))
+				print ('{')
 
 
 		if func.glx_rop != 0 or func.vectorequiv != None:
@@ -397,15 +397,15 @@
 			self.printSingleFunction(func, name)
 			pass
 		else:
-			print "/* Missing GLX protocol for %s. */" % (name)
+			print ("/* Missing GLX protocol for %s. */" % (name))
 
-		print footer
+		print (footer)
 		return
 
 
 	def print_generic_function(self, n):
 		size = (n + 3) & ~3
-		print """static FASTCALL NOINLINE void
+		print ("""static FASTCALL NOINLINE void
 generic_%u_byte( GLint rop, const void * ptr )
 {
     __GLXcontext * const gc = __glXGetCurrentContext();
@@ -416,7 +416,7 @@
     gc->pc += cmdlen;
     if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }
 }
-""" % (n, size + 4, size)
+""" % (n, size + 4, size))
 		return
 
 
@@ -427,14 +427,14 @@
 			src_ptr = "&" + p.name
 
 		if p.is_padding:
-			print '(void) memset((void *)(%s + %u), 0, %s);' \
-			    % (pc, p.offset + adjust, p.size_string() )
+			print ('(void) memset((void *)(%s + %u), 0, %s);' \
+			    % (pc, p.offset + adjust, p.size_string() ))
 		elif not extra_offset:
-			print '(void) memcpy((void *)(%s + %u), (void *)(%s), %s);' \
-			    % (pc, p.offset + adjust, src_ptr, p.size_string() )
+			print ('(void) memcpy((void *)(%s + %u), (void *)(%s), %s);' \
+			    % (pc, p.offset + adjust, src_ptr, p.size_string() ))
 		else:
-			print '(void) memcpy((void *)(%s + %u + %s), (void *)(%s), %s);' \
-			    % (pc, p.offset + adjust, extra_offset, src_ptr, p.size_string() )
+			print ('(void) memcpy((void *)(%s + %u + %s), (void *)(%s), %s);' \
+			    % (pc, p.offset + adjust, extra_offset, src_ptr, p.size_string() ))
 
 	def common_emit_args(self, f, pc, adjust, skip_vla):
 		extra_offset = None
@@ -470,7 +470,7 @@
 				self.common_emit_one_arg(param, pc, adjust, None)
 
 				if f.pad_after(param):
-					print '(void) memcpy((void *)(%s + %u), zero, 4);' % (pc, (param.offset + param.size()) + adjust)
+					print ('(void) memcpy((void *)(%s + %u), zero, 4);' % (pc, (param.offset + param.size()) + adjust))
 
 			else:
 				[dim, width, height, depth, extent] = param.get_dimensions()
@@ -480,14 +480,14 @@
 					dim_str = str(dim)
 
 				if param.is_padding:
-					print '(void) memset((void *)(%s + %u), 0, %s);' \
-					% (pc, (param.offset - 4) + adjust, param.size_string() )
+					print ('(void) memset((void *)(%s + %u), 0, %s);' \
+					% (pc, (param.offset - 4) + adjust, param.size_string() ))
 
 				if param.img_null_flag:
 					if large:
-						print '(void) memcpy((void *)(%s + %u), zero, 4);' % (pc, (param.offset - 4) + adjust)
+						print ('(void) memcpy((void *)(%s + %u), zero, 4);' % (pc, (param.offset - 4) + adjust))
 					else:
-						print '(void) memcpy((void *)(%s + %u), (void *)((%s == NULL) ? one : zero), 4);' % (pc, (param.offset - 4) + adjust, param.name)
+						print ('(void) memcpy((void *)(%s + %u), (void *)((%s == NULL) ? one : zero), 4);' % (pc, (param.offset - 4) + adjust, param.name))
 
 
 				pixHeaderPtr = "%s + %u" % (pc, adjust)
@@ -499,13 +499,13 @@
 					else:
 						condition = 'compsize > 0'
 
-					print 'if (%s) {' % (condition)
-					print '    (*gc->fillImage)(gc, %s, %s, %s, %s, %s, %s, %s, %s, %s);' % (dim_str, width, height, depth, param.img_format, param.img_type, param.name, pcPtr, pixHeaderPtr)
-					print '} else {'
-					print '    (void) memcpy( %s, default_pixel_store_%uD, default_pixel_store_%uD_size );' % (pixHeaderPtr, dim, dim)
-					print '}'
+					print ('if (%s) {' % (condition))
+					print ('    (*gc->fillImage)(gc, %s, %s, %s, %s, %s, %s, %s, %s, %s);' % (dim_str, width, height, depth, param.img_format, param.img_type, param.name, pcPtr, pixHeaderPtr))
+					print ('} else {')
+					print ('    (void) memcpy( %s, default_pixel_store_%uD, default_pixel_store_%uD_size );' % (pixHeaderPtr, dim, dim))
+					print ('}')
 				else:
-					print '__glXSendLargeImage(gc, compsize, %s, %s, %s, %s, %s, %s, %s, %s, %s);' % (dim_str, width, height, depth, param.img_format, param.img_type, param.name, pcPtr, pixHeaderPtr)
+					print ('__glXSendLargeImage(gc, compsize, %s, %s, %s, %s, %s, %s, %s, %s, %s);' % (dim_str, width, height, depth, param.img_format, param.img_type, param.name, pcPtr, pixHeaderPtr))
 
 		return
 
@@ -514,16 +514,16 @@
 		if not op_name:
 			op_name = f.opcode_real_name()
 
-		print 'const GLint op = %s;' % (op_name)
-		print 'const GLuint cmdlenLarge = cmdlen + 4;'
-		print 'GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);'
-		print '(void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);'
-		print '(void) memcpy((void *)(pc + 4), (void *)(&op), 4);'
+		print ('const GLint op = %s;' % (op_name))
+		print ('const GLuint cmdlenLarge = cmdlen + 4;')
+		print ('GLubyte * const pc = __glXFlushRenderBuffer(gc, gc->pc);')
+		print ('(void) memcpy((void *)(pc + 0), (void *)(&cmdlenLarge), 4);')
+		print ('(void) memcpy((void *)(pc + 4), (void *)(&op), 4);')
 		return
 
 
 	def common_func_print_just_start(self, f, name):
-		print '    __GLXcontext * const gc = __glXGetCurrentContext();'
+		print ('    __GLXcontext * const gc = __glXGetCurrentContext();')
 
 		# The only reason that single and vendor private commands need
 		# a variable called 'dpy' is becuase they use the SyncHandle
@@ -541,10 +541,10 @@
 		if not f.glx_rop:
 			for p in f.parameterIterateOutputs():
 				if p.is_image() and (p.img_format != "GL_COLOR_INDEX" or p.img_type != "GL_BITMAP"):
-					print '    const __GLXattribute * const state = gc->client_state_private;'
+					print ('    const __GLXattribute * const state = gc->client_state_private;')
 					break
 
-			print '    Display * const dpy = gc->currentDpy;'
+			print ('    Display * const dpy = gc->currentDpy;')
 			skip_condition = "dpy != NULL"
 		elif f.can_be_large:
 			skip_condition = "gc->currentDpy != NULL"
@@ -553,26 +553,26 @@
 
 
 		if f.return_type != 'void':
-			print '    %s retval = (%s) 0;' % (f.return_type, f.return_type)
+			print ('    %s retval = (%s) 0;' % (f.return_type, f.return_type))
 
 
 		if name != None and name not in f.glx_vendorpriv_names:
-			print '#ifndef USE_XCB'
+			print ('#ifndef USE_XCB')
 		self.emit_packet_size_calculation(f, 0)
 		if name != None and name not in f.glx_vendorpriv_names:
-			print '#endif'
+			print ('#endif')
 
 		condition_list = []
 		for p in f.parameterIterateCounters():
 			condition_list.append( "%s >= 0" % (p.name) )
 			# 'counter' parameters cannot be negative
-			print "    if (%s < 0) {" % p.name
-			print "        __glXSetError(gc, GL_INVALID_VALUE);"
+			print ("    if (%s < 0) {" % p.name)
+			print ("        __glXSetError(gc, GL_INVALID_VALUE);")
 			if f.return_type != 'void':
-				print "        return 0;"
+				print ("        return 0;")
 			else:
-				print "        return;"
-			print "    }"
+				print ("        return;")
+			print ("    }")
 
 		if skip_condition:
 			condition_list.append( skip_condition )
@@ -583,7 +583,7 @@
 			else:
 				skip_condition = "%s" % (condition_list.pop(0))
 
-			print '    if (__builtin_expect(%s, 1)) {' % (skip_condition)
+			print ('    if (__builtin_expect(%s, 1)) {' % (skip_condition))
 			return 1
 		else:
 			return 0
@@ -593,16 +593,16 @@
 		self.common_func_print_just_start(f, name)
 
 		if self.debug:
-			print '        printf( "Enter %%s...\\n", "gl%s" );' % (f.name)
+			print ('        printf( "Enter %%s...\\n", "gl%s" );' % (f.name))
 
 		if name not in f.glx_vendorpriv_names:
 
 			# XCB specific:
-			print '#ifdef USE_XCB'
+			print ('#ifdef USE_XCB')
 			if self.debug:
-				print '        printf("\\tUsing XCB.\\n");'
-			print '        xcb_connection_t *c = XGetXCBConnection(dpy);'
-			print '        (void) __glXFlushRenderBuffer(gc, gc->pc);'
+				print ('        printf("\\tUsing XCB.\\n");')
+			print ('        xcb_connection_t *c = XGetXCBConnection(dpy);')
+			print ('        (void) __glXFlushRenderBuffer(gc, gc->pc);')
 			xcb_name = 'xcb_glx%s' % convertStringForXCB(name)
 
 			iparams=[]
@@ -629,24 +629,24 @@
 			xcb_request = '%s(%s)' % (xcb_name, ", ".join(["c", "gc->currentContextTag"] + iparams + extra_iparams))
 
 			if f.needs_reply():
-				print '        %s_reply_t *reply = %s_reply(c, %s, NULL);' % (xcb_name, xcb_name, xcb_request)
+				print ('        %s_reply_t *reply = %s_reply(c, %s, NULL);' % (xcb_name, xcb_name, xcb_request))
 				if output and f.reply_always_array:
-					print '        (void)memcpy(%s, %s_data(reply), %s_data_length(reply) * sizeof(%s));' % (output.name, xcb_name, xcb_name, output.get_base_type_string())
+					print ('        (void)memcpy(%s, %s_data(reply), %s_data_length(reply) * sizeof(%s));' % (output.name, xcb_name, xcb_name, output.get_base_type_string()))
 
 				elif output and not f.reply_always_array:
 					if not output.is_image():
-						print '        if (%s_data_length(reply) == 0)' % (xcb_name)
-						print '            (void)memcpy(%s, &reply->datum, sizeof(reply->datum));' % (output.name)
-						print '        else'
-					print '        (void)memcpy(%s, %s_data(reply), %s_data_length(reply) * sizeof(%s));' % (output.name, xcb_name, xcb_name, output.get_base_type_string())
+						print ('        if (%s_data_length(reply) == 0)' % (xcb_name))
+						print ('            (void)memcpy(%s, &reply->datum, sizeof(reply->datum));' % (output.name))
+						print ('        else')
+					print ('        (void)memcpy(%s, %s_data(reply), %s_data_length(reply) * sizeof(%s));' % (output.name, xcb_name, xcb_name, output.get_base_type_string()))
 
 
 				if f.return_type != 'void':
-					print '        retval = reply->ret_val;'
-				print '        free(reply);'
+					print ('        retval = reply->ret_val;')
+				print ('        free(reply);')
 			else:
-				print '        ' + xcb_request + ';'
-			print '#else'
+				print ('        ' + xcb_request + ';')
+			print ('#else')
 			# End of XCB specific.
 
 
@@ -656,9 +656,9 @@
 			pc_decl = "(void)"
 
 		if name in f.glx_vendorpriv_names:
-			print '        %s __glXSetupVendorRequest(gc, %s, %s, cmdlen);' % (pc_decl, f.opcode_real_name(), f.opcode_vendor_name(name))
+			print ('        %s __glXSetupVendorRequest(gc, %s, %s, cmdlen);' % (pc_decl, f.opcode_real_name(), f.opcode_vendor_name(name)))
 		else:
-			print '        %s __glXSetupSingleRequest(gc, %s, cmdlen);' % (pc_decl, f.opcode_name())
+			print ('        %s __glXSetupSingleRequest(gc, %s, cmdlen);' % (pc_decl, f.opcode_name()))
 
 		self.common_emit_args(f, "pc", 0, 0)
 
@@ -667,12 +667,12 @@
 		for img in images:
 			if img.is_output:
 				o = f.command_fixed_length() - 4
-				print '        *(int32_t *)(pc + %u) = 0;' % (o)
+				print ('        *(int32_t *)(pc + %u) = 0;' % (o))
 				if img.img_format != "GL_COLOR_INDEX" or img.img_type != "GL_BITMAP":
-					print '        * (int8_t *)(pc + %u) = state->storePack.swapEndian;' % (o)
+					print ('        * (int8_t *)(pc + %u) = state->storePack.swapEndian;' % (o))
 		
 				if f.img_reset:
-					print '        * (int8_t *)(pc + %u) = %s;' % (o + 1, f.img_reset)
+					print ('        * (int8_t *)(pc + %u) = %s;' % (o + 1, f.img_reset))
 
 
 		return_name = ''
@@ -689,9 +689,9 @@
 				if p.is_image():
 					[dim, w, h, d, junk] = p.get_dimensions()
 					if f.dimensions_in_reply:
-						print "        __glXReadPixelReply(dpy, gc, %u, 0, 0, 0, %s, %s, %s, GL_TRUE);" % (dim, p.img_format, p.img_type, p.name)
+						print ("        __glXReadPixelReply(dpy, gc, %u, 0, 0, 0, %s, %s, %s, GL_TRUE);" % (dim, p.img_format, p.img_type, p.name))
 					else:
-						print "        __glXReadPixelReply(dpy, gc, %u, %s, %s, %s, %s, %s, %s, GL_FALSE);" % (dim, w, h, d, p.img_format, p.img_type, p.name)
+						print ("        __glXReadPixelReply(dpy, gc, %u, %s, %s, %s, %s, %s, %s, GL_FALSE);" % (dim, w, h, d, p.img_format, p.img_type, p.name))
 
 					got_reply = 1
 				else:
@@ -711,7 +711,7 @@
 					# non-arrays) gives us this.
 
 					s = p.size() / p.get_element_count()
-					print "       %s __glXReadReply(dpy, %s, %s, %s);" % (return_str, s, p.name, aa)
+					print ("       %s __glXReadReply(dpy, %s, %s, %s);" % (return_str, s, p.name, aa))
 					got_reply = 1
 
 
@@ -719,25 +719,25 @@
 			# read a NULL reply to get the return value.
 
 			if not got_reply:
-				print "       %s __glXReadReply(dpy, 0, NULL, GL_FALSE);" % (return_str)
+				print ("       %s __glXReadReply(dpy, 0, NULL, GL_FALSE);" % (return_str))
 
 
 		elif self.debug:
 			# Only emit the extra glFinish call for functions
 			# that don't already require a reply from the server.
-			print '        __indirect_glFinish();'
+			print ('        __indirect_glFinish();')
 
 		if self.debug:
-			print '        printf( "Exit %%s.\\n", "gl%s" );' % (name)
+			print ('        printf( "Exit %%s.\\n", "gl%s" );' % (name))
 
 
-		print '        UnlockDisplay(dpy); SyncHandle();'
+		print ('        UnlockDisplay(dpy); SyncHandle();')
 
 		if name not in f.glx_vendorpriv_names:
-			print '#endif /* USE_XCB */'
+			print ('#endif /* USE_XCB */')
 
-		print '    }'
-		print '    return%s;' % (return_name)
+		print ('    }')
+		print ('    return%s;' % (return_name))
 		return
 
 
@@ -761,7 +761,7 @@
 				if f.pad_after(param):
 					p_string += ", 1"
 
-			print '    %s(%s, %u%s );' % (self.pixel_stubs[f.name] , f.opcode_name(), dim, p_string)
+			print ('    %s(%s, %u%s );' % (self.pixel_stubs[f.name] , f.opcode_name(), dim, p_string))
 			return
 
 
@@ -772,32 +772,32 @@
 
 
 		if f.can_be_large:
-			print 'if (cmdlen <= gc->maxSmallRenderCommandSize) {'
-			print '    if ( (gc->pc + cmdlen) > gc->bufEnd ) {'
-			print '        (void) __glXFlushRenderBuffer(gc, gc->pc);'
-			print '    }'
+			print ('if (cmdlen <= gc->maxSmallRenderCommandSize) {')
+			print ('    if ( (gc->pc + cmdlen) > gc->bufEnd ) {')
+			print ('        (void) __glXFlushRenderBuffer(gc, gc->pc);')
+			print ('    }')
 
 		if f.glx_rop == ~0:
 			opcode = "opcode"
 		else:
 			opcode = f.opcode_real_name()
 
-		print 'emit_header(gc->pc, %s, cmdlen);' % (opcode)
+		print ('emit_header(gc->pc, %s, cmdlen);' % (opcode))
 
 		self.pixel_emit_args( f, "gc->pc", 0 )
-		print 'gc->pc += cmdlen;'
-		print 'if (gc->pc > gc->limit) { (void) __glXFlushRenderBuffer(gc, gc->pc); }'
+		print ('gc->pc += cmdlen;')
+		print ('if (gc->pc > gc->limit) { (void) __glXFlushRenderBuffer(gc, gc->pc); }')
 
 		if f.can_be_large:
-			print '}'
-			print 'else {'
+			print ('}')
+			print ('else {')
 
 			self.large_emit_begin(f, opcode)
 			self.pixel_emit_args(f, "pc", 1)
 
-			print '}'
+			print ('}')
 
-		if trailer: print trailer
+		if trailer: print (trailer)
 		return
 
 
@@ -814,7 +814,7 @@
 			if p.is_pointer():
 				cmdlen = f.command_fixed_length()
 				if cmdlen in self.generic_sizes:
-					print '    generic_%u_byte( %s, %s );' % (cmdlen, f.opcode_real_name(), p.name)
+					print ('    generic_%u_byte( %s, %s );' % (cmdlen, f.opcode_real_name(), p.name))
 					return
 
 		if self.common_func_print_just_start(f, None):
@@ -823,36 +823,36 @@
 			trailer = None
 
 		if self.debug:
-			print 'printf( "Enter %%s...\\n", "gl%s" );' % (f.name)
+			print ('printf( "Enter %%s...\\n", "gl%s" );' % (f.name))
 
 		if f.can_be_large:
-			print 'if (cmdlen <= gc->maxSmallRenderCommandSize) {'
-			print '    if ( (gc->pc + cmdlen) > gc->bufEnd ) {'
-			print '        (void) __glXFlushRenderBuffer(gc, gc->pc);'
-			print '    }'
+			print ('if (cmdlen <= gc->maxSmallRenderCommandSize) {')
+			print ('    if ( (gc->pc + cmdlen) > gc->bufEnd ) {')
+			print ('        (void) __glXFlushRenderBuffer(gc, gc->pc);')
+			print ('    }')
 
-		print 'emit_header(gc->pc, %s, cmdlen);' % (f.opcode_real_name())
+		print ('emit_header(gc->pc, %s, cmdlen);' % (f.opcode_real_name()))
 
 		self.common_emit_args(f, "gc->pc", 4, 0)
-		print 'gc->pc += cmdlen;'
-		print 'if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }'
+		print ('gc->pc += cmdlen;')
+		print ('if (__builtin_expect(gc->pc > gc->limit, 0)) { (void) __glXFlushRenderBuffer(gc, gc->pc); }')
 
 		if f.can_be_large:
-			print '}'
-			print 'else {'
+			print ('}')
+			print ('else {')
 
 			self.large_emit_begin(f)
 			self.common_emit_args(f, "pc", 8, 1)
 
 			p = f.variable_length_parameter()
-			print '    __glXSendLargeCommand(gc, pc, %u, %s, %s);' % (p.offset + 8, p.name, p.size_string())
-			print '}'
+			print ('    __glXSendLargeCommand(gc, pc, %u, %s, %s);' % (p.offset + 8, p.name, p.size_string()))
+			print ('}')
 
 		if self.debug:
-			print '__indirect_glFinish();'
-			print 'printf( "Exit %%s.\\n", "gl%s" );' % (f.name)
+			print ('__indirect_glFinish();')
+			print ('printf( "Exit %%s.\\n", "gl%s" );' % (f.name))
 
-		if trailer: print trailer
+		if trailer: print (trailer)
 		return
 
 
@@ -868,7 +868,7 @@
 
 
 	def printRealHeader(self):
-		print """/**
+		print ("""/**
  * \\file indirect_init.c
  * Initialize indirect rendering dispatch table.
  *
@@ -918,7 +918,7 @@
 		print """
     return glAPI;
 }
-"""
+""")
 		return
 
 
@@ -931,7 +931,7 @@
 
 			for func in api.functionIterateByCategory(name):
 				if func.client_supported_for_indirect():
-					print '%s    glAPI->%s = __indirect_gl%s;' % (preamble, func.name, func.name)
+					print ('%s    glAPI->%s = __indirect_gl%s;' % (preamble, func.name, func.name))
 					preamble = ''
 
 		return
@@ -952,19 +952,19 @@
 
 
 	def printRealHeader(self):
-		print """/**
+		print ("""/**
  * \\file
  * Prototypes for indirect rendering functions.
  *
  * \\author Kevin E. Martin <kevin@precisioninsight.com>
  * \\author Ian Romanick <idr@us.ibm.com>
  */
-"""
+""")
 		self.printVisibility( "HIDDEN", "hidden" )
 		self.printFastcall()
 		self.printNoinline()
 
-		print """
+		print ("""
 #include "glxclient.h"
 
 extern HIDDEN NOINLINE CARD32 __glXReadReply( Display *dpy, size_t size,
@@ -980,31 +980,31 @@
 
 extern HIDDEN NOINLINE FASTCALL GLubyte * __glXSetupVendorRequest(
     __GLXcontext * gc, GLint code, GLint vop, GLint cmdlen );
-"""
+""")
 
 
 	def printBody(self, api):
 		for func in api.functionIterateGlx():
 			params = func.get_parameter_string()
 
-			print 'extern HIDDEN %s __indirect_gl%s(%s);' % (func.return_type, func.name, params)
+			print ('extern HIDDEN %s __indirect_gl%s(%s);' % (func.return_type, func.name, params))
 
 			for n in func.entry_points:
 				if func.has_different_protocol(n):
 					asdf = func.static_glx_name(n)
 					if asdf not in func.static_entry_points:
-						print 'extern HIDDEN %s gl%s(%s);' % (func.return_type, asdf, params)
+						print ('extern HIDDEN %s gl%s(%s);' % (func.return_type, asdf, params))
 					else:
-						print 'GLAPI %s GLAPIENTRY gl%s(%s);' % (func.return_type, asdf, params)
+						print ('GLAPI %s GLAPIENTRY gl%s(%s);' % (func.return_type, asdf, params))
 						
 					break
 
 
 
 def show_usage():
-	print "Usage: %s [-f input_file_name] [-m output_mode] [-d]" % sys.argv[0]
-	print "    -m output_mode   Output mode can be one of 'proto', 'init_c' or 'init_h'."
-	print "    -d               Enable extra debug information in the generated code."
+	print ("Usage: %s [-f input_file_name] [-m output_mode] [-d]" % sys.argv[0])
+	print ("    -m output_mode   Output mode can be one of 'proto', 'init_c' or 'init_h'.")
+	print ("    -d               Enable extra debug information in the generated code.")
 	sys.exit(1)
 
 
--- Mesa-7.8.2/src/mesa/glapi/gen/glX_proto_size.py.orig	2010-06-16 03:43:42.000000000 +1000
+++ Mesa-7.8.2/src/mesa/glapi/gen/glX_proto_size.py	2010-12-06 15:14:02.000000000 +1100
@@ -166,19 +166,19 @@
 					masked_count[i] = c
 
 
-			print '    static const GLushort a[%u] = {' % (mask + 1)
+			print ('    static const GLushort a[%u] = {' % (mask + 1))
 			for e in masked_enums:
-				print '        %s, ' % (masked_enums[e])
-			print '    };'
+				print ('        %s, ' % (masked_enums[e]))
+			print ('    };')
 
-			print '    static const GLubyte b[%u] = {' % (mask + 1)
+			print ('    static const GLubyte b[%u] = {' % (mask + 1))
 			for c in masked_count:
-				print '        %u, ' % (masked_count[c])
-			print '    };'
+				print ('        %u, ' % (masked_count[c]))
+			print ('    };')
 
-			print '    const unsigned idx = (e & 0x%02xU);' % (mask)
-			print ''
-			print '    return (e == a[idx]) ? (GLint) b[idx] : 0;'
+			print ('    const unsigned idx = (e & 0x%02xU);' % (mask))
+			print ('')
+			print ('    return (e == a[idx]) ? (GLint) b[idx] : 0;')
 			return 1;
 		else:
 			return 0;
@@ -188,7 +188,7 @@
 		"""Emit the body of the __gl*_size function using a 
 		switch-statement."""
 
-		print '    switch( e ) {'
+		print ('    switch( e ) {')
 
 		for c in self.count:
 			for e in self.count[c]:
@@ -210,30 +210,30 @@
 				for k in keys:
 					j = list[k]
 					if first:
-						print '        case GL_%s:' % (j)
+						print ('        case GL_%s:' % (j))
 						first = 0
 					else:
-						print '/*      case GL_%s:*/' % (j)
+						print ('/*      case GL_%s:*/' % (j))
 					
 			if c == -1:
-				print '            return __gl%s_variable_size( e );' % (name)
+				print ('            return __gl%s_variable_size( e );' % (name))
 			else:
-				print '            return %u;' % (c)
+				print ('            return %u;' % (c))
 					
-		print '        default: return 0;'
-		print '    }'
+		print ('        default: return 0;')
+		print ('    }')
 
 
 	def Print(self, name):
-		print 'INTERNAL PURE FASTCALL GLint'
-		print '__gl%s_size( GLenum e )' % (name)
-		print '{'
+		print ('INTERNAL PURE FASTCALL GLint')
+		print ('__gl%s_size( GLenum e )' % (name))
+		print ('{')
 
 		if not self.PrintUsingTable():
 			self.PrintUsingSwitch(name)
 
-		print '}'
-		print ''
+		print ('}')
+		print ('')
 
 
 class glx_server_enum_function(glx_enum_function):
@@ -281,18 +281,18 @@
 			fixup.append( p.name )
 
 
-		print '    GLsizei compsize;'
-		print ''
+		print ('    GLsizei compsize;')
+		print ('')
 
 		printer.common_emit_fixups(fixup)
 
-		print ''
-		print '    compsize = __gl%s_size(%s);' % (f.name, string.join(f.count_parameter_list, ","))
+		print ('')
+		print ('    compsize = __gl%s_size(%s);' % (f.name, string.join(f.count_parameter_list, ",")))
 		p = f.variable_length_parameter()
-		print '    return __GLX_PAD(%s);' % (p.size_string())
+		print ('    return __GLX_PAD(%s);' % (p.size_string()))
 
-		print '}'
-		print ''
+		print ('}')
+		print ('')
 
 
 class PrintGlxSizeStubs_common(gl_XML.gl_print_base):
@@ -312,38 +312,38 @@
 
 class PrintGlxSizeStubs_c(PrintGlxSizeStubs_common):
 	def printRealHeader(self):
-		print ''
-		print '#include <GL/gl.h>'
+		print ('')
+		print ('#include <GL/gl.h>')
 		if self.emit_get:
-			print '#include "indirect_size_get.h"'
-			print '#include "glxserver.h"'
-			print '#include "indirect_util.h"'
+			print ('#include "indirect_size_get.h"')
+			print ('#include "glxserver.h"')
+			print ('#include "indirect_util.h"')
 		
-		print '#include "indirect_size.h"'
+		print ('#include "indirect_size.h"')
 
-		print ''
+		print ('')
 		self.printPure()
-		print ''
+		print ('')
 		self.printFastcall()
-		print ''
+		print ('')
 		self.printVisibility( "INTERNAL", "internal" )
-		print ''
-		print ''
-		print '#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__APPLE__)'
-		print '#  undef HAVE_ALIAS'
-		print '#endif'
-		print '#ifdef HAVE_ALIAS'
-		print '#  define ALIAS2(from,to) \\'
-		print '    INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \\'
-		print '        __attribute__ ((alias( # to )));'
-		print '#  define ALIAS(from,to) ALIAS2( from, __gl ## to ## _size )'
-		print '#else'
-		print '#  define ALIAS(from,to) \\'
-		print '    INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \\'
-		print '    { return __gl ## to ## _size( e ); }'
-		print '#endif'
-		print ''
-		print ''
+		print ('')
+		print ('')
+		print ('#if defined(__CYGWIN__) || defined(__MINGW32__) || defined(__APPLE__)')
+		print ('#  undef HAVE_ALIAS')
+		print ('#endif')
+		print ('#ifdef HAVE_ALIAS')
+		print ('#  define ALIAS2(from,to) \\')
+		print ('    INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \\')
+		print ('        __attribute__ ((alias( # to )));')
+		print ('#  define ALIAS(from,to) ALIAS2( from, __gl ## to ## _size )')
+		print ('#else')
+		print ('#  define ALIAS(from,to) \\')
+		print ('    INTERNAL PURE FASTCALL GLint __gl ## from ## _size( GLenum e ) \\')
+		print ('    { return __gl ## to ## _size( e ); }')
+		print ('#endif')
+		print ('')
+		print ('')
 
 
 	def printBody(self, api):
@@ -365,26 +365,26 @@
 
 
 		for [alias_name, real_name] in aliases:
-			print 'ALIAS( %s, %s )' % (alias_name, real_name)
+			print ('ALIAS( %s, %s )' % (alias_name, real_name))
 
 
 				
 class PrintGlxSizeStubs_h(PrintGlxSizeStubs_common):
 	def printRealHeader(self):
-		print """/**
+		print ("""/**
  * \\file
  * Prototypes for functions used to determine the number of data elements in
  * various GLX protocol messages.
  *
  * \\author Ian Romanick <idr@us.ibm.com>
  */
-"""
+""")
 		self.printPure();
-		print ''
+		print ('')
 		self.printFastcall();
-		print ''
+		print ('')
 		self.printVisibility( "INTERNAL", "internal" );
-		print ''
+		print ('')
 
 
 	def printBody(self, api):
@@ -394,7 +394,7 @@
 				continue
 
 			if (ef.is_set() and self.emit_set) or (not ef.is_set() and self.emit_get):
-				print 'extern INTERNAL PURE FASTCALL GLint __gl%s_size(GLenum);' % (func.name)
+				print ('extern INTERNAL PURE FASTCALL GLint __gl%s_size(GLenum);' % (func.name))
 
 
 class PrintGlxReqSize_common(gl_XML.gl_print_base):
@@ -419,15 +419,15 @@
 
 	def printRealHeader(self):
 		self.printVisibility("HIDDEN", "hidden")
-		print ''
+		print ('')
 		self.printPure()
-		print ''
+		print ('')
 
 
 	def printBody(self, api):
 		for func in api.functionIterateGlx():
 			if not func.ignore and func.has_variable_size_request():
-				print 'extern PURE HIDDEN int __glX%sReqSize(const GLbyte *pc, Bool swap);' % (func.name)
+				print ('extern PURE HIDDEN int __glX%sReqSize(const GLbyte *pc, Bool swap);' % (func.name))
 
 
 class PrintGlxReqSize_c(PrintGlxReqSize_common):
@@ -444,30 +444,30 @@
 
 
 	def printRealHeader(self):
-		print ''
-		print '#include <GL/gl.h>'
-		print '#include "glxserver.h"'
-		print '#include "glxbyteorder.h"'
-		print '#include "indirect_size.h"'
-		print '#include "indirect_reqsize.h"'
-		print ''
-		print '#define __GLX_PAD(x)  (((x) + 3) & ~3)'
-		print ''
-		print '#if defined(__CYGWIN__) || defined(__MINGW32__)'
-		print '#  undef HAVE_ALIAS'
-		print '#endif'
-		print '#ifdef HAVE_ALIAS'
-		print '#  define ALIAS2(from,to) \\'
-		print '    GLint __glX ## from ## ReqSize( const GLbyte * pc, Bool swap ) \\'
-		print '        __attribute__ ((alias( # to )));'
-		print '#  define ALIAS(from,to) ALIAS2( from, __glX ## to ## ReqSize )'
-		print '#else'
-		print '#  define ALIAS(from,to) \\'
-		print '    GLint __glX ## from ## ReqSize( const GLbyte * pc, Bool swap ) \\'
-		print '    { return __glX ## to ## ReqSize( pc, swap ); }'
-		print '#endif'
-		print ''
-		print ''
+		print ('')
+		print ('#include <GL/gl.h>')
+		print ('#include "glxserver.h"')
+		print ('#include "glxbyteorder.h"')
+		print ('#include "indirect_size.h"')
+		print ('#include "indirect_reqsize.h"')
+		print ('')
+		print ('#define __GLX_PAD(x)  (((x) + 3) & ~3)')
+		print ('')
+		print ('#if defined(__CYGWIN__) || defined(__MINGW32__)')
+		print ('#  undef HAVE_ALIAS')
+		print ('#endif')
+		print ('#ifdef HAVE_ALIAS')
+		print ('#  define ALIAS2(from,to) \\')
+		print ('    GLint __glX ## from ## ReqSize( const GLbyte * pc, Bool swap ) \\')
+		print ('        __attribute__ ((alias( # to )));')
+		print ('#  define ALIAS(from,to) ALIAS2( from, __glX ## to ## ReqSize )')
+		print ('#else')
+		print ('#  define ALIAS(from,to) \\')
+		print ('    GLint __glX ## from ## ReqSize( const GLbyte * pc, Bool swap ) \\')
+		print ('    { return __glX ## to ## ReqSize( pc, swap ); }')
+		print ('#endif')
+		print ('')
+		print ('')
 
 
 	def printBody(self, api):
@@ -519,7 +519,7 @@
 
 
 		for [alias_name, real_name] in aliases:
-			print 'ALIAS( %s, %s )' % (alias_name, real_name)
+			print ('ALIAS( %s, %s )' % (alias_name, real_name))
 
 		return
 
@@ -528,10 +528,10 @@
 		"""Utility function to emit conditional byte-swaps."""
 
 		if fixup:
-			print '    if (swap) {'
+			print ('    if (swap) {')
 			for name in fixup:
-				print '        %s = bswap_32(%s);' % (name, name)
-			print '    }'
+				print ('        %s = bswap_32(%s);' % (name, name))
+			print ('    }')
 
 		return
 
@@ -540,14 +540,14 @@
 		offset = p.offset
 		dst = p.string()
 		src = '(%s *)' % (p.type_string())
-		print '%-18s = *%11s(%s + %u);' % (dst, src, pc, offset + adjust);
+		print ('%-18s = *%11s(%s + %u);' % (dst, src, pc, offset + adjust))
 		return
 
 
 	def common_func_print_just_header(self, f):
-		print 'int'
-		print '__glX%sReqSize( const GLbyte * pc, Bool swap )' % (f.name)
-		print '{'
+		print ('int')
+		print ('__glX%sReqSize( const GLbyte * pc, Bool swap )' % (f.name))
+		print ('{')
 
 
 	def printPixelFunction(self, f):
@@ -556,20 +556,20 @@
 		f.offset_of( f.parameters[0].name )
 		[dim, w, h, d, junk] = f.get_images()[0].get_dimensions()
 
-		print '    GLint row_length   = *  (GLint *)(pc +  4);'
+		print ('    GLint row_length   = *  (GLint *)(pc +  4);')
 
 		if dim < 3:
 			fixup = ['row_length', 'skip_rows', 'alignment']
-			print '    GLint image_height = 0;'
-			print '    GLint skip_images  = 0;'
-			print '    GLint skip_rows    = *  (GLint *)(pc +  8);'
-			print '    GLint alignment    = *  (GLint *)(pc + 16);'
+			print ('    GLint image_height = 0;')
+			print ('    GLint skip_images  = 0;')
+			print ('    GLint skip_rows    = *  (GLint *)(pc +  8);')
+			print ('    GLint alignment    = *  (GLint *)(pc + 16);')
 		else:
 			fixup = ['row_length', 'image_height', 'skip_rows', 'skip_images', 'alignment']
-			print '    GLint image_height = *  (GLint *)(pc +  8);'
-			print '    GLint skip_rows    = *  (GLint *)(pc + 16);'
-			print '    GLint skip_images  = *  (GLint *)(pc + 20);'
-			print '    GLint alignment    = *  (GLint *)(pc + 32);'
+			print ('    GLint image_height = *  (GLint *)(pc +  8);')
+			print ('    GLint skip_rows    = *  (GLint *)(pc + 16);')
+			print ('    GLint skip_images  = *  (GLint *)(pc + 20);')
+			print ('    GLint alignment    = *  (GLint *)(pc + 32);')
 
 		img = f.images[0]
 		for p in f.parameterIterateGlxSend():
@@ -577,21 +577,21 @@
 				self.common_emit_one_arg(p, "pc", 0)
 				fixup.append( p.name )
 
-		print ''
+		print ('')
 
 		self.common_emit_fixups(fixup)
 
 		if img.img_null_flag:
-			print ''
-			print '	   if (*(CARD32 *) (pc + %s))' % (img.offset - 4)
-			print '	       return 0;'
-
-		print ''
-		print '    return __glXImageSize(%s, %s, %s, %s, %s, %s,' % (img.img_format, img.img_type, img.img_target, w, h, d )
-		print '                          image_height, row_length, skip_images,'
-		print '                          skip_rows, alignment);'
-		print '}'
-		print ''
+			print ('')
+			print ('	   if (*(CARD32 *) (pc + %s))' % (img.offset - 4))
+			print ('	       return 0;')
+
+		print ('')
+		print ('    return __glXImageSize(%s, %s, %s, %s, %s, %s,' % (img.img_format, img.img_type, img.img_target, w, h, d ))
+		print ('                          image_height, row_length, skip_images,')
+		print ('                          skip_rows, alignment);')
+		print ('}')
+		print ('')
 		return
 
 
@@ -640,24 +640,24 @@
 				self.common_emit_one_arg(p, "pc", 0)
 
 
-			print ''
+			print ('')
 			self.common_emit_fixups(fixup)
-			print ''
+			print ('')
 
-			print '    return __GLX_PAD(%s);' % (size)
-			print '}'
-			print ''
+			print ('    return __GLX_PAD(%s);' % (size))
+			print ('}')
+			print ('')
 
 		return alias
 
 
 def show_usage():
-	print "Usage: %s [-f input_file_name] -m output_mode [--only-get | --only-set] [--get-alias-set]" % sys.argv[0]
-	print "    -m output_mode   Output mode can be one of 'size_c' or 'size_h'."
-	print "    --only-get       Only emit 'get'-type functions."
-	print "    --only-set       Only emit 'set'-type functions."
-	print ""
-	print "By default, both 'get' and 'set'-type functions are emitted."
+	print ("Usage: %s [-f input_file_name] -m output_mode [--only-get | --only-set] [--get-alias-set]" % sys.argv[0])
+	print ("    -m output_mode   Output mode can be one of 'size_c' or 'size_h'.")
+	print ("    --only-get       Only emit 'get'-type functions.")
+	print ("    --only-set       Only emit 'set'-type functions.")
+	print ("")
+	print ("By default, both 'get' and 'set'-type functions are emitted.")
 	sys.exit(1)
 
 
--- Mesa-7.8.2/src/mesa/glapi/gen/glX_server_table.py.orig	2010-06-16 03:43:42.000000000 +1000
+++ Mesa-7.8.2/src/mesa/glapi/gen/glX_server_table.py	2010-12-06 15:09:33.000000000 +1100
@@ -172,8 +172,8 @@
 		if children == []:
 			return
 
-		print '    /* [%u] -> opcode range [%u, %u], node depth %u */' % (base_entry, base_opcode, base_opcode + (1 << remaining_bits), depth)
-		print '    %u,' % (M)
+		print ('    /* [%u] -> opcode range [%u, %u], node depth %u */' % (base_entry, base_opcode, base_opcode + (1 << remaining_bits), depth))
+		print ('    %u,' % (M))
 
 		base_entry += (1 << M) + 1
 
@@ -182,7 +182,7 @@
 		for child in children:
 			if child[1] == []:
 				if self.is_empty_leaf(child_base_opcode, child_M):
-					print '    EMPTY_LEAF,'
+					print ('    EMPTY_LEAF,')
 				else:
 					# Emit the index of the next dispatch
 					# function.  Then add all the
@@ -190,7 +190,7 @@
 					# node to the dispatch function
 					# lookup table.
 
-					print '    LEAF(%u),' % (len(self.lookup_table))
+					print ('    LEAF(%u),' % (len(self.lookup_table)))
 
 					for op in range(child_base_opcode, child_base_opcode + (1 << child_M)):
 						if self.functions.has_key(op):
@@ -218,12 +218,12 @@
 
 						self.lookup_table.append(temp)
 			else:
-				print '    %u,' % (child_index)
+				print ('    %u,' % (child_index))
 				child_index += child[2]
 
 			child_base_opcode += 1 << child_M
 
-		print ''
+		print ('')
 
 		child_index = base_entry
 		for child in children:
@@ -278,31 +278,31 @@
 
 		tree = self.divide_group(0, 0)
 
-		print '/*****************************************************************/'
-		print '/* tree depth = %u */' % (tree[3])
-		print 'static const int_fast16_t %s_dispatch_tree[%u] = {' % (self.name_base, tree[2])
+		print ('/*****************************************************************/')
+		print ('/* tree depth = %u */' % (tree[3]))
+		print ('static const int_fast16_t %s_dispatch_tree[%u] = {' % (self.name_base, tree[2]))
 		self.dump_tree(tree, 0, self.max_bits, 0, 1)
-		print '};\n'
+		print ('};\n')
 		
 		# After dumping the tree, dump the function lookup table.
 		
-		print 'static const void *%s_function_table[%u][2] = {' % (self.name_base, len(self.lookup_table))
+		print ('static const void *%s_function_table[%u][2] = {' % (self.name_base, len(self.lookup_table)))
 		index = 0
 		for func in self.lookup_table:
 			opcode = func[0]
 			name = func[1]
 			name_swap = func[2]
 			
-			print '    /* [% 3u] = %5u */ {%s, %s},' % (index, opcode, name, name_swap)
+			print ('    /* [% 3u] = %5u */ {%s, %s},' % (index, opcode, name, name_swap))
 			
 			index += 1
 
-		print '};\n'
+		print ('};\n')
 		
 		if self.do_size_check:
 			var_table = []
 
-			print 'static const int_fast16_t %s_size_table[%u][2] = {' % (self.name_base, len(self.lookup_table))
+			print ('static const int_fast16_t %s_size_table[%u][2] = {' % (self.name_base, len(self.lookup_table)))
 			index = 0
 			var_table = []
 			for func in self.lookup_table:
@@ -316,31 +316,31 @@
 				else:
 					var_offset = "~0"
 
-				print '    /* [%3u] = %5u */ {%3u, %s},' % (index, opcode, fixed, var_offset)
+				print ('    /* [%3u] = %5u */ {%3u, %s},' % (index, opcode, fixed, var_offset))
 				index += 1
 
 				
-			print '};\n'
+			print ('};\n')
 
 
-			print 'static const gl_proto_size_func %s_size_func_table[%u] = {' % (self.name_base, len(var_table))
+			print ('static const gl_proto_size_func %s_size_func_table[%u] = {' % (self.name_base, len(var_table)))
 			for func in var_table:
-				print '   %s,' % (func)
+				print ('   %s,' % (func))
  
-			print '};\n'
+			print ('};\n')
 
 
-		print 'const struct __glXDispatchInfo %s_dispatch_info = {' % (self.name_base)
-		print '    %u,' % (self.max_bits)
-		print '    %s_dispatch_tree,' % (self.name_base)
-		print '    %s_function_table,' % (self.name_base)
+		print ('const struct __glXDispatchInfo %s_dispatch_info = {' % (self.name_base))
+		print ('    %u,' % (self.max_bits))
+		print ('    %s_dispatch_tree,' % (self.name_base))
+		print ('    %s_function_table,' % (self.name_base))
 		if self.do_size_check:
-			print '    %s_size_table,' % (self.name_base)
-			print '    %s_size_func_table' % (self.name_base)
+			print ('    %s_size_table,' % (self.name_base))
+			print ('    %s_size_func_table' % (self.name_base))
 		else:
-			print '    NULL,'
-			print '    NULL'
-		print '};\n'
+			print ('    NULL,')
+			print ('    NULL')
+		print ('};\n')
 		return
 
 
@@ -357,14 +357,14 @@
 
 
 	def printRealHeader(self):
-		print '#include <inttypes.h>'
-		print '#include "glxserver.h"'
-		print '#include "glxext.h"'
-		print '#include "indirect_dispatch.h"'
-		print '#include "indirect_reqsize.h"'
-		print '#include "g_disptab.h"'
-		print '#include "indirect_table.h"'
-		print ''
+		print ('#include <inttypes.h>')
+		print ('#include "glxserver.h"')
+		print ('#include "glxext.h"')
+		print ('#include "indirect_dispatch.h"')
+		print ('#include "indirect_reqsize.h"')
+		print ('#include "g_disptab.h"')
+		print ('#include "indirect_table.h"')
+		print ('')
 		return
 
 
--- Mesa-7.8.2/src/mesa/glapi/gen/mesadef.py.orig	2010-06-16 03:43:43.000000000 +1000
+++ Mesa-7.8.2/src/mesa/glapi/gen/mesadef.py	2010-12-06 15:07:30.000000000 +1100
@@ -40,147 +40,147 @@
 
 
 def PrintHead():
-	print '; DO NOT EDIT - This file generated automatically by mesadef.py script'
-	print 'DESCRIPTION \'Mesa (OpenGL work-alike) for Win32\''
-	print 'VERSION 6.0'
-	print ';'
-	print '; Module definition file for Mesa (OPENGL32.DLL)'
-	print ';'
-	print '; Note: The OpenGL functions use the STDCALL'
-	print '; function calling convention.  Microsoft\'s'
-	print '; OPENGL32 uses this convention and so must the'
-	print '; Mesa OPENGL32 so that the Mesa DLL can be used'
-	print '; as a drop-in replacement.'
-	print ';'
-	print '; The linker exports STDCALL entry points with'
-	print '; \'decorated\' names; e.g., _glBegin@0, where the'
-	print '; trailing number is the number of bytes of '
-	print '; parameter data pushed onto the stack.  The'
-	print '; callee is responsible for popping this data'
-	print '; off the stack, usually via a RETF n instruction.'
-	print ';'
-	print '; However, the Microsoft OPENGL32.DLL does not export'
-	print '; the decorated names, even though the calling convention'
-	print '; is STDCALL.  So, this module definition file is'
-	print '; needed to force the Mesa OPENGL32.DLL to export the'
-	print '; symbols in the same manner as the Microsoft DLL.'
-	print '; Were it not for this problem, this file would not'
-	print '; be needed (for the gl* functions) since the entry'
-	print '; points are compiled with dllexport declspec.'
-	print ';'
-	print '; However, this file is still needed to export "internal"'
-	print '; Mesa symbols for the benefit of the OSMESA32.DLL.'
-	print ';'
-	print 'EXPORTS'
+	print ('; DO NOT EDIT - This file generated automatically by mesadef.py script')
+	print ('DESCRIPTION \'Mesa (OpenGL work-alike) for Win32\'')
+	print ('VERSION 6.0')
+	print (';')
+	print ('; Module definition file for Mesa (OPENGL32.DLL)')
+	print (';')
+	print ('; Note: The OpenGL functions use the STDCALL')
+	print ('; function calling convention.  Microsoft\'s')
+	print ('; OPENGL32 uses this convention and so must the')
+	print ('; Mesa OPENGL32 so that the Mesa DLL can be used')
+	print ('; as a drop-in replacement.')
+	print (';')
+	print ('; The linker exports STDCALL entry points with')
+	print ('; \'decorated\' names; e.g., _glBegin@0, where the')
+	print ('; trailing number is the number of bytes of ')
+	print ('; parameter data pushed onto the stack.  The')
+	print ('; callee is responsible for popping this data')
+	print ('; off the stack, usually via a RETF n instruction.')
+	print (';')
+	print ('; However, the Microsoft OPENGL32.DLL does not export')
+	print ('; the decorated names, even though the calling convention')
+	print ('; is STDCALL.  So, this module definition file is')
+	print ('; needed to force the Mesa OPENGL32.DLL to export the')
+	print ('; symbols in the same manner as the Microsoft DLL.')
+	print ('; Were it not for this problem, this file would not')
+	print ('; be needed (for the gl* functions) since the entry')
+	print ('; points are compiled with dllexport declspec.')
+	print (';')
+	print ('; However, this file is still needed to export "internal"')
+	print ('; Mesa symbols for the benefit of the OSMESA32.DLL.')
+	print (';')
+	print ('EXPORTS')
 	return
 #enddef
 
 
 def PrintTail():
-	print ';'
-	print '; WGL API'
-	print '\twglChoosePixelFormat'
-	print '\twglCopyContext'
-	print '\twglCreateContext'
-	print '\twglCreateLayerContext'
-	print '\twglDeleteContext'
-	print '\twglDescribeLayerPlane'
-	print '\twglDescribePixelFormat'
-	print '\twglGetCurrentContext'
-	print '\twglGetCurrentDC'
-	print '\twglGetExtensionsStringARB'
-	print '\twglGetLayerPaletteEntries'
-	print '\twglGetPixelFormat'
-	print '\twglGetProcAddress'
-	print '\twglMakeCurrent'
-	print '\twglRealizeLayerPalette'
-	print '\twglSetLayerPaletteEntries'
-	print '\twglSetPixelFormat'
-	print '\twglShareLists'
-	print '\twglSwapBuffers'
-	print '\twglSwapLayerBuffers'
-	print '\twglUseFontBitmapsA'
-	print '\twglUseFontBitmapsW'
-	print '\twglUseFontOutlinesA'
-	print '\twglUseFontOutlinesW'
-	print ';'
-	print '; Mesa internals - mostly for OSMESA'
-	print '\t_ac_CreateContext'
-	print '\t_ac_DestroyContext'
-	print '\t_ac_InvalidateState'
-	print '\t_glapi_get_context'
-	print '\t_glapi_get_proc_address'
-	print '\t_mesa_buffer_data'
-	print '\t_mesa_buffer_map'
-	print '\t_mesa_buffer_subdata'
-	print '\t_mesa_choose_tex_format'
-	print '\t_mesa_compressed_texture_size'
-	print '\t_mesa_create_framebuffer'
-	print '\t_mesa_create_visual'
-	print '\t_mesa_delete_buffer_object'
-	print '\t_mesa_delete_texture_object'
-	print '\t_mesa_destroy_framebuffer'
-	print '\t_mesa_destroy_visual'
-	print '\t_mesa_enable_1_3_extensions'
-	print '\t_mesa_enable_1_4_extensions'
-	print '\t_mesa_enable_1_5_extensions'
-	print '\t_mesa_enable_sw_extensions'
-	print '\t_mesa_error'
-	print '\t_mesa_free_context_data'
-	print '\t_mesa_get_current_context'
-	print '\t_mesa_init_default_imports'
-	print '\t_mesa_initialize_context'
-	print '\t_mesa_make_current'
-	print '\t_mesa_new_buffer_object'
-	print '\t_mesa_new_texture_object'
-	print '\t_mesa_problem'
-	print '\t_mesa_ResizeBuffersMESA'
-	print '\t_mesa_store_compressed_teximage1d'
-	print '\t_mesa_store_compressed_teximage2d'
-	print '\t_mesa_store_compressed_teximage3d'
-	print '\t_mesa_store_compressed_texsubimage1d'
-	print '\t_mesa_store_compressed_texsubimage2d'
-	print '\t_mesa_store_compressed_texsubimage3d'
-	print '\t_mesa_store_teximage1d'
-	print '\t_mesa_store_teximage2d'
-	print '\t_mesa_store_teximage3d'
-	print '\t_mesa_store_texsubimage1d'
-	print '\t_mesa_store_texsubimage2d'
-	print '\t_mesa_store_texsubimage3d'
-	print '\t_mesa_test_proxy_teximage'
-	print '\t_mesa_Viewport'
-	print '\t_mesa_meta_CopyColorSubTable'
-	print '\t_mesa_meta_CopyColorTable'
-	print '\t_mesa_meta_CopyConvolutionFilter1D'
-	print '\t_mesa_meta_CopyConvolutionFilter2D'
-	print '\t_mesa_meta_CopyTexImage1D'
-	print '\t_mesa_meta_CopyTexImage2D'
-	print '\t_mesa_meta_CopyTexSubImage1D'
-	print '\t_mesa_meta_CopyTexSubImage2D'
-	print '\t_mesa_meta_CopyTexSubImage3D'
-	print '\t_swrast_Accum'
-	print '\t_swrast_alloc_buffers'
-	print '\t_swrast_Bitmap'
-	print '\t_swrast_CopyPixels'
-	print '\t_swrast_DrawPixels'
-	print '\t_swrast_GetDeviceDriverReference'
-	print '\t_swrast_Clear'
-	print '\t_swrast_choose_line'
-	print '\t_swrast_choose_triangle'
-	print '\t_swrast_CreateContext'
-	print '\t_swrast_DestroyContext'
-	print '\t_swrast_InvalidateState'
-	print '\t_swrast_ReadPixels'
-	print '\t_swrast_zbuffer_address'
-	print '\t_swsetup_Wakeup'
-	print '\t_swsetup_CreateContext'
-	print '\t_swsetup_DestroyContext'
-	print '\t_swsetup_InvalidateState'
-	print '\t_tnl_CreateContext'
-	print '\t_tnl_DestroyContext'
-	print '\t_tnl_InvalidateState'
-	print '\t_tnl_MakeCurrent'
-	print '\t_tnl_run_pipeline'
+	print (';')
+	print ('; WGL API')
+	print ('\twglChoosePixelFormat')
+	print ('\twglCopyContext')
+	print ('\twglCreateContext')
+	print ('\twglCreateLayerContext')
+	print ('\twglDeleteContext')
+	print ('\twglDescribeLayerPlane')
+	print ('\twglDescribePixelFormat')
+	print ('\twglGetCurrentContext')
+	print ('\twglGetCurrentDC')
+	print ('\twglGetExtensionsStringARB')
+	print ('\twglGetLayerPaletteEntries')
+	print ('\twglGetPixelFormat')
+	print ('\twglGetProcAddress')
+	print ('\twglMakeCurrent')
+	print ('\twglRealizeLayerPalette')
+	print ('\twglSetLayerPaletteEntries')
+	print ('\twglSetPixelFormat')
+	print ('\twglShareLists')
+	print ('\twglSwapBuffers')
+	print ('\twglSwapLayerBuffers')
+	print ('\twglUseFontBitmapsA')
+	print ('\twglUseFontBitmapsW')
+	print ('\twglUseFontOutlinesA')
+	print ('\twglUseFontOutlinesW')
+	print (';')
+	print ('; Mesa internals - mostly for OSMESA')
+	print ('\t_ac_CreateContext')
+	print ('\t_ac_DestroyContext')
+	print ('\t_ac_InvalidateState')
+	print ('\t_glapi_get_context')
+	print ('\t_glapi_get_proc_address')
+	print ('\t_mesa_buffer_data')
+	print ('\t_mesa_buffer_map')
+	print ('\t_mesa_buffer_subdata')
+	print ('\t_mesa_choose_tex_format')
+	print ('\t_mesa_compressed_texture_size')
+	print ('\t_mesa_create_framebuffer')
+	print ('\t_mesa_create_visual')
+	print ('\t_mesa_delete_buffer_object')
+	print ('\t_mesa_delete_texture_object')
+	print ('\t_mesa_destroy_framebuffer')
+	print ('\t_mesa_destroy_visual')
+	print ('\t_mesa_enable_1_3_extensions')
+	print ('\t_mesa_enable_1_4_extensions')
+	print ('\t_mesa_enable_1_5_extensions')
+	print ('\t_mesa_enable_sw_extensions')
+	print ('\t_mesa_error')
+	print ('\t_mesa_free_context_data')
+	print ('\t_mesa_get_current_context')
+	print ('\t_mesa_init_default_imports')
+	print ('\t_mesa_initialize_context')
+	print ('\t_mesa_make_current')
+	print ('\t_mesa_new_buffer_object')
+	print ('\t_mesa_new_texture_object')
+	print ('\t_mesa_problem')
+	print ('\t_mesa_ResizeBuffersMESA')
+	print ('\t_mesa_store_compressed_teximage1d')
+	print ('\t_mesa_store_compressed_teximage2d')
+	print ('\t_mesa_store_compressed_teximage3d')
+	print ('\t_mesa_store_compressed_texsubimage1d')
+	print ('\t_mesa_store_compressed_texsubimage2d')
+	print ('\t_mesa_store_compressed_texsubimage3d')
+	print ('\t_mesa_store_teximage1d')
+	print ('\t_mesa_store_teximage2d')
+	print ('\t_mesa_store_teximage3d')
+	print ('\t_mesa_store_texsubimage1d')
+	print ('\t_mesa_store_texsubimage2d')
+	print ('\t_mesa_store_texsubimage3d')
+	print ('\t_mesa_test_proxy_teximage')
+	print ('\t_mesa_Viewport')
+	print ('\t_mesa_meta_CopyColorSubTable')
+	print ('\t_mesa_meta_CopyColorTable')
+	print ('\t_mesa_meta_CopyConvolutionFilter1D')
+	print ('\t_mesa_meta_CopyConvolutionFilter2D')
+	print ('\t_mesa_meta_CopyTexImage1D')
+	print ('\t_mesa_meta_CopyTexImage2D')
+	print ('\t_mesa_meta_CopyTexSubImage1D')
+	print ('\t_mesa_meta_CopyTexSubImage2D')
+	print ('\t_mesa_meta_CopyTexSubImage3D')
+	print ('\t_swrast_Accum')
+	print ('\t_swrast_alloc_buffers')
+	print ('\t_swrast_Bitmap')
+	print ('\t_swrast_CopyPixels')
+	print ('\t_swrast_DrawPixels')
+	print ('\t_swrast_GetDeviceDriverReference')
+	print ('\t_swrast_Clear')
+	print ('\t_swrast_choose_line')
+	print ('\t_swrast_choose_triangle')
+	print ('\t_swrast_CreateContext')
+	print ('\t_swrast_DestroyContext')
+	print ('\t_swrast_InvalidateState')
+	print ('\t_swrast_ReadPixels')
+	print ('\t_swrast_zbuffer_address')
+	print ('\t_swsetup_Wakeup')
+	print ('\t_swsetup_CreateContext')
+	print ('\t_swsetup_DestroyContext')
+	print ('\t_swsetup_InvalidateState')
+	print ('\t_tnl_CreateContext')
+	print ('\t_tnl_DestroyContext')
+	print ('\t_tnl_InvalidateState')
+	print ('\t_tnl_MakeCurrent')
+	print ('\t_tnl_run_pipeline')
 #enddef
 
 
@@ -204,7 +204,7 @@
 	if offset < 0:
 		offset = FindOffset(dispatchName)
 	if offset >= 0 and string.find(name, "unused") == -1:
-		print '\tgl%s' % (name)
+		print ('\tgl%s' % (name))
 		# save this info in case we need to look up an alias later
 		records.append((name, dispatchName, offset))
 
--- Mesa-7.8.2/src/mesa/glapi/gen/remap_helper.py.orig	2010-06-16 03:43:43.000000000 +1000
+++ Mesa-7.8.2/src/mesa/glapi/gen/remap_helper.py	2010-12-06 15:06:16.000000000 +1100
@@ -64,24 +64,24 @@
 
 
 	def printRealHeader(self):
-		print '#include "main/dispatch.h"'
-		print ''
+		print ('#include "main/dispatch.h"')
+		print ('')
 		return
 
 
 	def printBody(self, api):
-		print 'struct gl_function_remap {'
-		print '   GLint func_index;'
-		print '   GLint dispatch_offset; /* for sanity check */'
-		print '};'
-		print ''
+		print ('struct gl_function_remap {')
+		print ('   GLint func_index;')
+		print ('   GLint dispatch_offset; /* for sanity check */')
+		print ('};')
+		print ('')
 
 		pool_indices = {}
 
-		print '/* this is internal to remap.c */'
-		print '#ifdef need_MESA_remap_table'
-		print ''
-		print 'static const char _mesa_function_pool[] ='
+		print ('/* this is internal to remap.c */')
+		print ('#ifdef need_MESA_remap_table')
+		print ('')
+		print ('static const char _mesa_function_pool[] =')
 
 		# output string pool
 		index = 0;
@@ -99,29 +99,29 @@
 			else:
 				comments = "dynamic"
 
-			print '   /* _mesa_function_pool[%d]: %s (%s) */' \
-					% (index, f.name, comments)
+			print ('   /* _mesa_function_pool[%d]: %s (%s) */' \
+					% (index, f.name, comments))
 			for line in spec:
-				print '   "%s\\0"' % line
+				print ('   "%s\\0"' % line)
 				index += len(line) + 1
-		print '   ;'
-		print ''
+		print ('   ;')
+		print ('')
 
-		print '/* these functions need to be remapped */'
-		print 'static const struct {'
-		print '   GLint pool_index;'
-		print '   GLint remap_index;'
-		print '} MESA_remap_table_functions[] = {'
+		print ('/* these functions need to be remapped */')
+		print ('static const struct {')
+		print ('   GLint pool_index;')
+		print ('   GLint remap_index;')
+		print ('} MESA_remap_table_functions[] = {')
 		# output all functions that need to be remapped
 		# iterate by offsets so that they are sorted by remap indices
 		for f in api.functionIterateByOffset():
 			if not f.assign_offset:
 				continue
-			print '   { %5d, %s_remap_index },' \
-					% (pool_indices[f], f.name)
-		print '   {    -1, -1 }'
-		print '};'
-		print ''
+			print ('   { %5d, %s_remap_index },' \
+					% (pool_indices[f], f.name))
+		print ('   {    -1, -1 }')
+		print ('};')
+		print ('')
 
 		# collect functions by versions/extensions
 		extension_functions = {}
@@ -147,8 +147,8 @@
 		extensions.sort()
 
 		# output ABI functions that have alternative names (with ext suffix)
-		print '/* these functions are in the ABI, but have alternative names */'
-		print 'static const struct gl_function_remap MESA_alt_functions[] = {'
+		print ('/* these functions are in the ABI, but have alternative names */')
+		print ('static const struct gl_function_remap MESA_alt_functions[] = {')
 		for ext in extensions:
 			funcs = []
 			for f in extension_functions[ext]:
@@ -157,16 +157,16 @@
 					funcs.append(f)
 			if not funcs:
 				continue
-			print '   /* from %s */' % ext
+			print ('   /* from %s */' % ext)
 			for f in funcs:
-				print '   { %5d, _gloffset_%s },' \
-						% (pool_indices[f], f.name)
-		print '   {    -1, -1 }'
-		print '};'
-		print ''
+				print ('   { %5d, _gloffset_%s },' \
+						% (pool_indices[f], f.name))
+		print ('   {    -1, -1 }')
+		print ('};')
+		print ('')
 
-		print '#endif /* need_MESA_remap_table */'
-		print ''
+		print ('#endif /* need_MESA_remap_table */')
+		print ('')
 
 		# output remap helpers for DRI drivers
 
@@ -182,30 +182,30 @@
 					# abi, or have offset -1
 					funcs.append(f)
 
-			print '#if defined(need_%s)' % (ext)
+			print ('#if defined(need_%s)' % (ext))
 			if remapped:
-				print '/* functions defined in MESA_remap_table_functions are excluded */'
+				print ('/* functions defined in MESA_remap_table_functions are excluded */')
 
 			# output extension functions that need to be mapped
-			print 'static const struct gl_function_remap %s_functions[] = {' % (ext)
+			print ('static const struct gl_function_remap %s_functions[] = {' % (ext))
 			for f in funcs:
 				if f.offset >= 0:
-					print '   { %5d, _gloffset_%s },' \
-							% (pool_indices[f], f.name)
+					print ('   { %5d, _gloffset_%s },' \
+							% (pool_indices[f], f.name))
 				else:
-					print '   { %5d, -1 }, /* %s */' % \
-							(pool_indices[f], f.name)
-			print '   {    -1, -1 }'
-			print '};'
+					print ('   { %5d, -1 }, /* %s */' % \
+							(pool_indices[f], f.name))
+			print ('   {    -1, -1 }')
+			print ('};')
 
-			print '#endif'
-			print ''
+			print ('#endif')
+			print ('')
 
 		return
 
 
 def show_usage():
-	print "Usage: %s [-f input_file_name]" % sys.argv[0]
+	print ("Usage: %s [-f input_file_name]" % sys.argv[0])
 	sys.exit(1)
 
 if __name__ == '__main__':
--- Mesa-7.8.2/src/mesa/glapi/gen/typeexpr.py.orig	2010-06-16 03:43:43.000000000 +1000
+++ Mesa-7.8.2/src/mesa/glapi/gen/typeexpr.py	2010-12-06 15:00:49.000000000 +1100
@@ -287,6 +287,6 @@
 	create_initial_types()
 
 	for t in types_to_try:
-		print 'Trying "%s"...' % (t)
+		print ('Trying "%s"...' % (t))
 		te = type_expression( t )
-		print 'Got "%s" (%u, %u).' % (te.string(), te.get_stack_size(), te.get_element_size())
+		print ('Got "%s" (%u, %u).' % (te.string(), te.get_stack_size(), te.get_element_size()))
