generic.inc 37 KB

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