globals.pas 42 KB

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