globals.pas 41 KB

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