X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fmman%2Fmmap.c;h=fd2bb07e5d5fb53f180bf21e04145914d20e1aa1;hb=fcaec912ed406659832f452e71a6c965308362dd;hp=93c76582a5dfc77057e41c4b022098d5fc6c1067;hpb=0b44a0315b47dd8eced9f3b7f31580cf14bbfc01;p=musl diff --git a/src/mman/mmap.c b/src/mman/mmap.c index 93c76582..fd2bb07e 100644 --- a/src/mman/mmap.c +++ b/src/mman/mmap.c @@ -5,12 +5,25 @@ #include "syscall.h" #include "libc.h" +static void dummy1(int x) { } +static void dummy0(void) { } +weak_alias(dummy1, __vm_lock); +weak_alias(dummy0, __vm_unlock); + void *__mmap(void *start, size_t len, int prot, int flags, int fd, off_t off) { + void *ret; if (sizeof(off_t) > sizeof(long)) if (((long)off & 0xfff) | ((long)((unsigned long long)off>>(12 + 8*(sizeof(off_t)-sizeof(long)))))) start = (void *)-1; - return (void *)syscall6(__NR_mmap2, (long)start, len, prot, flags, fd, off>>12); + if (flags & MAP_FIXED) __vm_lock(-1); +#ifdef SYS_mmap2 + ret = (void *)syscall(SYS_mmap2, start, len, prot, flags, fd, off>>12); +#else + ret = (void *)syscall(SYS_mmap, start, len, prot, flags, fd, off); +#endif + if (flags & MAP_FIXED) __vm_unlock(); + return ret; } weak_alias(__mmap, mmap);