Make RS compile on ARM64.
bug 13280327
Change-Id: I79080c448ca17d0cba8df075737c22b24ce9a085
diff --git a/cpu_ref/rsCpuScript.cpp b/cpu_ref/rsCpuScript.cpp
index 2b69d85..2cf9b83 100644
--- a/cpu_ref/rsCpuScript.cpp
+++ b/cpu_ref/rsCpuScript.cpp
@@ -4,7 +4,7 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+< *
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@@ -17,6 +17,7 @@
#include "rsCpuCore.h"
#include "rsCpuScript.h"
+#ifndef FAKE_ARM64_BUILD
#ifdef RS_COMPATIBILITY_LIB
#include <set>
#include <string>
@@ -38,8 +39,10 @@
#include <sys/wait.h>
#include <unistd.h>
#endif
+#endif
namespace {
+#ifndef FAKE_ARM64_BUILD
#ifdef RS_COMPATIBILITY_LIB
// Create a len length string containing random characters from [A-Za-z0-9].
@@ -278,12 +281,12 @@
#endif // EXTERNAL_BCC_COMPILER
#endif // !defined(RS_COMPATIBILITY_LIB)
+#endif
} // namespace
namespace android {
namespace renderscript {
-
#ifdef RS_COMPATIBILITY_LIB
#define MAXLINE 500
#define MAKE_STR_HELPER(S) #S
@@ -327,6 +330,7 @@
mCtx = ctx;
mScript = s;
+#ifndef FAKE_ARM64_BUILD
#ifdef RS_COMPATIBILITY_LIB
mScriptSO = NULL;
mInvokeFunctions = NULL;
@@ -340,6 +344,7 @@
mExecutable = NULL;
#endif
+
mRoot = NULL;
mRootExpand = NULL;
mInit = NULL;
@@ -349,6 +354,7 @@
mBoundAllocs = NULL;
mIntrinsicData = NULL;
mIsThreadable = true;
+#endif
}
@@ -359,7 +365,7 @@
//ALOGE("rsdScriptInit %p %p", rsc, script);
mCtx->lockMutex();
-
+#ifndef FAKE_ARM64_BUILD
#ifndef RS_COMPATIBILITY_LIB
bcc::RSExecutable *exec = NULL;
@@ -418,7 +424,7 @@
#if defined(__i386__)
// x86 devices will use an optimized library.
- core_lib = bcc::RSInfo::LibCLCoreX86Path;
+ core_lib = bcc::RSInfo::LibCLCoreX86Path;
#endif
RSSelectRTCallback selectRTCallback = mCtx->getSelectRTCallback();
@@ -680,7 +686,7 @@
goto error;
}
#endif
-
+#endif // FAKE_ARM64_BUILD
mCtx->unlockMutex();
return true;
@@ -702,6 +708,7 @@
}
void RsdCpuScriptImpl::populateScript(Script *script) {
+#ifndef FAKE_ARM64_BUILD
#ifndef RS_COMPATIBILITY_LIB
const bcc::RSInfo *info = &mExecutable->getInfo();
@@ -735,6 +742,7 @@
script->mHal.info.root = mRoot;
}
#endif
+#endif
}
@@ -859,6 +867,7 @@
void RsdCpuScriptImpl::forEachKernelSetup(uint32_t slot, MTLaunchStruct *mtls) {
mtls->script = this;
mtls->fep.slot = slot;
+#ifndef FAKE_ARM64_BUILD
#ifndef RS_COMPATIBILITY_LIB
rsAssert(slot < mExecutable->getExportForeachFuncAddrs().size());
mtls->kernel = reinterpret_cast<ForEachFunc_t>(
@@ -870,25 +879,34 @@
rsAssert(mtls->kernel != NULL);
mtls->sig = mForEachSignatures[slot];
#endif
+#endif
}
int RsdCpuScriptImpl::invokeRoot() {
RsdCpuScriptImpl * oldTLS = mCtx->setTLS(this);
+#ifndef FAKE_ARM64_BUILD
int ret = mRoot();
+#else
+ int ret = 0;
+#endif
mCtx->setTLS(oldTLS);
return ret;
}
void RsdCpuScriptImpl::invokeInit() {
+#ifndef FAKE_ARM64_BUILD
if (mInit) {
mInit();
}
+#endif
}
void RsdCpuScriptImpl::invokeFreeChildren() {
+#ifndef FAKE_ARM64_BUILD
if (mFreeChildren) {
mFreeChildren();
}
+#endif
}
void RsdCpuScriptImpl::invokeFunction(uint32_t slot, const void *params,
@@ -896,12 +914,14 @@
//ALOGE("invoke %p %p %i %p %i", dc, script, slot, params, paramLength);
RsdCpuScriptImpl * oldTLS = mCtx->setTLS(this);
+#ifndef FAKE_ARM64_BUILD
reinterpret_cast<void (*)(const void *, uint32_t)>(
#ifndef RS_COMPATIBILITY_LIB
mExecutable->getExportFuncAddrs()[slot])(params, paramLength);
#else
mInvokeFunctions[slot])(params, paramLength);
#endif
+#endif
mCtx->setTLS(oldTLS);
}
@@ -914,12 +934,16 @@
//return;
//}
+#ifndef FAKE_ARM64_BUILD
#ifndef RS_COMPATIBILITY_LIB
int32_t *destPtr = reinterpret_cast<int32_t *>(
mExecutable->getExportVarAddrs()[slot]);
#else
int32_t *destPtr = reinterpret_cast<int32_t *>(mFieldAddress[slot]);
#endif
+#else
+ int32_t *destPtr = NULL;
+#endif
if (!destPtr) {
//ALOGV("Calling setVar on slot = %i which is null", slot);
return;
@@ -932,12 +956,16 @@
//rsAssert(!script->mFieldIsObject[slot]);
//ALOGE("getGlobalVar %p %p %i %p %i", dc, script, slot, data, dataLength);
+#ifndef FAKE_ARM64_BUILD
#ifndef RS_COMPATIBILITY_LIB
int32_t *srcPtr = reinterpret_cast<int32_t *>(
mExecutable->getExportVarAddrs()[slot]);
#else
int32_t *srcPtr = reinterpret_cast<int32_t *>(mFieldAddress[slot]);
#endif
+#else
+ int32_t *srcPtr = NULL;
+#endif
if (!srcPtr) {
//ALOGV("Calling setVar on slot = %i which is null", slot);
return;
@@ -950,12 +978,16 @@
const Element *elem,
const size_t *dims, size_t dimLength) {
+#ifndef FAKE_ARM64_BUILD
#ifndef RS_COMPATIBILITY_LIB
int32_t *destPtr = reinterpret_cast<int32_t *>(
mExecutable->getExportVarAddrs()[slot]);
#else
int32_t *destPtr = reinterpret_cast<int32_t *>(mFieldAddress[slot]);
#endif
+#else
+ int32_t *destPtr = NULL;
+#endif
if (!destPtr) {
//ALOGV("Calling setVar on slot = %i which is null", slot);
return;
@@ -992,12 +1024,16 @@
//rsAssert(!script->mFieldIsObject[slot]);
//ALOGE("setGlobalBind %p %p %i %p", dc, script, slot, data);
+#ifndef FAKE_ARM64_BUILD
#ifndef RS_COMPATIBILITY_LIB
int32_t *destPtr = reinterpret_cast<int32_t *>(
mExecutable->getExportVarAddrs()[slot]);
#else
int32_t *destPtr = reinterpret_cast<int32_t *>(mFieldAddress[slot]);
#endif
+#else
+ int32_t *destPtr = NULL;
+#endif
if (!destPtr) {
//ALOGV("Calling setVar on slot = %i which is null", slot);
return;
@@ -1021,12 +1057,18 @@
//return;
//}
+#ifndef FAKE_ARM64_BUILD
#ifndef RS_COMPATIBILITY_LIB
int32_t *destPtr = reinterpret_cast<int32_t *>(
mExecutable->getExportVarAddrs()[slot]);
#else
int32_t *destPtr = reinterpret_cast<int32_t *>(mFieldAddress[slot]);
#endif
+#else
+ int32_t *destPtr = NULL;
+#endif
+
+
if (!destPtr) {
//ALOGV("Calling setVar on slot = %i which is null", slot);
return;
@@ -1036,6 +1078,7 @@
}
RsdCpuScriptImpl::~RsdCpuScriptImpl() {
+#ifndef FAKE_ARM64_BUILD
#ifndef RS_COMPATIBILITY_LIB
if (mExecutable) {
Vector<void *>::const_iterator var_addr_iter =
@@ -1099,6 +1142,7 @@
dlclose(mScriptSO);
}
#endif
+#endif
}
Allocation * RsdCpuScriptImpl::getAllocationForPointer(const void *ptr) const {