globals.pas 41 KB

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