Changeset: af1d5fe5ed93 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=af1d5fe5ed93
Modified Files:
clients/Tests/exports.stable.out
gdk/gdk.h
gdk/gdk_posix.c
gdk/gdk_posix.h
gdk/gdk_storage.c
gdk/gdk_utils.c
monetdb5/modules/mal/mal_io.c
Branch: Feb2013
Log Message:
Cleanup: we don't need an offset when memory-mapping files.
diffs (148 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
@@ -263,7 +263,7 @@ BAT *GDKkey;
void *GDKmalloc(size_t size);
size_t GDKmem_cursize(void);
size_t GDKmem_inuse(void);
-void *GDKmmap(const char *path, int mode, off_t off, size_t len);
+void *GDKmmap(const char *path, int mode, size_t len);
int GDKms(void);
int GDKnr_threads;
void GDKqsort(void *h, void *t, const void *base, size_t n, int hs, int ts,
int tpe);
@@ -312,7 +312,7 @@ void MT_locktrace_end(void);
char *MT_locktrace_nme[65536];
void MT_locktrace_start(void);
struct Mallinfo MT_mallinfo(void);
-void *MT_mmap(const char *path, int mode, off_t off, size_t len);
+void *MT_mmap(const char *path, int mode, size_t len);
int MT_munmap(void *p, size_t len);
int MT_path_absolute(const char *path);
void MT_sleep_ms(unsigned int ms);
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -2190,7 +2190,7 @@ gdk_export BAT *BAThashjoin(BAT *l, BAT
#define GDK_HISTO_MAX_BIT ((int) (sizeof(size_t)<<3))
/* we prefer to use vm_alloc routines on size > GDKmmap */
-gdk_export void *GDKmmap(const char *path, int mode, off_t off, size_t len);
+gdk_export void *GDKmmap(const char *path, int mode, size_t len);
gdk_export size_t GDK_mem_bigsize; /* size after which we use anonymous VM
rather than malloc */
gdk_export size_t GDK_mem_maxsize; /* max allowed size of committed memory
*/
diff --git a/gdk/gdk_posix.c b/gdk/gdk_posix.c
--- a/gdk/gdk_posix.c
+++ b/gdk/gdk_posix.c
@@ -362,7 +362,7 @@ MT_heapcur(void)
}
void *
-MT_mmap(const char *path, int mode, off_t off, size_t len)
+MT_mmap(const char *path, int mode, size_t len)
{
int fd = open(path, O_CREAT | ((mode & MMAP_WRITE) ? O_RDWR :
O_RDONLY), MONETDB_MODE);
void *ret = (void *) -1L;
@@ -373,7 +373,7 @@ MT_mmap(const char *path, int mode, off_
((mode & MMAP_WRITABLE) ? PROT_WRITE : 0) |
PROT_READ,
(mode & MMAP_COPY) ? (MAP_PRIVATE | MAP_NORESERVE) :
MAP_SHARED,
fd,
- off);
+ 0);
close(fd);
}
return ret;
@@ -511,7 +511,7 @@ MT_heapcur(void)
* needs to be unmapped separately in the end. */
void *
-MT_mmap(const char *path, int mode, off_t off, size_t len)
+MT_mmap(const char *path, int mode, size_t len)
{
DWORD mode0 = FILE_READ_ATTRIBUTES | FILE_READ_DATA;
DWORD mode1 = FILE_SHARE_READ | FILE_SHARE_WRITE;
@@ -557,18 +557,18 @@ MT_mmap(const char *path, int mode, off_
}
}
- h2 = CreateFileMapping(h1, &sa, mode3, (DWORD) ((((__int64) off +
(__int64) len) >> 32) & LL_CONSTANT(0xFFFFFFFF)), (DWORD) ((off + len) &
LL_CONSTANT(0xFFFFFFFF)), NULL);
+ h2 = CreateFileMapping(h1, &sa, mode3, (DWORD) (((__int64) len >> 32) &
LL_CONSTANT(0xFFFFFFFF)), (DWORD) (len & LL_CONSTANT(0xFFFFFFFF)), NULL);
if (h2 == NULL) {
GDKsyserror("MT_mmap: CreateFileMapping(" PTRFMT ", &sa, %lu,
%lu, %lu, NULL) failed\n",
PTRFMTCAST h1, mode3,
- (DWORD) ((((__int64) off + (__int64) len) >> 32) &
LL_CONSTANT(0xFFFFFFFF)),
- (DWORD) ((off + len) & LL_CONSTANT(0xFFFFFFFF)));
+ (DWORD) (((__int64) len >> 32) &
LL_CONSTANT(0xFFFFFFFF)),
+ (DWORD) (len & LL_CONSTANT(0xFFFFFFFF)));
CloseHandle(h1);
return (void *) -1;
}
CloseHandle(h1);
- ret = MapViewOfFileEx(h2, mode4, (DWORD) ((__int64) off >> 32), (DWORD)
off, len, NULL);
+ ret = MapViewOfFileEx(h2, mode4, (DWORD) 0, (DWORD) 0, len, NULL);
CloseHandle(h2);
return ret ? ret : (void *) -1;
diff --git a/gdk/gdk_posix.h b/gdk/gdk_posix.h
--- a/gdk/gdk_posix.h
+++ b/gdk/gdk_posix.h
@@ -194,7 +194,7 @@ gdk_export char *MT_heapcur(void);
gdk_export size_t MT_getrss(void);
-gdk_export void *MT_mmap(const char *path, int mode, off_t off, size_t len);
+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 int MT_path_absolute(const char *path);
diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -377,7 +377,7 @@ GDKload(const char *nme, const char *ext
if (mode == STORE_PRIV)
mod |= MMAP_COPY;
- ret = (char *) GDKmmap(path, mod, (off_t) 0,
maxsize);
+ ret = (char *) GDKmmap(path, mod, maxsize);
if (ret == (char *) -1L) {
ret = NULL;
}
diff --git a/gdk/gdk_utils.c b/gdk/gdk_utils.c
--- a/gdk/gdk_utils.c
+++ b/gdk/gdk_utils.c
@@ -1021,18 +1021,18 @@ GDKstrdup(const char *s)
* allocations affect only the logical VM resources.
*/
void *
-GDKmmap(const char *path, int mode, off_t off, size_t len)
+GDKmmap(const char *path, int mode, size_t len)
{
- void *ret = MT_mmap(path, mode, off, len);
+ void *ret = MT_mmap(path, mode, len);
if (ret == (void *) -1L) {
GDKmemfail("GDKmmap", len);
- ret = MT_mmap(path, mode, off, len);
+ ret = MT_mmap(path, mode, len);
if (ret != (void *) -1L) {
THRprintf(GDKstdout, "#GDKmmap: recovery ok.
Continuing..\n");
}
}
- ALLOCDEBUG fprintf(stderr, "#GDKmmap " LLFMT " " SZFMT " " PTRFMT "\n",
(lng) off, len, PTRFMTCAST ret);
+ ALLOCDEBUG fprintf(stderr, "#GDKmmap " SZFMT " " PTRFMT "\n", len,
PTRFMTCAST ret);
if (ret != (void *) -1L) {
/* since mmap directly have content we say its zero-ed
* memory */
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
@@ -760,7 +760,7 @@ IOimport(int *ret, int *bid, str *fnme)
throw(MAL, "io.imports", OPERATION_FAILED "File too
large");
}
#endif
- base = cur = (char *) MT_mmap(*fnme, MMAP_SEQUENTIAL, 0,
(size_t) st.st_size);
+ base = cur = (char *) MT_mmap(*fnme, MMAP_SEQUENTIAL, (size_t)
st.st_size);
if (cur == (char *) -1) {
BBPunfix(b->batCacheid);
throw(MAL, "io.mport", OPERATION_FAILED "MT_mmap()");
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list