OSDN Git Service

merge from open-source master
authorThe Android Open Source Project <initial-contribution@android.com>
Tue, 15 Jun 2010 21:46:37 +0000 (14:46 -0700)
committerThe Android Open Source Project <initial-contribution@android.com>
Tue, 15 Jun 2010 21:46:37 +0000 (14:46 -0700)
Change-Id: I919a5dd1cc8d615c2d9224ff08e849394ee84df0

1  2 
vm/native/java_lang_Runtime.c

@@@ -19,7 -19,8 +19,8 @@@
   */
  #include "Dalvik.h"
  #include "native/InternalNativePriv.h"
+ #include <unistd.h>
+ #include <limits.h>
  
  /*
   * public void gc()
@@@ -53,9 -54,6 +54,9 @@@ static void Dalvik_java_lang_Runtime_na
          LOGW("JNI exit hook returned\n");
      }
      LOGD("Calling exit(%d)\n", status);
 +#if defined(WITH_JIT) && defined(WITH_JIT_TUNING)
 +    dvmCompilerDumpStats();
 +#endif
      exit(status);
  }
  
@@@ -109,6 -107,26 +110,26 @@@ static void Dalvik_java_lang_Runtime_ru
  }
  
  /*
+  * 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.
@@@ -152,6 -170,8 +173,8 @@@ const DalvikNativeMethod dvm_java_lang_
          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",