Remove libutils and fix rsDebug for RS support library.

Bug: 9664050

Our bitcode runtime library translates vector rsDebug() calls into passing
their parameters via pointers. The previous version of libRSSupport.so was
being created with non-pointer versions of these routines accidentally.
This change also fixes a missing permission issue for ImageProcessing2, so
that the compatibility library can be verified.

This change also removes the use of libutils by switching the implementation of
String8/Vector in the compatibility library to internal types backed by
libstlport_static.

Change-Id: I20da75e8c19a82a42dc2bceaba1937d21372db84
diff --git a/cpu_ref/rsCpuCore.cpp b/cpu_ref/rsCpuCore.cpp
index afa9c57..a4cf0ad 100644
--- a/cpu_ref/rsCpuCore.cpp
+++ b/cpu_ref/rsCpuCore.cpp
@@ -26,8 +26,9 @@
 #include <sched.h>
 #include <sys/syscall.h>
 #include <string.h>
+#include <unistd.h>
 
-#ifndef RS_SERVER
+#if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB)
 #include <cutils/properties.h>
 #include "utils/StopWatch.h"
 #endif
diff --git a/cpu_ref/rsCpuRuntimeStubs.cpp b/cpu_ref/rsCpuRuntimeStubs.cpp
index 889e008..9685511 100644
--- a/cpu_ref/rsCpuRuntimeStubs.cpp
+++ b/cpu_ref/rsCpuRuntimeStubs.cpp
@@ -26,10 +26,6 @@
 
 #include <time.h>
 
-#ifndef RS_SERVER
-#include "utils/Timers.h"
-#endif
-
 using namespace android;
 using namespace android::renderscript;
 
diff --git a/cpu_ref/rsCpuScript.cpp b/cpu_ref/rsCpuScript.cpp
index d9e0044..22e2f0e 100644
--- a/cpu_ref/rsCpuScript.cpp
+++ b/cpu_ref/rsCpuScript.cpp
@@ -19,15 +19,6 @@
 #include "rsCpuCore.h"
 
 #include "rsCpuScript.h"
-//#include "rsdRuntime.h"
-//#include "rsdAllocation.h"
-//#include "rsCpuIntrinsics.h"
-
-#ifndef RS_SERVER
-#include "utils/Vector.h"
-#include "utils/Timers.h"
-#include "utils/StopWatch.h"
-#endif
 
 #ifdef RS_COMPATIBILITY_LIB
     #include <dlfcn.h>
@@ -191,8 +182,7 @@
 #ifndef RS_SERVER
     String8 scriptSOName(cacheDir);
     scriptSOName = scriptSOName.getPathDir();
-    scriptSOName.appendPath("lib");
-    scriptSOName.append("/librs.");
+    scriptSOName.append("/lib/librs.");
 #else
     String8 scriptSOName("lib");
 #endif
diff --git a/cpu_ref/rsCpuScriptGroup.cpp b/cpu_ref/rsCpuScriptGroup.cpp
index b3b5bf9..91779b4 100644
--- a/cpu_ref/rsCpuScriptGroup.cpp
+++ b/cpu_ref/rsCpuScriptGroup.cpp
@@ -16,16 +16,6 @@
 
 #include "rsCpuCore.h"
 #include "rsCpuScript.h"
-#include "rsCpuScriptGroup.h"
-
-#ifndef RS_SERVER
-#include <bcc/BCCContext.h>
-#include <bcc/Renderscript/RSCompilerDriver.h>
-#include <bcc/Renderscript/RSExecutable.h>
-#include <bcc/Renderscript/RSInfo.h>
-#endif
-
-#include "rsScript.h"
 #include "rsScriptGroup.h"
 #include "rsCpuScriptGroup.h"
 //#include "rsdBcc.h"
diff --git a/driver/rsdAllocation.cpp b/driver/rsdAllocation.cpp
index f502f32..2daafbe 100644
--- a/driver/rsdAllocation.cpp
+++ b/driver/rsdAllocation.cpp
@@ -19,10 +19,12 @@
 
 #include "rsAllocation.h"
 
