Changeset: dcb51041c4a0 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=dcb51041c4a0
Modified Files:
        gdk/gdk_utils.mx
Branch: Apr2011
Log Message:

fix memory detection on Darwin since OpenBSD fixes

Apparently, Darwin needs an exact array, and doesn't like -1 termination
for sysctl.  This is what is documented, so should be ok everywhere.
Make sure we store output in the correct types, and that casts are
performed correctly as well.

This fixes a Floating exception upon queries, and most likely also the
mserver5 spins that we've been observing on all Darwin platforms.


diffs (58 lines):

diff --git a/gdk/gdk_utils.mx b/gdk/gdk_utils.mx
--- a/gdk/gdk_utils.mx
+++ b/gdk/gdk_utils.mx
@@ -479,15 +479,16 @@
        }
 #elif defined(HAVE_SYS_SYSCTL_H) && defined(HW_PAGESIZE)
        {
-               size_t len = sizeof(_MT_pagesize);
-               int mib[3];
+               int size;
+               size_t len = sizeof(int);
+               int mib[2];
 
                /* Everyone should have permission to make this call, 
                 * if we get a failure something is really wrong. */
                mib[0] = CTL_HW;
                mib[1] = HW_PAGESIZE;
-               mib[2] = -1;
-               sysctl(mib, 3, &_MT_pagesize, &len, NULL, 0);
+               sysctl(mib, 2, &size, &len, NULL, 0);
+               _MT_pagesize = size;
        }
 #elif defined(HAVE_SYSCONF) && defined(_SC_PAGESIZE)
        _MT_pagesize = sysconf(_SC_PAGESIZE);
@@ -515,14 +516,13 @@
        {
                uint64_t size = 0;
                size_t len = sizeof(size);
-               int mib[3];
+               int mib[2];
 
                /* Everyone should have permission to make this call, 
                 * if we get a failure something is really wrong. */
                mib[0] = CTL_HW;
                mib[1] = HW_MEMSIZE;
-               mib[2] = -1;
-               sysctl(mib, 3, &size, &len, NULL, 0);
+               sysctl(mib, 2, &size, &len, NULL, 0);
                _MT_npages = size / _MT_pagesize;
        }
 #elif defined(HAVE_SYS_SYSCTL_H) && defined (HW_PHYSMEM64)
@@ -530,14 +530,13 @@
        {
                int64_t size = 0;
                size_t len = sizeof(size);
-               int mib[3];
+               int mib[2];
 
                /* Everyone should have permission to make this call, 
                 * if we get a failure something is really wrong. */
                mib[0] = CTL_HW;
                mib[1] = HW_PHYSMEM64;
-               mib[2] = -1;
-               sysctl(mib, 3, &size, &len, NULL, 0);
+               sysctl(mib, 2, &size, &len, NULL, 0);
                _MT_npages = size / _MT_pagesize;
        }
 #elif defined(HAVE_SYSCONF) && defined(_SC_PHYS_PAGES)
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to