Merge "Fix build break."
diff --git a/api/gen_runtime.cpp b/api/gen_runtime.cpp
index 21a71f4..f7ee3c3 100644
--- a/api/gen_runtime.cpp
+++ b/api/gen_runtime.cpp
@@ -52,6 +52,7 @@
 #include <map>
 #include <set>
 #include <fstream>
+#include <sstream>
 #include <string>
 #include <vector>
 
@@ -87,7 +88,6 @@
  * parseParameterDefinition.
  */
 struct ParameterDefinition {
-    string raw;           // The raw entry in the spec file, e.g. "uint3 v"
     string rsType;        // The Renderscript type, e.g. "uint3"
     string rsBaseType;    // As above but without the number, e.g. "uint"
     string javaBaseType;  // The type we need to declare in Java, e.g. "unsigned int"
@@ -101,11 +101,20 @@
      */
     string vectorWidth;
 
+    string specName;       // e.g. x, as found in the spec file
     string variableName;   // e.g. inX, used both in .rs and .java
     string rsAllocName;    // e.g. gAllocInX
     string javaAllocName;  // e.g. inX
     string javaArrayName;  // e.g. arrayInX
 
+    // If non empty, the mininum and maximum values to be used when generating the test data.
+    string minValue;
+    string maxValue;
+    /* If non empty, contains the name of another parameter that should be smaller or equal to this
+     * parameter, i.e.  value(smallerParameter) <= value(this).  This is used when testing clamp.
+     */
+    string smallerParameter;
+
     bool isOutParameter;  // True if this parameter returns data from the script.
 
     /* Parse the parameter definition found in the spec file.  It will generate a name if none
@@ -293,9 +302,9 @@
     void writeJavaVerifyVectorMethod(ofstream& file) const;
     void writeJavaVerifyFunctionHeader(ofstream& file) const;
     void writeJavaInputAllocationDefinition(ofstream& file, const string& indent,
-                                            const string& name, const string& cType) const;
+                                            const ParameterDefinition& param) const;
     void writeJavaOutputAllocationDefinition(ofstream& file, const string& indent,
-                                             const string& name, const string& cType) const;
+                                             const ParameterDefinition& param) const;
     void writeJavaCallToRs(ofstream& file, bool relaxed, bool generateCallToVerify) const;
 
     void writeJavaTestOneValue(ofstream& file, int indent, const string& rsBaseType,
@@ -376,6 +385,16 @@
     return hash;
 }
 
+// Removes the character from present. Returns true if the string contained the character.
+static bool charRemoved(char c, string* s) {
+    size_t p = s->find(c);
+    if (p != string::npos) {
+        s->erase(p, 1);
+        return true;
+    }
+    return false;
+}
+
 // Return true if the string is already in the set.  Inserts it if not.
 bool testAndSet(const string& flag, set<string>* set) {
     if (set->find(flag) == set->end()) {
@@ -497,28 +516,16 @@
  * we can create names like in2, in3, etc. */
 void ParameterDefinition::parseParameterDefinition(string s, bool isReturn, int* inputCount,
                                                    int* outputCount) {
-    raw = s;
+    istringstream stream(s);
+    string name, type, option;
+    stream >> rsType;
+    stream >> specName;
+    stream >> option;
 
-    // Determine if this an output.
-    isOutParameter = false;
-    size_t p = s.find('*');
-    if (p != string::npos) {
-        isOutParameter = true;
-        s.erase(p, 1);
-    }
-    if (isReturn) {
-        isOutParameter = true;
-    }
+    // Determine if this is an output.
+    isOutParameter = charRemoved('*', &rsType) || charRemoved('*', &specName) || isReturn;
 
-    // Separate the type from the name.
-    string name;
-    p = s.find(' ');
-    if (p != string::npos) {
-        rsType = s.substr(0, p);
-        name = capitalize(s.substr(p + 1));
-    } else {
-        rsType = s;
-    }
+    // Extract the vector size out of the type.
     int last = rsType.size() - 1;
     char lastChar = rsType[last];
     if (lastChar >= '0' && lastChar <= '9') {
@@ -539,16 +546,16 @@
      */
     if (isOutParameter) {
         variableName = "out";
-        if (!name.empty()) {
-            variableName += name;
+        if (!specName.empty()) {
+            variableName += capitalize(specName);
         } else if (!isReturn) {
             variableName += toString(*outputCount);
         }
         (*outputCount)++;
     } else {
         variableName = "in";
-        if (!name.empty()) {
-            variableName += name;
+        if (!specName.empty()) {
+            variableName += capitalize(specName);
         } else if (*inputCount > 0) {
             variableName += toString(*inputCount);
         }
@@ -558,6 +565,29 @@
     javaAllocName = variableName;
     javaArrayName = "array" + capitalize(javaAllocName);
 
+    // Process the option.
+    if (!option.empty()) {
+        if (option.compare(0, 6, "range(") == 0) {
+            size_t pComma = option.find(',');
+            size_t pParen = option.find(')');
+            if (pComma == string::npos || pParen == string::npos) {
+                printf("Incorrect range %s\n", option.c_str());
+            } else {
+                minValue = option.substr(6, pComma - 6);
+                maxValue = option.substr(pComma + 1, pParen - pComma - 1);
+            }
+        } else if (option.compare(0, 6, "above(") == 0) {
+            size_t pParen = option.find(')');
+            if (pParen == string::npos) {
+                printf("Incorrect option %s\n", option.c_str());
+            } else {
+                smallerParameter = option.substr(6, pParen - 6);
+            }
+        } else {
+            printf("Unrecognized option %s\n", option.c_str());
+        }
+    }
+
     for (int i = 0; i < NUM_TYPES; i++) {
         if (rsBaseType == TYPES[i].cType) {
             javaBaseType = TYPES[i].javaType;
@@ -1111,10 +1141,17 @@
     bool needComma = false;
     for (int i = 0; i < (int)mParams.size(); i++) {
         if (i != mReturnIndex) {
+            const ParameterDefinition& p = *mParams[i];
             if (needComma) {
                 file << ", ";
             }
-            file << mParams[i]->raw;
+            file << p.rsType;
+            if (p.isOutParameter) {
+                file << "*";
+            }
+            if (!p.specName.empty()) {
+                file << " " << p.specName;
+            }
             needComma = true;
         }
     }
@@ -1313,7 +1350,16 @@
     for (size_t i = 0; i < mParams.size(); i++) {
         const ParameterDefinition& p = *mParams[i];
         if (!p.isOutParameter) {
-            writeJavaInputAllocationDefinition(file, tab(2), p.javaAllocName, p.rsType);
+            writeJavaInputAllocationDefinition(file, tab(2), p);
+        }
+    }
+    // Enforce ordering if needed.
+    for (size_t i = 0; i < mParams.size(); i++) {
+        const ParameterDefinition& p = *mParams[i];
+        if (!p.isOutParameter && !p.smallerParameter.empty()) {
+            string smallerAlloc = "in" + capitalize(p.smallerParameter);
+            file << tab(2) << "enforceOrdering(" << smallerAlloc << ", " << p.javaAllocName
+                 << ");\n";
         }
     }
     writeJavaCallToRs(file, false, generateCallToVerify);
@@ -1322,24 +1368,29 @@
 }
 
 void Permutation::writeJavaInputAllocationDefinition(ofstream& file, const string& indent,
-                                                     const string& name,
-                                                     const string& cType) const {
+                                                     const ParameterDefinition& param) const {
     string dataType;
     char vectorSize;
-    convertToRsType(cType, &dataType, &vectorSize);
-    long seed = hashString(mJavaCheckMethodName + mName);
-    file << indent << "Allocation " << name << " = CreateRandomAllocation(mRS, Element.DataType."
-         << dataType << ", " << vectorSize << ", 0x" << std::hex << seed << "L);\n";
+    convertToRsType(param.rsType, &dataType, &vectorSize);
+    long seed = hashString(mJavaCheckMethodName + param.javaAllocName);
+    file << indent << "Allocation " << param.javaAllocName
+         << " = createRandomAllocation(mRS, Element.DataType." << dataType << ", " << vectorSize
+         << ", 0x" << std::hex << seed << "l";
+    if (!param.minValue.empty()) {
+        file << ", " << param.minValue << ", " << param.maxValue;
+    } else {
+        file << ", false";  // TODO set to false only for native
+    }
+    file << ");\n";
 }
 
 void Permutation::writeJavaOutputAllocationDefinition(ofstream& file, const string& indent,
-                                                      const string& name,
-                                                      const string& cType) const {
+                                                      const ParameterDefinition& param) const {
     string dataType;
     char vectorSize;
-    convertToRsType(cType, &dataType, &vectorSize);
-    file << indent << "Allocation " << name << " = Allocation.createSized(mRS, "
-         << "GetElement(mRS, Element.DataType." << dataType << ", " << vectorSize
+    convertToRsType(param.rsType, &dataType, &vectorSize);
+    file << indent << "Allocation " << param.javaAllocName << " = Allocation.createSized(mRS, "
+         << "getElement(mRS, Element.DataType." << dataType << ", " << vectorSize
          << "), INPUTSIZE);\n";
 }
 
@@ -1424,8 +1475,8 @@
         }
     }
 
-    file << tab(5) << "assertTrue(\"Incorrect output for " << mJavaCheckMethodName
-         << "\" + (relaxed ? \"_relaxed\" : \"\") + \":\\n\" + message.toString(), valid);\n";
+    file << tab(5) << "assertTrue(\"Incorrect output for " << mJavaCheckMethodName << "\" +\n";
+    file << tab(7) << "(relaxed ? \"_relaxed\" : \"\") + \":\\n\" + message.toString(), valid);\n";
     file << tab(4) << "}\n";
     file << tab(3) << "}\n";
     file << tab(2) << "}\n";
@@ -1498,11 +1549,15 @@
                                                    const string& value) const {
     file << tab(indent) << "message.append(String.format(\"" + legend + ": ";
     if (rsBaseType[0] == 'f') {
-        file << "%x %.16f\", Float.floatToRawIntBits(" << value << "), " << value;
+        file << "%14.8g %8x %15a\",\n";
+        file << tab(indent + 2) << value << ", "
+             << "Float.floatToRawIntBits(" << value << "), " << value;
     } else if (rsBaseType[0] == 'u') {
-        file << "%x\", " << value;
+        file << "0x%x\",\n";
+        file << tab(indent + 2) << value;
     } else {
-        file << "%d\", " << value;
+        file << "%d\",\n";
+        file << tab(indent + 2) << value;
     }
     file << "));\n";
 }
@@ -1608,8 +1663,8 @@
         }
     }
 
-    file << tab(4) << "assertTrue(\"Incorrect output for " << mJavaCheckMethodName
-         << "\" + (relaxed ? \"_relaxed\" : \"\") + \":\\n\" + message.toString(), valid);\n";
+    file << tab(4) << "assertTrue(\"Incorrect output for " << mJavaCheckMethodName << "\" +\n";
+    file << tab(6) << "(relaxed ? \"_relaxed\" : \"\") + \":\\n\" + message.toString(), valid);\n";
     file << tab(3) << "}\n";
     file << tab(2) << "}\n";
     file << tab(1) << "}\n\n";
@@ -1625,7 +1680,7 @@
     for (size_t i = 0; i < mParams.size(); i++) {
         const ParameterDefinition& p = *mParams[i];
         if (p.isOutParameter) {
-            writeJavaOutputAllocationDefinition(file, tab(3), p.javaAllocName, p.rsType);
+            writeJavaOutputAllocationDefinition(file, tab(3), p);
         }
     }
 
diff --git a/api/rs_core_math.spec b/api/rs_core_math.spec
index 5b57b9f..251cd4c 100644
--- a/api/rs_core_math.spec
+++ b/api/rs_core_math.spec
@@ -274,6 +274,8 @@
 comment:
  Return 10 ^ value.
 version: 9
+#TODO
+test: noverify
 end:
 
 start:
@@ -459,6 +461,8 @@
 comment:
  Return the integer exponent of a value
 version: 9
+#TODO
+test: noverify
 end:
 
 start:
@@ -569,6 +573,8 @@
 comment:
  Compute the exponent of the value.
 version: 9
+#TODO
+test: noverify
 end:
 
 start:
@@ -646,6 +652,8 @@
 comment:
  Return x ^ y.
 version: 9
+#TODO
+test: noverify
 end:
 
 start:
@@ -653,11 +661,11 @@
 t: f32
 name: powr
 ret: #2#1
-arg: #2#1 x
+arg: #2#1 x range(0,200)
 arg: #2#1 y
 comment:
  Return x ^ y.
- y must be > 0
+ x must be >= 0
 version: 9
 end:
 
@@ -669,7 +677,7 @@
 arg: #2#1 x
 arg: #2#1 y
 comment:
- Return round x/y to the nearest integer then compute the remander.
+ Return round x/y to the nearest integer then compute the remainder.
 version: 9
 end:
 
@@ -682,9 +690,9 @@
 arg: #2#1 c
 arg: int#1 *d
 comment:
- todo
+ Return the quotient and the remainder of b/c
 version: 9
-# TODO Test to be implemented
+#TODO
 test: noverify
 end:
 
@@ -720,8 +728,6 @@
 comment:
  Round to the nearest integral value.  Half values are rounded away from zero.
 version: 9
-# TODO Test to be implemented
-test: noverify
 end:
 
 start:
@@ -1067,7 +1073,7 @@
 ret: #2#1
 arg: #2#1 value
 arg: #2#1 min_value
-arg: #2#1 max_value
+arg: #2#1 max_value above(min_value)
 comment:
  Clamp a value to a specified high and low bound.
 
@@ -1084,7 +1090,7 @@
 ret: #2#1
 arg: #2#1 value
 arg: #2 min_value
-arg: #2 max_value
+arg: #2 max_value above(min_value)
 comment:
  Clamp a value to a specified high and low bound.
 
@@ -1101,7 +1107,7 @@
 ret: #2#1
 arg: #2#1 value
 arg: #2#1 min_value
-arg: #2#1 max_value
+arg: #2#1 max_value above(min_value)
 comment:
  Clamp a value to a specified high and low bound.
 
@@ -1118,7 +1124,7 @@
 ret: #2#1
 arg: #2#1 value
 arg: #2 min_value
-arg: #2 max_value
+arg: #2 max_value above(min_value)
 comment:
  Clamp a value to a specified high and low bound.
 
@@ -1287,7 +1293,7 @@
 comment:
  Compute the distance between two points.
 version: 9
-# TODO Test to be implemented
+# TODO test: vector
 test: noverify
 end:
 
@@ -1300,7 +1306,7 @@
 comment:
  Normalize a vector.
 version: 9
-# TODO Test to be implemented
+# TODO test: vector
 test: noverify
 end:
 
@@ -1362,7 +1368,7 @@
 comment:
  Compute the approximate distance between two points.
 version: 17
-# TODO Test to be implemented
+# TODO test: vector
 test: noverify
 end:
 
@@ -1375,7 +1381,7 @@
 comment:
  Approximately normalize a vector.
 version: 17
-# TODO Test to be implemented
+# TODO test: vector
 test: noverify
 end:
 
@@ -1384,7 +1390,7 @@
 t: f32
 name: native_exp
 ret: #2#1
-arg: #2#1 v
+arg: #2#1 v range(-86,86)
 comment:
  Fast approximate exp
  valid for inputs -86.f to 86.f
@@ -1399,7 +1405,7 @@
 t: f32
 name: native_exp2
 ret: #2#1
-arg: #2#1 v
+arg: #2#1 v range(-125,125)
 comment:
  Fast approximate exp2
  valid for inputs -125.f to 125.f
@@ -1414,7 +1420,7 @@
 t: f32
 name: native_exp10
 ret: #2#1
-arg: #2#1 v
+arg: #2#1 v range(-37,37)
 comment:
  Fast approximate exp10
  valid for inputs -37.f to 37.f
diff --git a/driver/runtime/rs_cl.c b/driver/runtime/rs_cl.c
index 365b2fa..3a9252a 100644
--- a/driver/runtime/rs_cl.c
+++ b/driver/runtime/rs_cl.c
@@ -513,20 +513,15 @@
 FN_FUNC_FN_FN(pow)
 
 extern float __attribute__((overloadable)) pown(float v, int p) {
-    return pow(v, (float)p);
+    /* The mantissa of a float has fewer bits than an int (24 effective vs. 31).
+     * For very large ints, we'll lose whether the exponent is even or odd, making
+     * the selection of a correct sign incorrect.  We correct this.
+     */
+    float sign = (v < 0.0f && (p & 0x1)) ? -1.0 : 1.0;
+    float f = pow(v, (float)p);
+    return copysign(f, sign);
 }
-extern float2 __attribute__((overloadable)) pown(float2 v, int2 p) {
-    float2 f2 = convert_float2(p);
-    return pow(v, f2);
-}
-extern float3 __attribute__((overloadable)) pown(float3 v, int3 p) {
-    float3 f3 = convert_float3(p);
-    return pow(v, f3);
-}
-extern float4 __attribute__((overloadable)) pown(float4 v, int4 p) {
-    float4 f4 = convert_float4(p);
-    return pow(v, f4);
-}
+FN_FUNC_FN_IN(pown)
 
 extern float __attribute__((overloadable)) powr(float v, float p) {
     return pow(v, p);
@@ -976,17 +971,29 @@
     return length(lhs - rhs);
 }
 
+/* For the normalization functions, vectors of length 0 should simply be
+ * returned (i.e. all the components of that vector are 0).
+ */
 extern float __attribute__((overloadable)) normalize(float v) {
-    return (v < 0.0f) ? -1.0f : 1.0f;
+    if (v == 0.0f) {
+        return 0.0f;
+    } else if (v < 0.0f) {
+        return -1.0f;
+    } else {
+        return 1.0f;
+    }
 }
 extern float2 __attribute__((overloadable)) normalize(float2 v) {
-    return v / length(v);
+    float l = length(v);
+    return l == 0.0f ? v : v / l;
 }
 extern float3 __attribute__((overloadable)) normalize(float3 v) {
-    return v / length(v);
+    float l = length(v);
+    return l == 0.0f ? v : v / l;
 }
 extern float4 __attribute__((overloadable)) normalize(float4 v) {
-    return v / length(v);
+    float l = length(v);
+    return l == 0.0f ? v : v / l;
 }
 
 extern float __attribute__((overloadable)) half_sqrt(float);
@@ -1019,17 +1026,30 @@
 
 extern float __attribute__((overloadable)) half_rsqrt(float);
 
+/* For the normalization functions, vectors of length 0 should simply be
+ * returned (i.e. all the components of that vector are 0).
+ */
 extern float __attribute__((overloadable)) fast_normalize(float v) {
-    return 1.f;
+    if (v == 0.0f) {
+        return 0.0f;
+    } else if (v < 0.0f) {
+        return -1.0f;
+    } else {
+        return 1.0f;
+    }
 }
+// If the length is 0, then rlength should be NaN.
 extern float2 __attribute__((overloadable)) fast_normalize(float2 v) {
-    return v * half_rsqrt(v.x*v.x + v.y*v.y);
+    float rlength = half_rsqrt(v.x*v.x + v.y*v.y);
+    return (rlength == rlength) ? v * rlength : v;
 }
 extern float3 __attribute__((overloadable)) fast_normalize(float3 v) {
-    return v * half_rsqrt(v.x*v.x + v.y*v.y + v.z*v.z);
+    float rlength = half_rsqrt(v.x*v.x + v.y*v.y + v.z*v.z);
+    return (rlength == rlength) ? v * rlength : v;
 }
 extern float4 __attribute__((overloadable)) fast_normalize(float4 v) {
-    return v * half_rsqrt(v.x*v.x + v.y*v.y + v.z*v.z + v.w*v.w);
+    float rlength = half_rsqrt(v.x*v.x + v.y*v.y + v.z*v.z + v.w*v.w);
+    return (rlength == rlength) ? v * rlength : v;
 }
 
 extern float __attribute__((overloadable)) half_recip(float);
diff --git a/scriptc/rs_core_math.rsh b/scriptc/rs_core_math.rsh
index 8fe6ad2..8724fcf 100644
--- a/scriptc/rs_core_math.rsh
+++ b/scriptc/rs_core_math.rsh
@@ -5237,7 +5237,7 @@
  *
  * Supported by API versions 9 and newer.
  */
-extern float __attribute__((overloadable))fract(float v, float *floor);
+extern float __attribute__((overloadable))fract(float v, float* floor);
 #endif
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
@@ -5248,7 +5248,7 @@
  *
  * Supported by API versions 9 and newer.
  */
-extern float2 __attribute__((overloadable))fract(float2 v, float2 *floor);
+extern float2 __attribute__((overloadable))fract(float2 v, float2* floor);
 #endif
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
@@ -5259,7 +5259,7 @@
  *
  * Supported by API versions 9 and newer.
  */
-extern float3 __attribute__((overloadable))fract(float3 v, float3 *floor);
+extern float3 __attribute__((overloadable))fract(float3 v, float3* floor);
 #endif
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
@@ -5270,7 +5270,7 @@
  *
  * Supported by API versions 9 and newer.
  */
-extern float4 __attribute__((overloadable))fract(float4 v, float4 *floor);
+extern float4 __attribute__((overloadable))fract(float4 v, float4* floor);
 #endif
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
@@ -5329,7 +5329,7 @@
  *
  * Supported by API versions 9 and newer.
  */
-extern float __attribute__((overloadable))frexp(float v, int *iptr);
+extern float __attribute__((overloadable))frexp(float v, int* iptr);
 #endif
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
@@ -5340,7 +5340,7 @@
  *
  * Supported by API versions 9 and newer.
  */
-extern float2 __attribute__((overloadable))frexp(float2 v, int2 *iptr);
+extern float2 __attribute__((overloadable))frexp(float2 v, int2* iptr);
 #endif
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
@@ -5351,7 +5351,7 @@
  *
  * Supported by API versions 9 and newer.
  */
-extern float3 __attribute__((overloadable))frexp(float3 v, int3 *iptr);
+extern float3 __attribute__((overloadable))frexp(float3 v, int3* iptr);
 #endif
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
@@ -5362,7 +5362,7 @@
  *
  * Supported by API versions 9 and newer.
  */
-extern float4 __attribute__((overloadable))frexp(float4 v, int4 *iptr);
+extern float4 __attribute__((overloadable))frexp(float4 v, int4* iptr);
 #endif
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 17))
@@ -5707,7 +5707,7 @@
  *
  * Supported by API versions 9 and newer.
  */
