summaryrefslogtreecommitdiff
path: root/cpu_ref/rsCpuExecutable.h
diff options
context:
space:
mode:
authorYang Ni <yangni@google.com>2015-04-16 10:27:02 -0700
committerYang Ni <yangni@google.com>2015-04-16 15:29:11 -0700
commitcb17015fed6b11a5028f31cc804a3847e379945d (patch)
tree85179b598a90ed179586cf880321b524a3d49f7e /cpu_ref/rsCpuExecutable.h
parentf28aa55e416e662082bfda5716c4afbac7a77bbe (diff)
downloadrs-cb17015fed6b11a5028f31cc804a3847e379945d.tar.gz
Dedup checksum calculation routines
I introduced a separate routine to cacluate checksum for ScriptGroup in my previous CL, in addition to the one we use for regular scripts. This CL removes the new one and uses the old one. While I am on it, I made some other minor changes, e.g., changing mBuildChecksum in RsdCpuScriptIml from char* to uint32_t, and a few other minor cleanups in ScriptGroup2 implementation. Change-Id: I168fdbb4e7bd14f1549a687e7b0d0ca6dd4da866
Diffstat (limited to 'cpu_ref/rsCpuExecutable.h')
-rw-r--r--cpu_ref/rsCpuExecutable.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/cpu_ref/rsCpuExecutable.h b/cpu_ref/rsCpuExecutable.h
index ed6904d0..785f53d1 100644
--- a/cpu_ref/rsCpuExecutable.h
+++ b/cpu_ref/rsCpuExecutable.h
@@ -64,7 +64,7 @@ public:
size_t forEachCount,
const char** pragmaKeys, const char** pragmaValues,
size_t pragmaCount,
- bool isThreadable, const char *buildChecksum) :
+ bool isThreadable, uint32_t buildChecksum) :
mFieldAddress(fieldAddress), mFieldIsObject(fieldIsObject),
mFieldName(fieldName), mExportedVarCount(varCount),
mInvokeFunctions(invokeFunctions), mFuncCount(funcCount),
@@ -86,7 +86,6 @@ public:
}
}
- delete[] mBuildChecksum;
for (size_t i = 0; i < mPragmaCount; ++i) {
delete [] mPragmaKeys[i];
delete [] mPragmaValues[i];
@@ -107,8 +106,13 @@ public:
delete[] mFieldAddress;
}
+ // Create an ScriptExecutable object from a shared object.
+ // If expectedChecksum is not zero, it will be compared to the checksum
+ // embedded in the shared object. A mismatch will cause a failure.
+ // If succeeded, returns the new object. Otherwise, returns nullptr.
static ScriptExecutable*
- createFromSharedObject(Context* RSContext, void* sharedObj);
+ createFromSharedObject(Context* RSContext, void* sharedObj,
+ uint32_t expectedChecksum = 0);
size_t getExportedVariableCount() const { return mExportedVarCount; }
size_t getExportedFunctionCount() const { return mFuncCount; }
@@ -130,11 +134,7 @@ public:
bool getThreadable() const { return mIsThreadable; }
- const char *getBuildChecksum() const { return mBuildChecksum; }
- bool isChecksumValid(const char *checksum) const {
- return (mBuildChecksum != nullptr &&
- strcmp(checksum, mBuildChecksum) == 0);
- }
+ uint32_t getBuildChecksum() const { return mBuildChecksum; }
private:
void** mFieldAddress;
@@ -154,7 +154,7 @@ private:
size_t mPragmaCount;
bool mIsThreadable;
- const char *mBuildChecksum;
+ uint32_t mBuildChecksum;
Context* mRS;
};