globals.pas 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441
  1. {
  2. Copyright (c) 1998-2002 by Florian Klaempfl
  3. This unit implements some support functions and global variables
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. unit globals;
  18. {$i fpcdefs.inc}
  19. interface
  20. uses
  21. {$ifdef win32}
  22. windows,
  23. {$endif}
  24. {$ifdef os2}
  25. dos,
  26. {$endif os2}
  27. {$ifdef hasunix}
  28. Baseunix,unix,
  29. {$endif}
  30. {$IFNDEF USE_FAKE_SYSUTILS}
  31. sysutils,
  32. {$ELSE}
  33. fksysutl,
  34. {$ENDIF}
  35. { comphook pulls in sysutils anyways }
  36. cutils,cclasses,cfileutl,
  37. cpuinfo,
  38. globtype,version,systems;
  39. const
  40. delphimodeswitches =
  41. [m_delphi,m_all,m_class,m_objpas,m_result,m_string_pchar,
  42. m_pointer_2_procedure,m_autoderef,m_tp_procvar,m_initfinal,m_default_ansistring,
  43. m_out,m_default_para,m_duplicate_names,m_hintdirective,m_add_pointer,
  44. m_property,m_default_inline,m_except];
  45. fpcmodeswitches =
  46. [m_fpc,m_all,m_string_pchar,m_nested_comment,m_repeat_forward,
  47. m_cvar_support,m_initfinal,m_add_pointer,m_hintdirective,
  48. m_property,m_default_inline];
  49. objfpcmodeswitches =
  50. [m_objfpc,m_fpc,m_all,m_class,m_objpas,m_result,m_string_pchar,m_nested_comment,
  51. m_repeat_forward,m_cvar_support,m_initfinal,m_add_pointer,m_out,m_default_para,m_hintdirective,
  52. m_property,m_default_inline,m_except];
  53. tpmodeswitches =
  54. [m_tp7,m_all,m_tp_procvar,m_duplicate_names];
  55. {$ifdef gpc_mode}
  56. gpcmodeswitches =
  57. [m_gpc,m_all,m_tp_procvar];
  58. {$endif}
  59. macmodeswitches =
  60. [m_mac,m_all,m_result,m_cvar_support,m_mac_procvar];
  61. { maximum nesting of routines }
  62. maxnesting = 32;
  63. { Filenames and extensions }
  64. sourceext = '.pp';
  65. pasext = '.pas';
  66. pext = '.p';
  67. treelogfilename = 'tree.log';
  68. {$if defined(CPUARM) and defined(FPUFPA)}
  69. MathQNaN : tdoublerec = (bytes : (0,0,252,255,0,0,0,0));
  70. MathInf : tdoublerec = (bytes : (0,0,240,127,0,0,0,0));
  71. MathNegInf : tdoublerec = (bytes : (0,0,240,255,0,0,0,0));
  72. MathPi : tdoublerec = (bytes : (251,33,9,64,24,45,68,84));
  73. {$else}
  74. {$ifdef FPC_LITTLE_ENDIAN}
  75. MathQNaN : tdoublerec = (bytes : (0,0,0,0,0,0,252,255));
  76. MathInf : tdoublerec = (bytes : (0,0,0,0,0,0,240,127));
  77. MathNegInf : tdoublerec = (bytes : (0,0,0,0,0,0,240,255));
  78. MathPi : tdoublerec = (bytes : (24,45,68,84,251,33,9,64));
  79. MathPiExtended : textendedrec = (bytes : (53,194,104,33,162,218,15,201,0,64));
  80. {$else FPC_LITTLE_ENDIAN}
  81. MathQNaN : tdoublerec = (bytes : (255,252,0,0,0,0,0,0));
  82. MathInf : tdoublerec = (bytes : (127,240,0,0,0,0,0,0));
  83. MathNegInf : tdoublerec = (bytes : (255,240,0,0,0,0,0,0));
  84. MathPi : tdoublerec = (bytes : (64,9,33,251,84,68,45,24));
  85. MathPiExtended : textendedrec = (bytes : (64,0,201,15,218,162,33,104,194,53));
  86. {$endif FPC_LITTLE_ENDIAN}
  87. {$endif}
  88. type
  89. tcodepagestring = string[20];
  90. tsettings = record
  91. globalswitches : tglobalswitches;
  92. moduleswitches : tmoduleswitches;
  93. localswitches : tlocalswitches;
  94. modeswitches : tmodeswitches;
  95. optimizerswitches : toptimizerswitches;
  96. { generate information necessary to perform these wpo's during a subsequent compilation }
  97. genwpoptimizerswitches: twpoptimizerswitches;
  98. { perform these wpo's using information generated during a previous compilation }
  99. dowpoptimizerswitches: twpoptimizerswitches;
  100. debugswitches : tdebugswitches;
  101. { 0: old behaviour for sets <=256 elements
  102. >0: round to this size }
  103. setalloc,
  104. packenum : shortint;
  105. alignment : talignmentinfo;
  106. cputype,
  107. optimizecputype : tcputype;
  108. fputype : tfputype;
  109. asmmode : tasmmode;
  110. interfacetype : tinterfacetypes;
  111. defproccall : tproccalloption;
  112. sourcecodepage : tcodepagestring;
  113. packrecords : shortint;
  114. maxfpuregisters : shortint;
  115. minfpconstprec : tfloattype;
  116. { CPU targets with microcontroller support can add a controller specific unit }
  117. {$if defined(ARM)}
  118. controllertype : tcontrollertype;
  119. {$endif defined(ARM)}
  120. end;
  121. const
  122. LinkMapWeightDefault = 1000;
  123. type
  124. TLinkRec = record
  125. Key : AnsiString;
  126. Value : AnsiString; // key expands to valuelist "value"
  127. Weight: longint;
  128. end;
  129. TLinkStrMap = class
  130. private
  131. itemcnt : longint;
  132. fmap : Array Of TLinkRec;
  133. function Lookup(key:Ansistring):longint;
  134. function getlinkrec(i:longint):TLinkRec;
  135. public
  136. procedure Add(key:ansistring;value:AnsiString='';weight:longint=LinkMapWeightDefault);
  137. procedure addseries(keys:AnsiString;weight:longint=LinkMapWeightDefault);
  138. function AddDep(keyvalue:String):boolean;
  139. function AddWeight(keyvalue:String):boolean;
  140. procedure SetValue(key:AnsiString;Weight:Integer);
  141. procedure SortonWeight;
  142. function Find(key:AnsiString):AnsiString;
  143. procedure Expand(src:TCmdStrList;dest: TLinkStrMap);
  144. procedure UpdateWeights(Weightmap:TLinkStrMap);
  145. constructor Create;
  146. property count : longint read itemcnt;
  147. property items[I:longint]:TLinkRec read getlinkrec; default;
  148. end;
  149. tpendingstate = record
  150. nextverbositystr : shortstring;
  151. nextlocalswitches : tlocalswitches;
  152. nextverbosityfullswitch: longint;
  153. nextcallingstr : shortstring;
  154. verbosityfullswitched,
  155. localswitcheschanged : boolean;
  156. end;
  157. var
  158. { specified inputfile }
  159. inputfilepath : string;
  160. inputfilename : string;
  161. { specified outputfile with -o parameter }
  162. outputfilename : string;
  163. outputprefix : pshortstring;
  164. outputsuffix : pshortstring;
  165. { specified with -FE or -FU }
  166. outputexedir : TPathStr;
  167. outputunitdir : TPathStr;
  168. { specified with -FW and -Fw }
  169. wpofeedbackinput,
  170. wpofeedbackoutput : TPathStr;
  171. { things specified with parameters }
  172. paratarget : tsystem;
  173. paratargetdbg : tdbg;
  174. paratargetasm : tasm;
  175. paralinkoptions : TCmdStr;
  176. paradynamiclinker : string;
  177. paraprintnodetree : byte;
  178. parapreprocess : boolean;
  179. printnodefile : text;
  180. { typical cross compiling params}
  181. { directory where the utils can be found (options -FD) }
  182. utilsdirectory : TPathStr;
  183. { targetname specific prefix used by these utils (options -XP<path>) }
  184. utilsprefix : TCmdStr;
  185. cshared : boolean; { pass --shared to ld to link C libs shared}
  186. Dontlinkstdlibpath: Boolean; { Don't add std paths to linkpath}
  187. rlinkpath : TCmdStr; { rpath-link linkdir override}
  188. sysrootpath : TCmdStr; { target system root to search dyn linker }
  189. { some flags for global compiler switches }
  190. do_build,
  191. do_release,
  192. do_make : boolean;
  193. { path for searching units, different paths can be seperated by ; }
  194. exepath : TPathStr; { Path to ppc }
  195. librarysearchpath,
  196. unitsearchpath,
  197. objectsearchpath,
  198. includesearchpath,
  199. frameworksearchpath : TSearchPathList;
  200. autoloadunits : string;
  201. { linking }
  202. usewindowapi : boolean;
  203. description : string;
  204. SetPEFlagsSetExplicity,
  205. ImageBaseSetExplicity,
  206. MinStackSizeSetExplicity,
  207. MaxStackSizeSetExplicity,
  208. DescriptionSetExplicity : boolean;
  209. dllversion : string;
  210. dllmajor,
  211. dllminor,
  212. dllrevision : word; { revision only for netware }
  213. { win pe }
  214. peflags : longint;
  215. minstacksize,
  216. maxstacksize,
  217. imagebase : aword;
  218. UseDeffileForExports : boolean;
  219. UseDeffileForExportsSetExplicitly : boolean;
  220. GenerateImportSection,
  221. GenerateImportSectionSetExplicitly,
  222. RelocSection : boolean;
  223. RelocSectionSetExplicitly : boolean;
  224. LinkTypeSetExplicitly : boolean;
  225. current_tokenpos, { position of the last token }
  226. current_filepos : tfileposinfo; { current position }
  227. nwscreenname : string;
  228. nwthreadname : string;
  229. nwcopyright : string;
  230. codegenerror : boolean; { true if there is an error reported }
  231. block_type : tblock_type; { type of currently parsed block }
  232. compile_level : word;
  233. exceptblockcounter : integer; { each except block gets a unique number check gotos }
  234. current_exceptblock : integer; { the exceptblock number of the current block (0 if none) }
  235. LinkLibraryAliases : TLinkStrMap;
  236. LinkLibraryOrder : TLinkStrMap;
  237. init_settings,
  238. current_settings : tsettings;
  239. pendingstate : tpendingstate;
  240. { Memory sizes }
  241. heapsize,
  242. stacksize,
  243. jmp_buf_size,
  244. jmp_buf_align : longint;
  245. {$Ifdef EXTDEBUG}
  246. { parameter switches }
  247. debugstop : boolean;
  248. {$EndIf EXTDEBUG}
  249. { windows / OS/2 application type }
  250. apptype : tapptype;
  251. features : tfeatures;
  252. const
  253. DLLsource : boolean = false;
  254. DLLImageBase : pshortstring = nil;
  255. { used to set all registers used for each global function
  256. this should dramatically decrease the number of
  257. recompilations needed PM }
  258. simplify_ppu : boolean = true;
  259. Inside_asm_statement : boolean = false;
  260. global_unit_count : word = 0;
  261. { for error info in pp.pas }
  262. parser_current_file : string = '';
  263. {$if defined(m68k) or defined(arm)}
  264. { PalmOS resources }
  265. palmos_applicationname : string = 'FPC Application';
  266. palmos_applicationid : string[4] = 'FPCA';
  267. {$endif defined(m68k) or defined(arm)}
  268. {$ifdef powerpc}
  269. { default calling convention used on MorphOS }
  270. syscall_convention : string = 'LEGACY';
  271. {$endif powerpc}
  272. { default name of the C-style "main" procedure of the library/program }
  273. { (this will be prefixed with the target_info.cprefix) }
  274. defaultmainaliasname = 'main';
  275. mainaliasname : string = defaultmainaliasname;
  276. { by default no local variable trashing }
  277. localvartrashing: longint = -1;
  278. { actual values are defined in ncgutil.pas }
  279. nroftrashvalues = 4;
  280. const
  281. default_settings : TSettings = (
  282. globalswitches : [cs_check_unit_name,cs_link_static];
  283. moduleswitches : [cs_extsyntax,cs_implicit_exceptions];
  284. localswitches : [cs_check_io,cs_typed_const_writable];
  285. modeswitches : fpcmodeswitches;
  286. optimizerswitches : [];
  287. genwpoptimizerswitches : [];
  288. dowpoptimizerswitches : [];
  289. debugswitches : [];
  290. setalloc : 0;
  291. packenum : 4;
  292. alignment : (
  293. procalign : 0;
  294. loopalign : 0;
  295. jumpalign : 0;
  296. constalignmin : 0;
  297. constalignmax : 0;
  298. varalignmin : 0;
  299. varalignmax : 0;
  300. localalignmin : 0;
  301. localalignmax : 0;
  302. recordalignmin : 0;
  303. recordalignmax : 0;
  304. maxCrecordalign : 0;
  305. );
  306. {$ifdef i386}
  307. cputype : cpu_Pentium;
  308. optimizecputype : cpu_Pentium3;
  309. fputype : fpu_x87;
  310. {$endif i386}
  311. {$ifdef m68k}
  312. cputype : cpu_MC68020;
  313. optimizecputype : cpu_MC68020;
  314. fputype : fpu_soft;
  315. {$endif m68k}
  316. {$ifdef powerpc}
  317. cputype : cpu_PPC604;
  318. optimizecputype : cpu_ppc7400;
  319. fputype : fpu_standard;
  320. {$endif powerpc}
  321. {$ifdef POWERPC64}
  322. cputype : cpu_PPC970;
  323. optimizecputype : cpu_ppc970;
  324. fputype : fpu_standard;
  325. {$endif POWERPC64}
  326. {$ifdef sparc}
  327. cputype : cpu_SPARC_V8;
  328. optimizecputype : cpu_SPARC_V8;
  329. fputype : fpu_hard;
  330. {$endif sparc}
  331. {$ifdef arm}
  332. cputype : cpu_armv3;
  333. optimizecputype : cpu_armv3;
  334. fputype : fpu_fpa;
  335. {$endif arm}
  336. {$ifdef x86_64}
  337. cputype : cpu_athlon64;
  338. optimizecputype : cpu_athlon64;
  339. fputype : fpu_sse64;
  340. {$endif x86_64}
  341. {$ifdef avr}
  342. cputype : cpuinfo.cpu_avr;
  343. optimizecputype : cpuinfo.cpu_avr;
  344. fputype : fpu_none;
  345. {$endif avr}
  346. asmmode : asmmode_standard;
  347. interfacetype : it_interfacecom;
  348. defproccall : pocall_default;
  349. sourcecodepage : '8859-1';
  350. packrecords : 0;
  351. maxfpuregisters : 0;
  352. minfpconstprec : s32real;
  353. {$if defined(ARM)}
  354. controllertype : ct_none;
  355. {$endif defined(ARM)}
  356. );
  357. var
  358. starttime : real;
  359. function getdatestr:string;
  360. function gettimestr:string;
  361. function filetimestring( t : longint) : string;
  362. function getrealtime : real;
  363. procedure DefaultReplacements(var s:ansistring);
  364. function Shell(const command:ansistring): longint;
  365. function GetEnvPChar(const envname:string):pchar;
  366. procedure FreeEnvPChar(p:pchar);
  367. function is_number_float(d : double) : boolean;
  368. { discern +0.0 and -0.0 }
  369. function get_real_sign(r: bestreal): longint;
  370. procedure InitGlobals;
  371. procedure DoneGlobals;
  372. function string2guid(const s: string; var GUID: TGUID): boolean;
  373. function guid2string(const GUID: TGUID): string;
  374. function SetAktProcCall(const s:string; var a:tproccalloption):boolean;
  375. function Setabitype(const s:string;var a:tabi):boolean;
  376. function Setcputype(const s:string;var a:tcputype):boolean;
  377. function SetFpuType(const s:string;var a:tfputype):boolean;
  378. {$if defined(arm) or defined(avr)}
  379. function SetControllerType(const s:string;var a:tcontrollertype):boolean;
  380. {$endif defined(arm) or defined(avr)}
  381. function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
  382. function UpdateOptimizerStr(s:string;var a:toptimizerswitches):boolean;
  383. function UpdateWpoStr(s: string; var a: twpoptimizerswitches): boolean;
  384. function UpdateDebugStr(s:string;var a:tdebugswitches):boolean;
  385. function IncludeFeature(const s : string) : boolean;
  386. function SetMinFPConstPrec(const s: string; var a: tfloattype) : boolean;
  387. {# Routine to get the required alignment for size of data, which will
  388. be placed in bss segment, according to the current alignment requirements }
  389. function var_align(want_align: longint): shortint;
  390. function var_align_size(siz: longint): shortint;
  391. {# Routine to get the required alignment for size of data, which will
  392. be placed in data/const segment, according to the current alignment requirements }
  393. function const_align(want_align: longint): shortint;
  394. function const_align_size(siz: longint): shortint;
  395. {$ifdef ARM}
  396. function is_double_hilo_swapped: boolean;{$ifdef USEINLINE}inline;{$endif}
  397. {$endif ARM}
  398. function floating_point_range_check_error : boolean;
  399. implementation
  400. uses
  401. {$ifdef macos}
  402. macutils,
  403. {$endif}
  404. comphook;
  405. {****************************************************************************
  406. TLinkStrMap
  407. ****************************************************************************}
  408. Constructor TLinkStrMap.create;
  409. begin
  410. inherited;
  411. itemcnt:=0;
  412. end;
  413. procedure TLinkStrMap.Add(key:ansistring;value:AnsiString='';weight:longint=LinkMapWeightDefault);
  414. begin
  415. if lookup(key)<>-1 Then
  416. exit;
  417. if itemcnt<=length(fmap) Then
  418. setlength(fmap,itemcnt+10);
  419. fmap[itemcnt].key:=key;
  420. fmap[itemcnt].value:=value;
  421. fmap[itemcnt].weight:=weight;
  422. inc(itemcnt);
  423. end;
  424. function TLinkStrMap.AddDep(keyvalue:String):boolean;
  425. var
  426. i : Longint;
  427. begin
  428. AddDep:=false;
  429. i:=pos('=',keyvalue);
  430. if i=0 then
  431. exit;
  432. Add(Copy(KeyValue,1,i-1),Copy(KeyValue,i+1,length(KeyValue)-i));
  433. AddDep:=True;
  434. end;
  435. function TLinkStrMap.AddWeight(keyvalue:String):boolean;
  436. var
  437. i,j : Longint;
  438. Code : Word;
  439. s : AnsiString;
  440. begin
  441. AddWeight:=false;
  442. i:=pos('=',keyvalue);
  443. if i=0 then
  444. exit;
  445. s:=Copy(KeyValue,i+1,length(KeyValue)-i);
  446. val(s,j,code);
  447. if code=0 Then
  448. begin
  449. Add(Copy(KeyValue,1,i-1),'',j);
  450. AddWeight:=True;
  451. end;
  452. end;
  453. procedure TLinkStrMap.addseries(keys:AnsiString;weight:longint);
  454. var
  455. i,j,k : longint;
  456. begin
  457. k:=length(keys);
  458. i:=1;
  459. while i<=k do
  460. begin
  461. j:=i;
  462. while (i<=k) and (keys[i]<>',') do
  463. inc(i);
  464. add(copy(keys,j,i-j),'',weight);
  465. inc(i);
  466. end;
  467. end;
  468. procedure TLinkStrMap.SetValue(Key:Ansistring;weight:Integer);
  469. var
  470. j : longint;
  471. begin
  472. j:=lookup(key);
  473. if j<>-1 then
  474. fmap[j].weight:=weight;
  475. end;
  476. function TLinkStrMap.find(key:Ansistring):Ansistring;
  477. var
  478. j : longint;
  479. begin
  480. find:='';
  481. j:=lookup(key);
  482. if j<>-1 then
  483. find:=fmap[j].value;
  484. end;
  485. function TLinkStrMap.lookup(key:Ansistring):longint;
  486. var
  487. i : longint;
  488. begin
  489. lookup:=-1;
  490. i:=0;
  491. while (i<itemcnt) and (fmap[i].key<>key) do
  492. inc(i);
  493. if i<>itemcnt then
  494. lookup:=i;
  495. end;
  496. procedure TLinkStrMap.SortOnWeight;
  497. var
  498. i, j : longint;
  499. m : TLinkRec;
  500. begin
  501. if itemcnt <2 then exit;
  502. for i:=0 to itemcnt-1 do
  503. for j:=i+1 to itemcnt-1 do
  504. begin
  505. if fmap[i].weight>fmap[j].weight Then
  506. begin
  507. m:=fmap[i];
  508. fmap[i]:=fmap[j];
  509. fmap[j]:=m;
  510. end;
  511. end;
  512. end;
  513. function TLinkStrMap.getlinkrec(i:longint):TLinkRec;
  514. begin
  515. result:=fmap[i];
  516. end;
  517. procedure TLinkStrMap.Expand(Src:TCmdStrList;Dest:TLinkStrMap);
  518. // expands every thing in Src to Dest for linkorder purposes.
  519. var
  520. r : longint;
  521. LibN : TCmdStr;
  522. begin
  523. while not src.empty do
  524. begin
  525. LibN:=src.getfirst;
  526. r:=lookup (LibN);
  527. if r=-1 then
  528. dest.add(LibN)
  529. else
  530. dest.addseries(fmap[r].value);
  531. end;
  532. end;
  533. procedure TLinkStrMap.UpdateWeights(Weightmap:TLinkStrMap);
  534. var
  535. l,r : longint;
  536. begin
  537. for l := 0 to itemcnt-1 do
  538. begin
  539. r:=weightmap.lookup (fmap[l].key);
  540. if r<>-1 then
  541. fmap[l].weight:=weightmap[r].weight;
  542. end;
  543. end;
  544. {****************************************************************************
  545. Time Handling
  546. ****************************************************************************}
  547. Function L0(l:longint):string;
  548. {
  549. return the string of value l, if l<10 then insert a zero, so
  550. the string is always at least 2 chars '01','02',etc
  551. }
  552. var
  553. s : string;
  554. begin
  555. Str(l,s);
  556. if l<10 then
  557. s:='0'+s;
  558. L0:=s;
  559. end;
  560. function gettimestr:string;
  561. {
  562. get the current time in a string HH:MM:SS
  563. }
  564. var
  565. hour,min,sec,hsec : word;
  566. begin
  567. DecodeTime(Time,hour,min,sec,hsec);
  568. gettimestr:=L0(Hour)+':'+L0(min)+':'+L0(sec);
  569. end;
  570. function getdatestr:string;
  571. {
  572. get the current date in a string YY/MM/DD
  573. }
  574. var
  575. Year,Month,Day: Word;
  576. begin
  577. DecodeDate(Date,year,month,day);
  578. getdatestr:=L0(Year)+'/'+L0(Month)+'/'+L0(Day);
  579. end;
  580. function filetimestring( t : longint) : string;
  581. {
  582. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  583. }
  584. var
  585. DT : TDateTime;
  586. hsec : word;
  587. Year,Month,Day: Word;
  588. hour,min,sec : word;
  589. begin
  590. if t=-1 then
  591. begin
  592. Result := 'Not Found';
  593. exit;
  594. end;
  595. DT := FileDateToDateTime(t);
  596. DecodeTime(DT,hour,min,sec,hsec);
  597. DecodeDate(DT,year,month,day);
  598. Result := L0(Year)+'/'+L0(Month)+'/'+L0(Day)+' '+L0(Hour)+':'+L0(min)+':'+L0(sec);
  599. end;
  600. function getrealtime : real;
  601. var
  602. h,m,s,s1000 : word;
  603. begin
  604. DecodeTime(Time,h,m,s,s1000);
  605. result:=h*3600.0+m*60.0+s+s1000/1000.0;
  606. end;
  607. {****************************************************************************
  608. Default Macro Handling
  609. ****************************************************************************}
  610. procedure DefaultReplacements(var s:ansistring);
  611. begin
  612. { Replace some macros }
  613. Replace(s,'$FPCVERSION',version_string);
  614. Replace(s,'$FPCFULLVERSION',full_version_string);
  615. Replace(s,'$FPCDATE',date_string);
  616. Replace(s,'$FPCCPU',target_cpu_string);
  617. Replace(s,'$FPCOS',target_os_string);
  618. if tf_use_8_3 in Source_Info.Flags then
  619. Replace(s,'$FPCTARGET',target_os_string)
  620. else
  621. Replace(s,'$FPCTARGET',target_full_string);
  622. end;
  623. {****************************************************************************
  624. OS Dependent things
  625. ****************************************************************************}
  626. function GetEnvPChar(const envname:string):pchar;
  627. {$ifdef win32}
  628. var
  629. s : string;
  630. i,len : longint;
  631. hp,p,p2 : pchar;
  632. {$endif}
  633. begin
  634. {$ifdef hasunix}
  635. GetEnvPchar:=BaseUnix.fpGetEnv(envname);
  636. {$define GETENVOK}
  637. {$endif}
  638. {$ifdef win32}
  639. GetEnvPchar:=nil;
  640. p:=GetEnvironmentStrings;
  641. hp:=p;
  642. while hp^<>#0 do
  643. begin
  644. s:=strpas(hp);
  645. i:=pos('=',s);
  646. len:=strlen(hp);
  647. if upper(copy(s,1,i-1))=upper(envname) then
  648. begin
  649. GetMem(p2,len-length(envname));
  650. Move(hp[i],p2^,len-length(envname));
  651. GetEnvPchar:=p2;
  652. break;
  653. end;
  654. { next string entry}
  655. hp:=hp+len+1;
  656. end;
  657. FreeEnvironmentStrings(p);
  658. {$define GETENVOK}
  659. {$endif}
  660. {$ifdef os2}
  661. GetEnvPChar := Dos.GetEnvPChar (EnvName);
  662. {$define GETENVOK}
  663. {$endif}
  664. {$ifdef GETENVOK}
  665. {$undef GETENVOK}
  666. {$else}
  667. GetEnvPchar:=StrPNew(GetEnvironmentVariable(envname));
  668. {$endif}
  669. end;
  670. procedure FreeEnvPChar(p:pchar);
  671. begin
  672. {$ifndef hasunix}
  673. {$ifndef os2}
  674. freemem(p);
  675. {$endif}
  676. {$endif}
  677. end;
  678. {$if defined(MORPHOS) or defined(AMIGA)}
  679. {$define AMIGASHELL}
  680. {$endif}
  681. function Shell(const command:ansistring): longint;
  682. { This is already defined in the linux.ppu for linux, need for the *
  683. expansion under linux }
  684. {$ifdef hasunix}
  685. begin
  686. result := Unix.fpsystem(command);
  687. end;
  688. {$else hasunix}
  689. {$ifdef amigashell}
  690. begin
  691. result := ExecuteProcess('',command);
  692. end;
  693. {$else amigashell}
  694. var
  695. comspec : string;
  696. begin
  697. comspec:=GetEnvironmentVariable('COMSPEC');
  698. result := ExecuteProcess(comspec,' /C '+command);
  699. end;
  700. {$endif amigashell}
  701. {$endif hasunix}
  702. {$UNDEF AMIGASHELL}
  703. function is_number_float(d : double) : boolean;
  704. var
  705. bytearray : array[0..7] of byte;
  706. begin
  707. move(d,bytearray,8);
  708. { only 1.1 save, 1.0.x will use always little endian }
  709. {$ifdef FPC_BIG_ENDIAN}
  710. result:=((bytearray[0] and $7f)<>$7f) or ((bytearray[1] and $f0)<>$f0);
  711. {$else FPC_BIG_ENDIAN}
  712. result:=((bytearray[7] and $7f)<>$7f) or ((bytearray[6] and $f0)<>$f0);
  713. {$endif FPC_BIG_ENDIAN}
  714. end;
  715. function get_real_sign(r: bestreal): longint;
  716. var
  717. p: pbyte;
  718. begin
  719. p := pbyte(@r);
  720. {$ifdef CPU_ARM}
  721. inc(p,4);
  722. {$else}
  723. {$ifdef FPC_LITTLE_ENDIAN}
  724. inc(p,sizeof(r)-1);
  725. {$endif}
  726. {$endif}
  727. if (p^ and $80) = 0 then
  728. result := 1
  729. else
  730. result := -1;
  731. end;
  732. function convertdoublerec(d : tdoublerec) : tdoublerec;{$ifdef USEINLINE}inline;{$endif}
  733. {$ifdef CPUARM}
  734. var
  735. i : longint;
  736. begin
  737. for i:=0 to 3 do
  738. begin
  739. result.bytes[i+4]:=d.bytes[i];
  740. result.bytes[i]:=d.bytes[i+4];
  741. end;
  742. {$else CPUARM}
  743. begin
  744. result:=d;
  745. {$endif CPUARM}
  746. end;
  747. { '('D1:'00000000-'D2:'0000-'D3:'0000-'D4:'0000-000000000000)' }
  748. function string2guid(const s: string; var GUID: TGUID): boolean;
  749. function ishexstr(const hs: string): boolean;
  750. var
  751. i: integer;
  752. begin
  753. ishexstr:=false;
  754. for i:=1 to Length(hs) do begin
  755. if not (hs[i] in ['0'..'9','A'..'F','a'..'f']) then
  756. exit;
  757. end;
  758. ishexstr:=true;
  759. end;
  760. function hexstr2longint(const hexs: string): longint;
  761. var
  762. i: integer;
  763. rl: longint;
  764. begin
  765. rl:=0;
  766. for i:=1 to length(hexs) do begin
  767. rl:=rl shl 4;
  768. case hexs[i] of
  769. '0'..'9' : inc(rl,ord(hexs[i])-ord('0'));
  770. 'A'..'F' : inc(rl,ord(hexs[i])-ord('A')+10);
  771. 'a'..'f' : inc(rl,ord(hexs[i])-ord('a')+10);
  772. end
  773. end;
  774. hexstr2longint:=rl;
  775. end;
  776. var
  777. i: integer;
  778. begin
  779. if (Length(s)=38) and (s[1]='{') and (s[38]='}') and
  780. (s[10]='-') and (s[15]='-') and (s[20]='-') and (s[25]='-') and
  781. ishexstr(copy(s,2,8)) and ishexstr(copy(s,11,4)) and
  782. ishexstr(copy(s,16,4)) and ishexstr(copy(s,21,4)) and
  783. ishexstr(copy(s,26,12)) then begin
  784. GUID.D1:=dword(hexstr2longint(copy(s,2,8)));
  785. { these values are arealdy in the correct range (4 chars = word) }
  786. GUID.D2:=word(hexstr2longint(copy(s,11,4)));
  787. GUID.D3:=word(hexstr2longint(copy(s,16,4)));
  788. for i:=0 to 1 do
  789. GUID.D4[i]:=byte(hexstr2longint(copy(s,21+i*2,2)));
  790. for i:=2 to 7 do
  791. GUID.D4[i]:=byte(hexstr2longint(copy(s,22+i*2,2)));
  792. string2guid:=true;
  793. end
  794. else if (length(s)=0) then
  795. begin
  796. FillChar(GUID,SizeOf(GUID),0);
  797. string2guid:=true;
  798. end
  799. else
  800. string2guid:=false;
  801. end;
  802. function guid2string(const GUID: TGUID): string;
  803. begin
  804. guid2string:=
  805. '{'+hexstr(GUID.D1,8)+
  806. '-'+hexstr(GUID.D2,4)+
  807. '-'+hexstr(GUID.D3,4)+
  808. '-'+hexstr(GUID.D4[0],2)+hexstr(GUID.D4[1],2)+
  809. '-'+hexstr(GUID.D4[2],2)+hexstr(GUID.D4[3],2)+
  810. hexstr(GUID.D4[4],2)+hexstr(GUID.D4[5],2)+
  811. hexstr(GUID.D4[6],2)+hexstr(GUID.D4[7],2)+
  812. '}';
  813. end;
  814. function SetAktProcCall(const s:string; var a:tproccalloption):boolean;
  815. const
  816. DefProcCallName : array[tproccalloption] of string[12] = ('',
  817. 'CDECL',
  818. 'CPPDECL',
  819. 'FAR16',
  820. 'OLDFPCCALL',
  821. '', { internproc }
  822. '', { syscall }
  823. 'PASCAL',
  824. 'REGISTER',
  825. 'SAFECALL',
  826. 'STDCALL',
  827. 'SOFTFLOAT',
  828. 'MWPASCAL'
  829. );
  830. var
  831. t : tproccalloption;
  832. hs : string;
  833. begin
  834. result:=false;
  835. if (s = '') then
  836. exit;
  837. hs:=upper(s);
  838. if (hs = 'DEFAULT') then
  839. begin
  840. a := pocall_default;
  841. result := true;
  842. exit;
  843. end;
  844. for t:=low(tproccalloption) to high(tproccalloption) do
  845. if DefProcCallName[t]=hs then
  846. begin
  847. a:=t;
  848. result:=true;
  849. break;
  850. end;
  851. end;
  852. function Setabitype(const s:string;var a:tabi):boolean;
  853. var
  854. t : tabi;
  855. hs : string;
  856. begin
  857. result:=false;
  858. hs:=Upper(s);
  859. for t:=low(t) to high(t) do
  860. if abi2str[t]=hs then
  861. begin
  862. a:=t;
  863. result:=true;
  864. break;
  865. end;
  866. end;
  867. function Setcputype(const s:string;var a:tcputype):boolean;
  868. var
  869. t : tcputype;
  870. hs : string;
  871. begin
  872. result:=false;
  873. hs:=Upper(s);
  874. for t:=low(tcputype) to high(tcputype) do
  875. if cputypestr[t]=hs then
  876. begin
  877. a:=t;
  878. result:=true;
  879. break;
  880. end;
  881. end;
  882. function SetFpuType(const s:string;var a:tfputype):boolean;
  883. var
  884. t : tfputype;
  885. begin
  886. result:=false;
  887. for t:=low(tfputype) to high(tfputype) do
  888. if fputypestr[t]=s then
  889. begin
  890. a:=t;
  891. result:=true;
  892. break;
  893. end;
  894. end;
  895. {$if defined(arm) or defined(avr)}
  896. function SetControllerType(const s:string;var a:tcontrollertype):boolean;
  897. var
  898. t : tcontrollertype;
  899. hs : string;
  900. begin
  901. result:=false;
  902. hs:=Upper(s);
  903. for t:=low(tcontrollertype) to high(tcontrollertype) do
  904. if controllertypestr[t]=hs then
  905. begin
  906. a:=t;
  907. result:=true;
  908. break;
  909. end;
  910. end;
  911. {$endif defined(arm) or defined(avr)}
  912. function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
  913. var
  914. tok : string;
  915. vstr : string;
  916. l : longint;
  917. code : integer;
  918. b : talignmentinfo;
  919. begin
  920. UpdateAlignmentStr:=true;
  921. uppervar(s);
  922. fillchar(b,sizeof(b),0);
  923. repeat
  924. tok:=GetToken(s,'=');
  925. if tok='' then
  926. break;
  927. vstr:=GetToken(s,',');
  928. val(vstr,l,code);
  929. if tok='PROC' then
  930. b.procalign:=l
  931. else if tok='JUMP' then
  932. b.jumpalign:=l
  933. else if tok='LOOP' then
  934. b.loopalign:=l
  935. else if tok='CONSTMIN' then
  936. b.constalignmin:=l
  937. else if tok='CONSTMAX' then
  938. b.constalignmax:=l
  939. else if tok='VARMIN' then
  940. b.varalignmin:=l
  941. else if tok='VARMAX' then
  942. b.varalignmax:=l
  943. else if tok='LOCALMIN' then
  944. b.localalignmin:=l
  945. else if tok='LOCALMAX' then
  946. b.localalignmax:=l
  947. else if tok='RECORDMIN' then
  948. b.recordalignmin:=l
  949. else if tok='RECORDMAX' then
  950. b.recordalignmax:=l
  951. else { Error }
  952. UpdateAlignmentStr:=false;
  953. until false;
  954. UpdateAlignment(a,b);
  955. end;
  956. function UpdateOptimizerStr(s:string;var a:toptimizerswitches):boolean;
  957. var
  958. tok : string;
  959. doset,
  960. found : boolean;
  961. opt : toptimizerswitch;
  962. begin
  963. result:=true;
  964. uppervar(s);
  965. repeat
  966. tok:=GetToken(s,',');
  967. if tok='' then
  968. break;
  969. if Copy(tok,1,2)='NO' then
  970. begin
  971. delete(tok,1,2);
  972. doset:=false;
  973. end
  974. else
  975. doset:=true;
  976. found:=false;
  977. for opt:=low(toptimizerswitch) to high(toptimizerswitch) do
  978. begin
  979. if OptimizerSwitchStr[opt]=tok then
  980. begin
  981. found:=true;
  982. break;
  983. end;
  984. end;
  985. if found then
  986. begin
  987. if doset then
  988. include(a,opt)
  989. else
  990. exclude(a,opt);
  991. end
  992. else
  993. result:=false;
  994. until false;
  995. end;
  996. function UpdateWpoStr(s: string; var a: twpoptimizerswitches): boolean;
  997. var
  998. tok : string;
  999. doset,
  1000. found : boolean;
  1001. opt : twpoptimizerswitch;
  1002. begin
  1003. result:=true;
  1004. uppervar(s);
  1005. repeat
  1006. tok:=GetToken(s,',');
  1007. if tok='' then
  1008. break;
  1009. if Copy(tok,1,2)='NO' then
  1010. begin
  1011. delete(tok,1,2);
  1012. doset:=false;
  1013. end
  1014. else
  1015. doset:=true;
  1016. found:=false;
  1017. if (tok = 'ALL') then
  1018. begin
  1019. for opt:=low(twpoptimizerswitch) to high(twpoptimizerswitch) do
  1020. if doset then
  1021. include(a,opt)
  1022. else
  1023. exclude(a,opt);
  1024. end
  1025. else
  1026. begin
  1027. for opt:=low(twpoptimizerswitch) to high(twpoptimizerswitch) do
  1028. begin
  1029. if WPOptimizerSwitchStr[opt]=tok then
  1030. begin
  1031. found:=true;
  1032. break;
  1033. end;
  1034. end;
  1035. if found then
  1036. begin
  1037. if doset then
  1038. include(a,opt)
  1039. else
  1040. exclude(a,opt);
  1041. end
  1042. else
  1043. result:=false;
  1044. end;
  1045. until false;
  1046. end;
  1047. function UpdateDebugStr(s:string;var a:tdebugswitches):boolean;
  1048. var
  1049. tok : string;
  1050. doset,
  1051. found : boolean;
  1052. opt : tdebugswitch;
  1053. begin
  1054. result:=true;
  1055. uppervar(s);
  1056. repeat
  1057. tok:=GetToken(s,',');
  1058. if tok='' then
  1059. break;
  1060. if Copy(tok,1,2)='NO' then
  1061. begin
  1062. delete(tok,1,2);
  1063. doset:=false;
  1064. end
  1065. else
  1066. doset:=true;
  1067. found:=false;
  1068. for opt:=low(tdebugswitch) to high(tdebugswitch) do
  1069. begin
  1070. if DebugSwitchStr[opt]=tok then
  1071. begin
  1072. found:=true;
  1073. break;
  1074. end;
  1075. end;
  1076. if found then
  1077. begin
  1078. if doset then
  1079. include(a,opt)
  1080. else
  1081. exclude(a,opt);
  1082. end
  1083. else
  1084. result:=false;
  1085. until false;
  1086. end;
  1087. function IncludeFeature(const s : string) : boolean;
  1088. var
  1089. i : tfeature;
  1090. begin
  1091. result:=true;
  1092. for i:=low(tfeature) to high(tfeature) do
  1093. if s=featurestr[i] then
  1094. begin
  1095. include(features,i);
  1096. exit;
  1097. end;
  1098. result:=false;
  1099. end;
  1100. function SetMinFPConstPrec(const s: string; var a: tfloattype) : boolean;
  1101. var
  1102. value, error: longint;
  1103. begin
  1104. if (upper(s)='DEFAULT') then
  1105. begin
  1106. a:=s32real;
  1107. result:=true;
  1108. exit;
  1109. end;
  1110. result:=false;
  1111. val(s,value,error);
  1112. if (error<>0) then
  1113. exit;
  1114. case value of
  1115. 32: a:=s32real;
  1116. 64: a:=s64real;
  1117. { adding support for 80 bit here is tricky, since we can't really }
  1118. { check whether the target cpu+OS actually supports it }
  1119. else
  1120. exit;
  1121. end;
  1122. result:=true;
  1123. end;
  1124. function var_align(want_align: longint): shortint;
  1125. begin
  1126. var_align := used_align(want_align,current_settings.alignment.varalignmin,current_settings.alignment.varalignmax);
  1127. end;
  1128. function var_align_size(siz: longint): shortint;
  1129. begin
  1130. siz := size_2_align(siz);
  1131. var_align_size := var_align(siz);
  1132. end;
  1133. function const_align(want_align: longint): shortint;
  1134. begin
  1135. const_align := used_align(want_align,current_settings.alignment.constalignmin,current_settings.alignment.constalignmax);
  1136. end;
  1137. function const_align_size(siz: longint): shortint;
  1138. begin
  1139. siz := size_2_align(siz);
  1140. const_align_size := const_align(siz);
  1141. end;
  1142. {$ifdef ARM}
  1143. function is_double_hilo_swapped: boolean;{$ifdef USEINLINE}inline;{$endif}
  1144. begin
  1145. result := (current_settings.fputype in [fpu_fpa,fpu_fpa10,fpu_fpa11]) and
  1146. not(cs_fp_emulation in current_settings.moduleswitches);
  1147. {$ifdef FPC_DOUBLE_HILO_SWAPPED}
  1148. { inverse result if compiler was compiled with swapped hilo already }
  1149. result := not result;
  1150. {$endif FPC_DOUBLE_HILO_SWAPPED}
  1151. end;
  1152. {$endif ARM}
  1153. function floating_point_range_check_error : boolean;
  1154. begin
  1155. result:=((([cs_check_range,cs_check_overflow]*current_settings.localswitches)<>[]) and not
  1156. (m_delphi in current_settings.modeswitches)
  1157. ); // or (cs_ieee_errors in current_settings.localswitches);
  1158. end;
  1159. {****************************************************************************
  1160. Init
  1161. ****************************************************************************}
  1162. {$ifdef unix}
  1163. {$define need_path_search}
  1164. {$endif unix}
  1165. {$ifdef os2}
  1166. {$define need_path_search}
  1167. {$endif os2}
  1168. {$ifdef macos}
  1169. {$define need_path_search}
  1170. {$endif macos}
  1171. procedure get_exepath;
  1172. var
  1173. localExepath : TCmdStr;
  1174. exeName:TCmdStr;
  1175. {$ifdef need_path_search}
  1176. hs1 : TPathStr;
  1177. {$endif need_path_search}
  1178. begin
  1179. localexepath:=GetEnvironmentVariable('PPC_EXEC_PATH');
  1180. if localexepath='' then
  1181. begin
  1182. exeName := FixFileName(system.paramstr(0));
  1183. localexepath := ExtractFilePath(exeName);
  1184. end;
  1185. {$ifdef need_path_search}
  1186. if localexepath='' then
  1187. begin
  1188. hs1 := ExtractFileName(exeName);
  1189. ChangeFileExt(hs1,source_info.exeext);
  1190. {$ifdef macos}
  1191. FindFile(hs1,GetEnvironmentVariable('Commands'),false,localExepath);
  1192. {$else macos}
  1193. FindFile(hs1,GetEnvironmentVariable('PATH'),false,localExepath);
  1194. {$endif macos}
  1195. localExepath:=ExtractFilePath(localExepath);
  1196. end;
  1197. {$endif need_path_search}
  1198. exepath:=FixPath(localExepath,false);
  1199. end;
  1200. procedure DoneGlobals;
  1201. begin
  1202. if assigned(DLLImageBase) then
  1203. StringDispose(DLLImageBase);
  1204. librarysearchpath.Free;
  1205. unitsearchpath.Free;
  1206. objectsearchpath.Free;
  1207. includesearchpath.Free;
  1208. frameworksearchpath.Free;
  1209. LinkLibraryAliases.Free;
  1210. LinkLibraryOrder.Free;
  1211. end;
  1212. procedure InitGlobals;
  1213. begin
  1214. get_exepath;
  1215. { reset globals }
  1216. do_build:=false;
  1217. do_release:=false;
  1218. do_make:=true;
  1219. compile_level:=0;
  1220. DLLsource:=false;
  1221. paratarget:=system_none;
  1222. paratargetasm:=as_none;
  1223. paratargetdbg:=dbg_none;
  1224. { Output }
  1225. OutputFileName:='';
  1226. OutputPrefix:=Nil;
  1227. OutputSuffix:=Nil;
  1228. OutputExeDir:='';
  1229. OutputUnitDir:='';
  1230. { Utils directory }
  1231. utilsdirectory:='';
  1232. utilsprefix:='';
  1233. cshared:=false;
  1234. rlinkpath:='';
  1235. sysrootpath:='';
  1236. { Search Paths }
  1237. librarysearchpath:=TSearchPathList.Create;
  1238. unitsearchpath:=TSearchPathList.Create;
  1239. includesearchpath:=TSearchPathList.Create;
  1240. objectsearchpath:=TSearchPathList.Create;
  1241. frameworksearchpath:=TSearchPathList.Create;
  1242. { Def file }
  1243. usewindowapi:=false;
  1244. description:='Compiled by FPC '+version_string+' - '+target_cpu_string;
  1245. DescriptionSetExplicity:=false;
  1246. SetPEFlagsSetExplicity:=false;
  1247. ImageBaseSetExplicity:=false;
  1248. MinStackSizeSetExplicity:=false;
  1249. MaxStackSizeSetExplicity:=false;
  1250. dllversion:='';
  1251. dllmajor:=1;
  1252. dllminor:=0;
  1253. dllrevision:=0;
  1254. nwscreenname := '';
  1255. nwthreadname := '';
  1256. nwcopyright := '';
  1257. UseDeffileForExports:=false;
  1258. UseDeffileForExportsSetExplicitly:=false;
  1259. GenerateImportSection:=false;
  1260. RelocSection:=false;
  1261. RelocSectionSetExplicitly:=false;
  1262. LinkTypeSetExplicitly:=false;
  1263. { memory sizes, will be overriden by parameter or default for target
  1264. in options or init_parser }
  1265. stacksize:=0;
  1266. { not initialized yet }
  1267. jmp_buf_size:=-1;
  1268. apptype:=app_cui;
  1269. { Init values }
  1270. init_settings:=default_settings;
  1271. if init_settings.optimizecputype=cpu_none then
  1272. init_settings.optimizecputype:=init_settings.cputype;
  1273. LinkLibraryAliases :=TLinkStrMap.Create;
  1274. LinkLibraryOrder :=TLinkStrMap.Create;
  1275. { enable all features by default }
  1276. features:=[low(Tfeature)..high(Tfeature)];
  1277. end;
  1278. end.