am d95a8c2b: am 4e27bdb0: am 9e9b7f3a: Manually add all enum values to old apis.

* commit 'd95a8c2b1e537c054edc7324194b5d15daef2831':
  Manually add all enum values to old apis.
diff --git a/api/18.txt b/api/18.txt
index 02b95a0..ea3e1ae 100644
--- a/api/18.txt
+++ b/api/18.txt
@@ -27660,10 +27660,10 @@
     method public void setAlpha(float);
     method public void setTransformationType(int);
     method public java.lang.String toShortString();
-    field public static int TYPE_ALPHA;
-    field public static int TYPE_BOTH;
-    field public static int TYPE_IDENTITY;
-    field public static int TYPE_MATRIX;
+    field public static final int TYPE_ALPHA = 1; // 0x1
+    field public static final int TYPE_BOTH = 3; // 0x3
+    field public static final int TYPE_IDENTITY = 0; // 0x0
+    field public static final int TYPE_MATRIX = 2; // 0x2
     field protected float mAlpha;
     field protected android.graphics.Matrix mMatrix;
     field protected int mTransformationType;
diff --git a/current/android.jar b/current/android.jar
index 263520b..d70d557 100644
--- a/current/android.jar
+++ b/current/android.jar
Binary files differ
diff --git a/current/framework.aidl b/current/framework.aidl
index fdb392f..ebf4d83 100644
--- a/current/framework.aidl
+++ b/current/framework.aidl
@@ -12,6 +12,7 @@
 parcelable android.content.Intent;
 parcelable android.content.IntentSender;
 parcelable android.content.PeriodicSync;
+parcelable android.content.SyncRequest;
 parcelable android.content.SyncStats;
 parcelable android.content.res.Configuration;
 parcelable android.database.CursorWindow;
@@ -45,6 +46,7 @@
 parcelable android.location.Geofence;
 parcelable android.location.Location;
 parcelable android.location.LocationRequest;
+parcelable android.location.FusedBatchOptions;
 parcelable com.android.internal.location.ProviderProperties;
 parcelable com.android.internal.location.ProviderRequest;
 parcelable android.telephony.ServiceState;
diff --git a/current/uiautomator.jar b/current/uiautomator.jar
index 4ef880d..4c68e05 100644
--- a/current/uiautomator.jar
+++ b/current/uiautomator.jar
Binary files differ
diff --git a/renderscript/clang-include/avx2intrin.h b/renderscript/clang-include/avx2intrin.h
index 63b1efc..1887fc8 100644
--- a/renderscript/clang-include/avx2intrin.h
+++ b/renderscript/clang-include/avx2intrin.h
@@ -25,6 +25,9 @@
 #error "Never use <avx2intrin.h> directly; include <immintrin.h> instead."
 #endif
 
+#ifndef __AVX2INTRIN_H
+#define __AVX2INTRIN_H
+
 /* SSE4 Multiple Packed Sums of Absolute Difference.  */
 #define _mm256_mpsadbw_epu8(X, Y, M) __builtin_ia32_mpsadbw256((X), (Y), (M))
 
@@ -1199,3 +1202,5 @@
   (__m256i)__builtin_ia32_gatherq_q256((__v4di)_mm256_setzero_si256(), \
              (const __v4di *)__m, (__v4di)__i, \
              (__v4di)_mm256_set1_epi64x(-1), (s)); })
+
+#endif /* __AVX2INTRIN_H */
diff --git a/renderscript/clang-include/avxintrin.h b/renderscript/clang-include/avxintrin.h
index 412d284..50454f2 100644
--- a/renderscript/clang-include/avxintrin.h
+++ b/renderscript/clang-include/avxintrin.h
@@ -25,6 +25,9 @@
 #error "Never use <avxintrin.h> directly; include <immintrin.h> instead."
 #endif
 
+#ifndef __AVXINTRIN_H
+#define __AVXINTRIN_H
+
 typedef double __v4df __attribute__ ((__vector_size__ (32)));
 typedef float __v8sf __attribute__ ((__vector_size__ (32)));
 typedef long long __v4di __attribute__ ((__vector_size__ (32)));
@@ -1078,78 +1081,75 @@
 
 /* Cast between vector types */
 static __inline __m256 __attribute__((__always_inline__, __nodebug__))
-_mm256_castpd_ps(__m256d __in)
+_mm256_castpd_ps(__m256d __a)
 {
-  return (__m256)__in;
+  return (__m256)__a;
 }
 
 static __inline __m256i __attribute__((__always_inline__, __nodebug__))
-_mm256_castpd_si256(__m256d __in)
+_mm256_castpd_si256(__m256d __a)
 {
-  return (__m256i)__in;
+  return (__m256i)__a;
 }
 
 static __inline __m256d __attribute__((__always_inline__, __nodebug__))
-_mm256_castps_pd(__m256 __in)
+_mm256_castps_pd(__m256 __a)
 {
-  return (__m256d)__in;
+  return (__m256d)__a;
 }
 
 static __inline __m256i __attribute__((__always_inline__, __nodebug__))
-_mm256_castps_si256(__m256 __in)
+_mm256_castps_si256(__m256 __a)
 {
-  return (__m256i)__in;
+  return (__m256i)__a;
 }
 
 static __inline __m256 __attribute__((__always_inline__, __nodebug__))
-_mm256_castsi256_ps(__m256i __in)
+_mm256_castsi256_ps(__m256i __a)
 {
-  return (__m256)__in;
+  return (__m256)__a;
 }
 
 static __inline __m256d __attribute__((__always_inline__, __nodebug__))
-_mm256_castsi256_pd(__m256i __in)
+_mm256_castsi256_pd(__m256i __a)
 {
-  return (__m256d)__in;
+  return (__m256d)__a;
 }
 
 static __inline __m128d __attribute__((__always_inline__, __nodebug__))
-_mm256_castpd256_pd128(__m256d __in)
+_mm256_castpd256_pd128(__m256d __a)
 {
-  return __builtin_shufflevector(__in, __in, 0, 1);
+  return __builtin_shufflevector(__a, __a, 0, 1);
 }
 
 static __inline __m128 __attribute__((__always_inline__, __nodebug__))
-_mm256_castps256_ps128(__m256 __in)
+_mm256_castps256_ps128(__m256 __a)
 {
-  return __builtin_shufflevector(__in, __in, 0, 1, 2, 3);
+  return __builtin_shufflevector(__a, __a, 0, 1, 2, 3);
 }
 
 static __inline __m128i __attribute__((__always_inline__, __nodebug__))
-_mm256_castsi256_si128(__m256i __in)
+_mm256_castsi256_si128(__m256i __a)
 {
-  return __builtin_shufflevector(__in, __in, 0, 1);
+  return __builtin_shufflevector(__a, __a, 0, 1);
 }
 
 static __inline __m256d __attribute__((__always_inline__, __nodebug__))
-_mm256_castpd128_pd256(__m128d __in)
+_mm256_castpd128_pd256(__m128d __a)
 {
-  __m128d __zero = _mm_setzero_pd();
-  return __builtin_shufflevector(__in, __zero, 0, 1, 2, 2);
+  return __builtin_shufflevector(__a, __a, 0, 1, -1, -1);
 }
 
 static __inline __m256 __attribute__((__always_inline__, __nodebug__))
-_mm256_castps128_ps256(__m128 __in)
+_mm256_castps128_ps256(__m128 __a)
 {
-  __m128 __zero = _mm_setzero_ps();
-  return __builtin_shufflevector(__in, __zero, 0, 1, 2, 3, 4, 4, 4, 4);
+  return __builtin_shufflevector(__a, __a, 0, 1, 2, 3, -1, -1, -1, -1);
 }
 
 static __inline __m256i __attribute__((__always_inline__, __nodebug__))
-_mm256_castsi128_si256(__m128i __in)
+_mm256_castsi128_si256(__m128i __a)
 {
-  __m128i __zero = _mm_setzero_si128();
-  return __builtin_shufflevector(__in, __zero, 0, 1, 2, 2);
+  return __builtin_shufflevector(__a, __a, 0, 1, -1, -1);
 }
 
 /* SIMD load ops (unaligned) */
@@ -1220,3 +1220,5 @@
   __v128 = _mm256_extractf128_si256(__a, 1);
   __builtin_ia32_storedqu((char *)__addr_hi, (__v16qi)__v128);
 }
+
+#endif /* __AVXINTRIN_H */
diff --git a/renderscript/clang-include/cpuid.h b/renderscript/clang-include/cpuid.h
index 6d7d61d..8f12cae 100644
--- a/renderscript/clang-include/cpuid.h
+++ b/renderscript/clang-include/cpuid.h
@@ -25,10 +25,132 @@
 #error this header is for x86 only
 #endif
 
