Skip to content

Commit 546ccda

Browse files
committed
memory/linux: make memory_linux_memalign an enum
1 parent 06e811c commit 546ccda

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

opal/mca/memory/linux/memory_linux_component.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ static void *(*prev_malloc_hook)(size_t, const void *);
129129
* memalign which will be called through __malloc_hook instead of malloc.
130130
*/
131131
static void *_opal_memory_linux_malloc_align_hook(size_t sz, const void* caller);
132+
133+
#define ALIGN
134+
135+
static mca_base_var_enum_value_t align_values[] = {
136+
{-1, "disabled"},
137+
{0, "0"},
138+
{32, "32"},
139+
{64, "64"},
140+
{0, NULL}
141+
};
132142
#endif /* MEMORY_LINUX_MALLOC_ALIGN_ENABLED */
133143

134144

@@ -137,6 +147,9 @@ static void *_opal_memory_linux_malloc_align_hook(size_t sz, const void* caller)
137147
*/
138148
static int linux_register(void)
139149
{
150+
#if MEMORY_LINUX_MALLOC_ALIGN_ENABLED
151+
mca_base_var_enum_t *new_enum;
152+
#endif
140153
int ret;
141154
/* Information only */
142155
ret = mca_base_component_var_register (&mca_memory_linux_component.super.memoryc_version,
@@ -199,17 +212,19 @@ static int linux_register(void)
199212
}
200213

201214
#if MEMORY_LINUX_MALLOC_ALIGN_ENABLED
215+
(void)mca_base_var_enum_create("memory_linux_memalign", align_values, &new_enum);
202216
mca_memory_linux_component.use_memalign = -1;
203217
ret = mca_base_component_var_register(&mca_memory_linux_component.super.memoryc_version,
204218
"memalign",
205-
"[64 | 32 | 0] - Enable memory alignment for all malloc calls (default: disabled).",
219+
"[64 | 32 | 0] - Enable memory alignment for all malloc calls.",
206220
MCA_BASE_VAR_TYPE_INT,
207-
NULL,
221+
new_enum,
208222
0,
209223
0,
210224
OPAL_INFO_LVL_5,
211225
MCA_BASE_VAR_SCOPE_READONLY,
212226
&mca_memory_linux_component.use_memalign);
227+
OBJ_RELEASE(new_enum);
213228
if (0 > ret) {
214229
return ret;
215230
}

0 commit comments

Comments
 (0)