projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
epoll_create: fail with EINVAL if size is non-positive
[musl]
/
src
/
mman
/
mmap.c
diff --git
a/src/mman/mmap.c
b/src/mman/mmap.c
index
56e39a7
..
eff88d8
100644
(file)
--- a/
src/mman/mmap.c
+++ b/
src/mman/mmap.c
@@
-4,18
+4,16
@@
#include <stdint.h>
#include <limits.h>
#include "syscall.h"
#include <stdint.h>
#include <limits.h>
#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);
+static void dummy(void) { }
+weak_alias(dummy, __vm_wait);
#define UNIT SYSCALL_MMAP2_UNIT
#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)
{
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;
if (off & OFF_MASK) {
errno = EINVAL;
return MAP_FAILED;
@@
-25,16
+23,19
@@
void *__mmap(void *start, size_t len, int prot, int flags, int fd, off_t off)
return MAP_FAILED;
}
if (flags & MAP_FIXED) {
return MAP_FAILED;
}
if (flags & MAP_FIXED) {
- __vm_lock(-1);
- __vm_unlock();
+ __vm_wait();
}
#ifdef SYS_mmap2
}
#ifdef SYS_mmap2
- ret
urn (void *)
syscall(SYS_mmap2, start, len, prot, flags, fd, off/UNIT);
+ ret
= __
syscall(SYS_mmap2, start, len, prot, flags, fd, off/UNIT);
#else
#else
- ret
urn (void *)
syscall(SYS_mmap, start, len, prot, flags, fd, off);
+ ret
= __
syscall(SYS_mmap, start, len, prot, flags, fd, off);
#endif
#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);
}
weak_alias(__mmap, mmap);
-
LFS64(mmap
);
+
weak_alias(mmap, mmap64
);