On Fri, 3 Dec 2004 02:00:36 +0100
Christian Biere <[EMAIL PROTECTED]> wrote:

> Is the dependence on __sgi__ necessary? Otherwise, I'd rather omit it
> because using the operating system to decide about support of certain
> features is usually the wrong way.

I searched on Google and found that ia64-linux have similar function
syssgi(), same header invent.h ported by sgi(!?). So, I guess there
are the OS having same function, but I think that it is unnecessary
as you say.

> The return code of setinvent() should be checked.

I saw man for setinvent(3), its type is 'int setinvent (void);' and
return value on failure is -1.

Index: src/core/settings.c
===================================================================
RCS file: /cvsroot/gtk-gnutella/gtk-gnutella-current/src/core/settings.c,v
retrieving revision 1.9
diff -u -r1.9 settings.c
--- settings.c  6 Nov 2004 18:07:00 -0000       1.9
+++ settings.c  6 Dec 2004 08:04:56 -0000
@@ -210,7 +210,28 @@
                        "settings_getphysmemsize: sysctl() for HW_USERMEM 
failed: %s",
                        g_strerror(errno));
        return amount / 1024;
-#else /* !(defined (_SC_PHYS_PAGES) || defined(HAS_SYSCTL)) */
+#elif defined (HAS_GETINVENT)
+       inventory_t *inv;
+       int physmem = 0;
+
+       errno = 0;
+       setinvent();
+       while ((inv = getinvent()) != 0) {
+               if (inv->inv_class == INV_MEMORY && inv->inv_type == 
INV_MAIN_MB) {
+                               physmem = inv->inv_state;
+                               break;
+               }
+       }
+       endinvent();
+
+       if ((int) -1 == physmem && 0 != errno) {
+               g_warning(
+                       "settings_getphysmemsize: getinvent() for INV_MEMORY 
faild: %s",
+                       g_strerror(errno));
+                       return 0;
+       }
+       return physmem * 1024;
+#else /* !(defined (_SC_PHYS_PAGES) || defined(HAS_SYSCTL) || defined 
(HAS_GETINVENT)) */
        g_warning("Unable to determine amount of physical RAM");
        return 0;
 #endif         /* _SC_PHYS_PAGES */

-- 
Daichi


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
_______________________________________________
Gtk-gnutella-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/gtk-gnutella-devel

Reply via email to