generic.inc 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410
  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. {$ifndef FPC_UNIT_HAS_STRLEN}
  579. { if strlen is not yet defined, we need a forward declaration here }
  580. function strlen(p:pchar):longint; [external name 'FPC_PCHAR_LENGTH'];
  581. {$endif FPC_UNIT_HAS_STRLEN}
  582. {$ifndef FPC_SYSTEM_HAS_FPC_CHARARRAY_TO_SHORTSTR}
  583. {$ifdef hascompilerproc}
  584. function fpc_chararray_to_shortstr(const arr: array of char):shortstring;[public,alias:'FPC_CHARARRAY_TO_SHORTSTR']; compilerproc;
  585. var
  586. l: longint;
  587. {$else hascompilerproc}
  588. function fpc_chararray_to_shortstr(arr:pchar; l : longint):shortstring;[public,alias:'FPC_CHARARRAY_TO_SHORTSTR'];
  589. var
  590. {$endif hascompilerproc}
  591. index: longint;
  592. len: byte;
  593. begin
  594. {$ifdef hascompilerproc}
  595. l := high(arr)+1;
  596. {$endif hascompilerproc}
  597. if l>=256 then
  598. l:=255
  599. else if l<0 then
  600. l:=0;
  601. index:=IndexByte(arr[0],l,0);
  602. if (index < 0) then
  603. len := l
  604. else
  605. len := index;
  606. move(arr[0],fpc_chararray_to_shortstr[1],len);
  607. fpc_chararray_to_shortstr[0]:=chr(len);
  608. end;
  609. {$endif ndef FPC_SYSTEM_HAS_FPC_CHARARRAY_TO_SHORTSTR}
  610. {$ifdef hascompilerproc}
  611. {$ifndef FPC_SYSTEM_HAS_FPC_SHORTSTR_TO_CHARARRAY}
  612. { inside the compiler, the resulttype is modified to that of the actual }
  613. { chararray we're converting to (JM) }
  614. function fpc_shortstr_to_chararray(arraysize: longint; const src: ShortString): fpc_big_chararray;[public,alias: 'FPC_SHORTSTR_TO_CHARARRAY']; compilerproc;
  615. var
  616. len: longint;
  617. begin
  618. len := length(src);
  619. if len > arraysize then
  620. len := arraysize;
  621. { make sure we don't access char 1 if length is 0 (JM) }
  622. if len > 0 then
  623. move(src[1],fpc_shortstr_to_chararray[0],len);
  624. fillchar(fpc_shortstr_to_chararray[len],arraysize-len,0);
  625. end;
  626. {$endif FPC_SYSTEM_HAS_FPC_SHORTSTR_TO_CHARARRAY}
  627. {$else hascompilerproc}
  628. {$ifopt r+}
  629. {$define rangeon}
  630. {$r-}
  631. {$endif}
  632. {$ifndef FPC_SYSTEM_HAS_FPC_STR_TO_CHARARRAY}
  633. procedure fpc_str_to_chararray(strtyp, arraysize: longint; src,dest: pchar);[public,alias:'FPC_STR_TO_CHARARRAY']; {$ifdef hascompilerproc} compilerproc; {$endif}
  634. type
  635. plongint = ^longint;
  636. var
  637. len: longint;
  638. begin
  639. case strtyp of
  640. { shortstring }
  641. 0:
  642. begin
  643. len := byte(src[0]);
  644. inc(src);
  645. end;
  646. {$ifdef SUPPORT_ANSISTRING}
  647. { ansistring}
  648. 1: len := length(ansistring(pointer(src)));
  649. {$endif SUPPORT_ANSISTRING}
  650. { longstring }
  651. 2:;
  652. { widestring }
  653. 3: ;
  654. end;
  655. if len > arraysize then
  656. len := arraysize;
  657. { make sure we don't dereference src if it can be nil (JM) }
  658. if len > 0 then
  659. move(src^,dest^,len);
  660. fillchar(dest[len],arraysize-len,0);
  661. end;
  662. {$endif FPC_SYSTEM_HAS_FPC_STR_TO_CHARARRAY}
  663. {$ifdef rangeon}
  664. {$r+}
  665. {undef rangeon}
  666. {$endif rangeon}
  667. {$endif hascompilerproc}
  668. {$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
  669. function fpc_pchar_length(p:pchar):longint;[public,alias:'FPC_PCHAR_LENGTH']; {$ifdef hascompilerproc} compilerproc; {$endif}
  670. var i : longint;
  671. begin
  672. i:=0;
  673. while p[i]<>#0 do inc(i);
  674. exit(i);
  675. end;
  676. {$endif ndef FPC_SYSTEM_HAS_FPC_PCHAR_LENGTH}
  677. {$ifdef HASWIDESTRING}
  678. {$ifndef FPC_SYSTEM_HAS_FPC_PWIDECHAR_LENGTH}
  679. function fpc_pwidechar_length(p:pwidechar):longint;[public,alias:'FPC_PWIDECHAR_LENGTH']; {$ifdef hascompilerproc} compilerproc; {$endif}
  680. var i : longint;
  681. begin
  682. i:=0;
  683. while p[i]<>#0 do inc(i);
  684. exit(i);
  685. end;
  686. {$endif ndef FPC_SYSTEM_HAS_FPC_PWIDECHAR_LENGTH}
  687. {$endif HASWIDESTRING}
  688. {****************************************************************************
  689. Caller/StackFrame Helpers
  690. ****************************************************************************}
  691. {$ifndef FPC_SYSTEM_HAS_GET_FRAME}
  692. {_$error Get_frame must be defined for each processor }
  693. {$endif ndef FPC_SYSTEM_HAS_GET_FRAME}
  694. {$ifndef FPC_SYSTEM_HAS_GET_CALLER_ADDR}
  695. {_$error Get_caller_addr must be defined for each processor }
  696. {$endif ndef FPC_SYSTEM_HAS_GET_CALLER_ADDR}
  697. {$ifndef FPC_SYSTEM_HAS_GET_CALLER_FRAME}
  698. {_$error Get_caller_frame must be defined for each processor }
  699. {$endif ndef FPC_SYSTEM_HAS_GET_CALLER_FRAME}
  700. {****************************************************************************
  701. Math
  702. ****************************************************************************}
  703. {****************************************************************************
  704. Software longint/dword division
  705. ****************************************************************************}
  706. {$ifdef FPC_INCLUDE_SOFTWARE_MOD_DIV}
  707. function count_leading_zeros_32bit(l : longint) : longint;
  708. var
  709. i : longint;
  710. begin
  711. for i:=0 to 31 do
  712. begin
  713. if (l and (longint($80000000) shr i))<>0 then
  714. begin
  715. result:=i;
  716. exit;
  717. end;
  718. end;
  719. result:=i;
  720. end;
  721. {$ifndef FPC_SYSTEM_HAS_DIV_DWORD}
  722. function fpc_div_dword(n,z : dword) : dword; [public,alias: 'FPC_DIV_DWORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
  723. var
  724. shift,lzz,lzn : longint;
  725. begin
  726. result:=0;
  727. if n=0 then
  728. HandleErrorFrame(200,get_frame);
  729. lzz:=count_leading_zeros_32bit(z);
  730. lzn:=count_leading_zeros_32bit(n);
  731. { if the denominator contains less zeros
  732. then the numerator
  733. the d is greater than the n }
  734. if lzn<lzz then
  735. exit;
  736. shift:=lzn-lzz;
  737. n:=n shl shift;
  738. repeat
  739. if z>=n then
  740. begin
  741. z:=z-n;
  742. result:=result+dword(1 shl shift);
  743. end;
  744. dec(shift);
  745. n:=n shr 1;
  746. until shift<0;
  747. end;
  748. {$endif FPC_SYSTEM_HAS_DIV_DWORD}
  749. {$ifndef FPC_SYSTEM_HAS_MOD_DWORD}
  750. function fpc_mod_dword(n,z : dword) : dword; [public,alias: 'FPC_MOD_DWORD']; {$ifdef hascompilerproc} compilerproc; {$endif}
  751. var
  752. shift,lzz,lzn : longint;
  753. begin
  754. result:=0;
  755. if n=0 then
  756. HandleErrorFrame(200,get_frame);
  757. lzz:=count_leading_zeros_32bit(z);
  758. lzn:=count_leading_zeros_32bit(n);
  759. { if the denominator contains less zeros
  760. then the numerator
  761. the d is greater than the n }
  762. if lzn<lzz then
  763. begin
  764. result:=z;
  765. exit;
  766. end;
  767. shift:=lzn-lzz;
  768. n:=n shl shift;
  769. repeat
  770. if z>=n then
  771. z:=z-n;
  772. dec(shift);
  773. n:=n shr 1;
  774. until shift<0;
  775. result:=z;
  776. end;
  777. {$endif FPC_SYSTEM_HAS_MOD_DWORD}
  778. {$ifndef FPC_SYSTEM_HAS_DIV_LONGINT}
  779. function fpc_div_longint(n,z : longint) : longint; [public,alias: 'FPC_DIV_LONGINT']; {$ifdef hascompilerproc} compilerproc; {$endif}
  780. var
  781. sign : boolean;
  782. d1,d2 : dword;
  783. begin
  784. if n=0 then
  785. HandleErrorFrame(200,get_frame);
  786. sign:=false;
  787. if z<0 then
  788. begin
  789. sign:=not(sign);
  790. d1:=dword(-z);
  791. end
  792. else
  793. d1:=z;
  794. if n<0 then
  795. begin
  796. sign:=not(sign);
  797. d2:=dword(-n);
  798. end
  799. else
  800. d2:=n;
  801. { the div is coded by the compiler as call to divdword }
  802. if sign then
  803. result:=-(d1 div d2)
  804. else
  805. result:=d1 div d2;
  806. end;
  807. {$endif FPC_SYSTEM_HAS_DIV_LONGINT}
  808. {$ifndef FPC_SYSTEM_HAS_MOD_LONGINT}
  809. function fpc_mod_longint(n,z : longint) : longint; [public,alias: 'FPC_MOD_LONGINT']; {$ifdef hascompilerproc} compilerproc; {$endif}
  810. var
  811. signed : boolean;
  812. r,nq,zq : dword;
  813. begin
  814. if n=0 then
  815. HandleErrorFrame(200,get_frame);
  816. if n<0 then
  817. begin
  818. nq:=-n;
  819. signed:=true;
  820. end
  821. else
  822. begin
  823. signed:=false;
  824. nq:=n;
  825. end;
  826. if z<0 then
  827. begin
  828. zq:=dword(-z);
  829. signed:=not(signed);
  830. end
  831. else
  832. zq:=z;
  833. r:=zq mod nq;
  834. if signed then
  835. result:=-longint(r)
  836. else
  837. result:=r;
  838. end;
  839. {$endif FPC_SYSTEM_HAS_MOD_LONGINT}
  840. {$endif FPC_INCLUDE_SOFTWARE_MOD_DIV}
  841. {****************************************************************************}
  842. {$ifndef FPC_SYSTEM_HAS_ABS_LONGINT}
  843. function abs(l:longint):longint;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_abs];
  844. begin
  845. if l<0 then
  846. abs:=-l
  847. else
  848. abs:=l;
  849. end;
  850. {$endif not FPC_SYSTEM_HAS_ABS_LONGINT}
  851. {$ifndef FPC_SYSTEM_HAS_ODD_LONGINT}
  852. function odd(l:longint):boolean;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_odd];
  853. begin
  854. odd:=boolean(l and 1);
  855. end;
  856. {$endif ndef FPC_SYSTEM_HAS_ODD_LONGINT}
  857. {$ifndef FPC_SYSTEM_HAS_ODD_LONGWORD}
  858. function odd(l:longword):boolean;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_odd];
  859. begin
  860. odd:=boolean(l and 1);
  861. end;
  862. {$endif ndef FPC_SYSTEM_HAS_ODD_LONGWORD}
  863. {$ifndef FPC_SYSTEM_HAS_ODD_INT64}
  864. function odd(l:int64):boolean;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_odd];
  865. begin
  866. odd:=boolean(longint(l) and 1);
  867. end;
  868. {$endif ndef FPC_SYSTEM_HAS_ODD_INT64}
  869. {$ifndef FPC_SYSTEM_HAS_ODD_QWORD}
  870. function odd(l:qword):boolean;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_odd];
  871. begin
  872. odd:=boolean(longint(l) and 1);
  873. end;
  874. {$endif ndef FPC_SYSTEM_HAS_ODD_QWORD}
  875. {$ifndef FPC_SYSTEM_HAS_SQR_LONGINT}
  876. function sqr(l:longint):longint;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_sqr];
  877. begin
  878. sqr:=l*l;
  879. end;
  880. {$endif ndef FPC_SYSTEM_HAS_SQR_LONGINT}
  881. {$ifndef FPC_SYSTEM_HAS_ABS_INT64}
  882. function abs(l: Int64): Int64;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_abs];
  883. begin
  884. if l < 0 then
  885. abs := -l
  886. else
  887. abs := l;
  888. end;
  889. {$endif ndef FPC_SYSTEM_HAS_ABS_INT64}
  890. {$ifndef FPC_SYSTEM_HAS_SQR_INT64}
  891. function sqr(l: Int64): Int64;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_sqr];
  892. begin
  893. sqr := l*l;
  894. end;
  895. {$endif ndef FPC_SYSTEM_HAS_SQR_INT64}
  896. {$ifndef FPC_SYSTEM_HAS_SQR_QWORD}
  897. function sqr(l: QWord): QWord;{$ifdef SYSTEMINLINE}inline;{$endif}[internconst:in_const_sqr];
  898. begin
  899. sqr := l*l;
  900. end;
  901. {$endif ndef FPC_SYSTEM_HAS_SQR_INT64}
  902. {$ifndef FPC_SYSTEM_HAS_DECLOCKED_LONGINT}
  903. function declocked(var l:longint):boolean;
  904. begin
  905. Dec(l);
  906. declocked:=(l=0);
  907. end;
  908. {$endif FPC_SYSTEM_HAS_DECLOCKED_LONGINT}
  909. {$ifndef FPC_SYSTEM_HAS_DECLOCKED_INT64}
  910. function declocked(var l:int64):boolean;
  911. begin
  912. Dec(l);
  913. declocked:=(l=0);
  914. end;
  915. {$endif FPC_SYSTEM_HAS_DECLOCKED_INT64}
  916. {$ifndef FPC_SYSTEM_HAS_INCLOCKED_LONGINT}
  917. procedure inclocked(var l:longint);
  918. begin
  919. Inc(l);
  920. end;
  921. {$endif FPC_SYSTEM_HAS_INCLOCKED_LONGINT}
  922. {$ifndef FPC_SYSTEM_HAS_INCLOCKED_INT64}
  923. procedure inclocked(var l:int64);
  924. begin
  925. Inc(l);
  926. end;
  927. {$endif FPC_SYSTEM_HAS_INCLOCKED_INT64}
  928. {$ifndef FPC_SYSTEM_HAS_SPTR}
  929. {_$error Sptr must be defined for each processor }
  930. {$endif ndef FPC_SYSTEM_HAS_SPTR}
  931. procedure prefetch(const mem);[internproc:in_prefetch_var];
  932. {****************************************************************************
  933. Str()
  934. ****************************************************************************}
  935. {$ifndef FPC_SYSTEM_HAS_INT_STR_LONGINT}
  936. procedure int_str(l : longint;var s : string);
  937. var
  938. value: longint;
  939. negative: boolean;
  940. begin
  941. negative := false;
  942. s:='';
  943. { Workaround: }
  944. if l=longint($80000000) then
  945. begin
  946. s:='-2147483648';
  947. exit;
  948. end;
  949. { handle case where l = 0 }
  950. if l = 0 then
  951. begin
  952. s:='0';
  953. exit;
  954. end;
  955. If l < 0 then
  956. begin
  957. negative := true;
  958. value:=abs(l);
  959. end
  960. else
  961. value:=l;
  962. { handle non-zero case }
  963. while value>0 do
  964. begin
  965. s:=char((value mod 10)+ord('0'))+s;
  966. value := value div 10;
  967. end;
  968. if negative then
  969. s := '-' + s;
  970. end;
  971. {$endif ndef FPC_SYSTEM_HAS_INT_STR_LONGINT}
  972. {$ifndef FPC_SYSTEM_HAS_INT_STR_LONGWORD}
  973. procedure int_str(l : longword;var s : string);
  974. begin
  975. s:='';
  976. if l = 0 then
  977. begin
  978. s := '0';
  979. exit;
  980. end;
  981. while l>0 do
  982. begin
  983. s:=char(ord('0')+(l mod 10))+s;
  984. l:=l div 10;
  985. end;
  986. end;
  987. {$endif ndef FPC_SYSTEM_HAS_INT_STR_LONGWORD}
  988. {$ifndef FPC_SYSTEM_HAS_INT_STR_INT64}
  989. procedure int_str(l : int64;var s : string);
  990. var
  991. value: int64;
  992. negative: boolean;
  993. begin
  994. negative := false;
  995. s:='';
  996. { Workaround: }
  997. if l=int64($8000000000000000) then
  998. begin
  999. s:='-9223372036854775808';
  1000. exit;
  1001. end;
  1002. { handle case where l = 0 }
  1003. if l = 0 then
  1004. begin
  1005. s:='0';
  1006. exit;
  1007. end;
  1008. If l < 0 then
  1009. begin
  1010. negative := true;
  1011. value:=abs(l);
  1012. end
  1013. else
  1014. value:=l;
  1015. { handle non-zero case }
  1016. while value>0 do
  1017. begin
  1018. s:=char((value mod 10)+ord('0'))+s;
  1019. value := value div 10;
  1020. end;
  1021. if negative then
  1022. s := '-' + s;
  1023. end;
  1024. {$endif ndef FPC_SYSTEM_HAS_INT_STR_INT64}
  1025. {$ifndef FPC_SYSTEM_HAS_INT_STR_QWORD}
  1026. procedure int_str(l : qword;var s : string);
  1027. begin
  1028. s:='';
  1029. if l = 0 then
  1030. begin
  1031. s := '0';
  1032. exit;
  1033. end;
  1034. while l>0 do
  1035. begin
  1036. s:=char(ord('0')+(l mod 10))+s;
  1037. l:=l div 10;
  1038. end;
  1039. end;
  1040. {$endif ndef FPC_SYSTEM_HAS_INT_STR_QWORD}
  1041. {$ifndef FPC_SYSTEM_HAS_SYSRESETFPU}
  1042. procedure SysResetFpu;
  1043. begin
  1044. { nothing todo }
  1045. end;
  1046. {$endif FPC_SYSTEM_HAS_SYSRESETFPU}
  1047. {
  1048. $Log$
  1049. Revision 1.75 2004-05-01 20:52:50 peter
  1050. * ValSInt fixed for 64 bit
  1051. Revision 1.74 2004/05/01 15:26:33 jonas
  1052. * use some more string routines from libc if FPC_USE_LIBC is used
  1053. Revision 1.73 2004/04/29 19:50:13 peter
  1054. * x86-64 fixes
  1055. Revision 1.72 2004/04/28 21:01:29 florian
  1056. * tvmt fixed (longint -> ptrint)
  1057. Revision 1.71 2004/04/28 20:48:20 peter
  1058. * ordinal-pointer conversions fixed
  1059. Revision 1.70 2004/04/26 15:55:01 peter
  1060. * FPC_MOVE alias
  1061. Revision 1.69 2004/02/02 20:39:27 florian
  1062. + added prefetch(const mem)
  1063. Revision 1.68 2004/01/31 16:14:24 florian
  1064. * alignment handling of generic fillbyte/word fixed
  1065. Revision 1.66 2004/01/21 01:25:02 florian
  1066. * improved generic int. div routines
  1067. Revision 1.65 2004/01/20 23:16:56 florian
  1068. + created generic versions of software dword/longint mod/div
  1069. Revision 1.64 2004/01/10 17:01:29 jonas
  1070. * changed index* to conform to the assembler implementations (interpret
  1071. negative upper bound as maximum)
  1072. Revision 1.63 2003/12/16 09:43:04 daniel
  1073. * Use of 0 instead of nil fixed
  1074. Revision 1.62 2003/12/06 13:25:30 jonas
  1075. * fixed longint/cardinal comparison in int_str
  1076. Revision 1.61 2003/09/03 14:09:37 florian
  1077. * arm fixes to the common rtl code
  1078. * some generic math code fixed
  1079. * ...
  1080. Revision 1.60 2003/06/01 14:50:17 jonas
  1081. * fpc_shortstr_append_shortstr has to use high(s1) instead of 255 as
  1082. maxlen
  1083. + ppc version of fpc_shortstr_append_shortstr
  1084. Revision 1.59 2003/05/26 21:18:13 peter
  1085. * FPC_SHORTSTR_APPEND_SHORTSTR public added
  1086. Revision 1.58 2003/05/26 19:36:46 peter
  1087. * fpc_shortstr_concat is now the same for all targets
  1088. * fpc_shortstr_append_shortstr added for optimized code generation
  1089. Revision 1.57 2003/05/16 22:40:11 florian
  1090. * fixed generic shortstr_compare
  1091. Revision 1.56 2003/05/13 20:52:50 peter
  1092. * extra check for self and empty objects
  1093. Revision 1.55 2003/05/13 19:18:08 peter
  1094. * fpc_help_fail compilerproc
  1095. * fpc_new_class, fpc_dispose_class not needed by latest compiler
  1096. Revision 1.54 2003/04/23 13:10:09 peter
  1097. * remvoe objectsize loading from help_destructor
  1098. * implement fpc_check_object
  1099. * saveregistrers for check_object
  1100. Revision 1.53 2003/04/02 14:05:45 peter
  1101. * undo previous commit
  1102. Revision 1.51 2003/03/26 00:17:34 peter
  1103. * generic constructor/destructor fixes
  1104. Revision 1.50 2003/02/18 17:56:06 jonas
  1105. - removed buggy i386-specific FPC_CHARARRAY_TO_SHORTSTR
  1106. * fixed generic FPC_CHARARRAY_TO_SHORTSTR (web bug 2382)
  1107. * fixed some potential range errors in indexchar/word/dword
  1108. Revision 1.49 2003/01/20 22:21:36 mazen
  1109. * many stuff related to RTL fixed
  1110. Revision 1.48 2003/01/09 20:14:20 florian
  1111. * fixed helper declarations
  1112. Revision 1.47 2003/01/07 22:04:12 mazen
  1113. - space removed
  1114. Revision 1.46 2003/01/06 23:04:21 mazen
  1115. * functions headers modified in generic.inc to make it possible compiling sparc
  1116. RTL based on generic code
  1117. Revision 1.45 2003/01/05 21:32:35 mazen
  1118. * fixing several bugs compiling the RTL
  1119. Revision 1.44 2002/12/23 21:27:13 peter
  1120. * fix wrong var names for shortstr_compare
  1121. Revision 1.43 2002/10/20 11:51:54 carl
  1122. * avoid crashes with negative len counts on fills/moves
  1123. * movechar0 was wrong and did not do the behavior as
  1124. described in docs
  1125. Revision 1.42 2002/10/14 19:39:17 peter
  1126. * threads unit added for thread support
  1127. Revision 1.41 2002/10/12 20:32:41 carl
  1128. * RunError 220 -> RunError 219 to be more consistent with as operator
  1129. Revision 1.40 2002/10/10 16:08:50 florian
  1130. + several widestring/pwidechar related helpers added
  1131. Revision 1.39 2002/10/05 14:20:16 peter
  1132. * fpc_pchar_length compilerproc and strlen alias
  1133. Revision 1.38 2002/10/02 18:21:51 peter
  1134. * Copy() changed to internal function calling compilerprocs
  1135. * FPC_SHORTSTR_COPY renamed to FPC_SHORTSTR_ASSIGN because of the
  1136. new copy functions
  1137. Revision 1.37 2002/09/27 21:10:40 carl
  1138. * fix 2GB limit problem
  1139. Revision 1.36 2002/09/13 19:13:06 carl
  1140. * FPC_HELP_FAIL : reset _self to nil
  1141. Revision 1.35 2002/09/10 21:29:44 jonas
  1142. * added some missing compilerproc directives
  1143. Revision 1.34 2002/09/07 21:08:42 carl
  1144. * cardinal -> longword
  1145. - remove generic boundcheck (does not exist in v1.1)
  1146. Revision 1.33 2002/09/07 15:07:45 peter
  1147. * old logs removed and tabs fixed
  1148. Revision 1.32 2002/08/19 19:34:02 peter
  1149. * SYSTEMINLINE define that will add inline directives for small
  1150. functions and wrappers. This will be defined automaticly when
  1151. the compiler defines the HASINLINE directive
  1152. Revision 1.31 2002/07/29 21:28:16 florian
  1153. * several fixes to get further with linux/ppc system unit compilation
  1154. Revision 1.30 2002/07/29 09:23:11 jonas
  1155. * fixed some datastructures > 2GB
  1156. Revision 1.29 2002/07/28 21:39:28 florian
  1157. * made abs a compiler proc if it is generic
  1158. Revision 1.28 2002/07/28 20:43:47 florian
  1159. * several fixes for linux/powerpc
  1160. * several fixes to MT
  1161. Revision 1.27 2002/06/16 08:19:03 carl
  1162. * bugfix of FPC_NEW_CLASS (was not creating correct instance)
  1163. + FPC_HELP_FAIL_CLASS now tested (no longer required)
  1164. Revision 1.25 2002/05/16 19:58:05 carl
  1165. * generic constructor implemented
  1166. Revision 1.24 2002/03/30 13:08:54 carl
  1167. * memory corruption bugfix in FPC_HELP_CONSTRUCTOR if object cannot be allocated
  1168. Revision 1.23 2002/01/25 17:38:55 peter
  1169. * add internconst for all overloaded types of Odd/Abs/Sqr
  1170. Revision 1.22 2002/01/24 12:33:53 jonas
  1171. * adapted ranges of native types to int64 (e.g. high cardinal is no
  1172. longer longint($ffffffff), but just $fffffff in psystem)
  1173. * small additional fix in 64bit rangecheck code generation for 32 bit
  1174. processors
  1175. * adaption of ranges required the matching talgorithm used for selecting
  1176. which overloaded procedure to call to be adapted. It should now always
  1177. select the closest match for ordinal parameters.
  1178. + inttostr(qword) in sysstr.inc/sysstrh.inc
  1179. + abs(int64), sqr(int64), sqr(qword) in systemh.inc/generic.inc (previous
  1180. fixes were required to be able to add them)
  1181. * is_in_limit() moved from ncal to types unit, should always be used
  1182. instead of direct comparisons of low/high values of orddefs because
  1183. qword is a special case
  1184. }