-static inline int __get_cpuid (unsigned int __level, unsigned int *__eax,
-                               unsigned int *__ebx, unsigned int *__ecx,
-                               unsigned int *__edx) {
-    __asm("cpuid" : "=a"(*__eax), "=b" (*__ebx), "=c"(*__ecx), "=d"(*__edx)
-                  : "0"(__level));
+/* Features in %ecx for level 1 */
+#define bit_SSE3        0x00000001
+#define bit_PCLMULQDQ   0x00000002
+#define bit_DTES64      0x00000004
+#define bit_MONITOR     0x00000008
+#define bit_DSCPL       0x00000010
+#define bit_VMX         0x00000020
+#define bit_SMX         0x00000040
+#define bit_EIST        0x00000080
+#define bit_TM2         0x00000100
+#define bit_SSSE3       0x00000200
+#define bit_CNXTID      0x00000400
+#define bit_FMA         0x00001000
+#define bit_CMPXCHG16B  0x00002000
+#define bit_xTPR        0x00004000
+#define bit_PDCM        0x00008000
+#define bit_PCID        0x00020000
+#define bit_DCA         0x00040000
+#define bit_SSE41       0x00080000
+#define bit_SSE42       0x00100000
+#define bit_x2APIC      0x00200000
+#define bit_MOVBE       0x00400000
+#define bit_POPCNT      0x00800000
+#define bit_TSCDeadline 0x01000000
+#define bit_AESNI       0x02000000
+#define bit_XSAVE       0x04000000
+#define bit_OSXSAVE     0x08000000
+#define bit_AVX         0x10000000
+#define bit_RDRAND      0x40000000
+
+/* Features in %edx for level 1 */
+#define bit_FPU         0x00000001
+#define bit_VME         0x00000002
+#define bit_DE          0x00000004
+#define bit_PSE         0x00000008
+#define bit_TSC         0x00000010
+#define bit_MSR         0x00000020
+#define bit_PAE         0x00000040
+#define bit_MCE         0x00000080
+#define bit_CX8         0x00000100
+#define bit_APIC        0x00000200
+#define bit_SEP         0x00000800
+#define bit_MTRR        0x00001000
+#define bit_PGE         0x00002000
+#define bit_MCA         0x00004000
+#define bit_CMOV        0x00008000
+#define bit_PAT         0x00010000
+#define bit_PSE36       0x00020000
+#define bit_PSN         0x00040000
+#define bit_CLFSH       0x00080000
+#define bit_DS          0x00200000
+#define bit_ACPI        0x00400000
+#define bit_MMX         0x00800000
+#define bit_FXSR        0x01000000
+#define bit_SSE         0x02000000
+#define bit_SSE2        0x04000000
+#define bit_SS          0x08000000
+#define bit_HTT         0x10000000
+#define bit_TM          0x20000000
+#define bit_PBE         0x80000000
+
+/* Features in %ebx for level 7 sub-leaf 0 */
+#define bit_FSGSBASE    0x00000001
+#define bit_SMEP        0x00000080
+#define bit_ENH_MOVSB   0x00000200
+
+/* PIC on i386 uses %ebx, so preserve it. */
+#if __i386__
+#define __cpuid(__level, __eax, __ebx, __ecx, __edx) \
+    __asm("  pushl  %%ebx\n" \
+          "  cpuid\n" \
+          "  mov    %%ebx,%1\n" \
+          "  popl   %%ebx" \
+        : "=a"(__eax), "=r" (__ebx), "=c"(__ecx), "=d"(__edx) \
+        : "0"(__level))
+
+#define __cpuid_count(__level, __count, __eax, __ebx, __ecx, __edx) \
+    __asm("  pushl  %%ebx\n" \
+          "  cpuid\n" \
+          "  mov    %%ebx,%1\n" \
+          "  popl   %%ebx" \
+        : "=a"(__eax), "=r" (__ebx), "=c"(__ecx), "=d"(__edx) \
+        : "0"(__level), "2"(__count))
+#else
+#define __cpuid(__level, __eax, __ebx, __ecx, __edx) \
+    __asm("cpuid" : "=a"(__eax), "=b" (__ebx), "=c"(__ecx), "=d"(__edx) \
+                  : "0"(__level))
+
+#define __cpuid_count(__level, __count, __eax, __ebx, __ecx, __edx) \
+    __asm("cpuid" : "=a"(__eax), "=b" (__ebx), "=c"(__ecx), "=d"(__edx) \
+                  : "0"(__level), "2"(__count))
+#endif
+
+static __inline int __get_cpuid (unsigned int __level, unsigned int *__eax,
+                                 unsigned int *__ebx, unsigned int *__ecx,
+                                 unsigned int *__edx) {
+    __cpuid(__level, *__eax, *__ebx, *__ecx, *__edx);
     return 1;
 }
+
+static __inline int __get_cpuid_max (unsigned int __level, unsigned int *__sig)
+{
+    unsigned int __eax, __ebx, __ecx, __edx;
+#if __i386__
+    int __cpuid_supported;
+
+    __asm("  pushfl\n"
+          "  popl   %%eax\n"
+          "  movl   %%eax,%%ecx\n"
+          "  xorl   $0x00200000,%%eax\n"
+          "  pushl  %%eax\n"
+          "  popfl\n"
+          "  pushfl\n"
+          "  popl   %%eax\n"
+          "  movl   $0,%0\n"
+          "  cmpl   %%eax,%%ecx\n"
+          "  je     1f\n"
+          "  movl   $1,%0\n"
+          "1:"
+        : "=r" (__cpuid_supported) : : "eax", "ecx");
+    if (!__cpuid_supported)
+        return 0;
+#endif
+
+    __cpuid(__level, __eax, __ebx, __ecx, __edx);
+    if (__sig)
+        *__sig = __ebx;
+    return __eax;
+}
diff --git a/renderscript/clang-include/emmintrin.h b/renderscript/clang-include/emmintrin.h
index e18fae4..f965dce 100644
--- a/renderscript/clang-include/emmintrin.h
+++ b/renderscript/clang-include/emmintrin.h
@@ -245,13 +245,15 @@
 static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
 _mm_cmpgt_sd(__m128d __a, __m128d __b)
 {
-  return (__m128d)__builtin_ia32_cmpsd(__b, __a, 1);
+  __m128d __c = __builtin_ia32_cmpsd(__b, __a, 1);
+  return (__m128d) { __c[0], __a[1] };
 }
 
 static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
 _mm_cmpge_sd(__m128d __a, __m128d __b)
 {
-  return (__m128d)__builtin_ia32_cmpsd(__b, __a, 2);
+  __m128d __c = __builtin_ia32_cmpsd(__b, __a, 2);
+  return (__m128d) { __c[0], __a[1] };
 }
 
 static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
@@ -287,13 +289,15 @@
 static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
 _mm_cmpngt_sd(__m128d __a, __m128d __b)
 {
-  return (__m128d)__builtin_ia32_cmpsd(__b, __a, 5);
+  __m128d __c = __builtin_ia32_cmpsd(__b, __a, 5);
+  return (__m128d) { __c[0], __a[1] };
 }
 
 static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
 _mm_cmpnge_sd(__m128d __a, __m128d __b)
 {
-  return (__m128d)__builtin_ia32_cmpsd(__b, __a, 6);
+  __m128d __c = __builtin_ia32_cmpsd(__b, __a, 6);
+  return (__m128d) { __c[0], __a[1] };
 }
 
 static __inline__ int __attribute__((__always_inline__, __nodebug__))
@@ -1379,39 +1383,39 @@
   __builtin_shufflevector(__a, __b, (i) & 1, (((i) & 2) >> 1) + 2); })
 
 static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
-_mm_castpd_ps(__m128d __in)
+_mm_castpd_ps(__m128d __a)
 {
-  return (__m128)__in;
+  return (__m128)__a;
 }
 
 static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
-_mm_castpd_si128(__m128d __in)
+_mm_castpd_si128(__m128d __a)
 {
-  return (__m128i)__in;
+  return (__m128i)__a;
 }
 
 static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
-_mm_castps_pd(__m128 __in)
+_mm_castps_pd(__m128 __a)
 {
-  return (__m128d)__in;
+  return (__m128d)__a;
 }
 
 static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
-_mm_castps_si128(__m128 __in)
+_mm_castps_si128(__m128 __a)
 {
-  return (__m128i)__in;
+  return (__m128i)__a;
 }
 
 static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
-_mm_castsi128_ps(__m128i __in)
+_mm_castsi128_ps(__m128i __a)
 {
-  return (__m128)__in;
+  return (__m128)__a;
 }
 
 static __inline__ __m128d __attribute__((__always_inline__, __nodebug__))
-_mm_castsi128_pd(__m128i __in)
+_mm_castsi128_pd(__m128i __a)
 {
-  return (__m128d)__in;
+  return (__m128d)__a;
 }
 
 static __inline__ void __attribute__((__always_inline__, __nodebug__))
diff --git a/renderscript/clang-include/immintrin.h b/renderscript/clang-include/immintrin.h
index cd733bf..fea7c3b 100644
--- a/renderscript/clang-include/immintrin.h
+++ b/renderscript/clang-include/immintrin.h
@@ -102,4 +102,13 @@
 #include <rtmintrin.h>
 #endif
 
+/* FIXME: check __HLE__ as well when HLE is supported. */
+#if defined (__RTM__)
+static __inline__ int __attribute__((__always_inline__, __nodebug__))
+_xtest(void)
+{
+  return __builtin_ia32_xtest();
+}
+#endif
+
 #endif /* __IMMINTRIN_H */
diff --git a/renderscript/clang-include/mm3dnow.h b/renderscript/clang-include/mm3dnow.h
index d5236f8..5242d99 100644
--- a/renderscript/clang-include/mm3dnow.h
+++ b/renderscript/clang-include/mm3dnow.h
@@ -25,6 +25,7 @@
 #define _MM3DNOW_H_INCLUDED
 
 #include <mmintrin.h>
+#include <prfchwintrin.h>
 
 typedef float __v2sf __attribute__((__vector_size__(8)));
 
diff --git a/renderscript/clang-include/prfchwintrin.h b/renderscript/clang-include/prfchwintrin.h
new file mode 100644
index 0000000..9825bd8
--- /dev/null
+++ b/renderscript/clang-include/prfchwintrin.h
@@ -0,0 +1,39 @@
+/*===---- prfchwintrin.h - PREFETCHW intrinsic -----------------------------===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===-----------------------------------------------------------------------===
+ */
+
+#if !defined(__X86INTRIN_H) && !defined(_MM3DNOW_H_INCLUDED)
+#error "Never use <prfchwintrin.h> directly; include <x86intrin.h> or <mm3dnow.h> instead."
+#endif
+
+#ifndef __PRFCHWINTRIN_H
+#define __PRFCHWINTRIN_H
+
+#if defined(__PRFCHW__) || defined(__3dNOW__)
+static __inline__ void __attribute__((__always_inline__, __nodebug__))
+_m_prefetchw(void *__P)
+{
+  __builtin_prefetch (__P, 1, 3 /* _MM_HINT_T0 */);
+}
+#endif
+
+#endif /* __PRFCHWINTRIN_H */
diff --git a/renderscript/clang-include/rdseedintrin.h b/renderscript/clang-include/rdseedintrin.h
new file mode 100644
index 0000000..0fef1fa
--- /dev/null
+++ b/renderscript/clang-include/rdseedintrin.h
@@ -0,0 +1,52 @@
+/*===---- rdseedintrin.h - RDSEED intrinsics -------------------------------===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===-----------------------------------------------------------------------===
+ */
+
+#ifndef __X86INTRIN_H
+#error "Never use <rdseedintrin.h> directly; include <x86intrin.h> instead."
+#endif
+
+#ifndef __RDSEEDINTRIN_H
+#define __RDSEEDINTRIN_H
+
+#ifdef __RDSEED__
+static __inline__ int __attribute__((__always_inline__, __nodebug__))
+_rdseed16_step(unsigned short *__p)
+{
+  return __builtin_ia32_rdseed16_step(__p);
+}
+
+static __inline__ int __attribute__((__always_inline__, __nodebug__))
+_rdseed32_step(unsigned int *__p)
+{
+  return __builtin_ia32_rdseed32_step(__p);
+}
+
+#ifdef __x86_64__
+static __inline__ int __attribute__((__always_inline__, __nodebug__))
+_rdseed64_step(unsigned long long *__p)
+{
+  return __builtin_ia32_rdseed64_step(__p);
+}
+#endif
+#endif /* __RDSEED__ */
+#endif /* __RDSEEDINTRIN_H */
diff --git a/renderscript/clang-include/rtmintrin.h b/renderscript/clang-include/rtmintrin.h
index bdc2b99..26149ca 100644
--- a/renderscript/clang-include/rtmintrin.h
+++ b/renderscript/clang-include/rtmintrin.h
@@ -25,6 +25,9 @@
 #error "Never use <rtmintrin.h> directly; include <immintrin.h> instead."
 #endif
 
+#ifndef __RTMINTRIN_H
+#define __RTMINTRIN_H
+
 #define _XBEGIN_STARTED   (~0u)
 #define _XABORT_EXPLICIT  (1 << 0)
 #define _XABORT_RETRY     (1 << 1)
@@ -47,3 +50,5 @@
 }
 
 #define _xabort(imm) __builtin_ia32_xabort((imm))
+
+#endif /* __RTMINTRIN_H */
diff --git a/renderscript/clang-include/stddef.h b/renderscript/clang-include/stddef.h
index ad5dc21..6a64d6d 100644
--- a/renderscript/clang-include/stddef.h
+++ b/renderscript/clang-include/stddef.h
@@ -26,17 +26,42 @@
 #ifndef __STDDEF_H
 #define __STDDEF_H
 
-#ifndef _PTRDIFF_T
+#if !defined(_PTRDIFF_T) || __has_feature(modules)
+/* Always define ptrdiff_t when modules are available. */
+#if !__has_feature(modules)
 #define _PTRDIFF_T
