From e737b0a1061848fb598def05b9755f37a5758502 Mon Sep 17 00:00:00 2001 From: Brian Barrett Date: Thu, 20 Apr 2006 15:35:58 +0000 Subject: [PATCH] Fix a bunch of warnings the Sun compilers find: - The constant 1 is a signed int by default. Explicitly say that it is an unsigned value so we can't overflow - Fix unreachable statement warnings in dss_arith by breaking out of switch statements instead of returning - this should have no impact on performance, since it's a non-conditional jump - A couple of the GPR files had carriage returns and were in DOS mode - put them in unix mode... These should all probably go to the v1.1 branch... This commit was SVN r9664. --- orte/dss/dss_arith.c | 140 ++-- .../gpr/base/gpr_base_create_value_keyval.c | 250 +++--- orte/mca/gpr/base/gpr_base_simplified_put.c | 254 +++--- .../gpr/base/gpr_base_simplified_subscribe.c | 754 +++++++++--------- orte/mca/ns/ns_types.h | 6 +- 5 files changed, 702 insertions(+), 702 deletions(-) diff --git a/orte/dss/dss_arith.c b/orte/dss/dss_arith.c index 3899825045..8687c66136 100755 --- a/orte/dss/dss_arith.c +++ b/orte/dss/dss_arith.c @@ -331,15 +331,15 @@ static void orte_dss_arith_int(int *value, int *operand, orte_dss_arith_op_t ope switch(operation) { case ORTE_DSS_ADD: (*value) += *operand; - return; + break; case ORTE_DSS_SUB: (*value) -= *operand; - return; + break; case ORTE_DSS_MUL: (*value) *= *operand; - return; + break; case ORTE_DSS_DIV: if (0 == *operand) { @@ -347,11 +347,11 @@ static void orte_dss_arith_int(int *value, int *operand, orte_dss_arith_op_t ope return; } (*value) /= *operand; - return; + break; default: ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); - return; + break; } return; } @@ -361,15 +361,15 @@ static void orte_dss_arith_uint(uint *value, uint *operand, orte_dss_arith_op_t switch(operation) { case ORTE_DSS_ADD: (*value) += *operand; - return; + break; case ORTE_DSS_SUB: (*value) -= *operand; - return; + break; case ORTE_DSS_MUL: (*value) *= *operand; - return; + break; case ORTE_DSS_DIV: if (0 == *operand) { @@ -377,11 +377,11 @@ static void orte_dss_arith_uint(uint *value, uint *operand, orte_dss_arith_op_t return; } (*value) /= *operand; - return; + break; default: ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); - return; + break; } return; } @@ -391,15 +391,15 @@ static void orte_dss_arith_size(size_t *value, size_t *operand, orte_dss_arith_o switch(operation) { case ORTE_DSS_ADD: (*value) += *operand; - return; + break; case ORTE_DSS_SUB: (*value) -= *operand; - return; + break; case ORTE_DSS_MUL: (*value) *= *operand; - return; + break; case ORTE_DSS_DIV: if (0 == *operand) { @@ -407,11 +407,11 @@ static void orte_dss_arith_size(size_t *value, size_t *operand, orte_dss_arith_o return; } (*value) /= *operand; - return; + break; default: ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); - return; + break; } return; } @@ -421,15 +421,15 @@ static void orte_dss_arith_pid(pid_t *value, pid_t *operand, orte_dss_arith_op_t switch(operation) { case ORTE_DSS_ADD: (*value) += *operand; - return; + break; case ORTE_DSS_SUB: (*value) -= *operand; - return; + break; case ORTE_DSS_MUL: (*value) *= *operand; - return; + break; case ORTE_DSS_DIV: if (0 == *operand) { @@ -437,11 +437,11 @@ static void orte_dss_arith_pid(pid_t *value, pid_t *operand, orte_dss_arith_op_t return; } (*value) /= *operand; - return; + break; default: ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); - return; + break; } return; } @@ -451,15 +451,15 @@ static void orte_dss_arith_byte(uint8_t *value, uint8_t *operand, orte_dss_arith switch(operation) { case ORTE_DSS_ADD: (*value) += *operand; - return; + break; case ORTE_DSS_SUB: (*value) -= *operand; - return; + break; case ORTE_DSS_MUL: (*value) *= *operand; - return; + break; case ORTE_DSS_DIV: if (0 == *operand) { @@ -467,11 +467,11 @@ static void orte_dss_arith_byte(uint8_t *value, uint8_t *operand, orte_dss_arith return; } (*value) /= *operand; - return; + break; default: ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); - return; + break; } return; } @@ -481,15 +481,15 @@ static void orte_dss_arith_int8(int8_t *value, int8_t *operand, orte_dss_arith_o switch(operation) { case ORTE_DSS_ADD: (*value) += *operand; - return; + break; case ORTE_DSS_SUB: (*value) -= *operand; - return; + break; case ORTE_DSS_MUL: (*value) *= *operand; - return; + break; case ORTE_DSS_DIV: if (0 == *operand) { @@ -497,11 +497,11 @@ static void orte_dss_arith_int8(int8_t *value, int8_t *operand, orte_dss_arith_o return; } (*value) /= *operand; - return; + break; default: ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); - return; + break; } return; } @@ -511,15 +511,15 @@ static void orte_dss_arith_int16(int16_t *value, int16_t *operand, orte_dss_arit switch(operation) { case ORTE_DSS_ADD: (*value) += *operand; - return; + break; case ORTE_DSS_SUB: (*value) -= *operand; - return; + break; case ORTE_DSS_MUL: (*value) *= *operand; - return; + break; case ORTE_DSS_DIV: if (0 == *operand) { @@ -527,11 +527,11 @@ static void orte_dss_arith_int16(int16_t *value, int16_t *operand, orte_dss_arit return; } (*value) /= *operand; - return; + break; default: ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); - return; + break; } return; } @@ -541,15 +541,15 @@ static void orte_dss_arith_uint16(uint16_t *value, uint16_t *operand, orte_dss_a switch(operation) { case ORTE_DSS_ADD: (*value) += *operand; - return; + break; case ORTE_DSS_SUB: (*value) -= *operand; - return; + break; case ORTE_DSS_MUL: (*value) *= *operand; - return; + break; case ORTE_DSS_DIV: if (0 == *operand) { @@ -557,11 +557,11 @@ static void orte_dss_arith_uint16(uint16_t *value, uint16_t *operand, orte_dss_a return; } (*value) /= *operand; - return; + break; default: ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); - return; + break; } return; } @@ -571,15 +571,15 @@ static void orte_dss_arith_int32(int32_t *value, int32_t *operand, orte_dss_arit switch(operation) { case ORTE_DSS_ADD: (*value) += *operand; - return; + break; case ORTE_DSS_SUB: (*value) -= *operand; - return; + break; case ORTE_DSS_MUL: (*value) *= *operand; - return; + break; case ORTE_DSS_DIV: if (0 == *operand) { @@ -587,11 +587,11 @@ static void orte_dss_arith_int32(int32_t *value, int32_t *operand, orte_dss_arit return; } (*value) /= *operand; - return; + break; default: ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); - return; + break; } return; } @@ -601,15 +601,15 @@ static void orte_dss_arith_uint32(uint32_t *value, uint32_t *operand, orte_dss_a switch(operation) { case ORTE_DSS_ADD: (*value) += *operand; - return; + break; case ORTE_DSS_SUB: (*value) -= *operand; - return; + break; case ORTE_DSS_MUL: (*value) *= *operand; - return; + break; case ORTE_DSS_DIV: if (0 == *operand) { @@ -617,11 +617,11 @@ static void orte_dss_arith_uint32(uint32_t *value, uint32_t *operand, orte_dss_a return; } (*value) /= *operand; - return; + break; default: ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); - return; + break; } return; } @@ -631,15 +631,15 @@ static void orte_dss_arith_int64(int64_t *value, int64_t *operand, orte_dss_arit switch(operation) { case ORTE_DSS_ADD: (*value) += *operand; - return; + break; case ORTE_DSS_SUB: (*value) -= *operand; - return; + break; case ORTE_DSS_MUL: (*value) *= *operand; - return; + break; case ORTE_DSS_DIV: if (0 == *operand) { @@ -647,11 +647,11 @@ static void orte_dss_arith_int64(int64_t *value, int64_t *operand, orte_dss_arit return; } (*value) /= *operand; - return; + break; default: ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); - return; + break; } return; } @@ -661,15 +661,15 @@ static void orte_dss_arith_uint64(uint64_t *value, uint64_t *operand, orte_dss_a switch(operation) { case ORTE_DSS_ADD: (*value) += *operand; - return; + break; case ORTE_DSS_SUB: (*value) -= *operand; - return; + break; case ORTE_DSS_MUL: (*value) *= *operand; - return; + break; case ORTE_DSS_DIV: if (0 == *operand) { @@ -677,11 +677,11 @@ static void orte_dss_arith_uint64(uint64_t *value, uint64_t *operand, orte_dss_a return; } (*value) /= *operand; - return; + break; default: ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); - return; + break; } return; } @@ -691,15 +691,15 @@ static void orte_dss_arith_data_type(orte_data_type_t *value, orte_data_type_t * switch(operation) { case ORTE_DSS_ADD: (*value) += *operand; - return; + break; case ORTE_DSS_SUB: (*value) -= *operand; - return; + break; case ORTE_DSS_MUL: (*value) *= *operand; - return; + break; case ORTE_DSS_DIV: if (0 == *operand) { @@ -707,11 +707,11 @@ static void orte_dss_arith_data_type(orte_data_type_t *value, orte_data_type_t * return; } (*value) /= *operand; - return; + break; default: ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); - return; + break; } return; } @@ -721,15 +721,15 @@ static void orte_dss_arith_daemon_cmd(orte_daemon_cmd_flag_t *value, orte_daemon switch(operation) { case ORTE_DSS_ADD: (*value) += *operand; - return; + break; case ORTE_DSS_SUB: (*value) -= *operand; - return; + break; case ORTE_DSS_MUL: (*value) *= *operand; - return; + break; case ORTE_DSS_DIV: if (0 == *operand) { @@ -737,11 +737,11 @@ static void orte_dss_arith_daemon_cmd(orte_daemon_cmd_flag_t *value, orte_daemon return; } (*value) /= *operand; - return; + break; default: ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); - return; + break; } return; } diff --git a/orte/mca/gpr/base/gpr_base_create_value_keyval.c b/orte/mca/gpr/base/gpr_base_create_value_keyval.c index d020a163c7..2615266e92 100755 --- a/orte/mca/gpr/base/gpr_base_create_value_keyval.c +++ b/orte/mca/gpr/base/gpr_base_create_value_keyval.c @@ -1,125 +1,125 @@ -/* -*- C -*- - * - * 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 (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$ - */ -/** @file - * - */ - -#include "orte_config.h" -#include "orte/orte_constants.h" - -#include "opal/util/output.h" -#include "opal/util/trace.h" - -#include "orte/dss/dss.h" -#include "orte/mca/errmgr/errmgr.h" - -#include "orte/mca/gpr/base/base.h" - - -int orte_gpr_base_create_value(orte_gpr_value_t **value, - orte_gpr_addr_mode_t addr_mode, - char *segment, - size_t cnt, /**< Number of keyval objects */ - size_t num_tokens) -{ - orte_gpr_value_t *val; - - OPAL_TRACE(1); - - *value = OBJ_NEW(orte_gpr_value_t); - if (NULL == *value) { - ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); - return ORTE_ERR_OUT_OF_RESOURCE; - } - val = *value; - - /* get space for the specified number of keyvals */ - if (0 < cnt) { - val->keyvals = (orte_gpr_keyval_t**)malloc(cnt * sizeof(orte_gpr_keyval_t*)); - if (NULL == val->keyvals) { - ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); - OBJ_RELEASE(val); - return ORTE_ERR_OUT_OF_RESOURCE; - } - } - - /* get space for the specified number of tokens */ - if (0 < num_tokens) { - val->tokens = (char**)malloc(num_tokens * sizeof(char*)); - if (NULL == val->tokens) { - ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); - OBJ_RELEASE(val); - return ORTE_ERR_OUT_OF_RESOURCE; - } - } - - val->addr_mode = addr_mode; - if (NULL != segment) { - val->segment = strdup(segment); - } - val->cnt = cnt; - val->num_tokens = num_tokens; - - return ORTE_SUCCESS; -} - - -int orte_gpr_base_create_keyval(orte_gpr_keyval_t **keyval, - char *key, - orte_data_type_t type, - void *data) -{ - orte_gpr_keyval_t *kv; - int rc; - - OPAL_TRACE(1); - - *keyval = OBJ_NEW(orte_gpr_keyval_t); - if (NULL == *keyval) { - ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); - return ORTE_ERR_OUT_OF_RESOURCE; - } - kv = *keyval; - - /* if the type is ORTE_UNDEF, then we don't actually want to create a data_value. This - * is the case, for example, when we are doing subscriptions as the keyval is used simply - * to transmit the key - the data_value field must remain NULL - */ - if (ORTE_UNDEF != type) { - kv->value = OBJ_NEW(orte_data_value_t); - if (NULL == kv->value) { - ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); - OBJ_RELEASE(kv); - return ORTE_ERR_OUT_OF_RESOURCE; - } - kv->value->type = type; - if (NULL != data) { - if (ORTE_SUCCESS != (rc = orte_dss.copy((void**)&(kv->value->data), data, type))) { - ORTE_ERROR_LOG(rc); - OBJ_RELEASE(kv); - return rc; - } - } - } - - if (NULL != key) { - kv->key = strdup(key); - } - - return ORTE_SUCCESS; -} - +/* -*- C -*- + * + * 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 (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$ + */ +/** @file + * + */ + +#include "orte_config.h" +#include "orte/orte_constants.h" + +#include "opal/util/output.h" +#include "opal/util/trace.h" + +#include "orte/dss/dss.h" +#include "orte/mca/errmgr/errmgr.h" + +#include "orte/mca/gpr/base/base.h" + + +int orte_gpr_base_create_value(orte_gpr_value_t **value, + orte_gpr_addr_mode_t addr_mode, + char *segment, + size_t cnt, /**< Number of keyval objects */ + size_t num_tokens) +{ + orte_gpr_value_t *val; + + OPAL_TRACE(1); + + *value = OBJ_NEW(orte_gpr_value_t); + if (NULL == *value) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + val = *value; + + /* get space for the specified number of keyvals */ + if (0 < cnt) { + val->keyvals = (orte_gpr_keyval_t**)malloc(cnt * sizeof(orte_gpr_keyval_t*)); + if (NULL == val->keyvals) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + OBJ_RELEASE(val); + return ORTE_ERR_OUT_OF_RESOURCE; + } + } + + /* get space for the specified number of tokens */ + if (0 < num_tokens) { + val->tokens = (char**)malloc(num_tokens * sizeof(char*)); + if (NULL == val->tokens) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + OBJ_RELEASE(val); + return ORTE_ERR_OUT_OF_RESOURCE; + } + } + + val->addr_mode = addr_mode; + if (NULL != segment) { + val->segment = strdup(segment); + } + val->cnt = cnt; + val->num_tokens = num_tokens; + + return ORTE_SUCCESS; +} + + +int orte_gpr_base_create_keyval(orte_gpr_keyval_t **keyval, + char *key, + orte_data_type_t type, + void *data) +{ + orte_gpr_keyval_t *kv; + int rc; + + OPAL_TRACE(1); + + *keyval = OBJ_NEW(orte_gpr_keyval_t); + if (NULL == *keyval) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + kv = *keyval; + + /* if the type is ORTE_UNDEF, then we don't actually want to create a data_value. This + * is the case, for example, when we are doing subscriptions as the keyval is used simply + * to transmit the key - the data_value field must remain NULL + */ + if (ORTE_UNDEF != type) { + kv->value = OBJ_NEW(orte_data_value_t); + if (NULL == kv->value) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + OBJ_RELEASE(kv); + return ORTE_ERR_OUT_OF_RESOURCE; + } + kv->value->type = type; + if (NULL != data) { + if (ORTE_SUCCESS != (rc = orte_dss.copy((void**)&(kv->value->data), data, type))) { + ORTE_ERROR_LOG(rc); + OBJ_RELEASE(kv); + return rc; + } + } + } + + if (NULL != key) { + kv->key = strdup(key); + } + + return ORTE_SUCCESS; +} + diff --git a/orte/mca/gpr/base/gpr_base_simplified_put.c b/orte/mca/gpr/base/gpr_base_simplified_put.c index 1699060404..c6e2b9acbb 100644 --- a/orte/mca/gpr/base/gpr_base_simplified_put.c +++ b/orte/mca/gpr/base/gpr_base_simplified_put.c @@ -1,127 +1,127 @@ -/* -*- C -*- - * - * 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 (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$ - */ -/** @file - * - */ - -#include "orte_config.h" -#include "orte/orte_constants.h" - -#include "opal/util/output.h" -#include "opal/util/trace.h" - -#include "orte/dss/dss.h" -#include "orte/mca/errmgr/errmgr.h" - -#include "orte/mca/gpr/base/base.h" - - -int orte_gpr_base_put_1(orte_gpr_addr_mode_t addr_mode, - char *segment, char **tokens, - char *key, orte_data_value_t *data_value) -{ - orte_gpr_value_t *values; - orte_gpr_value_t value = ORTE_GPR_VALUE_EMPTY; - orte_gpr_keyval_t *keyvals; - orte_gpr_keyval_t keyval = ORTE_GPR_KEYVAL_EMPTY; - orte_data_value_t dval = ORTE_DATA_VALUE_EMPTY; - size_t i; - int rc; - - OPAL_TRACE(1); - - value.addr_mode = addr_mode; - value.segment = segment; - value.cnt = 1; - keyvals = &keyval; - value.keyvals = &keyvals; - keyval.key = key; - keyval.value = &dval; - dval.type = data_value->type; - if (ORTE_SUCCESS != (rc = orte_dss.set(&dval, data_value->data, data_value->type))) { - ORTE_ERROR_LOG(rc); - return rc; - } - - value.tokens = tokens; - /* must count the number of tokens */ - value.num_tokens = 0; - if (NULL != tokens) { - for (i=0; NULL != tokens[i]; i++) { - (value.num_tokens)++; - } - } - values = &value; - - /* put the value on the registry */ - if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &values))) { - ORTE_ERROR_LOG(rc); - return rc; - } - - /* no memory to clean up since we didn't allocate any */ - return ORTE_SUCCESS; -} - - -int orte_gpr_base_put_N(orte_gpr_addr_mode_t addr_mode, - char *segment, char **tokens, - size_t n, char **keys, - orte_data_value_t **data_values) -{ - orte_gpr_value_t *value; - size_t i, num_tokens; - int rc; - - OPAL_TRACE(1); - - /* must count the number of tokens */ - num_tokens = 0; - if (NULL != tokens) { - for (i=0; NULL != tokens[i]; i++) { - num_tokens++; - } - } - - if (ORTE_SUCCESS != (rc = orte_gpr_base_create_value(&value, addr_mode, segment, n, num_tokens))) { - ORTE_ERROR_LOG(rc); - return rc; - } - - for (i=0; i < n; i++) { - if (ORTE_SUCCESS != (rc = orte_gpr_base_create_keyval(&(value->keyvals[i]), keys[i], data_values[i]->type, data_values[i]->data))) { - ORTE_ERROR_LOG(rc); - OBJ_RELEASE(value); - return rc; - } - } - - for (i=0; i < value->num_tokens; i++) { - value->tokens[i] = strdup(tokens[i]); - } - - /* put the value on the registry */ - if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &value))) { - ORTE_ERROR_LOG(rc); - } - - /* clean up memory */ - OBJ_RELEASE(value); - - return rc; -} - +/* -*- C -*- + * + * 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 (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$ + */ +/** @file + * + */ + +#include "orte_config.h" +#include "orte/orte_constants.h" + +#include "opal/util/output.h" +#include "opal/util/trace.h" + +#include "orte/dss/dss.h" +#include "orte/mca/errmgr/errmgr.h" + +#include "orte/mca/gpr/base/base.h" + + +int orte_gpr_base_put_1(orte_gpr_addr_mode_t addr_mode, + char *segment, char **tokens, + char *key, orte_data_value_t *data_value) +{ + orte_gpr_value_t *values; + orte_gpr_value_t value = ORTE_GPR_VALUE_EMPTY; + orte_gpr_keyval_t *keyvals; + orte_gpr_keyval_t keyval = ORTE_GPR_KEYVAL_EMPTY; + orte_data_value_t dval = ORTE_DATA_VALUE_EMPTY; + size_t i; + int rc; + + OPAL_TRACE(1); + + value.addr_mode = addr_mode; + value.segment = segment; + value.cnt = 1; + keyvals = &keyval; + value.keyvals = &keyvals; + keyval.key = key; + keyval.value = &dval; + dval.type = data_value->type; + if (ORTE_SUCCESS != (rc = orte_dss.set(&dval, data_value->data, data_value->type))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + value.tokens = tokens; + /* must count the number of tokens */ + value.num_tokens = 0; + if (NULL != tokens) { + for (i=0; NULL != tokens[i]; i++) { + (value.num_tokens)++; + } + } + values = &value; + + /* put the value on the registry */ + if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &values))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + /* no memory to clean up since we didn't allocate any */ + return ORTE_SUCCESS; +} + + +int orte_gpr_base_put_N(orte_gpr_addr_mode_t addr_mode, + char *segment, char **tokens, + size_t n, char **keys, + orte_data_value_t **data_values) +{ + orte_gpr_value_t *value; + size_t i, num_tokens; + int rc; + + OPAL_TRACE(1); + + /* must count the number of tokens */ + num_tokens = 0; + if (NULL != tokens) { + for (i=0; NULL != tokens[i]; i++) { + num_tokens++; + } + } + + if (ORTE_SUCCESS != (rc = orte_gpr_base_create_value(&value, addr_mode, segment, n, num_tokens))) { + ORTE_ERROR_LOG(rc); + return rc; + } + + for (i=0; i < n; i++) { + if (ORTE_SUCCESS != (rc = orte_gpr_base_create_keyval(&(value->keyvals[i]), keys[i], data_values[i]->type, data_values[i]->data))) { + ORTE_ERROR_LOG(rc); + OBJ_RELEASE(value); + return rc; + } + } + + for (i=0; i < value->num_tokens; i++) { + value->tokens[i] = strdup(tokens[i]); + } + + /* put the value on the registry */ + if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &value))) { + ORTE_ERROR_LOG(rc); + } + + /* clean up memory */ + OBJ_RELEASE(value); + + return rc; +} + diff --git a/orte/mca/gpr/base/gpr_base_simplified_subscribe.c b/orte/mca/gpr/base/gpr_base_simplified_subscribe.c index e1c7cef041..c4b291375b 100644 --- a/orte/mca/gpr/base/gpr_base_simplified_subscribe.c +++ b/orte/mca/gpr/base/gpr_base_simplified_subscribe.c @@ -1,377 +1,377 @@ -/* -*- C -*- - * - * 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 (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$ - */ -/** @file - * - */ - -#include "orte_config.h" -#include "orte/orte_constants.h" - -#include "opal/util/output.h" -#include "opal/util/trace.h" - -#include "orte/dss/dss.h" -#include "orte/mca/errmgr/errmgr.h" - -#include "orte/mca/gpr/base/base.h" - -int orte_gpr_base_subscribe_1(orte_gpr_subscription_id_t *id, - char *trig_name, - char *sub_name, - orte_gpr_notify_action_t action, - orte_gpr_addr_mode_t addr_mode, - char *segment, - char **tokens, - char *key, - orte_gpr_notify_cb_fn_t cbfunc, - void *user_tag) -{ - orte_gpr_value_t *values; - orte_gpr_keyval_t *keyvals; - orte_gpr_keyval_t keyval = ORTE_GPR_KEYVAL_EMPTY; - orte_gpr_value_t value = ORTE_GPR_VALUE_EMPTY; - orte_gpr_subscription_t *subs; - orte_gpr_subscription_t sub = ORTE_GPR_SUBSCRIPTION_EMPTY; - orte_gpr_trigger_t *trigs; - orte_gpr_trigger_t trig = ORTE_GPR_TRIGGER_EMPTY; - size_t i; - int rc; - - OPAL_TRACE(1); - - /* assemble the subscription object */ - subs = ⊂ - sub.name = sub_name; - sub.action = action; - sub.cnt = 1; - values = &value; - sub.values = &values; - sub.cbfunc = cbfunc; - sub.user_tag = user_tag; - - value.addr_mode = addr_mode; - value.segment = segment; - value.cnt = 1; - keyvals = &keyval; - value.keyvals = &keyvals; - - value.tokens = tokens; - /* must count the number of tokens */ - value.num_tokens = 0; - if (NULL != tokens) { - for (i=0; NULL != tokens[i]; i++) { - (value.num_tokens)++; - } - } - - keyval.key = key; - - /* send the subscription */ - if (NULL == trig_name) { /* no trigger provided */ - if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(1, &subs, 0, NULL))) { - ORTE_ERROR_LOG(rc); - } - - } else { - trigs = &trig; - trig.name = trig_name; - if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(1, &subs, 1, &trigs))) { - ORTE_ERROR_LOG(rc); - } - - } - - /* no memory to cleanup since we didn't allocate anything */ - - /* return the subscription id */ - *id = sub.id; - - return rc; -} - - -int orte_gpr_base_subscribe_N(orte_gpr_subscription_id_t *id, - char *trig_name, - char *sub_name, - orte_gpr_notify_action_t action, - orte_gpr_addr_mode_t addr_mode, - char *segment, - char **tokens, - size_t n, - char **keys, - orte_gpr_notify_cb_fn_t cbfunc, - void *user_tag) -{ - orte_gpr_subscription_t *sub; - orte_gpr_trigger_t *trig; - size_t i, num_tokens; - int rc; - - OPAL_TRACE(1); - - /* assemble the subscription object */ - sub = OBJ_NEW(orte_gpr_subscription_t); - if (NULL == sub) { - ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); - return ORTE_ERR_OUT_OF_RESOURCE; - } - if (NULL != sub_name) { - sub->name = strdup(sub_name); - } - sub->action = action; - sub->cnt = 1; - sub->cbfunc = cbfunc; - sub->user_tag = user_tag; - - /* must count the number of tokens */ - num_tokens = 0; - if (NULL != tokens) { - for (i=0; NULL != tokens[i]; i++) { - num_tokens++; - } - } - - /* create the value object */ - sub->values = (orte_gpr_value_t**)malloc(sizeof(orte_gpr_value_t*)); - if (NULL == sub->values) { - ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); - OBJ_RELEASE(sub); - return ORTE_ERR_OUT_OF_RESOURCE; - } - if (ORTE_SUCCESS != (rc = orte_gpr_base_create_value(&(sub->values[0]), addr_mode, segment, n, num_tokens))) { - ORTE_ERROR_LOG(rc); - OBJ_RELEASE(sub); - return rc; - } - - for (i=0; i < n; i++) { - if (ORTE_SUCCESS != (rc = orte_gpr_base_create_keyval(&(sub->values[0]->keyvals[i]), keys[i], ORTE_UNDEF, NULL))) { - ORTE_ERROR_LOG(rc); - OBJ_RELEASE(sub); - return rc; - } - } - - /* copy the tokens */ - for (i=0; i < sub->values[0]->num_tokens; i++) { - sub->values[0]->tokens[i] = strdup(tokens[i]); - } - - /* send the subscription */ - if (NULL == trig_name) { /* no trigger provided */ - if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(1, &sub, 0, NULL))) { - ORTE_ERROR_LOG(rc); - } - - } else { - trig = OBJ_NEW(orte_gpr_trigger_t); - if (NULL == trig) { - ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); - OBJ_RELEASE(sub); - return ORTE_ERR_OUT_OF_RESOURCE; - } - trig->name = strdup(trig_name); - if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(1, &sub, 1, &trig))) { - ORTE_ERROR_LOG(rc); - } - OBJ_RELEASE(trig); - } - - /* return the subscription id */ - *id = sub->id; - - /* clean up memory */ - OBJ_RELEASE(sub); - - return rc; -} - - -int orte_gpr_base_define_trigger(orte_gpr_trigger_id_t *id, - char *trig_name, - orte_gpr_trigger_action_t action, - orte_gpr_addr_mode_t addr_mode, - char *segment, - char **tokens, - size_t n, - char **keys, - orte_gpr_trigger_cb_fn_t cbfunc, - void *user_tag) -{ - orte_gpr_trigger_t *trig; - size_t i, num_tokens; - int rc; - - OPAL_TRACE(1); - - /* check for error - this function can only be used to define triggers - * that compare their values to each other. It cannot be used to define - * triggers that fire when reaching a specified value as there is no - * way to specify a trigger level within this API - */ - if (ORTE_GPR_TRIG_AT_LEVEL & action) { - ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); - return ORTE_ERR_BAD_PARAM; - } - - /* assemble the trigger object */ - trig = OBJ_NEW(orte_gpr_trigger_t); - if (NULL == trig) { - ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); - return ORTE_ERR_OUT_OF_RESOURCE; - } - if (NULL != trig_name) { - trig->name = strdup(trig_name); - } - trig->action = action; - trig->cnt = 1; - trig->cbfunc = cbfunc; - trig->user_tag = user_tag; - - /* must count the number of tokens */ - num_tokens = 0; - if (NULL != tokens) { - for (i=0; NULL != tokens[i]; i++) { - num_tokens++; - } - } - - /* create the value object */ - trig->values = (orte_gpr_value_t**)malloc(sizeof(orte_gpr_value_t*)); - if (NULL == trig->values) { - ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); - return ORTE_ERR_OUT_OF_RESOURCE; - } - if (ORTE_SUCCESS != (rc = orte_gpr_base_create_value(&(trig->values[0]), addr_mode, segment, n, num_tokens))) { - ORTE_ERROR_LOG(rc); - OBJ_RELEASE(trig); - return rc; - } - - for (i=0; i < n; i++) { - if (ORTE_SUCCESS != (rc = orte_gpr_base_create_keyval(&(trig->values[0]->keyvals[i]), keys[i], ORTE_UNDEF, NULL))) { - ORTE_ERROR_LOG(rc); - OBJ_RELEASE(trig); - return rc; - } - } - - for (i=0; i < trig->values[0]->num_tokens; i++) { - trig->values[0]->tokens[i] = strdup(tokens[i]); - } - - /* send the subscription */ - if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(0, NULL, 1, &trig))) { - ORTE_ERROR_LOG(rc); - } - - /* return the subscription id */ - *id = trig->id; - - /* clean up memory */ - OBJ_RELEASE(trig); - - return rc; -} - -int orte_gpr_base_define_trigger_level(orte_gpr_trigger_id_t *id, - char *trig_name, - orte_gpr_trigger_action_t action, - orte_gpr_addr_mode_t addr_mode, - char *segment, - char **tokens, - size_t n, - char **keys, - size_t *levels, - orte_gpr_trigger_cb_fn_t cbfunc, - void *user_tag) -{ - orte_gpr_trigger_t *trig; - size_t i, num_tokens; - int rc; - - OPAL_TRACE(1); - - /* check for error - this function can only be used to define triggers - * that fire at a specified level. It cannot be used to define - * triggers that compare their values to each other - */ - if (ORTE_GPR_TRIG_CMP_LEVELS & action || NULL == trig_name) { - ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); - return ORTE_ERR_BAD_PARAM; - } - - /* assemble the trigger object */ - trig = OBJ_NEW(orte_gpr_trigger_t); - if (NULL == trig) { - ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); - return ORTE_ERR_OUT_OF_RESOURCE; - } - - if (NULL != trig_name) { - trig->name = strdup(trig_name); - } - trig->action = action; - trig->cnt = 1; - trig->cbfunc = cbfunc; - trig->user_tag = user_tag; - - /* must count the number of tokens */ - num_tokens = 0; - if (NULL != tokens) { - for (i=0; NULL != tokens[i]; i++) { - num_tokens++; - } - } - - /* create the value object */ - trig->values = (orte_gpr_value_t**)malloc(sizeof(orte_gpr_value_t*)); - if (NULL == trig->values) { - ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); - return ORTE_ERR_OUT_OF_RESOURCE; - } - if (ORTE_SUCCESS != (rc = orte_gpr_base_create_value(&(trig->values[0]), addr_mode, segment, n, num_tokens))) { - ORTE_ERROR_LOG(rc); - OBJ_RELEASE(trig); - return rc; - } - - for (i=0; i < n; i++) { - if (ORTE_SUCCESS != (rc = orte_gpr_base_create_keyval(&(trig->values[0]->keyvals[i]), keys[i], ORTE_SIZE, &(levels[i])))) { - ORTE_ERROR_LOG(rc); - OBJ_RELEASE(trig); - return rc; - } - } - - for (i=0; i < trig->values[0]->num_tokens; i++) { - trig->values[0]->tokens[i] = strdup(tokens[i]); - } - - /* send the subscription */ - if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(0, NULL, 1, &trig))) { - ORTE_ERROR_LOG(rc); - } - - /* return the subscription id */ - *id = trig->id; - - /* clean up memory */ - OBJ_RELEASE(trig); - - return rc; -} +/* -*- C -*- + * + * 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 (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$ + */ +/** @file + * + */ + +#include "orte_config.h" +#include "orte/orte_constants.h" + +#include "opal/util/output.h" +#include "opal/util/trace.h" + +#include "orte/dss/dss.h" +#include "orte/mca/errmgr/errmgr.h" + +#include "orte/mca/gpr/base/base.h" + +int orte_gpr_base_subscribe_1(orte_gpr_subscription_id_t *id, + char *trig_name, + char *sub_name, + orte_gpr_notify_action_t action, + orte_gpr_addr_mode_t addr_mode, + char *segment, + char **tokens, + char *key, + orte_gpr_notify_cb_fn_t cbfunc, + void *user_tag) +{ + orte_gpr_value_t *values; + orte_gpr_keyval_t *keyvals; + orte_gpr_keyval_t keyval = ORTE_GPR_KEYVAL_EMPTY; + orte_gpr_value_t value = ORTE_GPR_VALUE_EMPTY; + orte_gpr_subscription_t *subs; + orte_gpr_subscription_t sub = ORTE_GPR_SUBSCRIPTION_EMPTY; + orte_gpr_trigger_t *trigs; + orte_gpr_trigger_t trig = ORTE_GPR_TRIGGER_EMPTY; + size_t i; + int rc; + + OPAL_TRACE(1); + + /* assemble the subscription object */ + subs = ⊂ + sub.name = sub_name; + sub.action = action; + sub.cnt = 1; + values = &value; + sub.values = &values; + sub.cbfunc = cbfunc; + sub.user_tag = user_tag; + + value.addr_mode = addr_mode; + value.segment = segment; + value.cnt = 1; + keyvals = &keyval; + value.keyvals = &keyvals; + + value.tokens = tokens; + /* must count the number of tokens */ + value.num_tokens = 0; + if (NULL != tokens) { + for (i=0; NULL != tokens[i]; i++) { + (value.num_tokens)++; + } + } + + keyval.key = key; + + /* send the subscription */ + if (NULL == trig_name) { /* no trigger provided */ + if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(1, &subs, 0, NULL))) { + ORTE_ERROR_LOG(rc); + } + + } else { + trigs = &trig; + trig.name = trig_name; + if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(1, &subs, 1, &trigs))) { + ORTE_ERROR_LOG(rc); + } + + } + + /* no memory to cleanup since we didn't allocate anything */ + + /* return the subscription id */ + *id = sub.id; + + return rc; +} + + +int orte_gpr_base_subscribe_N(orte_gpr_subscription_id_t *id, + char *trig_name, + char *sub_name, + orte_gpr_notify_action_t action, + orte_gpr_addr_mode_t addr_mode, + char *segment, + char **tokens, + size_t n, + char **keys, + orte_gpr_notify_cb_fn_t cbfunc, + void *user_tag) +{ + orte_gpr_subscription_t *sub; + orte_gpr_trigger_t *trig; + size_t i, num_tokens; + int rc; + + OPAL_TRACE(1); + + /* assemble the subscription object */ + sub = OBJ_NEW(orte_gpr_subscription_t); + if (NULL == sub) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + if (NULL != sub_name) { + sub->name = strdup(sub_name); + } + sub->action = action; + sub->cnt = 1; + sub->cbfunc = cbfunc; + sub->user_tag = user_tag; + + /* must count the number of tokens */ + num_tokens = 0; + if (NULL != tokens) { + for (i=0; NULL != tokens[i]; i++) { + num_tokens++; + } + } + + /* create the value object */ + sub->values = (orte_gpr_value_t**)malloc(sizeof(orte_gpr_value_t*)); + if (NULL == sub->values) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + OBJ_RELEASE(sub); + return ORTE_ERR_OUT_OF_RESOURCE; + } + if (ORTE_SUCCESS != (rc = orte_gpr_base_create_value(&(sub->values[0]), addr_mode, segment, n, num_tokens))) { + ORTE_ERROR_LOG(rc); + OBJ_RELEASE(sub); + return rc; + } + + for (i=0; i < n; i++) { + if (ORTE_SUCCESS != (rc = orte_gpr_base_create_keyval(&(sub->values[0]->keyvals[i]), keys[i], ORTE_UNDEF, NULL))) { + ORTE_ERROR_LOG(rc); + OBJ_RELEASE(sub); + return rc; + } + } + + /* copy the tokens */ + for (i=0; i < sub->values[0]->num_tokens; i++) { + sub->values[0]->tokens[i] = strdup(tokens[i]); + } + + /* send the subscription */ + if (NULL == trig_name) { /* no trigger provided */ + if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(1, &sub, 0, NULL))) { + ORTE_ERROR_LOG(rc); + } + + } else { + trig = OBJ_NEW(orte_gpr_trigger_t); + if (NULL == trig) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + OBJ_RELEASE(sub); + return ORTE_ERR_OUT_OF_RESOURCE; + } + trig->name = strdup(trig_name); + if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(1, &sub, 1, &trig))) { + ORTE_ERROR_LOG(rc); + } + OBJ_RELEASE(trig); + } + + /* return the subscription id */ + *id = sub->id; + + /* clean up memory */ + OBJ_RELEASE(sub); + + return rc; +} + + +int orte_gpr_base_define_trigger(orte_gpr_trigger_id_t *id, + char *trig_name, + orte_gpr_trigger_action_t action, + orte_gpr_addr_mode_t addr_mode, + char *segment, + char **tokens, + size_t n, + char **keys, + orte_gpr_trigger_cb_fn_t cbfunc, + void *user_tag) +{ + orte_gpr_trigger_t *trig; + size_t i, num_tokens; + int rc; + + OPAL_TRACE(1); + + /* check for error - this function can only be used to define triggers + * that compare their values to each other. It cannot be used to define + * triggers that fire when reaching a specified value as there is no + * way to specify a trigger level within this API + */ + if (ORTE_GPR_TRIG_AT_LEVEL & action) { + ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); + return ORTE_ERR_BAD_PARAM; + } + + /* assemble the trigger object */ + trig = OBJ_NEW(orte_gpr_trigger_t); + if (NULL == trig) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + if (NULL != trig_name) { + trig->name = strdup(trig_name); + } + trig->action = action; + trig->cnt = 1; + trig->cbfunc = cbfunc; + trig->user_tag = user_tag; + + /* must count the number of tokens */ + num_tokens = 0; + if (NULL != tokens) { + for (i=0; NULL != tokens[i]; i++) { + num_tokens++; + } + } + + /* create the value object */ + trig->values = (orte_gpr_value_t**)malloc(sizeof(orte_gpr_value_t*)); + if (NULL == trig->values) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + if (ORTE_SUCCESS != (rc = orte_gpr_base_create_value(&(trig->values[0]), addr_mode, segment, n, num_tokens))) { + ORTE_ERROR_LOG(rc); + OBJ_RELEASE(trig); + return rc; + } + + for (i=0; i < n; i++) { + if (ORTE_SUCCESS != (rc = orte_gpr_base_create_keyval(&(trig->values[0]->keyvals[i]), keys[i], ORTE_UNDEF, NULL))) { + ORTE_ERROR_LOG(rc); + OBJ_RELEASE(trig); + return rc; + } + } + + for (i=0; i < trig->values[0]->num_tokens; i++) { + trig->values[0]->tokens[i] = strdup(tokens[i]); + } + + /* send the subscription */ + if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(0, NULL, 1, &trig))) { + ORTE_ERROR_LOG(rc); + } + + /* return the subscription id */ + *id = trig->id; + + /* clean up memory */ + OBJ_RELEASE(trig); + + return rc; +} + +int orte_gpr_base_define_trigger_level(orte_gpr_trigger_id_t *id, + char *trig_name, + orte_gpr_trigger_action_t action, + orte_gpr_addr_mode_t addr_mode, + char *segment, + char **tokens, + size_t n, + char **keys, + size_t *levels, + orte_gpr_trigger_cb_fn_t cbfunc, + void *user_tag) +{ + orte_gpr_trigger_t *trig; + size_t i, num_tokens; + int rc; + + OPAL_TRACE(1); + + /* check for error - this function can only be used to define triggers + * that fire at a specified level. It cannot be used to define + * triggers that compare their values to each other + */ + if (ORTE_GPR_TRIG_CMP_LEVELS & action || NULL == trig_name) { + ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); + return ORTE_ERR_BAD_PARAM; + } + + /* assemble the trigger object */ + trig = OBJ_NEW(orte_gpr_trigger_t); + if (NULL == trig) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + + if (NULL != trig_name) { + trig->name = strdup(trig_name); + } + trig->action = action; + trig->cnt = 1; + trig->cbfunc = cbfunc; + trig->user_tag = user_tag; + + /* must count the number of tokens */ + num_tokens = 0; + if (NULL != tokens) { + for (i=0; NULL != tokens[i]; i++) { + num_tokens++; + } + } + + /* create the value object */ + trig->values = (orte_gpr_value_t**)malloc(sizeof(orte_gpr_value_t*)); + if (NULL == trig->values) { + ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); + return ORTE_ERR_OUT_OF_RESOURCE; + } + if (ORTE_SUCCESS != (rc = orte_gpr_base_create_value(&(trig->values[0]), addr_mode, segment, n, num_tokens))) { + ORTE_ERROR_LOG(rc); + OBJ_RELEASE(trig); + return rc; + } + + for (i=0; i < n; i++) { + if (ORTE_SUCCESS != (rc = orte_gpr_base_create_keyval(&(trig->values[0]->keyvals[i]), keys[i], ORTE_SIZE, &(levels[i])))) { + ORTE_ERROR_LOG(rc); + OBJ_RELEASE(trig); + return rc; + } + } + + for (i=0; i < trig->values[0]->num_tokens; i++) { + trig->values[0]->tokens[i] = strdup(tokens[i]); + } + + /* send the subscription */ + if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(0, NULL, 1, &trig))) { + ORTE_ERROR_LOG(rc); + } + + /* return the subscription id */ + *id = trig->id; + + /* clean up memory */ + OBJ_RELEASE(trig); + + return rc; +} diff --git a/orte/mca/ns/ns_types.h b/orte/mca/ns/ns_types.h index 4ba6888cf5..4ad7433d46 100644 --- a/orte/mca/ns/ns_types.h +++ b/orte/mca/ns/ns_types.h @@ -82,9 +82,9 @@ typedef struct orte_process_name_t orte_process_name_t; /* * define maximum value for id's in any field */ -#define ORTE_CELLID_MAX ((orte_cellid_t)(1 << 31)) -#define ORTE_JOBID_MAX ((orte_jobid_t)(1 << 31)) -#define ORTE_VPID_MAX ((orte_vpid_t)(1 << 31)) +#define ORTE_CELLID_MAX ((orte_cellid_t)(1UL << 31)) +#define ORTE_JOBID_MAX ((orte_jobid_t)(1UL << 31)) +#define ORTE_VPID_MAX ((orte_vpid_t)(1UL << 31)) extern orte_process_name_t orte_name_all; #define ORTE_NAME_ALL &orte_name_all