FreeBASIC  0.91.0
rtl-math.bas
Go to the documentation of this file.
1 '' intrinsic runtime lib math functions (FIX, ACOS, LOG, ...)
2 ''
3 '' chng: oct/2004 written [v1ctor]
4 
5 #include once "fb.bi"
6 #include once "fbint.bi"
7 #include once "ast.bi"
8 #include once "rtl.bi"
9 
10 declare function hRndCallback( byval sym as FBSYMBOL ptr ) as integer
11 
12  dim shared as FB_RTL_PROCDEF funcdata( 0 to ... ) = _
13  { _
14 /' fb_LongintDIV cdecl ( byval x as longint, byval y as longint ) as longint '/ _
15  ( _
16  @FB_RTL_LONGINTDIV, @"__divdi3", _
17  FB_DATATYPE_LONGINT, FB_FUNCMODE_CDECL, _
18  NULL, FB_RTL_OPT_NONE, _
19  2, _
20  { _
21  ( FB_DATATYPE_LONGINT, FB_PARAMMODE_BYVAL, FALSE ), _
22  ( FB_DATATYPE_LONGINT, FB_PARAMMODE_BYVAL, FALSE ) _
23  } _
24  ), _
25 /' fb_ULongintDIV cdecl ( byval x as ulongint, byval y as ulongint ) as ulongint '/ _
26  ( _
27  @FB_RTL_ULONGINTDIV, @"__udivdi3", _
28  FB_DATATYPE_ULONGINT, FB_FUNCMODE_CDECL, _
29  NULL, FB_RTL_OPT_NONE, _
30  2, _
31  { _
32  ( FB_DATATYPE_ULONGINT, FB_PARAMMODE_BYVAL, FALSE ), _
33  ( FB_DATATYPE_ULONGINT, FB_PARAMMODE_BYVAL, FALSE ) _
34  } _
35  ), _
36 /' fb_LongintMOD cdecl ( byval x as longint, byval y as longint ) as longint '/ _
37  ( _
38  @FB_RTL_LONGINTMOD, @"__moddi3", _
39  FB_DATATYPE_LONGINT, FB_FUNCMODE_CDECL, _
40  NULL, FB_RTL_OPT_NONE, _
41  2, _
42  { _
43  ( FB_DATATYPE_LONGINT, FB_PARAMMODE_BYVAL, FALSE ), _
44  ( FB_DATATYPE_LONGINT, FB_PARAMMODE_BYVAL, FALSE ) _
45  } _
46  ), _
47 /' fb_ULongintMOD cdecl ( byval x as ulongint, byval y as ulongint ) as ulongint '/ _
48  ( _
49  @FB_RTL_ULONGINTMOD, @"__umoddi3", _
50  FB_DATATYPE_ULONGINT, FB_FUNCMODE_CDECL, _
51  NULL, FB_RTL_OPT_NONE, _
52  2, _
53  { _
54  ( FB_DATATYPE_ULONGINT, FB_PARAMMODE_BYVAL, FALSE ), _
55  ( FB_DATATYPE_ULONGINT, FB_PARAMMODE_BYVAL, FALSE ) _
56  } _
57  ), _
58 /' fb_Dbl2ULongint cdecl ( byval x as double ) as ulongint '/ _
59  ( _
60  @FB_RTL_DBL2ULONGINT, @"__fixunsdfdi", _
61  FB_DATATYPE_ULONGINT, FB_FUNCMODE_CDECL, _
62  NULL, FB_RTL_OPT_NONE, _
63  1, _
64  { _
65  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
66  } _
67  ), _
68 /' fb_Pow CDECL ( byval x as double, byval y as double ) as double '/ _
69  ( _
70  @FB_RTL_POW, @"pow", _
71  FB_DATATYPE_DOUBLE, FB_FUNCMODE_CDECL, _
72  NULL, FB_RTL_OPT_NONE, _
73  2, _
74  { _
75  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ), _
76  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
77  } _
78  ), _
79 /' sub randomize( byval seed as double = -1.0, byval algorithm as long = 0 ) '/ _
80  ( _
81  @"randomize", @"fb_Randomize", _
82  FB_DATATYPE_VOID, FB_FUNCMODE_FBCALL, _
83  @hRndCallback, FB_RTL_OPT_NONE, _
84  2, _
85  { _
86  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, TRUE, -1.0 ), _
87  ( FB_DATATYPE_LONG, FB_PARAMMODE_BYVAL, TRUE, 0 ) _
88  } _
89  ), _
90 /' rnd ( byval n as single ) as double '/ _
91  ( _
92  @"rnd", @"fb_Rnd", _
93  FB_DATATYPE_DOUBLE, FB_FUNCMODE_FBCALL, _
94  @hRndCallback, FB_RTL_OPT_NONE, _
95  1, _
96  { _
97  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, TRUE, 1.0 ) _
98  } _
99  ), _
100 /' sinf CDECL overload ( byval x as single ) as single '/ _
101  ( _
102  @FB_RTL_SIN, @"sinf", _
103  FB_DATATYPE_SINGLE, FB_FUNCMODE_CDECL, _
104  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
105  1, _
106  { _
107  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, FALSE ) _
108  } _
109  ), _
110 /' sin CDECL overload ( byval x as double ) as double '/ _
111  ( _
112  @FB_RTL_SIN, @"sin", _
113  FB_DATATYPE_DOUBLE, FB_FUNCMODE_CDECL, _
114  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
115  1, _
116  { _
117  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
118  } _
119  ), _
120 /' asinf CDECL overload ( byval x as single ) as single '/ _
121  ( _
122  @FB_RTL_ASIN, @"asinf", _
123  FB_DATATYPE_SINGLE, FB_FUNCMODE_CDECL, _
124  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
125  1, _
126  { _
127  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, FALSE ) _
128  } _
129  ), _
130 /' asin CDECL overload ( byval x as double ) as double '/ _
131  ( _
132  @FB_RTL_ASIN, @"asin", _
133  FB_DATATYPE_DOUBLE, FB_FUNCMODE_CDECL, _
134  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
135  1, _
136  { _
137  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
138  } _
139  ), _
140 /' cosf CDECL overload ( byval x as single ) as single '/ _
141  ( _
142  @FB_RTL_COS, @"cosf", _
143  FB_DATATYPE_SINGLE, FB_FUNCMODE_CDECL, _
144  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
145  1, _
146  { _
147  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, FALSE ) _
148  } _
149  ), _
150 /' cos CDECL overload ( byval x as double ) as double '/ _
151  ( _
152  @FB_RTL_COS, @"cos", _
153  FB_DATATYPE_DOUBLE, FB_FUNCMODE_CDECL, _
154  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
155  1, _
156  { _
157  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
158  } _
159  ), _
160 /' acosf CDECL overload ( byval x as single ) as single '/ _
161  ( _
162  @FB_RTL_ACOS, @"acosf", _
163  FB_DATATYPE_SINGLE, FB_FUNCMODE_CDECL, _
164  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
165  1, _
166  { _
167  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, FALSE ) _
168  } _
169  ), _
170 /' acos CDECL overload ( byval x as double ) as double '/ _
171  ( _
172  @FB_RTL_ACOS, @"acos", _
173  FB_DATATYPE_DOUBLE, FB_FUNCMODE_CDECL, _
174  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
175  1, _
176  { _
177  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
178  } _
179  ), _
180 /' tanf CDECL overload ( byval x as single ) as single '/ _
181  ( _
182  @FB_RTL_TAN, @"tanf", _
183  FB_DATATYPE_SINGLE, FB_FUNCMODE_CDECL, _
184  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
185  1, _
186  { _
187  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, FALSE ) _
188  } _
189  ), _
190 /' tan CDECL overload ( byval x as double ) as double '/ _
191  ( _
192  @FB_RTL_TAN, @"tan", _
193  FB_DATATYPE_DOUBLE, FB_FUNCMODE_CDECL, _
194  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
195  1, _
196  { _
197  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
198  } _
199  ), _
200 /' atanf CDECL overload ( byval x as single ) as single '/ _
201  ( _
202  @FB_RTL_ATAN, @"atanf", _
203  FB_DATATYPE_SINGLE, FB_FUNCMODE_CDECL, _
204  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
205  1, _
206  { _
207  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, FALSE ) _
208  } _
209  ), _
210 /' atan CDECL overload ( byval x as double ) as double '/ _
211  ( _
212  @FB_RTL_ATAN, @"atan", _
213  FB_DATATYPE_DOUBLE, FB_FUNCMODE_CDECL, _
214  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
215  1, _
216  { _
217  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
218  } _
219  ), _
220 /' sqrtf CDECL overload ( byval x as single ) as single '/ _
221  ( _
222  @FB_RTL_sqrt, @"sqrtf", _
223  FB_DATATYPE_SINGLE, FB_FUNCMODE_CDECL, _
224  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
225  1, _
226  { _
227  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, FALSE ) _
228  } _
229  ), _
230 /' sqrt CDECL overload ( byval x as double ) as double '/ _
231  ( _
232  @FB_RTL_sqrt, @"sqrt", _
233  FB_DATATYPE_DOUBLE, FB_FUNCMODE_CDECL, _
234  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
235  1, _
236  { _
237  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
238  } _
239  ), _
240 /' logf CDECL overload ( byval x as single ) as single '/ _
241  ( _
242  @FB_RTL_log, @"logf", _
243  FB_DATATYPE_SINGLE, FB_FUNCMODE_CDECL, _
244  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
245  1, _
246  { _
247  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, FALSE ) _
248  } _
249  ), _
250 /' log CDECL overload ( byval x as double ) as double '/ _
251  ( _
252  @FB_RTL_log, @"log", _
253  FB_DATATYPE_DOUBLE, FB_FUNCMODE_CDECL, _
254  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
255  1, _
256  { _
257  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
258  } _
259  ), _
260 /' expf CDECL overload ( byval x as single ) as single '/ _
261  ( _
262  @FB_RTL_exp, @"expf", _
263  FB_DATATYPE_SINGLE, FB_FUNCMODE_CDECL, _
264  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
265  1, _
266  { _
267  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, FALSE ) _
268  } _
269  ), _
270 /' exp CDECL overload ( byval x as double ) as double '/ _
271  ( _
272  @FB_RTL_exp, @"exp", _
273  FB_DATATYPE_DOUBLE, FB_FUNCMODE_CDECL, _
274  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
275  1, _
276  { _
277  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
278  } _
279  ), _
280 /' floorf CDECL overload ( byval x as single ) as single '/ _
281  ( _
282  @FB_RTL_floor, @"floorf", _
283  FB_DATATYPE_SINGLE, FB_FUNCMODE_CDECL, _
284  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
285  1, _
286  { _
287  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, FALSE ) _
288  } _
289  ), _
290 /' floor CDECL overload ( byval x as double ) as double '/ _
291  ( _
292  @FB_RTL_floor, @"floor", _
293  FB_DATATYPE_DOUBLE, FB_FUNCMODE_CDECL, _
294  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
295  1, _
296  { _
297  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
298  } _
299  ), _
300 /' function abs cdecl overload( byval x as long ) as long '/ _
301  ( _
302  @FB_RTL_abs, @"abs", _
303  FB_DATATYPE_LONG, FB_FUNCMODE_CDECL, _
304  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
305  1, _
306  { _
307  ( FB_DATATYPE_LONG, FB_PARAMMODE_BYVAL, FALSE ) _
308  } _
309  ), _
310 /' function abs cdecl overload( byval x as longint ) as longint '/ _
311  ( _
312  @FB_RTL_abs, @"llabs", _
313  FB_DATATYPE_LONGINT, FB_FUNCMODE_CDECL, _
314  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
315  1, _
316  { _
317  ( FB_DATATYPE_LONGINT, FB_PARAMMODE_BYVAL, FALSE ) _
318  } _
319  ), _
320 /' fabsf CDECL overload ( byval x as single ) as single '/ _
321  ( _
322  @FB_RTL_abs, @"fabsf", _
323  FB_DATATYPE_SINGLE, FB_FUNCMODE_CDECL, _
324  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
325  1, _
326  { _
327  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, FALSE ) _
328  } _
329  ), _
330 /' fabs CDECL overload ( byval x as double ) as double '/ _
331  ( _
332  @FB_RTL_abs, @"fabs", _
333  FB_DATATYPE_DOUBLE, FB_FUNCMODE_CDECL, _
334  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
335  1, _
336  { _
337  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
338  } _
339  ), _
340 /' function sgn overload( byval x as byte ) as long '/ _
341  ( _
342  @FB_RTL_sgn, @"fb_SGNb", _
343  FB_DATATYPE_LONG, FB_FUNCMODE_FBCALL, _
344  NULL, FB_RTL_OPT_OVER, _
345  1, _
346  { _
347  ( FB_DATATYPE_BYTE, FB_PARAMMODE_BYVAL, FALSE ) _
348  } _
349  ), _
350 /' function sgn overload( byval x as short ) as long '/ _
351  ( _
352  @FB_RTL_sgn, @"fb_SGNs", _
353  FB_DATATYPE_LONG, FB_FUNCMODE_FBCALL, _
354  NULL, FB_RTL_OPT_OVER, _
355  1, _
356  { _
357  ( FB_DATATYPE_SHORT, FB_PARAMMODE_BYVAL, FALSE ) _
358  } _
359  ), _
360 /' function sgn overload( byval x as long ) as long '/ _
361  ( _
362  @FB_RTL_sgn, @"fb_SGNi", _
363  FB_DATATYPE_LONG, FB_FUNCMODE_FBCALL, _
364  NULL, FB_RTL_OPT_OVER, _
365  1, _
366  { _
367  ( FB_DATATYPE_LONG, FB_PARAMMODE_BYVAL, FALSE ) _
368  } _
369  ), _
370 /' function sgn overload( byval x as longint ) as long '/ _
371  ( _
372  @FB_RTL_sgn, @"fb_SGNl", _
373  FB_DATATYPE_LONG, FB_FUNCMODE_FBCALL, _
374  NULL, FB_RTL_OPT_OVER, _
375  1, _
376  { _
377  ( FB_DATATYPE_LONGINT, FB_PARAMMODE_BYVAL, FALSE ) _
378  } _
379  ), _
380 /' function sgn overload( byval x as single ) as long '/ _
381  ( _
382  @FB_RTL_sgn, @"fb_SGNSingle", _
383  FB_DATATYPE_LONG, FB_FUNCMODE_FBCALL, _
384  NULL, FB_RTL_OPT_OVER, _
385  1, _
386  { _
387  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, FALSE ) _
388  } _
389  ), _
390 /' function sgn overload( byval x as double ) as long '/ _
391  ( _
392  @FB_RTL_sgn, @"fb_SGNDouble", _
393  FB_DATATYPE_LONG, FB_FUNCMODE_FBCALL, _
394  NULL, FB_RTL_OPT_OVER, _
395  1, _
396  { _
397  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
398  } _
399  ), _
400 /' fix overload ( byval x as single ) as single '/ _
401  ( _
402  @FB_RTL_fix, @"fb_FIXSingle", _
403  FB_DATATYPE_SINGLE, FB_FUNCMODE_FBCALL, _
404  NULL, FB_RTL_OPT_OVER, _
405  1, _
406  { _
407  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, FALSE ) _
408  } _
409  ), _
410 /' fix overload ( byval x as double ) as double '/ _
411  ( _
412  @FB_RTL_fix, @"fb_FIXDouble", _
413  FB_DATATYPE_DOUBLE, FB_FUNCMODE_FBCALL, _
414  NULL, FB_RTL_OPT_OVER, _
415  1, _
416  { _
417  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
418  } _
419  ), _
420 /' frac overload ( byval x as single ) as single '/ _
421  ( _
422  @FB_RTL_frac, @"fb_FRACf", _
423  FB_DATATYPE_SINGLE, FB_FUNCMODE_FBCALL, _
424  NULL, FB_RTL_OPT_OVER, _
425  1, _
426  { _
427  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, FALSE ) _
428  } _
429  ), _
430 /' frac overload ( byval x as double ) as double '/ _
431  ( _
432  @FB_RTL_frac, @"fb_FRACd", _
433  FB_DATATYPE_DOUBLE, FB_FUNCMODE_FBCALL, _
434  NULL, FB_RTL_OPT_OVER, _
435  1, _
436  { _
437  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
438  } _
439  ), _
440 /' atan2f CDECL overload ( byval x as single, byval y as single ) as single '/ _
441  ( _
442  @FB_RTL_ATAN2, @"atan2f", _
443  FB_DATATYPE_SINGLE, FB_FUNCMODE_CDECL, _
444  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
445  2, _
446  { _
447  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, FALSE ), _
448  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, FALSE ) _
449  } _
450  ), _
451 /' atan2 CDECL overload ( byval x as double, byval y as double ) as double '/ _
452  ( _
453  @FB_RTL_ATAN2, @"atan2", _
454  FB_DATATYPE_DOUBLE, FB_FUNCMODE_CDECL, _
455  NULL, FB_RTL_OPT_OVER or FB_RTL_OPT_GCCBUILTIN, _
456  2, _
457  { _
458  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ), _
459  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
460  } _
461  ), _
462 /' function ftosl cdecl( byval x as single ) as longint '/ _
463  ( _
464  @FB_RTL_FTOSL, @FB_RTL_FTOSL, _
465  FB_DATATYPE_LONGINT, FB_FUNCMODE_CDECL, _
466  NULL, FB_RTL_OPT_IRHLCBUILTIN, _
467  1, _
468  { _
469  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, FALSE ) _
470  } _
471  ), _
472 /' function dtosl cdecl( byval x as double ) as longint '/ _
473  ( _
474  @FB_RTL_DTOSL,@FB_RTL_DTOSL, _
475  FB_DATATYPE_LONGINT, FB_FUNCMODE_CDECL, _
476  NULL, FB_RTL_OPT_IRHLCBUILTIN, _
477  1, _
478  { _
479  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
480  } _
481  ), _
482 /' function ftosi cdecl( byval x as single ) as long '/ _
483  ( _
484  @FB_RTL_FTOSI, @FB_RTL_FTOSI, _
485  FB_DATATYPE_LONG, FB_FUNCMODE_CDECL, _
486  NULL, FB_RTL_OPT_IRHLCBUILTIN, _
487  1, _
488  { _
489  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, FALSE ) _
490  } _
491  ), _
492 /' function dtosi cdecl( byval x as double ) as long '/ _
493  ( _
494  @FB_RTL_DTOSI, @FB_RTL_DTOSI, _
495  FB_DATATYPE_LONG, FB_FUNCMODE_CDECL, _
496  NULL, FB_RTL_OPT_IRHLCBUILTIN, _
497  1, _
498  { _
499  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
500  } _
501  ), _
502 /' ftoss cdecl ( byval x as single ) as short '/ _
503  ( _
504  @FB_RTL_FTOSS, @FB_RTL_FTOSS, _
505  FB_DATATYPE_SHORT, FB_FUNCMODE_CDECL, _
506  NULL, FB_RTL_OPT_IRHLCBUILTIN, _
507  1, _
508  { _
509  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, FALSE ) _
510  } _
511  ), _
512 /' dtoss cdecl ( byval x as double ) as short '/ _
513  ( _
514  @FB_RTL_DTOSS, @FB_RTL_DTOSS, _
515  FB_DATATYPE_SHORT, FB_FUNCMODE_CDECL, _
516  NULL, FB_RTL_OPT_IRHLCBUILTIN, _
517  1, _
518  { _
519  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
520  } _
521  ), _
522 /' ftosb cdecl ( byval x as single ) as byte '/ _
523  ( _
524  @FB_RTL_FTOSB, @FB_RTL_FTOSB, _
525  FB_DATATYPE_BYTE, FB_FUNCMODE_CDECL, _
526  NULL, FB_RTL_OPT_IRHLCBUILTIN, _
527  1, _
528  { _
529  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, FALSE ) _
530  } _
531  ), _
532 /' dtosb cdecl ( byval x as double ) as byte '/ _
533  ( _
534  @FB_RTL_DTOSB, @FB_RTL_DTOSB, _
535  FB_DATATYPE_BYTE, FB_FUNCMODE_CDECL, _
536  NULL, FB_RTL_OPT_IRHLCBUILTIN, _
537  1, _
538  { _
539  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
540  } _
541  ), _
542 /' ftoul cdecl ( byval x as single ) as long '/ _
543  ( _
544  @FB_RTL_FTOUL, @FB_RTL_FTOUL, _
545  FB_DATATYPE_ULONGINT, FB_FUNCMODE_CDECL, _
546  NULL, FB_RTL_OPT_IRHLCBUILTIN, _
547  1, _
548  { _
549  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, FALSE ) _
550  } _
551  ), _
552 /' dtoul cdecl ( byval x as double ) as long '/ _
553  ( _
554  @FB_RTL_DTOUL, @FB_RTL_DTOUL, _
555  FB_DATATYPE_ULONGINT, FB_FUNCMODE_CDECL, _
556  NULL, FB_RTL_OPT_IRHLCBUILTIN, _
557  1, _
558  { _
559  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
560  } _
561  ), _
562 /' function ftoui cdecl( byval x as single ) as ulong '/ _
563  ( _
564  @FB_RTL_FTOUI, @FB_RTL_FTOUI, _
565  FB_DATATYPE_ULONG, FB_FUNCMODE_CDECL, _
566  NULL, FB_RTL_OPT_IRHLCBUILTIN, _
567  1, _
568  { _
569  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, FALSE ) _
570  } _
571  ), _
572 /' function dtoui cdecl( byval x as double ) as ulong '/ _
573  ( _
574  @FB_RTL_DTOUI, @FB_RTL_DTOUI, _
575  FB_DATATYPE_ULONG, FB_FUNCMODE_CDECL, _
576  NULL, FB_RTL_OPT_IRHLCBUILTIN, _
577  1, _
578  { _
579  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
580  } _
581  ), _
582 /' function ftous cdecl( byval x as single ) as ushort '/ _
583  ( _
584  @FB_RTL_FTOUS, @FB_RTL_FTOUS, _
585  FB_DATATYPE_USHORT, FB_FUNCMODE_CDECL, _
586  NULL, FB_RTL_OPT_IRHLCBUILTIN, _
587  1, _
588  { _
589  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, FALSE ) _
590  } _
591  ), _
592 /' function dtous cdecl( byval x as double ) as ushort '/ _
593  ( _
594  @FB_RTL_DTOUS, @FB_RTL_DTOUS, _
595  FB_DATATYPE_USHORT, FB_FUNCMODE_CDECL, _
596  NULL, FB_RTL_OPT_IRHLCBUILTIN, _
597  1, _
598  { _
599  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
600  } _
601  ), _
602 /' function ftoub cdecl( byval x as single ) as ubyte '/ _
603  ( _
604  @FB_RTL_FTOUB, @FB_RTL_FTOUB, _
605  FB_DATATYPE_UBYTE, FB_FUNCMODE_CDECL, _
606  NULL, FB_RTL_OPT_IRHLCBUILTIN, _
607  1, _
608  { _
609  ( FB_DATATYPE_SINGLE, FB_PARAMMODE_BYVAL, FALSE ) _
610  } _
611  ), _
612 /' function dtoub cdecl( byval x as double ) as ubyte '/ _
613  ( _
614  @FB_RTL_DTOUB, @FB_RTL_DTOUB, _
615  FB_DATATYPE_UBYTE, FB_FUNCMODE_CDECL, _
616  NULL, FB_RTL_OPT_IRHLCBUILTIN, _
617  1, _
618  { _
619  ( FB_DATATYPE_DOUBLE, FB_PARAMMODE_BYVAL, FALSE ) _
620  } _
621  ), _
622 /' EOL '/ _
623  ( _
624  NULL _
625  ) _
626  }
627 
628 '':::::
630 
632 
633 end sub
634 
635 '':::::
637 
638  '' procs will be deleted when symbEnd is called
639 
640 end sub
641 
642 '':::::
643 function rtlMathPow _
644  ( _
645  byval xexpr as ASTNODE ptr, _
646  byval yexpr as ASTNODE ptr _
647  ) as ASTNODE ptr
648 
649  dim as ASTNODE ptr proc = any
650 
651  function = NULL
652 
653  ''
654  proc = astNewCALL( PROCLOOKUP( POW ) )
655 
656  '' byval x as double
657  if( astNewARG( proc, xexpr ) = NULL ) then
658  exit function
659  end if
660 
661  '' byval y as double
662  if( astNewARG( proc, yexpr ) = NULL ) then
663  exit function
664  end if
665 
666  ''
667  function = proc
668 
669 end function
670 
671 '':::::
672 function rtlMathLongintDIV _
673  ( _
674  byval dtype as integer, _
675  byval lexpr as ASTNODE ptr, _
676  byval ldtype as integer, _
677  byval rexpr as ASTNODE ptr, _
678  byval rdtype as integer _
679  ) as ASTNODE ptr
680 
681  dim as ASTNODE ptr proc = any
682  dim as FBSYMBOL ptr f = any
683 
684  function = NULL
685 
686  if( typeGet( dtype ) = FB_DATATYPE_LONGINT ) then
687  f = PROCLOOKUP( LONGINTDIV )
688  else
689  f = PROCLOOKUP( ULONGINTDIV )
690  end if
691 
692  proc = astNewCALL( f )
693 
694  ''
695  if( astNewARG( proc, lexpr, ldtype ) = NULL ) then
696  exit function
697  end if
698 
699  if( astNewARG( proc, rexpr, rdtype ) = NULL ) then
700  exit function
701  end if
702 
703  function = proc
704 
705 end function
706 
707 '':::::
708 function rtlMathLongintMOD _
709  ( _
710  byval dtype as integer, _
711  byval lexpr as ASTNODE ptr, _
712  byval ldtype as integer, _
713  byval rexpr as ASTNODE ptr, _
714  byval rdtype as integer _
715  ) as ASTNODE ptr
716 
717  dim as ASTNODE ptr proc = any
718  dim as FBSYMBOL ptr f = any
719 
720  function = NULL
721 
722  if( typeGet( dtype ) = FB_DATATYPE_LONGINT ) then
723  f = PROCLOOKUP( LONGINTMOD )
724  else
725  f = PROCLOOKUP( ULONGINTMOD )
726  end if
727 
728  proc = astNewCALL( f )
729 
730  ''
731  if( astNewARG( proc, lexpr, ldtype ) = NULL ) then
732  exit function
733  end if
734 
735  if( astNewARG( proc, rexpr, rdtype ) = NULL ) then
736  exit function
737  end if
738 
739  function = proc
740 
741 end function
742 
743 '':::::
744 function rtlMathFp2ULongint _
745  ( _
746  byval expr as ASTNODE ptr, _
747  byval dtype as integer _
748  ) as ASTNODE ptr
749 
750  dim as ASTNODE ptr proc = any
751 
752  function = NULL
753 
754  proc = astNewCALL( PROCLOOKUP( DBL2ULONGINT) )
755 
756  ''
757  if( astNewARG( proc, expr, dtype ) = NULL ) then
758  exit function
759  end if
760 
761  function = proc
762 
763 end function
764 
765 
766 '':::::
767 function rtlMathUop _
768  ( _
769  byval op as integer, _
770  byval expr as ASTNODE ptr _
771  ) as ASTNODE ptr
772 
773  dim as FBSYMBOL ptr sym = any
774 
775  function = NULL
776 
777  select case as const op
778  case AST_OP_SGN
779  sym = PROCLOOKUP( SGN )
780 
781  case AST_OP_ABS
782  sym = PROCLOOKUP( ABS )
783 
784  case AST_OP_FIX
785  sym = PROCLOOKUP( FIX )
786 
787  case AST_OP_FRAC
788  sym = PROCLOOKUP( FRAC )
789 
790  case AST_OP_SIN
791  sym = PROCLOOKUP( SIN )
792 
793  case AST_OP_ASIN
794  sym = PROCLOOKUP( ASIN )
795 
796  case AST_OP_COS
797  sym = PROCLOOKUP( COS )
798 
799  case AST_OP_ACOS
800  sym = PROCLOOKUP( ACOS )
801 
802  case AST_OP_TAN
803  sym = PROCLOOKUP( TAN )
804 
805  case AST_OP_ATAN
806  sym = PROCLOOKUP( ATAN )
807 
808  case AST_OP_SQRT
809  sym = PROCLOOKUP( SQRT )
810 
811  case AST_OP_LOG
812  sym = PROCLOOKUP( LOG )
813 
814  case AST_OP_EXP
815  sym = PROCLOOKUP( EXP )
816 
817  case AST_OP_FLOOR
818  sym = PROCLOOKUP( FLOOR )
819 
820  case else
821  exit function
822 
823  end select
824 
825  function = rtlOvlProcCall( sym, expr )
826 
827 end function
828 
829 '':::::
830 function rtlMathBop _
831  ( _
832  byval op as integer, _
833  byval lexpr as ASTNODE ptr, _
834  byval rexpr as ASTNODE ptr _
835  ) as ASTNODE ptr
836 
837  dim as FBSYMBOL ptr sym = any
838 
839  function = NULL
840 
841  select case as const op
842  case AST_OP_ATAN2
843  sym = PROCLOOKUP( ATAN2 )
844 
845  case else
846  exit function
847 
848  end select
849 
850  function = rtlOvlProcCall( sym, lexpr, rexpr )
851 
852 end function
853 
854 '':::::
855 function rtlMathFTOI _
856  ( _
857  byval expr as ASTNODE ptr, _
858  byval to_dtype as integer _
859  ) as ASTNODE ptr
860 
861  dim as FBSYMBOL ptr sym = any
862 
863  function = NULL
864 
865  var from_dtype = astGetDataType( expr )
866 
867  select case as const( typeGetSizeType( to_dtype ) )
868  case FB_SIZETYPE_INT8
869  if( from_dtype = FB_DATATYPE_SINGLE ) then
870  sym = PROCLOOKUP( FTOSB )
871  else
872  sym = PROCLOOKUP( DTOSB )
873  end if
874 
875  case FB_SIZETYPE_UINT8
876  if( from_dtype = FB_DATATYPE_SINGLE ) then
877  sym = PROCLOOKUP( FTOUB )
878  else
879  sym = PROCLOOKUP( DTOUB )
880  end if
881 
882  case FB_SIZETYPE_INT16
883  if( from_dtype = FB_DATATYPE_SINGLE ) then
884  sym = PROCLOOKUP( FTOSS )
885  else
886  sym = PROCLOOKUP( DTOSS )
887  end if
888 
889  case FB_SIZETYPE_UINT16
890  if( from_dtype = FB_DATATYPE_SINGLE ) then
891  sym = PROCLOOKUP( FTOUS )
892  else
893  sym = PROCLOOKUP( DTOUS )
894  end if
895 
896  case FB_SIZETYPE_INT32
897  if( from_dtype = FB_DATATYPE_SINGLE ) then
898  sym = PROCLOOKUP( FTOSI )
899  else
900  sym = PROCLOOKUP( DTOSI )
901  end if
902 
903  case FB_SIZETYPE_UINT32
904  if( from_dtype = FB_DATATYPE_SINGLE ) then
905  sym = PROCLOOKUP( FTOUI )
906  else
907  sym = PROCLOOKUP( DTOUI )
908  end if
909 
910  case FB_SIZETYPE_INT64
911  if( from_dtype = FB_DATATYPE_SINGLE ) then
912  sym = PROCLOOKUP( FTOSL )
913  else
914  sym = PROCLOOKUP( DTOSL )
915  end if
916 
917  case FB_SIZETYPE_UINT64
918  if( from_dtype = FB_DATATYPE_SINGLE ) then
919  sym = PROCLOOKUP( FTOUL )
920  else
921  sym = PROCLOOKUP( DTOUL )
922  end if
923 
924  case else
925  exit function
926 
927  end select
928 
929  var proc = astNewCALL( sym )
930 
931  if( astNewARG( proc, expr ) = NULL ) then
932  exit function
933  end if
934 
935  function = proc
936 
937 end function
938 
939 function hRndCallback( byval sym as FBSYMBOL ptr ) as integer
940  static as integer added = FALSE
941 
942  if( added = FALSE ) then
943  added = TRUE
944  select case env.clopt.target
945  case FB_COMPTARGET_WIN32, FB_COMPTARGET_CYGWIN
946  fbAddLib( "advapi32" )
947  end select
948  end if
949 
950  return TRUE
951 end function
952