root/opal/mca/pmix/pmix4x/pmix/src/mca/pcompress/base/base.h

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

INCLUDED FROM


   1 /*
   2  * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  *
   6  * Copyright (c) 2019      Intel, Inc.  All rights reserved.
   7  * $COPYRIGHT$
   8  *
   9  * Additional copyrights may follow
  10  *
  11  * $HEADER$
  12  */
  13 #ifndef PMIX_COMPRESS_BASE_H
  14 #define PMIX_COMPRESS_BASE_H
  15 
  16 #include "pmix_config.h"
  17 #include "src/mca/pcompress/pcompress.h"
  18 #include "src/util/pmix_environ.h"
  19 
  20 #include "src/mca/base/base.h"
  21 
  22 /*
  23  * Global functions for MCA overall COMPRESS
  24  */
  25 
  26 #if defined(c_plusplus) || defined(__cplusplus)
  27 extern "C" {
  28 #endif
  29 
  30 /* define a macro for quickly checking if a string exceeds the
  31  * compression limit */
  32 #define PMIX_STRING_SIZE_CHECK(s) \
  33     (PMIX_STRING == (s)->type && NULL != (s)->data.string && pmix_compress_base.compress_limit < strlen((s)->data.string))
  34 
  35 #define PMIX_VALUE_COMPRESSED_STRING_UNPACK(s)                              \
  36     do {                                                                    \
  37         char *tmp;                                                          \
  38         /* if this is a compressed string, then uncompress it */            \
  39         if (PMIX_COMPRESSED_STRING == (s)->type) {                          \
  40             pmix_compress.decompress_string(&tmp, (uint8_t*)(s)->data.bo.bytes, \
  41                 (s)->data.bo.size);                                         \
  42             if (NULL == tmp) {                                              \
  43                 PMIX_ERROR_LOG(PMIX_ERR_NOMEM);                             \
  44                 rc = PMIX_ERR_NOMEM;                                        \
  45                 PMIX_VALUE_RELEASE(s);                                      \
  46                 val = NULL;                                                 \
  47             } else {                                                        \
  48                 PMIX_VALUE_DESTRUCT(s);                                     \
  49                 (s)->data.string = tmp;                                     \
  50                 (s)->type = PMIX_STRING;                                    \
  51             }                                                               \
  52         }                                                                   \
  53     } while(0)
  54 
  55 typedef struct {
  56     size_t compress_limit;
  57 } pmix_compress_base_t;
  58 
  59 PMIX_EXPORT extern pmix_compress_base_t pmix_compress_base;
  60 
  61     /**
  62      * Select an available component.
  63      *
  64      * @retval OPAL_SUCCESS Upon Success
  65      * @retval OPAL_NOT_FOUND If no component can be selected
  66      * @retval OPAL_ERROR Upon other failure
  67      *
  68      */
  69     PMIX_EXPORT int pmix_compress_base_select(void);
  70 
  71     /**
  72      * Globals
  73      */
  74     PMIX_EXPORT extern pmix_mca_base_framework_t pmix_pcompress_base_framework;
  75     PMIX_EXPORT extern pmix_compress_base_module_t pmix_compress;
  76 
  77     /**
  78      *
  79      */
  80     PMIX_EXPORT int pmix_compress_base_tar_create(char ** target);
  81     PMIX_EXPORT int pmix_compress_base_tar_extract(char ** target);
  82 
  83 #if defined(c_plusplus) || defined(__cplusplus)
  84 }
  85 #endif
  86 
  87 #endif /* PMIX_COMPRESS_BASE_H */

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