2006-02-07 06:32:36 +03:00
|
|
|
/*
|
2007-03-17 02:11:45 +03:00
|
|
|
* Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
|
2006-08-23 07:32:36 +04:00
|
|
|
* University Research and Technology
|
|
|
|
* Corporation. All rights reserved.
|
|
|
|
* Copyright (c) 2004-2006 The University of Tennessee and The University
|
|
|
|
* of Tennessee Research Foundation. All rights
|
|
|
|
* reserved.
|
2006-02-07 06:32:36 +03:00
|
|
|
* 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$
|
|
|
|
*/
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "opal_config.h"
|
2006-02-07 06:32:36 +03:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
#include "opal/dss/dss_internal.h"
|
2006-02-07 06:32:36 +03:00
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
int opal_dss_size(size_t *size, void *src, opal_data_type_t type)
|
2006-02-07 06:32:36 +03:00
|
|
|
{
|
2008-02-28 04:57:57 +03:00
|
|
|
opal_dss_type_info_t *info;
|
2006-02-07 06:32:36 +03:00
|
|
|
|
|
|
|
/* check for error */
|
|
|
|
if (NULL == size) {
|
2008-02-28 04:57:57 +03:00
|
|
|
return OPAL_ERR_BAD_PARAM;
|
2006-02-07 06:32:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Lookup the size function for this type and call it */
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
if (NULL == (info = (opal_dss_type_info_t*)opal_pointer_array_get_item(&opal_dss_types, type))) {
|
|
|
|
return OPAL_ERR_UNKNOWN_DATA_TYPE;
|
2006-02-07 06:32:36 +03:00
|
|
|
}
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
return info->odti_size_fn(size, src, type);
|
2006-02-07 06:32:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* STANDARD SIZE FUNCTION - WORKS FOR EVERYTHING NON-STRUCTURED
|
|
|
|
*/
|
2008-02-28 04:57:57 +03:00
|
|
|
int opal_dss_std_size(size_t *size, void *src, opal_data_type_t type)
|
2006-02-07 06:32:36 +03:00
|
|
|
{
|
|
|
|
switch(type) {
|
2008-02-28 04:57:57 +03:00
|
|
|
case OPAL_BOOL:
|
2006-02-07 06:32:36 +03:00
|
|
|
*size = sizeof(bool);
|
|
|
|
break;
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
case OPAL_INT:
|
|
|
|
case OPAL_UINT:
|
2006-02-07 06:32:36 +03:00
|
|
|
*size = sizeof(int);
|
|
|
|
break;
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
case OPAL_SIZE:
|
2006-02-07 06:32:36 +03:00
|
|
|
*size = sizeof(size_t);
|
|
|
|
break;
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
case OPAL_PID:
|
2006-02-07 06:32:36 +03:00
|
|
|
*size = sizeof(pid_t);
|
|
|
|
break;
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
case OPAL_BYTE:
|
|
|
|
case OPAL_INT8:
|
|
|
|
case OPAL_UINT8:
|
|
|
|
case OPAL_NULL:
|
2006-02-07 06:32:36 +03:00
|
|
|
*size = 1;
|
|
|
|
break;
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
case OPAL_INT16:
|
|
|
|
case OPAL_UINT16:
|
2006-02-07 06:32:36 +03:00
|
|
|
*size = sizeof(uint16_t);
|
|
|
|
break;
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
case OPAL_INT32:
|
|
|
|
case OPAL_UINT32:
|
2006-02-07 06:32:36 +03:00
|
|
|
*size = sizeof(uint32_t);
|
|
|
|
break;
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
case OPAL_INT64:
|
|
|
|
case OPAL_UINT64:
|
2006-02-07 06:32:36 +03:00
|
|
|
*size = sizeof(uint64_t);
|
|
|
|
break;
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
case OPAL_DATA_TYPE:
|
|
|
|
*size = sizeof(opal_data_type_t);
|
2007-03-17 02:11:45 +03:00
|
|
|
break;
|
|
|
|
|
2006-02-07 06:32:36 +03:00
|
|
|
default:
|
|
|
|
*size = 0;
|
2008-02-28 04:57:57 +03:00
|
|
|
return OPAL_ERR_UNKNOWN_DATA_TYPE;
|
2006-02-07 06:32:36 +03:00
|
|
|
}
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
return OPAL_SUCCESS;
|
2006-02-07 06:32:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* SIZE FUNCTIONS FOR NON-STANDARD SYSTEM TYPES */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* STRING
|
|
|
|
*/
|
2008-02-28 04:57:57 +03:00
|
|
|
int opal_dss_size_string(size_t *size, char *src, opal_data_type_t type)
|
2006-02-07 06:32:36 +03:00
|
|
|
{
|
|
|
|
if (NULL != src) {
|
|
|
|
*size = strlen(src) + 1;
|
|
|
|
} else {
|
|
|
|
*size = sizeof(char*); /* account for NULL */
|
|
|
|
}
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
return OPAL_SUCCESS;
|
2006-02-07 06:32:36 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
/* SIZE FUNCTIONS FOR GENERIC OPAL TYPES */
|
2006-02-07 06:32:36 +03:00
|
|
|
|
|
|
|
/*
|
2008-02-28 04:57:57 +03:00
|
|
|
* OPAL_DATA_VALUE
|
2006-02-07 06:32:36 +03:00
|
|
|
*/
|
2008-02-28 04:57:57 +03:00
|
|
|
int opal_dss_size_data_value(size_t *size, opal_dss_value_t *src, opal_data_type_t type)
|
2006-02-07 06:32:36 +03:00
|
|
|
{
|
|
|
|
size_t data_size;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
/* account for size of object itself... */
|
2008-02-28 04:57:57 +03:00
|
|
|
*size = sizeof(opal_dss_value_t);
|
2006-02-07 06:32:36 +03:00
|
|
|
|
|
|
|
if (NULL != src) {
|
|
|
|
/* ...and the number of bytes in the payload, IF an actual object was provided */
|
2008-02-28 04:57:57 +03:00
|
|
|
if (OPAL_SUCCESS != (rc = opal_dss.size(&data_size, src->data, src->type))) {
|
2006-02-07 06:32:36 +03:00
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
*size += data_size;
|
|
|
|
}
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
return OPAL_SUCCESS;
|
2006-02-07 06:32:36 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2008-02-28 04:57:57 +03:00
|
|
|
* OPAL_BYTE_OBJECT
|
2006-02-07 06:32:36 +03:00
|
|
|
*/
|
2008-02-28 04:57:57 +03:00
|
|
|
int opal_dss_size_byte_object(size_t *size, opal_byte_object_t *src, opal_data_type_t type)
|
2006-02-07 06:32:36 +03:00
|
|
|
{
|
|
|
|
/* account for size of object itself... */
|
2008-02-28 04:57:57 +03:00
|
|
|
*size = sizeof(opal_byte_object_t);
|
2006-02-07 06:32:36 +03:00
|
|
|
|
|
|
|
if (NULL != src) {
|
|
|
|
/* ...and the number of bytes in the payload, IF an actual object was provided */
|
|
|
|
*size += src->size;
|
|
|
|
}
|
|
|
|
|
2008-02-28 04:57:57 +03:00
|
|
|
return OPAL_SUCCESS;
|
2006-02-07 06:32:36 +03:00
|
|
|
}
|
2008-12-22 23:23:05 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* OPAL_PSTAT
|
|
|
|
*/
|
|
|
|
int opal_dss_size_pstat(size_t *size, opal_pstats_t *src, opal_data_type_t type)
|
|
|
|
{
|
|
|
|
*size = sizeof(opal_pstats_t);
|
|
|
|
return OPAL_SUCCESS;
|
|
|
|
}
|
|
|
|
|