OpenADFortTk (including Open64 and OpenAnalysis references)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
x_set_macro.h
Go to the documentation of this file.
1 /*
2 
3  Copyright (C) 2000, 2001 Silicon Graphics, Inc. All Rights Reserved.
4 
5  This program is free software; you can redistribute it and/or modify it
6  under the terms of version 2 of the GNU General Public License as
7  published by the Free Software Foundation.
8 
9  This program is distributed in the hope that it would be useful, but
10  WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 
13  Further, this software is distributed without any warranty that it is
14  free of the rightful claim of any third person regarding infringement
15  or the like. Any license provided herein, whether implied or
16  otherwise, applies only to this software file. Patent licenses, if
17  any, provided herein do not apply to combinations of this program with
18  other software, or any other product whatsoever.
19 
20  You should have received a copy of the GNU General Public License along
21  with this program; if not, write the Free Software Foundation, Inc., 59
22  Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 
24  Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pky,
25  Mountain View, CA 94043, or:
26 
27  http://www.sgi.com
28 
29  For further information regarding this notice, see:
30 
31  http://oss.sgi.com/projects/GenInfo/NoticeExplan
32 
33 */
34 
35 
36 /* ====================================================================
37  * ====================================================================
38  *
39  *
40  * Revision history:
41  * 05-05-93 - Original Version
42  *
43  * Description:
44  *
45  * Template for macro interface to sets of objects. This is
46  * processed by common/util/gen_x_set into a particular
47  * instantiation for a particular base type. See below for a
48  * complete interface documentation.
49  *
50  * ====================================================================
51  * ====================================================================
52  */
53 
54 BEGIN
55 
56 #ifndef #uset#_INCLUDED
57 #define #uset#_INCLUDED
58 #ifdef __cplusplus
59 extern "C" {
60 #endif
61 
62 
63 #include "bitset.h" /* our clients do not need to know about it */
64 
65 typedef BS #uset#;
66 
67 BEGIN SUBUNIVERSES
68 class #uset#_SUBUNIVERSE;
69 END SUBUNIVERSES
70 
71 #define #uset#_CHOOSE_FAILURE ((#base_type#)BS_CHOOSE_FAILURE)
72 
73 /* This macro will maps BS_ELTs to their corresponding base_type elements,
74  * allowing for the possibility that #num_elt# may not be defined on
75  * BS_CHOOSE_FAILURE and maintaining the mapping from BS_CHOOSE_FAILURE to
76  * #uset#_CHOOSE_FAILURE. In other words:
77  *
78  * #uset#_bs_elt_bas_type(x) ==>
79  * #uset#_CHOOSE_FAILURE if x == BS_CHOOSE_FAILURE
80  * #num_elt#(x) otherwise
81  *
82  * The complexity arises from the possibility that x may be an expression,
83  * instead of a simple variable. In that case we can't evaluate it twice,
84  * since it may have side effects or be expensive to evaluate. So we'll
85  * assign it to a file scoped static and select the result depending on
86  * whether it's a choose failure. Not so great, huh?
87  *
88  * TODO: Allow an optional straightforward implementation for mappings that
89  * map BS_CHOOSE_FAILURE to #uset#_CHOOSE_FAILURE.
90  */
91 inline #base_type#
92 #uset#_bs_elt_base_type( BS_ELT x )
93 {
94  if ( x == BS_CHOOSE_FAILURE )
95  return #uset#_CHOOSE_FAILURE;
96  else
97  return #num_elt#(x);
98 }
99 
100 
101 /* A subuniverse version as well. */
102 BEGIN SUBUNIVERSES
103 inline #base_type#
104 #uset#_bs_elt_base_type_sub( BS_ELT x, #uset#_SUBUNIVERSE* sub )
105 {
106  if ( x == BS_CHOOSE_FAILURE )
107  return #uset#_CHOOSE_FAILURE;
108  else
109  return #num_elt_sub#(x,sub);
110 }
111 END SUBUNIVERSES
112 
113 #define #uset#_Create BS_Create
114 #define #uset#_Size_Alloc_Size BS_Size_Alloc_Size
115 #define #uset#_Alloc_Size BS_Alloc_Size
116 #define #uset#_ClearD BS_ClearD
117 #define #uset#_Create_Empty BS_Create_Empty
118 #define #uset#_Range BS_Range
119 #define #uset#_RangeD BS_RangeD
120 
121 #define #uset#_Singleton(e,p) \
122  BS_Singleton(#elt_num#(e),(p))
123 
124 BEGIN SUBUNIVERSES
125 #define #uset#_SingletonS(e,p,s) \
126  BS_Singleton(#elt_num_sub#((e),(s)),(p))
127 END SUBUNIVERSES
128 
129 #define #uset#_SingletonD(s,e,p) \
130  BS_SingletonD((s),#elt_num#(e),(p))
131 
132 BEGIN SUBUNIVERSES
133 #define #uset#_SingletonDS(s,e,p,sub) \
134  BS_SingletonD((s),#elt_num_sub#((e),(sub)),(p))
135 END SUBUNIVERSES
136 
137 #define #uset#_Universe BS_Universe
138 #define #uset#_UniverseD BS_UniverseD
139 #define #uset#_Copy BS_Copy
140 #define #uset#_CopyD BS_CopyD
141 
142 #define #uset#_Choose(x) \
143  #uset#_bs_elt_base_type(BS_Choose(x))
144 
145 #define #uset#_ChooseS(x,s) \
146  #uset#_bs_elt_base_type_sub(BS_Choose(x),s)
147 
148 #define #uset#_Intersection_Choose(x1,x2) \
149  #uset#_bs_elt_base_type(BS_Intersection_Choose((x1),(x2)))
150 
151 #define #uset#_Intersection_ChooseS(x1,x2,s) \
152  #uset#_bs_elt_base_type_sub(BS_Intersection_Choose((x1),(x2)),(s))
153 
154 #define #uset#_Choose_Next(x,e) \
155  #uset#_bs_elt_base_type(BS_Choose_Next((x),#elt_num#(e)))
156 
157 BEGIN SUBUNIVERSES
158 /* Needs to evaluate "sub" twice, so it has to be a function:
159  */
160 extern #base_type# #uset#_Choose_NextS(
161  #uset#*,
162  #base_type#,
163  #uset#_SUBUNIVERSE*
164 );
165 END SUBUNIVERSES
166 
167 #define #uset#_Intersection_Choose_Next(x1,x2,e) \
168  #uset#_bs_elt_base_type(BS_Intersection_Choose_Next((x1),(x2),#elt_num#(e)))
169 
170 BEGIN SUBUNIVERSES
171 /* Needs to evaluate "sub" twice, so it has to be a function:
172  */
173 extern #base_type# #uset#_Intersection_Choose_NextS(
174  #uset#*,
175  #uset#*,
176  #base_type#,
177  #uset#_SUBUNIVERSE*
178 );
179 END SUBUNIVERSES
180 
181 #define #uset#_Choose_Range(x,l,h) \
182  #uset#_bs_elt_base_type(BS_Choose_Range((x),(l),(h)))
183 
184 #define #uset#_Choose_RangeS(x,l,h,s) \
185  #uset#_bs_elt_base_type_sub(BS_Choose_Range((x),(l),(h)),(s))
186 
187 #define #uset#_Difference BS_Difference
188 #define #uset#_DifferenceD BS_DifferenceD
189 
190 #define #uset#_Difference1(s,e,p) \
191  BS_Difference1(s,#elt_num#(e),(p))
192 
193 BEGIN SUBUNIVERSES
194 #define #uset#_Difference1S(s,e,p,sub) \
195  BS_Difference1(s,#elt_num_sub#((e),(sub)),(p))
196 END SUBUNIVERSES
197 
198 #define #uset#_Difference1D(s,e) \
199  BS_Difference1D(s,#elt_num#(e))
200 
201 BEGIN SUBUNIVERSES
202 #define #uset#_Difference1DS(s,e,sub) \
203  BS_Difference1D(s,#elt_num_sub#((e),(sub)))
204 END SUBUNIVERSES
205 
206 #define #uset#_Intersection BS_Intersection
207 #define #uset#_IntersectionD BS_IntersectionD
208 #define #uset#_Size BS_Size
209 #define #uset#_Union BS_Union
210 #define #uset#_UnionD BS_UnionD
211 
212 #define #uset#_Union1(s,x,p) \
213  BS_Union1((s),#elt_num#(x),(p))
214 
215 #define #uset#_UnionD_Intersection(s1,s2,s3,p) \
216  BS_UnionD_Intersection((s1),(s2),(s3),(p))
217 
218 BEGIN SUBUNIVERSES
219 #define #uset#_Union1S(s,x,p,sub) \
220  BS_Union1((s),#elt_num_sub#((x),(sub)),(p))
221 END SUBUNIVERSES
222 
223 #define #uset#_Union1D(s,x,p) \
224  BS_Union1D((s),#elt_num#(x),(p))
225 
226 BEGIN SUBUNIVERSES
227 #define #uset#_Union1DS(s,x,p,sub) \
228  BS_Union1D((s),#elt_num_sub#((x),(sub)),(p))
229 END SUBUNIVERSES
230 
231 #define #uset#_ContainsP BS_ContainsP
232 #define #uset#_EmptyP BS_EmptyP
233 #define #uset#_EqualP BS_EqualP
234 #define #uset#_IntersectsP BS_IntersectsP
235 
236 #define #uset#_MemberP(set,x) BS_MemberP((set),#elt_num#(x))
237 
238 BEGIN SUBUNIVERSES
239 #define #uset#_MemberPS(set,x,s) BS_MemberP((set),#elt_num_sub#((x),(s)))
240 END SUBUNIVERSES
241 
242 #define #uset#_Intersection_MemberP(set1,set2,x) \
243  BS_Intersection_MemberP((set1),(set2),#elt_num#(x))
244 
245 BEGIN SUBUNIVERSES
246 #define #uset#_Intersection_MemberPS(set1,set2,x,s) \
247  BS_Intersection_MemberP((set1),(set2),#elt_num_sub#((x),(s)))
248 END SUBUNIVERSES
249 
250 #define #uset#_Print BS_Print
251 
252 #define FOR_ALL_#uset#_members(set,x) \
253  for (x = #uset#_Choose(set); \
254  x != #uset#_CHOOSE_FAILURE; \
255  x = #uset#_Choose_Next(set,x))
256 
257 #ifdef __cplusplus
258 }
259 #endif
260 #endif /* #uset#_INCLUDED */