Update of /cvsroot/monetdb/MonetDB/src/gdk
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv19032/src/gdk

Modified Files:
        gdk_heap.mx gdk_posix.mx gdk_utils.mx 
Log Message:
propagated changes of Monday Feb 11 2008 - Tuesday Feb 12 2008
from the MonetDB_1-22 branch to the development trunk


Index: gdk_posix.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB/src/gdk/gdk_posix.mx,v
retrieving revision 1.153
retrieving revision 1.154
diff -u -d -r1.153 -r1.154
--- gdk_posix.mx        11 Jan 2008 10:37:00 -0000      1.153
+++ gdk_posix.mx        12 Feb 2008 18:47:38 -0000      1.154
@@ -75,7 +75,6 @@
 #undef HAVE_MALLOPT
 #endif
 
-#ifndef HAVE_MALLINFO
 #ifndef M_MXFAST
 #define M_MXFAST       1       /* set size of blocks to be fast */
 #endif
@@ -90,27 +89,22 @@
 #define M_KEEP         4       /* retain contents of block after a free */
                           /* until another allocation */
 #endif
-#ifndef HAVE_STRUCT_MALLINFO
-struct mallinfo {
-       int arena;              /* total space in arena */
-       int ordblks;            /* number of ordinary blocks */
-       int smblks;             /* number of small blocks */
-       int hblks;              /* number of holding blocks */
-       int hblkhd;             /* space in holding block headers */
-       int usmblks;            /* space in small blocks in use */
-       int fsmblks;            /* space in free small blocks */
-       int uordblks;           /* space in ordinary blocks in use */
-       int fordblks;           /* space in free ordinary blocks */
-       int keepcost;           /* cost of enabling keep option */
-};
-#endif
 
-#define mallinfo()             {0}
-#define mallopt(cmd,value)     0
-
-#endif /* ! HAVE_MALLINFO */
+/* our version of struct mallinfo */
+struct Mallinfo {
+       size_t arena;           /* total space in arena */
+       size_t ordblks;         /* number of ordinary blocks */
+       size_t smblks;          /* number of small blocks */
+       size_t hblks;           /* number of holding blocks */
+       size_t hblkhd;          /* space in holding block headers */
+       size_t usmblks;         /* space in small blocks in use */
+       size_t fsmblks;         /* space in free small blocks */
+       size_t uordblks;        /* space in ordinary blocks in use */
+       size_t fordblks;        /* space in free ordinary blocks */
+       size_t keepcost;        /* cost of enabling keep option */
+};
 
-gdk_export struct mallinfo MT_mallinfo(void);
+gdk_export struct Mallinfo MT_mallinfo(void);
 
 @- locking, sleep
 @h
@@ -1122,13 +1116,25 @@
        return ret;
 }
 
