1
1
This commit was SVN r18531.
Этот коммит содержится в:
Jeff Squyres 2008-05-28 23:50:53 +00:00
родитель e5ea9d08ca
Коммит ed5bc2cd08
4 изменённых файлов: 0 добавлений и 313 удалений

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

@ -1,23 +0,0 @@
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
noinst_LTLIBRARIES = libmca_memory_darwin.la
# Source code files
libmca_memory_darwin_la_SOURCES = \
memory_darwin_component.c

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

@ -1,69 +0,0 @@
# -*- shell-script -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
AC_DEFUN([MCA_memory_darwin_COMPILE_MODE], [
AC_MSG_CHECKING([for MCA component $2:$3 compile mode])
$4="static"
AC_MSG_RESULT([$$4])
])
# MCA_memory_darwin_CONFIG(action-if-can-compile,
# [action-if-cant-compile])
# ------------------------------------------------
AC_DEFUN([MCA_memory_darwin_CONFIG],[
AS_IF([test "$with_memory_manager" = "darwin"],
[memory_darwin_happy="yes"
memory_darwin_should_use=1],
[memory_darwin_should_use=0
AS_IF([test "$with_memory_manager" = ""],
[memory_darwin_happy="yes"],
[memory_darwin_happy="no"])])
AS_IF([test "$memory_darwin_happy" = "yes"],
[# check for malloc/malloc.h
AC_CHECK_HEADER([malloc/malloc.h],
[memory_darwin_happy="yes"],
[memory_darwin_happy="no"])])
AS_IF([test "$memory_darwin_happy" = "yes"],
[# check for hook to get correct callbacks
AC_CHECK_FUNC([malloc_default_zone],
[memory_darwin_happy="yes"],
[memory_darwin_happy="no"])])
# this should be true for any reasonably recent version of OS X,
# but make sure.
AS_IF([test "$memory_darwin_happy" = "yes"],
[AC_CHECK_FUNC([dlsym],
[memory_darwin_happy="yes"],
[memory_darwin_happy="no"])])
AS_IF([test "$memory_darwin_happy" = "no" -a \
"$memory_malloc_hoooks_should_use" = "1"],
[AC_MSG_ERROR([Darwin memory management requested but not available. Aborting.])])
AS_IF([test "$memory_darwin_happy" = "yes"],
[# Yes, we really do want to screw with LDFLAGS here...
LDFLAGS="$LDFLAGS -Wl,-u,_munmap -Wl,-multiply_defined,suppress"
memory_darwin_WRAPPER_EXTRA_LDFLAGS="-Wl,-u,_munmap -Wl,-multiply_defined,suppress"
memory_base_found=1
$1], [$2])
])

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

@ -1,23 +0,0 @@
# -*- shell-script -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
# Specific to this module
PARAM_CONFIG_PRIORITY=20
PARAM_CONFIG_FILES="Makefile"

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

