diff --git a/.gitignore b/.gitignore index d7e57999fb..698d0314b3 100644 --- a/.gitignore +++ b/.gitignore @@ -314,6 +314,8 @@ opal/mca/pmix/pmix3x/pmix/src/include/pmix_config.h opal/mca/pmix/pmix3x/pmix/src/include/pmix_config.h.in opal/mca/pmix/pmix3x/pmix/include/pmix_rename.h opal/mca/pmix/pmix3x/pmix/include/pmix_version.h +opal/mca/pmix/pmix3x/pmix/src/util/keyval/keyval_lex.c +opal/mca/pmix/pmix3x/pmix/src/util/show_help_lex.c opal/tools/opal-checkpoint/opal-checkpoint opal/tools/opal-checkpoint/opal-checkpoint.1 diff --git a/opal/mca/pmix/ext3x/Makefile.am b/opal/mca/pmix/ext3x/Makefile.am new file mode 100644 index 0000000000..2b6324baa6 --- /dev/null +++ b/opal/mca/pmix/ext3x/Makefile.am @@ -0,0 +1,46 @@ +# +# Copyright (c) 2014-2016 Intel, Inc. All rights reserved. +# Copyright (c) 2015 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2015 Research Organization for Information Science +# and Technology (RIST). All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +sources = \ + pmix3x.h \ + pmix3x_component.c \ + pmix3x.c \ + pmix3x_client.c \ + pmix3x_server_south.c \ + pmix3x_server_north.c + +# Make the output library in this directory, and name it either +# mca__.la (for DSO builds) or libmca__.la +# (for static builds). + +if MCA_BUILD_opal_pmix_ext3x_DSO +component_noinst = +component_install = mca_pmix_ext3x.la +else +component_noinst = libmca_pmix_ext3x.la +component_install = +endif + +mcacomponentdir = $(opallibdir) +mcacomponent_LTLIBRARIES = $(component_install) +mca_pmix_ext3x_la_SOURCES = $(sources) +mca_pmix_ext3x_la_CFLAGS = $(opal_pmix_ext3x_CFLAGS) +mca_pmix_ext3x_la_CPPFLAGS =$(opal_pmix_ext3x_CPPFLAGS) +mca_pmix_ext3x_la_LDFLAGS = -module -avoid-version $(opal_pmix_ext3x_LDFLAGS) +mca_pmix_ext3x_la_LIBADD = $(opal_pmix_ext3x_LIBS) + +noinst_LTLIBRARIES = $(component_noinst) +libmca_pmix_ext3x_la_SOURCES =$(sources) +libmca_pmix_ext3x_la_CFLAGS = $(opal_pmix_ext3x_CFLAGS) +libmca_pmix_ext3x_la_CPPFLAGS = $(opal_pmix_ext3x_CPPFLAGS) +libmca_pmix_ext3x_la_LDFLAGS = -module -avoid-version $(opal_pmix_ext3x_LDFLAGS) +libmca_pmix_ext3x_la_LIBADD = $(opal_pmix_ext3x_LIBS) diff --git a/opal/mca/pmix/ext3x/common_sym_whitelist.txt b/opal/mca/pmix/ext3x/common_sym_whitelist.txt new file mode 100644 index 0000000000..7a60b367d6 --- /dev/null +++ b/opal/mca/pmix/ext3x/common_sym_whitelist.txt @@ -0,0 +1,6 @@ +# Ignore symbols in this component that are auto-generated and we +# can't do anything about them (e.g., flex/bison symbols). +pmix_util_keyval_yyleng +pmix_util_keyval_yytext +pmix_show_help_yyleng +pmix_show_help_yytext diff --git a/opal/mca/pmix/ext3x/configure.m4 b/opal/mca/pmix/ext3x/configure.m4 new file mode 100644 index 0000000000..3e71d96e76 --- /dev/null +++ b/opal/mca/pmix/ext3x/configure.m4 @@ -0,0 +1,60 @@ +# -*- shell-script -*- +# +# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana +# University Research and Technology +# Corporation. All rights reserved. +# Copyright (c) 2004-2005 The University of Tennessee and The University +# of Tennessee Research Foundation. All rights +# reserved. +# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, +# University of Stuttgart. All rights reserved. +# Copyright (c) 2004-2005 The Regents of the University of California. +# All rights reserved. +# Copyright (c) 2011-2013 Los Alamos National Security, LLC. +# All rights reserved. +# Copyright (c) 2010-2016 Cisco Systems, Inc. All rights reserved. +# Copyright (c) 2013-2016 Intel, Inc. All rights reserved. +# Copyright (c) 2015-2016 Research Organization for Information Science +# and Technology (RIST). All rights reserved. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +# MCA_pmix_ext3x_CONFIG([action-if-found], [action-if-not-found]) +# ----------------------------------------------------------- +AC_DEFUN([MCA_opal_pmix_ext3x_CONFIG],[ + AC_CONFIG_FILES([opal/mca/pmix/ext3x/Makefile]) + + # check to see + # if we are linking to an external v3.x library. If not, then + # do not use this component. + AC_MSG_CHECKING([if external v3.x component is to be used]) + AS_IF([test "$opal_external_pmix_happy" = "yes"], + [AS_IF([test "$opal_external_pmix_version" = "3X"], + [AC_MSG_RESULT([yes - using an external v3.x library]) + opal_pmix_ext3x_happy=1 + # Build flags for our Makefile.am + opal_pmix_ext3x_CPPFLAGS=$opal_external_pmix_CPPFLAGS + opal_pmix_ext3x_LDFLAGS=$opal_external_pmix_LDFLAGS + opal_pmix_ext3x_LIBS=$opal_external_pmix_LIBS + # setup wrapper flags + pmix_ext3x_WRAPPER_EXTRA_LDFLAGS=$opal_external_pmix_LDFLAGS + pmix_ext3x_WRAPPER_EXTRA_LIBS=$opal_external_pmix_LIBS], + [AC_MSG_RESULT([no - disqualifying this component]) + opal_pmix_ext3x_happy=0])], + [AC_MSG_RESULT([no - disqualifying this component]) + opal_pmix_ext3x_happy=0]) + + AC_SUBST([opal_pmix_ext3x_LIBS]) + AC_SUBST([opal_pmix_ext3x_CPPFLAGS]) + AC_SUBST([opal_pmix_ext3x_LDFLAGS]) + AC_SUBST([opal_pmix_ext3x_DEPENDENCIES]) + + AS_IF([test $opal_pmix_ext3x_happy -eq 1], + [$1], + [$2]) + +])dnl diff --git a/opal/mca/pmix/ext3x/pmix3x.c b/opal/mca/pmix/ext3x/pmix3x.c new file mode 100644 index 0000000000..82e6d08d21 --- /dev/null +++ b/opal/mca/pmix/ext3x/pmix3x.c @@ -0,0 +1,1489 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2014-2016 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2016 Research Organization for Information Science + * and Technology (RIST). All rights reserved. + * Copyright (c) 2014-2015 Mellanox Technologies, Inc. + * All rights reserved. + * Copyright (c) 2016 Cisco Systems, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "opal_config.h" +#include "opal/constants.h" +#include "opal/types.h" + +#ifdef HAVE_STRING_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif + +#include "opal/dss/dss.h" +#include "opal/mca/event/event.h" +#include "opal/mca/hwloc/base/base.h" +#include "opal/runtime/opal.h" +#include "opal/runtime/opal_progress_threads.h" +#include "opal/util/argv.h" +#include "opal/util/error.h" +#include "opal/util/output.h" +#include "opal/util/proc.h" +#include "opal/util/show_help.h" + +#include "pmix3x.h" +#include "opal/mca/pmix/base/base.h" +#include "opal/mca/pmix/pmix_types.h" + +#include +#include + +/**** C.O.M.M.O.N I.N.T.E.R.F.A.C.E.S ****/ + +/* These are functions used by both client and server to + * access common functions in the embedded PMIx library */ + +static const char *pmix3x_get_nspace(opal_jobid_t jobid); +static void pmix3x_register_jobid(opal_jobid_t jobid, const char *nspace); +static void register_handler(opal_list_t *event_codes, + opal_list_t *info, + opal_pmix_notification_fn_t evhandler, + opal_pmix_evhandler_reg_cbfunc_t cbfunc, + void *cbdata); +static void deregister_handler(size_t evhandler, + opal_pmix_op_cbfunc_t cbfunc, + void *cbdata); +static int notify_event(int status, + const opal_process_name_t *source, + opal_pmix_data_range_t range, + opal_list_t *info, + opal_pmix_op_cbfunc_t cbfunc, void *cbdata); +static void pmix3x_query(opal_list_t *queries, + opal_pmix_info_cbfunc_t cbfunc, void *cbdata); +static void pmix3x_log(opal_list_t *info, + opal_pmix_op_cbfunc_t cbfunc, void *cbdata); + +const opal_pmix_base_module_t opal_pmix_pmix3x_module = { + /* client APIs */ + .init = pmix3x_client_init, + .finalize = pmix3x_client_finalize, + .initialized = pmix3x_initialized, + .abort = pmix3x_abort, + .commit = pmix3x_commit, + .fence = pmix3x_fence, + .fence_nb = pmix3x_fencenb, + .put = pmix3x_put, + .get = pmix3x_get, + .get_nb = pmix3x_getnb, + .publish = pmix3x_publish, + .publish_nb = pmix3x_publishnb, + .lookup = pmix3x_lookup, + .lookup_nb = pmix3x_lookupnb, + .unpublish = pmix3x_unpublish, + .unpublish_nb = pmix3x_unpublishnb, + .spawn = pmix3x_spawn, + .spawn_nb = pmix3x_spawnnb, + .connect = pmix3x_connect, + .connect_nb = pmix3x_connectnb, + .disconnect = pmix3x_disconnect, + .disconnect_nb = pmix3x_disconnectnb, + .resolve_peers = pmix3x_resolve_peers, + .resolve_nodes = pmix3x_resolve_nodes, + .query = pmix3x_query, + .log = pmix3x_log, + /* server APIs */ + .server_init = pmix3x_server_init, + .server_finalize = pmix3x_server_finalize, + .generate_regex = pmix3x_server_gen_regex, + .generate_ppn = pmix3x_server_gen_ppn, + .server_register_nspace = pmix3x_server_register_nspace, + .server_deregister_nspace = pmix3x_server_deregister_nspace, + .server_register_client = pmix3x_server_register_client, + .server_deregister_client = pmix3x_server_deregister_client, + .server_setup_fork = pmix3x_server_setup_fork, + .server_dmodex_request = pmix3x_server_dmodex, + .server_notify_event = pmix3x_server_notify_event, + /* utility APIs */ + .get_version = PMIx_Get_version, + .register_evhandler = register_handler, + .deregister_evhandler = deregister_handler, + .notify_event = notify_event, + .store_local = pmix3x_store_local, + .get_nspace = pmix3x_get_nspace, + .register_jobid = pmix3x_register_jobid +}; + +static const char *pmix3x_get_nspace(opal_jobid_t jobid) +{ + opal_pmix3x_jobid_trkr_t *jptr; + + OPAL_LIST_FOREACH(jptr, &mca_pmix_pmix3x_component.jobids, opal_pmix3x_jobid_trkr_t) { + if (jptr->jobid == jobid) { + return jptr->nspace; + } + } + return NULL; +} + +static void pmix3x_register_jobid(opal_jobid_t jobid, const char *nspace) +{ + opal_pmix3x_jobid_trkr_t *jptr; + + /* if we don't already have it, add this to our jobid tracker */ + OPAL_LIST_FOREACH(jptr, &mca_pmix_pmix3x_component.jobids, opal_pmix3x_jobid_trkr_t) { + if (jptr->jobid == jobid) { + return; + } + } + jptr = OBJ_NEW(opal_pmix3x_jobid_trkr_t); + (void)strncpy(jptr->nspace, nspace, PMIX_MAX_NSLEN); + jptr->jobid = jobid; + opal_list_append(&mca_pmix_pmix3x_component.jobids, &jptr->super); +} + +static void completion_handler(int status, void *cbdata) +{ + opal_pmix3x_event_chain_t *chain = (opal_pmix3x_event_chain_t*)cbdata; + if (NULL != chain->info) { + OPAL_LIST_RELEASE(chain->info); + } +} + +static void progress_local_event_hdlr(int status, + opal_list_t *results, + opal_pmix_op_cbfunc_t cbfunc, void *thiscbdata, + void *notification_cbdata) +{ + opal_pmix3x_event_chain_t *chain = (opal_pmix3x_event_chain_t*)notification_cbdata; + size_t n; + opal_list_item_t *nxt; + opal_pmix3x_single_event_t *sing; + opal_pmix3x_multi_event_t *multi; + opal_pmix3x_default_event_t *def; + + /* if the caller indicates that the chain is completed, then stop here */ + if (OPAL_ERR_HANDLERS_COMPLETE == status) { + goto complete; + } + + /* if any results were provided, then add them here */ + if (NULL != results) { + while (NULL != (nxt = opal_list_remove_first(results))) { + opal_list_append(results, nxt); + } + } + + /* see if we need to continue, starting with the single code events */ + if (NULL != chain->sing) { + /* the last handler was for a single code - see if there are + * any others that match this event */ + while (opal_list_get_end(&mca_pmix_pmix3x_component.single_events) != (nxt = opal_list_get_next(&chain->sing->super))) { + sing = (opal_pmix3x_single_event_t*)nxt; + if (sing->code == chain->status) { + OBJ_RETAIN(chain); + chain->sing = sing; + opal_output_verbose(2, opal_pmix_base_framework.framework_output, + "%s PROGRESS CALLING SINGLE EVHDLR", + OPAL_NAME_PRINT(OPAL_PROC_MY_NAME)); + sing->handler(chain->status, &chain->source, + chain->info, &chain->results, + progress_local_event_hdlr, (void*)chain); + goto complete; + } + } + /* if we get here, then there are no more single code + * events that match */ + chain->sing = NULL; + /* pickup the beginning of the multi-code event list */ + if (0 < opal_list_get_size(&mca_pmix_pmix3x_component.multi_events)) { + chain->multi = (opal_pmix3x_multi_event_t*)opal_list_get_begin(&mca_pmix_pmix3x_component.multi_events); + } + } + + /* see if we need to continue with the multi code events */ + if (NULL != chain->multi) { + while (opal_list_get_end(&mca_pmix_pmix3x_component.multi_events) != (nxt = opal_list_get_next(&chain->multi->super))) { + multi = (opal_pmix3x_multi_event_t*)nxt; + for (n=0; n < multi->ncodes; n++) { + if (multi->codes[n] == chain->status) { + /* found it - invoke the handler, pointing its + * callback function to our progression function */ + OBJ_RETAIN(chain); + chain->multi = multi; + opal_output_verbose(2, opal_pmix_base_framework.framework_output, + "%s PROGRESS CALLING MULTI EVHDLR", + OPAL_NAME_PRINT(OPAL_PROC_MY_NAME)); + multi->handler(chain->status, &chain->source, + chain->info, &chain->results, + progress_local_event_hdlr, (void*)chain); + goto complete; + } + } + } + /* if we get here, then there are no more multi-mode + * events that match */ + chain->multi = NULL; + /* pickup the beginning of the default event list */ + if (0 < opal_list_get_size(&mca_pmix_pmix3x_component.default_events)) { + chain->def = (opal_pmix3x_default_event_t*)opal_list_get_begin(&mca_pmix_pmix3x_component.default_events); + } + } + + /* if they didn't want it to go to a default handler, then we are done */ + if (chain->nondefault) { + goto complete; + } + + if (NULL != chain->def) { + if (opal_list_get_end(&mca_pmix_pmix3x_component.default_events) != (nxt = opal_list_get_next(&chain->def->super))) { + def = (opal_pmix3x_default_event_t*)nxt; + OBJ_RETAIN(chain); + chain->def = def; + opal_output_verbose(2, opal_pmix_base_framework.framework_output, + "%s PROGRESS CALLING DEFAULT EVHDLR", + OPAL_NAME_PRINT(OPAL_PROC_MY_NAME)); + def->handler(chain->status, &chain->source, + chain->info, &chain->results, + progress_local_event_hdlr, (void*)chain); + } + } + + complete: + /* we still have to call their final callback */ + if (NULL != chain->final_cbfunc) { + chain->final_cbfunc(OPAL_SUCCESS, chain->final_cbdata); + } + /* maintain acctng */ + OBJ_RELEASE(chain); + /* let the caller know that we are done with their callback */ + if (NULL != cbfunc) { + cbfunc(OPAL_SUCCESS, thiscbdata); + } +} + +static void _event_hdlr(int sd, short args, void *cbdata) +{ + pmix3x_threadshift_t *cd = (pmix3x_threadshift_t*)cbdata; + size_t n; + opal_pmix3x_event_chain_t *chain; + opal_pmix3x_single_event_t *sing; + opal_pmix3x_multi_event_t *multi; + opal_pmix3x_default_event_t *def; + + opal_output_verbose(2, opal_pmix_base_framework.framework_output, + "%s _EVENT_HDLR RECEIVED NOTIFICATION OF STATUS %d", + OPAL_NAME_PRINT(OPAL_PROC_MY_NAME), cd->status); + + chain = OBJ_NEW(opal_pmix3x_event_chain_t); + /* point it at our final callback */ + chain->final_cbfunc = completion_handler; + chain->final_cbdata = chain; + + /* carry across provided info */ + chain->status = cd->status; + chain->source = cd->pname; + chain->info = cd->info; + chain->nondefault = cd->nondefault; + + /* cycle thru the single-event registrations first */ + OPAL_LIST_FOREACH(sing, &mca_pmix_pmix3x_component.single_events, opal_pmix3x_single_event_t) { + if (sing->code == chain->status) { + /* found it - invoke the handler, pointing its + * callback function to our progression function */ + OBJ_RETAIN(chain); + chain->sing = sing; + opal_output_verbose(2, opal_pmix_base_framework.framework_output, + "%s _EVENT_HDLR CALLING SINGLE EVHDLR", + OPAL_NAME_PRINT(OPAL_PROC_MY_NAME)); + sing->handler(chain->status, &chain->source, + chain->info, &chain->results, + progress_local_event_hdlr, (void*)chain); + return; + } + } + + /* if we didn't find any match in the single-event registrations, + * then cycle thru the multi-event registrations next */ + OPAL_LIST_FOREACH(multi, &mca_pmix_pmix3x_component.multi_events, opal_pmix3x_multi_event_t) { + for (n=0; n < multi->ncodes; n++) { + if (multi->codes[n] == chain->status) { + /* found it - invoke the handler, pointing its + * callback function to our progression function */ + OBJ_RETAIN(chain); + chain->multi = multi; + opal_output_verbose(2, opal_pmix_base_framework.framework_output, + "%s _EVENT_HDLR CALLING MULTI EVHDLR", + OPAL_NAME_PRINT(OPAL_PROC_MY_NAME)); + multi->handler(chain->status, &chain->source, + chain->info, &chain->results, + progress_local_event_hdlr, (void*)chain); + return; + } + } + } + + /* if they didn't want it to go to a default handler, then we are done */ + if (chain->nondefault) { + /* if we get here, then we need to cache this event in case they + * register for it later - we cannot lose individual events */ + opal_list_append(&mca_pmix_pmix3x_component.cache, &chain->super); + return; + } + + /* we are done with the threadshift caddy */ + OBJ_RELEASE(cd); + + /* finally, pass it to any default handlers */ + if (0 < opal_list_get_size(&mca_pmix_pmix3x_component.default_events)) { + def = (opal_pmix3x_default_event_t*)opal_list_get_first(&mca_pmix_pmix3x_component.default_events); + OBJ_RETAIN(chain); + chain->def = def; + opal_output_verbose(2, opal_pmix_base_framework.framework_output, + "%s _EVENT_HDLR CALLING DEFAULT EVHDLR", + OPAL_NAME_PRINT(OPAL_PROC_MY_NAME)); + def->handler(chain->status, &chain->source, + chain->info, &chain->results, + progress_local_event_hdlr, (void*)chain); + return; + } + + /* we still have to call their final callback */ + if (NULL != chain->final_cbfunc) { + chain->final_cbfunc(PMIX_SUCCESS, chain->final_cbdata); + } + return; +} + +/* this function will be called by the PMIx client library + * whenever it receives notification of an event. The + * notification can come from an ORTE daemon (when launched + * by mpirun), directly from a RM (when direct launched), or + * from another process (via the local daemon). + * The call will occur in the PMIx event base */ +void pmix3x_event_hdlr(size_t evhdlr_registration_id, + pmix_status_t status, const pmix_proc_t *source, + pmix_info_t info[], size_t ninfo, + pmix_info_t results[], size_t nresults, + pmix_event_notification_cbfunc_fn_t cbfunc, + void *cbdata) +{ + pmix3x_threadshift_t *cd; + int rc; + opal_value_t *iptr; + size_t n; + + /* this is in the PMIx local thread - need to threadshift to + * our own thread as we will be accessing framework-global + * lists and objects */ + + opal_output_verbose(2, opal_pmix_base_framework.framework_output, + "%s RECEIVED NOTIFICATION OF STATUS %d", + OPAL_NAME_PRINT(OPAL_PROC_MY_NAME), status); + + cd = OBJ_NEW(pmix3x_threadshift_t); + + /* convert the incoming status */ + cd->status = pmix3x_convert_rc(status); + opal_output_verbose(2, opal_pmix_base_framework.framework_output, + "%s CONVERTED STATUS %d TO STATUS %d", + OPAL_NAME_PRINT(OPAL_PROC_MY_NAME), status, cd->status); + + /* convert the nspace/rank to an opal_process_name_t */ + if (NULL == source) { + cd->pname.jobid = OPAL_NAME_INVALID->jobid; + cd->pname.vpid = OPAL_NAME_INVALID->vpid; + } else { + if (OPAL_SUCCESS != (rc = opal_convert_string_to_jobid(&cd->pname.jobid, source->nspace))) { + OPAL_ERROR_LOG(rc); + OBJ_RELEASE(cd); + return; + } + cd->pname.vpid = pmix3x_convert_rank(source->rank); + } + + /* convert the array of info */ + if (NULL != info) { + cd->info = OBJ_NEW(opal_list_t); + for (n=0; n < ninfo; n++) { + if (0 == strncmp(info[n].key, PMIX_EVENT_NON_DEFAULT, PMIX_MAX_KEYLEN)) { + cd->nondefault = true; + } + iptr = OBJ_NEW(opal_value_t); + iptr->key = strdup(info[n].key); + if (OPAL_SUCCESS != (rc = pmix3x_value_unload(iptr, &info[n].value))) { + OPAL_ERROR_LOG(rc); + OBJ_RELEASE(iptr); + continue; + } + opal_list_append(cd->info, &iptr->super); + } + } + /* now push it into the local thread */ + event_assign(&cd->ev, opal_pmix_base.evbase, + -1, EV_WRITE, _event_hdlr, cd); + event_active(&cd->ev, EV_WRITE, 1); + + /* we don't need any of the data they provided, + * so let them go - also tell them that we will handle + * everything from this point forward */ + if (NULL != cbfunc) { + cbfunc(PMIX_EVENT_ACTION_COMPLETE, NULL, 0, NULL, NULL, cbdata); + } +} + +opal_vpid_t pmix3x_convert_rank(int rank) +{ + switch(rank) { + case PMIX_RANK_UNDEF: + return OPAL_VPID_INVALID; + case PMIX_RANK_WILDCARD: + return OPAL_VPID_WILDCARD; + default: + return (opal_vpid_t)rank; + } +} + +pmix_rank_t pmix3x_convert_opalrank(opal_vpid_t vpid) +{ + switch(vpid) { + case OPAL_VPID_WILDCARD: + return PMIX_RANK_WILDCARD; + case OPAL_VPID_INVALID: + return PMIX_RANK_UNDEF; + default: + return (pmix_rank_t)vpid; + } +} + +pmix_status_t pmix3x_convert_opalrc(int rc) +{ + switch (rc) { + case OPAL_ERR_DEBUGGER_RELEASE: + return PMIX_ERR_DEBUGGER_RELEASE; + + case OPAL_ERR_HANDLERS_COMPLETE: + return PMIX_EVENT_ACTION_COMPLETE; + + case OPAL_ERR_PROC_ABORTED: + return PMIX_ERR_PROC_ABORTED; + + case OPAL_ERR_PROC_REQUESTED_ABORT: + return PMIX_ERR_PROC_REQUESTED_ABORT; + + case OPAL_ERR_PROC_ABORTING: + return PMIX_ERR_PROC_ABORTING; + + case OPAL_ERR_NODE_DOWN: + return PMIX_ERR_NODE_DOWN; + + case OPAL_ERR_NODE_OFFLINE: + return PMIX_ERR_NODE_OFFLINE; + + case OPAL_ERR_JOB_TERMINATED: + return PMIX_ERR_JOB_TERMINATED; + + case OPAL_ERR_PROC_RESTART: + return PMIX_ERR_PROC_RESTART; + + case OPAL_ERR_PROC_CHECKPOINT: + return PMIX_ERR_PROC_CHECKPOINT; + + case OPAL_ERR_PROC_MIGRATE: + return PMIX_ERR_PROC_MIGRATE; + + case OPAL_ERR_EVENT_REGISTRATION: + return PMIX_ERR_EVENT_REGISTRATION; + + case OPAL_ERR_NOT_IMPLEMENTED: + case OPAL_ERR_NOT_SUPPORTED: + return PMIX_ERR_NOT_SUPPORTED; + + case OPAL_ERR_NOT_FOUND: + return PMIX_ERR_NOT_FOUND; + + case OPAL_ERR_PERM: + case OPAL_ERR_UNREACH: + case OPAL_ERR_SERVER_NOT_AVAIL: + return PMIX_ERR_UNREACH; + + case OPAL_ERR_BAD_PARAM: + return PMIX_ERR_BAD_PARAM; + + case OPAL_ERR_OUT_OF_RESOURCE: + return PMIX_ERR_OUT_OF_RESOURCE; + + case OPAL_ERR_DATA_VALUE_NOT_FOUND: + return PMIX_ERR_DATA_VALUE_NOT_FOUND; + + case OPAL_ERR_TIMEOUT: + return PMIX_ERR_TIMEOUT; + + case OPAL_ERR_WOULD_BLOCK: + return PMIX_ERR_WOULD_BLOCK; + + case OPAL_EXISTS: + return PMIX_EXISTS; + + case OPAL_ERR_PARTIAL_SUCCESS: + return PMIX_QUERY_PARTIAL_SUCCESS; + + case OPAL_ERROR: + return PMIX_ERROR; + case OPAL_SUCCESS: + return PMIX_SUCCESS; + default: + return PMIX_ERROR; + } +} + +int pmix3x_convert_rc(pmix_status_t rc) +{ + switch (rc) { + case PMIX_ERR_DEBUGGER_RELEASE: + return OPAL_ERR_DEBUGGER_RELEASE; + + case PMIX_EVENT_ACTION_COMPLETE: + return OPAL_ERR_HANDLERS_COMPLETE; + + case PMIX_ERR_PROC_ABORTED: + return OPAL_ERR_PROC_ABORTED; + + case PMIX_ERR_PROC_REQUESTED_ABORT: + return OPAL_ERR_PROC_REQUESTED_ABORT; + + case PMIX_ERR_PROC_ABORTING: + return OPAL_ERR_PROC_ABORTING; + + case PMIX_ERR_NODE_DOWN: + return OPAL_ERR_NODE_DOWN; + + case PMIX_ERR_NODE_OFFLINE: + return OPAL_ERR_NODE_OFFLINE; + + case PMIX_ERR_JOB_TERMINATED: + return OPAL_ERR_JOB_TERMINATED; + + case PMIX_ERR_PROC_RESTART: + return OPAL_ERR_PROC_RESTART; + + case PMIX_ERR_PROC_CHECKPOINT: + return OPAL_ERR_PROC_CHECKPOINT; + + case PMIX_ERR_PROC_MIGRATE: + return OPAL_ERR_PROC_MIGRATE; + + case PMIX_ERR_EVENT_REGISTRATION: + return OPAL_ERR_EVENT_REGISTRATION; + + case PMIX_ERR_NOT_SUPPORTED: + return OPAL_ERR_NOT_SUPPORTED; + + case PMIX_ERR_NOT_FOUND: + return OPAL_ERR_NOT_FOUND; + + case PMIX_ERR_OUT_OF_RESOURCE: + return OPAL_ERR_OUT_OF_RESOURCE; + + case PMIX_ERR_INIT: + return OPAL_ERROR; + + case PMIX_ERR_BAD_PARAM: + return OPAL_ERR_BAD_PARAM; + + case PMIX_ERR_UNREACH: + case PMIX_ERR_NO_PERMISSIONS: + return OPAL_ERR_UNREACH; + + case PMIX_ERR_TIMEOUT: + return OPAL_ERR_TIMEOUT; + + case PMIX_ERR_WOULD_BLOCK: + return OPAL_ERR_WOULD_BLOCK; + + case PMIX_ERR_LOST_CONNECTION_TO_SERVER: + case PMIX_ERR_LOST_PEER_CONNECTION: + case PMIX_ERR_LOST_CONNECTION_TO_CLIENT: + return OPAL_ERR_COMM_FAILURE; + + case PMIX_EXISTS: + return OPAL_EXISTS; + + case PMIX_QUERY_PARTIAL_SUCCESS: + return OPAL_ERR_PARTIAL_SUCCESS; + + case PMIX_ERROR: + return OPAL_ERROR; + case PMIX_SUCCESS: + return OPAL_SUCCESS; + default: + return OPAL_ERROR; + } +} + +opal_pmix_scope_t pmix3x_convert_scope(pmix_scope_t scope) +{ + switch(scope) { + case PMIX_SCOPE_UNDEF: + return OPAL_PMIX_SCOPE_UNDEF; + case PMIX_LOCAL: + return OPAL_PMIX_LOCAL; + case PMIX_REMOTE: + return OPAL_PMIX_REMOTE; + case PMIX_GLOBAL: + return OPAL_PMIX_GLOBAL; + default: + return OPAL_PMIX_SCOPE_UNDEF; + } +} + +pmix_scope_t pmix3x_convert_opalscope(opal_pmix_scope_t scope) { + switch(scope) { + case OPAL_PMIX_LOCAL: + return PMIX_LOCAL; + case OPAL_PMIX_REMOTE: + return PMIX_REMOTE; + case OPAL_PMIX_GLOBAL: + return PMIX_GLOBAL; + default: + return PMIX_SCOPE_UNDEF; + } +} + +pmix_data_range_t pmix3x_convert_opalrange(opal_pmix_data_range_t range) { + switch(range) { + case OPAL_PMIX_RANGE_UNDEF: + return PMIX_RANGE_UNDEF; + case OPAL_PMIX_RANGE_LOCAL: + return PMIX_RANGE_LOCAL; + case OPAL_PMIX_RANGE_NAMESPACE: + return PMIX_RANGE_NAMESPACE; + case OPAL_PMIX_RANGE_SESSION: + return PMIX_RANGE_SESSION; + case OPAL_PMIX_RANGE_GLOBAL: + return PMIX_RANGE_GLOBAL; + case OPAL_PMIX_RANGE_CUSTOM: + return PMIX_RANGE_CUSTOM; + default: + return PMIX_SCOPE_UNDEF; + } +} + +opal_pmix_data_range_t pmix3x_convert_range(pmix_data_range_t range) { + switch(range) { + case PMIX_RANGE_UNDEF: + return OPAL_PMIX_RANGE_UNDEF; + case PMIX_RANGE_LOCAL: + return OPAL_PMIX_RANGE_LOCAL; + case PMIX_RANGE_NAMESPACE: + return OPAL_PMIX_RANGE_NAMESPACE; + case PMIX_RANGE_SESSION: + return OPAL_PMIX_RANGE_SESSION; + case PMIX_RANGE_GLOBAL: + return OPAL_PMIX_RANGE_GLOBAL; + case PMIX_RANGE_CUSTOM: + return OPAL_PMIX_RANGE_CUSTOM; + default: + return OPAL_PMIX_SCOPE_UNDEF; + } +} + +opal_pmix_persistence_t pmix3x_convert_persist(pmix_persistence_t persist) +{ + switch(persist) { + case PMIX_PERSIST_INDEF: + return OPAL_PMIX_PERSIST_INDEF; + case PMIX_PERSIST_FIRST_READ: + return OPAL_PMIX_PERSIST_FIRST_READ; + case PMIX_PERSIST_PROC: + return OPAL_PMIX_PERSIST_PROC; + case PMIX_PERSIST_APP: + return OPAL_PMIX_PERSIST_APP; + case PMIX_PERSIST_SESSION: + return OPAL_PMIX_PERSIST_SESSION; + default: + return OPAL_PMIX_PERSIST_INDEF; + } +} + +pmix_persistence_t pmix3x_convert_opalpersist(opal_pmix_persistence_t persist) +{ + switch(persist) { + case OPAL_PMIX_PERSIST_INDEF: + return PMIX_PERSIST_INDEF; + case OPAL_PMIX_PERSIST_FIRST_READ: + return PMIX_PERSIST_FIRST_READ; + case OPAL_PMIX_PERSIST_PROC: + return PMIX_PERSIST_PROC; + case OPAL_PMIX_PERSIST_APP: + return PMIX_PERSIST_APP; + case OPAL_PMIX_PERSIST_SESSION: + return PMIX_PERSIST_SESSION; + default: + return PMIX_PERSIST_INDEF; + } +} + +/**** RHC: NEED TO ADD SUPPORT FOR NEW PMIX DATA TYPES, INCLUDING + **** CONVERSION OF PROC STATES ****/ + +void pmix3x_value_load(pmix_value_t *v, + opal_value_t *kv) +{ + switch(kv->type) { + case OPAL_UNDEF: + v->type = PMIX_UNDEF; + break; + case OPAL_BOOL: + v->type = PMIX_BOOL; + memcpy(&(v->data.flag), &kv->data.flag, 1); + break; + case OPAL_BYTE: + v->type = PMIX_BYTE; + memcpy(&(v->data.byte), &kv->data.byte, 1); + break; + case OPAL_STRING: + v->type = PMIX_STRING; + if (NULL != kv->data.string) { + v->data.string = strdup(kv->data.string); + } else { + v->data.string = NULL; + } + break; + case OPAL_SIZE: + v->type = PMIX_SIZE; + v->data.size = (size_t)kv->data.size; + break; + case OPAL_PID: + v->type = PMIX_PID; + memcpy(&(v->data.pid), &kv->data.pid, sizeof(pid_t)); + break; + case OPAL_INT: + v->type = PMIX_INT; + memcpy(&(v->data.integer), &kv->data.integer, sizeof(int)); + break; + case OPAL_INT8: + v->type = PMIX_INT8; + memcpy(&(v->data.int8), &kv->data.int8, 1); + break; + case OPAL_INT16: + v->type = PMIX_INT16; + memcpy(&(v->data.int16), &kv->data.int16, 2); + break; + case OPAL_INT32: + v->type = PMIX_INT32; + memcpy(&(v->data.int32), &kv->data.int32, 4); + break; + case OPAL_INT64: + v->type = PMIX_INT64; + memcpy(&(v->data.int64), &kv->data.int64, 8); + break; + case OPAL_UINT: + v->type = PMIX_UINT; + memcpy(&(v->data.uint), &kv->data.uint, sizeof(int)); + break; + case OPAL_UINT8: + v->type = PMIX_UINT8; + memcpy(&(v->data.uint8), &kv->data.uint8, 1); + break; + case OPAL_UINT16: + v->type = PMIX_UINT16; + memcpy(&(v->data.uint16), &kv->data.uint16, 2); + break; + case OPAL_UINT32: + v->type = PMIX_UINT32; + memcpy(&(v->data.uint32), &kv->data.uint32, 4); + break; + case OPAL_UINT64: + v->type = PMIX_UINT64; + memcpy(&(v->data.uint64), &kv->data.uint64, 8); + break; + case OPAL_FLOAT: + v->type = PMIX_FLOAT; + memcpy(&(v->data.fval), &kv->data.fval, sizeof(float)); + break; + case OPAL_DOUBLE: + v->type = PMIX_DOUBLE; + memcpy(&(v->data.dval), &kv->data.dval, sizeof(double)); + break; + case OPAL_TIMEVAL: + v->type = PMIX_TIMEVAL; + memcpy(&(v->data.tv), &kv->data.tv, sizeof(struct timeval)); + break; + case OPAL_TIME: + v->type = PMIX_TIME; + memcpy(&(v->data.time), &kv->data.time, sizeof(time_t)); + break; + case OPAL_STATUS: + v->type = PMIX_STATUS; + memcpy(&(v->data.status), &kv->data.status, sizeof(pmix_status_t)); + break; + case OPAL_VPID: + v->type = PMIX_PROC_RANK; + v->data.rank = pmix3x_convert_opalrank(kv->data.name.vpid); + break; + case OPAL_NAME: + v->type = PMIX_PROC; + /* have to stringify the jobid */ + PMIX_PROC_CREATE(v->data.proc, 1); + (void)opal_snprintf_jobid(v->data.proc->nspace, PMIX_MAX_NSLEN, kv->data.name.vpid); + v->data.proc->rank = pmix3x_convert_opalrank(kv->data.name.vpid); + break; + case OPAL_BYTE_OBJECT: + v->type = PMIX_BYTE_OBJECT; + if (NULL != kv->data.bo.bytes) { + v->data.bo.bytes = (char*)malloc(kv->data.bo.size); + memcpy(v->data.bo.bytes, kv->data.bo.bytes, kv->data.bo.size); + v->data.bo.size = (size_t)kv->data.bo.size; + } else { + v->data.bo.bytes = NULL; + v->data.bo.size = 0; + } + break; + case OPAL_PERSIST: + v->type = PMIX_PERSIST; + v->data.persist = pmix3x_convert_opalpersist(kv->data.uint8); + break; + case OPAL_SCOPE: + v->type = PMIX_SCOPE; + v->data.scope = pmix3x_convert_opalscope(kv->data.uint8); + break; + case OPAL_DATA_RANGE: + v->type = PMIX_DATA_RANGE; + v->data.range = pmix3x_convert_opalrange(kv->data.uint8); + break; + case OPAL_PROC_STATE: + v->type = PMIX_PROC_STATE; + /* the OPAL layer doesn't have any concept of proc state, + * so the ORTE layer is responsible for converting it */ + memcpy(&v->data.state, &kv->data.uint8, sizeof(uint8_t)); + break; + case OPAL_PTR: + v->type = PMIX_POINTER; + v->data.ptr = kv->data.ptr; + break; + default: + /* silence warnings */ + break; + } +} + +int pmix3x_value_unload(opal_value_t *kv, + const pmix_value_t *v) +{ + int rc=OPAL_SUCCESS; + + + switch(v->type) { + case PMIX_UNDEF: + kv->type = OPAL_UNDEF; + break; + case PMIX_BOOL: + kv->type = OPAL_BOOL; + memcpy(&kv->data.flag, &(v->data.flag), 1); + break; + case PMIX_BYTE: + kv->type = OPAL_BYTE; + memcpy(&kv->data.byte, &(v->data.byte), 1); + break; + case PMIX_STRING: + kv->type = OPAL_STRING; + if (NULL != v->data.string) { + kv->data.string = strdup(v->data.string); + } + break; + case PMIX_SIZE: + kv->type = OPAL_SIZE; + kv->data.size = (int)v->data.size; + break; + case PMIX_PID: + kv->type = OPAL_PID; + memcpy(&kv->data.pid, &(v->data.pid), sizeof(pid_t)); + break; + case PMIX_INT: + kv->type = OPAL_INT; + memcpy(&kv->data.integer, &(v->data.integer), sizeof(int)); + break; + case PMIX_INT8: + kv->type = OPAL_INT8; + memcpy(&kv->data.int8, &(v->data.int8), 1); + break; + case PMIX_INT16: + kv->type = OPAL_INT16; + memcpy(&kv->data.int16, &(v->data.int16), 2); + break; + case PMIX_INT32: + kv->type = OPAL_INT32; + memcpy(&kv->data.int32, &(v->data.int32), 4); + break; + case PMIX_INT64: + kv->type = OPAL_INT64; + memcpy(&kv->data.int64, &(v->data.int64), 8); + break; + case PMIX_UINT: + kv->type = OPAL_UINT; + memcpy(&kv->data.uint, &(v->data.uint), sizeof(int)); + break; + case PMIX_UINT8: + kv->type = OPAL_UINT8; + memcpy(&kv->data.uint8, &(v->data.uint8), 1); + break; + case PMIX_UINT16: + kv->type = OPAL_UINT16; + memcpy(&kv->data.uint16, &(v->data.uint16), 2); + break; + case PMIX_UINT32: + kv->type = OPAL_UINT32; + memcpy(&kv->data.uint32, &(v->data.uint32), 4); + break; + case PMIX_UINT64: + kv->type = OPAL_UINT64; + memcpy(&kv->data.uint64, &(v->data.uint64), 8); + break; + case PMIX_FLOAT: + kv->type = OPAL_FLOAT; + memcpy(&kv->data.fval, &(v->data.fval), sizeof(float)); + break; + case PMIX_DOUBLE: + kv->type = OPAL_DOUBLE; + memcpy(&kv->data.dval, &(v->data.dval), sizeof(double)); + break; + case PMIX_TIMEVAL: + kv->type = OPAL_TIMEVAL; + memcpy(&kv->data.tv, &(v->data.tv), sizeof(struct timeval)); + break; + case PMIX_TIME: + kv->type = OPAL_TIME; + memcpy(&kv->data.time, &(v->data.time), sizeof(time_t)); + break; + case PMIX_STATUS: + kv->type = OPAL_STATUS; + memcpy(&kv->data.status, &(v->data.status), sizeof(opal_status_t)); + break; + case PMIX_PROC_RANK: + kv->type = OPAL_VPID; + kv->data.name.vpid = pmix3x_convert_rank(v->data.rank); + break; + case PMIX_PROC: + kv->type = OPAL_NAME; + if (OPAL_SUCCESS != (rc = opal_convert_string_to_jobid(&kv->data.name.jobid, v->data.proc->nspace))) { + return pmix3x_convert_opalrc(rc); + } + kv->data.name.vpid = pmix3x_convert_rank(v->data.proc->rank); + break; + case PMIX_BYTE_OBJECT: + kv->type = OPAL_BYTE_OBJECT; + if (NULL != v->data.bo.bytes && 0 < v->data.bo.size) { + kv->data.bo.bytes = (uint8_t*)malloc(v->data.bo.size); + memcpy(kv->data.bo.bytes, v->data.bo.bytes, v->data.bo.size); + kv->data.bo.size = (int)v->data.bo.size; + } else { + kv->data.bo.bytes = NULL; + kv->data.bo.size = 0; + } + break; + case PMIX_PERSIST: + kv->type = OPAL_PERSIST; + kv->data.uint8 = pmix3x_convert_persist(v->data.persist); + break; + case PMIX_SCOPE: + kv->type = OPAL_SCOPE; + kv->data.uint8 = pmix3x_convert_scope(v->data.scope); + break; + case PMIX_DATA_RANGE: + kv->type = OPAL_DATA_RANGE; + kv->data.uint8 = pmix3x_convert_range(v->data.range); + break; + case PMIX_PROC_STATE: + kv->type = OPAL_PROC_STATE; + /* the OPAL layer doesn't have any concept of proc state, + * so the ORTE layer is responsible for converting it */ + memcpy(&kv->data.uint8, &v->data.state, sizeof(uint8_t)); + break; + case PMIX_POINTER: + kv->type = OPAL_PTR; + kv->data.ptr = v->data.ptr; + break; + default: + /* silence warnings */ + rc = OPAL_ERROR; + break; + } + return rc; +} + +static void _reg_hdlr(int sd, short args, void *cbdata) +{ + pmix3x_threadshift_t *cd = (pmix3x_threadshift_t*)cbdata; + opal_pmix3x_event_chain_t *chain; + opal_pmix3x_single_event_t *sing = NULL; + opal_pmix3x_multi_event_t *multi = NULL; + opal_pmix3x_default_event_t *def = NULL; + opal_value_t *kv; + int i; + bool prepend = false; + size_t n; + + opal_output_verbose(2, opal_pmix_base_framework.framework_output, + "%s REGISTER HANDLER CODES %s", + OPAL_NAME_PRINT(OPAL_PROC_MY_NAME), + (NULL == cd->event_codes) ? "NULL" : "NON-NULL"); + + if (NULL != cd->info) { + OPAL_LIST_FOREACH(kv, cd->info, opal_value_t) { + if (0 == strcmp(kv->key, OPAL_PMIX_EVENT_ORDER_PREPEND)) { + prepend = true; + break; + } + } + } + + if (NULL == cd->event_codes) { + /* this is a default handler */ + def = OBJ_NEW(opal_pmix3x_default_event_t); + def->handler = cd->evhandler; + def->index = mca_pmix_pmix3x_component.evindex; + if (prepend) { + opal_output_verbose(2, opal_pmix_base_framework.framework_output, + "%s PREPENDING TO DEFAULT EVENTS", + OPAL_NAME_PRINT(OPAL_PROC_MY_NAME)); + opal_list_prepend(&mca_pmix_pmix3x_component.default_events, &def->super); + } else { + opal_output_verbose(2, opal_pmix_base_framework.framework_output, + "%s APPENDING TO DEFAULT EVENTS", + OPAL_NAME_PRINT(OPAL_PROC_MY_NAME)); + opal_list_append(&mca_pmix_pmix3x_component.default_events, &def->super); + } + } else if (1 == opal_list_get_size(cd->event_codes)) { + /* single handler */ + sing = OBJ_NEW(opal_pmix3x_single_event_t); + kv = (opal_value_t*)opal_list_get_first(cd->event_codes); + sing->code = kv->data.integer; + sing->index = mca_pmix_pmix3x_component.evindex; + sing->handler = cd->evhandler; + if (prepend) { + opal_output_verbose(2, opal_pmix_base_framework.framework_output, + "%s PREPENDING TO SINGLE EVENTS WITH CODE %d", + OPAL_NAME_PRINT(OPAL_PROC_MY_NAME), sing->code); + opal_list_prepend(&mca_pmix_pmix3x_component.single_events, &sing->super); + } else { + opal_output_verbose(2, opal_pmix_base_framework.framework_output, + "%s APPENDING TO SINGLE EVENTS WITH CODE %d", + OPAL_NAME_PRINT(OPAL_PROC_MY_NAME), sing->code); + opal_list_append(&mca_pmix_pmix3x_component.single_events, &sing->super); + } + } else { + multi = OBJ_NEW(opal_pmix3x_multi_event_t); + multi->ncodes = opal_list_get_size(cd->event_codes); + multi->codes = (int*)malloc(multi->ncodes * sizeof(int)); + i=0; + OPAL_LIST_FOREACH(kv, cd->event_codes, opal_value_t) { + multi->codes[i] = kv->data.integer; + ++i; + } + multi->index = mca_pmix_pmix3x_component.evindex; + multi->handler = cd->evhandler; + if (prepend) { + opal_output_verbose(2, opal_pmix_base_framework.framework_output, + "%s PREPENDING TO MULTI EVENTS", + OPAL_NAME_PRINT(OPAL_PROC_MY_NAME)); + opal_list_prepend(&mca_pmix_pmix3x_component.multi_events, &multi->super); + } else { + opal_output_verbose(2, opal_pmix_base_framework.framework_output, + "%s APPENDING TO MULTI EVENTS", + OPAL_NAME_PRINT(OPAL_PROC_MY_NAME)); + opal_list_append(&mca_pmix_pmix3x_component.multi_events, &multi->super); + } + } + + /* release the caller */ + if (NULL != cd->cbfunc) { + cd->cbfunc(OPAL_SUCCESS, mca_pmix_pmix3x_component.evindex, cd->cbdata); + } + mca_pmix_pmix3x_component.evindex++; + + /* check if any matching notifications have been cached - only nondefault + * events will have been cached*/ + if (NULL == def) { + /* check single code registrations */ + if (NULL != sing) { + OPAL_LIST_FOREACH(chain, &mca_pmix_pmix3x_component.cache, opal_pmix3x_event_chain_t) { + if (sing->code == chain->status) { + opal_list_remove_item(&mca_pmix_pmix3x_component.cache, &chain->super); + chain->sing = sing; + sing->handler(chain->status, &chain->source, + chain->info, &chain->results, + progress_local_event_hdlr, (void*)chain); + OBJ_RELEASE(cd); + return; + } + } + } else if (NULL != multi) { + /* check for multi code registrations */ + OPAL_LIST_FOREACH(chain, &mca_pmix_pmix3x_component.cache, opal_pmix3x_event_chain_t) { + for (n=0; n < multi->ncodes; n++) { + if (multi->codes[n] == chain->status) { + opal_list_remove_item(&mca_pmix_pmix3x_component.cache, &chain->super); + chain->multi = multi; + multi->handler(chain->status, &chain->source, + chain->info, &chain->results, + progress_local_event_hdlr, (void*)chain); + OBJ_RELEASE(cd); + return; + } + } + } + } + } + + OBJ_RELEASE(cd); + return; +} +static void register_handler(opal_list_t *event_codes, + opal_list_t *info, + opal_pmix_notification_fn_t evhandler, + opal_pmix_evhandler_reg_cbfunc_t cbfunc, + void *cbdata) +{ + /* we must threadshift this request as we might not be in an event + * and we are going to access framework-global lists/objects */ + + OPAL_PMIX_THREADSHIFT(event_codes, info, evhandler, _reg_hdlr, cbfunc, cbdata); + return; +} + +static void _dereg_hdlr(int sd, short args, void *cbdata) +{ + pmix3x_threadshift_t *cd = (pmix3x_threadshift_t*)cbdata; + opal_pmix3x_single_event_t *sing; + opal_pmix3x_multi_event_t *multi; + opal_pmix3x_default_event_t *def; + + /* check the single events first */ + OPAL_LIST_FOREACH(sing, &mca_pmix_pmix3x_component.single_events, opal_pmix3x_single_event_t) { + if (cd->handler == sing->index) { + opal_list_remove_item(&mca_pmix_pmix3x_component.single_events, &sing->super); + OBJ_RELEASE(sing); + goto release; + } + } + /* check multi events */ + OPAL_LIST_FOREACH(multi, &mca_pmix_pmix3x_component.multi_events, opal_pmix3x_multi_event_t) { + if (cd->handler == multi->index) { + opal_list_remove_item(&mca_pmix_pmix3x_component.multi_events, &multi->super); + OBJ_RELEASE(multi); + goto release; + } + } + /* check default events */ + OPAL_LIST_FOREACH(def, &mca_pmix_pmix3x_component.default_events, opal_pmix3x_default_event_t) { + if (cd->handler == def->index) { + opal_list_remove_item(&mca_pmix_pmix3x_component.default_events, &def->super); + OBJ_RELEASE(def); + break; + } + } + + release: + if (NULL != cd->opcbfunc) { + cd->opcbfunc(OPAL_SUCCESS, cd->cbdata); + } + OBJ_RELEASE(cd); +} + +static void deregister_handler(size_t evhandler, + opal_pmix_op_cbfunc_t cbfunc, + void *cbdata) +{ + /* we must threadshift this request as we might not be in an event + * and we are going to access framework-global lists/objects */ + OPAL_PMIX_OP_THREADSHIFT(evhandler, _dereg_hdlr, cbfunc, cbdata); + return; +} + +static void _notify_event(int sd, short args, void *cbdata) +{ + pmix3x_threadshift_t *cd = (pmix3x_threadshift_t*)cbdata; + size_t i; + opal_pmix3x_single_event_t *sing; + opal_pmix3x_multi_event_t *multi; + opal_pmix3x_default_event_t *def; + opal_pmix3x_event_chain_t *chain; + + /* check the single events first */ + OPAL_LIST_FOREACH(sing, &mca_pmix_pmix3x_component.single_events, opal_pmix3x_single_event_t) { + if (cd->status == sing->code) { + /* found it - invoke the handler, pointing its + * callback function to our progression function */ + chain = OBJ_NEW(opal_pmix3x_event_chain_t); + chain->status = cd->status; + chain->range = pmix3x_convert_opalrange(cd->range); + chain->source = *(cd->source); + chain->info = cd->info; + chain->final_cbfunc = cd->opcbfunc; + chain->final_cbdata = cd->cbdata; + chain->sing = sing; + opal_output_verbose(2, opal_pmix_base_framework.framework_output, + "[%s] CALLING SINGLE EVHDLR FOR STATUS %d", + OPAL_NAME_PRINT(OPAL_PROC_MY_NAME), chain->status); + sing->handler(chain->status, &chain->source, + chain->info, &chain->results, + progress_local_event_hdlr, (void*)chain); + OBJ_RELEASE(cd); + return; + } + } + /* check multi events */ + OPAL_LIST_FOREACH(multi, &mca_pmix_pmix3x_component.multi_events, opal_pmix3x_multi_event_t) { + for (i=0; i < multi->ncodes; i++) { + if (cd->status == multi->codes[i]) { + /* found it - invoke the handler, pointing its + * callback function to our progression function */ + chain = OBJ_NEW(opal_pmix3x_event_chain_t); + chain->status = cd->status; + chain->range = pmix3x_convert_opalrange(cd->range); + chain->source = *(cd->source); + chain->info = cd->info; + chain->final_cbfunc = cd->opcbfunc; + chain->final_cbdata = cd->cbdata; + chain->multi = multi; + opal_output_verbose(2, opal_pmix_base_framework.framework_output, + "[%s] CALLING MULTI EVHDLR FOR STATUS %d", + OPAL_NAME_PRINT(OPAL_PROC_MY_NAME), chain->status); + multi->handler(chain->status, &chain->source, + chain->info, &chain->results, + progress_local_event_hdlr, (void*)chain); + OBJ_RELEASE(cd); + return; + } + } + } + /* check default events */ + if (0 < opal_list_get_size(&mca_pmix_pmix3x_component.default_events)) { + def = (opal_pmix3x_default_event_t*)opal_list_get_first(&mca_pmix_pmix3x_component.default_events); + chain = OBJ_NEW(opal_pmix3x_event_chain_t); + chain->status = cd->status; + chain->range = pmix3x_convert_opalrange(cd->range); + chain->source = *(cd->source); + chain->info = cd->info; + chain->final_cbfunc = cd->opcbfunc; + chain->final_cbdata = cd->cbdata; + chain->def = def; + opal_output_verbose(2, opal_pmix_base_framework.framework_output, + "[%s] CALLING DEFAULT EVHDLR FOR STATUS %d", + OPAL_NAME_PRINT(OPAL_PROC_MY_NAME), chain->status); + def->handler(chain->status, &chain->source, + chain->info, &chain->results, + progress_local_event_hdlr, (void*)chain); + OBJ_RELEASE(cd); + return; + } + + /* if we get here, then there are no registered event handlers */ + if (NULL != cd->opcbfunc) { + cd->opcbfunc(OPAL_ERR_NOT_FOUND, cd->cbdata); + } + OBJ_RELEASE(cd); + return; +} + +static int notify_event(int status, + const opal_process_name_t *source, + opal_pmix_data_range_t range, + opal_list_t *info, + opal_pmix_op_cbfunc_t cbfunc, void *cbdata) +{ + /* we must threadshift this request as we might not be in an event + * and we are going to access framework-global lists/objects */ + OPAL_PMIX_NOTIFY_THREADSHIFT(status, source, range, info, _notify_event, cbfunc, cbdata); + return OPAL_SUCCESS; +} + +static void pmix3x_query(opal_list_t *queries, + opal_pmix_info_cbfunc_t cbfunc, void *cbdata) +{ + if (NULL != cbfunc) { + cbfunc(OPAL_ERR_NOT_SUPPORTED, NULL, cbdata, NULL, NULL); + } + return; +} + +static void opcbfunc(pmix_status_t status, void *cbdata) +{ + pmix3x_opcaddy_t *op = (pmix3x_opcaddy_t*)cbdata; + + if (NULL != op->opcbfunc) { + op->opcbfunc(pmix3x_convert_rc(status), op->cbdata); + } + OBJ_RELEASE(op); +} + +static void pmix3x_log(opal_list_t *info, + opal_pmix_op_cbfunc_t cbfunc, void *cbdata) +{ + int rc; + opal_value_t *ival; + size_t n, ninfo; + pmix3x_opcaddy_t *cd; + + /* bozo check */ + if (NULL == info || 0 == (ninfo = opal_list_get_size(info))) { + rc = OPAL_ERR_BAD_PARAM; + goto CLEANUP; + } + + /* setup the operation */ + cd = OBJ_NEW(pmix3x_opcaddy_t); + cd->opcbfunc = cbfunc; + cd->cbdata = cbdata; + cd->ninfo = ninfo; + + /* convert the list to an array of info objects */ + PMIX_INFO_CREATE(cd->info, cd->ninfo); + n=0; + OPAL_LIST_FOREACH(ival, info, opal_value_t) { + (void)strncpy(cd->info[n].key, ival->key, PMIX_MAX_KEYLEN); + pmix3x_value_load(&cd->info[n].value, ival); + ++n; + } + + /* pass it down */ + PMIx_Log_nb(cd->info, cd->ninfo, NULL, 0, + opcbfunc, cd); + return; + + CLEANUP: + if (NULL != cbfunc) { + cbfunc(rc, cbdata); + } +} + +/**** INSTANTIATE INTERNAL CLASSES ****/ +OBJ_CLASS_INSTANCE(opal_pmix3x_jobid_trkr_t, + opal_list_item_t, + NULL, NULL); + +OBJ_CLASS_INSTANCE(opal_pmix3x_single_event_t, + opal_list_item_t, + NULL, NULL); + +static void mtevcon(opal_pmix3x_multi_event_t *p) +{ + p->codes = NULL; + p->ncodes = 0; +} +static void mtevdes(opal_pmix3x_multi_event_t *p) +{ + if (NULL != p->codes) { + free(p->codes); + } +} +OBJ_CLASS_INSTANCE(opal_pmix3x_multi_event_t, + opal_list_item_t, + mtevcon, mtevdes); + +OBJ_CLASS_INSTANCE(opal_pmix3x_default_event_t, + opal_list_item_t, + NULL, NULL); + +static void chcon(opal_pmix3x_event_chain_t *p) +{ + p->nondefault = false; + p->info = NULL; + OBJ_CONSTRUCT(&p->results, opal_list_t); + p->sing = NULL; + p->multi = NULL; + p->def = NULL; + p->final_cbfunc = NULL; + p->final_cbdata = NULL; +} +static void chdes(opal_pmix3x_event_chain_t *p) +{ + OPAL_LIST_DESTRUCT(&p->results); +} +OBJ_CLASS_INSTANCE(opal_pmix3x_event_chain_t, + opal_list_item_t, + chcon, chdes); + +static void opcon(pmix3x_opcaddy_t *p) +{ + memset(&p->p, 0, sizeof(pmix_proc_t)); + p->procs = NULL; + p->nprocs = 0; + p->error_procs = NULL; + p->nerror_procs = 0; + p->info = NULL; + p->ninfo = 0; + p->apps = NULL; + p->sz = 0; + p->active = false; + p->opcbfunc = NULL; + p->mdxcbfunc = NULL; + p->valcbfunc = NULL; + p->lkcbfunc = NULL; + p->spcbfunc = NULL; + p->cbdata = NULL; +} +static void opdes(pmix3x_opcaddy_t *p) +{ + if (NULL != p->procs) { + PMIX_PROC_FREE(p->procs, p->nprocs); + } + if (NULL != p->error_procs) { + PMIX_PROC_FREE(p->error_procs, p->nerror_procs); + } + if (NULL != p->info) { + PMIX_INFO_FREE(p->info, p->sz); + } + if (NULL != p->apps) { + PMIX_APP_FREE(p->apps, p->sz); + } +} +OBJ_CLASS_INSTANCE(pmix3x_opcaddy_t, + opal_object_t, + opcon, opdes); + +static void ocadcon(pmix3x_opalcaddy_t *p) +{ + OBJ_CONSTRUCT(&p->procs, opal_list_t); + OBJ_CONSTRUCT(&p->info, opal_list_t); + OBJ_CONSTRUCT(&p->apps, opal_list_t); + p->opcbfunc = NULL; + p->dmdxfunc = NULL; + p->mdxcbfunc = NULL; + p->lkupcbfunc = NULL; + p->spwncbfunc = NULL; + p->cbdata = NULL; + p->odmdxfunc = NULL; + p->infocbfunc = NULL; + p->toolcbfunc = NULL; + p->ocbdata = NULL; +} +static void ocaddes(pmix3x_opalcaddy_t *p) +{ + OPAL_LIST_DESTRUCT(&p->procs); + OPAL_LIST_DESTRUCT(&p->info); + OPAL_LIST_DESTRUCT(&p->apps); +} +OBJ_CLASS_INSTANCE(pmix3x_opalcaddy_t, + opal_object_t, + ocadcon, ocaddes); + +static void tscon(pmix3x_threadshift_t *p) +{ + p->active = false; + p->source = NULL; + p->event_codes = NULL; + p->info = NULL; + p->evhandler = NULL; + p->nondefault = false; + p->cbfunc = NULL; + p->opcbfunc = NULL; + p->cbdata = NULL; +} +OBJ_CLASS_INSTANCE(pmix3x_threadshift_t, + opal_object_t, + tscon, NULL); diff --git a/opal/mca/pmix/ext3x/pmix3x.h b/opal/mca/pmix/ext3x/pmix3x.h new file mode 100644 index 0000000000..3b85167fa7 --- /dev/null +++ b/opal/mca/pmix/ext3x/pmix3x.h @@ -0,0 +1,323 @@ +/* + * Copyright (c) 2014-2016 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2015 Mellanox Technologies, Inc. + * All rights reserved. + * Copyright (c) 2016 Research Organization for Information Science + * and Technology (RIST). All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#ifndef MCA_PMIX_PMIX2X_H +#define MCA_PMIX_PMIX2X_H + +#include "opal_config.h" + +#ifdef HAVE_SYS_SOCKET_H +#include +#endif +#ifdef HAVE_SYS_UN_H +#include +#endif + +#include "opal/class/opal_list.h" +#include "opal/mca/mca.h" +#include "opal/mca/event/event.h" +#include "opal/util/proc.h" + +#include "opal/mca/pmix/pmix.h" +#include "pmix_server.h" +#include "pmix_common.h" + +BEGIN_C_DECLS + +typedef struct { + opal_pmix_base_component_t super; + opal_list_t jobids; + bool native_launch; + size_t evindex; + opal_list_t single_events; + opal_list_t multi_events; + opal_list_t default_events; + int cache_size; + opal_list_t cache; +} mca_pmix_pmix3x_component_t; + +OPAL_DECLSPEC extern mca_pmix_pmix3x_component_t mca_pmix_pmix3x_component; + +OPAL_DECLSPEC extern const opal_pmix_base_module_t opal_pmix_pmix3x_module; + +/**** INTERNAL OBJECTS ****/ +typedef struct { + opal_list_item_t super; + opal_jobid_t jobid; + char nspace[PMIX_MAX_NSLEN + 1]; +} opal_pmix3x_jobid_trkr_t; +OBJ_CLASS_DECLARATION(opal_pmix3x_jobid_trkr_t); + +typedef struct { + opal_list_item_t super; + size_t index; + int code; + opal_pmix_notification_fn_t handler; +} opal_pmix3x_single_event_t; +OBJ_CLASS_DECLARATION(opal_pmix3x_single_event_t); + +typedef struct { + opal_list_item_t super; + size_t index; + int *codes; + size_t ncodes; + opal_pmix_notification_fn_t handler; +} opal_pmix3x_multi_event_t; +OBJ_CLASS_DECLARATION(opal_pmix3x_multi_event_t); + +typedef struct { + opal_list_item_t super; + size_t index; + opal_pmix_notification_fn_t handler; +} opal_pmix3x_default_event_t; +OBJ_CLASS_DECLARATION(opal_pmix3x_default_event_t); + +typedef struct { + opal_list_item_t super; + int status; + bool nondefault; + opal_process_name_t source; + pmix_data_range_t range; + opal_list_t *info; + opal_list_t results; + opal_pmix3x_single_event_t *sing; + opal_pmix3x_multi_event_t *multi; + opal_pmix3x_default_event_t *def; + opal_pmix_op_cbfunc_t final_cbfunc; + void *final_cbdata; +} opal_pmix3x_event_chain_t; +OBJ_CLASS_DECLARATION(opal_pmix3x_event_chain_t); + +typedef struct { + opal_object_t super; + pmix_status_t status; + pmix_proc_t p; + pmix_proc_t *procs; + size_t nprocs; + pmix_proc_t *error_procs; + size_t nerror_procs; + pmix_info_t *info; + size_t ninfo; + pmix_app_t *apps; + size_t sz; + volatile bool active; + opal_pmix_op_cbfunc_t opcbfunc; + opal_pmix_modex_cbfunc_t mdxcbfunc; + opal_pmix_value_cbfunc_t valcbfunc; + opal_pmix_lookup_cbfunc_t lkcbfunc; + opal_pmix_spawn_cbfunc_t spcbfunc; + void *cbdata; +} pmix3x_opcaddy_t; +OBJ_CLASS_DECLARATION(pmix3x_opcaddy_t); + +typedef struct { + opal_object_t super; + opal_list_t procs; + opal_list_t info; + opal_list_t apps; + pmix_op_cbfunc_t opcbfunc; + pmix_dmodex_response_fn_t dmdxfunc; + pmix_modex_cbfunc_t mdxcbfunc; + pmix_lookup_cbfunc_t lkupcbfunc; + pmix_spawn_cbfunc_t spwncbfunc; + pmix_info_cbfunc_t infocbfunc; + pmix_tool_connection_cbfunc_t toolcbfunc; + void *cbdata; + opal_pmix_release_cbfunc_t odmdxfunc; + void *ocbdata; +} pmix3x_opalcaddy_t; +OBJ_CLASS_DECLARATION(pmix3x_opalcaddy_t); + +typedef struct { + opal_object_t super; + opal_event_t ev; + volatile bool active; + size_t id; + int status; + opal_process_name_t pname; + opal_jobid_t jobid; + const opal_process_name_t *source; + opal_pmix_data_range_t range; + bool nondefault; + size_t handler; + opal_list_t *event_codes; + opal_list_t *info; + opal_pmix_notification_fn_t evhandler; + opal_pmix_evhandler_reg_cbfunc_t cbfunc; + opal_pmix_op_cbfunc_t opcbfunc; + void *cbdata; +} pmix3x_threadshift_t; +OBJ_CLASS_DECLARATION(pmix3x_threadshift_t); + +#define OPAL_PMIX_OPCD_THREADSHIFT(i, s, sr, if, nif, fn, cb, cd) \ + do { \ + pmix3x_opalcaddy_t *_cd; \ + _cd = OBJ_NEW(pmix3x_opalcaddy_t); \ + _cd->id = (i); \ + _cd->status = (s); \ + _cd->source = (sr); \ + _cd->info = (i); \ + _cd->evcbfunc = (cb); \ + _cd->cbdata = (cd); \ + event_assign(&((_cd)->ev), opal_pmix_base.evbase, \ + -1, EV_WRITE, (fn), (_cd)); \ + event_active(&((_cd)->ev), EV_WRITE, 1); \ + } while(0) + +#define OPAL_PMIX_OP_THREADSHIFT(e, fn, cb, cd) \ + do { \ + pmix3x_threadshift_t *_cd; \ + _cd = OBJ_NEW(pmix3x_threadshift_t); \ + _cd->handler = (e); \ + _cd->opcbfunc = (cb); \ + _cd->cbdata = (cd); \ + event_assign(&((_cd)->ev), opal_pmix_base.evbase, \ + -1, EV_WRITE, (fn), (_cd)); \ + event_active(&((_cd)->ev), EV_WRITE, 1); \ + } while(0) + +#define OPAL_PMIX_THREADSHIFT(e, i, eh, fn, cb, cd) \ + do { \ + pmix3x_threadshift_t *_cd; \ + _cd = OBJ_NEW(pmix3x_threadshift_t); \ + _cd->event_codes = (e); \ + _cd->info = (i); \ + _cd->evhandler = (eh); \ + _cd->cbfunc = (cb); \ + _cd->cbdata = (cd); \ + event_assign(&((_cd)->ev), opal_pmix_base.evbase, \ + -1, EV_WRITE, (fn), (_cd)); \ + event_active(&((_cd)->ev), EV_WRITE, 1); \ + } while(0) + +#define OPAL_PMIX_NOTIFY_THREADSHIFT(s, sr, r, i, fn, cb, cd) \ + do { \ + pmix3x_threadshift_t *_cd; \ + _cd = OBJ_NEW(pmix3x_threadshift_t); \ + _cd->status = (s); \ + _cd->source = (sr); \ + _cd->range = (r); \ + _cd->info = (i); \ + _cd->opcbfunc = (cb); \ + _cd->cbdata = (cd); \ + event_assign(&((_cd)->ev), opal_pmix_base.evbase, \ + -1, EV_WRITE, (fn), (_cd)); \ + event_active(&((_cd)->ev), EV_WRITE, 1); \ + } while(0) + +/**** CLIENT FUNCTIONS ****/ +OPAL_MODULE_DECLSPEC int pmix3x_client_init(void); +OPAL_MODULE_DECLSPEC int pmix3x_client_finalize(void); +OPAL_MODULE_DECLSPEC int pmix3x_initialized(void); +OPAL_MODULE_DECLSPEC int pmix3x_abort(int flag, const char *msg, + opal_list_t *procs); +OPAL_MODULE_DECLSPEC int pmix3x_commit(void); +OPAL_MODULE_DECLSPEC int pmix3x_fence(opal_list_t *procs, int collect_data); +OPAL_MODULE_DECLSPEC int pmix3x_fencenb(opal_list_t *procs, int collect_data, + opal_pmix_op_cbfunc_t cbfunc, void *cbdata); +OPAL_MODULE_DECLSPEC int pmix3x_put(opal_pmix_scope_t scope, + opal_value_t *val); +OPAL_MODULE_DECLSPEC int pmix3x_get(const opal_process_name_t *proc, const char *key, + opal_list_t *info, opal_value_t **val); +OPAL_MODULE_DECLSPEC int pmix3x_getnb(const opal_process_name_t *proc, const char *key, + opal_list_t *info, + opal_pmix_value_cbfunc_t cbfunc, void *cbdata); +OPAL_MODULE_DECLSPEC int pmix3x_publish(opal_list_t *info); +OPAL_MODULE_DECLSPEC int pmix3x_publishnb(opal_list_t *info, + opal_pmix_op_cbfunc_t cbfunc, void *cbdata); +OPAL_MODULE_DECLSPEC int pmix3x_lookup(opal_list_t *data, opal_list_t *info); +OPAL_MODULE_DECLSPEC int pmix3x_lookupnb(char **keys, opal_list_t *info, + opal_pmix_lookup_cbfunc_t cbfunc, void *cbdata); +OPAL_MODULE_DECLSPEC int pmix3x_unpublish(char **keys, opal_list_t *info); +OPAL_MODULE_DECLSPEC int pmix3x_unpublishnb(char **keys, opal_list_t *info, + opal_pmix_op_cbfunc_t cbfunc, void *cbdata); +OPAL_MODULE_DECLSPEC int pmix3x_spawn(opal_list_t *job_info, opal_list_t *apps, opal_jobid_t *jobid); +OPAL_MODULE_DECLSPEC int pmix3x_spawnnb(opal_list_t *job_info, opal_list_t *apps, + opal_pmix_spawn_cbfunc_t cbfunc, void *cbdata); +OPAL_MODULE_DECLSPEC int pmix3x_connect(opal_list_t *procs); +OPAL_MODULE_DECLSPEC int pmix3x_connectnb(opal_list_t *procs, + opal_pmix_op_cbfunc_t cbfunc, + void *cbdata); +OPAL_MODULE_DECLSPEC int pmix3x_disconnect(opal_list_t *procs); +OPAL_MODULE_DECLSPEC int pmix3x_disconnectnb(opal_list_t *procs, + opal_pmix_op_cbfunc_t cbfunc, + void *cbdata); +OPAL_MODULE_DECLSPEC int pmix3x_resolve_peers(const char *nodename, opal_jobid_t jobid, + opal_list_t *procs); +OPAL_MODULE_DECLSPEC int pmix3x_resolve_nodes(opal_jobid_t jobid, char **nodelist); + +/**** COMMON FUNCTIONS ****/ +OPAL_MODULE_DECLSPEC int pmix3x_store_local(const opal_process_name_t *proc, + opal_value_t *val); + +/**** SERVER SOUTHBOUND FUNCTIONS ****/ +OPAL_MODULE_DECLSPEC int pmix3x_server_init(opal_pmix_server_module_t *module, + opal_list_t *info); +OPAL_MODULE_DECLSPEC int pmix3x_server_finalize(void); +OPAL_MODULE_DECLSPEC int pmix3x_server_gen_regex(const char *input, char **regex); +OPAL_MODULE_DECLSPEC int pmix3x_server_gen_ppn(const char *input, char **ppn); +OPAL_MODULE_DECLSPEC int pmix3x_server_register_nspace(opal_jobid_t jobid, + int nlocalprocs, + opal_list_t *info, + opal_pmix_op_cbfunc_t cbfunc, + void *cbdata); +OPAL_MODULE_DECLSPEC void pmix3x_server_deregister_nspace(opal_jobid_t jobid, + opal_pmix_op_cbfunc_t cbfunc, + void *cbdata); +OPAL_MODULE_DECLSPEC int pmix3x_server_register_client(const opal_process_name_t *proc, + uid_t uid, gid_t gid, + void *server_object, + opal_pmix_op_cbfunc_t cbfunc, + void *cbdata); +OPAL_MODULE_DECLSPEC void pmix3x_server_deregister_client(const opal_process_name_t *proc, + opal_pmix_op_cbfunc_t cbfunc, + void *cbdata); +OPAL_MODULE_DECLSPEC int pmix3x_server_setup_fork(const opal_process_name_t *proc, char ***env); +OPAL_MODULE_DECLSPEC int pmix3x_server_dmodex(const opal_process_name_t *proc, + opal_pmix_modex_cbfunc_t cbfunc, void *cbdata); +OPAL_MODULE_DECLSPEC int pmix3x_server_notify_event(int status, + const opal_process_name_t *source, + opal_list_t *info, + opal_pmix_op_cbfunc_t cbfunc, void *cbdata); + + +/**** COMPONENT UTILITY FUNCTIONS ****/ +OPAL_MODULE_DECLSPEC void pmix3x_event_hdlr(size_t evhdlr_registration_id, + pmix_status_t status, const pmix_proc_t *source, + pmix_info_t info[], size_t ninfo, + pmix_info_t results[], size_t nresults, + pmix_event_notification_cbfunc_fn_t cbfunc, + void *cbdata); +OPAL_MODULE_DECLSPEC pmix_status_t pmix3x_convert_opalrc(int rc); +OPAL_MODULE_DECLSPEC int pmix3x_convert_rc(pmix_status_t rc); + +OPAL_MODULE_DECLSPEC opal_vpid_t pmix3x_convert_rank(int rank); +OPAL_MODULE_DECLSPEC pmix_rank_t pmix3x_convert_opalrank(opal_vpid_t vpid); + +OPAL_MODULE_DECLSPEC opal_pmix_scope_t pmix3x_convert_scope(pmix_scope_t scope); +OPAL_MODULE_DECLSPEC pmix_scope_t pmix3x_convert_opalscope(opal_pmix_scope_t scope); + +OPAL_MODULE_DECLSPEC pmix_data_range_t pmix3x_convert_opalrange(opal_pmix_data_range_t range); +OPAL_MODULE_DECLSPEC opal_pmix_data_range_t pmix3x_convert_range(pmix_data_range_t range); + +OPAL_MODULE_DECLSPEC opal_pmix_persistence_t pmix3x_convert_persist(pmix_persistence_t scope); +OPAL_MODULE_DECLSPEC pmix_persistence_t pmix3x_convert_opalpersist(opal_pmix_persistence_t scope); + +OPAL_MODULE_DECLSPEC void pmix3x_value_load(pmix_value_t *v, + opal_value_t *kv); +OPAL_MODULE_DECLSPEC int pmix3x_value_unload(opal_value_t *kv, + const pmix_value_t *v); + +END_C_DECLS + +#endif /* MCA_PMIX_EXTERNAL_H */ diff --git a/opal/mca/pmix/ext3x/pmix3x_client.c b/opal/mca/pmix/ext3x/pmix3x_client.c new file mode 100644 index 0000000000..ca7c799547 --- /dev/null +++ b/opal/mca/pmix/ext3x/pmix3x_client.c @@ -0,0 +1,1285 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2014-2016 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2016 Research Organization for Information Science + * and Technology (RIST). All rights reserved. + * Copyright (c) 2014-2015 Mellanox Technologies, Inc. + * All rights reserved. + * Copyright (c) 2016 Cisco Systems, Inc. All rights reserved. + * Copyright (c) 2016 Los Alamos National Security, LLC. All rights + * reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "opal_config.h" +#include "opal/constants.h" +#include "opal/types.h" + +#ifdef HAVE_STRING_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif + +#include "opal/hash_string.h" +#include "opal/util/argv.h" +#include "opal/util/proc.h" + +#include "opal/mca/pmix/base/base.h" +#include "pmix3x.h" +#include "pmix.h" + +static pmix_proc_t my_proc; +static char *dbgvalue=NULL; +static size_t errhdler_ref = 0; + +#define PMIX_WAIT_FOR_COMPLETION(a) \ + do { \ + while ((a)) { \ + usleep(10); \ + } \ + } while (0) + + +static void errreg_cbfunc (pmix_status_t status, + size_t errhandler_ref, + void *cbdata) +{ + errhdler_ref = errhandler_ref; + opal_output_verbose(5, opal_pmix_base_framework.framework_output, + "PMIX client errreg_cbfunc - error handler registered status=%d, reference=%lu", + status, (unsigned long)errhandler_ref); +} + +int pmix3x_client_init(void) +{ + opal_process_name_t pname; + pmix_status_t rc; + int dbg; + opal_pmix3x_jobid_trkr_t *job; + + opal_output_verbose(1, opal_pmix_base_framework.framework_output, + "PMIx_client init"); + + if (0 < (dbg = opal_output_get_verbosity(opal_pmix_base_framework.framework_output))) { + asprintf(&dbgvalue, "PMIX_DEBUG=%d", dbg); + putenv(dbgvalue); + } + + rc = PMIx_Init(&my_proc, NULL, 0); + if (PMIX_SUCCESS != rc) { + return pmix3x_convert_rc(rc); + } + + /* store our jobid and rank */ + if (NULL != getenv(OPAL_MCA_PREFIX"orte_launch")) { + /* if we were launched by the OMPI RTE, then + * the jobid is in a special format - so get it */ + mca_pmix_pmix3x_component.native_launch = true; + opal_convert_string_to_jobid(&pname.jobid, my_proc.nspace); + } else { + /* we were launched by someone else, so make the + * jobid just be the hash of the nspace */ + OPAL_HASH_JOBID(my_proc.nspace, pname.jobid); + } + /* insert this into our list of jobids - it will be the + * first, and so we'll check it first */ + job = OBJ_NEW(opal_pmix3x_jobid_trkr_t); + (void)strncpy(job->nspace, my_proc.nspace, PMIX_MAX_NSLEN); + job->jobid = pname.jobid; + opal_list_append(&mca_pmix_pmix3x_component.jobids, &job->super); + + pname.vpid = pmix3x_convert_rank(my_proc.rank); + opal_proc_set_name(&pname); + + /* register the default event handler */ + PMIx_Register_event_handler(NULL, 0, NULL, 0, pmix3x_event_hdlr, errreg_cbfunc, NULL); + return OPAL_SUCCESS; + +} + +int pmix3x_client_finalize(void) +{ + pmix_status_t rc; + + opal_output_verbose(1, opal_pmix_base_framework.framework_output, + "PMIx_client finalize"); + + /* deregister the default event handler */ + PMIx_Deregister_event_handler(errhdler_ref, NULL, NULL); + + rc = PMIx_Finalize(NULL, 0); + return pmix3x_convert_rc(rc); +} + +int pmix3x_initialized(void) +{ + opal_output_verbose(1, opal_pmix_base_framework.framework_output, + "PMIx_client initialized"); + + return PMIx_Initialized(); +} + +int pmix3x_abort(int flag, const char *msg, + opal_list_t *procs) +{ + pmix_status_t rc; + pmix_proc_t *parray=NULL; + size_t n, cnt=0; + opal_namelist_t *ptr; + opal_pmix3x_jobid_trkr_t *job, *jptr; + + opal_output_verbose(1, opal_pmix_base_framework.framework_output, + "PMIx_client abort"); + + /* convert the list of procs to an array + * of pmix_proc_t */ + if (NULL != procs && 0 < (cnt = opal_list_get_size(procs))) { + PMIX_PROC_CREATE(parray, cnt); + n=0; + OPAL_LIST_FOREACH(ptr, procs, opal_namelist_t) { + /* look thru our list of jobids and find the + * corresponding nspace */ + job = NULL; + OPAL_LIST_FOREACH(jptr, &mca_pmix_pmix3x_component.jobids, opal_pmix3x_jobid_trkr_t) { + if (jptr->jobid == ptr->name.jobid) { + job = jptr; + break; + } + } + if (NULL == job) { + PMIX_PROC_FREE(parray, cnt); + return OPAL_ERR_NOT_FOUND; + } + (void)strncpy(parray[n].nspace, job->nspace, PMIX_MAX_NSLEN); + parray[n].rank = pmix3x_convert_opalrank(ptr->name.vpid); + ++n; + } + } + + /* call the library abort */ + rc = PMIx_Abort(flag, msg, parray, cnt); + + /* release the array */ + PMIX_PROC_FREE(parray, cnt); + + return pmix3x_convert_rc(rc); +} + +int pmix3x_store_local(const opal_process_name_t *proc, opal_value_t *val) +{ + pmix_value_t kv; + pmix_status_t rc; + pmix_proc_t p; + opal_pmix3x_jobid_trkr_t *job, *jptr; + + /* we must threadshift this request as we might not be in an event + * and we are going to access framework-global lists/objects */ + + if (NULL != proc) { + /* look thru our list of jobids and find the + * corresponding nspace */ + job = NULL; + OPAL_LIST_FOREACH(jptr, &mca_pmix_pmix3x_component.jobids, opal_pmix3x_jobid_trkr_t) { + if (jptr->jobid == proc->jobid) { + job = jptr; + break; + } + } + if (NULL == job) { + OPAL_ERROR_LOG(OPAL_ERR_NOT_FOUND); + return OPAL_ERR_NOT_FOUND; + } + (void)strncpy(p.nspace, job->nspace, PMIX_MAX_NSLEN); + p.rank = pmix3x_convert_opalrank(proc->vpid); + } else { + /* use our name */ + (void)strncpy(p.nspace, my_proc.nspace, PMIX_MAX_NSLEN); + p.rank = pmix3x_convert_opalrank(OPAL_PROC_MY_NAME.vpid); + } + + PMIX_VALUE_CONSTRUCT(&kv); + pmix3x_value_load(&kv, val); + + rc = PMIx_Store_internal(&p, val->key, &kv); + PMIX_VALUE_DESTRUCT(&kv); + + return pmix3x_convert_rc(rc); +} + +int pmix3x_commit(void) +{ + pmix_status_t rc; + + rc = PMIx_Commit(); + return pmix3x_convert_rc(rc); +} + +static void opcbfunc(pmix_status_t status, void *cbdata) +{ + pmix3x_opcaddy_t *op = (pmix3x_opcaddy_t*)cbdata; + + if (NULL != op->opcbfunc) { + op->opcbfunc(pmix3x_convert_rc(status), op->cbdata); + } + OBJ_RELEASE(op); +} + +int pmix3x_fence(opal_list_t *procs, int collect_data) +{ + pmix_status_t rc; + pmix_proc_t *parray=NULL; + size_t n, cnt=0; + opal_namelist_t *ptr; + pmix_info_t info, *iptr; + opal_pmix3x_jobid_trkr_t *job, *jptr; + + opal_output_verbose(1, opal_pmix_base_framework.framework_output, + "PMIx_client fence"); + + /* convert the list of procs to an array + * of pmix_proc_t */ + if (NULL != procs && 0 < (cnt = opal_list_get_size(procs))) { + PMIX_PROC_CREATE(parray, cnt); + n=0; + OPAL_LIST_FOREACH(ptr, procs, opal_namelist_t) { + /* look thru our list of jobids and find the + * corresponding nspace */ + job = NULL; + OPAL_LIST_FOREACH(jptr, &mca_pmix_pmix3x_component.jobids, opal_pmix3x_jobid_trkr_t) { + if (jptr->jobid == ptr->name.jobid) { + job = jptr; + break; + } + } + if (NULL == job) { + PMIX_PROC_FREE(parray, cnt); + return OPAL_ERR_NOT_FOUND; + } + (void)strncpy(parray[n].nspace, job->nspace, PMIX_MAX_NSLEN); + parray[n].rank = pmix3x_convert_opalrank(ptr->name.vpid); + ++n; + } + } + if (collect_data) { + PMIX_INFO_CONSTRUCT(&info); + (void)strncpy(info.key, PMIX_COLLECT_DATA, PMIX_MAX_KEYLEN); + info.value.type = PMIX_BOOL; + info.value.data.flag = true; + iptr = &info; + n = 1; + } else { + iptr = NULL; + n = 0; + } + + /* call the library function */ + rc = PMIx_Fence(parray, cnt, iptr, n); + + /* release the array */ + PMIX_PROC_FREE(parray, cnt); + if (NULL != iptr) { + PMIX_INFO_DESTRUCT(&info); + } + + return pmix3x_convert_rc(rc); + +} + +int pmix3x_fencenb(opal_list_t *procs, int collect_data, + opal_pmix_op_cbfunc_t cbfunc, void *cbdata) +{ + pmix_status_t rc; + pmix_proc_t *parray=NULL; + size_t n, cnt=0; + opal_namelist_t *ptr; + pmix3x_opcaddy_t *op; + pmix_info_t info, *iptr; + opal_pmix3x_jobid_trkr_t *job, *jptr; + + /* we must threadshift this request as we might not be in an event + * and we are going to access framework-global lists/objects */ + + opal_output_verbose(1, opal_pmix_base_framework.framework_output, + "PMIx_client fence_nb"); + + /* convert the list of procs to an array + * of pmix_proc_t */ + if (NULL != procs && 0 < (cnt = opal_list_get_size(procs))) { + PMIX_PROC_CREATE(parray, cnt); + n=0; + OPAL_LIST_FOREACH(ptr, procs, opal_namelist_t) { + /* look thru our list of jobids and find the + * corresponding nspace */ + job = NULL; + OPAL_LIST_FOREACH(jptr, &mca_pmix_pmix3x_component.jobids, opal_pmix3x_jobid_trkr_t) { + if (jptr->jobid == ptr->name.jobid) { + job = jptr; + break; + } + } + if (NULL == job) { + PMIX_PROC_FREE(parray, cnt); + return OPAL_ERR_NOT_FOUND; + } + (void)strncpy(parray[n].nspace, job->nspace, PMIX_MAX_NSLEN); + parray[n].rank = pmix3x_convert_opalrank(ptr->name.vpid); + ++n; + } + } + + if (collect_data) { + PMIX_INFO_CONSTRUCT(&info); + (void)strncpy(info.key, PMIX_COLLECT_DATA, PMIX_MAX_KEYLEN); + info.value.type = PMIX_BOOL; + info.value.data.flag = true; + iptr = &info; + n = 1; + } else { + iptr = NULL; + n = 0; + } + + /* create the caddy */ + op = OBJ_NEW(pmix3x_opcaddy_t); + op->opcbfunc = cbfunc; + op->cbdata = cbdata; + op->procs = parray; + op->nprocs = cnt; + + /* call the library function */ + rc = PMIx_Fence_nb(parray, cnt, iptr, n, opcbfunc, op); + if (PMIX_SUCCESS != rc) { + OBJ_RELEASE(op); + } + + return pmix3x_convert_rc(rc); + +} + +int pmix3x_put(opal_pmix_scope_t opal_scope, + opal_value_t *val) +{ + pmix_value_t kv; + pmix_scope_t pmix_scope = pmix3x_convert_opalscope(opal_scope); + pmix_status_t rc; + + opal_output_verbose(1, opal_pmix_base_framework.framework_output, + "PMIx_client put"); + + PMIX_VALUE_CONSTRUCT(&kv); + pmix3x_value_load(&kv, val); + + rc = PMIx_Put(pmix_scope, val->key, &kv); + PMIX_VALUE_DESTRUCT(&kv); + return pmix3x_convert_rc(rc); +} + +int pmix3x_get(const opal_process_name_t *proc, const char *key, + opal_list_t *info, opal_value_t **val) +{ + int ret; + pmix_value_t *kv; + pmix_status_t rc; + pmix_proc_t p, *pptr; + size_t ninfo, n; + pmix_info_t *pinfo; + opal_value_t *ival; + opal_pmix3x_jobid_trkr_t *job, *jptr; + + opal_output_verbose(1, opal_pmix_base_framework.framework_output, + "%s PMIx_client get on proc %s key %s", + OPAL_NAME_PRINT(OPAL_PROC_MY_NAME), + (NULL == proc) ? "NULL" : OPAL_NAME_PRINT(*proc), key); + + /* prep default response */ + *val = NULL; + if (NULL != proc) { + /* look thru our list of jobids and find the + * corresponding nspace */ + job = NULL; + OPAL_LIST_FOREACH(jptr, &mca_pmix_pmix3x_component.jobids, opal_pmix3x_jobid_trkr_t) { + if (jptr->jobid == proc->jobid) { + job = jptr; + break; + } + } + if (NULL == job) { + return OPAL_ERR_NOT_FOUND; + } + (void)strncpy(p.nspace, job->nspace, PMIX_MAX_NSLEN); + p.rank = pmix3x_convert_opalrank(proc->vpid); + pptr = &p; + } else { + /* if they are asking for our jobid, then return it */ + if (0 == strcmp(key, OPAL_PMIX_JOBID)) { + (*val) = OBJ_NEW(opal_value_t); + (*val)->type = OPAL_UINT32; + (*val)->data.uint32 = OPAL_PROC_MY_NAME.jobid; + return OPAL_SUCCESS; + } else if (0 == strcmp(key, OPAL_PMIX_RANK)) { + (*val) = OBJ_NEW(opal_value_t); + (*val)->type = OPAL_INT; + (*val)->data.integer = pmix3x_convert_rank(my_proc.rank); + return OPAL_SUCCESS; + } + pptr = NULL; + } + + if (NULL != info) { + ninfo = opal_list_get_size(info); + if (0 < ninfo) { + PMIX_INFO_CREATE(pinfo, ninfo); + n=0; + OPAL_LIST_FOREACH(ival, info, opal_value_t) { + (void)strncpy(pinfo[n].key, ival->key, PMIX_MAX_KEYLEN); + pmix3x_value_load(&pinfo[n].value, ival); + ++n; + } + } else { + pinfo = NULL; + } + } else { + pinfo = NULL; + ninfo = 0; + } + + /* pass the request down */ + rc = PMIx_Get(pptr, key, pinfo, ninfo, &kv); + if (PMIX_SUCCESS == rc) { + if (NULL == kv) { + ret = OPAL_SUCCESS; + } else { + *val = OBJ_NEW(opal_value_t); + ret = pmix3x_value_unload(*val, kv); + PMIX_VALUE_FREE(kv, 1); + } + } else { + ret = pmix3x_convert_rc(rc); + } + PMIX_INFO_FREE(pinfo, ninfo); + return ret; +} + +static void val_cbfunc(pmix_status_t status, + pmix_value_t *kv, void *cbdata) +{ + pmix3x_opcaddy_t *op = (pmix3x_opcaddy_t*)cbdata; + int rc; + opal_value_t val, *v=NULL; + + rc = pmix3x_convert_opalrc(status); + if (PMIX_SUCCESS == status && NULL != kv) { + rc = pmix3x_value_unload(&val, kv); + v = &val; + } + + if (NULL != op->valcbfunc) { + op->valcbfunc(rc, v, op->cbdata); + } + OBJ_RELEASE(op); +} + +int pmix3x_getnb(const opal_process_name_t *proc, const char *key, + opal_list_t *info, + opal_pmix_value_cbfunc_t cbfunc, void *cbdata) +{ + pmix3x_opcaddy_t *op; + pmix_status_t rc; + size_t n; + opal_value_t *ival; + opal_pmix3x_jobid_trkr_t *job, *jptr; + + /* we must threadshift this request as we might not be in an event + * and we are going to access shared lists/objects */ + + opal_output_verbose(1, opal_pmix_base_framework.framework_output, + "%s PMIx_client get_nb on proc %s key %s", + OPAL_NAME_PRINT(OPAL_PROC_MY_NAME), + (NULL == proc) ? "NULL" : OPAL_NAME_PRINT(*proc), key); + + /* create the caddy */ + op = OBJ_NEW(pmix3x_opcaddy_t); + op->valcbfunc = cbfunc; + op->cbdata = cbdata; + + if (NULL != proc) { + /* look thru our list of jobids and find the + * corresponding nspace */ + job = NULL; + OPAL_LIST_FOREACH(jptr, &mca_pmix_pmix3x_component.jobids, opal_pmix3x_jobid_trkr_t) { + if (jptr->jobid == proc->jobid) { + job = jptr; + break; + } + } + if (NULL == job) { + return OPAL_ERR_NOT_FOUND; + } + (void)strncpy(op->p.nspace, job->nspace, PMIX_MAX_NSLEN); + op->p.rank = pmix3x_convert_opalrank(proc->vpid); + } else { + (void)strncpy(op->p.nspace, my_proc.nspace, PMIX_MAX_NSLEN); + op->p.rank = pmix3x_convert_rank(PMIX_RANK_WILDCARD); + } + + if (NULL != info) { + op->sz = opal_list_get_size(info); + if (0 < op->sz) { + PMIX_INFO_CREATE(op->info, op->sz); + n=0; + OPAL_LIST_FOREACH(ival, info, opal_value_t) { + (void)strncpy(op->info[n].key, ival->key, PMIX_MAX_KEYLEN); + pmix3x_value_load(&op->info[n].value, ival); + ++n; + } + } + } + + /* call the library function */ + rc = PMIx_Get_nb(&op->p, key, op->info, op->sz, val_cbfunc, op); + if (PMIX_SUCCESS != rc) { + OBJ_RELEASE(op); + } + + return pmix3x_convert_rc(rc); +} + +int pmix3x_publish(opal_list_t *info) +{ + pmix_info_t *pinfo; + pmix_status_t ret; + opal_value_t *iptr; + size_t sz, n; + + opal_output_verbose(1, opal_pmix_base_framework.framework_output, + "PMIx_client publish"); + + if (NULL == info) { + return OPAL_ERR_BAD_PARAM; + } + + sz = opal_list_get_size(info); + if (0 < sz) { + PMIX_INFO_CREATE(pinfo, sz); + n=0; + OPAL_LIST_FOREACH(iptr, info, opal_value_t) { + (void)strncpy(pinfo[n].key, iptr->key, PMIX_MAX_KEYLEN); + pmix3x_value_load(&pinfo[n].value, iptr); + ++n; + } + } else { + pinfo = NULL; + } + + ret = PMIx_Publish(pinfo, sz); + + return pmix3x_convert_rc(ret); +} + +int pmix3x_publishnb(opal_list_t *info, + opal_pmix_op_cbfunc_t cbfunc, void *cbdata) +{ + pmix_status_t ret; + opal_value_t *iptr; + size_t n; + pmix3x_opcaddy_t *op; + + opal_output_verbose(1, opal_pmix_base_framework.framework_output, + "PMIx_client publish_nb"); + + if (NULL == info) { + return OPAL_ERR_BAD_PARAM; + } + + /* create the caddy */ + op = OBJ_NEW(pmix3x_opcaddy_t); + op->opcbfunc = cbfunc; + op->cbdata = cbdata; + + op->sz = opal_list_get_size(info); + if (0 < op->sz) { + PMIX_INFO_CREATE(op->info, op->sz); + n=0; + OPAL_LIST_FOREACH(iptr, info, opal_value_t) { + (void)strncpy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); + pmix3x_value_load(&op->info[n].value, iptr); + ++n; + } + } + + ret = PMIx_Publish_nb(op->info, op->sz, opcbfunc, op); + + return pmix3x_convert_rc(ret); +} + +int pmix3x_lookup(opal_list_t *data, opal_list_t *info) +{ + pmix_pdata_t *pdata; + pmix_info_t *pinfo; + size_t sz, ninfo, n; + int rc; + pmix_status_t ret; + opal_pmix_pdata_t *d; + opal_value_t *iptr; + opal_pmix3x_jobid_trkr_t *job, *jptr; + + /* we must threadshift this request as we might not be in an event + * and we are going to access shared lists/objects */ + opal_output_verbose(1, opal_pmix_base_framework.framework_output, + "PMIx_client lookup"); + + if (NULL == data) { + return OPAL_ERR_BAD_PARAM; + } + + sz = opal_list_get_size(data); + PMIX_PDATA_CREATE(pdata, sz); + n=0; + OPAL_LIST_FOREACH(d, data, opal_pmix_pdata_t) { + (void)strncpy(pdata[n++].key, d->value.key, PMIX_MAX_KEYLEN); + } + + if (NULL != info) { + ninfo = opal_list_get_size(info); + PMIX_INFO_CREATE(pinfo, ninfo); + n=0; + OPAL_LIST_FOREACH(iptr, info, opal_value_t) { + (void)strncpy(pinfo[n].key, iptr->key, PMIX_MAX_KEYLEN); + pmix3x_value_load(&pinfo[n].value, iptr); + ++n; + } + } else { + pinfo = NULL; + ninfo = 0; + } + + ret = PMIx_Lookup(pdata, sz, pinfo, ninfo); + PMIX_INFO_FREE(pinfo, ninfo); + + if (PMIX_SUCCESS == ret) { + /* transfer the data back */ + n=0; + OPAL_LIST_FOREACH(d, data, opal_pmix_pdata_t) { + if (mca_pmix_pmix3x_component.native_launch) { + /* if we were launched by the OMPI RTE, then + * the jobid is in a special format - so get it */ + opal_convert_string_to_jobid(&d->proc.jobid, pdata[n].proc.nspace); + } else { + /* we were launched by someone else, so make the + * jobid just be the hash of the nspace */ + OPAL_HASH_JOBID(pdata[n].proc.nspace, d->proc.jobid); + } + /* if we don't already have it, add this to our jobid tracker */ + job = NULL; + OPAL_LIST_FOREACH(jptr, &mca_pmix_pmix3x_component.jobids, opal_pmix3x_jobid_trkr_t) { + if (jptr->jobid == d->proc.jobid) { + job = jptr; + break; + } + } + if (NULL == job) { + job = OBJ_NEW(opal_pmix3x_jobid_trkr_t); + (void)strncpy(job->nspace, pdata[n].proc.nspace, PMIX_MAX_NSLEN); + job->jobid = d->proc.jobid; + opal_list_append(&mca_pmix_pmix3x_component.jobids, &job->super); + } + d->proc.vpid = pmix3x_convert_rank(pdata[n].proc.rank); + rc = pmix3x_value_unload(&d->value, &pdata[n].value); + if (OPAL_SUCCESS != rc) { + OPAL_ERROR_LOG(rc); + PMIX_PDATA_FREE(pdata, sz); + return OPAL_ERR_BAD_PARAM; + } + ++n; + } + } + + return pmix3x_convert_rc(ret); +} + +static void lk_cbfunc(pmix_status_t status, + pmix_pdata_t data[], size_t ndata, + void *cbdata) +{ + pmix3x_opcaddy_t *op = (pmix3x_opcaddy_t*)cbdata; + opal_pmix_pdata_t *d; + opal_list_t results, *r = NULL; + int rc; + size_t n; + opal_pmix3x_jobid_trkr_t *job, *jptr; + + /* this is in the PMIx local thread - need to threadshift to + * our own thread as we will be accessing framework-global + * lists and objects */ + + if (NULL == op->lkcbfunc) { + OBJ_RELEASE(op); + return; + } + + rc = pmix3x_convert_rc(status); + if (OPAL_SUCCESS == rc) { + OBJ_CONSTRUCT(&results, opal_list_t); + for (n=0; n < ndata; n++) { + d = OBJ_NEW(opal_pmix_pdata_t); + opal_list_append(&results, &d->super); + if (mca_pmix_pmix3x_component.native_launch) { + /* if we were launched by the OMPI RTE, then + * the jobid is in a special format - so get it */ + opal_convert_string_to_jobid(&d->proc.jobid, data[n].proc.nspace); + } else { + /* we were launched by someone else, so make the + * jobid just be the hash of the nspace */ + OPAL_HASH_JOBID(data[n].proc.nspace, d->proc.jobid); + } + /* if we don't already have it, add this to our jobid tracker */ + job = NULL; + OPAL_LIST_FOREACH(jptr, &mca_pmix_pmix3x_component.jobids, opal_pmix3x_jobid_trkr_t) { + if (jptr->jobid == d->proc.jobid) { + job = jptr; + break; + } + } + if (NULL == job) { + job = OBJ_NEW(opal_pmix3x_jobid_trkr_t); + (void)strncpy(job->nspace, data[n].proc.nspace, PMIX_MAX_NSLEN); + job->jobid = d->proc.jobid; + opal_list_append(&mca_pmix_pmix3x_component.jobids, &job->super); + } + d->proc.vpid = pmix3x_convert_rank(data[n].proc.rank); + d->value.key = strdup(data[n].key); + rc = pmix3x_value_unload(&d->value, &data[n].value); + if (OPAL_SUCCESS != rc) { + rc = OPAL_ERR_BAD_PARAM; + OPAL_ERROR_LOG(rc); + goto release; + } + } + r = &results; + } +release: + /* execute the callback */ + op->lkcbfunc(rc, r, op->cbdata); + + if (NULL != r) { + OPAL_LIST_DESTRUCT(&results); + } + OBJ_RELEASE(op); +} + +int pmix3x_lookupnb(char **keys, opal_list_t *info, + opal_pmix_lookup_cbfunc_t cbfunc, void *cbdata) +{ + pmix_status_t ret; + pmix3x_opcaddy_t *op; + opal_value_t *iptr; + size_t n; + + + opal_output_verbose(1, opal_pmix_base_framework.framework_output, + "PMIx_client lookup_nb"); + + /* create the caddy */ + op = OBJ_NEW(pmix3x_opcaddy_t); + op->lkcbfunc = cbfunc; + op->cbdata = cbdata; + + if (NULL != info) { + op->sz = opal_list_get_size(info); + if (0 < op->sz) { + PMIX_INFO_CREATE(op->info, op->sz); + n=0; + OPAL_LIST_FOREACH(iptr, info, opal_value_t) { + (void)strncpy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); + pmix3x_value_load(&op->info[n].value, iptr); + ++n; + } + } + } + + ret = PMIx_Lookup_nb(keys, op->info, op->sz, lk_cbfunc, op); + + return pmix3x_convert_rc(ret); +} + +int pmix3x_unpublish(char **keys, opal_list_t *info) +{ + pmix_status_t ret; + size_t ninfo, n; + pmix_info_t *pinfo; + opal_value_t *iptr; + + if (NULL != info) { + ninfo = opal_list_get_size(info); + PMIX_INFO_CREATE(pinfo, ninfo); + n=0; + OPAL_LIST_FOREACH(iptr, info, opal_value_t) { + (void)strncpy(pinfo[n].key, iptr->key, PMIX_MAX_KEYLEN); + pmix3x_value_load(&pinfo[n].value, iptr); + ++n; + } + } else { + pinfo = NULL; + ninfo = 0; + } + + ret = PMIx_Unpublish(keys, pinfo, ninfo); + PMIX_INFO_FREE(pinfo, ninfo); + + return pmix3x_convert_rc(ret); +} + +int pmix3x_unpublishnb(char **keys, opal_list_t *info, + opal_pmix_op_cbfunc_t cbfunc, void *cbdata) +{ + pmix_status_t ret; + pmix3x_opcaddy_t *op; + opal_value_t *iptr; + size_t n; + + /* create the caddy */ + op = OBJ_NEW(pmix3x_opcaddy_t); + op->opcbfunc = cbfunc; + op->cbdata = cbdata; + + if (NULL != info) { + op->sz = opal_list_get_size(info); + if (0 < op->sz) { + PMIX_INFO_CREATE(op->info, op->sz); + n=0; + OPAL_LIST_FOREACH(iptr, info, opal_value_t) { + (void)strncpy(op->info[n].key, iptr->key, PMIX_MAX_KEYLEN); + pmix3x_value_load(&op->info[n].value, iptr); + ++n; + } + } + } + + ret = PMIx_Unpublish_nb(keys, op->info, op->sz, opcbfunc, op); + + return pmix3x_convert_rc(ret); +} + +int pmix3x_spawn(opal_list_t *job_info, opal_list_t *apps, opal_jobid_t *jobid) +{ + pmix_status_t ret; + pmix_info_t *pinfo = NULL; + pmix_app_t *papps; + size_t napps, n, m, ninfo = 0; + char nspace[PMIX_MAX_NSLEN+1]; + opal_value_t *info; + opal_pmix_app_t *app; + opal_pmix3x_jobid_trkr_t *job; + + if (NULL != job_info && 0 < (ninfo = opal_list_get_size(job_info))) { + PMIX_INFO_CREATE(pinfo, ninfo); + n=0; + OPAL_LIST_FOREACH(info, job_info, opal_value_t) { + (void)strncpy(pinfo[n].key, info->key, PMIX_MAX_KEYLEN); + pmix3x_value_load(&pinfo[n].value, info); + ++n; + } + } + + napps = opal_list_get_size(apps); + PMIX_APP_CREATE(papps, napps); + n=0; + OPAL_LIST_FOREACH(app, apps, opal_pmix_app_t) { + papps[n].cmd = strdup(app->cmd); + papps[n].argc = app->argc; + papps[n].argv = opal_argv_copy(app->argv); + papps[n].env = opal_argv_copy(app->env); + papps[n].maxprocs = app->maxprocs; + if (0 < (papps[n].ninfo = opal_list_get_size(&app->info))) { + PMIX_INFO_CREATE(papps[n].info, papps[n].ninfo); + m=0; + OPAL_LIST_FOREACH(info, &app->info, opal_value_t) { + (void)strncpy(papps[n].info[m].key, info->key, PMIX_MAX_KEYLEN); + pmix3x_value_load(&papps[n].info[m].value, info); + ++m; + } + } + ++n; + } + + ret = PMIx_Spawn(pinfo, ninfo, papps, napps, nspace); + if (PMIX_SUCCESS == ret) { + if (mca_pmix_pmix3x_component.native_launch) { + /* if we were launched by the OMPI RTE, then + * the jobid is in a special format - so get it */ + opal_convert_string_to_jobid(jobid, nspace); + } else { + /* we were launched by someone else, so make the + * jobid just be the hash of the nspace */ + OPAL_HASH_JOBID(nspace, *jobid); + } + /* add this to our jobid tracker */ + job = OBJ_NEW(opal_pmix3x_jobid_trkr_t); + (void)strncpy(job->nspace, nspace, PMIX_MAX_NSLEN); + job->jobid = *jobid; + opal_list_append(&mca_pmix_pmix3x_component.jobids, &job->super); + } + PMIX_APP_FREE(papps, napps); + + return pmix3x_convert_rc(ret); +} + +static void spcbfunc(pmix_status_t status, + char *nspace, void *cbdata) +{ + pmix3x_opcaddy_t *op = (pmix3x_opcaddy_t*)cbdata; + int rc; + opal_jobid_t jobid=OPAL_JOBID_INVALID; + opal_pmix3x_jobid_trkr_t *job; + + /* this is in the PMIx local thread - need to threadshift to + * our own thread as we will be accessing framework-global + * lists and objects */ + + rc = pmix3x_convert_rc(status); + if (PMIX_SUCCESS == status) { + if (mca_pmix_pmix3x_component.native_launch) { + /* if we were launched by the OMPI RTE, then + * the jobid is in a special format - so get it */ + opal_convert_string_to_jobid(&jobid, nspace); + } else { + /* we were launched by someone else, so make the + * jobid just be the hash of the nspace */ + OPAL_HASH_JOBID(nspace, jobid); + } + /* add this to our jobid tracker */ + job = OBJ_NEW(opal_pmix3x_jobid_trkr_t); + (void)strncpy(job->nspace, nspace, PMIX_MAX_NSLEN); + job->jobid = jobid; + opal_list_append(&mca_pmix_pmix3x_component.jobids, &job->super); + } + + op->spcbfunc(rc, jobid, op->cbdata); + OBJ_RELEASE(op); +} + +int pmix3x_spawnnb(opal_list_t *job_info, opal_list_t *apps, + opal_pmix_spawn_cbfunc_t cbfunc, void *cbdata) +{ + pmix_status_t ret; + pmix3x_opcaddy_t *op; + size_t n, m; + opal_value_t *info; + opal_pmix_app_t *app; + + /* create the caddy */ + op = OBJ_NEW(pmix3x_opcaddy_t); + op->spcbfunc = cbfunc; + op->cbdata = cbdata; + + if (NULL != job_info && 0 < (op->ninfo = opal_list_get_size(job_info))) { + PMIX_INFO_CREATE(op->info, op->ninfo); + n=0; + OPAL_LIST_FOREACH(info, job_info, opal_value_t) { + (void)strncpy(op->info[n].key, info->key, PMIX_MAX_KEYLEN); + pmix3x_value_load(&op->info[n].value, info); + ++n; + } + } + + op->sz = opal_list_get_size(apps); + PMIX_APP_CREATE(op->apps, op->sz); + n=0; + OPAL_LIST_FOREACH(app, apps, opal_pmix_app_t) { + op->apps[n].cmd = strdup(app->cmd); + op->apps[n].argc = app->argc; + op->apps[n].argv = opal_argv_copy(app->argv); + op->apps[n].env = opal_argv_copy(app->env); + op->apps[n].maxprocs = app->maxprocs; + if (0 < (op->apps[n].ninfo = opal_list_get_size(&app->info))) { + PMIX_INFO_CREATE(op->apps[n].info, op->apps[n].ninfo); + m=0; + OPAL_LIST_FOREACH(info, &app->info, opal_value_t) { + (void)strncpy(op->apps[n].info[m].key, info->key, PMIX_MAX_KEYLEN); + pmix3x_value_load(&op->apps[n].info[m].value, info); + ++m; + } + } + ++n; + } + + ret = PMIx_Spawn_nb(op->info, op->ninfo, op->apps, op->sz, spcbfunc, op); + + return pmix3x_convert_rc(ret); +} + +int pmix3x_connect(opal_list_t *procs) +{ + pmix_status_t ret; + pmix_proc_t *parray=NULL; + size_t n, cnt=0; + opal_namelist_t *ptr; + opal_pmix3x_jobid_trkr_t *job, *jptr; + + /* protect against bozo error */ + if (NULL == procs || 0 == (cnt = opal_list_get_size(procs))) { + return OPAL_ERR_BAD_PARAM; + } + + /* convert the list of procs to an array + * of pmix_proc_t */ + PMIX_PROC_CREATE(parray, cnt); + n=0; + OPAL_LIST_FOREACH(ptr, procs, opal_namelist_t) { + /* look thru our list of jobids and find the + * corresponding nspace */ + job = NULL; + OPAL_LIST_FOREACH(jptr, &mca_pmix_pmix3x_component.jobids, opal_pmix3x_jobid_trkr_t) { + if (jptr->jobid == ptr->name.jobid) { + job = jptr; + break; + } + } + if (NULL == job) { + OPAL_ERROR_LOG(OPAL_ERR_NOT_FOUND); + PMIX_PROC_FREE(parray, cnt); + return OPAL_ERR_NOT_FOUND; + } + (void)strncpy(parray[n].nspace, job->nspace, PMIX_MAX_NSLEN); + parray[n].rank = pmix3x_convert_opalrank(ptr->name.vpid); + ++n; + } + + ret = PMIx_Connect(parray, cnt, NULL, 0); + PMIX_PROC_FREE(parray, cnt); + + return pmix3x_convert_rc(ret); +} + +int pmix3x_connectnb(opal_list_t *procs, + opal_pmix_op_cbfunc_t cbfunc, + void *cbdata) +{ + pmix_status_t ret; + size_t n, cnt=0; + opal_namelist_t *ptr; + pmix3x_opcaddy_t *op; + opal_pmix3x_jobid_trkr_t *job; + + /* we must threadshift this request as we might not be in an event + * and we are going to access framework-global lists/objects */ + + /* protect against bozo error */ + if (NULL == procs || 0 == (cnt = opal_list_get_size(procs))) { + return OPAL_ERR_BAD_PARAM; + } + + /* create the caddy */ + op = OBJ_NEW(pmix3x_opcaddy_t); + op->opcbfunc = cbfunc; + op->cbdata = cbdata; + op->nprocs = cnt; + + /* convert the list of procs to an array + * of pmix_proc_t */ + PMIX_PROC_CREATE(op->procs, op->nprocs); + n=0; + OPAL_LIST_FOREACH(ptr, procs, opal_namelist_t) { + /* look thru our list of jobids and find the + * corresponding nspace */ + OPAL_LIST_FOREACH(job, &mca_pmix_pmix3x_component.jobids, opal_pmix3x_jobid_trkr_t) { + if (job->jobid == ptr->name.jobid) { + (void)strncpy(op->procs[n].nspace, job->nspace, PMIX_MAX_NSLEN); + break; + } + } + op->procs[n].rank = pmix3x_convert_opalrank(ptr->name.vpid); + ++n; + } + + ret = PMIx_Connect_nb(op->procs, op->nprocs, NULL, 0, opcbfunc, op); + + return pmix3x_convert_rc(ret); +} + +int pmix3x_disconnect(opal_list_t *procs) +{ + pmix_status_t ret; + pmix_proc_t *parray=NULL; + size_t n, cnt=0; + opal_namelist_t *ptr; + opal_pmix3x_jobid_trkr_t *job; + + /* protect against bozo error */ + if (NULL == procs || 0 == (cnt = opal_list_get_size(procs))) { + return OPAL_ERR_BAD_PARAM; + } + + /* convert the list of procs to an array + * of pmix_proc_t */ + PMIX_PROC_CREATE(parray, cnt); + n=0; + OPAL_LIST_FOREACH(ptr, procs, opal_namelist_t) { + /* look thru our list of jobids and find the + * corresponding nspace */ + OPAL_LIST_FOREACH(job, &mca_pmix_pmix3x_component.jobids, opal_pmix3x_jobid_trkr_t) { + if (job->jobid == ptr->name.jobid) { + (void)strncpy(parray[n].nspace, job->nspace, PMIX_MAX_NSLEN); + break; + } + } + parray[n].rank = pmix3x_convert_opalrank(ptr->name.vpid); + ++n; + } + + ret = PMIx_Disconnect(parray, cnt, NULL, 0); + PMIX_PROC_FREE(parray, cnt); + + return pmix3x_convert_rc(ret); +} + +int pmix3x_disconnectnb(opal_list_t *procs, + opal_pmix_op_cbfunc_t cbfunc, + void *cbdata) +{ + pmix_status_t ret; + size_t n, cnt=0; + opal_namelist_t *ptr; + pmix3x_opcaddy_t *op; + opal_pmix3x_jobid_trkr_t *job; + + /* we must threadshift this request as we might not be in an event + * and we are going to access framework-global lists/objects */ + + /* protect against bozo error */ + if (NULL == procs || 0 == (cnt = opal_list_get_size(procs))) { + return OPAL_ERR_BAD_PARAM; + } + + /* create the caddy */ + op = OBJ_NEW(pmix3x_opcaddy_t); + op->opcbfunc = cbfunc; + op->cbdata = cbdata; + op->nprocs = cnt; + + /* convert the list of procs to an array + * of pmix_proc_t */ + PMIX_PROC_CREATE(op->procs, op->nprocs); + n=0; + OPAL_LIST_FOREACH(ptr, procs, opal_namelist_t) { + /* look thru our list of jobids and find the + * corresponding nspace */ + OPAL_LIST_FOREACH(job, &mca_pmix_pmix3x_component.jobids, opal_pmix3x_jobid_trkr_t) { + if (job->jobid == ptr->name.jobid) { + (void)strncpy(op->procs[n].nspace, job->nspace, PMIX_MAX_NSLEN); + break; + } + } + op->procs[n].rank = pmix3x_convert_opalrank(ptr->name.vpid); + ++n; + } + + ret = PMIx_Disconnect_nb(op->procs, op->nprocs, NULL, 0, opcbfunc, op); + + return pmix3x_convert_rc(ret); +} + + +int pmix3x_resolve_peers(const char *nodename, opal_jobid_t jobid, + opal_list_t *procs) +{ + char *nspace; + pmix_proc_t *array=NULL; + size_t nprocs, n; + opal_namelist_t *nm; + int rc; + pmix_status_t ret; + opal_pmix3x_jobid_trkr_t *job, *jptr; + + /* we must threadshift this request as we might not be in an event + * and we are going to access framework-global lists/objects */ + + if (OPAL_JOBID_WILDCARD == jobid) { + nspace = NULL; + } else { + job = NULL; + OPAL_LIST_FOREACH(jptr, &mca_pmix_pmix3x_component.jobids, opal_pmix3x_jobid_trkr_t) { + if (jptr->jobid == jobid) { + job = jptr; + break; + } + } + if (NULL == job) { + return OPAL_ERR_NOT_FOUND; + } + nspace = job->nspace; + } + + ret = PMIx_Resolve_peers(nodename, nspace, &array, &nprocs); + rc = pmix3x_convert_rc(ret); + + if (NULL != array && 0 < nprocs) { + for (n=0; n < nprocs; n++) { + nm = OBJ_NEW(opal_namelist_t); + opal_list_append(procs, &nm->super); + if (mca_pmix_pmix3x_component.native_launch) { + /* if we were launched by the OMPI RTE, then + * the jobid is in a special format - so get it */ + opal_convert_string_to_jobid(&nm->name.jobid, array[n].nspace); + } else { + /* we were launched by someone else, so make the + * jobid just be the hash of the nspace */ + OPAL_HASH_JOBID(array[n].nspace, nm->name.jobid); + } + /* if we don't already have it, add this to our jobid tracker */ + job = NULL; + OPAL_LIST_FOREACH(jptr, &mca_pmix_pmix3x_component.jobids, opal_pmix3x_jobid_trkr_t) { + if (jptr->jobid == nm->name.jobid) { + job = jptr; + break; + } + } + if (NULL == job) { + job = OBJ_NEW(opal_pmix3x_jobid_trkr_t); + (void)strncpy(job->nspace, nspace, PMIX_MAX_NSLEN); + job->jobid = jobid; + opal_list_append(&mca_pmix_pmix3x_component.jobids, &job->super); + } + nm->name.vpid = pmix3x_convert_rank(array[n].rank); + } + } + PMIX_PROC_FREE(array, nprocs); + + return rc; +} + +int pmix3x_resolve_nodes(opal_jobid_t jobid, char **nodelist) +{ + pmix_status_t ret; + char *nspace=NULL; + opal_pmix3x_jobid_trkr_t *job, *jptr; + + /* we must threadshift this request as we might not be in an event + * and we are going to access framework-global lists/objects */ + + if (OPAL_JOBID_WILDCARD != jobid) { + /* look thru our list of jobids and find the + * corresponding nspace */ + job = NULL; + OPAL_LIST_FOREACH(jptr, &mca_pmix_pmix3x_component.jobids, opal_pmix3x_jobid_trkr_t) { + if (jptr->jobid == jobid) { + job = jptr; + break; + } + } + if (NULL == job) { + return OPAL_ERR_NOT_FOUND; + } + nspace = job->nspace; + } + + ret = PMIx_Resolve_nodes(nspace, nodelist); + + return pmix3x_convert_rc(ret);; +} diff --git a/opal/mca/pmix/ext3x/pmix3x_component.c b/opal/mca/pmix/ext3x/pmix3x_component.c new file mode 100644 index 0000000000..cd76f55109 --- /dev/null +++ b/opal/mca/pmix/ext3x/pmix3x_component.c @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2014-2016 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2015 Research Organization for Information Science + * and Technology (RIST). All rights reserved. + * Copyright (c) 2016 Cisco Systems, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + * + * These symbols are in a file by themselves to provide nice linker + * semantics. Since linkers generally pull in symbols by object + * files, keeping these symbols as the only symbols in this file + * prevents utility programs such as "ompi_info" from having to import + * entire components just to query their version and parameters. + */ + +#include "opal_config.h" + +#include "opal/constants.h" +#include "opal/class/opal_list.h" +#include "opal/util/proc.h" +#include "opal/mca/pmix/pmix.h" +#include "pmix3x.h" + +/* + * Public string showing the pmix external component version number + */ +const char *opal_pmix_pmix3x_component_version_string = + "OPAL pmix3x MCA component version " OPAL_VERSION; + +/* + * Local function + */ +static int external_open(void); +static int external_close(void); +static int external_component_query(mca_base_module_t **module, int *priority); +static int external_register(void); + + +/* + * Instantiate the public struct with all of our public information + * and pointers to our public functions in it + */ + +mca_pmix_pmix3x_component_t mca_pmix_pmix3x_component = { + { + /* First, the mca_component_t struct containing meta information + about the component itself */ + + .base_version = { + /* Indicate that we are a pmix v1.1.0 component (which also + implies a specific MCA version) */ + + OPAL_PMIX_BASE_VERSION_2_0_0, + + /* Component name and version */ + + .mca_component_name = "pmix3x", + MCA_BASE_MAKE_VERSION(component, OPAL_MAJOR_VERSION, OPAL_MINOR_VERSION, + OPAL_RELEASE_VERSION), + + /* Component open and close functions */ + + .mca_open_component = external_open, + .mca_close_component = external_close, + .mca_query_component = external_component_query, + .mca_register_component_params = external_register, + }, + /* Next the MCA v1.0.0 component meta data */ + .base_data = { + /* The component is checkpoint ready */ + MCA_BASE_METADATA_PARAM_CHECKPOINT + } + }, + .native_launch = false +}; + +static int external_register(void) +{ + mca_pmix_pmix3x_component.cache_size = 256; + mca_base_component_var_register(&mca_pmix_pmix3x_component.super.base_version, + "cache_size", "Size of the ring buffer cache for events", + MCA_BASE_VAR_TYPE_INT, NULL, 0, 0, OPAL_INFO_LVL_5, + MCA_BASE_VAR_SCOPE_CONSTANT, + &mca_pmix_pmix3x_component.cache_size); + + return OPAL_SUCCESS; +} + + +static int external_open(void) +{ + mca_pmix_pmix3x_component.evindex = 0; + OBJ_CONSTRUCT(&mca_pmix_pmix3x_component.jobids, opal_list_t); + OBJ_CONSTRUCT(&mca_pmix_pmix3x_component.single_events, opal_list_t); + OBJ_CONSTRUCT(&mca_pmix_pmix3x_component.multi_events, opal_list_t); + OBJ_CONSTRUCT(&mca_pmix_pmix3x_component.default_events, opal_list_t); + OBJ_CONSTRUCT(&mca_pmix_pmix3x_component.cache, opal_list_t); + + return OPAL_SUCCESS; +} + +static int external_close(void) +{ + OPAL_LIST_DESTRUCT(&mca_pmix_pmix3x_component.jobids); + OPAL_LIST_DESTRUCT(&mca_pmix_pmix3x_component.single_events); + OPAL_LIST_DESTRUCT(&mca_pmix_pmix3x_component.multi_events); + OPAL_LIST_DESTRUCT(&mca_pmix_pmix3x_component.default_events); + OPAL_LIST_DESTRUCT(&mca_pmix_pmix3x_component.cache); + return OPAL_SUCCESS; +} + + +static int external_component_query(mca_base_module_t **module, int *priority) +{ + char *t, *id; + + /* see if a PMIx server is present */ + if (NULL != (t = getenv("PMIX_SERVER_URI")) || + NULL != (id = getenv("PMIX_ID"))) { + /* if PMIx is present, then we are a client and need to use it */ + *priority = 100; + } else { + /* we could be a server, so we still need to be considered */ + *priority = 5; + } + *module = (mca_base_module_t *)&opal_pmix_pmix3x_module; + return OPAL_SUCCESS; +} diff --git a/opal/mca/pmix/ext3x/pmix3x_server_north.c b/opal/mca/pmix/ext3x/pmix3x_server_north.c new file mode 100644 index 0000000000..3161f4c6b5 --- /dev/null +++ b/opal/mca/pmix/ext3x/pmix3x_server_north.c @@ -0,0 +1,1047 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2014-2016 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2016 Research Organization for Information Science + * and Technology (RIST). All rights reserved. + * Copyright (c) 2014-2015 Mellanox Technologies, Inc. + * All rights reserved. + * Copyright (c) 2016 Cisco Systems, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "opal_config.h" +#include "opal/constants.h" +#include "opal/types.h" + +#ifdef HAVE_STRING_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif + +#include "opal/dss/dss.h" +#include "opal/mca/event/event.h" +#include "opal/mca/hwloc/base/base.h" +#include "opal/runtime/opal.h" +#include "opal/runtime/opal_progress_threads.h" +#include "opal/util/argv.h" +#include "opal/util/error.h" +#include "opal/util/output.h" +#include "opal/util/proc.h" +#include "opal/util/show_help.h" +#include "opal/mca/pmix/base/base.h" +#include "pmix3x.h" + +#include "pmix.h" +#include "pmix_server.h" + +/**** N.O.R.T.H.B.O.U.N.D I.N.T.E.R.F.A.C.E.S ****/ + +/* These are the interfaces used by the embedded PMIx server + * to call up into ORTE for service requests */ + + static pmix_status_t server_client_connected_fn(const pmix_proc_t *proc, void* server_object, + pmix_op_cbfunc_t cbfunc, void *cbdata); + static pmix_status_t server_client_finalized_fn(const pmix_proc_t *proc, void* server_object, + pmix_op_cbfunc_t cbfunc, void *cbdata); + static pmix_status_t server_abort_fn(const pmix_proc_t *proc, void *server_object, + int status, const char msg[], + pmix_proc_t procs[], size_t nprocs, + pmix_op_cbfunc_t cbfunc, void *cbdata); + static pmix_status_t server_fencenb_fn(const pmix_proc_t procs[], size_t nprocs, + const pmix_info_t info[], size_t ninfo, + char *data, size_t ndata, + pmix_modex_cbfunc_t cbfunc, void *cbdata); + static pmix_status_t server_dmodex_req_fn(const pmix_proc_t *proc, + const pmix_info_t info[], size_t ninfo, + pmix_modex_cbfunc_t cbfunc, void *cbdata); + static pmix_status_t server_publish_fn(const pmix_proc_t *proc, + const pmix_info_t info[], size_t ninfo, + pmix_op_cbfunc_t cbfunc, void *cbdata); + static pmix_status_t server_lookup_fn(const pmix_proc_t *proc, char **keys, + const pmix_info_t info[], size_t ninfo, + pmix_lookup_cbfunc_t cbfunc, void *cbdata); + static pmix_status_t server_unpublish_fn(const pmix_proc_t *proc, char **keys, + const pmix_info_t info[], size_t ninfo, + pmix_op_cbfunc_t cbfunc, void *cbdata); + static pmix_status_t server_spawn_fn(const pmix_proc_t *proc, + const pmix_info_t job_info[], size_t ninfo, + const pmix_app_t apps[], size_t napps, + pmix_spawn_cbfunc_t cbfunc, void *cbdata); + static pmix_status_t server_connect_fn(const pmix_proc_t procs[], size_t nprocs, + const pmix_info_t info[], size_t ninfo, + pmix_op_cbfunc_t cbfunc, void *cbdata); + static pmix_status_t server_disconnect_fn(const pmix_proc_t procs[], size_t nprocs, + const pmix_info_t info[], size_t ninfo, + pmix_op_cbfunc_t cbfunc, void *cbdata); + static pmix_status_t server_register_events(pmix_status_t *codes, size_t ncodes, + const pmix_info_t info[], size_t ninfo, + pmix_op_cbfunc_t cbfunc, void *cbdata); + static pmix_status_t server_deregister_events(pmix_status_t *codes, size_t ncodes, + pmix_op_cbfunc_t cbfunc, void *cbdata); + static pmix_status_t server_notify_event(pmix_status_t code, + const pmix_proc_t *source, + pmix_data_range_t range, + pmix_info_t info[], size_t ninfo, + pmix_op_cbfunc_t cbfunc, void *cbdata); + static pmix_status_t server_query(pmix_proc_t *proct, + pmix_query_t *queryies, size_t nqueries, + pmix_info_cbfunc_t cbfunc, + void *cbdata); + static void server_tool_connection(pmix_info_t *info, size_t ninfo, + pmix_tool_connection_cbfunc_t cbfunc, + void *cbdata); +static void server_log(const pmix_proc_t *client, + const pmix_info_t data[], size_t ndata, + const pmix_info_t directives[], size_t ndirs, + pmix_op_cbfunc_t cbfunc, void *cbdata); + + pmix_server_module_t mymodule = { + .client_connected = server_client_connected_fn, + .client_finalized = server_client_finalized_fn, + .abort = server_abort_fn, + .fence_nb = server_fencenb_fn, + .direct_modex = server_dmodex_req_fn, + .publish = server_publish_fn, + .lookup = server_lookup_fn, + .unpublish = server_unpublish_fn, + .spawn = server_spawn_fn, + .connect = server_connect_fn, + .disconnect = server_disconnect_fn, + .register_events = server_register_events, + .deregister_events = server_deregister_events, + .notify_event = server_notify_event, + .query = server_query, + .tool_connected = server_tool_connection, + .log = server_log +}; + +opal_pmix_server_module_t *host_module = NULL; + + +static void opal_opcbfunc(int status, void *cbdata) +{ + pmix3x_opalcaddy_t *opalcaddy = (pmix3x_opalcaddy_t*)cbdata; + + if (NULL != opalcaddy->opcbfunc) { + opalcaddy->opcbfunc(pmix3x_convert_opalrc(status), opalcaddy->cbdata); + } + OBJ_RELEASE(opalcaddy); +} + +static pmix_status_t server_client_connected_fn(const pmix_proc_t *p, void *server_object, + pmix_op_cbfunc_t cbfunc, void *cbdata) +{ + int rc; + opal_process_name_t proc; + pmix3x_opalcaddy_t *opalcaddy; + + if (NULL == host_module || NULL == host_module->client_connected) { + return PMIX_SUCCESS; + } + + opalcaddy = OBJ_NEW(pmix3x_opalcaddy_t); + opalcaddy->opcbfunc = cbfunc; + opalcaddy->cbdata = cbdata; + + /* convert the nspace/rank to an opal_process_name_t */ + if (OPAL_SUCCESS != (rc = opal_convert_string_to_jobid(&proc.jobid, p->nspace))) { + return pmix3x_convert_opalrc(rc); + } + proc.vpid = pmix3x_convert_rank(p->rank); + + /* pass it up */ + rc = host_module->client_connected(&proc, server_object, + opal_opcbfunc, opalcaddy); + return pmix3x_convert_opalrc(rc); +} + +static pmix_status_t server_client_finalized_fn(const pmix_proc_t *p, void* server_object, + pmix_op_cbfunc_t cbfunc, void *cbdata) +{ + int rc; + pmix3x_opalcaddy_t *opalcaddy; + opal_process_name_t proc; + + if (NULL == host_module || NULL == host_module->client_finalized) { + return PMIX_SUCCESS; + } + + /* convert the nspace/rank to an opal_process_name_t */ + if (OPAL_SUCCESS != (rc = opal_convert_string_to_jobid(&proc.jobid, p->nspace))) { + return pmix3x_convert_opalrc(rc); + } + proc.vpid = pmix3x_convert_rank(p->rank); + + /* setup the caddy */ + opalcaddy = OBJ_NEW(pmix3x_opalcaddy_t); + opalcaddy->opcbfunc = cbfunc; + opalcaddy->cbdata = cbdata; + + /* pass it up */ + rc = host_module->client_finalized(&proc, server_object, opal_opcbfunc, opalcaddy); + if (OPAL_SUCCESS != rc) { + OBJ_RELEASE(opalcaddy); + } + return pmix3x_convert_opalrc(rc); +} + +static pmix_status_t server_abort_fn(const pmix_proc_t *p, void *server_object, + int status, const char msg[], + pmix_proc_t procs[], size_t nprocs, + pmix_op_cbfunc_t cbfunc, void *cbdata) +{ + size_t n; + opal_namelist_t *nm; + opal_process_name_t proc; + int rc; + pmix3x_opalcaddy_t *opalcaddy; + + if (NULL == host_module || NULL == host_module->abort) { + return PMIX_ERR_NOT_SUPPORTED; + } + + /* convert the nspace/rank to an opal_process_name_t */ + if (OPAL_SUCCESS != (rc = opal_convert_string_to_jobid(&proc.jobid, p->nspace))) { + return pmix3x_convert_opalrc(rc); + } + proc.vpid = pmix3x_convert_rank(p->rank); + + /* setup the caddy */ + opalcaddy = OBJ_NEW(pmix3x_opalcaddy_t); + opalcaddy->opcbfunc = cbfunc; + opalcaddy->cbdata = cbdata; + + /* convert the array of pmix_proc_t to the list of procs */ + for (n=0; n < nprocs; n++) { + nm = OBJ_NEW(opal_namelist_t); + opal_list_append(&opalcaddy->procs, &nm->super); + if (OPAL_SUCCESS != (rc = opal_convert_string_to_jobid(&nm->name.jobid, procs[n].nspace))) { + OBJ_RELEASE(opalcaddy); + return pmix3x_convert_opalrc(rc); + } + nm->name.vpid = pmix3x_convert_rank(procs[n].rank); + } + + /* pass it up */ + rc = host_module->abort(&proc, server_object, status, msg, + &opalcaddy->procs, opal_opcbfunc, opalcaddy); + if (OPAL_SUCCESS != rc) { + OBJ_RELEASE(opalcaddy); + } + return pmix3x_convert_opalrc(rc); +} + +static void _data_release(void *cbdata) +{ + pmix3x_opalcaddy_t *opalcaddy = (pmix3x_opalcaddy_t*)cbdata; + + if (NULL != opalcaddy->odmdxfunc) { + opalcaddy->odmdxfunc(opalcaddy->ocbdata); + } + OBJ_RELEASE(opalcaddy); +} + +static void opmdx_response(int status, const char *data, size_t sz, void *cbdata, + opal_pmix_release_cbfunc_t relcbfunc, void *relcbdata) +{ + pmix_status_t rc; + pmix3x_opalcaddy_t *opalcaddy = (pmix3x_opalcaddy_t*)cbdata; + + rc = pmix3x_convert_rc(status); + if (NULL != opalcaddy->mdxcbfunc) { + opalcaddy->odmdxfunc = relcbfunc; + opalcaddy->ocbdata = relcbdata; + opalcaddy->mdxcbfunc(rc, data, sz, opalcaddy->cbdata, + _data_release, opalcaddy); + } else { + OBJ_RELEASE(opalcaddy); + } +} + +static pmix_status_t server_fencenb_fn(const pmix_proc_t procs[], size_t nprocs, + const pmix_info_t info[], size_t ninfo, + char *data, size_t ndata, + pmix_modex_cbfunc_t cbfunc, void *cbdata) +{ + pmix3x_opalcaddy_t *opalcaddy; + size_t n; + opal_namelist_t *nm; + opal_value_t *iptr; + int rc; + + if (NULL == host_module || NULL == host_module->fence_nb) { + return PMIX_ERR_NOT_SUPPORTED; + } + + /* setup the caddy */ + opalcaddy = OBJ_NEW(pmix3x_opalcaddy_t); + opalcaddy->mdxcbfunc = cbfunc; + opalcaddy->cbdata = cbdata; + + /* convert the array of pmix_proc_t to the list of procs */ + for (n=0; n < nprocs; n++) { + nm = OBJ_NEW(opal_namelist_t); + opal_list_append(&opalcaddy->procs, &nm->super); + if (OPAL_SUCCESS != (rc = opal_convert_string_to_jobid(&nm->name.jobid, procs[n].nspace))) { + OBJ_RELEASE(opalcaddy); + return pmix3x_convert_opalrc(rc); + } + nm->name.vpid = pmix3x_convert_rank(procs[n].rank); + } + + /* convert the array of pmix_info_t to the list of info */ + for (n=0; n < ninfo; n++) { + iptr = OBJ_NEW(opal_value_t); + opal_list_append(&opalcaddy->info, &iptr->super); + iptr->key = strdup(info[n].key); + if (OPAL_SUCCESS != (rc = pmix3x_value_unload(iptr, &info[n].value))) { + OBJ_RELEASE(opalcaddy); + return pmix3x_convert_opalrc(rc); + } + } + + /* pass it up */ + rc = host_module->fence_nb(&opalcaddy->procs, &opalcaddy->info, + data, ndata, opmdx_response, opalcaddy); + if (OPAL_SUCCESS != rc) { + OBJ_RELEASE(opalcaddy); + } + return pmix3x_convert_opalrc(rc); +} + +static pmix_status_t server_dmodex_req_fn(const pmix_proc_t *p, + const pmix_info_t info[], size_t ninfo, + pmix_modex_cbfunc_t cbfunc, void *cbdata) +{ + int rc; + pmix3x_opalcaddy_t *opalcaddy; + opal_process_name_t proc; + opal_value_t *iptr; + size_t n; + + if (NULL == host_module || NULL == host_module->direct_modex) { + return PMIX_ERR_NOT_SUPPORTED; + } + + /* convert the nspace/rank to an opal_process_name_t */ + if (OPAL_SUCCESS != (rc = opal_convert_string_to_jobid(&proc.jobid, p->nspace))) { + return pmix3x_convert_opalrc(rc); + } + proc.vpid = pmix3x_convert_rank(p->rank); + + /* setup the caddy */ + opalcaddy = OBJ_NEW(pmix3x_opalcaddy_t); + opalcaddy->mdxcbfunc = cbfunc; + opalcaddy->cbdata = cbdata; + + /* convert the array of pmix_info_t to the list of info */ + for (n=0; n < ninfo; n++) { + iptr = OBJ_NEW(opal_value_t); + opal_list_append(&opalcaddy->info, &iptr->super); + iptr->key = strdup(info[n].key); + if (OPAL_SUCCESS != (rc = pmix3x_value_unload(iptr, &info[n].value))) { + OBJ_RELEASE(opalcaddy); + return pmix3x_convert_opalrc(rc); + } + } + + /* pass it up */ + rc = host_module->direct_modex(&proc, &opalcaddy->info, opmdx_response, opalcaddy); + if (OPAL_SUCCESS != rc && OPAL_ERR_IN_PROCESS != rc) { + OBJ_RELEASE(opalcaddy); + } + if (OPAL_ERR_IN_PROCESS == rc) { + rc = OPAL_SUCCESS; + } + return pmix3x_convert_opalrc(rc); +} + +static pmix_status_t server_publish_fn(const pmix_proc_t *p, + const pmix_info_t info[], size_t ninfo, + pmix_op_cbfunc_t cbfunc, void *cbdata) +{ + int rc; + size_t n; + pmix3x_opalcaddy_t *opalcaddy; + opal_process_name_t proc; + opal_value_t *oinfo; + + if (NULL == host_module || NULL == host_module->publish) { + return PMIX_ERR_NOT_SUPPORTED; + } + + /* convert the nspace/rank to an opal_process_name_t */ + if (OPAL_SUCCESS != (rc = opal_convert_string_to_jobid(&proc.jobid, p->nspace))) { + return pmix3x_convert_opalrc(rc); + } + proc.vpid = pmix3x_convert_rank(p->rank); + + /* setup the caddy */ + opalcaddy = OBJ_NEW(pmix3x_opalcaddy_t); + opalcaddy->opcbfunc = cbfunc; + opalcaddy->cbdata = cbdata; + + /* convert the info array */ + for (n=0; n < ninfo; n++) { + oinfo = OBJ_NEW(opal_value_t); + opal_list_append(&opalcaddy->info, &oinfo->super); + oinfo->key = strdup(info[n].key); + if (OPAL_SUCCESS != (rc = pmix3x_value_unload(oinfo, &info[n].value))) { + OBJ_RELEASE(opalcaddy); + return pmix3x_convert_opalrc(rc); + } + } + + /* pass it up */ + rc = host_module->publish(&proc, &opalcaddy->info, opal_opcbfunc, opalcaddy); + if (OPAL_SUCCESS != rc) { + OBJ_RELEASE(opalcaddy); + } + + return pmix3x_convert_opalrc(rc); +} + +static void opal_lkupcbfunc(int status, + opal_list_t *data, + void *cbdata) +{ + pmix3x_opalcaddy_t *opalcaddy = (pmix3x_opalcaddy_t*)cbdata; + pmix_status_t rc; + pmix_pdata_t *d=NULL; + size_t nd=0, n; + opal_pmix_pdata_t *p; + + if (NULL != opalcaddy->lkupcbfunc) { + rc = pmix3x_convert_opalrc(status); + /* convert any returned data */ + if (NULL != data) { + nd = opal_list_get_size(data); + PMIX_PDATA_CREATE(d, nd); + n=0; + OPAL_LIST_FOREACH(p, data, opal_pmix_pdata_t) { + /* convert the jobid */ + (void)opal_snprintf_jobid(d[n].proc.nspace, PMIX_MAX_NSLEN, p->proc.jobid); + d[n].proc.rank = pmix3x_convert_opalrank(p->proc.vpid); + (void)strncpy(d[n].key, p->value.key, PMIX_MAX_KEYLEN); + pmix3x_value_load(&d[n].value, &p->value); + } + } + opalcaddy->lkupcbfunc(rc, d, nd, opalcaddy->cbdata); + } + OBJ_RELEASE(opalcaddy); +} + +static pmix_status_t server_lookup_fn(const pmix_proc_t *p, char **keys, + const pmix_info_t info[], size_t ninfo, + pmix_lookup_cbfunc_t cbfunc, void *cbdata) +{ + int rc; + pmix3x_opalcaddy_t *opalcaddy; + opal_process_name_t proc; + opal_value_t *iptr; + size_t n; + + if (NULL == host_module || NULL == host_module->lookup) { + return PMIX_ERR_NOT_SUPPORTED; + } + + /* convert the nspace/rank to an opal_process_name_t */ + if (OPAL_SUCCESS != (rc = opal_convert_string_to_jobid(&proc.jobid, p->nspace))) { + return pmix3x_convert_opalrc(rc); + } + proc.vpid = pmix3x_convert_rank(p->rank); + + /* setup the caddy */ + opalcaddy = OBJ_NEW(pmix3x_opalcaddy_t); + opalcaddy->lkupcbfunc = cbfunc; + opalcaddy->cbdata = cbdata; + + /* convert the array of pmix_info_t to the list of info */ + for (n=0; n < ninfo; n++) { + iptr = OBJ_NEW(opal_value_t); + opal_list_append(&opalcaddy->info, &iptr->super); + iptr->key = strdup(info[n].key); + if (OPAL_SUCCESS != (rc = pmix3x_value_unload(iptr, &info[n].value))) { + OBJ_RELEASE(opalcaddy); + return pmix3x_convert_opalrc(rc); + } + } + + /* pass it up */ + rc = host_module->lookup(&proc, keys, &opalcaddy->info, opal_lkupcbfunc, opalcaddy); + if (OPAL_SUCCESS != rc) { + OBJ_RELEASE(opalcaddy); + } + + return pmix3x_convert_opalrc(rc); +} + + +static pmix_status_t server_unpublish_fn(const pmix_proc_t *p, char **keys, + const pmix_info_t info[], size_t ninfo, + pmix_op_cbfunc_t cbfunc, void *cbdata) +{ + int rc; + pmix3x_opalcaddy_t *opalcaddy; + opal_process_name_t proc; + opal_value_t *iptr; + size_t n; + + if (NULL == host_module || NULL == host_module->unpublish) { + return PMIX_SUCCESS; + } + + /* convert the nspace/rank to an opal_process_name_t */ + if (OPAL_SUCCESS != (rc = opal_convert_string_to_jobid(&proc.jobid, p->nspace))) { + return pmix3x_convert_opalrc(rc); + } + proc.vpid = pmix3x_convert_rank(p->rank); + + /* setup the caddy */ + opalcaddy = OBJ_NEW(pmix3x_opalcaddy_t); + opalcaddy->opcbfunc = cbfunc; + opalcaddy->cbdata = cbdata; + + /* convert the array of pmix_info_t to the list of info */ + for (n=0; n < ninfo; n++) { + iptr = OBJ_NEW(opal_value_t); + opal_list_append(&opalcaddy->info, &iptr->super); + iptr->key = strdup(info[n].key); + if (OPAL_SUCCESS != (rc = pmix3x_value_unload(iptr, &info[n].value))) { + OBJ_RELEASE(opalcaddy); + return pmix3x_convert_opalrc(rc); + } + } + + /* pass it up */ + rc = host_module->unpublish(&proc, keys, &opalcaddy->info, opal_opcbfunc, opalcaddy); + if (OPAL_SUCCESS != rc) { + OBJ_RELEASE(opalcaddy); + } + + return pmix3x_convert_opalrc(rc); +} + +static void opal_spncbfunc(int status, opal_jobid_t jobid, void *cbdata) +{ + pmix3x_opalcaddy_t *opalcaddy = (pmix3x_opalcaddy_t*)cbdata; + pmix_status_t rc; + char nspace[PMIX_MAX_NSLEN]; + + if (NULL != opalcaddy->spwncbfunc) { + rc = pmix3x_convert_opalrc(status); + /* convert the jobid */ + (void)opal_snprintf_jobid(nspace, PMIX_MAX_NSLEN, jobid); + opalcaddy->spwncbfunc(rc, nspace, opalcaddy->cbdata); + } + OBJ_RELEASE(opalcaddy); +} + +static pmix_status_t server_spawn_fn(const pmix_proc_t *p, + const pmix_info_t job_info[], size_t ninfo, + const pmix_app_t apps[], size_t napps, + pmix_spawn_cbfunc_t cbfunc, void *cbdata) +{ + pmix3x_opalcaddy_t *opalcaddy; + opal_process_name_t proc; + opal_pmix_app_t *app; + opal_value_t *oinfo; + size_t k, n; + int rc; + + if (NULL == host_module || NULL == host_module->spawn) { + return PMIX_ERR_NOT_SUPPORTED; + } + + /* convert the nspace/rank to an opal_process_name_t */ + if (OPAL_SUCCESS != (rc = opal_convert_string_to_jobid(&proc.jobid, p->nspace))) { + return pmix3x_convert_opalrc(rc); + } + proc.vpid = pmix3x_convert_rank(p->rank); + + /* setup the caddy */ + opalcaddy = OBJ_NEW(pmix3x_opalcaddy_t); + opalcaddy->spwncbfunc = cbfunc; + opalcaddy->cbdata = cbdata; + + /* convert the job info */ + for (k=0; k < ninfo; k++) { + oinfo = OBJ_NEW(opal_value_t); + opal_list_append(&opalcaddy->info, &oinfo->super); + oinfo->key = strdup(job_info[k].key); + if (OPAL_SUCCESS != (rc = pmix3x_value_unload(oinfo, &job_info[k].value))) { + OBJ_RELEASE(opalcaddy); + return pmix3x_convert_opalrc(rc); + } + } + + /* convert the apps */ + for (n=0; n < napps; n++) { + app = OBJ_NEW(opal_pmix_app_t); + opal_list_append(&opalcaddy->apps, &app->super); + if (NULL != apps[n].cmd) { + app->cmd = strdup(apps[n].cmd); + } + app->argc = apps[n].argc; + if (NULL != apps[n].argv) { + app->argv = opal_argv_copy(apps[n].argv); + } + if (NULL != apps[n].env) { + app->env = opal_argv_copy(apps[n].env); + } + app->maxprocs = apps[n].maxprocs; + for (k=0; k < apps[n].ninfo; k++) { + oinfo = OBJ_NEW(opal_value_t); + opal_list_append(&app->info, &oinfo->super); + oinfo->key = strdup(apps[n].info[k].key); + if (OPAL_SUCCESS != (rc = pmix3x_value_unload(oinfo, &apps[n].info[k].value))) { + OBJ_RELEASE(opalcaddy); + return pmix3x_convert_opalrc(rc); + } + } + } + + /* pass it up */ + rc = host_module->spawn(&proc, &opalcaddy->info, &opalcaddy->apps, opal_spncbfunc, opalcaddy); + if (OPAL_SUCCESS != rc) { + OPAL_ERROR_LOG(rc); + OBJ_RELEASE(opalcaddy); + } + + return pmix3x_convert_opalrc(rc); +} + + +static pmix_status_t server_connect_fn(const pmix_proc_t procs[], size_t nprocs, + const pmix_info_t info[], size_t ninfo, + pmix_op_cbfunc_t cbfunc, void *cbdata) +{ + int rc; + pmix3x_opalcaddy_t *opalcaddy; + opal_namelist_t *nm; + size_t n; + opal_value_t *oinfo; + + if (NULL == host_module || NULL == host_module->connect) { + return PMIX_ERR_NOT_SUPPORTED; + } + + /* setup the caddy */ + opalcaddy = OBJ_NEW(pmix3x_opalcaddy_t); + opalcaddy->opcbfunc = cbfunc; + opalcaddy->cbdata = cbdata; + + /* convert the array of pmix_proc_t to the list of procs */ + for (n=0; n < nprocs; n++) { + nm = OBJ_NEW(opal_namelist_t); + opal_list_append(&opalcaddy->procs, &nm->super); + if (OPAL_SUCCESS != (rc = opal_convert_string_to_jobid(&nm->name.jobid, procs[n].nspace))) { + OBJ_RELEASE(opalcaddy); + return pmix3x_convert_opalrc(rc); + } + nm->name.vpid = pmix3x_convert_rank(procs[n].rank); + } + + /* convert the info */ + for (n=0; n < ninfo; n++) { + oinfo = OBJ_NEW(opal_value_t); + opal_list_append(&opalcaddy->info, &oinfo->super); + oinfo->key = strdup(info[n].key); + if (OPAL_SUCCESS != (rc = pmix3x_value_unload(oinfo, &info[n].value))) { + OBJ_RELEASE(opalcaddy); + return pmix3x_convert_opalrc(rc); + } + } + + /* pass it up */ + rc = host_module->connect(&opalcaddy->procs, &opalcaddy->info, opal_opcbfunc, opalcaddy); + if (OPAL_SUCCESS != rc) { + OBJ_RELEASE(opalcaddy); + } + + return pmix3x_convert_opalrc(rc); +} + + +static pmix_status_t server_disconnect_fn(const pmix_proc_t procs[], size_t nprocs, + const pmix_info_t info[], size_t ninfo, + pmix_op_cbfunc_t cbfunc, void *cbdata) +{ + int rc; + pmix3x_opalcaddy_t *opalcaddy; + opal_namelist_t *nm; + size_t n; + opal_value_t *oinfo; + + if (NULL == host_module || NULL == host_module->disconnect) { + return PMIX_ERR_NOT_SUPPORTED; + } + + /* setup the caddy */ + opalcaddy = OBJ_NEW(pmix3x_opalcaddy_t); + opalcaddy->opcbfunc = cbfunc; + opalcaddy->cbdata = cbdata; + + /* convert the array of pmix_proc_t to the list of procs */ + for (n=0; n < nprocs; n++) { + nm = OBJ_NEW(opal_namelist_t); + opal_list_append(&opalcaddy->procs, &nm->super); + if (OPAL_SUCCESS != (rc = opal_convert_string_to_jobid(&nm->name.jobid, procs[n].nspace))) { + OBJ_RELEASE(opalcaddy); + return pmix3x_convert_opalrc(rc); + } + nm->name.vpid = pmix3x_convert_rank(procs[n].rank); + } + + /* convert the info */ + for (n=0; n < ninfo; n++) { + oinfo = OBJ_NEW(opal_value_t); + opal_list_append(&opalcaddy->info, &oinfo->super); + oinfo->key = strdup(info[n].key); + if (OPAL_SUCCESS != (rc = pmix3x_value_unload(oinfo, &info[n].value))) { + OBJ_RELEASE(opalcaddy); + return pmix3x_convert_opalrc(rc); + } + } + + /* pass it up */ + rc = host_module->disconnect(&opalcaddy->procs, &opalcaddy->info, opal_opcbfunc, opalcaddy); + if (OPAL_SUCCESS != rc) { + OBJ_RELEASE(opalcaddy); + } + + return pmix3x_convert_opalrc(rc); +} + +static pmix_status_t server_register_events(pmix_status_t *codes, size_t ncodes, + const pmix_info_t info[], size_t ninfo, + pmix_op_cbfunc_t cbfunc, void *cbdata) +{ + pmix3x_opalcaddy_t *opalcaddy; + size_t n; + opal_value_t *oinfo; + int rc; + + /* setup the caddy */ + opalcaddy = OBJ_NEW(pmix3x_opalcaddy_t); + opalcaddy->opcbfunc = cbfunc; + opalcaddy->cbdata = cbdata; + + /* convert the info */ + for (n=0; n < ninfo; n++) { + oinfo = OBJ_NEW(opal_value_t); + opal_list_append(&opalcaddy->info, &oinfo->super); + oinfo->key = strdup(info[n].key); + if (OPAL_SUCCESS != (rc = pmix3x_value_unload(oinfo, &info[n].value))) { + OBJ_RELEASE(opalcaddy); + return pmix3x_convert_opalrc(rc); + } + } + + /* pass it up */ + rc = host_module->register_events(&opalcaddy->info, opal_opcbfunc, opalcaddy); + if (OPAL_SUCCESS != rc) { + OBJ_RELEASE(opalcaddy); + } + + return pmix3x_convert_opalrc(rc); +} + +static pmix_status_t server_deregister_events(pmix_status_t *codes, size_t ncodes, + pmix_op_cbfunc_t cbfunc, void *cbdata) +{ + return PMIX_ERR_NOT_SUPPORTED; +} + +static pmix_status_t server_notify_event(pmix_status_t code, + const pmix_proc_t *source, + pmix_data_range_t range, + pmix_info_t info[], size_t ninfo, + pmix_op_cbfunc_t cbfunc, void *cbdata) +{ + pmix3x_opalcaddy_t *opalcaddy; + opal_process_name_t src; + size_t n; + opal_value_t *oinfo; + int rc, status; + + if (NULL == host_module || NULL == host_module->notify_event) { + return PMIX_ERR_NOT_SUPPORTED; + } + + /* setup the caddy */ + opalcaddy = OBJ_NEW(pmix3x_opalcaddy_t); + opalcaddy->opcbfunc = cbfunc; + opalcaddy->cbdata = cbdata; + + /* convert the code */ + status = pmix3x_convert_rc(code); + + /* convert the source */ + if (OPAL_SUCCESS != (rc = opal_convert_string_to_jobid(&src.jobid, source->nspace))) { + opal_output(0, "FILE: %s LINE %d", __FILE__, __LINE__); + OBJ_RELEASE(opalcaddy); + return pmix3x_convert_opalrc(rc); + } + src.vpid = pmix3x_convert_rank(source->rank); + + /* ignore the range for now */ + + /* convert the info */ + for (n=0; n < ninfo; n++) { + oinfo = OBJ_NEW(opal_value_t); + opal_list_append(&opalcaddy->info, &oinfo->super); + oinfo->key = strdup(info[n].key); + if (OPAL_SUCCESS != (rc = pmix3x_value_unload(oinfo, &info[n].value))) { + OBJ_RELEASE(opalcaddy); + return pmix3x_convert_opalrc(rc); + } + } + + /* send it upstairs */ + if (OPAL_SUCCESS != (rc = host_module->notify_event(status, &src, &opalcaddy->info, + opal_opcbfunc, opalcaddy))) { + OBJ_RELEASE(opalcaddy); + } + return pmix3x_convert_opalrc(rc); +} + +static void _info_rel(void *cbdata) +{ + pmix3x_opcaddy_t *pcaddy = (pmix3x_opcaddy_t*)cbdata; + + OBJ_RELEASE(pcaddy); +} +static void info_cbfunc(int status, + opal_list_t *info, + void *cbdata, + opal_pmix_release_cbfunc_t release_fn, + void *release_cbdata) +{ + pmix3x_opalcaddy_t *opalcaddy = (pmix3x_opalcaddy_t*)cbdata; + pmix3x_opcaddy_t *pcaddy; + opal_value_t *kv; + size_t n; + + pcaddy = OBJ_NEW(pmix3x_opcaddy_t); + + /* convert the status */ + pcaddy->status = pmix3x_convert_opalrc(status); + + /* convert the list to a pmix_info_t array */ + if (NULL != info) { + pcaddy->ninfo = opal_list_get_size(info); + if (0 < pcaddy->ninfo) { + PMIX_INFO_CREATE(pcaddy->info, pcaddy->ninfo); + n = 0; + OPAL_LIST_FOREACH(kv, info, opal_value_t) { + (void)strncpy(pcaddy->info[n].key, kv->key, PMIX_MAX_KEYLEN); + pmix3x_value_load(&pcaddy->info[n].value, kv); + } + } + } + /* we are done with the incoming data */ + if (NULL != release_fn) { + release_fn(release_cbdata); + } + + /* provide the answer downward */ + if (NULL != opalcaddy->infocbfunc) { + opalcaddy->infocbfunc(pcaddy->status, pcaddy->info, pcaddy->ninfo, + opalcaddy->cbdata, _info_rel, pcaddy); + } + OBJ_RELEASE(opalcaddy); +} + +static pmix_status_t server_query(pmix_proc_t *proct, + pmix_query_t *queries, size_t nqueries, + pmix_info_cbfunc_t cbfunc, + void *cbdata) +{ + pmix3x_opalcaddy_t *opalcaddy; + opal_process_name_t requestor; + int rc; + size_t n, m; + opal_pmix_query_t *q; + opal_value_t *oinfo; + + if (NULL == host_module || NULL == host_module->query) { + return PMIX_ERR_NOT_SUPPORTED; + } + + /* setup the caddy */ + opalcaddy = OBJ_NEW(pmix3x_opalcaddy_t); + opalcaddy->infocbfunc = cbfunc; + opalcaddy->cbdata = cbdata; + + /* convert the requestor */ + if (OPAL_SUCCESS != (rc = opal_convert_string_to_jobid(&requestor.jobid, proct->nspace))) { + opal_output(0, "FILE: %s LINE %d", __FILE__, __LINE__); + OBJ_RELEASE(opalcaddy); + return pmix3x_convert_opalrc(rc); + } + requestor.vpid = pmix3x_convert_rank(proct->rank); + + /* convert the queries */ + for (n=0; n < nqueries; n++) { + q = OBJ_NEW(opal_pmix_query_t); + /* we "borrow" the info field of the caddy as we and the + * server function both agree on what will be there */ + opal_list_append(&opalcaddy->info, &q->super); + q->keys = opal_argv_copy(queries[n].keys); + for (m=0; m < queries[n].nqual; m++) { + oinfo = OBJ_NEW(opal_value_t); + opal_list_append(&q->qualifiers, &oinfo->super); + oinfo->key = strdup(queries[n].qualifiers[m].key); + if (OPAL_SUCCESS != (rc = pmix3x_value_unload(oinfo, &queries[n].qualifiers[m].value))) { + OBJ_RELEASE(opalcaddy); + return pmix3x_convert_opalrc(rc); + } + } + } + + /* pass the call upwards */ + if (OPAL_SUCCESS != (rc = host_module->query(&requestor, + &opalcaddy->info, + info_cbfunc, opalcaddy))) { + OBJ_RELEASE(opalcaddy); + } + + return pmix3x_convert_opalrc(rc); +} + +static void toolcbfunc(int status, + opal_process_name_t proc, + void *cbdata) +{ + pmix3x_opalcaddy_t *opalcaddy = (pmix3x_opalcaddy_t*)cbdata; + pmix_status_t rc; + pmix_proc_t p; + + /* convert the status */ + rc = pmix3x_convert_opalrc(status); + + /* convert the process name */ + (void)opal_snprintf_jobid(p.nspace, PMIX_MAX_NSLEN, proc.jobid); + p.rank = pmix3x_convert_opalrank(proc.vpid); + + /* pass it down */ + if (NULL != opalcaddy->toolcbfunc) { + opalcaddy->toolcbfunc(rc, &p, opalcaddy->cbdata); + } + OBJ_RELEASE(opalcaddy); +} + +static void server_tool_connection(pmix_info_t *info, size_t ninfo, + pmix_tool_connection_cbfunc_t cbfunc, + void *cbdata) +{ + pmix3x_opalcaddy_t *opalcaddy; + size_t n; + opal_value_t *oinfo; + int rc; + pmix_status_t err; + + /* setup the caddy */ + opalcaddy = OBJ_NEW(pmix3x_opalcaddy_t); + opalcaddy->toolcbfunc = cbfunc; + opalcaddy->cbdata = cbdata; + + /* convert the info */ + for (n=0; n < ninfo; n++) { + oinfo = OBJ_NEW(opal_value_t); + opal_list_append(&opalcaddy->info, &oinfo->super); + oinfo->key = strdup(info[n].key); + if (OPAL_SUCCESS != (rc = pmix3x_value_unload(oinfo, &info[n].value))) { + OBJ_RELEASE(opalcaddy); + err = pmix3x_convert_opalrc(rc); + if (NULL != cbfunc) { + cbfunc(err, NULL, cbdata); + } + } + } + + /* pass it up */ + host_module->tool_connected(&opalcaddy->info, toolcbfunc, opalcaddy); +} + +static void server_log(const pmix_proc_t *proct, + const pmix_info_t data[], size_t ndata, + const pmix_info_t directives[], size_t ndirs, + pmix_op_cbfunc_t cbfunc, void *cbdata) +{ + pmix3x_opalcaddy_t *opalcaddy; + opal_process_name_t requestor; + int rc; + size_t n; + opal_value_t *oinfo; + pmix_status_t ret; + + if (NULL == host_module || NULL == host_module->log) { + if (NULL != cbfunc) { + cbfunc(PMIX_ERR_NOT_SUPPORTED, cbdata); + } + return; + } + + /* setup the caddy */ + opalcaddy = OBJ_NEW(pmix3x_opalcaddy_t); + opalcaddy->opcbfunc = cbfunc; + opalcaddy->cbdata = cbdata; + + /* convert the requestor */ + if (OPAL_SUCCESS != (rc = opal_convert_string_to_jobid(&requestor.jobid, proct->nspace))) { + opal_output(0, "FILE: %s LINE %d", __FILE__, __LINE__); + OBJ_RELEASE(opalcaddy); + ret = pmix3x_convert_opalrc(rc); + if (NULL != cbfunc) { + cbfunc(ret, cbdata); + } + return; + } + requestor.vpid = pmix3x_convert_rank(proct->rank); + + /* convert the data */ + for (n=0; n < ndata; n++) { + oinfo = OBJ_NEW(opal_value_t); + /* we "borrow" the info field of the caddy as we and the + * server function both agree on what will be there */ + opal_list_append(&opalcaddy->info, &oinfo->super); + if (OPAL_SUCCESS != (rc = pmix3x_value_unload(oinfo, &data[n].value))) { + OBJ_RELEASE(opalcaddy); + ret = pmix3x_convert_opalrc(rc); + if (NULL != cbfunc) { + cbfunc(ret, cbdata); + } + return; + } + } + + /* convert the directives */ + for (n=0; n < ndirs; n++) { + oinfo = OBJ_NEW(opal_value_t); + /* we "borrow" the apps field of the caddy as we and the + * server function both agree on what will be there */ + opal_list_append(&opalcaddy->apps, &oinfo->super); + if (OPAL_SUCCESS != (rc = pmix3x_value_unload(oinfo, &directives[n].value))) { + OBJ_RELEASE(opalcaddy); + ret = pmix3x_convert_opalrc(rc); + if (NULL != cbfunc) { + cbfunc(ret, cbdata); + } + return; + } + } + + /* pass the call upwards */ + host_module->log(&requestor, + &opalcaddy->info, + &opalcaddy->apps, + opal_opcbfunc, opalcaddy); +} diff --git a/opal/mca/pmix/ext3x/pmix3x_server_south.c b/opal/mca/pmix/ext3x/pmix3x_server_south.c new file mode 100644 index 0000000000..3d6226382a --- /dev/null +++ b/opal/mca/pmix/ext3x/pmix3x_server_south.c @@ -0,0 +1,519 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ +/* + * Copyright (c) 2014-2016 Intel, Inc. All rights reserved. + * Copyright (c) 2014-2016 Research Organization for Information Science + * and Technology (RIST). All rights reserved. + * Copyright (c) 2014-2016 Intel, Inc. All rights reserved. + * Copyright (c) 2014 Mellanox Technologies, Inc. + * All rights reserved. + * Copyright (c) 2016 Cisco Systems, Inc. All rights reserved. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "opal_config.h" +#include "opal/constants.h" +#include "opal/types.h" + +#ifdef HAVE_STRING_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif + +#include "opal/dss/dss.h" +#include "opal/mca/event/event.h" +#include "opal/mca/hwloc/base/base.h" +#include "opal/runtime/opal.h" +#include "opal/runtime/opal_progress_threads.h" +#include "opal/util/argv.h" +#include "opal/util/error.h" +#include "opal/util/output.h" +#include "opal/util/proc.h" +#include "opal/util/show_help.h" +#include "opal/mca/pmix/base/base.h" +#include "pmix3x.h" + +#include "pmix.h" +#include "pmix_server.h" + +/**** S.O.U.T.H.B.O.U.N.D I.N.T.E.R.F.A.C.E.S ****/ + +/* These are the interfaces used by the OMPI/ORTE/OPAL layer to call + * down into the embedded PMIx server. */ + +extern pmix_server_module_t mymodule; +extern opal_pmix_server_module_t *host_module; +static char *dbgvalue=NULL; +static size_t errhdler_ref = 0; + +#define PMIX_WAIT_FOR_COMPLETION(a) \ + do { \ + while ((a)) { \ + usleep(10); \ + } \ + } while (0) + +static void errreg_cbfunc (pmix_status_t status, + size_t errhandler_ref, + void *cbdata) +{ + volatile bool *active = (volatile bool*)cbdata; + + errhdler_ref = errhandler_ref; + opal_output_verbose(5, opal_pmix_base_framework.framework_output, + "PMIX server errreg_cbfunc - error handler registered status=%d, reference=%lu", + status, (unsigned long)errhandler_ref); + *active = false; +} + +int pmix3x_server_init(opal_pmix_server_module_t *module, + opal_list_t *info) +{ + pmix_status_t rc; + int dbg; + opal_value_t *kv; + pmix_info_t *pinfo; + size_t sz, n; + volatile bool active; + opal_pmix3x_jobid_trkr_t *job; + + if (0 < (dbg = opal_output_get_verbosity(opal_pmix_base_framework.framework_output))) { + asprintf(&dbgvalue, "PMIX_DEBUG=%d", dbg); + putenv(dbgvalue); + } + + /* convert the list to an array of pmix_info_t */ + if (NULL != info) { + sz = opal_list_get_size(info); + PMIX_INFO_CREATE(pinfo, sz); + n = 0; + OPAL_LIST_FOREACH(kv, info, opal_value_t) { + (void)strncpy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); + pmix3x_value_load(&pinfo[n].value, kv); + ++n; + } + } else { + sz = 0; + pinfo = NULL; + } + + /* insert ourselves into our list of jobids - it will be the + * first, and so we'll check it first */ + job = OBJ_NEW(opal_pmix3x_jobid_trkr_t); + (void)opal_snprintf_jobid(job->nspace, PMIX_MAX_NSLEN, OPAL_PROC_MY_NAME.jobid); + job->jobid = OPAL_PROC_MY_NAME.jobid; + opal_list_append(&mca_pmix_pmix3x_component.jobids, &job->super); + + if (PMIX_SUCCESS != (rc = PMIx_server_init(&mymodule, pinfo, sz))) { + PMIX_INFO_FREE(pinfo, sz); + return pmix3x_convert_rc(rc); + } + PMIX_INFO_FREE(pinfo, sz); + + /* record the host module */ + host_module = module; + + /* register the default event handler */ + active = true; + PMIx_Register_event_handler(NULL, 0, NULL, 0, pmix3x_event_hdlr, errreg_cbfunc, (void*)&active); + PMIX_WAIT_FOR_COMPLETION(active); + + return OPAL_SUCCESS; +} + +static void fincb(pmix_status_t status, void *cbdata) +{ + volatile bool *active = (volatile bool*)cbdata; + *active = false; +} + +int pmix3x_server_finalize(void) +{ + pmix_status_t rc; + volatile bool active; + + /* deregister the default event handler */ + active = true; + PMIx_Deregister_event_handler(errhdler_ref, fincb, (void*)&active); + PMIX_WAIT_FOR_COMPLETION(active); + + rc = PMIx_server_finalize(); + return pmix3x_convert_rc(rc); +} + +int pmix3x_server_gen_regex(const char *input, char **regex) +{ + pmix_status_t rc; + + rc = PMIx_generate_regex(input, regex); + return pmix3x_convert_rc(rc); +} + + +int pmix3x_server_gen_ppn(const char *input, char **ppn) +{ + pmix_status_t rc; + + rc = PMIx_generate_ppn(input, ppn); + return pmix3x_convert_rc(rc); +} + +static void opcbfunc(pmix_status_t status, void *cbdata) +{ + pmix3x_opcaddy_t *op = (pmix3x_opcaddy_t*)cbdata; + + if (NULL != op->opcbfunc) { + op->opcbfunc(pmix3x_convert_rc(status), op->cbdata); + } + if (op->active) { + op->status = status; + op->active = false; + } else { + OBJ_RELEASE(op); + } +} + +static void _reg_nspace(int sd, short args, void *cbdata) +{ + pmix3x_threadshift_t *cd = (pmix3x_threadshift_t*)cbdata; + opal_value_t *kv, *k2; + pmix_info_t *pinfo = NULL, *pmap; + size_t sz, szmap, m, n; + char nspace[PMIX_MAX_NSLEN]; + pmix_status_t rc; + opal_list_t *pmapinfo; + opal_pmix3x_jobid_trkr_t *job; + pmix3x_opcaddy_t op; + + /* we must threadshift this request as we might not be in an event + * and we are going to access framework-global lists/objects */ + + /* convert the jobid */ + (void)opal_snprintf_jobid(nspace, PMIX_MAX_NSLEN, cd->jobid); + + /* store this job in our list of known nspaces */ + job = OBJ_NEW(opal_pmix3x_jobid_trkr_t); + (void)strncpy(job->nspace, nspace, PMIX_MAX_NSLEN); + job->jobid = cd->jobid; + opal_list_append(&mca_pmix_pmix3x_component.jobids, &job->super); + + /* convert the list to an array of pmix_info_t */ + if (NULL != cd->info) { + sz = opal_list_get_size(cd->info); + PMIX_INFO_CREATE(pinfo, sz); + n = 0; + OPAL_LIST_FOREACH(kv, cd->info, opal_value_t) { + (void)strncpy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); + if (0 == strcmp(kv->key, OPAL_PMIX_PROC_DATA)) { + pinfo[n].value.type = PMIX_DATA_ARRAY; + /* the value contains a list of values - convert + * that list to another array */ + pmapinfo = (opal_list_t*)kv->data.ptr; + szmap = opal_list_get_size(pmapinfo); + PMIX_INFO_CREATE(pmap, szmap); + pinfo[n].value.data.darray = (pmix_data_array_t*)calloc(1, sizeof(pmix_data_array_t)); + pinfo[n].value.data.darray->type = PMIX_INFO; + pinfo[n].value.data.darray->array = (struct pmix_info_t*)pmap; + pinfo[n].value.data.darray->size = szmap; + m = 0; + OPAL_LIST_FOREACH(k2, pmapinfo, opal_value_t) { + (void)strncpy(pmap[m].key, k2->key, PMIX_MAX_KEYLEN); + pmix3x_value_load(&pmap[m].value, k2); + ++m; + } + } else { + pmix3x_value_load(&pinfo[n].value, kv); + } + ++n; + } + } else { + sz = 0; + pinfo = NULL; + } + + OBJ_CONSTRUCT(&op, pmix3x_opcaddy_t); + op.active = true; + rc = PMIx_server_register_nspace(nspace, cd->status, pinfo, sz, + opcbfunc, (void*)&op); + if (PMIX_SUCCESS == rc) { + PMIX_WAIT_FOR_COMPLETION(op.active); + } else { + op.status = rc; + } + /* ensure we execute the cbfunc so the caller doesn't hang */ + if (NULL != cd->opcbfunc) { + cd->opcbfunc(pmix3x_convert_rc(op.status), cd->cbdata); + } + if (NULL != pinfo) { + PMIX_INFO_FREE(pinfo, sz); + } + OBJ_DESTRUCT(&op); + OBJ_RELEASE(cd); +} + +int pmix3x_server_register_nspace(opal_jobid_t jobid, + int nlocalprocs, + opal_list_t *info, + opal_pmix_op_cbfunc_t cbfunc, + void *cbdata) +{ + pmix3x_threadshift_t *cd; + + /* we must threadshift this request as it touches + * shared lists of objects */ + cd = OBJ_NEW(pmix3x_threadshift_t); + cd->jobid = jobid; + cd->status = nlocalprocs; + cd->info = info; + cd->opcbfunc = cbfunc; + cd->cbdata = cbdata; + /* if the cbfunc is NULL, then the caller is in an event + * and we can directly call the processing function */ + if (NULL == cbfunc) { + _reg_nspace(0, 0, cd); + } else { + event_assign(&cd->ev, opal_pmix_base.evbase, + -1, EV_WRITE, _reg_nspace, cd); + event_active(&cd->ev, EV_WRITE, 1); + } + + return OPAL_SUCCESS; +} + +static void tdcbfunc(pmix_status_t status, void *cbdata) +{ + pmix3x_threadshift_t *cd = (pmix3x_threadshift_t*)cbdata; + + if (NULL != cd->opcbfunc) { + cd->opcbfunc(pmix3x_convert_rc(status), cd->cbdata); + } + if (cd->active) { + cd->active = false; + } else { + OBJ_RELEASE(cd); + } +} + +static void _dereg_nspace(int sd, short args, void *cbdata) +{ + pmix3x_threadshift_t *cd = (pmix3x_threadshift_t*)cbdata; + opal_pmix3x_jobid_trkr_t *jptr; + + /* if we don't already have it, we can ignore this */ + OPAL_LIST_FOREACH(jptr, &mca_pmix_pmix3x_component.jobids, opal_pmix3x_jobid_trkr_t) { + if (jptr->jobid == cd->jobid) { + /* found it - tell the server to deregister */ + cd->active = true; + PMIx_server_deregister_nspace(jptr->nspace, tdcbfunc, cd); + PMIX_WAIT_FOR_COMPLETION(cd->active); + OBJ_RELEASE(cd); + /* now get rid of it from our list */ + opal_list_remove_item(&mca_pmix_pmix3x_component.jobids, &jptr->super); + OBJ_RELEASE(jptr); + return; + } + } + /* must release the caller */ + tdcbfunc(PMIX_ERR_NOT_FOUND, cd); +} + +void pmix3x_server_deregister_nspace(opal_jobid_t jobid, + opal_pmix_op_cbfunc_t cbfunc, + void *cbdata) +{ + pmix3x_threadshift_t *cd; + + /* we must threadshift this request as it touches + * shared lists of objects */ + cd = OBJ_NEW(pmix3x_threadshift_t); + cd->jobid = jobid; + cd->opcbfunc = cbfunc; + cd->cbdata = cbdata; + if (NULL == cbfunc) { + _dereg_nspace(0, 0, cd); + } else { + event_assign(&cd->ev, opal_pmix_base.evbase, + -1, EV_WRITE, _dereg_nspace, cd); + event_active(&cd->ev, EV_WRITE, 1); + } +} + +int pmix3x_server_register_client(const opal_process_name_t *proc, + uid_t uid, gid_t gid, + void *server_object, + opal_pmix_op_cbfunc_t cbfunc, + void *cbdata) +{ + pmix_status_t rc; + pmix_proc_t p; + pmix3x_opcaddy_t op; + + /* convert the jobid */ + (void)opal_snprintf_jobid(p.nspace, PMIX_MAX_NSLEN, proc->jobid); + p.rank = pmix3x_convert_opalrank(proc->vpid); + + OBJ_CONSTRUCT(&op, pmix3x_opcaddy_t); + op.active = true; + rc = PMIx_server_register_client(&p, uid, gid, server_object, + opcbfunc, (void*)&op); + if (PMIX_SUCCESS == rc) { + PMIX_WAIT_FOR_COMPLETION(op.active); + rc = op.status; + } + OBJ_DESTRUCT(&op); + return pmix3x_convert_rc(rc); +} + +static void _dereg_client(int sd, short args, void *cbdata) +{ + pmix3x_threadshift_t *cd = (pmix3x_threadshift_t*)cbdata; + opal_pmix3x_jobid_trkr_t *jptr; + pmix_proc_t p; + + /* if we don't already have it, we can ignore this */ + OPAL_LIST_FOREACH(jptr, &mca_pmix_pmix3x_component.jobids, opal_pmix3x_jobid_trkr_t) { + if (jptr->jobid == cd->source->jobid) { + /* found it - tell the server to deregister */ + (void)strncpy(p.nspace, jptr->nspace, PMIX_MAX_NSLEN); + p.rank = pmix3x_convert_opalrank(cd->source->vpid); + cd->active = true; + PMIx_server_deregister_client(&p, tdcbfunc, (void*)cd); + PMIX_WAIT_FOR_COMPLETION(cd->active); + break; + } + } + OBJ_RELEASE(cd); +} + +/* tell the local PMIx server to cleanup this client as it is + * done executing */ +void pmix3x_server_deregister_client(const opal_process_name_t *proc, + opal_pmix_op_cbfunc_t cbfunc, + void *cbdata) +{ + pmix3x_threadshift_t *cd; + + /* we must threadshift this request as we might not be in an event + * and we are going to access framework-global lists/objects */ + cd = OBJ_NEW(pmix3x_threadshift_t); + cd->source = proc; + cd->opcbfunc = cbfunc; + cd->cbdata = cbdata; + if (NULL == cbfunc) { + _dereg_client(0, 0, cd); + } else { + event_assign(&cd->ev, opal_pmix_base.evbase, + -1, EV_WRITE, _dereg_client, cd); + event_active(&cd->ev, EV_WRITE, 1); + } +} + +/* have the local PMIx server setup the environment for this client */ +int pmix3x_server_setup_fork(const opal_process_name_t *proc, char ***env) +{ + pmix_status_t rc; + pmix_proc_t p; + + /* convert the jobid */ + (void)opal_snprintf_jobid(p.nspace, PMIX_MAX_NSLEN, proc->jobid); + p.rank = pmix3x_convert_opalrank(proc->vpid); + + rc = PMIx_server_setup_fork(&p, env); + return pmix3x_convert_rc(rc); +} + +/* this is the call back up from the embedded PMIx server that + * will contain the returned data. Note that the embedded server + * "owns" the data and will free it upon return from this function */ +static void dmdx_response(pmix_status_t status, char *data, size_t sz, void *cbdata) +{ + int rc; + pmix3x_opcaddy_t *op = (pmix3x_opcaddy_t*)cbdata; + + rc = pmix3x_convert_rc(status); + if (NULL != op->mdxcbfunc) { + op->mdxcbfunc(rc, data, sz, op->cbdata, NULL, NULL); + } + OBJ_RELEASE(op); +} + +/* request modex data for a local proc from the PMIx server */ +int pmix3x_server_dmodex(const opal_process_name_t *proc, + opal_pmix_modex_cbfunc_t cbfunc, void *cbdata) +{ + pmix3x_opcaddy_t *op; + pmix_status_t rc; + + /* setup the caddy */ + op = OBJ_NEW(pmix3x_opcaddy_t); + op->mdxcbfunc = cbfunc; + op->cbdata = cbdata; + + /* convert the jobid */ + (void)opal_snprintf_jobid(op->p.nspace, PMIX_MAX_NSLEN, proc->jobid); + op->p.rank = pmix3x_convert_opalrank(proc->vpid); + + /* find the internally-cached data for this proc */ + rc = PMIx_server_dmodex_request(&op->p, dmdx_response, op); + if (PMIX_SUCCESS != rc) { + OBJ_RELEASE(op); + } + return pmix3x_convert_rc(rc); +} + +/* tell the PMIx server to notify its local clients of an event */ +int pmix3x_server_notify_event(int status, + const opal_process_name_t *source, + opal_list_t *info, + opal_pmix_op_cbfunc_t cbfunc, void *cbdata) +{ + opal_value_t *kv; + pmix_info_t *pinfo; + size_t sz, n; + pmix_status_t rc; + pmix3x_opcaddy_t *op; + + /* convert the list to an array of pmix_info_t */ + if (NULL != info) { + sz = opal_list_get_size(info); + PMIX_INFO_CREATE(pinfo, sz); + n = 0; + OPAL_LIST_FOREACH(kv, info, opal_value_t) { + (void)strncpy(pinfo[n].key, kv->key, PMIX_MAX_KEYLEN); + pmix3x_value_load(&pinfo[n].value, kv); + } + } else { + sz = 0; + pinfo = NULL; + } + /* setup the caddy */ + op = OBJ_NEW(pmix3x_opcaddy_t); + op->info = pinfo; + op->sz = sz; + op->opcbfunc = cbfunc; + op->cbdata = cbdata; + /* convert the jobid */ + if (NULL == source) { + (void)opal_snprintf_jobid(op->p.nspace, PMIX_MAX_NSLEN, OPAL_JOBID_INVALID); + op->p.rank = pmix3x_convert_opalrank(OPAL_VPID_INVALID); + } else { + (void)opal_snprintf_jobid(op->p.nspace, PMIX_MAX_NSLEN, source->jobid); + op->p.rank = pmix3x_convert_opalrank(source->vpid); + } + + + rc = pmix3x_convert_opalrc(status); + /* the range is irrelevant here as the server is passing + * the event down to its local clients */ + rc = PMIx_Notify_event(rc, &op->p, PMIX_RANGE_LOCAL, + pinfo, sz, opcbfunc, op); + if (PMIX_SUCCESS != rc) { + OBJ_RELEASE(op); + } + return pmix3x_convert_rc(rc); +} diff --git a/opal/mca/pmix/pmix3x/configure.m4 b/opal/mca/pmix/pmix3x/configure.m4 index dfa612bc2f..370ea6873d 100644 --- a/opal/mca/pmix/pmix3x/configure.m4 +++ b/opal/mca/pmix/pmix3x/configure.m4 @@ -77,18 +77,8 @@ AC_DEFUN([MCA_opal_pmix_pmix3x_CONFIG],[ # distclean" infrastructure to work properly). AC_MSG_CHECKING([if v3.x component is to be used]) AS_IF([test "$opal_external_pmix_happy" = "yes"], - [AS_IF([test "$opal_external_pmix_version" = "3X"], - [AC_MSG_RESULT([yes - using an external v3.x library]) - # Build flags for our Makefile.am - opal_pmix_pmix3x_CPPFLAGS=$opal_external_pmix_CPPFLAGS - opal_pmix_pmix3x_LDFLAGS=$opal_external_pmix_LDFLAGS - opal_pmix_pmix3x_LIBS=$opal_external_pmix_LIBS - opal_pmix_pmix3x_DEPENDENCIES= - # setup wrapper flags - pmix_pmix3x_WRAPPER_EXTRA_LDFLAGS=$opal_external_pmix_LDFLAGS - pmix_pmix3x_WRAPPER_EXTRA_LIBS=$opal_external_pmix_LIBS], - [AC_MSG_RESULT([no - disqualifying this component]) - opal_pmix_pmix3x_happy=0])], + [AC_MSG_RESULT([no - disqualifying this component]) + opal_pmix_pmix3x_happy=0], [AC_MSG_RESULT([yes - using the internal v3.x library]) # Build flags for our Makefile.am opal_pmix_pmix3x_LDFLAGS= diff --git a/opal/mca/pmix/pmix3x/pmix/src/util/keyval/keyval_lex.c b/opal/mca/pmix/pmix3x/pmix/src/util/keyval/keyval_lex.c deleted file mode 100644 index 0e040a91f7..0000000000 --- a/opal/mca/pmix/pmix3x/pmix/src/util/keyval/keyval_lex.c +++ /dev/null @@ -1,2070 +0,0 @@ - -#line 3 "keyval_lex.c" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define yy_create_buffer pmix_util_keyval_yy_create_buffer -#define yy_delete_buffer pmix_util_keyval_yy_delete_buffer -#define yy_flex_debug pmix_util_keyval_yy_flex_debug -#define yy_init_buffer pmix_util_keyval_yy_init_buffer -#define yy_flush_buffer pmix_util_keyval_yy_flush_buffer -#define yy_load_buffer_state pmix_util_keyval_yy_load_buffer_state -#define yy_switch_to_buffer pmix_util_keyval_yy_switch_to_buffer -#define yyin pmix_util_keyval_yyin -#define yyleng pmix_util_keyval_yyleng -#define yylex pmix_util_keyval_yylex -#define yylineno pmix_util_keyval_yylineno -#define yyout pmix_util_keyval_yyout -#define yyrestart pmix_util_keyval_yyrestart -#define yytext pmix_util_keyval_yytext -#define yywrap pmix_util_keyval_yywrap -#define yyalloc pmix_util_keyval_yyalloc -#define yyrealloc pmix_util_keyval_yyrealloc -#define yyfree pmix_util_keyval_yyfree - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 37 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN (yy_start) = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START (((yy_start) - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE pmix_util_keyval_yyrestart(pmix_util_keyval_yyin ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#define YY_BUF_SIZE 16384 -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -extern yy_size_t pmix_util_keyval_yyleng; - -extern FILE *pmix_util_keyval_yyin, *pmix_util_keyval_yyout; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires - * access to the local variable yy_act. Since yyless() is a macro, it would break - * existing scanners that call yyless() from OUTSIDE pmix_util_keyval_yylex. - * One obvious solution it to make yy_act a global. I tried that, and saw - * a 5% performance hit in a non-pmix_util_keyval_yylineno scanner, because yy_act is - * normally declared as a register variable-- so it is not worth it. - */ - #define YY_LESS_LINENO(n) \ - do { \ - int yyl;\ - for ( yyl = n; yyl < pmix_util_keyval_yyleng; ++yyl )\ - if ( pmix_util_keyval_yytext[yyl] == '\n' )\ - --pmix_util_keyval_yylineno;\ - }while(0) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up pmix_util_keyval_yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = (yy_hold_char); \ - YY_RESTORE_YY_MORE_OFFSET \ - (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up pmix_util_keyval_yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, (yytext_ptr) ) - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - yy_size_t yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via pmix_util_keyval_yyrestart()), so that the user can continue scanning by - * just pointing pmix_util_keyval_yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* Stack of input buffers. */ -static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ -static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ - ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ - : NULL) - -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] - -/* yy_hold_char holds the character lost when pmix_util_keyval_yytext is formed. */ -static char yy_hold_char; -static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ -yy_size_t pmix_util_keyval_yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 0; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow pmix_util_keyval_yywrap()'s to do buffer switches - * instead of setting up a fresh pmix_util_keyval_yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -void pmix_util_keyval_yyrestart (FILE *input_file ); -void pmix_util_keyval_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE pmix_util_keyval_yy_create_buffer (FILE *file,int size ); -void pmix_util_keyval_yy_delete_buffer (YY_BUFFER_STATE b ); -void pmix_util_keyval_yy_flush_buffer (YY_BUFFER_STATE b ); -void pmix_util_keyval_yypush_buffer_state (YY_BUFFER_STATE new_buffer ); -void pmix_util_keyval_yypop_buffer_state (void ); - -static void pmix_util_keyval_yyensure_buffer_stack (void ); -static void pmix_util_keyval_yy_load_buffer_state (void ); -static void pmix_util_keyval_yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); - -#define YY_FLUSH_BUFFER pmix_util_keyval_yy_flush_buffer(YY_CURRENT_BUFFER ) - -YY_BUFFER_STATE pmix_util_keyval_yy_scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE pmix_util_keyval_yy_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE pmix_util_keyval_yy_scan_bytes (yyconst char *bytes,yy_size_t len ); - -void *pmix_util_keyval_yyalloc (yy_size_t ); -void *pmix_util_keyval_yyrealloc (void *,yy_size_t ); -void pmix_util_keyval_yyfree (void * ); - -#define yy_new_buffer pmix_util_keyval_yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - pmix_util_keyval_yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - pmix_util_keyval_yy_create_buffer(pmix_util_keyval_yyin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - pmix_util_keyval_yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - pmix_util_keyval_yy_create_buffer(pmix_util_keyval_yyin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -typedef unsigned char YY_CHAR; - -FILE *pmix_util_keyval_yyin = (FILE *) 0, *pmix_util_keyval_yyout = (FILE *) 0; - -typedef int yy_state_type; - -extern int pmix_util_keyval_yylineno; - -int pmix_util_keyval_yylineno = 1; - -extern char *pmix_util_keyval_yytext; -#define yytext_ptr pmix_util_keyval_yytext - -static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -static void yy_fatal_error (yyconst char msg[] ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up pmix_util_keyval_yytext. - */ -#define YY_DO_BEFORE_ACTION \ - (yytext_ptr) = yy_bp; \ - pmix_util_keyval_yyleng = (size_t) (yy_cp - yy_bp); \ - (yy_hold_char) = *yy_cp; \ - *yy_cp = '\0'; \ - (yy_c_buf_p) = yy_cp; - -#define YY_NUM_RULES 22 -#define YY_END_OF_BUFFER 23 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static yyconst flex_int16_t yy_acclist[93] = - { 0, - 5, 5, 23, 21, 22, 10, 21, 22, 1, 22, - 21, 22, 11, 21, 22, 11, 21, 22, 21, 22, - 9, 21, 22, 8205, 22,16397, 22, 12, 22, 8205, - 22,16397, 5, 22, 7, 22, 6, 22, 14, 22, - 22, 17, 22, 14, 22, 14, 22, 14, 22, 10, - 1, 9, 2, 11, 11, 11, 11, 4, 9, 8205, - 16397, 8205, 12, 8205,16397, 8205, 5, 6, 6, 8, - 14, 17, 14, 14, 14, 14, 14, 11, 3, 16, - 14, 16, 15, 14, 15, 11, 20, 20, 20, 19, - 19, 18 - - } ; - -static yyconst flex_int16_t yy_accept[85] = - { 0, - 1, 1, 1, 1, 1, 2, 3, 3, 3, 4, - 6, 9, 11, 13, 16, 19, 21, 24, 27, 28, - 30, 33, 35, 37, 39, 41, 42, 44, 46, 48, - 50, 51, 52, 53, 53, 54, 55, 56, 57, 58, - 59, 59, 60, 62, 63, 63, 64, 66, 67, 68, - 69, 70, 71, 72, 72, 73, 74, 75, 75, 76, - 77, 77, 78, 79, 79, 79, 80, 80, 81, 83, - 83, 84, 86, 87, 87, 87, 88, 89, 90, 91, - 91, 92, 93, 93 - } ; - -static yyconst flex_int32_t yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, - 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 2, 1, 5, 6, 1, 1, 1, 7, 1, - 1, 8, 1, 1, 9, 10, 11, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 1, 1, 1, - 12, 1, 1, 1, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, - 1, 1, 1, 1, 10, 1, 13, 10, 14, 10, - - 10, 10, 10, 10, 10, 10, 10, 10, 15, 10, - 10, 10, 10, 10, 10, 10, 10, 10, 10, 16, - 10, 10, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst flex_int32_t yy_meta[17] = - { 0, - 1, 2, 3, 4, 1, 1, 1, 5, 6, 6, - 1, 1, 6, 6, 6, 6 - } ; - -static yyconst flex_int16_t yy_base[100] = - { 0, - 0, 0, 15, 18, 20, 21, 28, 34, 143, 252, - 40, 252, 121, 44, 52, 37, 23, 115, 67, 252, - 70, 0, 252, 38, 0, 111, 252, 73, 45, 49, - 0, 252, 60, 105, 252, 50, 0, 93, 76, 252, - 98, 77, 98, 91, 80, 252, 83, 86, 0, 83, - 84, 252, 0, 60, 252, 94, 97, 50, 101, 102, - 33, 108, 21, 109, 23, 252, 114, 0, 0, 118, - 0, 0, 119, 125, 140, 252, 136, 0, 151, 152, - 155, 156, 252, 160, 166, 172, 178, 184, 190, 196, - 202, 207, 211, 217, 223, 229, 235, 240, 245 - - } ; - -static yyconst flex_int16_t yy_def[100] = - { 0, - 83, 1, 84, 84, 85, 85, 86, 86, 83, 83, - 83, 83, 87, 83, 14, 83, 83, 88, 88, 83, - 88, 89, 83, 90, 91, 92, 83, 91, 93, 94, - 11, 83, 83, 87, 83, 15, 15, 15, 15, 83, - 95, 83, 88, 88, 88, 83, 88, 88, 89, 90, - 90, 83, 91, 92, 83, 91, 93, 96, 93, 94, - 97, 94, 15, 98, 95, 83, 96, 67, 59, 97, - 70, 62, 15, 83, 99, 83, 74, 74, 83, 99, - 83, 83, 0, 83, 83, 83, 83, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 83, 83, 83 - - } ; - -static yyconst flex_int16_t yy_nxt[269] = - { 0, - 10, 11, 12, 11, 10, 13, 10, 10, 14, 15, - 16, 17, 15, 15, 15, 15, 19, 20, 21, 19, - 20, 21, 23, 23, 42, 66, 42, 24, 24, 26, - 27, 28, 29, 73, 30, 26, 27, 28, 29, 70, - 30, 31, 32, 31, 40, 51, 58, 41, 52, 59, - 61, 33, 36, 37, 67, 62, 37, 37, 38, 39, - 37, 42, 55, 42, 38, 39, 37, 37, 45, 46, - 47, 48, 46, 47, 54, 55, 56, 64, 42, 64, - 42, 45, 46, 47, 48, 46, 47, 48, 46, 47, - 83, 51, 44, 83, 52, 54, 55, 56, 58, 44, - - 66, 59, 68, 61, 69, 59, 63, 35, 62, 71, - 64, 72, 64, 55, 62, 68, 44, 68, 67, 71, - 75, 71, 75, 35, 70, 76, 77, 76, 77, 76, - 76, 76, 76, 78, 78, 76, 79, 78, 78, 78, - 78, 75, 83, 75, 76, 76, 83, 83, 76, 76, - 76, 76, 81, 82, 81, 82, 81, 82, 81, 82, - 18, 18, 18, 18, 18, 18, 22, 22, 22, 22, - 22, 22, 25, 25, 25, 25, 25, 25, 34, 34, - 34, 34, 34, 34, 43, 43, 83, 43, 43, 43, - 49, 49, 83, 49, 83, 49, 50, 50, 83, 50, - - 50, 50, 53, 83, 83, 53, 53, 53, 54, 54, - 54, 57, 57, 83, 57, 57, 57, 60, 60, 83, - 60, 60, 60, 65, 65, 65, 65, 65, 65, 58, - 58, 83, 58, 58, 58, 61, 61, 83, 61, 61, - 61, 74, 83, 74, 83, 74, 80, 83, 80, 83, - 80, 9, 83, 83, 83, 83, 83, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 83, 83 - } ; - -static yyconst flex_int16_t yy_chk[269] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 3, 3, 3, 4, - 4, 4, 5, 6, 17, 65, 17, 5, 6, 7, - 7, 7, 7, 63, 7, 8, 8, 8, 8, 61, - 8, 11, 11, 11, 16, 24, 29, 16, 24, 29, - 30, 11, 14, 14, 58, 30, 14, 14, 14, 14, - 15, 33, 54, 33, 36, 36, 15, 15, 19, 19, - 19, 21, 21, 21, 28, 28, 28, 39, 42, 39, - 42, 45, 45, 45, 47, 47, 47, 48, 48, 48, - 50, 51, 44, 50, 51, 56, 56, 56, 57, 43, - - 41, 57, 59, 60, 59, 59, 38, 34, 60, 62, - 64, 62, 64, 26, 62, 67, 18, 67, 67, 70, - 73, 70, 73, 13, 70, 74, 74, 74, 74, 74, - 74, 74, 74, 74, 74, 74, 74, 74, 74, 74, - 74, 75, 9, 75, 77, 77, 0, 0, 77, 77, - 77, 77, 79, 80, 79, 80, 81, 82, 81, 82, - 84, 84, 84, 84, 84, 84, 85, 85, 85, 85, - 85, 85, 86, 86, 86, 86, 86, 86, 87, 87, - 87, 87, 87, 87, 88, 88, 0, 88, 88, 88, - 89, 89, 0, 89, 0, 89, 90, 90, 0, 90, - - 90, 90, 91, 0, 0, 91, 91, 91, 92, 92, - 92, 93, 93, 0, 93, 93, 93, 94, 94, 0, - 94, 94, 94, 95, 95, 95, 95, 95, 95, 96, - 96, 0, 96, 96, 96, 97, 97, 0, 97, 97, - 97, 98, 0, 98, 0, 98, 99, 0, 99, 0, - 99, 83, 83, 83, 83, 83, 83, 83, 83, 83, - 83, 83, 83, 83, 83, 83, 83, 83 - } ; - -/* Table of booleans, true if rule could match eol. */ -static yyconst flex_int32_t yy_rule_can_match_eol[23] = - { 0, -1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, - 1, 0, 0, }; - -extern int pmix_util_keyval_yy_flex_debug; -int pmix_util_keyval_yy_flex_debug = 0; - -static yy_state_type *yy_state_buf=0, *yy_state_ptr=0; -static char *yy_full_match; -static int yy_lp; -static int yy_looking_for_trail_begin = 0; -static int yy_full_lp; -static int *yy_full_state; -#define YY_TRAILING_MASK 0x2000 -#define YY_TRAILING_HEAD_MASK 0x4000 -#define REJECT \ -{ \ -*yy_cp = (yy_hold_char); /* undo effects of setting up pmix_util_keyval_yytext */ \ -yy_cp = (yy_full_match); /* restore poss. backed-over text */ \ -(yy_lp) = (yy_full_lp); /* restore orig. accepting pos. */ \ -(yy_state_ptr) = (yy_full_state); /* restore orig. state */ \ -yy_current_state = *(yy_state_ptr); /* restore curr. state */ \ -++(yy_lp); \ -goto find_rule; \ -} - -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -char *pmix_util_keyval_yytext; -#line 1 "keyval_lex.l" -#define YY_NO_INPUT 1 -#line 6 "keyval_lex.l" -/* - * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana - * University Research and Technology - * Corporation. All rights reserved. - * Copyright (c) 2004-2006 The University of Tennessee and The University - * of Tennessee Research Foundation. All rights - * reserved. - * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, - * University of Stuttgart. All rights reserved. - * Copyright (c) 2004-2005 The Regents of the University of California. - * All rights reserved. - * Copyright (c) 2012 Los Alamos National Security, LLC. All rights - * reserved. - * Copyright (c) 2016 Intel, Inc. All rights reserved. - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -#include - -#include -#ifdef HAVE_UNISTD_H -#include -#endif - -#include "src/util/keyval/keyval_lex.h" - -/* - * local functions - */ - -BEGIN_C_DECLS - -int pmix_util_keyval_yywrap(void); - -END_C_DECLS - -/* - * global variables - */ -int pmix_util_keyval_yynewlines = 1; -bool pmix_util_keyval_parse_done = false; -char *pmix_util_keyval_string = NULL; - - - - -#line 651 "keyval_lex.c" - -#define INITIAL 0 -#define VALUE 1 -#define comment 2 -#define MCA_VALUE 3 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -static int yy_init_globals (void ); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int pmix_util_keyval_yylex_destroy (void ); - -int pmix_util_keyval_yyget_debug (void ); - -void pmix_util_keyval_yyset_debug (int debug_flag ); - -YY_EXTRA_TYPE pmix_util_keyval_yyget_extra (void ); - -void pmix_util_keyval_yyset_extra (YY_EXTRA_TYPE user_defined ); - -FILE *pmix_util_keyval_yyget_in (void ); - -void pmix_util_keyval_yyset_in (FILE * in_str ); - -FILE *pmix_util_keyval_yyget_out (void ); - -void pmix_util_keyval_yyset_out (FILE * out_str ); - -yy_size_t pmix_util_keyval_yyget_leng (void ); - -char *pmix_util_keyval_yyget_text (void ); - -int pmix_util_keyval_yyget_lineno (void ); - -void pmix_util_keyval_yyset_lineno (int line_number ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int pmix_util_keyval_yywrap (void ); -#else -extern int pmix_util_keyval_yywrap (void ); -#endif -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); -#endif - -#ifndef YY_NO_INPUT - -#ifdef __cplusplus -static int yyinput (void ); -#else -static int input (void ); -#endif - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO do { if (fwrite( pmix_util_keyval_yytext, pmix_util_keyval_yyleng, 1, pmix_util_keyval_yyout )) {} } while (0) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - size_t n; \ - for ( n = 0; n < max_size && \ - (c = getc( pmix_util_keyval_yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( pmix_util_keyval_yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = fread(buf, 1, max_size, pmix_util_keyval_yyin))==0 && ferror(pmix_util_keyval_yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(pmix_util_keyval_yyin); \ - } \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int pmix_util_keyval_yylex (void); - -#define YY_DECL int pmix_util_keyval_yylex (void) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after pmix_util_keyval_yytext and pmix_util_keyval_yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - -#line 61 "keyval_lex.l" - - -#line 837 "keyval_lex.c" - - if ( !(yy_init) ) - { - (yy_init) = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - /* Create the reject buffer large enough to save one state per allowed character. */ - if ( ! (yy_state_buf) ) - (yy_state_buf) = (yy_state_type *)pmix_util_keyval_yyalloc(YY_STATE_BUF_SIZE ); - if ( ! (yy_state_buf) ) - YY_FATAL_ERROR( "out of dynamic memory in pmix_util_keyval_yylex()" ); - - if ( ! (yy_start) ) - (yy_start) = 1; /* first start state */ - - if ( ! pmix_util_keyval_yyin ) - pmix_util_keyval_yyin = stdin; - - if ( ! pmix_util_keyval_yyout ) - pmix_util_keyval_yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - pmix_util_keyval_yyensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - pmix_util_keyval_yy_create_buffer(pmix_util_keyval_yyin,YY_BUF_SIZE ); - } - - pmix_util_keyval_yy_load_buffer_state( ); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = (yy_c_buf_p); - - /* Support of pmix_util_keyval_yytext. */ - *yy_cp = (yy_hold_char); - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = (yy_start); - - (yy_state_ptr) = (yy_state_buf); - *(yy_state_ptr)++ = yy_current_state; - -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 84 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - *(yy_state_ptr)++ = yy_current_state; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 252 ); - -yy_find_action: - yy_current_state = *--(yy_state_ptr); - (yy_lp) = yy_accept[yy_current_state]; -find_rule: /* we branch to this label when backing up */ - for ( ; ; ) /* until we find what rule we matched */ - { - if ( (yy_lp) && (yy_lp) < yy_accept[yy_current_state + 1] ) - { - yy_act = yy_acclist[(yy_lp)]; - if ( yy_act & YY_TRAILING_HEAD_MASK || - (yy_looking_for_trail_begin) ) - { - if ( yy_act == (yy_looking_for_trail_begin) ) - { - (yy_looking_for_trail_begin) = 0; - yy_act &= ~YY_TRAILING_HEAD_MASK; - break; - } - } - else if ( yy_act & YY_TRAILING_MASK ) - { - (yy_looking_for_trail_begin) = yy_act & ~YY_TRAILING_MASK; - (yy_looking_for_trail_begin) |= YY_TRAILING_HEAD_MASK; - } - else - { - (yy_full_match) = yy_cp; - (yy_full_state) = (yy_state_ptr); - (yy_full_lp) = (yy_lp); - break; - } - ++(yy_lp); - goto find_rule; - } - --yy_cp; - yy_current_state = *--(yy_state_ptr); - (yy_lp) = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - - if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] ) - { - int yyl; - for ( yyl = 0; yyl < pmix_util_keyval_yyleng; ++yyl ) - if ( pmix_util_keyval_yytext[yyl] == '\n' ) - - pmix_util_keyval_yylineno++; -; - } - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ -case 1: -/* rule 1 can match eol */ -YY_RULE_SETUP -#line 63 "keyval_lex.l" -{ pmix_util_keyval_yynewlines++; return PMIX_UTIL_KEYVAL_PARSE_NEWLINE; } - YY_BREAK -case 2: -/* rule 2 can match eol */ -YY_RULE_SETUP -#line 64 "keyval_lex.l" -{ pmix_util_keyval_yynewlines++; return PMIX_UTIL_KEYVAL_PARSE_NEWLINE; } - YY_BREAK -case 3: -/* rule 3 can match eol */ -YY_RULE_SETUP -#line 65 "keyval_lex.l" -{ pmix_util_keyval_yynewlines++; return PMIX_UTIL_KEYVAL_PARSE_NEWLINE; } - YY_BREAK -case 4: -YY_RULE_SETUP -#line 67 "keyval_lex.l" -{ BEGIN(comment); - return PMIX_UTIL_KEYVAL_PARSE_NEWLINE; } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 69 "keyval_lex.l" -; /* Eat up non '*'s */ - YY_BREAK -case 6: -YY_RULE_SETUP -#line 70 "keyval_lex.l" -; /* Eat '*'s not followed by a '/' */ - YY_BREAK -case 7: -/* rule 7 can match eol */ -YY_RULE_SETUP -#line 71 "keyval_lex.l" -{ pmix_util_keyval_yynewlines++; - return PMIX_UTIL_KEYVAL_PARSE_NEWLINE; } - YY_BREAK -case 8: -YY_RULE_SETUP -#line 73 "keyval_lex.l" -{ BEGIN(INITIAL); /* Done with Block Comment */ - return PMIX_UTIL_KEYVAL_PARSE_NEWLINE; } - YY_BREAK -case 9: -YY_RULE_SETUP -#line 76 "keyval_lex.l" -{ BEGIN(VALUE); return PMIX_UTIL_KEYVAL_PARSE_EQUAL; } - YY_BREAK -case 10: -YY_RULE_SETUP -#line 77 "keyval_lex.l" -; /* whitespace */ - YY_BREAK -case 11: -YY_RULE_SETUP -#line 78 "keyval_lex.l" -{ return PMIX_UTIL_KEYVAL_PARSE_SINGLE_WORD; } - YY_BREAK -case 12: -/* rule 12 can match eol */ -YY_RULE_SETUP -#line 80 "keyval_lex.l" -{ BEGIN(INITIAL); return PMIX_UTIL_KEYVAL_PARSE_NEWLINE; } - YY_BREAK -case 13: -YY_RULE_SETUP -#line 81 "keyval_lex.l" -{ return PMIX_UTIL_KEYVAL_PARSE_VALUE; } - YY_BREAK -case 14: -YY_RULE_SETUP -#line 83 "keyval_lex.l" -{ BEGIN(INITIAL); return PMIX_UTIL_KEYVAL_PARSE_VALUE; } - YY_BREAK -case 15: -YY_RULE_SETUP -#line 84 "keyval_lex.l" -{ BEGIN(INITIAL); return PMIX_UTIL_KEYVAL_PARSE_VALUE; } - YY_BREAK -case 16: -YY_RULE_SETUP -#line 85 "keyval_lex.l" -{ BEGIN(INITIAL); return PMIX_UTIL_KEYVAL_PARSE_VALUE; } - YY_BREAK -case 17: -/* rule 17 can match eol */ -YY_RULE_SETUP -#line 86 "keyval_lex.l" -{ BEGIN(INITIAL); BEGIN(INITIAL); return PMIX_UTIL_KEYVAL_PARSE_NEWLINE; } - YY_BREAK -case 18: -YY_RULE_SETUP -#line 88 "keyval_lex.l" -{BEGIN(MCA_VALUE); return PMIX_UTIL_KEYVAL_PARSE_MCAVAR; } - YY_BREAK -case 19: -YY_RULE_SETUP -#line 89 "keyval_lex.l" -{BEGIN(MCA_VALUE); return PMIX_UTIL_KEYVAL_PARSE_ENVEQL; } - YY_BREAK -case 20: -/* rule 20 can match eol */ -*yy_cp = (yy_hold_char); /* undo effects of setting up pmix_util_keyval_yytext */ -(yy_c_buf_p) = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up pmix_util_keyval_yytext again */ -YY_RULE_SETUP -#line 90 "keyval_lex.l" -{ return PMIX_UTIL_KEYVAL_PARSE_ENVVAR; } - YY_BREAK -case 21: -YY_RULE_SETUP -#line 92 "keyval_lex.l" -{ return PMIX_UTIL_KEYVAL_PARSE_ERROR; } - YY_BREAK -case 22: -YY_RULE_SETUP -#line 94 "keyval_lex.l" -ECHO; - YY_BREAK -#line 1082 "keyval_lex.c" - case YY_STATE_EOF(INITIAL): - case YY_STATE_EOF(VALUE): - case YY_STATE_EOF(comment): - case YY_STATE_EOF(MCA_VALUE): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = (yy_hold_char); - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed pmix_util_keyval_yyin at a new source and called - * pmix_util_keyval_yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = pmix_util_keyval_yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++(yy_c_buf_p); - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = (yy_c_buf_p); - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_END_OF_FILE: - { - (yy_did_buffer_switch_on_eof) = 0; - - if ( pmix_util_keyval_yywrap( ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * pmix_util_keyval_yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = - (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - (yy_c_buf_p) = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ -} /* end of pmix_util_keyval_yylex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (void) -{ - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = (yytext_ptr); - register int number_to_move, i; - int ret_val; - - if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; - - else - { - yy_size_t num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - if ( (yy_n_chars) == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - pmix_util_keyval_yyrestart(pmix_util_keyval_yyin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) pmix_util_keyval_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - } - - (yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - - (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; -} - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (void) -{ - register yy_state_type yy_current_state; - register char *yy_cp; - - yy_current_state = (yy_start); - - (yy_state_ptr) = (yy_state_buf); - *(yy_state_ptr)++ = yy_current_state; - - for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 84 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - *(yy_state_ptr)++ = yy_current_state; - } - - return yy_current_state; -} - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) -{ - register int yy_is_jam; - - register YY_CHAR yy_c = 1; - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 84 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 83); - if ( ! yy_is_jam ) - *(yy_state_ptr)++ = yy_current_state; - - return yy_is_jam ? 0 : yy_current_state; -} - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (void) -#else - static int input (void) -#endif - -{ - int c; - - *(yy_c_buf_p) = (yy_hold_char); - - if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - /* This was really a NUL. */ - *(yy_c_buf_p) = '\0'; - - else - { /* need more input */ - yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); - ++(yy_c_buf_p); - - switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - pmix_util_keyval_yyrestart(pmix_util_keyval_yyin ); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( pmix_util_keyval_yywrap( ) ) - return EOF; - - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = (yytext_ptr) + offset; - break; - } - } - } - - c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve pmix_util_keyval_yytext */ - (yy_hold_char) = *++(yy_c_buf_p); - - if ( c == '\n' ) - - pmix_util_keyval_yylineno++; -; - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * - * @note This function does not reset the start condition to @c INITIAL . - */ - void pmix_util_keyval_yyrestart (FILE * input_file ) -{ - - if ( ! YY_CURRENT_BUFFER ){ - pmix_util_keyval_yyensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - pmix_util_keyval_yy_create_buffer(pmix_util_keyval_yyin,YY_BUF_SIZE ); - } - - pmix_util_keyval_yy_init_buffer(YY_CURRENT_BUFFER,input_file ); - pmix_util_keyval_yy_load_buffer_state( ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * - */ - void pmix_util_keyval_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) -{ - - /* TODO. We should be able to replace this entire function body - * with - * pmix_util_keyval_yypop_buffer_state(); - * pmix_util_keyval_yypush_buffer_state(new_buffer); - */ - pmix_util_keyval_yyensure_buffer_stack (); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - pmix_util_keyval_yy_load_buffer_state( ); - - /* We don't actually know whether we did this switch during - * EOF (pmix_util_keyval_yywrap()) processing, but the only time this flag - * is looked at is after pmix_util_keyval_yywrap() is called, so it's safe - * to go ahead and always set it. - */ - (yy_did_buffer_switch_on_eof) = 1; -} - -static void pmix_util_keyval_yy_load_buffer_state (void) -{ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - pmix_util_keyval_yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - (yy_hold_char) = *(yy_c_buf_p); -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * - * @return the allocated buffer state. - */ - YY_BUFFER_STATE pmix_util_keyval_yy_create_buffer (FILE * file, int size ) -{ - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) pmix_util_keyval_yyalloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in pmix_util_keyval_yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) pmix_util_keyval_yyalloc(b->yy_buf_size + 2 ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in pmix_util_keyval_yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - pmix_util_keyval_yy_init_buffer(b,file ); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with pmix_util_keyval_yy_create_buffer() - * - */ - void pmix_util_keyval_yy_delete_buffer (YY_BUFFER_STATE b ) -{ - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - pmix_util_keyval_yyfree((void *) b->yy_ch_buf ); - - pmix_util_keyval_yyfree((void *) b ); -} - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a pmix_util_keyval_yyrestart() or at EOF. - */ - static void pmix_util_keyval_yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) - -{ - int oerrno = errno; - - pmix_util_keyval_yy_flush_buffer(b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then pmix_util_keyval_yy_init_buffer was _probably_ - * called from pmix_util_keyval_yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * - */ - void pmix_util_keyval_yy_flush_buffer (YY_BUFFER_STATE b ) -{ - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - pmix_util_keyval_yy_load_buffer_state( ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * - */ -void pmix_util_keyval_yypush_buffer_state (YY_BUFFER_STATE new_buffer ) -{ - if (new_buffer == NULL) - return; - - pmix_util_keyval_yyensure_buffer_stack(); - - /* This block is copied from pmix_util_keyval_yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - (yy_buffer_stack_top)++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from pmix_util_keyval_yy_switch_to_buffer. */ - pmix_util_keyval_yy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * - */ -void pmix_util_keyval_yypop_buffer_state (void) -{ - if (!YY_CURRENT_BUFFER) - return; - - pmix_util_keyval_yy_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - if ((yy_buffer_stack_top) > 0) - --(yy_buffer_stack_top); - - if (YY_CURRENT_BUFFER) { - pmix_util_keyval_yy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void pmix_util_keyval_yyensure_buffer_stack (void) -{ - yy_size_t num_to_alloc; - - if (!(yy_buffer_stack)) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; - (yy_buffer_stack) = (struct yy_buffer_state**)pmix_util_keyval_yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in pmix_util_keyval_yyensure_buffer_stack()" ); - - memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - (yy_buffer_stack_max) = num_to_alloc; - (yy_buffer_stack_top) = 0; - return; - } - - if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)pmix_util_keyval_yyrealloc - ((yy_buffer_stack), - num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in pmix_util_keyval_yyensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); - (yy_buffer_stack_max) = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE pmix_util_keyval_yy_scan_buffer (char * base, yy_size_t size ) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) pmix_util_keyval_yyalloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in pmix_util_keyval_yy_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - pmix_util_keyval_yy_switch_to_buffer(b ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to pmix_util_keyval_yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * pmix_util_keyval_yy_scan_bytes() instead. - */ -YY_BUFFER_STATE pmix_util_keyval_yy_scan_string (yyconst char * yystr ) -{ - - return pmix_util_keyval_yy_scan_bytes(yystr,strlen(yystr) ); -} - -/** Setup the input buffer state to scan the given bytes. The next call to pmix_util_keyval_yylex() will - * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE pmix_util_keyval_yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) pmix_util_keyval_yyalloc(n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in pmix_util_keyval_yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = pmix_util_keyval_yy_scan_buffer(buf,n ); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in pmix_util_keyval_yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yy_fatal_error (yyconst char* msg ) -{ - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up pmix_util_keyval_yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - pmix_util_keyval_yytext[pmix_util_keyval_yyleng] = (yy_hold_char); \ - (yy_c_buf_p) = pmix_util_keyval_yytext + yyless_macro_arg; \ - (yy_hold_char) = *(yy_c_buf_p); \ - *(yy_c_buf_p) = '\0'; \ - pmix_util_keyval_yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the current line number. - * - */ -int pmix_util_keyval_yyget_lineno (void) -{ - - return pmix_util_keyval_yylineno; -} - -/** Get the input stream. - * - */ -FILE *pmix_util_keyval_yyget_in (void) -{ - return pmix_util_keyval_yyin; -} - -/** Get the output stream. - * - */ -FILE *pmix_util_keyval_yyget_out (void) -{ - return pmix_util_keyval_yyout; -} - -/** Get the length of the current token. - * - */ -yy_size_t pmix_util_keyval_yyget_leng (void) -{ - return pmix_util_keyval_yyleng; -} - -/** Get the current token. - * - */ - -char *pmix_util_keyval_yyget_text (void) -{ - return pmix_util_keyval_yytext; -} - -/** Set the current line number. - * @param line_number - * - */ -void pmix_util_keyval_yyset_lineno (int line_number ) -{ - - pmix_util_keyval_yylineno = line_number; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param in_str A readable stream. - * - * @see pmix_util_keyval_yy_switch_to_buffer - */ -void pmix_util_keyval_yyset_in (FILE * in_str ) -{ - pmix_util_keyval_yyin = in_str ; -} - -void pmix_util_keyval_yyset_out (FILE * out_str ) -{ - pmix_util_keyval_yyout = out_str ; -} - -int pmix_util_keyval_yyget_debug (void) -{ - return pmix_util_keyval_yy_flex_debug; -} - -void pmix_util_keyval_yyset_debug (int bdebug ) -{ - pmix_util_keyval_yy_flex_debug = bdebug ; -} - -static int yy_init_globals (void) -{ - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from pmix_util_keyval_yylex_destroy(), so don't allocate here. - */ - - /* We do not touch pmix_util_keyval_yylineno unless the option is enabled. */ - pmix_util_keyval_yylineno = 1; - - (yy_buffer_stack) = 0; - (yy_buffer_stack_top) = 0; - (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = (char *) 0; - (yy_init) = 0; - (yy_start) = 0; - - (yy_state_buf) = 0; - (yy_state_ptr) = 0; - (yy_full_match) = 0; - (yy_lp) = 0; - -/* Defined in main.c */ -#ifdef YY_STDINIT - pmix_util_keyval_yyin = stdin; - pmix_util_keyval_yyout = stdout; -#else - pmix_util_keyval_yyin = (FILE *) 0; - pmix_util_keyval_yyout = (FILE *) 0; -#endif - - /* For future reference: Set errno on error, since we are called by - * pmix_util_keyval_yylex_init() - */ - return 0; -} - -/* pmix_util_keyval_yylex_destroy is for both reentrant and non-reentrant scanners. */ -int pmix_util_keyval_yylex_destroy (void) -{ - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - pmix_util_keyval_yy_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - pmix_util_keyval_yypop_buffer_state(); - } - - /* Destroy the stack itself. */ - pmix_util_keyval_yyfree((yy_buffer_stack) ); - (yy_buffer_stack) = NULL; - - pmix_util_keyval_yyfree ( (yy_state_buf) ); - (yy_state_buf) = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * pmix_util_keyval_yylex() is called, initialization will occur. */ - yy_init_globals( ); - - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) -{ - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) -{ - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *pmix_util_keyval_yyalloc (yy_size_t size ) -{ - return (void *) malloc( size ); -} - -void *pmix_util_keyval_yyrealloc (void * ptr, yy_size_t size ) -{ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); -} - -void pmix_util_keyval_yyfree (void * ptr ) -{ - free( (char *) ptr ); /* see pmix_util_keyval_yyrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 94 "keyval_lex.l" - - - -/* Old flex (2.5.4a? and older) does not define a destroy function */ -#if !defined(YY_FLEX_SUBMINOR_VERSION) -#define YY_FLEX_SUBMINOR_VERSION 0 -#endif - -#if (YY_FLEX_MAJOR_VERSION < 2) || (YY_FLEX_MAJOR_VERSION == 2 && (YY_FLEX_MINOR_VERSION < 5 || (YY_FLEX_MINOR_VERSION == 5 && YY_FLEX_SUBMINOR_VERSION < 5))) -int pmix_util_keyval_yylex_destroy(void) -{ - if (NULL != YY_CURRENT_BUFFER) { - pmix_util_keyval_yy_delete_buffer(YY_CURRENT_BUFFER); -#if defined(YY_CURRENT_BUFFER_LVALUE) - YY_CURRENT_BUFFER_LVALUE = NULL; -#else - YY_CURRENT_BUFFER = NULL; -#endif /* YY_CURRENT_BUFFER_LVALUE */ - } - return YY_NULL; -} -#endif - -int pmix_util_keyval_yywrap(void) -{ - pmix_util_keyval_parse_done = true; - return 1; -} - -/* - * Ensure that we have a valid yybuffer to use. Specifically, if this - * scanner is invoked a second time, finish_parsing() (above) will - * have been executed, and the current buffer will have been freed. - * Flex doesn't recognize this fact because as far as it's concerned, - * its internal state was already initialized, so it thinks it should - * have a valid buffer. Hence, here we ensure to give it a valid - * buffer. - */ -int pmix_util_keyval_init_buffer(FILE *file) -{ - YY_BUFFER_STATE buf = pmix_util_keyval_yy_create_buffer(file,YY_BUF_SIZE); - pmix_util_keyval_yy_switch_to_buffer(buf); - - return 0; -} - diff --git a/opal/mca/pmix/pmix3x/pmix/src/util/show_help_lex.c b/opal/mca/pmix/pmix3x/pmix/src/util/show_help_lex.c deleted file mode 100644 index 0fdb995ea2..0000000000 --- a/opal/mca/pmix/pmix3x/pmix/src/util/show_help_lex.c +++ /dev/null @@ -1,1863 +0,0 @@ - -#line 3 "util/show_help_lex.c" - -#define YY_INT_ALIGNED short int - -/* A lexical scanner generated by flex */ - -#define yy_create_buffer pmix_show_help_yy_create_buffer -#define yy_delete_buffer pmix_show_help_yy_delete_buffer -#define yy_flex_debug pmix_show_help_yy_flex_debug -#define yy_init_buffer pmix_show_help_yy_init_buffer -#define yy_flush_buffer pmix_show_help_yy_flush_buffer -#define yy_load_buffer_state pmix_show_help_yy_load_buffer_state -#define yy_switch_to_buffer pmix_show_help_yy_switch_to_buffer -#define yyin pmix_show_help_yyin -#define yyleng pmix_show_help_yyleng -#define yylex pmix_show_help_yylex -#define yylineno pmix_show_help_yylineno -#define yyout pmix_show_help_yyout -#define yyrestart pmix_show_help_yyrestart -#define yytext pmix_show_help_yytext -#define yywrap pmix_show_help_yywrap -#define yyalloc pmix_show_help_yyalloc -#define yyrealloc pmix_show_help_yyrealloc -#define yyfree pmix_show_help_yyfree - -#define FLEX_SCANNER -#define YY_FLEX_MAJOR_VERSION 2 -#define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 37 -#if YY_FLEX_SUBMINOR_VERSION > 0 -#define FLEX_BETA -#endif - -/* First, we deal with platform-specific or compiler-specific issues. */ - -/* begin standard C headers. */ -#include -#include -#include -#include - -/* end standard C headers. */ - -/* flex integer type definitions */ - -#ifndef FLEXINT_H -#define FLEXINT_H - -/* C99 systems have . Non-C99 systems may or may not. */ - -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L - -/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. - */ -#ifndef __STDC_LIMIT_MACROS -#define __STDC_LIMIT_MACROS 1 -#endif - -#include -typedef int8_t flex_int8_t; -typedef uint8_t flex_uint8_t; -typedef int16_t flex_int16_t; -typedef uint16_t flex_uint16_t; -typedef int32_t flex_int32_t; -typedef uint32_t flex_uint32_t; -#else -typedef signed char flex_int8_t; -typedef short int flex_int16_t; -typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; -typedef unsigned short int flex_uint16_t; -typedef unsigned int flex_uint32_t; - -/* Limits of integral types. */ -#ifndef INT8_MIN -#define INT8_MIN (-128) -#endif -#ifndef INT16_MIN -#define INT16_MIN (-32767-1) -#endif -#ifndef INT32_MIN -#define INT32_MIN (-2147483647-1) -#endif -#ifndef INT8_MAX -#define INT8_MAX (127) -#endif -#ifndef INT16_MAX -#define INT16_MAX (32767) -#endif -#ifndef INT32_MAX -#define INT32_MAX (2147483647) -#endif -#ifndef UINT8_MAX -#define UINT8_MAX (255U) -#endif -#ifndef UINT16_MAX -#define UINT16_MAX (65535U) -#endif -#ifndef UINT32_MAX -#define UINT32_MAX (4294967295U) -#endif - -#endif /* ! C99 */ - -#endif /* ! FLEXINT_H */ - -#ifdef __cplusplus - -/* The "const" storage-class-modifier is valid. */ -#define YY_USE_CONST - -#else /* ! __cplusplus */ - -/* C99 requires __STDC__ to be defined as 1. */ -#if defined (__STDC__) - -#define YY_USE_CONST - -#endif /* defined (__STDC__) */ -#endif /* ! __cplusplus */ - -#ifdef YY_USE_CONST -#define yyconst const -#else -#define yyconst -#endif - -/* Returned upon end-of-file. */ -#define YY_NULL 0 - -/* Promotes a possibly negative, possibly signed char to an unsigned - * integer for use as an array index. If the signed char is negative, - * we want to instead treat it as an 8-bit unsigned char, hence the - * double cast. - */ -#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) - -/* Enter a start condition. This macro really ought to take a parameter, - * but we do it the disgusting crufty way forced on us by the ()-less - * definition of BEGIN. - */ -#define BEGIN (yy_start) = 1 + 2 * - -/* Translate the current start state into a value that can be later handed - * to BEGIN to return to the state. The YYSTATE alias is for lex - * compatibility. - */ -#define YY_START (((yy_start) - 1) / 2) -#define YYSTATE YY_START - -/* Action number for EOF rule of a given start state. */ -#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) - -/* Special action meaning "start processing a new file". */ -#define YY_NEW_FILE pmix_show_help_yyrestart(pmix_show_help_yyin ) - -#define YY_END_OF_BUFFER_CHAR 0 - -/* Size of default input buffer. */ -#ifndef YY_BUF_SIZE -#define YY_BUF_SIZE 16384 -#endif - -/* The state buf must be large enough to hold one state per character in the main buffer. - */ -#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) - -#ifndef YY_TYPEDEF_YY_BUFFER_STATE -#define YY_TYPEDEF_YY_BUFFER_STATE -typedef struct yy_buffer_state *YY_BUFFER_STATE; -#endif - -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - -extern yy_size_t pmix_show_help_yyleng; - -extern FILE *pmix_show_help_yyin, *pmix_show_help_yyout; - -#define EOB_ACT_CONTINUE_SCAN 0 -#define EOB_ACT_END_OF_FILE 1 -#define EOB_ACT_LAST_MATCH 2 - - #define YY_LESS_LINENO(n) - -/* Return all but the first "n" matched characters back to the input stream. */ -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up pmix_show_help_yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - *yy_cp = (yy_hold_char); \ - YY_RESTORE_YY_MORE_OFFSET \ - (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ - YY_DO_BEFORE_ACTION; /* set up pmix_show_help_yytext again */ \ - } \ - while ( 0 ) - -#define unput(c) yyunput( c, (yytext_ptr) ) - -#ifndef YY_STRUCT_YY_BUFFER_STATE -#define YY_STRUCT_YY_BUFFER_STATE -struct yy_buffer_state - { - FILE *yy_input_file; - - char *yy_ch_buf; /* input buffer */ - char *yy_buf_pos; /* current position in input buffer */ - - /* Size of input buffer in bytes, not including room for EOB - * characters. - */ - yy_size_t yy_buf_size; - - /* Number of characters read into yy_ch_buf, not including EOB - * characters. - */ - yy_size_t yy_n_chars; - - /* Whether we "own" the buffer - i.e., we know we created it, - * and can realloc() it to grow it, and should free() it to - * delete it. - */ - int yy_is_our_buffer; - - /* Whether this is an "interactive" input source; if so, and - * if we're using stdio for input, then we want to use getc() - * instead of fread(), to make sure we stop fetching input after - * each newline. - */ - int yy_is_interactive; - - /* Whether we're considered to be at the beginning of a line. - * If so, '^' rules will be active on the next match, otherwise - * not. - */ - int yy_at_bol; - - int yy_bs_lineno; /**< The line count. */ - int yy_bs_column; /**< The column count. */ - - /* Whether to try to fill the input buffer when we reach the - * end of it. - */ - int yy_fill_buffer; - - int yy_buffer_status; - -#define YY_BUFFER_NEW 0 -#define YY_BUFFER_NORMAL 1 - /* When an EOF's been seen but there's still some text to process - * then we mark the buffer as YY_EOF_PENDING, to indicate that we - * shouldn't try reading from the input source any more. We might - * still have a bunch of tokens to match, though, because of - * possible backing-up. - * - * When we actually see the EOF, we change the status to "new" - * (via pmix_show_help_yyrestart()), so that the user can continue scanning by - * just pointing pmix_show_help_yyin at a new input file. - */ -#define YY_BUFFER_EOF_PENDING 2 - - }; -#endif /* !YY_STRUCT_YY_BUFFER_STATE */ - -/* Stack of input buffers. */ -static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ -static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ -static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ - -/* We provide macros for accessing buffer states in case in the - * future we want to put the buffer states in a more general - * "scanner state". - * - * Returns the top of the stack, or NULL. - */ -#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ - ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ - : NULL) - -/* Same as previous macro, but useful when we know that the buffer stack is not - * NULL or when we need an lvalue. For internal use only. - */ -#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] - -/* yy_hold_char holds the character lost when pmix_show_help_yytext is formed. */ -static char yy_hold_char; -static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ -yy_size_t pmix_show_help_yyleng; - -/* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; -static int yy_init = 0; /* whether we need to initialize */ -static int yy_start = 0; /* start state number */ - -/* Flag which is used to allow pmix_show_help_yywrap()'s to do buffer switches - * instead of setting up a fresh pmix_show_help_yyin. A bit of a hack ... - */ -static int yy_did_buffer_switch_on_eof; - -void pmix_show_help_yyrestart (FILE *input_file ); -void pmix_show_help_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ); -YY_BUFFER_STATE pmix_show_help_yy_create_buffer (FILE *file,int size ); -void pmix_show_help_yy_delete_buffer (YY_BUFFER_STATE b ); -void pmix_show_help_yy_flush_buffer (YY_BUFFER_STATE b ); -void pmix_show_help_yypush_buffer_state (YY_BUFFER_STATE new_buffer ); -void pmix_show_help_yypop_buffer_state (void ); - -static void pmix_show_help_yyensure_buffer_stack (void ); -static void pmix_show_help_yy_load_buffer_state (void ); -static void pmix_show_help_yy_init_buffer (YY_BUFFER_STATE b,FILE *file ); - -#define YY_FLUSH_BUFFER pmix_show_help_yy_flush_buffer(YY_CURRENT_BUFFER ) - -YY_BUFFER_STATE pmix_show_help_yy_scan_buffer (char *base,yy_size_t size ); -YY_BUFFER_STATE pmix_show_help_yy_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE pmix_show_help_yy_scan_bytes (yyconst char *bytes,yy_size_t len ); - -void *pmix_show_help_yyalloc (yy_size_t ); -void *pmix_show_help_yyrealloc (void *,yy_size_t ); -void pmix_show_help_yyfree (void * ); - -#define yy_new_buffer pmix_show_help_yy_create_buffer - -#define yy_set_interactive(is_interactive) \ - { \ - if ( ! YY_CURRENT_BUFFER ){ \ - pmix_show_help_yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - pmix_show_help_yy_create_buffer(pmix_show_help_yyin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ - } - -#define yy_set_bol(at_bol) \ - { \ - if ( ! YY_CURRENT_BUFFER ){\ - pmix_show_help_yyensure_buffer_stack (); \ - YY_CURRENT_BUFFER_LVALUE = \ - pmix_show_help_yy_create_buffer(pmix_show_help_yyin,YY_BUF_SIZE ); \ - } \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ - } - -#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) - -/* Begin user sect3 */ - -typedef unsigned char YY_CHAR; - -FILE *pmix_show_help_yyin = (FILE *) 0, *pmix_show_help_yyout = (FILE *) 0; - -typedef int yy_state_type; - -extern int pmix_show_help_yylineno; - -int pmix_show_help_yylineno = 1; - -extern char *pmix_show_help_yytext; -#define yytext_ptr pmix_show_help_yytext - -static yy_state_type yy_get_previous_state (void ); -static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); -static int yy_get_next_buffer (void ); -static void yy_fatal_error (yyconst char msg[] ); - -/* Done after the current pattern has been matched and before the - * corresponding action - sets up pmix_show_help_yytext. - */ -#define YY_DO_BEFORE_ACTION \ - (yytext_ptr) = yy_bp; \ - pmix_show_help_yyleng = (size_t) (yy_cp - yy_bp); \ - (yy_hold_char) = *yy_cp; \ - *yy_cp = '\0'; \ - (yy_c_buf_p) = yy_cp; - -#define YY_NUM_RULES 5 -#define YY_END_OF_BUFFER 6 -/* This struct is not used in this scanner, - but its presence is necessary. */ -struct yy_trans_info - { - flex_int32_t yy_verify; - flex_int32_t yy_nxt; - }; -static yyconst flex_int16_t yy_acclist[17] = - { 0, - 6, 5, 4, 5, 5, 5, 5, 3, 5, 4, - 1, 4, 3,16386, 8194, 4 - } ; - -static yyconst flex_int16_t yy_accept[24] = - { 0, - 1, 1, 1, 1, 1, 2, 3, 5, 6, 7, - 8, 10, 10, 11, 11, 13, 13, 13, 14, 15, - 15, 17, 17 - } ; - -static yyconst flex_int32_t yy_ec[256] = - { 0, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 4, 1, 5, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1 - } ; - -static yyconst flex_int32_t yy_meta[6] = - { 0, - 1, 1, 1, 1, 1 - } ; - -static yyconst flex_int16_t yy_base[30] = - { 0, - 0, 3, 28, 27, 28, 25, 31, 24, 23, 22, - 31, 21, 31, 20, 31, 7, 19, 31, 11, 15, - 31, 31, 18, 17, 14, 13, 10, 9, 0 - } ; - -static yyconst flex_int16_t yy_def[30] = - { 0, - 23, 22, 24, 24, 22, 25, 22, 26, 27, 28, - 22, 25, 22, 26, 22, 27, 28, 22, 29, 29, - 22, 0, 22, 22, 22, 22, 22, 22, 22 - } ; - -static yyconst flex_int16_t yy_nxt[37] = - { 0, - 20, 7, 8, 6, 7, 8, 9, 6, 13, 17, - 16, 19, 21, 14, 12, 19, 21, 10, 6, 19, - 18, 15, 13, 18, 13, 15, 13, 22, 11, 11, - 5, 22, 22, 22, 22, 22 - } ; - -static yyconst flex_int16_t yy_chk[37] = - { 0, - 29, 1, 1, 2, 2, 2, 2, 2, 16, 28, - 27, 16, 19, 26, 25, 19, 20, 24, 23, 20, - 17, 14, 12, 10, 9, 8, 6, 5, 4, 3, - 22, 22, 22, 22, 22, 22 - } ; - -extern int pmix_show_help_yy_flex_debug; -int pmix_show_help_yy_flex_debug = 0; - -static yy_state_type *yy_state_buf=0, *yy_state_ptr=0; -static char *yy_full_match; -static int yy_lp; -static int yy_looking_for_trail_begin = 0; -static int yy_full_lp; -static int *yy_full_state; -#define YY_TRAILING_MASK 0x2000 -#define YY_TRAILING_HEAD_MASK 0x4000 -#define REJECT \ -{ \ -*yy_cp = (yy_hold_char); /* undo effects of setting up pmix_show_help_yytext */ \ -yy_cp = (yy_full_match); /* restore poss. backed-over text */ \ -(yy_lp) = (yy_full_lp); /* restore orig. accepting pos. */ \ -(yy_state_ptr) = (yy_full_state); /* restore orig. state */ \ -yy_current_state = *(yy_state_ptr); /* restore curr. state */ \ -++(yy_lp); \ -goto find_rule; \ -} - -#define yymore() yymore_used_but_not_detected -#define YY_MORE_ADJ 0 -#define YY_RESTORE_YY_MORE_OFFSET -char *pmix_show_help_yytext; -#line 1 "util/show_help_lex.l" -#define YY_NO_INPUT 1 -#line 5 "util/show_help_lex.l" -/* - * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana - * University Research and Technology - * Corporation. All rights reserved. - * Copyright (c) 2004-2006 The University of Tennessee and The University - * of Tennessee Research Foundation. All rights - * reserved. - * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, - * University of Stuttgart. All rights reserved. - * Copyright (c) 2004-2005 The Regents of the University of California. - * All rights reserved. - * Copyright (c) 2016 Intel, Inc. All rights reserved - * $COPYRIGHT$ - * - * Additional copyrights may follow - * - * $HEADER$ - */ - -#include - -#include -#ifdef HAVE_UNISTD_H -#include -#endif - -#include "src/util/show_help_lex.h" - -BEGIN_C_DECLS - -/* - * public functions - */ -extern int pmix_show_help_finish_parsing(void); - -/* - * local functions - */ -static int pmix_show_help_yywrap(void); - -END_C_DECLS - -/* - * global variables - */ -int pmix_show_help_yynewlines = 1; -bool pmix_show_help_parse_done = false; - - -#line 550 "util/show_help_lex.c" - -#define INITIAL 0 -#define CHOMP 1 - -#ifndef YY_NO_UNISTD_H -/* Special case for "unistd.h", since it is non-ANSI. We include it way - * down here because we want the user's section 1 to have been scanned first. - * The user has a chance to override it with an option. - */ -#include -#endif - -#ifndef YY_EXTRA_TYPE -#define YY_EXTRA_TYPE void * -#endif - -static int yy_init_globals (void ); - -/* Accessor methods to globals. - These are made visible to non-reentrant scanners for convenience. */ - -int pmix_show_help_yylex_destroy (void ); - -int pmix_show_help_yyget_debug (void ); - -void pmix_show_help_yyset_debug (int debug_flag ); - -YY_EXTRA_TYPE pmix_show_help_yyget_extra (void ); - -void pmix_show_help_yyset_extra (YY_EXTRA_TYPE user_defined ); - -FILE *pmix_show_help_yyget_in (void ); - -void pmix_show_help_yyset_in (FILE * in_str ); - -FILE *pmix_show_help_yyget_out (void ); - -void pmix_show_help_yyset_out (FILE * out_str ); - -yy_size_t pmix_show_help_yyget_leng (void ); - -char *pmix_show_help_yyget_text (void ); - -int pmix_show_help_yyget_lineno (void ); - -void pmix_show_help_yyset_lineno (int line_number ); - -/* Macros after this point can all be overridden by user definitions in - * section 1. - */ - -#ifndef YY_SKIP_YYWRAP -#ifdef __cplusplus -extern "C" int pmix_show_help_yywrap (void ); -#else -extern int pmix_show_help_yywrap (void ); -#endif -#endif - -#ifndef yytext_ptr -static void yy_flex_strncpy (char *,yyconst char *,int ); -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * ); -#endif - -#ifndef YY_NO_INPUT - -#ifdef __cplusplus -static int yyinput (void ); -#else -static int input (void ); -#endif - -#endif - -/* Amount of stuff to slurp up with each read. */ -#ifndef YY_READ_BUF_SIZE -#define YY_READ_BUF_SIZE 8192 -#endif - -/* Copy whatever the last rule matched to the standard output. */ -#ifndef ECHO -/* This used to be an fputs(), but since the string might contain NUL's, - * we now use fwrite(). - */ -#define ECHO do { if (fwrite( pmix_show_help_yytext, pmix_show_help_yyleng, 1, pmix_show_help_yyout )) {} } while (0) -#endif - -/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, - * is returned in "result". - */ -#ifndef YY_INPUT -#define YY_INPUT(buf,result,max_size) \ - if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ - { \ - int c = '*'; \ - size_t n; \ - for ( n = 0; n < max_size && \ - (c = getc( pmix_show_help_yyin )) != EOF && c != '\n'; ++n ) \ - buf[n] = (char) c; \ - if ( c == '\n' ) \ - buf[n++] = (char) c; \ - if ( c == EOF && ferror( pmix_show_help_yyin ) ) \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - result = n; \ - } \ - else \ - { \ - errno=0; \ - while ( (result = fread(buf, 1, max_size, pmix_show_help_yyin))==0 && ferror(pmix_show_help_yyin)) \ - { \ - if( errno != EINTR) \ - { \ - YY_FATAL_ERROR( "input in flex scanner failed" ); \ - break; \ - } \ - errno=0; \ - clearerr(pmix_show_help_yyin); \ - } \ - }\ -\ - -#endif - -/* No semi-colon after return; correct usage is to write "yyterminate();" - - * we don't want an extra ';' after the "return" because that will cause - * some compilers to complain about unreachable statements. - */ -#ifndef yyterminate -#define yyterminate() return YY_NULL -#endif - -/* Number of entries by which start-condition stack grows. */ -#ifndef YY_START_STACK_INCR -#define YY_START_STACK_INCR 25 -#endif - -/* Report a fatal error. */ -#ifndef YY_FATAL_ERROR -#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) -#endif - -/* end tables serialization structures and prototypes */ - -/* Default declaration of generated scanner - a define so the user can - * easily add parameters. - */ -#ifndef YY_DECL -#define YY_DECL_IS_OURS 1 - -extern int pmix_show_help_yylex (void); - -#define YY_DECL int pmix_show_help_yylex (void) -#endif /* !YY_DECL */ - -/* Code executed at the beginning of each rule, after pmix_show_help_yytext and pmix_show_help_yyleng - * have been set up. - */ -#ifndef YY_USER_ACTION -#define YY_USER_ACTION -#endif - -/* Code executed at the end of each rule. */ -#ifndef YY_BREAK -#define YY_BREAK break; -#endif - -#define YY_RULE_SETUP \ - if ( pmix_show_help_yyleng > 0 ) \ - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ - (pmix_show_help_yytext[pmix_show_help_yyleng - 1] == '\n'); \ - YY_USER_ACTION - -/** The main scanner function which does all the work. - */ -YY_DECL -{ - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - -#line 60 "util/show_help_lex.l" - - -#line 737 "util/show_help_lex.c" - - if ( !(yy_init) ) - { - (yy_init) = 1; - -#ifdef YY_USER_INIT - YY_USER_INIT; -#endif - - /* Create the reject buffer large enough to save one state per allowed character. */ - if ( ! (yy_state_buf) ) - (yy_state_buf) = (yy_state_type *)pmix_show_help_yyalloc(YY_STATE_BUF_SIZE ); - if ( ! (yy_state_buf) ) - YY_FATAL_ERROR( "out of dynamic memory in pmix_show_help_yylex()" ); - - if ( ! (yy_start) ) - (yy_start) = 1; /* first start state */ - - if ( ! pmix_show_help_yyin ) - pmix_show_help_yyin = stdin; - - if ( ! pmix_show_help_yyout ) - pmix_show_help_yyout = stdout; - - if ( ! YY_CURRENT_BUFFER ) { - pmix_show_help_yyensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - pmix_show_help_yy_create_buffer(pmix_show_help_yyin,YY_BUF_SIZE ); - } - - pmix_show_help_yy_load_buffer_state( ); - } - - while ( 1 ) /* loops until end-of-file is reached */ - { - yy_cp = (yy_c_buf_p); - - /* Support of pmix_show_help_yytext. */ - *yy_cp = (yy_hold_char); - - /* yy_bp points to the position in yy_ch_buf of the start of - * the current run. - */ - yy_bp = yy_cp; - - yy_current_state = (yy_start); - yy_current_state += YY_AT_BOL(); - - (yy_state_ptr) = (yy_state_buf); - *(yy_state_ptr)++ = yy_current_state; - -yy_match: - do - { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 23 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - *(yy_state_ptr)++ = yy_current_state; - ++yy_cp; - } - while ( yy_base[yy_current_state] != 31 ); - -yy_find_action: - yy_current_state = *--(yy_state_ptr); - (yy_lp) = yy_accept[yy_current_state]; -find_rule: /* we branch to this label when backing up */ - for ( ; ; ) /* until we find what rule we matched */ - { - if ( (yy_lp) && (yy_lp) < yy_accept[yy_current_state + 1] ) - { - yy_act = yy_acclist[(yy_lp)]; - if ( yy_act & YY_TRAILING_HEAD_MASK || - (yy_looking_for_trail_begin) ) - { - if ( yy_act == (yy_looking_for_trail_begin) ) - { - (yy_looking_for_trail_begin) = 0; - yy_act &= ~YY_TRAILING_HEAD_MASK; - break; - } - } - else if ( yy_act & YY_TRAILING_MASK ) - { - (yy_looking_for_trail_begin) = yy_act & ~YY_TRAILING_MASK; - (yy_looking_for_trail_begin) |= YY_TRAILING_HEAD_MASK; - } - else - { - (yy_full_match) = yy_cp; - (yy_full_state) = (yy_state_ptr); - (yy_full_lp) = (yy_lp); - break; - } - ++(yy_lp); - goto find_rule; - } - --yy_cp; - yy_current_state = *--(yy_state_ptr); - (yy_lp) = yy_accept[yy_current_state]; - } - - YY_DO_BEFORE_ACTION; - -do_action: /* This label is used only to access EOF actions. */ - - switch ( yy_act ) - { /* beginning of action switch */ -case 1: -/* rule 1 can match eol */ -YY_RULE_SETUP -#line 62 "util/show_help_lex.l" -; /* comment line */ - YY_BREAK -case 2: -/* rule 2 can match eol */ -YY_RULE_SETUP -#line 64 "util/show_help_lex.l" -{ BEGIN(CHOMP); return PMIX_SHOW_HELP_PARSE_TOPIC; } - YY_BREAK -case 3: -/* rule 3 can match eol */ -YY_RULE_SETUP -#line 66 "util/show_help_lex.l" -{ BEGIN(INITIAL); } - YY_BREAK -case 4: -/* rule 4 can match eol */ -*yy_cp = (yy_hold_char); /* undo effects of setting up pmix_show_help_yytext */ -(yy_c_buf_p) = yy_cp -= 1; -YY_DO_BEFORE_ACTION; /* set up pmix_show_help_yytext again */ -YY_RULE_SETUP -#line 68 "util/show_help_lex.l" -{ BEGIN(CHOMP); return PMIX_SHOW_HELP_PARSE_MESSAGE; } - YY_BREAK -case 5: -YY_RULE_SETUP -#line 70 "util/show_help_lex.l" -ECHO; - YY_BREAK -#line 882 "util/show_help_lex.c" - case YY_STATE_EOF(INITIAL): - case YY_STATE_EOF(CHOMP): - yyterminate(); - - case YY_END_OF_BUFFER: - { - /* Amount of text matched not including the EOB char. */ - int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; - - /* Undo the effects of YY_DO_BEFORE_ACTION. */ - *yy_cp = (yy_hold_char); - YY_RESTORE_YY_MORE_OFFSET - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) - { - /* We're scanning a new file or input source. It's - * possible that this happened because the user - * just pointed pmix_show_help_yyin at a new source and called - * pmix_show_help_yylex(). If so, then we have to assure - * consistency between YY_CURRENT_BUFFER and our - * globals. Here is the right place to do so, because - * this is the first action (other than possibly a - * back-up) that will match for the new input source. - */ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - YY_CURRENT_BUFFER_LVALUE->yy_input_file = pmix_show_help_yyin; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; - } - - /* Note that here we test for yy_c_buf_p "<=" to the position - * of the first EOB in the buffer, since yy_c_buf_p will - * already have been incremented past the NUL character - * (since all states make transitions on EOB to the - * end-of-buffer state). Contrast this with the test - * in input(). - */ - if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - { /* This was really a NUL. */ - yy_state_type yy_next_state; - - (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - /* Okay, we're now positioned to make the NUL - * transition. We couldn't have - * yy_get_previous_state() go ahead and do it - * for us because it doesn't know how to deal - * with the possibility of jamming (and we don't - * want to build jamming into it because then it - * will run more slowly). - */ - - yy_next_state = yy_try_NUL_trans( yy_current_state ); - - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - - if ( yy_next_state ) - { - /* Consume the NUL. */ - yy_cp = ++(yy_c_buf_p); - yy_current_state = yy_next_state; - goto yy_match; - } - - else - { - yy_cp = (yy_c_buf_p); - goto yy_find_action; - } - } - - else switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_END_OF_FILE: - { - (yy_did_buffer_switch_on_eof) = 0; - - if ( pmix_show_help_yywrap( ) ) - { - /* Note: because we've taken care in - * yy_get_next_buffer() to have set up - * pmix_show_help_yytext, we can now set up - * yy_c_buf_p so that if some total - * hoser (like flex itself) wants to - * call the scanner after we return the - * YY_NULL, it'll still work - another - * YY_NULL will get returned. - */ - (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; - - yy_act = YY_STATE_EOF(YY_START); - goto do_action; - } - - else - { - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; - } - break; - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = - (yytext_ptr) + yy_amount_of_matched_text; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_match; - - case EOB_ACT_LAST_MATCH: - (yy_c_buf_p) = - &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; - - yy_current_state = yy_get_previous_state( ); - - yy_cp = (yy_c_buf_p); - yy_bp = (yytext_ptr) + YY_MORE_ADJ; - goto yy_find_action; - } - break; - } - - default: - YY_FATAL_ERROR( - "fatal flex scanner internal error--no action found" ); - } /* end of action switch */ - } /* end of scanning one token */ -} /* end of pmix_show_help_yylex */ - -/* yy_get_next_buffer - try to read in a new buffer - * - * Returns a code representing an action: - * EOB_ACT_LAST_MATCH - - * EOB_ACT_CONTINUE_SCAN - continue scanning from current position - * EOB_ACT_END_OF_FILE - end of file - */ -static int yy_get_next_buffer (void) -{ - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = (yytext_ptr); - register int number_to_move, i; - int ret_val; - - if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) - YY_FATAL_ERROR( - "fatal flex scanner internal error--end of buffer missed" ); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) - { /* Don't try to fill the buffer, so this is an EOF. */ - if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) - { - /* We matched a single character, the EOB, so - * treat this as a final EOF. - */ - return EOB_ACT_END_OF_FILE; - } - - else - { - /* We matched some text prior to the EOB, first - * process it. - */ - return EOB_ACT_LAST_MATCH; - } - } - - /* Try to read more data. */ - - /* First move last chars to start of buffer. */ - number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; - - for ( i = 0; i < number_to_move; ++i ) - *(dest++) = *(source++); - - if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) - /* don't do the read, it's not guaranteed to return an EOF, - * just force an EOF - */ - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; - - else - { - yy_size_t num_to_read = - YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; - - while ( num_to_read <= 0 ) - { /* Not enough room in the buffer - grow it. */ - - YY_FATAL_ERROR( -"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); - - } - - if ( num_to_read > YY_READ_BUF_SIZE ) - num_to_read = YY_READ_BUF_SIZE; - - /* Read in more data. */ - YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), num_to_read ); - - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - if ( (yy_n_chars) == 0 ) - { - if ( number_to_move == YY_MORE_ADJ ) - { - ret_val = EOB_ACT_END_OF_FILE; - pmix_show_help_yyrestart(pmix_show_help_yyin ); - } - - else - { - ret_val = EOB_ACT_LAST_MATCH; - YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = - YY_BUFFER_EOF_PENDING; - } - } - - else - ret_val = EOB_ACT_CONTINUE_SCAN; - - if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { - /* Extend the array by 50%, plus the number we really need. */ - yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) pmix_show_help_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); - if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); - } - - (yy_n_chars) += number_to_move; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; - - (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; - - return ret_val; -} - -/* yy_get_previous_state - get the state just before the EOB char was reached */ - - static yy_state_type yy_get_previous_state (void) -{ - register yy_state_type yy_current_state; - register char *yy_cp; - - yy_current_state = (yy_start); - yy_current_state += YY_AT_BOL(); - - (yy_state_ptr) = (yy_state_buf); - *(yy_state_ptr)++ = yy_current_state; - - for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) - { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 23 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - *(yy_state_ptr)++ = yy_current_state; - } - - return yy_current_state; -} - -/* yy_try_NUL_trans - try to make a transition on the NUL character - * - * synopsis - * next_state = yy_try_NUL_trans( current_state ); - */ - static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) -{ - register int yy_is_jam; - - register YY_CHAR yy_c = 1; - while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) - { - yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 23 ) - yy_c = yy_meta[(unsigned int) yy_c]; - } - yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; - yy_is_jam = (yy_current_state == 22); - if ( ! yy_is_jam ) - *(yy_state_ptr)++ = yy_current_state; - - return yy_is_jam ? 0 : yy_current_state; -} - -#ifndef YY_NO_INPUT -#ifdef __cplusplus - static int yyinput (void) -#else - static int input (void) -#endif - -{ - int c; - - *(yy_c_buf_p) = (yy_hold_char); - - if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) - { - /* yy_c_buf_p now points to the character we want to return. - * If this occurs *before* the EOB characters, then it's a - * valid NUL; if not, then we've hit the end of the buffer. - */ - if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) - /* This was really a NUL. */ - *(yy_c_buf_p) = '\0'; - - else - { /* need more input */ - yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); - ++(yy_c_buf_p); - - switch ( yy_get_next_buffer( ) ) - { - case EOB_ACT_LAST_MATCH: - /* This happens because yy_g_n_b() - * sees that we've accumulated a - * token and flags that we need to - * try matching the token before - * proceeding. But for input(), - * there's no matching to consider. - * So convert the EOB_ACT_LAST_MATCH - * to EOB_ACT_END_OF_FILE. - */ - - /* Reset buffer status. */ - pmix_show_help_yyrestart(pmix_show_help_yyin ); - - /*FALLTHROUGH*/ - - case EOB_ACT_END_OF_FILE: - { - if ( pmix_show_help_yywrap( ) ) - return EOF; - - if ( ! (yy_did_buffer_switch_on_eof) ) - YY_NEW_FILE; -#ifdef __cplusplus - return yyinput(); -#else - return input(); -#endif - } - - case EOB_ACT_CONTINUE_SCAN: - (yy_c_buf_p) = (yytext_ptr) + offset; - break; - } - } - } - - c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ - *(yy_c_buf_p) = '\0'; /* preserve pmix_show_help_yytext */ - (yy_hold_char) = *++(yy_c_buf_p); - - YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); - - return c; -} -#endif /* ifndef YY_NO_INPUT */ - -/** Immediately switch to a different input stream. - * @param input_file A readable stream. - * - * @note This function does not reset the start condition to @c INITIAL . - */ - void pmix_show_help_yyrestart (FILE * input_file ) -{ - - if ( ! YY_CURRENT_BUFFER ){ - pmix_show_help_yyensure_buffer_stack (); - YY_CURRENT_BUFFER_LVALUE = - pmix_show_help_yy_create_buffer(pmix_show_help_yyin,YY_BUF_SIZE ); - } - - pmix_show_help_yy_init_buffer(YY_CURRENT_BUFFER,input_file ); - pmix_show_help_yy_load_buffer_state( ); -} - -/** Switch to a different input buffer. - * @param new_buffer The new input buffer. - * - */ - void pmix_show_help_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) -{ - - /* TODO. We should be able to replace this entire function body - * with - * pmix_show_help_yypop_buffer_state(); - * pmix_show_help_yypush_buffer_state(new_buffer); - */ - pmix_show_help_yyensure_buffer_stack (); - if ( YY_CURRENT_BUFFER == new_buffer ) - return; - - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - YY_CURRENT_BUFFER_LVALUE = new_buffer; - pmix_show_help_yy_load_buffer_state( ); - - /* We don't actually know whether we did this switch during - * EOF (pmix_show_help_yywrap()) processing, but the only time this flag - * is looked at is after pmix_show_help_yywrap() is called, so it's safe - * to go ahead and always set it. - */ - (yy_did_buffer_switch_on_eof) = 1; -} - -static void pmix_show_help_yy_load_buffer_state (void) -{ - (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; - (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; - pmix_show_help_yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; - (yy_hold_char) = *(yy_c_buf_p); -} - -/** Allocate and initialize an input buffer state. - * @param file A readable stream. - * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * - * @return the allocated buffer state. - */ - YY_BUFFER_STATE pmix_show_help_yy_create_buffer (FILE * file, int size ) -{ - YY_BUFFER_STATE b; - - b = (YY_BUFFER_STATE) pmix_show_help_yyalloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in pmix_show_help_yy_create_buffer()" ); - - b->yy_buf_size = size; - - /* yy_ch_buf has to be 2 characters longer than the size given because - * we need to put in 2 end-of-buffer characters. - */ - b->yy_ch_buf = (char *) pmix_show_help_yyalloc(b->yy_buf_size + 2 ); - if ( ! b->yy_ch_buf ) - YY_FATAL_ERROR( "out of dynamic memory in pmix_show_help_yy_create_buffer()" ); - - b->yy_is_our_buffer = 1; - - pmix_show_help_yy_init_buffer(b,file ); - - return b; -} - -/** Destroy the buffer. - * @param b a buffer created with pmix_show_help_yy_create_buffer() - * - */ - void pmix_show_help_yy_delete_buffer (YY_BUFFER_STATE b ) -{ - - if ( ! b ) - return; - - if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ - YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; - - if ( b->yy_is_our_buffer ) - pmix_show_help_yyfree((void *) b->yy_ch_buf ); - - pmix_show_help_yyfree((void *) b ); -} - -/* Initializes or reinitializes a buffer. - * This function is sometimes called more than once on the same buffer, - * such as during a pmix_show_help_yyrestart() or at EOF. - */ - static void pmix_show_help_yy_init_buffer (YY_BUFFER_STATE b, FILE * file ) - -{ - int oerrno = errno; - - pmix_show_help_yy_flush_buffer(b ); - - b->yy_input_file = file; - b->yy_fill_buffer = 1; - - /* If b is the current buffer, then pmix_show_help_yy_init_buffer was _probably_ - * called from pmix_show_help_yyrestart() or through yy_get_next_buffer. - * In that case, we don't want to reset the lineno or column. - */ - if (b != YY_CURRENT_BUFFER){ - b->yy_bs_lineno = 1; - b->yy_bs_column = 0; - } - - b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - - errno = oerrno; -} - -/** Discard all buffered characters. On the next scan, YY_INPUT will be called. - * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * - */ - void pmix_show_help_yy_flush_buffer (YY_BUFFER_STATE b ) -{ - if ( ! b ) - return; - - b->yy_n_chars = 0; - - /* We always need two end-of-buffer characters. The first causes - * a transition to the end-of-buffer state. The second causes - * a jam in that state. - */ - b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; - b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; - - b->yy_buf_pos = &b->yy_ch_buf[0]; - - b->yy_at_bol = 1; - b->yy_buffer_status = YY_BUFFER_NEW; - - if ( b == YY_CURRENT_BUFFER ) - pmix_show_help_yy_load_buffer_state( ); -} - -/** Pushes the new state onto the stack. The new state becomes - * the current state. This function will allocate the stack - * if necessary. - * @param new_buffer The new state. - * - */ -void pmix_show_help_yypush_buffer_state (YY_BUFFER_STATE new_buffer ) -{ - if (new_buffer == NULL) - return; - - pmix_show_help_yyensure_buffer_stack(); - - /* This block is copied from pmix_show_help_yy_switch_to_buffer. */ - if ( YY_CURRENT_BUFFER ) - { - /* Flush out information for old buffer. */ - *(yy_c_buf_p) = (yy_hold_char); - YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); - YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); - } - - /* Only push if top exists. Otherwise, replace top. */ - if (YY_CURRENT_BUFFER) - (yy_buffer_stack_top)++; - YY_CURRENT_BUFFER_LVALUE = new_buffer; - - /* copied from pmix_show_help_yy_switch_to_buffer. */ - pmix_show_help_yy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; -} - -/** Removes and deletes the top of the stack, if present. - * The next element becomes the new top. - * - */ -void pmix_show_help_yypop_buffer_state (void) -{ - if (!YY_CURRENT_BUFFER) - return; - - pmix_show_help_yy_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - if ((yy_buffer_stack_top) > 0) - --(yy_buffer_stack_top); - - if (YY_CURRENT_BUFFER) { - pmix_show_help_yy_load_buffer_state( ); - (yy_did_buffer_switch_on_eof) = 1; - } -} - -/* Allocates the stack if it does not exist. - * Guarantees space for at least one push. - */ -static void pmix_show_help_yyensure_buffer_stack (void) -{ - yy_size_t num_to_alloc; - - if (!(yy_buffer_stack)) { - - /* First allocation is just for 2 elements, since we don't know if this - * scanner will even need a stack. We use 2 instead of 1 to avoid an - * immediate realloc on the next call. - */ - num_to_alloc = 1; - (yy_buffer_stack) = (struct yy_buffer_state**)pmix_show_help_yyalloc - (num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in pmix_show_help_yyensure_buffer_stack()" ); - - memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - - (yy_buffer_stack_max) = num_to_alloc; - (yy_buffer_stack_top) = 0; - return; - } - - if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ - - /* Increase the buffer to prepare for a possible push. */ - int grow_size = 8 /* arbitrary grow size */; - - num_to_alloc = (yy_buffer_stack_max) + grow_size; - (yy_buffer_stack) = (struct yy_buffer_state**)pmix_show_help_yyrealloc - ((yy_buffer_stack), - num_to_alloc * sizeof(struct yy_buffer_state*) - ); - if ( ! (yy_buffer_stack) ) - YY_FATAL_ERROR( "out of dynamic memory in pmix_show_help_yyensure_buffer_stack()" ); - - /* zero only the new slots.*/ - memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); - (yy_buffer_stack_max) = num_to_alloc; - } -} - -/** Setup the input buffer state to scan directly from a user-specified character buffer. - * @param base the character buffer - * @param size the size in bytes of the character buffer - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE pmix_show_help_yy_scan_buffer (char * base, yy_size_t size ) -{ - YY_BUFFER_STATE b; - - if ( size < 2 || - base[size-2] != YY_END_OF_BUFFER_CHAR || - base[size-1] != YY_END_OF_BUFFER_CHAR ) - /* They forgot to leave room for the EOB's. */ - return 0; - - b = (YY_BUFFER_STATE) pmix_show_help_yyalloc(sizeof( struct yy_buffer_state ) ); - if ( ! b ) - YY_FATAL_ERROR( "out of dynamic memory in pmix_show_help_yy_scan_buffer()" ); - - b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ - b->yy_buf_pos = b->yy_ch_buf = base; - b->yy_is_our_buffer = 0; - b->yy_input_file = 0; - b->yy_n_chars = b->yy_buf_size; - b->yy_is_interactive = 0; - b->yy_at_bol = 1; - b->yy_fill_buffer = 0; - b->yy_buffer_status = YY_BUFFER_NEW; - - pmix_show_help_yy_switch_to_buffer(b ); - - return b; -} - -/** Setup the input buffer state to scan a string. The next call to pmix_show_help_yylex() will - * scan from a @e copy of @a str. - * @param yystr a NUL-terminated string to scan - * - * @return the newly allocated buffer state object. - * @note If you want to scan bytes that may contain NUL values, then use - * pmix_show_help_yy_scan_bytes() instead. - */ -YY_BUFFER_STATE pmix_show_help_yy_scan_string (yyconst char * yystr ) -{ - - return pmix_show_help_yy_scan_bytes(yystr,strlen(yystr) ); -} - -/** Setup the input buffer state to scan the given bytes. The next call to pmix_show_help_yylex() will - * scan from a @e copy of @a bytes. - * @param yybytes the byte buffer to scan - * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. - * - * @return the newly allocated buffer state object. - */ -YY_BUFFER_STATE pmix_show_help_yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ) -{ - YY_BUFFER_STATE b; - char *buf; - yy_size_t n; - int i; - - /* Get memory for full buffer, including space for trailing EOB's. */ - n = _yybytes_len + 2; - buf = (char *) pmix_show_help_yyalloc(n ); - if ( ! buf ) - YY_FATAL_ERROR( "out of dynamic memory in pmix_show_help_yy_scan_bytes()" ); - - for ( i = 0; i < _yybytes_len; ++i ) - buf[i] = yybytes[i]; - - buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; - - b = pmix_show_help_yy_scan_buffer(buf,n ); - if ( ! b ) - YY_FATAL_ERROR( "bad buffer in pmix_show_help_yy_scan_bytes()" ); - - /* It's okay to grow etc. this buffer, and we should throw it - * away when we're done. - */ - b->yy_is_our_buffer = 1; - - return b; -} - -#ifndef YY_EXIT_FAILURE -#define YY_EXIT_FAILURE 2 -#endif - -static void yy_fatal_error (yyconst char* msg ) -{ - (void) fprintf( stderr, "%s\n", msg ); - exit( YY_EXIT_FAILURE ); -} - -/* Redefine yyless() so it works in section 3 code. */ - -#undef yyless -#define yyless(n) \ - do \ - { \ - /* Undo effects of setting up pmix_show_help_yytext. */ \ - int yyless_macro_arg = (n); \ - YY_LESS_LINENO(yyless_macro_arg);\ - pmix_show_help_yytext[pmix_show_help_yyleng] = (yy_hold_char); \ - (yy_c_buf_p) = pmix_show_help_yytext + yyless_macro_arg; \ - (yy_hold_char) = *(yy_c_buf_p); \ - *(yy_c_buf_p) = '\0'; \ - pmix_show_help_yyleng = yyless_macro_arg; \ - } \ - while ( 0 ) - -/* Accessor methods (get/set functions) to struct members. */ - -/** Get the current line number. - * - */ -int pmix_show_help_yyget_lineno (void) -{ - - return pmix_show_help_yylineno; -} - -/** Get the input stream. - * - */ -FILE *pmix_show_help_yyget_in (void) -{ - return pmix_show_help_yyin; -} - -/** Get the output stream. - * - */ -FILE *pmix_show_help_yyget_out (void) -{ - return pmix_show_help_yyout; -} - -/** Get the length of the current token. - * - */ -yy_size_t pmix_show_help_yyget_leng (void) -{ - return pmix_show_help_yyleng; -} - -/** Get the current token. - * - */ - -char *pmix_show_help_yyget_text (void) -{ - return pmix_show_help_yytext; -} - -/** Set the current line number. - * @param line_number - * - */ -void pmix_show_help_yyset_lineno (int line_number ) -{ - - pmix_show_help_yylineno = line_number; -} - -/** Set the input stream. This does not discard the current - * input buffer. - * @param in_str A readable stream. - * - * @see pmix_show_help_yy_switch_to_buffer - */ -void pmix_show_help_yyset_in (FILE * in_str ) -{ - pmix_show_help_yyin = in_str ; -} - -void pmix_show_help_yyset_out (FILE * out_str ) -{ - pmix_show_help_yyout = out_str ; -} - -int pmix_show_help_yyget_debug (void) -{ - return pmix_show_help_yy_flex_debug; -} - -void pmix_show_help_yyset_debug (int bdebug ) -{ - pmix_show_help_yy_flex_debug = bdebug ; -} - -static int yy_init_globals (void) -{ - /* Initialization is the same as for the non-reentrant scanner. - * This function is called from pmix_show_help_yylex_destroy(), so don't allocate here. - */ - - (yy_buffer_stack) = 0; - (yy_buffer_stack_top) = 0; - (yy_buffer_stack_max) = 0; - (yy_c_buf_p) = (char *) 0; - (yy_init) = 0; - (yy_start) = 0; - - (yy_state_buf) = 0; - (yy_state_ptr) = 0; - (yy_full_match) = 0; - (yy_lp) = 0; - -/* Defined in main.c */ -#ifdef YY_STDINIT - pmix_show_help_yyin = stdin; - pmix_show_help_yyout = stdout; -#else - pmix_show_help_yyin = (FILE *) 0; - pmix_show_help_yyout = (FILE *) 0; -#endif - - /* For future reference: Set errno on error, since we are called by - * pmix_show_help_yylex_init() - */ - return 0; -} - -/* pmix_show_help_yylex_destroy is for both reentrant and non-reentrant scanners. */ -int pmix_show_help_yylex_destroy (void) -{ - - /* Pop the buffer stack, destroying each element. */ - while(YY_CURRENT_BUFFER){ - pmix_show_help_yy_delete_buffer(YY_CURRENT_BUFFER ); - YY_CURRENT_BUFFER_LVALUE = NULL; - pmix_show_help_yypop_buffer_state(); - } - - /* Destroy the stack itself. */ - pmix_show_help_yyfree((yy_buffer_stack) ); - (yy_buffer_stack) = NULL; - - pmix_show_help_yyfree ( (yy_state_buf) ); - (yy_state_buf) = NULL; - - /* Reset the globals. This is important in a non-reentrant scanner so the next time - * pmix_show_help_yylex() is called, initialization will occur. */ - yy_init_globals( ); - - return 0; -} - -/* - * Internal utility routines. - */ - -#ifndef yytext_ptr -static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) -{ - register int i; - for ( i = 0; i < n; ++i ) - s1[i] = s2[i]; -} -#endif - -#ifdef YY_NEED_STRLEN -static int yy_flex_strlen (yyconst char * s ) -{ - register int n; - for ( n = 0; s[n]; ++n ) - ; - - return n; -} -#endif - -void *pmix_show_help_yyalloc (yy_size_t size ) -{ - return (void *) malloc( size ); -} - -void *pmix_show_help_yyrealloc (void * ptr, yy_size_t size ) -{ - /* The cast to (char *) in the following accommodates both - * implementations that use char* generic pointers, and those - * that use void* generic pointers. It works with the latter - * because both ANSI C and C++ allow castless assignment from - * any pointer type to void*, and deal with argument conversions - * as though doing an assignment. - */ - return (void *) realloc( (char *) ptr, size ); -} - -void pmix_show_help_yyfree (void * ptr ) -{ - free( (char *) ptr ); /* see pmix_show_help_yyrealloc() for (char *) cast */ -} - -#define YYTABLES_NAME "yytables" - -#line 70 "util/show_help_lex.l" - - - -/* Old flex (2.5.4a? and older) does not define a destroy function */ -#if !defined(YY_FLEX_SUBMINOR_VERSION) -#define YY_FLEX_SUBMINOR_VERSION 0 -#endif - -#if (YY_FLEX_MAJOR_VERSION < 2) || (YY_FLEX_MAJOR_VERSION == 2 && (YY_FLEX_MINOR_VERSION < 5 || (YY_FLEX_MINOR_VERSION == 5 && YY_FLEX_SUBMINOR_VERSION < 5))) -int pmix_show_help_yylex_destroy(void) -{ - if (NULL != YY_CURRENT_BUFFER) { - pmix_show_help_yy_delete_buffer(YY_CURRENT_BUFFER); -#if defined(YY_CURRENT_BUFFER_LVALUE) - YY_CURRENT_BUFFER_LVALUE = NULL; -#else - YY_CURRENT_BUFFER = NULL; -#endif /* YY_CURRENT_BUFFER_LVALUE */ - } - return YY_NULL; -} -#endif - -static int pmix_show_help_yywrap(void) -{ - pmix_show_help_parse_done = true; - return 1; -} - - -/* - * Ensure that we have a valid yybuffer to use. Specifically, if this - * scanner is invoked a second time, finish_parsing() (above) will - * have been executed, and the current buffer will have been freed. - * Flex doesn't recognize this fact because as far as it's concerned, - * its internal state was already initialized, so it thinks it should - * have a valid buffer. Hence, here we ensure to give it a valid - * buffer. - */ -int pmix_show_help_init_buffer(FILE *file) -{ - YY_BUFFER_STATE buf = pmix_show_help_yy_create_buffer(file,YY_BUF_SIZE); - pmix_show_help_yy_switch_to_buffer(buf); - - return 0; -} -