include $(LOCAL_PATH)/ReconfigureDvm.mk
# Overwrite default settings
+ifneq ($(TARGET_ARCH),x86)
ifeq ($(TARGET_SIMULATOR),false)
LOCAL_PRELINK_MODULE := true
endif
+endif
LOCAL_MODULE_TAGS := user
LOCAL_MODULE := libdvm
LOCAL_CFLAGS += $(target_smp_flag)
*/
static void setThreadName(const char *threadName)
{
-#if defined(HAVE_PRCTL)
int hasAt = 0;
int hasDot = 0;
const char *s = threadName;
} else {
s = threadName + len - 15;
}
+#if defined(HAVE_PTHREAD_SETNAME_NP)
+ if (pthread_setname_np(pthread_self(), s) != 0)
+ LOGW("Unable to set the name of the current thread\n");
+#elif defined(HAVE_PRCTL)
prctl(PR_SET_NAME, (unsigned long) s, 0, 0, 0);
+#else
+ LOGD("Unable to set current thread's name: %s\n", s);
#endif
}
movl 32(%ebp), %ecx # %ecx<- return pointer
je 2f # handle double return
jl 1f # handle float return
+
+ /*
+ * If a native function returns a result smaller than 8-bytes
+ * then higher bytes may contain garbage.
+ * This code does type-checking based on size of return result.
+ * We zero higher bytes instead of allowing the garbage to go through.
+ */
+
+ cmpl $3,%ebx
+ je S8
+ cmpl $4,%ebx
+ je S4
+ cmpl $7,%ebx
+ je S1
+ cmpl $6,%ebx
+ jne S2
+U2:
+ movzwl %ax, %eax
+ movl %eax, (%ecx) # save 32-bit return
+ jmp CallABI_EXIT # exit call
+
+S1:
+ movsbl %al, %eax
movl %eax, (%ecx) # save 32-bit return
+ jmp CallABI_EXIT # exit call
+S2:
+ movswl %ax, %eax
+ movl %eax, (%ecx) # save 32-bit return
+ jmp CallABI_EXIT # exit call
+S4:
+ cltd
+ movl %eax, (%ecx) # save 32-bit return
+ jmp CallABI_EXIT # exit call
+S8:
movl %edx, 4(%ecx) # save 64-bit return
+ movl %eax, (%ecx) # save 32-bit return
jmp CallABI_EXIT # exit call
2:
*/
#include "Dalvik.h"
#include "native/InternalNativePriv.h"
-
+#include <unistd.h>
+#include <limits.h>
/*
* public void gc()
}
/*
+ * public int availableProcessors()
+ *
+ * Returns the number of online processors, at least one.
+ *
+ */
+static void Dalvik_java_lang_Runtime_availableProcessors(const u4* args,
+ JValue* pResult)
+{
+ long result = 1;
+#ifdef _SC_NPROCESSORS_ONLN
+ result = sysconf(_SC_NPROCESSORS_ONLN);
+ if (result > INT_MAX) {
+ result = INT_MAX;
+ } else if (result < 1 ) {
+ result = 1;
+ }
+#endif
+ RETURN_INT((int)result);
+}
+/*
* public void maxMemory()
*
* Returns GC heap max memory in bytes.
Dalvik_java_lang_Runtime_freeMemory },
{ "gc", "()V",
Dalvik_java_lang_Runtime_gc },
+ { "availableProcessors", "()I",
+ Dalvik_java_lang_Runtime_availableProcessors },
{ "maxMemory", "()J",
Dalvik_java_lang_Runtime_maxMemory },
{ "nativeExit", "(IZ)V",