1. corrected HAVE_PW_GECOS detection in configure (which never worked)

2. added and documented wxGetFreeMemory() for Unix (Linux/Solaris only)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6861 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-03-19 16:45:43 +00:00
parent 15909a16b3
commit bd3277fec0
8 changed files with 306 additions and 239 deletions

449
configure vendored

File diff suppressed because it is too large Load Diff

View File

@@ -2184,7 +2184,6 @@ AC_CACHE_CHECK([for pw_gecos in struct passwd], wx_cv_struct_pw_gecos,
],
[
wx_cv_struct_pw_gecos=yes
AC_DEFINE(HAVE_PW_GECOS)
],
[
wx_cv_struct_pw_gecos=no
@@ -2193,6 +2192,10 @@ AC_CACHE_CHECK([for pw_gecos in struct passwd], wx_cv_struct_pw_gecos,
]
)
if test "$wx_cv_struct_pw_gecos" = "yes"; then
AC_DEFINE(HAVE_PW_GECOS)
fi
dnl ---------------------------------------------------------------------------
dnl Checks for compiler characteristics
dnl ---------------------------------------------------------------------------

View File

@@ -1416,9 +1416,9 @@ See also \helpref{wxTimer}{wxtimer}.
\func{long}{wxGetFreeMemory}{\void}
Returns the amount of free memory in Kbytes under environments which
support it, and -1 if not supported. Currently, returns a positive value
under Windows, and -1 under Unix.
Returns the amount of free memory in bytes under environments which
support it, and -1 if not supported. Currently, it is supported only
under Windows, Linux and Solaris.
\wxheading{Include files}

View File

@@ -559,7 +559,8 @@ enum
wxMGL_X, // MGL on X
wxMGL_WIN32, // MGL on Win32
wxMGL_OS2, // MGL on OS/2
wxWINDOWS_OS2 // Native OS/2 PM
wxWINDOWS_OS2, // Native OS/2 PM
wxUNIX // wxBase under Unix
};
// ----------------------------------------------------------------------------

View File

@@ -474,10 +474,12 @@ static void TestOsInfo()
printf("Running under: %s, version %d.%d\n",
wxGetOsDescription().c_str(), major, minor);
printf("%d free bytes of memory left.\n", wxGetFreeMemory());
printf("%ld free bytes of memory left.\n", wxGetFreeMemory());
printf("Host name is %s (%s).\n",
wxGetHostName().c_str(), wxGetFullHostName().c_str());
puts("");
}
static void TestUserInfo()
@@ -488,6 +490,8 @@ static void TestUserInfo()
printf("User name is:\t%s\n", wxGetUserName().c_str());
printf("Home dir is:\t%s\n", wxGetHomeDir().c_str());
printf("Email address:\t%s\n", wxGetEmailAddress().c_str());
puts("");
}
#endif // TEST_INFO_FUNCTIONS

View File

@@ -640,6 +640,9 @@
/* struct tm doesn't always have the tm_gmtoff field, define this if it does */
#undef WX_GMTOFF_IN_TM
/* Define if you have pw_gecos field in struct passwd */
#undef HAVE_PW_GECOS
/* Define if you have dlopen() */
#undef HAVE_DLOPEN

View File

@@ -155,6 +155,14 @@ HBRUSH wxDisableButtonBrush = (HBRUSH) 0;
LRESULT WXDLLEXPORT APIENTRY wxWndProc(HWND, UINT, WPARAM, LPARAM);
// FIXME wxUSE_ON_FATAL_EXCEPTION is only supported for VC++ now because it
// needs compiler support for Win32 SEH. Others (especially Borland)
// probably have it too, but I'm not sure about how it works
#ifndef __VISUALC__
#undef wxUSE_ON_FATAL_EXCEPTION
#define wxUSE_ON_FATAL_EXCEPTION 0
#endif // VC++
#if wxUSE_ON_FATAL_EXCEPTION
static bool gs_handleExceptions = FALSE;
#endif
@@ -659,15 +667,6 @@ int wxEntry(WXHINSTANCE hInstance,
// take everything into a try-except block to be able to call
// OnFatalException() if necessary
// FIXME other compilers must support Win32 SEH (structured exception
// handling) too, just find the appropriate keyword in their docs!
// Please note that it's _not_ the same as C++ exceptions!
#ifndef __VISUALC__
#undef wxUSE_ON_FATAL_EXCEPTION
#define wxUSE_ON_FATAL_EXCEPTION 0
#endif // VC++
#if wxUSE_ON_FATAL_EXCEPTION
__try {
#endif

View File

@@ -763,7 +763,7 @@ bool wxGetUserName(wxChar *buf, int sz)
if ((who = getpwuid (getuid ())) != NULL)
{
// pw_gecos field in struct passwd is not standard
#if HAVE_PW_GECOS
#ifdef HAVE_PW_GECOS
char *comma = strchr(who->pw_gecos, ',');
if (comma)
*comma = '\0'; // cut off non-name comment fields
@@ -786,6 +786,60 @@ wxString wxGetOsDescription()
#endif
}
// this function returns the GUI toolkit version in GUI programs, but OS
// version in non-GUI ones
#if !wxUSE_GUI
int wxGetOsVersion(int *majorVsn, int *minorVsn)
{
int major, minor;
char name[256];
if ( sscanf(WXWIN_OS_DESCRIPTION, "%s %d.%d", name, &major, &minor) != 3 )
{
// unreckognized uname string format
major = minor = -1;
}
if ( majorVsn )
*majorVsn = major;
if ( minorVsn )
*minorVsn = minor;
return wxUNIX;
}
#endif // !wxUSE_GUI
long 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) )
{
long memTotal, memUsed;
sscanf(buf, "Mem: %ld %ld %ld", &memTotal, &memUsed, &memFree);
}
fclose(fp);
return memFree;
}
#elif defined(__SUN__) && defined(_SC_AVPHYS_PAGES)
return 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;
}
// ----------------------------------------------------------------------------
// signal handling
// ----------------------------------------------------------------------------