globals.pas 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118
  1. {
  2. $Id$
  3. Copyright (c) 1998-2002 by Florian Klaempfl
  4. This unit implements some support functions and global variables
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. unit globals;
  19. {$i fpcdefs.inc}
  20. { Use the internal linker by default }
  21. { define INTERNALLINKER}
  22. interface
  23. uses
  24. {$ifdef win32}
  25. windows,
  26. {$endif}
  27. {$ifdef hasunix}
  28. {$ifdef havelinuxrtl10}
  29. linux,
  30. {$else}
  31. Baseunix,unix,
  32. {$endif}
  33. {$endif}
  34. {$ifdef Delphi}
  35. SysUtils,
  36. dmisc,
  37. {$else}
  38. strings,
  39. dos,
  40. {$endif}
  41. cutils,cclasses,
  42. globtype,version,systems,cpuinfo;
  43. const
  44. {$ifdef Splitheap}
  45. testsplit : boolean = false;
  46. {$endif Splitheap}
  47. delphimodeswitches : tmodeswitches=
  48. [m_delphi,m_all,m_class,m_objpas,m_result,m_string_pchar,
  49. m_pointer_2_procedure,m_autoderef,m_tp_procvar,m_initfinal,m_default_ansistring,
  50. m_out,m_default_para,m_duplicate_names,m_hintdirective,m_add_pointer];
  51. fpcmodeswitches : tmodeswitches=
  52. [m_fpc,m_all,m_string_pchar,m_nested_comment,m_repeat_forward,
  53. m_cvar_support,m_initfinal,m_add_pointer,m_hintdirective];
  54. objfpcmodeswitches : tmodeswitches=
  55. [m_objfpc,m_fpc,m_all,m_class,m_objpas,m_result,m_string_pchar,m_nested_comment,
  56. m_repeat_forward,m_cvar_support,m_initfinal,m_add_pointer,m_out,m_default_para,m_hintdirective];
  57. tpmodeswitches : tmodeswitches=
  58. [m_tp7,m_all,m_tp_procvar,m_duplicate_names];
  59. gpcmodeswitches : tmodeswitches=
  60. [m_gpc,m_all];
  61. macmodeswitches : tmodeswitches=
  62. [m_mac,m_all,m_class,m_result,m_repeat_forward];
  63. { maximum number of locals in bytes before warning is emitted }
  64. maxlocalsize = high(smallint);
  65. { maximum number of paras in bytes before warning is emitted }
  66. maxparasize = high(word);
  67. { maximum nesting of routines }
  68. maxnesting = 32;
  69. treelogfilename = 'tree.log';
  70. { I don't know if this endian dependend }
  71. MathQNaN : array[0..7] of byte = (0,0,0,0,0,0,252,255);
  72. MathInf : array[0..7] of byte = (0,0,0,0,0,0,240,127);
  73. MathNegInf : array[0..7] of byte = (0,0,0,0,0,0,240,255);
  74. type
  75. {$ifdef ver1_0}
  76. PtrInt = DWord;
  77. {$endif ver1_0}
  78. TFPUException = (exInvalidOp, exDenormalized, exZeroDivide,
  79. exOverflow, exUnderflow, exPrecision);
  80. TFPUExceptionMask = set of TFPUException;
  81. pfileposinfo = ^tfileposinfo;
  82. tfileposinfo = record
  83. line : longint;
  84. column : word;
  85. fileindex : word;
  86. { moduleindex : word; }
  87. end;
  88. TSearchPathList = class(TStringList)
  89. procedure AddPath(s:string;addfirst:boolean);overload;
  90. procedure AddPath(SrcPath,s:string;addfirst:boolean);overload;
  91. procedure AddList(list:TSearchPathList;addfirst:boolean);
  92. function FindFile(const f : string;var foundfile:string):boolean;
  93. end;
  94. tcodepagestring = string[20];
  95. { the ordinal type used when evaluating constant integer expressions }
  96. TConstExprInt = int64;
  97. { ... the same unsigned }
  98. TConstExprUInt = {$ifdef fpc}qword{$else}int64{$endif};
  99. var
  100. { specified inputfile }
  101. inputdir : dirstr;
  102. inputfile : namestr;
  103. inputextension : extstr;
  104. { specified outputfile with -o parameter }
  105. outputfile : namestr;
  106. { specified with -FE or -FU }
  107. outputexedir : dirstr;
  108. outputunitdir : dirstr;
  109. { things specified with parameters }
  110. paralinkoptions,
  111. paradynamiclinker : string;
  112. paraprintnodetree : byte;
  113. parapreprocess : boolean;
  114. printnodefile : text;
  115. { typical cross compiling params}
  116. { directory where the utils can be found (options -FD) }
  117. utilsdirectory : dirstr;
  118. { targetname specific prefix used by these utils (options -XP<path>) }
  119. utilsprefix : dirstr;
  120. cshared : boolean; { pass --shared to ld to link C libs shared}
  121. Dontlinkstdlibpath: Boolean; { Don't add std paths to linkpath}
  122. rlinkpath : dirstr; { rpath-link linkdir override}
  123. { some flags for global compiler switches }
  124. do_build,
  125. do_release,
  126. do_make : boolean;
  127. { path for searching units, different paths can be seperated by ; }
  128. exepath : dirstr; { Path to ppc }
  129. librarysearchpath,
  130. unitsearchpath,
  131. objectsearchpath,
  132. includesearchpath : TSearchPathList;
  133. { deffile }
  134. usewindowapi : boolean;
  135. description : string;
  136. dllversion : string;
  137. dllmajor,dllminor,dllrevision : word; { revision only for netware }
  138. akttokenpos, { position of the last token }
  139. aktfilepos : tfileposinfo; { current position }
  140. nwscreenname : string;
  141. nwthreadname : string;
  142. nwcopyright : string;
  143. codegenerror : boolean; { true if there is an error reported }
  144. block_type : tblock_type; { type of currently parsed block }
  145. parsing_para_level : integer; { parameter level, used to convert
  146. proc calls to proc loads in firstcalln }
  147. compile_level : word;
  148. make_ref : boolean;
  149. resolving_forward : boolean; { used to add forward reference as second ref }
  150. inlining_procedure : boolean; { are we inlining a procedure }
  151. exceptblockcounter : integer; { each except block gets a unique number check gotos }
  152. aktexceptblock : integer; { the exceptblock number of the current block (0 if none) }
  153. { commandline values }
  154. initdefines : tstringlist;
  155. initglobalswitches : tglobalswitches;
  156. initmoduleswitches : tmoduleswitches;
  157. initlocalswitches : tlocalswitches;
  158. initmodeswitches : tmodeswitches;
  159. {$IFDEF testvarsets}
  160. Initsetalloc, {0=fixed, 1 =var}
  161. {$ENDIF}
  162. initpackrecords,
  163. initpackenum : shortint;
  164. initalignment : talignmentinfo;
  165. initoptprocessor,
  166. initspecificoptprocessor : tprocessors;
  167. initfputype : tfputype;
  168. initasmmode : tasmmode;
  169. initinterfacetype : tinterfacetypes;
  170. initoutputformat : tasm;
  171. initdefproccall : tproccalloption;
  172. initsourcecodepage : tcodepagestring;
  173. { current state values }
  174. aktglobalswitches : tglobalswitches;
  175. aktmoduleswitches : tmoduleswitches;
  176. aktlocalswitches : tlocalswitches;
  177. nextaktlocalswitches : tlocalswitches;
  178. localswitcheschanged : boolean;
  179. aktmodeswitches : tmodeswitches;
  180. {$IFDEF testvarsets}
  181. aktsetalloc,
  182. {$ENDIF}
  183. aktpackrecords,
  184. aktpackenum : longint;
  185. aktmaxfpuregisters : longint;
  186. aktalignment : talignmentinfo;
  187. aktoptprocessor,
  188. aktspecificoptprocessor : tprocessors;
  189. aktfputype : tfputype;
  190. aktasmmode : tasmmode;
  191. aktinterfacetype : tinterfacetypes;
  192. aktoutputformat : tasm;
  193. aktdefproccall : tproccalloption;
  194. aktsourcecodepage : tcodepagestring;
  195. { Memory sizes }
  196. heapsize,
  197. stacksize : longint;
  198. {$Ifdef EXTDEBUG}
  199. { parameter switches }
  200. debugstop : boolean;
  201. {$EndIf EXTDEBUG}
  202. { windows / OS/2 application type }
  203. apptype : tapptype;
  204. const
  205. RelocSection : boolean = true;
  206. RelocSectionSetExplicitly : boolean = false;
  207. LinkTypeSetExplicitly : boolean = false;
  208. DLLsource : boolean = false;
  209. DLLImageBase : pstring = nil;
  210. UseDeffileForExport : boolean = true;
  211. ForceDeffileForExport : boolean = false;
  212. { used to set all registers used for each global function
  213. this should dramatically decrease the number of
  214. recompilations needed PM }
  215. simplify_ppu : boolean = true;
  216. { should we allow non static members ? }
  217. allow_only_static : boolean = false;
  218. Inside_asm_statement : boolean = false;
  219. global_unit_count : word = 0;
  220. { for error info in pp.pas }
  221. parser_current_file : string = '';
  222. {$ifdef m68k}
  223. { PalmOS resources }
  224. palmos_applicationname : string = 'FPC Application';
  225. palmos_applicationid : string[4] = 'FPCA';
  226. {$endif m68k}
  227. procedure abstract;
  228. function bstoslash(const s : string) : string;
  229. function getdatestr:string;
  230. function gettimestr:string;
  231. function filetimestring( t : longint) : string;
  232. procedure DefaultReplacements(var s:string);
  233. function GetCurrentDir:string;
  234. function path_absolute(const s : string) : boolean;
  235. Function PathExists ( F : String) : Boolean;
  236. Function FileExists ( Const F : String) : Boolean;
  237. Function RemoveFile(const f:string):boolean;
  238. Function RemoveDir(d:string):boolean;
  239. Function GetFileTime ( Var F : File) : Longint;
  240. Function GetNamedFileTime ( Const F : String) : Longint;
  241. Function SplitPath(const s:string):string;
  242. Function SplitFileName(const s:string):string;
  243. Function SplitName(const s:string):string;
  244. Function SplitExtension(Const HStr:String):String;
  245. Function AddExtension(Const HStr,ext:String):String;
  246. Function ForceExtension(Const HStr,ext:String):String;
  247. Function FixPath(s:string;allowdot:boolean):string;
  248. function FixFileName(const s:string):string;
  249. function TargetFixPath(s:string;allowdot:boolean):string;
  250. function TargetFixFileName(const s:string):string;
  251. procedure SplitBinCmd(const s:string;var bstr,cstr:string);
  252. function FindFile(const f : string;path : string;var foundfile:string):boolean;
  253. function FindFilePchar(const f : string;path : pchar;var foundfile:string):boolean;
  254. function FindExe(const bin:string;var foundfile:string):boolean;
  255. function GetShortName(const n:string):string;
  256. Procedure Shell(const command:string);
  257. function GetEnvPChar(const envname:string):pchar;
  258. procedure FreeEnvPChar(p:pchar);
  259. function SetFPUExceptionMask(const Mask : TFPUExceptionMask) : TFPUExceptionMask;
  260. function is_number_float(d : double) : boolean;
  261. Function SetCompileMode(const s:string; changeInit: boolean):boolean;
  262. function SetAktProcCall(const s:string; changeInit: boolean):boolean;
  263. function SetProcessor(const s:string; changeInit: boolean):boolean;
  264. function SetFpuType(const s:string; changeInit: boolean):boolean;
  265. procedure InitGlobals;
  266. procedure DoneGlobals;
  267. function string2guid(const s: string; var GUID: TGUID): boolean;
  268. function guid2string(const GUID: TGUID): string;
  269. procedure swap_qword(var q : qword);
  270. function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
  271. {# Routine to get the required alignment for size of data, which will
  272. be placed in bss segment, according to the current alignment requirements }
  273. function var_align(siz: longint): longint;
  274. {# Routine to get the required alignment for size of data, which will
  275. be placed in data/const segment, according to the current alignment requirements }
  276. function const_align(siz: longint): longint;
  277. implementation
  278. uses
  279. comphook;
  280. procedure abstract;
  281. begin
  282. do_internalerror(255);
  283. end;
  284. procedure WarnNonExistingPath(const path : string);
  285. begin
  286. if assigned({$ifndef FPCPROCVAR}@{$endif}do_comment) then
  287. do_comment(V_Hint,'Path "'+path+'" not found');
  288. end;
  289. function bstoslash(const s : string) : string;
  290. {
  291. return string s with all \ changed into /
  292. }
  293. var
  294. i : longint;
  295. begin
  296. for i:=1to length(s) do
  297. if s[i]='\' then
  298. bstoslash[i]:='/'
  299. else
  300. bstoslash[i]:=s[i];
  301. bstoslash[0]:=s[0];
  302. end;
  303. {****************************************************************************
  304. Time Handling
  305. ****************************************************************************}
  306. Function L0(l:longint):string;
  307. {
  308. return the string of value l, if l<10 then insert a zero, so
  309. the string is always at least 2 chars '01','02',etc
  310. }
  311. var
  312. s : string;
  313. begin
  314. Str(l,s);
  315. if l<10 then
  316. s:='0'+s;
  317. L0:=s;
  318. end;
  319. function gettimestr:string;
  320. {
  321. get the current time in a string HH:MM:SS
  322. }
  323. var
  324. hour,min,sec,hsec : word;
  325. begin
  326. {$ifdef delphi}
  327. dmisc.gettime(hour,min,sec,hsec);
  328. {$else delphi}
  329. dos.gettime(hour,min,sec,hsec);
  330. {$endif delphi}
  331. gettimestr:=L0(Hour)+':'+L0(min)+':'+L0(sec);
  332. end;
  333. function getdatestr:string;
  334. {
  335. get the current date in a string YY/MM/DD
  336. }
  337. var
  338. Year,Month,Day,Wday : Word;
  339. begin
  340. {$ifdef delphi}
  341. dmisc.getdate(year,month,day,wday);
  342. {$else}
  343. dos.getdate(year,month,day,wday);
  344. {$endif}
  345. getdatestr:=L0(Year)+'/'+L0(Month)+'/'+L0(Day);
  346. end;
  347. function filetimestring( t : longint) : string;
  348. {
  349. convert dos datetime t to a string YY/MM/DD HH:MM:SS
  350. }
  351. var
  352. DT : DateTime;
  353. begin
  354. if t=-1 then
  355. begin
  356. FileTimeString:='Not Found';
  357. exit;
  358. end;
  359. unpacktime(t,DT);
  360. filetimestring:=L0(dt.Year)+'/'+L0(dt.Month)+'/'+L0(dt.Day)+' '+L0(dt.Hour)+':'+L0(dt.min)+':'+L0(dt.sec);
  361. end;
  362. {****************************************************************************
  363. Default Macro Handling
  364. ****************************************************************************}
  365. procedure DefaultReplacements(var s:string);
  366. begin
  367. { Replace some macros }
  368. Replace(s,'$FPCVER',version_string);
  369. Replace(s,'$VERSION',version_string);
  370. Replace(s,'$FULLVERSION',full_version_string);
  371. Replace(s,'$FPCDATE',date_string);
  372. Replace(s,'$FPCTARGET',target_cpu_string);
  373. Replace(s,'$FPCCPU',target_cpu_string);
  374. Replace(s,'$TARGET',target_path);
  375. Replace(s,'$FPCOS',target_path);
  376. end;
  377. {****************************************************************************
  378. File Handling
  379. ****************************************************************************}
  380. function GetCurrentDir:string;
  381. var
  382. CurrentDir : string;
  383. begin
  384. GetDir(0,CurrentDir);
  385. GetCurrentDir:=FixPath(CurrentDir,false);
  386. end;
  387. function path_absolute(const s : string) : boolean;
  388. {
  389. is path s an absolute path?
  390. }
  391. begin
  392. path_absolute:=false;
  393. {$ifdef unix}
  394. if (length(s)>0) and (s[1]='/') then
  395. path_absolute:=true;
  396. {$else unix}
  397. {$ifdef amiga}
  398. if ((length(s)>0) and ((s[1]='\') or (s[1]='/'))) or (Pos(':',s) = length(s)) then
  399. path_absolute:=true;
  400. {$else}
  401. if ((length(s)>0) and ((s[1]='\') or (s[1]='/'))) or
  402. ((length(s)>2) and (s[2]=':') and ((s[3]='\') or (s[3]='/'))) then
  403. path_absolute:=true;
  404. {$endif amiga}
  405. {$endif unix}
  406. end;
  407. {$ifndef FPC}
  408. Procedure FindClose(var Info : SearchRec);
  409. Begin
  410. End;
  411. {$endif not FPC}
  412. Function FileExists ( Const F : String) : Boolean;
  413. Var
  414. res : boolean;
  415. {$ifndef delphi}
  416. Info : SearchRec;
  417. {$endif}
  418. begin
  419. {$ifdef delphi}
  420. res:=sysutils.FileExists(f);
  421. {$else}
  422. findfirst(F,readonly+archive+hidden,info);
  423. res:=(doserror=0);
  424. findclose(Info);
  425. {$endif delphi}
  426. if assigned({$ifndef FPCPROVCAR}@{$endif}do_comment) then
  427. begin
  428. if res then
  429. do_comment(V_Tried,'Searching file '+F+'... found')
  430. else
  431. do_comment(V_Tried,'Searching file '+F+'... not found');
  432. end;
  433. FileExists:=res;
  434. end;
  435. Function PathExists ( F : String) : Boolean;
  436. Var
  437. Info : SearchRec;
  438. disk : byte;
  439. begin
  440. { these operating systems have dos type drives }
  441. if source_info.system in [system_m68k_atari,system_i386_go32v2,
  442. system_i386_win32,system_i386_os2,
  443. system_i386_emx,system_i386_wdosx] then
  444. Begin
  445. if (Length(f)=3) and (F[2]=':') and (F[3] in ['/','\']) then
  446. begin
  447. if F[1] in ['A'..'Z'] then
  448. disk:=ord(F[1])-ord('A')+1
  449. else if F[1] in ['a'..'z'] then
  450. disk:=ord(F[1])-ord('a')+1
  451. else
  452. disk:=255;
  453. if disk=255 then
  454. PathExists:=false
  455. else
  456. PathExists:=(DiskSize(disk)<>-1);
  457. exit;
  458. end;
  459. end;
  460. if F[Length(f)] in ['/','\'] then
  461. Delete(f,length(f),1);
  462. findfirst(F,readonly+archive+hidden+directory,info);
  463. PathExists:=(doserror=0) and ((info.attr and directory)=directory);
  464. findclose(Info);
  465. end;
  466. Function RemoveFile(const f:string):boolean;
  467. var
  468. g : file;
  469. begin
  470. assign(g,f);
  471. {$I-}
  472. erase(g);
  473. {$I+}
  474. RemoveFile:=(ioresult=0);
  475. end;
  476. Function RemoveDir(d:string):boolean;
  477. begin
  478. if d[length(d)]=source_info.DirSep then
  479. Delete(d,length(d),1);
  480. {$I-}
  481. rmdir(d);
  482. {$I+}
  483. RemoveDir:=(ioresult=0);
  484. end;
  485. Function SplitPath(const s:string):string;
  486. var
  487. i : longint;
  488. begin
  489. i:=Length(s);
  490. while (i>0) and not(s[i] in ['/','\']) do
  491. dec(i);
  492. SplitPath:=Copy(s,1,i);
  493. end;
  494. Function SplitFileName(const s:string):string;
  495. var
  496. p : dirstr;
  497. n : namestr;
  498. e : extstr;
  499. begin
  500. FSplit(s,p,n,e);
  501. SplitFileName:=n+e;
  502. end;
  503. Function SplitName(const s:string):string;
  504. var
  505. i,j : longint;
  506. begin
  507. i:=Length(s);
  508. j:=Length(s);
  509. while (i>0) and not(s[i] in ['/','\']) do
  510. dec(i);
  511. while (j>0) and (s[j]<>'.') do
  512. dec(j);
  513. if j<=i then
  514. j:=255;
  515. SplitName:=Copy(s,i+1,j-(i+1));
  516. end;
  517. Function SplitExtension(Const HStr:String):String;
  518. var
  519. j : longint;
  520. begin
  521. j:=length(Hstr);
  522. while (j>0) and (Hstr[j]<>'.') do
  523. begin
  524. if hstr[j]=source_info.DirSep then
  525. j:=0
  526. else
  527. dec(j);
  528. end;
  529. if j=0 then
  530. j:=254;
  531. SplitExtension:=Copy(Hstr,j,255);
  532. end;
  533. Function AddExtension(Const HStr,ext:String):String;
  534. begin
  535. if (Ext<>'') and (SplitExtension(HStr)='') then
  536. AddExtension:=Hstr+Ext
  537. else
  538. AddExtension:=Hstr;
  539. end;
  540. Function ForceExtension(Const HStr,ext:String):String;
  541. var
  542. j : longint;
  543. begin
  544. j:=length(Hstr);
  545. while (j>0) and (Hstr[j]<>'.') do
  546. dec(j);
  547. if j=0 then
  548. j:=255;
  549. ForceExtension:=Copy(Hstr,1,j-1)+Ext;
  550. end;
  551. Function FixPath(s:string;allowdot:boolean):string;
  552. var
  553. i : longint;
  554. begin
  555. { Fix separator }
  556. for i:=1 to length(s) do
  557. if s[i] in ['/','\'] then
  558. s[i]:=source_info.DirSep;
  559. { Fix ending / }
  560. if (length(s)>0) and (s[length(s)]<>source_info.DirSep) and
  561. (s[length(s)]<>':') then
  562. s:=s+source_info.DirSep;
  563. { Remove ./ }
  564. if (not allowdot) and (s='.'+source_info.DirSep) then
  565. s:='';
  566. { return }
  567. if source_info.files_case_relevent then
  568. FixPath:=s
  569. else
  570. FixPath:=Lower(s);
  571. end;
  572. function FixFileName(const s:string):string;
  573. var
  574. i : longint;
  575. begin
  576. if source_info.files_case_relevent then
  577. begin
  578. for i:=1 to length(s) do
  579. begin
  580. case s[i] of
  581. '/','\' :
  582. FixFileName[i]:=source_info.dirsep;
  583. else
  584. FixFileName[i]:=s[i];
  585. end;
  586. end;
  587. end
  588. else
  589. begin
  590. for i:=1 to length(s) do
  591. begin
  592. case s[i] of
  593. '/','\' :
  594. FixFileName[i]:=source_info.dirsep;
  595. 'A'..'Z' :
  596. FixFileName[i]:=char(byte(s[i])+32);
  597. else
  598. FixFileName[i]:=s[i];
  599. end;
  600. end;
  601. end;
  602. FixFileName[0]:=s[0];
  603. end;
  604. Function TargetFixPath(s:string;allowdot:boolean):string;
  605. var
  606. i : longint;
  607. begin
  608. { Fix separator }
  609. for i:=1 to length(s) do
  610. if s[i] in ['/','\'] then
  611. s[i]:=target_info.DirSep;
  612. { Fix ending / }
  613. if (length(s)>0) and (s[length(s)]<>target_info.DirSep) and
  614. (s[length(s)]<>':') then
  615. s:=s+target_info.DirSep;
  616. { Remove ./ }
  617. if (not allowdot) and (s='.'+target_info.DirSep) then
  618. s:='';
  619. { return }
  620. if target_info.files_case_relevent then
  621. TargetFixPath:=s
  622. else
  623. TargetFixPath:=Lower(s);
  624. end;
  625. function TargetFixFileName(const s:string):string;
  626. var
  627. i : longint;
  628. begin
  629. if target_info.files_case_relevent then
  630. begin
  631. for i:=1 to length(s) do
  632. begin
  633. case s[i] of
  634. '/','\' :
  635. TargetFixFileName[i]:=target_info.dirsep;
  636. else
  637. TargetFixFileName[i]:=s[i];
  638. end;
  639. end;
  640. end
  641. else
  642. begin
  643. for i:=1 to length(s) do
  644. begin
  645. case s[i] of
  646. '/','\' :
  647. TargetFixFileName[i]:=target_info.dirsep;
  648. 'A'..'Z' :
  649. TargetFixFileName[i]:=char(byte(s[i])+32);
  650. else
  651. TargetFixFileName[i]:=s[i];
  652. end;
  653. end;
  654. end;
  655. TargetFixFileName[0]:=s[0];
  656. end;
  657. procedure SplitBinCmd(const s:string;var bstr,cstr:string);
  658. var
  659. i : longint;
  660. begin
  661. i:=pos(' ',s);
  662. if i>0 then
  663. begin
  664. bstr:=Copy(s,1,i-1);
  665. cstr:=Copy(s,i+1,length(s)-i);
  666. end
  667. else
  668. begin
  669. bstr:=s;
  670. cstr:='';
  671. end;
  672. end;
  673. procedure TSearchPathList.AddPath(s:string;addfirst:boolean);
  674. begin
  675. AddPath('',s,AddFirst);
  676. end;
  677. procedure TSearchPathList.AddPath(SrcPath,s:string;addfirst:boolean);
  678. var
  679. j : longint;
  680. hs,hsd,
  681. CurrentDir,
  682. CurrPath : string;
  683. subdirfound : boolean;
  684. dir : searchrec;
  685. hp : TStringListItem;
  686. procedure addcurrpath;
  687. begin
  688. if addfirst then
  689. begin
  690. Remove(currPath);
  691. Insert(currPath);
  692. end
  693. else
  694. begin
  695. { Check if already in path, then we don't add it }
  696. hp:=Find(currPath);
  697. if not assigned(hp) then
  698. Concat(currPath);
  699. end;
  700. end;
  701. begin
  702. if s='' then
  703. exit;
  704. { Support default macro's }
  705. DefaultReplacements(s);
  706. { get current dir }
  707. CurrentDir:=GetCurrentDir;
  708. repeat
  709. { get currpath }
  710. if addfirst then
  711. begin
  712. j:=length(s);
  713. while (j>0) and (s[j]<>';') do
  714. dec(j);
  715. CurrPath:=FixPath(Copy(s,j+1,length(s)-j),false);
  716. if j=0 then
  717. s:=''
  718. else
  719. System.Delete(s,j,length(s)-j+1);
  720. end
  721. else
  722. begin
  723. j:=Pos(';',s);
  724. if j=0 then
  725. j:=255;
  726. CurrPath:=SrcPath+FixPath(Copy(s,1,j-1),false);
  727. System.Delete(s,1,j);
  728. end;
  729. { fix pathname }
  730. if CurrPath='' then
  731. CurrPath:='.'+source_info.DirSep
  732. else
  733. begin
  734. CurrPath:=FixPath(FExpand(CurrPath),false);
  735. if (CurrentDir<>'') and (Copy(CurrPath,1,length(CurrentDir))=CurrentDir) then
  736. begin
  737. {$ifdef AMIGA}
  738. CurrPath:=CurrentDir+Copy(CurrPath,length(CurrentDir)+1,255);
  739. {$else}
  740. CurrPath:='.'+source_info.DirSep+Copy(CurrPath,length(CurrentDir)+1,255);
  741. {$endif}
  742. end;
  743. end;
  744. { wildcard adding ? }
  745. if pos('*',currpath)>0 then
  746. begin
  747. if currpath[length(currpath)]=source_info.dirsep then
  748. hs:=Copy(currpath,1,length(CurrPath)-1)
  749. else
  750. hs:=currpath;
  751. hsd:=SplitPath(hs);
  752. findfirst(hs,directory,dir);
  753. subdirfound:=false;
  754. while doserror=0 do
  755. begin
  756. if (dir.name<>'.') and
  757. (dir.name<>'..') and
  758. ((dir.attr and directory)<>0) then
  759. begin
  760. subdirfound:=true;
  761. currpath:=hsd+dir.name+source_info.dirsep;
  762. hp:=Find(currPath);
  763. if not assigned(hp) then
  764. AddCurrPath;
  765. end;
  766. findnext(dir);
  767. if not subdirfound then
  768. WarnNonExistingPath(currpath);
  769. end;
  770. FindClose(dir);
  771. end
  772. else
  773. begin
  774. if PathExists(currpath) then
  775. addcurrpath
  776. else
  777. WarnNonExistingPath(currpath);
  778. end;
  779. until (s='');
  780. end;
  781. procedure TSearchPathList.AddList(list:TSearchPathList;addfirst:boolean);
  782. var
  783. s : string;
  784. hl : TSearchPathList;
  785. hp,hp2 : TStringListItem;
  786. begin
  787. if list.empty then
  788. exit;
  789. { create temp and reverse the list }
  790. if addfirst then
  791. begin
  792. hl:=TSearchPathList.Create;
  793. hp:=TStringListItem(list.first);
  794. while assigned(hp) do
  795. begin
  796. hl.insert(hp.Str);
  797. hp:=TStringListItem(hp.next);
  798. end;
  799. while not hl.empty do
  800. begin
  801. s:=hl.GetFirst;
  802. Remove(s);
  803. Insert(s);
  804. end;
  805. hl.Free;
  806. end
  807. else
  808. begin
  809. hp:=TStringListItem(list.first);
  810. while assigned(hp) do
  811. begin
  812. hp2:=Find(hp.Str);
  813. { Check if already in path, then we don't add it }
  814. if not assigned(hp2) then
  815. Concat(hp.Str);
  816. hp:=TStringListItem(hp.next);
  817. end;
  818. end;
  819. end;
  820. function TSearchPathList.FindFile(const f : string;var foundfile:string):boolean;
  821. Var
  822. p : TStringListItem;
  823. begin
  824. FindFile:=false;
  825. p:=TStringListItem(first);
  826. while assigned(p) do
  827. begin
  828. {
  829. Search order for case sensitive systems:
  830. 1. lowercase
  831. 2. NormalCase
  832. 3. UPPERCASE
  833. None case sensitive only lowercase
  834. }
  835. FoundFile:=p.Str+Lower(f);
  836. If FileExists(FoundFile) then
  837. begin
  838. FindFile:=true;
  839. exit;
  840. end;
  841. {$ifdef UNIX}
  842. FoundFile:=p.Str+f;
  843. If FileExists(FoundFile) then
  844. begin
  845. FindFile:=true;
  846. exit;
  847. end;
  848. FoundFile:=p.Str+Upper(f);
  849. If FileExists(FoundFile) then
  850. begin
  851. FindFile:=true;
  852. exit;
  853. end;
  854. {$endif UNIX}
  855. p:=TStringListItem(p.next);
  856. end;
  857. { Return original filename if not found }
  858. FoundFile:=f;
  859. end;
  860. Function GetFileTime ( Var F : File) : Longint;
  861. Var
  862. {$ifdef hasunix}
  863. info: Stat;
  864. {$endif}
  865. L : longint;
  866. begin
  867. {$ifdef hasunix}
  868. {$IFDEF havelinuxrtl10}
  869. FStat (F,Info);
  870. L:=Info.Mtime;
  871. {$ELSE}
  872. FPFStat (F,Info);
  873. L:=Info.st_Mtime;
  874. {$ENDIF}
  875. {$else}
  876. GetFTime(f,l);
  877. {$endif}
  878. GetFileTime:=L;
  879. end;
  880. Function GetNamedFileTime (Const F : String) : Longint;
  881. begin
  882. GetNamedFileTime:=do_getnamedfiletime(F);
  883. end;
  884. function FindFile(const f : string;path : string;var foundfile:string):boolean;
  885. Var
  886. singlepathstring : string;
  887. i : longint;
  888. begin
  889. {$ifdef Unix}
  890. for i:=1 to length(path) do
  891. if path[i]=':' then
  892. path[i]:=';';
  893. {$endif Unix}
  894. FindFile:=false;
  895. repeat
  896. i:=pos(';',path);
  897. if i=0 then
  898. i:=256;
  899. singlepathstring:=FixPath(copy(path,1,i-1),false);
  900. delete(path,1,i);
  901. {
  902. Search order for case sensitive systems:
  903. 1. lowercase
  904. 2. NormalCase
  905. 3. UPPERCASE
  906. None case sensitive only lowercase
  907. }
  908. FoundFile:=singlepathstring+Lower(f);
  909. If FileExists(FoundFile) then
  910. begin
  911. FindFile:=true;
  912. exit;
  913. end;
  914. {$ifdef UNIX}
  915. FoundFile:=singlepathstring+f;
  916. If FileExists(FoundFile) then
  917. begin
  918. FindFile:=true;
  919. exit;
  920. end;
  921. FoundFile:=singlepathstring+Upper(f);
  922. If FileExists(FoundFile) then
  923. begin
  924. FindFile:=true;
  925. exit;
  926. end;
  927. {$endif UNIX}
  928. until path='';
  929. FoundFile:=f;
  930. end;
  931. function FindFilePchar(const f : string;path : pchar;var foundfile:string):boolean;
  932. Var
  933. singlepathstring : string;
  934. startpc,pc : pchar;
  935. sepch : char;
  936. begin
  937. {$ifdef Unix}
  938. sepch:=':';
  939. {$else}
  940. sepch:=';';
  941. {$endif Unix}
  942. FindFilePchar:=false;
  943. pc:=path;
  944. repeat
  945. startpc:=pc;
  946. while (pc^<>sepch) and (pc^<>';') and (pc^<>#0) do
  947. inc(pc);
  948. move(startpc^,singlepathstring[1],pc-startpc);
  949. singlepathstring[0]:=char(longint(pc-startpc));
  950. singlepathstring:=FixPath(singlepathstring,false);
  951. {
  952. Search order for case sensitive systems:
  953. 1. lowercase
  954. 2. NormalCase
  955. 3. UPPERCASE
  956. None case sensitive only lowercase
  957. }
  958. FoundFile:=singlepathstring+Lower(f);
  959. If FileExists(FoundFile) then
  960. begin
  961. FindFilePchar:=true;
  962. exit;
  963. end;
  964. {$ifdef UNIX}
  965. FoundFile:=singlepathstring+f;
  966. If FileExists(FoundFile) then
  967. begin
  968. FindFilePchar:=true;
  969. exit;
  970. end;
  971. FoundFile:=singlepathstring+Upper(f);
  972. If FileExists(FoundFile) then
  973. begin
  974. FindFilePchar:=true;
  975. exit;
  976. end;
  977. {$endif UNIX}
  978. if (pc^=#0) then
  979. break;
  980. inc(pc);
  981. until false;
  982. end;
  983. function FindExe(const bin:string;var foundfile:string):boolean;
  984. var
  985. p : pchar;
  986. found : boolean;
  987. begin
  988. found:=FindFile(FixFileName(AddExtension(bin,source_info.exeext)),'.;'+exepath,foundfile);
  989. if not found then
  990. begin
  991. p:=GetEnvPchar('PATH');
  992. found:=FindFilePChar(FixFileName(AddExtension(bin,source_info.exeext)),p,foundfile);
  993. FreeEnvPChar(p);
  994. end;
  995. FindExe:=found;
  996. end;
  997. function GetShortName(const n:string):string;
  998. {$ifdef win32}
  999. var
  1000. hs,hs2 : string;
  1001. i : longint;
  1002. {$endif}
  1003. {$ifdef go32v2}
  1004. var
  1005. hs : string;
  1006. {$endif}
  1007. {$ifdef watcom}
  1008. var
  1009. hs : string;
  1010. {$endif}
  1011. begin
  1012. GetShortName:=n;
  1013. {$ifdef win32}
  1014. hs:=n+#0;
  1015. i:=Windows.GetShortPathName(@hs[1],@hs2[1],high(hs2));
  1016. if (i>0) and (i<=high(hs2)) then
  1017. begin
  1018. hs2[0]:=chr(strlen(@hs2[1]));
  1019. GetShortName:=hs2;
  1020. end;
  1021. {$endif}
  1022. {$ifdef go32v2}
  1023. hs:=n;
  1024. if Dos.GetShortName(hs) then
  1025. GetShortName:=hs;
  1026. {$endif}
  1027. {$ifdef watcom}
  1028. hs:=n;
  1029. if Dos.GetShortName(hs) then
  1030. GetShortName:=hs;
  1031. {$endif}
  1032. end;
  1033. {****************************************************************************
  1034. OS Dependent things
  1035. ****************************************************************************}
  1036. function GetEnvPChar(const envname:string):pchar;
  1037. {$ifdef win32}
  1038. var
  1039. s : string;
  1040. i,len : longint;
  1041. hp,p,p2 : pchar;
  1042. {$endif}
  1043. begin
  1044. {$ifdef hasunix}
  1045. GetEnvPchar:={$ifdef havelinuxrtl10}Linux.getenv{$else}BaseUnix.fpGetEnv{$endif}(envname);
  1046. {$define GETENVOK}
  1047. {$endif}
  1048. {$ifdef win32}
  1049. GetEnvPchar:=nil;
  1050. p:=GetEnvironmentStrings;
  1051. hp:=p;
  1052. while hp^<>#0 do
  1053. begin
  1054. s:=strpas(hp);
  1055. i:=pos('=',s);
  1056. len:=strlen(hp);
  1057. if upper(copy(s,1,i-1))=upper(envname) then
  1058. begin
  1059. GetMem(p2,len-length(envname));
  1060. Move(hp[i],p2^,len-length(envname));
  1061. GetEnvPchar:=p2;
  1062. break;
  1063. end;
  1064. { next string entry}
  1065. hp:=hp+len+1;
  1066. end;
  1067. FreeEnvironmentStrings(p);
  1068. {$define GETENVOK}
  1069. {$endif}
  1070. {$ifdef os2}
  1071. GetEnvPChar := Dos.GetEnvPChar (EnvName);
  1072. {$define GETENVOK}
  1073. {$endif}
  1074. {$ifdef GETENVOK}
  1075. {$undef GETENVOK}
  1076. {$else}
  1077. GetEnvPchar:=StrPNew({$ifdef delphi}DMisc{$else}Dos{$endif}.Getenv(envname));
  1078. {$endif}
  1079. end;
  1080. procedure FreeEnvPChar(p:pchar);
  1081. begin
  1082. {$ifndef hasunix}
  1083. {$ifndef os2}
  1084. StrDispose(p);
  1085. {$endif}
  1086. {$endif}
  1087. end;
  1088. Procedure Shell(const command:string);
  1089. { This is already defined in the linux.ppu for linux, need for the *
  1090. expansion under linux }
  1091. {$ifdef hasunix}
  1092. begin
  1093. {$ifdef havelinuxrtl10}Linux{$else}Unix{$endif}.Shell(command);
  1094. end;
  1095. {$else}
  1096. {$ifdef amiga}
  1097. begin
  1098. exec('',command);
  1099. end;
  1100. {$else}
  1101. var
  1102. comspec : string;
  1103. begin
  1104. comspec:=getenv('COMSPEC');
  1105. Exec(comspec,' /C '+command);
  1106. end;
  1107. {$endif}
  1108. {$endif}
  1109. {$ifdef CPUI386}
  1110. { later, this should be replaced by the math unit }
  1111. const
  1112. Default8087CW : word = $1332;
  1113. {$ASMMODE ATT}
  1114. procedure Set8087CW(cw:word);assembler;
  1115. asm
  1116. movw cw,%ax
  1117. movw %ax,default8087cw
  1118. fnclex
  1119. fldcw default8087cw
  1120. end;
  1121. function Get8087CW:word;assembler;
  1122. asm
  1123. pushl $0
  1124. fnstcw (%esp)
  1125. popl %eax
  1126. end;
  1127. function SetFPUExceptionMask(const Mask: TFPUExceptionMask): TFPUExceptionMask;
  1128. var
  1129. CtlWord: Word;
  1130. begin
  1131. CtlWord:=Get8087CW;
  1132. Set8087CW( (CtlWord and $FFC0) or Byte(Longint(Mask)) );
  1133. Result:=TFPUExceptionMask(CtlWord and $3F);
  1134. end;
  1135. {$else CPUI386}
  1136. {$ifdef CPUPOWERPC}
  1137. function SetFPUExceptionMask(const Mask: TFPUExceptionMask): TFPUExceptionMask;
  1138. var
  1139. newmask: record
  1140. case byte of
  1141. 1: (d: double);
  1142. 2: (a,b: cardinal);
  1143. end;
  1144. begin
  1145. { load currect control register contents }
  1146. asm
  1147. mffs f0
  1148. stfd f0,newmask.d
  1149. end;
  1150. { invalid operation: bit 24 (big endian, bit 0 = left-most bit) }
  1151. if (exInvalidOp in mask) then
  1152. newmask.b := newmask.b and not(1 shl (31-24))
  1153. else
  1154. newmask.b := newmask.b or (1 shl (31-24));
  1155. { denormals can not cause exceptions on the PPC }
  1156. { zero divide: bit 27 }
  1157. if (exZeroDivide in mask) then
  1158. newmask.b := newmask.b and not(1 shl (31-27))
  1159. else
  1160. newmask.b := newmask.b or (1 shl (31-27));
  1161. { overflow: bit 25 }
  1162. if (exOverflow in mask) then
  1163. newmask.b := newmask.b and not(1 shl (31-25))
  1164. else
  1165. newmask.b := newmask.b or (1 shl (31-25));
  1166. { underflow: bit 26 }
  1167. if (exUnderflow in mask) then
  1168. newmask.b := newmask.b and not(1 shl (31-26))
  1169. else
  1170. newmask.b := newmask.b or (1 shl (31-26));
  1171. { Precision (inexact result): bit 28 }
  1172. if (exUnderflow in mask) then
  1173. newmask.b := newmask.b and not(1 shl (31-28))
  1174. else
  1175. newmask.b := newmask.b or (1 shl (31-28));
  1176. { update control register contents }
  1177. asm
  1178. lfd f0, newmask.d
  1179. mtfsf 255,f0
  1180. end;
  1181. end;
  1182. {$else CPUPOWERPC}
  1183. function SetFPUExceptionMask(const Mask: TFPUExceptionMask): TFPUExceptionMask;
  1184. begin
  1185. end;
  1186. {$endif CPUPOWERPC}
  1187. {$endif CPUI386}
  1188. function is_number_float(d : double) : boolean;
  1189. var
  1190. bytearray : array[0..7] of byte;
  1191. begin
  1192. move(d,bytearray,8);
  1193. { only 1.1 save, 1.0.x will use always little endian }
  1194. {$ifdef FPC_BIG_ENDIAN}
  1195. result:=((bytearray[0] and $7f)<>$7f) or ((bytearray[1] and $f0)<>$f0);
  1196. {$else FPC_BIG_ENDIAN}
  1197. result:=((bytearray[7] and $7f)<>$7f) or ((bytearray[6] and $f0)<>$f0);
  1198. {$endif FPC_BIG_ENDIAN}
  1199. end;
  1200. Function SetCompileMode(const s:string; changeInit: boolean):boolean;
  1201. var
  1202. b : boolean;
  1203. begin
  1204. b:=true;
  1205. if s='DEFAULT' then
  1206. aktmodeswitches:=initmodeswitches
  1207. else
  1208. if s='DELPHI' then
  1209. aktmodeswitches:=delphimodeswitches
  1210. else
  1211. if s='TP' then
  1212. aktmodeswitches:=tpmodeswitches
  1213. else
  1214. if s='FPC' then
  1215. aktmodeswitches:=fpcmodeswitches
  1216. else
  1217. if s='OBJFPC' then
  1218. aktmodeswitches:=objfpcmodeswitches
  1219. else
  1220. if s='GPC' then
  1221. aktmodeswitches:=gpcmodeswitches
  1222. else
  1223. if s='MAC' then
  1224. aktmodeswitches:=macmodeswitches
  1225. else
  1226. b:=false;
  1227. if b and changeInit then
  1228. initmodeswitches := aktmodeswitches;
  1229. if b then
  1230. begin
  1231. { turn ansistrings on by default ? }
  1232. if (m_delphi in aktmodeswitches) then
  1233. begin
  1234. include(aktlocalswitches,cs_ansistrings);
  1235. if changeinit then
  1236. include(initlocalswitches,cs_ansistrings);
  1237. end
  1238. else
  1239. begin
  1240. exclude(aktlocalswitches,cs_ansistrings);
  1241. if changeinit then
  1242. exclude(initlocalswitches,cs_ansistrings);
  1243. end;
  1244. { Default enum packing for delphi/tp7 }
  1245. if (m_tp7 in aktmodeswitches) or
  1246. (m_delphi in aktmodeswitches) then
  1247. aktpackenum:=1
  1248. else
  1249. aktpackenum:=4;
  1250. if changeinit then
  1251. initpackenum:=aktpackenum;
  1252. {$ifdef i386}
  1253. { Default to intel assembler for delphi/tp7 on i386 }
  1254. if (m_delphi in aktmodeswitches) or
  1255. (m_tp7 in aktmodeswitches) then
  1256. aktasmmode:=asmmode_i386_intel;
  1257. if changeinit then
  1258. initasmmode:=aktasmmode;
  1259. {$endif i386}
  1260. end;
  1261. SetCompileMode:=b;
  1262. end;
  1263. function SetAktProcCall(const s:string; changeInit:boolean):boolean;
  1264. const
  1265. DefProcCallName : array[tproccalloption] of string[12] = ('',
  1266. 'CDECL',
  1267. 'CPPDECL',
  1268. '', { compilerproc }
  1269. 'FAR16',
  1270. 'FPCCALL',
  1271. 'INLINE',
  1272. '', { internproc }
  1273. '', { palmossyscall }
  1274. 'PASCAL',
  1275. 'REGISTER',
  1276. 'SAFECALL',
  1277. 'STDCALL',
  1278. 'SOFTFLOAT'
  1279. );
  1280. var
  1281. t : tproccalloption;
  1282. begin
  1283. result:=false;
  1284. for t:=low(tproccalloption) to high(tproccalloption) do
  1285. if DefProcCallName[t]=s then
  1286. begin
  1287. AktDefProcCall:=t;
  1288. result:=true;
  1289. break;
  1290. end;
  1291. if changeinit then
  1292. InitDefProcCall:=AktDefProcCall;
  1293. end;
  1294. function SetProcessor(const s:string; changeInit: boolean):boolean;
  1295. var
  1296. t : tprocessors;
  1297. begin
  1298. SetProcessor:=false;
  1299. for t:=low(tprocessors) to high(tprocessors) do
  1300. if processorsstr[t]=s then
  1301. begin
  1302. aktspecificoptprocessor:=t;
  1303. SetProcessor:=true;
  1304. break;
  1305. end;
  1306. if changeinit then
  1307. initspecificoptprocessor:=aktspecificoptprocessor;
  1308. end;
  1309. function SetFpuType(const s:string; changeInit: boolean):boolean;
  1310. var
  1311. t : tfputype;
  1312. begin
  1313. SetFpuType:=false;
  1314. for t:=low(tfputype) to high(tfputype) do
  1315. if fputypestr[t]=s then
  1316. begin
  1317. aktfputype:=t;
  1318. SetFpuType:=true;
  1319. break;
  1320. end;
  1321. if changeinit then
  1322. initfputype:=aktfputype;
  1323. end;
  1324. { '('D1:'00000000-'D2:'0000-'D3:'0000-'D4:'0000-000000000000)' }
  1325. function string2guid(const s: string; var GUID: TGUID): boolean;
  1326. function ishexstr(const hs: string): boolean;
  1327. var
  1328. i: integer;
  1329. begin
  1330. ishexstr:=false;
  1331. for i:=1 to Length(hs) do begin
  1332. if not (hs[i] in ['0'..'9','A'..'F','a'..'f']) then
  1333. exit;
  1334. end;
  1335. ishexstr:=true;
  1336. end;
  1337. function hexstr2longint(const hexs: string): longint;
  1338. var
  1339. i: integer;
  1340. rl: longint;
  1341. begin
  1342. rl:=0;
  1343. for i:=1 to length(hexs) do begin
  1344. rl:=rl shl 4;
  1345. case hexs[i] of
  1346. '0'..'9' : inc(rl,ord(hexs[i])-ord('0'));
  1347. 'A'..'F' : inc(rl,ord(hexs[i])-ord('A')+10);
  1348. 'a'..'f' : inc(rl,ord(hexs[i])-ord('a')+10);
  1349. end
  1350. end;
  1351. hexstr2longint:=rl;
  1352. end;
  1353. var
  1354. i: integer;
  1355. begin
  1356. if (Length(s)=38) and (s[1]='{') and (s[38]='}') and
  1357. (s[10]='-') and (s[15]='-') and (s[20]='-') and (s[25]='-') and
  1358. ishexstr(copy(s,2,8)) and ishexstr(copy(s,11,4)) and
  1359. ishexstr(copy(s,16,4)) and ishexstr(copy(s,21,4)) and
  1360. ishexstr(copy(s,26,12)) then begin
  1361. GUID.D1:=dword(hexstr2longint(copy(s,2,8)));
  1362. { these values are arealdy in the correct range (4 chars = word) }
  1363. GUID.D2:=word(hexstr2longint(copy(s,11,4)));
  1364. GUID.D3:=word(hexstr2longint(copy(s,16,4)));
  1365. for i:=0 to 1 do
  1366. GUID.D4[i]:=byte(hexstr2longint(copy(s,21+i*2,2)));
  1367. for i:=2 to 7 do
  1368. GUID.D4[i]:=byte(hexstr2longint(copy(s,22+i*2,2)));
  1369. string2guid:=true;
  1370. end
  1371. else
  1372. string2guid:=false;
  1373. end;
  1374. function guid2string(const GUID: TGUID): string;
  1375. function long2hex(l, len: longint): string;
  1376. const
  1377. hextbl: array[0..15] of char = '0123456789ABCDEF';
  1378. var
  1379. rs: string;
  1380. i: integer;
  1381. begin
  1382. rs[0]:=chr(len);
  1383. for i:=len downto 1 do begin
  1384. rs[i]:=hextbl[l and $F];
  1385. l:=l shr 4;
  1386. end;
  1387. long2hex:=rs;
  1388. end;
  1389. begin
  1390. guid2string:=
  1391. '{'+long2hex(GUID.D1,8)+
  1392. '-'+long2hex(GUID.D2,4)+
  1393. '-'+long2hex(GUID.D3,4)+
  1394. '-'+long2hex(GUID.D4[0],2)+long2hex(GUID.D4[1],2)+
  1395. '-'+long2hex(GUID.D4[2],2)+long2hex(GUID.D4[3],2)+
  1396. long2hex(GUID.D4[4],2)+long2hex(GUID.D4[5],2)+
  1397. long2hex(GUID.D4[6],2)+long2hex(GUID.D4[7],2)+
  1398. '}';
  1399. end;
  1400. procedure swap_qword(var q : qword);
  1401. begin
  1402. q:=(qword(lo(q)) shl 32) or hi(q);
  1403. end;
  1404. function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
  1405. var
  1406. tok : string;
  1407. vstr : string;
  1408. l : longint;
  1409. code : integer;
  1410. b : talignmentinfo;
  1411. begin
  1412. UpdateAlignmentStr:=true;
  1413. uppervar(s);
  1414. fillchar(b,sizeof(b),0);
  1415. repeat
  1416. tok:=GetToken(s,'=');
  1417. if tok='' then
  1418. break;
  1419. vstr:=GetToken(s,',');
  1420. val(vstr,l,code);
  1421. if tok='PROC' then
  1422. b.procalign:=l
  1423. else if tok='JUMP' then
  1424. b.jumpalign:=l
  1425. else if tok='LOOP' then
  1426. b.loopalign:=l
  1427. else if tok='CONSTMIN' then
  1428. b.constalignmin:=l
  1429. else if tok='CONSTMAX' then
  1430. b.constalignmax:=l
  1431. else if tok='VARMIN' then
  1432. b.varalignmin:=l
  1433. else if tok='VARMAX' then
  1434. b.varalignmax:=l
  1435. else if tok='LOCALMIN' then
  1436. b.localalignmin:=l
  1437. else if tok='LOCALMAX' then
  1438. b.localalignmax:=l
  1439. else if tok='RECORDMIN' then
  1440. b.recordalignmin:=l
  1441. else if tok='RECORDMAX' then
  1442. b.recordalignmax:=l
  1443. else { Error }
  1444. UpdateAlignmentStr:=false;
  1445. until false;
  1446. UpdateAlignment(a,b);
  1447. end;
  1448. function var_align(siz: longint): longint;
  1449. begin
  1450. siz := size_2_align(siz);
  1451. var_align := used_align(siz,aktalignment.varalignmin,aktalignment.varalignmax);
  1452. end;
  1453. function const_align(siz: longint): longint;
  1454. begin
  1455. siz := size_2_align(siz);
  1456. const_align := used_align(siz,aktalignment.constalignmin,aktalignment.constalignmax);
  1457. end;
  1458. {****************************************************************************
  1459. Init
  1460. ****************************************************************************}
  1461. {$ifdef unix}
  1462. {$define need_path_search}
  1463. {$endif unix}
  1464. {$ifdef os2}
  1465. {$define need_path_search}
  1466. {$endif os2}
  1467. procedure get_exepath;
  1468. var
  1469. hs1 : namestr;
  1470. hs2 : extstr;
  1471. p : pchar;
  1472. begin
  1473. {$ifdef delphi}
  1474. exepath:=dmisc.getenv('PPC_EXEC_PATH');
  1475. {$else delphi}
  1476. exepath:=dos.getenv('PPC_EXEC_PATH');
  1477. {$endif delphi}
  1478. if exepath='' then
  1479. fsplit(FixFileName(system.paramstr(0)),exepath,hs1,hs2);
  1480. {$ifdef need_path_search}
  1481. if exepath='' then
  1482. begin
  1483. if pos(source_info.exeext,hs1) <>
  1484. (length(hs1) - length(source_info.exeext)+1) then
  1485. hs1 := hs1 + source_info.exeext;
  1486. p:=GetEnvPchar('PATH');
  1487. FindFilePChar(hs1,p,exepath);
  1488. FreeEnvPChar(p);
  1489. exepath:=SplitPath(exepath);
  1490. end;
  1491. {$endif need_path_search}
  1492. exepath:=FixPath(exepath,false);
  1493. end;
  1494. procedure DoneGlobals;
  1495. begin
  1496. initdefines.free;
  1497. if assigned(DLLImageBase) then
  1498. StringDispose(DLLImageBase);
  1499. RelocSection:=true;
  1500. RelocSectionSetExplicitly:=false;
  1501. UseDeffileForExport:=true;
  1502. librarysearchpath.Free;
  1503. unitsearchpath.Free;
  1504. objectsearchpath.Free;
  1505. includesearchpath.Free;
  1506. end;
  1507. procedure InitGlobals;
  1508. begin
  1509. get_exepath;
  1510. { reset globals }
  1511. do_build:=false;
  1512. do_release:=false;
  1513. do_make:=true;
  1514. compile_level:=0;
  1515. DLLsource:=false;
  1516. inlining_procedure:=false;
  1517. resolving_forward:=false;
  1518. make_ref:=false;
  1519. { Output }
  1520. OutputFile:='';
  1521. OutputExeDir:='';
  1522. OutputUnitDir:='';
  1523. { Utils directory }
  1524. utilsdirectory:='';
  1525. utilsprefix:='';
  1526. cshared:=false;
  1527. rlinkpath:='';
  1528. { Search Paths }
  1529. librarysearchpath:=TSearchPathList.Create;
  1530. unitsearchpath:=TSearchPathList.Create;
  1531. includesearchpath:=TSearchPathList.Create;
  1532. objectsearchpath:=TSearchPathList.Create;
  1533. { Def file }
  1534. usewindowapi:=false;
  1535. description:='Compiled by FPC '+version_string+' - '+target_cpu_string;
  1536. dllversion:='';
  1537. nwscreenname := '';
  1538. nwthreadname := '';
  1539. nwcopyright := '';
  1540. { Init values }
  1541. initmodeswitches:=fpcmodeswitches;
  1542. initlocalswitches:=[cs_check_io,cs_typed_const_writable];
  1543. initmoduleswitches:=[cs_extsyntax,cs_implicit_exceptions];
  1544. initsourcecodepage:='8859-1';
  1545. initglobalswitches:=[cs_check_unit_name,cs_link_static{$ifdef INTERNALLINKER},cs_link_internal,cs_link_map{$endif}];
  1546. initoutputformat:=target_asm.id;
  1547. fillchar(initalignment,sizeof(talignmentinfo),0);
  1548. { might be overridden later }
  1549. initasmmode:=asmmode_standard;
  1550. {$ifdef i386}
  1551. initoptprocessor:=Class386;
  1552. initspecificoptprocessor:=Class386;
  1553. initfputype:=fpu_x87;
  1554. initpackrecords:=4;
  1555. initpackenum:=4;
  1556. {$IFDEF testvarsets}
  1557. initsetalloc:=0;
  1558. {$ENDIF}
  1559. initasmmode:=asmmode_i386_att;
  1560. {$endif i386}
  1561. {$ifdef m68k}
  1562. initoptprocessor:=MC68020;
  1563. initpackrecords:=2;
  1564. initpackenum:=4;
  1565. {$IFDEF testvarsets}
  1566. initsetalloc:=0;
  1567. {$ENDIF}
  1568. {$endif m68k}
  1569. {$ifdef powerpc}
  1570. initoptprocessor:=PPC604;
  1571. initpackrecords:=4;
  1572. initpackenum:=4;
  1573. {$IFDEF testvarsets}
  1574. initsetalloc:=0;
  1575. {$ENDIF}
  1576. initfputype:=fpu_standard;
  1577. {$endif powerpc}
  1578. {$ifdef sparc}
  1579. initoptprocessor:=SPARC_V8;
  1580. initpackrecords:=8;
  1581. initpackenum:=4;
  1582. {$IFDEF testvarsets}
  1583. initsetalloc:=0;
  1584. {$ENDIF}
  1585. {$endif sparc}
  1586. {$ifdef arm}
  1587. initpackrecords:=4;
  1588. initpackenum:=4;
  1589. {$IFDEF testvarsets}
  1590. initsetalloc:=0;
  1591. {$ENDIF}
  1592. initfputype:=fpu_fpa;
  1593. {$endif arm}
  1594. {$ifdef x86_64}
  1595. initoptprocessor:=ClassAthlon64;
  1596. initspecificoptprocessor:=ClassAthlon64;
  1597. initfputype:=fpu_sse64;
  1598. initpackrecords:=8;
  1599. initpackenum:=4;
  1600. {$IFDEF testvarsets}
  1601. initsetalloc:=0;
  1602. {$ENDIF}
  1603. initasmmode:=asmmode_x86_64_gas;
  1604. {$endif x86_64}
  1605. initinterfacetype:=it_interfacecom;
  1606. initdefproccall:=pocall_default;
  1607. initdefines:=TStringList.Create;
  1608. { memory sizes, will be overriden by parameter or default for target
  1609. in options or init_parser }
  1610. stacksize:=0;
  1611. heapsize:=0;
  1612. apptype:=app_cui;
  1613. end;
  1614. end.
  1615. {
  1616. $Log$
  1617. Revision 1.124 2004-02-08 16:38:51 florian
  1618. + PtrInt declared if VER1_0
  1619. Revision 1.123 2004/01/28 22:16:31 peter
  1620. * more record alignment fixes
  1621. Revision 1.122 2004/01/28 21:05:56 florian
  1622. * fixed alignment of classes
  1623. Revision 1.121 2004/01/14 23:39:05 florian
  1624. * another bunch of x86-64 fixes mainly calling convention and
  1625. assembler reader related
  1626. Revision 1.120 2004/01/12 16:36:53 peter
  1627. * removed asmmode_direct
  1628. Revision 1.119 2004/01/02 16:50:24 jonas
  1629. + SetFPUExceptionMask implementation for PPC
  1630. Revision 1.118 2003/12/25 01:07:09 florian
  1631. + $fputype directive support
  1632. + single data type operations with sse unit
  1633. * fixed more x86-64 stuff
  1634. Revision 1.117 2003/12/20 12:38:51 florian
  1635. * some x86-64 compilation fixe
  1636. Revision 1.116 2003/11/30 19:35:29 florian
  1637. * fixed several arm related problems
  1638. Revision 1.115 2003/11/12 16:05:39 florian
  1639. * assembler readers OOPed
  1640. + typed currency constants
  1641. + typed 128 bit float constants if the CPU supports it
  1642. Revision 1.114 2003/11/10 17:22:28 marco
  1643. * havelinuxrtl10 fixes
  1644. Revision 1.113 2003/11/07 15:58:32 florian
  1645. * Florian's culmutative nr. 1; contains:
  1646. - invalid calling conventions for a certain cpu are rejected
  1647. - arm softfloat calling conventions
  1648. - -Sp for cpu dependend code generation
  1649. - several arm fixes
  1650. - remaining code for value open array paras on heap
  1651. Revision 1.112 2003/10/23 17:18:56 peter
  1652. * delphi mode uses packenum 1
  1653. Revision 1.111 2003/10/22 15:40:44 marco
  1654. * -Xc -Xr support
  1655. Revision 1.110 2003/10/22 15:22:33 peter
  1656. * fixed unitsym-globalsymtable relation so the uses of a unit
  1657. is counted correctly
  1658. Revision 1.109 2003/10/11 19:32:04 marco
  1659. * -Xd
  1660. Revision 1.108 2003/10/08 14:10:16 mazen
  1661. + ASMMODE ATT added to bypass fpc.cfg defaults
  1662. Revision 1.107 2003/10/03 22:00:33 peter
  1663. * parameter alignment fixes
  1664. Revision 1.106 2003/10/03 14:16:48 marco
  1665. * -XP<prefix> support
  1666. Revision 1.105 2003/10/02 21:16:18 peter
  1667. * delphi and tp7 mode use intel asm by default
  1668. Revision 1.104 2003/10/01 20:34:48 peter
  1669. * procinfo unit contains tprocinfo
  1670. * cginfo renamed to cgbase
  1671. * moved cgmessage to verbose
  1672. * fixed ppc and sparc compiles
  1673. Revision 1.103 2003/09/24 17:13:22 florian
  1674. + processor type intialization for x86-64 added
  1675. Revision 1.102 2003/09/18 15:38:17 marco
  1676. * BSD 1.0.x still uses st_ prefixes.
  1677. Revision 1.101 2003/09/16 16:17:01 peter
  1678. * varspez in calls to push_addr_param
  1679. Revision 1.100 2003/09/15 20:11:06 marco
  1680. * fixed
  1681. Revision 1.99 2003/09/14 20:26:18 marco
  1682. * Unix reform
  1683. Revision 1.98 2003/09/14 12:55:06 jonas
  1684. * fixed compilation for non-x86
  1685. Revision 1.97 2003/09/07 22:09:34 peter
  1686. * preparations for different default calling conventions
  1687. * various RA fixes
  1688. Revision 1.96 2003/09/06 16:47:24 florian
  1689. + support of NaN and Inf in the compiler as values of real constants
  1690. Revision 1.95 2003/09/05 17:41:12 florian
  1691. * merged Wiktor's Watcom patches in 1.1
  1692. Revision 1.94 2003/09/04 21:37:29 olle
  1693. + added new lagnuage mode: MAC
  1694. Revision 1.93 2003/09/03 11:18:36 florian
  1695. * fixed arm concatcopy
  1696. + arm support in the common compiler sources added
  1697. * moved some generic cg code around
  1698. + tfputype added
  1699. * ...
  1700. Revision 1.92 2003/05/23 22:33:48 florian
  1701. * fix some small flaws which prevent sparc linux system unit from compiling
  1702. * some reformatting done
  1703. Revision 1.91 2003/05/23 15:03:31 peter
  1704. * fix previous commit for unix
  1705. Revision 1.90 2003/05/23 14:39:56 peter
  1706. * FindFilePChar added to allow PATH variables > 256 chars
  1707. Revision 1.89 2003/05/15 18:58:53 peter
  1708. * removed selfpointer_offset, vmtpointer_offset
  1709. * tvarsym.adjusted_address
  1710. * address in localsymtable is now in the real direction
  1711. * removed some obsolete globals
  1712. Revision 1.88 2003/04/27 11:21:32 peter
  1713. * aktprocdef renamed to current_procdef
  1714. * procinfo renamed to current_procinfo
  1715. * procinfo will now be stored in current_module so it can be
  1716. cleaned up properly
  1717. * gen_main_procsym changed to create_main_proc and release_main_proc
  1718. to also generate a tprocinfo structure
  1719. * fixed unit implicit initfinal
  1720. Revision 1.87 2003/04/27 07:29:50 peter
  1721. * current_procdef cleanup, current_procdef is now always nil when parsing
  1722. a new procdef declaration
  1723. * aktprocsym removed
  1724. * lexlevel removed, use symtable.symtablelevel instead
  1725. * implicit init/final code uses the normal genentry/genexit
  1726. * funcret state checking updated for new funcret handling
  1727. Revision 1.86 2003/04/25 20:59:33 peter
  1728. * removed funcretn,funcretsym, function result is now in varsym
  1729. and aliases for result and function name are added using absolutesym
  1730. * vs_hidden parameter for funcret passed in parameter
  1731. * vs_hidden fixes
  1732. * writenode changed to printnode and released from extdebug
  1733. * -vp option added to generate a tree.log with the nodetree
  1734. * nicer printnode for statements, callnode
  1735. Revision 1.85 2003/04/22 14:33:38 peter
  1736. * removed some notes/hints
  1737. Revision 1.84 2003/03/23 23:21:42 hajny
  1738. + emx target added
  1739. Revision 1.83 2003/01/30 21:45:53 peter
  1740. * amiga path fix (merged)
  1741. Revision 1.82 2003/01/12 15:42:23 peter
  1742. * m68k pathexist update from 1.0.x
  1743. * palmos res update from 1.0.x
  1744. Revision 1.81 2003/01/10 21:49:00 marco
  1745. * more hasunix fixes
  1746. Revision 1.80 2003/01/04 16:20:44 hajny
  1747. * modified to make use of the common GetEnv code under OS/2
  1748. Revision 1.79 2002/12/25 01:26:17 peter
  1749. * delphi also has pointer archimetic
  1750. Revision 1.78 2002/12/07 14:27:07 carl
  1751. * 3% memory optimization
  1752. * changed some types
  1753. + added type checking with different size for call node and for
  1754. parameters
  1755. Revision 1.77 2002/12/06 17:50:00 peter
  1756. * amiga fixes merged
  1757. Revision 1.76 2002/12/01 22:07:41 carl
  1758. * warning of portabilitiy problems with parasize / localsize
  1759. + some added documentation
  1760. Revision 1.75 2002/11/30 23:13:48 carl
  1761. - cs_fp_emulation is no longer automatic for m68k target
  1762. Revision 1.74 2002/11/30 11:08:46 carl
  1763. * fix bug n last commit (this bug was only detected gby 1.0.x, fixed)
  1764. Revision 1.73 2002/11/30 00:34:20 pierre
  1765. * remove double in delphimodeswitches to allow compilation with -Cr option
  1766. Revision 1.72 2002/11/29 22:31:19 carl
  1767. + unimplemented hint directive added
  1768. * hint directive parsing implemented
  1769. * warning on these directives
  1770. Revision 1.71 2002/11/20 10:11:46 mazen
  1771. + TSearchPathList.AddPath supports a local path in addition to file name
  1772. Revision 1.70 2002/11/16 14:49:12 carl
  1773. - browser information is off by default
  1774. Revision 1.69 2002/11/15 01:58:47 peter
  1775. * merged changes from 1.0.7 up to 04-11
  1776. - -V option for generating bug report tracing
  1777. - more tracing for option parsing
  1778. - errors for cdecl and high()
  1779. - win32 import stabs
  1780. - win32 records<=8 are returned in eax:edx (turned off by default)
  1781. - heaptrc update
  1782. - more info for temp management in .s file with EXTDEBUG
  1783. Revision 1.68 2002/11/09 15:38:39 carl
  1784. + added var_align/const_align routines
  1785. Revision 1.67 2002/10/16 19:01:43 peter
  1786. + $IMPLICITEXCEPTIONS switch to turn on/off generation of the
  1787. implicit exception frames for procedures with initialized variables
  1788. and for constructors. The default is on for compatibility
  1789. Revision 1.66 2002/09/05 19:28:29 peter
  1790. * removed repetitive pass counting
  1791. * display heapsize also for extdebug
  1792. Revision 1.65 2002/08/19 19:36:42 peter
  1793. * More fixes for cross unit inlining, all tnodes are now implemented
  1794. * Moved pocall_internconst to po_internconst because it is not a
  1795. calling type at all and it conflicted when inlining of these small
  1796. functions was requested
  1797. Revision 1.64 2002/08/12 15:08:39 carl
  1798. + stab register indexes for powerpc (moved from gdb to cpubase)
  1799. + tprocessor enumeration moved to cpuinfo
  1800. + linker in target_info is now a class
  1801. * many many updates for m68k (will soon start to compile)
  1802. - removed some ifdef or correct them for correct cpu
  1803. Revision 1.63 2002/08/10 14:46:29 carl
  1804. + moved target_cpu_string to cpuinfo
  1805. * renamed asmmode enum.
  1806. * assembler reader has now less ifdef's
  1807. * move from nppcmem.pas -> ncgmem.pas vec. node.
  1808. Revision 1.62 2002/07/28 20:45:22 florian
  1809. + added direct assembler reader for PowerPC
  1810. Revision 1.61 2002/07/20 17:12:42 florian
  1811. + source code page support
  1812. Revision 1.60 2002/07/01 18:46:22 peter
  1813. * internal linker
  1814. * reorganized aasm layer
  1815. Revision 1.59 2002/07/01 16:23:52 peter
  1816. * cg64 patch
  1817. * basics for currency
  1818. * asnode updates for class and interface (not finished)
  1819. Revision 1.58 2002/05/18 13:34:08 peter
  1820. * readded missing revisions
  1821. Revision 1.57 2002/05/16 19:46:36 carl
  1822. + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
  1823. + try to fix temp allocation (still in ifdef)
  1824. + generic constructor calls
  1825. + start of tassembler / tmodulebase class cleanup
  1826. Revision 1.55 2002/04/20 21:32:23 carl
  1827. + generic FPC_CHECKPOINTER
  1828. + first parameter offset in stack now portable
  1829. * rename some constants
  1830. + move some cpu stuff to other units
  1831. - remove unused constents
  1832. * fix stacksize for some targets
  1833. * fix generic size problems which depend now on EXTEND_SIZE constant
  1834. Revision 1.54 2002/04/07 13:24:30 carl
  1835. + moved constant from cpuinfo, these are NOT cpu specific
  1836. constant, but more related to compiler functionality.
  1837. Revision 1.53 2002/04/02 17:11:28 peter
  1838. * tlocation,treference update
  1839. * LOC_CONSTANT added for better constant handling
  1840. * secondadd splitted in multiple routines
  1841. * location_force_reg added for loading a location to a register
  1842. of a specified size
  1843. * secondassignment parses now first the right and then the left node
  1844. (this is compatible with Kylix). This saves a lot of push/pop especially
  1845. with string operations
  1846. * adapted some routines to use the new cg methods
  1847. Revision 1.52 2002/03/28 16:07:52 armin
  1848. + initialize threadvars defined local in units
  1849. Revision 1.51 2002/01/24 18:25:48 peter
  1850. * implicit result variable generation for assembler routines
  1851. * removed m_tp modeswitch, use m_tp7 or not(m_fpc) instead
  1852. }