diff --git a/aclocal.m4 b/aclocal.m4 index e8acad74a1..449d02c929 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -1106,7 +1106,7 @@ AC_DEFUN([SAH_HEADER_STDCXX],[ # # Revision Log: # $Log$ -# Revision 1.132 2004/08/04 13:11:14 davea +# Revision 1.133 2004/08/04 21:14:22 dhsu # *** empty log message *** # # Revision 1.1 2003/12/11 18:38:24 korpela diff --git a/api/boinc_api.C b/api/boinc_api.C index 8b7ab424ca..3172a3026c 100644 --- a/api/boinc_api.C +++ b/api/boinc_api.C @@ -635,7 +635,7 @@ static int mem_usage(unsigned long& vm_kb, unsigned long& rs_kb) { FILE* f; -#if defined(HAVE_PROCFS_H) +#if defined(HAVE_PROCFS_H) && defined(HAVE__PROC_SELF_PSINFO) // guess that this is solaris // need psinfo_t from procfs.h @@ -655,6 +655,7 @@ static int mem_usage(unsigned long& vm_kb, unsigned long& rs_kb) { } #endif +#if defined(HAVE__PROC_SELF_STAT) // guess that this is linux // if ((f = fopen("/proc/self/stat", "r")) != 0) { @@ -692,6 +693,7 @@ static int mem_usage(unsigned long& vm_kb, unsigned long& rs_kb) { fclose(f); return 0; } +#endif return ERR_NOT_IMPLEMENTED; #endif diff --git a/checkin_notes b/checkin_notes index 7fbc0d72bb..e4cef41134 100755 --- a/checkin_notes +++ b/checkin_notes @@ -15803,7 +15803,7 @@ David 3 Aug 2004 util.inc xml.inc (new) -Daniel 2004-08-3 +Daniel 2004-08-03 - Fixed "prefs and venue" issue. Before: host venue assignment always comes from the project that is contacted. Now: host venue assignment comes from the project with the newer global prefs. @@ -15847,3 +15847,17 @@ David 4 Aug 2004 host.inc sched/ handle_request.C + +Daniel 2004-08-04 + - autoconf: added HAVE__PROC_* macros + - client: added m_swap checking for Linux (via /proc/meminfo) + + aclocal.m4 + config.h.in + configure + configure.ac + api/ + boinc_api.C + client/ + hostinfo_unix.C + diff --git a/client/hostinfo_unix.C b/client/hostinfo_unix.C index f8598bb7d3..c40e43d3be 100644 --- a/client/hostinfo_unix.C +++ b/client/hostinfo_unix.C @@ -328,6 +328,7 @@ int HOST_INFO::get_host_info() { #endif #if defined(HAVE_SYS_SWAP_H) && defined(SC_GETNSWP) + // Solaris, ... char buf[256]; swaptbl_t* s; int i, n; @@ -341,6 +342,22 @@ int HOST_INFO::get_host_info() { for (i=0; iswt_ent[i].ste_length; } +#elif defined(HAVE__PROC_MEMINFO) + // Linux + FILE *fp; + if ((fp = fopen("/proc/meminfo", "r")) != 0) { + char minfo_buf[1024]; + int n; + if ((n = fread(minfo_buf, sizeof(char), sizeof(minfo_buf)-1, fp))) { + char *p; + minfo_buf[n] = '\0'; + if ((p = strstr(minfo_buf, "SwapTotal:"))) { + p += 10; // move past "SwapTotal:" + m_swap = (double) strtoul(p, NULL, 10); + } + } + fclose(fp); + } #elif defined(HAVE_SYS_SYSCTL_H) && defined(CTL_VM) && defined(VM_METER) // TODO: figure this out /*vmtotal vm_info; diff --git a/config.h.in b/config.h.in index 62fe562c5d..eea0199a9f 100644 --- a/config.h.in +++ b/config.h.in @@ -314,6 +314,15 @@ /* Define to 1 if /dev/tty1 exists */ #undef HAVE__DEV_TTY1 +/* Define to 1 if /proc/meminfo exists */ +#undef HAVE__PROC_MEMINFO + +/* Define to 1 if /proc/self/psinfo exists */ +#undef HAVE__PROC_SELF_PSINFO + +/* Define to 1 if /proc/self/stat exists */ +#undef HAVE__PROC_SELF_STAT + /* Host for this compilation */ #undef HOSTTYPE diff --git a/configure b/configure index 76a85833cb..0ae57fc45d 100755 --- a/configure +++ b/configure @@ -7886,6 +7886,30 @@ cat >>confdefs.h <<\_ACEOF #define HAVE__DEV_TTY1 1 _ACEOF +fi + +if test -e "/proc/self/psinfo"; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE__PROC_SELF_PSINFO 1 +_ACEOF + +fi + +if test -e "/proc/self/stat"; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE__PROC_SELF_STAT 1 +_ACEOF + +fi + +if test -e "/proc/meminfo"; then + +cat >>confdefs.h <<\_ACEOF +#define HAVE__PROC_MEMINFO 1 +_ACEOF + fi diff --git a/configure.ac b/configure.ac index 35181909c6..7d78c35fd0 100644 --- a/configure.ac +++ b/configure.ac @@ -185,6 +185,21 @@ if test -e "/dev/tty1"; then AC_DEFINE(HAVE__DEV_TTY1, 1, [Define to 1 if /dev/tty1 exists]) fi +dnl Check for /proc/self/psinfo (Solaris) +if test -e "/proc/self/psinfo"; then + AC_DEFINE(HAVE__PROC_SELF_PSINFO, 1, [Define to 1 if /proc/self/psinfo exists]) +fi + +dnl Check for /proc/self/stat (Linux) +if test -e "/proc/self/stat"; then + AC_DEFINE(HAVE__PROC_SELF_STAT, 1, [Define to 1 if /proc/self/stat exists]) +fi + +dnl Check for /proc/meminfo (Linux) +if test -e "/proc/meminfo"; then + AC_DEFINE(HAVE__PROC_MEMINFO, 1, [Define to 1 if /proc/meminfo exists]) +fi + dnl by default, create static binaries on linux. dnl [if [ "$target_os" = "linux-gnu" ]; then dnl STATIC_FLAGS="-static"