@ -1,198 +0,0 @@
/*
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2005 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#include "opal_config.h"
#include <malloc/malloc.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <dlfcn.h>
#include "opal/constants.h"
#include "opal/mca/memory/memory.h"
#include "opal/memoryhooks/memory_internal.h"
static int opal_memory_darwin_open(void);
static void* opal_memory_darwin_malloc(struct _malloc_zone_t *zone, size_t size);
static void* opal_memory_darwin_calloc(struct _malloc_zone_t *zone, size_t num_items,
size_t size);
static void* opal_memory_darwin_valloc(struct _malloc_zone_t *zone, size_t size);
static void opal_memory_darwin_free(struct _malloc_zone_t *zone, void *ptr);
static void* opal_memory_darwin_realloc(struct _malloc_zone_t *zone,
void *ptr, size_t size);
const opal_memory_base_component_1_0_0_t mca_memory_darwin_component = {
/* First, the mca_component_t struct containing meta information
about the component itself */
{
/* Indicate that we are a memory v1.0.0 component (which also
implies a specific MCA version) */
OPAL_MEMORY_BASE_VERSION_1_0_0,
/* Component name and version */
"darwin",
OPAL_MAJOR_VERSION,
OPAL_MINOR_VERSION,
OPAL_RELEASE_VERSION,
/* Component open and close functions */
opal_memory_darwin_open,
NULL
},
/* Next the MCA v1.0.0 component meta data */
{
/* The component is checkpoint ready */
MCA_BASE_METADATA_PARAM_CHECKPOINT
},
};
static void* (*next_malloc)(struct _malloc_zone_t *zone, size_t size);
static void* (*next_calloc)(struct _malloc_zone_t *zone, size_t num_items, size_t size);
static void* (*next_valloc)(struct _malloc_zone_t *zone, size_t size);
static void (*next_free)(struct _malloc_zone_t *zone, void *ptr);
static void* (*next_realloc)(struct _malloc_zone_t *zone, void *ptr, size_t size);
static int
opal_memory_darwin_open(void)
{
/* add hooks to intercept free */
malloc_zone_t *default_zone;
default_zone = malloc_default_zone();
/* save the pointers first, so that we can call them as soon as we
replace the hooks below (think threads) */
next_malloc = default_zone->malloc;
next_calloc = default_zone->calloc;
next_valloc = default_zone->valloc;
next_free = default_zone->free;
next_realloc = default_zone->realloc;
default_zone->malloc = opal_memory_darwin_malloc;
default_zone->calloc = opal_memory_darwin_calloc;
default_zone->valloc = opal_memory_darwin_valloc;
default_zone->free = opal_memory_darwin_free;
default_zone->realloc = opal_memory_darwin_realloc;
opal_mem_hooks_set_support(OPAL_MEMORY_FREE_SUPPORT|OPAL_MEMORY_MALLOC_SUPPORT);
return OPAL_SUCCESS;
}
static void *
opal_memory_darwin_malloc(struct _malloc_zone_t *zone, size_t size)
{
void *tmp = next_malloc(zone, size);
opal_mem_hooks_alloc_hook(tmp, malloc_size(tmp), 1);
return tmp;
}
static void*
opal_memory_darwin_calloc(struct _malloc_zone_t *zone, size_t num_items,
size_t size)
{
void *tmp = next_calloc(zone, num_items, size);
opal_mem_hooks_alloc_hook(tmp, malloc_size(tmp), 1);
return tmp;
}
static void*
opal_memory_darwin_valloc(struct _malloc_zone_t *zone, size_t size)
{
void *tmp = next_valloc(zone, size);
opal_mem_hooks_alloc_hook(tmp, malloc_size(tmp), 1);
return tmp;
}
static void
opal_memory_darwin_free(struct _malloc_zone_t *zone, void *ptr)
{
opal_mem_hooks_release_hook(ptr, malloc_size(ptr), 1);
next_free(zone, ptr);
}
static void *
opal_memory_darwin_realloc(struct _malloc_zone_t *zone,
void *ptr, size_t size)
{
char *tmp;
opal_mem_hooks_release_hook(ptr, malloc_size(ptr), 1);
tmp = next_realloc(zone, ptr, size);
opal_mem_hooks_alloc_hook(tmp, malloc_size(tmp), 1);
return tmp;
}
/* only need to catch mmap / munmap for user code, and we should be at the
far right of the library stack, so this should work. Darwin 7 and
later include dlsym as part of libSystem, so no need to do anything
special for it. Not sure what would happen if you tried to
statically link your application (as in -Bstatic, not libmpi.a),
but since Apple doesn't support that, neither do we. */
void*
mmap(void *addr, size_t len, int prot, int flags, int fd, off_t offset)
{
static void* (*realmmap)(void *, size_t, int, int, int, off_t);
void *tmp;
if (NULL == realmmap) {
union {
void* (*mmap_fp)(void *, size_t, int, int, int, off_t);
void *mmap_p;
} tmp;
tmp.mmap_p = dlsym(RTLD_NEXT, "mmap");
realmmap = tmp.mmap_fp;
}
tmp = realmmap(addr, len, prot, flags, fd, offset);
opal_mem_hooks_alloc_hook(tmp, len, 0);
return tmp;
}
int
munmap(void* addr, size_t len)
{
static int (*realmunmap)(void*, size_t);
/* dispatch about the pending release */
opal_mem_hooks_release_hook(addr, len, 0);
if (NULL == realmunmap) {
union {
int (*munmap_fp)(void*, size_t);
void *munmap_p;
} tmp;
tmp.munmap_p = dlsym(RTLD_NEXT, "munmap");
realmunmap = tmp.munmap_fp;
}
return realmunmap(addr, len);
}