[Cmake-commits] [cmake-commits] hoffman committed SystemInformation.cxx 1.22.2.6 1.22.2.7

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Apr 7 15:32:09 EDT 2009


Update of /cvsroot/CMake/CMake/Source/kwsys
In directory public:/mounts/ram/cvs-serv29663/Source/kwsys

Modified Files:
      Tag: CMake-2-6
	SystemInformation.cxx 
Log Message:
ENH: merge in changes for RC 4


Index: SystemInformation.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/kwsys/SystemInformation.cxx,v
retrieving revision 1.22.2.6
retrieving revision 1.22.2.7
diff -C 2 -d -r1.22.2.6 -r1.22.2.7
*** SystemInformation.cxx	31 Dec 2008 15:14:33 -0000	1.22.2.6
--- SystemInformation.cxx	7 Apr 2009 19:32:07 -0000	1.22.2.7
***************
*** 2274,2278 ****
    unsigned long ap=0;
    
!   char buffer[1024]; // for skipping unused lines
    
    int linuxMajor = 0;
--- 2274,2278 ----
    unsigned long ap=0;
    
!   char buffer[1024]; // for reading lines
    
    int linuxMajor = 0;
***************
*** 2317,2348 ****
      // Rigorously, this test should check from the developping version 2.5.x
      // that introduced the new format...
!     
!     long freeMem;
!     long buffersMem;
!     long cachedMem;
!     
!     fscanf(fd,"MemTotal:%ld kB\n", &this->TotalPhysicalMemory);
!     fscanf(fd,"MemFree:%ld kB\n", &freeMem);
!     fscanf(fd,"Buffers:%ld kB\n", &buffersMem);
!     fscanf(fd,"Cached:%ld kB\n", &cachedMem);
!     
!     this->TotalPhysicalMemory /= 1024;
!     this->AvailablePhysicalMemory = freeMem+cachedMem+buffersMem;
!     this->AvailablePhysicalMemory /= 1024;
!     
!     // Skip SwapCached, Active, Inactive, HighTotal, HighFree, LowTotal
!     // and LowFree.
!     int i=0;
!     while(i<7)
        {
!       fgets(buffer, sizeof(buffer), fd); // skip a line
!       ++i;
        }
-     
-     fscanf(fd,"SwapTotal:%ld kB\n", &this->TotalVirtualMemory);
-     fscanf(fd,"SwapFree:%ld kB\n", &this->AvailableVirtualMemory);
- 
-     this->TotalVirtualMemory /= 1024;
-     this->AvailableVirtualMemory /= 1024;
      }
    else
--- 2317,2353 ----
      // Rigorously, this test should check from the developping version 2.5.x
      // that introduced the new format...
! 
!     enum { mMemTotal, mMemFree, mBuffers, mCached, mSwapTotal, mSwapFree };
!     const char* format[6] =
!       { "MemTotal:%lu kB", "MemFree:%lu kB", "Buffers:%lu kB",
!         "Cached:%lu kB", "SwapTotal:%lu kB", "SwapFree:%lu kB" };
!     bool have[6] = { false, false, false, false, false, false };
!     unsigned long value[6];
!     int count = 0;
!     while(fgets(buffer, sizeof(buffer), fd))
        {
!       for(int i=0; i < 6; ++i)
!         {
!         if(!have[i] && sscanf(buffer, format[i], &value[i]) == 1)
!           {
!           have[i] = true;
!           ++count;
!           }
!         }
!       }
!     if(count == 6)
!       {
!       this->TotalPhysicalMemory = value[mMemTotal] / 1024;
!       this->AvailablePhysicalMemory =
!         (value[mMemFree] + value[mBuffers] + value[mCached]) / 1024;
!       this->TotalVirtualMemory = value[mSwapTotal] / 1024;
!       this->AvailableVirtualMemory = value[mSwapFree] / 1024;
!       }
!     else
!       {
!       kwsys_ios::cout << "Problem parsing /proc/meminfo" << kwsys_ios::endl;
!       fclose(fd);
!       return 0;
        }
      }
    else



More information about the Cmake-commits mailing list