PIPS
activate_extensions_bc.c
Go to the documentation of this file.
1 /*
2 
3  $Id: activate_extensions_bc.c 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 #ifdef HAVE_CONFIG_H
25  #include "pips_config.h"
26 #endif
27 /* static bool rule_multi_produced_consistent_p(rule mp_rule, makefile make_file)
28  * input : a rule that produces more than one resource and a the current makefile
29  * output : true if the others rules of the make file that produce at least
30  * one of the resource that mp_rule produces, produce exactly the
31  * same resources, or if no other rule produces the same resources.
32  * false otherwise.
33  * modifies : nothing
34  * comment :
35  */
36 static bool rule_multi_produced_consistent_p(mp_rule, make_file)
37 rule mp_rule;
38 makefile make_file;
39 {
40  static bool rule_produced_consistent_p(rule rule_1, rule rule_2);
41  list all_rules = makefile_rules(make_file);
42  rule c_rule = rule_undefined;
43  bool consistent = true;
44 
45 
46  while (consistent && !ENDP(all_rules)) {
47  c_rule = RULE(CAR(all_rules));
48 
49  if ( (c_rule != mp_rule)
50  && !rule_produced_consistent_p(mp_rule, c_rule))
51  consistent = false;
52  all_rules = CDR(all_rules);
53  }
54 
55  return(consistent);
56 
57 }
58 
59 
60 /* static bool rule_produced_consistent_p(rule rule_1, rule_2)
61  * input : two rules
62  * output : true if they produce exactly the same resources, or if
63  * they produce no common resource. false otherwise.
64  * modifies : nothing.
65  * comment :
66  */
67 static bool rule_produced_consistent_p(rule_1, rule_2)
68 rule rule_1, rule_2;
69 {
70  list l_prod1 = rule_produced(rule_1);
71  list l_prod2 = rule_produced(rule_2);
72  list l2;
73  bool consistent = true;
74  bool first_common = true;
75  bool first = true;
76  bool same_length = (gen_length(l_prod1) == gen_length(l_prod2));
77  string vr1, vr2;
78 
79  while (consistent && !ENDP(l_prod1)) {
80 
81  bool found = false;
83  l2 = l_prod2;
84 
85  while (!found && !ENDP(l2)) {
87  if (same_string_p(vr1,vr2))
88  found = true;
89  else
90  l2 = CDR(l2);
91  }
92 
93 
94  if (first && !found ) first_common = false;
95  if (first) first = false;
96 
97  consistent = (first_common && found && same_length) || (!first_common && !found);
98 
99  l_prod1 = CDR(l_prod1);
100  }
101  return(consistent);
102 }
103 
104 
static bool rule_multi_produced_consistent_p(rule mp_rule, makefile make_file)
static bool rule_multi_produced_consistent_p(rule mp_rule, makefile make_file) input : a rule that pr...
static bool rule_produced_consistent_p(rule rule_1, rule rule_2)
static bool rule_produced_consistent_p(rule rule_1, rule_2) input : two rules output : true if they p...
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
size_t gen_length(const list l)
Definition: list.c:150
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
#define RULE(x)
RULE.
Definition: makefile.h:209
#define rule_undefined
Definition: makefile.h:215
#define virtual_resource_name(x)
Definition: makefile.h:290
#define rule_produced(x)
Definition: makefile.h:248
#define VIRTUAL_RESOURCE(x)
VIRTUAL_RESOURCE.
Definition: makefile.h:260
#define makefile_rules(x)
Definition: makefile.h:82
#define same_string_p(s1, s2)
The structure used to build lists in NewGen.
Definition: newgen_list.h:41