-extern float __attribute__((overloadable))lgamma(float x, int *y);
+extern float __attribute__((overloadable))lgamma(float x, int* y);
 #endif
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
@@ -5716,7 +5716,7 @@
  *
  * Supported by API versions 9 and newer.
  */
-extern float2 __attribute__((overloadable))lgamma(float2 x, int2 *y);
+extern float2 __attribute__((overloadable))lgamma(float2 x, int2* y);
 #endif
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
@@ -5725,7 +5725,7 @@
  *
  * Supported by API versions 9 and newer.
  */
-extern float3 __attribute__((overloadable))lgamma(float3 x, int3 *y);
+extern float3 __attribute__((overloadable))lgamma(float3 x, int3* y);
 #endif
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
@@ -5734,7 +5734,7 @@
  *
  * Supported by API versions 9 and newer.
  */
-extern float4 __attribute__((overloadable))lgamma(float4 x, int4 *y);
+extern float4 __attribute__((overloadable))lgamma(float4 x, int4* y);
 #endif
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
@@ -7346,7 +7346,7 @@
  *
  * Supported by API versions 9 and newer.
  */
-extern float __attribute__((overloadable))modf(float x, float *iret);
+extern float __attribute__((overloadable))modf(float x, float* iret);
 #endif
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
@@ -7359,7 +7359,7 @@
  *
  * Supported by API versions 9 and newer.
  */
