globals.pas 65 KB

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