globals.pas 64 KB

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