ppu.pas 22 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010
  1. {
  2. $Id$
  3. Copyright (c) 1993-98 by Florian Klaempfl
  4. Routines to read/write ppu files
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  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. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. ****************************************************************************
  17. }
  18. {$ifdef TP}
  19. {$N+,E+}
  20. {$endif}
  21. unit ppu;
  22. interface
  23. {$ifdef Test_Double_checksum}
  24. var
  25. CRCFile : text;
  26. const
  27. CRC_array_Size = 20000;
  28. type
  29. tcrc_array = array[0..crc_array_size] of longint;
  30. pcrc_array = ^tcrc_array;
  31. {$endif Test_Double_checksum}
  32. const
  33. {$ifdef OLDPPU}
  34. CurrentPPUVersion=15;
  35. {$else}
  36. CurrentPPUVersion=16;
  37. {$endif}
  38. { buffer sizes }
  39. maxentrysize = 1024;
  40. {$ifdef TP}
  41. ppubufsize = 1024;
  42. {$else}
  43. ppubufsize = 16384;
  44. {$endif}
  45. {ppu entries}
  46. mainentryid = 1;
  47. subentryid = 2;
  48. {special}
  49. iberror = 0;
  50. ibstartdefs = 248;
  51. ibenddefs = 249;
  52. ibstartsyms = 250;
  53. ibendsyms = 251;
  54. ibendinterface = 252;
  55. ibendimplementation = 253;
  56. ibendbrowser = 254;
  57. ibend = 255;
  58. {general}
  59. ibmodulename = 1;
  60. ibsourcefiles = 2;
  61. ibloadunit = 3;
  62. ibinitunit = 5;
  63. iblinkofiles = 6;
  64. iblinksharedlibs = 7;
  65. iblinkstaticlibs = 8;
  66. ibdbxcount = 9;
  67. ibsymref = 10;
  68. ibdefref = 11;
  69. ibendsymtablebrowser = 12;
  70. ibbeginsymtablebrowser = 13;
  71. iblinkunitfiles = 14;
  72. {syms}
  73. ibtypesym = 20;
  74. ibprocsym = 21;
  75. ibvarsym = 22;
  76. ibconstsym = 23;
  77. ibenumsym = 24;
  78. ibtypedconstsym = 25;
  79. ibabsolutesym = 26;
  80. ibpropertysym = 27;
  81. ibvarsym_C = 28;
  82. ibunitsym = 29; { needed for browser }
  83. iblabelsym = 30;
  84. ibfuncretsym = 31;
  85. ibsyssym = 32;
  86. {definitions}
  87. iborddef = 40;
  88. ibpointerdef = 41;
  89. ibarraydef = 42;
  90. ibprocdef = 43;
  91. ibshortstringdef = 44;
  92. ibrecorddef = 45;
  93. ibfiledef = 46;
  94. ibformaldef = 47;
  95. ibobjectdef = 48;
  96. ibenumdef = 49;
  97. ibsetdef = 50;
  98. ibprocvardef = 51;
  99. ibfloatdef = 52;
  100. ibclassrefdef = 53;
  101. iblongstringdef = 54;
  102. ibansistringdef = 55;
  103. ibwidestringdef = 56;
  104. { unit flags }
  105. uf_init = $1;
  106. uf_finalize = $2;
  107. uf_big_endian = $4;
  108. uf_has_dbx = $8;
  109. uf_has_browser = $10;
  110. uf_smartlink = $20; { the ppu is smartlinked }
  111. uf_in_library = $40; { is the file in another file than <ppufile>.* ? }
  112. uf_static_linked = $80; { the ppu is linked in a static library }
  113. uf_shared_linked = $100; { the ppu is linked in a shared library }
  114. uf_local_browser = $200;
  115. uf_obj_linked = $400; { the ppu is linked in a object file }
  116. type
  117. {$ifdef m68k}
  118. ppureal=single;
  119. {$else}
  120. ppureal=extended;
  121. {$endif}
  122. tppuerror=(ppuentrytoobig,ppuentryerror);
  123. tppuheader=packed record { 40 bytes }
  124. id : array[1..3] of char; { = 'PPU' }
  125. ver : array[1..3] of char;
  126. compiler : word;
  127. cpu : word;
  128. target : word;
  129. flags : longint;
  130. size : longint; { size of the ppufile without header }
  131. checksum : longint; { checksum for this ppufile }
  132. {$ifndef OLDPPU}
  133. interface_checksum : longint;
  134. future : array[0..2] of longint;
  135. {$endif}
  136. end;
  137. tppuentry=packed record
  138. id : byte;
  139. nr : byte;
  140. size : longint;
  141. end;
  142. pppufile=^tppufile;
  143. tppufile=object
  144. f : file;
  145. mode : byte; {0 - Closed, 1 - Reading, 2 - Writing}
  146. error : boolean;
  147. fname : string;
  148. fsize : longint;
  149. header : tppuheader;
  150. size,crc : longint;
  151. {$ifdef Test_Double_checksum}
  152. crcindex : longint;
  153. crc_index : longint;
  154. crc_test : pcrc_array;
  155. {$endif def Test_Double_checksum}
  156. interface_crc : longint;
  157. do_interface_crc : boolean;
  158. crc_only : boolean; { used to calculate interface_crc before implementation }
  159. do_crc,
  160. change_endian : boolean;
  161. buf : pchar;
  162. bufstart,
  163. bufsize,
  164. bufidx : longint;
  165. entrybufstart,
  166. entrystart,
  167. entryidx : longint;
  168. entry : tppuentry;
  169. entrytyp : byte;
  170. constructor init(fn:string);
  171. destructor done;
  172. procedure flush;
  173. procedure close;
  174. function CheckPPUId:boolean;
  175. function GetPPUVersion:longint;
  176. procedure NewHeader;
  177. procedure NewEntry;
  178. {read}
  179. function open:boolean;
  180. procedure reloadbuf;
  181. procedure readdata(var b;len:longint);
  182. procedure skipdata(len:longint);
  183. function readentry:byte;
  184. function EndOfEntry:boolean;
  185. procedure getdatabuf(var b;len:longint;var result:longint);
  186. procedure getdata(var b;len:longint);
  187. function getbyte:byte;
  188. function getword:word;
  189. function getlongint:longint;
  190. function getreal:ppureal;
  191. function getstring:string;
  192. function skipuntilentry(untilb:byte):boolean;
  193. {write}
  194. function create:boolean;
  195. procedure writeheader;
  196. procedure writebuf;
  197. procedure writedata(var b;len:longint);
  198. procedure writeentry(ibnr:byte);
  199. procedure putdata(var b;len:longint);
  200. procedure putbyte(b:byte);
  201. procedure putword(w:word);
  202. procedure putlongint(l:longint);
  203. procedure putreal(d:ppureal);
  204. procedure putstring(s:string);
  205. end;
  206. implementation
  207. {$ifdef Test_Double_checksum}
  208. uses
  209. comphook;
  210. {$endif def Test_Double_checksum}
  211. {*****************************************************************************
  212. Crc 32
  213. *****************************************************************************}
  214. var
  215. Crc32Tbl : array[0..255] of longint;
  216. procedure MakeCRC32Tbl;
  217. var
  218. crc : longint;
  219. i,n : byte;
  220. begin
  221. for i:=0 to 255 do
  222. begin
  223. crc:=i;
  224. for n:=1 to 8 do
  225. if odd(crc) then
  226. crc:=(crc shr 1) xor $edb88320
  227. else
  228. crc:=crc shr 1;
  229. Crc32Tbl[i]:=crc;
  230. end;
  231. end;
  232. {$ifopt R+}
  233. {$define Range_check_on}
  234. {$endif opt R+}
  235. {$R- needed here }
  236. {CRC 32}
  237. Function Crc32(Const HStr:String):longint;
  238. var
  239. i,InitCrc : longint;
  240. begin
  241. if Crc32Tbl[1]=0 then
  242. MakeCrc32Tbl;
  243. InitCrc:=$ffffffff;
  244. for i:=1to Length(Hstr) do
  245. InitCrc:=Crc32Tbl[byte(InitCrc) xor ord(Hstr[i])] xor (InitCrc shr 8);
  246. Crc32:=InitCrc;
  247. end;
  248. Function UpdateCrc32(InitCrc:longint;var InBuf;InLen:Longint):longint;
  249. var
  250. i : word;
  251. p : pchar;
  252. begin
  253. if Crc32Tbl[1]=0 then
  254. MakeCrc32Tbl;
  255. p:=@InBuf;
  256. for i:=1to InLen do
  257. begin
  258. InitCrc:=Crc32Tbl[byte(InitCrc) xor byte(p^)] xor (InitCrc shr 8);
  259. inc(longint(p));
  260. end;
  261. UpdateCrc32:=InitCrc;
  262. end;
  263. Function UpdCrc32(InitCrc:longint;b:byte):longint;
  264. begin
  265. if Crc32Tbl[1]=0 then
  266. MakeCrc32Tbl;
  267. UpdCrc32:=Crc32Tbl[byte(InitCrc) xor b] xor (InitCrc shr 8);
  268. end;
  269. {$ifdef Range_check_on}
  270. {$R+}
  271. {$undef Range_check_on}
  272. {$endif Range_check_on}
  273. {*****************************************************************************
  274. TPPUFile
  275. *****************************************************************************}
  276. constructor tppufile.init(fn:string);
  277. begin
  278. fname:=fn;
  279. change_endian:=false;
  280. crc_only:=false;
  281. Mode:=0;
  282. NewHeader;
  283. Error:=false;
  284. getmem(buf,ppubufsize);
  285. end;
  286. destructor tppufile.done;
  287. begin
  288. close;
  289. freemem(buf,ppubufsize);
  290. end;
  291. procedure tppufile.flush;
  292. begin
  293. if Mode=2 then
  294. writebuf;
  295. end;
  296. procedure tppufile.close;
  297. var
  298. i : word;
  299. begin
  300. if Mode<>0 then
  301. begin
  302. Flush;
  303. {$I-}
  304. system.close(f);
  305. {$I+}
  306. i:=ioresult;
  307. Mode:=0;
  308. end;
  309. end;
  310. function tppufile.CheckPPUId:boolean;
  311. begin
  312. CheckPPUId:=((Header.Id[1]='P') and (Header.Id[2]='P') and (Header.Id[3]='U'));
  313. end;
  314. function tppufile.GetPPUVersion:longint;
  315. var
  316. l : longint;
  317. code : word;
  318. begin
  319. Val(header.ver[1]+header.ver[2]+header.ver[3],l,code);
  320. if code=0 then
  321. GetPPUVersion:=l
  322. else
  323. GetPPUVersion:=0;
  324. end;
  325. procedure tppufile.NewHeader;
  326. begin
  327. fillchar(header,sizeof(tppuheader),0);
  328. with header do
  329. begin
  330. Id[1]:='P';
  331. Id[2]:='P';
  332. Id[3]:='U';
  333. Ver[1]:='0';
  334. Ver[2]:='1';
  335. {$ifdef OLDPPU}
  336. Ver[3]:='5';
  337. {$else}
  338. Ver[3]:='6';
  339. {$endif}
  340. end;
  341. end;
  342. {*****************************************************************************
  343. TPPUFile Reading
  344. *****************************************************************************}
  345. function tppufile.open:boolean;
  346. var
  347. ofmode : byte;
  348. i : word;
  349. begin
  350. open:=false;
  351. assign(f,fname);
  352. ofmode:=filemode;
  353. filemode:=$0;
  354. {$I-}
  355. reset(f,1);
  356. {$I+}
  357. filemode:=ofmode;
  358. if ioresult<>0 then
  359. exit;
  360. {read ppuheader}
  361. fsize:=filesize(f);
  362. if fsize<sizeof(tppuheader) then
  363. exit;
  364. blockread(f,header,sizeof(tppuheader),i);
  365. {reset buffer}
  366. bufstart:=i;
  367. bufsize:=0;
  368. bufidx:=0;
  369. Mode:=1;
  370. FillChar(entry,sizeof(tppuentry),0);
  371. entryidx:=0;
  372. entrystart:=0;
  373. entrybufstart:=0;
  374. Error:=false;
  375. open:=true;
  376. end;
  377. procedure tppufile.reloadbuf;
  378. {$ifdef TP}
  379. var
  380. i : word;
  381. {$endif}
  382. begin
  383. inc(bufstart,bufsize);
  384. {$ifdef TP}
  385. blockread(f,buf^,ppubufsize,i);
  386. bufsize:=i;
  387. {$else}
  388. blockread(f,buf^,ppubufsize,bufsize);
  389. {$endif}
  390. bufidx:=0;
  391. end;
  392. procedure tppufile.readdata(var b;len:longint);
  393. var
  394. p : pchar;
  395. left,
  396. idx : longint;
  397. begin
  398. p:=pchar(@b);
  399. idx:=0;
  400. while len>0 do
  401. begin
  402. left:=bufsize-bufidx;
  403. if len>left then
  404. begin
  405. move(buf[bufidx],p[idx],left);
  406. dec(len,left);
  407. inc(idx,left);
  408. reloadbuf;
  409. if bufsize=0 then
  410. exit;
  411. end
  412. else
  413. begin
  414. move(buf[bufidx],p[idx],len);
  415. inc(bufidx,len);
  416. exit;
  417. end;
  418. end;
  419. end;
  420. procedure tppufile.skipdata(len:longint);
  421. var
  422. left : longint;
  423. begin
  424. while len>0 do
  425. begin
  426. left:=bufsize-bufidx;
  427. if len>left then
  428. begin
  429. dec(len,left);
  430. reloadbuf;
  431. if bufsize=0 then
  432. exit;
  433. end
  434. else
  435. begin
  436. inc(bufidx,len);
  437. exit;
  438. end;
  439. end;
  440. end;
  441. function tppufile.readentry:byte;
  442. begin
  443. if entryidx<entry.size then
  444. skipdata(entry.size-entryidx);
  445. readdata(entry,sizeof(tppuentry));
  446. entrystart:=bufstart+bufidx;
  447. entryidx:=0;
  448. if not(entry.id in [mainentryid,subentryid]) then
  449. begin
  450. readentry:=iberror;
  451. error:=true;
  452. exit;
  453. end;
  454. readentry:=entry.nr;
  455. end;
  456. function tppufile.endofentry:boolean;
  457. begin
  458. endofentry:=(entryidx>=entry.size);
  459. end;
  460. procedure tppufile.getdatabuf(var b;len:longint;var result:longint);
  461. begin
  462. if entryidx+len>entry.size then
  463. result:=entry.size-entryidx
  464. else
  465. result:=len;
  466. readdata(b,result);
  467. inc(entryidx,result);
  468. end;
  469. procedure tppufile.getdata(var b;len:longint);
  470. begin
  471. if entryidx+len>entry.size then
  472. begin
  473. error:=true;
  474. exit;
  475. end;
  476. readdata(b,len);
  477. inc(entryidx,len);
  478. end;
  479. function tppufile.getbyte:byte;
  480. var
  481. b : byte;
  482. begin
  483. if entryidx+1>entry.size then
  484. begin
  485. error:=true;
  486. getbyte:=0;
  487. exit;
  488. end;
  489. readdata(b,1);
  490. getbyte:=b;
  491. inc(entryidx);
  492. end;
  493. function tppufile.getword:word;
  494. type
  495. pword = ^word;
  496. var
  497. w : word;
  498. begin
  499. if entryidx+2>entry.size then
  500. begin
  501. error:=true;
  502. getword:=0;
  503. exit;
  504. end;
  505. readdata(w,2);
  506. if change_endian then
  507. getword:=swap(w)
  508. else
  509. getword:=w;
  510. inc(entryidx,2);
  511. end;
  512. function tppufile.getlongint:longint;
  513. type
  514. plongint = ^longint;
  515. var
  516. l : longint;
  517. begin
  518. if entryidx+4>entry.size then
  519. begin
  520. error:=true;
  521. getlongint:=0;
  522. exit;
  523. end;
  524. readdata(l,4);
  525. if change_endian then
  526. { someone added swap(l : longint) in system unit
  527. this broke the following code !! }
  528. getlongint:=swap(word(l shr 16)) or (longint(swap(word(l and $ffff))) shl 16)
  529. else
  530. getlongint:=l;
  531. inc(entryidx,4);
  532. end;
  533. function tppufile.getreal:ppureal;
  534. type
  535. pppureal = ^ppureal;
  536. var
  537. d : ppureal;
  538. begin
  539. if entryidx+sizeof(ppureal)>entry.size then
  540. begin
  541. error:=true;
  542. getreal:=0;
  543. exit;
  544. end;
  545. readdata(d,sizeof(ppureal));
  546. getreal:=d;
  547. inc(entryidx,sizeof(ppureal));
  548. end;
  549. function tppufile.getstring:string;
  550. var
  551. s : string;
  552. begin
  553. {$ifndef TP}
  554. {$ifopt H+}
  555. setlength(s,getbyte);
  556. {$else}
  557. s[0]:=chr(getbyte);
  558. {$endif}
  559. {$else}
  560. s[0]:=chr(getbyte);
  561. {$endif}
  562. if entryidx+length(s)>entry.size then
  563. begin
  564. error:=true;
  565. exit;
  566. end;
  567. ReadData(s[1],length(s));
  568. getstring:=s;
  569. inc(entryidx,length(s));
  570. end;
  571. function tppufile.skipuntilentry(untilb:byte):boolean;
  572. var
  573. b : byte;
  574. begin
  575. repeat
  576. b:=readentry;
  577. until (b in [ibend,iberror]) or ((b=untilb) and (entry.id=mainentryid));
  578. skipuntilentry:=(b=untilb);
  579. end;
  580. {*****************************************************************************
  581. TPPUFile Writing
  582. *****************************************************************************}
  583. function tppufile.create:boolean;
  584. begin
  585. create:=false;
  586. assign(f,fname);
  587. {$I-}
  588. rewrite(f,1);
  589. {$I+}
  590. if ioresult<>0 then
  591. exit;
  592. Mode:=2;
  593. {write header for sure}
  594. blockwrite(f,header,sizeof(tppuheader));
  595. bufsize:=ppubufsize;
  596. bufstart:=sizeof(tppuheader);
  597. bufidx:=0;
  598. {reset}
  599. crc:=$ffffffff;
  600. interface_crc:=$ffffffff;
  601. do_interface_crc:=true;
  602. Error:=false;
  603. do_crc:=true;
  604. size:=0;
  605. entrytyp:=mainentryid;
  606. {start}
  607. NewEntry;
  608. create:=true;
  609. end;
  610. procedure tppufile.writeheader;
  611. var
  612. opos : longint;
  613. begin
  614. { flush buffer }
  615. writebuf;
  616. { update size (w/o header!) in the header }
  617. header.size:=bufstart-sizeof(tppuheader);
  618. { write header and restore filepos after it }
  619. opos:=filepos(f);
  620. seek(f,0);
  621. blockwrite(f,header,sizeof(tppuheader));
  622. seek(f,opos);
  623. end;
  624. procedure tppufile.writebuf;
  625. begin
  626. blockwrite(f,buf^,bufidx);
  627. inc(bufstart,bufidx);
  628. bufidx:=0;
  629. end;
  630. procedure tppufile.writedata(var b;len:longint);
  631. var
  632. p : pchar;
  633. left,
  634. idx : longint;
  635. begin
  636. p:=pchar(@b);
  637. idx:=0;
  638. while len>0 do
  639. begin
  640. left:=bufsize-bufidx;
  641. if len>left then
  642. begin
  643. move(p[idx],buf[bufidx],left);
  644. dec(len,left);
  645. inc(idx,left);
  646. inc(bufidx,left);
  647. writebuf;
  648. end
  649. else
  650. begin
  651. move(p[idx],buf[bufidx],len);
  652. inc(bufidx,len);
  653. exit;
  654. end;
  655. end;
  656. end;
  657. procedure tppufile.NewEntry;
  658. begin
  659. with entry do
  660. begin
  661. id:=entrytyp;
  662. nr:=ibend;
  663. size:=0;
  664. end;
  665. {Reset Entry State}
  666. entryidx:=0;
  667. entrybufstart:=bufstart;
  668. entrystart:=bufstart+bufidx;
  669. {Alloc in buffer}
  670. writedata(entry,sizeof(tppuentry));
  671. end;
  672. procedure tppufile.writeentry(ibnr:byte);
  673. var
  674. opos : longint;
  675. begin
  676. {create entry}
  677. entry.id:=entrytyp;
  678. entry.nr:=ibnr;
  679. entry.size:=entryidx;
  680. {it's already been sent to disk ?}
  681. if entrybufstart<>bufstart then
  682. begin
  683. {flush to be sure}
  684. WriteBuf;
  685. {write entry}
  686. opos:=filepos(f);
  687. seek(f,entrystart);
  688. blockwrite(f,entry,sizeof(tppuentry));
  689. seek(f,opos);
  690. entrybufstart:=bufstart;
  691. end
  692. else
  693. move(entry,buf[entrystart-bufstart],sizeof(entry));
  694. {Add New Entry, which is ibend by default}
  695. entrystart:=bufstart+bufidx; {next entry position}
  696. NewEntry;
  697. end;
  698. procedure tppufile.putdata(var b;len:longint);
  699. begin
  700. if do_crc then
  701. begin
  702. crc:=UpdateCrc32(crc,b,len);
  703. {$ifndef OLDPPU}
  704. if do_interface_crc then
  705. begin
  706. interface_crc:=UpdateCrc32(interface_crc,b,len);
  707. {$ifdef Test_Double_checksum}
  708. if crc_only then
  709. begin
  710. crc_test^[crc_index]:=interface_crc;
  711. {$ifdef Test_Double_checksum_write}
  712. Writeln(CRCFile,interface_crc);
  713. {$endif Test_Double_checksum_write}
  714. if crc_index<crc_array_size then
  715. inc(crc_index);
  716. end
  717. else
  718. begin
  719. if (crcindex<crc_array_size) and (crcindex<crc_index) and
  720. (crc_test^[crcindex]<>interface_crc) then
  721. Def_comment(V_Warning,'CRC changed');
  722. {$ifdef Test_Double_checksum_write}
  723. Writeln(CRCFile,interface_crc);
  724. {$endif Test_Double_checksum_write}
  725. inc(crcindex);
  726. end;
  727. {$endif def Test_Double_checksum}
  728. end;
  729. end;
  730. if not crc_only then
  731. {$else}
  732. end;
  733. {$endif OLDPPU}
  734. writedata(b,len);
  735. inc(entryidx,len);
  736. end;
  737. procedure tppufile.putbyte(b:byte);
  738. begin
  739. writedata(b,1);
  740. inc(entryidx);
  741. end;
  742. procedure tppufile.putword(w:word);
  743. begin
  744. if change_endian then
  745. w:=swap(w);
  746. putdata(w,2);
  747. end;
  748. procedure tppufile.putlongint(l:longint);
  749. begin
  750. if change_endian then
  751. { someone added swap(l : longint) in system unit
  752. this broke the following code !! }
  753. l:=swap(word(l shr 16)) or (longint(swap(word(l and $ffff))) shl 16);
  754. putdata(l,4);
  755. end;
  756. procedure tppufile.putreal(d:ppureal);
  757. begin
  758. putdata(d,sizeof(ppureal));
  759. end;
  760. procedure tppufile.putstring(s:string);
  761. begin
  762. putdata(s,length(s)+1);
  763. end;
  764. end.
  765. {
  766. $Log$
  767. Revision 1.30 1999-04-26 18:30:00 peter
  768. * farpointerdef moved into pointerdef.is_far
  769. Revision 1.29 1999/04/26 13:31:41 peter
  770. * release storenumber,double_checksum
  771. Revision 1.28 1999/04/26 09:33:07 peter
  772. * header extended to 40 bytes so there is room for future
  773. Revision 1.27 1999/04/17 13:16:20 peter
  774. * fixes for storenumber
  775. Revision 1.26 1999/04/07 15:39:31 pierre
  776. + double_checksum code added
  777. Revision 1.25 1999/03/02 13:49:18 peter
  778. * renamed loadunit_int -> loadunit
  779. Revision 1.24 1999/02/22 13:07:00 pierre
  780. + -b and -bl options work !
  781. + cs_local_browser ($L+) is disabled if cs_browser ($Y+)
  782. is not enabled when quitting global section
  783. * local vars and procedures are not yet stored into PPU
  784. Revision 1.23 1999/02/16 00:48:24 peter
  785. * save in the ppu if linked with obj file instead of using the
  786. library flag, so the .inc files are also checked
  787. Revision 1.22 1999/02/05 08:54:29 pierre
  788. + linkofiles splitted inot linkofiles and linkunitfiles
  789. because linkofiles must be stored with directory
  790. to enabled linking of different objects with same name
  791. in a different directory
  792. Revision 1.21 1998/12/30 22:15:50 peter
  793. + farpointer type
  794. * absolutesym now also stores if its far
  795. Revision 1.20 1998/11/30 16:34:45 pierre
  796. * corrected problems with rangecheck
  797. + added needed code for no rangecheck in CRC32 functions in ppu unit
  798. * enumdef lso need its rangenr reset to zero
  799. when calling reset_global_defs
  800. Revision 1.19 1998/11/16 15:41:42 peter
  801. * tp7 didn't like my ifopt H+ :(
  802. Revision 1.18 1998/11/16 12:18:03 peter
  803. * H+ fixes
  804. Revision 1.17 1998/10/14 10:45:08 pierre
  805. * ppu problems for m68k fixed (at least in cross compiling)
  806. * one last memory leak for sysamiga fixed
  807. * the amiga RTL compiles now completely !!
  808. Revision 1.16 1998/09/24 23:49:14 peter
  809. + aktmodeswitches
  810. Revision 1.15 1998/09/23 15:39:10 pierre
  811. * browser bugfixes
  812. was adding a reference when looking for the symbol
  813. if -bSYM_NAME was used
  814. Revision 1.14 1998/09/21 10:00:07 peter
  815. * store number of defs in ppu file
  816. Revision 1.13 1998/09/21 08:45:18 pierre
  817. + added vmt_offset in tobjectdef.write for fututre use
  818. (first steps to have objects without vmt if no virtual !!)
  819. + added fpu_used field for tabstractprocdef :
  820. sets this level to 2 if the functions return with value in FPU
  821. (is then set to correct value at parsing of implementation)
  822. THIS MIGHT refuse some code with FPU expression too complex
  823. that were accepted before and even in some cases
  824. that don't overflow in fact
  825. ( like if f : float; is a forward that finally in implementation
  826. only uses one fpu register !!)
  827. Nevertheless I think that it will improve security on
  828. FPU operations !!
  829. * most other changes only for UseBrowser code
  830. (added symtable references for record and objects)
  831. local switch for refs to args and local of each function
  832. (static symtable still missing)
  833. UseBrowser still not stable and probably broken by
  834. the definition hash array !!
  835. Revision 1.12 1998/09/18 08:01:37 pierre
  836. + improvement on the usebrowser part
  837. (does not work correctly for now)
  838. Revision 1.11 1998/09/11 15:16:47 peter
  839. * merge fixes
  840. Revision 1.10.2.1 1998/09/11 15:15:04 peter
  841. * fixed not in [] bug
  842. Revision 1.10 1998/08/31 12:26:30 peter
  843. * m68k and palmos updates from surebugfixes
  844. Revision 1.9 1998/08/17 09:17:51 peter
  845. * static/shared linking updates
  846. Revision 1.8 1998/08/11 15:31:40 peter
  847. * write extended to ppu file
  848. * new version 0.99.7
  849. Revision 1.7 1998/06/25 10:51:01 pierre
  850. * removed a remaining ifndef NEWPPU
  851. replaced by ifdef OLDPPU
  852. * added uf_finalize to ppu unit
  853. Revision 1.6 1998/06/16 08:56:26 peter
  854. + targetcpu
  855. * cleaner pmodules for newppu
  856. Revision 1.5 1998/06/13 00:10:12 peter
  857. * working browser and newppu
  858. * some small fixes against crashes which occured in bp7 (but not in
  859. fpc?!)
  860. Revision 1.4 1998/06/09 16:01:48 pierre
  861. + added procedure directive parsing for procvars
  862. (accepted are popstack cdecl and pascal)
  863. + added C vars with the following syntax
  864. var C calias 'true_c_name';(can be followed by external)
  865. reason is that you must add the Cprefix
  866. which is target dependent
  867. Revision 1.3 1998/05/28 14:40:26 peter
  868. * fixes for newppu, remake3 works now with it
  869. Revision 1.2 1998/05/27 19:45:08 peter
  870. * symtable.pas splitted into includefiles
  871. * symtable adapted for $ifdef NEWPPU
  872. Revision 1.1 1998/05/12 10:56:07 peter
  873. + the ppufile object unit
  874. }