1
1

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.
Этот коммит содержится в:
Brian Barrett 2006-04-20 15:35:58 +00:00
родитель c31a5ad4b3
Коммит e737b0a106
5 изменённых файлов: 702 добавлений и 702 удалений

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

@ -331,15 +331,15 @@ static void orte_dss_arith_int(int *value, int *operand, orte_dss_arith_op_t ope
switch(operation) { switch(operation) {
case ORTE_DSS_ADD: case ORTE_DSS_ADD:
(*value) += *operand; (*value) += *operand;
return; break;
case ORTE_DSS_SUB: case ORTE_DSS_SUB:
(*value) -= *operand; (*value) -= *operand;
return; break;
case ORTE_DSS_MUL: case ORTE_DSS_MUL:
(*value) *= *operand; (*value) *= *operand;
return; break;
case ORTE_DSS_DIV: case ORTE_DSS_DIV:
if (0 == *operand) { if (0 == *operand) {
@ -347,11 +347,11 @@ static void orte_dss_arith_int(int *value, int *operand, orte_dss_arith_op_t ope
return; return;
} }
(*value) /= *operand; (*value) /= *operand;
return; break;
default: default:
ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED);
return; break;
} }
return; return;
} }
@ -361,15 +361,15 @@ static void orte_dss_arith_uint(uint *value, uint *operand, orte_dss_arith_op_t
switch(operation) { switch(operation) {
case ORTE_DSS_ADD: case ORTE_DSS_ADD:
(*value) += *operand; (*value) += *operand;
return; break;
case ORTE_DSS_SUB: case ORTE_DSS_SUB:
(*value) -= *operand; (*value) -= *operand;
return; break;
case ORTE_DSS_MUL: case ORTE_DSS_MUL:
(*value) *= *operand; (*value) *= *operand;
return; break;
case ORTE_DSS_DIV: case ORTE_DSS_DIV:
if (0 == *operand) { if (0 == *operand) {
@ -377,11 +377,11 @@ static void orte_dss_arith_uint(uint *value, uint *operand, orte_dss_arith_op_t
return; return;
} }
(*value) /= *operand; (*value) /= *operand;
return; break;
default: default:
ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED);
return; break;
} }
return; return;
} }
@ -391,15 +391,15 @@ static void orte_dss_arith_size(size_t *value, size_t *operand, orte_dss_arith_o
switch(operation) { switch(operation) {
case ORTE_DSS_ADD: case ORTE_DSS_ADD:
(*value) += *operand; (*value) += *operand;
return; break;
case ORTE_DSS_SUB: case ORTE_DSS_SUB:
(*value) -= *operand; (*value) -= *operand;
return; break;
case ORTE_DSS_MUL: case ORTE_DSS_MUL:
(*value) *= *operand; (*value) *= *operand;
return; break;
case ORTE_DSS_DIV: case ORTE_DSS_DIV:
if (0 == *operand) { if (0 == *operand) {
@ -407,11 +407,11 @@ static void orte_dss_arith_size(size_t *value, size_t *operand, orte_dss_arith_o
return; return;
} }
(*value) /= *operand; (*value) /= *operand;
return; break;
default: default:
ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED);
return; break;
} }
return; return;
} }
@ -421,15 +421,15 @@ static void orte_dss_arith_pid(pid_t *value, pid_t *operand, orte_dss_arith_op_t
switch(operation) { switch(operation) {
case ORTE_DSS_ADD: case ORTE_DSS_ADD:
(*value) += *operand; (*value) += *operand;
return; break;
case ORTE_DSS_SUB: case ORTE_DSS_SUB:
(*value) -= *operand; (*value) -= *operand;
return; break;
case ORTE_DSS_MUL: case ORTE_DSS_MUL:
(*value) *= *operand; (*value) *= *operand;
return; break;
case ORTE_DSS_DIV: case ORTE_DSS_DIV:
if (0 == *operand) { 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; return;
} }
(*value) /= *operand; (*value) /= *operand;
return; break;
default: default:
ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED);
return; break;
} }
return; return;
} }
@ -451,15 +451,15 @@ static void orte_dss_arith_byte(uint8_t *value, uint8_t *operand, orte_dss_arith
switch(operation) { switch(operation) {
case ORTE_DSS_ADD: case ORTE_DSS_ADD:
(*value) += *operand; (*value) += *operand;
return; break;
case ORTE_DSS_SUB: case ORTE_DSS_SUB:
(*value) -= *operand; (*value) -= *operand;
return; break;
case ORTE_DSS_MUL: case ORTE_DSS_MUL:
(*value) *= *operand; (*value) *= *operand;
return; break;
case ORTE_DSS_DIV: case ORTE_DSS_DIV:
if (0 == *operand) { if (0 == *operand) {
@ -467,11 +467,11 @@ static void orte_dss_arith_byte(uint8_t *value, uint8_t *operand, orte_dss_arith
return; return;
} }
(*value) /= *operand; (*value) /= *operand;
return; break;
default: default:
ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED);
return; break;
} }
return; return;
} }
@ -481,15 +481,15 @@ static void orte_dss_arith_int8(int8_t *value, int8_t *operand, orte_dss_arith_o
switch(operation) { switch(operation) {
case ORTE_DSS_ADD: case ORTE_DSS_ADD:
(*value) += *operand; (*value) += *operand;
return; break;
case ORTE_DSS_SUB: case ORTE_DSS_SUB:
(*value) -= *operand; (*value) -= *operand;
return; break;
case ORTE_DSS_MUL: case ORTE_DSS_MUL:
(*value) *= *operand; (*value) *= *operand;
return; break;
case ORTE_DSS_DIV: case ORTE_DSS_DIV:
if (0 == *operand) { if (0 == *operand) {
@ -497,11 +497,11 @@ static void orte_dss_arith_int8(int8_t *value, int8_t *operand, orte_dss_arith_o
return; return;
} }
(*value) /= *operand; (*value) /= *operand;
return; break;
default: default:
ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED);
return; break;
} }
return; return;
} }
@ -511,15 +511,15 @@ static void orte_dss_arith_int16(int16_t *value, int16_t *operand, orte_dss_arit
switch(operation) { switch(operation) {
case ORTE_DSS_ADD: case ORTE_DSS_ADD:
(*value) += *operand; (*value) += *operand;
return; break;
case ORTE_DSS_SUB: case ORTE_DSS_SUB:
(*value) -= *operand; (*value) -= *operand;
return; break;
case ORTE_DSS_MUL: case ORTE_DSS_MUL:
(*value) *= *operand; (*value) *= *operand;
return; break;
case ORTE_DSS_DIV: case ORTE_DSS_DIV:
if (0 == *operand) { if (0 == *operand) {
@ -527,11 +527,11 @@ static void orte_dss_arith_int16(int16_t *value, int16_t *operand, orte_dss_arit
return; return;
} }
(*value) /= *operand; (*value) /= *operand;
return; break;
default: default:
ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED);
return; break;
} }
return; return;
} }
@ -541,15 +541,15 @@ static void orte_dss_arith_uint16(uint16_t *value, uint16_t *operand, orte_dss_a
switch(operation) { switch(operation) {
case ORTE_DSS_ADD: case ORTE_DSS_ADD:
(*value) += *operand; (*value) += *operand;
return; break;
case ORTE_DSS_SUB: case ORTE_DSS_SUB:
(*value) -= *operand; (*value) -= *operand;
return; break;
case ORTE_DSS_MUL: case ORTE_DSS_MUL:
(*value) *= *operand; (*value) *= *operand;
return; break;
case ORTE_DSS_DIV: case ORTE_DSS_DIV:
if (0 == *operand) { if (0 == *operand) {
@ -557,11 +557,11 @@ static void orte_dss_arith_uint16(uint16_t *value, uint16_t *operand, orte_dss_a
return; return;
} }
(*value) /= *operand; (*value) /= *operand;
return; break;
default: default:
ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED);
return; break;
} }
return; return;
} }
@ -571,15 +571,15 @@ static void orte_dss_arith_int32(int32_t *value, int32_t *operand, orte_dss_arit
switch(operation) { switch(operation) {
case ORTE_DSS_ADD: case ORTE_DSS_ADD:
(*value) += *operand; (*value) += *operand;
return; break;
case ORTE_DSS_SUB: case ORTE_DSS_SUB:
(*value) -= *operand; (*value) -= *operand;
return; break;
case ORTE_DSS_MUL: case ORTE_DSS_MUL:
(*value) *= *operand; (*value) *= *operand;
return; break;
case ORTE_DSS_DIV: case ORTE_DSS_DIV:
if (0 == *operand) { if (0 == *operand) {
@ -587,11 +587,11 @@ static void orte_dss_arith_int32(int32_t *value, int32_t *operand, orte_dss_arit
return; return;
} }
(*value) /= *operand; (*value) /= *operand;
return; break;
default: default:
ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED);
return; break;
} }
return; return;
} }
@ -601,15 +601,15 @@ static void orte_dss_arith_uint32(uint32_t *value, uint32_t *operand, orte_dss_a
switch(operation) { switch(operation) {
case ORTE_DSS_ADD: case ORTE_DSS_ADD:
(*value) += *operand; (*value) += *operand;
return; break;
case ORTE_DSS_SUB: case ORTE_DSS_SUB:
(*value) -= *operand; (*value) -= *operand;
return; break;
case ORTE_DSS_MUL: case ORTE_DSS_MUL:
(*value) *= *operand; (*value) *= *operand;
return; break;
case ORTE_DSS_DIV: case ORTE_DSS_DIV:
if (0 == *operand) { if (0 == *operand) {
@ -617,11 +617,11 @@ static void orte_dss_arith_uint32(uint32_t *value, uint32_t *operand, orte_dss_a
return; return;
} }
(*value) /= *operand; (*value) /= *operand;
return; break;
default: default:
ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED);
return; break;
} }
return; return;
} }
@ -631,15 +631,15 @@ static void orte_dss_arith_int64(int64_t *value, int64_t *operand, orte_dss_arit
switch(operation) { switch(operation) {
case ORTE_DSS_ADD: case ORTE_DSS_ADD:
(*value) += *operand; (*value) += *operand;
return; break;
case ORTE_DSS_SUB: case ORTE_DSS_SUB:
(*value) -= *operand; (*value) -= *operand;
return; break;
case ORTE_DSS_MUL: case ORTE_DSS_MUL:
(*value) *= *operand; (*value) *= *operand;
return; break;
case ORTE_DSS_DIV: case ORTE_DSS_DIV:
if (0 == *operand) { if (0 == *operand) {
@ -647,11 +647,11 @@ static void orte_dss_arith_int64(int64_t *value, int64_t *operand, orte_dss_arit
return; return;
} }
(*value) /= *operand; (*value) /= *operand;
return; break;
default: default:
ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED);
return; break;
} }
return; return;
} }
@ -661,15 +661,15 @@ static void orte_dss_arith_uint64(uint64_t *value, uint64_t *operand, orte_dss_a
switch(operation) { switch(operation) {
case ORTE_DSS_ADD: case ORTE_DSS_ADD:
(*value) += *operand; (*value) += *operand;
return; break;
case ORTE_DSS_SUB: case ORTE_DSS_SUB:
(*value) -= *operand; (*value) -= *operand;
return; break;
case ORTE_DSS_MUL: case ORTE_DSS_MUL:
(*value) *= *operand; (*value) *= *operand;
return; break;
case ORTE_DSS_DIV: case ORTE_DSS_DIV:
if (0 == *operand) { if (0 == *operand) {
@ -677,11 +677,11 @@ static void orte_dss_arith_uint64(uint64_t *value, uint64_t *operand, orte_dss_a
return; return;
} }
(*value) /= *operand; (*value) /= *operand;
return; break;
default: default:
ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED);
return; break;
} }
return; return;
} }
@ -691,15 +691,15 @@ static void orte_dss_arith_data_type(orte_data_type_t *value, orte_data_type_t *
switch(operation) { switch(operation) {
case ORTE_DSS_ADD: case ORTE_DSS_ADD:
(*value) += *operand; (*value) += *operand;
return; break;
case ORTE_DSS_SUB: case ORTE_DSS_SUB:
(*value) -= *operand; (*value) -= *operand;
return; break;
case ORTE_DSS_MUL: case ORTE_DSS_MUL:
(*value) *= *operand; (*value) *= *operand;
return; break;
case ORTE_DSS_DIV: case ORTE_DSS_DIV:
if (0 == *operand) { if (0 == *operand) {
@ -707,11 +707,11 @@ static void orte_dss_arith_data_type(orte_data_type_t *value, orte_data_type_t *
return; return;
} }
(*value) /= *operand; (*value) /= *operand;
return; break;
default: default:
ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED);
return; break;
} }
return; return;
} }
@ -721,15 +721,15 @@ static void orte_dss_arith_daemon_cmd(orte_daemon_cmd_flag_t *value, orte_daemon
switch(operation) { switch(operation) {
case ORTE_DSS_ADD: case ORTE_DSS_ADD:
(*value) += *operand; (*value) += *operand;
return; break;
case ORTE_DSS_SUB: case ORTE_DSS_SUB:
(*value) -= *operand; (*value) -= *operand;
return; break;
case ORTE_DSS_MUL: case ORTE_DSS_MUL:
(*value) *= *operand; (*value) *= *operand;
return; break;
case ORTE_DSS_DIV: case ORTE_DSS_DIV:
if (0 == *operand) { if (0 == *operand) {
@ -737,11 +737,11 @@ static void orte_dss_arith_daemon_cmd(orte_daemon_cmd_flag_t *value, orte_daemon
return; return;
} }
(*value) /= *operand; (*value) /= *operand;
return; break;
default: default:
ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED); ORTE_ERROR_LOG(ORTE_ERR_OPERATION_UNSUPPORTED);
return; break;
} }
return; return;
} }

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

