Index: gc_gen/src/gen/gen.cpp =================================================================== --- gc_gen/src/gen/gen.cpp (revision 473200) +++ gc_gen/src/gen/gen.cpp (working copy) @@ -53,7 +53,11 @@ max_heap_size = round_up_to_size(max_heap_size, GC_BLOCK_SIZE_BYTES); gc_gen_get_system_info(gc_gen); + //RDG tests + printf("numprocs is %d\n", gc_gen->_num_processors); + printf("numcores is %d\n", port_Cores_number()); + void *reserved_base = NULL; /* allocate memory for gc_gen */ Index: port/include/port_sysinfo.h =================================================================== --- port/include/port_sysinfo.h (revision 473200) +++ port/include/port_sysinfo.h (working copy) @@ -42,6 +42,11 @@ APR_DECLARE(int) port_CPUs_number(void); /** +* Returns number of processors in the system. +*/ +APR_DECLARE(int) port_Cores_number(void); + +/** * Returns name of CPU architecture. */ APR_DECLARE(const char *) port_CPU_architecture(void); Index: port/src/misc/linux/sysinfo.c =================================================================== --- port/src/misc/linux/sysinfo.c (revision 473200) +++ port/src/misc/linux/sysinfo.c (working copy) @@ -46,6 +46,10 @@ return (int)sysconf(_SC_NPROCESSORS_CONF); } +APR_DECLARE(int) port_Cores_number(void) { + // To be replaced with a better implementation + return (int)sysconf(_SC_NPROCESSORS_CONF); +} /** * Returns OS name and version. */ Index: port/src/misc/win/sysinfo.c =================================================================== --- port/src/misc/win/sysinfo.c (revision 473200) +++ port/src/misc/win/sysinfo.c (working copy) @@ -25,10 +25,77 @@ APR_DECLARE(int) port_CPUs_number() { SYSTEM_INFO sys_info; - GetSystemInfo(&sys_info); + typedef void (WINAPI *PTR_GETNATIVESYSTEM_INFO)(LPSYSTEM_INFO); + PTR_GETNATIVESYSTEM_INFO pTrGetNativeSystemInfo; + HMODULE h; + // Use GetNativeSystemInfo if available in kernel + h = GetModuleHandleA("kernel32.dll"); + pTrGetNativeSystemInfo = (PTR_GETNATIVESYSTEM_INFO) GetProcAddress(h, "GetNativeSystemInfo"); + if(pTrGetNativeSystemInfo != NULL)//use it + pTrGetNativeSystemInfo(&sys_info); + else + GetSystemInfo(&sys_info); return sys_info.dwNumberOfProcessors; } +APR_DECLARE(int) port_Cores_number() { + typedef BOOL (WINAPI *LPFN_GETLOGICALPROCESSOR_INFO)( PSYSTEM_LOGICAL_PROCESSOR_INFORMATION, PDWORD); + LPFN_GETLOGICALPROCESSOR_INFO pTrGetLogicalProcessorInfo; + HMODULE h; + BOOL ret; + DWORD bufferLength; + DWORD numCores; + DWORD byteOffset; + PSYSTEM_LOGICAL_PROCESSOR_INFORMATION buffer, pSlpInfo; + // Use GetLogicalProcessorInfo if available in kernel + h = GetModuleHandleA("kernel32.dll"); + pTrGetLogicalProcessorInfo = (LPFN_GETLOGICALPROCESSOR_INFO) GetProcAddress(h, "GetLogicalProcessorInfo"); + if (pTrGetLogicalProcessorInfo == NULL )//not supported, use the down level apis + return port_CPUs_number(); + + buffer = NULL; + bufferLength = 0; + // call once to get buffer length + ret = pTrGetLogicalProcessorInfo(buffer, &bufferLength); + if (ret==FALSE) + { + if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) + { + // allocate buffer for all the logical procinfos + buffer=(PSYSTEM_LOGICAL_PROCESSOR_INFORMATION)malloc(bufferLength); + } + else + return apr_get_os_error(); + } + numCores = 0; + byteOffset = 0; + // call for data + ret = pTrGetLogicalProcessorInfo(buffer, &bufferLength); + pSlpInfo = buffer; + while (byteOffset < bufferLength) + { + switch (pSlpInfo->Relationship) + { + case RelationProcessorCore: + numCores++; //count the core structures + break; + + default: + break; + } + byteOffset += sizeof(SYSTEM_LOGICAL_PROCESSOR_INFORMATION); + pSlpInfo++; + } + free(buffer); + return numCores; +} + + + + + + + APR_DECLARE(apr_status_t) port_OS_name_version(char** os_name, char** os_ver, apr_pool_t* pool){ Index: vmcore/include/version_svn_tag.h =================================================================== --- vmcore/include/version_svn_tag.h (revision 473200) +++ vmcore/include/version_svn_tag.h (working copy) @@ -18,6 +18,6 @@ #ifndef _VERSION_SVN_TAG_ #define _VERSION_SVN_TAG_ -#define VERSION_SVN_TAG "473137" +#define VERSION_SVN_TAG "473200" #endif // _VERSION_SVN_TAG_