Merge changes Ic10cba73,I28ab2d92
* changes:
Ensure arch/generic.c is always included in libclcore_g.bc.
Make RenderScript constants variables instead of macros.
diff --git a/api/GenerateHeaderFiles.cpp b/api/GenerateHeaderFiles.cpp
index ce778b3..9f40d3d 100644
--- a/api/GenerateHeaderFiles.cpp
+++ b/api/GenerateHeaderFiles.cpp
@@ -120,7 +120,13 @@
const Constant* constant = spec.getConstant();
VersionInfo info = spec.getVersionInfo();
writeVersionGuardStart(file, info, constant->getFinalVersion());
- *file << "#define " << constant->getName() << " " << spec.getValue() << "\n\n";
+
+ *file << "#if (defined(RS_VERSION) && (RS_VERSION >= UNRELEASED))\n";
+ *file << "extern const " << spec.getType() << " " << constant->getName() << ";\n";
+ *file << "#else\n";
+ *file << "#define " << constant->getName() << " " << spec.getValue() << "\n";
+ *file << "#endif\n\n";
+
writeVersionGuardEnd(file, info);
}
diff --git a/api/Generator.cpp b/api/Generator.cpp
index 456f214..f67e473 100644
--- a/api/Generator.cpp
+++ b/api/Generator.cpp
@@ -62,6 +62,7 @@
* [version: ({Starting API level} [ {Last API level that supports this.}] | UNRELEASED)
* [size: {32 or 64. Used if this is available only for 32 or 64 bit code.}]
* value: {The value of the constant.}
+ * type: {The type of the constant.}
* [hidden:] ...If present, don't document the constant. Omit the following two fields.
* [deprecated: [{Deprecation message.}] ... This is deprecated. Compiler will issue a wrning.
* summary: {A one line string describing this section.}
diff --git a/api/Specification.cpp b/api/Specification.cpp
index 7afeea4..024b8b6 100644
--- a/api/Specification.cpp
+++ b/api/Specification.cpp
@@ -380,6 +380,9 @@
if (scanner->findTag("value:")) {
spec->mValue = scanner->getValue();
}
+ if (scanner->findTag("type:")) {
+ spec->mType = scanner->getValue();
+ }
constant->scanDocumentationTags(scanner, created, specFile);
scanner->findTag("end:");
diff --git a/api/Specification.h b/api/Specification.h
index c467c5c..8326659 100644
--- a/api/Specification.h
+++ b/api/Specification.h
@@ -262,11 +262,13 @@
Constant* mConstant; // Not owned
std::string mValue; // E.g. "3.1415"
+ std::string mType;
public:
ConstantSpecification(Constant* constant) : mConstant(constant) {}
Constant* getConstant() const { return mConstant; }
std::string getValue() const { return mValue; }
+ std::string getType() const { return mType; }
// Parse a constant specification and add it to specFile.
static void scanConstantSpecification(Scanner* scanner, SpecFile* specFile, unsigned int maxApiLevel);
diff --git a/api/rs_math.spec b/api/rs_math.spec
index acc2eb6..96eee81 100644
--- a/api/rs_math.spec
+++ b/api/rs_math.spec
@@ -51,6 +51,7 @@
# TODO Add f16 versions of these constants.
constant: M_1_PI
value: 0.318309886183790671537767526745028724f
+type: float
summary: 1 / pi, as a 32 bit float
description:
The inverse of pi, as a 32 bit float.
@@ -58,6 +59,7 @@
constant: M_2_PI
value: 0.636619772367581343075535053490057448f
+type: float
summary: 2 / pi, as a 32 bit float
description:
2 divided by pi, as a 32 bit float.
@@ -65,6 +67,7 @@
constant: M_2_PIl
value: 0.636619772367581343075535053490057448f
+type: float
hidden:
deprecated: 22, Use M_2_PI instead.
summary: 2 / pi, as a 32 bit float
@@ -74,6 +77,7 @@
constant: M_2_SQRTPI
value: 1.128379167095512573896158903121545172f
+type: float
summary: 2 / sqrt(pi), as a 32 bit float
description:
2 divided by the square root of pi, as a 32 bit float.
@@ -81,6 +85,7 @@
constant: M_E
value: 2.718281828459045235360287471352662498f
+type: float
summary: e, as a 32 bit float
description:
The number e, the base of the natural logarithm, as a 32 bit float.
@@ -88,6 +93,7 @@
constant: M_LN10
value: 2.302585092994045684017991454684364208f
+type: float
summary: log_e(10), as a 32 bit float
description:
The natural logarithm of 10, as a 32 bit float.
@@ -95,6 +101,7 @@
constant: M_LN2
value: 0.693147180559945309417232121458176568f
+type: float
summary: log_e(2), as a 32 bit float
description:
The natural logarithm of 2, as a 32 bit float.
@@ -102,6 +109,7 @@
constant: M_LOG10E
value: 0.434294481903251827651128918916605082f
+type: float
summary: log_10(e), as a 32 bit float
description:
The logarithm base 10 of e, as a 32 bit float.
@@ -109,6 +117,7 @@
constant: M_LOG2E
value: 1.442695040888963407359924681001892137f
+type: float
summary: log_2(e), as a 32 bit float
description:
The logarithm base 2 of e, as a 32 bit float.
@@ -116,6 +125,7 @@
constant: M_PI
value: 3.141592653589793238462643383279502884f
+type: float
summary: pi, as a 32 bit float
description:
The constant pi, as a 32 bit float.
@@ -123,6 +133,7 @@
constant: M_PI_2
value: 1.570796326794896619231321691639751442f
+type: float
summary: pi / 2, as a 32 bit float
description:
Pi divided by 2, as a 32 bit float.
@@ -130,6 +141,7 @@
constant: M_PI_4
value: 0.785398163397448309615660845819875721f
+type: float
summary: pi / 4, as a 32 bit float
description:
Pi divided by 4, as a 32 bit float.
@@ -137,6 +149,7 @@
constant: M_SQRT1_2
value: 0.707106781186547524400844362104849039f
+type: float
summary: 1 / sqrt(2), as a 32 bit float
description:
The inverse of the square root of 2, as a 32 bit float.
@@ -144,6 +157,7 @@
constant: M_SQRT2
value: 1.414213562373095048801688724209698079f
+type: float
summary: sqrt(2), as a 32 bit float
description:
The square root of 2, as a 32 bit float.
diff --git a/driver/runtime/Android.mk b/driver/runtime/Android.mk
index 8db4394..cbce202 100755
--- a/driver/runtime/Android.mk
+++ b/driver/runtime/Android.mk
@@ -44,7 +44,8 @@
arch/generic.c
clcore_g_files := \
- rs_abi_debuginfo.c
+ rs_abi_debuginfo.c \
+ arch/generic.c
clcore_files_32 := \
$(clcore_base_files_32) \
@@ -150,11 +151,9 @@
LOCAL_CFLAGS += $(clcore_cflags)
LOCAL_CFLAGS += -g -O0
LOCAL_SRC_FILES := $(clcore_base_files) $(clcore_g_files)
-LOCAL_SRC_FILES_32 := arch/generic.c
ifeq ($(TARGET_ARCH),$(filter $(TARGET_ARCH),arm64))
LOCAL_CFLAGS_64 += -DARCH_ARM64_HAVE_NEON
-LOCAL_SRC_FILES_64 := arch/generic.c
endif
include $(LOCAL_PATH)/build_bc_lib.mk
diff --git a/driver/runtime/rs_core.c b/driver/runtime/rs_core.c
index 10e360e..60d8578 100644
--- a/driver/runtime/rs_core.c
+++ b/driver/runtime/rs_core.c
@@ -3,6 +3,37 @@
#include "rsCpuCoreRuntime.h"
+/* Definition of constants */
+#if (defined(RS_VERSION) && (RS_VERSION >= UNRELEASED))
+const float M_1_PI = 0.318309886183790671537767526745028724f;
+
+const float M_2_PI = 0.636619772367581343075535053490057448f;
+
+const float M_2_PIl = 0.636619772367581343075535053490057448f;
+
+const float M_2_SQRTPI = 1.128379167095512573896158903121545172f;
+
+const float M_E = 2.718281828459045235360287471352662498f;
+
+const float M_LN10 = 2.302585092994045684017991454684364208f;
+
+const float M_LN2 = 0.693147180559945309417232121458176568f;
+
+const float M_LOG10E = 0.434294481903251827651128918916605082f;
+
+const float M_LOG2E = 1.442695040888963407359924681001892137f;
+
+const float M_PI = 3.141592653589793238462643383279502884f;
+
+const float M_PI_2 = 1.570796326794896619231321691639751442f;
+
+const float M_PI_4 = 0.785398163397448309615660845819875721f;
+
+const float M_SQRT1_2 = 0.707106781186547524400844362104849039f;
+
+const float M_SQRT2 = 1.414213562373095048801688724209698079f;
+#endif // (defined(RS_VERSION) && (RS_VERSION >= UNRELEASED))
+
extern float __attribute__((overloadable)) rsFrac(float v) {
int i = (int)floor(v);
return fmin(v - i, 0x1.fffffep-1f);
diff --git a/scriptc/rs_math.rsh b/scriptc/rs_math.rsh
index 3d034d0..849b52e 100644
--- a/scriptc/rs_math.rsh
+++ b/scriptc/rs_math.rsh
@@ -58,14 +58,22 @@
*
* The inverse of pi, as a 32 bit float.
*/
+#if (defined(RS_VERSION) && (RS_VERSION >= UNRELEASED))
+extern const float M_1_PI;
+#else
#define M_1_PI 0.318309886183790671537767526745028724f
+#endif
/*
* M_2_PI: 2 / pi, as a 32 bit float
*
* 2 divided by pi, as a 32 bit float.
*/
+#if (defined(RS_VERSION) && (RS_VERSION >= UNRELEASED))
+extern const float M_2_PI;
+#else
#define M_2_PI 0.636619772367581343075535053490057448f
+#endif
/*
* M_2_PIl: 2 / pi, as a 32 bit float
@@ -74,84 +82,132 @@
*
* 2 divided by pi, as a 32 bit float.
*/
+#if (defined(RS_VERSION) && (RS_VERSION >= UNRELEASED))
+extern const float M_2_PIl;
+#else
#define M_2_PIl 0.636619772367581343075535053490057448f
+#endif
/*
* M_2_SQRTPI: 2 / sqrt(pi), as a 32 bit float
*
* 2 divided by the square root of pi, as a 32 bit float.
*/
+#if (defined(RS_VERSION) && (RS_VERSION >= UNRELEASED))
+extern const float M_2_SQRTPI;
+#else
#define M_2_SQRTPI 1.128379167095512573896158903121545172f
+#endif
/*
* M_E: e, as a 32 bit float
*
* The number e, the base of the natural logarithm, as a 32 bit float.
*/
+#if (defined(RS_VERSION) && (RS_VERSION >= UNRELEASED))
+extern const float M_E;
+#else
#define M_E 2.718281828459045235360287471352662498f
+#endif
/*
* M_LN10: log_e(10), as a 32 bit float
*
* The natural logarithm of 10, as a 32 bit float.
*/
+#if (defined(RS_VERSION) && (RS_VERSION >= UNRELEASED))
+extern const float M_LN10;
+#else
#define M_LN10 2.302585092994045684017991454684364208f
+#endif
/*
* M_LN2: log_e(2), as a 32 bit float
*
* The natural logarithm of 2, as a 32 bit float.
*/
+#if (defined(RS_VERSION) && (RS_VERSION >= UNRELEASED))
+extern const float M_LN2;
+#else
#define M_LN2 0.693147180559945309417232121458176568f
+#endif
/*
* M_LOG10E: log_10(e), as a 32 bit float
*
* The logarithm base 10 of e, as a 32 bit float.
*/
+#if (defined(RS_VERSION) && (RS_VERSION >= UNRELEASED))
+extern const float M_LOG10E;
+#else
#define M_LOG10E 0.434294481903251827651128918916605082f
+#endif
/*
* M_LOG2E: log_2(e), as a 32 bit float
*
* The logarithm base 2 of e, as a 32 bit float.
*/
+#if (defined(RS_VERSION) && (RS_VERSION >= UNRELEASED))
+extern const float M_LOG2E;
+#else
#define M_LOG2E 1.442695040888963407359924681001892137f
+#endif
/*
* M_PI: pi, as a 32 bit float
*
* The constant pi, as a 32 bit float.
*/
+#if (defined(RS_VERSION) && (RS_VERSION >= UNRELEASED))
+extern const float M_PI;
+#else
#define M_PI 3.141592653589793238462643383279502884f
+#endif
/*
* M_PI_2: pi / 2, as a 32 bit float
*
* Pi divided by 2, as a 32 bit float.
*/
+#if (defined(RS_VERSION) && (RS_VERSION >= UNRELEASED))
+extern const float M_PI_2;
+#else
#define M_PI_2 1.570796326794896619231321691639751442f
+#endif
/*
* M_PI_4: pi / 4, as a 32 bit float
*
* Pi divided by 4, as a 32 bit float.
*/
+#if (defined(RS_VERSION) && (RS_VERSION >= UNRELEASED))
+extern const float M_PI_4;
+#else
#define M_PI_4 0.785398163397448309615660845819875721f
+#endif
/*
* M_SQRT1_2: 1 / sqrt(2), as a 32 bit float
*
* The inverse of the square root of 2, as a 32 bit float.
*/
+#if (defined(RS_VERSION) && (RS_VERSION >= UNRELEASED))
+extern const float M_SQRT1_2;
+#else
#define M_SQRT1_2 0.707106781186547524400844362104849039f
+#endif
/*
* M_SQRT2: sqrt(2), as a 32 bit float
*
* The square root of 2, as a 32 bit float.
*/
+#if (defined(RS_VERSION) && (RS_VERSION >= UNRELEASED))
+extern const float M_SQRT2;
+#else
#define M_SQRT2 1.414213562373095048801688724209698079f
+#endif
/*
* abs: Absolute value of an integer