globals.pas 60 KB

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