On Sunday 06 January 2008, Danny Pansters wrote:
> I never found the time and/or inspiration to persue it further, but I
> created a few "kitchen sink" type ports for kdesupport4, kdelibs4,
> kdebase4, kdepimlibs4 back in September. It compiled and I could start the
> desktop but (as Adriaan has also blogged about and somewhat worked around)
> knotify4 barfed really bad.

A viable approach is to disable multimedia, although then you *do* get lots of 
dialog boxes. I have not fixed that one yet. support, libs, pimlibs all build 
out-of-the-box on FreeBSD-6. I've just discovered that FBSD-6 doesn't have 
the _SC_PHYS_PAGES sysconf constant (which FBSD-7 does, and which FBSD-7 
documents as a "Solaris and Linux extension").

Here's a patch to do the same with sysctl() on 6-STABLE.


-- 
These are your friends - Adem
    GPG: FEA2 A3FE Adriaan de Groot
Index: workspace/plasma/plasma/plasmaapp.cpp
===================================================================
--- workspace/plasma/plasma/plasmaapp.cpp	(revision 758467)
+++ workspace/plasma/plasma/plasmaapp.cpp	(working copy)
@@ -24,6 +24,10 @@
 #include "plasmaapp.h"
 
 #include <unistd.h>
+#if !defined(_SC_PHYS_PAGES) && defined(Q_OS_FREEBSD)
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#endif
 
 #include <QApplication>
 #include <QDesktopWidget>
@@ -138,9 +142,33 @@
     }
     cacheSize += cacheSize / 10;
 
-    // Calculate the size of physical system memory
+    // Calculate the size of physical system memory; _SC_PHYS_PAGES *
+    // _SC_PAGESIZE is documented to be able to overflow 32-bit integers,
+    // so apply a 10-bit shift. FreeBSD 6-STABLE doesn't have _SC_PHYS_PAGES
+    // (it is documented in FreeBSD 7-STABLE as "Solaris and Linux extension")
+    // so use sysctl in those cases.
+#if defined(_SC_PHYS_PAGES)
     int memorySize = sysconf(_SC_PHYS_PAGES);
     memorySize *= sysconf(_SC_PAGESIZE) / 1024;
+#else
+#ifdef Q_OS_FREEBSD
+    int sysctlbuf[2];
+    size_t size = sizeof(sysctlbuf);
+    int memorySize;
+    // This could actually use hw.physmem instead, but I can't find
+    // reliable documentation on how to read the value (which may 
+    // not fit in a 32 bit integer).
+    if (!sysctlbyname("vm.stats.vm.v_page_size", sysctlbuf, &size, NULL, 0)) {
+	memorySize = sysctlbuf[0] / 1024;
+	size = sizeof(sysctlbuf);
+        if (!sysctlbyname("vm.stats.vm.v_page_count", sysctlbuf, &size, NULL, 0)) {
+            memorySize *= sysctlbuf[0];
+	}
+    }
+#endif
+    // If you have no suitable sysconf() interface and are not FreeBSD,
+    // then you are out of luck and get a compile error.
+#endif
 
     // Increase the pixmap cache size to 1% of system memory if it isn't already
     // larger so as to maximize cache usage. 1% of 1GB ~= 10MB.

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
kde-freebsd mailing list
kde-freebsd@kde.org
https://mail.kde.org/mailman/listinfo/kde-freebsd

Reply via email to