globals.pas 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420
  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. end;
  1131. procedure InitGlobals;
  1132. begin
  1133. get_exepath;
  1134. { reset globals }
  1135. do_build:=false;
  1136. do_release:=false;
  1137. do_make:=true;
  1138. compile_level:=0;
  1139. DLLsource:=false;
  1140. inlining_procedure:=false;
  1141. resolving_forward:=false;
  1142. LinkTypeSetExplicitly:=false;
  1143. paratarget:=system_none;
  1144. paratargetasm:=as_none;
  1145. paratargetdbg:=dbg_none;
  1146. { Output }
  1147. OutputFileName:='';
  1148. OutputPrefix:=Nil;
  1149. OutputSuffix:=Nil;
  1150. OutputExeDir:='';
  1151. OutputUnitDir:='';
  1152. { Utils directory }
  1153. utilsdirectory:='';
  1154. utilsprefix:='';
  1155. cshared:=false;
  1156. rlinkpath:='';
  1157. { Search Paths }
  1158. librarysearchpath:=TSearchPathList.Create;
  1159. unitsearchpath:=TSearchPathList.Create;
  1160. includesearchpath:=TSearchPathList.Create;
  1161. objectsearchpath:=TSearchPathList.Create;
  1162. { Def file }
  1163. usewindowapi:=false;
  1164. description:='Compiled by FPC '+version_string+' - '+target_cpu_string;
  1165. DescriptionSetExplicity:=false;
  1166. SetPEFlagsSetExplicity:=false;
  1167. ImageBaseSetExplicity:=false;
  1168. MinStackSizeSetExplicity:=false;
  1169. MaxStackSizeSetExplicity:=false;
  1170. dllversion:='';
  1171. dllmajor:=1;
  1172. dllminor:=0;
  1173. dllrevision:=0;
  1174. nwscreenname := '';
  1175. nwthreadname := '';
  1176. nwcopyright := '';
  1177. UseDeffileForExports:=false;
  1178. UseDeffileForExportsSetExplicitly:=false;
  1179. GenerateImportSection:=false;
  1180. RelocSection:=false;
  1181. RelocSectionSetExplicitly:=false;
  1182. LinkTypeSetExplicitly:=false;
  1183. { memory sizes, will be overriden by parameter or default for target
  1184. in options or init_parser }
  1185. stacksize:=0;
  1186. { not initialized yet }
  1187. jmp_buf_size:=-1;
  1188. apptype:=app_cui;
  1189. { Init values }
  1190. init_settings.modeswitches:=fpcmodeswitches;
  1191. init_settings.localswitches:=[cs_check_io,cs_typed_const_writable];
  1192. init_settings.moduleswitches:=[cs_extsyntax,cs_implicit_exceptions];
  1193. init_settings.globalswitches:=[cs_check_unit_name,cs_link_static];
  1194. init_settings.optimizerswitches:=[];
  1195. init_settings.sourcecodepage:='8859-1';
  1196. init_settings.packenum:=4;
  1197. init_settings.setalloc:=0;
  1198. fillchar(init_settings.alignment,sizeof(talignmentinfo),0);
  1199. { might be overridden later }
  1200. init_settings.asmmode:=asmmode_standard;
  1201. init_settings.cputype:=cpu_none;
  1202. init_settings.optimizecputype:=cpu_none;
  1203. init_settings.fputype:=fpu_none;
  1204. init_settings.interfacetype:=it_interfacecom;
  1205. init_settings.defproccall:=pocall_default;
  1206. { Target specific defaults, these can override previous default options }
  1207. {$ifdef i386}
  1208. init_settings.cputype:=cpu_Pentium;
  1209. init_settings.optimizecputype:=cpu_Pentium3;
  1210. init_settings.fputype:=fpu_x87;
  1211. {$endif i386}
  1212. {$ifdef m68k}
  1213. init_settings.cputype:=cpu_MC68020;
  1214. init_settings.fputype:=fpu_soft;
  1215. {$endif m68k}
  1216. {$ifdef powerpc}
  1217. init_settings.cputype:=cpu_PPC604;
  1218. init_settings.fputype:=fpu_standard;
  1219. {$endif powerpc}
  1220. {$ifdef POWERPC64}
  1221. init_settings.cputype:=cpu_PPC970;
  1222. init_settings.fputype:=fpu_standard;
  1223. {$endif POWERPC64}
  1224. {$ifdef sparc}
  1225. init_settings.cputype:=cpu_SPARC_V8;
  1226. init_settings.fputype:=fpu_hard;
  1227. {$endif sparc}
  1228. {$ifdef arm}
  1229. init_settings.cputype:=cpu_armv3;
  1230. init_settings.fputype:=fpu_fpa;
  1231. {$endif arm}
  1232. {$ifdef x86_64}
  1233. init_settings.cputype:=cpu_athlon64;
  1234. init_settings.fputype:=fpu_sse64;
  1235. {$endif x86_64}
  1236. if init_settings.optimizecputype=cpu_none then
  1237. init_settings.optimizecputype:=init_settings.cputype;
  1238. LinkLibraryAliases :=TLinkStrMap.Create;
  1239. LinkLibraryOrder :=TLinkStrMap.Create;
  1240. end;
  1241. end.