X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=src%2Fmman%2Fmmap.c;h=eff88d82a8fcff843247a5436f42016690daac24;hb=d4f987e4ac44e4e5ca2bcf68365b4c2b77bdf2d0;hp=b85f25ca083e8aeff9a20f645a2e4d0f4bd701b6;hpb=f08ab9e61a147630497198fe3239149275c0a3f4;p=musl diff --git a/src/mman/mmap.c b/src/mman/mmap.c index b85f25ca..eff88d82 100644 --- a/src/mman/mmap.c +++ b/src/mman/mmap.c @@ -4,16 +4,16 @@ #include #include #include "syscall.h" -#include "libc.h" static void dummy(void) { } weak_alias(dummy, __vm_wait); #define UNIT SYSCALL_MMAP2_UNIT -#define OFF_MASK ((-0x2000ULL << (8*sizeof(long)-1)) | (UNIT-1)) +#define OFF_MASK ((-0x2000ULL << (8*sizeof(syscall_arg_t)-1)) | (UNIT-1)) void *__mmap(void *start, size_t len, int prot, int flags, int fd, off_t off) { + long ret; if (off & OFF_MASK) { errno = EINVAL; return MAP_FAILED; @@ -26,12 +26,16 @@ void *__mmap(void *start, size_t len, int prot, int flags, int fd, off_t off) __vm_wait(); } #ifdef SYS_mmap2 - return (void *)syscall(SYS_mmap2, start, len, prot, flags, fd, off/UNIT); + ret = __syscall(SYS_mmap2, start, len, prot, flags, fd, off/UNIT); #else - return (void *)syscall(SYS_mmap, start, len, prot, flags, fd, off); + ret = __syscall(SYS_mmap, start, len, prot, flags, fd, off); #endif + /* Fixup incorrect EPERM from kernel. */ + if (ret == -EPERM && !start && (flags&MAP_ANON) && !(flags&MAP_FIXED)) + ret = -ENOMEM; + return (void *)__syscall_ret(ret); } weak_alias(__mmap, mmap); -LFS64(mmap); +weak_alias(mmap, mmap64);