@ -1,125 +1,125 @@
/* -*- C -*- /* -*- C -*-
* *
* Copyright (c) 2004-2005 The Trustees of Indiana University. * Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved. * All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee. * Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved. * All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved. * University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California. * Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
* Additional copyrights may follow * Additional copyrights may follow
* *
* $HEADER$ * $HEADER$
*/ */
/** @file /** @file
* *
*/ */
#include "orte_config.h" #include "orte_config.h"
#include "orte/orte_constants.h" #include "orte/orte_constants.h"
#include "opal/util/output.h" #include "opal/util/output.h"
#include "opal/util/trace.h" #include "opal/util/trace.h"
#include "orte/dss/dss.h" #include "orte/dss/dss.h"
#include "orte/mca/errmgr/errmgr.h" #include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/gpr/base/base.h" #include "orte/mca/gpr/base/base.h"
int orte_gpr_base_create_value(orte_gpr_value_t **value, int orte_gpr_base_create_value(orte_gpr_value_t **value,
orte_gpr_addr_mode_t addr_mode, orte_gpr_addr_mode_t addr_mode,
char *segment, char *segment,
size_t cnt, /**< Number of keyval objects */ size_t cnt, /**< Number of keyval objects */
size_t num_tokens) size_t num_tokens)
{ {
orte_gpr_value_t *val; orte_gpr_value_t *val;
OPAL_TRACE(1); OPAL_TRACE(1);
*value = OBJ_NEW(orte_gpr_value_t); *value = OBJ_NEW(orte_gpr_value_t);
if (NULL == *value) { if (NULL == *value) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
val = *value; val = *value;
/* get space for the specified number of keyvals */ /* get space for the specified number of keyvals */
if (0 < cnt) { if (0 < cnt) {
val->keyvals = (orte_gpr_keyval_t**)malloc(cnt * sizeof(orte_gpr_keyval_t*)); val->keyvals = (orte_gpr_keyval_t**)malloc(cnt * sizeof(orte_gpr_keyval_t*));
if (NULL == val->keyvals) { if (NULL == val->keyvals) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_RELEASE(val); OBJ_RELEASE(val);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
} }
/* get space for the specified number of tokens */ /* get space for the specified number of tokens */
if (0 < num_tokens) { if (0 < num_tokens) {
val->tokens = (char**)malloc(num_tokens * sizeof(char*)); val->tokens = (char**)malloc(num_tokens * sizeof(char*));
if (NULL == val->tokens) { if (NULL == val->tokens) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_RELEASE(val); OBJ_RELEASE(val);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
} }
val->addr_mode = addr_mode; val->addr_mode = addr_mode;
if (NULL != segment) { if (NULL != segment) {
val->segment = strdup(segment); val->segment = strdup(segment);
} }
val->cnt = cnt; val->cnt = cnt;
val->num_tokens = num_tokens; val->num_tokens = num_tokens;
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }
int orte_gpr_base_create_keyval(orte_gpr_keyval_t **keyval, int orte_gpr_base_create_keyval(orte_gpr_keyval_t **keyval,
char *key, char *key,
orte_data_type_t type, orte_data_type_t type,
void *data) void *data)
{ {
orte_gpr_keyval_t *kv; orte_gpr_keyval_t *kv;
int rc; int rc;
OPAL_TRACE(1); OPAL_TRACE(1);
*keyval = OBJ_NEW(orte_gpr_keyval_t); *keyval = OBJ_NEW(orte_gpr_keyval_t);
if (NULL == *keyval) { if (NULL == *keyval) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
kv = *keyval; kv = *keyval;
/* if the type is ORTE_UNDEF, then we don't actually want to create a data_value. This /* 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 * 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 * to transmit the key - the data_value field must remain NULL
*/ */
if (ORTE_UNDEF != type) { if (ORTE_UNDEF != type) {
kv->value = OBJ_NEW(orte_data_value_t); kv->value = OBJ_NEW(orte_data_value_t);
if (NULL == kv->value) { if (NULL == kv->value) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_RELEASE(kv); OBJ_RELEASE(kv);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
kv->value->type = type; kv->value->type = type;
if (NULL != data) { if (NULL != data) {
if (ORTE_SUCCESS != (rc = orte_dss.copy((void**)&(kv->value->data), data, type))) { if (ORTE_SUCCESS != (rc = orte_dss.copy((void**)&(kv->value->data), data, type))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_RELEASE(kv); OBJ_RELEASE(kv);
return rc; return rc;
} }
} }
} }
if (NULL != key) { if (NULL != key) {
kv->key = strdup(key); kv->key = strdup(key);
} }
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }

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

@ -1,127 +1,127 @@
/* -*- C -*- /* -*- C -*-
* *
* Copyright (c) 2004-2005 The Trustees of Indiana University. * Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved. * All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee. * Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved. * All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved. * University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California. * Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
* Additional copyrights may follow * Additional copyrights may follow
* *
* $HEADER$ * $HEADER$
*/ */
/** @file /** @file
* *
*/ */
#include "orte_config.h" #include "orte_config.h"
#include "orte/orte_constants.h" #include "orte/orte_constants.h"
#include "opal/util/output.h" #include "opal/util/output.h"
#include "opal/util/trace.h" #include "opal/util/trace.h"
#include "orte/dss/dss.h" #include "orte/dss/dss.h"
#include "orte/mca/errmgr/errmgr.h" #include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/gpr/base/base.h" #include "orte/mca/gpr/base/base.h"
int orte_gpr_base_put_1(orte_gpr_addr_mode_t addr_mode, int orte_gpr_base_put_1(orte_gpr_addr_mode_t addr_mode,
char *segment, char **tokens, char *segment, char **tokens,
char *key, orte_data_value_t *data_value) char *key, orte_data_value_t *data_value)
{ {
orte_gpr_value_t *values; orte_gpr_value_t *values;
orte_gpr_value_t value = ORTE_GPR_VALUE_EMPTY; orte_gpr_value_t value = ORTE_GPR_VALUE_EMPTY;
orte_gpr_keyval_t *keyvals; orte_gpr_keyval_t *keyvals;
orte_gpr_keyval_t keyval = ORTE_GPR_KEYVAL_EMPTY; orte_gpr_keyval_t keyval = ORTE_GPR_KEYVAL_EMPTY;
orte_data_value_t dval = ORTE_DATA_VALUE_EMPTY; orte_data_value_t dval = ORTE_DATA_VALUE_EMPTY;
size_t i; size_t i;
int rc; int rc;
OPAL_TRACE(1); OPAL_TRACE(1);
value.addr_mode = addr_mode; value.addr_mode = addr_mode;
value.segment = segment; value.segment = segment;
value.cnt = 1; value.cnt = 1;
keyvals = &keyval; keyvals = &keyval;
value.keyvals = &keyvals; value.keyvals = &keyvals;
keyval.key = key; keyval.key = key;
keyval.value = &dval; keyval.value = &dval;
dval.type = data_value->type; dval.type = data_value->type;
if (ORTE_SUCCESS != (rc = orte_dss.set(&dval, data_value->data, data_value->type))) { if (ORTE_SUCCESS != (rc = orte_dss.set(&dval, data_value->data, data_value->type))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
value.tokens = tokens; value.tokens = tokens;
/* must count the number of tokens */ /* must count the number of tokens */
value.num_tokens = 0; value.num_tokens = 0;
if (NULL != tokens) { if (NULL != tokens) {
for (i=0; NULL != tokens[i]; i++) { for (i=0; NULL != tokens[i]; i++) {
(value.num_tokens)++; (value.num_tokens)++;
} }
} }
values = &value; values = &value;
/* put the value on the registry */ /* put the value on the registry */
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &values))) { if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &values))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
/* no memory to clean up since we didn't allocate any */ /* no memory to clean up since we didn't allocate any */
return ORTE_SUCCESS; return ORTE_SUCCESS;
} }
int orte_gpr_base_put_N(orte_gpr_addr_mode_t addr_mode, int orte_gpr_base_put_N(orte_gpr_addr_mode_t addr_mode,
char *segment, char **tokens, char *segment, char **tokens,
size_t n, char **keys, size_t n, char **keys,
orte_data_value_t **data_values) orte_data_value_t **data_values)
{ {
orte_gpr_value_t *value; orte_gpr_value_t *value;
size_t i, num_tokens; size_t i, num_tokens;
int rc; int rc;
OPAL_TRACE(1); OPAL_TRACE(1);
/* must count the number of tokens */ /* must count the number of tokens */
num_tokens = 0; num_tokens = 0;
if (NULL != tokens) { if (NULL != tokens) {
for (i=0; NULL != tokens[i]; i++) { for (i=0; NULL != tokens[i]; i++) {
num_tokens++; num_tokens++;
} }
} }
if (ORTE_SUCCESS != (rc = orte_gpr_base_create_value(&value, addr_mode, segment, n, num_tokens))) { if (ORTE_SUCCESS != (rc = orte_gpr_base_create_value(&value, addr_mode, segment, n, num_tokens))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
return rc; return rc;
} }
for (i=0; i < n; i++) { 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))) { 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); ORTE_ERROR_LOG(rc);
OBJ_RELEASE(value); OBJ_RELEASE(value);
return rc; return rc;
} }
} }
for (i=0; i < value->num_tokens; i++) { for (i=0; i < value->num_tokens; i++) {
value->tokens[i] = strdup(tokens[i]); value->tokens[i] = strdup(tokens[i]);
} }
/* put the value on the registry */ /* put the value on the registry */
if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &value))) { if (ORTE_SUCCESS != (rc = orte_gpr.put(1, &value))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
} }
/* clean up memory */ /* clean up memory */
OBJ_RELEASE(value); OBJ_RELEASE(value);
return rc; return rc;
} }

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

