globals.pas 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This unit implements some support functions and global variables
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit globals;
  19. {$i fpcdefs.inc}
  20. { Use the internal linker by default }
  21. { define INTERNALLINKER}
  22. interface
  23. uses
  24. {$ifdef win32}
  25. windows,
  26. {$endif}
  27. {$ifdef unix}
  28. {$ifdef ver1_0}
  29. linux,
  30. {$else}
  31. unix,
  32. {$endif}
  33. {$endif}
  34. {$ifdef os2}
  35. doscalls,
  36. {$endif}
  37. {$ifdef Delphi}
  38. SysUtils,
  39. dmisc,
  40. {$else}
  41. strings,
  42. dos,
  43. {$endif}
  44. cutils,cclasses,
  45. globtype,version,systems;
  46. const
  47. {$ifdef Splitheap}
  48. testsplit : boolean = false;
  49. {$endif Splitheap}
  50. delphimodeswitches : tmodeswitches=
  51. [m_delphi,m_all,m_class,m_objpas,m_result,m_string_pchar,
  52. m_pointer_2_procedure,m_autoderef,m_tp_procvar,m_initfinal,m_default_ansistring,
  53. m_out,m_default_para,m_hintdirective,m_duplicate_names];
  54. fpcmodeswitches : tmodeswitches=
  55. [m_fpc,m_all,m_string_pchar,m_nested_comment,m_repeat_forward,
  56. m_cvar_support,m_initfinal,m_add_pointer];
  57. objfpcmodeswitches : tmodeswitches=
  58. [m_objfpc,m_fpc,m_all,m_class,m_objpas,m_result,m_string_pchar,m_nested_comment,
  59. m_repeat_forward,m_cvar_support,m_initfinal,m_add_pointer,m_out,m_default_para];
  60. tpmodeswitches : tmodeswitches=
  61. [m_tp7,m_all,m_tp_procvar,m_duplicate_names];
  62. gpcmodeswitches : tmodeswitches=
  63. [m_gpc,m_all];
  64. type
  65. pfileposinfo = ^tfileposinfo;
  66. tfileposinfo = record
  67. line : longint;
  68. column : word;
  69. fileindex : word;
  70. { moduleindex : word; }
  71. end;
  72. TSearchPathList = class(TStringList)
  73. procedure AddPath(s:string;addfirst:boolean);
  74. procedure AddList(list:TSearchPathList;addfirst:boolean);
  75. function FindFile(const f : string;var foundfile:string):boolean;
  76. end;
  77. {# the ordinal type used when evaluating constant integer expressions }
  78. TConstExprInt = int64;
  79. { ... the same unsigned }
  80. TConstExprUInt = {$ifdef fpc}qword{$else}int64{$endif};
  81. var
  82. { specified inputfile }
  83. inputdir : dirstr;
  84. inputfile : namestr;
  85. inputextension : extstr;
  86. { specified outputfile with -o parameter }
  87. outputfile : namestr;
  88. { specified with -FE or -FU }
  89. outputexedir : dirstr;
  90. outputunitdir : dirstr;
  91. { things specified with parameters }
  92. paralinkoptions,
  93. paradynamiclinker : string;
  94. parapreprocess : boolean;
  95. { directory where the utils can be found (options -FD) }
  96. utilsdirectory : dirstr;
  97. { some flags for global compiler switches }
  98. do_build,
  99. do_release,
  100. do_make : boolean;
  101. not_unit_proc : boolean;
  102. { path for searching units, different paths can be seperated by ; }
  103. exepath : dirstr; { Path to ppc }
  104. librarysearchpath,
  105. unitsearchpath,
  106. objectsearchpath,
  107. includesearchpath : TSearchPathList;
  108. { deffile }
  109. usewindowapi : boolean;
  110. description : string;
  111. dllversion : string;
  112. dllmajor,dllminor,dllrevision : word; { revision only for netware }
  113. akttokenpos, { position of the last token }
  114. aktfilepos : tfileposinfo; { current position }
  115. { ad 18.05.2001: Screen and Threadname for Netware }
  116. nwscreenname : string;
  117. nwthreadname : string;
  118. nwcopyright : string;
  119. block_type : tblock_type; { type of currently parsed block }
  120. in_args : boolean; { arguments must be checked especially }
  121. parsing_para_level : integer; { parameter level, used to convert
  122. proc calls to proc loads in firstcalln }
  123. compile_level : word;
  124. make_ref : boolean;
  125. resolving_forward : boolean; { used to add forward reference as second ref }
  126. use_esp_stackframe : boolean; { to test for call with ESP as stack frame }
  127. inlining_procedure : boolean; { are we inlining a procedure }
  128. statement_level : integer;
  129. exceptblockcounter : integer; { each except block gets a unique number check gotos }
  130. aktexceptblock : integer; { the exceptblock number of the current block (0 if none) }
  131. have_local_threadvars : boolean; { set if a table of local threadvars-tables is present and has to be initialized }
  132. { commandline values }
  133. initdefines : tstringlist;
  134. initglobalswitches : tglobalswitches;
  135. initmoduleswitches : tmoduleswitches;
  136. initlocalswitches : tlocalswitches;
  137. initmodeswitches : tmodeswitches;
  138. {$IFDEF testvarsets}
  139. Initsetalloc, {0=fixed, 1 =var}
  140. {$ENDIF}
  141. initpackenum : longint;
  142. initalignment : talignmentinfo;
  143. initoptprocessor,
  144. initspecificoptprocessor : tprocessors;
  145. initasmmode : tasmmode;
  146. initinterfacetype : tinterfacetypes;
  147. initoutputformat : tasm;
  148. initdefproccall : tproccalloption;
  149. { current state values }
  150. aktglobalswitches : tglobalswitches;
  151. aktmoduleswitches : tmoduleswitches;
  152. aktlocalswitches : tlocalswitches;
  153. nextaktlocalswitches : tlocalswitches;
  154. localswitcheschanged : boolean;
  155. aktmodeswitches : tmodeswitches;
  156. {$IFDEF testvarsets}
  157. aktsetalloc,
  158. {$ENDIF}
  159. aktpackenum : longint;
  160. aktmaxfpuregisters : longint;
  161. aktalignment : talignmentinfo;
  162. aktoptprocessor,
  163. aktspecificoptprocessor : tprocessors;
  164. aktasmmode : tasmmode;
  165. aktinterfacetype : tinterfacetypes;
  166. aktoutputformat : tasm;
  167. aktdefproccall : tproccalloption;
  168. { Memory sizes }
  169. heapsize,
  170. stacksize : longint;
  171. {$Ifdef EXTDEBUG}
  172. total_of_firstpass,
  173. firstpass_several : longint;
  174. {$ifdef FPC}
  175. EntryMemUsed : longint;
  176. {$endif FPC}
  177. { parameter switches }
  178. debugstop : boolean;
  179. {$EndIf EXTDEBUG}
  180. { windows / OS/2 application type }
  181. apptype : tapptype;
  182. const
  183. RelocSection : boolean = true;
  184. RelocSectionSetExplicitly : boolean = false;
  185. LinkTypeSetExplicitly : boolean = false;
  186. DLLsource : boolean = false;
  187. DLLImageBase : pstring = nil;
  188. UseDeffileForExport : boolean = true;
  189. ForceDeffileForExport : boolean = false;
  190. { used to set all registers used for each global function
  191. this should dramatically decrease the number of
  192. recompilations needed PM }
  193. simplify_ppu : boolean = true;
  194. { should we allow non static members ? }
  195. allow_only_static : boolean = false;
  196. Inside_asm_statement : boolean = false;
  197. global_unit_count : word = 0;
  198. { for error info in pp.pas }
  199. parser_current_file : string = '';
  200. {$ifdef m68k}
  201. { PalmOS resources }
  202. palmos_applicationname : string = 'FPC Application';
  203. palmos_applicationid : string[4] = 'FPCA';
  204. {$endif m68k}
  205. procedure abstract;
  206. function bstoslash(const s : string) : string;
  207. function getdatestr:string;
  208. function gettimestr:string;
  209. function filetimestring( t : longint) : string;
  210. procedure DefaultReplacements(var s:string);
  211. function GetCurrentDir:string;
  212. function path_absolute(const s : string) : boolean;
  213. Function PathExists ( F : String) : Boolean;
  214. Function FileExists ( Const F : String) : Boolean;
  215. Function RemoveFile(const f:string):boolean;
  216. Function RemoveDir(d:string):boolean;
  217. Function GetFileTime ( Var F : File) : Longint;
  218. Function GetNamedFileTime ( Const F : String) : Longint;
  219. Function SplitPath(const s:string):string;
  220. Function SplitFileName(const s:string):string;
  221. Function SplitName(const s:string):string;
  222. Function SplitExtension(Const HStr:String):String;
  223. Function AddExtension(Const HStr,ext:String):String;
  224. Function ForceExtension(Const HStr,ext:String):String;
  225. Function FixPath(s:string;allowdot:boolean):string;
  226. function FixFileName(const s:string):string;
  227. function TargetFixPath(s:string;allowdot:boolean):string;
  228. function TargetFixFileName(const s:string):string;
  229. procedure SplitBinCmd(const s:string;var bstr,cstr:string);
  230. function FindFile(const f : string;path : string;var foundfile:string):boolean;
  231. function FindExe(const bin:string;var foundfile:string):boolean;
  232. function GetShortName(const n:string):string;
  233. Procedure Shell(const command:string);
  234. function GetEnvPChar(const envname:string):pchar;
  235. procedure FreeEnvPChar(p:pchar);
  236. Function SetCompileMode(const s:string; changeInit: boolean):boolean;
  237. function SetAktProcCall(const s:string; changeInit: boolean):boolean;
  238. procedure InitGlobals;
  239. procedure DoneGlobals;
  240. function string2guid(const s: string; var GUID: TGUID): boolean;
  241. function guid2string(const GUID: TGUID): string;
  242. procedure swap_qword(var q : qword);
  243. function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
  244. implementation
  245. uses
  246. comphook;
  247. procedure abstract;
  248. begin
  249. do_internalerror(255);
  250. end;
  251. function bstoslash(const s : string) : string;
  252. {
  253. return string s with all \ changed into /
  254. }
  255. var
  256. i : longint;
  257. begin
  258. for i:=1to length(s) do
  259. if s[i]='\' then
  260. bstoslash[i]:='/'
  261. else
  262. bstoslash[i]:=s[i];
  263. bstoslash[0]:=s[0];
  264. end;
  265. {****************************************************************************
  266. Time Handling
  267. ****************************************************************************}
  268. Function L0(l:longint):string;
  269. {
  270. return the string of value l, if l<10 then insert a zero, so
  271. the string is always at least 2 chars '01','02',etc
  272. }
  273. var
  274. s : string;
  275. begin
  276. Str(l,s);
  277. if l<10 then
  278. s:='0'+s;
  279. L0:=s;
  280. end;
  281. function gettimestr:string;
  282. {
  283. get the current time in a string HH:MM:SS
  284. }
  285. var
  286. hour,min,sec,hsec : word;
  287. begin
  288. {$ifdef delphi}
  289. dmisc.gettime(hour,min,sec,hsec);
  290. {$else delphi}
  291. dos.gettime(hour,min,sec,hsec);
  292. {$endif delphi}
  293. gettimestr:=L0(Hour)+':'+L0(min)+':'+L0(sec);
  294. end;
  295. function getdatestr:string;
  296. {
  297. get the current date in a string YY/MM/DD
  298. }
  299. var
  300. Year,Month,Day,Wday : Word;
  301. begin
  302. {$ifdef delphi}
  303. dmisc.getdate(year,month,day,wday);
  304. {$else}
  305. dos.getdate(year,month,day,wday);
  306. {$endif}
  307. getdatestr:=L0(Year)+'/'+L0(Month)+'/'+L0(Day);
  308. end;
  309. function filetimestring( t : longint) : string;
  310. {
  311. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  312. }
  313. var
  314. DT : DateTime;
  315. begin
  316. if t=-1 then
  317. begin
  318. FileTimeString:='Not Found';
  319. exit;
  320. end;
  321. unpacktime(t,DT);
  322. filetimestring:=L0(dt.Year)+'/'+L0(dt.Month)+'/'+L0(dt.Day)+' '+L0(dt.Hour)+':'+L0(dt.min)+':'+L0(dt.sec);
  323. end;
  324. {****************************************************************************
  325. Default Macro Handling
  326. ****************************************************************************}
  327. procedure DefaultReplacements(var s:string);
  328. begin
  329. { Replace some macro's }
  330. Replace(s,'$FPCVER',version_string);
  331. Replace(s,'$VERSION',version_string);
  332. Replace(s,'$FULLVERSION',full_version_string);
  333. Replace(s,'$FPCDATE',date_string);
  334. Replace(s,'$FPCTARGET',target_cpu_string);
  335. Replace(s,'$FPCCPU',target_cpu_string);
  336. Replace(s,'$TARGET',target_path);
  337. Replace(s,'$FPCOS',target_path);
  338. end;
  339. {****************************************************************************
  340. File Handling
  341. ****************************************************************************}
  342. function GetCurrentDir:string;
  343. var
  344. CurrentDir : string;
  345. begin
  346. GetDir(0,CurrentDir);
  347. GetCurrentDir:=FixPath(CurrentDir,false);
  348. end;
  349. function path_absolute(const s : string) : boolean;
  350. {
  351. is path s an absolute path?
  352. }
  353. begin
  354. path_absolute:=false;
  355. {$ifdef unix}
  356. if (length(s)>0) and (s[1]='/') then
  357. path_absolute:=true;
  358. {$else unix}
  359. {$ifdef amiga}
  360. if ((length(s)>0) and ((s[1]='\') or (s[1]='/'))) or (Pos(':',s) = length(s)) then
  361. path_absolute:=true;
  362. {$else}
  363. if ((length(s)>0) and ((s[1]='\') or (s[1]='/'))) or
  364. ((length(s)>2) and (s[2]=':') and ((s[3]='\') or (s[3]='/'))) then
  365. path_absolute:=true;
  366. {$endif amiga}
  367. {$endif unix}
  368. end;
  369. {$ifndef FPC}
  370. Procedure FindClose(var Info : SearchRec);
  371. Begin
  372. End;
  373. {$endif not FPC}
  374. Function FileExists ( Const F : String) : Boolean;
  375. {$ifndef delphi}
  376. Var
  377. Info : SearchRec;
  378. {$endif}
  379. begin
  380. {$ifdef delphi}
  381. FileExists:=sysutils.FileExists(f);
  382. {$else}
  383. findfirst(F,readonly+archive+hidden,info);
  384. FileExists:=(doserror=0);
  385. findclose(Info);
  386. {$endif delphi}
  387. end;
  388. Function PathExists ( F : String) : Boolean;
  389. Var
  390. Info : SearchRec;
  391. {$ifdef i386}
  392. disk : byte;
  393. {$endif i386}
  394. begin
  395. {$ifdef i386}
  396. if (Length(f)=3) and (F[2]=':') and (F[3] in ['/','\']) then
  397. begin
  398. if F[1] in ['A'..'Z'] then
  399. disk:=ord(F[1])-ord('A')+1
  400. else if F[1] in ['a'..'z'] then
  401. disk:=ord(F[1])-ord('a')+1
  402. else
  403. disk:=255;
  404. if disk=255 then
  405. PathExists:=false
  406. else
  407. PathExists:=(DiskSize(disk)<>-1);
  408. exit;
  409. end;
  410. {$endif i386}
  411. if F[Length(f)] in ['/','\'] then
  412. Delete(f,length(f),1);
  413. findfirst(F,readonly+archive+hidden+directory,info);
  414. PathExists:=(doserror=0) and ((info.attr and directory)=directory);
  415. findclose(Info);
  416. end;
  417. Function RemoveFile(const f:string):boolean;
  418. var
  419. g : file;
  420. begin
  421. assign(g,f);
  422. {$I-}
  423. erase(g);
  424. {$I+}
  425. RemoveFile:=(ioresult=0);
  426. end;
  427. Function RemoveDir(d:string):boolean;
  428. begin
  429. if d[length(d)]=source_info.DirSep then
  430. Delete(d,length(d),1);
  431. {$I-}
  432. rmdir(d);
  433. {$I+}
  434. RemoveDir:=(ioresult=0);
  435. end;
  436. Function SplitPath(const s:string):string;
  437. var
  438. i : longint;
  439. begin
  440. i:=Length(s);
  441. while (i>0) and not(s[i] in ['/','\']) do
  442. dec(i);
  443. SplitPath:=Copy(s,1,i);
  444. end;
  445. Function SplitFileName(const s:string):string;
  446. var
  447. p : dirstr;
  448. n : namestr;
  449. e : extstr;
  450. begin
  451. FSplit(s,p,n,e);
  452. SplitFileName:=n+e;
  453. end;
  454. Function SplitName(const s:string):string;
  455. var
  456. i,j : longint;
  457. begin
  458. i:=Length(s);
  459. j:=Length(s);
  460. while (i>0) and not(s[i] in ['/','\']) do
  461. dec(i);
  462. while (j>0) and (s[j]<>'.') do
  463. dec(j);
  464. if j<=i then
  465. j:=255;
  466. SplitName:=Copy(s,i+1,j-(i+1));
  467. end;
  468. Function SplitExtension(Const HStr:String):String;
  469. var
  470. j : longint;
  471. begin
  472. j:=length(Hstr);
  473. while (j>0) and (Hstr[j]<>'.') do
  474. begin
  475. if hstr[j]=source_info.DirSep then
  476. j:=0
  477. else
  478. dec(j);
  479. end;
  480. if j=0 then
  481. j:=254;
  482. SplitExtension:=Copy(Hstr,j,255);
  483. end;
  484. Function AddExtension(Const HStr,ext:String):String;
  485. begin
  486. if (Ext<>'') and (SplitExtension(HStr)='') then
  487. AddExtension:=Hstr+Ext
  488. else
  489. AddExtension:=Hstr;
  490. end;
  491. Function ForceExtension(Const HStr,ext:String):String;
  492. var
  493. j : longint;
  494. begin
  495. j:=length(Hstr);
  496. while (j>0) and (Hstr[j]<>'.') do
  497. dec(j);
  498. if j=0 then
  499. j:=255;
  500. ForceExtension:=Copy(Hstr,1,j-1)+Ext;
  501. end;
  502. Function FixPath(s:string;allowdot:boolean):string;
  503. var
  504. i : longint;
  505. begin
  506. { Fix separator }
  507. for i:=1 to length(s) do
  508. if s[i] in ['/','\'] then
  509. s[i]:=source_info.DirSep;
  510. { Fix ending / }
  511. if (length(s)>0) and (s[length(s)]<>source_info.DirSep) and
  512. (s[length(s)]<>':') then
  513. s:=s+source_info.DirSep;
  514. { Remove ./ }
  515. if (not allowdot) and (s='.'+source_info.DirSep) then
  516. s:='';
  517. { return }
  518. if source_info.files_case_relevent then
  519. FixPath:=s
  520. else
  521. FixPath:=Lower(s);
  522. end;
  523. function FixFileName(const s:string):string;
  524. var
  525. i : longint;
  526. begin
  527. if source_info.files_case_relevent then
  528. begin
  529. for i:=1 to length(s) do
  530. begin
  531. case s[i] of
  532. '/','\' :
  533. FixFileName[i]:=source_info.dirsep;
  534. else
  535. FixFileName[i]:=s[i];
  536. end;
  537. end;
  538. end
  539. else
  540. begin
  541. for i:=1 to length(s) do
  542. begin
  543. case s[i] of
  544. '/','\' :
  545. FixFileName[i]:=source_info.dirsep;
  546. 'A'..'Z' :
  547. FixFileName[i]:=char(byte(s[i])+32);
  548. else
  549. FixFileName[i]:=s[i];
  550. end;
  551. end;
  552. end;
  553. FixFileName[0]:=s[0];
  554. end;
  555. Function TargetFixPath(s:string;allowdot:boolean):string;
  556. var
  557. i : longint;
  558. begin
  559. { Fix separator }
  560. for i:=1 to length(s) do
  561. if s[i] in ['/','\'] then
  562. s[i]:=target_info.DirSep;
  563. { Fix ending / }
  564. if (length(s)>0) and (s[length(s)]<>target_info.DirSep) and
  565. (s[length(s)]<>':') then
  566. s:=s+target_info.DirSep;
  567. { Remove ./ }
  568. if (not allowdot) and (s='.'+target_info.DirSep) then
  569. s:='';
  570. { return }
  571. if target_info.files_case_relevent then
  572. TargetFixPath:=s
  573. else
  574. TargetFixPath:=Lower(s);
  575. end;
  576. function TargetFixFileName(const s:string):string;
  577. var
  578. i : longint;
  579. begin
  580. if target_info.files_case_relevent then
  581. begin
  582. for i:=1 to length(s) do
  583. begin
  584. case s[i] of
  585. '/','\' :
  586. TargetFixFileName[i]:=target_info.dirsep;
  587. else
  588. TargetFixFileName[i]:=s[i];
  589. end;
  590. end;
  591. end
  592. else
  593. begin
  594. for i:=1 to length(s) do
  595. begin
  596. case s[i] of
  597. '/','\' :
  598. TargetFixFileName[i]:=target_info.dirsep;
  599. 'A'..'Z' :
  600. TargetFixFileName[i]:=char(byte(s[i])+32);
  601. else
  602. TargetFixFileName[i]:=s[i];
  603. end;
  604. end;
  605. end;
  606. TargetFixFileName[0]:=s[0];
  607. end;
  608. procedure SplitBinCmd(const s:string;var bstr,cstr:string);
  609. var
  610. i : longint;
  611. begin
  612. i:=pos(' ',s);
  613. if i>0 then
  614. begin
  615. bstr:=Copy(s,1,i-1);
  616. cstr:=Copy(s,i+1,length(s)-i);
  617. end
  618. else
  619. begin
  620. bstr:=s;
  621. cstr:='';
  622. end;
  623. end;
  624. procedure TSearchPathList.AddPath(s:string;addfirst:boolean);
  625. var
  626. j : longint;
  627. hs,hsd,
  628. CurrentDir,
  629. CurrPath : string;
  630. dir : searchrec;
  631. hp : TStringListItem;
  632. procedure addcurrpath;
  633. begin
  634. if addfirst then
  635. begin
  636. Remove(currPath);
  637. Insert(currPath);
  638. end
  639. else
  640. begin
  641. { Check if already in path, then we don't add it }
  642. hp:=Find(currPath);
  643. if not assigned(hp) then
  644. Concat(currPath);
  645. end;
  646. end;
  647. begin
  648. if s='' then
  649. exit;
  650. { Support default macro's }
  651. DefaultReplacements(s);
  652. { get current dir }
  653. CurrentDir:=GetCurrentDir;
  654. repeat
  655. { get currpath }
  656. if addfirst then
  657. begin
  658. j:=length(s);
  659. while (j>0) and (s[j]<>';') do
  660. dec(j);
  661. CurrPath:=FixPath(Copy(s,j+1,length(s)-j),false);
  662. if j=0 then
  663. s:=''
  664. else
  665. System.Delete(s,j,length(s)-j+1);
  666. end
  667. else
  668. begin
  669. j:=Pos(';',s);
  670. if j=0 then
  671. j:=255;
  672. CurrPath:=FixPath(Copy(s,1,j-1),false);
  673. System.Delete(s,1,j);
  674. end;
  675. { fix pathname }
  676. if CurrPath='' then
  677. CurrPath:='.'+source_info.DirSep
  678. else
  679. begin
  680. CurrPath:=FixPath(FExpand(CurrPath),false);
  681. if (CurrentDir<>'') and (Copy(CurrPath,1,length(CurrentDir))=CurrentDir) then
  682. CurrPath:='.'+source_info.DirSep+Copy(CurrPath,length(CurrentDir)+1,255);
  683. end;
  684. { wildcard adding ? }
  685. if pos('*',currpath)>0 then
  686. begin
  687. if currpath[length(currpath)]=source_info.dirsep then
  688. hs:=Copy(currpath,1,length(CurrPath)-1)
  689. else
  690. hs:=currpath;
  691. hsd:=SplitPath(hs);
  692. findfirst(hs,directory,dir);
  693. while doserror=0 do
  694. begin
  695. if (dir.name<>'.') and
  696. (dir.name<>'..') and
  697. ((dir.attr and directory)<>0) then
  698. begin
  699. currpath:=hsd+dir.name+source_info.dirsep;
  700. hp:=Find(currPath);
  701. if not assigned(hp) then
  702. AddCurrPath;
  703. end;
  704. findnext(dir);
  705. end;
  706. FindClose(dir);
  707. end
  708. else
  709. begin
  710. if PathExists(currpath) then
  711. addcurrpath;
  712. end;
  713. until (s='');
  714. end;
  715. procedure TSearchPathList.AddList(list:TSearchPathList;addfirst:boolean);
  716. var
  717. s : string;
  718. hl : TSearchPathList;
  719. hp,hp2 : TStringListItem;
  720. begin
  721. if list.empty then
  722. exit;
  723. { create temp and reverse the list }
  724. if addfirst then
  725. begin
  726. hl:=TSearchPathList.Create;
  727. hp:=TStringListItem(list.first);
  728. while assigned(hp) do
  729. begin
  730. hl.insert(hp.Str);
  731. hp:=TStringListItem(hp.next);
  732. end;
  733. while not hl.empty do
  734. begin
  735. s:=hl.GetFirst;
  736. Remove(s);
  737. Insert(s);
  738. end;
  739. hl.Free;
  740. end
  741. else
  742. begin
  743. hp:=TStringListItem(list.first);
  744. while assigned(hp) do
  745. begin
  746. hp2:=Find(hp.Str);
  747. { Check if already in path, then we don't add it }
  748. if not assigned(hp2) then
  749. Concat(hp.Str);
  750. hp:=TStringListItem(hp.next);
  751. end;
  752. end;
  753. end;
  754. function TSearchPathList.FindFile(const f : string;var foundfile:string):boolean;
  755. Var
  756. p : TStringListItem;
  757. begin
  758. FindFile:=false;
  759. p:=TStringListItem(first);
  760. while assigned(p) do
  761. begin
  762. {
  763. Search order for case sensitive systems:
  764. 1. lowercase
  765. 2. NormalCase
  766. 3. UPPERCASE
  767. None case sensitive only lowercase
  768. }
  769. FoundFile:=p.Str+Lower(f);
  770. If FileExists(FoundFile) then
  771. begin
  772. FindFile:=true;
  773. exit;
  774. end;
  775. {$ifdef UNIX}
  776. FoundFile:=p.Str+f;
  777. If FileExists(FoundFile) then
  778. begin
  779. FindFile:=true;
  780. exit;
  781. end;
  782. FoundFile:=p.Str+Upper(f);
  783. If FileExists(FoundFile) then
  784. begin
  785. FindFile:=true;
  786. exit;
  787. end;
  788. {$endif UNIX}
  789. p:=TStringListItem(p.next);
  790. end;
  791. { Return original filename if not found }
  792. FoundFile:=f;
  793. end;
  794. Function GetFileTime ( Var F : File) : Longint;
  795. Var
  796. {$ifdef unix}
  797. Info : Stat;
  798. {$endif}
  799. L : longint;
  800. begin
  801. {$ifdef unix}
  802. FStat (F,Info);
  803. L:=Info.Mtime;
  804. {$else}
  805. GetFTime(f,l);
  806. {$endif}
  807. GetFileTime:=L;
  808. end;
  809. Function GetNamedFileTime (Const F : String) : Longint;
  810. begin
  811. GetNamedFileTime:=do_getnamedfiletime(F);
  812. end;
  813. function FindFile(const f : string;path : string;var foundfile:string):boolean;
  814. Var
  815. singlepathstring : string;
  816. i : longint;
  817. begin
  818. {$ifdef Unix}
  819. for i:=1 to length(path) do
  820. if path[i]=':' then
  821. path[i]:=';';
  822. {$endif Unix}
  823. FindFile:=false;
  824. repeat
  825. i:=pos(';',path);
  826. if i=0 then
  827. i:=256;
  828. singlepathstring:=FixPath(copy(path,1,i-1),false);
  829. delete(path,1,i);
  830. {
  831. Search order for case sensitive systems:
  832. 1. lowercase
  833. 2. NormalCase
  834. 3. UPPERCASE
  835. None case sensitive only lowercase
  836. }
  837. FoundFile:=singlepathstring+Lower(f);
  838. If FileExists(FoundFile) then
  839. begin
  840. FindFile:=true;
  841. exit;
  842. end;
  843. {$ifdef UNIX}
  844. FoundFile:=singlepathstring+f;
  845. If FileExists(FoundFile) then
  846. begin
  847. FindFile:=true;
  848. exit;
  849. end;
  850. FoundFile:=singlepathstring+Upper(f);
  851. If FileExists(FoundFile) then
  852. begin
  853. FindFile:=true;
  854. exit;
  855. end;
  856. {$endif UNIX}
  857. until path='';
  858. FoundFile:=f;
  859. end;
  860. function FindExe(const bin:string;var foundfile:string):boolean;
  861. begin
  862. {$ifdef delphi}
  863. FindExe:=FindFile(FixFileName(AddExtension(bin,source_info.exeext)),'.;'+exepath+';'+dmisc.getenv('PATH'),foundfile);
  864. {$else delphi}
  865. FindExe:=FindFile(FixFileName(AddExtension(bin,source_info.exeext)),'.;'+exepath+';'+dos.getenv('PATH'),foundfile);
  866. {$endif delphi}
  867. end;
  868. function GetShortName(const n:string):string;
  869. {$ifdef win32}
  870. var
  871. hs,hs2 : string;
  872. i : longint;
  873. {$endif}
  874. {$ifdef go32v2}
  875. var
  876. hs : string;
  877. {$endif}
  878. begin
  879. GetShortName:=n;
  880. {$ifdef win32}
  881. hs:=n+#0;
  882. i:=Windows.GetShortPathName(@hs[1],@hs2[1],high(hs2));
  883. if (i>0) and (i<=high(hs2)) then
  884. begin
  885. hs2[0]:=chr(strlen(@hs2[1]));
  886. GetShortName:=hs2;
  887. end;
  888. {$endif}
  889. {$ifdef go32v2}
  890. hs:=n;
  891. if Dos.GetShortName(hs) then
  892. GetShortName:=hs;
  893. {$endif}
  894. end;
  895. {****************************************************************************
  896. OS Dependent things
  897. ****************************************************************************}
  898. function GetEnvPChar(const envname:string):pchar;
  899. {$ifdef win32}
  900. var
  901. s : string;
  902. i,len : longint;
  903. hp,p,p2 : pchar;
  904. {$endif}
  905. {$ifdef os2}
  906. var
  907. P1, P2: PChar;
  908. {$endif}
  909. begin
  910. {$ifdef unix}
  911. GetEnvPchar:={$ifdef ver1_0}Linux{$else}Unix{$endif}.Getenv(envname);
  912. {$define GETENVOK}
  913. {$endif}
  914. {$ifdef win32}
  915. GetEnvPchar:=nil;
  916. p:=GetEnvironmentStrings;
  917. hp:=p;
  918. while hp^<>#0 do
  919. begin
  920. s:=strpas(hp);
  921. i:=pos('=',s);
  922. len:=strlen(hp);
  923. if upper(copy(s,1,i-1))=upper(envname) then
  924. begin
  925. GetMem(p2,len-length(envname));
  926. Move(hp[i],p2^,len-length(envname));
  927. GetEnvPchar:=p2;
  928. break;
  929. end;
  930. { next string entry}
  931. hp:=hp+len+1;
  932. end;
  933. FreeEnvironmentStrings(p);
  934. {$define GETENVOK}
  935. {$endif}
  936. {$ifdef os2}
  937. P1 := StrPNew (EnvName);
  938. if Assigned (P1) then
  939. begin
  940. if DosCalls.DosScanEnv (P1, P2) = 0 then
  941. GetEnvPChar := P2
  942. else
  943. GetEnvPChar := nil;
  944. StrDispose (P1);
  945. end else GetEnvPChar := nil;
  946. {$define GETENVOK}
  947. {$endif}
  948. {$ifdef GETENVOK}
  949. {$undef GETENVOK}
  950. {$else}
  951. GetEnvPchar:=StrPNew({$ifdef delphi}DMisc{$else}Dos{$endif}.Getenv(envname));
  952. {$endif}
  953. end;
  954. procedure FreeEnvPChar(p:pchar);
  955. begin
  956. {$ifndef unix}
  957. {$ifndef os2}
  958. StrDispose(p);
  959. {$endif}
  960. {$endif}
  961. end;
  962. Procedure Shell(const command:string);
  963. { This is already defined in the linux.ppu for linux, need for the *
  964. expansion under linux }
  965. {$ifdef unix}
  966. begin
  967. {$ifdef ver1_0}Linux{$else}Unix{$endif}.Shell(command);
  968. end;
  969. {$else}
  970. var
  971. comspec : string;
  972. begin
  973. comspec:=getenv('COMSPEC');
  974. Exec(comspec,' /C '+command);
  975. end;
  976. {$endif}
  977. Function SetCompileMode(const s:string; changeInit: boolean):boolean;
  978. var
  979. b : boolean;
  980. begin
  981. b:=true;
  982. if s='DEFAULT' then
  983. aktmodeswitches:=initmodeswitches
  984. else
  985. if s='DELPHI' then
  986. aktmodeswitches:=delphimodeswitches
  987. else
  988. if s='TP' then
  989. aktmodeswitches:=tpmodeswitches
  990. else
  991. if s='FPC' then
  992. aktmodeswitches:=fpcmodeswitches
  993. else
  994. if s='OBJFPC' then
  995. aktmodeswitches:=objfpcmodeswitches
  996. else
  997. if s='GPC' then
  998. aktmodeswitches:=gpcmodeswitches
  999. else
  1000. b:=false;
  1001. if b and changeInit then
  1002. initmodeswitches := aktmodeswitches;
  1003. if b then
  1004. begin
  1005. { turn ansistrings on by default ? }
  1006. if (m_delphi in aktmodeswitches) then
  1007. begin
  1008. include(aktlocalswitches,cs_ansistrings);
  1009. if changeinit then
  1010. include(initlocalswitches,cs_ansistrings);
  1011. end
  1012. else
  1013. begin
  1014. exclude(aktlocalswitches,cs_ansistrings);
  1015. if changeinit then
  1016. exclude(initlocalswitches,cs_ansistrings);
  1017. end;
  1018. { enum packing }
  1019. if (m_tp7 in aktmodeswitches) then
  1020. aktpackenum:=1
  1021. else
  1022. aktpackenum:=4;
  1023. if changeinit then
  1024. initpackenum:=aktpackenum;
  1025. end;
  1026. SetCompileMode:=b;
  1027. end;
  1028. function SetAktProcCall(const s:string; changeInit:boolean):boolean;
  1029. const
  1030. DefProcCallName : array[tproccalloption] of string[12] = ('',
  1031. 'CDECL',
  1032. 'CPPDECL',
  1033. '', { compilerproc }
  1034. 'FAR16',
  1035. 'FPCCALL',
  1036. 'INLINE',
  1037. '', { internconst }
  1038. '', { internproc }
  1039. '', { palmossyscall }
  1040. 'PASCAL',
  1041. 'REGISTER',
  1042. 'SAFECALL',
  1043. 'STDCALL',
  1044. 'SYSTEM'
  1045. );
  1046. var
  1047. t : tproccalloption;
  1048. begin
  1049. SetAktProcCall:=false;
  1050. for t:=low(tproccalloption) to high(tproccalloption) do
  1051. if DefProcCallName[t]=s then
  1052. begin
  1053. AktDefProcCall:=t;
  1054. SetAktProcCall:=true;
  1055. break;
  1056. end;
  1057. if changeinit then
  1058. InitDefProcCall:=AktDefProcCall;
  1059. end;
  1060. { '('D1:'00000000-'D2:'0000-'D3:'0000-'D4:'0000-000000000000)' }
  1061. function string2guid(const s: string; var GUID: TGUID): boolean;
  1062. function ishexstr(const hs: string): boolean;
  1063. var
  1064. i: integer;
  1065. begin
  1066. ishexstr:=false;
  1067. for i:=1 to Length(hs) do begin
  1068. if not (hs[i] in ['0'..'9','A'..'F','a'..'f']) then
  1069. exit;
  1070. end;
  1071. ishexstr:=true;
  1072. end;
  1073. function hexstr2longint(const hexs: string): longint;
  1074. var
  1075. i: integer;
  1076. rl: longint;
  1077. begin
  1078. rl:=0;
  1079. for i:=1 to length(hexs) do begin
  1080. rl:=rl shl 4;
  1081. case hexs[i] of
  1082. '0'..'9' : inc(rl,ord(hexs[i])-ord('0'));
  1083. 'A'..'F' : inc(rl,ord(hexs[i])-ord('A')+10);
  1084. 'a'..'f' : inc(rl,ord(hexs[i])-ord('a')+10);
  1085. end
  1086. end;
  1087. hexstr2longint:=rl;
  1088. end;
  1089. var
  1090. i: integer;
  1091. begin
  1092. if (Length(s)=38) and (s[1]='{') and (s[38]='}') and
  1093. (s[10]='-') and (s[15]='-') and (s[20]='-') and (s[25]='-') and
  1094. ishexstr(copy(s,2,8)) and ishexstr(copy(s,11,4)) and
  1095. ishexstr(copy(s,16,4)) and ishexstr(copy(s,21,4)) and
  1096. ishexstr(copy(s,26,12)) then begin
  1097. GUID.D1:=dword(hexstr2longint(copy(s,2,8)));
  1098. GUID.D2:=hexstr2longint(copy(s,11,4));
  1099. GUID.D3:=hexstr2longint(copy(s,16,4));
  1100. for i:=0 to 1 do
  1101. GUID.D4[i]:=hexstr2longint(copy(s,21+i*2,2));
  1102. for i:=2 to 7 do
  1103. GUID.D4[i]:=hexstr2longint(copy(s,22+i*2,2));
  1104. string2guid:=true;
  1105. end
  1106. else
  1107. string2guid:=false;
  1108. end;
  1109. function guid2string(const GUID: TGUID): string;
  1110. function long2hex(l, len: longint): string;
  1111. const
  1112. hextbl: array[0..15] of char = '0123456789ABCDEF';
  1113. var
  1114. rs: string;
  1115. i: integer;
  1116. begin
  1117. rs[0]:=chr(len);
  1118. for i:=len downto 1 do begin
  1119. rs[i]:=hextbl[l and $F];
  1120. l:=l shr 4;
  1121. end;
  1122. long2hex:=rs;
  1123. end;
  1124. begin
  1125. guid2string:=
  1126. '{'+long2hex(GUID.D1,8)+
  1127. '-'+long2hex(GUID.D2,4)+
  1128. '-'+long2hex(GUID.D3,4)+
  1129. '-'+long2hex(GUID.D4[0],2)+long2hex(GUID.D4[1],2)+
  1130. '-'+long2hex(GUID.D4[2],2)+long2hex(GUID.D4[3],2)+
  1131. long2hex(GUID.D4[4],2)+long2hex(GUID.D4[5],2)+
  1132. long2hex(GUID.D4[6],2)+long2hex(GUID.D4[7],2)+
  1133. '}';
  1134. end;
  1135. procedure swap_qword(var q : qword);
  1136. begin
  1137. q:=(qword(lo(q)) shl 32) or hi(q);
  1138. end;
  1139. function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
  1140. var
  1141. tok : string;
  1142. vstr : string;
  1143. l : longint;
  1144. code : integer;
  1145. b : talignmentinfo;
  1146. begin
  1147. UpdateAlignmentStr:=true;
  1148. uppervar(s);
  1149. fillchar(b,sizeof(b),0);
  1150. repeat
  1151. tok:=GetToken(s,'=');
  1152. if tok='' then
  1153. break;
  1154. vstr:=GetToken(s,',');
  1155. val(vstr,l,code);
  1156. if tok='PROC' then
  1157. b.procalign:=l
  1158. else if tok='JUMP' then
  1159. b.jumpalign:=l
  1160. else if tok='LOOP' then
  1161. b.loopalign:=l
  1162. else if tok='CONSTMIN' then
  1163. b.constalignmin:=l
  1164. else if tok='CONSTMAX' then
  1165. b.constalignmax:=l
  1166. else if tok='VARMIN' then
  1167. b.varalignmin:=l
  1168. else if tok='VARMAX' then
  1169. b.varalignmax:=l
  1170. else if tok='LOCALMIN' then
  1171. b.localalignmin:=l
  1172. else if tok='LOCALMAX' then
  1173. b.localalignmax:=l
  1174. else if tok='RECORDMIN' then
  1175. b.recordalignmin:=l
  1176. else if tok='RECORDMAX' then
  1177. b.recordalignmax:=l
  1178. else if tok='PARAALIGN' then
  1179. b.paraalign:=l
  1180. else { Error }
  1181. UpdateAlignmentStr:=false;
  1182. until false;
  1183. UpdateAlignment(a,b);
  1184. end;
  1185. {****************************************************************************
  1186. Init
  1187. ****************************************************************************}
  1188. {$ifdef unix}
  1189. {$define need_path_search}
  1190. {$endif unix}
  1191. {$ifdef os2}
  1192. {$define need_path_search}
  1193. {$endif os2}
  1194. procedure get_exepath;
  1195. var
  1196. hs1 : namestr;
  1197. hs2 : extstr;
  1198. begin
  1199. {$ifdef delphi}
  1200. exepath:=dmisc.getenv('PPC_EXEC_PATH');
  1201. {$else delphi}
  1202. exepath:=dos.getenv('PPC_EXEC_PATH');
  1203. {$endif delphi}
  1204. if exepath='' then
  1205. fsplit(FixFileName(system.paramstr(0)),exepath,hs1,hs2);
  1206. {$ifdef need_path_search}
  1207. if exepath='' then
  1208. begin
  1209. if pos(source_info.exeext,hs1) <>
  1210. (length(hs1) - length(source_info.exeext)+1) then
  1211. hs1 := hs1 + source_info.exeext;
  1212. {$ifdef delphi}
  1213. findfile(hs1,dmisc.getenv('PATH'),exepath);
  1214. {$else delphi}
  1215. findfile(hs1,dos.getenv('PATH'),exepath);
  1216. {$endif delphi}
  1217. exepath:=SplitPath(exepath);
  1218. end;
  1219. {$endif need_path_search}
  1220. exepath:=FixPath(exepath,false);
  1221. end;
  1222. procedure DoneGlobals;
  1223. begin
  1224. initdefines.free;
  1225. if assigned(DLLImageBase) then
  1226. StringDispose(DLLImageBase);
  1227. RelocSection:=true;
  1228. RelocSectionSetExplicitly:=false;
  1229. UseDeffileForExport:=true;
  1230. librarysearchpath.Free;
  1231. unitsearchpath.Free;
  1232. objectsearchpath.Free;
  1233. includesearchpath.Free;
  1234. end;
  1235. procedure InitGlobals;
  1236. begin
  1237. get_exepath;
  1238. { reset globals }
  1239. do_build:=false;
  1240. do_release:=false;
  1241. do_make:=true;
  1242. compile_level:=0;
  1243. DLLsource:=false;
  1244. inlining_procedure:=false;
  1245. resolving_forward:=false;
  1246. in_args:=false;
  1247. make_ref:=false;
  1248. { Output }
  1249. OutputFile:='';
  1250. OutputExeDir:='';
  1251. OutputUnitDir:='';
  1252. { Utils directory }
  1253. utilsdirectory:='';
  1254. { Search Paths }
  1255. librarysearchpath:=TSearchPathList.Create;
  1256. unitsearchpath:=TSearchPathList.Create;
  1257. includesearchpath:=TSearchPathList.Create;
  1258. objectsearchpath:=TSearchPathList.Create;
  1259. { Def file }
  1260. usewindowapi:=false;
  1261. description:='Compiled by FPC '+version_string+' - '+target_cpu_string;
  1262. dllversion:='';
  1263. nwscreenname := '';
  1264. nwthreadname := '';
  1265. nwcopyright := '';
  1266. { Init values }
  1267. initmodeswitches:=fpcmodeswitches;
  1268. initlocalswitches:=[cs_check_io,cs_typed_const_writable];
  1269. initmoduleswitches:=[cs_extsyntax,cs_browser];
  1270. initglobalswitches:=[cs_check_unit_name,cs_link_static{$ifdef INTERNALLINKER},cs_link_internal,cs_link_map{$endif}];
  1271. initoutputformat:=target_asm.id;
  1272. fillchar(initalignment,sizeof(talignmentinfo),0);
  1273. {$ifdef i386}
  1274. initoptprocessor:=Class386;
  1275. initspecificoptprocessor:=Class386;
  1276. initpackenum:=4;
  1277. {$IFDEF testvarsets}
  1278. initsetalloc:=0;
  1279. {$ENDIF}
  1280. initasmmode:=asmmode_i386_att;
  1281. {$else not i386}
  1282. {$ifdef m68k}
  1283. initoptprocessor:=MC68000;
  1284. include(initmoduleswitches,cs_fp_emulation);
  1285. initpackenum:=4;
  1286. {$IFDEF testvarsets}
  1287. initsetalloc:=0;
  1288. {$ENDIF}
  1289. initasmmode:=asmmode_m68k_mot;
  1290. {$endif m68k}
  1291. {$endif i386}
  1292. initinterfacetype:=it_interfacecom;
  1293. initdefproccall:=pocall_none;
  1294. initdefines:=TStringList.Create;
  1295. { memory sizes, will be overriden by parameter or default for target
  1296. in options or init_parser }
  1297. stacksize:=0;
  1298. heapsize:=0;
  1299. { compile state }
  1300. in_args:=false;
  1301. { must_be_valid:=true; obsolete PM }
  1302. not_unit_proc:=true;
  1303. apptype:=app_cui;
  1304. have_local_threadvars := false;
  1305. end;
  1306. {$ifdef EXTDEBUG}
  1307. begin
  1308. {$ifdef FPC}
  1309. EntryMemUsed:=system.HeapSize-MemAvail;
  1310. {$endif FPC}
  1311. {$endif}
  1312. end.
  1313. {
  1314. $Log$
  1315. Revision 1.60 2002-07-01 18:46:22 peter
  1316. * internal linker
  1317. * reorganized aasm layer
  1318. Revision 1.59 2002/07/01 16:23:52 peter
  1319. * cg64 patch
  1320. * basics for currency
  1321. * asnode updates for class and interface (not finished)
  1322. Revision 1.58 2002/05/18 13:34:08 peter
  1323. * readded missing revisions
  1324. Revision 1.57 2002/05/16 19:46:36 carl
  1325. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  1326. + try to fix temp allocation (still in ifdef)
  1327. + generic constructor calls
  1328. + start of tassembler / tmodulebase class cleanup
  1329. Revision 1.55 2002/04/20 21:32:23 carl
  1330. + generic FPC_CHECKPOINTER
  1331. + first parameter offset in stack now portable
  1332. * rename some constants
  1333. + move some cpu stuff to other units
  1334. - remove unused constents
  1335. * fix stacksize for some targets
  1336. * fix generic size problems which depend now on EXTEND_SIZE constant
  1337. Revision 1.54 2002/04/07 13:24:30 carl
  1338. + moved constant from cpuinfo, these are NOT cpu specific
  1339. constant, but more related to compiler functionality.
  1340. Revision 1.53 2002/04/02 17:11:28 peter
  1341. * tlocation,treference update
  1342. * LOC_CONSTANT added for better constant handling
  1343. * secondadd splitted in multiple routines
  1344. * location_force_reg added for loading a location to a register
  1345. of a specified size
  1346. * secondassignment parses now first the right and then the left node
  1347. (this is compatible with Kylix). This saves a lot of push/pop especially
  1348. with string operations
  1349. * adapted some routines to use the new cg methods
  1350. Revision 1.52 2002/03/28 16:07:52 armin
  1351. + initialize threadvars defined local in units
  1352. Revision 1.51 2002/01/24 18:25:48 peter
  1353. * implicit result variable generation for assembler routines
  1354. * removed m_tp modeswitch, use m_tp7 or not(m_fpc) instead
  1355. }