Add callback to allow replacement of runtime support library.
Change-Id: I84ec56dfb29a0158015ebf31b3a73ac5bf34ef98
diff --git a/cpu_ref/rsCpuCore.cpp b/cpu_ref/rsCpuCore.cpp
index 7facade..afa9c57 100644
--- a/cpu_ref/rsCpuCore.cpp
+++ b/cpu_ref/rsCpuCore.cpp
@@ -58,7 +58,8 @@
RsdCpuReference * RsdCpuReference::create(Context *rsc, uint32_t version_major,
uint32_t version_minor, sym_lookup_t lfn, script_lookup_t slfn
#ifndef RS_COMPATIBILITY_LIB
- , bcc::RSLinkRuntimeCallback pLinkRuntimeCallback
+ , bcc::RSLinkRuntimeCallback pLinkRuntimeCallback,
+ RSSelectRTCallback pSelectRTCallback
#endif
) {
@@ -73,6 +74,7 @@
#ifndef RS_COMPATIBILITY_LIB
cpu->setLinkRuntimeCallback(pLinkRuntimeCallback);
+ cpu->setSelectRTCallback(pSelectRTCallback);
#endif
return cpu;
@@ -105,6 +107,7 @@
mExit = false;
#ifndef RS_COMPATIBILITY_LIB
mLinkRuntimeCallback = NULL;
+ mSelectRTCallback = NULL;
#endif
}
diff --git a/cpu_ref/rsCpuCore.h b/cpu_ref/rsCpuCore.h
index 3ff8636..c6704fb 100644
--- a/cpu_ref/rsCpuCore.h
+++ b/cpu_ref/rsCpuCore.h
@@ -118,6 +118,13 @@
bcc::RSLinkRuntimeCallback getLinkRuntimeCallback() {
return mLinkRuntimeCallback;
}
+
+ void setSelectRTCallback(RSSelectRTCallback pSelectRTCallback) {
+ mSelectRTCallback = pSelectRTCallback;
+ }
+ RSSelectRTCallback getSelectRTCallback() {
+ return mSelectRTCallback;
+ }
#endif
virtual bool getInForEach() { return mInForEach; }
@@ -148,6 +155,7 @@
#ifndef RS_COMPATIBILITY_LIB
bcc::RSLinkRuntimeCallback mLinkRuntimeCallback;
+ RSSelectRTCallback mSelectRTCallback;
#endif
};
diff --git a/cpu_ref/rsCpuScript.cpp b/cpu_ref/rsCpuScript.cpp
index 7887474..ff1fd14 100644
--- a/cpu_ref/rsCpuScript.cpp
+++ b/cpu_ref/rsCpuScript.cpp
@@ -122,7 +122,6 @@
#ifndef RS_COMPATIBILITY_LIB
bcc::RSExecutable *exec;
- const bcc::RSInfo *info;
mCompilerContext = NULL;
mCompilerDriver = NULL;
@@ -145,8 +144,13 @@
mCompilerDriver->setRSRuntimeLookupFunction(lookupRuntimeStub);
mCompilerDriver->setRSRuntimeLookupContext(this);
+ const char *core_lib = NULL;
+ RSSelectRTCallback selectRTCallback = mCtx->getSelectRTCallback();
+ if (selectRTCallback != NULL) {
+ core_lib = selectRTCallback((const char *)bitcode, bitcodeSize);
+ }
exec = mCompilerDriver->build(*mCompilerContext, cacheDir, resName,
- (const char *)bitcode, bitcodeSize, NULL,
+ (const char *)bitcode, bitcodeSize, core_lib,
mCtx->getLinkRuntimeCallback());
if (exec == NULL) {
@@ -170,7 +174,7 @@
reinterpret_cast<void (*)()>(exec->getSymbolAddress(".rs.dtor"));
- info = &mExecutable->getInfo();
+ const bcc::RSInfo *info = &mExecutable->getInfo();
if (info->getExportVarNames().size()) {
mBoundAllocs = new Allocation *[info->getExportVarNames().size()];
memset(mBoundAllocs, 0, sizeof(void *) * info->getExportVarNames().size());
diff --git a/cpu_ref/rsd_cpu.h b/cpu_ref/rsd_cpu.h
index 13a9656..47984d9 100644
--- a/cpu_ref/rsd_cpu.h
+++ b/cpu_ref/rsd_cpu.h
@@ -32,6 +32,8 @@
typedef llvm::Module* (*RSLinkRuntimeCallback) (bcc::RSScript *, llvm::Module *, llvm::Module *);
} // end namespace bcc;
+
+typedef const char* (*RSSelectRTCallback) (const char*, size_t);
#endif
namespace android {
@@ -102,7 +104,8 @@
static RsdCpuReference * create(Context *c, uint32_t version_major,
uint32_t version_minor, sym_lookup_t lfn, script_lookup_t slfn
#ifndef RS_COMPATIBILITY_LIB
- , bcc::RSLinkRuntimeCallback pLinkRuntimeCallback = NULL
+ , bcc::RSLinkRuntimeCallback pLinkRuntimeCallback = NULL,
+ RSSelectRTCallback pSelectRTCallback = NULL
#endif
);
virtual ~RsdCpuReference();