root/opal/dss/dss_print.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. opal_dss_print
  2. opal_dss_print_byte
  3. opal_dss_print_string
  4. opal_dss_print_size
  5. opal_dss_print_pid
  6. opal_dss_print_bool
  7. opal_dss_print_int
  8. opal_dss_print_uint
  9. opal_dss_print_uint8
  10. opal_dss_print_uint16
  11. opal_dss_print_uint32
  12. opal_dss_print_int8
  13. opal_dss_print_int16
  14. opal_dss_print_int32
  15. opal_dss_print_uint64
  16. opal_dss_print_int64
  17. opal_dss_print_float
  18. opal_dss_print_double
  19. opal_dss_print_time
  20. opal_dss_print_timeval
  21. opal_dss_print_null
  22. opal_dss_print_data_type
  23. opal_dss_print_byte_object
  24. opal_dss_print_pstat
  25. opal_dss_print_node_stat
  26. opal_dss_print_value
  27. opal_dss_print_buffer_contents
  28. opal_dss_print_name
  29. opal_dss_print_jobid
  30. opal_dss_print_vpid
  31. opal_dss_print_status
  32. opal_dss_print_envar

   1 /*
   2  * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2006 The University of Tennessee and The University
   6  *                         of Tennessee Research Foundation.  All rights
   7  *                         reserved.
   8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
   9  *                         University of Stuttgart.  All rights reserved.
  10  * Copyright (c) 2004-2005 The Regents of the University of California.
  11  *                         All rights reserved.
  12  * Copyright (c) 2012      Los Alamos National Security, Inc.  All rights reserved.
  13  * Copyright (c) 2014-2018 Intel, Inc. All rights reserved.
  14  * Copyright (c) 2014      Research Organization for Information Science
  15  *                         and Technology (RIST). All rights reserved.
  16  * Copyright (c) 2018      Amazon.com, Inc. or its affiliates.  All Rights reserved.
  17  * $COPYRIGHT$
  18  *
  19  * Additional copyrights may follow
  20  *
  21  * $HEADER$
  22  */
  23 
  24 #include "opal_config.h"
  25 
  26 #include "opal_stdint.h"
  27 #include <stdio.h>
  28 
  29 #include "opal/util/error.h"
  30 #include "opal/util/printf.h"
  31 #include "opal/dss/dss_internal.h"
  32 
  33 int opal_dss_print(char **output, char *prefix, void *src, opal_data_type_t type)
  34 {
  35     opal_dss_type_info_t *info;
  36 
  37     /* check for error */
  38     if (NULL == output) {
  39         return OPAL_ERR_BAD_PARAM;
  40     }
  41 
  42     /* Lookup the print function for this type and call it */
  43 
  44     if(NULL == (info = (opal_dss_type_info_t*)opal_pointer_array_get_item(&opal_dss_types, type))) {
  45         return OPAL_ERR_UNKNOWN_DATA_TYPE;
  46     }
  47 
  48     return info->odti_print_fn(output, prefix, src, type);
  49 }
  50 
  51 /*
  52  * STANDARD PRINT FUNCTIONS FOR SYSTEM TYPES
  53  */
  54 int opal_dss_print_byte(char **output, char *prefix, uint8_t *src, opal_data_type_t type)
  55 {
  56     char *prefx;
  57 
  58     /* deal with NULL prefix */
  59     if (NULL == prefix) opal_asprintf(&prefx, " ");
  60     else prefx = prefix;
  61 
  62     /* if src is NULL, just print data type and return */
  63     if (NULL == src) {
  64         opal_asprintf(output, "%sData type: OPAL_BYTE\tValue: NULL pointer", prefx);
  65         if (prefx != prefix) {
  66             free(prefx);
  67         }
  68         return OPAL_SUCCESS;
  69     }
  70 
  71     opal_asprintf(output, "%sData type: OPAL_BYTE\tValue: %x", prefix, *src);
  72     if (prefx != prefix) {
  73         free(prefx);
  74     }
  75 
  76     return OPAL_SUCCESS;
  77 }
  78 
  79 int opal_dss_print_string(char **output, char *prefix, char *src, opal_data_type_t type)
  80 {
  81     char *prefx;
  82 
  83     /* deal with NULL prefix */
  84     if (NULL == prefix) opal_asprintf(&prefx, " ");
  85     else prefx = prefix;
  86 
  87     /* if src is NULL, just print data type and return */
  88     if (NULL == src) {
  89         opal_asprintf(output, "%sData type: OPAL_STRING\tValue: NULL pointer", prefx);
  90         if (prefx != prefix) {
  91             free(prefx);
  92         }
  93         return OPAL_SUCCESS;
  94     }
  95 
  96     opal_asprintf(output, "%sData type: OPAL_STRING\tValue: %s", prefx, src);
  97     if (prefx != prefix) {
  98         free(prefx);
  99     }
 100 
 101     return OPAL_SUCCESS;
 102 }
 103 
 104 int opal_dss_print_size(char **output, char *prefix, size_t *src, opal_data_type_t type)
 105 {
 106     char *prefx;
 107 
 108     /* deal with NULL prefix */
 109     if (NULL == prefix) opal_asprintf(&prefx, " ");
 110     else prefx = prefix;
 111 
 112     /* if src is NULL, just print data type and return */
 113     if (NULL == src) {
 114         opal_asprintf(output, "%sData type: OPAL_SIZE\tValue: NULL pointer", prefx);
 115         if (prefx != prefix) {
 116             free(prefx);
 117         }
 118         return OPAL_SUCCESS;
 119     }
 120 
 121     opal_asprintf(output, "%sData type: OPAL_SIZE\tValue: %lu", prefx, (unsigned long) *src);
 122     if (prefx != prefix) {
 123         free(prefx);
 124     }
 125 
 126     return OPAL_SUCCESS;
 127 }
 128 
 129 int opal_dss_print_pid(char **output, char *prefix, pid_t *src, opal_data_type_t type)
 130 {
 131     char *prefx;
 132 
 133     /* deal with NULL prefix */
 134     if (NULL == prefix) opal_asprintf(&prefx, " ");
 135     else prefx = prefix;
 136 
 137     /* if src is NULL, just print data type and return */
 138     if (NULL == src) {
 139         opal_asprintf(output, "%sData type: OPAL_PID\tValue: NULL pointer", prefx);
 140         if (prefx != prefix) {
 141             free(prefx);
 142         }
 143         return OPAL_SUCCESS;
 144     }
 145 
 146     opal_asprintf(output, "%sData type: OPAL_PID\tValue: %lu", prefx, (unsigned long) *src);
 147     if (prefx != prefix) {
 148         free(prefx);
 149     }
 150     return OPAL_SUCCESS;
 151 }
 152 
 153 int opal_dss_print_bool(char **output, char *prefix, bool *src, opal_data_type_t type)
 154 {
 155     char *prefx;
 156 
 157     /* deal with NULL prefix */
 158     if (NULL == prefix) opal_asprintf(&prefx, " ");
 159     else prefx = prefix;
 160 
 161     /* if src is NULL, just print data type and return */
 162     if (NULL == src) {
 163         opal_asprintf(output, "%sData type: OPAL_BOOL\tValue: NULL pointer", prefx);
 164         if (prefx != prefix) {
 165             free(prefx);
 166         }
 167         return OPAL_SUCCESS;
 168     }
 169 
 170     opal_asprintf(output, "%sData type: OPAL_BOOL\tValue: %s", prefx, *src ? "TRUE" : "FALSE");
 171     if (prefx != prefix) {
 172         free(prefx);
 173     }
 174 
 175     return OPAL_SUCCESS;
 176 }
 177 
 178 int opal_dss_print_int(char **output, char *prefix, int *src, opal_data_type_t type)
 179 {
 180     char *prefx;
 181 
 182     /* deal with NULL prefix */
 183     if (NULL == prefix) opal_asprintf(&prefx, " ");
 184     else prefx = prefix;
 185 
 186     /* if src is NULL, just print data type and return */
 187     if (NULL == src) {
 188         opal_asprintf(output, "%sData type: OPAL_INT\tValue: NULL pointer", prefx);
 189         if (prefx != prefix) {
 190             free(prefx);
 191         }
 192         return OPAL_SUCCESS;
 193     }
 194 
 195     opal_asprintf(output, "%sData type: OPAL_INT\tValue: %ld", prefx, (long) *src);
 196     if (prefx != prefix) {
 197         free(prefx);
 198     }
 199 
 200     return OPAL_SUCCESS;
 201 }
 202 
 203 int opal_dss_print_uint(char **output, char *prefix, int *src, opal_data_type_t type)
 204 {
 205     char *prefx;
 206 
 207     /* deal with NULL prefix */
 208     if (NULL == prefix) opal_asprintf(&prefx, " ");
 209     else prefx = prefix;
 210 
 211     /* if src is NULL, just print data type and return */
 212     if (NULL == src) {
 213         opal_asprintf(output, "%sData type: OPAL_UINT\tValue: NULL pointer", prefx);
 214         if (prefx != prefix) {
 215             free(prefx);
 216         }
 217         return OPAL_SUCCESS;
 218     }
 219 
 220     opal_asprintf(output, "%sData type: OPAL_UINT\tValue: %lu", prefx, (unsigned long) *src);
 221     if (prefx != prefix) {
 222         free(prefx);
 223     }
 224 
 225     return OPAL_SUCCESS;
 226 }
 227 
 228 int opal_dss_print_uint8(char **output, char *prefix, uint8_t *src, opal_data_type_t type)
 229 {
 230     char *prefx;
 231 
 232     /* deal with NULL prefix */
 233     if (NULL == prefix) opal_asprintf(&prefx, " ");
 234     else prefx = prefix;
 235 
 236     /* if src is NULL, just print data type and return */
 237     if (NULL == src) {
 238         opal_asprintf(output, "%sData type: OPAL_UINT8\tValue: NULL pointer", prefx);
 239         if (prefx != prefix) {
 240             free(prefx);
 241         }
 242         return OPAL_SUCCESS;
 243     }
 244 
 245     opal_asprintf(output, "%sData type: OPAL_UINT8\tValue: %u", prefx, (unsigned int) *src);
 246     if (prefx != prefix) {
 247         free(prefx);
 248     }
 249 
 250     return OPAL_SUCCESS;
 251 }
 252 
 253 int opal_dss_print_uint16(char **output, char *prefix, uint16_t *src, opal_data_type_t type)
 254 {
 255     char *prefx;
 256 
 257     /* deal with NULL prefix */
 258     if (NULL == prefix) opal_asprintf(&prefx, " ");
 259     else prefx = prefix;
 260 
 261     /* if src is NULL, just print data type and return */
 262     if (NULL == src) {
 263         opal_asprintf(output, "%sData type: OPAL_UINT16\tValue: NULL pointer", prefx);
 264         if (prefx != prefix) {
 265             free(prefx);
 266         }
 267         return OPAL_SUCCESS;
 268     }
 269 
 270     opal_asprintf(output, "%sData type: OPAL_UINT16\tValue: %u", prefx, (unsigned int) *src);
 271     if (prefx != prefix) {
 272         free(prefx);
 273     }
 274 
 275     return OPAL_SUCCESS;
 276 }
 277 
 278 int opal_dss_print_uint32(char **output, char *prefix, uint32_t *src, opal_data_type_t type)
 279 {
 280     char *prefx;
 281 
 282     /* deal with NULL prefix */
 283     if (NULL == prefix) opal_asprintf(&prefx, " ");
 284     else prefx = prefix;
 285 
 286     /* if src is NULL, just print data type and return */
 287     if (NULL == src) {
 288         opal_asprintf(output, "%sData type: OPAL_UINT32\tValue: NULL pointer", prefx);
 289         if (prefx != prefix) {
 290             free(prefx);
 291         }
 292         return OPAL_SUCCESS;
 293     }
 294 
 295     opal_asprintf(output, "%sData type: OPAL_UINT32\tValue: %u", prefx, (unsigned int) *src);
 296     if (prefx != prefix) {
 297         free(prefx);
 298     }
 299 
 300     return OPAL_SUCCESS;
 301 }
 302 
 303 int opal_dss_print_int8(char **output, char *prefix, int8_t *src, opal_data_type_t type)
 304 {
 305     char *prefx;
 306 
 307     /* deal with NULL prefix */
 308     if (NULL == prefix) opal_asprintf(&prefx, " ");
 309     else prefx = prefix;
 310 
 311     /* if src is NULL, just print data type and return */
 312     if (NULL == src) {
 313         opal_asprintf(output, "%sData type: OPAL_INT8\tValue: NULL pointer", prefx);
 314         if (prefx != prefix) {
 315             free(prefx);
 316         }
 317         return OPAL_SUCCESS;
 318     }
 319 
 320     opal_asprintf(output, "%sData type: OPAL_INT8\tValue: %d", prefx, (int) *src);
 321     if (prefx != prefix) {
 322         free(prefx);
 323     }
 324 
 325     return OPAL_SUCCESS;
 326 }
 327 
 328 int opal_dss_print_int16(char **output, char *prefix, int16_t *src, opal_data_type_t type)
 329 {
 330     char *prefx;
 331 
 332     /* deal with NULL prefix */
 333     if (NULL == prefix) opal_asprintf(&prefx, " ");
 334     else prefx = prefix;
 335 
 336     /* if src is NULL, just print data type and return */
 337     if (NULL == src) {
 338         opal_asprintf(output, "%sData type: OPAL_INT16\tValue: NULL pointer", prefx);
 339         if (prefx != prefix) {
 340             free(prefx);
 341         }
 342         return OPAL_SUCCESS;
 343     }
 344 
 345     opal_asprintf(output, "%sData type: OPAL_INT16\tValue: %d", prefx, (int) *src);
 346     if (prefx != prefix) {
 347         free(prefx);
 348     }
 349 
 350     return OPAL_SUCCESS;
 351 }
 352 
 353 int opal_dss_print_int32(char **output, char *prefix, int32_t *src, opal_data_type_t type)
 354 {
 355     char *prefx;
 356 
 357     /* deal with NULL prefix */
 358     if (NULL == prefix) opal_asprintf(&prefx, " ");
 359     else prefx = prefix;
 360 
 361     /* if src is NULL, just print data type and return */
 362     if (NULL == src) {
 363         opal_asprintf(output, "%sData type: OPAL_INT32\tValue: NULL pointer", prefx);
 364         if (prefx != prefix) {
 365             free(prefx);
 366         }
 367         return OPAL_SUCCESS;
 368     }
 369 
 370     opal_asprintf(output, "%sData type: OPAL_INT32\tValue: %d", prefx, (int) *src);
 371     if (prefx != prefix) {
 372         free(prefx);
 373     }
 374 
 375     return OPAL_SUCCESS;
 376 }
 377 int opal_dss_print_uint64(char **output, char *prefix,
 378 #ifdef HAVE_INT64_T
 379                           uint64_t *src,
 380 #else
 381                           void *src,
 382 #endif  /* HAVE_INT64_T */
 383                           opal_data_type_t type)
 384 {
 385     char *prefx;
 386 
 387     /* deal with NULL prefix */
 388     if (NULL == prefix) opal_asprintf(&prefx, " ");
 389     else prefx = prefix;
 390 
 391     /* if src is NULL, just print data type and return */
 392     if (NULL == src) {
 393         opal_asprintf(output, "%sData type: OPAL_UINT64\tValue: NULL pointer", prefx);
 394         if (prefx != prefix) {
 395             free(prefx);
 396         }
 397         return OPAL_SUCCESS;
 398     }
 399 
 400 #ifdef HAVE_INT64_T
 401     opal_asprintf(output, "%sData type: OPAL_UINT64\tValue: %lu", prefx, (unsigned long) *src);
 402 #else
 403     opal_asprintf(output, "%sData type: OPAL_UINT64\tValue: unsupported", prefx);
 404 #endif  /* HAVE_INT64_T */
 405     if (prefx != prefix) {
 406         free(prefx);
 407     }
 408 
 409     return OPAL_SUCCESS;
 410 }
 411 
 412 int opal_dss_print_int64(char **output, char *prefix,
 413 #ifdef HAVE_INT64_T
 414                          int64_t *src,
 415 #else
 416                          void *src,
 417 #endif  /* HAVE_INT64_T */
 418                          opal_data_type_t type)
 419 {
 420     char *prefx;
 421 
 422     /* deal with NULL prefix */
 423     if (NULL == prefix) opal_asprintf(&prefx, " ");
 424     else prefx = prefix;
 425 
 426     /* if src is NULL, just print data type and return */
 427     if (NULL == src) {
 428         opal_asprintf(output, "%sData type: OPAL_INT64\tValue: NULL pointer", prefx);
 429         if (prefx != prefix) {
 430             free(prefx);
 431         }
 432         return OPAL_SUCCESS;
 433     }
 434 
 435 #ifdef HAVE_INT64_T
 436     opal_asprintf(output, "%sData type: OPAL_INT64\tValue: %ld", prefx, (long) *src);
 437 #else
 438     opal_asprintf(output, "%sData type: OPAL_INT64\tValue: unsupported", prefx);
 439 #endif  /* HAVE_INT64_T */
 440     if (prefx != prefix) {
 441         free(prefx);
 442     }
 443 
 444     return OPAL_SUCCESS;
 445 }
 446 
 447 int opal_dss_print_float(char **output, char *prefix,
 448                          float *src, opal_data_type_t type)
 449 {
 450     char *prefx;
 451 
 452     /* deal with NULL prefix */
 453     if (NULL == prefix) opal_asprintf(&prefx, " ");
 454     else prefx = prefix;
 455 
 456     /* if src is NULL, just print data type and return */
 457     if (NULL == src) {
 458         opal_asprintf(output, "%sData type: OPAL_FLOAT\tValue: NULL pointer", prefx);
 459         if (prefx != prefix) {
 460             free(prefx);
 461         }
 462         return OPAL_SUCCESS;
 463     }
 464 
 465     opal_asprintf(output, "%sData type: OPAL_FLOAT\tValue: %f", prefx, *src);
 466     if (prefx != prefix) {
 467         free(prefx);
 468     }
 469 
 470     return OPAL_SUCCESS;
 471 }
 472 
 473 int opal_dss_print_double(char **output, char *prefix,
 474                           double *src, opal_data_type_t type)
 475 {
 476     char *prefx;
 477 
 478     /* deal with NULL prefix */
 479     if (NULL == prefix) opal_asprintf(&prefx, " ");
 480     else prefx = prefix;
 481 
 482     /* if src is NULL, just print data type and return */
 483     if (NULL == src) {
 484         opal_asprintf(output, "%sData type: OPAL_DOUBLE\tValue: NULL pointer", prefx);
 485         if (prefx != prefix) {
 486             free(prefx);
 487         }
 488         return OPAL_SUCCESS;
 489     }
 490 
 491     opal_asprintf(output, "%sData type: OPAL_DOUBLE\tValue: %f", prefx, *src);
 492     if (prefx != prefix) {
 493         free(prefx);
 494     }
 495 
 496     return OPAL_SUCCESS;
 497 }
 498 
 499 int opal_dss_print_time(char **output, char *prefix,
 500                         time_t *src, opal_data_type_t type)
 501 {
 502     char *prefx;
 503     char *t;
 504 
 505     /* deal with NULL prefix */
 506     if (NULL == prefix) opal_asprintf(&prefx, " ");
 507     else prefx = prefix;
 508 
 509     /* if src is NULL, just print data type and return */
 510     if (NULL == src) {
 511         opal_asprintf(output, "%sData type: OPAL_TIME\tValue: NULL pointer", prefx);
 512         if (prefx != prefix) {
 513             free(prefx);
 514         }
 515         return OPAL_SUCCESS;
 516     }
 517 
 518     t = ctime(src);
 519     t[strlen(t)-1] = '\0';  // remove trailing newline
 520 
 521     opal_asprintf(output, "%sData type: OPAL_TIME\tValue: %s", prefx, t);
 522     if (prefx != prefix) {
 523         free(prefx);
 524     }
 525 
 526     return OPAL_SUCCESS;
 527 }
 528 
 529 int opal_dss_print_timeval(char **output, char *prefix,
 530                            struct timeval *src, opal_data_type_t type)
 531 {
 532     char *prefx;
 533 
 534     /* deal with NULL prefix */
 535     if (NULL == prefix) opal_asprintf(&prefx, " ");
 536     else prefx = prefix;
 537 
 538     /* if src is NULL, just print data type and return */
 539     if (NULL == src) {
 540         opal_asprintf(output, "%sData type: OPAL_TIMEVAL\tValue: NULL pointer", prefx);
 541         if (prefx != prefix) {
 542             free(prefx);
 543         }
 544         return OPAL_SUCCESS;
 545     }
 546 
 547     opal_asprintf(output, "%sData type: OPAL_TIMEVAL\tValue: %ld.%06ld", prefx,
 548              (long)src->tv_sec, (long)src->tv_usec);
 549     if (prefx != prefix) {
 550         free(prefx);
 551     }
 552 
 553     return OPAL_SUCCESS;
 554 }
 555 
 556 int opal_dss_print_null(char **output, char *prefix, void *src, opal_data_type_t type)
 557 {
 558     char *prefx;
 559 
 560     /* deal with NULL prefix */
 561     if (NULL == prefix) opal_asprintf(&prefx, " ");
 562     else prefx = prefix;
 563 
 564     /* if src is NULL, just print data type and return */
 565     if (NULL == src) {
 566         opal_asprintf(output, "%sData type: OPAL_NULL\tValue: NULL pointer", prefx);
 567         if (prefx != prefix) {
 568             free(prefx);
 569         }
 570         return OPAL_SUCCESS;
 571     }
 572 
 573     opal_asprintf(output, "%sData type: OPAL_NULL", prefx);
 574     if (prefx != prefix) {
 575         free(prefx);
 576     }
 577 
 578     return OPAL_SUCCESS;
 579 }
 580 
 581 
 582 /* PRINT FUNCTIONS FOR GENERIC OPAL TYPES */
 583 
 584 /*
 585  * OPAL_DATA_TYPE
 586  */
 587 int opal_dss_print_data_type(char **output, char *prefix, opal_data_type_t *src, opal_data_type_t type)
 588 {
 589     char *prefx;
 590 
 591     /* deal with NULL prefix */
 592     if (NULL == prefix) opal_asprintf(&prefx, " ");
 593     else prefx = prefix;
 594 
 595     /* if src is NULL, just print data type and return */
 596     if (NULL == src) {
 597         opal_asprintf(output, "%sData type: OPAL_DATA_TYPE\tValue: NULL pointer", prefx);
 598         if (prefx != prefix) {
 599             free(prefx);
 600         }
 601         return OPAL_SUCCESS;
 602     }
 603 
 604     opal_asprintf(output, "%sData type: OPAL_DATA_TYPE\tValue: %lu", prefx, (unsigned long) *src);
 605     if (prefx != prefix) {
 606         free(prefx);
 607     }
 608     return OPAL_SUCCESS;
 609 }
 610 
 611 /*
 612  * OPAL_BYTE_OBJECT
 613  */
 614 int opal_dss_print_byte_object(char **output, char *prefix, opal_byte_object_t *src, opal_data_type_t type)
 615 {
 616     char *prefx;
 617 
 618     /* deal with NULL prefix */
 619     if (NULL == prefix) opal_asprintf(&prefx, " ");
 620     else prefx = prefix;
 621 
 622     /* if src is NULL, just print data type and return */
 623     if (NULL == src) {
 624         opal_asprintf(output, "%sData type: OPAL_BYTE_OBJECT\tValue: NULL pointer", prefx);
 625         if (prefx != prefix) {
 626             free(prefx);
 627         }
 628         return OPAL_SUCCESS;
 629     }
 630 
 631     opal_asprintf(output, "%sData type: OPAL_BYTE_OBJECT\tSize: %lu", prefx, (unsigned long) src->size);
 632     if (prefx != prefix) {
 633         free(prefx);
 634     }
 635 
 636     return OPAL_SUCCESS;
 637 }
 638 
 639 /*
 640  * OPAL_PSTAT
 641  */
 642 int opal_dss_print_pstat(char **output, char *prefix, opal_pstats_t *src, opal_data_type_t type)
 643 {
 644     char *prefx;
 645 
 646     /* deal with NULL prefix */
 647     if (NULL == prefix) opal_asprintf(&prefx, " ");
 648     else prefx = prefix;
 649 
 650     /* if src is NULL, just print data type and return */
 651     if (NULL == src) {
 652         opal_asprintf(output, "%sData type: OPAL_PSTATS\tValue: NULL pointer", prefx);
 653         if (prefx != prefix) {
 654             free(prefx);
 655         }
 656         return OPAL_SUCCESS;
 657     }
 658     opal_asprintf(output, "%sOPAL_PSTATS SAMPLED AT: %ld.%06ld\n%snode: %s rank: %d pid: %d cmd: %s state: %c pri: %d #threads: %d Processor: %d\n"
 659              "%s\ttime: %ld.%06ld cpu: %5.2f  PSS: %8.2f  VMsize: %8.2f PeakVMSize: %8.2f RSS: %8.2f\n",
 660              prefx, (long)src->sample_time.tv_sec, (long)src->sample_time.tv_usec,
 661              prefx, src->node, src->rank, src->pid, src->cmd, src->state[0], src->priority, src->num_threads, src->processor,
 662              prefx, (long)src->time.tv_sec, (long)src->time.tv_usec, src->percent_cpu, src->pss, src->vsize, src->peak_vsize, src->rss);
 663     if (prefx != prefix) {
 664         free(prefx);
 665     }
 666 
 667     return OPAL_SUCCESS;
 668 }
 669 
 670 /*
 671  * OPAL_NODE_STAT
 672  */
 673 int opal_dss_print_node_stat(char **output, char *prefix, opal_node_stats_t *src, opal_data_type_t type)
 674 {
 675     char *prefx;
 676 
 677     /* deal with NULL prefix */
 678     if (NULL == prefix) opal_asprintf(&prefx, " ");
 679     else prefx = prefix;
 680 
 681     /* if src is NULL, just print data type and return */
 682     if (NULL == src) {
 683         opal_asprintf(output, "%sData type: OPAL_NODE_STATS\tValue: NULL pointer", prefx);
 684         if (prefx != prefix) {
 685             free(prefx);
 686         }
 687         return OPAL_SUCCESS;
 688     }
 689     opal_asprintf(output, "%sOPAL_NODE_STATS SAMPLED AT: %ld.%06ld\n%sTotal Mem: %5.2f Free Mem: %5.2f Buffers: %5.2f Cached: %5.2f\n"
 690              "%sSwapCached: %5.2f SwapTotal: %5.2f SwapFree: %5.2f Mapped: %5.2f\n"
 691              "%s\tla: %5.2f\tla5: %5.2f\tla15: %5.2f\n",
 692              prefx, (long)src->sample_time.tv_sec, (long)src->sample_time.tv_usec,
 693              prefx, src->total_mem, src->free_mem, src->buffers, src->cached,
 694              prefx, src->swap_cached, src->swap_total, src->swap_free, src->mapped,
 695              prefx, src->la, src->la5, src->la15);
 696     if (prefx != prefix) {
 697         free(prefx);
 698     }
 699 
 700     return OPAL_SUCCESS;
 701 }
 702 
 703 /*
 704  * OPAL_VALUE
 705  */
 706 int opal_dss_print_value(char **output, char *prefix, opal_value_t *src, opal_data_type_t type)
 707 {
 708     char *prefx;
 709 
 710     /* deal with NULL prefix */
 711     if (NULL == prefix) opal_asprintf(&prefx, " ");
 712     else prefx = prefix;
 713 
 714     /* if src is NULL, just print data type and return */
 715     if (NULL == src) {
 716         opal_asprintf(output, "%sData type: OPAL_VALUE\tValue: NULL pointer", prefx);
 717         if (prefx != prefix) {
 718             free(prefx);
 719         }
 720         return OPAL_SUCCESS;
 721     }
 722 
 723     switch (src->type) {
 724     case OPAL_BOOL:
 725         opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_BOOL\tKey: %s\tValue: %s",
 726                  prefx, src->key, src->data.flag ? "true" : "false");
 727         break;
 728     case OPAL_BYTE:
 729         opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_BYTE\tKey: %s\tValue: %x",
 730                  prefx, src->key, src->data.byte);
 731         break;
 732     case OPAL_STRING:
 733         opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_STRING\tKey: %s\tValue: %s",
 734                  prefx, src->key, src->data.string);
 735         break;
 736     case OPAL_SIZE:
 737         opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_SIZE\tKey: %s\tValue: %lu",
 738                  prefx, src->key, (unsigned long)src->data.size);
 739         break;
 740     case OPAL_PID:
 741         opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_PID\tKey: %s\tValue: %lu",
 742                  prefx, src->key, (unsigned long)src->data.pid);
 743         break;
 744     case OPAL_INT:
 745         opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_INT\tKey: %s\tValue: %d",
 746                  prefx, src->key, src->data.integer);
 747         break;
 748     case OPAL_INT8:
 749         opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_INT8\tKey: %s\tValue: %d",
 750                  prefx, src->key, (int)src->data.int8);
 751         break;
 752     case OPAL_INT16:
 753         opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_INT16\tKey: %s\tValue: %d",
 754                  prefx, src->key, (int)src->data.int16);
 755         break;
 756     case OPAL_INT32:
 757         opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_INT32\tKey: %s\tValue: %d",
 758                  prefx, src->key, src->data.int32);
 759         break;
 760     case OPAL_INT64:
 761         opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_INT64\tKey: %s\tValue: %ld",
 762                  prefx, src->key, (long)src->data.int64);
 763         break;
 764     case OPAL_UINT:
 765         opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_UINT\tKey: %s\tValue: %u",
 766                  prefx, src->key, src->data.uint);
 767         break;
 768     case OPAL_UINT8:
 769         opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_UINT8\tKey: %s\tValue: %u",
 770                  prefx, src->key, (unsigned int)src->data.uint8);
 771         break;
 772     case OPAL_UINT16:
 773         opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_UINT16\tKey: %s\tValue: %u",
 774                  prefx, src->key, (unsigned int)src->data.uint16);
 775         break;
 776     case OPAL_UINT32:
 777         opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_UINT32\tKey: %s\tValue: %u",
 778                  prefx, src->key, src->data.uint32);
 779         break;
 780     case OPAL_UINT64:
 781         opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_UINT64\tKey: %s\tValue: %lu",
 782                  prefx, src->key, (unsigned long)src->data.uint64);
 783         break;
 784     case OPAL_FLOAT:
 785         opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_FLOAT\tKey: %s\tValue: %f",
 786                  prefx, src->key, src->data.fval);
 787         break;
 788     case OPAL_DOUBLE:
 789         opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_DOUBLE\tKey: %s\tValue: %f",
 790                  prefx, src->key, src->data.dval);
 791         break;
 792     case OPAL_BYTE_OBJECT:
 793         opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_BYTE_OBJECT\tKey: %s\tData: %s\tSize: %lu",
 794                  prefx, src->key, (NULL == src->data.bo.bytes) ? "NULL" : "NON-NULL", (unsigned long)src->data.bo.size);
 795         break;
 796     case OPAL_TIMEVAL:
 797         opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_TIMEVAL\tKey: %s\tValue: %ld.%06ld", prefx,
 798                  src->key, (long)src->data.tv.tv_sec, (long)src->data.tv.tv_usec);
 799         break;
 800     case OPAL_TIME:
 801         opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_TIME\tKey: %s\tValue: %s", prefx,
 802                  src->key, ctime(&src->data.time));
 803         break;
 804     case OPAL_NAME:
 805         opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_NAME\tKey: %s\tValue: %s", prefx,
 806                  src->key, OPAL_NAME_PRINT(src->data.name));
 807         break;
 808     case OPAL_PTR:
 809         opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_PTR\tKey: %s", prefx, src->key);
 810         break;
 811     case OPAL_ENVAR:
 812         opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_ENVAR\tKey: %s\tName: %s\tValue: %s\tSeparator: %c",
 813                  prefx, src->key,
 814                  (NULL == src->data.envar.envar) ? "NULL" : src->data.envar.envar,
 815                  (NULL == src->data.envar.value) ? "NULL" : src->data.envar.value,
 816                  ('\0' == src->data.envar.separator) ? ' ' : src->data.envar.separator);
 817         break;
 818     default:
 819         opal_asprintf(output, "%sOPAL_VALUE: Data type: UNKNOWN\tKey: %s\tValue: UNPRINTABLE",
 820                  prefx, src->key);
 821         break;
 822     }
 823     if (prefx != prefix) {
 824         free(prefx);
 825     }
 826     return OPAL_SUCCESS;
 827 }
 828 
 829 int opal_dss_print_buffer_contents(char **output, char *prefix,
 830                                    opal_buffer_t *src, opal_data_type_t type)
 831 {
 832     return OPAL_SUCCESS;
 833 }
 834 
 835 /*
 836  * NAME
 837  */
 838 int opal_dss_print_name(char **output, char *prefix, opal_process_name_t *name, opal_data_type_t type)
 839 {
 840     /* set default result */
 841     *output = NULL;
 842 
 843     if (NULL == name) {
 844         opal_asprintf(output, "%sData type: ORTE_PROCESS_NAME\tData Value: NULL",
 845                  (NULL == prefix ? " " : prefix));
 846     } else {
 847         opal_asprintf(output, "%sData type: ORTE_PROCESS_NAME\tData Value: [%d,%d]",
 848                  (NULL == prefix ? " " : prefix), name->jobid, name->vpid);
 849     }
 850 
 851     return OPAL_SUCCESS;
 852 }
 853 
 854 int opal_dss_print_jobid(char **output, char *prefix,
 855                          opal_process_name_t *src, opal_data_type_t type)
 856 {
 857     char *prefx = " ";
 858 
 859     /* deal with NULL prefix */
 860     if (NULL != prefix) prefx = prefix;
 861 
 862     /* if src is NULL, just print data type and return */
 863     if (NULL == src) {
 864         opal_asprintf(output, "%sData type: OPAL_JOBID\tValue: NULL pointer", prefx);
 865         return OPAL_SUCCESS;
 866     }
 867 
 868     opal_asprintf(output, "%sData type: OPAL_JOBID\tValue: %s", prefx, opal_jobid_print(src->jobid));
 869     return OPAL_SUCCESS;
 870 }
 871 
 872 int opal_dss_print_vpid(char **output, char *prefix,
 873                          opal_process_name_t *src, opal_data_type_t type)
 874 {
 875     char *prefx = " ";
 876 
 877     /* deal with NULL prefix */
 878     if (NULL != prefix) prefx = prefix;
 879 
 880     /* if src is NULL, just print data type and return */
 881     if (NULL == src) {
 882         opal_asprintf(output, "%sData type: OPAL_VPID\tValue: NULL pointer", prefx);
 883         return OPAL_SUCCESS;
 884     }
 885 
 886     opal_asprintf(output, "%sData type: OPAL_VPID\tValue: %s", prefx, opal_vpid_print(src->vpid));
 887     return OPAL_SUCCESS;
 888 }
 889 
 890 int opal_dss_print_status(char **output, char *prefix,
 891                           int *src, opal_data_type_t type)
 892 {
 893     char *prefx = " ";
 894 
 895     /* deal with NULL prefix */
 896     if (NULL != prefix) prefx = prefix;
 897 
 898     /* if src is NULL, just print data type and return */
 899     if (NULL == src) {
 900         opal_asprintf(output, "%sData type: OPAL_STATUS\tValue: NULL pointer", prefx);
 901         return OPAL_SUCCESS;
 902     }
 903 
 904     opal_asprintf(output, "%sData type: OPAL_STATUS\tValue: %s", prefx, opal_strerror(*src));
 905     return OPAL_SUCCESS;
 906 }
 907 
 908 
 909 int opal_dss_print_envar(char **output, char *prefix,
 910                          opal_envar_t *src, opal_data_type_t type)
 911 {
 912     char *prefx = " ";
 913 
 914     /* deal with NULL prefix */
 915     if (NULL != prefix) prefx = prefix;
 916 
 917     /* if src is NULL, just print data type and return */
 918     if (NULL == src) {
 919         opal_asprintf(output, "%sData type: OPAL_ENVAR\tValue: NULL pointer", prefx);
 920         return OPAL_SUCCESS;
 921     }
 922 
 923     opal_asprintf(output, "%sOPAL_VALUE: Data type: OPAL_ENVAR\tName: %s\tValue: %s\tSeparator: %c",
 924              prefx, (NULL == src->envar) ? "NULL" : src->envar,
 925              (NULL == src->value) ? "NULL" : src->value,
 926              ('\0' == src->separator) ? ' ' : src->separator);
 927     return OPAL_SUCCESS;
 928 }

/* [<][>][^][v][top][bottom][index][help] */