From 7568c3a29c794f278a9af16901ddffc526f90994 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 7 Mar 2007 22:25:17 +0000 Subject: [PATCH] fixed detection of number of processors under Linux 2.6 [backport from HEAD] git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@44649 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/unix/threadpsx.cpp | 16 ++++++++-------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 5bf14a3cff..de6e2d59f5 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -106,6 +106,7 @@ All: - Fixed tab-related drawing and hit-testing bugs in wxRichTextCtrl. - Implemented background colour in wxRichTextCtrl. - Fixed crashes in helpview when opening a file. +- Fixed detection of number of processors under Linux 2.6 wxMSW diff --git a/src/unix/threadpsx.cpp b/src/unix/threadpsx.cpp index ff291daa3f..983ac3632a 100644 --- a/src/unix/threadpsx.cpp +++ b/src/unix/threadpsx.cpp @@ -988,7 +988,14 @@ void wxThread::Sleep(unsigned long milliseconds) int wxThread::GetCPUCount() { -#if defined(__LINUX__) && wxUSE_FFILE +#if defined(_SC_NPROCESSORS_ONLN) + // this works for Solaris and Linux 2.6 + int rc = sysconf(_SC_NPROCESSORS_ONLN); + if ( rc != -1 ) + { + return rc; + } +#elif defined(__LINUX__) && wxUSE_FFILE // read from proc (can't use wxTextFile here because it's a special file: // it has 0 size but still can be read from) wxLogNull nolog; @@ -1014,13 +1021,6 @@ int wxThread::GetCPUCount() wxLogDebug(_T("failed to read /proc/cpuinfo")); } } -#elif defined(_SC_NPROCESSORS_ONLN) - // this works for Solaris - int rc = sysconf(_SC_NPROCESSORS_ONLN); - if ( rc != -1 ) - { - return rc; - } #endif // different ways to get number of CPUs // unknown