-struct mallinfo
+struct Mallinfo
 MT_mallinfo(void)
 {
-       struct mallinfo _ret;
+       struct Mallinfo _ret;
 
-#ifdef HAVE_MALLINFO
-       _ret = mallinfo();
+#ifdef HAVE_USEFUL_MALLINFO
+       struct mallinfo m;
+
+       m = mallinfo();
+       _ret.arena = m.arena;
+       _ret.ordblks = m.ordblks;
+       _ret.smblks = m.smblks;
+       _ret.hblks = m.hblks;
+       _ret.hblkhd = m.hblkhd;
+       _ret.usmblks = m.usmblks;
+       _ret.fsmblks = m.fsmblks;
+       _ret.uordblks = m.uordblks;
+       _ret.fordblks = m.fordblks;
+       _ret.keepcost = m.keepcost;
 #else
        memset(&_ret, 0, sizeof(_ret));
 #endif
@@ -1427,17 +1433,16 @@
 #define _HEAPBADPTR     (-6)
 #endif
 
-struct mallinfo
+struct Mallinfo
 MT_mallinfo(void)
 {
-       struct mallinfo _ret;
+       struct Mallinfo _ret;
        _HEAPINFO hinfo;
        int heapstatus;
 
        hinfo._pentry = NULL;
-       memset(&_ret, 0, sizeof(struct mallinfo));
+       memset(&_ret, 0, sizeof(_ret));
 
-/* 64bit: mallinfo uses ints which won't work on 64 bit platforms */
        while ((heapstatus = _heapwalk(&hinfo)) == _HEAPOK) {
                _ret.arena += hinfo._size;
                if (hinfo._size > MT_SMALLBLOCK) {

Index: gdk_utils.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB/src/gdk/gdk_utils.mx,v
retrieving revision 1.207
retrieving revision 1.208
diff -u -d -r1.207 -r1.208
--- gdk_utils.mx        10 Feb 2008 23:47:11 -0000      1.207
+++ gdk_utils.mx        12 Feb 2008 18:47:39 -0000      1.208
@@ -511,22 +511,14 @@
 }
 
 volatile int GDK_heapcheck_last = 0;
-int mallinfo_ok = 1;
 
 static INLINE void
 GDKmem_heapcheck(int t)
 {
        /* correct heap estimate with the real thing */
-       if (mallinfo_ok) {
-               struct mallinfo m = MT_mallinfo();
+       struct Mallinfo m = MT_mallinfo();
 
-#if ((SIZEOF_VOID_P==8) && defined(HAVE_SIGNED_MALLINFO))
-               if (m.usmblks < 0 || m.uordblks < 0 || m.hblkhd < 0)
-                       mallinfo_ok = 0;        /* incredible POSIX 
incompetence!! non-64-bit safe mallinfo */
-               else
-#endif
-                       GDK_mallocedbytes_estimate = (size_t) (m.usmblks + 
m.uordblks + m.hblkhd);
-       }
+       GDK_mallocedbytes_estimate = (size_t) (m.usmblks + m.uordblks + 
m.hblkhd);
        GDK_heapcheck_last = t;
 }
 
@@ -624,7 +616,7 @@
 static void
 GDKmemdump(void)
 {
-       struct mallinfo m = MT_mallinfo();
+       struct Mallinfo m = MT_mallinfo();
 
        THRprintf(GDKout, "\n#mallinfo.arena = " SSZFMT "\n", (ssize_t) 
m.arena);
        THRprintf(GDKout, "#mallinfo.ordblks = " SSZFMT "\n", (ssize_t) 
m.ordblks);
@@ -967,7 +959,7 @@
 these redirected blocks.
 @end table
 
-64-bits update: POSIX mallinfo is severely broken, as it uses int-s for memory 
sizes!!
+64-bits update: Some 64-bit implementations (Linux) of mallinfo is severely 
broken, as they use int-s for memory sizes!!
 This causes corruption of mallinfo stats. As we depend on those, we should 
keep the
 malloc arena small. Thus, VM redirection is now quickly applied: for all 
mallocs > 1MB.
 @{

Index: gdk_heap.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB/src/gdk/gdk_heap.mx,v
retrieving revision 1.94
retrieving revision 1.95
diff -u -d -r1.94 -r1.95
--- gdk_heap.mx 8 Feb 2008 22:35:06 -0000       1.94
+++ gdk_heap.mx 12 Feb 2008 18:47:38 -0000      1.95
@@ -70,14 +70,11 @@
 static char *
 decompose_filename(str nme)
 {
-       char *ext, *priv;
+       char *ext;
 
        ext = strchr(nme, '.'); /* extract base and ext from heap file name */
        if (ext) {
                *ext++ = 0;
-               priv = strchr(ext, '.');
-               if (priv)
-                       *priv = 0;
        }
        return ext;
 }
@@ -139,7 +136,7 @@
                        fclose(fp);
                        /* a non-persistent heap: we create a .priv but *not* 
MMAP_PRIV !!! */
                        h->storage = STORE_MMAP;
-                       HEAPload(h, nme, ext, FALSE);
+                       HEAPload(h, nme, privext, FALSE);
                }
                GDKfree(of);
        }
@@ -222,7 +219,7 @@
                                /* a non-persistent heap: we create a .priv but 
*not* MMAP_PRIV !!! */
                                h->storage = STORE_MMAP;
                                h->base = NULL;
-                               if (HEAPload(h, nme, ext, FALSE) >= 0) {
+                               if (HEAPload(h, nme, privext, FALSE) >= 0) {
                                        memcpy(h->base, bak.base, bak.free);
                                        HEAPfree(&bak);
                                        return 0;


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins

Reply via email to