@ -1,377 +1,377 @@
/* -*- C -*- /* -*- C -*-
* *
* Copyright (c) 2004-2005 The Trustees of Indiana University. * Copyright (c) 2004-2005 The Trustees of Indiana University.
* All rights reserved. * All rights reserved.
* Copyright (c) 2004-2005 The Trustees of the University of Tennessee. * Copyright (c) 2004-2005 The Trustees of the University of Tennessee.
* All rights reserved. * All rights reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved. * University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California. * Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved. * All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
* *
* Additional copyrights may follow * Additional copyrights may follow
* *
* $HEADER$ * $HEADER$
*/ */
/** @file /** @file
* *
*/ */
#include "orte_config.h" #include "orte_config.h"
#include "orte/orte_constants.h" #include "orte/orte_constants.h"
#include "opal/util/output.h" #include "opal/util/output.h"
#include "opal/util/trace.h" #include "opal/util/trace.h"
#include "orte/dss/dss.h" #include "orte/dss/dss.h"
#include "orte/mca/errmgr/errmgr.h" #include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/gpr/base/base.h" #include "orte/mca/gpr/base/base.h"
int orte_gpr_base_subscribe_1(orte_gpr_subscription_id_t *id, int orte_gpr_base_subscribe_1(orte_gpr_subscription_id_t *id,
char *trig_name, char *trig_name,
char *sub_name, char *sub_name,
orte_gpr_notify_action_t action, orte_gpr_notify_action_t action,
orte_gpr_addr_mode_t addr_mode, orte_gpr_addr_mode_t addr_mode,
char *segment, char *segment,
char **tokens, char **tokens,
char *key, char *key,
orte_gpr_notify_cb_fn_t cbfunc, orte_gpr_notify_cb_fn_t cbfunc,
void *user_tag) void *user_tag)
{ {
orte_gpr_value_t *values; orte_gpr_value_t *values;
orte_gpr_keyval_t *keyvals; orte_gpr_keyval_t *keyvals;
orte_gpr_keyval_t keyval = ORTE_GPR_KEYVAL_EMPTY; orte_gpr_keyval_t keyval = ORTE_GPR_KEYVAL_EMPTY;
orte_gpr_value_t value = ORTE_GPR_VALUE_EMPTY; orte_gpr_value_t value = ORTE_GPR_VALUE_EMPTY;
orte_gpr_subscription_t *subs; orte_gpr_subscription_t *subs;
orte_gpr_subscription_t sub = ORTE_GPR_SUBSCRIPTION_EMPTY; orte_gpr_subscription_t sub = ORTE_GPR_SUBSCRIPTION_EMPTY;
orte_gpr_trigger_t *trigs; orte_gpr_trigger_t *trigs;
orte_gpr_trigger_t trig = ORTE_GPR_TRIGGER_EMPTY; orte_gpr_trigger_t trig = ORTE_GPR_TRIGGER_EMPTY;
size_t i; size_t i;
int rc; int rc;
OPAL_TRACE(1); OPAL_TRACE(1);
/* assemble the subscription object */ /* assemble the subscription object */
subs = &sub; subs = &sub;
sub.name = sub_name; sub.name = sub_name;
sub.action = action; sub.action = action;
sub.cnt = 1; sub.cnt = 1;
values = &value; values = &value;
sub.values = &values; sub.values = &values;
sub.cbfunc = cbfunc; sub.cbfunc = cbfunc;
sub.user_tag = user_tag; sub.user_tag = user_tag;
value.addr_mode = addr_mode; value.addr_mode = addr_mode;
value.segment = segment; value.segment = segment;
value.cnt = 1; value.cnt = 1;
keyvals = &keyval; keyvals = &keyval;
value.keyvals = &keyvals; value.keyvals = &keyvals;
value.tokens = tokens; value.tokens = tokens;
/* must count the number of tokens */ /* must count the number of tokens */
value.num_tokens = 0; value.num_tokens = 0;
if (NULL != tokens) { if (NULL != tokens) {
for (i=0; NULL != tokens[i]; i++) { for (i=0; NULL != tokens[i]; i++) {
(value.num_tokens)++; (value.num_tokens)++;
} }
} }
keyval.key = key; keyval.key = key;
/* send the subscription */ /* send the subscription */
if (NULL == trig_name) { /* no trigger provided */ if (NULL == trig_name) { /* no trigger provided */
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(1, &subs, 0, NULL))) { if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(1, &subs, 0, NULL))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
} }
} else { } else {
trigs = &trig; trigs = &trig;
trig.name = trig_name; trig.name = trig_name;
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(1, &subs, 1, &trigs))) { if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(1, &subs, 1, &trigs))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
} }
} }
/* no memory to cleanup since we didn't allocate anything */ /* no memory to cleanup since we didn't allocate anything */
/* return the subscription id */ /* return the subscription id */
*id = sub.id; *id = sub.id;
return rc; return rc;
} }
int orte_gpr_base_subscribe_N(orte_gpr_subscription_id_t *id, int orte_gpr_base_subscribe_N(orte_gpr_subscription_id_t *id,
char *trig_name, char *trig_name,
char *sub_name, char *sub_name,
orte_gpr_notify_action_t action, orte_gpr_notify_action_t action,
orte_gpr_addr_mode_t addr_mode, orte_gpr_addr_mode_t addr_mode,
char *segment, char *segment,
char **tokens, char **tokens,
size_t n, size_t n,
char **keys, char **keys,
orte_gpr_notify_cb_fn_t cbfunc, orte_gpr_notify_cb_fn_t cbfunc,
void *user_tag) void *user_tag)
{ {
orte_gpr_subscription_t *sub; orte_gpr_subscription_t *sub;
orte_gpr_trigger_t *trig; orte_gpr_trigger_t *trig;
size_t i, num_tokens; size_t i, num_tokens;
int rc; int rc;
OPAL_TRACE(1); OPAL_TRACE(1);
/* assemble the subscription object */ /* assemble the subscription object */
sub = OBJ_NEW(orte_gpr_subscription_t); sub = OBJ_NEW(orte_gpr_subscription_t);
if (NULL == sub) { if (NULL == sub) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
if (NULL != sub_name) { if (NULL != sub_name) {
sub->name = strdup(sub_name); sub->name = strdup(sub_name);
} }
sub->action = action; sub->action = action;
sub->cnt = 1; sub->cnt = 1;
sub->cbfunc = cbfunc; sub->cbfunc = cbfunc;
sub->user_tag = user_tag; sub->user_tag = user_tag;
/* must count the number of tokens */ /* must count the number of tokens */
num_tokens = 0; num_tokens = 0;
if (NULL != tokens) { if (NULL != tokens) {
for (i=0; NULL != tokens[i]; i++) { for (i=0; NULL != tokens[i]; i++) {
num_tokens++; num_tokens++;
} }
} }
/* create the value object */ /* create the value object */
sub->values = (orte_gpr_value_t**)malloc(sizeof(orte_gpr_value_t*)); sub->values = (orte_gpr_value_t**)malloc(sizeof(orte_gpr_value_t*));
if (NULL == sub->values) { if (NULL == sub->values) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_RELEASE(sub); OBJ_RELEASE(sub);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
if (ORTE_SUCCESS != (rc = orte_gpr_base_create_value(&(sub->values[0]), addr_mode, segment, n, num_tokens))) { if (ORTE_SUCCESS != (rc = orte_gpr_base_create_value(&(sub->values[0]), addr_mode, segment, n, num_tokens))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_RELEASE(sub); OBJ_RELEASE(sub);
return rc; return rc;
} }
for (i=0; i < n; i++) { 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))) { if (ORTE_SUCCESS != (rc = orte_gpr_base_create_keyval(&(sub->values[0]->keyvals[i]), keys[i], ORTE_UNDEF, NULL))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_RELEASE(sub); OBJ_RELEASE(sub);
return rc; return rc;
} }
} }
/* copy the tokens */ /* copy the tokens */
for (i=0; i < sub->values[0]->num_tokens; i++) { for (i=0; i < sub->values[0]->num_tokens; i++) {
sub->values[0]->tokens[i] = strdup(tokens[i]); sub->values[0]->tokens[i] = strdup(tokens[i]);
} }
/* send the subscription */ /* send the subscription */
if (NULL == trig_name) { /* no trigger provided */ if (NULL == trig_name) { /* no trigger provided */
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(1, &sub, 0, NULL))) { if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(1, &sub, 0, NULL))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
} }
} else { } else {
trig = OBJ_NEW(orte_gpr_trigger_t); trig = OBJ_NEW(orte_gpr_trigger_t);
if (NULL == trig) { if (NULL == trig) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
OBJ_RELEASE(sub); OBJ_RELEASE(sub);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
trig->name = strdup(trig_name); trig->name = strdup(trig_name);
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(1, &sub, 1, &trig))) { if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(1, &sub, 1, &trig))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
} }
OBJ_RELEASE(trig); OBJ_RELEASE(trig);
} }
/* return the subscription id */ /* return the subscription id */
*id = sub->id; *id = sub->id;
/* clean up memory */ /* clean up memory */
OBJ_RELEASE(sub); OBJ_RELEASE(sub);
return rc; return rc;
} }
int orte_gpr_base_define_trigger(orte_gpr_trigger_id_t *id, int orte_gpr_base_define_trigger(orte_gpr_trigger_id_t *id,
char *trig_name, char *trig_name,
orte_gpr_trigger_action_t action, orte_gpr_trigger_action_t action,
orte_gpr_addr_mode_t addr_mode, orte_gpr_addr_mode_t addr_mode,
char *segment, char *segment,
char **tokens, char **tokens,
size_t n, size_t n,
char **keys, char **keys,
orte_gpr_trigger_cb_fn_t cbfunc, orte_gpr_trigger_cb_fn_t cbfunc,
void *user_tag) void *user_tag)
{ {
orte_gpr_trigger_t *trig; orte_gpr_trigger_t *trig;
size_t i, num_tokens; size_t i, num_tokens;
int rc; int rc;
OPAL_TRACE(1); OPAL_TRACE(1);
/* check for error - this function can only be used to define triggers /* 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 * 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 * triggers that fire when reaching a specified value as there is no
* way to specify a trigger level within this API * way to specify a trigger level within this API
*/ */
if (ORTE_GPR_TRIG_AT_LEVEL & action) { if (ORTE_GPR_TRIG_AT_LEVEL & action) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM; return ORTE_ERR_BAD_PARAM;
} }
/* assemble the trigger object */ /* assemble the trigger object */
trig = OBJ_NEW(orte_gpr_trigger_t); trig = OBJ_NEW(orte_gpr_trigger_t);
if (NULL == trig) { if (NULL == trig) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
if (NULL != trig_name) { if (NULL != trig_name) {
trig->name = strdup(trig_name); trig->name = strdup(trig_name);
} }
trig->action = action; trig->action = action;
trig->cnt = 1; trig->cnt = 1;
trig->cbfunc = cbfunc; trig->cbfunc = cbfunc;
trig->user_tag = user_tag; trig->user_tag = user_tag;
/* must count the number of tokens */ /* must count the number of tokens */
num_tokens = 0; num_tokens = 0;
if (NULL != tokens) { if (NULL != tokens) {
for (i=0; NULL != tokens[i]; i++) { for (i=0; NULL != tokens[i]; i++) {
num_tokens++; num_tokens++;
} }
} }
/* create the value object */ /* create the value object */
trig->values = (orte_gpr_value_t**)malloc(sizeof(orte_gpr_value_t*)); trig->values = (orte_gpr_value_t**)malloc(sizeof(orte_gpr_value_t*));
if (NULL == trig->values) { if (NULL == trig->values) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return 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))) { if (ORTE_SUCCESS != (rc = orte_gpr_base_create_value(&(trig->values[0]), addr_mode, segment, n, num_tokens))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_RELEASE(trig); OBJ_RELEASE(trig);
return rc; return rc;
} }
for (i=0; i < n; i++) { 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))) { if (ORTE_SUCCESS != (rc = orte_gpr_base_create_keyval(&(trig->values[0]->keyvals[i]), keys[i], ORTE_UNDEF, NULL))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_RELEASE(trig); OBJ_RELEASE(trig);
return rc; return rc;
} }
} }
for (i=0; i < trig->values[0]->num_tokens; i++) { for (i=0; i < trig->values[0]->num_tokens; i++) {
trig->values[0]->tokens[i] = strdup(tokens[i]); trig->values[0]->tokens[i] = strdup(tokens[i]);
} }
/* send the subscription */ /* send the subscription */
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(0, NULL, 1, &trig))) { if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(0, NULL, 1, &trig))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
} }
/* return the subscription id */ /* return the subscription id */
*id = trig->id; *id = trig->id;
/* clean up memory */ /* clean up memory */
OBJ_RELEASE(trig); OBJ_RELEASE(trig);
return rc; return rc;
} }
int orte_gpr_base_define_trigger_level(orte_gpr_trigger_id_t *id, int orte_gpr_base_define_trigger_level(orte_gpr_trigger_id_t *id,
char *trig_name, char *trig_name,
orte_gpr_trigger_action_t action, orte_gpr_trigger_action_t action,
orte_gpr_addr_mode_t addr_mode, orte_gpr_addr_mode_t addr_mode,
char *segment, char *segment,
char **tokens, char **tokens,
size_t n, size_t n,
char **keys, char **keys,
size_t *levels, size_t *levels,
orte_gpr_trigger_cb_fn_t cbfunc, orte_gpr_trigger_cb_fn_t cbfunc,
void *user_tag) void *user_tag)
{ {
orte_gpr_trigger_t *trig; orte_gpr_trigger_t *trig;
size_t i, num_tokens; size_t i, num_tokens;
int rc; int rc;
OPAL_TRACE(1); OPAL_TRACE(1);
/* check for error - this function can only be used to define triggers /* check for error - this function can only be used to define triggers
* that fire at a specified level. It cannot be used to define * that fire at a specified level. It cannot be used to define
* triggers that compare their values to each other * triggers that compare their values to each other
*/ */
if (ORTE_GPR_TRIG_CMP_LEVELS & action || NULL == trig_name) { if (ORTE_GPR_TRIG_CMP_LEVELS & action || NULL == trig_name) {
ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM); ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
return ORTE_ERR_BAD_PARAM; return ORTE_ERR_BAD_PARAM;
} }
/* assemble the trigger object */ /* assemble the trigger object */
trig = OBJ_NEW(orte_gpr_trigger_t); trig = OBJ_NEW(orte_gpr_trigger_t);
if (NULL == trig) { if (NULL == trig) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return ORTE_ERR_OUT_OF_RESOURCE; return ORTE_ERR_OUT_OF_RESOURCE;
} }
if (NULL != trig_name) { if (NULL != trig_name) {
trig->name = strdup(trig_name); trig->name = strdup(trig_name);
} }
trig->action = action; trig->action = action;
trig->cnt = 1; trig->cnt = 1;
trig->cbfunc = cbfunc; trig->cbfunc = cbfunc;
trig->user_tag = user_tag; trig->user_tag = user_tag;
/* must count the number of tokens */ /* must count the number of tokens */
num_tokens = 0; num_tokens = 0;
if (NULL != tokens) { if (NULL != tokens) {
for (i=0; NULL != tokens[i]; i++) { for (i=0; NULL != tokens[i]; i++) {
num_tokens++; num_tokens++;
} }
} }
/* create the value object */ /* create the value object */
trig->values = (orte_gpr_value_t**)malloc(sizeof(orte_gpr_value_t*)); trig->values = (orte_gpr_value_t**)malloc(sizeof(orte_gpr_value_t*));
if (NULL == trig->values) { if (NULL == trig->values) {
ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE); ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
return 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))) { if (ORTE_SUCCESS != (rc = orte_gpr_base_create_value(&(trig->values[0]), addr_mode, segment, n, num_tokens))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_RELEASE(trig); OBJ_RELEASE(trig);
return rc; return rc;
} }
for (i=0; i < n; i++) { 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])))) { if (ORTE_SUCCESS != (rc = orte_gpr_base_create_keyval(&(trig->values[0]->keyvals[i]), keys[i], ORTE_SIZE, &(levels[i])))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
OBJ_RELEASE(trig); OBJ_RELEASE(trig);
return rc; return rc;
} }
} }
for (i=0; i < trig->values[0]->num_tokens; i++) { for (i=0; i < trig->values[0]->num_tokens; i++) {
trig->values[0]->tokens[i] = strdup(tokens[i]); trig->values[0]->tokens[i] = strdup(tokens[i]);
} }
/* send the subscription */ /* send the subscription */
if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(0, NULL, 1, &trig))) { if (ORTE_SUCCESS != (rc = orte_gpr.subscribe(0, NULL, 1, &trig))) {
ORTE_ERROR_LOG(rc); ORTE_ERROR_LOG(rc);
} }
/* return the subscription id */ /* return the subscription id */
*id = trig->id; *id = trig->id;
/* clean up memory */ /* clean up memory */
OBJ_RELEASE(trig); OBJ_RELEASE(trig);
return rc; return rc;
} }

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

@ -82,9 +82,9 @@ typedef struct orte_process_name_t orte_process_name_t;
/* /*
* define maximum value for id's in any field * define maximum value for id's in any field
*/ */
#define ORTE_CELLID_MAX ((orte_cellid_t)(1 << 31)) #define ORTE_CELLID_MAX ((orte_cellid_t)(1UL << 31))
#define ORTE_JOBID_MAX ((orte_jobid_t)(1 << 31)) #define ORTE_JOBID_MAX ((orte_jobid_t)(1UL << 31))
#define ORTE_VPID_MAX ((orte_vpid_t)(1 << 31)) #define ORTE_VPID_MAX ((orte_vpid_t)(1UL << 31))
extern orte_process_name_t orte_name_all; extern orte_process_name_t orte_name_all;
#define ORTE_NAME_ALL &orte_name_all #define ORTE_NAME_ALL &orte_name_all