root/opal/mca/pmix/pmix4x/pmix4x_local.c

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

DEFINITIONS

This source file includes following definitions.
  1. econ
  2. opal_pmix_pmix4x_check_evars

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2014-2018 Intel, Inc.  All rights reserved.
   4  * Copyright (c) 2014-2017 Research Organization for Information Science
   5  *                         and Technology (RIST). All rights reserved.
   6  * Copyright (c) 2014-2015 Mellanox Technologies, Inc.
   7  *                         All rights reserved.
   8  * Copyright (c) 2016      Cisco Systems, Inc.  All rights reserved.
   9  * Copyright (c) 2017      Los Alamos National Security, LLC. All rights
  10  *                         reserved.
  11  * $COPYRIGHT$
  12  *
  13  * Additional copyrights may follow
  14  *
  15  * $HEADER$
  16  */
  17 
  18 #include "opal_config.h"
  19 #include "opal/constants.h"
  20 #include "opal/types.h"
  21 
  22 #ifdef HAVE_STRING_H
  23 #include <string.h>
  24 #endif
  25 #ifdef HAVE_UNISTD_H
  26 #include <unistd.h>
  27 #endif
  28 
  29 #include "opal/dss/dss.h"
  30 #include "opal/mca/event/event.h"
  31 #include "opal/mca/hwloc/base/base.h"
  32 #include "opal/runtime/opal.h"
  33 #include "opal/runtime/opal_progress_threads.h"
  34 #include "opal/threads/threads.h"
  35 #include "opal/util/argv.h"
  36 #include "opal/util/error.h"
  37 #include "opal/util/opal_environ.h"
  38 #include "opal/util/output.h"
  39 #include "opal/util/proc.h"
  40 #include "opal/util/show_help.h"
  41 
  42 #include "pmix4x.h"
  43 #include "opal/mca/pmix/base/base.h"
  44 #include "opal/mca/pmix/pmix_types.h"
  45 
  46 #include <pmix_common.h>
  47 #include <pmix.h>
  48 
  49 
  50 typedef struct {
  51     opal_list_item_t super;
  52     char *opalname;
  53     char *opalvalue;
  54     char *pmixname;
  55     char *pmixvalue;
  56     bool mismatched;
  57 } opal_pmix_evar_t;
  58 static void econ(opal_pmix_evar_t *p)
  59 {
  60     p->opalname = NULL;
  61     p->opalvalue = NULL;
  62     p->pmixname = NULL;
  63     p->pmixvalue = NULL;
  64     p->mismatched = false;
  65 }
  66 static OBJ_CLASS_INSTANCE(opal_pmix_evar_t,
  67                           opal_list_item_t,
  68                           econ, NULL);
  69 struct known_value {
  70     char *opalname;
  71     char *pmixname;
  72 };
  73 
  74 static struct known_value known_values[] = {
  75     {"OPAL_PREFIX", "PMIX_INSTALL_PREFIX"},
  76     {"OPAL_EXEC_PREFIX", "PMIX_EXEC_PREFIX"},
  77     {"OPAL_BINDIR", "PMIX_BINDIR"},
  78     {"OPAL_SBINDIR", "PMIX_SBINDIR"},
  79     {"OPAL_LIBEXECDIR", "PMIX_LIBEXECDIR"},
  80     {"OPAL_DATAROOTDIR", "PMIX_DATAROOTDIR"},
  81     {"OPAL_DATADIR", "PMIX_DATADIR"},
  82     {"OPAL_SYSCONFDIR", "PMIX_SYSCONFDIR"},
  83     {"OPAL_SHAREDSTATEDIR", "PMIX_SHAREDSTATEDIR"},
  84     {"OPAL_LOCALSTATEDIR", "PMIX_LOCALSTATEDIR"},
  85     {"OPAL_LIBDIR", "PMIX_LIBDIR"},
  86     {"OPAL_INCLUDEDIR", "PMIX_INCLUDEDIR"},
  87     {"OPAL_INFODIR", "PMIX_INFODIR"},
  88     {"OPAL_MANDIR", "PMIX_MANDIR"},
  89     {"OPAL_PKGDATADIR", "PMIX_PKGDATADIR"},
  90     {"OPAL_PKGLIBDIR", "PMIX_PKGLIBDIR"},
  91     {"OPAL_PKGINCLUDEDIR", "PMIX_PKGINCLUDEDIR"}
  92 };
  93 
  94 
  95 int opal_pmix_pmix4x_check_evars(void)
  96 {
  97     opal_list_t values;
  98     int nvals, i;
  99     opal_pmix_evar_t *evar;
 100     bool mismatched = false;
 101     char *tmp=NULL, *tmp2;
 102 
 103     OBJ_CONSTRUCT(&values, opal_list_t);
 104     nvals = sizeof(known_values) / sizeof(struct known_value);
 105     for (i=0; i < nvals; i++) {
 106         evar = OBJ_NEW(opal_pmix_evar_t);
 107         evar->opalname = known_values[i].opalname;
 108         evar->opalvalue = getenv(evar->opalname);
 109         evar->pmixname = known_values[i].pmixname;
 110         evar->pmixvalue = getenv(evar->pmixname);
 111         /* if the OPAL value is not set and the PMIx value is,
 112          * then that is a problem. Likewise, if both are set
 113          * and are different, then that is also a problem. Note that
 114          * it is okay for the OPAL value to be set and the PMIx
 115          * value to not be set */
 116         if ((NULL == evar->opalvalue && NULL != evar->pmixvalue) ||
 117             (NULL != evar->opalvalue && NULL != evar->pmixvalue &&
 118              0 != strcmp(evar->opalvalue, evar->pmixvalue))) {
 119             evar->mismatched = true;
 120             mismatched = true;
 121         }
 122         opal_list_append(&values, &evar->super);
 123     }
 124     if (!mismatched) {
 125         /* transfer any OPAL values that were set - we already verified
 126          * that the equivalent PMIx value, if present, matches, so
 127          * don't overwrite it */
 128         OPAL_LIST_FOREACH(evar, &values, opal_pmix_evar_t) {
 129             if (NULL != evar->opalvalue && NULL == evar->pmixvalue) {
 130                 opal_setenv(evar->pmixname, evar->opalvalue, true, &environ);
 131             }
 132         }
 133         OPAL_LIST_DESTRUCT(&values);
 134         return OPAL_SUCCESS;
 135     }
 136     /* we have at least one mismatch somewhere, so print out the table */
 137     OPAL_LIST_FOREACH(evar, &values, opal_pmix_evar_t) {
 138         if (evar->mismatched) {
 139             if (NULL == tmp) {
 140                 asprintf(&tmp, "  %s:  %s\n  %s:  %s",
 141                          evar->opalname, (NULL == evar->opalvalue) ? "NULL" : evar->opalvalue,
 142                          evar->pmixname, (NULL == evar->pmixvalue) ? "NULL" : evar->pmixvalue);
 143             } else {
 144                 asprintf(&tmp2, "%s\n\n  %s:  %s\n  %s:  %s", tmp,
 145                          evar->opalname, (NULL == evar->opalvalue) ? "NULL" : evar->opalvalue,
 146                          evar->pmixname, (NULL == evar->pmixvalue) ? "NULL" : evar->pmixvalue);
 147                 free(tmp);
 148                 tmp = tmp2;
 149             }
 150         }
 151     }
 152     opal_show_help("help-pmix-pmix4x.txt", "evars", true, tmp);
 153     free(tmp);
 154     return OPAL_ERR_SILENT;
 155 }

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