11 declare function hMultithread_cb (
byval sym
as FBSYMBOL
ptr )
as integer
12 declare function hThreadCall_cb (
byval sym
as FBSYMBOL
ptr )
as integer
18 @FB_RTL_CPUDETECT, NULL, _
19 FB_DATATYPE_ULONG, FB_FUNCMODE_CDECL, _
20 NULL, FB_RTL_OPT_X86ONLY, _
26 FB_DATATYPE_VOID, FB_FUNCMODE_FBCALL, _
27 NULL, FB_RTL_OPT_NONE, _
30 ( FB_DATATYPE_LONG, FB_PARAMMODE_BYVAL, FALSE ), _
31 ( typeMultAddrOf( FB_DATATYPE_CHAR, 2 ), FB_PARAMMODE_BYVAL, FALSE ), _
32 ( FB_DATATYPE_LONG, FB_PARAMMODE_BYVAL, FALSE ) _
37 @FB_RTL_INITSIGNALS, NULL, _
38 FB_DATATYPE_VOID, FB_FUNCMODE_FBCALL, _
39 NULL, FB_RTL_OPT_NONE, _
44 @FB_RTL_INITCRTCTOR, @
"__main", _
45 FB_DATATYPE_VOID, FB_FUNCMODE_CDECL, _
46 NULL, FB_RTL_OPT_NONE, _
52 FB_DATATYPE_VOID, FB_FUNCMODE_FBCALL, _
53 NULL, FB_RTL_OPT_NONE, _
56 ( FB_DATATYPE_LONG, FB_PARAMMODE_BYVAL, FALSE ) _
61 @FB_RTL_ATEXIT, @
"atexit", _
62 FB_DATATYPE_LONG, FB_FUNCMODE_CDECL, _
63 NULL, FB_RTL_OPT_NONE, _
66 ( typeAddrOf( FB_DATATYPE_VOID ), FB_PARAMMODE_BYVAL, FALSE ) _
71 @
"command", @
"fb_Command", _
72 FB_DATATYPE_STRING, FB_FUNCMODE_FBCALL, _
73 NULL, FB_RTL_OPT_STRSUFFIX, _
76 ( FB_DATATYPE_LONG, FB_PARAMMODE_BYVAL, TRUE, -1 ) _
81 @
"curdir", @
"fb_CurDir", _
82 FB_DATATYPE_STRING, FB_FUNCMODE_FBCALL, _
83 NULL, FB_RTL_OPT_NOQB, _
88 @
"exepath", @
"fb_ExePath", _
89 FB_DATATYPE_STRING, FB_FUNCMODE_FBCALL, _
90 NULL, FB_RTL_OPT_NOQB, _
95 @
"timer", @
"fb_Timer", _
96 FB_DATATYPE_DOUBLE, FB_FUNCMODE_FBCALL, _
97 NULL, FB_RTL_OPT_NONE, _
102 @
"time", @
"fb_Time", _
103 FB_DATATYPE_STRING, FB_FUNCMODE_FBCALL, _
104 NULL, FB_RTL_OPT_STRSUFFIX, _
109 @
"date", @
"fb_Date", _
110 FB_DATATYPE_STRING, FB_FUNCMODE_FBCALL, _
111 NULL, FB_RTL_OPT_STRSUFFIX, _
116 @
"shell", @
"fb_Shell", _
117 FB_DATATYPE_LONG, FB_FUNCMODE_FBCALL, _
118 NULL, FB_RTL_OPT_NONE, _
121 ( FB_DATATYPE_STRING, FB_PARAMMODE_BYREF, TRUE, NULL ) _
126 @
"system", @
"fb_End", _
127 FB_DATATYPE_VOID, FB_FUNCMODE_FBCALL, _
128 NULL, FB_RTL_OPT_NONE, _
131 ( FB_DATATYPE_LONG, FB_PARAMMODE_BYVAL, TRUE, 0 ) _
136 @
"stop", @
"fb_End", _
137 FB_DATATYPE_VOID, FB_FUNCMODE_FBCALL, _
138 NULL, FB_RTL_OPT_NONE, _
141 ( FB_DATATYPE_LONG, FB_PARAMMODE_BYVAL, TRUE, 0 ) _
147 FB_DATATYPE_LONG, FB_FUNCMODE_FBCALL, _
148 NULL, FB_RTL_OPT_NONE, _
151 ( FB_DATATYPE_STRING, FB_PARAMMODE_BYREF, FALSE ), _
152 ( FB_DATATYPE_STRING, FB_PARAMMODE_BYREF, TRUE, NULL ) _
157 @
"chain", @
"fb_Chain", _
158 FB_DATATYPE_LONG, FB_FUNCMODE_FBCALL, _
159 NULL, FB_RTL_OPT_NONE, _
162 ( FB_DATATYPE_STRING, FB_PARAMMODE_BYREF, FALSE ) _
167 @
"exec", @
"fb_Exec", _
168 FB_DATATYPE_LONG, FB_FUNCMODE_FBCALL, _
169 NULL, FB_RTL_OPT_NOQB, _
172 ( FB_DATATYPE_STRING, FB_PARAMMODE_BYREF, FALSE ), _
173 ( FB_DATATYPE_STRING, FB_PARAMMODE_BYREF, FALSE ) _
178 @
"environ", @
"fb_GetEnviron", _
179 FB_DATATYPE_STRING, FB_FUNCMODE_FBCALL, _
180 NULL, FB_RTL_OPT_STRSUFFIX, _
183 ( FB_DATATYPE_STRING, FB_PARAMMODE_BYREF, FALSE ) _
188 @
"setenviron", @
"fb_SetEnviron", _
189 FB_DATATYPE_LONG, FB_FUNCMODE_FBCALL, _
190 NULL, FB_RTL_OPT_NONE, _
193 ( FB_DATATYPE_STRING,FB_PARAMMODE_BYREF, FALSE ) _
198 @
"sleep", @
"fb_Sleep", _
199 FB_DATATYPE_VOID, FB_FUNCMODE_FBCALL, _
200 @rtlMultinput_cb, FB_RTL_OPT_OVER
or FB_RTL_OPT_NOQB, _
203 ( FB_DATATYPE_LONG, FB_PARAMMODE_BYVAL, TRUE, -1 ) _
208 @
"sleep", @
"fb_SleepQB", _
209 FB_DATATYPE_VOID, FB_FUNCMODE_FBCALL, _
210 @rtlMultinput_cb, FB_RTL_OPT_OVER
or FB_RTL_OPT_QBONLY, _
213 ( FB_DATATYPE_LONG, FB_PARAMMODE_BYVAL, TRUE, -1 ) _
218 @
"sleep", @
"fb_SleepEx", _
219 FB_DATATYPE_LONG, FB_FUNCMODE_FBCALL, _
220 @rtlMultinput_cb, FB_RTL_OPT_OVER
or FB_RTL_OPT_ERROR, _
223 ( FB_DATATYPE_LONG, FB_PARAMMODE_BYVAL, FALSE ), _
224 ( FB_DATATYPE_LONG, FB_PARAMMODE_BYVAL, FALSE ) _
229 @
"dir", @
"fb_DirNext", _
230 FB_DATATYPE_STRING, FB_FUNCMODE_FBCALL, _
231 NULL, FB_RTL_OPT_OVER
or FB_RTL_OPT_NOQB, _
234 ( typeAddrOf( FB_DATATYPE_LONG ), FB_PARAMMODE_BYVAL, TRUE, NULL ) _
239 @
"dir", @
"fb_DirNext", _
240 FB_DATATYPE_STRING, FB_FUNCMODE_FBCALL, _
241 NULL, FB_RTL_OPT_OVER
or FB_RTL_OPT_NOQB, _
244 ( FB_DATATYPE_LONG, FB_PARAMMODE_BYREF, FALSE ) _
249 @
"dir", @
"fb_DirNext64", _
250 FB_DATATYPE_STRING, FB_FUNCMODE_FBCALL, _
251 NULL, FB_RTL_OPT_OVER
or FB_RTL_OPT_NOQB, _
254 ( FB_DATATYPE_LONGINT, FB_PARAMMODE_BYREF, FALSE ) _
262 FB_DATATYPE_STRING, FB_FUNCMODE_FBCALL, _
263 NULL, FB_RTL_OPT_OVER
or FB_RTL_OPT_NOQB, _
266 ( FB_DATATYPE_STRING, FB_PARAMMODE_BYREF, FALSE ), _
267 ( FB_DATATYPE_LONG, FB_PARAMMODE_BYVAL, TRUE, &h21 ), _
268 ( typeAddrOf( FB_DATATYPE_LONG ), FB_PARAMMODE_BYVAL, TRUE, NULL ) _
276 FB_DATATYPE_STRING, FB_FUNCMODE_FBCALL, _
277 NULL, FB_RTL_OPT_OVER
or FB_RTL_OPT_NOQB, _
280 ( FB_DATATYPE_STRING, FB_PARAMMODE_BYREF, FALSE ), _
281 ( FB_DATATYPE_LONG, FB_PARAMMODE_BYVAL, TRUE, &h21 ), _
282 ( FB_DATATYPE_LONG, FB_PARAMMODE_BYREF, FALSE ) _
289 @
"dir", @
"fb_Dir64", _
290 FB_DATATYPE_STRING, FB_FUNCMODE_FBCALL, _
291 NULL, FB_RTL_OPT_OVER
or FB_RTL_OPT_NOQB, _
294 ( FB_DATATYPE_STRING, FB_PARAMMODE_BYREF, FALSE ), _
295 ( FB_DATATYPE_LONG, FB_PARAMMODE_BYVAL, TRUE, &h21 ), _
296 ( FB_DATATYPE_LONGINT, FB_PARAMMODE_BYREF, FALSE ) _
301 @
"settime", @
"fb_SetTime", _
302 FB_DATATYPE_LONG, FB_FUNCMODE_FBCALL, _
303 NULL, FB_RTL_OPT_NONE, _
306 ( FB_DATATYPE_STRING, FB_PARAMMODE_BYREF, FALSE ) _
311 @
"setdate", @
"fb_SetDate", _
312 FB_DATATYPE_LONG, FB_FUNCMODE_FBCALL, _
313 NULL, FB_RTL_OPT_NONE, _
316 ( FB_DATATYPE_STRING, FB_PARAMMODE_BYREF, FALSE ) _
326 @
"threadcreate", @
"fb_ThreadCreate", _
327 typeAddrOf( FB_DATATYPE_VOID ), FB_FUNCMODE_FBCALL, _
331 ( typeAddrOf( FB_DATATYPE_FUNCTION ), FB_PARAMMODE_BYVAL, TRUE, 1 ), _
332 ( typeAddrOf( FB_DATATYPE_VOID ), FB_PARAMMODE_BYVAL, FALSE ), _
333 ( FB_DATATYPE_VOID, NULL, FALSE ), _
334 ( typeAddrOf( FB_DATATYPE_VOID ), FB_PARAMMODE_BYVAL, TRUE, 0 ), _
335 ( FB_DATATYPE_INTEGER, FB_PARAMMODE_BYVAL, TRUE, 0 ) _
340 @
"threadwait", @
"fb_ThreadWait", _
341 FB_DATATYPE_VOID, FB_FUNCMODE_FBCALL, _
345 ( typeAddrOf( FB_DATATYPE_VOID ), FB_PARAMMODE_BYVAL, FALSE ) _
351 @
"fb_ThreadCall", NULL, _
352 typeAddrOf( FB_DATATYPE_VOID ), FB_FUNCMODE_CDECL, _
356 ( typeAddrOf( FB_DATATYPE_VOID ), FB_PARAMMODE_BYVAL, FALSE ), _
357 ( FB_DATATYPE_LONG, FB_PARAMMODE_BYVAL, FALSE ), _
358 ( FB_DATATYPE_INTEGER, FB_PARAMMODE_BYVAL, FALSE ), _
359 ( FB_DATATYPE_LONG, FB_PARAMMODE_BYVAL, FALSE ), _
360 ( FB_DATATYPE_INVALID, FB_PARAMMODE_VARARG, FALSE ) _
365 @
"mutexcreate", @
"fb_MutexCreate", _
366 typeAddrOf( FB_DATATYPE_VOID ), FB_FUNCMODE_FBCALL, _
367 NULL, FB_RTL_OPT_MT
or FB_RTL_OPT_NOQB, _
372 @
"mutexdestroy", @
"fb_MutexDestroy", _
373 FB_DATATYPE_VOID, FB_FUNCMODE_FBCALL, _
374 NULL, FB_RTL_OPT_MT
or FB_RTL_OPT_NOQB, _
377 ( typeAddrOf( FB_DATATYPE_VOID ), FB_PARAMMODE_BYVAL, FALSE ) _
382 @
"mutexlock", @
"fb_MutexLock", _
383 FB_DATATYPE_VOID, FB_FUNCMODE_FBCALL, _
384 NULL, FB_RTL_OPT_MT
or FB_RTL_OPT_NOQB, _
387 ( typeAddrOf( FB_DATATYPE_VOID ), FB_PARAMMODE_BYVAL, FALSE ) _
392 @
"mutexunlock", @
"fb_MutexUnlock", _
393 FB_DATATYPE_VOID, FB_FUNCMODE_FBCALL, _
394 NULL, FB_RTL_OPT_MT
or FB_RTL_OPT_NOQB, _
397 ( typeAddrOf( FB_DATATYPE_VOID ), FB_PARAMMODE_BYVAL, FALSE ) _
402 @
"condcreate", @
"fb_CondCreate", _
403 typeAddrOf( FB_DATATYPE_VOID ), FB_FUNCMODE_FBCALL, _
404 NULL, FB_RTL_OPT_MT
or FB_RTL_OPT_NOQB, _
409 @
"conddestroy", @
"fb_CondDestroy", _
410 FB_DATATYPE_VOID, FB_FUNCMODE_FBCALL, _
411 NULL, FB_RTL_OPT_MT
or FB_RTL_OPT_NOQB, _
414 ( typeAddrOf( FB_DATATYPE_VOID ), FB_PARAMMODE_BYVAL, FALSE ) _
419 @
"condsignal", @
"fb_CondSignal", _
420 FB_DATATYPE_VOID, FB_FUNCMODE_FBCALL, _
421 NULL, FB_RTL_OPT_MT
or FB_RTL_OPT_NOQB, _
424 ( typeAddrOf( FB_DATATYPE_VOID ), FB_PARAMMODE_BYVAL, FALSE ) _
429 @
"condbroadcast", @
"fb_CondBroadcast", _
430 FB_DATATYPE_VOID, FB_FUNCMODE_FBCALL, _
431 NULL, FB_RTL_OPT_MT
or FB_RTL_OPT_NOQB, _
434 ( typeAddrOf( FB_DATATYPE_VOID ), FB_PARAMMODE_BYVAL, FALSE ) _
439 @
"condwait", @
"fb_CondWait", _
440 FB_DATATYPE_VOID, FB_FUNCMODE_FBCALL, _
441 NULL, FB_RTL_OPT_MT
or FB_RTL_OPT_NOQB, _
444 ( typeAddrOf( FB_DATATYPE_VOID ), FB_PARAMMODE_BYVAL, FALSE ), _
445 ( typeAddrOf( FB_DATATYPE_VOID ), FB_PARAMMODE_BYVAL, FALSE ) _
450 @
"dylibload", @
"fb_DylibLoad", _
451 typeAddrOf( FB_DATATYPE_VOID ), FB_FUNCMODE_FBCALL, _
452 NULL, FB_RTL_OPT_NOQB, _
455 ( FB_DATATYPE_STRING, FB_PARAMMODE_BYREF, FALSE ) _
460 @
"dylibsymbol", @
"fb_DylibSymbol", _
461 typeAddrOf( FB_DATATYPE_VOID ), FB_FUNCMODE_FBCALL, _
462 NULL, FB_RTL_OPT_OVER
or FB_RTL_OPT_NOQB, _
465 ( typeAddrOf( FB_DATATYPE_VOID ), FB_PARAMMODE_BYVAL, FALSE ), _
466 ( FB_DATATYPE_STRING, FB_PARAMMODE_BYREF, FALSE ) _
471 @
"dylibsymbol", @
"fb_DylibSymbolByOrd", _
472 typeAddrOf( FB_DATATYPE_VOID ), FB_FUNCMODE_FBCALL, _
473 NULL, FB_RTL_OPT_OVER
or FB_RTL_OPT_NOQB, _
476 ( typeAddrOf( FB_DATATYPE_VOID ), FB_PARAMMODE_BYVAL, FALSE ), _
477 ( FB_DATATYPE_SHORT, FB_PARAMMODE_BYVAL, FALSE ) _
482 @
"dylibfree", @
"fb_DylibFree", _
483 FB_DATATYPE_VOID, FB_FUNCMODE_FBCALL, _
484 NULL, FB_RTL_OPT_NOQB, _
487 ( typeAddrOf( FB_DATATYPE_VOID ), FB_PARAMMODE_BYVAL, FALSE ) _
492 @
"beep", @
"fb_Beep", _
493 FB_DATATYPE_VOID, FB_FUNCMODE_FBCALL, _
494 NULL, FB_RTL_OPT_NONE, _
499 @
"mkdir", @
"fb_MkDir", _
500 FB_DATATYPE_LONG, FB_FUNCMODE_FBCALL, _
501 NULL, FB_RTL_OPT_NONE, _
504 ( FB_DATATYPE_STRING, FB_PARAMMODE_BYREF, FALSE ) _
509 @
"rmdir", @
"fb_RmDir", _
510 FB_DATATYPE_LONG, FB_FUNCMODE_FBCALL, _
511 NULL, FB_RTL_OPT_NONE, _
514 ( FB_DATATYPE_STRING, FB_PARAMMODE_BYREF, FALSE ) _
519 @
"chdir", @
"fb_ChDir", _
520 FB_DATATYPE_LONG, FB_FUNCMODE_FBCALL, _
521 NULL, FB_RTL_OPT_NONE, _
524 ( FB_DATATYPE_STRING,FB_PARAMMODE_BYREF, FALSE ) _
548 dim as ASTNODE
ptr proc =
any, cpu =
any
549 dim as FBSYMBOL
ptr s =
any, label =
any
550 dim as integer family =
any
551 dim as string familystr
558 family = env.clopt.cputype
559 if( family > FB_CPUTYPE_686 )
then
560 family = FB_CPUTYPE_686
563 select case( family )
564 case FB_CPUTYPE_386 : familystr =
"386" : family = 3
565 case FB_CPUTYPE_486 : familystr =
"486" : family = 4
566 case FB_CPUTYPE_586 : familystr =
"586" : family = 5
567 case else : familystr =
"686" : family = 6
571 proc =
astNewCALL( PROCLOOKUP( CPUDETECT ), NULL )
581 s =
symbAllocStrConst(
"This program requires at least a " + familystr +
" to run.", -1 )
594 if( env.clopt.fputype = FB_FPUTYPE_SSE )
then
595 proc =
astNewCALL( PROCLOOKUP( CPUDETECT ), NULL )
609 s =
symbAllocStrConst(
"This program requires SSE and SSE2 instructions to run.", -1 )
629 byval argc
as ASTNODE
ptr, _
630 byval argv
as ASTNODE
ptr _
633 dim as ASTNODE
ptr proc =
any
634 dim as integer is_exe =
any
636 is_exe = (env.clopt.outtype <> FB_OUTTYPE_DYNAMICLIB)
638 if( env.clopt.backend = FB_BACKEND_GAS )
then
640 select case( env.clopt.target )
641 case FB_COMPTARGET_WIN32, FB_COMPTARGET_CYGWIN
642 if( env.clopt.profile )
then
649 if( env.clopt.target = FB_COMPTARGET_WIN32 )
then
663 if( env.clopt.errorcheck
and is_exe )
then
668 if( fbCpuTypeIsX86( ) )
then
677 function rtlExitApp(
byval errlevel
as ASTNODE
ptr )
as integer
678 dim as ASTNODE
ptr proc =
any
685 if( errlevel = NULL )
then
688 if(
astNewARG( proc, errlevel ) = NULL )
then
700 byval sym
as FBSYMBOL
ptr _
703 env.clopt.multithreaded = TRUE
712 byval sym
as FBSYMBOL
ptr _
715 static as integer libsAdded = FALSE
717 if( libsadded = FALSE )
then
728 byval procexpr
as ASTNODE
ptr _
729 )
as ASTNODE
ptr static
731 dim as ASTNODE
ptr proc
738 if(
astNewARG( proc, procexpr ) = NULL )
then