summaryrefslogtreecommitdiff
path: root/05/musl-0.6.0/src/mman
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2022-02-20 13:18:21 -0800
committerpommicket <pommicket@gmail.com>2022-02-20 13:18:21 -0800
commit9bc8a11afeed3569736b89754012e3ca22ee10f6 (patch)
tree5f0ec0d5c05f879b1ee86adfa654ed3ef2178d5f /05/musl-0.6.0/src/mman
parent0f97a589b800bdb71dda05984192f0f66a52edaa (diff)
conclusion
Diffstat (limited to '05/musl-0.6.0/src/mman')
-rw-r--r--05/musl-0.6.0/src/mman/madvise.c10
-rw-r--r--05/musl-0.6.0/src/mman/mlock.c7
-rw-r--r--05/musl-0.6.0/src/mman/mlockall.c7
-rw-r--r--05/musl-0.6.0/src/mman/mmap.c22
-rw-r--r--05/musl-0.6.0/src/mman/mprotect.c7
-rw-r--r--05/musl-0.6.0/src/mman/mremap.c19
-rw-r--r--05/musl-0.6.0/src/mman/msync.c8
-rw-r--r--05/musl-0.6.0/src/mman/munlock.c7
-rw-r--r--05/musl-0.6.0/src/mman/munlockall.c7
-rw-r--r--05/musl-0.6.0/src/mman/munmap.c11
-rw-r--r--05/musl-0.6.0/src/mman/posix_madvise.c6
11 files changed, 111 insertions, 0 deletions
diff --git a/05/musl-0.6.0/src/mman/madvise.c b/05/musl-0.6.0/src/mman/madvise.c
new file mode 100644
index 0000000..f03647c
--- /dev/null
+++ b/05/musl-0.6.0/src/mman/madvise.c
@@ -0,0 +1,10 @@
+#include <sys/mman.h>
+#include "syscall.h"
+#include "libc.h"
+
+int __madvise(void *addr, size_t len, int advice)
+{
+ return syscall3(__NR_madvise, (long)addr, len, advice);
+}
+
+weak_alias(__madvise, madvise);
diff --git a/05/musl-0.6.0/src/mman/mlock.c b/05/musl-0.6.0/src/mman/mlock.c
new file mode 100644
index 0000000..3c7c653
--- /dev/null
+++ b/05/musl-0.6.0/src/mman/mlock.c
@@ -0,0 +1,7 @@
+#include <sys/mman.h>
+#include "syscall.h"
+
+int mlock(const void *addr, size_t len)
+{
+ return syscall2(__NR_mlock, (long)addr, len);
+}
diff --git a/05/musl-0.6.0/src/mman/mlockall.c b/05/musl-0.6.0/src/mman/mlockall.c
new file mode 100644
index 0000000..782fc9d
--- /dev/null
+++ b/05/musl-0.6.0/src/mman/mlockall.c
@@ -0,0 +1,7 @@
+#include <sys/mman.h>
+#include "syscall.h"
+
+int mlockall(int flags)
+{
+ return syscall1(__NR_mlockall, flags);
+}
diff --git a/05/musl-0.6.0/src/mman/mmap.c b/05/musl-0.6.0/src/mman/mmap.c
new file mode 100644
index 0000000..5be6e12
--- /dev/null
+++ b/05/musl-0.6.0/src/mman/mmap.c
@@ -0,0 +1,22 @@
+#include <unistd.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <limits.h>
+#include "syscall.h"
+#include "libc.h"
+
+void *__mmap(void *start, size_t len, int prot, int flags, int fd, off_t off)
+{
+ 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;
+#ifdef __NR_mmap2
+ return (void *)syscall6(__NR_mmap2, (long)start, len, prot, flags, fd, off>>12);
+#else
+ return (void *)syscall6(__NR_mmap, (long)start, len, prot, flags, fd, off);
+#endif
+}
+
+weak_alias(__mmap, mmap);
+
+LFS64(mmap);
diff --git a/05/musl-0.6.0/src/mman/mprotect.c b/05/musl-0.6.0/src/mman/mprotect.c
new file mode 100644
index 0000000..11d5e23
--- /dev/null
+++ b/05/musl-0.6.0/src/mman/mprotect.c
@@ -0,0 +1,7 @@
+#include <sys/mman.h>
+#include "syscall.h"
+
+int mprotect(void *addr, size_t len, int prot)
+{
+ return syscall3(__NR_mprotect, (long)addr, len, prot);
+}
diff --git a/05/musl-0.6.0/src/mman/mremap.c b/05/musl-0.6.0/src/mman/mremap.c
new file mode 100644
index 0000000..78491ef
--- /dev/null
+++ b/05/musl-0.6.0/src/mman/mremap.c
@@ -0,0 +1,19 @@
+#include <unistd.h>
+#include <sys/mman.h>
+#include <stdarg.h>
+#include "syscall.h"
+#include "libc.h"
+
+void *__mremap(void *old_addr, size_t old_len, size_t new_len, int flags, ...)
+{
+ va_list ap;
+ void *new_addr;
+
+ va_start(ap, flags);
+ new_addr = va_arg(ap, void *);
+ va_end(ap);
+
+ return (void *)syscall5(__NR_mremap, (long)old_addr, old_len, new_len, flags, (long)new_addr);
+}
+
+weak_alias(__mremap, mremap);
diff --git a/05/musl-0.6.0/src/mman/msync.c b/05/musl-0.6.0/src/mman/msync.c
new file mode 100644
index 0000000..e092647
--- /dev/null
+++ b/05/musl-0.6.0/src/mman/msync.c
@@ -0,0 +1,8 @@
+#include <unistd.h>
+#include <sys/mman.h>
+#include "syscall.h"
+
+int msync(void *start, size_t len, int flags)
+{
+ return syscall3(__NR_msync, (long)start, len, flags);
+}
diff --git a/05/musl-0.6.0/src/mman/munlock.c b/05/musl-0.6.0/src/mman/munlock.c
new file mode 100644
index 0000000..0db5981
--- /dev/null
+++ b/05/musl-0.6.0/src/mman/munlock.c
@@ -0,0 +1,7 @@
+#include <sys/mman.h>
+#include "syscall.h"
+
+int munlock(const void *addr, size_t len)
+{
+ return syscall2(__NR_munlock, (long)addr, len);
+}
diff --git a/05/musl-0.6.0/src/mman/munlockall.c b/05/musl-0.6.0/src/mman/munlockall.c
new file mode 100644
index 0000000..ce3e86c
--- /dev/null
+++ b/05/musl-0.6.0/src/mman/munlockall.c
@@ -0,0 +1,7 @@
+#include <sys/mman.h>
+#include "syscall.h"
+
+int munlockall(void)
+{
+ return syscall0(__NR_munlockall);
+}
diff --git a/05/musl-0.6.0/src/mman/munmap.c b/05/musl-0.6.0/src/mman/munmap.c
new file mode 100644
index 0000000..c9661cd
--- /dev/null
+++ b/05/musl-0.6.0/src/mman/munmap.c
@@ -0,0 +1,11 @@
+#include <unistd.h>
+#include <sys/mman.h>
+#include "syscall.h"
+#include "libc.h"
+
+int __munmap(void *start, size_t len)
+{
+ return syscall2(__NR_munmap, (long)start, len);
+}
+
+weak_alias(__munmap, munmap);
diff --git a/05/musl-0.6.0/src/mman/posix_madvise.c b/05/musl-0.6.0/src/mman/posix_madvise.c
new file mode 100644
index 0000000..4727ad7
--- /dev/null
+++ b/05/musl-0.6.0/src/mman/posix_madvise.c
@@ -0,0 +1,6 @@
+#include <sys/mman.h>
+
+int posix_madvise(void *addr, size_t len, int advice)
+{
+ return 0;
+}