harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From var...@apache.org
Subject svn commit: r480009 - /harmony/enhanced/drlvm/trunk/vm/port/src/misc/win/sysinfo.c
Date Tue, 28 Nov 2006 11:53:55 GMT
Author: varlax
Date: Tue Nov 28 03:53:54 2006
New Revision: 480009

URL: http://svn.apache.org/viewvc?view=rev&rev=480009
Log:
HARMONY-2154 port_CPUs_number returns incorrect information on EM64T in wow mode
Applied fix for the issue subject; left port_Cores_number number aside.
Tested on Win2003sp1

Modified:
    harmony/enhanced/drlvm/trunk/vm/port/src/misc/win/sysinfo.c

Modified: harmony/enhanced/drlvm/trunk/vm/port/src/misc/win/sysinfo.c
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/port/src/misc/win/sysinfo.c?view=diff&rev=480009&r1=480008&r2=480009
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/port/src/misc/win/sysinfo.c (original)
+++ harmony/enhanced/drlvm/trunk/vm/port/src/misc/win/sysinfo.c Tue Nov 28 03:53:54 2006
@@ -14,10 +14,6 @@
  *  See the License for the specific language governing permissions and
  *  limitations under the License.
  */
-/** 
-* @author Alexey V. Varlamov
-* @version $Revision: 1.1.2.1.4.3 $
-*/  
 
 #include <stdio.h>
 #include <windows.h>
@@ -25,7 +21,21 @@
 
 APR_DECLARE(int) port_CPUs_number() {
 	SYSTEM_INFO sys_info;
-	GetSystemInfo(&sys_info);
+	typedef void (WINAPI *PTR_GETNATIVESYSTEM_INFO)(LPSYSTEM_INFO);
+	static PTR_GETNATIVESYSTEM_INFO pTrGetNativeSystemInfo = NULL;
+    if (!pTrGetNativeSystemInfo) {
+        HMODULE h = GetModuleHandleA("kernel32.dll");
+       /* 
+        * Use GetNativeSystemInfo if available in kernel 
+        * It provides more accurate info in WOW64 mode
+        */
+        pTrGetNativeSystemInfo = (PTR_GETNATIVESYSTEM_INFO) GetProcAddress(h, "GetNativeSystemInfo");
+    }
+    if(pTrGetNativeSystemInfo != NULL) {
+		pTrGetNativeSystemInfo(&sys_info);
+    } else {
+		GetSystemInfo(&sys_info);
+    }
 	return sys_info.dwNumberOfProcessors;
 }
 



Mime
View raw message