globals.pas 41 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438
  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 = packed 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 : puint;
  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. { used to set all registers used for each global function
  255. this should dramatically decrease the number of
  256. recompilations needed PM }
  257. simplify_ppu : boolean = true;
  258. Inside_asm_statement : boolean = false;
  259. global_unit_count : word = 0;
  260. { for error info in pp.pas }
  261. parser_current_file : string = '';
  262. {$if defined(m68k) or defined(arm)}
  263. { PalmOS resources }
  264. palmos_applicationname : string = 'FPC Application';
  265. palmos_applicationid : string[4] = 'FPCA';
  266. {$endif defined(m68k) or defined(arm)}
  267. {$ifdef powerpc}
  268. { default calling convention used on MorphOS }
  269. syscall_convention : string = 'LEGACY';
  270. {$endif powerpc}
  271. { default name of the C-style "main" procedure of the library/program }
  272. { (this will be prefixed with the target_info.cprefix) }
  273. defaultmainaliasname = 'main';
  274. mainaliasname : string = defaultmainaliasname;
  275. { by default no local variable trashing }
  276. localvartrashing: longint = -1;
  277. { actual values are defined in ncgutil.pas }
  278. nroftrashvalues = 4;
  279. const
  280. default_settings : TSettings = (
  281. globalswitches : [cs_check_unit_name,cs_link_static];
  282. moduleswitches : [cs_extsyntax,cs_implicit_exceptions];
  283. localswitches : [cs_check_io,cs_typed_const_writable];
  284. modeswitches : fpcmodeswitches;
  285. optimizerswitches : [];
  286. genwpoptimizerswitches : [];
  287. dowpoptimizerswitches : [];
  288. debugswitches : [];
  289. setalloc : 0;
  290. packenum : 4;
  291. alignment : (
  292. procalign : 0;
  293. loopalign : 0;
  294. jumpalign : 0;
  295. constalignmin : 0;
  296. constalignmax : 0;
  297. varalignmin : 0;
  298. varalignmax : 0;
  299. localalignmin : 0;
  300. localalignmax : 0;
  301. recordalignmin : 0;
  302. recordalignmax : 0;
  303. maxCrecordalign : 0;
  304. );
  305. {$ifdef i386}
  306. cputype : cpu_Pentium;
  307. optimizecputype : cpu_Pentium3;
  308. fputype : fpu_x87;
  309. {$endif i386}
  310. {$ifdef m68k}
  311. cputype : cpu_MC68020;
  312. optimizecputype : cpu_MC68020;
  313. fputype : fpu_soft;
  314. {$endif m68k}
  315. {$ifdef powerpc}
  316. cputype : cpu_PPC604;
  317. optimizecputype : cpu_ppc7400;
  318. fputype : fpu_standard;
  319. {$endif powerpc}
  320. {$ifdef POWERPC64}
  321. cputype : cpu_PPC970;
  322. optimizecputype : cpu_ppc970;
  323. fputype : fpu_standard;
  324. {$endif POWERPC64}
  325. {$ifdef sparc}
  326. cputype : cpu_SPARC_V8;
  327. optimizecputype : cpu_SPARC_V8;
  328. fputype : fpu_hard;
  329. {$endif sparc}
  330. {$ifdef arm}
  331. cputype : cpu_armv3;
  332. optimizecputype : cpu_armv3;
  333. fputype : fpu_fpa;
  334. {$endif arm}
  335. {$ifdef x86_64}
  336. cputype : cpu_athlon64;
  337. optimizecputype : cpu_athlon64;
  338. fputype : fpu_sse64;
  339. {$endif x86_64}
  340. {$ifdef avr}
  341. cputype : cpuinfo.cpu_avr;
  342. optimizecputype : cpuinfo.cpu_avr;
  343. fputype : fpu_none;
  344. {$endif avr}
  345. asmmode : asmmode_standard;
  346. interfacetype : it_interfacecom;
  347. defproccall : pocall_default;
  348. sourcecodepage : '8859-1';
  349. packrecords : 0;
  350. maxfpuregisters : 0;
  351. minfpconstprec : s32real;
  352. {$if defined(ARM)}
  353. controllertype : ct_none;
  354. {$endif defined(ARM)}
  355. );
  356. var
  357. starttime : real;
  358. function getdatestr:string;
  359. function gettimestr:string;
  360. function filetimestring( t : longint) : string;
  361. function getrealtime : real;
  362. procedure DefaultReplacements(var s:ansistring);
  363. function Shell(const command:ansistring): longint;
  364. function GetEnvPChar(const envname:string):pchar;
  365. procedure FreeEnvPChar(p:pchar);
  366. function is_number_float(d : double) : boolean;
  367. { discern +0.0 and -0.0 }
  368. function get_real_sign(r: bestreal): longint;
  369. procedure InitGlobals;
  370. procedure DoneGlobals;
  371. function string2guid(const s: string; var GUID: TGUID): boolean;
  372. function guid2string(const GUID: TGUID): string;
  373. function SetAktProcCall(const s:string; var a:tproccalloption):boolean;
  374. function Setabitype(const s:string;var a:tabi):boolean;
  375. function Setcputype(const s:string;var a:tcputype):boolean;
  376. function SetFpuType(const s:string;var a:tfputype):boolean;
  377. {$if defined(arm) or defined(avr)}
  378. function SetControllerType(const s:string;var a:tcontrollertype):boolean;
  379. {$endif defined(arm) or defined(avr)}
  380. function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
  381. function UpdateOptimizerStr(s:string;var a:toptimizerswitches):boolean;
  382. function UpdateWpoStr(s: string; var a: twpoptimizerswitches): boolean;
  383. function UpdateDebugStr(s:string;var a:tdebugswitches):boolean;
  384. function IncludeFeature(const s : string) : boolean;
  385. function SetMinFPConstPrec(const s: string; var a: tfloattype) : boolean;
  386. {# Routine to get the required alignment for size of data, which will
  387. be placed in bss segment, according to the current alignment requirements }
  388. function var_align(want_align: longint): shortint;
  389. function var_align_size(siz: longint): shortint;
  390. {# Routine to get the required alignment for size of data, which will
  391. be placed in data/const segment, according to the current alignment requirements }
  392. function const_align(want_align: longint): shortint;
  393. function const_align_size(siz: longint): shortint;
  394. {$ifdef ARM}
  395. function is_double_hilo_swapped: boolean;{$ifdef USEINLINE}inline;{$endif}
  396. {$endif ARM}
  397. function floating_point_range_check_error : boolean;
  398. implementation
  399. uses
  400. {$ifdef macos}
  401. macutils,
  402. {$endif}
  403. comphook;
  404. {****************************************************************************
  405. TLinkStrMap
  406. ****************************************************************************}
  407. Constructor TLinkStrMap.create;
  408. begin
  409. inherited;
  410. itemcnt:=0;
  411. end;
  412. procedure TLinkStrMap.Add(key:ansistring;value:AnsiString='';weight:longint=LinkMapWeightDefault);
  413. begin
  414. if lookup(key)<>-1 Then
  415. exit;
  416. if itemcnt<=length(fmap) Then
  417. setlength(fmap,itemcnt+10);
  418. fmap[itemcnt].key:=key;
  419. fmap[itemcnt].value:=value;
  420. fmap[itemcnt].weight:=weight;
  421. inc(itemcnt);
  422. end;
  423. function TLinkStrMap.AddDep(keyvalue:String):boolean;
  424. var
  425. i : Longint;
  426. begin
  427. AddDep:=false;
  428. i:=pos('=',keyvalue);
  429. if i=0 then
  430. exit;
  431. Add(Copy(KeyValue,1,i-1),Copy(KeyValue,i+1,length(KeyValue)-i));
  432. AddDep:=True;
  433. end;
  434. function TLinkStrMap.AddWeight(keyvalue:String):boolean;
  435. var
  436. i,j : Longint;
  437. Code : Word;
  438. s : AnsiString;
  439. begin
  440. AddWeight:=false;
  441. i:=pos('=',keyvalue);
  442. if i=0 then
  443. exit;
  444. s:=Copy(KeyValue,i+1,length(KeyValue)-i);
  445. val(s,j,code);
  446. if code=0 Then
  447. begin
  448. Add(Copy(KeyValue,1,i-1),'',j);
  449. AddWeight:=True;
  450. end;
  451. end;
  452. procedure TLinkStrMap.addseries(keys:AnsiString;weight:longint);
  453. var
  454. i,j,k : longint;
  455. begin
  456. k:=length(keys);
  457. i:=1;
  458. while i<=k do
  459. begin
  460. j:=i;
  461. while (i<=k) and (keys[i]<>',') do
  462. inc(i);
  463. add(copy(keys,j,i-j),'',weight);
  464. inc(i);
  465. end;
  466. end;
  467. procedure TLinkStrMap.SetValue(Key:Ansistring;weight:Integer);
  468. var
  469. j : longint;
  470. begin
  471. j:=lookup(key);
  472. if j<>-1 then
  473. fmap[j].weight:=weight;
  474. end;
  475. function TLinkStrMap.find(key:Ansistring):Ansistring;
  476. var
  477. j : longint;
  478. begin
  479. find:='';
  480. j:=lookup(key);
  481. if j<>-1 then
  482. find:=fmap[j].value;
  483. end;
  484. function TLinkStrMap.lookup(key:Ansistring):longint;
  485. var
  486. i : longint;
  487. begin
  488. lookup:=-1;
  489. i:=0;
  490. while (i<itemcnt) and (fmap[i].key<>key) do
  491. inc(i);
  492. if i<>itemcnt then
  493. lookup:=i;
  494. end;
  495. procedure TLinkStrMap.SortOnWeight;
  496. var
  497. i, j : longint;
  498. m : TLinkRec;
  499. begin
  500. if itemcnt <2 then exit;
  501. for i:=0 to itemcnt-1 do
  502. for j:=i+1 to itemcnt-1 do
  503. begin
  504. if fmap[i].weight>fmap[j].weight Then
  505. begin
  506. m:=fmap[i];
  507. fmap[i]:=fmap[j];
  508. fmap[j]:=m;
  509. end;
  510. end;
  511. end;
  512. function TLinkStrMap.getlinkrec(i:longint):TLinkRec;
  513. begin
  514. result:=fmap[i];
  515. end;
  516. procedure TLinkStrMap.Expand(Src:TCmdStrList;Dest:TLinkStrMap);
  517. // expands every thing in Src to Dest for linkorder purposes.
  518. var
  519. r : longint;
  520. LibN : TCmdStr;
  521. begin
  522. while not src.empty do
  523. begin
  524. LibN:=src.getfirst;
  525. r:=lookup (LibN);
  526. if r=-1 then
  527. dest.add(LibN)
  528. else
  529. dest.addseries(fmap[r].value);
  530. end;
  531. end;
  532. procedure TLinkStrMap.UpdateWeights(Weightmap:TLinkStrMap);
  533. var
  534. l,r : longint;
  535. begin
  536. for l := 0 to itemcnt-1 do
  537. begin
  538. r:=weightmap.lookup (fmap[l].key);
  539. if r<>-1 then
  540. fmap[l].weight:=weightmap[r].weight;
  541. end;
  542. end;
  543. {****************************************************************************
  544. Time Handling
  545. ****************************************************************************}
  546. Function L0(l:longint):string;
  547. {
  548. return the string of value l, if l<10 then insert a zero, so
  549. the string is always at least 2 chars '01','02',etc
  550. }
  551. var
  552. s : string;
  553. begin
  554. Str(l,s);
  555. if l<10 then
  556. s:='0'+s;
  557. L0:=s;
  558. end;
  559. function gettimestr:string;
  560. {
  561. get the current time in a string HH:MM:SS
  562. }
  563. var
  564. hour,min,sec,hsec : word;
  565. begin
  566. DecodeTime(Time,hour,min,sec,hsec);
  567. gettimestr:=L0(Hour)+':'+L0(min)+':'+L0(sec);
  568. end;
  569. function getdatestr:string;
  570. {
  571. get the current date in a string YY/MM/DD
  572. }
  573. var
  574. Year,Month,Day: Word;
  575. begin
  576. DecodeDate(Date,year,month,day);
  577. getdatestr:=L0(Year)+'/'+L0(Month)+'/'+L0(Day);
  578. end;
  579. function filetimestring( t : longint) : string;
  580. {
  581. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  582. }
  583. var
  584. DT : TDateTime;
  585. hsec : word;
  586. Year,Month,Day: Word;
  587. hour,min,sec : word;
  588. begin
  589. if t=-1 then
  590. begin
  591. Result := 'Not Found';
  592. exit;
  593. end;
  594. DT := FileDateToDateTime(t);
  595. DecodeTime(DT,hour,min,sec,hsec);
  596. DecodeDate(DT,year,month,day);
  597. Result := L0(Year)+'/'+L0(Month)+'/'+L0(Day)+' '+L0(Hour)+':'+L0(min)+':'+L0(sec);
  598. end;
  599. function getrealtime : real;
  600. var
  601. h,m,s,s1000 : word;
  602. begin
  603. DecodeTime(Time,h,m,s,s1000);
  604. result:=h*3600.0+m*60.0+s+s1000/1000.0;
  605. end;
  606. {****************************************************************************
  607. Default Macro Handling
  608. ****************************************************************************}
  609. procedure DefaultReplacements(var s:ansistring);
  610. begin
  611. { Replace some macros }
  612. Replace(s,'$FPCVERSION',version_string);
  613. Replace(s,'$FPCFULLVERSION',full_version_string);
  614. Replace(s,'$FPCDATE',date_string);
  615. Replace(s,'$FPCCPU',target_cpu_string);
  616. Replace(s,'$FPCOS',target_os_string);
  617. if tf_use_8_3 in Source_Info.Flags then
  618. Replace(s,'$FPCTARGET',target_os_string)
  619. else
  620. Replace(s,'$FPCTARGET',target_full_string);
  621. end;
  622. {****************************************************************************
  623. OS Dependent things
  624. ****************************************************************************}
  625. function GetEnvPChar(const envname:string):pchar;
  626. {$ifdef win32}
  627. var
  628. s : string;
  629. i,len : longint;
  630. hp,p,p2 : pchar;
  631. {$endif}
  632. begin
  633. {$ifdef hasunix}
  634. GetEnvPchar:=BaseUnix.fpGetEnv(envname);
  635. {$define GETENVOK}
  636. {$endif}
  637. {$ifdef win32}
  638. GetEnvPchar:=nil;
  639. p:=GetEnvironmentStrings;
  640. hp:=p;
  641. while hp^<>#0 do
  642. begin
  643. s:=strpas(hp);
  644. i:=pos('=',s);
  645. len:=strlen(hp);
  646. if upper(copy(s,1,i-1))=upper(envname) then
  647. begin
  648. GetMem(p2,len-length(envname));
  649. Move(hp[i],p2^,len-length(envname));
  650. GetEnvPchar:=p2;
  651. break;
  652. end;
  653. { next string entry}
  654. hp:=hp+len+1;
  655. end;
  656. FreeEnvironmentStrings(p);
  657. {$define GETENVOK}
  658. {$endif}
  659. {$ifdef os2}
  660. GetEnvPChar := Dos.GetEnvPChar (EnvName);
  661. {$define GETENVOK}
  662. {$endif}
  663. {$ifdef GETENVOK}
  664. {$undef GETENVOK}
  665. {$else}
  666. GetEnvPchar:=StrPNew(GetEnvironmentVariable(envname));
  667. {$endif}
  668. end;
  669. procedure FreeEnvPChar(p:pchar);
  670. begin
  671. {$ifndef hasunix}
  672. {$ifndef os2}
  673. freemem(p);
  674. {$endif}
  675. {$endif}
  676. end;
  677. {$if defined(MORPHOS) or defined(AMIGA)}
  678. {$define AMIGASHELL}
  679. {$endif}
  680. function Shell(const command:ansistring): longint;
  681. { This is already defined in the linux.ppu for linux, need for the *
  682. expansion under linux }
  683. {$ifdef hasunix}
  684. begin
  685. result := Unix.fpsystem(command);
  686. end;
  687. {$else hasunix}
  688. {$ifdef amigashell}
  689. begin
  690. result := ExecuteProcess('',command);
  691. end;
  692. {$else amigashell}
  693. var
  694. comspec : string;
  695. begin
  696. comspec:=GetEnvironmentVariable('COMSPEC');
  697. result := ExecuteProcess(comspec,' /C '+command);
  698. end;
  699. {$endif amigashell}
  700. {$endif hasunix}
  701. {$UNDEF AMIGASHELL}
  702. function is_number_float(d : double) : boolean;
  703. var
  704. bytearray : array[0..7] of byte;
  705. begin
  706. move(d,bytearray,8);
  707. { only 1.1 save, 1.0.x will use always little endian }
  708. {$ifdef FPC_BIG_ENDIAN}
  709. result:=((bytearray[0] and $7f)<>$7f) or ((bytearray[1] and $f0)<>$f0);
  710. {$else FPC_BIG_ENDIAN}
  711. result:=((bytearray[7] and $7f)<>$7f) or ((bytearray[6] and $f0)<>$f0);
  712. {$endif FPC_BIG_ENDIAN}
  713. end;
  714. function get_real_sign(r: bestreal): longint;
  715. var
  716. p: pbyte;
  717. begin
  718. p := pbyte(@r);
  719. {$ifdef CPU_ARM}
  720. inc(p,4);
  721. {$else}
  722. {$ifdef FPC_LITTLE_ENDIAN}
  723. inc(p,sizeof(r)-1);
  724. {$endif}
  725. {$endif}
  726. if (p^ and $80) = 0 then
  727. result := 1
  728. else
  729. result := -1;
  730. end;
  731. function convertdoublerec(d : tdoublerec) : tdoublerec;{$ifdef USEINLINE}inline;{$endif}
  732. {$ifdef CPUARM}
  733. var
  734. i : longint;
  735. begin
  736. for i:=0 to 3 do
  737. begin
  738. result.bytes[i+4]:=d.bytes[i];
  739. result.bytes[i]:=d.bytes[i+4];
  740. end;
  741. {$else CPUARM}
  742. begin
  743. result:=d;
  744. {$endif CPUARM}
  745. end;
  746. { '('D1:'00000000-'D2:'0000-'D3:'0000-'D4:'0000-000000000000)' }
  747. function string2guid(const s: string; var GUID: TGUID): boolean;
  748. function ishexstr(const hs: string): boolean;
  749. var
  750. i: integer;
  751. begin
  752. ishexstr:=false;
  753. for i:=1 to Length(hs) do begin
  754. if not (hs[i] in ['0'..'9','A'..'F','a'..'f']) then
  755. exit;
  756. end;
  757. ishexstr:=true;
  758. end;
  759. function hexstr2longint(const hexs: string): longint;
  760. var
  761. i: integer;
  762. rl: longint;
  763. begin
  764. rl:=0;
  765. for i:=1 to length(hexs) do begin
  766. rl:=rl shl 4;
  767. case hexs[i] of
  768. '0'..'9' : inc(rl,ord(hexs[i])-ord('0'));
  769. 'A'..'F' : inc(rl,ord(hexs[i])-ord('A')+10);
  770. 'a'..'f' : inc(rl,ord(hexs[i])-ord('a')+10);
  771. end
  772. end;
  773. hexstr2longint:=rl;
  774. end;
  775. var
  776. i: integer;
  777. begin
  778. if (Length(s)=38) and (s[1]='{') and (s[38]='}') and
  779. (s[10]='-') and (s[15]='-') and (s[20]='-') and (s[25]='-') and
  780. ishexstr(copy(s,2,8)) and ishexstr(copy(s,11,4)) and
  781. ishexstr(copy(s,16,4)) and ishexstr(copy(s,21,4)) and
  782. ishexstr(copy(s,26,12)) then begin
  783. GUID.D1:=dword(hexstr2longint(copy(s,2,8)));
  784. { these values are arealdy in the correct range (4 chars = word) }
  785. GUID.D2:=word(hexstr2longint(copy(s,11,4)));
  786. GUID.D3:=word(hexstr2longint(copy(s,16,4)));
  787. for i:=0 to 1 do
  788. GUID.D4[i]:=byte(hexstr2longint(copy(s,21+i*2,2)));
  789. for i:=2 to 7 do
  790. GUID.D4[i]:=byte(hexstr2longint(copy(s,22+i*2,2)));
  791. string2guid:=true;
  792. end
  793. else if (length(s)=0) then
  794. begin
  795. FillChar(GUID,SizeOf(GUID),0);
  796. string2guid:=true;
  797. end
  798. else
  799. string2guid:=false;
  800. end;
  801. function guid2string(const GUID: TGUID): string;
  802. begin
  803. guid2string:=
  804. '{'+hexstr(GUID.D1,8)+
  805. '-'+hexstr(GUID.D2,4)+
  806. '-'+hexstr(GUID.D3,4)+
  807. '-'+hexstr(GUID.D4[0],2)+hexstr(GUID.D4[1],2)+
  808. '-'+hexstr(GUID.D4[2],2)+hexstr(GUID.D4[3],2)+
  809. hexstr(GUID.D4[4],2)+hexstr(GUID.D4[5],2)+
  810. hexstr(GUID.D4[6],2)+hexstr(GUID.D4[7],2)+
  811. '}';
  812. end;
  813. function SetAktProcCall(const s:string; var a:tproccalloption):boolean;
  814. const
  815. DefProcCallName : array[tproccalloption] of string[12] = ('',
  816. 'CDECL',
  817. 'CPPDECL',
  818. 'FAR16',
  819. 'OLDFPCCALL',
  820. '', { internproc }
  821. '', { syscall }
  822. 'PASCAL',
  823. 'REGISTER',
  824. 'SAFECALL',
  825. 'STDCALL',
  826. 'SOFTFLOAT',
  827. 'MWPASCAL'
  828. );
  829. var
  830. t : tproccalloption;
  831. hs : string;
  832. begin
  833. result:=false;
  834. if (s = '') then
  835. exit;
  836. hs:=upper(s);
  837. if (hs = 'DEFAULT') then
  838. begin
  839. a := pocall_default;
  840. result := true;
  841. exit;
  842. end;
  843. for t:=low(tproccalloption) to high(tproccalloption) do
  844. if DefProcCallName[t]=hs then
  845. begin
  846. a:=t;
  847. result:=true;
  848. break;
  849. end;
  850. end;
  851. function Setabitype(const s:string;var a:tabi):boolean;
  852. var
  853. t : tabi;
  854. hs : string;
  855. begin
  856. result:=false;
  857. hs:=Upper(s);
  858. for t:=low(t) to high(t) do
  859. if abi2str[t]=hs then
  860. begin
  861. a:=t;
  862. result:=true;
  863. break;
  864. end;
  865. end;
  866. function Setcputype(const s:string;var a:tcputype):boolean;
  867. var
  868. t : tcputype;
  869. hs : string;
  870. begin
  871. result:=false;
  872. hs:=Upper(s);
  873. for t:=low(tcputype) to high(tcputype) do
  874. if cputypestr[t]=hs then
  875. begin
  876. a:=t;
  877. result:=true;
  878. break;
  879. end;
  880. end;
  881. function SetFpuType(const s:string;var a:tfputype):boolean;
  882. var
  883. t : tfputype;
  884. begin
  885. result:=false;
  886. for t:=low(tfputype) to high(tfputype) do
  887. if fputypestr[t]=s then
  888. begin
  889. a:=t;
  890. result:=true;
  891. break;
  892. end;
  893. end;
  894. {$if defined(arm) or defined(avr)}
  895. function SetControllerType(const s:string;var a:tcontrollertype):boolean;
  896. var
  897. t : tcontrollertype;
  898. hs : string;
  899. begin
  900. result:=false;
  901. hs:=Upper(s);
  902. for t:=low(tcontrollertype) to high(tcontrollertype) do
  903. if controllertypestr[t]=hs then
  904. begin
  905. a:=t;
  906. result:=true;
  907. break;
  908. end;
  909. end;
  910. {$endif defined(arm) or defined(avr)}
  911. function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
  912. var
  913. tok : string;
  914. vstr : string;
  915. l : longint;
  916. code : integer;
  917. b : talignmentinfo;
  918. begin
  919. UpdateAlignmentStr:=true;
  920. uppervar(s);
  921. fillchar(b,sizeof(b),0);
  922. repeat
  923. tok:=GetToken(s,'=');
  924. if tok='' then
  925. break;
  926. vstr:=GetToken(s,',');
  927. val(vstr,l,code);
  928. if tok='PROC' then
  929. b.procalign:=l
  930. else if tok='JUMP' then
  931. b.jumpalign:=l
  932. else if tok='LOOP' then
  933. b.loopalign:=l
  934. else if tok='CONSTMIN' then
  935. b.constalignmin:=l
  936. else if tok='CONSTMAX' then
  937. b.constalignmax:=l
  938. else if tok='VARMIN' then
  939. b.varalignmin:=l
  940. else if tok='VARMAX' then
  941. b.varalignmax:=l
  942. else if tok='LOCALMIN' then
  943. b.localalignmin:=l
  944. else if tok='LOCALMAX' then
  945. b.localalignmax:=l
  946. else if tok='RECORDMIN' then
  947. b.recordalignmin:=l
  948. else if tok='RECORDMAX' then
  949. b.recordalignmax:=l
  950. else { Error }
  951. UpdateAlignmentStr:=false;
  952. until false;
  953. UpdateAlignment(a,b);
  954. end;
  955. function UpdateOptimizerStr(s:string;var a:toptimizerswitches):boolean;
  956. var
  957. tok : string;
  958. doset,
  959. found : boolean;
  960. opt : toptimizerswitch;
  961. begin
  962. result:=true;
  963. uppervar(s);
  964. repeat
  965. tok:=GetToken(s,',');
  966. if tok='' then
  967. break;
  968. if Copy(tok,1,2)='NO' then
  969. begin
  970. delete(tok,1,2);
  971. doset:=false;
  972. end
  973. else
  974. doset:=true;
  975. found:=false;
  976. for opt:=low(toptimizerswitch) to high(toptimizerswitch) do
  977. begin
  978. if OptimizerSwitchStr[opt]=tok then
  979. begin
  980. found:=true;
  981. break;
  982. end;
  983. end;
  984. if found then
  985. begin
  986. if doset then
  987. include(a,opt)
  988. else
  989. exclude(a,opt);
  990. end
  991. else
  992. result:=false;
  993. until false;
  994. end;
  995. function UpdateWpoStr(s: string; var a: twpoptimizerswitches): boolean;
  996. var
  997. tok : string;
  998. doset,
  999. found : boolean;
  1000. opt : twpoptimizerswitch;
  1001. begin
  1002. result:=true;
  1003. uppervar(s);
  1004. repeat
  1005. tok:=GetToken(s,',');
  1006. if tok='' then
  1007. break;
  1008. if Copy(tok,1,2)='NO' then
  1009. begin
  1010. delete(tok,1,2);
  1011. doset:=false;
  1012. end
  1013. else
  1014. doset:=true;
  1015. found:=false;
  1016. if (tok = 'ALL') then
  1017. begin
  1018. for opt:=low(twpoptimizerswitch) to high(twpoptimizerswitch) do
  1019. if doset then
  1020. include(a,opt)
  1021. else
  1022. exclude(a,opt);
  1023. end
  1024. else
  1025. begin
  1026. for opt:=low(twpoptimizerswitch) to high(twpoptimizerswitch) do
  1027. begin
  1028. if WPOptimizerSwitchStr[opt]=tok then
  1029. begin
  1030. found:=true;
  1031. break;
  1032. end;
  1033. end;
  1034. if found then
  1035. begin
  1036. if doset then
  1037. include(a,opt)
  1038. else
  1039. exclude(a,opt);
  1040. end
  1041. else
  1042. result:=false;
  1043. end;
  1044. until false;
  1045. end;
  1046. function UpdateDebugStr(s:string;var a:tdebugswitches):boolean;
  1047. var
  1048. tok : string;
  1049. doset,
  1050. found : boolean;
  1051. opt : tdebugswitch;
  1052. begin
  1053. result:=true;
  1054. uppervar(s);
  1055. repeat
  1056. tok:=GetToken(s,',');
  1057. if tok='' then
  1058. break;
  1059. if Copy(tok,1,2)='NO' then
  1060. begin
  1061. delete(tok,1,2);
  1062. doset:=false;
  1063. end
  1064. else
  1065. doset:=true;
  1066. found:=false;
  1067. for opt:=low(tdebugswitch) to high(tdebugswitch) do
  1068. begin
  1069. if DebugSwitchStr[opt]=tok then
  1070. begin
  1071. found:=true;
  1072. break;
  1073. end;
  1074. end;
  1075. if found then
  1076. begin
  1077. if doset then
  1078. include(a,opt)
  1079. else
  1080. exclude(a,opt);
  1081. end
  1082. else
  1083. result:=false;
  1084. until false;
  1085. end;
  1086. function IncludeFeature(const s : string) : boolean;
  1087. var
  1088. i : tfeature;
  1089. begin
  1090. result:=true;
  1091. for i:=low(tfeature) to high(tfeature) do
  1092. if s=featurestr[i] then
  1093. begin
  1094. include(features,i);
  1095. exit;
  1096. end;
  1097. result:=false;
  1098. end;
  1099. function SetMinFPConstPrec(const s: string; var a: tfloattype) : boolean;
  1100. var
  1101. value, error: longint;
  1102. begin
  1103. if (upper(s)='DEFAULT') then
  1104. begin
  1105. a:=s32real;
  1106. result:=true;
  1107. exit;
  1108. end;
  1109. result:=false;
  1110. val(s,value,error);
  1111. if (error<>0) then
  1112. exit;
  1113. case value of
  1114. 32: a:=s32real;
  1115. 64: a:=s64real;
  1116. { adding support for 80 bit here is tricky, since we can't really }
  1117. { check whether the target cpu+OS actually supports it }
  1118. else
  1119. exit;
  1120. end;
  1121. result:=true;
  1122. end;
  1123. function var_align(want_align: longint): shortint;
  1124. begin
  1125. var_align := used_align(want_align,current_settings.alignment.varalignmin,current_settings.alignment.varalignmax);
  1126. end;
  1127. function var_align_size(siz: longint): shortint;
  1128. begin
  1129. siz := size_2_align(siz);
  1130. var_align_size := var_align(siz);
  1131. end;
  1132. function const_align(want_align: longint): shortint;
  1133. begin
  1134. const_align := used_align(want_align,current_settings.alignment.constalignmin,current_settings.alignment.constalignmax);
  1135. end;
  1136. function const_align_size(siz: longint): shortint;
  1137. begin
  1138. siz := size_2_align(siz);
  1139. const_align_size := const_align(siz);
  1140. end;
  1141. {$ifdef ARM}
  1142. function is_double_hilo_swapped: boolean;{$ifdef USEINLINE}inline;{$endif}
  1143. begin
  1144. result := (current_settings.fputype in [fpu_fpa,fpu_fpa10,fpu_fpa11]) and
  1145. not(cs_fp_emulation in current_settings.moduleswitches);
  1146. {$ifdef FPC_DOUBLE_HILO_SWAPPED}
  1147. { inverse result if compiler was compiled with swapped hilo already }
  1148. result := not result;
  1149. {$endif FPC_DOUBLE_HILO_SWAPPED}
  1150. end;
  1151. {$endif ARM}
  1152. function floating_point_range_check_error : boolean;
  1153. begin
  1154. result:=((([cs_check_range,cs_check_overflow]*current_settings.localswitches)<>[]) and not
  1155. (m_delphi in current_settings.modeswitches)
  1156. ); // or (cs_ieee_errors in current_settings.localswitches);
  1157. end;
  1158. {****************************************************************************
  1159. Init
  1160. ****************************************************************************}
  1161. {$ifdef unix}
  1162. {$define need_path_search}
  1163. {$endif unix}
  1164. {$ifdef os2}
  1165. {$define need_path_search}
  1166. {$endif os2}
  1167. {$ifdef macos}
  1168. {$define need_path_search}
  1169. {$endif macos}
  1170. procedure get_exepath;
  1171. var
  1172. localExepath : TCmdStr;
  1173. exeName:TCmdStr;
  1174. {$ifdef need_path_search}
  1175. hs1 : TPathStr;
  1176. {$endif need_path_search}
  1177. begin
  1178. localexepath:=GetEnvironmentVariable('PPC_EXEC_PATH');
  1179. if localexepath='' then
  1180. begin
  1181. exeName := FixFileName(system.paramstr(0));
  1182. localexepath := ExtractFilePath(exeName);
  1183. end;
  1184. {$ifdef need_path_search}
  1185. if localexepath='' then
  1186. begin
  1187. hs1 := ExtractFileName(exeName);
  1188. ChangeFileExt(hs1,source_info.exeext);
  1189. {$ifdef macos}
  1190. FindFile(hs1,GetEnvironmentVariable('Commands'),false,localExepath);
  1191. {$else macos}
  1192. FindFile(hs1,GetEnvironmentVariable('PATH'),false,localExepath);
  1193. {$endif macos}
  1194. localExepath:=ExtractFilePath(localExepath);
  1195. end;
  1196. {$endif need_path_search}
  1197. exepath:=FixPath(localExepath,false);
  1198. end;
  1199. procedure DoneGlobals;
  1200. begin
  1201. librarysearchpath.Free;
  1202. unitsearchpath.Free;
  1203. objectsearchpath.Free;
  1204. includesearchpath.Free;
  1205. frameworksearchpath.Free;
  1206. LinkLibraryAliases.Free;
  1207. LinkLibraryOrder.Free;
  1208. end;
  1209. procedure InitGlobals;
  1210. begin
  1211. get_exepath;
  1212. { reset globals }
  1213. do_build:=false;
  1214. do_release:=false;
  1215. do_make:=true;
  1216. compile_level:=0;
  1217. DLLsource:=false;
  1218. paratarget:=system_none;
  1219. paratargetasm:=as_none;
  1220. paratargetdbg:=dbg_none;
  1221. { Output }
  1222. OutputFileName:='';
  1223. OutputPrefix:=Nil;
  1224. OutputSuffix:=Nil;
  1225. OutputExeDir:='';
  1226. OutputUnitDir:='';
  1227. { Utils directory }
  1228. utilsdirectory:='';
  1229. utilsprefix:='';
  1230. cshared:=false;
  1231. rlinkpath:='';
  1232. sysrootpath:='';
  1233. { Search Paths }
  1234. librarysearchpath:=TSearchPathList.Create;
  1235. unitsearchpath:=TSearchPathList.Create;
  1236. includesearchpath:=TSearchPathList.Create;
  1237. objectsearchpath:=TSearchPathList.Create;
  1238. frameworksearchpath:=TSearchPathList.Create;
  1239. { Def file }
  1240. usewindowapi:=false;
  1241. description:='Compiled by FPC '+version_string+' - '+target_cpu_string;
  1242. DescriptionSetExplicity:=false;
  1243. SetPEFlagsSetExplicity:=false;
  1244. ImageBaseSetExplicity:=false;
  1245. MinStackSizeSetExplicity:=false;
  1246. MaxStackSizeSetExplicity:=false;
  1247. dllversion:='';
  1248. dllmajor:=1;
  1249. dllminor:=0;
  1250. dllrevision:=0;
  1251. nwscreenname := '';
  1252. nwthreadname := '';
  1253. nwcopyright := '';
  1254. UseDeffileForExports:=false;
  1255. UseDeffileForExportsSetExplicitly:=false;
  1256. GenerateImportSection:=false;
  1257. RelocSection:=false;
  1258. RelocSectionSetExplicitly:=false;
  1259. LinkTypeSetExplicitly:=false;
  1260. { memory sizes, will be overriden by parameter or default for target
  1261. in options or init_parser }
  1262. stacksize:=0;
  1263. { not initialized yet }
  1264. jmp_buf_size:=-1;
  1265. apptype:=app_cui;
  1266. { Init values }
  1267. init_settings:=default_settings;
  1268. if init_settings.optimizecputype=cpu_none then
  1269. init_settings.optimizecputype:=init_settings.cputype;
  1270. LinkLibraryAliases :=TLinkStrMap.Create;
  1271. LinkLibraryOrder :=TLinkStrMap.Create;
  1272. { enable all features by default }
  1273. features:=[low(Tfeature)..high(Tfeature)];
  1274. end;
  1275. end.