generic.inc 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341
  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);[public, alias: 'FPC_MOVE'];
  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:ptrint;
  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 : ptrint;
  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 : ptrint;
  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 ptrint(_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 : ptrint;
  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 : ptrint;
  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_LONGINT}
  901. function declocked(var l:longint):boolean;
  902. begin
  903. Dec(l);
  904. declocked:=(l=0);
  905. end;
  906. {$endif FPC_SYSTEM_HAS_DECLOCKED_LONGINT}
  907. {$ifndef FPC_SYSTEM_HAS_DECLOCKED_INT64}
  908. function declocked(var l:int64):boolean;
  909. begin
  910. Dec(l);
  911. declocked:=(l=0);
  912. end;
  913. {$endif FPC_SYSTEM_HAS_DECLOCKED_INT64}
  914. {$ifndef FPC_SYSTEM_HAS_INCLOCKED_LONGINT}
  915. procedure inclocked(var l:longint);
  916. begin
  917. Inc(l);
  918. end;
  919. {$endif FPC_SYSTEM_HAS_INCLOCKED_LONGINT}
  920. {$ifndef FPC_SYSTEM_HAS_INCLOCKED_INT64}
  921. procedure inclocked(var l:int64);
  922. begin
  923. Inc(l);
  924. end;
  925. {$endif FPC_SYSTEM_HAS_INCLOCKED_INT64}
  926. {$ifndef FPC_SYSTEM_HAS_SPTR}
  927. {_$error Sptr must be defined for each processor }
  928. {$endif ndef FPC_SYSTEM_HAS_SPTR}
  929. procedure prefetch(const mem);[internproc:in_prefetch_var];
  930. {****************************************************************************
  931. Str()
  932. ****************************************************************************}
  933. {$ifndef FPC_SYSTEM_HAS_INT_STR_LONGINT}
  934. procedure int_str(l : longint;var s : string);
  935. var
  936. value: longint;
  937. negative: boolean;
  938. begin
  939. negative := false;
  940. s:='';
  941. { Workaround: }
  942. if l=longint($80000000) then
  943. begin
  944. s:='-2147483648';
  945. exit;
  946. end;
  947. { handle case where l = 0 }
  948. if l = 0 then
  949. begin
  950. s:='0';
  951. exit;
  952. end;
  953. If l < 0 then
  954. begin
  955. negative := true;
  956. value:=abs(l);
  957. end
  958. else
  959. value:=l;
  960. { handle non-zero case }
  961. while value>0 do
  962. begin
  963. s:=char((value mod 10)+ord('0'))+s;
  964. value := value div 10;
  965. end;
  966. if negative then
  967. s := '-' + s;
  968. end;
  969. {$endif ndef FPC_SYSTEM_HAS_INT_STR_LONGINT}
  970. {$ifndef FPC_SYSTEM_HAS_INT_STR_LONGWORD}
  971. procedure int_str(l : longword;var s : string);
  972. begin
  973. s:='';
  974. if l = 0 then
  975. begin
  976. s := '0';
  977. exit;
  978. end;
  979. while l>0 do
  980. begin
  981. s:=char(ord('0')+(l mod 10))+s;
  982. l:=l div 10;
  983. end;
  984. end;
  985. {$endif ndef FPC_SYSTEM_HAS_INT_STR_LONGWORD}
  986. {$ifndef FPC_SYSTEM_HAS_SYSRESETFPU}
  987. procedure SysResetFpu;
  988. begin
  989. { nothing todo }
  990. end;
  991. {$endif FPC_SYSTEM_HAS_SYSRESETFPU}
  992. {
  993. $Log$
  994. Revision 1.73 2004-04-29 19:50:13 peter
  995. * x86-64 fixes
  996. Revision 1.72 2004/04/28 21:01:29 florian
  997. * tvmt fixed (longint -> ptrint)
  998. Revision 1.71 2004/04/28 20:48:20 peter
  999. * ordinal-pointer conversions fixed
  1000. Revision 1.70 2004/04/26 15:55:01 peter
  1001. * FPC_MOVE alias
  1002. Revision 1.69 2004/02/02 20:39:27 florian
  1003. + added prefetch(const mem)
  1004. Revision 1.68 2004/01/31 16:14:24 florian
  1005. * alignment handling of generic fillbyte/word fixed
  1006. Revision 1.66 2004/01/21 01:25:02 florian
  1007. * improved generic int. div routines
  1008. Revision 1.65 2004/01/20 23:16:56 florian
  1009. + created generic versions of software dword/longint mod/div
  1010. Revision 1.64 2004/01/10 17:01:29 jonas
  1011. * changed index* to conform to the assembler implementations (interpret
  1012. negative upper bound as maximum)
  1013. Revision 1.63 2003/12/16 09:43:04 daniel
  1014. * Use of 0 instead of nil fixed
  1015. Revision 1.62 2003/12/06 13:25:30 jonas
  1016. * fixed longint/cardinal comparison in int_str
  1017. Revision 1.61 2003/09/03 14:09:37 florian
  1018. * arm fixes to the common rtl code
  1019. * some generic math code fixed
  1020. * ...
  1021. Revision 1.60 2003/06/01 14:50:17 jonas
  1022. * fpc_shortstr_append_shortstr has to use high(s1) instead of 255 as
  1023. maxlen
  1024. + ppc version of fpc_shortstr_append_shortstr
  1025. Revision 1.59 2003/05/26 21:18:13 peter
  1026. * FPC_SHORTSTR_APPEND_SHORTSTR public added
  1027. Revision 1.58 2003/05/26 19:36:46 peter
  1028. * fpc_shortstr_concat is now the same for all targets
  1029. * fpc_shortstr_append_shortstr added for optimized code generation
  1030. Revision 1.57 2003/05/16 22:40:11 florian
  1031. * fixed generic shortstr_compare
  1032. Revision 1.56 2003/05/13 20:52:50 peter
  1033. * extra check for self and empty objects
  1034. Revision 1.55 2003/05/13 19:18:08 peter
  1035. * fpc_help_fail compilerproc
  1036. * fpc_new_class, fpc_dispose_class not needed by latest compiler
  1037. Revision 1.54 2003/04/23 13:10:09 peter
  1038. * remvoe objectsize loading from help_destructor
  1039. * implement fpc_check_object
  1040. * saveregistrers for check_object
  1041. Revision 1.53 2003/04/02 14:05:45 peter
  1042. * undo previous commit
  1043. Revision 1.51 2003/03/26 00:17:34 peter
  1044. * generic constructor/destructor fixes
  1045. Revision 1.50 2003/02/18 17:56:06 jonas
  1046. - removed buggy i386-specific FPC_CHARARRAY_TO_SHORTSTR
  1047. * fixed generic FPC_CHARARRAY_TO_SHORTSTR (web bug 2382)
  1048. * fixed some potential range errors in indexchar/word/dword
  1049. Revision 1.49 2003/01/20 22:21:36 mazen
  1050. * many stuff related to RTL fixed
  1051. Revision 1.48 2003/01/09 20:14:20 florian
  1052. * fixed helper declarations
  1053. Revision 1.47 2003/01/07 22:04:12 mazen
  1054. - space removed
  1055. Revision 1.46 2003/01/06 23:04:21 mazen
  1056. * functions headers modified in generic.inc to make it possible compiling sparc
  1057. RTL based on generic code
  1058. Revision 1.45 2003/01/05 21:32:35 mazen
  1059. * fixing several bugs compiling the RTL
  1060. Revision 1.44 2002/12/23 21:27:13 peter
  1061. * fix wrong var names for shortstr_compare
  1062. Revision 1.43 2002/10/20 11:51:54 carl
  1063. * avoid crashes with negative len counts on fills/moves
  1064. * movechar0 was wrong and did not do the behavior as
  1065. described in docs
  1066. Revision 1.42 2002/10/14 19:39:17 peter
  1067. * threads unit added for thread support
  1068. Revision 1.41 2002/10/12 20:32:41 carl
  1069. * RunError 220 -> RunError 219 to be more consistent with as operator
  1070. Revision 1.40 2002/10/10 16:08:50 florian
  1071. + several widestring/pwidechar related helpers added
  1072. Revision 1.39 2002/10/05 14:20:16 peter
  1073. * fpc_pchar_length compilerproc and strlen alias
  1074. Revision 1.38 2002/10/02 18:21:51 peter
  1075. * Copy() changed to internal function calling compilerprocs
  1076. * FPC_SHORTSTR_COPY renamed to FPC_SHORTSTR_ASSIGN because of the
  1077. new copy functions
  1078. Revision 1.37 2002/09/27 21:10:40 carl
  1079. * fix 2GB limit problem
  1080. Revision 1.36 2002/09/13 19:13:06 carl
  1081. * FPC_HELP_FAIL : reset _self to nil
  1082. Revision 1.35 2002/09/10 21:29:44 jonas
  1083. * added some missing compilerproc directives
  1084. Revision 1.34 2002/09/07 21:08:42 carl
  1085. * cardinal -> longword
  1086. - remove generic boundcheck (does not exist in v1.1)
  1087. Revision 1.33 2002/09/07 15:07:45 peter
  1088. * old logs removed and tabs fixed
  1089. Revision 1.32 2002/08/19 19:34:02 peter
  1090. * SYSTEMINLINE define that will add inline directives for small
  1091. functions and wrappers. This will be defined automaticly when
  1092. the compiler defines the HASINLINE directive
  1093. Revision 1.31 2002/07/29 21:28:16 florian
  1094. * several fixes to get further with linux/ppc system unit compilation
  1095. Revision 1.30 2002/07/29 09:23:11 jonas
  1096. * fixed some datastructures > 2GB
  1097. Revision 1.29 2002/07/28 21:39:28 florian
  1098. * made abs a compiler proc if it is generic
  1099. Revision 1.28 2002/07/28 20:43:47 florian
  1100. * several fixes for linux/powerpc
  1101. * several fixes to MT
  1102. Revision 1.27 2002/06/16 08:19:03 carl
  1103. * bugfix of FPC_NEW_CLASS (was not creating correct instance)
  1104. + FPC_HELP_FAIL_CLASS now tested (no longer required)
  1105. Revision 1.25 2002/05/16 19:58:05 carl
  1106. * generic constructor implemented
  1107. Revision 1.24 2002/03/30 13:08:54 carl
  1108. * memory corruption bugfix in FPC_HELP_CONSTRUCTOR if object cannot be allocated
  1109. Revision 1.23 2002/01/25 17:38:55 peter
  1110. * add internconst for all overloaded types of Odd/Abs/Sqr
  1111. Revision 1.22 2002/01/24 12:33:53 jonas
  1112. * adapted ranges of native types to int64 (e.g. high cardinal is no
  1113. longer longint($ffffffff), but just $fffffff in psystem)
  1114. * small additional fix in 64bit rangecheck code generation for 32 bit
  1115. processors
  1116. * adaption of ranges required the matching talgorithm used for selecting
  1117. which overloaded procedure to call to be adapted. It should now always
  1118. select the closest match for ordinal parameters.
  1119. + inttostr(qword) in sysstr.inc/sysstrh.inc
  1120. + abs(int64), sqr(int64), sqr(qword) in systemh.inc/generic.inc (previous
  1121. fixes were required to be able to add them)
  1122. * is_in_limit() moved from ncal to types unit, should always be used
  1123. instead of direct comparisons of low/high values of orddefs because
  1124. qword is a special case
  1125. }