Skip to content

Commit 9f34176

Browse files
committed
add entry point of test
1 parent 525ae42 commit 9f34176

File tree

6 files changed

+12
-15
lines changed

6 files changed

+12
-15
lines changed

libc/config/linux/aarch64/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ set(TARGET_LIBC_ENTRYPOINTS
245245
libc.src.sys.mman.mlock2
246246
libc.src.sys.mman.mlockall
247247
libc.src.sys.mman.mmap
248+
libc.src.sys.mman.mremap
248249
libc.src.sys.mman.mprotect
249250
libc.src.sys.mman.msync
250251
libc.src.sys.mman.munlock

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ set(TARGET_LIBC_ENTRYPOINTS
244244
libc.src.sys.mman.mlock2
245245
libc.src.sys.mman.mlockall
246246
libc.src.sys.mman.mmap
247+
libc.src.sys.mman.mremap
247248
libc.src.sys.mman.mprotect
248249
libc.src.sys.mman.msync
249250
libc.src.sys.mman.munlock

libc/src/sys/mman/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ add_entrypoint_object(
108108
)
109109

110110
add_entrypoint_object(
111-
mremap,
112-
ALIAS,
111+
mremap
112+
ALIAS
113113
DEPENDS
114114
.${LIBC_TARGET_OS}.mremap
115115
)

libc/src/sys/mman/linux/mremap.cpp

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,18 @@ LLVM_LIBC_FUNCTION(void *, mremap,
2424
(void *old_address, size_t old_size, size_t new_size,
2525
int flags, ... /* void *new_address */)) {
2626

27-
#ifdef SYS_mremap
28-
long syscall_number = SYS_mremap;
29-
#else
30-
#error "mremap syscalls not available."
31-
#endif
3227
long ret = 0;
28+
void *new_address = nullptr;
3329
if (flags & MREMAP_FIXED) {
34-
void *arg;
3530
va_list varargs;
3631
va_start(varargs, flags);
37-
arg = va_arg(varargs, void *);
32+
new_address = va_arg(varargs, void *);
3833
va_end(varargs);
39-
ret = LIBC_NAMESPACE::syscall_impl(syscall_number, old_address, old_size,
40-
new_size, flags, arg);
34+
ret = LIBC_NAMESPACE::syscall_impl<long>(SYS_mremap, old_address, old_size,
35+
new_size, flags, new_address);
4136
} else {
42-
ret = LIBC_NAMESPACE::syscall_impl(syscall_number, old_address, old_size,
43-
new_size, flags);
37+
ret = LIBC_NAMESPACE::syscall_impl<long>(SYS_mremap, old_address, old_size,
38+
new_size, flags);
4439
}
4540
if (ret < 0 && ret > -EXEC_PAGESIZE) {
4641
libc_errno = static_cast<int>(-ret);

libc/src/sys/mman/mremap.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
//===-- Implementation header for mremap function -----------------*- C++
2-
//-*-===//
1+
//===-- Implementation header for mremap function -------------------------===//
32
//
43
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
54
// See https://llvm.org/LICENSE.txt for license information.

libc/test/src/sys/mman/linux/mremap_test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "src/errno/libc_errno.h"
1010
#include "src/sys/mman/mmap.h"
11+
#include "src/sys/mman/mremap.h"
1112
#include "src/sys/mman/munmap.h"
1213
#include "test/UnitTest/ErrnoSetterMatcher.h"
1314
#include "test/UnitTest/Test.h"

0 commit comments

Comments
 (0)