Hi,
I hope I'm sending this to the right address, cc'ing Peter Bex
because he's mentioned in the .egg definition.
The `memory-mapped-files` egg currently treats the `length` and
`offset` parameters of `mmap` as integers which arbitrarily
restricts mapable files to a size of MAX_INT bytes.
By simply changing the type declaration in the `foreign-lambda`
definitions we can allow basically arbitrarily big files to be
mapped.
Ultimately I'm looking to also patch the `simple-md5` egg to be
able to hash arbitrarily big files. Currently it has the same
restriction.
Caveats:
1. I have no insight if this was a deliberate restriction that
works around some issue I'm not aware of.
2. I'm not able to test the code for any platform but linux.
I have basically no experience with svn, I hope I got the patch
format right, let me know if not.
~~lou
Index: memory-mapped-files.scm
===================================================================
--- memory-mapped-files.scm (revision 43989)
+++ memory-mapped-files.scm (working copy)
@@ -124,7 +124,7 @@
return 0;
}
-void* mmap(void* addr,int len,int prot,int flags,int fd,int off)
+void* mmap(void* addr,size_t len,int prot,int flags,int fd,int off)
{
HANDLE hMap;
HANDLE hFile;
@@ -180,7 +180,7 @@
return ptr;
}
-int munmap(void* addr,int len)
+int munmap(void* addr,size_t len)
{
if (UnmapViewOfFile(addr))
{
@@ -269,7 +269,7 @@
(define map/file _map_file)
(define map-file-to-memory
- (let ((mmap (foreign-lambda c-pointer "mmap" c-pointer integer int int int integer))
+ (let ((mmap (foreign-lambda c-pointer "mmap" c-pointer size_t int int int size_t))
(bad-mmap? (foreign-lambda bool "is_bad_mmap" c-pointer)))
(lambda (addr len prot flag fd . off)
(let ((addr (if (not addr) (##sys#null-pointer) addr))
@@ -282,7 +282,7 @@
(##sys#make-structure 'mmap addr2 len) ) ) ) ) )
(define unmap-file-from-memory
- (let ((munmap (foreign-lambda int "munmap" c-pointer integer)) )
+ (let ((munmap (foreign-lambda int "munmap" c-pointer size_t)) )
(lambda (mmap . len)
(##sys#check-structure mmap 'mmap 'unmap-file-from-memory)
(let ((len (if (pair? len) (car len) (##sys#slot mmap 2))))