1
1

mca base: convert to opal_dl interface

Этот коммит содержится в:
Jeff Squyres 2015-02-18 10:24:10 -08:00
родитель 39364d315c
Коммит a9d86129c6
3 изменённых файлов: 90 добавлений и 147 удалений

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

@ -10,7 +10,7 @@
* University of Stuttgart. All rights reserved. * University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California. * Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* Copyright (c) 2008-2010 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2015 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved. * Copyright (c) 2008 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science * Copyright (c) 2015 Research Organization for Information Science
* and Technology (RIST). All rights reserved. * and Technology (RIST). All rights reserved.
@ -43,14 +43,6 @@
#include <netdb.h> #include <netdb.h>
#endif #endif
#if OPAL_WANT_LIBLTDL
#if OPAL_LIBLTDL_INTERNAL
#include "opal/libltdl/ltdl.h"
#else
#include "ltdl.h"
#endif
#endif
#include "opal/mca/installdirs/installdirs.h" #include "opal/mca/installdirs/installdirs.h"
#include "opal/util/opal_environ.h" #include "opal/util/opal_environ.h"
#include "opal/util/output.h" #include "opal/util/output.h"
@ -61,9 +53,10 @@
#include "opal/mca/base/base.h" #include "opal/mca/base/base.h"
#include "opal/mca/base/mca_base_component_repository.h" #include "opal/mca/base/mca_base_component_repository.h"
#include "opal/constants.h" #include "opal/constants.h"
#include "opal/mca/dl/base/base.h"
#if OPAL_WANT_LIBLTDL #if OPAL_HAVE_DL_SUPPORT
/* /*
* Private types; only necessary when we're dlopening components. * Private types; only necessary when we're dlopening components.
*/ */
@ -98,20 +91,17 @@ typedef struct dependency_item_t dependency_item_t;
static OBJ_CLASS_INSTANCE(dependency_item_t, opal_list_item_t, NULL, NULL); static OBJ_CLASS_INSTANCE(dependency_item_t, opal_list_item_t, NULL, NULL);
#if OPAL_HAVE_LTDL_ADVISE #endif /* OPAL_HAVE_DL_SUPPORT */
extern lt_dladvise opal_mca_dladvise;
#endif
#endif /* OPAL_WANT_LIBLTDL */
#if OPAL_WANT_LIBLTDL #if OPAL_HAVE_DL_SUPPORT
/* /*
* Private functions * Private functions
*/ */
static void find_dyn_components(const char *path, const char *type, static void find_dyn_components(const char *path, const char *type,
const char **names, bool include_mode, const char **names, bool include_mode,
opal_list_t *found_components); opal_list_t *found_components);
static int save_filename(const char *filename, lt_ptr data); static int save_filename(const char *filename, void *data);
static int open_component(component_file_item_t *target_file, static int open_component(component_file_item_t *target_file,
opal_list_t *found_components); opal_list_t *found_components);
static int check_opal_info(component_file_item_t *target_file, static int check_opal_info(component_file_item_t *target_file,
@ -131,7 +121,7 @@ static const char component_template[] = "mca_%s_";
static opal_list_t found_files; static opal_list_t found_files;
static char **found_filenames = NULL; static char **found_filenames = NULL;
static char *last_path_to_use = NULL; static char *last_path_to_use = NULL;
#endif /* OPAL_WANT_LIBLTDL */ #endif /* OPAL_HAVE_DL_SUPPORT */
static int component_find_check (const char *framework_name, char **requested_component_names, opal_list_t *components); static int component_find_check (const char *framework_name, char **requested_component_names, opal_list_t *components);
@ -196,7 +186,7 @@ int mca_base_component_find(const char *directory, const char *type,
} }
} }
#if OPAL_WANT_LIBLTDL #if OPAL_HAVE_DL_SUPPORT
/* Find any available dynamic components in the specified directory */ /* Find any available dynamic components in the specified directory */
if (open_dso_components && !mca_base_component_disable_dlopen) { if (open_dso_components && !mca_base_component_disable_dlopen) {
find_dyn_components(directory, type, find_dyn_components(directory, type,
@ -228,7 +218,7 @@ component_find_out:
int mca_base_component_find_finalize(void) int mca_base_component_find_finalize(void)
{ {
#if OPAL_WANT_LIBLTDL #if OPAL_HAVE_DL_SUPPORT
if (NULL != found_filenames) { if (NULL != found_filenames) {
opal_argv_free(found_filenames); opal_argv_free(found_filenames);
found_filenames = NULL; found_filenames = NULL;
@ -306,18 +296,15 @@ int mca_base_components_filter (const char *framework_name, opal_list_t *compone
return ret; return ret;
} }
#if OPAL_WANT_LIBLTDL #if OPAL_HAVE_DL_SUPPORT
/* /*
* Open up all directories in a given path and search for components of * Open up all directories in a given path and search for components of
* the specified type (and possibly of a given name). * the specified type (and possibly of a given name).
* *
* Note that we use our own path iteration functionality (vs. ltdl's * Note that we use our own path iteration functionality because we
* lt_dladdsearchdir() functionality) because we need to look at * need to look at companion .ompi_info files in the same directory as
* companion .ompi_info files in the same directory as the library to * the library to generate dependencies, etc.
* generate dependencies, etc. If we use the plain lt_dlopen()
* functionality, we would not get the directory name of the file
* finally opened in recursive dependency traversals.
*/ */
static void find_dyn_components(const char *path, const char *type_name, static void find_dyn_components(const char *path, const char *type_name,
const char **names, bool include_mode, const char **names, bool include_mode,
@ -377,18 +364,18 @@ static void find_dyn_components(const char *path, const char *type_name,
if ((0 == strcmp(dir, "USER_DEFAULT") || if ((0 == strcmp(dir, "USER_DEFAULT") ||
0 == strcmp(dir, "USR_DEFAULT")) 0 == strcmp(dir, "USR_DEFAULT"))
&& NULL != mca_base_user_default_path) { && NULL != mca_base_user_default_path) {
if (0 != lt_dlforeachfile(mca_base_user_default_path, if (0 != opal_dl_foreachfile(mca_base_user_default_path,
save_filename, NULL)) { save_filename, NULL)) {
break; break;
} }
} else if (0 == strcmp(dir, "SYS_DEFAULT") || } else if (0 == strcmp(dir, "SYS_DEFAULT") ||
0 == strcmp(dir, "SYSTEM_DEFAULT")) { 0 == strcmp(dir, "SYSTEM_DEFAULT")) {
if (0 != lt_dlforeachfile(mca_base_system_default_path, if (0 != opal_dl_foreachfile(mca_base_system_default_path,
save_filename, NULL)) { save_filename, NULL)) {
break; break;
} }
} else { } else {
if (0 != lt_dlforeachfile(dir, save_filename, NULL)) { if (0 != opal_dl_foreachfile(dir, save_filename, NULL)) {
break; break;
} }
} }
@ -475,7 +462,7 @@ static void find_dyn_components(const char *path, const char *type_name,
* Blindly save all filenames into an argv-style list. This function * Blindly save all filenames into an argv-style list. This function
* is the callback from lt_dlforeachfile(). * is the callback from lt_dlforeachfile().
*/ */
static int save_filename(const char *filename, lt_ptr data) static int save_filename(const char *filename, void *data)
{ {
opal_argv_append_nosize(&found_filenames, filename); opal_argv_append_nosize(&found_filenames, filename);
return 0; return 0;
@ -508,9 +495,9 @@ static int file_exists(const char *filename, const char *ext)
static int open_component(component_file_item_t *target_file, static int open_component(component_file_item_t *target_file,
opal_list_t *found_components) opal_list_t *found_components)
{ {
lt_dlhandle component_handle; opal_dl_handle_t *component_handle;
mca_base_component_t *component_struct; mca_base_component_t *component_struct;
char *struct_name, *err; char *struct_name;
opal_list_t dependencies; opal_list_t dependencies;
opal_list_item_t *cur; opal_list_item_t *cur;
mca_base_component_list_item_t *mitem; mca_base_component_list_item_t *mitem;
@ -562,18 +549,14 @@ static int open_component(component_file_item_t *target_file,
/* Now try to load the component */ /* Now try to load the component */
#if OPAL_HAVE_LTDL_ADVISE char *err_msg;
component_handle = lt_dlopenadvise(target_file->filename, opal_mca_dladvise); if (OPAL_SUCCESS !=
#else opal_dl_open(target_file->filename, true, false, &component_handle,
component_handle = lt_dlopenext(target_file->filename); &err_msg)) {
#endif if (NULL != err_msg) {
if (NULL == component_handle) { err_msg = strdup(err_msg);
/* Apparently lt_dlerror() sometimes returns NULL! */
const char *str = lt_dlerror();
if (NULL != str) {
err = strdup(str);
} else { } else {
err = strdup("lt_dlerror() returned NULL!"); err_msg = strdup("opal_dl_open() error message was NULL!");
} }
/* Because libltdl erroneously says "file not found" for any /* Because libltdl erroneously says "file not found" for any
type of error -- which is especially misleading when the file type of error -- which is especially misleading when the file
@ -581,17 +564,17 @@ static int open_component(component_file_item_t *target_file,
(e.g., missing symbol) -- do some simple huersitics and if (e.g., missing symbol) -- do some simple huersitics and if
the file [probably] does exist, print a slightly better error the file [probably] does exist, print a slightly better error
message. */ message. */
if (0 == strcmp("file not found", err) && if (0 == strcmp("file not found", err_msg) &&
(file_exists(target_file->filename, "lo") || (file_exists(target_file->filename, "lo") ||
file_exists(target_file->filename, "so") || file_exists(target_file->filename, "so") ||
file_exists(target_file->filename, "dylib") || file_exists(target_file->filename, "dylib") ||
file_exists(target_file->filename, "dll"))) { file_exists(target_file->filename, "dll"))) {
free(err); free(err_msg);
err = strdup("perhaps a missing symbol, or compiled for a different version of Open MPI?"); err_msg = strdup("perhaps a missing symbol, or compiled for a different version of Open MPI?");
} }
opal_output_verbose(vl, 0, "mca: base: component_find: unable to open %s: %s (ignored)", opal_output_verbose(vl, 0, "mca: base: component_find: unable to open %s: %s (ignored)",
target_file->filename, err); target_file->filename, err_msg);
free(err); free(err_msg);
target_file->status = FAILED_TO_LOAD; target_file->status = FAILED_TO_LOAD;
free_dependency_list(&dependencies); free_dependency_list(&dependencies);
return OPAL_ERR_BAD_PARAM; return OPAL_ERR_BAD_PARAM;
@ -603,7 +586,7 @@ static int open_component(component_file_item_t *target_file,
len = strlen(target_file->type) + strlen(target_file->name) + 32; len = strlen(target_file->type) + strlen(target_file->name) + 32;
struct_name = (char*)malloc(len); struct_name = (char*)malloc(len);
if (NULL == struct_name) { if (NULL == struct_name) {
lt_dlclose(component_handle); opal_dl_close(component_handle);
target_file->status = FAILED_TO_LOAD; target_file->status = FAILED_TO_LOAD;
free_dependency_list(&dependencies); free_dependency_list(&dependencies);
return OPAL_ERR_OUT_OF_RESOURCE; return OPAL_ERR_OUT_OF_RESOURCE;
@ -614,25 +597,24 @@ static int open_component(component_file_item_t *target_file,
mitem = OBJ_NEW(mca_base_component_list_item_t); mitem = OBJ_NEW(mca_base_component_list_item_t);
if (NULL == mitem) { if (NULL == mitem) {
free(struct_name); free(struct_name);
lt_dlclose(component_handle); opal_dl_close(component_handle);
target_file->status = FAILED_TO_LOAD; target_file->status = FAILED_TO_LOAD;
free_dependency_list(&dependencies); free_dependency_list(&dependencies);
return OPAL_ERR_OUT_OF_RESOURCE; return OPAL_ERR_OUT_OF_RESOURCE;
} }
component_struct = (mca_base_component_t*)lt_dlsym(component_handle, struct_name); if (OPAL_SUCCESS != opal_dl_lookup(component_handle, struct_name,
if (NULL == component_struct) { (void**) &component_struct, &err_msg) ||
/* Apparently lt_dlerror() sometimes returns NULL! */ NULL == component_struct) {
const char *str = lt_dlerror(); if (NULL == err_msg) {
if (NULL == str) { err_msg = "opal_dl_loookup() error message was NULL!";
str = "lt_dlerror() returned NULL!";
} }
opal_output_verbose(vl, 0, "mca: base: component_find: \"%s\" does not appear to be a valid " opal_output_verbose(vl, 0, "mca: base: component_find: \"%s\" does not appear to be a valid "
"%s MCA dynamic component (ignored): %s", "%s MCA dynamic component (ignored): %s",
target_file->basename, target_file->type, str); target_file->basename, target_file->type, err_msg);
free(mitem); free(mitem);
free(struct_name); free(struct_name);
lt_dlclose(component_handle); opal_dl_close(component_handle);
target_file->status = FAILED_TO_LOAD; target_file->status = FAILED_TO_LOAD;
free_dependency_list(&dependencies); free_dependency_list(&dependencies);
return OPAL_ERR_BAD_PARAM; return OPAL_ERR_BAD_PARAM;
@ -652,7 +634,7 @@ static int open_component(component_file_item_t *target_file,
MCA_BASE_VERSION_RELEASE); MCA_BASE_VERSION_RELEASE);
free(mitem); free(mitem);
free(struct_name); free(struct_name);
lt_dlclose(component_handle); opal_dl_close(component_handle);
target_file->status = FAILED_TO_LOAD; target_file->status = FAILED_TO_LOAD;
free_dependency_list(&dependencies); free_dependency_list(&dependencies);
return OPAL_ERR_BAD_PARAM; return OPAL_ERR_BAD_PARAM;
@ -668,7 +650,7 @@ static int open_component(component_file_item_t *target_file,
component_struct->mca_component_name); component_struct->mca_component_name);
free(mitem); free(mitem);
free(struct_name); free(struct_name);
lt_dlclose(component_handle); opal_dl_close(component_handle);
target_file->status = FAILED_TO_LOAD; target_file->status = FAILED_TO_LOAD;
free_dependency_list(&dependencies); free_dependency_list(&dependencies);
return OPAL_ERR_BAD_PARAM; return OPAL_ERR_BAD_PARAM;
@ -945,7 +927,7 @@ static void free_dependency_list(opal_list_t *dependencies)
OBJ_DESTRUCT(dependencies); OBJ_DESTRUCT(dependencies);
} }
#endif /* OPAL_WANT_LIBLTDL */ #endif /* OPAL_HAVE_DL_SUPPORT */
static bool use_component(const bool include_mode, static bool use_component(const bool include_mode,
const char **requested_component_names, const char **requested_component_names,

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

@ -9,7 +9,7 @@
* University of Stuttgart. All rights reserved. * University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California. * Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* Copyright (c) 2008-2010 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2008-2015 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
* Additional copyrights may follow * Additional copyrights may follow
@ -26,21 +26,14 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#if OPAL_WANT_LIBLTDL
#if OPAL_LIBLTDL_INTERNAL
#include "opal/libltdl/ltdl.h"
#else
#include "ltdl.h"
#endif
#endif
#include "opal/class/opal_list.h" #include "opal/class/opal_list.h"
#include "opal/mca/mca.h" #include "opal/mca/mca.h"
#include "opal/mca/base/base.h" #include "opal/mca/base/base.h"
#include "opal/mca/base/mca_base_component_repository.h" #include "opal/mca/base/mca_base_component_repository.h"
#include "opal/mca/dl/base/base.h"
#include "opal/constants.h" #include "opal/constants.h"
#if OPAL_WANT_LIBLTDL #if OPAL_HAVE_DL_SUPPORT
/* /*
* Private types * Private types
@ -49,7 +42,7 @@ struct repository_item_t {
opal_list_item_t super; opal_list_item_t super;
char ri_type[MCA_BASE_MAX_TYPE_NAME_LEN + 1]; char ri_type[MCA_BASE_MAX_TYPE_NAME_LEN + 1];
lt_dlhandle ri_dlhandle; opal_dl_handle_t *ri_dlhandle;
const mca_base_component_t *ri_component_struct; const mca_base_component_t *ri_component_struct;
opal_list_t ri_dependencies; opal_list_t ri_dependencies;
}; };
@ -70,7 +63,7 @@ static void di_destructor(opal_object_t *obj);
static OBJ_CLASS_INSTANCE(dependency_item_t, opal_list_item_t, static OBJ_CLASS_INSTANCE(dependency_item_t, opal_list_item_t,
di_constructor, di_destructor); di_constructor, di_destructor);
#endif /* OPAL_WANT_LIBLTDL */ #endif /* OPAL_HAVE_DL_SUPPORT */
/* /*
@ -79,7 +72,7 @@ static OBJ_CLASS_INSTANCE(dependency_item_t, opal_list_item_t,
static bool initialized = false; static bool initialized = false;
#if OPAL_WANT_LIBLTDL #if OPAL_HAVE_DL_SUPPORT
static opal_list_t repository; static opal_list_t repository;
@ -90,11 +83,7 @@ static opal_list_t repository;
static repository_item_t *find_component(const char *type, const char *name); static repository_item_t *find_component(const char *type, const char *name);
static int link_items(repository_item_t *src, repository_item_t *depend); static int link_items(repository_item_t *src, repository_item_t *depend);
#if OPAL_HAVE_LTDL_ADVISE #endif /* OPAL_HAVE_DL_SUPPORT */
lt_dladvise opal_mca_dladvise;
#endif
#endif /* OPAL_WANT_LIBLTDL */
/* /*
@ -105,29 +94,30 @@ int mca_base_component_repository_init(void)
/* Setup internal structures */ /* Setup internal structures */
if (!initialized) { if (!initialized) {
#if OPAL_WANT_LIBLTDL #if OPAL_HAVE_DL_SUPPORT
/* Initialize libltdl */
if (lt_dlinit() != 0) { /* Initialize the dl framework */
return OPAL_ERR_OUT_OF_RESOURCE; int ret = mca_base_framework_open(&opal_dl_base_framework, 0);
if (OPAL_SUCCESS != ret) {
opal_output(0, "%s %d:%s failed -- process will likely abort (open the dl framework returned %d instead of OPAL_SUCCESS)\n",
__FILE__, __LINE__, __func__, ret);
return ret;
} }
opal_dl_base_select();
#if OPAL_HAVE_LTDL_ADVISE /* Bump the refcount to indicate that this framework is "special"
if (lt_dladvise_init(&opal_mca_dladvise)) { -- it can't be finalized until all other frameworks have been
return OPAL_ERR_OUT_OF_RESOURCE; finalized. E.g., in opal/runtime/opal_info_support.c, there's
} a loop calling mca_base_framework_close() on all OPAL
frameworks. But that function simply decrements each
if (lt_dladvise_ext(&opal_mca_dladvise)) { framework's refcount, and if it's zero, closes it. This
return OPAL_ERROR; additional increment ensures that the "dl" framework is not
} closed as part of that loop. */
++opal_dl_base_framework.framework_refcnt;
if (lt_dladvise_global(&opal_mca_dladvise)) {
return OPAL_ERROR;
}
#endif
OBJ_CONSTRUCT(&repository, opal_list_t); OBJ_CONSTRUCT(&repository, opal_list_t);
#endif #endif
initialized = true; initialized = true;
} }
@ -143,10 +133,10 @@ int mca_base_component_repository_init(void)
* saved. * saved.
*/ */
int mca_base_component_repository_retain(char *type, int mca_base_component_repository_retain(char *type,
lt_dlhandle component_handle, opal_dl_handle_t *component_handle,
const mca_base_component_t *component_struct) const mca_base_component_t *component_struct)
{ {
#if OPAL_WANT_LIBLTDL #if OPAL_HAVE_DL_SUPPORT
repository_item_t *ri; repository_item_t *ri;
/* Allocate a new repository item */ /* Allocate a new repository item */
@ -182,7 +172,7 @@ int mca_base_component_repository_retain(char *type,
int mca_base_component_repository_retain_component(const char *type, int mca_base_component_repository_retain_component(const char *type,
const char *name) const char *name)
{ {
#if OPAL_WANT_LIBLTDL #if OPAL_HAVE_DL_SUPPORT
repository_item_t *ri = find_component(type, name); repository_item_t *ri = find_component(type, name);
if (NULL != ri) { if (NULL != ri) {
OBJ_RETAIN(ri); OBJ_RETAIN(ri);
@ -203,7 +193,7 @@ int mca_base_component_repository_link(const char *src_type,
const char *depend_type, const char *depend_type,
const char *depend_name) const char *depend_name)
{ {
#if OPAL_WANT_LIBLTDL #if OPAL_HAVE_DL_SUPPORT
repository_item_t *src, *depend; repository_item_t *src, *depend;
/* Look up the two components */ /* Look up the two components */
@ -232,7 +222,7 @@ int mca_base_component_repository_link(const char *src_type,
*/ */
void mca_base_component_repository_release(const mca_base_component_t *component) void mca_base_component_repository_release(const mca_base_component_t *component)
{ {
#if OPAL_WANT_LIBLTDL #if OPAL_HAVE_DL_SUPPORT
if (initialized) { if (initialized) {
repository_item_t *ri = find_component(component->mca_type_name, repository_item_t *ri = find_component(component->mca_type_name,
component->mca_component_name); component->mca_component_name);
@ -249,12 +239,12 @@ void mca_base_component_repository_release(const mca_base_component_t *component
*/ */
void mca_base_component_repository_finalize(void) void mca_base_component_repository_finalize(void)
{ {
#if OPAL_WANT_LIBLTDL #if OPAL_HAVE_DL_SUPPORT
repository_item_t *ri, *next; repository_item_t *ri, *next;
#endif #endif
if (initialized) { if (initialized) {
#if OPAL_WANT_LIBLTDL #if OPAL_HAVE_DL_SUPPORT
/* Have to be slightly careful about this because of dependencies, /* Have to be slightly careful about this because of dependencies,
particularly on OS's where it matters (i.e., closing a particularly on OS's where it matters (i.e., closing a
@ -275,22 +265,17 @@ void mca_base_component_repository_finalize(void)
} }
} while (opal_list_get_size(&repository) > 0); } while (opal_list_get_size(&repository) > 0);
#if OPAL_HAVE_LTDL_ADVISE /* Close the dl framework (see comment about refcnt in
if (lt_dladvise_destroy(&opal_mca_dladvise)) { mca_base_component_repository_init()) */
return; --opal_dl_base_framework.framework_refcnt;
} (void) mca_base_framework_close(&opal_dl_base_framework);
#endif
/* Close down libltdl */
lt_dlexit();
#endif #endif
initialized = false; initialized = false;
} }
} }
#if OPAL_WANT_LIBLTDL #if OPAL_HAVE_DL_SUPPORT
static repository_item_t *find_component(const char *type, const char *name) static repository_item_t *find_component(const char *type, const char *name)
{ {
@ -379,7 +364,7 @@ static void ri_destructor(opal_object_t *obj)
} }
/* Close the component (and potentially unload it from memory */ /* Close the component (and potentially unload it from memory */
lt_dlclose(ri->ri_dlhandle); opal_dl_close(ri->ri_dlhandle);
/* It should be obvious, but I'll state it anyway because it bit me /* It should be obvious, but I'll state it anyway because it bit me
during debugging: after the dlclose(), the mca_base_component_t during debugging: after the dlclose(), the mca_base_component_t
@ -419,4 +404,4 @@ static void di_destructor(opal_object_t *obj)
OBJ_RELEASE(di->di_repository_entry); OBJ_RELEASE(di->di_repository_entry);
} }
#endif /* OPAL_WANT_LIBLTDL */ #endif /* OPAL_HAVE_DL_SUPPORT */

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

@ -9,6 +9,7 @@
* University of Stuttgart. All rights reserved. * University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California. * Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* Copyright (c) 2015 Cisco Systems, Inc. All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
* Additional copyrights may follow * Additional copyrights may follow
@ -21,6 +22,9 @@
#include "opal_config.h" #include "opal_config.h"
#include "opal/mca/dl/dl.h"
#include "opal/mca/dl/base/base.h"
BEGIN_C_DECLS BEGIN_C_DECLS
OPAL_DECLSPEC int mca_base_component_repository_init(void); OPAL_DECLSPEC int mca_base_component_repository_init(void);
@ -33,37 +37,9 @@ BEGIN_C_DECLS
* the functions exported from one header file rather than to separate * the functions exported from one header file rather than to separate
* retain_component() and retain() into two separate header files * retain_component() and retain() into two separate header files
* (i.e., have a separate header file just for retain()). * (i.e., have a separate header file just for retain()).
*
* Note that internal to opal/mca/base, <ltdl.h> will *always* be
* included before this file, and <ltdl.h> is not included anywhere
* else in the OMPI tree. So checking for the LTDL_H preprocessor
* macro is a good indicator as to whether this file is being included
* from an opal/mca/base source file or not. If we are, then we need
* already have a real definition of lt_dlhandle. If we are being
* included from elsewhere, then <ltdl.h> will not previously have
* been included, LTDL_H will not be defined, and we need a fake
* definition of lt_dlhandle (or we'll get compile errors). So just
* typedef it to (void*).
*
* One more case that this handles is the --disable-dlopen case. In
* that case, even in opal/mca/base, we *won't* be including <ltdl.h>.
* Hence, LTDL_H won't be defined, so we'll end up typedefing
* lt_dlhandle to (void *). "But why does that matter?" you ask, "If
* we configure with --disable-dlopen, then lt_dlhandle shouldn't be
* used anywhere." Incorrect, Grasshopper. A small number of places
* (like the retain() function) are still prototyped, but have 99% of
* their innards #if'ed out -- i.e., they just return
* OPAL_ERR_NOT_SUPPORTED. Why was it coded up this way? I'm not
* entirely sure -- there may be a reason (and that reason may just be
* conservative coding), but I'm not really too inspired to look into
* it any further at this point. :-)
*/ */
#if !defined(LTDL_H)
typedef void *lt_dlhandle;
#endif
OPAL_DECLSPEC int mca_base_component_repository_retain(char *type, OPAL_DECLSPEC int mca_base_component_repository_retain(char *type,
lt_dlhandle component_handle, opal_dl_handle_t *component_handle,
const mca_base_component_t *component_struct); const mca_base_component_t *component_struct);
OPAL_DECLSPEC int mca_base_component_repository_retain_component(const char *type, OPAL_DECLSPEC int mca_base_component_repository_retain_component(const char *type,