2004-01-18 02:07:40 +03:00
|
|
|
/*
|
2004-11-22 04:38:40 +03:00
|
|
|
* Copyright (c) 2004-2005 The Trustees of Indiana University.
|
|
|
|
* All rights reserved.
|
|
|
|
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
|
|
|
|
* All rights reserved.
|
|
|
|
* $COPYRIGHT$
|
|
|
|
*
|
|
|
|
* Additional copyrights may follow
|
|
|
|
*
|
2004-01-18 02:07:40 +03:00
|
|
|
* $HEADER$
|
|
|
|
*/
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "ompi_config.h"
|
2004-01-18 02:07:40 +03:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
2004-03-19 00:35:28 +03:00
|
|
|
#include "include/constants.h"
|
2004-06-07 19:33:53 +04:00
|
|
|
#include "class/ompi_value_array.h"
|
2004-06-29 04:02:25 +04:00
|
|
|
#include "class/ompi_hash_table.h"
|
2004-09-16 20:17:36 +04:00
|
|
|
#if 0
|
|
|
|
/* JMS commented out for now -- see lookup_keyvals() below for an
|
|
|
|
explanation */
|
2004-06-29 04:02:25 +04:00
|
|
|
#include "attribute/attribute.h"
|
2004-09-16 20:17:36 +04:00
|
|
|
#endif
|
2004-08-31 13:49:56 +04:00
|
|
|
#include "util/printf.h"
|
|
|
|
#include "util/argv.h"
|
2004-01-18 02:07:40 +03:00
|
|
|
#include "mca/mca.h"
|
2004-03-17 21:45:16 +03:00
|
|
|
#include "mca/base/mca_base_param.h"
|
2004-07-14 00:24:26 +04:00
|
|
|
#include "mca/base/mca_base_param_internal.h"
|
2004-01-18 02:07:40 +03:00
|
|
|
|
|
|
|
|
2004-01-30 01:10:33 +03:00
|
|
|
/*
|
|
|
|
* Public variables
|
|
|
|
*
|
|
|
|
* This variable is public, but not advertised in mca_base_param.h.
|
2004-07-14 00:24:26 +04:00
|
|
|
* It's only public so that ompi_info can see it. The relevant component
|
2004-06-07 19:33:53 +04:00
|
|
|
* in ompi_info will provide an extern to see this variable.
|
2004-01-30 01:10:33 +03:00
|
|
|
*/
|
2004-06-07 19:33:53 +04:00
|
|
|
ompi_value_array_t mca_base_params;
|
2004-08-31 13:49:56 +04:00
|
|
|
ompi_list_t mca_base_param_file_values;
|
2004-01-18 02:07:40 +03:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* local variables
|
|
|
|
*/
|
2004-08-31 13:49:56 +04:00
|
|
|
static const char *mca_prefix = "OMPI_MCA_";
|
|
|
|
static char *home = NULL;
|
2004-01-18 02:07:40 +03:00
|
|
|
static bool initialized = false;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* local functions
|
|
|
|
*/
|
2004-08-31 13:49:56 +04:00
|
|
|
static int read_files(char *file_list);
|
2004-07-14 00:24:26 +04:00
|
|
|
static int param_register(const char *type_name, const char *component_name,
|
2004-01-21 02:23:47 +03:00
|
|
|
const char *param_name,
|
2004-01-18 02:07:40 +03:00
|
|
|
const char *mca_param_name,
|
|
|
|
mca_base_param_type_t type,
|
2004-08-31 13:49:56 +04:00
|
|
|
mca_base_param_storage_t *default_value,
|
|
|
|
mca_base_param_storage_t *file_value,
|
|
|
|
mca_base_param_storage_t *override_value);
|
2004-10-20 03:58:12 +04:00
|
|
|
static bool param_lookup(size_t index, mca_base_param_storage_t *storage,
|
2004-06-29 04:02:25 +04:00
|
|
|
ompi_hash_table_t *attrs);
|
2004-08-31 13:49:56 +04:00
|
|
|
static bool lookup_keyvals(mca_base_param_t *param,
|
|
|
|
mca_base_param_storage_t *storage,
|
|
|
|
ompi_hash_table_t *attrs);
|
|
|
|
static bool lookup_env(mca_base_param_t *param,
|
|
|
|
mca_base_param_storage_t *storage);
|
|
|
|
static bool lookup_file(mca_base_param_t *param,
|
|
|
|
mca_base_param_storage_t *storage);
|
|
|
|
static bool lookup_default(mca_base_param_t *param,
|
|
|
|
mca_base_param_storage_t *storage);
|
|
|
|
static bool set(mca_base_param_type_t type,
|
|
|
|
mca_base_param_storage_t *dest, mca_base_param_storage_t *src);
|
2004-07-14 00:24:26 +04:00
|
|
|
static void param_constructor(mca_base_param_t *p);
|
|
|
|
static void param_destructor(mca_base_param_t *p);
|
2004-08-31 13:49:56 +04:00
|
|
|
static void fv_constructor(mca_base_param_file_value_t *p);
|
|
|
|
static void fv_destructor(mca_base_param_file_value_t *p);
|
2004-07-14 00:24:26 +04:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make the class instance for mca_base_param_t
|
|
|
|
*/
|
|
|
|
OBJ_CLASS_INSTANCE(mca_base_param_t, ompi_object_t,
|
|
|
|
param_constructor, param_destructor);
|
2004-08-31 13:49:56 +04:00
|
|
|
OBJ_CLASS_INSTANCE(mca_base_param_file_value_t, ompi_list_item_t,
|
|
|
|
fv_constructor, fv_destructor);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set it up
|
|
|
|
*/
|
|
|
|
int mca_base_param_init(void)
|
|
|
|
{
|
|
|
|
int id;
|
|
|
|
char *files;
|
|
|
|
|
|
|
|
if (!initialized) {
|
|
|
|
|
|
|
|
/* Init the value array for the param storage */
|
|
|
|
|
|
|
|
OBJ_CONSTRUCT(&mca_base_params, ompi_value_array_t);
|
|
|
|
ompi_value_array_init(&mca_base_params, sizeof(mca_base_param_t));
|
|
|
|
|
|
|
|
/* Init the file param value list */
|
|
|
|
|
|
|
|
OBJ_CONSTRUCT(&mca_base_param_file_values, ompi_list_t);
|
|
|
|
|
|
|
|
/* Set this before we register the parameter, below */
|
|
|
|
|
|
|
|
initialized = true;
|
|
|
|
|
|
|
|
/* We may need this later */
|
|
|
|
|
|
|
|
home = getenv("HOME");
|
|
|
|
|
|
|
|
/* Initialize a parameter that says where MCA param files can
|
|
|
|
be found */
|
|
|
|
|
|
|
|
asprintf(&files,
|
|
|
|
"~/.openmpi/mca-params.conf:%s/openmpi-mca-params.conf",
|
|
|
|
OMPI_SYSCONFDIR);
|
|
|
|
id = mca_base_param_register_string("base", NULL, "param_files",
|
|
|
|
"param_files", files);
|
|
|
|
free(files);
|
|
|
|
|
|
|
|
/* Read in MCA parameters from files */
|
|
|
|
|
|
|
|
mca_base_param_lookup_string(id, &files);
|
|
|
|
read_files(files);
|
|
|
|
free(files);
|
|
|
|
}
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
2004-01-18 02:07:40 +03:00
|
|
|
|
|
|
|
|
2004-04-22 20:59:56 +04:00
|
|
|
/*
|
|
|
|
* Register an integer MCA parameter
|
2004-01-18 02:07:40 +03:00
|
|
|
*/
|
2004-06-29 04:02:25 +04:00
|
|
|
int mca_base_param_register_int(const char *type_name,
|
2004-07-14 00:24:26 +04:00
|
|
|
const char *component_name,
|
2004-01-18 02:07:40 +03:00
|
|
|
const char *param_name,
|
|
|
|
const char *mca_param_name,
|
|
|
|
int default_value)
|
|
|
|
{
|
|
|
|
mca_base_param_storage_t storage;
|
|
|
|
|
|
|
|
storage.intval = default_value;
|
2004-07-14 00:24:26 +04:00
|
|
|
return param_register(type_name, component_name, param_name, mca_param_name,
|
2004-08-31 13:49:56 +04:00
|
|
|
MCA_BASE_PARAM_TYPE_INT, &storage, NULL, NULL);
|
2004-01-18 02:07:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-04-22 20:59:56 +04:00
|
|
|
/*
|
2004-01-18 02:07:40 +03:00
|
|
|
* Register a string MCA parameter.
|
|
|
|
*/
|
|
|
|
int mca_base_param_register_string(const char *type_name,
|
2004-07-14 00:24:26 +04:00
|
|
|
const char *component_name,
|
2004-01-18 02:07:40 +03:00
|
|
|
const char *param_name,
|
|
|
|
const char *mca_param_name,
|
|
|
|
const char *default_value)
|
|
|
|
{
|
|
|
|
mca_base_param_storage_t storage;
|
2004-06-29 04:02:25 +04:00
|
|
|
if (NULL != default_value) {
|
2004-01-22 03:37:58 +03:00
|
|
|
storage.stringval = (char *) default_value;
|
2004-06-29 04:02:25 +04:00
|
|
|
} else {
|
2004-01-21 02:23:47 +03:00
|
|
|
storage.stringval = NULL;
|
2004-06-29 04:02:25 +04:00
|
|
|
}
|
2004-07-14 00:24:26 +04:00
|
|
|
return param_register(type_name, component_name, param_name, mca_param_name,
|
2004-08-31 13:49:56 +04:00
|
|
|
MCA_BASE_PARAM_TYPE_STRING, &storage, NULL, NULL);
|
2004-01-18 02:07:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-29 04:02:25 +04:00
|
|
|
/*
|
|
|
|
* Associate a keyval with a parameter index
|
|
|
|
*/
|
2004-10-20 03:58:12 +04:00
|
|
|
int mca_base_param_kv_associate(size_t index, int keyval)
|
2004-06-29 04:02:25 +04:00
|
|
|
{
|
|
|
|
size_t len;
|
|
|
|
mca_base_param_t *array;
|
|
|
|
|
|
|
|
if (!initialized) {
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
len = ompi_value_array_get_size(&mca_base_params);
|
|
|
|
if (0 > index || index > len) {
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We have a valid entry (remember that we never delete MCA
|
|
|
|
parameters, so if the index is >0 and <len, it must be good), so
|
|
|
|
save the keyval */
|
|
|
|
|
|
|
|
array = OMPI_VALUE_ARRAY_GET_BASE(&mca_base_params, mca_base_param_t);
|
|
|
|
array[index].mbp_keyval = keyval;
|
|
|
|
|
|
|
|
/* All done */
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
|
2004-04-22 20:59:56 +04:00
|
|
|
/*
|
2004-01-18 02:07:40 +03:00
|
|
|
* Look up an integer MCA parameter.
|
|
|
|
*/
|
|
|
|
int mca_base_param_lookup_int(int index, int *value)
|
|
|
|
{
|
|
|
|
mca_base_param_storage_t storage;
|
|
|
|
|
2004-06-29 04:02:25 +04:00
|
|
|
if (param_lookup(index, &storage, NULL)) {
|
|
|
|
*value = storage.intval;
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look up an integer MCA parameter, including in attributes
|
|
|
|
*/
|
|
|
|
int mca_base_param_kv_lookup_int(int index, ompi_hash_table_t *attrs,
|
|
|
|
int *value)
|
|
|
|
{
|
|
|
|
mca_base_param_storage_t storage;
|
|
|
|
|
|
|
|
if (param_lookup(index, &storage, attrs)) {
|
2004-01-18 02:07:40 +03:00
|
|
|
*value = storage.intval;
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_SUCCESS;
|
2004-01-18 02:07:40 +03:00
|
|
|
}
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERROR;
|
2004-01-18 02:07:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
/*
|
|
|
|
* Set an integer parameter
|
|
|
|
*/
|
|
|
|
#if 0
|
|
|
|
#error JMS: Need to figure out what to do here
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2004-04-22 20:59:56 +04:00
|
|
|
/*
|
2004-01-18 02:07:40 +03:00
|
|
|
* Look up a string MCA parameter.
|
|
|
|
*/
|
|
|
|
int mca_base_param_lookup_string(int index, char **value)
|
|
|
|
{
|
|
|
|
mca_base_param_storage_t storage;
|
|
|
|
|
2004-06-29 04:02:25 +04:00
|
|
|
if (param_lookup(index, &storage, NULL)) {
|
|
|
|
*value = storage.stringval;
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Look up a string MCA parameter, including in attributes.
|
|
|
|
*/
|
|
|
|
int mca_base_param_kv_lookup_string(int index, ompi_hash_table_t *attrs,
|
|
|
|
char **value)
|
|
|
|
{
|
|
|
|
mca_base_param_storage_t storage;
|
|
|
|
|
|
|
|
if (param_lookup(index, &storage, attrs)) {
|
2004-01-18 02:07:40 +03:00
|
|
|
*value = storage.stringval;
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_SUCCESS;
|
2004-01-18 02:07:40 +03:00
|
|
|
}
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERROR;
|
2004-01-18 02:07:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
/*
|
|
|
|
* Set an string parameter
|
|
|
|
*/
|
|
|
|
#if 0
|
|
|
|
#error JMS: Need to figure out what to do here
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2004-04-22 20:59:56 +04:00
|
|
|
/*
|
2004-01-18 02:07:40 +03:00
|
|
|
* Find the index for an MCA parameter based on its names.
|
|
|
|
*/
|
2004-07-14 00:24:26 +04:00
|
|
|
int mca_base_param_find(const char *type_name, const char *component_name,
|
2004-01-18 02:07:40 +03:00
|
|
|
const char *param_name)
|
|
|
|
{
|
|
|
|
size_t i, size;
|
2004-02-11 01:12:47 +03:00
|
|
|
mca_base_param_t *array;
|
2004-01-18 02:07:40 +03:00
|
|
|
|
|
|
|
/* Check for bozo cases */
|
|
|
|
|
2004-06-29 04:02:25 +04:00
|
|
|
if (!initialized) {
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERROR;
|
2004-06-29 04:02:25 +04:00
|
|
|
}
|
2004-07-14 00:24:26 +04:00
|
|
|
if (NULL == type_name) {
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERROR;
|
2004-06-29 04:02:25 +04:00
|
|
|
}
|
2004-01-18 02:07:40 +03:00
|
|
|
|
|
|
|
/* Loop through looking for a parameter of a given
|
2004-07-14 00:24:26 +04:00
|
|
|
type/component/param */
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
size = ompi_value_array_get_size(&mca_base_params);
|
|
|
|
array = OMPI_VALUE_ARRAY_GET_BASE(&mca_base_params, mca_base_param_t);
|
2004-01-18 02:07:40 +03:00
|
|
|
for (i = 0; i < size; ++i) {
|
2004-02-11 01:12:47 +03:00
|
|
|
if (0 == strcmp(type_name, array[i].mbp_type_name) &&
|
2004-07-14 00:24:26 +04:00
|
|
|
((NULL == component_name && NULL == array[i].mbp_component_name) ||
|
|
|
|
(NULL != component_name && NULL != array[i].mbp_component_name &&
|
|
|
|
0 == strcmp(component_name, array[i].mbp_component_name))) &&
|
|
|
|
((NULL == param_name && NULL == array[i].mbp_param_name) ||
|
|
|
|
(NULL != param_name && NULL != array[i].mbp_param_name &&
|
|
|
|
0 == strcmp(param_name, array[i].mbp_param_name)))) {
|
2004-01-18 02:07:40 +03:00
|
|
|
return i;
|
2004-06-29 04:02:25 +04:00
|
|
|
}
|
2004-01-18 02:07:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Didn't find it */
|
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERROR;
|
2004-01-18 02:07:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-04-22 20:59:56 +04:00
|
|
|
/*
|
2004-01-18 02:07:40 +03:00
|
|
|
* Shut down the MCA parameter system (normally only invoked by the
|
|
|
|
* MCA framework itself).
|
|
|
|
*/
|
|
|
|
int mca_base_param_finalize(void)
|
|
|
|
{
|
2004-08-31 13:49:56 +04:00
|
|
|
ompi_list_item_t *item;
|
|
|
|
mca_base_param_t *array;
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
if (initialized) {
|
2004-07-14 00:24:26 +04:00
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
/* This is slow, but effective :-) */
|
2004-07-14 00:24:26 +04:00
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
array = OMPI_VALUE_ARRAY_GET_BASE(&mca_base_params, mca_base_param_t);
|
|
|
|
while (ompi_value_array_get_size(&mca_base_params) > 0) {
|
|
|
|
OBJ_DESTRUCT(&array[0]);
|
|
|
|
ompi_value_array_remove_item(&mca_base_params, 0);
|
|
|
|
}
|
|
|
|
OBJ_DESTRUCT(&mca_base_params);
|
|
|
|
|
|
|
|
for (item = ompi_list_remove_first(&mca_base_param_file_values);
|
|
|
|
NULL != item;
|
|
|
|
item = ompi_list_remove_first(&mca_base_param_file_values)) {
|
|
|
|
OBJ_RELEASE(item);
|
|
|
|
}
|
|
|
|
OBJ_DESTRUCT(&mca_base_param_file_values);
|
|
|
|
initialized = false;
|
2004-01-21 07:13:53 +03:00
|
|
|
}
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
/* All done */
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
2004-01-18 02:07:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
static int read_files(char *file_list)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
char **files;
|
|
|
|
|
|
|
|
/* Iterate through all the files passed in -- read them in reverse
|
|
|
|
order so that we preserve unix/shell path-like semantics (i.e.,
|
|
|
|
the entries farthest to the left get precedence) */
|
|
|
|
|
|
|
|
files = ompi_argv_split(file_list, ':');
|
|
|
|
for (i = ompi_argv_count(files) - 1; i >= 0; --i) {
|
|
|
|
mca_base_parse_paramfile(files[i]);
|
|
|
|
}
|
|
|
|
ompi_argv_free(files);
|
|
|
|
|
|
|
|
return OMPI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-14 00:24:26 +04:00
|
|
|
static int param_register(const char *type_name, const char *component_name,
|
2004-01-18 02:07:40 +03:00
|
|
|
const char *param_name, const char *mca_param_name,
|
|
|
|
mca_base_param_type_t type,
|
2004-08-31 13:49:56 +04:00
|
|
|
mca_base_param_storage_t *default_value,
|
|
|
|
mca_base_param_storage_t *file_value,
|
|
|
|
mca_base_param_storage_t *override_value)
|
2004-01-18 02:07:40 +03:00
|
|
|
{
|
2004-07-14 00:24:26 +04:00
|
|
|
int ret;
|
2004-01-18 02:07:40 +03:00
|
|
|
size_t i, len;
|
2004-02-11 01:12:47 +03:00
|
|
|
mca_base_param_t param, *array;
|
2004-01-18 02:07:40 +03:00
|
|
|
|
|
|
|
/* Initialize the array if it has never been initialized */
|
|
|
|
|
|
|
|
if (!initialized) {
|
2004-08-31 13:49:56 +04:00
|
|
|
mca_base_param_init();
|
2004-01-18 02:07:40 +03:00
|
|
|
}
|
|
|
|
|
2004-07-14 00:24:26 +04:00
|
|
|
/* Error check */
|
|
|
|
|
|
|
|
if (NULL == type_name) {
|
|
|
|
return OMPI_ERR_BAD_PARAM;
|
|
|
|
}
|
|
|
|
|
2004-01-18 02:07:40 +03:00
|
|
|
/* Create a parameter entry. If a keyval is to be used, it will be
|
|
|
|
registered elsewhere. We simply assign -1 here. */
|
|
|
|
|
2004-07-14 00:24:26 +04:00
|
|
|
OBJ_CONSTRUCT(¶m, mca_base_param_t);
|
2004-02-11 01:12:47 +03:00
|
|
|
param.mbp_type = type;
|
2004-07-14 00:24:26 +04:00
|
|
|
param.mbp_keyval = MPI_KEYVAL_INVALID;
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2004-02-11 01:12:47 +03:00
|
|
|
param.mbp_type_name = strdup(type_name);
|
|
|
|
if (NULL == param.mbp_type_name) {
|
2004-07-14 00:24:26 +04:00
|
|
|
OBJ_DESTRUCT(¶m);
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
|
|
|
}
|
|
|
|
if (NULL != component_name) {
|
|
|
|
param.mbp_component_name = strdup(component_name);
|
|
|
|
if (NULL == param.mbp_component_name) {
|
|
|
|
OBJ_DESTRUCT(¶m);
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
2004-01-18 02:07:40 +03:00
|
|
|
}
|
2004-01-21 07:13:53 +03:00
|
|
|
} else {
|
2004-07-14 00:24:26 +04:00
|
|
|
param.mbp_param_name = NULL;
|
2004-01-21 07:13:53 +03:00
|
|
|
}
|
2004-07-14 00:24:26 +04:00
|
|
|
if (NULL != param_name) {
|
2004-02-11 01:12:47 +03:00
|
|
|
param.mbp_param_name = strdup(param_name);
|
|
|
|
if (NULL == param.mbp_param_name) {
|
2004-07-14 00:24:26 +04:00
|
|
|
OBJ_DESTRUCT(¶m);
|
|
|
|
return OMPI_ERR_OUT_OF_RESOURCE;
|
2004-01-18 02:07:40 +03:00
|
|
|
}
|
2004-01-21 07:13:53 +03:00
|
|
|
} else {
|
2004-02-11 01:12:47 +03:00
|
|
|
param.mbp_param_name = NULL;
|
2004-01-21 07:13:53 +03:00
|
|
|
}
|
2004-01-18 02:07:40 +03:00
|
|
|
|
|
|
|
/* The full parameter name may have been specified by the caller.
|
|
|
|
If it was, use that (only for backwards compatability).
|
2004-07-14 00:24:26 +04:00
|
|
|
Otherwise, derive it from the type, component, and parameter
|
2004-01-18 02:07:40 +03:00
|
|
|
name. */
|
|
|
|
|
2004-02-11 01:12:47 +03:00
|
|
|
param.mbp_env_var_name = NULL;
|
2004-07-14 00:24:26 +04:00
|
|
|
if (NULL != mca_param_name) {
|
2004-02-11 01:12:47 +03:00
|
|
|
param.mbp_full_name = strdup(mca_param_name);
|
2004-07-14 00:24:26 +04:00
|
|
|
if (NULL == param.mbp_full_name) {
|
|
|
|
OBJ_DESTRUCT(¶m);
|
|
|
|
return OMPI_ERROR;
|
|
|
|
}
|
2004-01-18 02:07:40 +03:00
|
|
|
} else {
|
|
|
|
len = 16 + strlen(type_name);
|
2004-07-14 00:24:26 +04:00
|
|
|
if (NULL != component_name) {
|
|
|
|
len += strlen(component_name);
|
2004-01-21 07:13:53 +03:00
|
|
|
}
|
|
|
|
if (NULL != param_name) {
|
2004-01-18 02:07:40 +03:00
|
|
|
len += strlen(param_name);
|
2004-01-21 07:13:53 +03:00
|
|
|
}
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2004-02-11 01:12:47 +03:00
|
|
|
param.mbp_full_name = malloc(len);
|
|
|
|
if (NULL == param.mbp_full_name) {
|
2004-07-14 00:24:26 +04:00
|
|
|
OBJ_DESTRUCT(¶m);
|
2004-06-07 19:33:53 +04:00
|
|
|
return OMPI_ERROR;
|
2004-01-18 02:07:40 +03:00
|
|
|
}
|
|
|
|
|
2004-07-14 00:24:26 +04:00
|
|
|
/* Copy the name over in parts */
|
|
|
|
|
|
|
|
strncpy(param.mbp_full_name, type_name, len);
|
|
|
|
if (NULL != component_name) {
|
2004-02-11 01:12:47 +03:00
|
|
|
strcat(param.mbp_full_name, "_");
|
2004-07-14 00:24:26 +04:00
|
|
|
strcat(param.mbp_full_name, component_name);
|
2004-01-18 02:07:40 +03:00
|
|
|
}
|
|
|
|
if (NULL != param_name) {
|
2004-02-11 01:12:47 +03:00
|
|
|
strcat(param.mbp_full_name, "_");
|
|
|
|
strcat(param.mbp_full_name, param_name);
|
2004-01-18 02:07:40 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-07-14 00:24:26 +04:00
|
|
|
/* Create the environment name */
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2004-07-14 00:24:26 +04:00
|
|
|
len = strlen(param.mbp_full_name) + strlen(mca_prefix) + 16;
|
|
|
|
param.mbp_env_var_name = malloc(len);
|
|
|
|
if (NULL == param.mbp_env_var_name) {
|
|
|
|
OBJ_DESTRUCT(¶m);
|
|
|
|
return OMPI_ERROR;
|
2004-01-18 02:07:40 +03:00
|
|
|
}
|
2004-07-14 00:24:26 +04:00
|
|
|
snprintf(param.mbp_env_var_name, len, "%s%s", mca_prefix,
|
|
|
|
param.mbp_full_name);
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2004-07-14 00:24:26 +04:00
|
|
|
/* Figure out the default value; zero it out if a default is not
|
|
|
|
provided */
|
2004-01-18 02:07:40 +03:00
|
|
|
|
|
|
|
if (NULL != default_value) {
|
2004-02-11 01:12:47 +03:00
|
|
|
if (MCA_BASE_PARAM_TYPE_STRING == param.mbp_type &&
|
2004-01-21 07:13:53 +03:00
|
|
|
NULL != default_value->stringval) {
|
2004-02-11 01:12:47 +03:00
|
|
|
param.mbp_default_value.stringval = strdup(default_value->stringval);
|
2004-01-21 07:13:53 +03:00
|
|
|
} else {
|
2004-02-11 01:12:47 +03:00
|
|
|
param.mbp_default_value = *default_value;
|
2004-01-21 07:13:53 +03:00
|
|
|
}
|
|
|
|
} else {
|
2004-02-11 01:12:47 +03:00
|
|
|
memset(¶m.mbp_default_value, 0, sizeof(param.mbp_default_value));
|
2004-01-21 07:13:53 +03:00
|
|
|
}
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
/* Figure out the file value; zero it out if a file is not
|
|
|
|
provided */
|
|
|
|
|
|
|
|
if (NULL != file_value) {
|
|
|
|
if (MCA_BASE_PARAM_TYPE_STRING == param.mbp_type &&
|
|
|
|
NULL != file_value->stringval) {
|
|
|
|
param.mbp_file_value.stringval = strdup(file_value->stringval);
|
|
|
|
} else {
|
|
|
|
param.mbp_file_value = *file_value;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
memset(¶m.mbp_file_value, 0, sizeof(param.mbp_file_value));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Figure out the override value; zero it out if a override is not
|
|
|
|
provided */
|
|
|
|
|
|
|
|
if (NULL != override_value) {
|
|
|
|
if (MCA_BASE_PARAM_TYPE_STRING == param.mbp_type &&
|
|
|
|
NULL != override_value->stringval) {
|
|
|
|
param.mbp_override_value.stringval = strdup(override_value->stringval);
|
|
|
|
} else {
|
|
|
|
param.mbp_override_value = *override_value;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
memset(¶m.mbp_override_value, 0, sizeof(param.mbp_override_value));
|
|
|
|
}
|
|
|
|
|
2004-07-14 00:24:26 +04:00
|
|
|
/* See if this entry is already in the array */
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2004-06-07 19:33:53 +04:00
|
|
|
len = ompi_value_array_get_size(&mca_base_params);
|
|
|
|
array = OMPI_VALUE_ARRAY_GET_BASE(&mca_base_params, mca_base_param_t);
|
2004-01-21 07:13:53 +03:00
|
|
|
for (i = 0; i < len; ++i) {
|
2004-02-11 01:12:47 +03:00
|
|
|
if (0 == strcmp(param.mbp_full_name, array[i].mbp_full_name)) {
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2004-07-14 00:24:26 +04:00
|
|
|
/* We found an entry with the same param name. Free the old
|
|
|
|
value (if it was a string */
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
if (MCA_BASE_PARAM_TYPE_STRING == array[i].mbp_type) {
|
|
|
|
if (NULL != array[i].mbp_default_value.stringval) {
|
|
|
|
free(array[i].mbp_default_value.stringval);
|
|
|
|
}
|
|
|
|
if (NULL != array[i].mbp_file_value.stringval) {
|
|
|
|
free(array[i].mbp_file_value.stringval);
|
|
|
|
}
|
|
|
|
if (NULL != array[i].mbp_override_value.stringval) {
|
|
|
|
free(array[i].mbp_override_value.stringval);
|
|
|
|
}
|
2004-01-21 07:13:53 +03:00
|
|
|
}
|
2004-07-14 00:24:26 +04:00
|
|
|
|
|
|
|
/* Now put in the new value */
|
|
|
|
|
|
|
|
if (MCA_BASE_PARAM_TYPE_STRING == param.mbp_type) {
|
|
|
|
if (NULL != param.mbp_default_value.stringval) {
|
|
|
|
array[i].mbp_default_value.stringval =
|
|
|
|
strdup(param.mbp_default_value.stringval);
|
|
|
|
} else {
|
|
|
|
array[i].mbp_default_value.stringval = NULL;
|
|
|
|
}
|
2004-08-31 13:49:56 +04:00
|
|
|
if (NULL != param.mbp_file_value.stringval) {
|
|
|
|
array[i].mbp_file_value.stringval =
|
|
|
|
strdup(param.mbp_file_value.stringval);
|
|
|
|
} else {
|
|
|
|
array[i].mbp_file_value.stringval = NULL;
|
|
|
|
}
|
|
|
|
if (NULL != param.mbp_override_value.stringval) {
|
|
|
|
array[i].mbp_override_value.stringval =
|
|
|
|
strdup(param.mbp_override_value.stringval);
|
|
|
|
} else {
|
|
|
|
array[i].mbp_override_value.stringval = NULL;
|
|
|
|
}
|
2004-07-14 00:24:26 +04:00
|
|
|
} else {
|
|
|
|
array[i].mbp_default_value.intval =
|
|
|
|
param.mbp_default_value.intval;
|
2004-08-31 13:49:56 +04:00
|
|
|
array[i].mbp_file_value.intval =
|
|
|
|
param.mbp_file_value.intval;
|
|
|
|
array[i].mbp_override_value.intval =
|
|
|
|
param.mbp_override_value.intval;
|
2004-01-21 07:13:53 +03:00
|
|
|
}
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2004-07-14 00:24:26 +04:00
|
|
|
/* Just in case we changed type */
|
|
|
|
|
|
|
|
array[i].mbp_type = param.mbp_type;
|
|
|
|
|
|
|
|
/* Now delete the newly-created entry (since we just saved the
|
|
|
|
value in the old entry) */
|
|
|
|
|
|
|
|
OBJ_DESTRUCT(¶m);
|
2004-01-18 02:07:40 +03:00
|
|
|
return i;
|
|
|
|
}
|
2004-01-21 07:13:53 +03:00
|
|
|
}
|
2004-01-18 02:07:40 +03:00
|
|
|
|
|
|
|
/* Add it to the array */
|
|
|
|
|
2004-07-14 00:24:26 +04:00
|
|
|
if (OMPI_SUCCESS !=
|
|
|
|
(ret = ompi_value_array_append_item(&mca_base_params, ¶m))) {
|
|
|
|
return ret;
|
2004-01-21 07:13:53 +03:00
|
|
|
}
|
2004-06-07 19:33:53 +04:00
|
|
|
return ompi_value_array_get_size(&mca_base_params) - 1;
|
2004-01-18 02:07:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2004-08-31 13:49:56 +04:00
|
|
|
* Lookup a parameter in multiple places
|
2004-01-18 02:07:40 +03:00
|
|
|
*/
|
2004-10-20 03:58:12 +04:00
|
|
|
static bool param_lookup(size_t index, mca_base_param_storage_t *storage,
|
2004-06-29 04:02:25 +04:00
|
|
|
ompi_hash_table_t *attrs)
|
2004-01-18 02:07:40 +03:00
|
|
|
{
|
2004-08-31 13:49:56 +04:00
|
|
|
size_t size;
|
|
|
|
mca_base_param_t *array;
|
|
|
|
char *p, *q;
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
/* Lookup the index and see if it's valid */
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
if (!initialized) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
size = ompi_value_array_get_size(&mca_base_params);
|
|
|
|
if (index > size) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
array = OMPI_VALUE_ARRAY_GET_BASE(&mca_base_params, mca_base_param_t);
|
|
|
|
|
|
|
|
/* Ensure that MCA param has a good type */
|
|
|
|
|
|
|
|
if (MCA_BASE_PARAM_TYPE_INT != array[index].mbp_type &&
|
|
|
|
MCA_BASE_PARAM_TYPE_STRING != array[index].mbp_type) {
|
|
|
|
return false;
|
|
|
|
}
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
/* Check all the places that the param may be hiding, in priority
|
|
|
|
order */
|
|
|
|
|
|
|
|
if (lookup_keyvals(&array[index], storage, attrs) ||
|
|
|
|
lookup_env(&array[index], storage) ||
|
|
|
|
lookup_file(&array[index], storage) ||
|
|
|
|
lookup_default(&array[index], storage)) {
|
|
|
|
|
|
|
|
/* If we're returning a string, replace all instances of "~/"
|
|
|
|
with the user's home directory */
|
|
|
|
|
|
|
|
if (MCA_BASE_PARAM_TYPE_STRING == array[index].mbp_type &&
|
|
|
|
NULL != storage->stringval) {
|
|
|
|
if (0 == strncmp(storage->stringval, "~/", 2)) {
|
|
|
|
asprintf(&p, "%s/%s", home, storage->stringval + 2);
|
|
|
|
free(storage->stringval);
|
|
|
|
storage->stringval = p;
|
|
|
|
}
|
|
|
|
|
|
|
|
p = strstr(storage->stringval, ":~/");
|
|
|
|
while (NULL != p) {
|
|
|
|
*p = '\0';
|
|
|
|
asprintf(&q, "%s:%s%s", storage->stringval, home, p + 2);
|
|
|
|
free(storage->stringval);
|
|
|
|
storage->stringval = q;
|
|
|
|
p = strstr(storage->stringval, ":~/");
|
|
|
|
}
|
|
|
|
}
|
2004-06-29 04:02:25 +04:00
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Didn't find it. Doh! */
|
|
|
|
|
2004-06-29 04:02:25 +04:00
|
|
|
return false;
|
2004-08-31 13:49:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Lookup a param in the set of attributes/keyvals
|
|
|
|
*/
|
|
|
|
static bool lookup_keyvals(mca_base_param_t *param,
|
|
|
|
mca_base_param_storage_t *storage,
|
|
|
|
ompi_hash_table_t *attrs)
|
|
|
|
{
|
2004-09-16 20:17:36 +04:00
|
|
|
#if 1
|
|
|
|
/* JMS: Comment this out for now, because it drags in all of
|
|
|
|
libmpi. This is undesirable for programs like mpirun, etc.
|
|
|
|
Need a better solution for this -- perhaps a registration kind
|
|
|
|
of thing...? */
|
|
|
|
return false;
|
|
|
|
#else
|
2004-08-31 13:49:56 +04:00
|
|
|
int err, flag;
|
2004-06-29 04:02:25 +04:00
|
|
|
|
|
|
|
/* If this param has a keyval and we were provided with a hash
|
|
|
|
table, look it up and see if we can find a value */
|
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
if (-1 != param->mbp_keyval) {
|
2004-06-29 04:02:25 +04:00
|
|
|
|
|
|
|
/* Use the stringval member of the union because it's definitely
|
|
|
|
big enough to handle both (int) and (char*) */
|
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
err = ompi_attr_get(attrs, param->mbp_keyval,
|
2004-06-29 04:02:25 +04:00
|
|
|
&storage->stringval, &flag);
|
|
|
|
if (OMPI_SUCCESS == err && 1 == flag) {
|
|
|
|
|
2004-07-14 00:24:26 +04:00
|
|
|
/* Because of alignment weirdness between (void*) and int, we
|
|
|
|
must grab the lower sizeof(int) bytes from the (char*) in
|
|
|
|
stringval, in case sizeof(int) != sizeof(char*). */
|
2004-06-29 04:02:25 +04:00
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
if (MCA_BASE_PARAM_TYPE_INT == param->mbp_type) {
|
2004-07-14 00:24:26 +04:00
|
|
|
storage->intval = *((int *) (storage->stringval +
|
|
|
|
sizeof(void *) - sizeof(int)));
|
2004-06-29 04:02:25 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Nothing to do for string -- we already have the value loaded
|
|
|
|
in the right place */
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
/* Either this param has not keyval or we didn't find the keyval */
|
|
|
|
|
|
|
|
return false;
|
2004-09-16 20:17:36 +04:00
|
|
|
#endif
|
2004-08-31 13:49:56 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Lookup a param in the environment
|
|
|
|
*/
|
|
|
|
static bool lookup_env(mca_base_param_t *param,
|
|
|
|
mca_base_param_storage_t *storage)
|
|
|
|
{
|
|
|
|
char *env;
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
if (NULL != param->mbp_env_var_name &&
|
|
|
|
NULL != (env = getenv(param->mbp_env_var_name))) {
|
|
|
|
if (MCA_BASE_PARAM_TYPE_INT == param->mbp_type) {
|
2004-01-18 02:07:40 +03:00
|
|
|
storage->intval = atoi(env);
|
2004-08-31 13:49:56 +04:00
|
|
|
} else if (MCA_BASE_PARAM_TYPE_STRING == param->mbp_type) {
|
2004-01-18 02:07:40 +03:00
|
|
|
storage->stringval = strdup(env);
|
2004-01-21 07:13:53 +03:00
|
|
|
}
|
2004-01-18 02:07:40 +03:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
/* Didn't find it */
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
return false;
|
|
|
|
}
|
2004-01-18 02:07:40 +03:00
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Lookup a param in the files
|
|
|
|
*/
|
|
|
|
static bool lookup_file(mca_base_param_t *param,
|
|
|
|
mca_base_param_storage_t *storage)
|
|
|
|
{
|
|
|
|
ompi_list_item_t *item;
|
|
|
|
mca_base_param_file_value_t *fv;
|
|
|
|
|
|
|
|
/* See if we previously found a match from a file. If so, just
|
|
|
|
return that */
|
|
|
|
|
|
|
|
if (param->mbp_file_value_set) {
|
|
|
|
return set(param->mbp_type, storage, ¶m->mbp_file_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Scan through the list of values read in from files and try to
|
|
|
|
find a match. If we do, cache it on the param (for future
|
|
|
|
lookups) and save it in the storage. */
|
|
|
|
|
|
|
|
for (item = ompi_list_get_first(&mca_base_param_file_values);
|
|
|
|
ompi_list_get_end(&mca_base_param_file_values) != item;
|
|
|
|
item = ompi_list_get_next(item)) {
|
|
|
|
fv = (mca_base_param_file_value_t *) item;
|
|
|
|
if (0 == strcmp(fv->mbpfv_param, param->mbp_full_name)) {
|
|
|
|
if (MCA_BASE_PARAM_TYPE_INT == param->mbp_type) {
|
|
|
|
if (NULL != fv->mbpfv_value) {
|
|
|
|
param->mbp_file_value.intval = atoi(fv->mbpfv_value);
|
|
|
|
} else {
|
|
|
|
param->mbp_file_value.intval = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
param->mbp_file_value.stringval = fv->mbpfv_value;
|
|
|
|
fv->mbpfv_value = NULL;
|
|
|
|
}
|
|
|
|
param->mbp_file_value_set = true;
|
|
|
|
|
|
|
|
/* Since this is now cached on the param, we might as well
|
|
|
|
remove it from the list and make future file lookups
|
|
|
|
faster */
|
|
|
|
|
|
|
|
ompi_list_remove_item(&mca_base_param_file_values,
|
|
|
|
(ompi_list_item_t *) fv);
|
|
|
|
OBJ_RELEASE(fv);
|
|
|
|
|
|
|
|
return set(param->mbp_type, storage, ¶m->mbp_file_value);
|
|
|
|
}
|
2004-01-22 03:37:58 +03:00
|
|
|
}
|
2004-01-18 02:07:40 +03:00
|
|
|
|
|
|
|
return false;
|
2004-08-31 13:49:56 +04:00
|
|
|
}
|
2004-01-18 02:07:40 +03:00
|
|
|
|
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
/*
|
|
|
|
* Return the default value for a param
|
|
|
|
*/
|
|
|
|
static bool lookup_default(mca_base_param_t *param,
|
|
|
|
mca_base_param_storage_t *storage)
|
|
|
|
{
|
|
|
|
return set(param->mbp_type, storage, ¶m->mbp_default_value);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static bool set(mca_base_param_type_t type,
|
|
|
|
mca_base_param_storage_t *dest, mca_base_param_storage_t *src)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case MCA_BASE_PARAM_TYPE_INT:
|
|
|
|
dest->intval = src->intval;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MCA_BASE_PARAM_TYPE_STRING:
|
|
|
|
if (NULL != src->stringval) {
|
|
|
|
dest->stringval = strdup(src->stringval);
|
|
|
|
} else {
|
|
|
|
dest->stringval = NULL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2004-01-18 02:07:40 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-07-14 00:24:26 +04:00
|
|
|
/*
|
|
|
|
* Create an empty param container
|
|
|
|
*/
|
|
|
|
static void param_constructor(mca_base_param_t *p)
|
|
|
|
{
|
2004-08-31 13:49:56 +04:00
|
|
|
p->mbp_type = MCA_BASE_PARAM_TYPE_MAX;
|
2004-07-14 00:24:26 +04:00
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
p->mbp_type_name = NULL;
|
|
|
|
p->mbp_component_name = NULL;
|
|
|
|
p->mbp_param_name = NULL;
|
|
|
|
p->mbp_full_name = NULL;
|
2004-07-14 00:24:26 +04:00
|
|
|
|
2004-08-31 13:49:56 +04:00
|
|
|
p->mbp_keyval = -1;
|
|
|
|
p->mbp_env_var_name = NULL;
|
|
|
|
|
|
|
|
p->mbp_default_value.stringval = NULL;
|
|
|
|
p->mbp_file_value_set = false;
|
|
|
|
p->mbp_file_value.stringval = NULL;
|
|
|
|
p->mbp_override_value_set = false;
|
|
|
|
p->mbp_override_value.stringval = NULL;
|
2004-07-14 00:24:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Free all the contents of a param container
|
|
|
|
*/
|
|
|
|
static void param_destructor(mca_base_param_t *p)
|
2004-01-18 02:07:40 +03:00
|
|
|
{
|
2004-08-31 13:49:56 +04:00
|
|
|
if (NULL != p->mbp_type_name) {
|
|
|
|
free(p->mbp_type_name);
|
|
|
|
}
|
|
|
|
if (NULL != p->mbp_component_name) {
|
|
|
|
free(p->mbp_component_name);
|
|
|
|
}
|
|
|
|
if (NULL != p->mbp_param_name) {
|
|
|
|
free(p->mbp_param_name);
|
|
|
|
}
|
|
|
|
if (NULL != p->mbp_env_var_name) {
|
|
|
|
free(p->mbp_env_var_name);
|
|
|
|
}
|
|
|
|
if (NULL != p->mbp_full_name) {
|
|
|
|
free(p->mbp_full_name);
|
|
|
|
}
|
|
|
|
if (MCA_BASE_PARAM_TYPE_STRING == p->mbp_type) {
|
|
|
|
if (NULL != p->mbp_default_value.stringval) {
|
|
|
|
free(p->mbp_default_value.stringval);
|
|
|
|
}
|
|
|
|
if (p->mbp_file_value_set &&
|
|
|
|
NULL != p->mbp_file_value.stringval) {
|
|
|
|
free(p->mbp_file_value.stringval);
|
|
|
|
}
|
|
|
|
if (p->mbp_override_value_set &&
|
|
|
|
NULL != p->mbp_override_value.stringval) {
|
|
|
|
free(p->mbp_override_value.stringval);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void fv_constructor(mca_base_param_file_value_t *f)
|
|
|
|
{
|
|
|
|
f->mbpfv_param = NULL;
|
|
|
|
f->mbpfv_value = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void fv_destructor(mca_base_param_file_value_t *f)
|
|
|
|
{
|
|
|
|
if (NULL != f->mbpfv_param) {
|
|
|
|
free(f->mbpfv_param);
|
|
|
|
}
|
|
|
|
if (NULL != f->mbpfv_value) {
|
|
|
|
free(f->mbpfv_value);
|
|
|
|
}
|
2004-01-18 02:07:40 +03:00
|
|
|
}
|