root/opal/mca/pmix/pmix4x/pmix/src/mca/bfrops/base/bfrop_base_frame.c

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

DEFINITIONS

This source file includes following definitions.
  1. pmix_bfrop_register
  2. pmix_bfrop_close
  3. pmix_bfrop_open
  4. moddes
  5. pmix_buffer_construct
  6. pmix_buffer_destruct
  7. pmix_bfrop_type_info_construct
  8. pmix_bfrop_type_info_destruct
  9. kvcon
  10. kvdes

   1 /* -*- Mode: C; c-basic-offset:4 ; -*- */
   2 /*
   3  * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2009 The University of Tennessee and The University
   7  *                         of Tennessee Research Foundation.  All rights
   8  *                         reserved.
   9  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
  10  *                         University of Stuttgart.  All rights reserved.
  11  * Copyright (c) 2004-2005 The Regents of the University of California.
  12  *                         All rights reserved.
  13  * Copyright (c) 2012-2013 Los Alamos National Security, Inc.  All rights reserved.
  14  * Copyright (c) 2014-2017 Intel, Inc.  All rights reserved.
  15  * Copyright (c) 2015-2018 Research Organization for Information Science
  16  *                         and Technology (RIST). All rights reserved.
  17  * $COPYRIGHT$
  18  *
  19  * Additional copyrights may follow
  20  *
  21  * $HEADER$
  22  */
  23 /** @file:
  24  *
  25  */
  26 #include <src/include/pmix_config.h>
  27 
  28 #include <pmix_common.h>
  29 
  30 #ifdef HAVE_STRING_H
  31 #include <string.h>
  32 #endif
  33 
  34 #include "src/mca/mca.h"
  35 #include "src/mca/base/base.h"
  36 #include "src/mca/base/pmix_mca_base_var.h"
  37 #include "src/mca/base/pmix_mca_base_framework.h"
  38 #include "src/class/pmix_list.h"
  39 #include "src/mca/bfrops/base/base.h"
  40 
  41 /*
  42  * The following file was created by configure.  It contains extern
  43  * statements and the definition of an array of pointers to each
  44  * component's public mca_base_component_t struct.
  45  */
  46 
  47 #include "src/mca/bfrops/base/static-components.h"
  48 
  49 /* Instantiate the global vars */
  50 pmix_bfrops_globals_t pmix_bfrops_globals = {{{0}}};
  51 int pmix_bfrops_base_output = 0;
  52 
  53 static int pmix_bfrop_register(pmix_mca_base_register_flag_t flags)
  54 {
  55     pmix_bfrops_globals.initial_size = PMIX_BFROP_DEFAULT_INITIAL_SIZE;
  56     pmix_mca_base_var_register("pmix", "bfrops", "base", "initial_size",
  57                                "Initial size of a buffer",
  58                                PMIX_MCA_BASE_VAR_TYPE_SIZE_T, NULL, 0, 0,
  59                                PMIX_INFO_LVL_2,
  60                                PMIX_MCA_BASE_VAR_SCOPE_READONLY,
  61                                &pmix_bfrops_globals.initial_size);
  62 
  63     pmix_bfrops_globals.threshold_size = PMIX_BFROP_DEFAULT_THRESHOLD_SIZE;
  64     pmix_mca_base_var_register("pmix", "bfrops", "base", "threshold_size",
  65                                "Size at which we switch from extending a buffer by doubling to extending by a smaller value",
  66                                PMIX_MCA_BASE_VAR_TYPE_SIZE_T, NULL, 0, 0,
  67                                PMIX_INFO_LVL_2,
  68                                PMIX_MCA_BASE_VAR_SCOPE_READONLY,
  69                                &pmix_bfrops_globals.threshold_size);
  70 
  71 #if PMIX_ENABLE_DEBUG
  72     pmix_bfrops_globals.default_type = PMIX_BFROP_BUFFER_FULLY_DESC;
  73 #else
  74     pmix_bfrops_globals.default_type = PMIX_BFROP_BUFFER_NON_DESC;
  75 #endif
  76     pmix_mca_base_var_register("pmix", "bfrops", "base", "default_type",
  77                                "Default type for buffers",
  78                                PMIX_MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
  79                                PMIX_INFO_LVL_2,
  80                                PMIX_MCA_BASE_VAR_SCOPE_READONLY,
  81                                &pmix_bfrops_globals.default_type);
  82     return PMIX_SUCCESS;
  83 }
  84 
  85 static pmix_status_t pmix_bfrop_close(void)
  86 {
  87     if (!pmix_bfrops_globals.initialized) {
  88         return PMIX_SUCCESS;
  89     }
  90     pmix_bfrops_globals.initialized = false;
  91 
  92     /* the components will cleanup when closed */
  93     PMIX_LIST_DESTRUCT(&pmix_bfrops_globals.actives);
  94 
  95     return pmix_mca_base_framework_components_close(&pmix_bfrops_base_framework, NULL);
  96 }
  97 
  98 static pmix_status_t pmix_bfrop_open(pmix_mca_base_open_flag_t flags)
  99 {
 100     pmix_status_t rc;
 101 
 102     /* initialize globals */
 103     pmix_bfrops_globals.initialized = true;
 104     PMIX_CONSTRUCT(&pmix_bfrops_globals.actives, pmix_list_t);
 105 
 106     /* Open up all available components */
 107     rc = pmix_mca_base_framework_components_open(&pmix_bfrops_base_framework, flags);
 108     pmix_bfrops_base_output = pmix_bfrops_base_framework.framework_output;
 109     return rc;
 110 }
 111 
 112 PMIX_MCA_BASE_FRAMEWORK_DECLARE(pmix, bfrops, "PMIx Buffer Operations",
 113                                 pmix_bfrop_register, pmix_bfrop_open, pmix_bfrop_close,
 114                                 mca_bfrops_base_static_components, 0);
 115 
 116 static void moddes(pmix_bfrops_base_active_module_t *p)
 117 {
 118     if (NULL != p->module->finalize) {
 119         p->module->finalize();
 120     }
 121 }
 122 PMIX_CLASS_INSTANCE(pmix_bfrops_base_active_module_t,
 123                     pmix_list_item_t,
 124                     NULL, moddes);
 125 
 126 /**
 127  * Object constructors, destructors, and instantiations
 128  */
 129 /** Value **/
 130 static void pmix_buffer_construct (pmix_buffer_t* buffer)
 131 {
 132     /** set the default buffer type */
 133     buffer->type = PMIX_BFROP_BUFFER_UNDEF;
 134 
 135     /* Make everything NULL to begin with */
 136     buffer->base_ptr = buffer->pack_ptr = buffer->unpack_ptr = NULL;
 137     buffer->bytes_allocated = buffer->bytes_used = 0;
 138 }
 139 
 140 static void pmix_buffer_destruct (pmix_buffer_t* buffer)
 141 {
 142     if (NULL != buffer->base_ptr) {
 143         free (buffer->base_ptr);
 144     }
 145 }
 146 
 147 PMIX_CLASS_INSTANCE(pmix_buffer_t,
 148                    pmix_object_t,
 149                    pmix_buffer_construct,
 150                    pmix_buffer_destruct);
 151 
 152 
 153 static void pmix_bfrop_type_info_construct(pmix_bfrop_type_info_t *obj)
 154 {
 155     obj->odti_name = NULL;
 156     obj->odti_pack_fn = NULL;
 157     obj->odti_unpack_fn = NULL;
 158     obj->odti_copy_fn = NULL;
 159     obj->odti_print_fn = NULL;
 160 }
 161 
 162 static void pmix_bfrop_type_info_destruct(pmix_bfrop_type_info_t *obj)
 163 {
 164     if (NULL != obj->odti_name) {
 165         free(obj->odti_name);
 166     }
 167 }
 168 
 169 PMIX_CLASS_INSTANCE(pmix_bfrop_type_info_t, pmix_object_t,
 170                    pmix_bfrop_type_info_construct,
 171                    pmix_bfrop_type_info_destruct);
 172 
 173 static void kvcon(pmix_kval_t *k)
 174 {
 175     k->key = NULL;
 176     k->value = NULL;
 177 }
 178 static void kvdes(pmix_kval_t *k)
 179 {
 180     if (NULL != k->key) {
 181         free(k->key);
 182     }
 183     if (NULL != k->value) {
 184         PMIX_VALUE_RELEASE(k->value);
 185     }
 186 }
 187 PMIX_CLASS_INSTANCE(pmix_kval_t,
 188                    pmix_list_item_t,
 189                    kvcon, kvdes);

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