ppu.pas 22 KB

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