-#ifndef RS_SERVER
+#if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB)
 #include "system/window.h"
 #include "ui/Rect.h"
 #include "ui/GraphicBufferMapper.h"
+#else
+#include "system/graphics.h"
 #endif
 
 #ifndef RS_COMPATIBILITY_LIB
diff --git a/driver/rsdAllocation.h b/driver/rsdAllocation.h
index 97e0d6a..35999d3 100644
--- a/driver/rsdAllocation.h
+++ b/driver/rsdAllocation.h
@@ -24,12 +24,15 @@
 #include "../cpu_ref/rsd_cpu.h"
 
 #ifndef RS_SERVER
-#include "gui/CpuConsumer.h"
-#include "gui/GLConsumer.h"
 #include <GLES/gl.h>
 #include <GLES2/gl2.h>
 #endif
 
+#if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB)
+#include "gui/CpuConsumer.h"
+#include "gui/GLConsumer.h"
+#endif
+
 class RsdFrameBufferObj;
 struct ANativeWindow;
 struct ANativeWindowBuffer;
@@ -77,7 +80,7 @@
     ANativeWindow *wnd;
     ANativeWindowBuffer *wndBuffer;
 
-#ifndef RS_SERVER
+#if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB)
     android::sp< android::CpuConsumer > cpuConsumer;
     android::CpuConsumer::LockedBuffer lb;
 #endif
diff --git a/driver/rsdBcc.cpp b/driver/rsdBcc.cpp
index 9252dbf..212184e 100644
--- a/driver/rsdBcc.cpp
+++ b/driver/rsdBcc.cpp
@@ -25,7 +25,7 @@
 #include "rsElement.h"
 #include "rsScriptC.h"
 
-#ifndef RS_SERVER
+#if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB)
 #include "utils/Vector.h"
 #include "utils/Timers.h"
 #include "utils/StopWatch.h"
diff --git a/driver/rsdRuntimeStubs.cpp b/driver/rsdRuntimeStubs.cpp
index c22b966..cb3a5b4 100644
--- a/driver/rsdRuntimeStubs.cpp
+++ b/driver/rsdRuntimeStubs.cpp
@@ -1442,31 +1442,31 @@
     SC_debugFv4(s, f1, f2, f3, f4);
 }
 
