root/opal/mca/dl/libltdl/dl_libltdl_component.c

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

DEFINITIONS

This source file includes following definitions.
  1. libltdl_component_register
  2. libltdl_component_open
  3. libltdl_component_close
  4. libltdl_component_query

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2015 Cisco Systems, Inc.  All rights reserved.
   4  * Copyright (c) 2015       Los Alamos National Security, Inc.  All rights
   5  *                          reserved.
   6  * $COPYRIGHT$
   7  *
   8  * Additional copyrights may follow
   9  *
  10  * $HEADER$
  11  */
  12 
  13 #include "opal_config.h"
  14 
  15 #include "opal/constants.h"
  16 #include "opal/mca/dl/dl.h"
  17 #include "opal/mca/base/mca_base_var.h"
  18 #include "opal/util/argv.h"
  19 
  20 #include "dl_libltdl.h"
  21 
  22 
  23 /*
  24  * Public string showing the sysinfo ompi_linux component version number
  25  */
  26 const char *opal_dl_libltdl_component_version_string =
  27     "OPAL dl libltdl MCA component version " OPAL_VERSION;
  28 
  29 
  30 /*
  31  * Local functions
  32  */
  33 static int libltdl_component_register(void);
  34 static int libltdl_component_open(void);
  35 static int libltdl_component_close(void);
  36 static int libltdl_component_query(mca_base_module_t **module, int *priority);
  37 
  38 /*
  39  * Instantiate the public struct with all of our public information
  40  * and pointers to our public functions in it
  41  */
  42 
  43 opal_dl_libltdl_component_t mca_dl_libltdl_component = {
  44 
  45     /* Fill in the mca_dl_base_component_t */
  46     .base = {
  47 
  48         /* First, the mca_component_t struct containing meta information
  49            about the component itself */
  50         .base_version = {
  51             OPAL_DL_BASE_VERSION_1_0_0,
  52 
  53             /* Component name and version */
  54             .mca_component_name = "libltdl",
  55             MCA_BASE_MAKE_VERSION(component, OPAL_MAJOR_VERSION, OPAL_MINOR_VERSION,
  56                                   OPAL_RELEASE_VERSION),
  57 
  58             /* Component functions */
  59             .mca_register_component_params = libltdl_component_register,
  60             .mca_open_component = libltdl_component_open,
  61             .mca_close_component = libltdl_component_close,
  62             .mca_query_component = libltdl_component_query,
  63         },
  64 
  65         .base_data = {
  66             /* The component is checkpoint ready */
  67             MCA_BASE_METADATA_PARAM_CHECKPOINT
  68         },
  69 
  70         /* The dl framework members */
  71         .priority = 50
  72     }
  73 
  74     /* Now fill in the libltdl component-specific members */
  75 };
  76 
  77 
  78 static int libltdl_component_register(void)
  79 {
  80     /* Register an info param indicating whether we have lt_dladvise
  81        support or not */
  82     bool supported = OPAL_INT_TO_BOOL(OPAL_DL_LIBLTDL_HAVE_LT_DLADVISE);
  83     mca_base_component_var_register(&mca_dl_libltdl_component.base.base_version,
  84                                     "have_lt_dladvise",
  85                                     "Whether the version of libltdl that this component is built against supports lt_dladvise functionality or not",
  86                                     MCA_BASE_VAR_TYPE_BOOL,
  87                                     NULL,
  88                                     0,
  89                                     MCA_BASE_VAR_FLAG_DEFAULT_ONLY,
  90                                     OPAL_INFO_LVL_7,
  91                                     MCA_BASE_VAR_SCOPE_CONSTANT,
  92                                     &supported);
  93 
  94     return OPAL_SUCCESS;
  95 }
  96 
  97 static int libltdl_component_open(void)
  98 {
  99     if (lt_dlinit()) {
 100         return OPAL_ERROR;
 101     }
 102 
 103 #if OPAL_DL_LIBLTDL_HAVE_LT_DLADVISE
 104     opal_dl_libltdl_component_t *c = &mca_dl_libltdl_component;
 105 
 106     if (lt_dladvise_init(&c->advise_private_noext)) {
 107         return OPAL_ERR_OUT_OF_RESOURCE;
 108     }
 109 
 110     if (lt_dladvise_init(&c->advise_private_ext) ||
 111         lt_dladvise_ext(&c->advise_private_ext)) {
 112         return OPAL_ERR_OUT_OF_RESOURCE;
 113     }
 114 
 115     if (lt_dladvise_init(&c->advise_public_noext) ||
 116         lt_dladvise_global(&c->advise_public_noext)) {
 117         return OPAL_ERR_OUT_OF_RESOURCE;
 118     }
 119 
 120     if (lt_dladvise_init(&c->advise_public_ext) ||
 121         lt_dladvise_global(&c->advise_public_ext) ||
 122         lt_dladvise_ext(&c->advise_public_ext)) {
 123         return OPAL_ERR_OUT_OF_RESOURCE;
 124     }
 125 #endif
 126 
 127     return OPAL_SUCCESS;
 128 }
 129 
 130 
 131 static int libltdl_component_close(void)
 132 {
 133 #if OPAL_DL_LIBLTDL_HAVE_LT_DLADVISE
 134     opal_dl_libltdl_component_t *c = &mca_dl_libltdl_component;
 135 
 136     lt_dladvise_destroy(&c->advise_private_noext);
 137     lt_dladvise_destroy(&c->advise_private_ext);
 138     lt_dladvise_destroy(&c->advise_public_noext);
 139     lt_dladvise_destroy(&c->advise_public_ext);
 140 #endif
 141 
 142     lt_dlexit();
 143 
 144     return OPAL_SUCCESS;
 145 }
 146 
 147 
 148 static int libltdl_component_query(mca_base_module_t **module, int *priority)
 149 {
 150     /* The priority value is somewhat meaningless here; by
 151        opal/mca/dl/configure.m4, there's at most one component
 152        available. */
 153     *priority = mca_dl_libltdl_component.base.priority;
 154     *module = &opal_dl_libltdl_module.super;
 155 
 156     return OPAL_SUCCESS;
 157 }

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