globals.pas 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437
  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 : string;
  151. nextlocalswitches : tlocalswitches;
  152. nextverbosityfullswitch: longint;
  153. verbosityfullswitched,
  154. localswitcheschanged : boolean;
  155. end;
  156. var
  157. { specified inputfile }
  158. inputfilepath : string;
  159. inputfilename : string;
  160. { specified outputfile with -o parameter }
  161. outputfilename : string;
  162. outputprefix : pshortstring;
  163. outputsuffix : pshortstring;
  164. { specified with -FE or -FU }
  165. outputexedir : TPathStr;
  166. outputunitdir : TPathStr;
  167. { specified with -FW and -Fw }
  168. wpofeedbackinput,
  169. wpofeedbackoutput : TPathStr;
  170. { things specified with parameters }
  171. paratarget : tsystem;
  172. paratargetdbg : tdbg;
  173. paratargetasm : tasm;
  174. paralinkoptions : TCmdStr;
  175. paradynamiclinker : string;
  176. paraprintnodetree : byte;
  177. parapreprocess : boolean;
  178. printnodefile : text;
  179. { typical cross compiling params}
  180. { directory where the utils can be found (options -FD) }
  181. utilsdirectory : TPathStr;
  182. { targetname specific prefix used by these utils (options -XP<path>) }
  183. utilsprefix : TCmdStr;
  184. cshared : boolean; { pass --shared to ld to link C libs shared}
  185. Dontlinkstdlibpath: Boolean; { Don't add std paths to linkpath}
  186. rlinkpath : TCmdStr; { rpath-link linkdir override}
  187. sysrootpath : TCmdStr; { target system root to search dyn linker }
  188. { some flags for global compiler switches }
  189. do_build,
  190. do_release,
  191. do_make : boolean;
  192. { path for searching units, different paths can be seperated by ; }
  193. exepath : TPathStr; { Path to ppc }
  194. librarysearchpath,
  195. unitsearchpath,
  196. objectsearchpath,
  197. includesearchpath,
  198. frameworksearchpath : TSearchPathList;
  199. autoloadunits : string;
  200. { linking }
  201. usewindowapi : boolean;
  202. description : string;
  203. SetPEFlagsSetExplicity,
  204. ImageBaseSetExplicity,
  205. MinStackSizeSetExplicity,
  206. MaxStackSizeSetExplicity,
  207. DescriptionSetExplicity : boolean;
  208. dllversion : string;
  209. dllmajor,
  210. dllminor,
  211. dllrevision : word; { revision only for netware }
  212. { win pe }
  213. peflags : longint;
  214. minstacksize,
  215. maxstacksize,
  216. imagebase : aword;
  217. UseDeffileForExports : boolean;
  218. UseDeffileForExportsSetExplicitly : boolean;
  219. GenerateImportSection,
  220. GenerateImportSectionSetExplicitly,
  221. RelocSection : boolean;
  222. RelocSectionSetExplicitly : boolean;
  223. LinkTypeSetExplicitly : boolean;
  224. current_tokenpos, { position of the last token }
  225. current_filepos : tfileposinfo; { current position }
  226. nwscreenname : string;
  227. nwthreadname : string;
  228. nwcopyright : string;
  229. codegenerror : boolean; { true if there is an error reported }
  230. block_type : tblock_type; { type of currently parsed block }
  231. compile_level : word;
  232. exceptblockcounter : integer; { each except block gets a unique number check gotos }
  233. current_exceptblock : integer; { the exceptblock number of the current block (0 if none) }
  234. LinkLibraryAliases : TLinkStrMap;
  235. LinkLibraryOrder : TLinkStrMap;
  236. init_settings,
  237. current_settings : tsettings;
  238. pendingstate : tpendingstate;
  239. { Memory sizes }
  240. heapsize,
  241. stacksize,
  242. jmp_buf_size,
  243. jmp_buf_align : longint;
  244. {$Ifdef EXTDEBUG}
  245. { parameter switches }
  246. debugstop : boolean;
  247. {$EndIf EXTDEBUG}
  248. { windows / OS/2 application type }
  249. apptype : tapptype;
  250. features : tfeatures;
  251. const
  252. DLLsource : boolean = false;
  253. DLLImageBase : pshortstring = nil;
  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. );
  353. var
  354. starttime : real;
  355. function getdatestr:string;
  356. function gettimestr:string;
  357. function filetimestring( t : longint) : string;
  358. function getrealtime : real;
  359. procedure DefaultReplacements(var s:ansistring);
  360. function Shell(const command:ansistring): longint;
  361. function GetEnvPChar(const envname:string):pchar;
  362. procedure FreeEnvPChar(p:pchar);
  363. function is_number_float(d : double) : boolean;
  364. { discern +0.0 and -0.0 }
  365. function get_real_sign(r: bestreal): longint;
  366. procedure InitGlobals;
  367. procedure DoneGlobals;
  368. function string2guid(const s: string; var GUID: TGUID): boolean;
  369. function guid2string(const GUID: TGUID): string;
  370. function SetAktProcCall(const s:string; var a:tproccalloption):boolean;
  371. function Setabitype(const s:string;var a:tabi):boolean;
  372. function Setcputype(const s:string;var a:tcputype):boolean;
  373. function SetFpuType(const s:string;var a:tfputype):boolean;
  374. {$if defined(arm) or defined(avr)}
  375. function SetControllerType(const s:string;var a:tcontrollertype):boolean;
  376. {$endif defined(arm) or defined(avr)}
  377. function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
  378. function UpdateOptimizerStr(s:string;var a:toptimizerswitches):boolean;
  379. function UpdateWpoStr(s: string; var a: twpoptimizerswitches): boolean;
  380. function UpdateDebugStr(s:string;var a:tdebugswitches):boolean;
  381. function IncludeFeature(const s : string) : boolean;
  382. function SetMinFPConstPrec(const s: string; var a: tfloattype) : boolean;
  383. {# Routine to get the required alignment for size of data, which will
  384. be placed in bss segment, according to the current alignment requirements }
  385. function var_align(want_align: longint): shortint;
  386. function var_align_size(siz: longint): shortint;
  387. {# Routine to get the required alignment for size of data, which will
  388. be placed in data/const segment, according to the current alignment requirements }
  389. function const_align(want_align: longint): shortint;
  390. function const_align_size(siz: longint): shortint;
  391. {$ifdef ARM}
  392. function is_double_hilo_swapped: boolean;{$ifdef USEINLINE}inline;{$endif}
  393. {$endif ARM}
  394. function floating_point_range_check_error : boolean;
  395. implementation
  396. uses
  397. {$ifdef macos}
  398. macutils,
  399. {$endif}
  400. comphook;
  401. {****************************************************************************
  402. TLinkStrMap
  403. ****************************************************************************}
  404. Constructor TLinkStrMap.create;
  405. begin
  406. inherited;
  407. itemcnt:=0;
  408. end;
  409. procedure TLinkStrMap.Add(key:ansistring;value:AnsiString='';weight:longint=LinkMapWeightDefault);
  410. begin
  411. if lookup(key)<>-1 Then
  412. exit;
  413. if itemcnt<=length(fmap) Then
  414. setlength(fmap,itemcnt+10);
  415. fmap[itemcnt].key:=key;
  416. fmap[itemcnt].value:=value;
  417. fmap[itemcnt].weight:=weight;
  418. inc(itemcnt);
  419. end;
  420. function TLinkStrMap.AddDep(keyvalue:String):boolean;
  421. var
  422. i : Longint;
  423. begin
  424. AddDep:=false;
  425. i:=pos('=',keyvalue);
  426. if i=0 then
  427. exit;
  428. Add(Copy(KeyValue,1,i-1),Copy(KeyValue,i+1,length(KeyValue)-i));
  429. AddDep:=True;
  430. end;
  431. function TLinkStrMap.AddWeight(keyvalue:String):boolean;
  432. var
  433. i,j : Longint;
  434. Code : Word;
  435. s : AnsiString;
  436. begin
  437. AddWeight:=false;
  438. i:=pos('=',keyvalue);
  439. if i=0 then
  440. exit;
  441. s:=Copy(KeyValue,i+1,length(KeyValue)-i);
  442. val(s,j,code);
  443. if code=0 Then
  444. begin
  445. Add(Copy(KeyValue,1,i-1),'',j);
  446. AddWeight:=True;
  447. end;
  448. end;
  449. procedure TLinkStrMap.addseries(keys:AnsiString;weight:longint);
  450. var
  451. i,j,k : longint;
  452. begin
  453. k:=length(keys);
  454. i:=1;
  455. while i<=k do
  456. begin
  457. j:=i;
  458. while (i<=k) and (keys[i]<>',') do
  459. inc(i);
  460. add(copy(keys,j,i-j),'',weight);
  461. inc(i);
  462. end;
  463. end;
  464. procedure TLinkStrMap.SetValue(Key:Ansistring;weight:Integer);
  465. var
  466. j : longint;
  467. begin
  468. j:=lookup(key);
  469. if j<>-1 then
  470. fmap[j].weight:=weight;
  471. end;
  472. function TLinkStrMap.find(key:Ansistring):Ansistring;
  473. var
  474. j : longint;
  475. begin
  476. find:='';
  477. j:=lookup(key);
  478. if j<>-1 then
  479. find:=fmap[j].value;
  480. end;
  481. function TLinkStrMap.lookup(key:Ansistring):longint;
  482. var
  483. i : longint;
  484. begin
  485. lookup:=-1;
  486. i:=0;
  487. while (i<itemcnt) and (fmap[i].key<>key) do
  488. inc(i);
  489. if i<>itemcnt then
  490. lookup:=i;
  491. end;
  492. procedure TLinkStrMap.SortOnWeight;
  493. var
  494. i, j : longint;
  495. m : TLinkRec;
  496. begin
  497. if itemcnt <2 then exit;
  498. for i:=0 to itemcnt-1 do
  499. for j:=i+1 to itemcnt-1 do
  500. begin
  501. if fmap[i].weight>fmap[j].weight Then
  502. begin
  503. m:=fmap[i];
  504. fmap[i]:=fmap[j];
  505. fmap[j]:=m;
  506. end;
  507. end;
  508. end;
  509. function TLinkStrMap.getlinkrec(i:longint):TLinkRec;
  510. begin
  511. result:=fmap[i];
  512. end;
  513. procedure TLinkStrMap.Expand(Src:TCmdStrList;Dest:TLinkStrMap);
  514. // expands every thing in Src to Dest for linkorder purposes.
  515. var
  516. r : longint;
  517. LibN : TCmdStr;
  518. begin
  519. while not src.empty do
  520. begin
  521. LibN:=src.getfirst;
  522. r:=lookup (LibN);
  523. if r=-1 then
  524. dest.add(LibN)
  525. else
  526. dest.addseries(fmap[r].value);
  527. end;
  528. end;
  529. procedure TLinkStrMap.UpdateWeights(Weightmap:TLinkStrMap);
  530. var
  531. l,r : longint;
  532. begin
  533. for l := 0 to itemcnt-1 do
  534. begin
  535. r:=weightmap.lookup (fmap[l].key);
  536. if r<>-1 then
  537. fmap[l].weight:=weightmap[r].weight;
  538. end;
  539. end;
  540. {****************************************************************************
  541. Time Handling
  542. ****************************************************************************}
  543. Function L0(l:longint):string;
  544. {
  545. return the string of value l, if l<10 then insert a zero, so
  546. the string is always at least 2 chars '01','02',etc
  547. }
  548. var
  549. s : string;
  550. begin
  551. Str(l,s);
  552. if l<10 then
  553. s:='0'+s;
  554. L0:=s;
  555. end;
  556. function gettimestr:string;
  557. {
  558. get the current time in a string HH:MM:SS
  559. }
  560. var
  561. hour,min,sec,hsec : word;
  562. begin
  563. DecodeTime(Time,hour,min,sec,hsec);
  564. gettimestr:=L0(Hour)+':'+L0(min)+':'+L0(sec);
  565. end;
  566. function getdatestr:string;
  567. {
  568. get the current date in a string YY/MM/DD
  569. }
  570. var
  571. Year,Month,Day: Word;
  572. begin
  573. DecodeDate(Date,year,month,day);
  574. getdatestr:=L0(Year)+'/'+L0(Month)+'/'+L0(Day);
  575. end;
  576. function filetimestring( t : longint) : string;
  577. {
  578. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  579. }
  580. var
  581. DT : TDateTime;
  582. hsec : word;
  583. Year,Month,Day: Word;
  584. hour,min,sec : word;
  585. begin
  586. if t=-1 then
  587. begin
  588. Result := 'Not Found';
  589. exit;
  590. end;
  591. DT := FileDateToDateTime(t);
  592. DecodeTime(DT,hour,min,sec,hsec);
  593. DecodeDate(DT,year,month,day);
  594. Result := L0(Year)+'/'+L0(Month)+'/'+L0(Day)+' '+L0(Hour)+':'+L0(min)+':'+L0(sec);
  595. end;
  596. function getrealtime : real;
  597. var
  598. h,m,s,s1000 : word;
  599. begin
  600. DecodeTime(Time,h,m,s,s1000);
  601. result:=h*3600.0+m*60.0+s+s1000/1000.0;
  602. end;
  603. {****************************************************************************
  604. Default Macro Handling
  605. ****************************************************************************}
  606. procedure DefaultReplacements(var s:ansistring);
  607. begin
  608. { Replace some macros }
  609. Replace(s,'$FPCVERSION',version_string);
  610. Replace(s,'$FPCFULLVERSION',full_version_string);
  611. Replace(s,'$FPCDATE',date_string);
  612. Replace(s,'$FPCCPU',target_cpu_string);
  613. Replace(s,'$FPCOS',target_os_string);
  614. if tf_use_8_3 in Source_Info.Flags then
  615. Replace(s,'$FPCTARGET',target_os_string)
  616. else
  617. Replace(s,'$FPCTARGET',target_full_string);
  618. end;
  619. {****************************************************************************
  620. OS Dependent things
  621. ****************************************************************************}
  622. function GetEnvPChar(const envname:string):pchar;
  623. {$ifdef win32}
  624. var
  625. s : string;
  626. i,len : longint;
  627. hp,p,p2 : pchar;
  628. {$endif}
  629. begin
  630. {$ifdef hasunix}
  631. GetEnvPchar:=BaseUnix.fpGetEnv(envname);
  632. {$define GETENVOK}
  633. {$endif}
  634. {$ifdef win32}
  635. GetEnvPchar:=nil;
  636. p:=GetEnvironmentStrings;
  637. hp:=p;
  638. while hp^<>#0 do
  639. begin
  640. s:=strpas(hp);
  641. i:=pos('=',s);
  642. len:=strlen(hp);
  643. if upper(copy(s,1,i-1))=upper(envname) then
  644. begin
  645. GetMem(p2,len-length(envname));
  646. Move(hp[i],p2^,len-length(envname));
  647. GetEnvPchar:=p2;
  648. break;
  649. end;
  650. { next string entry}
  651. hp:=hp+len+1;
  652. end;
  653. FreeEnvironmentStrings(p);
  654. {$define GETENVOK}
  655. {$endif}
  656. {$ifdef os2}
  657. GetEnvPChar := Dos.GetEnvPChar (EnvName);
  658. {$define GETENVOK}
  659. {$endif}
  660. {$ifdef GETENVOK}
  661. {$undef GETENVOK}
  662. {$else}
  663. GetEnvPchar:=StrPNew(GetEnvironmentVariable(envname));
  664. {$endif}
  665. end;
  666. procedure FreeEnvPChar(p:pchar);
  667. begin
  668. {$ifndef hasunix}
  669. {$ifndef os2}
  670. freemem(p);
  671. {$endif}
  672. {$endif}
  673. end;
  674. {$if defined(MORPHOS) or defined(AMIGA)}
  675. {$define AMIGASHELL}
  676. {$endif}
  677. function Shell(const command:ansistring): longint;
  678. { This is already defined in the linux.ppu for linux, need for the *
  679. expansion under linux }
  680. {$ifdef hasunix}
  681. begin
  682. result := Unix.fpsystem(command);
  683. end;
  684. {$else hasunix}
  685. {$ifdef amigashell}
  686. begin
  687. result := ExecuteProcess('',command);
  688. end;
  689. {$else amigashell}
  690. var
  691. comspec : string;
  692. begin
  693. comspec:=GetEnvironmentVariable('COMSPEC');
  694. result := ExecuteProcess(comspec,' /C '+command);
  695. end;
  696. {$endif amigashell}
  697. {$endif hasunix}
  698. {$UNDEF AMIGASHELL}
  699. function is_number_float(d : double) : boolean;
  700. var
  701. bytearray : array[0..7] of byte;
  702. begin
  703. move(d,bytearray,8);
  704. { only 1.1 save, 1.0.x will use always little endian }
  705. {$ifdef FPC_BIG_ENDIAN}
  706. result:=((bytearray[0] and $7f)<>$7f) or ((bytearray[1] and $f0)<>$f0);
  707. {$else FPC_BIG_ENDIAN}
  708. result:=((bytearray[7] and $7f)<>$7f) or ((bytearray[6] and $f0)<>$f0);
  709. {$endif FPC_BIG_ENDIAN}
  710. end;
  711. function get_real_sign(r: bestreal): longint;
  712. var
  713. p: pbyte;
  714. begin
  715. p := pbyte(@r);
  716. {$ifdef CPU_ARM}
  717. inc(p,4);
  718. {$else}
  719. {$ifdef FPC_LITTLE_ENDIAN}
  720. inc(p,sizeof(r)-1);
  721. {$endif}
  722. {$endif}
  723. if (p^ and $80) = 0 then
  724. result := 1
  725. else
  726. result := -1;
  727. end;
  728. function convertdoublerec(d : tdoublerec) : tdoublerec;{$ifdef USEINLINE}inline;{$endif}
  729. {$ifdef CPUARM}
  730. var
  731. i : longint;
  732. begin
  733. for i:=0 to 3 do
  734. begin
  735. result.bytes[i+4]:=d.bytes[i];
  736. result.bytes[i]:=d.bytes[i+4];
  737. end;
  738. {$else CPUARM}
  739. begin
  740. result:=d;
  741. {$endif CPUARM}
  742. end;
  743. { '('D1:'00000000-'D2:'0000-'D3:'0000-'D4:'0000-000000000000)' }
  744. function string2guid(const s: string; var GUID: TGUID): boolean;
  745. function ishexstr(const hs: string): boolean;
  746. var
  747. i: integer;
  748. begin
  749. ishexstr:=false;
  750. for i:=1 to Length(hs) do begin
  751. if not (hs[i] in ['0'..'9','A'..'F','a'..'f']) then
  752. exit;
  753. end;
  754. ishexstr:=true;
  755. end;
  756. function hexstr2longint(const hexs: string): longint;
  757. var
  758. i: integer;
  759. rl: longint;
  760. begin
  761. rl:=0;
  762. for i:=1 to length(hexs) do begin
  763. rl:=rl shl 4;
  764. case hexs[i] of
  765. '0'..'9' : inc(rl,ord(hexs[i])-ord('0'));
  766. 'A'..'F' : inc(rl,ord(hexs[i])-ord('A')+10);
  767. 'a'..'f' : inc(rl,ord(hexs[i])-ord('a')+10);
  768. end
  769. end;
  770. hexstr2longint:=rl;
  771. end;
  772. var
  773. i: integer;
  774. begin
  775. if (Length(s)=38) and (s[1]='{') and (s[38]='}') and
  776. (s[10]='-') and (s[15]='-') and (s[20]='-') and (s[25]='-') and
  777. ishexstr(copy(s,2,8)) and ishexstr(copy(s,11,4)) and
  778. ishexstr(copy(s,16,4)) and ishexstr(copy(s,21,4)) and
  779. ishexstr(copy(s,26,12)) then begin
  780. GUID.D1:=dword(hexstr2longint(copy(s,2,8)));
  781. { these values are arealdy in the correct range (4 chars = word) }
  782. GUID.D2:=word(hexstr2longint(copy(s,11,4)));
  783. GUID.D3:=word(hexstr2longint(copy(s,16,4)));
  784. for i:=0 to 1 do
  785. GUID.D4[i]:=byte(hexstr2longint(copy(s,21+i*2,2)));
  786. for i:=2 to 7 do
  787. GUID.D4[i]:=byte(hexstr2longint(copy(s,22+i*2,2)));
  788. string2guid:=true;
  789. end
  790. else if (length(s)=0) then
  791. begin
  792. FillChar(GUID,SizeOf(GUID),0);
  793. string2guid:=true;
  794. end
  795. else
  796. string2guid:=false;
  797. end;
  798. function guid2string(const GUID: TGUID): string;
  799. begin
  800. guid2string:=
  801. '{'+hexstr(GUID.D1,8)+
  802. '-'+hexstr(GUID.D2,4)+
  803. '-'+hexstr(GUID.D3,4)+
  804. '-'+hexstr(GUID.D4[0],2)+hexstr(GUID.D4[1],2)+
  805. '-'+hexstr(GUID.D4[2],2)+hexstr(GUID.D4[3],2)+
  806. hexstr(GUID.D4[4],2)+hexstr(GUID.D4[5],2)+
  807. hexstr(GUID.D4[6],2)+hexstr(GUID.D4[7],2)+
  808. '}';
  809. end;
  810. function SetAktProcCall(const s:string; var a:tproccalloption):boolean;
  811. const
  812. DefProcCallName : array[tproccalloption] of string[12] = ('',
  813. 'CDECL',
  814. 'CPPDECL',
  815. 'FAR16',
  816. 'OLDFPCCALL',
  817. '', { internproc }
  818. '', { syscall }
  819. 'PASCAL',
  820. 'REGISTER',
  821. 'SAFECALL',
  822. 'STDCALL',
  823. 'SOFTFLOAT',
  824. 'MWPASCAL'
  825. );
  826. var
  827. t : tproccalloption;
  828. hs : string;
  829. begin
  830. result:=false;
  831. if (s = '') then
  832. exit;
  833. hs:=upper(s);
  834. if (hs = 'DEFAULT') then
  835. begin
  836. a := pocall_default;
  837. result := true;
  838. exit;
  839. end;
  840. for t:=low(tproccalloption) to high(tproccalloption) do
  841. if DefProcCallName[t]=hs then
  842. begin
  843. a:=t;
  844. result:=true;
  845. break;
  846. end;
  847. end;
  848. function Setabitype(const s:string;var a:tabi):boolean;
  849. var
  850. t : tabi;
  851. hs : string;
  852. begin
  853. result:=false;
  854. hs:=Upper(s);
  855. for t:=low(t) to high(t) do
  856. if abi2str[t]=hs then
  857. begin
  858. a:=t;
  859. result:=true;
  860. break;
  861. end;
  862. end;
  863. function Setcputype(const s:string;var a:tcputype):boolean;
  864. var
  865. t : tcputype;
  866. hs : string;
  867. begin
  868. result:=false;
  869. hs:=Upper(s);
  870. for t:=low(tcputype) to high(tcputype) do
  871. if cputypestr[t]=hs then
  872. begin
  873. a:=t;
  874. result:=true;
  875. break;
  876. end;
  877. end;
  878. function SetFpuType(const s:string;var a:tfputype):boolean;
  879. var
  880. t : tfputype;
  881. begin
  882. result:=false;
  883. for t:=low(tfputype) to high(tfputype) do
  884. if fputypestr[t]=s then
  885. begin
  886. a:=t;
  887. result:=true;
  888. break;
  889. end;
  890. end;
  891. {$if defined(arm) or defined(avr)}
  892. function SetControllerType(const s:string;var a:tcontrollertype):boolean;
  893. var
  894. t : tcontrollertype;
  895. hs : string;
  896. begin
  897. result:=false;
  898. hs:=Upper(s);
  899. for t:=low(tcontrollertype) to high(tcontrollertype) do
  900. if controllertypestr[t]=hs then
  901. begin
  902. a:=t;
  903. result:=true;
  904. break;
  905. end;
  906. end;
  907. {$endif defined(arm) or defined(avr)}
  908. function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
  909. var
  910. tok : string;
  911. vstr : string;
  912. l : longint;
  913. code : integer;
  914. b : talignmentinfo;
  915. begin
  916. UpdateAlignmentStr:=true;
  917. uppervar(s);
  918. fillchar(b,sizeof(b),0);
  919. repeat
  920. tok:=GetToken(s,'=');
  921. if tok='' then
  922. break;
  923. vstr:=GetToken(s,',');
  924. val(vstr,l,code);
  925. if tok='PROC' then
  926. b.procalign:=l
  927. else if tok='JUMP' then
  928. b.jumpalign:=l
  929. else if tok='LOOP' then
  930. b.loopalign:=l
  931. else if tok='CONSTMIN' then
  932. b.constalignmin:=l
  933. else if tok='CONSTMAX' then
  934. b.constalignmax:=l
  935. else if tok='VARMIN' then
  936. b.varalignmin:=l
  937. else if tok='VARMAX' then
  938. b.varalignmax:=l
  939. else if tok='LOCALMIN' then
  940. b.localalignmin:=l
  941. else if tok='LOCALMAX' then
  942. b.localalignmax:=l
  943. else if tok='RECORDMIN' then
  944. b.recordalignmin:=l
  945. else if tok='RECORDMAX' then
  946. b.recordalignmax:=l
  947. else { Error }
  948. UpdateAlignmentStr:=false;
  949. until false;
  950. UpdateAlignment(a,b);
  951. end;
  952. function UpdateOptimizerStr(s:string;var a:toptimizerswitches):boolean;
  953. var
  954. tok : string;
  955. doset,
  956. found : boolean;
  957. opt : toptimizerswitch;
  958. begin
  959. result:=true;
  960. uppervar(s);
  961. repeat
  962. tok:=GetToken(s,',');
  963. if tok='' then
  964. break;
  965. if Copy(tok,1,2)='NO' then
  966. begin
  967. delete(tok,1,2);
  968. doset:=false;
  969. end
  970. else
  971. doset:=true;
  972. found:=false;
  973. for opt:=low(toptimizerswitch) to high(toptimizerswitch) do
  974. begin
  975. if OptimizerSwitchStr[opt]=tok then
  976. begin
  977. found:=true;
  978. break;
  979. end;
  980. end;
  981. if found then
  982. begin
  983. if doset then
  984. include(a,opt)
  985. else
  986. exclude(a,opt);
  987. end
  988. else
  989. result:=false;
  990. until false;
  991. end;
  992. function UpdateWpoStr(s: string; var a: twpoptimizerswitches): boolean;
  993. var
  994. tok : string;
  995. doset,
  996. found : boolean;
  997. opt : twpoptimizerswitch;
  998. begin
  999. result:=true;
  1000. uppervar(s);
  1001. repeat
  1002. tok:=GetToken(s,',');
  1003. if tok='' then
  1004. break;
  1005. if Copy(tok,1,2)='NO' then
  1006. begin
  1007. delete(tok,1,2);
  1008. doset:=false;
  1009. end
  1010. else
  1011. doset:=true;
  1012. found:=false;
  1013. if (tok = 'ALL') then
  1014. begin
  1015. for opt:=low(twpoptimizerswitch) to high(twpoptimizerswitch) do
  1016. if doset then
  1017. include(a,opt)
  1018. else
  1019. exclude(a,opt);
  1020. end
  1021. else
  1022. begin
  1023. for opt:=low(twpoptimizerswitch) to high(twpoptimizerswitch) do
  1024. begin
  1025. if WPOptimizerSwitchStr[opt]=tok then
  1026. begin
  1027. found:=true;
  1028. break;
  1029. end;
  1030. end;
  1031. if found then
  1032. begin
  1033. if doset then
  1034. include(a,opt)
  1035. else
  1036. exclude(a,opt);
  1037. end
  1038. else
  1039. result:=false;
  1040. end;
  1041. until false;
  1042. end;
  1043. function UpdateDebugStr(s:string;var a:tdebugswitches):boolean;
  1044. var
  1045. tok : string;
  1046. doset,
  1047. found : boolean;
  1048. opt : tdebugswitch;
  1049. begin
  1050. result:=true;
  1051. uppervar(s);
  1052. repeat
  1053. tok:=GetToken(s,',');
  1054. if tok='' then
  1055. break;
  1056. if Copy(tok,1,2)='NO' then
  1057. begin
  1058. delete(tok,1,2);
  1059. doset:=false;
  1060. end
  1061. else
  1062. doset:=true;
  1063. found:=false;
  1064. for opt:=low(tdebugswitch) to high(tdebugswitch) do
  1065. begin
  1066. if DebugSwitchStr[opt]=tok then
  1067. begin
  1068. found:=true;
  1069. break;
  1070. end;
  1071. end;
  1072. if found then
  1073. begin
  1074. if doset then
  1075. include(a,opt)
  1076. else
  1077. exclude(a,opt);
  1078. end
  1079. else
  1080. result:=false;
  1081. until false;
  1082. end;
  1083. function IncludeFeature(const s : string) : boolean;
  1084. var
  1085. i : tfeature;
  1086. begin
  1087. result:=true;
  1088. for i:=low(tfeature) to high(tfeature) do
  1089. if s=featurestr[i] then
  1090. begin
  1091. include(features,i);
  1092. exit;
  1093. end;
  1094. result:=false;
  1095. end;
  1096. function SetMinFPConstPrec(const s: string; var a: tfloattype) : boolean;
  1097. var
  1098. value, error: longint;
  1099. begin
  1100. if (upper(s)='DEFAULT') then
  1101. begin
  1102. a:=s32real;
  1103. result:=true;
  1104. exit;
  1105. end;
  1106. result:=false;
  1107. val(s,value,error);
  1108. if (error<>0) then
  1109. exit;
  1110. case value of
  1111. 32: a:=s32real;
  1112. 64: a:=s64real;
  1113. { adding support for 80 bit here is tricky, since we can't really }
  1114. { check whether the target cpu+OS actually supports it }
  1115. else
  1116. exit;
  1117. end;
  1118. result:=true;
  1119. end;
  1120. function var_align(want_align: longint): shortint;
  1121. begin
  1122. var_align := used_align(want_align,current_settings.alignment.varalignmin,current_settings.alignment.varalignmax);
  1123. end;
  1124. function var_align_size(siz: longint): shortint;
  1125. begin
  1126. siz := size_2_align(siz);
  1127. var_align_size := var_align(siz);
  1128. end;
  1129. function const_align(want_align: longint): shortint;
  1130. begin
  1131. const_align := used_align(want_align,current_settings.alignment.constalignmin,current_settings.alignment.constalignmax);
  1132. end;
  1133. function const_align_size(siz: longint): shortint;
  1134. begin
  1135. siz := size_2_align(siz);
  1136. const_align_size := const_align(siz);
  1137. end;
  1138. {$ifdef ARM}
  1139. function is_double_hilo_swapped: boolean;{$ifdef USEINLINE}inline;{$endif}
  1140. begin
  1141. result := (current_settings.fputype in [fpu_fpa,fpu_fpa10,fpu_fpa11]) and
  1142. not(cs_fp_emulation in current_settings.moduleswitches);
  1143. {$ifdef FPC_DOUBLE_HILO_SWAPPED}
  1144. { inverse result if compiler was compiled with swapped hilo already }
  1145. result := not result;
  1146. {$endif FPC_DOUBLE_HILO_SWAPPED}
  1147. end;
  1148. {$endif ARM}
  1149. function floating_point_range_check_error : boolean;
  1150. begin
  1151. result:=((([cs_check_range,cs_check_overflow]*current_settings.localswitches)<>[]) and not
  1152. (m_delphi in current_settings.modeswitches)
  1153. ); // or (cs_ieee_errors in current_settings.localswitches);
  1154. end;
  1155. {****************************************************************************
  1156. Init
  1157. ****************************************************************************}
  1158. {$ifdef unix}
  1159. {$define need_path_search}
  1160. {$endif unix}
  1161. {$ifdef os2}
  1162. {$define need_path_search}
  1163. {$endif os2}
  1164. {$ifdef macos}
  1165. {$define need_path_search}
  1166. {$endif macos}
  1167. procedure get_exepath;
  1168. var
  1169. localExepath : TCmdStr;
  1170. exeName:TCmdStr;
  1171. {$ifdef need_path_search}
  1172. hs1 : TPathStr;
  1173. {$endif need_path_search}
  1174. begin
  1175. localexepath:=GetEnvironmentVariable('PPC_EXEC_PATH');
  1176. if localexepath='' then
  1177. begin
  1178. exeName := FixFileName(system.paramstr(0));
  1179. localexepath := ExtractFilePath(exeName);
  1180. end;
  1181. {$ifdef need_path_search}
  1182. if localexepath='' then
  1183. begin
  1184. hs1 := ExtractFileName(exeName);
  1185. ChangeFileExt(hs1,source_info.exeext);
  1186. {$ifdef macos}
  1187. FindFile(hs1,GetEnvironmentVariable('Commands'),false,localExepath);
  1188. {$else macos}
  1189. FindFile(hs1,GetEnvironmentVariable('PATH'),false,localExepath);
  1190. {$endif macos}
  1191. localExepath:=ExtractFilePath(localExepath);
  1192. end;
  1193. {$endif need_path_search}
  1194. exepath:=FixPath(localExepath,false);
  1195. end;
  1196. procedure DoneGlobals;
  1197. begin
  1198. if assigned(DLLImageBase) then
  1199. StringDispose(DLLImageBase);
  1200. librarysearchpath.Free;
  1201. unitsearchpath.Free;
  1202. objectsearchpath.Free;
  1203. includesearchpath.Free;
  1204. frameworksearchpath.Free;
  1205. LinkLibraryAliases.Free;
  1206. LinkLibraryOrder.Free;
  1207. end;
  1208. procedure InitGlobals;
  1209. begin
  1210. get_exepath;
  1211. { reset globals }
  1212. do_build:=false;
  1213. do_release:=false;
  1214. do_make:=true;
  1215. compile_level:=0;
  1216. DLLsource:=false;
  1217. paratarget:=system_none;
  1218. paratargetasm:=as_none;
  1219. paratargetdbg:=dbg_none;
  1220. { Output }
  1221. OutputFileName:='';
  1222. OutputPrefix:=Nil;
  1223. OutputSuffix:=Nil;
  1224. OutputExeDir:='';
  1225. OutputUnitDir:='';
  1226. { Utils directory }
  1227. utilsdirectory:='';
  1228. utilsprefix:='';
  1229. cshared:=false;
  1230. rlinkpath:='';
  1231. sysrootpath:='';
  1232. { Search Paths }
  1233. librarysearchpath:=TSearchPathList.Create;
  1234. unitsearchpath:=TSearchPathList.Create;
  1235. includesearchpath:=TSearchPathList.Create;
  1236. objectsearchpath:=TSearchPathList.Create;
  1237. frameworksearchpath:=TSearchPathList.Create;
  1238. { Def file }
  1239. usewindowapi:=false;
  1240. description:='Compiled by FPC '+version_string+' - '+target_cpu_string;
  1241. DescriptionSetExplicity:=false;
  1242. SetPEFlagsSetExplicity:=false;
  1243. ImageBaseSetExplicity:=false;
  1244. MinStackSizeSetExplicity:=false;
  1245. MaxStackSizeSetExplicity:=false;
  1246. dllversion:='';
  1247. dllmajor:=1;
  1248. dllminor:=0;
  1249. dllrevision:=0;
  1250. nwscreenname := '';
  1251. nwthreadname := '';
  1252. nwcopyright := '';
  1253. UseDeffileForExports:=false;
  1254. UseDeffileForExportsSetExplicitly:=false;
  1255. GenerateImportSection:=false;
  1256. RelocSection:=false;
  1257. RelocSectionSetExplicitly:=false;
  1258. LinkTypeSetExplicitly:=false;
  1259. { memory sizes, will be overriden by parameter or default for target
  1260. in options or init_parser }
  1261. stacksize:=0;
  1262. { not initialized yet }
  1263. jmp_buf_size:=-1;
  1264. apptype:=app_cui;
  1265. { Init values }
  1266. init_settings:=default_settings;
  1267. if init_settings.optimizecputype=cpu_none then
  1268. init_settings.optimizecputype:=init_settings.cputype;
  1269. LinkLibraryAliases :=TLinkStrMap.Create;
  1270. LinkLibraryOrder :=TLinkStrMap.Create;
  1271. { enable all features by default }
  1272. features:=[low(Tfeature)..high(Tfeature)];
  1273. end;
  1274. end.