generic.inc 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by the Free Pascal development team.
  5. Processor independent implementation for the system unit
  6. (adapted for intel i386.inc file)
  7. See the file COPYING.FPC, included in this distribution,
  8. for details about the copyright.
  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.
  12. **********************************************************************}
  13. {****************************************************************************
  14. Primitives
  15. ****************************************************************************}
  16. type
  17. pstring = ^shortstring;
  18. {$ifndef FPC_SYSTEM_HAS_MOVE}
  19. procedure Move(const source;var dest;count:longint);
  20. type
  21. bytearray = array [0..maxlongint-1] of byte;
  22. var
  23. i:longint;
  24. begin
  25. if count <= 0 then exit;
  26. Dec(count);
  27. if @source<@dest then
  28. begin
  29. for i:=count downto 0 do
  30. bytearray(dest)[i]:=bytearray(source)[i];
  31. end
  32. else
  33. begin
  34. for i:=0 to count do
  35. bytearray(dest)[i]:=bytearray(source)[i];
  36. end;
  37. end;
  38. {$endif not FPC_SYSTEM_HAS_MOVE}
  39. {$ifndef FPC_SYSTEM_HAS_FILLCHAR}
  40. Procedure FillChar(var x;count:longint;value:byte);
  41. type
  42. longintarray = array [0..maxlongint div 4] of longint;
  43. bytearray = array [0..maxlongint-1] of byte;
  44. var
  45. i,v : longint;
  46. begin
  47. if count <= 0 then exit;
  48. v := 0;
  49. { aligned? }
  50. if (PtrUInt(@x) mod sizeof(PtrUInt))<>0 then
  51. begin
  52. for i:=0 to count-1 do
  53. bytearray(x)[i]:=value;
  54. end
  55. else
  56. begin
  57. v:=(value shl 8) or (value and $FF);
  58. v:=(v shl 16) or (v and $ffff);
  59. for i:=0 to (count div 4)-1 do
  60. longintarray(x)[i]:=v;
  61. for i:=(count div 4)*4 to count-1 do
  62. bytearray(x)[i]:=value;
  63. end;
  64. end;
  65. {$endif FPC_SYSTEM_HAS_FILLCHAR}
  66. {$ifndef FPC_SYSTEM_HAS_FILLBYTE}
  67. procedure FillByte (var x;count : longint;value : byte );
  68. begin
  69. FillChar (X,Count,CHR(VALUE));
  70. end;
  71. {$endif not FPC_SYSTEM_HAS_FILLBYTE}
  72. {$ifndef FPC_SYSTEM_HAS_FILLWORD}
  73. procedure fillword(var x;count : longint;value : word);
  74. type
  75. longintarray = array [0..maxlongint div 4] of longint;
  76. wordarray = array [0..maxlongint div 2] of word;
  77. var
  78. i,v : longint;
  79. begin
  80. if Count <= 0 then exit;
  81. { aligned? }
  82. if (PtrUInt(@x) mod sizeof(PtrUInt))<>0 then
  83. begin
  84. for i:=0 to count-1 do
  85. wordarray(x)[i]:=value;
  86. end
  87. else
  88. begin
  89. v:=value*$10000+value;
  90. for i:=0 to (count div 2) -1 do
  91. longintarray(x)[i]:=v;
  92. for i:=(count div 2)*2 to count-1 do
  93. wordarray(x)[i]:=value;
  94. end;
  95. end;
  96. {$endif not FPC_SYSTEM_HAS_FILLWORD}
  97. {$ifndef FPC_SYSTEM_HAS_FILLDWORD}
  98. procedure FillDWord(var x;count : longint;value : DWord);
  99. type
  100. longintarray = array [0..maxlongint div 4] of longint;
  101. begin
  102. if count <= 0 then exit;
  103. while Count<>0 do
  104. begin
  105. { range checking must be disabled here }
  106. longintarray(x)[count-1]:=longint(value);
  107. Dec(count);
  108. end;
  109. end;
  110. {$endif FPC_SYSTEM_HAS_FILLDWORD}
  111. {$ifndef FPC_SYSTEM_HAS_INDEXCHAR}
  112. function IndexChar(Const buf;len:longint;b:char):longint;
  113. begin
  114. IndexChar:=IndexByte(Buf,Len,byte(B));
  115. end;
  116. {$endif not FPC_SYSTEM_HAS_INDEXCHAR}
  117. {$ifndef FPC_SYSTEM_HAS_INDEXBYTE}
  118. function IndexByte(Const buf;len:longint;b:byte):longint;
  119. type
  120. bytearray = array [0..maxlongint-1] of byte;
  121. var
  122. I : longint;
  123. begin
  124. I:=0;
  125. { simulate assembler implementations behaviour, which is expected }
  126. { fpc_pchar_to_ansistr in astrings.inc }
  127. if (len < 0) then
  128. len := high(longint);
  129. while (I<Len) and (bytearray(buf)[I]<>b) do
  130. inc(I);
  131. if (i=Len) then
  132. i:=-1; {Can't use 0, since it is a possible value}
  133. IndexByte:=I;
  134. end;
  135. {$endif not FPC_SYSTEM_HAS_INDEXBYTE}
  136. {$ifndef FPC_SYSTEM_HAS_INDEXWORD}
  137. function Indexword(Const buf;len:longint;b:word):longint;
  138. type
  139. wordarray = array [0..maxlongint div 2] of word;
  140. var
  141. I : longint;
  142. begin
  143. I:=0;
  144. if (len < 0) then
  145. len := high(longint);
  146. while (I<Len) and (wordarray(buf)[I]<>b) do
  147. inc(I);
  148. if (i=Len) then
  149. i:=-1; {Can't use 0, since it is a possible value for index}
  150. Indexword:=I;
  151. end;
  152. {$endif not FPC_SYSTEM_HAS_INDEXWORD}
  153. {$ifndef FPC_SYSTEM_HAS_INDEXDWORD}
  154. function IndexDWord(Const buf;len:longint;b:DWord):longint;
  155. type
  156. longintarray = array [0..maxlongint div 4] of longint;
  157. var
  158. I : longint;
  159. begin
  160. I:=0;
  161. if (len < 0) then
  162. len := high(longint);
  163. while (I<Len) and (longintarray(buf)[I]<>b) do inc(I);
  164. if (i=Len) then
  165. i:=-1; {Can't use 0, since it is a possible value for index}
  166. IndexDWord:=I;
  167. end;
  168. {$endif not FPC_SYSTEM_HAS_INDEXDWORD}
  169. {$ifndef FPC_SYSTEM_HAS_COMPARECHAR}
  170. function CompareChar(Const buf1,buf2;len:longint):longint;
  171. begin
  172. CompareChar:=CompareByte(buf1,buf2,len);
  173. end;
  174. {$endif not FPC_SYSTEM_HAS_COMPARECHAR}
  175. {$ifndef FPC_SYSTEM_HAS_COMPAREBYTE}
  176. function CompareByte(Const buf1,buf2;len:longint):longint;
  177. type
  178. bytearray = array [0..maxlongint-1] of byte;
  179. var
  180. I : longint;
  181. begin
  182. I:=0;
  183. if (Len<>0) and (@Buf1<>@Buf2) then
  184. begin
  185. while (bytearray(Buf1)[I]=bytearray(Buf2)[I]) and (I<Len) do
  186. inc(I);
  187. if I=Len then {No difference}
  188. I:=0
  189. else
  190. begin
  191. I:=bytearray(Buf1)[I]-bytearray(Buf2)[I];
  192. if I>0 then
  193. I:=1
  194. else
  195. if I<0 then
  196. I:=-1;
  197. end;
  198. end;
  199. CompareByte:=I;
  200. end;
  201. {$endif not FPC_SYSTEM_HAS_COMPAREBYTE}
  202. {$ifndef FPC_SYSTEM_HAS_COMPAREWORD}
  203. function CompareWord(Const buf1,buf2;len:longint):longint;
  204. type
  205. wordarray = array [0..maxlongint div 2] of word;
  206. var
  207. I : longint;
  208. begin
  209. I:=0;
  210. if (Len<>0) and (@Buf1<>@Buf2) then
  211. begin
  212. while (wordarray(Buf1)[I]=wordarray(Buf2)[I]) and (I<Len) do
  213. inc(I);
  214. if I=Len then {No difference}
  215. I:=0
  216. else
  217. begin
  218. I:=wordarray(Buf1)[I]-wordarray(Buf2)[I];
  219. if I>0 then
  220. I:=1
  221. else
  222. if I<0 then
  223. I:=-1;
  224. end;
  225. end;
  226. CompareWord:=I;
  227. end;
  228. {$endif not FPC_SYSTEM_HAS_COMPAREWORD}
  229. {$ifndef FPC_SYSTEM_HAS_COMPAREDWORD}
  230. function CompareDWord(Const buf1,buf2;len:longint):longint;
  231. type
  232. longintarray = array [0..maxlongint div 4] of longint;
  233. var
  234. I : longint;
  235. begin
  236. I:=0;
  237. if (Len<>0) and (@Buf1<>@Buf2) then
  238. begin
  239. while (longintarray(Buf1)[I]=longintarray(Buf2)[I]) and (I<Len) do
  240. inc(I);
  241. if I=Len then {No difference}
  242. I:=0
  243. else
  244. begin
  245. I:=longintarray(Buf1)[I]-longintarray(Buf2)[I];
  246. if I>0 then
  247. I:=1
  248. else
  249. if I<0 then
  250. I:=-1;
  251. end;
  252. end;
  253. CompareDWord:=I;
  254. end;
  255. {$endif ndef FPC_SYSTEM_HAS_COMPAREDWORD}
  256. {$ifndef FPC_SYSTEM_HAS_MOVECHAR0}
  257. procedure MoveChar0(Const buf1;var buf2;len:longint);
  258. var
  259. I : longint;
  260. begin
  261. if Len = 0 then exit;
  262. I:=IndexByte(Buf1,Len,0);
  263. if I<>-1 then
  264. Move(Buf1,Buf2,I)
  265. else
  266. Move(Buf1,Buf2,len);
  267. end;
  268. {$endif ndef FPC_SYSTEM_HAS_MOVECHAR0}
  269. {$ifndef FPC_SYSTEM_HAS_INDEXCHAR0}
  270. function IndexChar0(Const buf;len:longint;b:Char):longint;
  271. var
  272. I : longint;
  273. begin
  274. if Len<>0 then
  275. begin
  276. I:=IndexByte(Buf,Len,0);
  277. IndexChar0:=IndexByte(Buf,I,0);
  278. end
  279. else
  280. IndexChar0:=0;
  281. end;
  282. {$endif ndef FPC_SYSTEM_HAS_INDEXCHAR0}
  283. {$ifndef FPC_SYSTEM_HAS_COMPARECHAR0}
  284. function CompareChar0(Const buf1,buf2;len:longint):longint;
  285. type
  286. bytearray = array [0..maxlongint-1] of byte;
  287. Var i : longint;
  288. begin
  289. I:=0;
  290. if (Len<>0) and (@Buf1<>@Buf2) then
  291. begin
  292. while (I<Len) And
  293. ((Pbyte(@Buf1)[i]<>0) and (PByte(@buf2)[i]<>0)) and
  294. (pbyte(@Buf1)[I]=pbyte(@Buf2)[I]) do
  295. inc(I);
  296. if (I=Len) or
  297. (PByte(@Buf1)[i]=0) or
  298. (PByte(@buf2)[I]=0) then {No difference or 0 reached }
  299. I:=0
  300. else
  301. begin
  302. I:=bytearray(Buf1)[I]-bytearray(Buf2)[I];
  303. if I>0 then
  304. I:=1
  305. else
  306. if I<0 then
  307. I:=-1;
  308. end;
  309. end;
  310. CompareChar0:=I;
  311. end;
  312. {$endif not FPC_SYSTEM_HAS_COMPARECHAR0}
  313. {****************************************************************************
  314. Object Helpers
  315. ****************************************************************************}
  316. {$ifndef FPC_SYSTEM_HAS_FPC_HELP_CONSTRUCTOR}
  317. { Note: _vmt will be reset to -1 when memory is allocated,
  318. this is needed for fpc_help_fail }
  319. function fpc_help_constructor(_self:pointer;var _vmt:pointer;_vmt_pos:cardinal):pointer;[public,alias:'FPC_HELP_CONSTRUCTOR'];{$ifdef hascompilerproc}compilerproc;{$endif}
  320. type
  321. ppointer = ^pointer;
  322. pvmt = ^tvmt;
  323. tvmt=packed record
  324. size,msize:longint;
  325. parent:pointer;
  326. end;
  327. var
  328. vmtcopy : pointer;
  329. begin
  330. { Inherited call? }
  331. if _vmt=nil then
  332. begin
  333. fpc_help_constructor:=_self;
  334. exit;
  335. end;
  336. vmtcopy:=_vmt;
  337. if (_self=nil) and
  338. (pvmt(_vmt)^.size>0) then
  339. begin
  340. getmem(_self,pvmt(_vmt)^.size);
  341. { reset vmt needed for fail }
  342. _vmt:=pointer(-1);
  343. end;
  344. if _self<>nil then
  345. begin
  346. fillchar(_self^,pvmt(vmtcopy)^.size,#0);
  347. ppointer(_self+_vmt_pos)^:=vmtcopy;
  348. end;
  349. fpc_help_constructor:=_self;
  350. end;
  351. {$endif FPC_SYSTEM_HAS_FPC_HELP_CONSTRUCTOR}
  352. {$ifndef FPC_SYSTEM_HAS_FPC_HELP_DESTRUCTOR}
  353. { Note: _self will not be reset, the compiler has to generate the reset }
  354. procedure fpc_help_destructor(_self,_vmt:pointer;vmt_pos:cardinal);[public,alias:'FPC_HELP_DESTRUCTOR']; {$ifdef hascompilerproc} compilerproc; {$endif}
  355. type
  356. ppointer = ^pointer;
  357. pvmt = ^tvmt;
  358. tvmt = packed record
  359. size,msize : longint;
  360. parent : pointer;
  361. end;
  362. begin
  363. { already released? }
  364. if (_self=nil) or
  365. (_vmt=nil) or
  366. (ppointer(_self+vmt_pos)^=nil) then
  367. exit;
  368. if (pvmt(ppointer(_self+vmt_pos)^)^.size=0) or
  369. (pvmt(ppointer(_self+vmt_pos)^)^.size+pvmt(ppointer(_self+vmt_pos)^)^.msize<>0) then
  370. RunError(210);
  371. { reset vmt to nil for protection }
  372. ppointer(_self+vmt_pos)^:=nil;
  373. freemem(_self);
  374. end;
  375. {$endif FPC_SYSTEM_HAS_FPC_HELP_DESTRUCTOR}
  376. {$ifndef FPC_SYSTEM_HAS_FPC_HELP_FAIL}
  377. { Note: _self will not be reset, the compiler has to generate the reset }
  378. procedure fpc_help_fail(_self:pointer;var _vmt:pointer;vmt_pos:cardinal);[public,alias:'FPC_HELP_FAIL'];compilerproc;
  379. type
  380. ppointer = ^pointer;
  381. pvmt = ^tvmt;
  382. tvmt = packed record
  383. size,msize : longint;
  384. parent : pointer;
  385. end;
  386. begin
  387. if (_self=nil) or (_vmt=nil) then
  388. exit;
  389. { vmt=-1 when memory was allocated }
  390. if longint(_vmt)=-1 then
  391. begin
  392. if (_self=nil) or (ppointer(_self+vmt_pos)^=nil) then
  393. HandleError(210)
  394. else
  395. begin
  396. ppointer(_self+vmt_pos)^:=nil;
  397. freemem(_self);
  398. { reset _vmt to nil so it will not be freed a
  399. second time }
  400. _vmt:=nil;
  401. end;
  402. end
  403. else
  404. ppointer(_self+vmt_pos)^:=nil;
  405. end;
  406. {$endif FPC_SYSTEM_HAS_FPC_HELP_FAIL}
  407. {$ifndef NOCLASSHELPERS}
  408. {$ifndef FPC_SYSTEM_HAS_FPC_NEW_CLASS}
  409. function fpc_new_class(_self,_vmt:pointer):pointer;[public,alias:'FPC_NEW_CLASS']; {$ifdef hascompilerproc} compilerproc; {$endif}
  410. begin
  411. { Inherited call? }
  412. if _vmt=nil then
  413. begin
  414. fpc_new_class:=_self;
  415. exit;
  416. end;
  417. fpc_new_class := tclass(_vmt).NewInstance
  418. end;
  419. {$endif FPC_SYSTEM_HAS_FPC_NEW_CLASS}
  420. {$ifndef FPC_SYSTEM_HAS_FPC_DISPOSE_CLASS}
  421. procedure fpc_dispose_class(_self: pointer; flag : longint);[public,alias:'FPC_DISPOSE_CLASS'];compilerproc;
  422. begin
  423. { inherited -> flag = 0 -> no destroy }
  424. { normal -> flag = 1 -> destroy }
  425. if (_self <> nil) and (flag = 1) then
  426. tobject(_self).FreeInstance;
  427. end;
  428. {$endif ndef FPC_SYSTEM_HAS_FPC_DISPOSE_CLASS}
  429. {$endif NOCLASSHELPERS}
  430. {$ifndef FPC_SYSTEM_HAS_FPC_CHECK_OBJECT}
  431. procedure fpc_check_object(_vmt : pointer);saveregisters;[public,alias:'FPC_CHECK_OBJECT']; {$ifdef hascompilerproc} compilerproc; {$endif}
  432. type
  433. pvmt = ^tvmt;
  434. tvmt = packed record
  435. size,msize : longint;
  436. parent : pointer;
  437. end;
  438. begin
  439. if (_vmt=nil) or
  440. (pvmt(_vmt)^.size=0) or
  441. (pvmt(_vmt)^.size+pvmt(_vmt)^.msize<>0) then
  442. RunError(210);
  443. end;
  444. {$endif ndef FPC_SYSTEM_HAS_FPC_CHECK_OBJECT}
  445. {$ifndef FPC_SYSTEM_HAS_FPC_CHECK_OBJECT_EXT}
  446. { checks for a correct vmt pointer }
  447. { deeper check to see if the current object is }
  448. { really related to the true }
  449. procedure fpc_check_object_ext(vmt, expvmt : pointer);saveregisters;[public,alias:'FPC_CHECK_OBJECT_EXT']; {$ifdef hascompilerproc} compilerproc; {$endif}
  450. type
  451. pvmt = ^tvmt;
  452. tvmt = packed record
  453. size,msize : longint;
  454. parent : pointer;
  455. end;
  456. begin
  457. if (vmt=nil) or
  458. (pvmt(vmt)^.size=0) or
  459. (pvmt(vmt)^.size+pvmt(vmt)^.msize<>0) then
  460. RunError(210);
  461. while assigned(vmt) do
  462. if vmt=expvmt then
  463. exit
  464. else
  465. vmt:=pvmt(vmt)^.parent;
  466. RunError(219);
  467. end;
  468. {$endif not FPC_SYSTEM_HAS_FPC_CHECK_OBJECT_EXT}
  469. {****************************************************************************
  470. String
  471. ****************************************************************************}
  472. {$ifndef FPC_SYSTEM_HAS_FPC_SHORTSTR_ASSIGN}
  473. function fpc_shortstr_to_shortstr(len:longint;const sstr:shortstring): shortstring;[public,alias:'FPC_SHORTSTR_TO_SHORTSTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
  474. var
  475. slen : byte;
  476. begin
  477. slen:=length(sstr);
  478. if slen<len then
  479. len:=slen;
  480. move(sstr[0],result[0],len+1);
  481. if slen>len then
  482. result[0]:=chr(len);
  483. end;
  484. {$ifdef interncopy}
  485. procedure fpc_shortstr_assign(len:longint;sstr,dstr:pointer);[public,alias:'FPC_SHORTSTR_ASSIGN']; {$ifdef HAS_COMPILER_PROC} compilerproc; {$endif}
  486. {$else}
  487. procedure fpc_shortstr_copy(len:longint;sstr,dstr:pointer);[public,alias:'FPC_SHORTSTR_COPY']; {$ifdef HAS_COMPILER_PROC} compilerproc; {$endif}
  488. {$endif}
  489. var
  490. slen : byte;
  491. type
  492. pstring = ^string;
  493. begin
  494. slen:=length(pstring(sstr)^);
  495. if slen<len then
  496. len:=slen;
  497. move(sstr^,dstr^,len+1);
  498. if slen>len then
  499. pchar(dstr)^:=chr(len);
  500. end;
  501. {$endif ndef FPC_SYSTEM_HAS_FPC_SHORTSTR_ASSIGN}
  502. {$ifndef FPC_SYSTEM_HAS_FPC_SHORTSTR_CONCAT}
  503. function fpc_shortstr_concat(const s1,s2:shortstring): shortstring;[public,alias:'FPC_SHORTSTR_CONCAT']; {$ifdef hascompilerproc} compilerproc; {$endif}
  504. var
  505. s1l, s2l : byte;
  506. begin
  507. s1l:=length(s1);
  508. s2l:=length(s2);
  509. if s1l+s2l>255 then
  510. s2l:=255-s1l;
  511. move(s1[1],fpc_shortstr_concat[1],s1l);
  512. move(s2[1],fpc_shortstr_concat[s1l+1],s2l);
  513. fpc_shortstr_concat[0]:=chr(s1l+s2l);
  514. end;
  515. {$endif ndef FPC_SYSTEM_HAS_FPC_SHORTSTR_CONCAT}
  516. {$ifndef FPC_SYSTEM_HAS_FPC_SHORTSTR_APPEND_SHORTSTR}
  517. procedure fpc_shortstr_append_shortstr(var s1:shortstring;const s2:shortstring);{$ifdef hascompilerproc} compilerproc; {$endif}
  518. [public,alias:'FPC_SHORTSTR_APPEND_SHORTSTR'];
  519. var
  520. s1l, s2l : byte;
  521. begin
  522. s1l:=length(s1);
  523. s2l:=length(s2);
  524. if s1l+s2l>high(s1) then
  525. s2l:=high(s1)-s1l;
  526. move(s2[1],s1[s1l+1],s2l);
  527. s1[0]:=chr(s1l+s2l);
  528. end;
  529. {$endif ndef FPC_SYSTEM_HAS_FPC_SHORTSTR_APPEND_SHORTSTR}
  530. {$ifndef FPC_SYSTEM_HAS_FPC_SHORTSTR_COMPARE}
  531. function fpc_shortstr_compare(const left,right:shortstring) : longint;[public,alias:'FPC_SHORTSTR_COMPARE']; {$ifdef hascompilerproc} compilerproc; {$endif}
  532. var
  533. s1,s2,max,i : byte;
  534. d : longint;
  535. begin
  536. s1:=length(left);
  537. s2:=length(right);
  538. if s1<s2 then
  539. max:=s1
  540. else
  541. max:=s2;
  542. for i:=1 to max do
  543. begin
  544. d:=byte(left[i])-byte(right[i]);
  545. if d>0 then
  546. exit(1)
  547. else if d<0 then
  548. exit(-1);
  549. end;
  550. if s1>s2 then
  551. exit(1)
  552. else if s1<s2 then
  553. exit(-1)
  554. else
  555. exit(0);
  556. end;
  557. {$endif ndef FPC_SYSTEM_HAS_FPC_SHORTSTR_COMPARE}
  558. {$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
  559. function fpc_pchar_to_shortstr(p:pchar):shortstring;[public,alias:'FPC_PCHAR_TO_SHORTSTR']; {$ifdef hascompilerproc} compilerproc; {$endif}
  560. var
  561. l : longint;
  562. s: shortstring;
  563. begin
  564. if p=nil then
  565. l:=0
  566. else
  567. l:=strlen(p);
  568. if l>255 then
  569. l:=255;
  570. if l>0 then
  571. move(p^,s[1],l);
  572. s[0]:=chr(l);
  573. fpc_pchar_to_shortstr := s;
  574. end;
  575. {$endif ndef FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
  576. { also add a strpas alias for internal use in the system unit (JM) }
  577. function strpas(p:pchar):shortstring; [external name 'FPC_PCHAR_TO_SHORTSTR'];
  578. { also add a strlen alias for internal use in the system unit (JM) }
  579. function strlen(p:pchar):longint; [external name 'FPC_PCHAR_LENGTH'];
  580. {$ifndef FPC_SYSTEM_HAS_FPC_CHARARRAY_TO_SHORTSTR}
  581. {$ifdef hascompilerproc}
  582. function fpc_chararray_to_shortstr(const arr: array of char):shortstring;[public,alias:'FPC_CHARARRAY_TO_SHORTSTR']; compilerproc;
  583. var
  584. l: longint;
  585. {$else hascompilerproc}
  586. function fpc_chararray_to_shortstr(arr:pchar; l : longint):shortstring;[public,alias:'FPC_CHARARRAY_TO_SHORTSTR'];
  587. var
  588. {$endif hascompilerproc}
  589. index: longint;
  590. len: byte;
  591. begin
  592. {$ifdef hascompilerproc}
  593. l := high(arr)+1;
  594. {$endif hascompilerproc}
  595. if l>=256 then
  596. l:=255
  597. else if l<0 then
  598. l:=0;
  599. index:=IndexByte(arr[0],l,0);
  600. if (index < 0) then
  601. len := l
  602. else
  603. len := index;
  604. move(arr[0],fpc_chararray_to_shortstr[1],len);
  605. fpc_chararray_to_shortstr[0]:=chr(len);
  606. end;
  607. {$endif ndef FPC_SYSTEM_HAS_FPC_CHARARRAY_TO_SHORTSTR}
  608. {$ifdef hascompilerproc}
  609. {$ifndef FPC_SYSTEM_HAS_FPC_SHORTSTR_TO_CHARARRAY}
  610. { inside the compiler, the resulttype is modified to that of the actual }
  611. { chararray we're converting to (JM) }
  612. function fpc_shortstr_to_chararray(arraysize: longint; const src: ShortString): fpc_big_chararray;[public,alias: 'FPC_SHORTSTR_TO_CHARARRAY']; compilerproc;
  613. var
  614. len: longint;
  615. begin
  616. len := length(src);
  617. if len > arraysize then
  618. len := arraysize;
  619. { make sure we don't access char 1 if length is 0 (JM) }
  620. if len > 0 then
  621. move(src[1],fpc_shortstr_to_chararray[0],len);
  622. fillchar(fpc_shortstr_to_chararray[len],arraysize-len,0);
  623. end;
  624. {$endif FPC_SYSTEM_HAS_FPC_SHORTSTR_TO_CHARARRAY}
  625. {$else hascompilerproc}
  626. {$ifopt r+}
  627. {$define rangeon}
  628. {$r-}
  629. {$endif}
  630. {$ifndef FPC_SYSTEM_HAS_FPC_STR_TO_CHARARRAY}
  631. procedure fpc_str_to_chararray(strtyp, arraysize: longint; src,dest: pchar);[public,alias:'FPC_STR_TO_CHARARRAY']; {$ifdef hascompilerproc} compilerproc; {$endif}
  632. type
  633. plongint = ^longint;
  634. var
  635. len: longint;
  636. begin
  637. case strtyp of
  638. { shortstring }
  639. 0:
  640. begin
  641. len := byte(src[0]);
  642. inc(src);
  643. end;
  644. {$ifdef SUPPORT_ANSISTRING}
  645. { ansistring}
  646. 1: len := length(ansistring(pointer(src)));
  647. {$endif SUPPORT_ANSISTRING}
  648. { longstring }
  649. 2:;
  650. { widestring }
  651. 3: ;
  652. end;
  653. if len > arraysize then
  654. len := arraysize;
  655. { make sure we don't dereference src if it can be nil (JM) }
  656. if len > 0 then
  657. move(src^,dest^,len);
  658. fillchar(dest[len],arraysize-len,0);
  659. end;
  660. {$endif FPC_SYSTEM_HAS_FPC_STR_TO_CHARARRAY}
  661. {$ifdef rangeon}
  662. {$r+}
  663. {undef rangeon}
  664. {$endif rangeon}
  665. {$endif hascompilerproc}
  666. {$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
  667. function fpc_pchar_length(p:pchar):longint;[public,alias:'FPC_PCHAR_LENGTH']; {$ifdef hascompilerproc} compilerproc; {$endif}
  668. var i : longint;
  669. begin
  670. i:=0;
  671. while p[i]<>#0 do inc(i);
  672. exit(i);
  673. end;
  674. {$endif ndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
  675. {$ifdef HASWIDESTRING}
  676. {$ifndef FPC_SYSTEM_HAS_FPC_PWIDECHAR_LENGTH}
  677. function fpc_pwidechar_length(p:pwidechar):longint;[public,alias:'FPC_PWIDECHAR_LENGTH']; {$ifdef hascompilerproc} compilerproc; {$endif}
  678. var i : longint;
  679. begin
  680. i:=0;
  681. while p[i]<>#0 do inc(i);
  682. exit(i);
  683. end;
  684. {$endif ndef FPC_SYSTEM_HAS_FPC_PWIDECHAR_LENGTH}
  685. {$endif HASWIDESTRING}
  686. {****************************************************************************
  687. Caller/StackFrame Helpers
  688. ****************************************************************************}
  689. {$ifndef FPC_SYSTEM_HAS_GET_FRAME}
  690. {_$error Get_frame must be defined for each processor }
  691. {$endif ndef FPC_SYSTEM_HAS_GET_FRAME}
  692. {$ifndef FPC_SYSTEM_HAS_GET_CALLER_ADDR}
  693. {_$error Get_caller_addr must be defined for each processor }
  694. {$endif ndef FPC_SYSTEM_HAS_GET_CALLER_ADDR}
  695. {$ifndef FPC_SYSTEM_HAS_GET_CALLER_FRAME}
  696. {_$error Get_caller_frame must be defined for each processor }
  697. {$endif ndef FPC_SYSTEM_HAS_GET_CALLER_FRAME}
  698. {****************************************************************************
  699. Math
  700. ****************************************************************************}
  701. {****************************************************************************
  702. Software longint/dword division
  703. ****************************************************************************}
  704. {$ifdef FPC_INCLUDE_SOFTWARE_MOD_DIV}
  705. function count_leading_zeros_32bit(l : longint) : longint;
  706. var
  707. i : longint;
  708. begin
  709. for i:=0 to 31 do
  710. begin
  711. if (l and (longint($80000000) shr i))<>0 then
  712. begin
  713. result:=i;
  714. exit;
  715. end;
  716. end;
  717. result:=i;
  718. end;
  719. {$ifndef FPC_SYSTEM_HAS_DIV_DWORD}
  720. function fpc_div_dword(n,z : dword) : dword; [public,alias: 'FPC_DIV_DWORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
  721. var
  722. shift,lzz,lzn : longint;
  723. begin
  724. result:=0;
  725. if n=0 then
  726. HandleErrorFrame(200,get_frame);
  727. lzz:=count_leading_zeros_32bit(z);
  728. lzn:=count_leading_zeros_32bit(n);
  729. { if the denominator contains less zeros
  730. then the numerator
  731. the d is greater than the n }
  732. if lzn<lzz then
  733. exit;
  734. shift:=lzn-lzz;
  735. n:=n shl shift;
  736. repeat
  737. if z>=n then
  738. begin
  739. z:=z-n;
  740. result:=result+dword(1 shl shift);
  741. end;
  742. dec(shift);
  743. n:=n shr 1;
  744. until shift<0;
  745. end;
  746. {$endif FPC_SYSTEM_HAS_DIV_DWORD}
  747. {$ifndef FPC_SYSTEM_HAS_MOD_DWORD}
  748. function fpc_mod_dword(n,z : dword) : dword; [public,alias: 'FPC_MOD_DWORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
  749. var
  750. shift,lzz,lzn : longint;
  751. begin
  752. result:=0;
  753. if n=0 then
  754. HandleErrorFrame(200,get_frame);
  755. lzz:=count_leading_zeros_32bit(z);
  756. lzn:=count_leading_zeros_32bit(n);
  757. { if the denominator contains less zeros
  758. then the numerator
  759. the d is greater than the n }
  760. if lzn<lzz then
  761. begin
  762. result:=z;
  763. exit;
  764. end;
  765. shift:=lzn-lzz;
  766. n:=n shl shift;
  767. repeat
  768. if z>=n then
  769. z:=z-n;
  770. dec(shift);
  771. n:=n shr 1;
  772. until shift<0;
  773. result:=z;
  774. end;
  775. {$endif FPC_SYSTEM_HAS_MOD_DWORD}
  776. {$ifndef FPC_SYSTEM_HAS_DIV_LONGINT}
  777. function fpc_div_longint(n,z : longint) : longint; [public,alias: 'FPC_DIV_LONGINT']; {$ifdef hascompilerproc} compilerproc; {$endif}
  778. var
  779. sign : boolean;
  780. d1,d2 : dword;
  781. begin
  782. if n=0 then
  783. HandleErrorFrame(200,get_frame);
  784. sign:=false;
  785. if z<0 then
  786. begin
  787. sign:=not(sign);
  788. d1:=dword(-z);
  789. end
  790. else
  791. d1:=z;
  792. if n<0 then
  793. begin
  794. sign:=not(sign);
  795. d2:=dword(-n);
  796. end
  797. else
  798. d2:=n;
  799. { the div is coded by the compiler as call to divdword }
  800. if sign then
  801. result:=-(d1 div d2)
  802. else
  803. result:=d1 div d2;
  804. end;
  805. {$endif FPC_SYSTEM_HAS_DIV_LONGINT}
  806. {$ifndef FPC_SYSTEM_HAS_MOD_LONGINT}
  807. function fpc_mod_longint(n,z : longint) : longint; [public,alias: 'FPC_MOD_LONGINT']; {$ifdef hascompilerproc} compilerproc; {$endif}
  808. var
  809. signed : boolean;
  810. r,nq,zq : dword;
  811. begin
  812. if n=0 then
  813. HandleErrorFrame(200,get_frame);
  814. if n<0 then
  815. begin
  816. nq:=-n;
  817. signed:=true;
  818. end
  819. else
  820. begin
  821. signed:=false;
  822. nq:=n;
  823. end;
  824. if z<0 then
  825. begin
  826. zq:=dword(-z);
  827. signed:=not(signed);
  828. end
  829. else
  830. zq:=z;
  831. r:=zq mod nq;
  832. if signed then
  833. result:=-longint(r)
  834. else
  835. result:=r;
  836. end;
  837. {$endif FPC_SYSTEM_HAS_MOD_LONGINT}
  838. {$endif FPC_INCLUDE_SOFTWARE_MOD_DIV}
  839. {****************************************************************************}
  840. {$ifndef FPC_SYSTEM_HAS_ABS_LONGINT}
  841. function abs(l:longint):longint;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_abs];
  842. begin
  843. if l<0 then
  844. abs:=-l
  845. else
  846. abs:=l;
  847. end;
  848. {$endif not FPC_SYSTEM_HAS_ABS_LONGINT}
  849. {$ifndef FPC_SYSTEM_HAS_ODD_LONGINT}
  850. function odd(l:longint):boolean;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_odd];
  851. begin
  852. odd:=boolean(l and 1);
  853. end;
  854. {$endif ndef FPC_SYSTEM_HAS_ODD_LONGINT}
  855. {$ifndef FPC_SYSTEM_HAS_ODD_LONGWORD}
  856. function odd(l:longword):boolean;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_odd];
  857. begin
  858. odd:=boolean(l and 1);
  859. end;
  860. {$endif ndef FPC_SYSTEM_HAS_ODD_LONGWORD}
  861. {$ifndef FPC_SYSTEM_HAS_ODD_INT64}
  862. function odd(l:int64):boolean;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_odd];
  863. begin
  864. odd:=boolean(longint(l) and 1);
  865. end;
  866. {$endif ndef FPC_SYSTEM_HAS_ODD_INT64}
  867. {$ifndef FPC_SYSTEM_HAS_ODD_QWORD}
  868. function odd(l:qword):boolean;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_odd];
  869. begin
  870. odd:=boolean(longint(l) and 1);
  871. end;
  872. {$endif ndef FPC_SYSTEM_HAS_ODD_QWORD}
  873. {$ifndef FPC_SYSTEM_HAS_SQR_LONGINT}
  874. function sqr(l:longint):longint;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_sqr];
  875. begin
  876. sqr:=l*l;
  877. end;
  878. {$endif ndef FPC_SYSTEM_HAS_SQR_LONGINT}
  879. {$ifndef FPC_SYSTEM_HAS_ABS_INT64}
  880. function abs(l: Int64): Int64;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_abs];
  881. begin
  882. if l < 0 then
  883. abs := -l
  884. else
  885. abs := l;
  886. end;
  887. {$endif ndef FPC_SYSTEM_HAS_ABS_INT64}
  888. {$ifndef FPC_SYSTEM_HAS_SQR_INT64}
  889. function sqr(l: Int64): Int64;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_sqr];
  890. begin
  891. sqr := l*l;
  892. end;
  893. {$endif ndef FPC_SYSTEM_HAS_SQR_INT64}
  894. {$ifndef FPC_SYSTEM_HAS_SQR_QWORD}
  895. function sqr(l: QWord): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_sqr];
  896. begin
  897. sqr := l*l;
  898. end;
  899. {$endif ndef FPC_SYSTEM_HAS_SQR_INT64}
  900. {$ifndef FPC_SYSTEM_HAS_DECLOCKED}
  901. function declocked(var l:longint):boolean;
  902. begin
  903. Dec(l);
  904. declocked:=(l=0);
  905. end;
  906. {$endif FPC_SYSTEM_HAS_DECLOCKED}
  907. {$ifndef FPC_SYSTEM_HAS_INCLOCKED}
  908. procedure inclocked(var l:longint);
  909. begin
  910. Inc(l);
  911. end;
  912. {$endif FPC_SYSTEM_HAS_INCLOCKED}
  913. {$ifndef FPC_SYSTEM_HAS_SPTR}
  914. {_$error Sptr must be defined for each processor }
  915. {$endif ndef FPC_SYSTEM_HAS_SPTR}
  916. procedure prefetch(const mem);[internproc:in_prefetch_var];
  917. {****************************************************************************
  918. Str()
  919. ****************************************************************************}
  920. {$ifndef FPC_SYSTEM_HAS_INT_STR_LONGINT}
  921. procedure int_str(l : longint;var s : string);
  922. var
  923. value: longint;
  924. negative: boolean;
  925. begin
  926. negative := false;
  927. s:='';
  928. { Workaround: }
  929. if l=longint($80000000) then
  930. begin
  931. s:='-2147483648';
  932. exit;
  933. end;
  934. { handle case where l = 0 }
  935. if l = 0 then
  936. begin
  937. s:='0';
  938. exit;
  939. end;
  940. If l < 0 then
  941. begin
  942. negative := true;
  943. value:=abs(l);
  944. end
  945. else
  946. value:=l;
  947. { handle non-zero case }
  948. while value>0 do
  949. begin
  950. s:=char((value mod 10)+ord('0'))+s;
  951. value := value div 10;
  952. end;
  953. if negative then
  954. s := '-' + s;
  955. end;
  956. {$endif ndef FPC_SYSTEM_HAS_INT_STR_LONGINT}
  957. {$ifndef FPC_SYSTEM_HAS_INT_STR_LONGWORD}
  958. procedure int_str(l : longword;var s : string);
  959. begin
  960. s:='';
  961. if l = 0 then
  962. begin
  963. s := '0';
  964. exit;
  965. end;
  966. while l>0 do
  967. begin
  968. s:=char(ord('0')+(l mod 10))+s;
  969. l:=l div 10;
  970. end;
  971. end;
  972. {$endif ndef FPC_SYSTEM_HAS_INT_STR_LONGWORD}
  973. {$ifndef FPC_SYSTEM_HAS_SYSRESETFPU}
  974. procedure SysResetFpu;
  975. begin
  976. { nothing todo }
  977. end;
  978. {$endif FPC_SYSTEM_HAS_SYSRESETFPU}
  979. {
  980. $Log$
  981. Revision 1.69 2004-02-02 20:39:27 florian
  982. + added prefetch(const mem)
  983. Revision 1.68 2004/01/31 16:14:24 florian
  984. * alignment handling of generic fillbyte/word fixed
  985. Revision 1.66 2004/01/21 01:25:02 florian
  986. * improved generic int. div routines
  987. Revision 1.65 2004/01/20 23:16:56 florian
  988. + created generic versions of software dword/longint mod/div
  989. Revision 1.64 2004/01/10 17:01:29 jonas
  990. * changed index* to conform to the assembler implementations (interpret
  991. negative upper bound as maximum)
  992. Revision 1.63 2003/12/16 09:43:04 daniel
  993. * Use of 0 instead of nil fixed
  994. Revision 1.62 2003/12/06 13:25:30 jonas
  995. * fixed longint/cardinal comparison in int_str
  996. Revision 1.61 2003/09/03 14:09:37 florian
  997. * arm fixes to the common rtl code
  998. * some generic math code fixed
  999. * ...
  1000. Revision 1.60 2003/06/01 14:50:17 jonas
  1001. * fpc_shortstr_append_shortstr has to use high(s1) instead of 255 as
  1002. maxlen
  1003. + ppc version of fpc_shortstr_append_shortstr
  1004. Revision 1.59 2003/05/26 21:18:13 peter
  1005. * FPC_SHORTSTR_APPEND_SHORTSTR public added
  1006. Revision 1.58 2003/05/26 19:36:46 peter
  1007. * fpc_shortstr_concat is now the same for all targets
  1008. * fpc_shortstr_append_shortstr added for optimized code generation
  1009. Revision 1.57 2003/05/16 22:40:11 florian
  1010. * fixed generic shortstr_compare
  1011. Revision 1.56 2003/05/13 20:52:50 peter
  1012. * extra check for self and empty objects
  1013. Revision 1.55 2003/05/13 19:18:08 peter
  1014. * fpc_help_fail compilerproc
  1015. * fpc_new_class, fpc_dispose_class not needed by latest compiler
  1016. Revision 1.54 2003/04/23 13:10:09 peter
  1017. * remvoe objectsize loading from help_destructor
  1018. * implement fpc_check_object
  1019. * saveregistrers for check_object
  1020. Revision 1.53 2003/04/02 14:05:45 peter
  1021. * undo previous commit
  1022. Revision 1.51 2003/03/26 00:17:34 peter
  1023. * generic constructor/destructor fixes
  1024. Revision 1.50 2003/02/18 17:56:06 jonas
  1025. - removed buggy i386-specific FPC_CHARARRAY_TO_SHORTSTR
  1026. * fixed generic FPC_CHARARRAY_TO_SHORTSTR (web bug 2382)
  1027. * fixed some potential range errors in indexchar/word/dword
  1028. Revision 1.49 2003/01/20 22:21:36 mazen
  1029. * many stuff related to RTL fixed
  1030. Revision 1.48 2003/01/09 20:14:20 florian
  1031. * fixed helper declarations
  1032. Revision 1.47 2003/01/07 22:04:12 mazen
  1033. - space removed
  1034. Revision 1.46 2003/01/06 23:04:21 mazen
  1035. * functions headers modified in generic.inc to make it possible compiling sparc
  1036. RTL based on generic code
  1037. Revision 1.45 2003/01/05 21:32:35 mazen
  1038. * fixing several bugs compiling the RTL
  1039. Revision 1.44 2002/12/23 21:27:13 peter
  1040. * fix wrong var names for shortstr_compare
  1041. Revision 1.43 2002/10/20 11:51:54 carl
  1042. * avoid crashes with negative len counts on fills/moves
  1043. * movechar0 was wrong and did not do the behavior as
  1044. described in docs
  1045. Revision 1.42 2002/10/14 19:39:17 peter
  1046. * threads unit added for thread support
  1047. Revision 1.41 2002/10/12 20:32:41 carl
  1048. * RunError 220 -> RunError 219 to be more consistent with as operator
  1049. Revision 1.40 2002/10/10 16:08:50 florian
  1050. + several widestring/pwidechar related helpers added
  1051. Revision 1.39 2002/10/05 14:20:16 peter
  1052. * fpc_pchar_length compilerproc and strlen alias
  1053. Revision 1.38 2002/10/02 18:21:51 peter
  1054. * Copy() changed to internal function calling compilerprocs
  1055. * FPC_SHORTSTR_COPY renamed to FPC_SHORTSTR_ASSIGN because of the
  1056. new copy functions
  1057. Revision 1.37 2002/09/27 21:10:40 carl
  1058. * fix 2GB limit problem
  1059. Revision 1.36 2002/09/13 19:13:06 carl
  1060. * FPC_HELP_FAIL : reset _self to nil
  1061. Revision 1.35 2002/09/10 21:29:44 jonas
  1062. * added some missing compilerproc directives
  1063. Revision 1.34 2002/09/07 21:08:42 carl
  1064. * cardinal -> longword
  1065. - remove generic boundcheck (does not exist in v1.1)
  1066. Revision 1.33 2002/09/07 15:07:45 peter
  1067. * old logs removed and tabs fixed
  1068. Revision 1.32 2002/08/19 19:34:02 peter
  1069. * SYSTEMINLINE define that will add inline directives for small
  1070. functions and wrappers. This will be defined automaticly when
  1071. the compiler defines the HASINLINE directive
  1072. Revision 1.31 2002/07/29 21:28:16 florian
  1073. * several fixes to get further with linux/ppc system unit compilation
  1074. Revision 1.30 2002/07/29 09:23:11 jonas
  1075. * fixed some datastructures > 2GB
  1076. Revision 1.29 2002/07/28 21:39:28 florian
  1077. * made abs a compiler proc if it is generic
  1078. Revision 1.28 2002/07/28 20:43:47 florian
  1079. * several fixes for linux/powerpc
  1080. * several fixes to MT
  1081. Revision 1.27 2002/06/16 08:19:03 carl
  1082. * bugfix of FPC_NEW_CLASS (was not creating correct instance)
  1083. + FPC_HELP_FAIL_CLASS now tested (no longer required)
  1084. Revision 1.25 2002/05/16 19:58:05 carl
  1085. * generic constructor implemented
  1086. Revision 1.24 2002/03/30 13:08:54 carl
  1087. * memory corruption bugfix in FPC_HELP_CONSTRUCTOR if object cannot be allocated
  1088. Revision 1.23 2002/01/25 17:38:55 peter
  1089. * add internconst for all overloaded types of Odd/Abs/Sqr
  1090. Revision 1.22 2002/01/24 12:33:53 jonas
  1091. * adapted ranges of native types to int64 (e.g. high cardinal is no
  1092. longer longint($ffffffff), but just $fffffff in psystem)
  1093. * small additional fix in 64bit rangecheck code generation for 32 bit
  1094. processors
  1095. * adaption of ranges required the matching talgorithm used for selecting
  1096. which overloaded procedure to call to be adapted. It should now always
  1097. select the closest match for ordinal parameters.
  1098. + inttostr(qword) in sysstr.inc/sysstrh.inc
  1099. + abs(int64), sqr(int64), sqr(qword) in systemh.inc/generic.inc (previous
  1100. fixes were required to be able to add them)
  1101. * is_in_limit() moved from ncal to types unit, should always be used
  1102. instead of direct comparisons of low/high values of orddefs because
  1103. qword is a special case
  1104. }