*/
#include "Dalvik.h"
#include "native/InternalNativePriv.h"
-
+ #include <unistd.h>
+ #include <limits.h>
/*
* public void gc()
LOGW("JNI exit hook returned\n");
}
LOGD("Calling exit(%d)\n", status);
+#if defined(WITH_JIT) && defined(WITH_JIT_TUNING)
+ dvmCompilerDumpStats();
+#endif
exit(status);
}
}
/*
+ * 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",