memory/patcher: fix compilation on BSDs
The function signature of mremap on BSD (NetBSD, FreeBSD) differs from the linux version. Added support for the BSD style of mremap. Signed-off-by: Nathan Hjelm <hjelmn@lanl.gov>
Этот коммит содержится в:
родитель
52edb43bdc
Коммит
eb14b34f04
@ -166,11 +166,20 @@ static int intercept_munmap(void *start, size_t length)
|
||||
|
||||
#if defined (SYS_mremap)
|
||||
|
||||
#if defined(__linux__)
|
||||
/* on linux this function has an optional extra argument but ... can not be used here because it
|
||||
* causes issues when intercepting a 4-argument mremap call */
|
||||
static void *(*original_mremap) (void *, size_t, size_t, int, void *);
|
||||
#else
|
||||
/* mremap has a different signature on BSD systems */
|
||||
static void *(*original_mremap) (void *, size_t, void *, size_t, int);
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
static void *intercept_mremap (void *start, size_t oldlen, size_t newlen, int flags, void *new_address)
|
||||
#else
|
||||
static void *intercept_mremap (void *start, size_t oldlen, void *new_address, size_t newlen, int flags)
|
||||
#endif
|
||||
{
|
||||
OPAL_PATCHER_BEGIN;
|
||||
void *result = MAP_FAILED;
|
||||
@ -185,11 +194,19 @@ static void *intercept_mremap (void *start, size_t oldlen, size_t newlen, int fl
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
if (!original_mremap) {
|
||||
result = (void *)(intptr_t) memory_patcher_syscall (SYS_mremap, start, oldlen, newlen, flags, new_address);
|
||||
} else {
|
||||
result = original_mremap (start, oldlen, newlen, flags, new_address);
|
||||
}
|
||||
#else
|
||||
if (!original_mremap) {
|
||||
result = (void *)(intptr_t) memory_patcher_syscall (SYS_mremap, start, oldlen, new_address, newlen, flags);
|
||||
} else {
|
||||
result = original_mremap (start, oldlen, new_address, newlen, flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
OPAL_PATCHER_END;
|
||||
return result;
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user