File: patcher_base_frame.c

package info (click to toggle)
openmpi 4.1.0-10
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 126,560 kB
  • sloc: ansic: 685,465; makefile: 42,952; f90: 19,220; sh: 7,002; java: 6,360; perl: 3,524; cpp: 2,227; python: 1,350; lex: 989; fortran: 61; tcl: 12
file content (81 lines) | stat: -rw-r--r-- 2,157 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
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 2016      Los Alamos National Security, LLC. All rights
 *                         reserved.
 * $COPYRIGHT$
 *
 * Additional copyrights may follow
 *
 * $HEADER$
 */

#include "opal_config.h"

#include "opal/mca/patcher/patcher.h"
#include "opal/mca/patcher/base/base.h"
#include "opal/mca/patcher/base/static-components.h"

/*
 * Local variables
 */
static mca_patcher_base_module_t empty_module;

/*
 * Globals
 */
mca_patcher_base_module_t *opal_patcher = &empty_module;

int opal_patcher_base_select (void)
{
    mca_patcher_base_module_t *best_module;
    mca_patcher_base_component_t *best_component;
    int rc, priority;

    rc = mca_base_select ("patcher", opal_patcher_base_framework.framework_output,
                          &opal_patcher_base_framework.framework_components,
                          (mca_base_module_t **) &best_module, (mca_base_component_t **) &best_component,
                          &priority);
    if (OPAL_SUCCESS != rc) {
        return rc;
    }

    OBJ_CONSTRUCT(&best_module->patch_list, opal_list_t);
    OBJ_CONSTRUCT(&best_module->patch_list_mutex, opal_mutex_t);

    if (best_module->patch_init) {
        rc = best_module->patch_init ();
        if (OPAL_SUCCESS != rc) {
            return rc;
        }
    }

    opal_patcher = best_module;

    return OPAL_SUCCESS;
}

static int opal_patcher_base_close (void)
{
    if (opal_patcher == &empty_module) {
        return OPAL_SUCCESS;
    }

    mca_patcher_base_patch_t *patch;
    OPAL_LIST_FOREACH_REV(patch, &opal_patcher->patch_list, mca_patcher_base_patch_t) {
        patch->patch_restore (patch);
    }

    OPAL_LIST_DESTRUCT(&opal_patcher->patch_list);
    OBJ_DESTRUCT(&opal_patcher->patch_list_mutex);

    if (opal_patcher->patch_fini) {
        return opal_patcher->patch_fini ();
    }

    return OPAL_SUCCESS;
}

/* Use default register/open functions */
MCA_BASE_FRAMEWORK_DECLARE(opal, patcher, "runtime code patching", NULL, NULL,
                           opal_patcher_base_close, mca_patcher_base_static_components,
                           0);