1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- #include <_lfs_64.h>
- #include <stdint.h>
- #include <sys/syscall.h>
- #include <errno.h>
- #include <sys/mman.h>
- #ifndef __NR_mmap2
- void *mmap64(void *addr, size_t len, int prot, int flags, int fd, __off64_t offset)
- {
- if (offset != (off_t) offset ||
- (offset + len) != (off_t) (offset + len)) {
- __set_errno(EINVAL);
- return MAP_FAILED;
- }
- return mmap(addr, len, prot, flags, fd, (off_t) offset);
- }
- #else
- # include <bits/uClibc_page.h>
- # ifndef MMAP2_PAGE_SHIFT
- # define MMAP2_PAGE_SHIFT 12
- # endif
- void *mmap64(void *addr, size_t len, int prot, int flags, int fd, __off64_t offset)
- {
-
- # if __WORDSIZE == 32
- uint32_t sysoff;
- # else
- uint64_t sysoff;
- # endif
- if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1)) {
- __set_errno(EINVAL);
- return MAP_FAILED;
- }
-
- sysoff = (uint64_t)offset >> MMAP2_PAGE_SHIFT;
- return (void*) INLINE_SYSCALL(mmap2, 6, addr, len, prot, flags, fd, sysoff);
- }
- #endif
|