Increase compatibility with clang, mostly around SK_RESTRICT.
Attempting to fix up our use of __restrict__ so Chrome can enable it.



git-svn-id: http://skia.googlecode.com/svn/trunk@1597 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp
index bd9eba0..f015c00 100644
--- a/gm/gmmain.cpp
+++ b/gm/gmmain.cpp
@@ -21,7 +21,7 @@
 using namespace skiagm;
 
 // need to explicitly declare this, or we get some weird infinite loop llist
-template GMRegistry* GMRegistry::gHead;
+template GMRegistry* SkTRegistry<GM*, void*>::gHead;
 
 class Iter {
 public:
diff --git a/gpu/src/gr_unittests.cpp b/gpu/src/gr_unittests.cpp
index 338f2cc..2af0def 100644
--- a/gpu/src/gr_unittests.cpp
+++ b/gpu/src/gr_unittests.cpp
@@ -15,13 +15,23 @@
  */
 
 
-#include "GrDrawTarget.h"
-#include "GrTDArray.h"
-#include "GrTBSearch.h"
-#include "GrMatrix.h"
-#include "GrRedBlackTree.h"
-#include "GrPath.h"
 #include "GrBinHashKey.h"
+#include "GrDrawTarget.h"
+#include "GrMatrix.h"
+#include "GrPath.h"
+#include "GrRedBlackTree.h"
+#include "GrTDArray.h"
+
+// If we aren't inheriting these as #defines from elsewhere,
+// clang demands they be declared before we #include the template
+// that relies on them.
+static bool LT(const int& elem, int value) {
+    return elem < value;
+}
+static bool EQ(const int& elem, int value) {
+    return elem == value;
+}
+#include "GrTBSearch.h"
 
 static void dump(const GrTDArray<int>& array) {
 #if 0
@@ -53,12 +63,6 @@
     GrAssert(array.count() == 4);
 }
 
-static bool LT(const int& elem, int value) {
-    return elem < value;
-}
-static bool EQ(const int& elem, int value) {
-    return elem == value;
-}
 
 static void test_bsearch() {
     const int array[] = {
diff --git a/include/core/SkBlitRow.h b/include/core/SkBlitRow.h
index bb8cbc2..a6a274a 100644
--- a/include/core/SkBlitRow.h
+++ b/include/core/SkBlitRow.h
@@ -25,8 +25,8 @@
         @param x The x coordinate of the beginning of the scanline
         @param y THe y coordinate of the scanline
      */
-    typedef void (*Proc)(uint16_t* SK_RESTRICT dst,
-                         const SkPMColor* SK_RESTRICT src,
+    typedef void (*Proc)(uint16_t* dst,
+                         const SkPMColor* src,
                          int count, U8CPU alpha, int x, int y);
 
    /** Function pointer that blends a single color with a row of 32-bit colors
@@ -51,8 +51,8 @@
         @param count number of colors to blend
         @param alpha global alpha to be applied to all src colors
      */
-    typedef void (*Proc32)(uint32_t* SK_RESTRICT dst,
-                         const SkPMColor* SK_RESTRICT src,
+    typedef void (*Proc32)(uint32_t* dst,
+                         const SkPMColor* src,
                          int count, U8CPU alpha);
 
     static Proc32 Factory32(unsigned flags32);
diff --git a/include/core/SkBlitter.h b/include/core/SkBlitter.h
index 11b84fd..4e6ba00 100644
--- a/include/core/SkBlitter.h
+++ b/include/core/SkBlitter.h
@@ -30,7 +30,8 @@
     virtual ~SkBlitter();
 
     virtual void blitH(int x, int y, int width);
-    virtual void blitAntiH(int x, int y, const SkAlpha[], const int16_t runs[]);
+    virtual void blitAntiH(int x, int y, const SkAlpha* antialias,
+                           const int16_t* runs);
     virtual void blitV(int x, int y, int height, SkAlpha alpha);
     virtual void blitRect(int x, int y, int width, int height);
     virtual void blitMask(const SkMask&, const SkIRect& clip);
diff --git a/src/core/SkBitmap.cpp b/src/core/SkBitmap.cpp
index 20af3f0..72b6b62 100644
--- a/src/core/SkBitmap.cpp
+++ b/src/core/SkBitmap.cpp
@@ -1205,7 +1205,7 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-static bool GetBitmapAlpha(const SkBitmap& src, uint8_t SK_RESTRICT alpha[],
+static bool GetBitmapAlpha(const SkBitmap& src, uint8_t* SK_RESTRICT alpha,
                            int alphaRowBytes) {
     SkASSERT(alpha != NULL);
     SkASSERT(alphaRowBytes >= src.width());
@@ -1527,4 +1527,3 @@
 #endif
 }
 #endif
-
diff --git a/src/core/SkBlitter_RGB16.cpp b/src/core/SkBlitter_RGB16.cpp
index 882866b..c9f6224 100644
--- a/src/core/SkBlitter_RGB16.cpp
+++ b/src/core/SkBlitter_RGB16.cpp
@@ -63,10 +63,12 @@
 public:
     SkRGB16_Blitter(const SkBitmap& device, const SkPaint& paint);
     virtual void blitH(int x, int y, int width);
-    virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]);
+    virtual void blitAntiH(int x, int y, const SkAlpha* antialias,
+                           const int16_t* runs);
     virtual void blitV(int x, int y, int height, SkAlpha alpha);
     virtual void blitRect(int x, int y, int width, int height);
-    virtual void blitMask(const SkMask&, const SkIRect&);
+    virtual void blitMask(const SkMask&,
+                          const SkIRect&);
     virtual const SkBitmap* justAnOpaqueColor(uint32_t*);
     
 protected:
@@ -88,10 +90,12 @@
 public:
     SkRGB16_Opaque_Blitter(const SkBitmap& device, const SkPaint& paint);
     virtual void blitH(int x, int y, int width);
-    virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]);
+    virtual void blitAntiH(int x, int y, const SkAlpha* antialias,
+                           const int16_t* runs);
     virtual void blitV(int x, int y, int height, SkAlpha alpha);
     virtual void blitRect(int x, int y, int width, int height);
-    virtual void blitMask(const SkMask&, const SkIRect&);
+    virtual void blitMask(const SkMask&,
+                          const SkIRect&);
     
 private:
     typedef SkRGB16_Blitter INHERITED;
@@ -102,7 +106,8 @@
 public:
     SkRGB16_Black_Blitter(const SkBitmap& device, const SkPaint& paint);
     virtual void blitMask(const SkMask&, const SkIRect&);
-    virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]);
+    virtual void blitAntiH(int x, int y, const SkAlpha* antialias,
+                           const int16_t* runs);
     
 private:
     typedef SkRGB16_Opaque_Blitter INHERITED;
