globals.pas 60 KB

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