Fix a couple issues with the mca_base_var system:
- Use ->boolval for booleans when creating a string. - Solaris has some issue with the ?: used in one of find functions. Use an if instead. - Change all instances of index -> vari to avoid issues with redefining index. cmr=v1.7.4:reviewer=jsquyres This commit was SVN r29997.
Этот коммит содержится в:
родитель
ee9cd13b90
Коммит
653babc737
@ -131,7 +131,7 @@ static int fixup_files(char **file_list, char * path, bool rel_path_search);
|
||||
static int read_files (char *file_list, opal_list_t *file_values);
|
||||
static int mca_base_var_cache_files (bool rel_path_search);
|
||||
static int var_set_initial (mca_base_var_t *var);
|
||||
static int var_get (int index, mca_base_var_t **var_out, bool original);
|
||||
static int var_get (int vari, mca_base_var_t **var_out, bool original);
|
||||
static int var_value_string (mca_base_var_t *var, char **value_string);
|
||||
|
||||
/*
|
||||
@ -420,7 +420,7 @@ static int mca_base_var_cache_files(bool rel_path_search)
|
||||
/*
|
||||
* Look up an integer MCA parameter.
|
||||
*/
|
||||
int mca_base_var_get_value (int index, const void *value,
|
||||
int mca_base_var_get_value (int vari, const void *value,
|
||||
mca_base_var_source_t *source,
|
||||
const char **source_file)
|
||||
{
|
||||
@ -428,7 +428,7 @@ int mca_base_var_get_value (int index, const void *value,
|
||||
void **tmp = (void **) value;
|
||||
int ret;
|
||||
|
||||
ret = var_get (index, &var, true);
|
||||
ret = var_get (vari, &var, true);
|
||||
if (OPAL_SUCCESS != ret) {
|
||||
return ret;
|
||||
}
|
||||
@ -623,13 +623,13 @@ static int var_set_from_string (mca_base_var_t *var, char *src)
|
||||
/*
|
||||
* Set a variable
|
||||
*/
|
||||
int mca_base_var_set_value (int index, const void *value, size_t size, mca_base_var_source_t source,
|
||||
int mca_base_var_set_value (int vari, const void *value, size_t size, mca_base_var_source_t source,
|
||||
const char *source_file)
|
||||
{
|
||||
mca_base_var_t *var;
|
||||
int ret;
|
||||
|
||||
ret = var_get (index, &var, true);
|
||||
ret = var_get (vari, &var, true);
|
||||
if (OPAL_SUCCESS != ret) {
|
||||
return ret;
|
||||
}
|
||||
@ -669,12 +669,12 @@ int mca_base_var_set_value (int index, const void *value, size_t size, mca_base_
|
||||
/*
|
||||
* Deregister a parameter
|
||||
*/
|
||||
int mca_base_var_deregister(int index)
|
||||
int mca_base_var_deregister(int vari)
|
||||
{
|
||||
mca_base_var_t *var;
|
||||
int ret;
|
||||
|
||||
ret = var_get (index, &var, false);
|
||||
ret = var_get (vari, &var, false);
|
||||
if (OPAL_SUCCESS != ret) {
|
||||
return ret;
|
||||
}
|
||||
@ -708,7 +708,7 @@ int mca_base_var_deregister(int index)
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
static int var_get (int index, mca_base_var_t **var_out, bool original)
|
||||
static int var_get (int vari, mca_base_var_t **var_out, bool original)
|
||||
{
|
||||
mca_base_var_t *var;
|
||||
|
||||
@ -721,11 +721,11 @@ static int var_get (int index, mca_base_var_t **var_out, bool original)
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
|
||||
if (index < 0) {
|
||||
if (vari < 0) {
|
||||
return OPAL_ERR_BAD_PARAM;
|
||||
}
|
||||
|
||||
var = opal_pointer_array_get_item (&mca_base_vars, index);
|
||||
var = opal_pointer_array_get_item (&mca_base_vars, vari);
|
||||
if (NULL == var) {
|
||||
return OPAL_ERR_BAD_PARAM;
|
||||
}
|
||||
@ -759,7 +759,7 @@ int mca_base_var_env_name(const char *param_name,
|
||||
/*
|
||||
* Find the index for an MCA parameter based on its names.
|
||||
*/
|
||||
static int var_find_by_name (const char *full_name, int *index, bool invalidok)
|
||||
static int var_find_by_name (const char *full_name, int *vari, bool invalidok)
|
||||
{
|
||||
mca_base_var_t *var;
|
||||
void *tmp;
|
||||
@ -774,7 +774,7 @@ static int var_find_by_name (const char *full_name, int *index, bool invalidok)
|
||||
(void) var_get ((int)(uintptr_t) tmp, &var, false);
|
||||
|
||||
if (invalidok || VAR_IS_VALID(var[0])) {
|
||||
*index = (int)(uintptr_t) tmp;
|
||||
*vari = (int)(uintptr_t) tmp;
|
||||
return OPAL_SUCCESS;
|
||||
}
|
||||
|
||||
@ -786,7 +786,7 @@ static int var_find (const char *project_name, const char *framework_name,
|
||||
bool invalidok)
|
||||
{
|
||||
char *full_name;
|
||||
int ret, index;
|
||||
int ret, vari;
|
||||
|
||||
ret = mca_base_var_generate_full_name4 (NULL, framework_name, component_name,
|
||||
variable_name, &full_name);
|
||||
@ -794,12 +794,17 @@ static int var_find (const char *project_name, const char *framework_name,
|
||||
return OPAL_ERROR;
|
||||
}
|
||||
|
||||
ret = var_find_by_name(full_name, &index, invalidok);
|
||||
ret = var_find_by_name(full_name, &vari, invalidok);
|
||||
|
||||
/* NTH: should we verify the name components match? */
|
||||
|
||||
free (full_name);
|
||||
return (OPAL_SUCCESS != ret) ? ret : index;
|
||||
|
||||
if (OPAL_SUCCESS != ret) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return vari;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -814,17 +819,17 @@ int mca_base_var_find (const char *project_name, const char *framework_name,
|
||||
/*
|
||||
* Find the index for an MCA parameter based on full name.
|
||||
*/
|
||||
int mca_base_var_find_by_name (const char *full_name, int *index)
|
||||
int mca_base_var_find_by_name (const char *full_name, int *vari)
|
||||
{
|
||||
return var_find_by_name (full_name, index, false);
|
||||
return var_find_by_name (full_name, vari, false);
|
||||
}
|
||||
|
||||
int mca_base_var_set_flag (int index, mca_base_var_flag_t flag, bool set)
|
||||
int mca_base_var_set_flag (int vari, mca_base_var_flag_t flag, bool set)
|
||||
{
|
||||
mca_base_var_t *var;
|
||||
int ret;
|
||||
|
||||
ret = var_get (index, &var, true);
|
||||
ret = var_get (vari, &var, true);
|
||||
if (OPAL_SUCCESS != ret || VAR_IS_SYNONYM(var[0])) {
|
||||
return OPAL_ERR_BAD_PARAM;
|
||||
}
|
||||
@ -838,9 +843,9 @@ int mca_base_var_set_flag (int index, mca_base_var_flag_t flag, bool set)
|
||||
/*
|
||||
* Return info on a parameter at an index
|
||||
*/
|
||||
int mca_base_var_get (int index, const mca_base_var_t **var)
|
||||
int mca_base_var_get (int vari, const mca_base_var_t **var)
|
||||
{
|
||||
return var_get (index, (mca_base_var_t **) var, false);
|
||||
return var_get (vari, (mca_base_var_t **) var, false);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1682,7 +1687,12 @@ static int var_value_string (mca_base_var_t *var, char **value_string)
|
||||
|
||||
ret = (0 > ret) ? OPAL_ERR_OUT_OF_RESOURCE : OPAL_SUCCESS;
|
||||
} else {
|
||||
ret = var->mbv_enumerator->string_from_value(var->mbv_enumerator, value->intval, &tmp);
|
||||
/* we use an enumerator to handle string->bool and bool->string conversion */
|
||||
if (MCA_BASE_VAR_TYPE_BOOL == var->mbv_type) {
|
||||
ret = var->mbv_enumerator->string_from_value(var->mbv_enumerator, value->boolval, &tmp);
|
||||
} else {
|
||||
ret = var->mbv_enumerator->string_from_value(var->mbv_enumerator, value->intval, &tmp);
|
||||
}
|
||||
|
||||
*value_string = strdup (tmp);
|
||||
if (NULL == value_string) {
|
||||
@ -1752,7 +1762,7 @@ int mca_base_var_get_count (void)
|
||||
return mca_base_var_count;
|
||||
}
|
||||
|
||||
int mca_base_var_dump(int index, char ***out, mca_base_var_dump_type_t output_type)
|
||||
int mca_base_var_dump(int vari, char ***out, mca_base_var_dump_type_t output_type)
|
||||
{
|
||||
const char *framework, *component, *full_name;
|
||||
int i, line_count, line = 0, enum_count = 0;
|
||||
@ -1761,7 +1771,7 @@ int mca_base_var_dump(int index, char ***out, mca_base_var_dump_type_t output_ty
|
||||
mca_base_var_t *var, *original=NULL;
|
||||
mca_base_var_group_t *group;
|
||||
|
||||
ret = var_get(index, &var, false);
|
||||
ret = var_get(vari, &var, false);
|
||||
if (OPAL_SUCCESS != ret) {
|
||||
return ret;
|
||||
}
|
||||
|
@ -473,22 +473,22 @@ OPAL_DECLSPEC int mca_base_var_register_synonym (int synonym_for, const char *pr
|
||||
/**
|
||||
* Deregister a MCA variable or synonym
|
||||
*
|
||||
* @param index Index returned from mca_base_var_register() or
|
||||
* @param vari Index returned from mca_base_var_register() or
|
||||
* mca_base_var_register_synonym().
|
||||
*
|
||||
* Deregistering a variable does not free the index or any memory assoicated
|
||||
* with the variable. All memory will be freed and the index released when
|
||||
* Deregistering a variable does not free the variable or any memory assoicated
|
||||
* with it. All memory will be freed and the variable index released when
|
||||
* mca_base_var_finalize() is called.
|
||||
*
|
||||
* If an enumerator is associated with this variable it will be dereferenced.
|
||||
*/
|
||||
OPAL_DECLSPEC int mca_base_var_deregister(int index);
|
||||
OPAL_DECLSPEC int mca_base_var_deregister(int vari);
|
||||
|
||||
|
||||
/**
|
||||
* Get the current value of an MCA variable.
|
||||
*
|
||||
* @param[in] index Index of variable
|
||||
* @param[in] vari Index of variable
|
||||
* @param[in,out] value Pointer to copy the value to. Can be NULL.
|
||||
* @param[in,out] value_size Size of memory pointed to by value.
|
||||
* copied size will be returned in value_size.
|
||||
@ -505,14 +505,14 @@ OPAL_DECLSPEC int mca_base_var_deregister(int index);
|
||||
* Note: The value can be changed by the registering code without using
|
||||
* the mca_base_var_* interface so the source may be incorrect.
|
||||
*/
|
||||
OPAL_DECLSPEC int mca_base_var_get_value (int index, const void *value,
|
||||
OPAL_DECLSPEC int mca_base_var_get_value (int vari, const void *value,
|
||||
mca_base_var_source_t *source,
|
||||
const char **source_file);
|
||||
|
||||
/**
|
||||
* Sets an "override" value for an integer MCA variable.
|
||||
*
|
||||
* @param[in] index Index of MCA variable to set
|
||||
* @param[in] vari Index of MCA variable to set
|
||||
* @param[in] value Pointer to the value to set. Should point to
|
||||
* a char * for string variables or a int * for integer variables.
|
||||
* @param[in] size Size of value.
|
||||
@ -530,7 +530,7 @@ OPAL_DECLSPEC int mca_base_var_get_value (int index, const void *value,
|
||||
* a synonym the variable the synonym represents) if the value is
|
||||
* settable.
|
||||
*/
|
||||
OPAL_DECLSPEC int mca_base_var_set_value (int index, const void *value, size_t size,
|
||||
OPAL_DECLSPEC int mca_base_var_set_value (int vari, const void *value, size_t size,
|
||||
mca_base_var_source_t source,
|
||||
const char *source_file);
|
||||
|
||||
@ -559,7 +559,7 @@ OPAL_DECLSPEC int mca_base_var_env_name(const char *param_name,
|
||||
* @param param_name Name of the variable.
|
||||
*
|
||||
* @retval OPAL_ERROR If the variable was not found.
|
||||
* @retval index If the variable was found.
|
||||
* @retval vari If the variable was found.
|
||||
*
|
||||
* It is not always convenient to widely propagate a variable's index
|
||||
* value, or it may be necessary to look up the variable from a
|
||||
@ -576,11 +576,11 @@ OPAL_DECLSPEC int mca_base_var_find (const char *project_name,
|
||||
* Find the index for a variable based on its full name
|
||||
*
|
||||
* @param full_name [in] Full name of the variable
|
||||
* @param index [out] Index of the variable
|
||||
* @param vari [out] Index of the variable
|
||||
*
|
||||
* See mca_base_var_find().
|
||||
*/
|
||||
OPAL_DECLSPEC int mca_base_var_find_by_name (const char *full_name, int *index);
|
||||
OPAL_DECLSPEC int mca_base_var_find_by_name (const char *full_name, int *vari);
|
||||
|
||||
/**
|
||||
* Check that two MCA variables were not both set to non-default
|
||||
@ -621,7 +621,7 @@ OPAL_DECLSPEC int mca_base_var_check_exclusive (const char *project,
|
||||
/**
|
||||
* Set or unset a flag on a variable.
|
||||
*
|
||||
* @param[in] index Index of variable
|
||||
* @param[in] vari Index of variable
|
||||
* @param[in] flag Flag(s) to set or unset.
|
||||
* @param[in] set Boolean indicating whether to set flag(s).
|
||||
*
|
||||
@ -629,13 +629,13 @@ OPAL_DECLSPEC int mca_base_var_check_exclusive (const char *project,
|
||||
* @returns OPAL_ERR_BAD_PARAM If the variable is not registered.
|
||||
* @returns OPAL_ERROR Otherwise
|
||||
*/
|
||||
OPAL_DECLSPEC int mca_base_var_set_flag(int index, mca_base_var_flag_t flag,
|
||||
OPAL_DECLSPEC int mca_base_var_set_flag(int vari, mca_base_var_flag_t flag,
|
||||
bool set);
|
||||
|
||||
/**
|
||||
* Obtain basic info on a single variable (name, help message, etc)
|
||||
*
|
||||
* @param[in] index Valid variable index.
|
||||
* @param[in] vari Valid variable index.
|
||||
* @param[out] var Storage for the variable pointer.
|
||||
*
|
||||
* @retval OPAL_SUCCESS Upon success.
|
||||
@ -644,7 +644,7 @@ OPAL_DECLSPEC int mca_base_var_set_flag(int index, mca_base_var_flag_t flag,
|
||||
* The returned pointer belongs to the MCA variable system. Do not
|
||||
* modify/free/retain the pointer.
|
||||
*/
|
||||
OPAL_DECLSPEC int mca_base_var_get (int index, const mca_base_var_t **var);
|
||||
OPAL_DECLSPEC int mca_base_var_get (int vari, const mca_base_var_t **var);
|
||||
|
||||
/**
|
||||
* Obtain the number of variables that have been registered.
|
||||
@ -707,14 +707,14 @@ typedef enum {
|
||||
/**
|
||||
* Dump strings describing the MCA variable at an index.
|
||||
*
|
||||
* @param[in] index Variable index
|
||||
* @param[in] vari Variable index
|
||||
* @param[out] out Array of strings describing this variable
|
||||
* @param[in] output_type Type of output desired
|
||||
*
|
||||
* This function returns an array of strings describing the variable. All strings
|
||||
* and the array must be freed by the caller.
|
||||
*/
|
||||
OPAL_DECLSPEC int mca_base_var_dump(int index, char ***out, mca_base_var_dump_type_t output_type);
|
||||
OPAL_DECLSPEC int mca_base_var_dump(int vari, char ***out, mca_base_var_dump_type_t output_type);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user