-extern float2 __attribute__((overloadable))modf(float2 x, float2 *iret);
+extern float2 __attribute__((overloadable))modf(float2 x, float2* iret);
 #endif
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
@@ -7372,7 +7372,7 @@
  *
  * Supported by API versions 9 and newer.
  */
-extern float3 __attribute__((overloadable))modf(float3 x, float3 *iret);
+extern float3 __attribute__((overloadable))modf(float3 x, float3* iret);
 #endif
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
@@ -7385,7 +7385,7 @@
  *
  * Supported by API versions 9 and newer.
  */
-extern float4 __attribute__((overloadable))modf(float4 x, float4 *iret);
+extern float4 __attribute__((overloadable))modf(float4 x, float4* iret);
 #endif
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
@@ -7820,7 +7820,7 @@
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
 /*
  * Return x ^ y.
- * y must be > 0
+ * x must be >= 0
  *
  * Supported by API versions 9 and newer.
  */
@@ -7830,7 +7830,7 @@
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
 /*
  * Return x ^ y.
- * y must be > 0
+ * x must be >= 0
  *
  * Supported by API versions 9 and newer.
  */
@@ -7840,7 +7840,7 @@
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
 /*
  * Return x ^ y.
- * y must be > 0
+ * x must be >= 0
  *
  * Supported by API versions 9 and newer.
  */
