1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
2 /*
3 * Copyright (c) 2004-2008 The Trustees of Indiana University and Indiana
4 * University Research and Technology
5 * Corporation. All rights reserved.
6 * Copyright (c) 2004-2005 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) 2015 Los Alamos National Security, LLC. All rights
14 * reserved.
15 * Copyright (c) 2016-2018 Intel, Inc. All rights reserved.
16 * $COPYRIGHT$
17 *
18 * Additional copyrights may follow
19 *
20 * $HEADER$
21 *
22 * These symbols are in a file by themselves to provide nice linker
23 * semantics. Since linkers generally pull in symbols by object
24 * files, keeping these symbols as the only symbols in this file
25 * prevents utility programs such as "ompi_info" from having to import
26 * entire components just to query their version and parameters.
27 */
28
29 #include <src/include/pmix_config.h>
30 #include "pmix_common.h"
31
32 #include "src/util/argv.h"
33 #include "src/mca/pnet/pnet.h"
34 #include "pnet_test.h"
35
36 static pmix_status_t component_open(void);
37 static pmix_status_t component_close(void);
38 static pmix_status_t component_query(pmix_mca_base_module_t **module, int *priority);
39
40 /*
41 * Instantiate the public struct with all of our public information
42 * and pointers to our public functions in it
43 */
44 pmix_pnet_test_component_t mca_pnet_test_component = {
45 .super = {
46 .base = {
47 PMIX_PNET_BASE_VERSION_1_0_0,
48
49 /* Component name and version */
50 .pmix_mca_component_name = "test",
51 PMIX_MCA_BASE_MAKE_VERSION(component,
52 PMIX_MAJOR_VERSION,
53 PMIX_MINOR_VERSION,
54 PMIX_RELEASE_VERSION),
55
56 /* Component open and close functions */
57 .pmix_mca_open_component = component_open,
58 .pmix_mca_close_component = component_close,
59 .pmix_mca_query_component = component_query,
60 },
61 .data = {
62 /* The component is checkpoint ready */
63 PMIX_MCA_BASE_METADATA_PARAM_CHECKPOINT
64 }
65 },
66 .include = NULL,
67 .exclude = NULL
68 };
69
70 static pmix_status_t component_open(void)
71 {
72 int index;
73 const pmix_mca_base_var_storage_t *value=NULL;
74
75 /* we only allow ourselves to be considered IF the user
76 * specifically requested so */
77 if (0 > (index = pmix_mca_base_var_find("pmix", "pnet", NULL, NULL))) {
78 return PMIX_ERROR;
79 }
80 pmix_mca_base_var_get_value(index, &value, NULL, NULL);
81 if (NULL != value && NULL != value->stringval && '\0' != value->stringval[0]) {
82 if (NULL != strstr(value->stringval, "test")) {
83 return PMIX_SUCCESS;
84 }
85 }
86 return PMIX_ERROR;
87 }
88
89
90 static pmix_status_t component_query(pmix_mca_base_module_t **module, int *priority)
91 {
92 *priority = 0;
93 *module = (pmix_mca_base_module_t *)&pmix_test_module;
94 return PMIX_SUCCESS;
95 }
96
97
98 static pmix_status_t component_close(void)
99 {
100 return PMIX_SUCCESS;
101 }