Changeset: fb91bbd3a06d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fb91bbd3a06d
Modified Files:
        clients/Tests/exports.stable.out
        gdk/ChangeLog.Jun2020
        gdk/gdk_posix.h
        gdk/gdk_private.h
        gdk/gdk_utils.h
        monetdb5/modules/mal/mal_io.c
Branch: Jun2020
Log Message:

Hide MT_mmap and MT_munmap, expose GDKmunmap.
GDKmmap was already exposed.  The GDK functions check the VM limits
that were set.


diffs (228 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -283,9 +283,10 @@ void GDKlockstatistics(int);
 void *GDKmalloc(size_t size) __attribute__((__malloc__)) 
__attribute__((__alloc_size__(1))) __attribute__((__warn_unused_result__));
 size_t GDKmem_cursize(void);
 gdk_return GDKmergeidx(BAT *b, BAT **a, int n_ar);
-void *GDKmmap(const char *path, int mode, size_t len);
+void *GDKmmap(const char *path, int mode, size_t len) 
__attribute__((__warn_unused_result__));
 gdk_return GDKmmapfile(str buffer, size_t max, size_t id);
 int GDKms(void);
+gdk_return GDKmunmap(void *addr, size_t len);
 int GDKnr_threads;
 void GDKprepareExit(void);
 void GDKqsort(void *restrict h, void *restrict t, const void *restrict base, 
size_t n, int hs, int ts, int tpe, bool reverse, bool nilslast);
@@ -344,8 +345,6 @@ size_t MT_getrss(void);
 void MT_init(void);
 int MT_join_thread(MT_Id t);
 int MT_lockf(char *filename, int mode);
-void *MT_mmap(const char *path, int mode, size_t len);
-int MT_munmap(void *p, size_t len);
 bool MT_path_absolute(const char *path);
 void MT_sleep_ms(unsigned int ms);
 void *MT_thread_getdata(void);
diff --git a/gdk/ChangeLog.Jun2020 b/gdk/ChangeLog.Jun2020
--- a/gdk/ChangeLog.Jun2020
+++ b/gdk/ChangeLog.Jun2020
@@ -1,6 +1,10 @@
 # ChangeLog file for GDK
 # This file is updated with Maddlog
 
+* Wed Mar 25 2020 Sjoerd Mullender <[email protected]>
+- Removed MT_mmap and MT_munmap from the list of exported functions.
+  Use GDKmmap and GDKmunmap with the same parameters instead.
+
 * Fri Mar 20 2020 Sjoerd Mullender <[email protected]>
 - Changed the interface of the atom "fix" and "unfix" functions.
   They now return a value of type gdk_return to indicater success/failure.
diff --git a/gdk/gdk_posix.h b/gdk/gdk_posix.h
--- a/gdk/gdk_posix.h
+++ b/gdk/gdk_posix.h
@@ -114,18 +114,11 @@
 #define MMAP_ASYNC             8192    /* asynchronous writes (default if 
ommitted) */
 #define MMAP_SYNC              16384   /* writing is done synchronously */
 
-#define MT_MMAP_LOG 27
-#define MT_MMAP_TILE (1<<MT_MMAP_LOG)
-#define MT_MMAP_BUFSIZE 4096
-
 /* in order to be sure of madvise and msync modes, pass them to mmap()
  * call as well */
 
 gdk_export size_t MT_getrss(void);
 