@@ -7850,7 +7850,7 @@
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
 /*
  * Return x ^ y.
- * y must be > 0
+ * x must be >= 0
  *
  * Supported by API versions 9 and newer.
  */
@@ -7895,7 +7895,7 @@
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
 /*
- * Return round x/y to the nearest integer then compute the remander.
+ * Return round x/y to the nearest integer then compute the remainder.
  *
  * Supported by API versions 9 and newer.
  */
@@ -7904,7 +7904,7 @@
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
 /*
- * Return round x/y to the nearest integer then compute the remander.
+ * Return round x/y to the nearest integer then compute the remainder.
  *
  * Supported by API versions 9 and newer.
  */
@@ -7913,7 +7913,7 @@
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
 /*
- * Return round x/y to the nearest integer then compute the remander.
+ * Return round x/y to the nearest integer then compute the remainder.
  *
  * Supported by API versions 9 and newer.
  */
@@ -7922,7 +7922,7 @@
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
 /*
- * Return round x/y to the nearest integer then compute the remander.
+ * Return round x/y to the nearest integer then compute the remainder.
  *
  * Supported by API versions 9 and newer.
  */
@@ -7931,38 +7931,38 @@
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
 /*
- * todo
+ * Return the quotient and the remainder of b/c
  *
  * Supported by API versions 9 and newer.
  */
