MSTORAGE.LST 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549
  1. Listing:
  2. 1 (* Release 3.10 *)
  3. 2 (*-------------------------------------------------------------------------*
  4. 3 * *
  5. 4 * MSTORAGE.MOD - Dynamic allocations for mixed M2/C, and overlay model *
  6. 5 * *
  7. 6 * COPYRIGHT (C) 1987..1992 Clarion Software Corporation. *
  8. 7 * All Rights Reserved *
  9. 8 * *
  10. 9 *--------------------------------------------------------------------------*)
  11. 10
  12. 11 (*%F _fdata *)
  13. 12 (*# call(seg_name => null) *)
  14. 13 (*# data(seg_name => null) *)
  15. 14 (*%E *)
  16. 15 (*# module(implementation=>off) *)
  17. 16 (*# check(stack=>off,
  18. 17 index=>off,
  19. 18 range=>off,
  20. 19 overflow=>off,
  21. 20 nil_ptr=>off) *)
  22. 21
  23. 22 IMPLEMENTATION MODULE Storage;
  24. 23
  25. 24 (*
  26. 25 Version of STORAGE.MOD for DOS Overlay, Dynalink and mixed-language
  27. 26 libraries
  28. 27 *)
  29. 28
  30. 29 IMPORT SYSTEM, Lib, CoreMem, CoreSig, CoreMain;
  31. 30 (*%T _mthread *)
  32. 31 IMPORT Process;
  33. 32 (*%E *)
  34. 33
  35. 34 CONST
  36. 35 _DLLOVL = (_DLL OR _OVL) AND NOT _OS2;
  37. ***** ^ undeclared identifier
  38. ***** ^ undeclared identifier
  39. ***** ^ undeclared identifier
  40. 36
  41. 37 CONST
  42. 38 EndMarker = 0FFFFH;
  43. 39 Align = 4;
  44. 40
  45. 41
  46. 42 (* This is DOS ONLY *)
  47. 43
  48. 44 PROCEDURE FarMakeHeap( Source : CARDINAL; (* base segment of heap *)
  49. 45 Size : CARDINAL (* size in paragraphs *)
  50. 46 ) : FarHeapRecPtr;
  51. ***** ^ undeclared identifier
  52. 47 VAR
  53. 48 storage,first,last : FarHeapRecPtr;
  54. ***** ^ undeclared identifier
  55. 49 BEGIN
  56. 50 (*%T _mthread *)
  57. 51 Process.Lock;
  58. ***** ^ not supported yet
  59. ***** ^ not supported yet
  60. 52 (*%E *)
  61. 53 storage := [Source:0];
  62. ***** ^ not supported yet
  63. ***** ^ not supported yet
  64. 54 first := [Source+1:0];
  65. ***** ^ not supported yet
  66. ***** ^ not supported yet
  67. 55 last := [Source+Size-1:0];
  68. ***** ^ not supported yet
  69. ***** ^ not supported yet
  70. 56 storage^.next := first;
  71. ***** ^ not supported yet
  72. ***** ^ not supported yet
  73. ***** ^ not supported yet
  74. 57 storage^.size := 0;
  75. ***** ^ not supported yet
  76. ***** ^ not supported yet
  77. 58 first^.next := last;
  78. ***** ^ not supported yet
  79. ***** ^ not supported yet
  80. ***** ^ not supported yet
  81. 59 last^.next := storage;
  82. ***** ^ not supported yet
  83. ***** ^ not supported yet
  84. ***** ^ not supported yet
  85. 60 first^.size := Size-2;
  86. ***** ^ not supported yet
  87. ***** ^ not supported yet
  88. 61 last^.size := EndMarker;
  89. ***** ^ not supported yet
  90. ***** ^ not supported yet
  91. 62 (*%T _mthread *)
  92. 63 Process.Unlock;
  93. ***** ^ not supported yet
  94. ***** ^ not supported yet
  95. 64 (*%E *)
  96. 65 RETURN storage;
  97. ***** ^ not supported yet
  98. 66 END FarMakeHeap;
  99. ***** ^ not supported yet
  100. 67
  101. 68
  102. 69 PROCEDURE FarHeapAllocate(Source : FarHeapRecPtr; (* source heap *)
  103. ***** ^ undeclared identifier
  104. 70 VAR A : FarADDRESS; (* result *)
  105. ***** ^ undeclared identifier
  106. 71 Size : CARDINAL); (* request size in paragraphs *)
  107. 72
  108. 73 VAR
  109. 74 res,prev,split : FarHeapRecPtr;
  110. ***** ^ undeclared identifier
  111. 75 BEGIN
  112. 76 IF Source = MainHeap THEN
  113. ***** ^ not supported yet
  114. ***** ^ undeclared identifier
  115. 77 A:=CoreMem.halloc(LONGCARD(Size)<<4);
  116. ***** ^ not supported yet
  117. ***** ^ not supported yet
  118. ***** ^ not supported yet
  119. ***** ^ undeclared identifier
  120. ***** ^ not supported yet
  121. ***** ^ arithmetic operand must be numeric
  122. 78 IF A = SYSTEM.FarNIL THEN
  123. ***** ^ not supported yet
  124. ***** ^ not supported yet
  125. ***** ^ not supported yet
  126. 79 IF Check THEN
  127. ***** ^ undeclared identifier
  128. 80 Lib.RunTimeError(CoreSig._FatalErrorPos(), 90H, 'FarHeapAllocate : Out Of Space');
  129. ***** ^ not supported yet
  130. ***** ^ not supported yet
  131. ***** ^ not supported yet
  132. ***** ^ not supported yet
  133. ***** ^ not supported yet
  134. ***** ^ not supported yet
  135. 81 ELSE
  136. 82 A := FarNIL;
  137. ***** ^ not supported yet
  138. ***** ^ undeclared identifier
  139. 83 RETURN;
  140. 84 END;
  141. 85 END;
  142. 86 RETURN;
  143. 87 END;
  144. 88 (*%T _mthread *)
  145. 89 Process.Lock;
  146. ***** ^ not supported yet
  147. ***** ^ not supported yet
  148. 90 (*%E *)
  149. 91 IF Size=0 THEN INC(Size) END ;
  150. ***** ^ undeclared identifier
  151. ***** ^ not supported yet
  152. 92 prev := Source;
  153. ***** ^ not supported yet
  154. ***** ^ not supported yet
  155. 93 WHILE prev^.next^.size < Size DO
  156. ***** ^ not supported yet
  157. ***** ^ not supported yet
  158. ***** ^ not supported yet
  159. 94 prev := prev^.next;
  160. ***** ^ not supported yet
  161. ***** ^ not supported yet
  162. ***** ^ not supported yet
  163. 95 END;
  164. 96 res := prev^.next;
  165. ***** ^ not supported yet
  166. ***** ^ not supported yet
  167. ***** ^ not supported yet
  168. 97 IF res^.size = EndMarker THEN (* heap run out of space *)
  169. ***** ^ not supported yet
  170. ***** ^ not supported yet
  171. 98 SYSTEM.EI ;
  172. ***** ^ not supported yet
  173. ***** ^ not supported yet
  174. 99 IF Check THEN
  175. ***** ^ undeclared identifier
  176. 100 Lib.RunTimeError(CoreSig._FatalErrorPos(), 90H, 'FarHeapAllocate : Out Of Space');
  177. ***** ^ not supported yet
  178. ***** ^ not supported yet
  179. ***** ^ not supported yet
  180. ***** ^ not supported yet
  181. ***** ^ not supported yet
  182. ***** ^ not supported yet
  183. 101 ELSE
  184. 102 A := FarNIL;
  185. ***** ^ not supported yet
  186. ***** ^ undeclared identifier
  187. 103 RETURN;
  188. 104 END;
  189. 105 END;
  190. 106 IF res^.size = Size THEN (* block correct size *)
  191. ***** ^ not supported yet
  192. ***** ^ not supported yet
  193. 107 prev^.next := res^.next;
  194. ***** ^ not supported yet
  195. ***** ^ not supported yet
  196. ***** ^ not supported yet
  197. ***** ^ not supported yet
  198. 108 ELSE (* split block, bottom half returned, top half linked to free chain *)
  199. 109 split := [CARDINAL(Seg(res^))+Size:0];
  200. ***** ^ not supported yet
  201. ***** ^ undeclared identifier
  202. ***** ^ not supported yet
  203. ***** ^ not supported yet
  204. 110 prev^.next := split;
  205. ***** ^ not supported yet
  206. ***** ^ not supported yet
  207. ***** ^ not supported yet
  208. 111 split^.next := res^.next;
  209. ***** ^ not supported yet
  210. ***** ^ not supported yet
  211. ***** ^ not supported yet
  212. ***** ^ not supported yet
  213. 112 split^.size := res^.size - Size;
  214. ***** ^ not supported yet
  215. ***** ^ not supported yet
  216. ***** ^ not supported yet
  217. ***** ^ not supported yet
  218. 113 END;
  219. 114 (*%T _mthread *)
  220. 115 Process.Unlock;
  221. ***** ^ not supported yet
  222. ***** ^ not supported yet
  223. 116 (*%E *)
  224. 117 A := FarADR(res^);
  225. ***** ^ not supported yet
  226. ***** ^ undeclared identifier
  227. ***** ^ not supported yet
  228. 118 END FarHeapAllocate;
  229. ***** ^ not supported yet
  230. 119
  231. 120
  232. 121 PROCEDURE FarHeapAvail(Source: FarHeapRecPtr) : CARDINAL;
  233. ***** ^ undeclared identifier
  234. 122 (* returns the largest block size available for allocation in paragraphs *)
  235. 123 VAR
  236. 124 size : CARDINAL;
  237. 125 p : FarHeapRecPtr;
  238. ***** ^ undeclared identifier
  239. 126 BEGIN
  240. 127 IF Source = MainHeap THEN
  241. ***** ^ not supported yet
  242. ***** ^ undeclared identifier
  243. 128 size := CARDINAL(CoreMem._fblockavail() DIV 16);
  244. ***** ^ not supported yet
  245. ***** ^ not supported yet
  246. ***** ^ not supported yet
  247. ***** ^ not supported yet
  248. 129 IF size # 0 THEN
  249. 130 DEC(size);
  250. ***** ^ undeclared identifier
  251. ***** ^ not supported yet
  252. 131 END;
  253. 132 RETURN size;
  254. 133 END;
  255. 134 (*%T _mthread *)
  256. 135 Process.Lock;
  257. ***** ^ not supported yet
  258. ***** ^ not supported yet
  259. 136 (*%E *)
  260. 137 p := Source^.next;
  261. ***** ^ not supported yet
  262. ***** ^ not supported yet
  263. ***** ^ not supported yet
  264. 138 size := 0;
  265. 139 WHILE p^.size <> EndMarker DO
  266. ***** ^ not supported yet
  267. ***** ^ not supported yet
  268. 140 IF p^.size>size THEN size := p^.size END;
  269. ***** ^ not supported yet
  270. ***** ^ not supported yet
  271. ***** ^ not supported yet
  272. ***** ^ not supported yet
  273. 141 p := p^.next;
  274. ***** ^ not supported yet
  275. ***** ^ not supported yet
  276. ***** ^ not supported yet
  277. 142 END;
  278. 143 (*%T _mthread *)
  279. 144 Process.Unlock;
  280. ***** ^ not supported yet
  281. ***** ^ not supported yet
  282. 145 (*%E *)
  283. 146 RETURN size;
  284. 147 END FarHeapAvail;
  285. ***** ^ not supported yet
  286. 148
  287. 149
  288. 150 PROCEDURE FarHeapTotalAvail(Source: FarHeapRecPtr) : CARDINAL;
  289. ***** ^ undeclared identifier
  290. 151 (* returns the total block size available for allocation in paragraphs *)
  291. 152 VAR
  292. 153 size : CARDINAL;
  293. 154 p : FarHeapRecPtr;
  294. ***** ^ undeclared identifier
  295. 155 BEGIN
  296. 156 IF Source = MainHeap THEN
  297. ***** ^ not supported yet
  298. ***** ^ undeclared identifier
  299. 157 RETURN CARDINAL(CoreMem.farcoreleft()>>4);
  300. ***** ^ not supported yet
  301. ***** ^ not supported yet
  302. ***** ^ not supported yet
  303. ***** ^ arithmetic operand must be numeric
  304. 158 END;
  305. 159 (*%T _mthread *)
  306. 160 Process.Lock;
  307. ***** ^ not supported yet
  308. ***** ^ not supported yet
  309. 161 (*%E *)
  310. 162 p := Source^.next;
  311. ***** ^ not supported yet
  312. ***** ^ not supported yet
  313. ***** ^ not supported yet
  314. 163 size := 0;
  315. 164 WHILE p^.size <> EndMarker DO
  316. ***** ^ not supported yet
  317. ***** ^ not supported yet
  318. 165 INC(size,p^.size);
  319. ***** ^ undeclared identifier
  320. ***** ^ not supported yet
  321. ***** ^ not supported yet
  322. 166 p := p^.next;
  323. ***** ^ not supported yet
  324. ***** ^ not supported yet
  325. ***** ^ not supported yet
  326. 167 END;
  327. 168 (*%T _mthread *)
  328. 169 Process.Unlock;
  329. ***** ^ not supported yet
  330. ***** ^ not supported yet
  331. 170 (*%E *)
  332. 171 RETURN size;
  333. 172 END FarHeapTotalAvail;
  334. ***** ^ not supported yet
  335. 173
  336. 174
  337. 175
  338. 176 PROCEDURE FarHeapDeallocate(Source : FarHeapRecPtr; (* source heap *)
  339. ***** ^ undeclared identifier
  340. 177 VAR A: FarADDRESS;
  341. ***** ^ undeclared identifier
  342. 178 Size : CARDINAL ); (* size of block
  343. 179 in paragraphs *)
  344. 180 VAR
  345. 181 target,prev,split : FarHeapRecPtr;
  346. ***** ^ undeclared identifier
  347. 182 tseg : CARDINAL;
  348. 183 BEGIN
  349. 184 IF Source = MainHeap THEN
  350. ***** ^ not supported yet
  351. ***** ^ undeclared identifier
  352. 185 CoreMem._ffree(A);
  353. ***** ^ not supported yet
  354. ***** ^ not supported yet
  355. ***** ^ not supported yet
  356. 186 RETURN;
  357. 187 END;
  358. 188 IF (CARDINAL(Seg(A^))=0)OR(CARDINAL(Ofs(A^))<>0) THEN
  359. ***** ^ undeclared identifier
  360. ***** ^ not supported yet
  361. ***** ^ undeclared identifier
  362. ***** ^ not supported yet
  363. 189 Lib.RunTimeError(CoreSig._FatalErrorPos(), 91H, 'FarHeapDeallocate : Invalid Argument');
  364. ***** ^ not supported yet
  365. ***** ^ not supported yet
  366. ***** ^ not supported yet
  367. ***** ^ not supported yet
  368. ***** ^ not supported yet
  369. ***** ^ not supported yet
  370. 190 END;
  371. 191 (*%T _mthread *)
  372. 192 Process.Lock;
  373. ***** ^ not supported yet
  374. ***** ^ not supported yet
  375. 193 (*%E *)
  376. 194 IF Size=0 THEN INC(Size) END ;
  377. ***** ^ undeclared identifier
  378. ***** ^ not supported yet
  379. 195 target := A;
  380. ***** ^ not supported yet
  381. ***** ^ not supported yet
  382. 196 prev := Source;
  383. ***** ^ not supported yet
  384. ***** ^ not supported yet
  385. 197 tseg := Seg(target^);
  386. ***** ^ undeclared identifier
  387. ***** ^ not supported yet
  388. 198 WHILE CARDINAL(Seg(prev^.next^)) < tseg DO
  389. ***** ^ undeclared identifier
  390. ***** ^ not supported yet
  391. ***** ^ not supported yet
  392. 199 prev := prev^.next;
  393. ***** ^ not supported yet
  394. ***** ^ not supported yet
  395. ***** ^ not supported yet
  396. 200 END;
  397. 201 IF CARDINAL(Seg(prev^))+prev^.size = tseg THEN (* amalgamate with prev *)
  398. ***** ^ undeclared identifier
  399. ***** ^ not supported yet
  400. ***** ^ not supported yet
  401. ***** ^ not supported yet
  402. 202 prev^.size := prev^.size + Size;
  403. ***** ^ not supported yet
  404. ***** ^ not supported yet
  405. ***** ^ not supported yet
  406. ***** ^ not supported yet
  407. 203 target := prev;
  408. ***** ^ not supported yet
  409. ***** ^ not supported yet
  410. 204 ELSIF CARDINAL(Seg(prev^))+prev^.size > tseg THEN (* Heap corrupt *)
  411. ***** ^ undeclared identifier
  412. ***** ^ not supported yet
  413. ***** ^ not supported yet
  414. ***** ^ not supported yet
  415. 205 SYSTEM.EI;
  416. ***** ^ not supported yet
  417. ***** ^ not supported yet
  418. 206 Lib.RunTimeError(CoreSig._FatalErrorPos(), 92H, 'FarHeapDeallocate : Heap Corrupt');
  419. ***** ^ not supported yet
  420. ***** ^ not supported yet
  421. ***** ^ not supported yet
  422. ***** ^ not supported yet
  423. ***** ^ not supported yet
  424. ***** ^ not supported yet
  425. 207 ELSE
  426. 208 (* link after prev *)
  427. 209 target^.next := prev^.next;
  428. ***** ^ not supported yet
  429. ***** ^ not supported yet
  430. ***** ^ not supported yet
  431. ***** ^ not supported yet
  432. 210 prev^.next := target;
  433. ***** ^ not supported yet
  434. ***** ^ not supported yet
  435. ***** ^ not supported yet
  436. 211 target^.size := Size;
  437. ***** ^ not supported yet
  438. ***** ^ not supported yet
  439. 212 END;
  440. 213 IF (target^.next^.size <> EndMarker)
  441. ***** ^ not supported yet
  442. ***** ^ not supported yet
  443. ***** ^ not supported yet
  444. 214 AND (CARDINAL(Seg(target^.next^)) = CARDINAL(Seg(target^))+target^.size) THEN
  445. ***** ^ undeclared identifier
  446. ***** ^ not supported yet
  447. ***** ^ not supported yet
  448. ***** ^ undeclared identifier
  449. ***** ^ not supported yet
  450. ***** ^ not supported yet
  451. ***** ^ not supported yet
  452. 215 (* amalgamate with next block *)
  453. 216 target^.size := target^.size+target^.next^.size;
  454. ***** ^ not supported yet
  455. ***** ^ not supported yet
  456. ***** ^ not supported yet
  457. ***** ^ not supported yet
  458. ***** ^ not supported yet
  459. ***** ^ not supported yet
  460. ***** ^ not supported yet
  461. 217 target^.next := target^.next^.next;
  462. ***** ^ not supported yet
  463. ***** ^ not supported yet
  464. ***** ^ not supported yet
  465. ***** ^ not supported yet
  466. ***** ^ not supported yet
  467. 218 END;
  468. 219 A := SYSTEM.FarNIL;
  469. ***** ^ not supported yet
  470. ***** ^ not supported yet
  471. ***** ^ not supported yet
  472. 220 (*%T _mthread *)
  473. 221 Process.Unlock;
  474. ***** ^ not supported yet
  475. ***** ^ not supported yet
  476. 222 (*%E *)
  477. 223 END FarHeapDeallocate;
  478. ***** ^ not supported yet
  479. 224
  480. 225
  481. 226 PROCEDURE FarHeapChangeAlloc(Source : FarHeapRecPtr; (* source heap *)
  482. ***** ^ undeclared identifier
  483. 227 A : FarADDRESS; (* block to change *)
  484. ***** ^ undeclared identifier
  485. 228 OldSize, (* old size of block *)
  486. 229 NewSize : CARDINAL) (* new size of block *)
  487. 230 (* in paragraphs *)
  488. 231 : BOOLEAN; (* if sucessful *)
  489. 232
  490. 233 (* This procedure attempts to change the size of an allocated block
  491. 234 It returns TRUE if succeeded (only expansion can fail)
  492. 235 *)
  493. 236
  494. 237 VAR
  495. 238 target,prev,
  496. 239 split : FarHeapRecPtr;
  497. ***** ^ undeclared identifier
  498. 240 tseg : CARDINAL;
  499. 241 result : BOOLEAN;
  500. 242 extendsize : CARDINAL;
  501. 243 Res : FarADDRESS;
  502. ***** ^ undeclared identifier
  503. 244 BEGIN
  504. 245 IF Source = MainHeap THEN
  505. ***** ^ not supported yet
  506. ***** ^ undeclared identifier
  507. 246 Res := CoreMem.hrealloc(A, LONGCARD(NewSize)<<4);
  508. ***** ^ not supported yet
  509. ***** ^ not supported yet
  510. ***** ^ not supported yet
  511. ***** ^ not supported yet
  512. ***** ^ undeclared identifier
  513. ***** ^ not supported yet
  514. ***** ^ arithmetic operand must be numeric
  515. 247 IF Res = SYSTEM.FarNIL THEN
  516. ***** ^ not supported yet
  517. ***** ^ not supported yet
  518. ***** ^ not supported yet
  519. 248 RETURN FALSE;
  520. 249 ELSE
  521. 250 A := Res;
  522. ***** ^ not supported yet
  523. ***** ^ not supported yet
  524. 251 RETURN TRUE;
  525. 252 END;
  526. 253 END;
  527. 254 IF (CARDINAL(Seg(A^))=0)OR(CARDINAL(Ofs(A^))<>0) THEN
  528. ***** ^ undeclared identifier
  529. ***** ^ not supported yet
  530. ***** ^ undeclared identifier
  531. ***** ^ not supported yet
  532. 255 Lib.RunTimeError(CoreSig._FatalErrorPos(), 93H, 'FarHeapChangeAlloc : Invalid Argument');
  533. ***** ^ not supported yet
  534. ***** ^ not supported yet
  535. ***** ^ not supported yet
  536. ***** ^ not supported yet
  537. ***** ^ not supported yet
  538. ***** ^ not supported yet
  539. 256 END;
  540. 257 IF OldSize = NewSize THEN RETURN TRUE END;
  541. 258 IF OldSize > NewSize THEN
  542. 259 target := [CARDINAL(Seg(A^))+NewSize:0];
  543. ***** ^ not supported yet
  544. ***** ^ undeclared identifier
  545. ***** ^ not supported yet
  546. ***** ^ not supported yet
  547. 260 FarHeapDeallocate(Source,target,OldSize-NewSize);
  548. ***** ^ not supported yet
  549. ***** ^ not supported yet
  550. ***** ^ not supported yet
  551. ***** ^ not supported yet
  552. 261 RETURN TRUE;
  553. 262 END;
  554. 263 extendsize := NewSize-OldSize;
  555. 264 (*%T _mthread *)
  556. 265 Process.Lock;
  557. ***** ^ not supported yet
  558. ***** ^ not supported yet
  559. 266 (*%E *)
  560. 267 target := A;
  561. ***** ^ not supported yet
  562. ***** ^ not supported yet
  563. 268 prev := Source;
  564. ***** ^ not supported yet
  565. ***** ^ not supported yet
  566. 269 tseg := Seg(target^);
  567. ***** ^ undeclared identifier
  568. ***** ^ not supported yet
  569. 270 WHILE CARDINAL(Seg(prev^.next^)) < tseg DO
  570. ***** ^ undeclared identifier
  571. ***** ^ not supported yet
  572. ***** ^ not supported yet
  573. 271 prev := prev^.next;
  574. ***** ^ not supported yet
  575. ***** ^ not supported yet
  576. ***** ^ not supported yet
  577. 272 END;
  578. 273 IF (prev^.next^.size <> EndMarker) AND
  579. ***** ^ not supported yet
  580. ***** ^ not supported yet
  581. ***** ^ not supported yet
  582. 274 (CARDINAL(Seg(prev^.next^)) = CARDINAL(Seg(target^))+OldSize) AND
  583. ***** ^ undeclared identifier
  584. ***** ^ not supported yet
  585. ***** ^ not supported yet
  586. ***** ^ undeclared identifier
  587. ***** ^ not supported yet
  588. 275 (extendsize <= prev^.next^.size) THEN
  589. ***** ^ not supported yet
  590. ***** ^ not supported yet
  591. ***** ^ not supported yet
  592. 276 IF (extendsize = prev^.next^.size) THEN
  593. ***** ^ not supported yet
  594. ***** ^ not supported yet
  595. ***** ^ not supported yet
  596. 277 prev^.next := prev^.next^.next
  597. ***** ^ not supported yet
  598. ***** ^ not supported yet
  599. ***** ^ not supported yet
  600. ***** ^ not supported yet
  601. ***** ^ not supported yet
  602. 278 ELSE
  603. 279 split := [CARDINAL(Seg(target^))+NewSize:0];
  604. ***** ^ not supported yet
  605. ***** ^ undeclared identifier
  606. ***** ^ not supported yet
  607. ***** ^ not supported yet
  608. 280 split^.next := prev^.next^.next;
  609. ***** ^ not supported yet
  610. ***** ^ not supported yet
  611. ***** ^ not supported yet
  612. ***** ^ not supported yet
  613. ***** ^ not supported yet
  614. 281 split^.size := prev^.next^.size - extendsize;
  615. ***** ^ not supported yet
  616. ***** ^ not supported yet
  617. ***** ^ not supported yet
  618. ***** ^ not supported yet
  619. ***** ^ not supported yet
  620. 282 prev^.next := split;
  621. ***** ^ not supported yet
  622. ***** ^ not supported yet
  623. ***** ^ not supported yet
  624. 283 END;
  625. 284 result := TRUE;
  626. 285 ELSE
  627. 286 result := FALSE;
  628. 287 END;
  629. 288 (*%T _mthread *)
  630. 289 Process.Unlock;
  631. ***** ^ not supported yet
  632. ***** ^ not supported yet
  633. 290 (*%E *)
  634. 291 RETURN result;
  635. 292 END FarHeapChangeAlloc;
  636. ***** ^ not supported yet
  637. 293
  638. 294
  639. 295
  640. 296 PROCEDURE FarHeapChangeSize(Source : FarHeapRecPtr; (* source heap *)
  641. ***** ^ undeclared identifier
  642. 297 VAR A : FarADDRESS; (* block to change *)
  643. ***** ^ undeclared identifier
  644. 298 OldSize, (* old size of block *)
  645. 299 NewSize : CARDINAL ); (* new size of block
  646. 300 in paragraphs *)
  647. 301
  648. 302 (*
  649. 303 This procedure will change the size of an allocated block
  650. 304 avoiding any copy of data if possible
  651. 305 calls HeapChangeAlloc
  652. 306 *)
  653. 307
  654. 308 VAR
  655. 309 na : FarADDRESS;
  656. ***** ^ undeclared identifier
  657. 310 BEGIN
  658. 311 IF NOT FarHeapChangeAlloc ( Source, A, OldSize, NewSize ) THEN
  659. ***** ^ not supported yet
  660. ***** ^ not supported yet
  661. ***** ^ not supported yet
  662. ***** ^ not supported yet
  663. 312 FarHeapAllocate(Source,na,NewSize);
  664. ***** ^ not supported yet
  665. ***** ^ not supported yet
  666. ***** ^ not supported yet
  667. ***** ^ not supported yet
  668. 313 IF na # FarNIL THEN
  669. ***** ^ not supported yet
  670. ***** ^ undeclared identifier
  671. 314 Lib.FarWordMove(A, na, OldSize*8);
  672. ***** ^ not supported yet
  673. ***** ^ not supported yet
  674. ***** ^ not supported yet
  675. ***** ^ not supported yet
  676. ***** ^ not supported yet
  677. 315 FarHeapDeallocate(Source,A,OldSize);
  678. ***** ^ not supported yet
  679. ***** ^ not supported yet
  680. ***** ^ not supported yet
  681. ***** ^ not supported yet
  682. 316 END;
  683. 317 A := na;
  684. ***** ^ not supported yet
  685. ***** ^ not supported yet
  686. 318 END;
  687. 319 END FarHeapChangeSize;
  688. ***** ^ not supported yet
  689. 320
  690. 321
  691. 322 PROCEDURE FarAllocate(VAR a: FarADDRESS; size: CARDINAL);
  692. ***** ^ undeclared identifier
  693. 323
  694. 324 VAR
  695. 325 Res: FarADDRESS;
  696. ***** ^ undeclared identifier
  697. 326 BEGIN
  698. 327 IF size = 0 THEN size := 2 END;
  699. 328 IF ClearOnAllocate THEN
  700. ***** ^ undeclared identifier
  701. 329 Res := CoreMem._fcalloc(1, size);
  702. ***** ^ not supported yet
  703. ***** ^ not supported yet
  704. ***** ^ not supported yet
  705. ***** ^ not supported yet
  706. 330 ELSE
  707. 331 Res := CoreMem._fmalloc(size);
  708. ***** ^ not supported yet
  709. ***** ^ not supported yet
  710. ***** ^ not supported yet
  711. ***** ^ not supported yet
  712. 332 END;
  713. 333 IF Res = FarNIL THEN
  714. ***** ^ not supported yet
  715. ***** ^ undeclared identifier
  716. 334 IF Check THEN
  717. ***** ^ undeclared identifier
  718. 335 Lib.RunTimeError(CoreSig._FatalErrorPos(), 94H, 'FarAllocate : Out Of Memory');
  719. ***** ^ not supported yet
  720. ***** ^ not supported yet
  721. ***** ^ not supported yet
  722. ***** ^ not supported yet
  723. ***** ^ not supported yet
  724. ***** ^ not supported yet
  725. 336 END;
  726. 337 END;
  727. 338 a := Res;
  728. ***** ^ not supported yet
  729. ***** ^ not supported yet
  730. 339 END FarAllocate;
  731. ***** ^ not supported yet
  732. 340
  733. 341
  734. 342 PROCEDURE FarDeallocate(VAR a: FarADDRESS; size: CARDINAL);
  735. ***** ^ undeclared identifier
  736. 343
  737. 344 BEGIN
  738. 345 CoreMem._ffree(a);
  739. ***** ^ not supported yet
  740. ***** ^ not supported yet
  741. ***** ^ not supported yet
  742. 346 a:= SYSTEM.FarNIL;
  743. ***** ^ not supported yet
  744. ***** ^ not supported yet
  745. ***** ^ not supported yet
  746. 347 END FarDeallocate;
  747. ***** ^ not supported yet
  748. 348
  749. 349
  750. 350 PROCEDURE FarAvailable(size: CARDINAL) : BOOLEAN;
  751. 351 VAR
  752. 352 ps, rs: LONGCARD;
  753. ***** ^ undeclared identifier
  754. 353
  755. 354 BEGIN
  756. 355 (*%T _DLLOVL*)
  757. 356 RETURN TRUE; (* Overlay loader takes resposibility *)
  758. 357 (*%E*)
  759. 358 (*%F _DLLOVL*)
  760. 359 ps := CoreMem._fblockavail();
  761. 360 rs := LONGCARD(size+2);
  762. 361 RETURN ps >= rs;
  763. 362 (*%E*)
  764. 363 END FarAvailable;
  765. ***** ^ not supported yet
  766. 364
  767. 365 PROCEDURE NearMakeHeap(Source: NearADDRESS; Size: CARDINAL): NearHeapRecPtr;
  768. ***** ^ undeclared identifier
  769. ***** ^ undeclared identifier
  770. 366 (* ========== *)
  771. 367 VAR Storage, FirstFree: NearHeapRecPtr;
  772. ***** ^ undeclared identifier
  773. 368 BEGIN
  774. 369 Size := (Size DIV Align) * Align;
  775. 370 IF Size < Align*3 THEN
  776. 371 Lib.RunTimeError(CoreSig._FatalErrorPos(), 95H, 'NearMakeHeap: Size Too Small');
  777. ***** ^ not supported yet
  778. ***** ^ not supported yet
  779. ***** ^ not supported yet
  780. ***** ^ not supported yet
  781. ***** ^ not supported yet
  782. ***** ^ not supported yet
  783. 372 END;
  784. 373 IF Source = SYSTEM.NearNIL THEN
  785. ***** ^ not supported yet
  786. ***** ^ not supported yet
  787. ***** ^ not supported yet
  788. 374 Lib.RunTimeError(CoreSig._FatalErrorPos(), 89H, 'NearMakeHeap: Invalid Argument');
  789. ***** ^ not supported yet
  790. ***** ^ not supported yet
  791. ***** ^ not supported yet
  792. ***** ^ not supported yet
  793. ***** ^ not supported yet
  794. ***** ^ not supported yet
  795. 375 END;
  796. 376 Storage := NearHeapRecPtr(Source);
  797. ***** ^ not supported yet
  798. ***** ^ undeclared identifier
  799. ***** ^ not supported yet
  800. 377 FirstFree := NearHeapRecPtr(CARDINAL(Source)+CARDINAL(Align));
  801. ***** ^ not supported yet
  802. ***** ^ undeclared identifier
  803. ***** ^ not supported yet
  804. ***** ^ not supported yet
  805. 378 Storage^.size := Size;
  806. ***** ^ not supported yet
  807. ***** ^ not supported yet
  808. 379 Storage^.next := FirstFree;
  809. ***** ^ not supported yet
  810. ***** ^ not supported yet
  811. ***** ^ not supported yet
  812. 380 FirstFree^.size := Size - Align;
  813. ***** ^ not supported yet
  814. ***** ^ not supported yet
  815. 381 FirstFree^.next := SYSTEM.NearNIL;
  816. ***** ^ not supported yet
  817. ***** ^ not supported yet
  818. ***** ^ not supported yet
  819. ***** ^ not supported yet
  820. 382 RETURN Storage;
  821. ***** ^ not supported yet
  822. 383 END NearMakeHeap;
  823. ***** ^ not supported yet
  824. 384
  825. 385 PROCEDURE NearHeapAllocate(Source: NearHeapRecPtr; VAR A: NearADDRESS; Size: CARDINAL);
  826. ***** ^ undeclared identifier
  827. ***** ^ undeclared identifier
  828. 386 (* ======== *)
  829. 387 VAR Base, Free, New: NearHeapRecPtr;
  830. ***** ^ undeclared identifier
  831. 388 BEGIN
  832. 389 IF Source = SYSTEM.NearNIL THEN
  833. ***** ^ not supported yet
  834. ***** ^ not supported yet
  835. ***** ^ not supported yet
  836. 390 Lib.RunTimeError(CoreSig._FatalErrorPos(), 8AH, 'NearHeapAllocate: Invalid Argument');
  837. ***** ^ not supported yet
  838. ***** ^ not supported yet
  839. ***** ^ not supported yet
  840. ***** ^ not supported yet
  841. ***** ^ not supported yet
  842. ***** ^ not supported yet
  843. 391 END;
  844. 392 IF Source = NearHeap THEN
  845. ***** ^ not supported yet
  846. ***** ^ undeclared identifier
  847. 393 NearAllocate(A, Size);
  848. ***** ^ undeclared identifier
  849. ***** ^ not supported yet
  850. ***** ^ not supported yet
  851. 394 RETURN;
  852. 395 END;
  853. 396 IF Size < Align THEN
  854. 397 Size := Align;
  855. 398 ELSE
  856. 399 Size := ( (Size+Align-1) DIV Align) * Align;
  857. 400 IF Size = 0 THEN
  858. 401 Size:=MAX(CARDINAL);
  859. ***** ^ undeclared identifier
  860. ***** ^ not supported yet
  861. 402 END;
  862. 403 END;
  863. 404 Base := Source;
  864. ***** ^ not supported yet
  865. ***** ^ not supported yet
  866. 405 LOOP
  867. 406 Free := Base^.next;
  868. ***** ^ not supported yet
  869. ***** ^ not supported yet
  870. ***** ^ not supported yet
  871. 407 IF Free = SYSTEM.NearNIL THEN
  872. ***** ^ not supported yet
  873. ***** ^ not supported yet
  874. ***** ^ not supported yet
  875. 408 IF Check THEN
  876. ***** ^ undeclared identifier
  877. 409 Lib.RunTimeError(CoreSig._FatalErrorPos(), 96H, 'NearHeapAllocate: Out Of Memory');
  878. ***** ^ not supported yet
  879. ***** ^ not supported yet
  880. ***** ^ not supported yet
  881. ***** ^ not supported yet
  882. ***** ^ not supported yet
  883. ***** ^ not supported yet
  884. 410 END;
  885. 411 A := SYSTEM.NearNIL;
  886. ***** ^ not supported yet
  887. ***** ^ not supported yet
  888. ***** ^ not supported yet
  889. 412 RETURN;
  890. 413 ELSIF Free^.size >= Size THEN
  891. ***** ^ not supported yet
  892. ***** ^ not supported yet
  893. 414 EXIT;
  894. 415 END;
  895. 416 Base := Free;
  896. ***** ^ not supported yet
  897. ***** ^ not supported yet
  898. 417 END;
  899. 418 IF Free^.size = Size THEN
  900. ***** ^ not supported yet
  901. ***** ^ not supported yet
  902. 419 Base^.next := Free^.next;
  903. ***** ^ not supported yet
  904. ***** ^ not supported yet
  905. ***** ^ not supported yet
  906. ***** ^ not supported yet
  907. 420 ELSE
  908. 421 New := NearHeapRecPtr(CARDINAL(Free)+Size);
  909. ***** ^ not supported yet
  910. ***** ^ undeclared identifier
  911. ***** ^ not supported yet
  912. ***** ^ not supported yet
  913. 422 Base^.next := New;
  914. ***** ^ not supported yet
  915. ***** ^ not supported yet
  916. ***** ^ not supported yet
  917. 423 New^.size := Free^.size - Size;
  918. ***** ^ not supported yet
  919. ***** ^ not supported yet
  920. ***** ^ not supported yet
  921. ***** ^ not supported yet
  922. 424 New^.next := Free^.next;
  923. ***** ^ not supported yet
  924. ***** ^ not supported yet
  925. ***** ^ not supported yet
  926. ***** ^ not supported yet
  927. 425 END;
  928. 426 IF ClearOnAllocate THEN
  929. ***** ^ undeclared identifier
  930. 427 Lib.WordFill ( ADR(Free^) , Size DIV 2 , 0 );
  931. ***** ^ not supported yet
  932. ***** ^ not supported yet
  933. ***** ^ undeclared identifier
  934. ***** ^ not supported yet
  935. ***** ^ not supported yet
  936. 428 END;
  937. 429 A := NearADDRESS(Free);
  938. ***** ^ not supported yet
  939. ***** ^ undeclared identifier
  940. ***** ^ not supported yet
  941. 430 END NearHeapAllocate;
  942. ***** ^ not supported yet
  943. 431
  944. 432 PROCEDURE NearHeapDeallocate(Source: NearHeapRecPtr; VAR A: NearADDRESS; Size: CARDINAL );
  945. ***** ^ undeclared identifier
  946. ***** ^ undeclared identifier
  947. 433
  948. 434 VAR
  949. 435 Curr, Base, Free: NearHeapRecPtr;
  950. ***** ^ undeclared identifier
  951. 436
  952. 437 BEGIN
  953. 438 IF (Source = SYSTEM.NearNIL) OR (A = SYSTEM.NearNIL) THEN
  954. ***** ^ not supported yet
  955. ***** ^ not supported yet
  956. ***** ^ not supported yet
  957. ***** ^ not supported yet
  958. ***** ^ not supported yet
  959. ***** ^ not supported yet
  960. 439 Lib.RunTimeError(CoreSig._FatalErrorPos(), 8BH, 'NearHeapDeallocate: Invalid Argument');
  961. ***** ^ not supported yet
  962. ***** ^ not supported yet
  963. ***** ^ not supported yet
  964. ***** ^ not supported yet
  965. ***** ^ not supported yet
  966. ***** ^ not supported yet
  967. 440 END;
  968. 441 IF Source = NearHeap THEN
  969. ***** ^ not supported yet
  970. ***** ^ undeclared identifier
  971. 442 NearDeallocate(A, Size);
  972. ***** ^ undeclared identifier
  973. ***** ^ not supported yet
  974. ***** ^ not supported yet
  975. 443 RETURN;
  976. 444 END;
  977. 445 IF Size < Align THEN
  978. 446 Size := Align;
  979. 447 ELSE
  980. 448 Size := ( (Size+Align-1) DIV Align) * Align;
  981. 449 IF Size = 0 THEN
  982. 450 Size:=MAX(CARDINAL);
  983. ***** ^ undeclared identifier
  984. ***** ^ not supported yet
  985. 451 END;
  986. 452 END;
  987. 453 Curr := NearHeapRecPtr(A);
  988. ***** ^ not supported yet
  989. ***** ^ undeclared identifier
  990. ***** ^ not supported yet
  991. 454 A := SYSTEM.NearNIL;
  992. ***** ^ not supported yet
  993. ***** ^ not supported yet
  994. ***** ^ not supported yet
  995. 455 Base:=Source;
  996. ***** ^ not supported yet
  997. ***** ^ not supported yet
  998. 456 LOOP
  999. 457 Free := Base^.next;
  1000. ***** ^ not supported yet
  1001. ***** ^ not supported yet
  1002. ***** ^ not supported yet
  1003. 458 IF (Free = SYSTEM.NearNIL) OR (CARDINAL(Curr) < CARDINAL(Free)) THEN EXIT; END;
  1004. ***** ^ not supported yet
  1005. ***** ^ not supported yet
  1006. ***** ^ not supported yet
  1007. ***** ^ not supported yet
  1008. ***** ^ not supported yet
  1009. 459 Base := Free;
  1010. ***** ^ not supported yet
  1011. ***** ^ not supported yet
  1012. 460 END;
  1013. 461 IF CARDINAL(Base) + Base^.size = CARDINAL(Curr) THEN
  1014. ***** ^ not supported yet
  1015. ***** ^ not supported yet
  1016. ***** ^ not supported yet
  1017. ***** ^ not supported yet
  1018. 462 INC ( Base^.size , Size );
  1019. ***** ^ undeclared identifier
  1020. ***** ^ not supported yet
  1021. ***** ^ not supported yet
  1022. ***** ^ not supported yet
  1023. 463 Curr := Base;
  1024. ***** ^ not supported yet
  1025. ***** ^ not supported yet
  1026. 464 ELSE
  1027. 465 Base^.next := Curr;
  1028. ***** ^ not supported yet
  1029. ***** ^ not supported yet
  1030. ***** ^ not supported yet
  1031. 466 Curr^.next := Free;
  1032. ***** ^ not supported yet
  1033. ***** ^ not supported yet
  1034. ***** ^ not supported yet
  1035. 467 Curr^.size := Size;
  1036. ***** ^ not supported yet
  1037. ***** ^ not supported yet
  1038. 468 END;
  1039. 469 IF (Free # SYSTEM.NearNIL) AND (CARDINAL(Curr) + Curr^.size = CARDINAL(Free)) THEN
  1040. ***** ^ not supported yet
  1041. ***** ^ not supported yet
  1042. ***** ^ not supported yet
  1043. ***** ^ not supported yet
  1044. ***** ^ not supported yet
  1045. ***** ^ not supported yet
  1046. ***** ^ not supported yet
  1047. 470 INC ( Curr^.size, Free^.size);
  1048. ***** ^ undeclared identifier
  1049. ***** ^ not supported yet
  1050. ***** ^ not supported yet
  1051. ***** ^ not supported yet
  1052. ***** ^ not supported yet
  1053. 471 Curr^.next := Free^.next;
  1054. ***** ^ not supported yet
  1055. ***** ^ not supported yet
  1056. ***** ^ not supported yet
  1057. ***** ^ not supported yet
  1058. 472 END;
  1059. 473 END NearHeapDeallocate;
  1060. ***** ^ not supported yet
  1061. 474
  1062. 475 PROCEDURE NearHeapAvail(Source: NearHeapRecPtr): CARDINAL;
  1063. ***** ^ undeclared identifier
  1064. 476
  1065. 477 VAR
  1066. 478 Curr: NearHeapRecPtr;
  1067. ***** ^ undeclared identifier
  1068. 479 Size, av: CARDINAL;
  1069. 480 BEGIN
  1070. 481 IF Source = SYSTEM.NearNIL THEN
  1071. ***** ^ not supported yet
  1072. ***** ^ not supported yet
  1073. ***** ^ not supported yet
  1074. 482 Lib.RunTimeError(CoreSig._FatalErrorPos(), 8CH, 'NearHeapAvail: Invalid Argument');
  1075. ***** ^ not supported yet
  1076. ***** ^ not supported yet
  1077. ***** ^ not supported yet
  1078. ***** ^ not supported yet
  1079. ***** ^ not supported yet
  1080. ***** ^ not supported yet
  1081. 483 END;
  1082. 484 IF Source = NearHeap THEN
  1083. ***** ^ not supported yet
  1084. ***** ^ undeclared identifier
  1085. 485 av := CoreMem._memmax();
  1086. ***** ^ not supported yet
  1087. ***** ^ not supported yet
  1088. ***** ^ not supported yet
  1089. 486 IF av <= 4 THEN
  1090. 487 av := 0;
  1091. 488 ELSE
  1092. 489 DEC(av, 4);
  1093. ***** ^ undeclared identifier
  1094. ***** ^ not supported yet
  1095. 490 END;
  1096. 491 RETURN av;
  1097. 492 END;
  1098. 493 Curr := Source^.next;
  1099. ***** ^ not supported yet
  1100. ***** ^ not supported yet
  1101. ***** ^ not supported yet
  1102. 494 Size := 0;
  1103. 495 WHILE Curr # SYSTEM.NearNIL DO
  1104. ***** ^ not supported yet
  1105. ***** ^ not supported yet
  1106. ***** ^ not supported yet
  1107. 496 IF Size < Curr^.size THEN
  1108. ***** ^ not supported yet
  1109. ***** ^ not supported yet
  1110. 497 Size := Curr^.size;
  1111. ***** ^ not supported yet
  1112. ***** ^ not supported yet
  1113. 498 END;
  1114. 499 Curr := Curr^.next;
  1115. ***** ^ not supported yet
  1116. ***** ^ not supported yet
  1117. ***** ^ not supported yet
  1118. 500 END;
  1119. 501 RETURN Size;
  1120. 502 END NearHeapAvail;
  1121. ***** ^ not supported yet
  1122. 503
  1123. 504
  1124. 505 PROCEDURE NearHeapTotalAvail(Source: NearHeapRecPtr): CARDINAL;
  1125. ***** ^ undeclared identifier
  1126. 506
  1127. 507 VAR
  1128. 508 Curr: NearHeapRecPtr;
  1129. ***** ^ undeclared identifier
  1130. 509 Size: CARDINAL;
  1131. 510 BEGIN
  1132. 511 IF Source = SYSTEM.NearNIL THEN
  1133. ***** ^ not supported yet
  1134. ***** ^ not supported yet
  1135. ***** ^ not supported yet
  1136. 512 Lib.RunTimeError(CoreSig._FatalErrorPos(), 8DH, 'NearHeapTotalAvail: Invalid Argument');
  1137. ***** ^ not supported yet
  1138. ***** ^ not supported yet
  1139. ***** ^ not supported yet
  1140. ***** ^ not supported yet
  1141. ***** ^ not supported yet
  1142. ***** ^ not supported yet
  1143. 513 END;
  1144. 514 IF Source = NearHeap THEN
  1145. ***** ^ not supported yet
  1146. ***** ^ undeclared identifier
  1147. 515 RETURN CoreMem.nearcoreleft();
  1148. ***** ^ not supported yet
  1149. ***** ^ not supported yet
  1150. ***** ^ not supported yet
  1151. 516 END;
  1152. 517 Curr := Source^.next;
  1153. ***** ^ not supported yet
  1154. ***** ^ not supported yet
  1155. ***** ^ not supported yet
  1156. 518 Size := 0;
  1157. 519 WHILE Curr # SYSTEM.NearNIL DO
  1158. ***** ^ not supported yet
  1159. ***** ^ not supported yet
  1160. ***** ^ not supported yet
  1161. 520 INC ( Size , Curr^.size );
  1162. ***** ^ undeclared identifier
  1163. ***** ^ not supported yet
  1164. ***** ^ not supported yet
  1165. 521 Curr := Curr^.next;
  1166. ***** ^ not supported yet
  1167. ***** ^ not supported yet
  1168. ***** ^ not supported yet
  1169. 522 END;
  1170. 523 RETURN Size;
  1171. 524 END NearHeapTotalAvail;
  1172. ***** ^ not supported yet
  1173. 525
  1174. 526
  1175. 527 PROCEDURE Merge(LowRec, HighRec: NearHeapRecPtr);
  1176. ***** ^ undeclared identifier
  1177. 528
  1178. 529 BEGIN
  1179. 530 IF (LowRec = SYSTEM.NearNIL) AND (HighRec = SYSTEM.NearNIL) AND
  1180. ***** ^ not supported yet
  1181. ***** ^ not supported yet
  1182. ***** ^ not supported yet
  1183. ***** ^ not supported yet
  1184. ***** ^ not supported yet
  1185. ***** ^ not supported yet
  1186. 531 (NearHeapRecPtr(CARDINAL(LowRec)+LowRec^.size) = HighRec) THEN
  1187. ***** ^ undeclared identifier
  1188. ***** ^ not supported yet
  1189. ***** ^ not supported yet
  1190. ***** ^ not supported yet
  1191. ***** ^ not supported yet
  1192. 532 LowRec^.next:=HighRec^.next;
  1193. ***** ^ not supported yet
  1194. ***** ^ not supported yet
  1195. ***** ^ not supported yet
  1196. ***** ^ not supported yet
  1197. 533 INC(LowRec^.size, HighRec^.size);
  1198. ***** ^ undeclared identifier
  1199. ***** ^ not supported yet
  1200. ***** ^ not supported yet
  1201. ***** ^ not supported yet
  1202. ***** ^ not supported yet
  1203. 534 END;
  1204. 535 END Merge;
  1205. ***** ^ not supported yet
  1206. 536
  1207. 537 PROCEDURE NearHeapChangeSize(Source: NearHeapRecPtr; VAR A: NearADDRESS;
  1208. ***** ^ undeclared identifier
  1209. ***** ^ undeclared identifier
  1210. 538 OldSize, NewSize : CARDINAL);
  1211. 539
  1212. 540 VAR
  1213. 541 OldA: NearADDRESS;
  1214. ***** ^ undeclared identifier
  1215. 542 BEGIN
  1216. 543 IF (Source = SYSTEM.NearNIL) OR (A = SYSTEM.NearNIL) THEN
  1217. ***** ^ not supported yet
  1218. ***** ^ not supported yet
  1219. ***** ^ not supported yet
  1220. ***** ^ not supported yet
  1221. ***** ^ not supported yet
  1222. ***** ^ not supported yet
  1223. 544 Lib.RunTimeError(CoreSig._FatalErrorPos(), 8EH, 'NearHeapChangeSize: Invalid Argument');
  1224. ***** ^ not supported yet
  1225. ***** ^ not supported yet
  1226. ***** ^ not supported yet
  1227. ***** ^ not supported yet
  1228. ***** ^ not supported yet
  1229. ***** ^ not supported yet
  1230. 545 END;
  1231. 546 IF NearHeapChangeAlloc(Source, A, OldSize, NewSize) THEN
  1232. ***** ^ undeclared identifier
  1233. ***** ^ not supported yet
  1234. ***** ^ not supported yet
  1235. ***** ^ not supported yet
  1236. 547 RETURN;
  1237. 548 END;
  1238. 549 OldA := A;
  1239. ***** ^ not supported yet
  1240. ***** ^ not supported yet
  1241. 550 NearHeapAllocate(Source, A, NewSize);
  1242. ***** ^ not supported yet
  1243. ***** ^ not supported yet
  1244. ***** ^ not supported yet
  1245. ***** ^ not supported yet
  1246. 551 IF A # NearNIL THEN
  1247. ***** ^ not supported yet
  1248. ***** ^ undeclared identifier
  1249. 552 Lib.WordMove(ADR(OldA^), ADR(A^), OldSize DIV 2);
  1250. ***** ^ not supported yet
  1251. ***** ^ not supported yet
  1252. ***** ^ undeclared identifier
  1253. ***** ^ not supported yet
  1254. ***** ^ undeclared identifier
  1255. ***** ^ not supported yet
  1256. ***** ^ not supported yet
  1257. 553 NearHeapDeallocate(Source, OldA, OldSize);
  1258. ***** ^ not supported yet
  1259. ***** ^ not supported yet
  1260. ***** ^ not supported yet
  1261. ***** ^ not supported yet
  1262. 554 END;
  1263. 555 END NearHeapChangeSize;
  1264. ***** ^ not supported yet
  1265. 556
  1266. 557 PROCEDURE NearHeapChangeAlloc(Source: NearHeapRecPtr; A: NearADDRESS;
  1267. ***** ^ undeclared identifier
  1268. ***** ^ undeclared identifier
  1269. 558 OldSize, NewSize : CARDINAL): BOOLEAN;
  1270. 559
  1271. 560 VAR
  1272. 561 Curr, SplitRec, NextRec, PrevRec, NewRec: NearHeapRecPtr;
  1273. ***** ^ undeclared identifier
  1274. 562 Temp: NearHeapRec;
  1275. ***** ^ undeclared identifier
  1276. 563 SplitSize: CARDINAL;
  1277. 564 T: NearADDRESS;
  1278. ***** ^ undeclared identifier
  1279. 565 BEGIN
  1280. 566 IF (Source = SYSTEM.NearNIL) OR (A = SYSTEM.NearNIL) THEN
  1281. ***** ^ not supported yet
  1282. ***** ^ not supported yet
  1283. ***** ^ not supported yet
  1284. ***** ^ not supported yet
  1285. ***** ^ not supported yet
  1286. ***** ^ not supported yet
  1287. 567 Lib.RunTimeError(CoreSig._FatalErrorPos(), 8FH, 'NearHeapChangeAlloc: Invalid Argument');
  1288. ***** ^ not supported yet
  1289. ***** ^ not supported yet
  1290. ***** ^ not supported yet
  1291. ***** ^ not supported yet
  1292. ***** ^ not supported yet
  1293. ***** ^ not supported yet
  1294. 568 END;
  1295. 569 IF Source = NearHeap THEN
  1296. ***** ^ not supported yet
  1297. ***** ^ undeclared identifier
  1298. 570 T := CoreMem._nexpand(A, NewSize);
  1299. ***** ^ not supported yet
  1300. ***** ^ not supported yet
  1301. ***** ^ not supported yet
  1302. ***** ^ not supported yet
  1303. ***** ^ not supported yet
  1304. 571 IF T # NearNIL THEN
  1305. ***** ^ not supported yet
  1306. ***** ^ undeclared identifier
  1307. 572 A := T;
  1308. ***** ^ not supported yet
  1309. ***** ^ not supported yet
  1310. 573 RETURN TRUE;
  1311. 574 ELSE
  1312. 575 RETURN FALSE;
  1313. 576 END;
  1314. 577 END;
  1315. 578 IF NewSize < Align THEN
  1316. 579 NewSize := Align;
  1317. 580 ELSE
  1318. 581 NewSize := ( (NewSize+Align-1) DIV Align) * Align;
  1319. 582 IF NewSize = 0 THEN
  1320. 583 NewSize:=MAX(CARDINAL);
  1321. ***** ^ undeclared identifier
  1322. ***** ^ not supported yet
  1323. 584 END;
  1324. 585 END;
  1325. 586 IF OldSize < Align THEN
  1326. 587 OldSize := Align;
  1327. 588 ELSE
  1328. 589 OldSize := ( (OldSize+Align-1) DIV Align) * Align;
  1329. 590 IF OldSize = 0 THEN
  1330. 591 OldSize:=MAX(CARDINAL);
  1331. ***** ^ undeclared identifier
  1332. ***** ^ not supported yet
  1333. 592 END;
  1334. 593 END;
  1335. 594 IF OldSize = NewSize THEN RETURN TRUE END;
  1336. 595 Curr:=NearHeapRecPtr(A);
  1337. ***** ^ not supported yet
  1338. ***** ^ undeclared identifier
  1339. ***** ^ not supported yet
  1340. 596 NextRec:=Source;
  1341. ***** ^ not supported yet
  1342. ***** ^ not supported yet
  1343. 597 LOOP
  1344. 598 PrevRec:=NextRec;
  1345. ***** ^ not supported yet
  1346. ***** ^ not supported yet
  1347. 599 NextRec:=NextRec^.next;
  1348. ***** ^ not supported yet
  1349. ***** ^ not supported yet
  1350. ***** ^ not supported yet
  1351. 600 IF (NextRec = SYSTEM.NearNIL) OR (CARDINAL(NextRec) > CARDINAL(Curr)) THEN EXIT END;
  1352. ***** ^ not supported yet
  1353. ***** ^ not supported yet
  1354. ***** ^ not supported yet
  1355. ***** ^ not supported yet
  1356. ***** ^ not supported yet
  1357. 601 END;
  1358. 602 IF OldSize > NewSize THEN
  1359. 603 SplitSize:=OldSize-NewSize;
  1360. 604 SplitRec:=NearHeapRecPtr(CARDINAL(Curr)+NewSize);
  1361. ***** ^ not supported yet
  1362. ***** ^ undeclared identifier
  1363. ***** ^ not supported yet
  1364. ***** ^ not supported yet
  1365. 605 SplitRec^.size:=SplitSize;
  1366. ***** ^ not supported yet
  1367. ***** ^ not supported yet
  1368. 606 SplitRec^.next:=NextRec;
  1369. ***** ^ not supported yet
  1370. ***** ^ not supported yet
  1371. ***** ^ not supported yet
  1372. 607 PrevRec^.next:=SplitRec;
  1373. ***** ^ not supported yet
  1374. ***** ^ not supported yet
  1375. ***** ^ not supported yet
  1376. 608 Merge(SplitRec, NextRec);
  1377. ***** ^ not supported yet
  1378. ***** ^ not supported yet
  1379. ***** ^ not supported yet
  1380. 609 RETURN TRUE;
  1381. 610 END;
  1382. 611 IF (NextRec # SYSTEM.NearNIL) AND (NearHeapRecPtr(CARDINAL(Curr)+OldSize) = NextRec) THEN (* Next Block is free *)
  1383. ***** ^ not supported yet
  1384. ***** ^ not supported yet
  1385. ***** ^ not supported yet
  1386. ***** ^ undeclared identifier
  1387. ***** ^ not supported yet
  1388. ***** ^ not supported yet
  1389. ***** ^ not supported yet
  1390. 612 Temp.size := OldSize+NextRec^.size;
  1391. ***** ^ not supported yet
  1392. ***** ^ not supported yet
  1393. ***** ^ not supported yet
  1394. ***** ^ not supported yet
  1395. 613 Temp.next := NextRec^.next;
  1396. ***** ^ not supported yet
  1397. ***** ^ not supported yet
  1398. ***** ^ not supported yet
  1399. ***** ^ not supported yet
  1400. 614 IF Temp.size = NewSize THEN
  1401. ***** ^ not supported yet
  1402. ***** ^ not supported yet
  1403. 615 PrevRec^.next := Temp.next;
  1404. ***** ^ not supported yet
  1405. ***** ^ not supported yet
  1406. ***** ^ not supported yet
  1407. ***** ^ not supported yet
  1408. 616 ELSE
  1409. 617 NewRec := NearHeapRecPtr(CARDINAL(Curr)+NewSize);
  1410. ***** ^ not supported yet
  1411. ***** ^ undeclared identifier
  1412. ***** ^ not supported yet
  1413. ***** ^ not supported yet
  1414. 618 PrevRec^.next := NewRec;
  1415. ***** ^ not supported yet
  1416. ***** ^ not supported yet
  1417. ***** ^ not supported yet
  1418. 619 NewRec^.size := Temp.size-NewSize;
  1419. ***** ^ not supported yet
  1420. ***** ^ not supported yet
  1421. ***** ^ not supported yet
  1422. ***** ^ not supported yet
  1423. 620 NewRec^.next := Temp.next;
  1424. ***** ^ not supported yet
  1425. ***** ^ not supported yet
  1426. ***** ^ not supported yet
  1427. ***** ^ not supported yet
  1428. 621 END;
  1429. 622 RETURN TRUE;
  1430. 623 ELSE
  1431. 624 RETURN FALSE;
  1432. 625 END;
  1433. 626 END NearHeapChangeAlloc;
  1434. ***** ^ not supported yet
  1435. 627
  1436. 628 (*%F _DLL *)
  1437. 629 PROCEDURE NearDeallocate(VAR a: NearADDRESS; size: CARDINAL);
  1438. 630
  1439. 631 BEGIN
  1440. 632 CoreMem._nfree(a);
  1441. 633 a:= NearADDRESS(NIL);
  1442. 634 END NearDeallocate;
  1443. 635
  1444. 636 PROCEDURE NearAllocate(VAR a: NearADDRESS; size: CARDINAL);
  1445. 637
  1446. 638 VAR
  1447. 639 Res: NearADDRESS;
  1448. 640 BEGIN
  1449. 641 IF size = 0 THEN size := 2 END;
  1450. 642 IF ClearOnAllocate THEN
  1451. 643 Res := CoreMem._ncalloc(1, size);
  1452. 644 ELSE
  1453. 645 Res := CoreMem._nmalloc(size);
  1454. 646 END;
  1455. 647 IF Res = NearNIL THEN
  1456. 648 IF Check THEN
  1457. 649 Lib.RunTimeError(CoreSig._FatalErrorPos(), 98H, 'NearAllocate: Out Of Memory');
  1458. 650 END;
  1459. 651 END;
  1460. 652 a := Res;
  1461. 653 END NearAllocate;
  1462. 654
  1463. 655 PROCEDURE NearAvailable(size: CARDINAL) : BOOLEAN;
  1464. 656 VAR
  1465. 657 ps : CARDINAL;
  1466. 658 BEGIN
  1467. 659 ps := CoreMem._memmax();
  1468. 660 RETURN ps >= (size+4);
  1469. 661 END NearAvailable;
  1470. 662 (*%E *)
  1471. 663
  1472. 664 (*%T _DLL *)
  1473. 665 PROCEDURE NearAllocate(VAR a: NearADDRESS; size: CARDINAL);
  1474. ***** ^ undeclared identifier
  1475. 666
  1476. 667 BEGIN
  1477. 668 a := NearNIL;
  1478. ***** ^ not supported yet
  1479. ***** ^ undeclared identifier
  1480. 669 END NearAllocate;
  1481. ***** ^ not supported yet
  1482. 670
  1483. 671
  1484. 672 PROCEDURE NearDeallocate(VAR a: NearADDRESS; size: CARDINAL);
  1485. ***** ^ undeclared identifier
  1486. 673
  1487. 674 BEGIN
  1488. 675 END NearDeallocate;
  1489. ***** ^ not supported yet
  1490. 676
  1491. 677
  1492. 678 PROCEDURE NearAvailable(size: CARDINAL) : BOOLEAN;
  1493. 679
  1494. 680 BEGIN
  1495. 681 RETURN FALSE;
  1496. 682 END NearAvailable;
  1497. ***** ^ not supported yet
  1498. 683 (*%E *)
  1499. 684
  1500. 685 PROCEDURE SegAllocate(Size: CARDINAL): CARDINAL;
  1501. 686
  1502. 687 BEGIN
  1503. 688 RETURN Seg(CoreMem.halloc(LONGCARD(Size))^);
  1504. ***** ^ undeclared identifier
  1505. ***** ^ not supported yet
  1506. ***** ^ not supported yet
  1507. ***** ^ undeclared identifier
  1508. ***** ^ not supported yet
  1509. 689 END SegAllocate;
  1510. ***** ^ not supported yet
  1511. 690
  1512. 691 PROCEDURE SegDeallocate(Sel: CARDINAL; Size: CARDINAL);
  1513. 692
  1514. 693 VAR
  1515. 694 S: FarADDRESS;
  1516. ***** ^ undeclared identifier
  1517. 695 BEGIN
  1518. 696 S := [Sel: 0];
  1519. ***** ^ not supported yet
  1520. ***** ^ not supported yet
  1521. 697 CoreMem.hfree(S);
  1522. ***** ^ not supported yet
  1523. ***** ^ not supported yet
  1524. ***** ^ not supported yet
  1525. 698 END SegDeallocate;
  1526. ***** ^ not supported yet
  1527. 699
  1528. 700 BEGIN
  1529. 701 NearHeap := NearHeapRecPtr(0FFFFH);
  1530. ***** ^ undeclared identifier
  1531. ***** ^ undeclared identifier
  1532. ***** ^ not supported yet
  1533. 702 MainHeap := FarHeapRecPtr(CoreMain._getheapbase());
  1534. ***** ^ undeclared identifier
  1535. ***** ^ undeclared identifier
  1536. ***** ^ not supported yet
  1537. ***** ^ not supported yet
  1538. ***** ^ not supported yet
  1539. 703 Check := TRUE;
  1540. ***** ^ undeclared identifier
  1541. 704 ClearOnAllocate := FALSE;
  1542. ***** ^ undeclared identifier
  1543. 705 END Storage.
  1544. ***** ^ not supported yet
  1545. 838 errors