1
1
register mca_base_var_enum_value_flag_t so they can be free'd
upon finalize

Signed-off-by: Gilles Gouaillardet <gilles@rist.or.jp>
Этот коммит содержится в:
Gilles Gouaillardet 2017-01-06 13:12:16 +09:00
родитель cf534d0c95
Коммит c2ddb1e2fc
6 изменённых файлов: 91 добавлений и 9 удалений

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

@ -25,6 +25,7 @@
#include "opal_config.h"
#include "opal/mca/base/mca_base_var_enum.h"
#include "opal/mca/base/mca_base_vari.h"
#include "opal/mca/base/base.h"
#include "opal/util/argv.h"
@ -633,3 +634,28 @@ static void mca_base_var_enum_flag_destructor (mca_base_var_enum_flag_t *enumera
free (enumerator->super.enum_name);
}
}
int mca_base_var_enum_register(const char *project_name, const char *framework_name,
const char *component_name, const char *enum_name,
void *storage)
{
int group_index;
/* Developer error. Storage can not be NULL */
assert (NULL != storage);
/* Create a new parameter entry */
group_index = mca_base_var_group_register (project_name, framework_name, component_name,
NULL);
if (-1 > group_index) {
return group_index;
}
if (0 <= group_index) {
mca_base_var_group_add_enum (group_index, storage);
}
return OPAL_SUCCESS;
/* All done */
}

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

@ -13,6 +13,8 @@
* Copyright (c) 2008-2011 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2012-2016 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -227,6 +229,9 @@ OPAL_DECLSPEC int mca_base_var_enum_create (const char *name, const mca_base_var
OPAL_DECLSPEC int mca_base_var_enum_create_flag (const char *name, const mca_base_var_enum_value_flag_t flags[],
mca_base_var_enum_flag_t **enumerator);
OPAL_DECLSPEC int mca_base_var_enum_register(const char *project_name, const char *framework_name,
const char *component_name, const char *enum_name,
void *storage);
/* standard enumerators. it is invalid to call OBJ_RELEASE on any of these enumerators */
/**
* Boolean enumerator

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

@ -13,6 +13,8 @@
* Copyright (c) 2008-2013 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -330,6 +332,7 @@ int mca_base_var_group_deregister (int group_index)
mca_base_var_group_t *group;
int size, ret;
int *params, *subgroups;
opal_object_t ** enums;
ret = mca_base_var_group_get_internal (group_index, &group, false);
if (OPAL_SUCCESS != ret) {
@ -368,6 +371,12 @@ int mca_base_var_group_deregister (int group_index)
(void) mca_base_pvar_mark_invalid (params[i]);
}
size = opal_value_array_get_size(&group->group_enums);
enums = OPAL_VALUE_ARRAY_GET_BASE(&group->group_enums, opal_object_t *);
for (int i = 0 ; i < size ; ++i) {
OBJ_RELEASE (enums[i]);
}
size = opal_value_array_get_size(&group->group_subgroups);
subgroups = OPAL_VALUE_ARRAY_GET_BASE(&group->group_subgroups, int);
for (int i = 0 ; i < size ; ++i) {
@ -453,6 +462,34 @@ int mca_base_var_group_add_pvar (const int group_index, const int param_index)
return (int) opal_value_array_get_size (&group->group_pvars) - 1;
}
int mca_base_var_group_add_enum (const int group_index, const void * storage)
{
mca_base_var_group_t *group;
int size, i, ret;
void **params;
ret = mca_base_var_group_get_internal (group_index, &group, false);
if (OPAL_SUCCESS != ret) {
return ret;
}
size = opal_value_array_get_size(&group->group_enums);
params = OPAL_VALUE_ARRAY_GET_BASE(&group->group_enums, void *);
for (i = 0 ; i < size ; ++i) {
if (params[i] == storage) {
return i;
}
}
if (OPAL_SUCCESS !=
(ret = opal_value_array_append_item (&group->group_enums, storage))) {
return ret;
}
/* return the group index */
return (int) opal_value_array_get_size (&group->group_enums) - 1;
}
int mca_base_var_group_get (const int group_index, const mca_base_var_group_t **group)
{
return mca_base_var_group_get_internal (group_index, (mca_base_var_group_t **) group, false);
@ -495,6 +532,9 @@ static void mca_base_var_group_constructor (mca_base_var_group_t *group)
OBJ_CONSTRUCT(&group->group_pvars, opal_value_array_t);
opal_value_array_init (&group->group_pvars, sizeof (int));
OBJ_CONSTRUCT(&group->group_enums, opal_value_array_t);
opal_value_array_init (&group->group_enums, sizeof(void *));
}
static void mca_base_var_group_destructor (mca_base_var_group_t *group)
@ -517,6 +557,7 @@ static void mca_base_var_group_destructor (mca_base_var_group_t *group)
OBJ_DESTRUCT(&group->group_subgroups);
OBJ_DESTRUCT(&group->group_vars);
OBJ_DESTRUCT(&group->group_pvars);
OBJ_DESTRUCT(&group->group_enums);
}
int mca_base_var_group_get_count (void)

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

@ -13,6 +13,8 @@
* Copyright (c) 2008-2011 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -52,6 +54,9 @@ struct mca_base_var_group_t {
/** Integer array of group performance variables */
opal_value_array_t group_pvars;
/** Pointer array of group enums */
opal_value_array_t group_enums;
};
typedef struct mca_base_var_group_t mca_base_var_group_t;

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

@ -13,6 +13,8 @@
* Copyright (c) 2008 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights
* reserved.
* Copyright (c) 2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
@ -136,6 +138,13 @@ OPAL_DECLSPEC int mca_base_var_group_add_var (const int group_index, const int p
*/
OPAL_DECLSPEC int mca_base_var_group_add_pvar (const int group_index, const int param_index);
/**
* \internal
*
* Add an enum to a group
*/
OPAL_DECLSPEC int mca_base_var_group_add_enum (const int group_index, const void *storage);
/**
* \internal
*

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

@ -12,7 +12,7 @@
* All rights reserved.
* Copyright (c) 2006-2007 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2008-2013 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2015 Research Organization for Information Science
* Copyright (c) 2015-2017 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* Copyright (c) 2016 Los Alamos National Security, LLC. All rights
* reserved.
@ -147,7 +147,11 @@ static int mca_btl_base_register(mca_base_register_flag_t flags)
&mca_btl_base_warn_component_unused);
(void) mca_base_var_enum_create_flag ("btl_flags", mca_btl_base_flag_enum_flags, &mca_btl_base_flag_enum);
(void) mca_base_var_enum_register("opal", "btl", "base", "btl_flags",
&mca_btl_base_flag_enum);
(void) mca_base_var_enum_create_flag ("btl_atomic_flags", mca_btl_base_atomic_enum_flags, &mca_btl_base_atomic_enum);
(void) mca_base_var_enum_register("opal", "btl", "base", "btl_atomic_flags",
&mca_btl_base_atomic_enum);
return OPAL_SUCCESS;
}
@ -204,14 +208,6 @@ static int mca_btl_base_close(void)
OBJ_DESTRUCT(&mca_btl_base_modules_initialized);
if (mca_btl_base_flag_enum) {
OBJ_RELEASE(mca_btl_base_flag_enum);
}
if (mca_btl_base_atomic_enum) {
OBJ_RELEASE(mca_btl_base_atomic_enum);
}
#if 0
/* restore event processing */
opal_event_enable();