-extern float __attribute__((overloadable))remquo(float b, float c, int *d);
+extern float __attribute__((overloadable))remquo(float b, float c, int* d);
 #endif
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
 /*
- * todo
+ * Return the quotient and the remainder of b/c
  *
  * Supported by API versions 9 and newer.
  */
-extern float2 __attribute__((overloadable))remquo(float2 b, float2 c, int2 *d);
+extern float2 __attribute__((overloadable))remquo(float2 b, float2 c, int2* d);
 #endif
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
 /*
- * todo
+ * Return the quotient and the remainder of b/c
  *
  * Supported by API versions 9 and newer.
  */
-extern float3 __attribute__((overloadable))remquo(float3 b, float3 c, int3 *d);
+extern float3 __attribute__((overloadable))remquo(float3 b, float3 c, int3* d);
 #endif
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
 /*
- * todo
+ * Return the quotient and the remainder of b/c
  *
  * Supported by API versions 9 and newer.
  */
-extern float4 __attribute__((overloadable))remquo(float4 b, float4 c, int4 *d);
+extern float4 __attribute__((overloadable))remquo(float4 b, float4 c, int4* d);
 #endif
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
@@ -8207,7 +8207,7 @@
  *
  * Supported by API versions 9 and newer.
  */
-extern float __attribute__((overloadable))sincos(float v, float *cosptr);
+extern float __attribute__((overloadable))sincos(float v, float* cosptr);
 #endif
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
@@ -8220,7 +8220,7 @@
  *
  * Supported by API versions 9 and newer.
  */
-extern float2 __attribute__((overloadable))sincos(float2 v, float2 *cosptr);
+extern float2 __attribute__((overloadable))sincos(float2 v, float2* cosptr);
 #endif
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
@@ -8233,7 +8233,7 @@
  *
  * Supported by API versions 9 and newer.
  */
-extern float3 __attribute__((overloadable))sincos(float3 v, float3 *cosptr);
+extern float3 __attribute__((overloadable))sincos(float3 v, float3* cosptr);
 #endif
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))
@@ -8246,7 +8246,7 @@
  *
  * Supported by API versions 9 and newer.
  */
-extern float4 __attribute__((overloadable))sincos(float4 v, float4 *cosptr);
+extern float4 __attribute__((overloadable))sincos(float4 v, float4* cosptr);
 #endif
 
 #if (defined(RS_VERSION) && (RS_VERSION >= 9))