Merge pull request #1941 from ggouaillardet/topic/memory_patcher_configury
configury: make memory/patcher symbol detection more robust
Этот коммит содержится в:
Коммит
38f18eed22
@ -36,57 +36,17 @@ AC_DEFUN([MCA_opal_memory_patcher_COMPILE_MODE], [
|
||||
AC_DEFUN([MCA_opal_memory_patcher_CONFIG],[
|
||||
AC_CONFIG_FILES([opal/mca/memory/patcher/Makefile])
|
||||
|
||||
OPAL_VAR_SCOPE_PUSH([memory_patcher_have___curbrk memory_patcher_have___mmap memory_patcher_have___syscall memory_patcher_have___mmap_prototype memory_patcher_have___syscall_prototype])
|
||||
|
||||
memory_patcher_have___curbrk=0
|
||||
memory_patcher_have___mmap=0
|
||||
memory_patcher_have___mmap_prototype=0
|
||||
memory_patcher_have___syscall=0
|
||||
memory_patcher_have___syscall_prototype=0
|
||||
|
||||
AC_MSG_CHECKING([for __curbrk symbol])
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([extern char *__curbrk;],[char *tmp = __curbrk;])],
|
||||
[AC_MSG_RESULT([yes])
|
||||
memory_patcher_have___curbrk=1],
|
||||
[AC_MSG_RESULT([no])])
|
||||
AC_DEFINE_UNQUOTED([OPAL_MEMORY_PATCHER_HAVE___CURBRK], [$memory_patcher_have___curbrk],
|
||||
[Whether the glibc __curbrk exists])
|
||||
|
||||
AC_MSG_CHECKING([whether __mmap prototype exists])
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/mman.h>],[char *tmp = __mmap (NULL, 0, 0, 0, 0, 0);])],
|
||||
[AC_MSG_RESULT([yes])
|
||||
memory_patcher_have___mmap_prototype=1],
|
||||
[AC_MSG_RESULT([no])])
|
||||
AC_DEFINE_UNQUOTED([OPAL_MEMORY_PATCHER_HAVE___MMAP_PROTO], [$memory_patcher_have___mmap_prototype],
|
||||
[Whether the internal __mmap call has a prototype])
|
||||
|
||||
AC_MSG_CHECKING([whether __mmap symbol exists])
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([void *__mmap ();],[char *tmp = __mmap ();])],
|
||||
[AC_MSG_RESULT([yes])
|
||||
memory_patcher_have___mmap=1],
|
||||
[AC_MSG_RESULT([no])])
|
||||
AC_DEFINE_UNQUOTED([OPAL_MEMORY_PATCHER_HAVE___MMAP], [$memory_patcher_have___mmap],
|
||||
[Whether the internal __mmap call exists])
|
||||
|
||||
AC_MSG_CHECKING([whether __syscall prototype exists])
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/syscall.h>],[char *tmp = __syscall (SYS_mmap, NULL);])],
|
||||
[AC_MSG_RESULT([yes])
|
||||
memory_patcher_have___syscall_prototype=1],
|
||||
[AC_MSG_RESULT([no])])
|
||||
AC_DEFINE_UNQUOTED([OPAL_MEMORY_PATCHER_HAVE___SYSCALL_PROTO], [$memory_patcher_have___syscall_prototype],
|
||||
[Whether the internal __syscall call has a prototype])
|
||||
|
||||
AC_MSG_CHECKING([whether __syscall symbol exists])
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([void *__syscall ();],[char *tmp = __syscall ();])],
|
||||
[AC_MSG_RESULT([yes])
|
||||
memory_patcher_have___syscall=1],
|
||||
[AC_MSG_RESULT([no])])
|
||||
AC_DEFINE_UNQUOTED([OPAL_MEMORY_PATCHER_HAVE___SYSCALL], [$memory_patcher_have___syscall],
|
||||
[Whether the internal __syscall call exists])
|
||||
AC_CHECK_FUNCS([__curbrk])
|
||||
|
||||
AC_CHECK_HEADERS([linux/mman.h sys/syscall.h])
|
||||
|
||||
[$1]
|
||||
AC_CHECK_DECLS([__mmap], [], [], [#include <sys/mman.h>])
|
||||
|
||||
OPAL_VAR_SCOPE_POP
|
||||
AC_CHECK_FUNCS([__mmap])
|
||||
|
||||
AC_CHECK_DECLS([__syscall], [], [], [#include <sys/syscall.h>])
|
||||
|
||||
AC_CHECK_FUNCS([__syscall])
|
||||
|
||||
[$1]
|
||||
])
|
||||
|
@ -90,7 +90,7 @@ opal_memory_patcher_component_t mca_memory_patcher_component = {
|
||||
it out) */
|
||||
};
|
||||
|
||||
#if OPAL_MEMORY_PATCHER_HAVE___SYSCALL_PROTO && OPAL_MEMORY_PATCHER_HAVE___SYSCALL
|
||||
#if HAVE_DECL___SYSCALL && defined(HAVE___SYSCALL)
|
||||
/* calling __syscall is preferred on some systems when some arguments may be 64-bit. it also
|
||||
* has the benefit of having an off_t return type */
|
||||
#define memory_patcher_syscall __syscall
|
||||
@ -108,7 +108,7 @@ opal_memory_patcher_component_t mca_memory_patcher_component = {
|
||||
*/
|
||||
#if 0
|
||||
|
||||
#if OPAL_MEMORY_PATCHER_HAVE___MMAP && !OPAL_MEMORY_PATCHER_HAVE___MMAP_PROTO
|
||||
#if defined(HAVE___MMAP) && !HAVE_DECL___MMAP
|
||||
/* prototype for Apple's internal mmap function */
|
||||
void *__mmap (void *start, size_t length, int prot, int flags, int fd, off_t offset);
|
||||
#endif
|
||||
@ -125,7 +125,7 @@ static void *intercept_mmap(void *start, size_t length, int prot, int flags, int
|
||||
}
|
||||
|
||||
if (!original_mmap) {
|
||||
#if OPAL_MEMORY_PATCHER_HAVE___MMAP
|
||||
#ifdef HAVE___MMAP
|
||||
/* the darwin syscall returns an int not a long so call the underlying __mmap function */
|
||||
result = __mmap (start, length, prot, flags, fd, offset);
|
||||
#else
|
||||
@ -248,7 +248,7 @@ static int intercept_madvise (void *start, size_t length, int advice)
|
||||
|
||||
#if defined SYS_brk
|
||||
|
||||
#if OPAL_MEMORY_PATCHER_HAVE___CURBRK
|
||||
#ifdef HAVE___CURBRK
|
||||
extern void *__curbrk; /* in libc */
|
||||
#endif
|
||||
|
||||
@ -260,7 +260,7 @@ static int intercept_brk (void *addr)
|
||||
int result = 0;
|
||||
void *old_addr, *new_addr;
|
||||
|
||||
#if OPAL_MEMORY_PATCHER_HAVE___CURBRK
|
||||
#ifdef HAVE___CURBRK
|
||||
old_addr = __curbrk;
|
||||
#else
|
||||
old_addr = sbrk (0);
|
||||
@ -270,7 +270,7 @@ static int intercept_brk (void *addr)
|
||||
/* get the current_addr */
|
||||
new_addr = (void *) (intptr_t) memory_patcher_syscall(SYS_brk, addr);
|
||||
|
||||
#if OPAL_MEMORY_PATCHER_HAVE___CURBRK
|
||||
#ifdef HAVE___CURBRK
|
||||
/*
|
||||
* Note: if we were using glibc brk/sbrk, their __curbrk would get
|
||||
* updated, but since we're going straight to the syscall, we have
|
||||
@ -280,7 +280,7 @@ static int intercept_brk (void *addr)
|
||||
#endif
|
||||
} else {
|
||||
result = original_brk (addr);
|
||||
#if OPAL_MEMORY_PATCHER_HAVE___CURBRK
|
||||
#ifdef HAVE___CURBRK
|
||||
new_addr = __curbrk;
|
||||
#else
|
||||
new_addr = sbrk (0);
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user