+#endif
 typedef __PTRDIFF_TYPE__ ptrdiff_t;
 #endif
-#ifndef _SIZE_T
+
+#if !defined(_SIZE_T) || __has_feature(modules)
+/* Always define size_t when modules are available. */
+#if !__has_feature(modules)
 #define _SIZE_T
+#endif
 typedef __SIZE_TYPE__ size_t;
 #endif
+
+/* ISO9899:2011 7.20 (C11 Annex K): Define rsize_t if __STDC_WANT_LIB_EXT1__ is
+ * enabled. */
+#if (defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1 && \
+     !defined(_RSIZE_T)) || __has_feature(modules)
+/* Always define rsize_t when modules are available. */
+#if !__has_feature(modules)
+#define _RSIZE_T
+#endif
+typedef __SIZE_TYPE__ rsize_t;
+#endif
+
 #ifndef __cplusplus
-#ifndef _WCHAR_T
+/* Always define wchar_t when modules are available. */
+#if !defined(_WCHAR_T) || __has_feature(modules)
+#if !__has_feature(modules)
 #define _WCHAR_T
+#if defined(_MSC_EXTENSIONS)
+#define _WCHAR_T_DEFINED
+#endif
+#endif
 typedef __WCHAR_TYPE__ wchar_t;
 #endif
 #endif
@@ -66,9 +91,12 @@
 /* Some C libraries expect to see a wint_t here. Others (notably MinGW) will use
 __WINT_TYPE__ directly; accommodate both by requiring __need_wint_t */
 #if defined(__need_wint_t)
-#if !defined(_WINT_T)
+/* Always define wint_t when modules are available. */
+#if !defined(_WINT_T) || __has_feature(modules)
+#if !__has_feature(modules)
 #define _WINT_T
+#endif
 typedef __WINT_TYPE__ wint_t;
-#endif /* _WINT_T */
+#endif
 #undef __need_wint_t
 #endif /* __need_wint_t */
diff --git a/renderscript/clang-include/stdint.h b/renderscript/clang-include/stdint.h
index 6f1a876..11529c0 100644
--- a/renderscript/clang-include/stdint.h
+++ b/renderscript/clang-include/stdint.h
@@ -30,7 +30,48 @@
  */
 #if __STDC_HOSTED__ && \
     defined(__has_include_next) && __has_include_next(<stdint.h>)
+
+// C99 7.18.3 Limits of other integer types
+//
+//  Footnote 219, 220: C++ implementations should define these macros only when
+//  __STDC_LIMIT_MACROS is defined before <stdint.h> is included.
+//
+//  Footnote 222: C++ implementations should define these macros only when
+//  __STDC_CONSTANT_MACROS is defined before <stdint.h> is included.
+//
+// C++11 [cstdint.syn]p2:
+//
+//  The macros defined by <cstdint> are provided unconditionally. In particular,
+//  the symbols __STDC_LIMIT_MACROS and __STDC_CONSTANT_MACROS (mentioned in
+//  footnotes 219, 220, and 222 in the C standard) play no role in C++.
+//
+// C11 removed the problematic footnotes.
+//
+// Work around this inconsistency by always defining those macros in C++ mode,
+// so that a C library implementation which follows the C99 standard can be
+// used in C++.
+# ifdef __cplusplus
+#  if !defined(__STDC_LIMIT_MACROS)
+#   define __STDC_LIMIT_MACROS
+#   define __STDC_LIMIT_MACROS_DEFINED_BY_CLANG
+#  endif
+#  if !defined(__STDC_CONSTANT_MACROS)
+#   define __STDC_CONSTANT_MACROS
+#   define __STDC_CONSTANT_MACROS_DEFINED_BY_CLANG
+#  endif
+# endif
+
 # include_next <stdint.h>
+
+# ifdef __STDC_LIMIT_MACROS_DEFINED_BY_CLANG
+#  undef __STDC_LIMIT_MACROS
+#  undef __STDC_LIMIT_MACROS_DEFINED_BY_CLANG
+# endif
+# ifdef __STDC_CONSTANT_MACROS_DEFINED_BY_CLANG
+#  undef __STDC_CONSTANT_MACROS
+#  undef __STDC_CONSTANT_MACROS_DEFINED_BY_CLANG
+# endif
+
 #else
 
 /* C99 7.18.1.1 Exact-width integer types.
@@ -626,6 +667,12 @@
 #define PTRDIFF_MAX  __INTN_MAX(__PTRDIFF_WIDTH__)
 #define    SIZE_MAX __UINTN_MAX(__SIZE_WIDTH__)
 
+/* ISO9899:2011 7.20 (C11 Annex K): Define RSIZE_MAX if __STDC_WANT_LIB_EXT1__
+ * is enabled. */
+#if defined(__STDC_WANT_LIB_EXT1__) && __STDC_WANT_LIB_EXT1__ >= 1
+#define   RSIZE_MAX            (SIZE_MAX >> 1)
+#endif
+
 /* C99 7.18.2.5 Limits of greatest-width integer types. */
 #define INTMAX_MIN   __INTN_MIN(__INTMAX_WIDTH__)
 #define INTMAX_MAX   __INTN_MAX(__INTMAX_WIDTH__)
diff --git a/renderscript/clang-include/tgmath.h b/renderscript/clang-include/tgmath.h
index 4fa1cf7..a48e267 100644
--- a/renderscript/clang-include/tgmath.h
+++ b/renderscript/clang-include/tgmath.h
@@ -1340,15 +1340,15 @@
 
 // creal
 
-static float _Complex
+static float
     _TG_ATTRS
     __tg_creal(float __x) {return __x;}
 
-static double _Complex
+static double
     _TG_ATTRS
     __tg_creal(double __x) {return __x;}
 
-static long double _Complex
+static long double
     _TG_ATTRS
     __tg_creal(long double __x) {return __x;}
 
diff --git a/renderscript/clang-include/x86intrin.h b/renderscript/clang-include/x86intrin.h
index 68ce106..94fbe2f 100644
--- a/renderscript/clang-include/x86intrin.h
+++ b/renderscript/clang-include/x86intrin.h
@@ -46,6 +46,14 @@
 #include <popcntintrin.h>
 #endif
 
+#ifdef __RDSEED__
+#include <rdseedintrin.h>
+#endif
+
+#ifdef __PRFCHW__
+#include <prfchwintrin.h>
+#endif
+
 #ifdef __SSE4A__
 #include <ammintrin.h>
 #endif
diff --git a/renderscript/clang-include/xmmintrin.h b/renderscript/clang-include/xmmintrin.h
index b3b23cb..c68d3ed 100644
--- a/renderscript/clang-include/xmmintrin.h
+++ b/renderscript/clang-include/xmmintrin.h
@@ -218,7 +218,9 @@
 static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
 _mm_cmpgt_ss(__m128 __a, __m128 __b)
 {
-  return (__m128)__builtin_ia32_cmpss(__b, __a, 1);
+  return (__m128)__builtin_shufflevector(__a,
+                                         __builtin_ia32_cmpss(__b, __a, 1),
+                                         4, 1, 2, 3);
 }
 
 static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
@@ -230,7 +232,9 @@
 static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
 _mm_cmpge_ss(__m128 __a, __m128 __b)
 {
-  return (__m128)__builtin_ia32_cmpss(__b, __a, 2);
+  return (__m128)__builtin_shufflevector(__a,
+                                         __builtin_ia32_cmpss(__b, __a, 2),
+                                         4, 1, 2, 3);
 }
 
 static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
@@ -278,7 +282,9 @@
 static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
 _mm_cmpngt_ss(__m128 __a, __m128 __b)
 {
-  return (__m128)__builtin_ia32_cmpss(__b, __a, 5);
+  return (__m128)__builtin_shufflevector(__a,
+                                         __builtin_ia32_cmpss(__b, __a, 5),
+                                         4, 1, 2, 3);
 }
 
 static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
@@ -290,7 +296,9 @@
 static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
 _mm_cmpnge_ss(__m128 __a, __m128 __b)
 {
-  return (__m128)__builtin_ia32_cmpss(__b, __a, 6);
+  return (__m128)__builtin_shufflevector(__a,
+                                         __builtin_ia32_cmpss(__b, __a, 6),
+                                         4, 1, 2, 3);
 }
 
 static __inline__ __m128 __attribute__((__always_inline__, __nodebug__))
diff --git a/renderscript/clang-include/xopintrin.h b/renderscript/clang-include/xopintrin.h
index d107be4..cc94ca0 100644
--- a/renderscript/clang-include/xopintrin.h
+++ b/renderscript/clang-include/xopintrin.h
@@ -1,4 +1,4 @@
-/*===---- xopintrin.h - FMA4 intrinsics ------------------------------------===
+/*===---- xopintrin.h - XOP intrinsics -------------------------------------===
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -22,7 +22,7 @@
  */
 
 #ifndef __X86INTRIN_H
-#error "Never use <fma4intrin.h> directly; include <x86intrin.h> instead."
+#error "Never use <xopintrin.h> directly; include <x86intrin.h> instead."
 #endif
 
 #ifndef __XOPINTRIN_H
@@ -342,6 +342,399 @@
   __m128i __B = (B); \
   (__m128i)__builtin_ia32_vpcomq((__v2di)__A, (__v2di)__B, (N)); })
 
