wxMemorySize wxGetFreeMemory() { #if defined(__LINUX__) // get it from /proc/meminfo FILE *fp = fopen("/proc/meminfo", "r"); if ( fp ) { long memFree = -1; char buf[1024]; if ( fgets(buf, WXSIZEOF(buf), fp) && fgets(buf, WXSIZEOF(buf), fp) ) { // /proc/meminfo changed its format in kernel 2.6 if ( wxPlatformInfo().CheckOSVersion(2, 6) ) { unsigned long cached, buffers; sscanf(buf, "MemFree: %ld", &memFree); fgets(buf, WXSIZEOF(buf), fp); sscanf(buf, "Buffers: %lu", &buffers); fgets(buf, WXSIZEOF(buf), fp); sscanf(buf, "Cached: %lu", &cached); // add to "MemFree" also the "Buffers" and "Cached" values as // free(1) does as otherwise the value never makes sense: for // kernel 2.6 it's always almost 0 memFree += buffers + cached; // values here are always expressed in kB and we want bytes memFree *= 1024; } else // Linux 2.4 (or < 2.6, anyhow) { long memTotal, memUsed; sscanf(buf, "Mem: %ld %ld %ld", &memTotal, &memUsed, &memFree); } } fclose(fp); return (wxMemorySize)memFree; } #elif defined(__SGI__) struct rminfo realmem; if ( sysmp(MP_SAGET, MPSA_RMINFO, &realmem, sizeof realmem) == 0 ) return ((wxMemorySize)realmem.physmem * sysconf(_SC_PAGESIZE)); #elif defined(_SC_AVPHYS_PAGES) return ((wxMemorySize)sysconf(_SC_AVPHYS_PAGES))*sysconf(_SC_PAGESIZE); //#elif defined(__FREEBSD__) -- might use sysctl() to find it out, probably #endif // can't find it out return -1; }
bool IsPreVistaWindows() { return wxPlatformInfo().GetOSMajorVersion() < 6; }
wxMemorySize wxGetFreeMemory() { #if defined(__LINUX__) // get it from /proc/meminfo FILE *fp = fopen("/proc/meminfo", "r"); if ( fp ) { wxMemorySize memFreeBytes = (wxMemorySize)-1; char buf[1024]; if ( fgets(buf, WXSIZEOF(buf), fp) && fgets(buf, WXSIZEOF(buf), fp) ) { // /proc/meminfo changed its format in kernel 2.6 if ( wxPlatformInfo().CheckOSVersion(2, 6) ) { unsigned long memFree; if ( sscanf(buf, "MemFree: %lu", &memFree) == 1 ) { // We consider memory used by the IO buffers and cache as // being "free" too as Linux aggressively uses free memory // for caching and the amount of memory reported as really // free is far too low for lightly loaded system. if ( fgets(buf, WXSIZEOF(buf), fp) ) { unsigned long buffers; if ( sscanf(buf, "Buffers: %lu", &buffers) == 1 ) memFree += buffers; } if ( fgets(buf, WXSIZEOF(buf), fp) ) { unsigned long cached; if ( sscanf(buf, "Cached: %lu", &cached) == 1 ) memFree += cached; } // values here are always expressed in kB and we want bytes memFreeBytes = memFree; memFreeBytes *= 1024; } } else // Linux 2.4 (or < 2.6, anyhow) { long memTotal, memUsed, memFree; if ( sscanf(buf, "Mem: %ld %ld %ld", &memTotal, &memUsed, &memFree) == 3 ) { memFreeBytes = memFree; } } } fclose(fp); return memFreeBytes; } #elif defined(__SGI__) struct rminfo realmem; if ( sysmp(MP_SAGET, MPSA_RMINFO, &realmem, sizeof realmem) == 0 ) return ((wxMemorySize)realmem.physmem * sysconf(_SC_PAGESIZE)); #elif defined(_SC_AVPHYS_PAGES) return ((wxMemorySize)sysconf(_SC_AVPHYS_PAGES))*sysconf(_SC_PAGESIZE); //#elif defined(__FREEBSD__) -- might use sysctl() to find it out, probably #endif // can't find it out return -1; }
void DIALOG_ABOUT::buildVersionInfoData( wxString& aMsg, bool aFormatHtml ) { // DO NOT translate information in the msg_version string wxString eol = aFormatHtml ? "<br>" : "\n"; wxString indent4 = aFormatHtml ? " " : " "; #define ON "ON" << eol #define OFF "OFF" << eol wxPlatformInfo platform; aMsg << "Application: " << m_info.GetAppName() << eol; aMsg << "Version: " << m_info.GetBuildVersion() << eol; aMsg << "Libraries:" << eol; aMsg << indent4 << wxGetLibraryVersionInfo().GetVersionString() << eol; #ifdef BUILD_GITHUB_PLUGIN aMsg << indent4 << GetKicadCurlVersion() << eol; #endif aMsg << "Platform: " << wxGetOsDescription() << ", " << platform.GetArchName() << ", " << platform.GetEndiannessName() << ", " << platform.GetPortIdName() << eol; aMsg << "Build Info:" << eol; aMsg << indent4 << "wxWidgets: " << wxVERSION_NUM_DOT_STRING << " ("; aMsg << __WX_BO_UNICODE __WX_BO_STL __WX_BO_WXWIN_COMPAT_2_8 ")"; // Get the GTK+ version where possible. #ifdef __WXGTK__ int major, minor; major = wxPlatformInfo().Get().GetToolkitMajorVersion(); minor = wxPlatformInfo().Get().GetToolkitMinorVersion(); aMsg << " GTK+ " << major << "." << minor; #endif aMsg << eol; aMsg << indent4 << "Boost: " << ( BOOST_VERSION / 100000 ) << wxT( "." ) << ( BOOST_VERSION / 100 % 1000 ) << wxT( "." ) << ( BOOST_VERSION % 100 ) << eol; #ifdef BUILD_GITHUB_PLUGIN aMsg << indent4 << "Curl: " << GetCurlLibVersion() << eol; #endif aMsg << indent4 << "Compiler: "; #if defined(__clang__) aMsg << "Clang " << __clang_major__ << "." << __clang_minor__ << "." << __clang_patchlevel__; #elif defined(__GNUG__) aMsg << "GCC " << __GNUC__ << "." << __GNUC_MINOR__ << "." << __GNUC_PATCHLEVEL__; #elif defined(_MSC_VER) aMsg << "Visual C++ " << _MSC_VER; #elif defined(__INTEL_COMPILER) aMsg << "Intel C++ " << __INTEL_COMPILER; #else aMsg << "Other Compiler "; #endif #if defined(__GXX_ABI_VERSION) aMsg << " with C++ ABI " << __GXX_ABI_VERSION << eol; #else aMsg << " without C++ ABI"; #endif aMsg << eol; // Add build settings config (build options): aMsg << "Build settings:" << eol; aMsg << indent4 << "USE_WX_GRAPHICS_CONTEXT="; #ifdef USE_WX_GRAPHICS_CONTEXT aMsg << ON; #else aMsg << OFF; #endif aMsg << indent4 << "USE_WX_OVERLAY="; #ifdef USE_WX_OVERLAY aMsg << ON; #else aMsg << OFF; #endif aMsg << indent4 << "KICAD_SCRIPTING="; #ifdef KICAD_SCRIPTING aMsg << ON; #else aMsg << OFF; #endif aMsg << indent4 << "KICAD_SCRIPTING_MODULES="; #ifdef KICAD_SCRIPTING_MODULES aMsg << ON; #else aMsg << OFF; #endif aMsg << indent4 << "KICAD_SCRIPTING_WXPYTHON="; #ifdef KICAD_SCRIPTING_WXPYTHON aMsg << ON; #else aMsg << OFF; #endif aMsg << indent4 << "KICAD_SCRIPTING_ACTION_MENU="; #ifdef KICAD_SCRIPTING_ACTION_MENU aMsg << ON; #else aMsg << OFF; #endif aMsg << indent4 << "BUILD_GITHUB_PLUGIN="; #ifdef BUILD_GITHUB_PLUGIN aMsg << ON; #else aMsg << OFF; #endif aMsg << indent4 << "KICAD_USE_OCE="; #ifdef KICAD_USE_OCE aMsg << ON; #else aMsg << OFF; #endif aMsg << indent4 << "KICAD_SPICE="; #ifdef KICAD_SPICE aMsg << ON; #else aMsg << OFF; #endif }