Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 10:12:53

0001 /*
0002  * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana
0003  *                         University Research and Technology
0004  *                         Corporation.  All rights reserved.
0005  *
0006  * Copyright (c) 2019      Intel, Inc.  All rights reserved.
0007  * Copyright (c) 2021-2022 Nanook Consulting.  All rights reserved.
0008  * $COPYRIGHT$
0009  *
0010  * Additional copyrights may follow
0011  *
0012  * $HEADER$
0013  */
0014 #ifndef PMIX_COMPRESS_BASE_H
0015 #define PMIX_COMPRESS_BASE_H
0016 
0017 #include "pmix_config.h"
0018 #include "src/mca/pcompress/pcompress.h"
0019 #include "src/util/pmix_environ.h"
0020 
0021 #include "src/mca/base/pmix_base.h"
0022 
0023 /*
0024  * Global functions for MCA overall COMPRESS
0025  */
0026 
0027 #if defined(c_plusplus) || defined(__cplusplus)
0028 extern "C" {
0029 #endif
0030 
0031 /* define a macro for quickly checking if a string exceeds the
0032  * compression limit */
0033 #define PMIX_STRING_SIZE_CHECK(s)                         \
0034     (PMIX_STRING == (s)->type && NULL != (s)->data.string \
0035      && pmix_compress_base.compress_limit < strlen((s)->data.string))
0036 
0037 #define PMIX_VALUE_COMPRESSED_STRING_UNPACK(s)                                    \
0038     do {                                                                          \
0039         char *tmp;                                                                \
0040         /* if this is a compressed string, then uncompress it */                  \
0041         if (PMIX_COMPRESSED_STRING == (s)->type) {                                \
0042             pmix_compress.decompress_string(&tmp, (uint8_t *) (s)->data.bo.bytes, \
0043                                             (s)->data.bo.size);                   \
0044             if (NULL == tmp) {                                                    \
0045                 PMIX_ERROR_LOG(PMIX_ERR_NOMEM);                                   \
0046                 rc = PMIX_ERR_NOMEM;                                              \
0047                 PMIX_VALUE_RELEASE(s);                                            \
0048                 val = NULL;                                                       \
0049             } else {                                                              \
0050                 PMIX_VALUE_DESTRUCT(s);                                           \
0051                 (s)->data.string = tmp;                                           \
0052                 (s)->type = PMIX_STRING;                                          \
0053             }                                                                     \
0054         }                                                                         \
0055     } while (0)
0056 
0057 typedef struct {
0058     size_t compress_limit;
0059     bool selected;
0060     bool silent;
0061 } pmix_compress_base_t;
0062 
0063 PMIX_EXPORT extern pmix_compress_base_t pmix_compress_base;
0064 
0065 /**
0066  * Select an available component.
0067  *
0068  * @retval OPAL_SUCCESS Upon Success
0069  * @retval OPAL_NOT_FOUND If no component can be selected
0070  * @retval OPAL_ERROR Upon other failure
0071  *
0072  */
0073 PMIX_EXPORT int pmix_compress_base_select(void);
0074 
0075 /**
0076  * Globals
0077  */
0078 PMIX_EXPORT extern pmix_mca_base_framework_t pmix_pcompress_base_framework;
0079 PMIX_EXPORT extern pmix_compress_base_module_t pmix_compress;
0080 
0081 #if defined(c_plusplus) || defined(__cplusplus)
0082 }
0083 #endif
0084 
0085 #endif /* PMIX_COMPRESS_BASE_H */