* pt.c (tsubst_decl <FUNCTION_DECL>): Move var decls to
[official-gcc.git] / liboffloadmic / runtime / offload_env.h
blob166b5d9242df3adbfe32420d4841dbbd2d61fb71
1 /*
2 Copyright (c) 2014-2016 Intel Corporation. All Rights Reserved.
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions
6 are met:
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10 * Redistributions in binary form must reproduce the above copyright
11 notice, this list of conditions and the following disclaimer in the
12 documentation and/or other materials provided with the distribution.
13 * Neither the name of Intel Corporation nor the names of its
14 contributors may be used to endorse or promote products derived
15 from this software without specific prior written permission.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef OFFLOAD_ENV_H_INCLUDED
32 #define OFFLOAD_ENV_H_INCLUDED
34 #include <list>
35 #include "offload_util.h"
37 // data structure and routines to parse MIC user environment and pass to MIC
39 enum MicEnvVarKind
41 c_no_mic, // not MIC env var
42 c_mic_var, // for <mic-prefix>_<var>
43 c_mic_card_var, // for <mic-prefix>_<card-number>_<var>
44 c_mic_card_env // for <mic-prefix>_<card-number>_ENV
47 struct DLL_LOCAL MicEnvVar {
48 public:
49 MicEnvVar() : prefix(0) {}
50 ~MicEnvVar();
52 void analyze_env_var(char *env_var_string);
53 char** create_environ_for_card(int card_num);
54 MicEnvVarKind get_env_var_kind(
55 char *env_var_string,
56 int *card_number,
57 char **env_var_name,
58 int *env_var_name_length,
59 char **env_var_def
61 void add_env_var(
62 int card_number,
63 char *env_var_name,
64 int env_var_name_length,
65 char *env_var_def
68 void set_prefix(const char *pref) {
69 prefix = (pref && *pref != '\0') ? pref : 0;
72 struct VarValue {
73 public:
74 char* env_var;
75 int length;
76 char* env_var_value;
78 VarValue(char* var, int ln, char* value)
80 env_var = var;
81 length = ln;
82 env_var_value = value;
84 ~VarValue();
87 struct CardEnvVars {
88 public:
90 int card_number;
91 std::list<struct VarValue*> env_vars;
93 CardEnvVars() { card_number = any_card; }
94 CardEnvVars(int num) { card_number = num; }
95 ~CardEnvVars();
97 void add_new_env_var(int number, char *env_var, int length,
98 char *env_var_value);
99 VarValue* find_var(char* env_var_name, int env_var_name_length);
101 static const int any_card;
103 private:
104 void mic_parse_env_var_list(int card_number, char *env_var_def);
105 CardEnvVars* get_card(int number);
107 const char *prefix;
108 std::list<struct CardEnvVars *> card_spec_list;
109 CardEnvVars common_vars;
112 #endif // OFFLOAD_ENV_H_INCLUDED