+#define _MM_PCOMCTRL_LT    0
+#define _MM_PCOMCTRL_LE    1
+#define _MM_PCOMCTRL_GT    2
+#define _MM_PCOMCTRL_GE    3
+#define _MM_PCOMCTRL_EQ    4
+#define _MM_PCOMCTRL_NEQ   5
+#define _MM_PCOMCTRL_FALSE 6
+#define _MM_PCOMCTRL_TRUE  7
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comlt_epu8(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_LT);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comle_epu8(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_LE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comgt_epu8(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_GT);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comge_epu8(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_GE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comeq_epu8(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_EQ);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comneq_epu8(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_NEQ);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comfalse_epu8(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_FALSE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comtrue_epu8(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu8(__A, __B, _MM_PCOMCTRL_TRUE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comlt_epu16(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_LT);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comle_epu16(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_LE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comgt_epu16(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_GT);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comge_epu16(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_GE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comeq_epu16(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_EQ);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comneq_epu16(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_NEQ);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comfalse_epu16(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_FALSE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comtrue_epu16(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu16(__A, __B, _MM_PCOMCTRL_TRUE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comlt_epu32(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_LT);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comle_epu32(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_LE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comgt_epu32(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_GT);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comge_epu32(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_GE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comeq_epu32(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_EQ);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comneq_epu32(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_NEQ);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comfalse_epu32(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_FALSE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comtrue_epu32(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu32(__A, __B, _MM_PCOMCTRL_TRUE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comlt_epu64(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_LT);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comle_epu64(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_LE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comgt_epu64(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_GT);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comge_epu64(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_GE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comeq_epu64(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_EQ);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comneq_epu64(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_NEQ);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comfalse_epu64(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_FALSE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comtrue_epu64(__m128i __A, __m128i __B)
+{
+  return _mm_com_epu64(__A, __B, _MM_PCOMCTRL_TRUE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comlt_epi8(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_LT);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comle_epi8(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_LE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comgt_epi8(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_GT);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comge_epi8(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_GE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comeq_epi8(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_EQ);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comneq_epi8(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_NEQ);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comfalse_epi8(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_FALSE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comtrue_epi8(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi8(__A, __B, _MM_PCOMCTRL_TRUE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comlt_epi16(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_LT);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comle_epi16(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_LE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comgt_epi16(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_GT);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comge_epi16(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_GE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comeq_epi16(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_EQ);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comneq_epi16(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_NEQ);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comfalse_epi16(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_FALSE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comtrue_epi16(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi16(__A, __B, _MM_PCOMCTRL_TRUE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comlt_epi32(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_LT);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comle_epi32(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_LE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comgt_epi32(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_GT);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comge_epi32(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_GE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comeq_epi32(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_EQ);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comneq_epi32(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_NEQ);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comfalse_epi32(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_FALSE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comtrue_epi32(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi32(__A, __B, _MM_PCOMCTRL_TRUE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comlt_epi64(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_LT);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comle_epi64(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_LE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comgt_epi64(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_GT);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comge_epi64(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_GE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comeq_epi64(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_EQ);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comneq_epi64(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_NEQ);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comfalse_epi64(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_FALSE);
+}
+
+static __inline__ __m128i __attribute__((__always_inline__, __nodebug__))
+_mm_comtrue_epi64(__m128i __A, __m128i __B)
+{
+  return _mm_com_epi64(__A, __B, _MM_PCOMCTRL_TRUE);
+}
+
 #define _mm_permute2_pd(X, Y, C, I) __extension__ ({ \
   __m128d __X = (X); \
   __m128d __Y = (Y); \
diff --git a/renderscript/include/rs_allocation.rsh b/renderscript/include/rs_allocation.rsh
index 0f5e79d..7dffa54 100644
--- a/renderscript/include/rs_allocation.rsh
+++ b/renderscript/include/rs_allocation.rsh
@@ -134,17 +134,17 @@
  * Extract a single element from an allocation.
  */
 extern const void * __attribute__((overloadable))
-    rsGetElementAt(rs_allocation, uint32_t x);
+    rsGetElementAt(rs_allocation a, uint32_t x);
 /**
  * \overload
  */
 extern const void * __attribute__((overloadable))
-    rsGetElementAt(rs_allocation, uint32_t x, uint32_t y);
+    rsGetElementAt(rs_allocation a, uint32_t x, uint32_t y);
 /**
  * \overload
  */
 extern const void * __attribute__((overloadable))
-    rsGetElementAt(rs_allocation, uint32_t x, uint32_t y, uint32_t z);
+    rsGetElementAt(rs_allocation a, uint32_t x, uint32_t y, uint32_t z);
 
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 18))
diff --git a/renderscript/include/rs_cl.rsh b/renderscript/include/rs_cl.rsh
index 788aea8..2ff5d8b 100644
--- a/renderscript/include/rs_cl.rsh
+++ b/renderscript/include/rs_cl.rsh
@@ -25,11 +25,11 @@
 
 // Conversions
 #define CVT_FUNC_2(typeout, typein)                             \
-_RS_RUNTIME typeout##2 __attribute__((overloadable))            \
+_RS_RUNTIME typeout##2 __attribute__((const, overloadable))     \
         convert_##typeout##2(typein##2 v);                      \
-_RS_RUNTIME typeout##3 __attribute__((overloadable))            \
+_RS_RUNTIME typeout##3 __attribute__((const, overloadable))     \
         convert_##typeout##3(typein##3 v);                      \
-_RS_RUNTIME typeout##4 __attribute__((overloadable))            \
+_RS_RUNTIME typeout##4 __attribute__((const, overloadable))     \
         convert_##typeout##4(typein##4 v);
 
 
@@ -92,98 +92,119 @@
 
 // Float ops, 6.11.2
 
-#define FN_FUNC_FN(fnc)                                         \
-_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v); \
-_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v); \
-_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v);
+#ifdef DOXYGEN
 
-#define F_FUNC_FN(fnc)                                          \
-_RS_RUNTIME float __attribute__((overloadable)) fnc(float2 v);  \
-_RS_RUNTIME float __attribute__((overloadable)) fnc(float3 v);  \
-_RS_RUNTIME float __attribute__((overloadable)) fnc(float4 v);
+#define FN_FUNC_FN(fnc)
+#define F_FUNC_FN(fnc)
+#define IN_FUNC_FN(fnc)
+#define FN_FUNC_FN_FN(fnc)
+#define F_FUNC_FN_FN(fnc)
+#define FN_FUNC_FN_F(fnc)
+#define FN_FUNC_FN_IN(fnc)
+#define FN_FUNC_FN_I(fnc)
+#define FN_FUNC_FN_PFN(fnc)
+#define FN_FUNC_FN_PIN(fnc)
+#define FN_FUNC_FN_FN_FN(fnc)
+#define FN_FUNC_FN_FN_F(fnc)
+#define FN_FUNC_FN_F_F(fnc)
+#define FN_FUNC_FN_FN_PIN(fnc)
 
-#define IN_FUNC_FN(fnc)                                         \
-_RS_RUNTIME int2 __attribute__((overloadable)) fnc(float2 v);   \
-_RS_RUNTIME int3 __attribute__((overloadable)) fnc(float3 v);   \
-_RS_RUNTIME int4 __attribute__((overloadable)) fnc(float4 v);
+#else
 
-#define FN_FUNC_FN_FN(fnc)                                                  \
-_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, float2 v2); \
-_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, float3 v2); \
-_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, float4 v2);
+#define FN_FUNC_FN(fnc)                                                \
+_RS_RUNTIME float2 __attribute__((const, overloadable)) fnc(float2 v); \
+_RS_RUNTIME float3 __attribute__((const, overloadable)) fnc(float3 v); \
+_RS_RUNTIME float4 __attribute__((const, overloadable)) fnc(float4 v);
 
-#define F_FUNC_FN_FN(fnc)                                                   \
-_RS_RUNTIME float __attribute__((overloadable)) fnc(float2 v1, float2 v2);  \
-_RS_RUNTIME float __attribute__((overloadable)) fnc(float3 v1, float3 v2);  \
-_RS_RUNTIME float __attribute__((overloadable)) fnc(float4 v1, float4 v2);
+#define F_FUNC_FN(fnc)                                                \
+_RS_RUNTIME float __attribute__((const, overloadable)) fnc(float2 v); \
+_RS_RUNTIME float __attribute__((const, overloadable)) fnc(float3 v); \
+_RS_RUNTIME float __attribute__((const, overloadable)) fnc(float4 v);
 
-#define FN_FUNC_FN_F(fnc)                                                   \
-_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, float v2);  \
-_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, float v2);  \
-_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, float v2);
+#define IN_FUNC_FN(fnc)                                              \
+_RS_RUNTIME int2 __attribute__((const, overloadable)) fnc(float2 v); \
+_RS_RUNTIME int3 __attribute__((const, overloadable)) fnc(float3 v); \
+_RS_RUNTIME int4 __attribute__((const, overloadable)) fnc(float4 v);
 
-#define FN_FUNC_FN_IN(fnc)                                                  \
-_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, int2 v2);   \
-_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, int3 v2);   \
-_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, int4 v2);   \
+#define FN_FUNC_FN_FN(fnc)                                                         \
+_RS_RUNTIME float2 __attribute__((const, overloadable)) fnc(float2 v1, float2 v2); \
+_RS_RUNTIME float3 __attribute__((const, overloadable)) fnc(float3 v1, float3 v2); \
+_RS_RUNTIME float4 __attribute__((const, overloadable)) fnc(float4 v1, float4 v2);
 
-#define FN_FUNC_FN_I(fnc)                                                   \
-_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, int v2);    \
-_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, int v2);    \
-_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, int v2);
+#define F_FUNC_FN_FN(fnc)                                                         \
+_RS_RUNTIME float __attribute__((const, overloadable)) fnc(float2 v1, float2 v2); \
+_RS_RUNTIME float __attribute__((const, overloadable)) fnc(float3 v1, float3 v2); \
+_RS_RUNTIME float __attribute__((const, overloadable)) fnc(float4 v1, float4 v2);
 
-#define FN_FUNC_FN_PFN(fnc)                         \
-_RS_RUNTIME float2 __attribute__((overloadable))    \
-        fnc(float2 v1, float2 *v2);                 \
-_RS_RUNTIME float3 __attribute__((overloadable))    \
-        fnc(float3 v1, float3 *v2);                 \
-_RS_RUNTIME float4 __attribute__((overloadable))    \
+#define FN_FUNC_FN_F(fnc)                                                         \
+_RS_RUNTIME float2 __attribute__((const, overloadable)) fnc(float2 v1, float v2); \
+_RS_RUNTIME float3 __attribute__((const, overloadable)) fnc(float3 v1, float v2); \
+_RS_RUNTIME float4 __attribute__((const, overloadable)) fnc(float4 v1, float v2);
+
+#define FN_FUNC_FN_IN(fnc)                                                       \
+_RS_RUNTIME float2 __attribute__((const, overloadable)) fnc(float2 v1, int2 v2); \
+_RS_RUNTIME float3 __attribute__((const, overloadable)) fnc(float3 v1, int3 v2); \
+_RS_RUNTIME float4 __attribute__((const, overloadable)) fnc(float4 v1, int4 v2);
+
+#define FN_FUNC_FN_I(fnc)                                                       \
+_RS_RUNTIME float2 __attribute__((const, overloadable)) fnc(float2 v1, int v2); \
+_RS_RUNTIME float3 __attribute__((const, overloadable)) fnc(float3 v1, int v2); \
+_RS_RUNTIME float4 __attribute__((const, overloadable)) fnc(float4 v1, int v2);
+
+#define FN_FUNC_FN_PFN(fnc)                            \
+_RS_RUNTIME float2 __attribute__((pure, overloadable)) \
+        fnc(float2 v1, float2 *v2);                    \
+_RS_RUNTIME float3 __attribute__((pure, overloadable)) \
+        fnc(float3 v1, float3 *v2);                    \
+_RS_RUNTIME float4 __attribute__((pure, overloadable)) \
         fnc(float4 v1, float4 *v2);
 
-#define FN_FUNC_FN_PIN(fnc)                                                 \
-_RS_RUNTIME float2 __attribute__((overloadable)) fnc(float2 v1, int2 *v2);  \
-_RS_RUNTIME float3 __attribute__((overloadable)) fnc(float3 v1, int3 *v2);  \
-_RS_RUNTIME float4 __attribute__((overloadable)) fnc(float4 v1, int4 *v2);
+#define FN_FUNC_FN_PIN(fnc)                                                      \
+_RS_RUNTIME float2 __attribute__((pure, overloadable)) fnc(float2 v1, int2 *v2); \
+_RS_RUNTIME float3 __attribute__((pure, overloadable)) fnc(float3 v1, int3 *v2); \
+_RS_RUNTIME float4 __attribute__((pure, overloadable)) fnc(float4 v1, int4 *v2);
 
-#define FN_FUNC_FN_FN_FN(fnc)                       \
-_RS_RUNTIME float2 __attribute__((overloadable))    \
-        fnc(float2 v1, float2 v2, float2 v3);       \
-_RS_RUNTIME float3 __attribute__((overloadable))    \
-        fnc(float3 v1, float3 v2, float3 v3);       \
-_RS_RUNTIME float4 __attribute__((overloadable))    \
+#define FN_FUNC_FN_FN_FN(fnc)                           \
+_RS_RUNTIME float2 __attribute__((const, overloadable)) \
+        fnc(float2 v1, float2 v2, float2 v3);           \
+_RS_RUNTIME float3 __attribute__((const, overloadable)) \
+        fnc(float3 v1, float3 v2, float3 v3);           \
+_RS_RUNTIME float4 __attribute__((const, overloadable)) \
         fnc(float4 v1, float4 v2, float4 v3);
 
-#define FN_FUNC_FN_FN_F(fnc)                        \
-_RS_RUNTIME float2 __attribute__((overloadable))    \
-        fnc(float2 v1, float2 v2, float v3);        \
-_RS_RUNTIME float3 __attribute__((overloadable))    \
-        fnc(float3 v1, float3 v2, float v3);        \
-_RS_RUNTIME float4 __attribute__((overloadable))    \
+#define FN_FUNC_FN_FN_F(fnc)                            \
+_RS_RUNTIME float2 __attribute__((const, overloadable)) \
+        fnc(float2 v1, float2 v2, float v3);            \
+_RS_RUNTIME float3 __attribute__((const, overloadable)) \
+        fnc(float3 v1, float3 v2, float v3);            \
+_RS_RUNTIME float4 __attribute__((const, overloadable)) \
         fnc(float4 v1, float4 v2, float v3);
 
-#define FN_FUNC_FN_F_F(fnc)                         \
-_RS_RUNTIME float2 __attribute__((overloadable))    \
-        fnc(float2 v1, float v2, float v3);         \
-_RS_RUNTIME float3 __attribute__((overloadable))    \
-        fnc(float3 v1, float v2, float v3);         \
-_RS_RUNTIME float4 __attribute__((overloadable))    \
+#define FN_FUNC_FN_F_F(fnc)                             \
+_RS_RUNTIME float2 __attribute__((const, overloadable)) \
+        fnc(float2 v1, float v2, float v3);             \
+_RS_RUNTIME float3 __attribute__((const, overloadable)) \
+        fnc(float3 v1, float v2, float v3);             \
+_RS_RUNTIME float4 __attribute__((const, overloadable)) \
         fnc(float4 v1, float v2, float v3);
 
-#define FN_FUNC_FN_FN_PIN(fnc)                      \
-_RS_RUNTIME float2 __attribute__((overloadable))    \
-        fnc(float2 v1, float2 v2, int2 *v3);        \
-_RS_RUNTIME float3 __attribute__((overloadable))    \
-        fnc(float3 v1, float3 v2, int3 *v3);        \
-_RS_RUNTIME float4 __attribute__((overloadable))    \
+#define FN_FUNC_FN_FN_PIN(fnc)                         \
+_RS_RUNTIME float2 __attribute__((pure, overloadable)) \
+        fnc(float2 v1, float2 v2, int2 *v3);           \
+_RS_RUNTIME float3 __attribute__((pure, overloadable)) \
+        fnc(float3 v1, float3 v2, int3 *v3);           \
+_RS_RUNTIME float4 __attribute__((pure, overloadable)) \
         fnc(float4 v1, float4 v2, int4 *v3);
 
+#endif  // DOXYGEN
+
 
 /**
  * Return the inverse cosine.
  *
  * Supports float, float2, float3, float4
  */
-extern float __attribute__((overloadable)) acos(float);
+extern float __attribute__((const, overloadable)) acos(float);
 FN_FUNC_FN(acos)
 
 /**
@@ -191,7 +212,7 @@
  *
  * Supports float, float2, float3, float4
  */
-extern float __attribute__((overloadable)) acosh(float);
+extern float __attribute__((const, overloadable)) acosh(float);
 FN_FUNC_FN(acosh)
 
 /**
@@ -199,7 +220,7 @@
  *
  * Supports float, float2, float3, float4
  */
-_RS_RUNTIME float __attribute__((overloadable)) acospi(float v);
+_RS_RUNTIME float __attribute__((const, overloadable)) acospi(float v);
 FN_FUNC_FN(acospi)
 
 /**
@@ -207,7 +228,7 @@
  *
  * Supports float, float2, float3, float4
  */
-extern float __attribute__((overloadable)) asin(float);
+extern float __attribute__((const, overloadable)) asin(float);
 FN_FUNC_FN(asin)
 
 /**
@@ -215,7 +236,7 @@
  *
  * Supports float, float2, float3, float4
  */
-extern float __attribute__((overloadable)) asinh(float);
+extern float __attribute__((const, overloadable)) asinh(float);
 FN_FUNC_FN(asinh)
 
 
@@ -224,7 +245,7 @@
  *
  * Supports float, float2, float3, float4
  */
-_RS_RUNTIME float __attribute__((overloadable)) asinpi(float v);
+_RS_RUNTIME float __attribute__((const, overloadable)) asinpi(float v);
 FN_FUNC_FN(asinpi)
 
 /**
@@ -232,7 +253,7 @@
  *
  * Supports float, float2, float3, float4
  */
-extern float __attribute__((overloadable)) atan(float);
+extern float __attribute__((const, overloadable)) atan(float);
 FN_FUNC_FN(atan)
 
 /**
@@ -244,7 +265,7 @@
  * @param y
  * @param x
  */
-extern float __attribute__((overloadable)) atan2(float y, float x);
+extern float __attribute__((const, overloadable)) atan2(float y, float x);
 FN_FUNC_FN_FN(atan2)
 
 /**
@@ -252,7 +273,7 @@
  *
  * Supports float, float2, float3, float4
  */
-extern float __attribute__((overloadable)) atanh(float);
+extern float __attribute__((const, overloadable)) atanh(float);
 FN_FUNC_FN(atanh)
 
 /**
@@ -260,7 +281,7 @@
  *
  * Supports float, float2, float3, float4
  */
-_RS_RUNTIME float __attribute__((overloadable)) atanpi(float v);
+_RS_RUNTIME float __attribute__((const, overloadable)) atanpi(float v);
 FN_FUNC_FN(atanpi)
 
 /**
@@ -272,7 +293,7 @@
  * @param y
  * @param x
  */
-_RS_RUNTIME float __attribute__((overloadable)) atan2pi(float y, float x);
+_RS_RUNTIME float __attribute__((const, overloadable)) atan2pi(float y, float x);
 FN_FUNC_FN_FN(atan2pi)
 
 
@@ -281,7 +302,7 @@
  *
  * Supports float, float2, float3, float4.
  */
-extern float __attribute__((overloadable)) cbrt(float);
+extern float __attribute__((const, overloadable)) cbrt(float);
 FN_FUNC_FN(cbrt)
 
 /**
@@ -289,7 +310,7 @@
  *
  * Supports float, float2, float3, float4.
  */
-extern float __attribute__((overloadable)) ceil(float);
+extern float __attribute__((const, overloadable)) ceil(float);
 FN_FUNC_FN(ceil)
 
 /**
@@ -301,7 +322,7 @@
  * @param x
  * @param y
  */
-extern float __attribute__((overloadable)) copysign(float x, float y);
+extern float __attribute__((const, overloadable)) copysign(float x, float y);
 FN_FUNC_FN_FN(copysign)
 
 /**
@@ -309,7 +330,7 @@
  *
  * Supports float, float2, float3, float4.
  */
-extern float __attribute__((overloadable)) cos(float);
+extern float __attribute__((const, overloadable)) cos(float);
 FN_FUNC_FN(cos)
 
 /**
@@ -317,7 +338,7 @@
  *
  * Supports float, float2, float3, float4.
  */
-extern float __attribute__((overloadable)) cosh(float);
+extern float __attribute__((const, overloadable)) cosh(float);
 FN_FUNC_FN(cosh)
 
 /**
@@ -325,7 +346,7 @@
  *
  * Supports float, float2, float3, float4.
  */
-_RS_RUNTIME float __attribute__((overloadable)) cospi(float v);
+_RS_RUNTIME float __attribute__((const, overloadable)) cospi(float v);
 FN_FUNC_FN(cospi)
 
 /**
@@ -333,7 +354,7 @@
  *
  * Supports float, float2, float3, float4.
  */
-extern float __attribute__((overloadable)) erfc(float);
+extern float __attribute__((const, overloadable)) erfc(float);
 FN_FUNC_FN(erfc)
 
 /**
@@ -341,7 +362,7 @@
  *
  * Supports float, float2, float3, float4.
  */
-extern float __attribute__((overloadable)) erf(float);
+extern float __attribute__((const, overloadable)) erf(float);
 FN_FUNC_FN(erf)
 
 /**
@@ -349,7 +370,7 @@
  *
  * Supports float, float2, float3, float4.
  */
-extern float __attribute__((overloadable)) exp(float);
+extern float __attribute__((const, overloadable)) exp(float);
 FN_FUNC_FN(exp)
 
 /**
@@ -357,7 +378,7 @@
  *
  * Supports float, float2, float3, float4.
  */
-extern float __attribute__((overloadable)) exp2(float);
+extern float __attribute__((const, overloadable)) exp2(float);
 FN_FUNC_FN(exp2)
 
 /**
@@ -366,7 +387,7 @@
  * Supports float, float2, float3, float4. Both arguments must be of the same
  * type.
  */
-extern float __attribute__((overloadable)) pow(float x, float y);
+extern float __attribute__((const, overloadable)) pow(float x, float y);
 FN_FUNC_FN_FN(pow)
 
 /**
@@ -374,7 +395,7 @@
  *
  * Supports float, float2, float3, float4.
  */
-_RS_RUNTIME float __attribute__((overloadable)) exp10(float v);
+_RS_RUNTIME float __attribute__((const, overloadable)) exp10(float v);
 FN_FUNC_FN(exp10)
 
 /**
@@ -382,7 +403,7 @@
  *
  * Supports float, float2, float3, float4.
  */
-extern float __attribute__((overloadable)) expm1(float);
+extern float __attribute__((const, overloadable)) expm1(float);
 FN_FUNC_FN(expm1)
 
 /**
@@ -390,7 +411,7 @@
  *
  * Supports float, float2, float3, float4.
  */
-extern float __attribute__((overloadable)) fabs(float);
+extern float __attribute__((const, overloadable)) fabs(float);
 FN_FUNC_FN(fabs)
 
 /**
@@ -399,7 +420,7 @@
  * Supports float, float2, float3, float4.  Both arguments must be of the same
  * type.
  */
-extern float __attribute__((overloadable)) fdim(float, float);
+extern float __attribute__((const, overloadable)) fdim(float, float);
 FN_FUNC_FN_FN(fdim)
 
 /**
@@ -407,7 +428,7 @@
  *
  * Supports float, float2, float3, float4.
  */
-extern float __attribute__((overloadable)) floor(float);
+extern float __attribute__((const, overloadable)) floor(float);
 FN_FUNC_FN(floor)
 
 /**
@@ -415,7 +436,7 @@
  *
  * Supports float, float2, float3, float4.
  */
-extern float __attribute__((overloadable)) fma(float a, float b, float c);
+extern float __attribute__((const, overloadable)) fma(float a, float b, float c);
 FN_FUNC_FN_FN_FN(fma)
 
 /**
@@ -425,7 +446,7 @@
  * @param x: may be float, float2, float3, float4
  * @param y: may be float or vector.  If vector must match type of x.
  */
-extern float __attribute__((overloadable)) fmax(float x, float y);
+extern float __attribute__((const, overloadable)) fmax(float x, float y);
 FN_FUNC_FN_FN(fmax);
 FN_FUNC_FN_F(fmax);
 
@@ -435,7 +456,7 @@
  * @param x: may be float, float2, float3, float4
  * @param y: may be float or vector.  If vector must match type of x.
  */
-extern float __attribute__((overloadable)) fmin(float x, float y);
+extern float __attribute__((const, overloadable)) fmin(float x, float y);
 FN_FUNC_FN_FN(fmin);
 FN_FUNC_FN_F(fmin);
 
@@ -444,7 +465,7 @@
  *
  * Supports float, float2, float3, float4.
  */
-extern float __attribute__((overloadable)) fmod(float x, float y);
+extern float __attribute__((const, overloadable)) fmod(float x, float y);
 FN_FUNC_FN_FN(fmod)
 
 /**
@@ -453,7 +474,7 @@
  * @param iptr  iptr[0] will be set to the floor of the input value.
  * Supports float, float2, float3, float4.
  */
-_RS_RUNTIME float __attribute__((overloadable)) fract(float v, float *iptr);
+_RS_RUNTIME float __attribute__((pure, overloadable)) fract(float v, float *iptr);
 FN_FUNC_FN_PFN(fract)
 
 /**
@@ -461,22 +482,22 @@
  *
  * Supports float, float2, float3, float4.
  */
-static inline float __attribute__((overloadable)) fract(float v) {
+static inline float __attribute__((const, overloadable)) fract(float v) {
     float unused;
     return fract(v, &unused);
 }
 
-static inline float2 __attribute__((overloadable)) fract(float2 v) {
+static inline float2 __attribute__((const, overloadable)) fract(float2 v) {
     float2 unused;
     return fract(v, &unused);
 }
 
-static inline float3 __attribute__((overloadable)) fract(float3 v) {
+static inline float3 __attribute__((const, overloadable)) fract(float3 v) {
     float3 unused;
     return fract(v, &unused);
 }
 
-static inline float4 __attribute__((overloadable)) fract(float4 v) {
+static inline float4 __attribute__((const, overloadable)) fract(float4 v) {
     float4 unused;
     return fract(v, &unused);
 }
@@ -487,7 +508,7 @@
  * @param v Supports float, float2, float3, float4.
  * @param iptr  Must have the same vector size as v.
  */
-extern float __attribute__((overloadable)) frexp(float v, int *iptr);
+extern float __attribute__((pure, overloadable)) frexp(float v, int *iptr);
 FN_FUNC_FN_PIN(frexp)
 
 /**
@@ -495,7 +516,7 @@
  *
  * Supports float, float2, float3, float4.
  */
-extern float __attribute__((overloadable)) hypot(float x, float y);
+extern float __attribute__((const, overloadable)) hypot(float x, float y);
 FN_FUNC_FN_FN(hypot)
 
 /**
@@ -503,7 +524,7 @@
  *
  * Supports 1,2,3,4 components
  */
-extern int __attribute__((overloadable)) ilogb(float);
+extern int __attribute__((const, overloadable)) ilogb(float);
 IN_FUNC_FN(ilogb)
 
 /**
@@ -512,7 +533,7 @@
  * @param x Supports 1,2,3,4 components
  * @param y Supports single component or matching vector.
  */
-extern float __attribute__((overloadable)) ldexp(float x, int y);
+extern float __attribute__((const, overloadable)) ldexp(float x, int y);
 FN_FUNC_FN_IN(ldexp)
 FN_FUNC_FN_I(ldexp)
 
@@ -521,7 +542,7 @@
  *
  * Supports 1,2,3,4 components
  */
-extern float __attribute__((overloadable)) lgamma(float);
+extern float __attribute__((const, overloadable)) lgamma(float);
 FN_FUNC_FN(lgamma)
 
 /**
@@ -530,7 +551,7 @@
  * @param x Supports 1,2,3,4 components
  * @param y Supports matching vector.
  */
-extern float __attribute__((overloadable)) lgamma(float x, int* y);
+extern float __attribute__((pure, overloadable)) lgamma(float x, int* y);
 FN_FUNC_FN_PIN(lgamma)
 
 /**
@@ -538,7 +559,7 @@
  *
  * Supports 1,2,3,4 components
  */
-extern float __attribute__((overloadable)) log(float);
+extern float __attribute__((const, overloadable)) log(float);
 FN_FUNC_FN(log)
 
 /**
@@ -546,7 +567,7 @@
  *
  * Supports 1,2,3,4 components
  */
-extern float __attribute__((overloadable)) log10(float);
+extern float __attribute__((const, overloadable)) log10(float);
 FN_FUNC_FN(log10)
 
 /**
@@ -554,7 +575,7 @@
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) log2(float v);
+_RS_RUNTIME float __attribute__((const, overloadable)) log2(float v);
 FN_FUNC_FN(log2)
 
 /**
@@ -562,7 +583,7 @@
  *
  * Supports 1,2,3,4 components
  */
-extern float __attribute__((overloadable)) log1p(float v);
+extern float __attribute__((const, overloadable)) log1p(float v);
 FN_FUNC_FN(log1p)
 
 /**
@@ -570,7 +591,7 @@
  *
  * Supports 1,2,3,4 components
  */
-extern float __attribute__((overloadable)) logb(float);
+extern float __attribute__((const, overloadable)) logb(float);
 FN_FUNC_FN(logb)
 
 /**
@@ -578,7 +599,7 @@
  *
  * Supports 1,2,3,4 components
  */
-extern float __attribute__((overloadable)) mad(float a, float b, float c);
+extern float __attribute__((const, overloadable)) mad(float a, float b, float c);
 FN_FUNC_FN_FN_FN(mad)
 
 /**
@@ -589,17 +610,17 @@
  * @param iret iret[0] will be set to the integral portion of the number.
  * @return The floating point portion of the value.
  */
-extern float __attribute__((overloadable)) modf(float x, float *iret);
+extern float __attribute__((pure, overloadable)) modf(float x, float *iret);
 FN_FUNC_FN_PFN(modf);
 
-extern float __attribute__((overloadable)) nan(uint);
+extern float __attribute__((const, overloadable)) nan(uint);
 
 /**
  * Return the next floating point number from x towards y.
  *
  * Supports 1,2,3,4 components
  */
-extern float __attribute__((overloadable)) nextafter(float x, float y);
+extern float __attribute__((const, overloadable)) nextafter(float x, float y);
 FN_FUNC_FN_FN(nextafter)
 
 /**
@@ -607,7 +628,7 @@
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) pown(float v, int p);
+_RS_RUNTIME float __attribute__((const, overloadable)) pown(float v, int p);
 FN_FUNC_FN_IN(pown)
 
 /**
@@ -616,7 +637,7 @@
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) powr(float v, float p);
+_RS_RUNTIME float __attribute__((const, overloadable)) powr(float v, float p);
 FN_FUNC_FN_FN(powr)
 
 /**
@@ -624,11 +645,11 @@
  *
  * Supports 1,2,3,4 components
  */
-extern float __attribute__((overloadable)) remainder(float x, float y);
+extern float __attribute__((const, overloadable)) remainder(float x, float y);
 FN_FUNC_FN_FN(remainder)
 
 // document once we know the precision of bionic
-extern float __attribute__((overloadable)) remquo(float, float, int *);
+extern float __attribute__((pure, overloadable)) remquo(float, float, int *);
 FN_FUNC_FN_FN_PIN(remquo)
 
 /**
@@ -636,7 +657,7 @@
  *
  * Supports 1,2,3,4 components
  */
-extern float __attribute__((overloadable)) rint(float);
+extern float __attribute__((const, overloadable)) rint(float);
 FN_FUNC_FN(rint)
 
 /**
@@ -644,7 +665,7 @@
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) rootn(float v, int n);
+_RS_RUNTIME float __attribute__((const, overloadable)) rootn(float v, int n);
 FN_FUNC_FN_IN(rootn)
 
 /**
@@ -652,7 +673,7 @@
  *
  * Supports 1,2,3,4 components
  */
-extern float __attribute__((overloadable)) round(float);
+extern float __attribute__((const, overloadable)) round(float);
 FN_FUNC_FN(round)
 
 /**
@@ -660,7 +681,7 @@
  *
  * Supports 1,2,3,4 components
  */
-extern float __attribute__((overloadable)) sqrt(float);
+extern float __attribute__((const, overloadable)) sqrt(float);
 FN_FUNC_FN(sqrt)
 
 /**
@@ -668,7 +689,7 @@
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) rsqrt(float v);
+_RS_RUNTIME float __attribute__((const, overloadable)) rsqrt(float v);
 FN_FUNC_FN(rsqrt)
 
 /**
@@ -677,7 +698,7 @@
  * @param v The incoming value in radians
  * Supports 1,2,3,4 components
  */
-extern float __attribute__((overloadable)) sin(float v);
+extern float __attribute__((const, overloadable)) sin(float v);
 FN_FUNC_FN(sin)
 
 /**
@@ -689,7 +710,7 @@
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) sincos(float v, float *cosptr);
+_RS_RUNTIME float __attribute__((pure, overloadable)) sincos(float v, float *cosptr);
 FN_FUNC_FN_PFN(sincos);
 
 /**
@@ -697,7 +718,7 @@
  *
  * Supports 1,2,3,4 components
  */
-extern float __attribute__((overloadable)) sinh(float);
+extern float __attribute__((const, overloadable)) sinh(float);
 FN_FUNC_FN(sinh)
 
 /**
@@ -705,7 +726,7 @@
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) sinpi(float v);
+_RS_RUNTIME float __attribute__((const, overloadable)) sinpi(float v);
 FN_FUNC_FN(sinpi)
 
 /**
@@ -714,7 +735,7 @@
  * Supports 1,2,3,4 components
  * @param v The incoming value in radians
  */
-extern float __attribute__((overloadable)) tan(float v);
+extern float __attribute__((const, overloadable)) tan(float v);
 FN_FUNC_FN(tan)
 
 /**
@@ -723,7 +744,7 @@
  * Supports 1,2,3,4 components
  * @param v The incoming value in radians
  */
-extern float __attribute__((overloadable)) tanh(float);
+extern float __attribute__((const, overloadable)) tanh(float);
 FN_FUNC_FN(tanh)
 
 /**
@@ -731,7 +752,7 @@
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) tanpi(float v);
+_RS_RUNTIME float __attribute__((const, overloadable)) tanpi(float v);
 FN_FUNC_FN(tanpi)
 
 /**
@@ -739,7 +760,7 @@
  *
  * Supports 1,2,3,4 components
  */
-extern float __attribute__((overloadable)) tgamma(float);
+extern float __attribute__((const, overloadable)) tgamma(float);
 FN_FUNC_FN(tgamma)
 
 /**
@@ -747,15 +768,37 @@
  *
  * Supports 1,2,3,4 components
  */
-extern float __attribute__((overloadable)) trunc(float);
+extern float __attribute__((const, overloadable)) trunc(float);
 FN_FUNC_FN(trunc)
 
+#ifdef DOXYGEN
 
 #define XN_FUNC_YN(typeout, fnc, typein)                                \
-extern typeout __attribute__((overloadable)) fnc(typein);               \
-_RS_RUNTIME typeout##2 __attribute__((overloadable)) fnc(typein##2 v);  \
-_RS_RUNTIME typeout##3 __attribute__((overloadable)) fnc(typein##3 v);  \
-_RS_RUNTIME typeout##4 __attribute__((overloadable)) fnc(typein##4 v);
+extern typeout __attribute__((overloadable)) fnc(typein v);
+
+#define XN_FUNC_XN_XN_BODY(type, fnc, body)         \
+_RS_RUNTIME type __attribute__((overloadable))      \
+        fnc(type v1, type v2);
+
+#else
+
+#define XN_FUNC_YN(typeout, fnc, typein)                                      \
+extern typeout __attribute__((const, overloadable)) fnc(typein v);            \
+_RS_RUNTIME typeout##2 __attribute__((const, overloadable)) fnc(typein##2 v); \
+_RS_RUNTIME typeout##3 __attribute__((const, overloadable)) fnc(typein##3 v); \
+_RS_RUNTIME typeout##4 __attribute__((const, overloadable)) fnc(typein##4 v);
+
+#define XN_FUNC_XN_XN_BODY(type, fnc, body)              \
+_RS_RUNTIME type __attribute__((const, overloadable))    \
+        fnc(type v1, type v2);                           \
+_RS_RUNTIME type##2 __attribute__((const, overloadable)) \
+        fnc(type##2 v1, type##2 v2);                     \
+_RS_RUNTIME type##3 __attribute__((const, overloadable)) \
+        fnc(type##3 v1, type##3 v2);                     \
+_RS_RUNTIME type##4 __attribute__((const, overloadable)) \
+        fnc(type##4 v1, type##4 v2);
+
+#endif  // DOXYGEN
 
 #define UIN_FUNC_IN(fnc)          \
 XN_FUNC_YN(uchar, fnc, char)      \
@@ -770,17 +813,6 @@
 XN_FUNC_YN(uint, fnc, uint)       \
 XN_FUNC_YN(int, fnc, int)
 
-
-#define XN_FUNC_XN_XN_BODY(type, fnc, body)         \
-_RS_RUNTIME type __attribute__((overloadable))      \
-        fnc(type v1, type v2);                      \
-_RS_RUNTIME type##2 __attribute__((overloadable))   \
-        fnc(type##2 v1, type##2 v2);                \
-_RS_RUNTIME type##3 __attribute__((overloadable))   \
-        fnc(type##3 v1, type##3 v2);                \
-_RS_RUNTIME type##4 __attribute__((overloadable))   \
-        fnc(type##4 v1, type##4 v2);
-
 #define IN_FUNC_IN_IN_BODY(fnc, body)   \
 XN_FUNC_XN_XN_BODY(uchar, fnc, body)    \
 XN_FUNC_XN_XN_BODY(char, fnc, body)     \
@@ -791,6 +823,7 @@
 XN_FUNC_XN_XN_BODY(float, fnc, body)
 
 /**
+ * \fn uchar abs(char)
  * Return the absolute value of a value.
  *
  * Supports 1,2,3,4 components of char, short, int.
@@ -827,16 +860,41 @@
  * @param low Lower bound, must be scalar or matching vector.
  * @param high High bound, must match type of low
  */
-_RS_RUNTIME float __attribute__((overloadable)) clamp(float amount, float low, float high);
+
+#if !defined(RS_VERSION) || (RS_VERSION < 19)
+_RS_RUNTIME float __attribute__((const, overloadable)) clamp(float amount, float low, float high);
 FN_FUNC_FN_FN_FN(clamp)
 FN_FUNC_FN_F_F(clamp)
+#else
+#define _CLAMP(T)                                                                   \
+extern T __attribute__((overloadable)) clamp(T amount, T low, T high);              \
+extern T##2 __attribute__((overloadable)) clamp(T##2 amount, T##2 low, T##2 high);  \
+extern T##3 __attribute__((overloadable)) clamp(T##3 amount, T##3 low, T##3 high);  \
+extern T##4 __attribute__((overloadable)) clamp(T##4 amount, T##4 low, T##4 high);  \
+extern T##2 __attribute__((overloadable)) clamp(T##2 amount, T low, T high);        \
+extern T##3 __attribute__((overloadable)) clamp(T##3 amount, T low, T high);        \
+extern T##4 __attribute__((overloadable)) clamp(T##4 amount, T low, T high)
+
+_CLAMP(float);
+_CLAMP(double);
+_CLAMP(char);
+_CLAMP(uchar);
+_CLAMP(short);
+_CLAMP(ushort);
+_CLAMP(int);
+_CLAMP(uint);
+_CLAMP(long);
+_CLAMP(ulong);
+
+#undef _CLAMP
+#endif
 
 /**
  * Convert from radians to degrees.
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) degrees(float radians);
+_RS_RUNTIME float __attribute__((const, overloadable)) degrees(float radians);
 FN_FUNC_FN(degrees)
 
 /**
@@ -844,7 +902,7 @@
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) mix(float start, float stop, float amount);
+_RS_RUNTIME float __attribute__((const, overloadable)) mix(float start, float stop, float amount);
 FN_FUNC_FN_FN_FN(mix)
 FN_FUNC_FN_FN_F(mix)
 
@@ -853,7 +911,7 @@
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) radians(float degrees);
+_RS_RUNTIME float __attribute__((const, overloadable)) radians(float degrees);
 FN_FUNC_FN(radians)
 
 /**
@@ -864,18 +922,18 @@
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) step(float edge, float v);
+_RS_RUNTIME float __attribute__((const, overloadable)) step(float edge, float v);
 FN_FUNC_FN_FN(step)
 FN_FUNC_FN_F(step)
 
 // not implemented
-extern float __attribute__((overloadable)) smoothstep(float, float, float);
-extern float2 __attribute__((overloadable)) smoothstep(float2, float2, float2);
-extern float3 __attribute__((overloadable)) smoothstep(float3, float3, float3);
-extern float4 __attribute__((overloadable)) smoothstep(float4, float4, float4);
-extern float2 __attribute__((overloadable)) smoothstep(float, float, float2);
-extern float3 __attribute__((overloadable)) smoothstep(float, float, float3);
-extern float4 __attribute__((overloadable)) smoothstep(float, float, float4);
+extern float __attribute__((const, overloadable)) smoothstep(float, float, float);
+extern float2 __attribute__((const, overloadable)) smoothstep(float2, float2, float2);
+extern float3 __attribute__((const, overloadable)) smoothstep(float3, float3, float3);
+extern float4 __attribute__((const, overloadable)) smoothstep(float4, float4, float4);
+extern float2 __attribute__((const, overloadable)) smoothstep(float, float, float2);
+extern float3 __attribute__((const, overloadable)) smoothstep(float, float, float3);
+extern float4 __attribute__((const, overloadable)) smoothstep(float, float, float4);
 
 /**
  * Return the sign of a value.
@@ -886,7 +944,7 @@
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) sign(float v);
+_RS_RUNTIME float __attribute__((const, overloadable)) sign(float v);
 FN_FUNC_FN(sign)
 
 /**
@@ -894,15 +952,15 @@
  *
  * Supports 3,4 components
  */
-_RS_RUNTIME float3 __attribute__((overloadable)) cross(float3 lhs, float3 rhs);
-_RS_RUNTIME float4 __attribute__((overloadable)) cross(float4 lhs, float4 rhs);
+_RS_RUNTIME float3 __attribute__((const, overloadable)) cross(float3 lhs, float3 rhs);
+_RS_RUNTIME float4 __attribute__((const, overloadable)) cross(float4 lhs, float4 rhs);
 
 /**
  * Compute the dot product of two vectors.
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) dot(float lhs, float rhs);
+_RS_RUNTIME float __attribute__((const, overloadable)) dot(float lhs, float rhs);
 F_FUNC_FN_FN(dot)
 
 /**
@@ -910,7 +968,7 @@
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) length(float v);
+_RS_RUNTIME float __attribute__((const, overloadable)) length(float v);
 F_FUNC_FN(length)
 
 /**
@@ -918,7 +976,7 @@
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) distance(float lhs, float rhs);
+_RS_RUNTIME float __attribute__((const, overloadable)) distance(float lhs, float rhs);
 F_FUNC_FN_FN(distance)
 
 /**
@@ -926,7 +984,7 @@
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) normalize(float v);
+_RS_RUNTIME float __attribute__((const, overloadable)) normalize(float v);
 FN_FUNC_FN(normalize)
 
 
@@ -938,7 +996,7 @@
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) half_recip(float);
+_RS_RUNTIME float __attribute__((const, overloadable)) half_recip(float);
 FN_FUNC_FN(half_recip)
 
 /**
@@ -946,7 +1004,7 @@
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) half_sqrt(float);
+_RS_RUNTIME float __attribute__((const, overloadable)) half_sqrt(float);
 FN_FUNC_FN(half_sqrt)
 
 /**
@@ -954,7 +1012,7 @@
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) half_rsqrt(float v);
+_RS_RUNTIME float __attribute__((const, overloadable)) half_rsqrt(float v);
 FN_FUNC_FN(half_rsqrt)
 
 /**
@@ -962,7 +1020,7 @@
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) fast_length(float v);
+_RS_RUNTIME float __attribute__((const, overloadable)) fast_length(float v);
 F_FUNC_FN(fast_length)
 
 /**
@@ -970,7 +1028,7 @@
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) fast_distance(float lhs, float rhs);
+_RS_RUNTIME float __attribute__((const, overloadable)) fast_distance(float lhs, float rhs);
 F_FUNC_FN_FN(fast_distance)
 
 /**
@@ -978,7 +1036,7 @@
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) fast_normalize(float v);
+_RS_RUNTIME float __attribute__((const, overloadable)) fast_normalize(float v);
 F_FUNC_FN(fast_normalize)
 
 #endif  // (defined(RS_VERSION) && (RS_VERSION >= 17))
@@ -996,7 +1054,7 @@
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) native_exp2(float v);
+_RS_RUNTIME float __attribute__((const, overloadable)) native_exp2(float v);
 FN_FUNC_FN(native_exp2)
 
 /**
@@ -1006,7 +1064,7 @@
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) native_exp(float v);
+_RS_RUNTIME float __attribute__((const, overloadable)) native_exp(float v);
 FN_FUNC_FN(native_exp)
 
 /**
@@ -1016,21 +1074,21 @@
  *
  * Supports 1,2,3,4 components
  */
-_RS_RUNTIME float __attribute__((overloadable)) native_exp10(float v);
+_RS_RUNTIME float __attribute__((const, overloadable)) native_exp10(float v);
 FN_FUNC_FN(native_exp10)
 
 
-_RS_RUNTIME float __attribute__((overloadable)) native_log2(float v);
+_RS_RUNTIME float __attribute__((const, overloadable)) native_log2(float v);
 FN_FUNC_FN(native_log2)
 
-_RS_RUNTIME float __attribute__((overloadable)) native_log(float v);
+_RS_RUNTIME float __attribute__((const, overloadable)) native_log(float v);
 FN_FUNC_FN(native_log)
 
-_RS_RUNTIME float __attribute__((overloadable)) native_log10(float v);
+_RS_RUNTIME float __attribute__((const, overloadable)) native_log10(float v);
 FN_FUNC_FN(native_log10)
 
 
-_RS_RUNTIME float __attribute__((overloadable)) native_powr(float v, float y);
+_RS_RUNTIME float __attribute__((const, overloadable)) native_powr(float v, float y);
 FN_FUNC_FN_FN(native_powr)
 
 
diff --git a/renderscript/include/rs_math.rsh b/renderscript/include/rs_math.rsh
index 73040b3..4d3124c 100644
--- a/renderscript/include/rs_math.rsh
+++ b/renderscript/include/rs_math.rsh
@@ -49,7 +49,7 @@
 /**
  * Returns the fractional part of a float
  */
-extern float __attribute__((overloadable))
+extern float __attribute__((const, overloadable))
     rsFrac(float);
 
 
@@ -64,28 +64,28 @@
  * @param low
  * @param high
  */
-_RS_RUNTIME uint __attribute__((overloadable, always_inline)) rsClamp(uint amount, uint low, uint high);
+_RS_RUNTIME uint __attribute__((const, overloadable, always_inline)) rsClamp(uint amount, uint low, uint high);
 
 /**
  * \overload
  */
-_RS_RUNTIME int __attribute__((overloadable, always_inline)) rsClamp(int amount, int low, int high);
+_RS_RUNTIME int __attribute__((const, overloadable, always_inline)) rsClamp(int amount, int low, int high);
 /**
  * \overload
  */
-_RS_RUNTIME ushort __attribute__((overloadable, always_inline)) rsClamp(ushort amount, ushort low, ushort high);
+_RS_RUNTIME ushort __attribute__((const, overloadable, always_inline)) rsClamp(ushort amount, ushort low, ushort high);
 /**
  * \overload
  */
-_RS_RUNTIME short __attribute__((overloadable, always_inline)) rsClamp(short amount, short low, short high);
+_RS_RUNTIME short __attribute__((const, overloadable, always_inline)) rsClamp(short amount, short low, short high);
 /**
  * \overload
  */
-_RS_RUNTIME uchar __attribute__((overloadable, always_inline)) rsClamp(uchar amount, uchar low, uchar high);
+_RS_RUNTIME uchar __attribute__((const, overloadable, always_inline)) rsClamp(uchar amount, uchar low, uchar high);
 /**
  * \overload
  */
-_RS_RUNTIME char __attribute__((overloadable, always_inline)) rsClamp(char amount, char low, char high);
+_RS_RUNTIME char __attribute__((const, overloadable, always_inline)) rsClamp(char amount, char low, char high);
 
 
 /**
@@ -202,7 +202,7 @@
  *
  * @return uchar4
  */
-_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b);
+_RS_RUNTIME uchar4 __attribute__((const, overloadable)) rsPackColorTo8888(float r, float g, float b);
 
 /**
  * Pack floating point (0-1) RGBA values into a uchar4.
@@ -214,7 +214,7 @@
  *
  * @return uchar4
  */
-_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float r, float g, float b, float a);
+_RS_RUNTIME uchar4 __attribute__((const, overloadable)) rsPackColorTo8888(float r, float g, float b, float a);
 
 /**
  * Pack floating point (0-1) RGB values into a uchar4.  The alpha component is
@@ -224,7 +224,7 @@
  *
  * @return uchar4
  */
-_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float3 color);
+_RS_RUNTIME uchar4 __attribute__((const, overloadable)) rsPackColorTo8888(float3 color);
 
 /**
  * Pack floating point (0-1) RGBA values into a uchar4.
@@ -233,7 +233,7 @@
  *
  * @return uchar4
  */
-_RS_RUNTIME uchar4 __attribute__((overloadable)) rsPackColorTo8888(float4 color);
+_RS_RUNTIME uchar4 __attribute__((const, overloadable)) rsPackColorTo8888(float4 color);
 
 /**
  * Unpack a uchar4 color to float4.  The resulting float range will be (0-1).
@@ -242,10 +242,10 @@
  *
  * @return float4
  */
-_RS_RUNTIME float4 rsUnpackColor8888(uchar4 c);
+_RS_RUNTIME float4 __attribute__((const)) rsUnpackColor8888(uchar4 c);
 
-_RS_RUNTIME uchar4 __attribute__((overloadable)) rsYuvToRGBA_uchar4(uchar y, uchar u, uchar v);
-_RS_RUNTIME float4 __attribute__((overloadable)) rsYuvToRGBA_float4(uchar y, uchar u, uchar v);
+_RS_RUNTIME uchar4 __attribute__((const, overloadable)) rsYuvToRGBA_uchar4(uchar y, uchar u, uchar v);
+_RS_RUNTIME float4 __attribute__((const, overloadable)) rsYuvToRGBA_float4(uchar y, uchar u, uchar v);
 
 
 #endif
diff --git a/renderscript/lib/arm/libRSSupport.so b/renderscript/lib/arm/libRSSupport.so
index 078583c..90492f3 100755
--- a/renderscript/lib/arm/libRSSupport.so
+++ b/renderscript/lib/arm/libRSSupport.so
Binary files differ
diff --git a/renderscript/lib/arm/libclcore.bc b/renderscript/lib/arm/libclcore.bc
index 32ed0ce..789cd38 100644
--- a/renderscript/lib/arm/libclcore.bc
+++ b/renderscript/lib/arm/libclcore.bc
Binary files differ
diff --git a/renderscript/lib/arm/librsjni.so b/renderscript/lib/arm/librsjni.so
index e30cfb7..cddf0b5 100755
--- a/renderscript/lib/arm/librsjni.so
+++ b/renderscript/lib/arm/librsjni.so
Binary files differ
diff --git a/renderscript/lib/javalib.jar b/renderscript/lib/javalib.jar
index 8b08a19..84414e0 100644
--- a/renderscript/lib/javalib.jar
+++ b/renderscript/lib/javalib.jar
Binary files differ
diff --git a/renderscript/lib/mips/libRSSupport.so b/renderscript/lib/mips/libRSSupport.so
index 4f8762e..6b42ebe 100755
--- a/renderscript/lib/mips/libRSSupport.so
+++ b/renderscript/lib/mips/libRSSupport.so
Binary files differ
diff --git a/renderscript/lib/mips/libclcore.bc b/renderscript/lib/mips/libclcore.bc
index 32ed0ce..789cd38 100644
--- a/renderscript/lib/mips/libclcore.bc
+++ b/renderscript/lib/mips/libclcore.bc
Binary files differ
diff --git a/renderscript/lib/mips/librsjni.so b/renderscript/lib/mips/librsjni.so
index 87321f6..5ca0bb5 100755
--- a/renderscript/lib/mips/librsjni.so
+++ b/renderscript/lib/mips/librsjni.so
Binary files differ
diff --git a/renderscript/lib/x86/libRSSupport.so b/renderscript/lib/x86/libRSSupport.so
index b943d8c..8c5ed44 100755
--- a/renderscript/lib/x86/libRSSupport.so
+++ b/renderscript/lib/x86/libRSSupport.so
Binary files differ
diff --git a/renderscript/lib/x86/libclcore.bc b/renderscript/lib/x86/libclcore.bc
index 32ed0ce..789cd38 100644
--- a/renderscript/lib/x86/libclcore.bc
+++ b/renderscript/lib/x86/libclcore.bc
Binary files differ
diff --git a/renderscript/lib/x86/librsjni.so b/renderscript/lib/x86/librsjni.so
index 7f5c83f..c7f703f 100755
--- a/renderscript/lib/x86/librsjni.so
+++ b/renderscript/lib/x86/librsjni.so
Binary files differ
diff --git a/tools/darwin/aapt b/tools/darwin/aapt
index 20b29e3..3845e22 100755
--- a/tools/darwin/aapt
+++ b/tools/darwin/aapt
Binary files differ
diff --git a/tools/darwin/aidl b/tools/darwin/aidl
index 650444e..7f17f62 100755
--- a/tools/darwin/aidl
+++ b/tools/darwin/aidl
Binary files differ
diff --git a/tools/darwin/bcc_compat b/tools/darwin/bcc_compat
index 502b7db..aa3760d 100755
--- a/tools/darwin/bcc_compat
+++ b/tools/darwin/bcc_compat
Binary files differ
diff --git a/tools/darwin/libLLVM.dylib b/tools/darwin/libLLVM.dylib
index ea7da57..2bd1f10 100755
--- a/tools/darwin/libLLVM.dylib
+++ b/tools/darwin/libLLVM.dylib
Binary files differ
diff --git a/tools/darwin/libbcc.dylib b/tools/darwin/libbcc.dylib
index 034adee..e087c49 100755
--- a/tools/darwin/libbcc.dylib
+++ b/tools/darwin/libbcc.dylib
Binary files differ
diff --git a/tools/darwin/libbcinfo.dylib b/tools/darwin/libbcinfo.dylib
index 3326e94..1818e28 100755
--- a/tools/darwin/libbcinfo.dylib
+++ b/tools/darwin/libbcinfo.dylib
Binary files differ
diff --git a/tools/darwin/libclang.dylib b/tools/darwin/libclang.dylib
index 3358bb8..bebb9be 100755
--- a/tools/darwin/libclang.dylib
+++ b/tools/darwin/libclang.dylib
Binary files differ
diff --git a/tools/darwin/llvm-rs-cc b/tools/darwin/llvm-rs-cc
index 54f9d91..6b46aa4 100755
--- a/tools/darwin/llvm-rs-cc
+++ b/tools/darwin/llvm-rs-cc
Binary files differ
diff --git a/tools/dx b/tools/dx
index e5cedff..632af43 100755
--- a/tools/dx
+++ b/tools/dx
@@ -39,7 +39,7 @@
 
 if [ ! -r "$libdir/$jarfile" ]; then
     # set dx.jar location for the SDK case
-    libdir=`dirname "$progdir"`/platform-tools/lib
+    libdir="$libdir/lib"
 fi
 
 
diff --git a/tools/lib/dx.jar b/tools/lib/dx.jar
index f89282f..746163b 100644
--- a/tools/lib/dx.jar
+++ b/tools/lib/dx.jar
Binary files differ
diff --git a/tools/linux/aapt b/tools/linux/aapt
index 6f5364a..27e739f 100755
--- a/tools/linux/aapt
+++ b/tools/linux/aapt
Binary files differ
diff --git a/tools/linux/aidl b/tools/linux/aidl
index 7a1c0e4..cfee320 100755
--- a/tools/linux/aidl
+++ b/tools/linux/aidl
Binary files differ
diff --git a/tools/linux/bcc_compat b/tools/linux/bcc_compat
index 3a02e98..45aefe1 100755
--- a/tools/linux/bcc_compat
+++ b/tools/linux/bcc_compat
Binary files differ
diff --git a/tools/linux/libLLVM.so b/tools/linux/libLLVM.so
index 7ce99ee..f2a1217 100755
--- a/tools/linux/libLLVM.so
+++ b/tools/linux/libLLVM.so
Binary files differ
diff --git a/tools/linux/libbcc.so b/tools/linux/libbcc.so
index 48ff644..a12c4d9 100755
--- a/tools/linux/libbcc.so
+++ b/tools/linux/libbcc.so
Binary files differ
diff --git a/tools/linux/libbcinfo.so b/tools/linux/libbcinfo.so
index 0975c5e..e1e4914 100755
--- a/tools/linux/libbcinfo.so
+++ b/tools/linux/libbcinfo.so
Binary files differ
diff --git a/tools/linux/libclang.so b/tools/linux/libclang.so
index fe2eca3..2346e13 100755
--- a/tools/linux/libclang.so
+++ b/tools/linux/libclang.so
Binary files differ
diff --git a/tools/linux/llvm-rs-cc b/tools/linux/llvm-rs-cc
index bcdf2a0..8536304 100755
--- a/tools/linux/llvm-rs-cc
+++ b/tools/linux/llvm-rs-cc
Binary files differ