From 0b44a0315b47dd8eced9f3b7f31580cf14bbfc01 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Sat, 12 Feb 2011 00:22:29 -0500 Subject: initial check-in, version 0.5.0 --- src/mman/madvise.c | 10 ++++++++++ src/mman/mlock.c | 7 +++++++ src/mman/mlockall.c | 7 +++++++ src/mman/mmap.c | 18 ++++++++++++++++++ src/mman/mprotect.c | 7 +++++++ src/mman/mremap.c | 19 +++++++++++++++++++ src/mman/msync.c | 8 ++++++++ src/mman/munlock.c | 7 +++++++ src/mman/munlockall.c | 7 +++++++ src/mman/munmap.c | 11 +++++++++++ src/mman/posix_madvise.c | 6 ++++++ 11 files changed, 107 insertions(+) create mode 100644 src/mman/madvise.c create mode 100644 src/mman/mlock.c create mode 100644 src/mman/mlockall.c create mode 100644 src/mman/mmap.c create mode 100644 src/mman/mprotect.c create mode 100644 src/mman/mremap.c create mode 100644 src/mman/msync.c create mode 100644 src/mman/munlock.c create mode 100644 src/mman/munlockall.c create mode 100644 src/mman/munmap.c create mode 100644 src/mman/posix_madvise.c (limited to 'src/mman') diff --git a/src/mman/madvise.c b/src/mman/madvise.c new file mode 100644 index 00000000..f03647ca --- /dev/null +++ b/src/mman/madvise.c @@ -0,0 +1,10 @@ +#include +#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/src/mman/mlock.c b/src/mman/mlock.c new file mode 100644 index 00000000..3c7c653c --- /dev/null +++ b/src/mman/mlock.c @@ -0,0 +1,7 @@ +#include +#include "syscall.h" + +int mlock(const void *addr, size_t len) +{ + return syscall2(__NR_mlock, (long)addr, len); +} diff --git a/src/mman/mlockall.c b/src/mman/mlockall.c new file mode 100644 index 00000000..782fc9db --- /dev/null +++ b/src/mman/mlockall.c @@ -0,0 +1,7 @@ +#include +#include "syscall.h" + +int mlockall(int flags) +{ + return syscall1(__NR_mlockall, flags); +} diff --git a/src/mman/mmap.c b/src/mman/mmap.c new file mode 100644 index 00000000..93c76582 --- /dev/null +++ b/src/mman/mmap.c @@ -0,0 +1,18 @@ +#include +#include +#include +#include +#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; + return (void *)syscall6(__NR_mmap2, (long)start, len, prot, flags, fd, off>>12); +} + +weak_alias(__mmap, mmap); + +LFS64(mmap); diff --git a/src/mman/mprotect.c b/src/mman/mprotect.c new file mode 100644 index 00000000..11d5e231 --- /dev/null +++ b/src/mman/mprotect.c @@ -0,0 +1,7 @@ +#include +#include "syscall.h" + +int mprotect(void *addr, size_t len, int prot) +{ + return syscall3(__NR_mprotect, (long)addr, len, prot); +} diff --git a/src/mman/mremap.c b/src/mman/mremap.c new file mode 100644 index 00000000..78491ef4 --- /dev/null +++ b/src/mman/mremap.c @@ -0,0 +1,19 @@ +#include +#include +#include +#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/src/mman/msync.c b/src/mman/msync.c new file mode 100644 index 00000000..e0926470 --- /dev/null +++ b/src/mman/msync.c @@ -0,0 +1,8 @@ +#include +#include +#include "syscall.h" + +int msync(void *start, size_t len, int flags) +{ + return syscall3(__NR_msync, (long)start, len, flags); +} diff --git a/src/mman/munlock.c b/src/mman/munlock.c new file mode 100644 index 00000000..0db59815 --- /dev/null +++ b/src/mman/munlock.c @@ -0,0 +1,7 @@ +#include +#include "syscall.h" + +int munlock(const void *addr, size_t len) +{ + return syscall2(__NR_munlock, (long)addr, len); +} diff --git a/src/mman/munlockall.c b/src/mman/munlockall.c new file mode 100644 index 00000000..ce3e86cc --- /dev/null +++ b/src/mman/munlockall.c @@ -0,0 +1,7 @@ +#include +#include "syscall.h" + +int munlockall(void) +{ + return syscall0(__NR_munlockall); +} diff --git a/src/mman/munmap.c b/src/mman/munmap.c new file mode 100644 index 00000000..c9661cda --- /dev/null +++ b/src/mman/munmap.c @@ -0,0 +1,11 @@ +#include +#include +#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/src/mman/posix_madvise.c b/src/mman/posix_madvise.c new file mode 100644 index 00000000..4727ad75 --- /dev/null +++ b/src/mman/posix_madvise.c @@ -0,0 +1,6 @@ +#include + +int posix_madvise(void *addr, size_t len, int advice) +{ + return 0; +} -- cgit v1.2.1