b5063190fa6caa09e930a3cb5a210427a3bf5c84
[com/gs-lite.git] / cfg / external_fcns.def
1  ///////////////////////////////////////////////////////////
2 //          Matching predicates
3 ///////////////////////////////////////////////////////////
4         PRED [LFTA_LEGAL, COST HIGH]str_exists_substr[string, string];
5         PRED [LFTA_LEGAL, COST HIGH]str_compare[string,string];
6         PRED [LFTA_LEGAL, COST LOW] str_match_offset [uint,string,string];
7         PRED [LFTA_LEGAL, COST LOW] byte_match_offset [uint,uint,string];
8     
9 ///////////////////////////////////////////////////////////
10 //          MIN/MAX functions
11 ///////////////////////////////////////////////////////////
12
13 // return ullong
14         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (uint,int);
15         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (uint,uint);
16         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (uint,llong);
17         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (uint,ullong);
18         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (uint,float);
19         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (int,int);
20         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (int,uint);
21         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (int,llong);
22         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (int,ullong);
23         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (int,float);
24         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (ullong,int);
25         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (ullong,uint);
26         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (ullong,llong);
27         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (ullong,ullong);
28         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (ullong,float);
29         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (llong,int);
30         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (llong,uint);
31         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (llong,llong);
32         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (llong,ullong);
33         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (llong,float);
34         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (float,int);
35         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (float,uint);
36         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (float,llong);
37         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (float,ullong);
38         ullong FUN [LFTA_LEGAL, COST FREE] ULLMIN (float,float);
39
40         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (uint,int);
41         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (uint,uint);
42         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (uint,llong);
43         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (uint,ullong);
44         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (uint,float);
45         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (int,int);
46         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (int,uint);
47         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (int,llong);
48         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (int,ullong);
49         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (int,float);
50         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (ullong,int);
51         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (ullong,uint);
52         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (ullong,llong);
53         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (ullong,ullong);
54         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (ullong,float);
55         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (llong,int);
56         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (llong,uint);
57         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (llong,llong);
58         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (llong,ullong);
59         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (llong,float);
60         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (float,int);
61         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (float,uint);
62         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (float,llong);
63         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (float,ullong);
64         ullong FUN [LFTA_LEGAL, COST FREE] ULLMAX (float,float);
65
66 // return llong
67         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (uint,int);
68         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (uint,uint);
69         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (uint,llong);
70         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (uint,ullong);
71         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (uint,float);
72         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (int,int);
73         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (int,uint);
74         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (int,llong);
75         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (int,ullong);
76         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (int,float);
77         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (ullong,int);
78         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (ullong,uint);
79         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (ullong,llong);
80         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (ullong,ullong);
81         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (ullong,float);
82         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (llong,int);
83         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (llong,uint);
84         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (llong,llong);
85         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (llong,ullong);
86         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (llong,float);
87         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (float,int);
88         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (float,uint);
89         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (float,llong);
90         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (float,ullong);
91         ullong FUN [LFTA_LEGAL, COST FREE] LLMIN (float,float);
92
93         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (uint,int);
94         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (uint,uint);
95         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (uint,llong);
96         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (uint,ullong);
97         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (uint,float);
98         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (int,int);
99         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (int,uint);
100         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (int,llong);
101         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (int,ullong);
102         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (int,float);
103         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (ullong,int);
104         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (ullong,uint);
105         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (ullong,llong);
106         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (ullong,ullong);
107         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (ullong,float);
108         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (llong,int);
109         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (llong,uint);
110         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (llong,llong);
111         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (llong,ullong);
112         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (llong,float);
113         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (float,int);
114         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (float,uint);
115         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (float,llong);
116         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (float,ullong);
117         ullong FUN [LFTA_LEGAL, COST FREE] LLMAX (float,float);
118
119 // return uint
120         uint FUN [LFTA_LEGAL, COST FREE] UMIN (uint,int);
121         uint FUN [LFTA_LEGAL, COST FREE] UMIN (uint,uint);
122         uint FUN [LFTA_LEGAL, COST FREE] UMIN (uint,llong);
123         uint FUN [LFTA_LEGAL, COST FREE] UMIN (uint,ullong);
124         uint FUN [LFTA_LEGAL, COST FREE] UMIN (uint,float);
125         uint FUN [LFTA_LEGAL, COST FREE] UMIN (int,int);
126         uint FUN [LFTA_LEGAL, COST FREE] UMIN (int,uint);
127         uint FUN [LFTA_LEGAL, COST FREE] UMIN (int,llong);
128         uint FUN [LFTA_LEGAL, COST FREE] UMIN (int,ullong);
129         uint FUN [LFTA_LEGAL, COST FREE] UMIN (int,float);
130         uint FUN [LFTA_LEGAL, COST FREE] UMIN (ullong,int);
131         uint FUN [LFTA_LEGAL, COST FREE] UMIN (ullong,uint);
132         uint FUN [LFTA_LEGAL, COST FREE] UMIN (ullong,llong);
133         uint FUN [LFTA_LEGAL, COST FREE] UMIN (ullong,ullong);
134         uint FUN [LFTA_LEGAL, COST FREE] UMIN (ullong,float);
135         uint FUN [LFTA_LEGAL, COST FREE] UMIN (llong,int);
136         uint FUN [LFTA_LEGAL, COST FREE] UMIN (llong,uint);
137         uint FUN [LFTA_LEGAL, COST FREE] UMIN (llong,llong);
138         uint FUN [LFTA_LEGAL, COST FREE] UMIN (llong,ullong);
139         uint FUN [LFTA_LEGAL, COST FREE] UMIN (llong,float);
140         uint FUN [LFTA_LEGAL, COST FREE] UMIN (float,int);
141         uint FUN [LFTA_LEGAL, COST FREE] UMIN (float,uint);
142         uint FUN [LFTA_LEGAL, COST FREE] UMIN (float,llong);
143         uint FUN [LFTA_LEGAL, COST FREE] UMIN (float,ullong);
144         uint FUN [LFTA_LEGAL, COST FREE] UMIN (float,float);
145
146         uint FUN [LFTA_LEGAL, COST FREE] UMAX (uint,int);
147         uint FUN [LFTA_LEGAL, COST FREE] UMAX (uint,uint);
148         uint FUN [LFTA_LEGAL, COST FREE] UMAX (uint,llong);
149         uint FUN [LFTA_LEGAL, COST FREE] UMAX (uint,ullong);
150         uint FUN [LFTA_LEGAL, COST FREE] UMAX (uint,float);
151         uint FUN [LFTA_LEGAL, COST FREE] UMAX (int,int);
152         uint FUN [LFTA_LEGAL, COST FREE] UMAX (int,uint);
153         uint FUN [LFTA_LEGAL, COST FREE] UMAX (int,llong);
154         uint FUN [LFTA_LEGAL, COST FREE] UMAX (int,ullong);
155         uint FUN [LFTA_LEGAL, COST FREE] UMAX (int,float);
156         uint FUN [LFTA_LEGAL, COST FREE] UMAX (ullong,int);
157         uint FUN [LFTA_LEGAL, COST FREE] UMAX (ullong,uint);
158         uint FUN [LFTA_LEGAL, COST FREE] UMAX (ullong,llong);
159         uint FUN [LFTA_LEGAL, COST FREE] UMAX (ullong,ullong);
160         uint FUN [LFTA_LEGAL, COST FREE] UMAX (ullong,float);
161         uint FUN [LFTA_LEGAL, COST FREE] UMAX (llong,int);
162         uint FUN [LFTA_LEGAL, COST FREE] UMAX (llong,uint);
163         uint FUN [LFTA_LEGAL, COST FREE] UMAX (llong,llong);
164         uint FUN [LFTA_LEGAL, COST FREE] UMAX (llong,ullong);
165         uint FUN [LFTA_LEGAL, COST FREE] UMAX (llong,float);
166         uint FUN [LFTA_LEGAL, COST FREE] UMAX (float,int);
167         uint FUN [LFTA_LEGAL, COST FREE] UMAX (float,uint);
168         uint FUN [LFTA_LEGAL, COST FREE] UMAX (float,llong);
169         uint FUN [LFTA_LEGAL, COST FREE] UMAX (float,ullong);
170         uint FUN [LFTA_LEGAL, COST FREE] UMAX (float,float);
171
172 // return int
173         int FUN [LFTA_LEGAL, COST FREE] LMIN (uint,int);
174         int FUN [LFTA_LEGAL, COST FREE] LMIN (uint,uint);
175         int FUN [LFTA_LEGAL, COST FREE] LMIN (uint,llong);
176         int FUN [LFTA_LEGAL, COST FREE] LMIN (uint,ullong);
177         int FUN [LFTA_LEGAL, COST FREE] LMIN (uint,float);
178         int FUN [LFTA_LEGAL, COST FREE] LMIN (int,int);
179         int FUN [LFTA_LEGAL, COST FREE] LMIN (int,uint);
180         int FUN [LFTA_LEGAL, COST FREE] LMIN (int,llong);
181         int FUN [LFTA_LEGAL, COST FREE] LMIN (int,ullong);
182         int FUN [LFTA_LEGAL, COST FREE] LMIN (int,float);
183         int FUN [LFTA_LEGAL, COST FREE] LMIN (ullong,int);
184         int FUN [LFTA_LEGAL, COST FREE] LMIN (ullong,uint);
185         int FUN [LFTA_LEGAL, COST FREE] LMIN (ullong,llong);
186         int FUN [LFTA_LEGAL, COST FREE] LMIN (ullong,ullong);
187         int FUN [LFTA_LEGAL, COST FREE] LMIN (ullong,float);
188         int FUN [LFTA_LEGAL, COST FREE] LMIN (llong,int);
189         int FUN [LFTA_LEGAL, COST FREE] LMIN (llong,uint);
190         int FUN [LFTA_LEGAL, COST FREE] LMIN (llong,llong);
191         int FUN [LFTA_LEGAL, COST FREE] LMIN (llong,ullong);
192         int FUN [LFTA_LEGAL, COST FREE] LMIN (llong,float);
193         int FUN [LFTA_LEGAL, COST FREE] LMIN (float,int);
194         int FUN [LFTA_LEGAL, COST FREE] LMIN (float,uint);
195         int FUN [LFTA_LEGAL, COST FREE] LMIN (float,llong);
196         int FUN [LFTA_LEGAL, COST FREE] LMIN (float,ullong);
197         int FUN [LFTA_LEGAL, COST FREE] LMIN (float,float);
198
199         int FUN [LFTA_LEGAL, COST FREE] LMAX (uint,int);
200         int FUN [LFTA_LEGAL, COST FREE] LMAX (uint,uint);
201         int FUN [LFTA_LEGAL, COST FREE] LMAX (uint,llong);
202         int FUN [LFTA_LEGAL, COST FREE] LMAX (uint,ullong);
203         int FUN [LFTA_LEGAL, COST FREE] LMAX (uint,float);
204         int FUN [LFTA_LEGAL, COST FREE] LMAX (int,int);
205         int FUN [LFTA_LEGAL, COST FREE] LMAX (int,uint);
206         int FUN [LFTA_LEGAL, COST FREE] LMAX (int,llong);
207         int FUN [LFTA_LEGAL, COST FREE] LMAX (int,ullong);
208         int FUN [LFTA_LEGAL, COST FREE] LMAX (int,float);
209         int FUN [LFTA_LEGAL, COST FREE] LMAX (ullong,int);
210         int FUN [LFTA_LEGAL, COST FREE] LMAX (ullong,uint);
211         int FUN [LFTA_LEGAL, COST FREE] LMAX (ullong,llong);
212         int FUN [LFTA_LEGAL, COST FREE] LMAX (ullong,ullong);
213         int FUN [LFTA_LEGAL, COST FREE] LMAX (ullong,float);
214         int FUN [LFTA_LEGAL, COST FREE] LMAX (llong,int);
215         int FUN [LFTA_LEGAL, COST FREE] LMAX (llong,uint);
216         int FUN [LFTA_LEGAL, COST FREE] LMAX (llong,llong);
217         int FUN [LFTA_LEGAL, COST FREE] LMAX (llong,ullong);
218         int FUN [LFTA_LEGAL, COST FREE] LMAX (llong,float);
219         int FUN [LFTA_LEGAL, COST FREE] LMAX (float,int);
220         int FUN [LFTA_LEGAL, COST FREE] LMAX (float,uint);
221         int FUN [LFTA_LEGAL, COST FREE] LMAX (float,llong);
222         int FUN [LFTA_LEGAL, COST FREE] LMAX (float,ullong);
223         int FUN [LFTA_LEGAL, COST FREE] LMAX (float,float);
224
225 // return float
226         float FUN [LFTA_LEGAL, COST FREE] FMIN (uint,int);
227         float FUN [LFTA_LEGAL, COST FREE] FMIN (uint,uint);
228         float FUN [LFTA_LEGAL, COST FREE] FMIN (uint,llong);
229         float FUN [LFTA_LEGAL, COST FREE] FMIN (uint,ullong);
230         float FUN [LFTA_LEGAL, COST FREE] FMIN (uint,float);
231         float FUN [LFTA_LEGAL, COST FREE] FMIN (int,int);
232         float FUN [LFTA_LEGAL, COST FREE] FMIN (int,uint);
233         float FUN [LFTA_LEGAL, COST FREE] FMIN (int,llong);
234         float FUN [LFTA_LEGAL, COST FREE] FMIN (int,ullong);
235         float FUN [LFTA_LEGAL, COST FREE] FMIN (int,float);
236         float FUN [LFTA_LEGAL, COST FREE] FMIN (ullong,int);
237         float FUN [LFTA_LEGAL, COST FREE] FMIN (ullong,uint);
238         float FUN [LFTA_LEGAL, COST FREE] FMIN (ullong,llong);
239         float FUN [LFTA_LEGAL, COST FREE] FMIN (ullong,ullong);
240         float FUN [LFTA_LEGAL, COST FREE] FMIN (ullong,float);
241         float FUN [LFTA_LEGAL, COST FREE] FMIN (llong,int);
242         float FUN [LFTA_LEGAL, COST FREE] FMIN (llong,uint);
243         float FUN [LFTA_LEGAL, COST FREE] FMIN (llong,llong);
244         float FUN [LFTA_LEGAL, COST FREE] FMIN (llong,ullong);
245         float FUN [LFTA_LEGAL, COST FREE] FMIN (llong,float);
246         float FUN [LFTA_LEGAL, COST FREE] FMIN (float,int);
247         float FUN [LFTA_LEGAL, COST FREE] FMIN (float,uint);
248         float FUN [LFTA_LEGAL, COST FREE] FMIN (float,llong);
249         float FUN [LFTA_LEGAL, COST FREE] FMIN (float,ullong);
250         float FUN [LFTA_LEGAL, COST FREE] FMIN (float,float);
251
252         float FUN [LFTA_LEGAL, COST FREE] FMAX (uint,int);
253         float FUN [LFTA_LEGAL, COST FREE] FMAX (uint,uint);
254         float FUN [LFTA_LEGAL, COST FREE] FMAX (uint,llong);
255         float FUN [LFTA_LEGAL, COST FREE] FMAX (uint,ullong);
256         float FUN [LFTA_LEGAL, COST FREE] FMAX (uint,float);
257         float FUN [LFTA_LEGAL, COST FREE] FMAX (int,int);
258         float FUN [LFTA_LEGAL, COST FREE] FMAX (int,uint);
259         float FUN [LFTA_LEGAL, COST FREE] FMAX (int,llong);
260         float FUN [LFTA_LEGAL, COST FREE] FMAX (int,ullong);
261         float FUN [LFTA_LEGAL, COST FREE] FMAX (int,float);
262         float FUN [LFTA_LEGAL, COST FREE] FMAX (ullong,int);
263         float FUN [LFTA_LEGAL, COST FREE] FMAX (ullong,uint);
264         float FUN [LFTA_LEGAL, COST FREE] FMAX (ullong,llong);
265         float FUN [LFTA_LEGAL, COST FREE] FMAX (ullong,ullong);
266         float FUN [LFTA_LEGAL, COST FREE] FMAX (ullong,float);
267         float FUN [LFTA_LEGAL, COST FREE] FMAX (llong,int);
268         float FUN [LFTA_LEGAL, COST FREE] FMAX (llong,uint);
269         float FUN [LFTA_LEGAL, COST FREE] FMAX (llong,llong);
270         float FUN [LFTA_LEGAL, COST FREE] FMAX (llong,ullong);
271         float FUN [LFTA_LEGAL, COST FREE] FMAX (llong,float);
272         float FUN [LFTA_LEGAL, COST FREE] FMAX (float,int);
273         float FUN [LFTA_LEGAL, COST FREE] FMAX (float,uint);
274         float FUN [LFTA_LEGAL, COST FREE] FMAX (float,llong);
275         float FUN [LFTA_LEGAL, COST FREE] FMAX (float,ullong);
276         float FUN [LFTA_LEGAL, COST FREE] FMAX (float,float);
277
278 // return IP
279         IP FUN [LFTA_LEGAL, COST FREE] UMIN (IP,IP);
280         IP FUN [LFTA_LEGAL, COST FREE] UMAX (IP,IP);
281    
282 ///////////////////////////////////////////////////////////
283 //          conditional functions
284 ///////////////////////////////////////////////////////////
285
286 // rhs == lhs
287         uint FUN [LFTA_LEGAL, COST FREE] EQ (uint, int);
288         uint FUN [LFTA_LEGAL, COST FREE] EQ (uint, uint);
289         uint FUN [LFTA_LEGAL, COST FREE] EQ (uint, llong);
290         uint FUN [LFTA_LEGAL, COST FREE] EQ (uint, ullong);
291         uint FUN [LFTA_LEGAL, COST FREE] EQ (uint, float);
292         uint FUN [LFTA_LEGAL, COST FREE] EQ (int, int);
293         uint FUN [LFTA_LEGAL, COST FREE] EQ (int, uint);
294         uint FUN [LFTA_LEGAL, COST FREE] EQ (int, llong);
295         uint FUN [LFTA_LEGAL, COST FREE] EQ (int, ullong);
296         uint FUN [LFTA_LEGAL, COST FREE] EQ (int, float);
297         uint FUN [LFTA_LEGAL, COST FREE] EQ (ullong, int);
298         uint FUN [LFTA_LEGAL, COST FREE] EQ (ullong, uint);
299         uint FUN [LFTA_LEGAL, COST FREE] EQ (ullong, llong);
300         uint FUN [LFTA_LEGAL, COST FREE] EQ (ullong, ullong);
301         uint FUN [LFTA_LEGAL, COST FREE] EQ (ullong, float);
302         uint FUN [LFTA_LEGAL, COST FREE] EQ (llong, int);
303         uint FUN [LFTA_LEGAL, COST FREE] EQ (llong, uint);
304         uint FUN [LFTA_LEGAL, COST FREE] EQ (llong, llong);
305         uint FUN [LFTA_LEGAL, COST FREE] EQ (llong, ullong);
306         uint FUN [LFTA_LEGAL, COST FREE] EQ (llong, float);
307         uint FUN [LFTA_LEGAL, COST FREE] EQ (float, int);
308         uint FUN [LFTA_LEGAL, COST FREE] EQ (float, uint);
309         uint FUN [LFTA_LEGAL, COST FREE] EQ (float, llong);
310         uint FUN [LFTA_LEGAL, COST FREE] EQ (float, ullong);
311         uint FUN [LFTA_LEGAL, COST FREE] EQ (float, float);
312
313 // rhs >= lhs
314         uint FUN [LFTA_LEGAL, COST FREE] GEQ (uint, int);
315         uint FUN [LFTA_LEGAL, COST FREE] GEQ (uint, uint);
316         uint FUN [LFTA_LEGAL, COST FREE] GEQ (uint, llong);
317         uint FUN [LFTA_LEGAL, COST FREE] GEQ (uint, ullong);
318         uint FUN [LFTA_LEGAL, COST FREE] GEQ (uint, float);
319         uint FUN [LFTA_LEGAL, COST FREE] GEQ (int, int);
320         uint FUN [LFTA_LEGAL, COST FREE] GEQ (int, uint);
321         uint FUN [LFTA_LEGAL, COST FREE] GEQ (int, llong);
322         uint FUN [LFTA_LEGAL, COST FREE] GEQ (int, ullong);
323         uint FUN [LFTA_LEGAL, COST FREE] GEQ (int, float);
324         uint FUN [LFTA_LEGAL, COST FREE] GEQ (ullong, int);
325         uint FUN [LFTA_LEGAL, COST FREE] GEQ (ullong, uint);
326         uint FUN [LFTA_LEGAL, COST FREE] GEQ (ullong, llong);
327         uint FUN [LFTA_LEGAL, COST FREE] GEQ (ullong, ullong);
328         uint FUN [LFTA_LEGAL, COST FREE] GEQ (ullong, float);
329         uint FUN [LFTA_LEGAL, COST FREE] GEQ (llong, int);
330         uint FUN [LFTA_LEGAL, COST FREE] GEQ (llong, uint);
331         uint FUN [LFTA_LEGAL, COST FREE] GEQ (llong, llong);
332         uint FUN [LFTA_LEGAL, COST FREE] GEQ (llong, ullong);
333         uint FUN [LFTA_LEGAL, COST FREE] GEQ (llong, float);
334         uint FUN [LFTA_LEGAL, COST FREE] GEQ (float, int);
335         uint FUN [LFTA_LEGAL, COST FREE] GEQ (float, uint);
336         uint FUN [LFTA_LEGAL, COST FREE] GEQ (float, llong);
337         uint FUN [LFTA_LEGAL, COST FREE] GEQ (float, ullong);
338         uint FUN [LFTA_LEGAL, COST FREE] GEQ (float, float);
339
340 // rhs > lhs
341         uint FUN [LFTA_LEGAL, COST FREE] GE (uint, int);
342         uint FUN [LFTA_LEGAL, COST FREE] GE (uint, uint);
343         uint FUN [LFTA_LEGAL, COST FREE] GE (uint, llong);
344         uint FUN [LFTA_LEGAL, COST FREE] GE (uint, ullong);
345         uint FUN [LFTA_LEGAL, COST FREE] GE (uint, float);
346         uint FUN [LFTA_LEGAL, COST FREE] GE (int, int);
347         uint FUN [LFTA_LEGAL, COST FREE] GE (int, uint);
348         uint FUN [LFTA_LEGAL, COST FREE] GE (int, llong);
349         uint FUN [LFTA_LEGAL, COST FREE] GE (int, ullong);
350         uint FUN [LFTA_LEGAL, COST FREE] GE (int, float);
351         uint FUN [LFTA_LEGAL, COST FREE] GE (ullong, int);
352         uint FUN [LFTA_LEGAL, COST FREE] GE (ullong, uint);
353         uint FUN [LFTA_LEGAL, COST FREE] GE (ullong, llong);
354         uint FUN [LFTA_LEGAL, COST FREE] GE (ullong, ullong);
355         uint FUN [LFTA_LEGAL, COST FREE] GE (ullong, float);
356         uint FUN [LFTA_LEGAL, COST FREE] GE (llong, int);
357         uint FUN [LFTA_LEGAL, COST FREE] GE (llong, uint);
358         uint FUN [LFTA_LEGAL, COST FREE] GE (llong, llong);
359         uint FUN [LFTA_LEGAL, COST FREE] GE (llong, ullong);
360         uint FUN [LFTA_LEGAL, COST FREE] GE (llong, float);
361         uint FUN [LFTA_LEGAL, COST FREE] GE (float, int);
362         uint FUN [LFTA_LEGAL, COST FREE] GE (float, uint);
363         uint FUN [LFTA_LEGAL, COST FREE] GE (float, llong);
364         uint FUN [LFTA_LEGAL, COST FREE] GE (float, ullong);
365         uint FUN [LFTA_LEGAL, COST FREE] GE (float, float);
366
367 // rhs <= lhs
368         uint FUN [LFTA_LEGAL, COST FREE] LEQ (uint, int);
369         uint FUN [LFTA_LEGAL, COST FREE] LEQ (uint, uint);
370         uint FUN [LFTA_LEGAL, COST FREE] LEQ (uint, llong);
371         uint FUN [LFTA_LEGAL, COST FREE] LEQ (uint, ullong);
372         uint FUN [LFTA_LEGAL, COST FREE] LEQ (uint, float);
373         uint FUN [LFTA_LEGAL, COST FREE] LEQ (int, int);
374         uint FUN [LFTA_LEGAL, COST FREE] LEQ (int, uint);
375         uint FUN [LFTA_LEGAL, COST FREE] LEQ (int, llong);
376         uint FUN [LFTA_LEGAL, COST FREE] LEQ (int, ullong);
377         uint FUN [LFTA_LEGAL, COST FREE] LEQ (int, float);
378         uint FUN [LFTA_LEGAL, COST FREE] LEQ (ullong, int);
379         uint FUN [LFTA_LEGAL, COST FREE] LEQ (ullong, uint);
380         uint FUN [LFTA_LEGAL, COST FREE] LEQ (ullong, llong);
381         uint FUN [LFTA_LEGAL, COST FREE] LEQ (ullong, ullong);
382         uint FUN [LFTA_LEGAL, COST FREE] LEQ (ullong, float);
383         uint FUN [LFTA_LEGAL, COST FREE] LEQ (llong, int);
384         uint FUN [LFTA_LEGAL, COST FREE] LEQ (llong, uint);
385         uint FUN [LFTA_LEGAL, COST FREE] LEQ (llong, llong);
386         uint FUN [LFTA_LEGAL, COST FREE] LEQ (llong, ullong);
387         uint FUN [LFTA_LEGAL, COST FREE] LEQ (llong, float);
388         uint FUN [LFTA_LEGAL, COST FREE] LEQ (float, int);
389         uint FUN [LFTA_LEGAL, COST FREE] LEQ (float, uint);
390         uint FUN [LFTA_LEGAL, COST FREE] LEQ (float, llong);
391         uint FUN [LFTA_LEGAL, COST FREE] LEQ (float, ullong);
392         uint FUN [LFTA_LEGAL, COST FREE] LEQ (float, float);
393
394 // rhs < lhs
395         uint FUN [LFTA_LEGAL, COST FREE] LE (uint, int);
396         uint FUN [LFTA_LEGAL, COST FREE] LE (uint, uint);
397         uint FUN [LFTA_LEGAL, COST FREE] LE (uint, llong);
398         uint FUN [LFTA_LEGAL, COST FREE] LE (uint, ullong);
399         uint FUN [LFTA_LEGAL, COST FREE] LE (uint, float);
400         uint FUN [LFTA_LEGAL, COST FREE] LE (int, int);
401         uint FUN [LFTA_LEGAL, COST FREE] LE (int, uint);
402         uint FUN [LFTA_LEGAL, COST FREE] LE (int, llong);
403         uint FUN [LFTA_LEGAL, COST FREE] LE (int, ullong);
404         uint FUN [LFTA_LEGAL, COST FREE] LE (int, float);
405         uint FUN [LFTA_LEGAL, COST FREE] LE (ullong, int);
406         uint FUN [LFTA_LEGAL, COST FREE] LE (ullong, uint);
407         uint FUN [LFTA_LEGAL, COST FREE] LE (ullong, llong);
408         uint FUN [LFTA_LEGAL, COST FREE] LE (ullong, ullong);
409         uint FUN [LFTA_LEGAL, COST FREE] LE (ullong, float);
410         uint FUN [LFTA_LEGAL, COST FREE] LE (llong, int);
411         uint FUN [LFTA_LEGAL, COST FREE] LE (llong, uint);
412         uint FUN [LFTA_LEGAL, COST FREE] LE (llong, llong);
413         uint FUN [LFTA_LEGAL, COST FREE] LE (llong, ullong);
414         uint FUN [LFTA_LEGAL, COST FREE] LE (llong, float);
415         uint FUN [LFTA_LEGAL, COST FREE] LE (float, int);
416         uint FUN [LFTA_LEGAL, COST FREE] LE (float, uint);
417         uint FUN [LFTA_LEGAL, COST FREE] LE (float, llong);
418         uint FUN [LFTA_LEGAL, COST FREE] LE (float, ullong);
419         uint FUN [LFTA_LEGAL, COST FREE] LE (float, float);
420
421 //////////////////////////////////////////////////////////////
422 //      Conditional evaluation
423 //              add int, uint in the else clause to allow for constants
424 ///////////////////////////////////////////////////////
425
426         int FUN [LFTA_LEGAL, COST FREE] if_else_i(uint, int, int);
427         int FUN [LFTA_LEGAL, COST FREE] if_else_i(uint, int, uint);
428         uint FUN [LFTA_LEGAL, COST FREE] if_else_i(uint, uint, uint); 
429         uint FUN [LFTA_LEGAL, COST FREE] if_else_i(uint, uint, int);
430         llong FUN [LFTA_LEGAL, COST FREE] if_else_i(uint, llong, llong);
431         llong FUN [LFTA_LEGAL, COST FREE] if_else_i(uint, llong, uint);
432         llong FUN [LFTA_LEGAL, COST FREE] if_else_i(uint, llong, int);
433         ullong FUN [LFTA_LEGAL, COST FREE] if_else_i(uint, ullong, ullong);
434         ullong FUN [LFTA_LEGAL, COST FREE] if_else_i(uint, ullong, int);
435         ullong FUN [LFTA_LEGAL, COST FREE] if_else_i(uint, ullong, uint);
436
437
438 ///////////////////////////////////////////////////////////
439 //          Function for regex matching
440 ///////////////////////////////////////////////////////////
441
442         uint FUN [LFTA_LEGAL] endian_swap_ui(uint);
443
444 ///////////////////////////////////////////////////////////
445 //          Function for regex matching
446 ///////////////////////////////////////////////////////////
447
448
449 uint FUN [LFTA_LEGAL, COST EXPENSIVE]
450                 str_regex_match( string, string HANDLE);
451         uint FUN [LFTA_LEGAL, COST EXPENSIVE] 
452                 str_partial_regex_match( string, string HANDLE, uint);
453         string FUN [PARTIAL, COST EXPENSIVE] str_extract_regex( string, string HANDLE);
454   
455
456 ///////////////////////////////////////////////////////////
457 //         Truncating strings and substrings
458 ///////////////////////////////////////////////////////////
459        
460 // str_truncate(str, n) : return the 1st n chars of str, or as much as possible
461         string FUN [LFTA_LEGAL,PARTIAL,COST FREE] str_truncate (string, uint);
462 // str_suffix(str, n) : return the last n chars of str, or as much as possible
463         string FUN [LFTA_LEGAL,PARTIAL,COST FREE] str_suffix (string, uint);
464 // get_list_entry(list_str, sep_str, i) : split the list by sep,
465 //              return the i-th value, if it exists.
466         string FUN [LFTA_LEGAL,PARTIAL,COST FREE] get_list_entry (string, string, uint CONST);
467
468
469 ///////////////////////////////////////////////////////////
470 //         hashing
471 ///////////////////////////////////////////////////////////
472
473         uint FUN [LFTA_LEGAL] string_hash(string);
474         ullong FUN string_hash_long(string);
475
476  
477 ///////////////////////////////////////////////////////////
478 //          Function for casting
479 ///////////////////////////////////////////////////////////
480
481     int FUN [LFTA_LEGAL,COST FREE] non_temporal(int);
482         uint FUN [LFTA_LEGAL,COST FREE] non_temporal(uint);
483         llong FUN [LFTA_LEGAL,COST FREE] non_temporal(llong);
484         ullong FUN [LFTA_LEGAL,COST FREE] non_temporal(ullong);
485
486         int FUN [LFTA_LEGAL,COST FREE]INT(uint);
487         int FUN [LFTA_LEGAL,COST FREE]INT(int);
488     int FUN [LFTA_LEGAL,COST FREE]INT(ullong);
489     int FUN [LFTA_LEGAL,COST FREE]INT(llong);
490     int FUN [LFTA_LEGAL,COST FREE]INT(float);
491  
492     uint FUN [LFTA_LEGAL,COST FREE]UINT(uint);
493     uint FUN [LFTA_LEGAL,COST FREE]UINT(int);
494     uint FUN [LFTA_LEGAL,COST FREE]UINT(ullong);
495     uint FUN [LFTA_LEGAL,COST FREE]UINT(llong);
496     uint FUN [LFTA_LEGAL,COST FREE]UINT(float);
497         uint FUN [LFTA_LEGAL,COST FREE]UINT(IP);
498
499         float FUN [LFTA_LEGAL,COST FREE] FLOAT(llong);
500         float FUN [LFTA_LEGAL,COST FREE] FLOAT(float);
501         float FUN [LFTA_LEGAL,COST FREE] FLOAT(ullong);
502         float FUN [LFTA_LEGAL,COST FREE] FLOAT(int);
503         float FUN [LFTA_LEGAL,COST FREE] FLOAT(uint);
504
505         ullong FUN [LFTA_LEGAL,COST FREE]ULLONG(uint);
506         ullong FUN [LFTA_LEGAL,COST FREE]ULLONG(int);
507         ullong FUN [LFTA_LEGAL,COST FREE]ULLONG(ullong);
508         ullong FUN [LFTA_LEGAL,COST FREE]ULLONG(llong);
509         ullong FUN [LFTA_LEGAL,COST FREE]ULLONG(float);
510
511         llong FUN [LFTA_LEGAL,COST FREE]LLONG(uint);
512         llong FUN [LFTA_LEGAL,COST FREE]LLONG(int);
513         llong FUN [LFTA_LEGAL,COST FREE]LLONG(ullong);
514         llong FUN [LFTA_LEGAL,COST FREE]LLONG(llong);
515         llong FUN [LFTA_LEGAL,COST FREE]LLONG(float);
516
517         llong FUN [LFTA_LEGAL,COST LOW] to_llong(string);
518
519 ///////////////////////////////////////////////////////////
520 //          Numeric functions
521 ///////////////////////////////////////////////////////////
522
523         float FUN [LFTA_LEGAL, COST LOW] sqrt(float); 
524         float FUN [LFTA_LEGAL, COST LOW] pow(float, float); 
525         float FUN [LFTA_LEGAL, COST LOW] sin(float); 
526         float FUN [LFTA_LEGAL, COST LOW] cos(float); 
527         float FUN [LFTA_LEGAL, COST LOW] tan(float); 
528         float FUN [LFTA_LEGAL, COST LOW] asin(float); 
529         float FUN [LFTA_LEGAL, COST LOW] acos(float); 
530         float FUN [LFTA_LEGAL, COST LOW] atan(float); 
531         float FUN [LFTA_LEGAL, COST LOW] log(float); 
532         float FUN [LFTA_LEGAL, COST LOW] log2(float); 
533         float FUN [LFTA_LEGAL, COST LOW] log10(float); 
534         float FUN [LFTA_LEGAL, COST LOW] ceil(float); 
535         float FUN [LFTA_LEGAL, COST LOW] floor(float); 
536         float FUN [LFTA_LEGAL, COST LOW] fmod(float); 
537         float FUN [LFTA_LEGAL, COST LOW] trunc(float); 
538
539
540
541 ///////////////////////////////////////////////////////////
542 //          Convert an IPv4 address 
543 ///////////////////////////////////////////////////////////
544
545
546     uint FUN [PARTIAL,COST HIGH] strtoi(string);
547         IP FUN [PARTIAL,COST HIGH] strtoip(string); 
548
549 //      for constant strings - faster at runtime
550         uint FUN [LFTA_LEGAL,COST LOW] strtoi_c(string HANDLE);
551         IP FUN [LFTA_LEGAL,COST LOW] strtoip_c(string HANDLE); 
552
553
554 /////////////////////////////////////////////////////////////
555 //      Add up uints in a delimited ascii list.
556 //      return 135 on '34|45|56' and sep '|'
557
558         llong FUN [LFTA_LEGAL,COST LOW] sum_uint_in_list(string, string CONST);
559
560
561 ///////////////////////////////////////////////////////////
562 //          Compute running sum
563 ///////////////////////////////////////////////////////////
564
565
566
567     ullong UDAF [RUNNING, SUBAGGR moving_sum_lfta, SUPERAGGR super_moving_sum_udaf ] moving_sum_udaf fstring12 (uint, uint);
568
569         uint EXTR moving_sum moving_sum_udaf moving_sum_extract (uint,uint);
570         uint FUN  [COST LOW] moving_sum_extract(ullong);
571
572         float EXTR moving_sum_exp moving_sum_udaf moving_sum_extract_exp (uint,uint, float);
573         float FUN  [COST LOW]  moving_sum_extract_exp(ullong, float);
574
575         ullong UDAF [RUNNING] super_moving_sum_udaf fstring12 (ullong);
576         ullong UDAF moving_sum_lfta fstring8 (uint, uint);
577
578
579 ///////////////////////////////////////////////////////////
580 //               Compute the average of 
581 //              all positive numbers 
582 ///////////////////////////////////////////////////////////
583
584         float UDAF POSAVG fstring16(float);
585
586
587 ///////////////////////////////////////////////////////////
588 //               Simple average example 
589 ///////////////////////////////////////////////////////////
590
591         float EXTR extr_avg avg_udaf extr_avg_fcn (uint);
592         float FUN extr_avg_fcn (string);
593         string UDAF[SUBAGGR avg_udaf_lfta, SUPERAGGR avg_udaf_hfta] avg_udaf fstring12 (uint);
594         string UDAF avg_udaf_hfta fstring12 (string);
595         string UDAF avg_udaf_lfta fstring12 (uint);
596
597 ///////////////////////////////////////////////////////////
598 //               SAMPLING 
599 ///////////////////////////////////////////////////////////
600
601         fstring100 STATE smart_sampling_state;
602         int SFUN packet_count smart_sampling_state ();
603         float SFUN gamma smart_sampling_state ();
604         int SFUN do_clean_count smart_sampling_state ();
605         int SFUN init_threshold smart_sampling_state ();
606         int SFUN delay smart_sampling_state();
607         int SFUN newly_closed smart_sampling_state();
608
609 ///////////////////////////////////////////////////////////
610 //               Manku Heavy Hitter 
611 ///////////////////////////////////////////////////////////
612
613  
614         fstring20 STATE manku_hh_state;
615         BOOL SFUN local_count manku_hh_state (UINT);
616         int SFUN current_bucket manku_hh_state ();
617
618 ///////////////////////////////////////////////////////////
619 //         Flips approximate quantile
620 ///////////////////////////////////////////////////////////
621
622 // uint
623         uint EXTR quantile_of quant_ui_udaf_hftaZ extr_quant_ui_hftaZ_fcn (uint, float);
624         uint  FUN [COST LOW] extr_quant_ui_hftaZ_fcn(string, float);
625         uint EXTR median_of quant_ui_udaf_hftaZ extr_med_ui_hftaZ_fcn (uint);
626         uint  FUN [COST LOW] extr_med_ui_hftaZ_fcn(string);
627
628         string UDAF [SUBAGGR quant_ui_udaf_lfta3, SUPERAGGR quant_ui_udaf_hfta3] quant_ui_udaf_hftaZ fstring32 (uint);
629         string UDAF quant_ui_udaf_hfta3 fstring32 (string);
630         string UDAF quant_ui_udaf_lfta3 fstring2088 (uint);
631 // int
632         int EXTR quantile_of quant_i_udaf_hftaZ extr_quant_i_hftaZ_fcn (int, float);
633         int  FUN [COST LOW] extr_quant_i_hftaZ_fcn(string, float);
634         int EXTR median_of quant_i_udaf_hftaZ extr_med_i_hftaZ_fcn (int);
635         int  FUN [COST LOW] extr_med_i_hftaZ_fcn(string);
636
637         string UDAF [SUBAGGR quant_i_udaf_lfta3, SUPERAGGR quant_i_udaf_hfta3] quant_i_udaf_hftaZ fstring32 (int);
638         string UDAF quant_i_udaf_hfta3 fstring32 (string);
639         string UDAF quant_i_udaf_lfta3 fstring2088 (int);
640 // ullong
641         ullong EXTR quantile_of quant_ul_udaf_hftaZ extr_quant_ul_hftaZ_fcn (ullong, float);
642         ullong  FUN [COST LOW] extr_quant_ul_hftaZ_fcn(string, float);
643         ullong EXTR median_of quant_ul_udaf_hftaZ extr_med_ul_hftaZ_fcn (ullong);
644         ullong  FUN [COST LOW] extr_med_ul_hftaZ_fcn(string);
645
646         string UDAF [SUBAGGR quant_ul_udaf_lfta3, SUPERAGGR quant_ul_udaf_hfta3] quant_ul_udaf_hftaZ fstring32 (ullong);
647         string UDAF quant_ul_udaf_hfta3 fstring32 (string);
648         string UDAF quant_ul_udaf_lfta3 fstring2904 (ullong);
649 // llong
650         llong EXTR quantile_of quant_l_udaf_hftaZ extr_quant_l_hftaZ_fcn (llong, float);
651         llong  FUN [COST LOW] extr_quant_l_hftaZ_fcn(string, float);
652         llong EXTR median_of quant_l_udaf_hftaZ extr_med_l_hftaZ_fcn (llong);
653         llong  FUN [COST LOW] extr_med_l_hftaZ_fcn(string);
654
655         string UDAF [SUBAGGR quant_l_udaf_lfta3, SUPERAGGR quant_l_udaf_hfta3] quant_l_udaf_hftaZ fstring32 (llong);
656         string UDAF quant_l_udaf_hfta3 fstring32 (string);
657         string UDAF quant_l_udaf_lfta3 fstring2904 (llong);
658 // float
659         float EXTR quantile_of quant_f_udaf_hftaZ extr_quant_f_hftaZ_fcn (float, float);
660         float  FUN [COST LOW] extr_quant_f_hftaZ_fcn(string, float);
661         float EXTR median_of quant_f_udaf_hftaZ extr_med_f_hftaZ_fcn (float);
662         float  FUN [COST LOW] extr_med_f_hftaZ_fcn(string);
663
664         string UDAF [SUBAGGR quant_f_udaf_lfta3, SUPERAGGR quant_f_udaf_hfta3] quant_f_udaf_hftaZ fstring32 (float);
665         string UDAF quant_f_udaf_hfta3 fstring32 (string);
666         string UDAF quant_f_udaf_lfta3 fstring2904 (float);
667
668 ///////////////////////////////////////////////////////////
669 //               FIRST and LAST aggregation funciton
670 //      Should be replaced by builtins
671 ///////////////////////////////////////////////////////////
672
673 // FIRST
674         uint UDAF [RUNNING, SUBAGGR FIRST_lfta, SUPERAGGR FIRST_hfta] FIRST uint (uint);
675         uint UDAF [RUNNING] FIRST_hfta uint (uint);
676         uint UDAF [RUNNING] FIRST_lfta uint (uint);
677
678         int UDAF [RUNNING, SUBAGGR FIRST_INT_lfta, SUPERAGGR FIRST_INT_hfta] FIRST int (int);
679         int UDAF [RUNNING] FIRST_INT_hfta int (int);
680         int UDAF [RUNNING] FIRST_INT_lfta int (int);
681
682         ullong UDAF [RUNNING, SUBAGGR FIRST_ULL_lfta, SUPERAGGR FIRST_ULL_hfta] FIRST ullong (ullong);
683         ullong UDAF [RUNNING] FIRST_ULL_hfta ullong (ullong);
684         ullong UDAF [RUNNING] FIRST_ULL_lfta ullong (ullong);
685
686         llong UDAF [RUNNING, SUBAGGR FIRST_LL_lfta, SUPERAGGR FIRST_LL_hfta] FIRST llong (llong);
687         llong UDAF [RUNNING] FIRST_LL_hfta llong (llong);
688         llong UDAF [RUNNING] FIRST_LL_lfta llong (llong);
689
690         IP UDAF [RUNNING, SUBAGGR FIRST_lfta, SUPERAGGR FIRST_hfta] FIRST IP (IP);
691         IP UDAF [RUNNING] FIRST_hfta IP (IP);
692         IP UDAF [RUNNING] FIRST_lfta IP (IP);
693
694         string UDAF [RUNNING, SUBAGGR FIRST_STR_lfta, SUPERAGGR FIRST_STR_hfta] FIRST string (string);
695         string UDAF [RUNNING] FIRST_STR_hfta string (string);
696         string UDAF [RUNNING] FIRST_STR_lfta string (string);
697
698
699 // LAST
700         uint UDAF [RUNNING, SUBAGGR LAST_lfta, SUPERAGGR LAST_hfta] LAST uint (uint);
701         uint UDAF [RUNNING] LAST_hfta uint (uint);
702         uint UDAF [RUNNING] LAST_lfta uint (uint);
703
704         int UDAF [RUNNING, SUBAGGR LAST_INT_lfta, SUPERAGGR LAST_INT_hfta] LAST int (int);
705         int UDAF [RUNNING] LAST_INT_hfta int (int);
706         int UDAF [RUNNING] LAST_INT_lfta int (int);
707
708         ullong UDAF [RUNNING, SUBAGGR LAST_ULL_lfta, SUPERAGGR LAST_ULL_hfta] LAST ullong (ullong);
709         ullong UDAF [RUNNING] LAST_ULL_hfta ullong (ullong);
710         ullong UDAF [RUNNING] LAST_ULL_lfta ullong (ullong);
711
712         llong UDAF [RUNNING, SUBAGGR LAST_LL_lfta, SUPERAGGR LAST_LL_hfta] LAST llong (llong);
713         llong UDAF [RUNNING] LAST_LL_hfta llong (llong);
714         llong UDAF [RUNNING] LAST_LL_lfta llong (llong);
715
716         IP UDAF [RUNNING, SUBAGGR LAST_lfta, SUPERAGGR LAST_hfta] LAST IP (IP);
717         IP UDAF [RUNNING] LAST_hfta IP (IP);
718         IP UDAF [RUNNING] LAST_lfta IP (IP);
719
720         string UDAF [RUNNING, SUBAGGR LAST_STR_lfta, SUPERAGGR LAST_STR_hfta] LAST string (string);
721         string UDAF [RUNNING] LAST_STR_hfta string (string);
722         string UDAF [RUNNING] LAST_STR_lfta string (string);
723
724
725 ////////////////////////////////////////////////////////////
726 //      count_diff aggregation
727 //      count the # times the payload is different from the previous value
728 /////////////////////////////////////////////////////////////
729
730         uint UDAF [SUBAGGR count_diff_lfta_ui, SUPERAGGR count_diff_hfta] count_diff fstring16 (uint);
731         uint UDAF  count_diff_hfta fstring16 (string);
732         string UDAF  count_diff_lfta_ui fstring20 (uint);
733
734         uint UDAF [SUBAGGR count_diff_lfta_i, SUPERAGGR count_diff_hfta] count_diff fstring16 (int);
735         string UDAF  count_diff_lfta_i fstring20 (int);
736
737         uint UDAF [SUBAGGR count_diff_lfta_ul, SUPERAGGR count_diff_hfta] count_diff fstring16 (ullong);
738         string UDAF  count_diff_lfta_ul fstring20 (ullong);
739
740         uint UDAF [SUBAGGR count_diff_lfta_l, SUPERAGGR count_diff_hfta] count_diff fstring16 (llong);
741         string UDAF  count_diff_lfta_l fstring20 (llong);
742
743         uint UDAF [SUBAGGR count_diff_lfta_s, SUPERAGGR count_diff_hfta] count_diff fstring16 (string);
744         string UDAF  count_diff_lfta_s fstring20 (string);
745
746
747 ////////////////////////////////////////////////////////////////
748 //      string aggregation via catenation
749 //////////////////////////////////////////////////////
750
751         string UDAF [HFTA_ONLY] CAT_aggr fstring8 (string, string);
752
753 ///////////////////////////////////////////////////////////
754 //               integer array aggregation function
755 //      We are going to store 4 values in LFTA in fixed size buffer
756 //      plus one byte for array length (17 bytes total)
757 //      HFTA will combine partial aggregates
758 //              This seems to create a string with a comma-separated list of the uints
759 ///////////////////////////////////////////////////////////
760
761         string UDAF [RUNNING, SUBAGGR running_array_aggr_lfta, SUPERAGGR running_array_aggr_hfta] running_array_aggr string (uint);
762         string UDAF [RUNNING] running_array_aggr_hfta string (string);
763         string UDAF [RUNNING] running_array_aggr_lfta fstring17 (uint);
764         
765 //////////////////////////////////////////////////////////
766 //      Mapping functions
767 //      Should eventually be replaced by watchlist join ?
768 //////////////////////////////////
769         string FUN [HFTA_ONLY, COST EXPENSIVE] int_to_string_map(llong, string HANDLE);
770         string FUN [HFTA_ONLY, COST EXPENSIVE] int_to_string_map(ullong, string HANDLE);
771         string FUN [HFTA_ONLY, COST EXPENSIVE] int_to_string_map(int, string HANDLE);
772         string FUN [HFTA_ONLY, COST EXPENSIVE] int_to_string_map(uint, string HANDLE);
773
774 //////////////////////////////////////////////////////////
775 //      time-averaged aggregate.
776 //      time_avg(sample, ts, window_size)
777         float UDAF [HFTA_ONLY, RUNNING] time_avg fstring44 (uint, llong, llong) ;
778         float UDAF [HFTA_ONLY, RUNNING] time_avg fstring44 (int, llong, llong) ;
779         float UDAF [HFTA_ONLY, RUNNING] time_avg fstring44 (ullong, llong, llong) ;
780         float UDAF [HFTA_ONLY, RUNNING] time_avg fstring44 (llong, llong, llong) ;
781         float UDAF [HFTA_ONLY, RUNNING] time_avg fstring44 (float, llong, llong) ;
782
783 // ------------------------------------------------------------
784 //              running_sum_max : get the running sum of an int,
785 //              be able to report this sum and also its max value
786 //              during the time window
787
788         llong EXTR running_sum run_sum_max extr_running_sum (uint);
789         llong EXTR running_sum run_sum_max extr_running_sum (int);
790         llong EXTR running_sum run_sum_max extr_running_sum (llong);
791         llong EXTR running_sum run_sum_max extr_running_sum (ullong);
792         llong FUN [COST LOW] extr_running_sum(string);
793         llong EXTR running_sum_max run_sum_max extr_running_sum_max (uint);
794         llong EXTR running_sum_max run_sum_max extr_running_sum_max (int);
795         llong EXTR running_sum_max run_sum_max extr_running_sum_max (llong);
796         llong EXTR running_sum_max run_sum_max extr_running_sum_max (ullong);
797         llong FUN [COST LOW] extr_running_sum_max(string);
798         string UDAF [HFTA_ONLY, RUNNING] run_sum_max fstring16 (uint);
799         string UDAF [HFTA_ONLY, RUNNING] run_sum_max fstring16 (int);
800         string UDAF [HFTA_ONLY, RUNNING] run_sum_max fstring16 (ullong);
801         string UDAF [HFTA_ONLY, RUNNING] run_sum_max fstring16 (llong);
802
803 // ------------------------------------------------------------
804 //      to_hex_string : allow printing of binary strings
805
806         string FUN [HFTA_ONLY, COST EXPENSIVE] to_hex_string(string);
807
808 // -------------------------------------------------------------------
809 //      approx_count_distinct : approximate the count distinct by
810 //      taking minhashes.  accurate to 7%, tested up to 100M distinct
811 //      items.
812 //
813 //      TODO : allow running aggregates to be used in regular aggregation?
814
815         float EXTR approx_count_distinct approx_count_distinct_udaf extr_approx_count_distinct(string);
816         string UDAF approx_count_distinct_udaf fstring1000 (string);
817         float FUN extr_approx_count_distinct(string);
818
819         float EXTR running_approx_count_distinct running_approx_count_distinct_udaf extr_approx_count_distinct(string);
820         string UDAF [RUNNING] running_approx_count_distinct_udaf fstring1000 (string);
821         float FUN extr_approx_count_distinct(string);