@@ -114,7 +119,8 @@
     SkRGB16_Shader_Blitter(const SkBitmap& device, const SkPaint& paint);
     virtual ~SkRGB16_Shader_Blitter();
     virtual void blitH(int x, int y, int width);
-    virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]);
+    virtual void blitAntiH(int x, int y, const SkAlpha* antialias,
+                           const int16_t* runs);
     virtual void blitRect(int x, int y, int width, int height);
     
 protected:
@@ -134,7 +140,8 @@
 public:
     SkRGB16_Shader16_Blitter(const SkBitmap& device, const SkPaint& paint);
     virtual void blitH(int x, int y, int width);
-    virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]);
+    virtual void blitAntiH(int x, int y, const SkAlpha* antialias,
+                           const int16_t* runs);
     virtual void blitRect(int x, int y, int width, int height);
     
 private:
@@ -146,7 +153,8 @@
     SkRGB16_Shader_Xfermode_Blitter(const SkBitmap& device, const SkPaint& paint);
     virtual ~SkRGB16_Shader_Xfermode_Blitter();
     virtual void blitH(int x, int y, int width);
-    virtual void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]);
+    virtual void blitAntiH(int x, int y, const SkAlpha* antialias,
+                           const int16_t* runs);
     
 private:
     SkXfermode* fXfermode;
