Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1708)

Unified Diff: fusl/src/mman/mmap.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fusl/src/mman/mlockall.c ('k') | fusl/src/mman/mprotect.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fusl/src/mman/mmap.c
diff --git a/fusl/src/mman/mmap.c b/fusl/src/mman/mmap.c
new file mode 100644
index 0000000000000000000000000000000000000000..b85f25ca083e8aeff9a20f645a2e4d0f4bd701b6
--- /dev/null
+++ b/fusl/src/mman/mmap.c
@@ -0,0 +1,37 @@
+#include <unistd.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <stdint.h>
+#include <limits.h>
+#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))
+
+void *__mmap(void *start, size_t len, int prot, int flags, int fd, off_t off)
+{
+ if (off & OFF_MASK) {
+ errno = EINVAL;
+ return MAP_FAILED;
+ }
+ if (len >= PTRDIFF_MAX) {
+ errno = ENOMEM;
+ return MAP_FAILED;
+ }
+ if (flags & MAP_FIXED) {
+ __vm_wait();
+ }
+#ifdef SYS_mmap2
+ return (void *)syscall(SYS_mmap2, start, len, prot, flags, fd, off/UNIT);
+#else
+ return (void *)syscall(SYS_mmap, start, len, prot, flags, fd, off);
+#endif
+}
+
+weak_alias(__mmap, mmap);
+
+LFS64(mmap);
« no previous file with comments | « fusl/src/mman/mlockall.c ('k') | fusl/src/mman/mprotect.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698