about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2014-07-30 23:24:31 -0400
committerRich Felker <dalias@aerifal.cx>2014-07-30 23:24:31 -0400
commitb5bbe797493ea732d4cac15619753c545ed392af (patch)
treebe2033bb393de2e36577f3c5c83e8ad3517089be /src
parentcc54f0aebad529c1abfa49d2d9e319267d57cb9f (diff)
downloadmusl-b5bbe797493ea732d4cac15619753c545ed392af.tar.gz
musl-b5bbe797493ea732d4cac15619753c545ed392af.tar.xz
musl-b5bbe797493ea732d4cac15619753c545ed392af.zip
add framework for mmap2 syscall unit to vary by arch
Diffstat (limited to 'src')
-rw-r--r--src/internal/syscall.h4
-rw-r--r--src/mman/mmap.c5
2 files changed, 7 insertions, 2 deletions
diff --git a/src/internal/syscall.h b/src/internal/syscall.h
index 0a2840ad..bb96c26e 100644
--- a/src/internal/syscall.h
+++ b/src/internal/syscall.h
@@ -8,6 +8,10 @@
 #define SYSCALL_RLIM_INFINITY (~0ULL)
 #endif
 
+#ifndef SYSCALL_MMAP2_UNIT
+#define SYSCALL_MMAP2_UNIT 4096ULL
+#endif
+
 #ifndef __scc
 #define __scc(X) ((long) (X))
 typedef long syscall_arg_t;
diff --git a/src/mman/mmap.c b/src/mman/mmap.c
index b56cff86..1917a540 100644
--- a/src/mman/mmap.c
+++ b/src/mman/mmap.c
@@ -11,7 +11,8 @@ static void dummy0(void) { }
 weak_alias(dummy1, __vm_lock);
 weak_alias(dummy0, __vm_unlock);
 
-#define OFF_MASK ((-0x2000ULL << (8*sizeof(long)-1)) | 0xfff)
+#define UNIT SYSCALL_MMAP2_UNIT
+#define OFF_MASK ((-0x2000ULL << (8*sizeof(long)-1)) | (UNIT-1))
 
 void *__mmap(void *start, size_t len, int prot, int flags, int fd, off_t off)
 {
@@ -27,7 +28,7 @@ void *__mmap(void *start, size_t len, int prot, int flags, int fd, off_t off)
 	}
 	if (flags & MAP_FIXED) __vm_lock(-1);
 #ifdef SYS_mmap2
-	ret = (void *)syscall(SYS_mmap2, start, len, prot, flags, fd, off>>12);
+	ret = (void *)syscall(SYS_mmap2, start, len, prot, flags, fd, off/UNIT);
 #else
 	ret = (void *)syscall(SYS_mmap, start, len, prot, flags, fd, off);
 #endif