File: rtc_base_stubs.c

package info (click to toggle)
openmpi 3.1.3-11
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 118,572 kB
  • sloc: ansic: 628,972; f90: 17,993; makefile: 13,761; sh: 7,051; java: 6,360; perl: 3,215; cpp: 2,225; python: 1,350; lex: 988; fortran: 52; tcl: 12
file content (139 lines) | stat: -rw-r--r-- 3,623 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
 * Copyright (c) 2014      Intel, Inc.  All rights reserved.
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */


#include "orte_config.h"

#include "opal/util/fd.h"
#include "opal/util/show_help.h"

#include "orte/mca/errmgr/errmgr.h"
#include "orte/mca/odls/odls_types.h"

#include "orte/mca/rtc/base/base.h"

void orte_rtc_base_assign(orte_job_t *jdata)
{
    orte_rtc_base_selected_module_t *active;

    OPAL_LIST_FOREACH(active, &orte_rtc_base.actives, orte_rtc_base_selected_module_t) {
        if (NULL != active->module->assign) {
            /* give this module a chance to operate on it */
            active->module->assign(jdata);
        }
    }
}

void orte_rtc_base_set(orte_job_t *jdata, orte_proc_t *proc,
                       char ***environ_copy, int error_fd)
{
    orte_rtc_base_selected_module_t *active;

    OPAL_LIST_FOREACH(active, &orte_rtc_base.actives, orte_rtc_base_selected_module_t) {
        if (NULL != active->module->set) {
            /* give this module a chance to operate on it */
            active->module->set(jdata, proc, environ_copy, error_fd);
        }
    }
}

void orte_rtc_base_get_avail_vals(opal_list_t *vals)
{
    orte_rtc_base_selected_module_t *active;

    OPAL_LIST_FOREACH(active, &orte_rtc_base.actives, orte_rtc_base_selected_module_t) {
        if (NULL != active->module->get_available_values) {
            /* give this module a chance to operate on it */
            active->module->get_available_values(vals);
        }
    }
}


static int write_help_msg(int fd, orte_odls_pipe_err_msg_t *msg, const char *file,
                          const char *topic, va_list ap)
{
    int ret;
    char *str;

    if (NULL == file || NULL == topic) {
        return OPAL_ERR_BAD_PARAM;
    }

    str = opal_show_help_vstring(file, topic, true, ap);

    msg->file_str_len = (int) strlen(file);
    if (msg->file_str_len > ORTE_ODLS_MAX_FILE_LEN) {
        ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
        return ORTE_ERR_BAD_PARAM;
    }
    msg->topic_str_len = (int) strlen(topic);
    if (msg->topic_str_len > ORTE_ODLS_MAX_TOPIC_LEN) {
        ORTE_ERROR_LOG(ORTE_ERR_BAD_PARAM);
        return ORTE_ERR_BAD_PARAM;
    }
    msg->msg_str_len = (int) strlen(str);

    /* Only keep writing if each write() succeeds */
    if (OPAL_SUCCESS != (ret = opal_fd_write(fd, sizeof(*msg), msg))) {
        goto out;
    }
    if (msg->file_str_len > 0 &&
        OPAL_SUCCESS != (ret = opal_fd_write(fd, msg->file_str_len, file))) {
        goto out;
    }
    if (msg->topic_str_len > 0 &&
        OPAL_SUCCESS != (ret = opal_fd_write(fd, msg->topic_str_len, topic))) {
        goto out;
    }
    if (msg->msg_str_len > 0 &&
        OPAL_SUCCESS != (ret = opal_fd_write(fd, msg->msg_str_len, str))) {
        goto out;
    }

 out:
    free(str);
    return ret;
}

int orte_rtc_base_send_warn_show_help(int fd, const char *file,
                                      const char *topic, ...)
{
    int ret;
    va_list ap;
    orte_odls_pipe_err_msg_t msg;

    msg.fatal = false;
    msg.exit_status = 0; /* ignored */

    /* Send it */
    va_start(ap, topic);
    ret = write_help_msg(fd, &msg, file, topic, ap);
    va_end(ap);

    return ret;
}

void orte_rtc_base_send_error_show_help(int fd, int exit_status,
                                        const char *file, const char *topic, ...)
{
    va_list ap;
    orte_odls_pipe_err_msg_t msg;

    msg.fatal = true;
    msg.exit_status = exit_status;

    /* Send it */
    va_start(ap, topic);
    write_help_msg(fd, &msg, file, topic, ap);
    va_end(ap);

    exit(exit_status);
}