updates from mesa_3_4_branch :

commit fe1d24754e9ef91199fdd8ac104441bbc72a9c68
Author: Brian Paul <brian.paul@tungstengraphics.com>
Date:   Tue Jan 8 14:55:48 2002 +0000

    work-around for QNX compiler problem

commit 1aad7ae66a257ffa4b4966772b32387887d563f2
Author: Alan Hourihane <alanh@tungstengraphics.com>
Date:   Tue Nov 13 23:55:32 2001 +0000

    Check pixel buffer count for general_flat_rgba_line.

commit 3df4a3c3e209e769a10887a8bd5299712d85d169
Author: Brian Paul <brian.paul@tungstengraphics.com>
Date:   Mon Jun 11 19:24:06 2001 +0000

    fixed broken debug code for vertex cassette (bug #432079)

commit 7f7dd6ee1730096a13d8d4790eef56ed43adf06c
Author: Brian Paul <brian.paul@tungstengraphics.com>
Date:   Mon Jun 11 19:19:14 2001 +0000

    fixed minor display list bugs (#431517)

commit 5ff0c3b97d81ef7f915472e6f91945e6da7ac9a8
Author: Brian Paul <brian.paul@tungstengraphics.com>
Date:   Mon Jun 11 15:18:09 2001 +0000

    fixed non-i386 broken COPY_4UBV macro

commit c334f11fddd43817463ed5eec4e8e0c062a578aa
Author: Brian Paul <brian.paul@tungstengraphics.com>
Date:   Fri Jun 8 20:11:03 2001 +0000

    add check for NULL malloc (from Stanford metacompilation analysis)

commit 12c1538d0ee8deae09f3c2b7db4dcfebd54f5d34
Author: Brian Paul <brian.paul@tungstengraphics.com>
Date:   Fri Jun 8 15:46:41 2001 +0000

    only copy GLubyte[4] as a GLuint on x86

commit b150fb418e814e4cd9cadc0de64aa5603489ff59
Author: Brian Paul <brian.paul@tungstengraphics.com>
Date:   Fri Jun 8 12:49:25 2001 +0000

    use unoptimized COPY_4UBV code on SPARC to avoid memory alignment problems (bug 430689)

commit 2cbd3698ba5c719b8315cc9c156ef8e424514ebc
Author: Brian Paul <brian.paul@tungstengraphics.com>
Date:   Wed Jun 6 18:28:59 2001 +0000

    added -D_POSIX_SOURCE stuff (ported from 3.5)

commit 76be965b48a71d1ce4adb06952d0b983af33871c
Author: Brian Paul <brian.paul@tungstengraphics.com>
Date:   Wed Jun 6 18:28:17 2001 +0000

    don't test for _POSIX_SOURCE when includeing signal.h (port from 3.5)

commit faada79f82144b67e7bc085fa13e935a4f89d73f
Author: Brian Paul <brian.paul@tungstengraphics.com>
Date:   Wed Jun 6 18:12:50 2001 +0000

    test for X86_FXSR_MAGIC to be sure we have the _fpstate.magic field, needed for SSE signal handler

commit 025dd4a0fce4b4f5c98bc3618c4a2f91797ba209
Author: Brian Paul <brian.paul@tungstengraphics.com>
Date:   Wed May 23 23:55:08 2001 +0000

    fix bug 426657: need to clamp RGBA before color table lookups

commit c597a160842c4963d7d36eabdff884d59f4bb815
Author: Brian Paul <brian.paul@tungstengraphics.com>
Date:   Mon May 21 17:46:35 2001 +0000

    added aa_multitex_spec_line() to fix segfault in aa_multitex_rgba_line() when separate specular not enabled

commit 3a1646bcb02c1b0e099a0673141cca417d5e3fb7
Author: Brian Paul <brian.paul@tungstengraphics.com>
Date:   Mon May 21 15:21:52 2001 +0000

    removed unneeded const from _mesa_TexParameteri()

commit 91ad51253421b4ccd5eabb72f4be187f4eb50eef
Author: Brian Paul <brian.paul@tungstengraphics.com>
Date:   Mon May 21 14:46:25 2001 +0000

    s/Height/height/ (Jeff Potter)



diff --git a/Make-config b/Make-config
index c9c9d18..e38432d 100644
--- a/Make-config
+++ b/Make-config
@@ -1,4 +1,4 @@
-# $Id: Make-config,v 1.25.4.7 2001/05/14 19:11:32 brianp Exp $
+# $Id: Make-config,v 1.25.4.8 2001/06/06 18:28:59 brianp Exp $
 
 MESA_MAJOR=3
 MESA_MINOR=4
@@ -453,7 +453,7 @@ linux:
 	"GLUT_LIB = libglut.so" \
 	"GLW_LIB = libGLw.so" \
 	"CC = gcc" \
-	"CFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -I/usr/X11R6/include" \
+	"CFLAGS = -O3 -ansi -pedantic -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -I/usr/X11R6/include" \
 	"MAKELIB = ../bin/mklib.linux" \
 	"GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lpthread" \
 	"GLU_LIB_DEPS = -L../lib -lGL -lm" \
@@ -467,7 +467,7 @@ linux-static:
 	"GLUT_LIB = libglut.a" \
 	"GLW_LIB = libGLw.a" \
 	"CC = gcc" \
-	"CFLAGS = -O3 -funroll-loops -ansi -pedantic -ffast-math -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -I/usr/X11R6/include" \
+	"CFLAGS = -O3 -funroll-loops -ansi -pedantic -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DPTHREADS -I/usr/X11R6/include" \
 	"MAKELIB = ../bin/mklib.ar-ruv" \
 	"APP_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lXmu -lXt -lXi -lm -lpthread"
 
@@ -478,7 +478,7 @@ linux-x86:
 	"GLUT_LIB = libglut.so" \
 	"GLW_LIB = libGLw.so" \
 	"CC = gcc -malign-loops=2 -malign-jumps=2 -malign-functions=2" \
-	"CFLAGS = -Wall -O3 -ansi -pedantic -fPIC -ffast-math -funroll-loops -fomit-frame-pointer -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_KATMAI_ASM -DPTHREADS -I/usr/X11R6/include" \
+	"CFLAGS = -Wall -O3 -ansi -pedantic -fPIC -ffast-math -funroll-loops -fomit-frame-pointer -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_KATMAI_ASM -DPTHREADS -I/usr/X11R6/include" \
 	"MAKELIB = ../bin/mklib.linux" \
 	"GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lm -lpthread" \
 	"GLU_LIB_DEPS = -L../lib -lGL -lm" \
@@ -508,7 +508,7 @@ linux-x86-static:
 	"GLUT_LIB = libglut.a" \
 	"GLW_LIB = libGLw.a" \
 	"CC = gcc -malign-loops=2 -malign-jumps=2 -malign-functions=2" \
-	"CFLAGS = -Wall -O3 -ansi -pedantic -fPIC -ffast-math -funroll-loops -fomit-frame-pointer -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_KATMAI_ASM -DPTHREADS -I/usr/X11R6/include" \
+	"CFLAGS = -Wall -O3 -ansi -pedantic -fPIC -ffast-math -funroll-loops -fomit-frame-pointer -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_KATMAI_ASM -DPTHREADS -I/usr/X11R6/include" \
 	"MAKELIB = ../bin/mklib.ar-ruv" \
 	"GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lm -lpthread" \
 	"GLU_LIB_DEPS = -L../lib -lGL -lm" \
@@ -1295,7 +1295,7 @@ linux-x86-debug:
 	"GLUT_LIB = libglut.so" \
 	"GLW_LIB = libGLw.so" \
 	"CC = gcc -malign-loops=2 -malign-jumps=2 -malign-functions=2" \
-	"CFLAGS = -O2 -g -ansi -pedantic -Wall -Wmissing-prototypes -fPIC -ffast-math -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_KATMAI_ASM -DPTHREADS -I/usr/X11R6/include -DDEBUG -DMESA_DEBUG" \
+	"CFLAGS = -O2 -g -ansi -pedantic -Wall -Wmissing-prototypes -fPIC -ffast-math -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_BSD_SOURCE -DUSE_XSHM -DUSE_X86_ASM -DUSE_MMX_ASM -DUSE_3DNOW_ASM -DUSE_KATMAI_ASM -DPTHREADS -I/usr/X11R6/include -DDEBUG -DMESA_DEBUG" \
 	"MAKELIB = ../bin/mklib.linux" \
 	"GL_LIB_DEPS = -L/usr/X11R6/lib -lX11 -lXext -lm -lm -lpthread" \
 	"GLU_LIB_DEPS = -L../lib -lGL -lm" \
diff --git a/src/mesa/drivers/windows/wmesa.c b/src/mesa/drivers/windows/wmesa.c
index 3d2aa8f..66fc660 100644
--- a/src/Windows/wmesa.c
+++ b/src/Windows/wmesa.c
@@ -1,4 +1,4 @@
-/* $Id: wmesa.c,v 1.3.4.5 2001/05/09 20:42:45 brianp Exp $ */
+/* $Id: wmesa.c,v 1.3.4.6 2001/05/21 14:46:25 brianp Exp $ */
 
 /*
  * Windows (Win32) device driver for Mesa 3.4
@@ -1085,7 +1085,7 @@ static void read_rgba_pixels( const GLcontext* ctx,
    assert(Current->rgb_flag==GL_TRUE);
    for (i=0; i<n; i++) {
       if (mask[i]) {
-         GLint y2 = Current->Height - y[i] - 1;
+         GLint y2 = Current->height - y[i] - 1;
          Color=GetPixel(DC,x[i],y2);
          rgba[i][RCOMP] = GetRValue(Color);
          rgba[i][GCOMP] = GetGValue(Color);
diff --git a/src/mesa/main/dlist.c b/src/mesa/main/dlist.c
index 15f1524..e0fad61 100644
--- a/src/dlist.c
+++ b/src/dlist.c
@@ -1,4 +1,4 @@
-/* $Id: dlist.c,v 1.44 2000/07/10 13:22:01 keithw Exp $ */
+/* $Id: dlist.c,v 1.44.4.2 2001/06/11 19:24:06 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -1153,7 +1153,7 @@ save_CopyColorSubTable(GLenum target, GLsizei start,
    Node *n;
 
    FLUSH_VB(ctx, "dlist");
-   n = alloc_instruction( ctx, OPCODE_COPY_COLOR_SUB_TABLE, 6 );
+   n = alloc_instruction( ctx, OPCODE_COPY_COLOR_SUB_TABLE, 5 );
    if (n) {
       n[1].e = target;
       n[2].i = start;
@@ -1175,7 +1175,7 @@ save_CopyColorTable(GLenum target, GLenum internalformat,
    Node *n;
 
    FLUSH_VB(ctx, "dlist");
-   n = alloc_instruction( ctx, OPCODE_COPY_COLOR_TABLE, 6 );
+   n = alloc_instruction( ctx, OPCODE_COPY_COLOR_TABLE, 5 );
    if (n) {
       n[1].e = target;
       n[2].e = internalformat;
@@ -1317,7 +1317,7 @@ save_ConvolutionParameterfv(GLenum target, GLenum pname, const GLfloat *params)
    GET_CURRENT_CONTEXT(ctx);
    Node *n;
    FLUSH_VB(ctx, "dlist");
-   n = alloc_instruction( ctx, OPCODE_CONVOLUTION_PARAMETER_IV, 6 );
+   n = alloc_instruction( ctx, OPCODE_CONVOLUTION_PARAMETER_FV, 6 );
    if (n) {
       n[1].e = target;
       n[2].e = pname;
@@ -3670,7 +3670,7 @@ save_CompressedTexImage1DARB(GLenum target, GLint level,
          return;
       }
       MEMCPY(image, data, imageSize);
-      n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 8 );
+      n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_IMAGE_1D, 7 );
       if (n) {
          n[1].e = target;
          n[2].i = level;
@@ -3714,7 +3714,7 @@ save_CompressedTexImage2DARB(GLenum target, GLint level,
          return;
       }
       MEMCPY(image, data, imageSize);
-      n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 9 );
+      n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_IMAGE_2D, 8 );
       if (n) {
          n[1].e = target;
          n[2].i = level;
@@ -3759,7 +3759,7 @@ save_CompressedTexImage3DARB(GLenum target, GLint level,
          return;
       }
       MEMCPY(image, data, imageSize);
-      n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 10 );
+      n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_IMAGE_3D, 9 );
       if (n) {
          n[1].e = target;
          n[2].i = level;
@@ -3800,7 +3800,7 @@ save_CompressedTexSubImage1DARB(GLenum target, GLint level, GLint xoffset,
       return;
    }
    MEMCPY(image, data, imageSize);
-   n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 8 );
+   n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_1D, 7 );
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -3839,7 +3839,7 @@ save_CompressedTexSubImage2DARB(GLenum target, GLint level, GLint xoffset,
       return;
    }
    MEMCPY(image, data, imageSize);
-   n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 10 );
+   n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_2D, 9 );
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -3880,7 +3880,7 @@ save_CompressedTexSubImage3DARB(GLenum target, GLint level, GLint xoffset,
       return;
    }
    MEMCPY(image, data, imageSize);
-   n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 12 );
+   n = alloc_instruction( ctx, OPCODE_COMPRESSED_TEX_SUB_IMAGE_3D, 11 );
    if (n) {
       n[1].e = target;
       n[2].i = level;
@@ -5661,11 +5661,22 @@ static void print_list( GLcontext *ctx, FILE *f, GLuint list )
             fprintf(f,"Error: %s %s\n", enum_string(n[1].e), (const char *)n[2].data );
             break;
 	 case OPCODE_VERTEX_CASSETTE:
-            fprintf(f,"VERTEX-CASSETTE, id %u, rows %u..%u\n", 
-		    ((struct immediate *) n[1].data)->id,
-		    n[2].ui,
-		    n[3].ui);
-	    gl_print_cassette( (struct immediate *) n[1].data );
+            {
+               struct immediate *IM; 
+               fprintf(f,"VERTEX-CASSETTE, id %u, rows %u..%u\n", 
+                       ((struct immediate *) n[1].data)->id,
+                       n[2].ui,
+                       n[3].ui);
+               IM = (struct immediate *) n[1].data; 
+               IM->Start = n[2].ui; 
+               IM->Count = n[3].ui; 
+               IM->BeginState = n[4].ui; 
+               IM->OrFlag = n[5].ui; 
+               IM->AndFlag = n[6].ui; 
+               IM->LastData = n[7].ui; 
+               IM->LastPrimitive = n[8].ui; 
+               gl_print_cassette( (struct immediate *) n[1].data );
+            }
 	    break;
 	 case OPCODE_CONTINUE:
             fprintf(f,"DISPLAY-LIST-CONTINUE\n");
diff --git a/src/mesa/main/enums.c b/src/mesa/main/enums.c
index f4a313a..4903ab4 100644
--- a/src/enums.c
+++ b/src/enums.c
@@ -1,4 +1,4 @@
-/* $Id: enums.c,v 1.9.4.2 2001/01/06 22:43:00 gareth Exp $ */
+/* $Id: enums.c,v 1.9.4.3 2001/06/08 20:11:03 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -863,6 +863,9 @@ static void sort_enums( void )
    index1 = (enum_elt **)MALLOC( Elements(all_enums) * sizeof(enum_elt *) );
    sorted = 1;
 
+   if (!index1)
+      return;  /* what else can we do? */
+
    qsort( all_enums, Elements(all_enums), sizeof(*all_enums),
 	  (cfunc) compar_name );
 
diff --git a/src/mesa/main/lines.c b/src/mesa/main/lines.c
index 3a7a0f1..2461a56 100644
--- a/src/lines.c
+++ b/src/lines.c
@@ -1,4 +1,4 @@
-/* $Id: lines.c,v 1.12.2.1 2000/11/08 16:42:48 brianp Exp $ */
+/* $Id: lines.c,v 1.12.2.3 2001/11/13 23:55:32 alanh Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -558,6 +558,7 @@ static void general_flat_rgba_line( GLcontext *ctx,
                                     GLuint vert0, GLuint vert1, GLuint pvert )
 {
    const GLubyte *color = ctx->VB->ColorPtr->data[pvert];
+   GLuint count;
    PB_SET_COLOR( ctx->PB, color[0], color[1], color[2], color[3] );
 
    if (ctx->Line.StippleFlag) {
@@ -566,7 +567,10 @@ static void general_flat_rgba_line( GLcontext *ctx,
 #define INTERP_Z 1
 #define WIDE 1
 #define STIPPLE 1
-#define PLOT(X,Y)  PB_WRITE_PIXEL(ctx->PB, X, Y, Z);
+#define PLOT(X,Y) 				\
+	PB_WRITE_PIXEL(ctx->PB, X, Y, Z);	\
+	count = ctx->PB->count;			\
+	CHECK_FULL(count);
 #include "linetemp.h"
    }
    else {
@@ -586,7 +590,10 @@ static void general_flat_rgba_line( GLcontext *ctx,
 #define INTERP_XY 1
 #define INTERP_Z 1
 #define WIDE 1
-#define PLOT(X,Y) PB_WRITE_PIXEL(ctx->PB, X, Y, Z);
+#define PLOT(X,Y) 				\
+	PB_WRITE_PIXEL(ctx->PB, X, Y, Z);	\
+	count = ctx->PB->count;			\
+	CHECK_FULL(count);
 #include "linetemp.h"
       }
    }
@@ -969,6 +976,23 @@ static void aa_multitex_rgba_line( GLcontext *ctx,
                                    GLuint vert0, GLuint vert1, GLuint pvert )
 {
 #define INTERP_RGBA 1
+#define INTERP_STUV0 1
+#define INTERP_STUV1 1
+#define PLOT(x, y)							\
+   {									\
+      PB_WRITE_MULTITEX_PIXEL( pb, (x), (y), z,				\
+            red, green, blue, coverage,					\
+            s, t, u, s1, t1, u1 );					\
+   }
+#include "lnaatemp.h"
+}
+
+
+/* As above but with separate specular */
+static void aa_multitex_spec_line( GLcontext *ctx,
+                                   GLuint vert0, GLuint vert1, GLuint pvert )
+{
+#define INTERP_RGBA 1
 #define INTERP_SPEC 1
 #define INTERP_STUV0 1
 #define INTERP_STUV1 1
@@ -1053,6 +1077,8 @@ _mesa_print_line_function(GLcontext *ctx)
       printf("aa_tex_rgba_line\n");
    else if (ctx->Driver.LineFunc == aa_multitex_rgba_line)
       printf("aa_multitex_rgba_line\n");
+   else if (ctx->Driver.LineFunc == aa_multitex_spec_line)
+      printf("aa_multitex_spec_line\n");
    else if (ctx->Driver.LineFunc == aa_ci_line)
       printf("aa_ci_line\n");
    else if (ctx->Driver.LineFunc == null_line)
@@ -1087,12 +1113,16 @@ void gl_set_line_function( GLcontext *ctx )
          /* antialiased lines */
          if (rgbmode) {
             if (ctx->Texture.ReallyEnabled) {
-               if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D
-                  || ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR)
+               if (ctx->Texture.ReallyEnabled >= TEXTURE1_1D) {
                   /* Multitextured! */
-                  ctx->Driver.LineFunc = aa_multitex_rgba_line;
-               else
+                  if (ctx->Light.Model.ColorControl==GL_SEPARATE_SPECULAR_COLOR)
+                     ctx->Driver.LineFunc = aa_multitex_spec_line;
+                  else
+                     ctx->Driver.LineFunc = aa_multitex_rgba_line;
+               }
+               else {
                   ctx->Driver.LineFunc = aa_tex_rgba_line;
+               }
             } else {
                ctx->Driver.LineFunc = aa_rgba_line;
             }
diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h
index acc70cf..8facdfc 100644
--- a/src/macros.h
+++ b/src/macros.h
@@ -1,4 +1,4 @@
-/* $Id: macros.h,v 1.8.4.1 2001/03/02 16:40:47 gareth Exp $ */
+/* $Id: macros.h,v 1.8.4.4 2001/06/11 15:18:09 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -356,18 +356,22 @@ do {						\
 /*
  * Copy a vector of 4 GLubytes from SRC to DST.
  */
+#if defined(__i386__)
 #define COPY_4UBV(DST, SRC)			\
 do {						\
-   if (sizeof(GLuint)==4*sizeof(GLubyte)) {	\
-      *((GLuint*)(DST)) = *((GLuint*)(SRC));	\
-   }						\
-   else {					\
-      (DST)[0] = (SRC)[0];			\
-      (DST)[1] = (SRC)[1];			\
-      (DST)[2] = (SRC)[2];			\
-      (DST)[3] = (SRC)[3];			\
-   }						\
+   *((GLuint*)(DST)) = *((GLuint*)(SRC));	\
 } while (0)
+#else
+/* The GLuint cast might fail if DST or SRC are not dword-aligned (RISC) */
+#define COPY_4UBV(DST, SRC)			\
+do {						\
+   (DST)[0] = (SRC)[0];				\
+   (DST)[1] = (SRC)[1];				\
+   (DST)[2] = (SRC)[2];				\
+   (DST)[3] = (SRC)[3];				\
+} while (0)
+#endif
+
 
 
 /* Assign scalers to short vectors: */
diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c
index 9e9d4a1..5390d2d 100644
--- a/src/pixel.c
+++ b/src/pixel.c
@@ -1,4 +1,4 @@
-/* $Id: pixel.c,v 1.11.4.1 2000/10/19 20:09:29 brianp Exp $ */
+/* $Id: pixel.c,v 1.11.4.2 2001/05/23 23:55:08 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -722,10 +722,14 @@ _mesa_map_rgba( const GLcontext *ctx, GLuint n, GLfloat rgba[][4] )
    const GLfloat *aMap = ctx->Pixel.MapAtoA;
    GLuint i;
    for (i=0;i<n;i++) {
-      rgba[i][RCOMP] = rMap[(GLint) (rgba[i][RCOMP] * rscale + 0.5F)];
-      rgba[i][GCOMP] = gMap[(GLint) (rgba[i][GCOMP] * gscale + 0.5F)];
-      rgba[i][BCOMP] = bMap[(GLint) (rgba[i][BCOMP] * bscale + 0.5F)];
-      rgba[i][ACOMP] = aMap[(GLint) (rgba[i][ACOMP] * ascale + 0.5F)];
+      GLfloat r = CLAMP(rgba[i][RCOMP], 0.0F, 1.0F);
+      GLfloat g = CLAMP(rgba[i][GCOMP], 0.0F, 1.0F);
+      GLfloat b = CLAMP(rgba[i][BCOMP], 0.0F, 1.0F);
+      GLfloat a = CLAMP(rgba[i][ACOMP], 0.0F, 1.0F);
+      rgba[i][RCOMP] = rMap[(GLint) (r * rscale + 0.5F)];
+      rgba[i][GCOMP] = gMap[(GLint) (g * gscale + 0.5F)];
+      rgba[i][BCOMP] = bMap[(GLint) (b * bscale + 0.5F)];
+      rgba[i][ACOMP] = aMap[(GLint) (a * ascale + 0.5F)];
    }
 }
 
@@ -774,24 +778,26 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
       case GL_INTENSITY:
          /* replace RGBA with I */
          if (table->TableType == GL_UNSIGNED_BYTE) {
-            const GLfloat scale = (GLfloat) (table->Size - 1);
+            const GLint max = table->Size - 1;
+            const GLfloat scale = (GLfloat) max;
             const GLubyte *lut = (const GLubyte *) table->Table;
             GLuint i;
             for (i = 0; i < n; i++) {
                GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
-               GLfloat c = lut[j] * (1.0F / 255.0F);
+               GLfloat c = lut[CLAMP(j, 0, max)] * (1.0F / 255.0F);
                rgba[i][RCOMP] = rgba[i][GCOMP] =
                   rgba[i][BCOMP] = rgba[i][ACOMP] = c;
             }
 
          }
          else {
-            const GLfloat scale = (GLfloat) (table->Size - 1);
+            const GLint max = table->Size - 1;
+            const GLfloat scale = (GLfloat) max;
             const GLfloat *lut = (const GLfloat *) table->Table;
             GLuint i;
             for (i = 0; i < n; i++) {
                GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
-               GLfloat c = lut[j];
+               GLfloat c = lut[CLAMP(j, 0, max)];
                rgba[i][RCOMP] = rgba[i][GCOMP] =
                   rgba[i][BCOMP] = rgba[i][ACOMP] = c;
             }
@@ -800,22 +806,24 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
       case GL_LUMINANCE:
          /* replace RGB with L */
          if (table->TableType == GL_UNSIGNED_BYTE) {
-            const GLfloat scale = (GLfloat) (table->Size - 1);
+            const GLint max = table->Size - 1;
+            const GLfloat scale = (GLfloat) max;
             const GLubyte *lut = (const GLubyte *) table->Table;
             GLuint i;
             for (i = 0; i < n; i++) {
                GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
-               GLfloat c = lut[j] * (1.0F / 255.0F);
+               GLfloat c = lut[CLAMP(j, 0, max)] * (1.0F / 255.0F);
                rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c;
             }
          }
          else {
-            const GLfloat scale = (GLfloat) (table->Size - 1);
+            const GLint max = table->Size - 1;
+            const GLfloat scale = (GLfloat) max;
             const GLfloat *lut = (const GLfloat *) table->Table;
             GLuint i;
             for (i = 0; i < n; i++) {
                GLint j = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
-               GLfloat c = lut[j];
+               GLfloat c = lut[CLAMP(j, 0, max)];
                rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = c;
             }
          }
@@ -823,48 +831,58 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
       case GL_ALPHA:
          /* replace A with A */
          if (table->TableType == GL_UNSIGNED_BYTE) {
-            const GLfloat scale = (GLfloat) (table->Size - 1);
+            const GLint max = table->Size - 1;
+            const GLfloat scale = (GLfloat) max;
             const GLubyte *lut = (const GLubyte *) table->Table;
             GLuint i;
             for (i = 0; i < n; i++) {
                GLint j = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
-               rgba[i][ACOMP] = lut[j] * (1.0F / 255.0F);
+               rgba[i][ACOMP] = lut[CLAMP(j, 0, max)] * (1.0F / 255.0F);
             }
          }
          else  {
-            const GLfloat scale = (GLfloat) (table->Size - 1);
+            const GLint max = table->Size - 1;
+            const GLfloat scale = (GLfloat) max;
             const GLfloat *lut = (const GLfloat *) table->Table;
             GLuint i;
             for (i = 0; i < n; i++) {
                GLint j = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
-               rgba[i][ACOMP] = lut[j];
+               rgba[i][ACOMP] = lut[CLAMP(j, 0, max)];
             }
          }
          break;
       case GL_LUMINANCE_ALPHA:
          /* replace RGBA with LLLA */
          if (table->TableType == GL_UNSIGNED_BYTE) {
-            const GLfloat scale = (GLfloat) (table->Size - 1);
+            const GLint max = table->Size - 1;
+            const GLfloat scale = (GLfloat) max;
             const GLubyte *lut = (const GLubyte *) table->Table;
             GLuint i;
             for (i = 0; i < n; i++) {
                GLint jL = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
                GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
-               GLfloat luminance = lut[jL * 2 + 0] * (1.0F / 255.0F);
-               GLfloat alpha     = lut[jA * 2 + 1] * (1.0F / 255.0F);
+               GLfloat luminance, alpha;
+               jL = CLAMP(jL, 0, max);
+               jA = CLAMP(jA, 0, max);
+               luminance = lut[jL * 2 + 0] * (1.0F / 255.0F);
+               alpha     = lut[jA * 2 + 1] * (1.0F / 255.0F);
                rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance;
                rgba[i][ACOMP] = alpha;;
             }
          }
          else {
-            const GLfloat scale = (GLfloat) (table->Size - 1);
+            const GLint max = table->Size - 1;
+            const GLfloat scale = (GLfloat) max;
             const GLfloat *lut = (const GLfloat *) table->Table;
             GLuint i;
             for (i = 0; i < n; i++) {
                GLint jL = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
                GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
-               GLfloat luminance = lut[jL * 2 + 0];
-               GLfloat alpha     = lut[jA * 2 + 1];
+               GLfloat luminance, alpha;
+               jL = CLAMP(jL, 0, max);
+               jA = CLAMP(jA, 0, max);
+               luminance = lut[jL * 2 + 0];
+               alpha     = lut[jA * 2 + 1];
                rgba[i][RCOMP] = rgba[i][GCOMP] = rgba[i][BCOMP] = luminance;
                rgba[i][ACOMP] = alpha;;
             }
@@ -873,26 +891,34 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
       case GL_RGB:
          /* replace RGB with RGB */
          if (table->TableType == GL_UNSIGNED_BYTE) {
-            const GLfloat scale = (GLfloat) (table->Size - 1);
+            const GLint max = table->Size - 1;
+            const GLfloat scale = (GLfloat) max;
             const GLubyte *lut = (const GLubyte *) table->Table;
             GLuint i;
             for (i = 0; i < n; i++) {
                GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
                GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F);
                GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F);
+               jR = CLAMP(jR, 0, max);
+               jG = CLAMP(jG, 0, max);
+               jB = CLAMP(jB, 0, max);
                rgba[i][RCOMP] = lut[jR * 3 + 0] * (1.0F / 255.0F);
                rgba[i][GCOMP] = lut[jG * 3 + 1] * (1.0F / 255.0F);
                rgba[i][BCOMP] = lut[jB * 3 + 2] * (1.0F / 255.0F);
             }
          }
          else {
-            const GLfloat scale = (GLfloat) (table->Size - 1);
+            const GLint max = table->Size - 1;
+            const GLfloat scale = (GLfloat) max;
             const GLfloat *lut = (const GLfloat *) table->Table;
             GLuint i;
             for (i = 0; i < n; i++) {
                GLint jR = (GLint) (rgba[i][RCOMP] * scale + 0.5F);
                GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F);
                GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F);
+               jR = CLAMP(jR, 0, max);
+               jG = CLAMP(jG, 0, max);
+               jB = CLAMP(jB, 0, max);
                rgba[i][RCOMP] = lut[jR * 3 + 0];
                rgba[i][GCOMP] = lut[jG * 3 + 1];
                rgba[i][BCOMP] = lut[jB * 3 + 2];
@@ -902,7 +928,8 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
       case GL_RGBA:
          /* replace RGBA with RGBA */
          if (table->TableType == GL_UNSIGNED_BYTE) {
-            const GLfloat scale = (GLfloat) (table->Size - 1);
+            const GLint max = table->Size - 1;
+            const GLfloat scale = (GLfloat) max;
             const GLubyte *lut = (const GLubyte *) table->Table;
             GLuint i;
             for (i = 0; i < n; i++) {
@@ -910,6 +937,10 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
                GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F);
                GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F);
                GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
+               jR = CLAMP(jR, 0, max);
+               jG = CLAMP(jG, 0, max);
+               jB = CLAMP(jB, 0, max);
+               jA = CLAMP(jA, 0, max);
                rgba[i][RCOMP] = lut[jR * 4 + 0] * (1.0F / 255.0F);
                rgba[i][GCOMP] = lut[jG * 4 + 1] * (1.0F / 255.0F);
                rgba[i][BCOMP] = lut[jB * 4 + 2] * (1.0F / 255.0F);
@@ -917,7 +948,8 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
             }
          }
          else {
-            const GLfloat scale = (GLfloat) (table->Size - 1);
+            const GLint max = table->Size - 1;
+            const GLfloat scale = (GLfloat) max;
             const GLfloat *lut = (const GLfloat *) table->Table;
             GLuint i;
             for (i = 0; i < n; i++) {
@@ -925,6 +957,10 @@ _mesa_lookup_rgba(const struct gl_color_table *table,
                GLint jG = (GLint) (rgba[i][GCOMP] * scale + 0.5F);
                GLint jB = (GLint) (rgba[i][BCOMP] * scale + 0.5F);
                GLint jA = (GLint) (rgba[i][ACOMP] * scale + 0.5F);
+               jR = CLAMP(jR, 0, max);
+               jG = CLAMP(jG, 0, max);
+               jB = CLAMP(jB, 0, max);
+               jA = CLAMP(jA, 0, max);
                rgba[i][RCOMP] = lut[jR * 4 + 0];
                rgba[i][GCOMP] = lut[jG * 4 + 1];
                rgba[i][BCOMP] = lut[jB * 4 + 2];
diff --git a/src/mesa/main/stencil.c b/src/mesa/main/stencil.c
index 02e805c..0d05577 100644
--- a/src/stencil.c
+++ b/src/stencil.c
@@ -1,4 +1,4 @@
-/* $Id: stencil.c,v 1.16.4.4 2001/05/17 20:19:00 brianp Exp $ */
+/* $Id: stencil.c,v 1.16.4.5 2002/01/08 14:55:48 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -1181,6 +1181,8 @@ void
 _mesa_write_stencil_span( GLcontext *ctx, GLint n, GLint x, GLint y,
                           const GLstencil stencil[] )
 {
+   const GLstencil *ssrc = stencil;
+
    if (y < 0 || y >= ctx->DrawBuffer->Height ||
        x + n <= 0 || x >= ctx->DrawBuffer->Width) {
       /* span is completely outside framebuffer */
@@ -1191,7 +1193,7 @@ _mesa_write_stencil_span( GLcontext *ctx, GLint n, GLint x, GLint y,
       GLint dx = -x;
       x = 0;
       n -= dx;
-      stencil += dx;
+      ssrc += dx;
    }
    if (x + n > ctx->DrawBuffer->Width) {
       GLint dx = x + n - ctx->DrawBuffer->Width;
@@ -1202,16 +1204,16 @@ _mesa_write_stencil_span( GLcontext *ctx, GLint n, GLint x, GLint y,
    }
 
    if (ctx->Driver.WriteStencilSpan) {
-      (*ctx->Driver.WriteStencilSpan)( ctx, n, x, y, stencil, NULL );
+      (*ctx->Driver.WriteStencilSpan)( ctx, n, x, y, ssrc, NULL );
    }
    else if (ctx->DrawBuffer->Stencil) {
       GLstencil *s = STENCIL_ADDRESS( x, y );
 #if STENCIL_BITS == 8
-      MEMCPY( s, stencil, n * sizeof(GLstencil) );
+      MEMCPY( s, ssrc, n * sizeof(GLstencil) );
 #else
       GLuint i;
       for (i=0;i<n;i++)
-         s[i] = stencil[i];
+         s[i] = ssrc[i];
 #endif
    }
 }
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 25cae9f..1aef07d 100644
--- a/src/texstate.c
+++ b/src/texstate.c
@@ -1,4 +1,4 @@
-/* $Id: texstate.c,v 1.15.4.7 2001/05/18 21:58:04 brianp Exp $ */
+/* $Id: texstate.c,v 1.15.4.8 2001/05/21 15:21:52 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -774,7 +774,7 @@ _mesa_TexParameterfv( GLenum target, GLenum pname, const GLfloat *params )
 
 
 void
-_mesa_TexParameteri( GLenum target, GLenum pname, const GLint param )
+_mesa_TexParameteri( GLenum target, GLenum pname, GLint param )
 {
    GLfloat fparam[4];
    fparam[0] = (GLfloat) param;
diff --git a/src/mesa/x86/common_x86.c b/src/mesa/x86/common_x86.c
index b48fcce..4daa73e 100644
--- a/src/X86/common_x86.c
+++ b/src/X86/common_x86.c
@@ -1,4 +1,4 @@
-/* $Id: common_x86.c,v 1.6.4.6 2000/12/07 02:36:07 gareth Exp $ */
+/* $Id: common_x86.c,v 1.6.4.8 2001/06/06 18:28:17 brianp Exp $ */
 
 /*
  * Mesa 3-D graphics library
@@ -36,7 +36,7 @@
 
 #include <stdlib.h>
 #include <stdio.h>
-#if defined(USE_KATMAI_ASM) && defined(__linux__) && defined(_POSIX_SOURCE)
+#if defined(USE_KATMAI_ASM) && defined(__linux__)
 #include <signal.h>
 #endif
 
@@ -88,7 +88,7 @@ static void message( const char *msg )
 extern void gl_test_os_katmai_support( void );
 extern void gl_test_os_katmai_exception_support( void );
 
-#if defined(__linux__) && defined(_POSIX_SOURCE)
+#if defined(__linux__) && defined(_POSIX_SOURCE) && defined(X86_FXSR_MAGIC)
 static void sigill_handler( int signal, struct sigcontext sc )
 {
    message( "SIGILL, " );
@@ -126,7 +126,7 @@ static void sigfpe_handler( int signal, struct sigcontext sc )
       gl_problem( NULL, "SSE enabling test failed badly!" );
    }
 }
-#endif /* __linux__ && _POSIX_SOURCE */
+#endif /* __linux__ && _POSIX_SOURCE && X86_FXSR_MAGIC */
 
 /* If we're running on a processor that can do SSE, let's see if we
  * are allowed to or not.  This will catch 2.4.0 or later kernels that
@@ -139,7 +139,7 @@ static void sigfpe_handler( int signal, struct sigcontext sc )
 static void check_os_katmai_support( void )
 {
 #if defined(__linux__)
-#if defined(_POSIX_SOURCE)
+#if defined(_POSIX_SOURCE) && defined(X86_FXSR_MAGIC)
    struct sigaction saved_sigill;
    struct sigaction saved_sigfpe;
 
@@ -213,7 +213,7 @@ static void check_os_katmai_support( void )
     */
    message( "Cannot test OS support for SSE, disabling to be safe.\n" );
    gl_x86_cpu_features &= ~(X86_FEATURE_XMM);
-#endif /* _POSIX_SOURCE */
+#endif /* _POSIX_SOURCE && X86_FXSR_MAGIC */
 #else
    /* Do nothing on non-Linux platforms for now.
     */
