globals.pas 44 KB

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