This source file includes following definitions.
- pmix_bfrop_register
- pmix_bfrop_close
- pmix_bfrop_open
- moddes
- pmix_buffer_construct
- pmix_buffer_destruct
- pmix_bfrop_type_info_construct
- pmix_bfrop_type_info_destruct
- kvcon
- kvdes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
43
44
45
46
47 #include "src/mca/bfrops/base/static-components.h"
48
49
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
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
103 pmix_bfrops_globals.initialized = true;
104 PMIX_CONSTRUCT(&pmix_bfrops_globals.actives, pmix_list_t);
105
106
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
128
129
130 static void pmix_buffer_construct (pmix_buffer_t* buffer)
131 {
132
133 buffer->type = PMIX_BFROP_BUFFER_UNDEF;
134
135
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);