-gdk_export void *MT_mmap(const char *path, int mode, size_t len);
-gdk_export int MT_munmap(void *p, size_t len);
-
 gdk_export bool MT_path_absolute(const char *path);
 
 
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -155,9 +155,6 @@ gdk_return GDKmove(int farmid, const cha
        __attribute__((__visibility__("hidden")));
 void *GDKmremap(const char *path, int mode, void *old_address, size_t 
old_size, size_t *new_size)
        __attribute__((__visibility__("hidden")));
-gdk_return GDKmunmap(void *addr, size_t len)
-       __attribute__((__warn_unused_result__))
-       __attribute__((__visibility__("hidden")));
 gdk_return GDKremovedir(int farmid, const char *nme)
        __attribute__((__warn_unused_result__))
        __attribute__((__visibility__("hidden")));
@@ -221,10 +218,14 @@ void IMPSprint(BAT *b)            /* never called:
 #endif
 void MT_init_posix(void)
        __attribute__((__visibility__("hidden")));
+void *MT_mmap(const char *path, int mode, size_t len)
+       __attribute__((__visibility__("hidden")));
 void *MT_mremap(const char *path, int mode, void *old_address, size_t 
old_size, size_t *new_size)
        __attribute__((__visibility__("hidden")));
 int MT_msync(void *p, size_t len)
        __attribute__((__visibility__("hidden")));
+int MT_munmap(void *p, size_t len)
+       __attribute__((__visibility__("hidden")));
 void OIDXfree(BAT *b)
        __attribute__((__visibility__("hidden")));
 void persistOIDX(BAT *b)
@@ -380,15 +381,6 @@ extern MT_Lock GDKtmLock;
 #if !defined(NDEBUG) && !defined(STATIC_CODE_ANALYSIS)
 /* see comment in gdk.h */
 #ifdef __GNUC__
-#define GDKmunmap(p, l)                                                \
-       ({      void *_ptr = (p);                               \
-               size_t _len = (l);                              \
-               gdk_return _res = GDKmunmap(_ptr, _len);        \
-               TRC_DEBUG(ALLOC,                                \
-                         "GDKmunmap(%p,%zu) -> %u\n",          \
-                         _ptr, _len, _res);                    \
-               _res;                                           \
-       })
 #define GDKmremap(p, m, oa, os, ns)                                    \
        ({                                                              \
                const char *_path = (p);                                \
@@ -405,15 +397,6 @@ extern MT_Lock GDKtmLock;
                _res;                                                   \
         })
 #else
-static inline gdk_return
-GDKmunmap_debug(void *ptr, size_t len)
-{
-       gdk_return res = GDKmunmap(ptr, len);
-       TRC_DEBUG(ALLOC, "GDKmunmap(%p,%zu) -> %d\n",
-                                 ptr, len, (int) res);
-       return res;
-}
-#define GDKmunmap(p, l)                GDKmunmap_debug((p), (l))
 static inline void *
 GDKmremap_debug(const char *path, int mode, void *old_address, size_t 
old_size, size_t *new_size)
 {
diff --git a/gdk/gdk_utils.h b/gdk/gdk_utils.h
--- a/gdk/gdk_utils.h
+++ b/gdk/gdk_utils.h
@@ -73,7 +73,9 @@ gdk_export size_t _MT_pagesize;
 gdk_export size_t GDK_mem_maxsize;     /* max allowed size of committed memory 
*/
 gdk_export size_t GDK_vm_maxsize;      /* max allowed size of reserved vm */
 
-gdk_export void *GDKmmap(const char *path, int mode, size_t len);
+gdk_export void *GDKmmap(const char *path, int mode, size_t len)
+       __attribute__((__warn_unused_result__));
+gdk_export gdk_return GDKmunmap(void *addr, size_t len);
 
 gdk_export size_t GDKmem_cursize(void);        /* RAM/swapmem that MonetDB has 
claimed from OS */
 gdk_export size_t GDKvm_cursize(void); /* current MonetDB VM address space 
usage */
@@ -203,6 +205,15 @@ gdk_export int GDKms(void);
                          _res);                                        \
                _res;                                                   \
         })
