Merge "fix the mremap signature"
This commit is contained in:
commit
8b5b2c4672
|
@ -47,7 +47,6 @@ libc_common_src_files := \
|
|||
bionic/if_indextoname.c \
|
||||
bionic/if_nametoindex.c \
|
||||
bionic/initgroups.c \
|
||||
bionic/ioctl.c \
|
||||
bionic/isatty.c \
|
||||
bionic/memmem.c \
|
||||
bionic/pututline.c \
|
||||
|
@ -151,6 +150,7 @@ libc_bionic_ndk_src_files := \
|
|||
bionic/gettid.cpp \
|
||||
bionic/__gnu_basename.cpp \
|
||||
bionic/inotify_init.cpp \
|
||||
bionic/ioctl.cpp \
|
||||
bionic/lchown.cpp \
|
||||
bionic/lfs64_support.cpp \
|
||||
bionic/__libc_current_sigrtmax.cpp \
|
||||
|
@ -170,6 +170,7 @@ libc_bionic_ndk_src_files := \
|
|||
bionic/mkfifo.cpp \
|
||||
bionic/mknod.cpp \
|
||||
bionic/mntent.cpp \
|
||||
bionic/mremap.cpp \
|
||||
bionic/NetdClientDispatch.cpp \
|
||||
bionic/open.cpp \
|
||||
bionic/pathconf.cpp \
|
||||
|
|
|
@ -107,7 +107,7 @@ ssize_t pwritev|pwritev64(int, const struct iovec*, int, off_t) arm64,mips64
|
|||
int ___close:close(int) all
|
||||
pid_t __getpid:getpid() all
|
||||
int munmap(void*, size_t) all
|
||||
void* mremap(void*, size_t, size_t, unsigned long) all
|
||||
void* ___mremap:mremap(void*, size_t, size_t, int, void*) all
|
||||
int msync(const void*, size_t, int) all
|
||||
int mprotect(const void*, size_t, int) all
|
||||
int madvise(void*, size_t, int) all
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
/* Generated by gensyscalls.py. Do not edit. */
|
||||
|
||||
#include <private/bionic_asm.h>
|
||||
|
||||
ENTRY(___mremap)
|
||||
mov ip, sp
|
||||
stmfd sp!, {r4, r5, r6, r7}
|
||||
.cfi_def_cfa_offset 16
|
||||
.cfi_rel_offset r4, 0
|
||||
.cfi_rel_offset r5, 4
|
||||
.cfi_rel_offset r6, 8
|
||||
.cfi_rel_offset r7, 12
|
||||
ldmfd ip, {r4, r5, r6}
|
||||
ldr r7, =__NR_mremap
|
||||
swi #0
|
||||
ldmfd sp!, {r4, r5, r6, r7}
|
||||
.cfi_def_cfa_offset 0
|
||||
cmn r0, #(MAX_ERRNO + 1)
|
||||
bxls lr
|
||||
neg r0, r0
|
||||
b __set_errno_internal
|
||||
END(___mremap)
|
||||
.hidden ___mremap
|
|
@ -1,14 +0,0 @@
|
|||
/* Generated by gensyscalls.py. Do not edit. */
|
||||
|
||||
#include <private/bionic_asm.h>
|
||||
|
||||
ENTRY(mremap)
|
||||
mov ip, r7
|
||||
ldr r7, =__NR_mremap
|
||||
swi #0
|
||||
mov r7, ip
|
||||
cmn r0, #(MAX_ERRNO + 1)
|
||||
bxls lr
|
||||
neg r0, r0
|
||||
b __set_errno_internal
|
||||
END(mremap)
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <private/bionic_asm.h>
|
||||
|
||||
ENTRY(mremap)
|
||||
ENTRY(___mremap)
|
||||
mov x8, __NR_mremap
|
||||
svc #0
|
||||
|
||||
|
@ -11,4 +11,5 @@ ENTRY(mremap)
|
|||
b.hi __set_errno_internal
|
||||
|
||||
ret
|
||||
END(mremap)
|
||||
END(___mremap)
|
||||
.hidden ___mremap
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <private/bionic_asm.h>
|
||||
|
||||
ENTRY(mremap)
|
||||
ENTRY(___mremap)
|
||||
.set noreorder
|
||||
.cpload t9
|
||||
li v0, __NR_mremap
|
||||
|
@ -16,4 +16,5 @@ ENTRY(mremap)
|
|||
j t9
|
||||
nop
|
||||
.set reorder
|
||||
END(mremap)
|
||||
END(___mremap)
|
||||
.hidden ___mremap
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <private/bionic_asm.h>
|
||||
|
||||
ENTRY(mremap)
|
||||
ENTRY(___mremap)
|
||||
.set push
|
||||
.set noreorder
|
||||
li v0, __NR_mremap
|
||||
|
@ -22,4 +22,5 @@ ENTRY(mremap)
|
|||
j t9
|
||||
move ra, t0
|
||||
.set pop
|
||||
END(mremap)
|
||||
END(___mremap)
|
||||
.hidden ___mremap
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <private/bionic_asm.h>
|
||||
|
||||
ENTRY(mremap)
|
||||
ENTRY(___mremap)
|
||||
pushl %ebx
|
||||
.cfi_def_cfa_offset 8
|
||||
.cfi_rel_offset ebx, 0
|
||||
|
@ -15,10 +15,14 @@ ENTRY(mremap)
|
|||
pushl %esi
|
||||
.cfi_adjust_cfa_offset 4
|
||||
.cfi_rel_offset esi, 0
|
||||
mov 20(%esp), %ebx
|
||||
mov 24(%esp), %ecx
|
||||
mov 28(%esp), %edx
|
||||
mov 32(%esp), %esi
|
||||
pushl %edi
|
||||
.cfi_adjust_cfa_offset 4
|
||||
.cfi_rel_offset edi, 0
|
||||
mov 24(%esp), %ebx
|
||||
mov 28(%esp), %ecx
|
||||
mov 32(%esp), %edx
|
||||
mov 36(%esp), %esi
|
||||
mov 40(%esp), %edi
|
||||
movl $__NR_mremap, %eax
|
||||
int $0x80
|
||||
cmpl $-MAX_ERRNO, %eax
|
||||
|
@ -28,9 +32,11 @@ ENTRY(mremap)
|
|||
call __set_errno_internal
|
||||
addl $4, %esp
|
||||
1:
|
||||
popl %edi
|
||||
popl %esi
|
||||
popl %edx
|
||||
popl %ecx
|
||||
popl %ebx
|
||||
ret
|
||||
END(mremap)
|
||||
END(___mremap)
|
||||
.hidden ___mremap
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include <private/bionic_asm.h>
|
||||
|
||||
ENTRY(mremap)
|
||||
ENTRY(___mremap)
|
||||
movq %rcx, %r10
|
||||
movl $__NR_mremap, %eax
|
||||
syscall
|
||||
|
@ -13,4 +13,5 @@ ENTRY(mremap)
|
|||
call __set_errno_internal
|
||||
1:
|
||||
ret
|
||||
END(mremap)
|
||||
END(___mremap)
|
||||
.hidden ___mremap
|
|
@ -25,19 +25,16 @@
|
|||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
extern int __ioctl(int, int, void *);
|
||||
extern "C" int __ioctl(int, int, void *);
|
||||
|
||||
int ioctl(int fd, int request, ...)
|
||||
{
|
||||
va_list ap;
|
||||
void * arg;
|
||||
|
||||
va_start(ap, request);
|
||||
arg = va_arg(ap, void *);
|
||||
va_end(ap);
|
||||
|
||||
return __ioctl(fd, request, arg);
|
||||
int ioctl(int fd, int request, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, request);
|
||||
void* arg = va_arg(ap, void*);
|
||||
va_end(ap);
|
||||
return __ioctl(fd, request, arg);
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (C) 2015 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
extern "C" void* ___mremap(void*, size_t, size_t, int, void*);
|
||||
|
||||
void* mremap(void* old_address, size_t old_size, size_t new_size, int flags, ...) {
|
||||
void* new_address = nullptr;
|
||||
// The optional argument is only valid if the MREMAP_FIXED flag is set,
|
||||
// so we assume it's not present otherwise.
|
||||
if ((flags & MREMAP_FIXED) != 0) {
|
||||
va_list ap;
|
||||
va_start(ap, flags);
|
||||
new_address = va_arg(ap, void*);
|
||||
va_end(ap);
|
||||
}
|
||||
return ___mremap(old_address, old_size, new_size, flags, new_address);
|
||||
}
|
|
@ -59,7 +59,7 @@ extern void* mmap64(void*, size_t, int, int, int, off64_t);
|
|||
extern int munmap(void*, size_t);
|
||||
extern int msync(const void*, size_t, int);
|
||||
extern int mprotect(const void*, size_t, int);
|
||||
extern void* mremap(void*, size_t, size_t, unsigned long);
|
||||
extern void* mremap(void*, size_t, size_t, int, ...);
|
||||
|
||||
extern int mlockall(int);
|
||||
extern int munlockall(void);
|
||||
|
|
|
@ -215,3 +215,7 @@ TEST(sys_mman, posix_madvise_POSIX_MADV_DONTNEED) {
|
|||
|
||||
ASSERT_EQ(0, munmap(map, pagesize));
|
||||
}
|
||||
|
||||
TEST(sys_mman, mremap) {
|
||||
ASSERT_EQ(MAP_FAILED, mremap(nullptr, 0, 0, 0));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue