globals.pas 40 KB

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