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. resolving_forward : boolean; { used to add forward reference as second ref }
  221. inlining_procedure : boolean; { are we inlining a procedure }
  222. exceptblockcounter : integer; { each except block gets a unique number check gotos }
  223. aktexceptblock : integer; { the exceptblock number of the current block (0 if none) }
  224. LinkLibraryAliases : TLinkStrMap;
  225. LinkLibraryOrder : TLinkStrMap;
  226. init_settings,
  227. current_settings : tsettings;
  228. nextlocalswitches : tlocalswitches;
  229. localswitcheschanged : boolean;
  230. { Memory sizes }
  231. heapsize,
  232. stacksize,
  233. jmp_buf_size : longint;
  234. {$Ifdef EXTDEBUG}
  235. { parameter switches }
  236. debugstop : boolean;
  237. {$EndIf EXTDEBUG}
  238. { windows / OS/2 application type }
  239. apptype : tapptype;
  240. const
  241. DLLsource : boolean = false;
  242. DLLImageBase : pshortstring = nil;
  243. { used to set all registers used for each global function
  244. this should dramatically decrease the number of
  245. recompilations needed PM }
  246. simplify_ppu : boolean = true;
  247. { should we allow non static members ? }
  248. allow_only_static : boolean = false;
  249. Inside_asm_statement : boolean = false;
  250. global_unit_count : word = 0;
  251. { for error info in pp.pas }
  252. parser_current_file : string = '';
  253. {$if defined(m68k) or defined(arm)}
  254. { PalmOS resources }
  255. palmos_applicationname : string = 'FPC Application';
  256. palmos_applicationid : string[4] = 'FPCA';
  257. {$endif defined(m68k) or defined(arm)}
  258. {$ifdef powerpc}
  259. { default calling convention used on MorphOS }
  260. syscall_convention : string = 'LEGACY';
  261. {$endif powerpc}
  262. { default name of the C-style "main" procedure of the library/program }
  263. { (this will be prefixed with the target_info.cprefix) }
  264. mainaliasname : string = 'main';
  265. { by default no local variable trashing }
  266. localvartrashing: longint = -1;
  267. { actual values are defined in ncgutil.pas }
  268. nroftrashvalues = 4;
  269. function getdatestr:string;
  270. function gettimestr:string;
  271. function filetimestring( t : longint) : string;
  272. procedure DefaultReplacements(var s:string);
  273. function Shell(const command:ansistring): longint;
  274. function GetEnvPChar(const envname:string):pchar;
  275. procedure FreeEnvPChar(p:pchar);
  276. procedure SetFPUExceptionMask(const Mask: TFPUExceptionMask);
  277. function is_number_float(d : double) : boolean;
  278. { discern +0.0 and -0.0 }
  279. function get_real_sign(r: bestreal): longint;
  280. procedure InitGlobals;
  281. procedure DoneGlobals;
  282. function string2guid(const s: string; var GUID: TGUID): boolean;
  283. function guid2string(const GUID: TGUID): string;
  284. function SetAktProcCall(const s:string; var a:tproccalloption):boolean;
  285. function Setcputype(const s:string;var a:tcputype):boolean;
  286. function SetFpuType(const s:string;var a:tfputype):boolean;
  287. function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
  288. function UpdateOptimizerStr(s:string;var a:toptimizerswitches):boolean;
  289. {# Routine to get the required alignment for size of data, which will
  290. be placed in bss segment, according to the current alignment requirements }
  291. function var_align(siz: shortint): shortint;
  292. {# Routine to get the required alignment for size of data, which will
  293. be placed in data/const segment, according to the current alignment requirements }
  294. function const_align(siz: shortint): shortint;
  295. implementation
  296. uses
  297. {$ifdef macos}
  298. macutils,
  299. {$endif}
  300. comphook;
  301. {****************************************************************************
  302. TLinkStrMap
  303. ****************************************************************************}
  304. Constructor TLinkStrMap.create;
  305. begin
  306. inherited;
  307. itemcnt:=0;
  308. end;
  309. procedure TLinkStrMap.Add(key:ansistring;value:AnsiString='';weight:longint=LinkMapWeightDefault);
  310. begin
  311. if lookup(key)<>-1 Then
  312. exit;
  313. if itemcnt<=length(fmap) Then
  314. setlength(fmap,itemcnt+10);
  315. fmap[itemcnt].key:=key;
  316. fmap[itemcnt].value:=value;
  317. fmap[itemcnt].weight:=weight;
  318. inc(itemcnt);
  319. end;
  320. function TLinkStrMap.AddDep(keyvalue:String):boolean;
  321. var
  322. i : Longint;
  323. begin
  324. AddDep:=false;
  325. i:=pos('=',keyvalue);
  326. if i=0 then
  327. exit;
  328. Add(Copy(KeyValue,1,i-1),Copy(KeyValue,i+1,length(KeyValue)-i));
  329. AddDep:=True;
  330. end;
  331. function TLinkStrMap.AddWeight(keyvalue:String):boolean;
  332. var
  333. i,j : Longint;
  334. Code : Word;
  335. s : AnsiString;
  336. begin
  337. AddWeight:=false;
  338. i:=pos('=',keyvalue);
  339. if i=0 then
  340. exit;
  341. s:=Copy(KeyValue,i+1,length(KeyValue)-i);
  342. val(s,j,code);
  343. if code=0 Then
  344. begin
  345. Add(Copy(KeyValue,1,i-1),'',j);
  346. AddWeight:=True;
  347. end;
  348. end;
  349. procedure TLinkStrMap.addseries(keys:AnsiString;weight:longint);
  350. var
  351. i,j,k : longint;
  352. begin
  353. k:=length(keys);
  354. i:=1;
  355. while i<=k do
  356. begin
  357. j:=i;
  358. while (i<=k) and (keys[i]<>',') do
  359. inc(i);
  360. add(copy(keys,j,i-j),'',weight);
  361. inc(i);
  362. end;
  363. end;
  364. procedure TLinkStrMap.SetValue(Key:Ansistring;weight:Integer);
  365. var
  366. j : longint;
  367. begin
  368. j:=lookup(key);
  369. if j<>-1 then
  370. fmap[j].weight:=weight;
  371. end;
  372. function TLinkStrMap.find(key:Ansistring):Ansistring;
  373. var
  374. j : longint;
  375. begin
  376. find:='';
  377. j:=lookup(key);
  378. if j<>-1 then
  379. find:=fmap[j].value;
  380. end;
  381. function TLinkStrMap.lookup(key:Ansistring):longint;
  382. var
  383. i : longint;
  384. begin
  385. lookup:=-1;
  386. i:=0;
  387. while (i<itemcnt) and (fmap[i].key<>key) do
  388. inc(i);
  389. if i<>itemcnt then
  390. lookup:=i;
  391. end;
  392. procedure TLinkStrMap.SortOnWeight;
  393. var
  394. i, j : longint;
  395. m : TLinkRec;
  396. begin
  397. if itemcnt <2 then exit;
  398. for i:=0 to itemcnt-1 do
  399. for j:=i+1 to itemcnt-1 do
  400. begin
  401. if fmap[i].weight>fmap[j].weight Then
  402. begin
  403. m:=fmap[i];
  404. fmap[i]:=fmap[j];
  405. fmap[j]:=m;
  406. end;
  407. end;
  408. end;
  409. function TLinkStrMap.getlinkrec(i:longint):TLinkRec;
  410. begin
  411. result:=fmap[i];
  412. end;
  413. procedure TLinkStrMap.Expand(Src:TStringList;Dest:TLinkStrMap);
  414. // expands every thing in Src to Dest for linkorder purposes.
  415. var
  416. l,r : longint;
  417. LibN : String;
  418. begin
  419. while not src.empty do
  420. begin
  421. LibN:=src.getfirst;
  422. r:=lookup (LibN);
  423. if r=-1 then
  424. dest.add(LibN)
  425. else
  426. dest.addseries(fmap[r].value);
  427. end;
  428. end;
  429. procedure TLinkStrMap.UpdateWeights(Weightmap:TLinkStrMap);
  430. var
  431. l,r : longint;
  432. begin
  433. for l := 0 to itemcnt-1 do
  434. begin
  435. r:=weightmap.lookup (fmap[l].key);
  436. if r<>-1 then
  437. fmap[l].weight:=weightmap[r].weight;
  438. end;
  439. end;
  440. {****************************************************************************
  441. Time Handling
  442. ****************************************************************************}
  443. Function L0(l:longint):string;
  444. {
  445. return the string of value l, if l<10 then insert a zero, so
  446. the string is always at least 2 chars '01','02',etc
  447. }
  448. var
  449. s : string;
  450. begin
  451. Str(l,s);
  452. if l<10 then
  453. s:='0'+s;
  454. L0:=s;
  455. end;
  456. function gettimestr:string;
  457. {
  458. get the current time in a string HH:MM:SS
  459. }
  460. var
  461. hour,min,sec,hsec : word;
  462. begin
  463. DecodeTime(Time,hour,min,sec,hsec);
  464. gettimestr:=L0(Hour)+':'+L0(min)+':'+L0(sec);
  465. end;
  466. function getdatestr:string;
  467. {
  468. get the current date in a string YY/MM/DD
  469. }
  470. var
  471. Year,Month,Day: Word;
  472. begin
  473. DecodeDate(Date,year,month,day);
  474. getdatestr:=L0(Year)+'/'+L0(Month)+'/'+L0(Day);
  475. end;
  476. function filetimestring( t : longint) : string;
  477. {
  478. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  479. }
  480. var
  481. DT : TDateTime;
  482. hsec : word;
  483. Year,Month,Day: Word;
  484. hour,min,sec : word;
  485. begin
  486. if t=-1 then
  487. begin
  488. Result := 'Not Found';
  489. exit;
  490. end;
  491. DT := FileDateToDateTime(t);
  492. DecodeTime(DT,hour,min,sec,hsec);
  493. DecodeDate(DT,year,month,day);
  494. Result := L0(Year)+'/'+L0(Month)+'/'+L0(Day)+' '+L0(Hour)+':'+L0(min)+':'+L0(sec);
  495. end;
  496. {****************************************************************************
  497. Default Macro Handling
  498. ****************************************************************************}
  499. procedure DefaultReplacements(var s:string);
  500. begin
  501. { Replace some macros }
  502. Replace(s,'$FPCVERSION',version_string);
  503. Replace(s,'$FPCFULLVERSION',full_version_string);
  504. Replace(s,'$FPCDATE',date_string);
  505. Replace(s,'$FPCCPU',target_cpu_string);
  506. Replace(s,'$FPCOS',target_os_string);
  507. if tf_use_8_3 in Source_Info.Flags then
  508. Replace(s,'$FPCTARGET',target_os_string)
  509. else
  510. Replace(s,'$FPCTARGET',target_full_string);
  511. end;
  512. {****************************************************************************
  513. OS Dependent things
  514. ****************************************************************************}
  515. function GetEnvPChar(const envname:string):pchar;
  516. {$ifdef win32}
  517. var
  518. s : string;
  519. i,len : longint;
  520. hp,p,p2 : pchar;
  521. {$endif}
  522. begin
  523. {$ifdef hasunix}
  524. GetEnvPchar:=BaseUnix.fpGetEnv(envname);
  525. {$define GETENVOK}
  526. {$endif}
  527. {$ifdef win32}
  528. GetEnvPchar:=nil;
  529. p:=GetEnvironmentStrings;
  530. hp:=p;
  531. while hp^<>#0 do
  532. begin
  533. s:=strpas(hp);
  534. i:=pos('=',s);
  535. len:=strlen(hp);
  536. if upper(copy(s,1,i-1))=upper(envname) then
  537. begin
  538. GetMem(p2,len-length(envname));
  539. Move(hp[i],p2^,len-length(envname));
  540. GetEnvPchar:=p2;
  541. break;
  542. end;
  543. { next string entry}
  544. hp:=hp+len+1;
  545. end;
  546. FreeEnvironmentStrings(p);
  547. {$define GETENVOK}
  548. {$endif}
  549. {$ifdef os2}
  550. GetEnvPChar := Dos.GetEnvPChar (EnvName);
  551. {$define GETENVOK}
  552. {$endif}
  553. {$ifdef GETENVOK}
  554. {$undef GETENVOK}
  555. {$else}
  556. GetEnvPchar:=StrPNew(GetEnvironmentVariable(envname));
  557. {$endif}
  558. end;
  559. procedure FreeEnvPChar(p:pchar);
  560. begin
  561. {$ifndef hasunix}
  562. {$ifndef os2}
  563. freemem(p);
  564. {$endif}
  565. {$endif}
  566. end;
  567. {$if defined(MORPHOS) or defined(AMIGA)}
  568. {$define AMIGASHELL}
  569. {$endif}
  570. function Shell(const command:ansistring): longint;
  571. { This is already defined in the linux.ppu for linux, need for the *
  572. expansion under linux }
  573. {$ifdef hasunix}
  574. begin
  575. result := Unix.Shell(command);
  576. end;
  577. {$else hasunix}
  578. {$ifdef amigashell}
  579. begin
  580. result := ExecuteProcess('',command);
  581. end;
  582. {$else amigashell}
  583. var
  584. comspec : string;
  585. begin
  586. comspec:=GetEnvironmentVariable('COMSPEC');
  587. result := ExecuteProcess(comspec,' /C '+command);
  588. end;
  589. {$endif amigashell}
  590. {$endif hasunix}
  591. {$UNDEF AMIGASHELL}
  592. {$ifdef CPUI386}
  593. {$asmmode att}
  594. {$define HASSETFPUEXCEPTIONMASK}
  595. { later, this should be replaced by the math unit }
  596. const
  597. Default8087CW : word = $1332;
  598. procedure Set8087CW(cw:word);assembler;
  599. asm
  600. movw cw,%ax
  601. movw %ax,default8087cw
  602. fnclex
  603. fldcw default8087cw
  604. end;
  605. function Get8087CW:word;assembler;
  606. asm
  607. pushl $0
  608. fnstcw (%esp)
  609. popl %eax
  610. end;
  611. procedure SetFPUExceptionMask(const Mask: TFPUExceptionMask);
  612. var
  613. CtlWord: Word;
  614. begin
  615. CtlWord:=Get8087CW;
  616. Set8087CW( (CtlWord and $FFC0) or Byte(Longint(Mask)) );
  617. end;
  618. {$endif CPUI386}
  619. {$ifdef CPUX86_64}
  620. {$define HASSETFPUEXCEPTIONMASK}
  621. { later, this should be replaced by the math unit }
  622. const
  623. Default8087CW : word = $1332;
  624. procedure Set8087CW(cw:word);assembler;
  625. asm
  626. movw cw,%ax
  627. movw %ax,default8087cw
  628. fnclex
  629. fldcw default8087cw
  630. end;
  631. function Get8087CW:word;assembler;
  632. asm
  633. pushq $0
  634. fnstcw (%rsp)
  635. popq %rax
  636. end;
  637. procedure SetSSECSR(w : dword);
  638. var
  639. _w : dword;
  640. begin
  641. _w:=w;
  642. asm
  643. ldmxcsr _w
  644. end;
  645. end;
  646. function GetSSECSR : dword;
  647. var
  648. _w : dword;
  649. begin
  650. asm
  651. stmxcsr _w
  652. end;
  653. result:=_w;
  654. end;
  655. procedure SetFPUExceptionMask(const Mask: TFPUExceptionMask);
  656. var
  657. CtlWord: Word;
  658. newmask : dword;
  659. const
  660. MM_MaskInvalidOp = %0000000010000000;
  661. MM_MaskDenorm = %0000000100000000;
  662. MM_MaskDivZero = %0000001000000000;
  663. MM_MaskOverflow = %0000010000000000;
  664. MM_MaskUnderflow = %0000100000000000;
  665. MM_MaskPrecision = %0001000000000000;
  666. begin
  667. { classic FPU }
  668. CtlWord:=Get8087CW;
  669. Set8087CW( (CtlWord and $FFC0) or Byte(Longint(Mask)) );
  670. { SSE }
  671. newmask:=GetSSECSR;
  672. { invalid operation }
  673. if (exInvalidOp in mask) then
  674. newmask:=newmask or MM_MaskInvalidOp
  675. else
  676. newmask:=newmask and not(MM_MaskInvalidOp);
  677. { denormals }
  678. if (exDenormalized in mask) then
  679. newmask:=newmask or MM_MaskDenorm
  680. else
  681. newmask:=newmask and not(MM_MaskDenorm);
  682. { zero divide }
  683. if (exZeroDivide in mask) then
  684. newmask:=newmask or MM_MaskDivZero
  685. else
  686. newmask:=newmask and not(MM_MaskDivZero);
  687. { overflow }
  688. if (exOverflow in mask) then
  689. newmask:=newmask or MM_MaskOverflow
  690. else
  691. newmask:=newmask and not(MM_MaskOverflow);
  692. { underflow }
  693. if (exUnderflow in mask) then
  694. newmask:=newmask or MM_MaskUnderflow
  695. else
  696. newmask:=newmask and not(MM_MaskUnderflow);
  697. { Precision (inexact result) }
  698. if (exPrecision in mask) then
  699. newmask:=newmask or MM_MaskPrecision
  700. else
  701. newmask:=newmask and not(MM_MaskPrecision);
  702. SetSSECSR(newmask);
  703. end;
  704. {$endif CPUX86_64}
  705. {$ifdef CPUPOWERPC}
  706. {$define HASSETFPUEXCEPTIONMASK}
  707. procedure SetFPUExceptionMask(const Mask: TFPUExceptionMask);
  708. var
  709. newmask: record
  710. case byte of
  711. 1: (d: double);
  712. 2: (a,b: cardinal);
  713. end;
  714. begin
  715. { load current control register contents }
  716. asm
  717. mffs f0
  718. stfd f0,newmask.d
  719. end;
  720. { invalid operation: bit 24 (big endian, bit 0 = left-most bit) }
  721. if (exInvalidOp in mask) then
  722. newmask.b := newmask.b and not(1 shl (31-24))
  723. else
  724. newmask.b := newmask.b or (1 shl (31-24));
  725. { denormals can not cause exceptions on the PPC }
  726. { zero divide: bit 27 }
  727. if (exZeroDivide in mask) then
  728. newmask.b := newmask.b and not(1 shl (31-27))
  729. else
  730. newmask.b := newmask.b or (1 shl (31-27));
  731. { overflow: bit 25 }
  732. if (exOverflow in mask) then
  733. newmask.b := newmask.b and not(1 shl (31-25))
  734. else
  735. newmask.b := newmask.b or (1 shl (31-25));
  736. { underflow: bit 26 }
  737. if (exUnderflow in mask) then
  738. newmask.b := newmask.b and not(1 shl (31-26))
  739. else
  740. newmask.b := newmask.b or (1 shl (31-26));
  741. { Precision (inexact result): bit 28 }
  742. if (exPrecision in mask) then
  743. newmask.b := newmask.b and not(1 shl (31-28))
  744. else
  745. newmask.b := newmask.b or (1 shl (31-28));
  746. { update control register contents }
  747. asm
  748. lfd f0, newmask.d
  749. mtfsf 255,f0
  750. end;
  751. end;
  752. {$endif CPUPOWERPC}
  753. {$ifdef CPUSPARC}
  754. {$define HASSETFPUEXCEPTIONMASK}
  755. procedure SetFPUExceptionMask(const Mask: TFPUExceptionMask);
  756. var
  757. fsr : cardinal;
  758. begin
  759. { load current control register contents }
  760. asm
  761. st %fsr,fsr
  762. end;
  763. { invalid operation: bit 27 }
  764. if (exInvalidOp in mask) then
  765. fsr:=fsr and not(1 shl 27)
  766. else
  767. fsr:=fsr or (1 shl 27);
  768. { zero divide: bit 24 }
  769. if (exZeroDivide in mask) then
  770. fsr:=fsr and not(1 shl 24)
  771. else
  772. fsr:=fsr or (1 shl 24);
  773. { overflow: bit 26 }
  774. if (exOverflow in mask) then
  775. fsr:=fsr and not(1 shl 26)
  776. else
  777. fsr:=fsr or (1 shl 26);
  778. { underflow: bit 25 }
  779. if (exUnderflow in mask) then
  780. fsr:=fsr and not(1 shl 25)
  781. else
  782. fsr:=fsr or (1 shl 25);
  783. { Precision (inexact result): bit 23 }
  784. if (exPrecision in mask) then
  785. fsr:=fsr and not(1 shl 23)
  786. else
  787. fsr:=fsr or (1 shl 23);
  788. { update control register contents }
  789. asm
  790. ld fsr,%fsr
  791. end;
  792. end;
  793. {$endif CPUSPARC}
  794. {$ifndef HASSETFPUEXCEPTIONMASK}
  795. procedure SetFPUExceptionMask(const Mask: TFPUExceptionMask);
  796. begin
  797. end;
  798. {$endif HASSETFPUEXCEPTIONMASK}
  799. function is_number_float(d : double) : boolean;
  800. var
  801. bytearray : array[0..7] of byte;
  802. begin
  803. move(d,bytearray,8);
  804. { only 1.1 save, 1.0.x will use always little endian }
  805. {$ifdef FPC_BIG_ENDIAN}
  806. result:=((bytearray[0] and $7f)<>$7f) or ((bytearray[1] and $f0)<>$f0);
  807. {$else FPC_BIG_ENDIAN}
  808. result:=((bytearray[7] and $7f)<>$7f) or ((bytearray[6] and $f0)<>$f0);
  809. {$endif FPC_BIG_ENDIAN}
  810. end;
  811. function get_real_sign(r: bestreal): longint;
  812. var
  813. p: pbyte;
  814. begin
  815. p := pbyte(@r);
  816. {$ifdef CPU_ARM}
  817. inc(p,4);
  818. {$else}
  819. {$ifdef FPC_LITTLE_ENDIAN}
  820. inc(p,sizeof(r)-1);
  821. {$endif}
  822. {$endif}
  823. if (p^ and $80) = 0 then
  824. result := 1
  825. else
  826. result := -1;
  827. end;
  828. function convertdoublerec(d : tdoublerec) : tdoublerec;{$ifdef USEINLINE}inline;{$endif}
  829. {$ifdef CPUARM}
  830. var
  831. i : longint;
  832. begin
  833. for i:=0 to 3 do
  834. begin
  835. result.bytes[i+4]:=d.bytes[i];
  836. result.bytes[i]:=d.bytes[i+4];
  837. end;
  838. {$else CPUARM}
  839. begin
  840. result:=d;
  841. {$endif CPUARM}
  842. end;
  843. { '('D1:'00000000-'D2:'0000-'D3:'0000-'D4:'0000-000000000000)' }
  844. function string2guid(const s: string; var GUID: TGUID): boolean;
  845. function ishexstr(const hs: string): boolean;
  846. var
  847. i: integer;
  848. begin
  849. ishexstr:=false;
  850. for i:=1 to Length(hs) do begin
  851. if not (hs[i] in ['0'..'9','A'..'F','a'..'f']) then
  852. exit;
  853. end;
  854. ishexstr:=true;
  855. end;
  856. function hexstr2longint(const hexs: string): longint;
  857. var
  858. i: integer;
  859. rl: longint;
  860. begin
  861. rl:=0;
  862. for i:=1 to length(hexs) do begin
  863. rl:=rl shl 4;
  864. case hexs[i] of
  865. '0'..'9' : inc(rl,ord(hexs[i])-ord('0'));
  866. 'A'..'F' : inc(rl,ord(hexs[i])-ord('A')+10);
  867. 'a'..'f' : inc(rl,ord(hexs[i])-ord('a')+10);
  868. end
  869. end;
  870. hexstr2longint:=rl;
  871. end;
  872. var
  873. i: integer;
  874. begin
  875. if (Length(s)=38) and (s[1]='{') and (s[38]='}') and
  876. (s[10]='-') and (s[15]='-') and (s[20]='-') and (s[25]='-') and
  877. ishexstr(copy(s,2,8)) and ishexstr(copy(s,11,4)) and
  878. ishexstr(copy(s,16,4)) and ishexstr(copy(s,21,4)) and
  879. ishexstr(copy(s,26,12)) then begin
  880. GUID.D1:=dword(hexstr2longint(copy(s,2,8)));
  881. { these values are arealdy in the correct range (4 chars = word) }
  882. GUID.D2:=word(hexstr2longint(copy(s,11,4)));
  883. GUID.D3:=word(hexstr2longint(copy(s,16,4)));
  884. for i:=0 to 1 do
  885. GUID.D4[i]:=byte(hexstr2longint(copy(s,21+i*2,2)));
  886. for i:=2 to 7 do
  887. GUID.D4[i]:=byte(hexstr2longint(copy(s,22+i*2,2)));
  888. string2guid:=true;
  889. end
  890. else
  891. string2guid:=false;
  892. end;
  893. function guid2string(const GUID: TGUID): string;
  894. function long2hex(l, len: longint): string;
  895. const
  896. hextbl: array[0..15] of char = '0123456789ABCDEF';
  897. var
  898. rs: string;
  899. i: integer;
  900. begin
  901. rs[0]:=chr(len);
  902. for i:=len downto 1 do begin
  903. rs[i]:=hextbl[l and $F];
  904. l:=l shr 4;
  905. end;
  906. long2hex:=rs;
  907. end;
  908. begin
  909. guid2string:=
  910. '{'+long2hex(GUID.D1,8)+
  911. '-'+long2hex(GUID.D2,4)+
  912. '-'+long2hex(GUID.D3,4)+
  913. '-'+long2hex(GUID.D4[0],2)+long2hex(GUID.D4[1],2)+
  914. '-'+long2hex(GUID.D4[2],2)+long2hex(GUID.D4[3],2)+
  915. long2hex(GUID.D4[4],2)+long2hex(GUID.D4[5],2)+
  916. long2hex(GUID.D4[6],2)+long2hex(GUID.D4[7],2)+
  917. '}';
  918. end;
  919. function SetAktProcCall(const s:string; var a:tproccalloption):boolean;
  920. const
  921. DefProcCallName : array[tproccalloption] of string[12] = ('',
  922. 'CDECL',
  923. 'CPPDECL',
  924. 'FAR16',
  925. 'OLDFPCCALL',
  926. '', { internproc }
  927. '', { syscall }
  928. 'PASCAL',
  929. 'REGISTER',
  930. 'SAFECALL',
  931. 'STDCALL',
  932. 'SOFTFLOAT',
  933. 'MWPASCAL'
  934. );
  935. var
  936. t : tproccalloption;
  937. hs : string;
  938. begin
  939. result:=false;
  940. if (s = '') then
  941. exit;
  942. hs:=upper(s);
  943. if (hs = 'DEFAULT') then
  944. begin
  945. a := pocall_default;
  946. result := true;
  947. exit;
  948. end;
  949. for t:=low(tproccalloption) to high(tproccalloption) do
  950. if DefProcCallName[t]=hs then
  951. begin
  952. a:=t;
  953. result:=true;
  954. break;
  955. end;
  956. end;
  957. function Setcputype(const s:string;var a:tcputype):boolean;
  958. var
  959. t : tcputype;
  960. hs : string;
  961. begin
  962. result:=false;
  963. hs:=Upper(s);
  964. for t:=low(tcputype) to high(tcputype) do
  965. if cputypestr[t]=hs then
  966. begin
  967. a:=t;
  968. result:=true;
  969. break;
  970. end;
  971. end;
  972. function SetFpuType(const s:string;var a:tfputype):boolean;
  973. var
  974. t : tfputype;
  975. begin
  976. result:=false;
  977. for t:=low(tfputype) to high(tfputype) do
  978. if fputypestr[t]=s then
  979. begin
  980. a:=t;
  981. result:=true;
  982. break;
  983. end;
  984. end;
  985. function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
  986. var
  987. tok : string;
  988. vstr : string;
  989. l : longint;
  990. code : integer;
  991. b : talignmentinfo;
  992. begin
  993. UpdateAlignmentStr:=true;
  994. uppervar(s);
  995. fillchar(b,sizeof(b),0);
  996. repeat
  997. tok:=GetToken(s,'=');
  998. if tok='' then
  999. break;
  1000. vstr:=GetToken(s,',');
  1001. val(vstr,l,code);
  1002. if tok='PROC' then
  1003. b.procalign:=l
  1004. else if tok='JUMP' then
  1005. b.jumpalign:=l
  1006. else if tok='LOOP' then
  1007. b.loopalign:=l
  1008. else if tok='CONSTMIN' then
  1009. b.constalignmin:=l
  1010. else if tok='CONSTMAX' then
  1011. b.constalignmax:=l
  1012. else if tok='VARMIN' then
  1013. b.varalignmin:=l
  1014. else if tok='VARMAX' then
  1015. b.varalignmax:=l
  1016. else if tok='LOCALMIN' then
  1017. b.localalignmin:=l
  1018. else if tok='LOCALMAX' then
  1019. b.localalignmax:=l
  1020. else if tok='RECORDMIN' then
  1021. b.recordalignmin:=l
  1022. else if tok='RECORDMAX' then
  1023. b.recordalignmax:=l
  1024. else { Error }
  1025. UpdateAlignmentStr:=false;
  1026. until false;
  1027. UpdateAlignment(a,b);
  1028. end;
  1029. function UpdateOptimizerStr(s:string;var a:toptimizerswitches):boolean;
  1030. var
  1031. tok : string;
  1032. doset,
  1033. found : boolean;
  1034. opt : toptimizerswitch;
  1035. begin
  1036. result:=true;
  1037. uppervar(s);
  1038. repeat
  1039. tok:=GetToken(s,',');
  1040. if tok='' then
  1041. break;
  1042. if Copy(tok,1,2)='NO' then
  1043. begin
  1044. delete(tok,1,2);
  1045. doset:=false;
  1046. end
  1047. else
  1048. doset:=true;
  1049. found:=false;
  1050. for opt:=low(toptimizerswitch) to high(toptimizerswitch) do
  1051. begin
  1052. if OptimizerSwitchStr[opt]=tok then
  1053. begin
  1054. found:=true;
  1055. break;
  1056. end;
  1057. end;
  1058. if found then
  1059. begin
  1060. if doset then
  1061. include(a,opt)
  1062. else
  1063. exclude(a,opt);
  1064. end
  1065. else
  1066. result:=false;
  1067. until false;
  1068. end;
  1069. function var_align(siz: shortint): shortint;
  1070. begin
  1071. siz := size_2_align(siz);
  1072. var_align := used_align(siz,current_settings.alignment.varalignmin,current_settings.alignment.varalignmax);
  1073. end;
  1074. function const_align(siz: shortint): shortint;
  1075. begin
  1076. siz := size_2_align(siz);
  1077. const_align := used_align(siz,current_settings.alignment.constalignmin,current_settings.alignment.constalignmax);
  1078. end;
  1079. {****************************************************************************
  1080. Init
  1081. ****************************************************************************}
  1082. {$ifdef unix}
  1083. {$define need_path_search}
  1084. {$endif unix}
  1085. {$ifdef os2}
  1086. {$define need_path_search}
  1087. {$endif os2}
  1088. {$ifdef macos}
  1089. {$define need_path_search}
  1090. {$endif macos}
  1091. procedure get_exepath;
  1092. var
  1093. exeName:String;
  1094. {$ifdef need_path_search}
  1095. hs1 : TPathStr;
  1096. p : pchar;
  1097. {$endif need_path_search}
  1098. begin
  1099. exepath:=GetEnvironmentVariable('PPC_EXEC_PATH');
  1100. if exepath='' then
  1101. begin
  1102. exeName := FixFileName(system.paramstr(0));
  1103. exepath := ExtractFilePath(exeName);
  1104. end;
  1105. {$ifdef need_path_search}
  1106. if exepath='' then
  1107. begin
  1108. hs1 := ExtractFileName(exeName);
  1109. ChangeFileExt(hs1,source_info.exeext);
  1110. {$ifdef macos}
  1111. p:=GetEnvPchar('Commands');
  1112. {$else macos}
  1113. p:=GetEnvPchar('PATH');
  1114. {$endif macos}
  1115. FindFilePChar(hs1,p,false,exepath);
  1116. FreeEnvPChar(p);
  1117. exepath:=ExtractFilePath(exepath);
  1118. end;
  1119. {$endif need_path_search}
  1120. exepath:=FixPath(exepath,false);
  1121. end;
  1122. procedure DoneGlobals;
  1123. begin
  1124. if assigned(DLLImageBase) then
  1125. StringDispose(DLLImageBase);
  1126. librarysearchpath.Free;
  1127. unitsearchpath.Free;
  1128. objectsearchpath.Free;
  1129. includesearchpath.Free;
  1130. LinkLibraryAliases.Free;
  1131. LinkLibraryOrder.Free;
  1132. end;
  1133. procedure InitGlobals;
  1134. begin
  1135. get_exepath;
  1136. { reset globals }
  1137. do_build:=false;
  1138. do_release:=false;
  1139. do_make:=true;
  1140. compile_level:=0;
  1141. DLLsource:=false;
  1142. inlining_procedure:=false;
  1143. resolving_forward:=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.