--- src/mesa/drivers/dri/intel/intel_context.h	Thu Sep  6 08:31:50 2012
+++ src/mesa/drivers/dri/intel/intel_context.h	Thu Sep  6 08:33:19 2012
@@ -358,9 +358,13 @@
    driOptionCache optionCache;
 };
 
+#if defined(__sun)
+#include <stdlib.h>
+#define __progname getexecname()
+#else
 extern char *__progname;
+#endif
 
-
 #define SUBPIXEL_X 0.125
 #define SUBPIXEL_Y 0.125
 
@@ -418,7 +422,7 @@
  * than COPY_DWORDS would:
  * XXX Put this in src/mesa/main/imports.h ???
  */
-#if defined(i386) || defined(__i386__)
+#if (defined(i386) || defined(__i386__)) && !(defined(__SOLARIS__) || defined(sun))
 static INLINE void * __memcpy(void * to, const void * from, size_t n)
 {
    int d0, d1, d2;
--- src/mesa/drivers/dri/common/dri_util.h	Thu Sep  6 08:33:58 2012
+++ src/mesa/drivers/dri/common/dri_util.h	Thu Sep  6 08:37:46 2012
@@ -58,6 +58,11 @@
 #include "main/mtypes.h"
 #include "xmlconfig.h"
 
+#define u_int64_t uint64_t
+#define u_int32_t uint32_t
+#define u_int8_t uint8_t
+
+
 /**
  * Extensions.
  /
--- src/mesa/drivers/dri/common/mmio.h	Thu Sep  6 08:38:14 2012
+++ src/mesa/drivers/dri/common/mmio.h	Thu Sep  6 08:38:27 2012
@@ -34,6 +34,7 @@
 #define MMIO_H
 
 #include "main/glheader.h"
+#include "dri_util.h"
 
 #if defined( __powerpc__ )
 
--- src/mesa/drivers/dri/i965/brw_draw_upload.c	Thu Sep  6 08:39:01 2012
+++ src/mesa/drivers/dri/i965/brw_draw_upload.c	Thu Sep  6 08:39:32 2012
@@ -209,7 +209,27 @@
    BRW_SURFACEFORMAT_R8G8B8A8_SSCALED
 };
 
+#if defined (sun)
+/* Solaris does not have ffsll in libc */
+#define        NBITS_INT       (CHAR_BIT * sizeof (int))
+static int ffsll(long long i)
+{
+       int i1;
+       int ret;
 
+       i1 = i & UINT_MAX;
+       ret = ffs(i1);
+       if (ret == 0) {
+               i1 = (i & 0xffffffff00000000) >> NBITS_INT;
+               ret = ffs(i1) + NBITS_INT;
+       }
+       return ret;
+}
+#endif
+
+
+
+
 /**
  * Given vertex array type/size/format/normalized info, return
  * the appopriate hardware surface type.
--- src/mesa/drivers/dri/i915/intel_tris.c	Thu Sep  6 08:39:52 2012
+++ src/mesa/drivers/dri/i915/intel_tris.c	Thu Sep  6 08:40:10 2012
@@ -345,7 +345,7 @@
  *                    Emit primitives as inline vertices               *
  ***********************************************************************/
 
-#ifdef __i386__
+#if (defined(i386) || defined(__i386__)) && !(defined(__SOLARIS__) || defined(sun))
 #define COPY_DWORDS( j, vb, vertsize, v )			\
 do {								\
    int __tmp;							\
--- configure.ac	Thu Sep  6 08:47:48 2012
+++ configure.ac	Thu Sep  6 08:48:26 2012
@@ -172,7 +172,7 @@
     # Enable -fvisibility=hidden if using a gcc that supports it
     save_CFLAGS="$CFLAGS"
     AC_MSG_CHECKING([whether $CC supports -fvisibility=hidden])
-    VISIBILITY_CFLAGS="-fvisibility=hidden"
+    VISIBILITY_CFLAGS=""
     CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
     AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
 		   [VISIBILITY_CFLAGS=""; AC_MSG_RESULT([no])]);
@@ -193,7 +193,7 @@
     # Enable -fvisibility=hidden if using a gcc that supports it
     save_CXXFLAGS="$CXXFLAGS"
     AC_MSG_CHECKING([whether $CXX supports -fvisibility=hidden])
-    VISIBILITY_CXXFLAGS="-fvisibility=hidden"
+    VISIBILITY_CXXFLAGS=""
     CXXFLAGS="$CXXFLAGS $VISIBILITY_CXXFLAGS"
     AC_LANG_PUSH([C++])
     AC_LINK_IFELSE([AC_LANG_PROGRAM()], AC_MSG_RESULT([yes]),
--- configure	Thu Sep  6 08:48:39 2012
+++ configure	Thu Sep  6 08:49:02 2012
@@ -6040,7 +6040,7 @@
     save_CFLAGS="$CFLAGS"
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -fvisibility=hidden" >&5
 $as_echo_n "checking whether $CC supports -fvisibility=hidden... " >&6; }
-    VISIBILITY_CFLAGS="-fvisibility=hidden"
+    VISIBILITY_CFLAGS=""
     CFLAGS="$CFLAGS $VISIBILITY_CFLAGS"
     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -6080,7 +6080,7 @@
     save_CXXFLAGS="$CXXFLAGS"
     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX supports -fvisibility=hidden" >&5
 $as_echo_n "checking whether $CXX supports -fvisibility=hidden... " >&6; }
-    VISIBILITY_CXXFLAGS="-fvisibility=hidden"
+    VISIBILITY_CXXFLAGS=""
     CXXFLAGS="$CXXFLAGS $VISIBILITY_CXXFLAGS"
     ac_ext=cpp
 ac_cpp='$CXXCPP $CPPFLAGS'
--- src/mesa/drivers/dri/intel/intel_context.c	Thu Sep  6 08:54:15 2012
+++ src/mesa/drivers/dri/intel/intel_context.c	Thu Sep  6 08:54:55 2012
@@ -638,7 +638,7 @@
    driParseConfigFiles(&intel->optionCache, &intelScreen->optionCache,
                        sPriv->myNum, (intel->gen >= 4) ? "i965" : "i915");
    if (intel->gen < 4)
-      intel->maxBatchSize = 4096;
+      intel->maxBatchSize = 2*4096;
    else
       intel->maxBatchSize = sizeof(intel->batch.map);
 
--- src/mesa/drivers/dri/intel/intel_batchbuffer.c	Thu Sep  6 08:55:15 2012
+++ src/mesa/drivers/dri/intel/intel_batchbuffer.c	Thu Sep  6 08:55:35 2012
@@ -82,7 +82,7 @@
    intel->batch.bo = drm_intel_bo_alloc(intel->bufmgr, "batchbuffer",
 					intel->maxBatchSize, 4096);
 
-   intel->batch.reserved_space = BATCH_RESERVED;
+   intel->batch.reserved_space = 4096;
    intel->batch.state_batch_offset = intel->batch.bo->size;
    intel->batch.used = 0;
    intel->batch.needs_sol_reset = false;