+#define GDKmunmap(p, l)                                                \
+       ({      void *_ptr = (p);                               \
+               size_t _len = (l);                              \
+               gdk_return _res = GDKmunmap(_ptr, _len);        \
+               TRC_DEBUG(ALLOC,                                \
+                         "GDKmunmap(%p,%zu) -> %u\n",          \
+                         _ptr, _len, _res);                    \
+               _res;                                           \
+       })
 #define malloc(s)                                      \
        ({                                              \
                size_t _size = (s);                     \
@@ -293,6 +304,15 @@ GDKmmap_debug(const char *path, int mode
        return res;
 }
 #define GDKmmap(p, m, l)       GDKmmap_debug((p), (m), (l))
+static inline gdk_return
+GDKmunmap_debug(void *ptr, size_t len)
+{
+       gdk_return res = GDKmunmap(ptr, len);
+       TRC_DEBUG(ALLOC, "GDKmunmap(%p,%zu) -> %d\n",
+                                 ptr, len, (int) res);
+       return res;
+}
+#define GDKmunmap(p, l)                GDKmunmap_debug((p), (l))
 static inline void *
 malloc_debug(size_t size)
 {
diff --git a/monetdb5/modules/mal/mal_io.c b/monetdb5/modules/mal/mal_io.c
--- a/monetdb5/modules/mal/mal_io.c
+++ b/monetdb5/modules/mal/mal_io.c
@@ -692,11 +692,11 @@ IOimport(void *ret, bat *bid, str *fnme)
                        throw(MAL, "io.imports", OPERATION_FAILED "File too 
large");
                }
 #endif
-               base = cur = (char *) MT_mmap(*fnme, MMAP_SEQUENTIAL, (size_t) 
st.st_size);
+               base = cur = (char *) GDKmmap(*fnme, MMAP_SEQUENTIAL, (size_t) 
st.st_size);
                if (cur == NULL) {
                        BBPunfix(b->batCacheid);
                        GDKfree(buf);
-                       throw(MAL, "io.mport", OPERATION_FAILED "MT_mmap()");
+                       throw(MAL, "io.mport", OPERATION_FAILED "GDKmmap()");
                }
                end = cur + st.st_size;
 
@@ -768,7 +768,7 @@ IOimport(void *ret, bat *bid, str *fnme)
                        BBPunfix(b->batCacheid);
                        snprintf(msg,sizeof(msg),"error in input %s",buf);
                        GDKfree(buf);
-                       MT_munmap(base, end - base);
+                       GDKmunmap(base, end - base);
                        GDKfree(t);
                        throw(MAL, "io.import", "%s", msg);
                }
@@ -777,7 +777,7 @@ IOimport(void *ret, bat *bid, str *fnme)
                        BBPunfix(b->batCacheid);
                        snprintf(msg,sizeof(msg),"error in input %s",buf);
                        GDKfree(buf);
-                       MT_munmap(base, end - base);
+                       GDKmunmap(base, end - base);
                        GDKfree(t);
                        throw(MAL, "io.import", "%s", msg);
                }
@@ -786,7 +786,7 @@ IOimport(void *ret, bat *bid, str *fnme)
                        BBPunfix(b->batCacheid);
                        GDKfree(buf);
                        GDKfree(t);
-                       MT_munmap(base, end - base);
+                       GDKmunmap(base, end - base);
                        throw(MAL, "io.import", "insert failed");
                }
 
@@ -797,7 +797,7 @@ IOimport(void *ret, bat *bid, str *fnme)
 #ifndef WIN32
 #define MAXBUF 40*MT_pagesize()
                if ((unsigned) (cur - base) > MAXBUF) {
-                       MT_munmap(base, MAXBUF);
+                       GDKmunmap(base, MAXBUF);
                        base += MAXBUF;
                }
 #endif
@@ -807,7 +807,7 @@ IOimport(void *ret, bat *bid, str *fnme)
        if (t)
                GDKfree(t);
        GDKfree(buf);
-       MT_munmap(base, end - base);
+       GDKmunmap(base, end - base);
        BBPunfix(b->batCacheid);
        return MAL_SUCCEED;
 }
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to