-void rsDebug(const char *s, float2 f) {
-    SC_debugF2(s, f);
+void rsDebug(const char *s, const float2 *f) {
+    SC_debugF2(s, *f);
 }
 
-void rsDebug(const char *s, float3 f) {
-    SC_debugF3(s, f);
+void rsDebug(const char *s, const float3 *f) {
+    SC_debugF3(s, *f);
 }
 
-void rsDebug(const char *s, float4 f) {
-    SC_debugF4(s, f);
+void rsDebug(const char *s, const float4 *f) {
+    SC_debugF4(s, *f);
 }
 
 void rsDebug(const char *s, double d) {
     SC_debugD(s, d);
 }
 
-void rsDebug(const char *s, rs_matrix4x4 *m) {
+void rsDebug(const char *s, const rs_matrix4x4 *m) {
     SC_debugFM4v4(s, (float *) m);
 }
 
-void rsDebug(const char *s, rs_matrix3x3 *m) {
+void rsDebug(const char *s, const rs_matrix3x3 *m) {
     SC_debugFM3v3(s, (float *) m);
 }
 
-void rsDebug(const char *s, rs_matrix2x2 *m) {
+void rsDebug(const char *s, const rs_matrix2x2 *m) {
     SC_debugFM2v2(s, (float *) m);
 }
 
@@ -1474,96 +1474,96 @@
     SC_debugI8(s, c);
 }
 
-void rsDebug(const char *s, char2 c) {
-    SC_debugC2(s, c);
+void rsDebug(const char *s, const char2 *c) {
+    SC_debugC2(s, *c);
 }
 
-void rsDebug(const char *s, char3 c) {
-    SC_debugC3(s, c);
+void rsDebug(const char *s, const char3 *c) {
+    SC_debugC3(s, *c);
 }
 
-void rsDebug(const char *s, char4 c) {
-    SC_debugC4(s, c);
+void rsDebug(const char *s, const char4 *c) {
+    SC_debugC4(s, *c);
 }
 
 void rsDebug(const char *s, unsigned char c) {
     SC_debugU8(s, c);
 }
 
-void rsDebug(const char *s, uchar2 c) {
-    SC_debugUC2(s, c);
+void rsDebug(const char *s, const uchar2 *c) {
+    SC_debugUC2(s, *c);
 }
 
-void rsDebug(const char *s, uchar3 c) {
-    SC_debugUC3(s, c);
+void rsDebug(const char *s, const uchar3 *c) {
+    SC_debugUC3(s, *c);
 }
 
-void rsDebug(const char *s, uchar4 c) {
-    SC_debugUC4(s, c);
+void rsDebug(const char *s, const uchar4 *c) {
+    SC_debugUC4(s, *c);
 }
 
 void rsDebug(const char *s, short c) {
     SC_debugI16(s, c);
 }
 
-void rsDebug(const char *s, short2 c) {
-    SC_debugS2(s, c);
+void rsDebug(const char *s, const short2 *c) {
+    SC_debugS2(s, *c);
 }
 
-void rsDebug(const char *s, short3 c) {
-    SC_debugS3(s, c);
+void rsDebug(const char *s, const short3 *c) {
+    SC_debugS3(s, *c);
 }
 
-void rsDebug(const char *s, short4 c) {
-    SC_debugS4(s, c);
+void rsDebug(const char *s, const short4 *c) {
+    SC_debugS4(s, *c);
 }
 
 void rsDebug(const char *s, unsigned short c) {
     SC_debugU16(s, c);
 }
 
-void rsDebug(const char *s, ushort2 c) {
-    SC_debugUS2(s, c);
+void rsDebug(const char *s, const ushort2 *c) {
+    SC_debugUS2(s, *c);
 }
 
-void rsDebug(const char *s, ushort3 c) {
-    SC_debugUS3(s, c);
+void rsDebug(const char *s, const ushort3 *c) {
+    SC_debugUS3(s, *c);
 }
 
-void rsDebug(const char *s, ushort4 c) {
-    SC_debugUS4(s, c);
+void rsDebug(const char *s, const ushort4 *c) {
+    SC_debugUS4(s, *c);
 }
 
 void rsDebug(const char *s, int c) {
     SC_debugI32(s, c);
 }
 
-void rsDebug(const char *s, int2 c) {
-    SC_debugI2(s, c);
+void rsDebug(const char *s, const int2 *c) {
+    SC_debugI2(s, *c);
 }
 
-void rsDebug(const char *s, int3 c) {
-    SC_debugI3(s, c);
+void rsDebug(const char *s, const int3 *c) {
+    SC_debugI3(s, *c);
 }
 
-void rsDebug(const char *s, int4 c) {
-    SC_debugI4(s, c);
+void rsDebug(const char *s, const int4 *c) {
+    SC_debugI4(s, *c);
 }
 
 void rsDebug(const char *s, unsigned int c) {
     SC_debugU32(s, c);
 }
 
-void rsDebug(const char *s, uint2 c) {
-    SC_debugUI2(s, c);
+void rsDebug(const char *s, const uint2 *c) {
+    SC_debugUI2(s, *c);
 }
 
-void rsDebug(const char *s, uint3 c) {
-    SC_debugUI3(s, c);
+void rsDebug(const char *s, const uint3 *c) {
+    SC_debugUI3(s, *c);
 }
 
-void rsDebug(const char *s, uint4 c) {
-    SC_debugUI4(s, c);
+void rsDebug(const char *s, const uint4 *c) {
+    SC_debugUI4(s, *c);
 }
 
 void rsDebug(const char *s, long c) {
@@ -1574,16 +1574,16 @@
     SC_debugLL64(s, c);
 }
 
-void rsDebug(const char *s, long2 c) {
-    SC_debugL2(s, c);
+void rsDebug(const char *s, const long2 *c) {
+    SC_debugL2(s, *c);
 }
 
-void rsDebug(const char *s, long3 c) {
-    SC_debugL3(s, c);
+void rsDebug(const char *s, const long3 *c) {
+    SC_debugL3(s, *c);
 }
 
-void rsDebug(const char *s, long4 c) {
-    SC_debugL4(s, c);
+void rsDebug(const char *s, const long4 *c) {
+    SC_debugL4(s, *c);
 }
 
 void rsDebug(const char *s, unsigned long c) {
@@ -1594,16 +1594,16 @@
     SC_debugULL64(s, c);
 }
 
-void rsDebug(const char *s, ulong2 c) {
-    SC_debugUL2(s, c);
+void rsDebug(const char *s, const ulong2 *c) {
+    SC_debugUL2(s, *c);
 }
 
-void rsDebug(const char *s, ulong3 c) {
-    SC_debugUL3(s, c);
+void rsDebug(const char *s, const ulong3 *c) {
+    SC_debugUL3(s, *c);
 }
 
-void rsDebug(const char *s, ulong4 c) {
-    SC_debugUL4(s, c);
+void rsDebug(const char *s, const ulong4 *c) {
+    SC_debugUL4(s, *c);
 }
 
 void rsDebug(const char *s, const void *p) {
diff --git a/driver/rsdShaderCache.h b/driver/rsdShaderCache.h
index 1ac1aa1..6de1d63 100644
--- a/driver/rsdShaderCache.h
+++ b/driver/rsdShaderCache.h
@@ -25,7 +25,7 @@
 }
 }
 
-#ifndef RS_SERVER
+#if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB)
 #include <utils/String8.h>
 #include <utils/Vector.h>
 #else
diff --git a/java/tests/ImageProcessing2/AndroidManifest.xml b/java/tests/ImageProcessing2/AndroidManifest.xml
index 20ee053..0129fa8 100644
--- a/java/tests/ImageProcessing2/AndroidManifest.xml
+++ b/java/tests/ImageProcessing2/AndroidManifest.xml
@@ -2,6 +2,7 @@
 
 <manifest xmlns:android="http://schemas.android.com/apk/res/android"
     package="com.android.rs.image2">
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
     <uses-sdk android:minSdkVersion="8" />
     <application android:label="IP GB">
         <activity android:name="ImageProcessingActivity2">
diff --git a/rsAllocation.cpp b/rsAllocation.cpp
index b558d10..0c271c1 100644
--- a/rsAllocation.cpp
+++ b/rsAllocation.cpp
@@ -19,7 +19,7 @@
 #include "rsAdapter.h"
 #include "rs_hal.h"
 
-#ifndef RS_SERVER
+#if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB)
 #include "system/window.h"
 #include "gui/GLConsumer.h"
 #endif
diff --git a/rsContext.cpp b/rsContext.cpp
index bb2808e..74c40c5 100644
--- a/rsContext.cpp
+++ b/rsContext.cpp
@@ -32,8 +32,9 @@
 #include <sys/syscall.h>
 #include <string.h>
 #include <dlfcn.h>
+#include <unistd.h>
 
-#ifndef RS_SERVER
+#if !defined(RS_SERVER)
 #include <cutils/properties.h>
 #endif
 
diff --git a/rsCppUtils.h b/rsCppUtils.h
index abae7d8..ced13c1 100644
--- a/rsCppUtils.h
+++ b/rsCppUtils.h
@@ -17,7 +17,7 @@
 #ifndef ANDROID_RS_CPP_UTILS_H
 #define ANDROID_RS_CPP_UTILS_H
 
-#ifndef RS_SERVER
+#if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB)
 #include <utils/Log.h>
 #include <utils/String8.h>
 #include <utils/Vector.h>
@@ -32,12 +32,25 @@
 
 #include <math.h>
 
-#ifdef RS_SERVER
+#ifdef RS_COMPATIBILITY_LIB
+#include <android/log.h>
+#endif
+
+#if defined(RS_SERVER) || defined(RS_COMPATIBILITY_LIB)
 
 #include <string>
 #include <vector>
 #include <algorithm>
 
+#define ALOGE(...) \
+    __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__);
+#define ALOGW(...) \
+    __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__);
+#define ALOGD(...) \
+    __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__);
+#define ALOGV(...) \
+    __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__);
+
 namespace android {
 
     // server has no Vector or String8 classes; implement on top of STL
@@ -46,6 +59,9 @@
     String8(const char *ptr) : std::string(ptr) {
 
         }
+    String8(const char *ptr, size_t len) : std::string(ptr, len) {
+
+        }
     String8() : std::string() {
 
         }
@@ -60,7 +76,16 @@
         void setTo(const char* str) {
             this->assign(str);
         }
+        String8 getPathDir(void) const {
+            const char* cp;
+            const char*const str = this->c_str();
 
+            cp = strrchr(str, OS_PATH_SEPARATOR);
+            if (cp == NULL)
+                return String8("");
+            else
+                return String8(str, cp - str);
+        }
     };
 
     template <class T> class Vector: public std::vector<T> {
@@ -80,11 +105,11 @@
         }
 
         T* editArray() {
-            return this->data();
+            return (T*)(this->begin());
         }
 
         const T* array() {
-            return this->data();
+            return (const T*)(this->begin());
         }
 
     };
@@ -106,17 +131,56 @@
         }
 
         bool* editArray() {
-            return (bool*)this->data();
+            return (bool*)(this->begin());
         }
 
         const bool* array() {
-            return (const bool*)this->data();
+            return (const bool*)(this->begin());
         }
     };
 
 }
 
-#endif // RS_SERVER
+typedef int64_t nsecs_t;  // nano-seconds
+
+enum {
+    SYSTEM_TIME_REALTIME = 0,  // system-wide realtime clock
+    SYSTEM_TIME_MONOTONIC = 1, // monotonic time since unspecified starting point
+    SYSTEM_TIME_PROCESS = 2,   // high-resolution per-process clock
+    SYSTEM_TIME_THREAD = 3,    // high-resolution per-thread clock
+    SYSTEM_TIME_BOOTTIME = 4   // same as SYSTEM_TIME_MONOTONIC, but including CPU suspend time
+};
+
+static inline nsecs_t systemTime(int clock)
+{
+#if defined(HAVE_POSIX_CLOCKS)
+    static const clockid_t clocks[] = {
+            CLOCK_REALTIME,
+            CLOCK_MONOTONIC,
+            CLOCK_PROCESS_CPUTIME_ID,
+            CLOCK_THREAD_CPUTIME_ID,
+            CLOCK_BOOTTIME
+    };
+    struct timespec t;
+    t.tv_sec = t.tv_nsec = 0;
+    clock_gettime(clocks[clock], &t);
+    return nsecs_t(t.tv_sec)*1000000000LL + t.tv_nsec;
+#else
+    // we don't support the clocks here.
+    struct timeval t;
+    t.tv_sec = t.tv_usec = 0;
+    gettimeofday(&t, NULL);
+    return nsecs_t(t.tv_sec)*1000000000LL + nsecs_t(t.tv_usec)*1000LL;
+#endif
+}
+
+static inline nsecs_t nanoseconds_to_milliseconds(nsecs_t secs)
+{
+    return secs/1000000;
+}
+
+
+#endif // RS_SERVER || RS_COMPATIBILITY_LIB
 
 namespace android {
 namespace renderscript {
diff --git a/rsFifoSocket.cpp b/rsFifoSocket.cpp
index c10ec4f..51f3f07 100644
--- a/rsFifoSocket.cpp
+++ b/rsFifoSocket.cpp
@@ -24,11 +24,6 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 
-#ifndef RS_SERVER
-#include "utils/Timers.h"
-#include "utils/StopWatch.h"
-#endif
-
 using namespace android;
 using namespace android::renderscript;
 
diff --git a/rsObjectBase.cpp b/rsObjectBase.cpp
index f864bac..c8d7349 100644
--- a/rsObjectBase.cpp
+++ b/rsObjectBase.cpp
@@ -29,6 +29,7 @@
     mNext = NULL;
     mPrev = NULL;
     mDH = NULL;
+    mName = NULL;
 
 #if RS_OBJECT_DEBUG
     mDH = new DebugHelper();
@@ -47,6 +48,8 @@
     mDH = NULL;
 #endif
 
+    free(const_cast<char *>(mName));
+
     if (mPrev || mNext) {
         // While the normal practice is to call remove before we call
         // delete.  Its possible for objects without a re-use list
@@ -62,9 +65,9 @@
 }
 
 void ObjectBase::dumpLOGV(const char *op) const {
-    if (mName.size()) {
+    if (mName) {
         ALOGV("%s RSobj %p, name %s, refs %i,%i  links %p,%p,%p",
-             op, this, mName.string(), mUserRefCount, mSysRefCount, mNext, mPrev, mRSC);
+             op, this, mName, mUserRefCount, mSysRefCount, mNext, mPrev, mRSC);
     } else {
         ALOGV("%s RSobj %p, no-name, refs %i,%i  links %p,%p,%p",
              op, this, mUserRefCount, mSysRefCount, mNext, mPrev, mRSC);
@@ -152,11 +155,14 @@
 }
 
 void ObjectBase::setName(const char *name) {
-    mName.setTo(name);
+    mName = strdup(name);
 }
 
 void ObjectBase::setName(const char *name, uint32_t len) {
-    mName.setTo(name, len);
+    char *c = (char*)calloc(len + 1, sizeof(char));
+    rsAssert(c);
+    memcpy(c, name, len);
+    mName = c;
 }
 
 void ObjectBase::asyncLock() {
diff --git a/rsObjectBase.h b/rsObjectBase.h
index 470c334..12c89a3 100644
--- a/rsObjectBase.h
+++ b/rsObjectBase.h
@@ -42,7 +42,7 @@
     static bool checkDelete(const ObjectBase *);
 
     const char * getName() const {
-        return mName.string();
+        return mName;
     }
     void setName(const char *);
     void setName(const char *, uint32_t len);
@@ -79,7 +79,7 @@
     void add() const;
     void remove() const;
 
-    String8 mName;
+    const char* mName;
     mutable int32_t mSysRefCount;
     mutable int32_t mUserRefCount;
 
diff --git a/rsRuntime.h b/rsRuntime.h
index d55042c..2939176 100644
--- a/rsRuntime.h
+++ b/rsRuntime.h
@@ -17,7 +17,7 @@
 #include "rsContext.h"
 #include "rsScriptC.h"
 
-#ifndef RS_SERVER
+#if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB)
 #include "utils/Timers.h"
 #endif
 
diff --git a/rsScriptC.cpp b/rsScriptC.cpp
index 56c9f06..d8f356c 100644
--- a/rsScriptC.cpp
+++ b/rsScriptC.cpp
@@ -24,9 +24,8 @@
 #endif
 #endif
 
-#ifndef RS_SERVER
+#if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB)
 #include "utils/Timers.h"
-#include "utils/StopWatch.h"
 #endif
 
 #include <sys/stat.h>
diff --git a/rsScriptC_Lib.cpp b/rsScriptC_Lib.cpp
index cd5cc3b..123b8b3 100644
--- a/rsScriptC_Lib.cpp
+++ b/rsScriptC_Lib.cpp
@@ -21,7 +21,7 @@
 #include "rsMatrix2x2.h"
 #include "rsgApiStructs.h"
 
-#ifndef RS_SERVER
+#if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB)
 #include "utils/Timers.h"
 #endif
 
diff --git a/rsScriptGroup.cpp b/rsScriptGroup.cpp
index 55acf23..17ef211 100644
--- a/rsScriptGroup.cpp
+++ b/rsScriptGroup.cpp
@@ -78,7 +78,7 @@
     return ret;
 }
 
-#ifndef RS_SERVER
+#if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB)
 static int CompareNodeForSort(ScriptGroup::Node *const* lhs,
                               ScriptGroup::Node *const* rhs) {
     if (lhs[0]->mOrder > rhs[0]->mOrder) {
@@ -181,7 +181,7 @@
     }
 
     // sort
-#ifndef RS_SERVER
+#if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB)
     mNodes.sort(&CompareNodeForSort);
 #else
     std::sort(mNodes.begin(), mNodes.end(), NodeCompare());