globals.pas 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585
  1. {
  2. $Id$
  3. Copyright (C) 1998-2000 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. {$ifdef tp}
  19. {$E+,N+}
  20. {$endif}
  21. unit globals;
  22. interface
  23. uses
  24. {$ifdef win32}
  25. windows,
  26. {$endif}
  27. {$ifdef linux}
  28. linux,
  29. {$endif}
  30. {$ifdef Delphi}
  31. sysutils,
  32. dmisc,
  33. {$else}
  34. strings,dos,
  35. {$endif}
  36. {$ifdef TP}
  37. objects,
  38. {$endif}
  39. globtype,version,tokens,systems,cobjects;
  40. const
  41. {$ifdef linux}
  42. DirSep = '/';
  43. {$else}
  44. {$ifdef amiga}
  45. DirSep = '/';
  46. {$else}
  47. DirSep = '\';
  48. {$endif}
  49. {$endif}
  50. {$ifdef Splitheap}
  51. testsplit : boolean = false;
  52. {$endif Splitheap}
  53. delphimodeswitches : tmodeswitches=
  54. [m_delphi,m_tp,m_all,m_class,m_objpas,m_result,m_string_pchar,
  55. m_pointer_2_procedure,m_autoderef,m_tp_procvar,m_initfinal,m_default_ansistring,
  56. m_out,m_default_para];
  57. fpcmodeswitches : tmodeswitches=
  58. [m_fpc,m_all,m_string_pchar,m_nested_comment,m_repeat_forward,
  59. m_cvar_support,m_initfinal,m_add_pointer];
  60. objfpcmodeswitches : tmodeswitches=
  61. [m_objfpc,m_fpc,m_all,m_class,m_objpas,m_result,m_string_pchar,m_nested_comment,
  62. m_repeat_forward,m_cvar_support,m_initfinal,m_add_pointer,m_out,m_default_para];
  63. tpmodeswitches : tmodeswitches=
  64. [m_tp7,m_tp,m_all,m_tp_procvar];
  65. gpcmodeswitches : tmodeswitches=
  66. [m_gpc,m_all];
  67. type
  68. TSearchPathList = object(TStringQueue)
  69. procedure AddPath(s:string;addfirst:boolean);
  70. procedure AddList(list:TSearchPathList;addfirst:boolean);
  71. function FindFile(const f : string;var b : boolean) : string;
  72. end;
  73. var
  74. { specified inputfile }
  75. inputdir : dirstr;
  76. inputfile : namestr;
  77. inputextension : extstr;
  78. { specified outputfile with -o parameter }
  79. outputfile : namestr;
  80. { specified with -FE or -FU }
  81. outputexedir : dirstr;
  82. outputunitdir : dirstr;
  83. { things specified with parameters }
  84. paralinkoptions,
  85. paradynamiclinker : string;
  86. parapreprocess : boolean;
  87. { directory where the utils can be found (options -FD) }
  88. utilsdirectory : dirstr;
  89. { some flags for global compiler switches }
  90. do_build,
  91. do_make : boolean;
  92. not_unit_proc : boolean;
  93. { path for searching units, different paths can be seperated by ; }
  94. exepath : dirstr; { Path to ppc }
  95. librarysearchpath,
  96. unitsearchpath,
  97. objectsearchpath,
  98. includesearchpath : TSearchPathList;
  99. { deffile }
  100. usewindowapi : boolean;
  101. description : string;
  102. dllversion : string;
  103. dllmajor,dllminor : word;
  104. { current position }
  105. token, { current token being parsed }
  106. idtoken : ttoken; { holds the token if the pattern is a known word }
  107. tokenpos, { last postion of the read token }
  108. aktfilepos : tfileposinfo; { current position }
  109. { type of currently parsed block }
  110. { isn't full implemented (FK) }
  111. block_type : tblock_type;
  112. in_args : boolean; { arguments must be checked especially }
  113. parsing_para_level : longint; { parameter level, used to convert
  114. proc calls to proc loads in firstcalln }
  115. { Must_be_valid : boolean; should the variable already have a value
  116. obsolete replace by set_varstate function }
  117. compile_level : word;
  118. make_ref : boolean;
  119. resolving_forward : boolean; { used to add forward reference as second ref }
  120. use_esp_stackframe : boolean; { to test for call with ESP as stack frame }
  121. inlining_procedure : boolean; { are we inlining a procedure }
  122. {$ifdef TP}
  123. use_big : boolean;
  124. {$endif}
  125. { commandline values }
  126. initdefines : tlinkedlist;
  127. initglobalswitches : tglobalswitches;
  128. initmoduleswitches : tmoduleswitches;
  129. initlocalswitches : tlocalswitches;
  130. initmodeswitches : tmodeswitches;
  131. {$IFDEF testvarsets}
  132. Initsetalloc, {0=fixed, 1 =var}
  133. {$ENDIF}
  134. initpackenum : longint;
  135. initpackrecords : tpackrecords;
  136. initoutputformat : tasm;
  137. initoptprocessor,
  138. initspecificoptprocessor : tprocessors;
  139. initasmmode : tasmmode;
  140. { current state values }
  141. aktglobalswitches : tglobalswitches;
  142. aktmoduleswitches : tmoduleswitches;
  143. aktlocalswitches : tlocalswitches;
  144. nextaktlocalswitches : tlocalswitches;
  145. localswitcheschanged : boolean;
  146. aktmodeswitches : tmodeswitches;
  147. {$IFDEF testvarsets}
  148. aktsetalloc,
  149. {$ENDIF}
  150. aktpackenum : longint;
  151. aktmaxfpuregisters: longint;
  152. aktpackrecords : tpackrecords;
  153. aktoutputformat : tasm;
  154. aktoptprocessor,
  155. aktspecificoptprocessor : tprocessors;
  156. aktasmmode : tasmmode;
  157. { Memory sizes }
  158. heapsize,
  159. maxheapsize,
  160. stacksize : longint;
  161. {$Ifdef EXTDEBUG}
  162. total_of_firstpass,
  163. firstpass_several : longint;
  164. {$ifdef FPC}
  165. EntryMemUsed : longint;
  166. {$endif FPC}
  167. { parameter switches }
  168. debugstop,
  169. only_one_pass : boolean;
  170. {$EndIf EXTDEBUG}
  171. { windows application type }
  172. apptype : tapptype;
  173. const
  174. RelocSection : boolean = true;
  175. RelocSectionSetExplicitly : boolean = false;
  176. LinkTypeSetExplicitly : boolean = false;
  177. DLLsource : boolean = false;
  178. DLLImageBase : pstring = nil;
  179. UseDeffileForExport : boolean = true;
  180. ForceDeffileForExport : boolean = false;
  181. { used to set all registers used for each global function
  182. this should dramatically decrease the number of
  183. recompilations needed PM }
  184. simplify_ppu : boolean = false;
  185. { should we allow non static members ? }
  186. allow_only_static : boolean = false;
  187. Inside_asm_statement : boolean = false;
  188. { for error info in pp.pas }
  189. const
  190. parser_current_file : string = '';
  191. {$ifdef debug}
  192. { if the pointer don't point to the heap then write an error }
  193. function assigned(p : pointer) : boolean;
  194. {$endif}
  195. function min(a,b : longint) : longint;
  196. function max(a,b : longint) : longint;
  197. function align(i,a:longint):longint;
  198. function align_from_size(datasize:longint;length:longint):longint;
  199. procedure Replace(var s:string;s1:string;const s2:string);
  200. procedure ReplaceCase(var s:string;const s1,s2:string);
  201. function upper(const s : string) : string;
  202. function lower(const s : string) : string;
  203. function trimspace(const s:string):string;
  204. {$ifdef FPC}
  205. function tostru(i:cardinal) : string;
  206. {$else}
  207. function tostru(i:longint) : string;
  208. {$endif}
  209. procedure uppervar(var s : string);
  210. function hexstr(val : longint;cnt : byte) : string;
  211. function tostr(i : longint) : string;
  212. function tostr_with_plus(i : longint) : string;
  213. procedure valint(S : string;var V : longint;var code : integer);
  214. function is_number(const s : string) : boolean;
  215. function ispowerof2(value : longint;var power : longint) : boolean;
  216. { enable ansistring comparison }
  217. function compareansistrings(p1,p2 : pchar;length1,length2 : longint) : longint;
  218. function concatansistrings(p1,p2 : pchar;length1,length2 : longint) : pchar;
  219. function bstoslash(const s : string) : string;
  220. procedure abstract;
  221. function getdatestr:string;
  222. function gettimestr:string;
  223. function filetimestring( t : longint) : string;
  224. procedure DefaultReplacements(var s:string);
  225. function GetCurrentDir:string;
  226. function path_absolute(const s : string) : boolean;
  227. Function PathExists ( F : String) : Boolean;
  228. Function FileExists ( Const F : String) : Boolean;
  229. Function RemoveFile(const f:string):boolean;
  230. Function RemoveDir(d:string):boolean;
  231. Function GetFileTime ( Var F : File) : Longint;
  232. Function GetNamedFileTime ( Const F : String) : Longint;
  233. Function SplitPath(const s:string):string;
  234. Function SplitFileName(const s:string):string;
  235. Function SplitName(const s:string):string;
  236. Function SplitExtension(Const HStr:String):String;
  237. Function AddExtension(Const HStr,ext:String):String;
  238. Function ForceExtension(Const HStr,ext:String):String;
  239. Function FixPath(s:string;allowdot:boolean):string;
  240. function FixFileName(const s:string):string;
  241. procedure SplitBinCmd(const s:string;var bstr,cstr:string);
  242. procedure SynchronizeFileTime(const fn1,fn2:string);
  243. function FindFile(const f : string;path : string;var b : boolean) : string;
  244. function FindExe(bin:string;var found:boolean):string;
  245. function GetShortName(const n:string):string;
  246. Procedure Shell(const command:string);
  247. function GetEnvPChar(const envname:string):pchar;
  248. procedure FreeEnvPChar(p:pchar);
  249. procedure InitGlobals;
  250. procedure DoneGlobals;
  251. implementation
  252. uses
  253. comphook;
  254. procedure abstract;
  255. begin
  256. do_internalerror(255);
  257. end;
  258. function ngraphsearchvalue(const s1,s2 : string) : double;
  259. const
  260. n = 3;
  261. var
  262. equals,i,j : longint;
  263. hs : string;
  264. begin
  265. equals:=0;
  266. { is the string long enough ? }
  267. if min(length(s1),length(s2))-n+1<1 then
  268. begin
  269. ngraphsearchvalue:=0.0;
  270. exit;
  271. end;
  272. for i:=1 to length(s1)-n+1 do
  273. begin
  274. hs:=copy(s1,i,n);
  275. for j:=1 to length(s2)-n+1 do
  276. if hs=copy(s2,j,n) then
  277. inc(equals);
  278. end;
  279. {$ifdef fpc}
  280. ngraphsearchvalue:=equals/double(max(length(s1),length(s2))-n+1);
  281. {$else}
  282. ngraphsearchvalue:=equals/(max(length(s1),length(s2))-n+1);
  283. {$endif}
  284. end;
  285. function bstoslash(const s : string) : string;
  286. {
  287. return string s with all \ changed into /
  288. }
  289. var
  290. i : longint;
  291. begin
  292. for i:=1to length(s) do
  293. if s[i]='\' then
  294. bstoslash[i]:='/'
  295. else
  296. bstoslash[i]:=s[i];
  297. {$ifndef TP}
  298. {$ifopt H+}
  299. setlength(bstoslash,length(s));
  300. {$else}
  301. bstoslash[0]:=s[0];
  302. {$endif}
  303. {$else}
  304. bstoslash[0]:=s[0];
  305. {$endif}
  306. end;
  307. {$ifdef debug}
  308. function assigned(p : pointer) : boolean;
  309. {$ifndef FPC}
  310. {$ifndef DPMI}
  311. type
  312. ptrrec = record
  313. ofs,seg : word;
  314. end;
  315. var
  316. lp : longint;
  317. {$endif DPMI}
  318. {$endif FPC}
  319. begin
  320. {$ifdef FPC}
  321. { Assigned is used for procvar and
  322. stack stored temp records !! PM }
  323. (* if (p<>nil) {and
  324. ((p<heaporg) or
  325. (p>heapptr))} then
  326. do_internalerror(230); *)
  327. {$else}
  328. {$ifdef DPMI}
  329. assigned:=(p<>nil);
  330. exit;
  331. {$else DPMI}
  332. if p=nil then
  333. lp:=0
  334. else
  335. lp:=longint(ptrrec(p).seg)*16+longint(ptrrec(p).ofs);
  336. if (lp<>0) and
  337. ((lp<longint(seg(heaporg^))*16+longint(ofs(heaporg^))) or
  338. (lp>longint(seg(heapptr^))*16+longint(ofs(heapptr^)))) then
  339. do_internalerror(230);
  340. {$endif DPMI}
  341. {$endif FPC}
  342. assigned:=(p<>nil);
  343. end;
  344. {$endif}
  345. function min(a,b : longint) : longint;
  346. {
  347. return the minimal of a and b
  348. }
  349. begin
  350. if a>b then
  351. min:=b
  352. else
  353. min:=a;
  354. end;
  355. function max(a,b : longint) : longint;
  356. {
  357. return the maximum of a and b
  358. }
  359. begin
  360. if a<b then
  361. max:=b
  362. else
  363. max:=a;
  364. end;
  365. function align_from_size(datasize:longint;length:longint):longint;
  366. {Increases the datasize with the required alignment; i.e. on pentium
  367. words should be aligned word; and dwords should be aligned dword.
  368. So for a word (len=2), datasize is increased to the nearest multiple
  369. of 2, and for len=4, datasize is increased to the nearest multiple of
  370. 4.}
  371. var data_align:word;
  372. begin
  373. {$IFDEF I386}
  374. if length>2 then
  375. data_align:=4
  376. else if length>1 then
  377. data_align:=2
  378. else
  379. data_align:=1;
  380. {$ENDIF}
  381. {$IFDEF M68K}
  382. data_align:=2;
  383. {$ENDIF}
  384. align_from_size:=(datasize+data_align-1) and not(data_align-1);
  385. end;
  386. function align(i,a:longint):longint;
  387. {
  388. return value <i> aligned <a> boundary
  389. }
  390. begin
  391. { for 0 and 1 no aligning is needed }
  392. if a<=1 then
  393. align:=i
  394. else
  395. align:=(i+a-1) and not(a-1);
  396. end;
  397. procedure Replace(var s:string;s1:string;const s2:string);
  398. var
  399. last,
  400. i : longint;
  401. begin
  402. s1:=upper(s1);
  403. last:=0;
  404. repeat
  405. i:=pos(s1,upper(s));
  406. if i=last then
  407. i:=0;
  408. if (i>0) then
  409. begin
  410. Delete(s,i,length(s1));
  411. Insert(s2,s,i);
  412. last:=i;
  413. end;
  414. until (i=0);
  415. end;
  416. procedure ReplaceCase(var s:string;const s1,s2:string);
  417. var
  418. last,
  419. i : longint;
  420. begin
  421. last:=0;
  422. repeat
  423. i:=pos(s1,s);
  424. if i=last then
  425. i:=0;
  426. if (i>0) then
  427. begin
  428. Delete(s,i,length(s1));
  429. Insert(s2,s,i);
  430. last:=i;
  431. end;
  432. until (i=0);
  433. end;
  434. function upper(const s : string) : string;
  435. {
  436. return uppercased string of s
  437. }
  438. var
  439. i : longint;
  440. begin
  441. for i:=1 to length(s) do
  442. if s[i] in ['a'..'z'] then
  443. upper[i]:=char(byte(s[i])-32)
  444. else
  445. upper[i]:=s[i];
  446. upper[0]:=s[0];
  447. end;
  448. function lower(const s : string) : string;
  449. {
  450. return lowercased string of s
  451. }
  452. var
  453. i : longint;
  454. begin
  455. for i:=1 to length(s) do
  456. if s[i] in ['A'..'Z'] then
  457. lower[i]:=char(byte(s[i])+32)
  458. else
  459. lower[i]:=s[i];
  460. lower[0]:=s[0];
  461. end;
  462. procedure uppervar(var s : string);
  463. {
  464. uppercase string s
  465. }
  466. var
  467. i : longint;
  468. begin
  469. for i:=1 to length(s) do
  470. if s[i] in ['a'..'z'] then
  471. s[i]:=char(byte(s[i])-32);
  472. end;
  473. function hexstr(val : longint;cnt : byte) : string;
  474. const
  475. HexTbl : array[0..15] of char='0123456789ABCDEF';
  476. var
  477. i : longint;
  478. begin
  479. hexstr[0]:=char(cnt);
  480. for i:=cnt downto 1 do
  481. begin
  482. hexstr[i]:=hextbl[val and $f];
  483. val:=val shr 4;
  484. end;
  485. end;
  486. {$ifdef FPC}
  487. function tostru(i:cardinal):string;
  488. {
  489. return string of value i, but for cardinals
  490. }
  491. var
  492. hs : string;
  493. begin
  494. str(i,hs);
  495. tostru:=hs;
  496. end;
  497. {$else FPC}
  498. function tostru(i:longint):string;
  499. begin
  500. tostru:=tostr(i);
  501. end;
  502. {$endif FPC}
  503. function trimspace(const s:string):string;
  504. {
  505. return s with all leading and ending spaces and tabs removed
  506. }
  507. var
  508. i,j : longint;
  509. begin
  510. i:=length(s);
  511. while (i>0) and (s[i] in [#9,' ']) do
  512. dec(i);
  513. j:=1;
  514. while (j<i) and (s[j] in [#9,' ']) do
  515. inc(j);
  516. trimspace:=Copy(s,j,i-j+1);
  517. end;
  518. function tostr(i : longint) : string;
  519. {
  520. return string of value i
  521. }
  522. var
  523. hs : string;
  524. begin
  525. str(i,hs);
  526. tostr:=hs;
  527. end;
  528. function tostr_with_plus(i : longint) : string;
  529. {
  530. return string of value i, but always include a + when i>=0
  531. }
  532. var
  533. hs : string;
  534. begin
  535. str(i,hs);
  536. if i>=0 then
  537. tostr_with_plus:='+'+hs
  538. else
  539. tostr_with_plus:=hs;
  540. end;
  541. procedure valint(S : string;var V : longint;var code : integer);
  542. {
  543. val() with support for octal, which is not supported under tp7
  544. }
  545. {$ifndef FPC}
  546. var
  547. vs : longint;
  548. c : byte;
  549. begin
  550. if s[1]='%' then
  551. begin
  552. vs:=0;
  553. longint(v):=0;
  554. for c:=2 to length(s) do
  555. begin
  556. if s[c]='0' then
  557. vs:=vs shl 1
  558. else
  559. if s[c]='1' then
  560. vs:=vs shl 1+1
  561. else
  562. begin
  563. code:=c;
  564. exit;
  565. end;
  566. end;
  567. code:=0;
  568. longint(v):=vs;
  569. end
  570. else
  571. system.val(S,V,code);
  572. end;
  573. {$else not FPC}
  574. begin
  575. system.val(S,V,code);
  576. end;
  577. {$endif not FPC}
  578. function is_number(const s : string) : boolean;
  579. {
  580. is string a correct number ?
  581. }
  582. var
  583. w : integer;
  584. l : longint;
  585. begin
  586. valint(s,l,w);
  587. is_number:=(w=0);
  588. end;
  589. function ispowerof2(value : longint;var power : longint) : boolean;
  590. {
  591. return if value is a power of 2. And if correct return the power
  592. }
  593. var
  594. hl : longint;
  595. i : longint;
  596. begin
  597. hl:=1;
  598. ispowerof2:=true;
  599. for i:=0 to 31 do
  600. begin
  601. if hl=value then
  602. begin
  603. power:=i;
  604. exit;
  605. end;
  606. hl:=hl shl 1;
  607. end;
  608. ispowerof2:=false;
  609. end;
  610. { enable ansistring comparison }
  611. { 0 means equal }
  612. { 1 means p1 > p2 }
  613. { -1 means p1 < p2 }
  614. function compareansistrings(p1,p2 : pchar;length1,length2 : longint) : longint;
  615. var
  616. i,j : longint;
  617. begin
  618. compareansistrings:=0;
  619. j:=min(length1,length2);
  620. i:=0;
  621. while (i<j) do
  622. begin
  623. if p1[i]>p2[i] then
  624. begin
  625. compareansistrings:=1;
  626. exit;
  627. end
  628. else
  629. if p1[i]<p2[i] then
  630. begin
  631. compareansistrings:=-1;
  632. exit;
  633. end;
  634. inc(i);
  635. end;
  636. if length1>length2 then
  637. compareansistrings:=1
  638. else
  639. if length1<length2 then
  640. compareansistrings:=-1;
  641. end;
  642. function concatansistrings(p1,p2 : pchar;length1,length2 : longint) : pchar;
  643. var
  644. p : pchar;
  645. begin
  646. getmem(p,length1+length2+1);
  647. move(p1[0],p[0],length1);
  648. move(p2[0],p[length1],length2+1);
  649. concatansistrings:=p;
  650. end;
  651. {****************************************************************************
  652. Time Handling
  653. ****************************************************************************}
  654. Function L0(l:longint):string;
  655. {
  656. return the string of value l, if l<10 then insert a zero, so
  657. the string is always at least 2 chars '01','02',etc
  658. }
  659. var
  660. s : string;
  661. begin
  662. Str(l,s);
  663. if l<10 then
  664. s:='0'+s;
  665. L0:=s;
  666. end;
  667. function gettimestr:string;
  668. {
  669. get the current time in a string HH:MM:SS
  670. }
  671. var
  672. hour,min,sec,hsec : word;
  673. begin
  674. {$ifdef delphi}
  675. dmisc.gettime(hour,min,sec,hsec);
  676. {$else delphi}
  677. dos.gettime(hour,min,sec,hsec);
  678. {$endif delphi}
  679. gettimestr:=L0(Hour)+':'+L0(min)+':'+L0(sec);
  680. end;
  681. function getdatestr:string;
  682. {
  683. get the current date in a string YY/MM/DD
  684. }
  685. var
  686. Year,Month,Day,Wday : Word;
  687. begin
  688. {$ifdef delphi}
  689. dmisc.getdate(year,month,day,wday);
  690. {$else}
  691. dos.getdate(year,month,day,wday);
  692. {$endif}
  693. getdatestr:=L0(Year)+'/'+L0(Month)+'/'+L0(Day);
  694. end;
  695. function filetimestring( t : longint) : string;
  696. {
  697. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  698. }
  699. var
  700. {$ifndef linux}
  701. DT : DateTime;
  702. {$endif}
  703. Year,Month,Day,Hour,Min,Sec : Word;
  704. begin
  705. if t=-1 then
  706. begin
  707. FileTimeString:='Not Found';
  708. exit;
  709. end;
  710. {$ifndef linux}
  711. unpacktime(t,DT);
  712. Year:=dT.year;month:=dt.month;day:=dt.day;
  713. Hour:=dt.hour;min:=dt.min;sec:=dt.sec;
  714. {$else}
  715. EpochToLocal (t,year,month,day,hour,min,sec);
  716. {$endif}
  717. filetimestring:=L0(Year)+'/'+L0(Month)+'/'+L0(Day)+' '+L0(Hour)+':'+L0(min)+':'+L0(sec);
  718. end;
  719. {****************************************************************************
  720. Default Macro Handling
  721. ****************************************************************************}
  722. procedure DefaultReplacements(var s:string);
  723. begin
  724. { Replace some macro's }
  725. Replace(s,'$FPCVER',version_string);
  726. Replace(s,'$VERSION',version_string);
  727. Replace(s,'$FULLVERSION',full_version_string);
  728. Replace(s,'$FPCDATE',date_string);
  729. Replace(s,'$FPCTARGET',target_cpu_string);
  730. Replace(s,'$FPCCPU',target_cpu_string);
  731. Replace(s,'$TARGET',target_path);
  732. Replace(s,'$FPCOS',target_path);
  733. end;
  734. {****************************************************************************
  735. File Handling
  736. ****************************************************************************}
  737. function GetCurrentDir:string;
  738. var
  739. CurrentDir : string;
  740. begin
  741. GetDir(0,CurrentDir);
  742. GetCurrentDir:=FixPath(CurrentDir,false);
  743. end;
  744. function path_absolute(const s : string) : boolean;
  745. {
  746. is path s an absolute path?
  747. }
  748. begin
  749. path_absolute:=false;
  750. {$ifdef linux}
  751. if (length(s)>0) and (s[1]='/') then
  752. path_absolute:=true;
  753. {$else linux}
  754. {$ifdef amiga}
  755. if ((length(s)>0) and ((s[1]='\') or (s[1]='/'))) or (Pos(':',s) = length(s)) then
  756. path_absolute:=true;
  757. {$else}
  758. if ((length(s)>0) and ((s[1]='\') or (s[1]='/'))) or
  759. ((length(s)>2) and (s[2]=':') and ((s[3]='\') or (s[3]='/'))) then
  760. path_absolute:=true;
  761. {$endif amiga}
  762. {$endif linux}
  763. end;
  764. {$ifndef FPC}
  765. Procedure FindClose(var Info : SearchRec);
  766. Begin
  767. End;
  768. {$endif not FPC}
  769. Function FileExists ( Const F : String) : Boolean;
  770. {$ifndef delphi}
  771. Var
  772. Info : SearchRec;
  773. {$endif}
  774. begin
  775. {$ifdef delphi}
  776. FileExists:=sysutils.FileExists(f);
  777. {$else}
  778. findfirst(F,readonly+archive+hidden,info);
  779. FileExists:=(doserror=0);
  780. findclose(Info);
  781. {$endif delphi}
  782. end;
  783. Function PathExists ( F : String) : Boolean;
  784. Var
  785. Info : SearchRec;
  786. begin
  787. if F[Length(f)] in ['/','\'] then
  788. Delete(f,length(f),1);
  789. findfirst(F,readonly+archive+hidden+directory,info);
  790. PathExists:=(doserror=0) and ((info.attr and directory)=directory);
  791. findclose(Info);
  792. end;
  793. Function RemoveFile(const f:string):boolean;
  794. var
  795. g : file;
  796. begin
  797. assign(g,f);
  798. {$I-}
  799. erase(g);
  800. {$I+}
  801. RemoveFile:=(ioresult=0);
  802. end;
  803. Function RemoveDir(d:string):boolean;
  804. begin
  805. if d[length(d)]=DirSep then
  806. Delete(d,length(d),1);
  807. {$I-}
  808. rmdir(d);
  809. {$I+}
  810. RemoveDir:=(ioresult=0);
  811. end;
  812. Function SplitPath(const s:string):string;
  813. var
  814. i : longint;
  815. begin
  816. i:=Length(s);
  817. while (i>0) and not(s[i] in ['/','\']) do
  818. dec(i);
  819. SplitPath:=Copy(s,1,i);
  820. end;
  821. Function SplitFileName(const s:string):string;
  822. var
  823. p : dirstr;
  824. n : namestr;
  825. e : extstr;
  826. begin
  827. FSplit(s,p,n,e);
  828. SplitFileName:=n+e;
  829. end;
  830. Function SplitName(const s:string):string;
  831. var
  832. i,j : longint;
  833. begin
  834. i:=Length(s);
  835. j:=Length(s);
  836. while (i>0) and not(s[i] in ['/','\']) do
  837. dec(i);
  838. while (j>0) and (s[j]<>'.') do
  839. dec(j);
  840. if j<=i then
  841. j:=255;
  842. SplitName:=Copy(s,i+1,j-(i+1));
  843. end;
  844. Function SplitExtension(Const HStr:String):String;
  845. var
  846. j : longint;
  847. begin
  848. j:=length(Hstr);
  849. while (j>0) and (Hstr[j]<>'.') do
  850. begin
  851. if hstr[j]=DirSep then
  852. j:=0
  853. else
  854. dec(j);
  855. end;
  856. if j=0 then
  857. j:=254;
  858. SplitExtension:=Copy(Hstr,j,255);
  859. end;
  860. Function AddExtension(Const HStr,ext:String):String;
  861. begin
  862. if (Ext<>'') and (SplitExtension(HStr)='') then
  863. AddExtension:=Hstr+Ext
  864. else
  865. AddExtension:=Hstr;
  866. end;
  867. Function ForceExtension(Const HStr,ext:String):String;
  868. var
  869. j : longint;
  870. begin
  871. j:=length(Hstr);
  872. while (j>0) and (Hstr[j]<>'.') do
  873. dec(j);
  874. if j=0 then
  875. j:=255;
  876. ForceExtension:=Copy(Hstr,1,j-1)+Ext;
  877. end;
  878. Function FixPath(s:string;allowdot:boolean):string;
  879. var
  880. i : longint;
  881. begin
  882. { Fix separator }
  883. for i:=1 to length(s) do
  884. if s[i] in ['/','\'] then
  885. s[i]:=DirSep;
  886. { Fix ending / }
  887. if (length(s)>0) and (s[length(s)]<>DirSep) and
  888. (s[length(s)]<>':') then
  889. s:=s+DirSep;
  890. { Remove ./ }
  891. if (not allowdot) and (s='.'+DirSep) then
  892. s:='';
  893. { return }
  894. {$ifdef linux}
  895. FixPath:=s;
  896. {$else}
  897. FixPath:=Lower(s);
  898. {$endif}
  899. end;
  900. function FixFileName(const s:string):string;
  901. var
  902. i : longint;
  903. {$ifdef Linux}
  904. NoPath : boolean;
  905. {$endif Linux}
  906. begin
  907. {$ifdef Linux}
  908. NoPath:=true;
  909. {$endif Linux}
  910. for i:=length(s) downto 1 do
  911. begin
  912. case s[i] of
  913. {$ifdef Linux}
  914. '/','\' : begin
  915. FixFileName[i]:='/';
  916. NoPath:=false; {Skip lowercasing path: 'X11'<>'x11' }
  917. end;
  918. 'A'..'Z' : if NoPath then
  919. FixFileName[i]:=char(byte(s[i])+32)
  920. else
  921. FixFileName[i]:=s[i];
  922. {$else}
  923. '/' : FixFileName[i]:='\';
  924. 'A'..'Z' : FixFileName[i]:=char(byte(s[i])+32);
  925. {$endif}
  926. else
  927. FixFileName[i]:=s[i];
  928. end;
  929. end;
  930. {$ifndef TP}
  931. {$ifopt H+}
  932. SetLength(FixFileName,length(s));
  933. {$else}
  934. FixFileName[0]:=s[0];
  935. {$endif}
  936. {$else}
  937. FixFileName[0]:=s[0];
  938. {$endif}
  939. end;
  940. procedure SplitBinCmd(const s:string;var bstr,cstr:string);
  941. var
  942. i : longint;
  943. begin
  944. i:=pos(' ',s);
  945. if i>0 then
  946. begin
  947. bstr:=Copy(s,1,i-1);
  948. cstr:=Copy(s,i+1,length(s)-i);
  949. end
  950. else
  951. begin
  952. bstr:='';
  953. cstr:='';
  954. end;
  955. end;
  956. procedure TSearchPathList.AddPath(s:string;addfirst:boolean);
  957. var
  958. j : longint;
  959. hs,hsd,
  960. CurrentDir,
  961. CurrPath : string;
  962. dir : searchrec;
  963. {$IFDEF NEWST}
  964. hp : PStringItem;
  965. {$ELSE}
  966. hp : PStringQueueItem;
  967. {$ENDIF}
  968. procedure addcurrpath;
  969. begin
  970. if addfirst then
  971. begin
  972. Delete(currPath);
  973. Insert(currPath);
  974. end
  975. else
  976. begin
  977. { Check if already in path, then we don't add it }
  978. hp:=Find(currPath);
  979. if not assigned(hp) then
  980. Concat(currPath);
  981. end;
  982. end;
  983. begin
  984. if s='' then
  985. exit;
  986. { Support default macro's }
  987. DefaultReplacements(s);
  988. { get current dir }
  989. CurrentDir:=GetCurrentDir;
  990. repeat
  991. { get currpath }
  992. if addfirst then
  993. begin
  994. j:=length(s);
  995. while (j>0) and (s[j]<>';') do
  996. dec(j);
  997. CurrPath:=FixPath(Copy(s,j+1,length(s)-j),false);
  998. if j=0 then
  999. s:=''
  1000. else
  1001. System.Delete(s,j,length(s)-j+1);
  1002. end
  1003. else
  1004. begin
  1005. j:=Pos(';',s);
  1006. if j=0 then
  1007. j:=255;
  1008. CurrPath:=FixPath(Copy(s,1,j-1),false);
  1009. System.Delete(s,1,j);
  1010. end;
  1011. { fix pathname }
  1012. if CurrPath='' then
  1013. CurrPath:='.'+DirSep
  1014. else
  1015. begin
  1016. CurrPath:=FixPath(FExpand(CurrPath),false);
  1017. if (CurrentDir<>'') and (Copy(CurrPath,1,length(CurrentDir))=CurrentDir) then
  1018. CurrPath:='.'+DirSep+Copy(CurrPath,length(CurrentDir)+1,255);
  1019. end;
  1020. { wildcard adding ? }
  1021. if pos('*',currpath)>0 then
  1022. begin
  1023. if currpath[length(currpath)]=dirsep then
  1024. hs:=Copy(currpath,1,length(CurrPath)-1)
  1025. else
  1026. hs:=currpath;
  1027. hsd:=SplitPath(hs);
  1028. findfirst(hs,directory,dir);
  1029. while doserror=0 do
  1030. begin
  1031. if (dir.name<>'.') and
  1032. (dir.name<>'..') and
  1033. ((dir.attr and directory)<>0) then
  1034. begin
  1035. currpath:=hsd+dir.name+dirsep;
  1036. hp:=Find(currPath);
  1037. if not assigned(hp) then
  1038. AddCurrPath;
  1039. end;
  1040. findnext(dir);
  1041. end;
  1042. FindClose(dir);
  1043. end
  1044. else
  1045. begin
  1046. if PathExists(currpath) then
  1047. addcurrpath;
  1048. end;
  1049. until (s='');
  1050. end;
  1051. procedure TSearchPathList.AddList(list:TSearchPathList;addfirst:boolean);
  1052. var
  1053. s : string;
  1054. hl : TSearchPathList;
  1055. {$IFDEF NEWST}
  1056. hp,hp2 : PStringItem;
  1057. {$ELSE}
  1058. hp,hp2 : PStringQueueItem;
  1059. {$ENDIF}
  1060. begin
  1061. if list.empty then
  1062. exit;
  1063. { create temp and reverse the list }
  1064. if addfirst then
  1065. begin
  1066. hl.Init;
  1067. hp:=list.first;
  1068. while assigned(hp) do
  1069. begin
  1070. hl.insert(hp^.data^);
  1071. hp:=hp^.next;
  1072. end;
  1073. while not hl.empty do
  1074. begin
  1075. s:=hl.Get;
  1076. Delete(s);
  1077. Insert(s);
  1078. end;
  1079. hl.done;
  1080. end
  1081. else
  1082. begin
  1083. hp:=list.first;
  1084. while assigned(hp) do
  1085. begin
  1086. hp2:=Find(hp^.data^);
  1087. { Check if already in path, then we don't add it }
  1088. if not assigned(hp2) then
  1089. Concat(hp^.data^);
  1090. hp:=hp^.next;
  1091. end;
  1092. end;
  1093. end;
  1094. function TSearchPathList.FindFile(const f : string;var b : boolean) : string;
  1095. Var
  1096. {$IFDEF NEWST}
  1097. p : PStringItem;
  1098. {$ELSE}
  1099. p : PStringQueueItem;
  1100. {$ENDIF}
  1101. begin
  1102. FindFile:='';
  1103. b:=false;
  1104. p:=first;
  1105. while assigned(p) do
  1106. begin
  1107. If FileExists(p^.data^+f) then
  1108. begin
  1109. FindFile:=p^.data^;
  1110. b:=true;
  1111. exit;
  1112. end;
  1113. p:=p^.next;
  1114. end;
  1115. end;
  1116. Function GetFileTime ( Var F : File) : Longint;
  1117. Var
  1118. {$ifdef linux}
  1119. Info : Stat;
  1120. {$endif}
  1121. L : longint;
  1122. begin
  1123. {$ifdef linux}
  1124. FStat (F,Info);
  1125. L:=Info.Mtime;
  1126. {$else}
  1127. GetFTime(f,l);
  1128. {$endif}
  1129. GetFileTime:=L;
  1130. end;
  1131. Function GetNamedFileTime (Const F : String) : Longint;
  1132. begin
  1133. GetNamedFileTime:=do_getnamedfiletime(F);
  1134. end;
  1135. {Touch Assembler and object time to ppu time is there is a ppufilename}
  1136. procedure SynchronizeFileTime(const fn1,fn2:string);
  1137. var
  1138. f : file;
  1139. l : longint;
  1140. begin
  1141. Assign(f,fn1);
  1142. {$I-}
  1143. reset(f,1);
  1144. {$I+}
  1145. if ioresult=0 then
  1146. begin
  1147. getftime(f,l);
  1148. { just to be sure in case there are rounding errors }
  1149. setftime(f,l);
  1150. close(f);
  1151. assign(f,fn2);
  1152. {$I-}
  1153. reset(f,1);
  1154. {$I+}
  1155. if ioresult=0 then
  1156. begin
  1157. setftime(f,l);
  1158. close(f);
  1159. end;
  1160. end;
  1161. end;
  1162. function FindFile(const f : string;path : string;var b : boolean) : string;
  1163. Var
  1164. singlepathstring : string;
  1165. i : longint;
  1166. begin
  1167. {$ifdef linux}
  1168. for i:=1 to length(path) do
  1169. if path[i]=':' then
  1170. path[i]:=';';
  1171. {$endif}
  1172. b:=false;
  1173. FindFile:='';
  1174. repeat
  1175. i:=pos(';',path);
  1176. if i=0 then
  1177. i:=256;
  1178. singlepathstring:=FixPath(copy(path,1,i-1),false);
  1179. delete(path,1,i);
  1180. If FileExists (singlepathstring+f) then
  1181. begin
  1182. FindFile:=singlepathstring;
  1183. b:=true;
  1184. exit;
  1185. end;
  1186. until path='';
  1187. end;
  1188. function FindExe(bin:string;var found:boolean):string;
  1189. begin
  1190. bin:=FixFileName(bin)+source_os.exeext;
  1191. {$ifdef delphi}
  1192. FindExe:=FindFile(bin,'.;'+exepath+';'+dmisc.getenv('PATH'),found)+bin;
  1193. {$else delphi}
  1194. FindExe:=FindFile(bin,'.;'+exepath+';'+dos.getenv('PATH'),found)+bin;
  1195. {$endif delphi}
  1196. end;
  1197. function GetShortName(const n:string):string;
  1198. {$ifdef win32}
  1199. var
  1200. hs,hs2 : string;
  1201. i : longint;
  1202. {$endif}
  1203. {$ifdef go32v2}
  1204. var
  1205. hs : string;
  1206. {$endif}
  1207. begin
  1208. GetShortName:=n;
  1209. {$ifdef win32}
  1210. hs:=n+#0;
  1211. i:=Windows.GetShortPathName(@hs[1],@hs2[1],high(hs2));
  1212. if (i>0) and (i<=high(hs2)) then
  1213. begin
  1214. hs2[0]:=chr(strlen(@hs2[1]));
  1215. GetShortName:=hs2;
  1216. end;
  1217. {$endif}
  1218. {$ifdef go32v2}
  1219. hs:=n;
  1220. if Dos.GetShortName(hs) then
  1221. GetShortName:=hs;
  1222. {$endif}
  1223. end;
  1224. {****************************************************************************
  1225. OS Dependent things
  1226. ****************************************************************************}
  1227. function GetEnvPChar(const envname:string):pchar;
  1228. {$ifdef win32}
  1229. var
  1230. s : string;
  1231. i,len : longint;
  1232. hp,p,p2 : pchar;
  1233. {$endif}
  1234. begin
  1235. {$ifdef linux}
  1236. GetEnvPchar:=Linux.Getenv(envname);
  1237. {$define GETENVOK}
  1238. {$endif}
  1239. {$ifdef win32}
  1240. GetEnvPchar:=nil;
  1241. p:=GetEnvironmentStrings;
  1242. hp:=p;
  1243. while hp^<>#0 do
  1244. begin
  1245. s:=strpas(hp);
  1246. i:=pos('=',s);
  1247. len:=strlen(hp);
  1248. if upper(copy(s,1,i-1))=upper(envname) then
  1249. begin
  1250. GetMem(p2,len-length(envname));
  1251. Move(hp[i],p2^,len-length(envname));
  1252. GetEnvPchar:=p2;
  1253. break;
  1254. end;
  1255. { next string entry}
  1256. hp:=hp+len+1;
  1257. end;
  1258. FreeEnvironmentStrings(p);
  1259. {$define GETENVOK}
  1260. {$endif}
  1261. {$ifdef GETENVOK}
  1262. {$undef GETENVOK}
  1263. {$else}
  1264. GetEnvPchar:=StrPNew(Dos.Getenv(envname));
  1265. {$endif}
  1266. end;
  1267. procedure FreeEnvPChar(p:pchar);
  1268. begin
  1269. {$ifndef linux}
  1270. StrDispose(p);
  1271. {$endif}
  1272. end;
  1273. Procedure Shell(const command:string);
  1274. { This is already defined in the linux.ppu for linux, need for the *
  1275. expansion under linux }
  1276. {$ifdef linux}
  1277. begin
  1278. Linux.Shell(command);
  1279. end;
  1280. {$else}
  1281. var
  1282. comspec : string;
  1283. begin
  1284. comspec:=getenv('COMSPEC');
  1285. Exec(comspec,' /C '+command);
  1286. end;
  1287. {$endif}
  1288. {****************************************************************************
  1289. Init
  1290. ****************************************************************************}
  1291. procedure get_exepath;
  1292. var
  1293. hs1 : namestr;
  1294. hs2 : extstr;
  1295. begin
  1296. {$ifdef delphi}
  1297. exepath:=dmisc.getenv('PPC_EXEC_PATH');
  1298. {$else delphi}
  1299. exepath:=dos.getenv('PPC_EXEC_PATH');
  1300. {$endif delphi}
  1301. if exepath='' then
  1302. fsplit(FixFileName(paramstr(0)),exepath,hs1,hs2);
  1303. {$ifndef VER0_99_15}
  1304. {$ifdef linux}
  1305. if exepath='' then
  1306. fsearch(hs1,dos.getenv('PATH'));
  1307. {$endif}
  1308. {$endif}
  1309. exepath:=FixPath(exepath,false);
  1310. end;
  1311. procedure DoneGlobals;
  1312. begin
  1313. initdefines.done;
  1314. if assigned(DLLImageBase) then
  1315. StringDispose(DLLImageBase);
  1316. RelocSection:=true;
  1317. RelocSectionSetExplicitly:=false;
  1318. DLLsource:=false;
  1319. UseDeffileForExport:=true;
  1320. librarysearchpath.Done;
  1321. unitsearchpath.Done;
  1322. objectsearchpath.Done;
  1323. includesearchpath.Done;
  1324. end;
  1325. procedure InitGlobals;
  1326. begin
  1327. { set global switches }
  1328. do_build:=false;
  1329. do_make:=true;
  1330. {$ifdef tp}
  1331. use_big:=false;
  1332. {$endif tp}
  1333. compile_level:=0;
  1334. { Output }
  1335. OutputFile:='';
  1336. OutputExeDir:='';
  1337. OutputUnitDir:='';
  1338. { Utils directory }
  1339. utilsdirectory:='';
  1340. { Search Paths }
  1341. librarysearchpath.Init;
  1342. unitsearchpath.Init;
  1343. includesearchpath.Init;
  1344. objectsearchpath.Init;
  1345. { Def file }
  1346. usewindowapi:=false;
  1347. description:='Compiled by FPC '+version_string+' - '+target_cpu_string;
  1348. dllversion:='';
  1349. { Init values }
  1350. initmodeswitches:=fpcmodeswitches;
  1351. initlocalswitches:=[cs_check_io];
  1352. initmoduleswitches:=[cs_extsyntax,cs_browser];
  1353. initglobalswitches:=[cs_check_unit_name,cs_link_static];
  1354. {$ifdef i386}
  1355. initoptprocessor:=Class386;
  1356. initspecificoptprocessor:=Class386;
  1357. initpackenum:=4;
  1358. {$IFDEF testvarsets}
  1359. initsetalloc:=0;
  1360. {$ENDIF}
  1361. initpackrecords:=packrecord_2;
  1362. initoutputformat:=target_asm.id;
  1363. initasmmode:=asmmode_i386_att;
  1364. {$else not i386}
  1365. {$ifdef m68k}
  1366. initoptprocessor:=MC68000;
  1367. include(initmoduleswitches,cs_fp_emulation);
  1368. initpackenum:=4;
  1369. {$IFDEF testvarsets}
  1370. initsetalloc:=0;
  1371. {$ENDIF}
  1372. initpackrecords:=packrecord_2;
  1373. initoutputformat:=as_m68k_as;
  1374. initasmmode:=asmmode_m68k_mot;
  1375. {$endif m68k}
  1376. {$endif i386}
  1377. initdefines.init;
  1378. { memory sizes, will be overriden by parameter or default for target
  1379. in options or init_parser }
  1380. stacksize:=0;
  1381. heapsize:=0;
  1382. maxheapsize:=0;
  1383. { compile state }
  1384. in_args:=false;
  1385. { must_be_valid:=true; obsolete PM }
  1386. not_unit_proc:=true;
  1387. apptype:=at_cui;
  1388. end;
  1389. begin
  1390. get_exepath;
  1391. {$ifdef EXTDEBUG}
  1392. {$ifdef FPC}
  1393. EntryMemUsed:=system.HeapSize-MemAvail;
  1394. {$endif FPC}
  1395. {$endif}
  1396. end.
  1397. {
  1398. $Log$
  1399. Revision 1.6 2000-08-12 19:14:58 peter
  1400. * ELF writer works now also with -g
  1401. * ELF writer is default again for linux
  1402. Revision 1.5 2000/08/12 15:30:44 peter
  1403. * IDE patch for stream reading (merged)
  1404. Revision 1.4 2000/08/02 19:49:59 peter
  1405. * first things for default parameters
  1406. Revision 1.3 2000/07/13 12:08:25 michael
  1407. + patched to 1.1.0 with former 1.09patch from peter
  1408. Revision 1.2 2000/07/13 11:32:41 michael
  1409. + removed logs
  1410. }