1
1

Add in a proper test for munmap.

This commit was SVN r20936.
Этот коммит содержится в:
Jeff Squyres 2009-04-04 00:43:17 +00:00
родитель 5032f59edf
Коммит a13dfb2140
3 изменённых файлов: 16 добавлений и 11 удалений

Просмотреть файл

@ -84,8 +84,6 @@ for the most up-to-date set of tests):
- if the env variable is set to -1, enable our ptmalloc2 if the file
was found
- if the env variable is any other value, enable our ptmalloc2
- if the file is a static library, then override all of the above and
disable our ptmalloc2
- if we're enabling our ptmalloc2, initialize ptmalloc (via
ptmalloc_init()) and then set the 4 hooks to point to our
name-shifted ptmalloc2 functions

Просмотреть файл

@ -24,9 +24,8 @@
#include "opal_config.h"
/* Include <link.h> for _DYNAMIC */
#include <link.h>
#include <malloc.h>
#include <sys/mman.h>
#include "opal/constants.h"
#include "opal/mca/memory/memory.h"
@ -61,17 +60,12 @@ bool opal_memory_ptmalloc2_free_invoked = false;
bool opal_memory_ptmalloc2_malloc_invoked = false;
bool opal_memory_ptmalloc2_realloc_invoked = false;
bool opal_memory_ptmalloc2_memalign_invoked = false;
bool opal_memory_ptmalloc2_munmap_invoked = false;
static int ptmalloc2_open(void)
{
void *p;
/* We always provide munmap support as part of libopen-pal.la. */
int val = OPAL_MEMORY_MUNMAP_SUPPORT;
/* We can't catch munmap if we're a static library */
if (NULL == &_DYNAMIC) {
val = 0;
}
int val = 0;
/* We will also provide malloc/free support if we've been
activated. We don't rely on the __malloc_initialize_hook()
@ -91,6 +85,7 @@ static int ptmalloc2_open(void)
opal_memory_ptmalloc2_realloc_invoked = false;
opal_memory_ptmalloc2_memalign_invoked = false;
opal_memory_ptmalloc2_free_invoked = false;
opal_memory_ptmalloc2_munmap_invoked = false;
p = malloc(1024 * 1024 * 4);
if (NULL == p) {
@ -115,6 +110,13 @@ static int ptmalloc2_open(void)
val |= OPAL_MEMORY_FREE_SUPPORT | OPAL_MEMORY_CHUNK_SUPPORT;
}
p = mmap(NULL, 4096, PROT_READ, MAP_ANONYMOUS, -1, 0);
munmap(p, 4096);
if (opal_memory_ptmalloc2_munmap_invoked) {
val |= OPAL_MEMORY_MUNMAP_SUPPORT;
}
/* Set the support level */
opal_mem_hooks_set_support(val);

Просмотреть файл

@ -66,6 +66,11 @@ opal_mem_free_ptmalloc2_munmap(void *start, size_t length, int from_alloc)
static int (*realmunmap)(void*, size_t);
#endif
{
extern bool opal_memory_ptmalloc2_munmap_invoked;
opal_memory_ptmalloc2_munmap_invoked = true;
}
opal_mem_hooks_release_hook(start, length, from_alloc);
#if defined(HAVE___MUNMAP)