generic.inc 33 KB

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