@@ -203,8 +211,7 @@
 #include "SkBlitBWMaskTemplate.h"
 
 void SkRGB16_Black_Blitter::blitMask(const SkMask& SK_RESTRICT mask,
-                                     const SkIRect& SK_RESTRICT clip)
-                                     SK_RESTRICT {
+                                     const SkIRect& SK_RESTRICT clip) {
     if (mask.fFormat == SkMask::kBW_Format) {
         SkRGB16_Black_BlitBW(fDevice, mask, clip);
     } else {
@@ -235,8 +242,7 @@
 
 void SkRGB16_Black_Blitter::blitAntiH(int x, int y,
                                       const SkAlpha* SK_RESTRICT antialias,
-                                      const int16_t* SK_RESTRICT runs)
-                                      SK_RESTRICT {
+                                      const int16_t* SK_RESTRICT runs) {
     uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y);
 
     for (;;) {
@@ -273,7 +279,7 @@
                                                const SkPaint& paint)
 : INHERITED(device, paint) {}
 
-void SkRGB16_Opaque_Blitter::blitH(int x, int y, int width) SK_RESTRICT {
+void SkRGB16_Opaque_Blitter::blitH(int x, int y, int width) {
     SkASSERT(width > 0);
     SkASSERT(x + width <= fDevice.width());
     uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y);
@@ -298,7 +304,7 @@
 
 void SkRGB16_Opaque_Blitter::blitAntiH(int x, int y,
                                        const SkAlpha* SK_RESTRICT antialias,
-                                       const int16_t* SK_RESTRICT runs) SK_RESTRICT {
+                                       const int16_t* SK_RESTRICT runs) {
     uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y);
     uint16_t    srcColor = fRawColor16;
     uint32_t    srcExpanded = fExpandedRaw16;
@@ -373,7 +379,7 @@
 }
 
 void SkRGB16_Opaque_Blitter::blitMask(const SkMask& SK_RESTRICT mask,
-                                      const SkIRect& SK_RESTRICT clip) SK_RESTRICT {
+                                      const SkIRect& SK_RESTRICT clip) {
     if (mask.fFormat == SkMask::kBW_Format) {
         SkRGB16_BlitBW(fDevice, mask, clip, fColor16);
         return;
@@ -572,7 +578,7 @@
     } while (--count != 0);
 }
 
-void SkRGB16_Blitter::blitH(int x, int y, int width) SK_RESTRICT {
+void SkRGB16_Blitter::blitH(int x, int y, int width) {
     SkASSERT(width > 0);
     SkASSERT(x + width <= fDevice.width());
     uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y);
@@ -583,7 +589,7 @@
 
 void SkRGB16_Blitter::blitAntiH(int x, int y,
                                 const SkAlpha* SK_RESTRICT antialias,
-                                const int16_t* SK_RESTRICT runs) SK_RESTRICT {
+                                const int16_t* SK_RESTRICT runs) {
     uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y);
     uint32_t    srcExpanded = fExpandedRaw16;
     unsigned    scale = fScale;
@@ -633,7 +639,7 @@
 #include "SkBlitBWMaskTemplate.h"
 
 void SkRGB16_Blitter::blitMask(const SkMask& SK_RESTRICT mask,
-                               const SkIRect& SK_RESTRICT clip) SK_RESTRICT {
+                               const SkIRect& SK_RESTRICT clip) {
     if (mask.fFormat == SkMask::kBW_Format) {
         SkRGB16_BlendBW(fDevice, mask, clip, 256 - fScale, fColor16);
         return;
@@ -697,7 +703,7 @@
     SkASSERT(SkShader::CanCallShadeSpan16(fShaderFlags));
 }
 
-void SkRGB16_Shader16_Blitter::blitH(int x, int y, int width) SK_RESTRICT {
+void SkRGB16_Shader16_Blitter::blitH(int x, int y, int width) {
     SkASSERT(x + width <= fDevice.width());
 
     uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y);
@@ -760,8 +766,7 @@
 
 void SkRGB16_Shader16_Blitter::blitAntiH(int x, int y,
                                          const SkAlpha* SK_RESTRICT antialias,
-                                         const int16_t* SK_RESTRICT runs)
-                                         SK_RESTRICT {
+                                         const int16_t* SK_RESTRICT runs) {
     SkShader*   shader = fShader;
     SkPMColor* SK_RESTRICT span = fBuffer;
     uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y);
@@ -893,8 +898,7 @@
 
 void SkRGB16_Shader_Blitter::blitAntiH(int x, int y,
                                        const SkAlpha* SK_RESTRICT antialias,
-                                       const int16_t* SK_RESTRICT runs)
-                                       SK_RESTRICT {
+                                       const int16_t* SK_RESTRICT runs) {
     SkShader*   shader = fShader;
     SkPMColor* SK_RESTRICT span = fBuffer;
     uint16_t* SK_RESTRICT device = fDevice.getAddr16(x, y);
@@ -971,7 +975,7 @@
 
 void SkRGB16_Shader_Xfermode_Blitter::blitAntiH(int x, int y,
                                 const SkAlpha* SK_RESTRICT antialias,
-                                const int16_t* SK_RESTRICT runs) SK_RESTRICT {
+                                const int16_t* SK_RESTRICT runs) {
     SkShader*   shader = fShader;
     SkXfermode* mode = fXfermode;
     SkPMColor* SK_RESTRICT span = fBuffer;
diff --git a/src/core/SkPackBits.cpp b/src/core/SkPackBits.cpp
index 3e92841..29d1166 100644
--- a/src/core/SkPackBits.cpp
+++ b/src/core/SkPackBits.cpp
@@ -151,8 +151,8 @@
     return dst;
 }
 
-static uint8_t* flush_diff16(uint8_t SK_RESTRICT dst[],
-                             const uint16_t SK_RESTRICT src[], int count) {
+static uint8_t* flush_diff16(uint8_t* SK_RESTRICT dst,
+                             const uint16_t* SK_RESTRICT src, int count) {
     while (count > 0) {
         int n = count;
         if (n > 128) {
@@ -167,8 +167,8 @@
     return dst;
 }
 
-static uint8_t* flush_diff8(uint8_t SK_RESTRICT dst[],
-                            const uint8_t SK_RESTRICT src[], int count) {
+static uint8_t* flush_diff8(uint8_t* SK_RESTRICT dst,
+                            const uint8_t* SK_RESTRICT src, int count) {
     while (count > 0) {
         int n = count;
         if (n > 128) {
@@ -183,8 +183,8 @@
     return dst;
 }
 
-size_t SkPackBits::Pack16(const uint16_t SK_RESTRICT src[], int count,
-                          uint8_t SK_RESTRICT dst[]) {
+size_t SkPackBits::Pack16(const uint16_t* SK_RESTRICT src, int count,
+                          uint8_t* SK_RESTRICT dst) {
     uint8_t* origDst = dst;
     const uint16_t* stop = src + count;
 
@@ -226,8 +226,8 @@
     }
 }
 
-size_t SkPackBits::Pack8(const uint8_t SK_RESTRICT src[], int count,
-                         uint8_t SK_RESTRICT dst[]) {
+size_t SkPackBits::Pack8(const uint8_t* SK_RESTRICT src, int count,
+                         uint8_t* SK_RESTRICT dst) {
     uint8_t* origDst = dst;
     const uint8_t* stop = src + count;
 
@@ -272,8 +272,8 @@
 
 #include "SkUtils.h"
 
-int SkPackBits::Unpack16(const uint8_t SK_RESTRICT src[], size_t srcSize,
-                         uint16_t SK_RESTRICT dst[]) {
+int SkPackBits::Unpack16(const uint8_t* SK_RESTRICT src, size_t srcSize,
+                         uint16_t* SK_RESTRICT dst) {
     uint16_t* origDst = dst;
     const uint8_t* stop = src + srcSize;
     
@@ -294,8 +294,8 @@
     return dst - origDst;
 }
 
-int SkPackBits::Unpack8(const uint8_t SK_RESTRICT src[], size_t srcSize,
-                        uint8_t SK_RESTRICT dst[]) {
+int SkPackBits::Unpack8(const uint8_t* SK_RESTRICT src, size_t srcSize,
+                        uint8_t* SK_RESTRICT dst) {
     uint8_t* origDst = dst;
     const uint8_t* stop = src + srcSize;
     
@@ -321,8 +321,8 @@
     COPY_SRC_STATE
 };
 
-void SkPackBits::Unpack8(uint8_t SK_RESTRICT dst[], size_t dstSkip,
-                         size_t dstWrite, const uint8_t SK_RESTRICT src[]) {
+void SkPackBits::Unpack8(uint8_t* SK_RESTRICT dst, size_t dstSkip,
+                         size_t dstWrite, const uint8_t* SK_RESTRICT src) {
     if (dstWrite == 0) {
         return;
     }
@@ -402,6 +402,3 @@
     }
     SkASSERT(0 == dstWrite);
 }
-
-
-
diff --git a/src/core/SkSpriteBlitterTemplate.h b/src/core/SkSpriteBlitterTemplate.h
index 2ab2b3a..e4f03a3 100644
--- a/src/core/SkSpriteBlitterTemplate.h
+++ b/src/core/SkSpriteBlitterTemplate.h
@@ -27,8 +27,8 @@
         SkASSERT(width > 0 && height > 0);
         int srcX = x - fLeft;
         int srcY = y - fTop;
-        SK_RESTRICT SkSPRITE_DST_TYPE* dst =fDevice->SkSPRITE_DST_GETADDR(x, y);
-        const SK_RESTRICT SkSPRITE_SRC_TYPE* src =
+        SkSPRITE_DST_TYPE* SK_RESTRICT dst =fDevice->SkSPRITE_DST_GETADDR(x, y);
+        const SkSPRITE_SRC_TYPE* SK_RESTRICT src =
                                       fSource->SkSPRITE_SRC_GETADDR(srcX, srcY);
         unsigned dstRB = fDevice->rowBytes();
         unsigned srcRB = fSource->rowBytes();
@@ -55,8 +55,8 @@
                 d += 1;
             } while (--w != 0);
 #endif
-            dst = (SK_RESTRICT SkSPRITE_DST_TYPE*)((char*)dst + dstRB);
-            src = (const SK_RESTRICT SkSPRITE_SRC_TYPE*)
+            dst = (SkSPRITE_DST_TYPE* SK_RESTRICT)((char*)dst + dstRB);
+            src = (const SkSPRITE_SRC_TYPE* SK_RESTRICT)
                                             ((const char*)src + srcRB);
             SkSPRITE_NEXT_ROW
 #ifdef SkSPRITE_ROW_PROC
@@ -88,4 +88,3 @@
 #ifdef SkSPRITE_ROW_PROC
     #undef SkSPRITE_ROW_PROC
 #endif
-
diff --git a/src/core/SkSpriteBlitter_ARGB32.cpp b/src/core/SkSpriteBlitter_ARGB32.cpp
index df9e2a1..be17908 100644
--- a/src/core/SkSpriteBlitter_ARGB32.cpp
+++ b/src/core/SkSpriteBlitter_ARGB32.cpp
@@ -44,8 +44,8 @@
 
     virtual void blitRect(int x, int y, int width, int height) {
         SkASSERT(width > 0 && height > 0);
-        SK_RESTRICT uint32_t* dst = fDevice->getAddr32(x, y);
-        const SK_RESTRICT uint32_t* src = fSource->getAddr32(x - fLeft,
+        uint32_t* SK_RESTRICT dst = fDevice->getAddr32(x, y);
+        const uint32_t* SK_RESTRICT src = fSource->getAddr32(x - fLeft,
                                                              y - fTop);
         size_t dstRB = fDevice->rowBytes();
         size_t srcRB = fSource->rowBytes();
@@ -54,8 +54,8 @@
 
         do {
             proc(dst, src, width, alpha);
-            dst = (SK_RESTRICT uint32_t*)((char*)dst + dstRB);
-            src = (const SK_RESTRICT uint32_t*)((const char*)src + srcRB);
+            dst = (uint32_t* SK_RESTRICT)((char*)dst + dstRB);
+            src = (const uint32_t* SK_RESTRICT)((const char*)src + srcRB);
         } while (--height != 0);
     }
 
@@ -132,8 +132,8 @@
 
     virtual void blitRect(int x, int y, int width, int height) {
         SkASSERT(width > 0 && height > 0);
-        SK_RESTRICT uint32_t* dst = fDevice->getAddr32(x, y);
-        const SK_RESTRICT uint32_t* src = fSource->getAddr32(x - fLeft,
+        uint32_t* SK_RESTRICT dst = fDevice->getAddr32(x, y);
+        const uint32_t* SK_RESTRICT src = fSource->getAddr32(x - fLeft,
                                                              y - fTop);
         unsigned dstRB = fDevice->rowBytes();
         unsigned srcRB = fSource->rowBytes();
@@ -154,8 +154,8 @@
                 fProc32(dst, tmp, width, fAlpha);
             }
 
-            dst = (SK_RESTRICT uint32_t*)((char*)dst + dstRB);
-            src = (const SK_RESTRICT uint32_t*)((const char*)src + srcRB);
+            dst = (uint32_t* SK_RESTRICT)((char*)dst + dstRB);
+            src = (const uint32_t* SK_RESTRICT)((const char*)src + srcRB);
         } while (--height != 0);
     }
 
@@ -163,8 +163,8 @@
     typedef Sprite_D32_XferFilter INHERITED;
 };
 
-static void fillbuffer(SK_RESTRICT SkPMColor dst[],
-                       const SK_RESTRICT SkPMColor16 src[], int count) {
+static void fillbuffer(SkPMColor* SK_RESTRICT dst,
+                       const SkPMColor16* SK_RESTRICT src, int count) {
     SkASSERT(count > 0);
 
     do {
@@ -179,12 +179,12 @@
 
     virtual void blitRect(int x, int y, int width, int height) {
         SkASSERT(width > 0 && height > 0);
-        SK_RESTRICT SkPMColor* dst = fDevice->getAddr32(x, y);
-        const SK_RESTRICT SkPMColor16* src = fSource->getAddr16(x - fLeft,
+        SkPMColor* SK_RESTRICT dst = fDevice->getAddr32(x, y);
+        const SkPMColor16* SK_RESTRICT src = fSource->getAddr16(x - fLeft,
                                                                 y - fTop);
         unsigned dstRB = fDevice->rowBytes();
         unsigned srcRB = fSource->rowBytes();
-        SK_RESTRICT SkPMColor* buffer = fBuffer;
+        SkPMColor* SK_RESTRICT buffer = fBuffer;
         SkColorFilter* colorFilter = fColorFilter;
         SkXfermode* xfermode = fXfermode;
 
@@ -200,8 +200,8 @@
                 fProc32(dst, buffer, width, fAlpha);
             }
 
-            dst = (SK_RESTRICT SkPMColor*)((char*)dst + dstRB);
-            src = (const SK_RESTRICT SkPMColor16*)((const char*)src + srcRB);
+            dst = (SkPMColor* SK_RESTRICT)((char*)dst + dstRB);
+            src = (const SkPMColor16* SK_RESTRICT)((const char*)src + srcRB);
         } while (--height != 0);
     }
 
@@ -211,8 +211,8 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-static void src_row(SK_RESTRICT SkPMColor dst[],
-                    const SK_RESTRICT SkPMColor16 src[], int count) {
+static void src_row(SkPMColor* SK_RESTRICT dst,
+                    const SkPMColor16* SK_RESTRICT src, int count) {
     do {
         *dst = SkPixel4444ToPixel32(*src);
         src += 1;
@@ -226,22 +226,22 @@
 
     virtual void blitRect(int x, int y, int width, int height) {
         SkASSERT(width > 0 && height > 0);
-        SK_RESTRICT SkPMColor* dst = fDevice->getAddr32(x, y);
-        const SK_RESTRICT SkPMColor16* src = fSource->getAddr16(x - fLeft,
+        SkPMColor* SK_RESTRICT dst = fDevice->getAddr32(x, y);
+        const SkPMColor16* SK_RESTRICT src = fSource->getAddr16(x - fLeft,
                                                                 y - fTop);
         unsigned dstRB = fDevice->rowBytes();
         unsigned srcRB = fSource->rowBytes();
 
         do {
             src_row(dst, src, width);
-            dst = (SK_RESTRICT SkPMColor*)((char*)dst + dstRB);
-            src = (const SK_RESTRICT SkPMColor16*)((const char*)src + srcRB);
+            dst = (SkPMColor* SK_RESTRICT)((char*)dst + dstRB);
+            src = (const SkPMColor16* SK_RESTRICT)((const char*)src + srcRB);
         } while (--height != 0);
     }
 };
 
-static void srcover_row(SK_RESTRICT SkPMColor dst[],
-                        const SK_RESTRICT SkPMColor16 src[], int count) {
+static void srcover_row(SkPMColor* SK_RESTRICT dst,
+                        const SkPMColor16* SK_RESTRICT src, int count) {
     do {
         *dst = SkPMSrcOver(SkPixel4444ToPixel32(*src), *dst);
         src += 1;
@@ -255,16 +255,16 @@
 
     virtual void blitRect(int x, int y, int width, int height) {
         SkASSERT(width > 0 && height > 0);
-        SK_RESTRICT SkPMColor* dst = fDevice->getAddr32(x, y);
-        const SK_RESTRICT SkPMColor16* src = fSource->getAddr16(x - fLeft,
+        SkPMColor* SK_RESTRICT dst = fDevice->getAddr32(x, y);
+        const SkPMColor16* SK_RESTRICT src = fSource->getAddr16(x - fLeft,
                                                                 y - fTop);
         unsigned dstRB = fDevice->rowBytes();
         unsigned srcRB = fSource->rowBytes();
 
         do {
             srcover_row(dst, src, width);
-            dst = (SK_RESTRICT SkPMColor*)((char*)dst + dstRB);
-            src = (const SK_RESTRICT SkPMColor16*)((const char*)src + srcRB);
+            dst = (SkPMColor* SK_RESTRICT)((char*)dst + dstRB);
+            src = (const SkPMColor16* SK_RESTRICT)((const char*)src + srcRB);
         } while (--height != 0);
     }
 };
@@ -319,4 +319,3 @@
     }
     return blitter;
 }
-
diff --git a/src/core/SkSpriteBlitter_RGB16.cpp b/src/core/SkSpriteBlitter_RGB16.cpp
index 4dcd73d..83923b0 100644
--- a/src/core/SkSpriteBlitter_RGB16.cpp
+++ b/src/core/SkSpriteBlitter_RGB16.cpp
@@ -63,8 +63,8 @@
 
     // overrides
     virtual void blitRect(int x, int y, int width, int height) {
-        SK_RESTRICT uint16_t* dst = fDevice->getAddr16(x, y);
-        const SK_RESTRICT uint16_t* src = fSource->getAddr16(x - fLeft,
+        uint16_t* SK_RESTRICT dst = fDevice->getAddr16(x, y);
+        const uint16_t* SK_RESTRICT src = fSource->getAddr16(x - fLeft,
                                                              y - fTop);
         unsigned dstRB = fDevice->rowBytes();
         unsigned srcRB = fSource->rowBytes();
@@ -176,9 +176,9 @@
     return reinterpret_cast<const char*>(ptr) - (const char*)0;
 }
 
-static void blitrow_d16_si8(SK_RESTRICT uint16_t* dst,
-                            SK_RESTRICT const uint8_t* src, int count,
-                            SK_RESTRICT const uint16_t* ctable) {
+static void blitrow_d16_si8(uint16_t* SK_RESTRICT dst,
+                            const uint8_t* SK_RESTRICT src, int count,
+                            const uint16_t* SK_RESTRICT ctable) {
     if (count <= 8) {
         do {
             *dst++ = ctable[*src++];
@@ -290,8 +290,8 @@
     }
     
     virtual void blitRect(int x, int y, int width, int height) {
-        SK_RESTRICT uint16_t* dst = fDevice->getAddr16(x, y);
-        const SK_RESTRICT SkPMColor* src = fSource->getAddr32(x - fLeft,
+        uint16_t* SK_RESTRICT dst = fDevice->getAddr16(x, y);
+        const SkPMColor* SK_RESTRICT src = fSource->getAddr32(x - fLeft,
                                                               y - fTop);
         unsigned dstRB = fDevice->rowBytes();
         unsigned srcRB = fSource->rowBytes();
@@ -301,8 +301,8 @@
         while (--height >= 0) {
             proc(dst, src, width, alpha, x, y);
             y += 1;
-            dst = (SK_RESTRICT uint16_t*)((char*)dst + dstRB);
-            src = (const SK_RESTRICT SkPMColor*)((const char*)src + srcRB);
+            dst = (uint16_t* SK_RESTRICT)((char*)dst + dstRB);
+            src = (const SkPMColor* SK_RESTRICT)((const char*)src + srcRB);
         }
     }
     
@@ -383,4 +383,3 @@
     }
     return blitter;
 }
-
diff --git a/src/core/SkXfermode.cpp b/src/core/SkXfermode.cpp
index 90cf13a..598b390 100644
--- a/src/core/SkXfermode.cpp
+++ b/src/core/SkXfermode.cpp
@@ -477,9 +477,9 @@
     return dst;
 }
 
-void SkXfermode::xfer32(SK_RESTRICT SkPMColor dst[],
-                        const SK_RESTRICT SkPMColor src[], int count,
-                        const SK_RESTRICT SkAlpha aa[]) {
+void SkXfermode::xfer32(SkPMColor* SK_RESTRICT dst,
+                        const SkPMColor* SK_RESTRICT src, int count,
+                        const SkAlpha* SK_RESTRICT aa) {
     SkASSERT(dst && src && count >= 0);
 
     if (NULL == aa) {
@@ -501,9 +501,9 @@
     }
 }
 
-void SkXfermode::xfer16(SK_RESTRICT uint16_t dst[],
-                        const SK_RESTRICT SkPMColor src[], int count,
-                        const SK_RESTRICT SkAlpha aa[]) {
+void SkXfermode::xfer16(uint16_t* dst,
+                        const SkPMColor* SK_RESTRICT src, int count,
+                        const SkAlpha* SK_RESTRICT aa) {
     SkASSERT(dst && src && count >= 0);
 
     if (NULL == aa) {
@@ -526,9 +526,9 @@
     }
 }
 
-void SkXfermode::xfer4444(SK_RESTRICT SkPMColor16 dst[],
-                          const SK_RESTRICT SkPMColor src[], int count,
-                          const SK_RESTRICT SkAlpha aa[])
+void SkXfermode::xfer4444(SkPMColor16* SK_RESTRICT dst,
+                          const SkPMColor* SK_RESTRICT src, int count,
+                          const SkAlpha* SK_RESTRICT aa)
 {
     SkASSERT(dst && src && count >= 0);
 
@@ -552,9 +552,9 @@
     }
 }
 
-void SkXfermode::xferA8(SK_RESTRICT SkAlpha dst[],
+void SkXfermode::xferA8(SkAlpha* SK_RESTRICT dst,
                         const SkPMColor src[], int count,
-                        const SK_RESTRICT SkAlpha aa[])
+                        const SkAlpha* SK_RESTRICT aa)
 {
     SkASSERT(dst && src && count >= 0);
 
@@ -581,9 +581,9 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-void SkProcXfermode::xfer32(SK_RESTRICT SkPMColor dst[],
-                            const SK_RESTRICT SkPMColor src[], int count,
-                            const SK_RESTRICT SkAlpha aa[]) {
+void SkProcXfermode::xfer32(SkPMColor* SK_RESTRICT dst,
+                            const SkPMColor* SK_RESTRICT src, int count,
+                            const SkAlpha* SK_RESTRICT aa) {
     SkASSERT(dst && src && count >= 0);
 
     SkXfermodeProc proc = fProc;
@@ -609,9 +609,9 @@
     }
 }
 
-void SkProcXfermode::xfer16(SK_RESTRICT uint16_t dst[],
-                            const SK_RESTRICT SkPMColor src[], int count,
-                            const SK_RESTRICT SkAlpha aa[]) {
+void SkProcXfermode::xfer16(uint16_t* SK_RESTRICT dst,
+                            const SkPMColor* SK_RESTRICT src, int count,
+                            const SkAlpha* SK_RESTRICT aa) {
     SkASSERT(dst && src && count >= 0);
 
     SkXfermodeProc proc = fProc;
@@ -638,9 +638,9 @@
     }
 }
 
-void SkProcXfermode::xfer4444(SK_RESTRICT SkPMColor16 dst[],
-                              const SK_RESTRICT SkPMColor src[], int count,
-                              const SK_RESTRICT SkAlpha aa[]) {
+void SkProcXfermode::xfer4444(SkPMColor16* SK_RESTRICT dst,
+                              const SkPMColor* SK_RESTRICT src, int count,
+                              const SkAlpha* SK_RESTRICT aa) {
     SkASSERT(dst && src && count >= 0);
 
     SkXfermodeProc proc = fProc;
@@ -667,9 +667,9 @@
     }
 }
 
-void SkProcXfermode::xferA8(SK_RESTRICT SkAlpha dst[],
-                            const SK_RESTRICT SkPMColor src[], int count,
-                            const SK_RESTRICT SkAlpha aa[]) {
+void SkProcXfermode::xferA8(SkAlpha* SK_RESTRICT dst,
+                            const SkPMColor* SK_RESTRICT src, int count,
+                            const SkAlpha* SK_RESTRICT aa) {
     SkASSERT(dst && src && count >= 0);
 
     SkXfermodeProc proc = fProc;
@@ -774,9 +774,9 @@
 public:
     SkClearXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kClear_Mode) {}
 
-    virtual void xfer32(SK_RESTRICT SkPMColor dst[],
-                        const SK_RESTRICT SkPMColor[], int count,
-                        const SK_RESTRICT SkAlpha aa[]) {
+    virtual void xfer32(SkPMColor* SK_RESTRICT dst,
+                        const SkPMColor* SK_RESTRICT, int count,
+                        const SkAlpha* SK_RESTRICT aa) {
         SkASSERT(dst && count >= 0);
 
         if (NULL == aa) {
@@ -792,9 +792,9 @@
             }
         }
     }
-    virtual void xferA8(SK_RESTRICT SkAlpha dst[],
-                        const SK_RESTRICT SkPMColor[], int count,
-                        const SK_RESTRICT SkAlpha aa[]) {
+    virtual void xferA8(SkAlpha* SK_RESTRICT dst,
+                        const SkPMColor* SK_RESTRICT, int count,
+                        const SkAlpha* SK_RESTRICT aa) {
         SkASSERT(dst && count >= 0);
 
         if (NULL == aa) {
@@ -829,9 +829,9 @@
 public:
     SkSrcXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kSrc_Mode) {}
 
-    virtual void xfer32(SK_RESTRICT SkPMColor dst[],
-                        const SK_RESTRICT SkPMColor src[], int count,
-                        const SK_RESTRICT SkAlpha aa[]) {
+    virtual void xfer32(SkPMColor* SK_RESTRICT dst,
+                        const SkPMColor* SK_RESTRICT src, int count,
+                        const SkAlpha* SK_RESTRICT aa) {
         SkASSERT(dst && src && count >= 0);
 
         if (NULL == aa) {
@@ -848,9 +848,9 @@
         }
     }
 
-    virtual void xferA8(SK_RESTRICT SkAlpha dst[],
-                        const SK_RESTRICT SkPMColor src[], int count,
-                        const SK_RESTRICT SkAlpha aa[]) {
+    virtual void xferA8(SkAlpha* SK_RESTRICT dst,
+                        const SkPMColor* SK_RESTRICT src, int count,
+                        const SkAlpha* SK_RESTRICT aa) {
         SkASSERT(dst && src && count >= 0);
 
         if (NULL == aa) {
@@ -888,9 +888,9 @@
 public:
     SkDstInXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kDstIn_Mode) {}
 
-    virtual void xfer32(SK_RESTRICT SkPMColor dst[],
-                        const SK_RESTRICT SkPMColor src[], int count,
-                        const SK_RESTRICT SkAlpha aa[]) {
+    virtual void xfer32(SkPMColor* SK_RESTRICT dst,
+                        const SkPMColor* SK_RESTRICT src, int count,
+                        const SkAlpha* SK_RESTRICT aa) {
         SkASSERT(dst && src);
 
         if (count <= 0) {
@@ -924,9 +924,9 @@
 public:
     SkDstOutXfermode(const ProcCoeff& rec) : SkProcCoeffXfermode(rec, kDstOut_Mode) {}
 
-    virtual void xfer32(SK_RESTRICT SkPMColor dst[],
-                        const SK_RESTRICT SkPMColor src[], int count,
-                        const SK_RESTRICT SkAlpha aa[]) {
+    virtual void xfer32(SkPMColor* SK_RESTRICT dst,
+                        const SkPMColor* SK_RESTRICT src, int count,
+                        const SkAlpha* SK_RESTRICT aa) {
         SkASSERT(dst && src);
 
         if (count <= 0) {
diff --git a/src/effects/SkColorMatrixFilter.cpp b/src/effects/SkColorMatrixFilter.cpp
index 9270052..d5d1d31 100644
--- a/src/effects/SkColorMatrixFilter.cpp
+++ b/src/effects/SkColorMatrixFilter.cpp
@@ -110,7 +110,9 @@
 #define kNO_ALPHA_FLAGS (SkColorFilter::kAlphaUnchanged_Flag |  \
                          SkColorFilter::kHasFilter16_Flag)
 
-void SkColorMatrixFilter::setup(const SkScalar SK_RESTRICT src[20]) {
+// src is [20] but some compilers won't accept __restrict__ on anything
+// but an raw pointer or reference
+void SkColorMatrixFilter::setup(const SkScalar* SK_RESTRICT src) {
     if (NULL == src) {
         fProc = NULL;   // signals identity
         fFlags  = kNO_ALPHA_FLAGS;
diff --git a/src/images/SkImageEncoder_Factory.cpp b/src/images/SkImageEncoder_Factory.cpp
index 0bb4d1a..c78b18d 100644
--- a/src/images/SkImageEncoder_Factory.cpp
+++ b/src/images/SkImageEncoder_Factory.cpp
@@ -19,7 +19,8 @@
 
 typedef SkTRegistry<SkImageEncoder*, SkImageEncoder::Type> EncodeReg;
 
-template EncodeReg* EncodeReg::gHead;
+// Can't use the typedef here because of complex C++ corner cases
+template EncodeReg* SkTRegistry<SkImageEncoder*, SkImageEncoder::Type>::gHead;
 
 #ifdef SK_ENABLE_LIBPNG
     extern SkImageEncoder* sk_libpng_efactory(SkImageEncoder::Type);
@@ -41,4 +42,3 @@
 #endif
     return NULL;
 }
-