scheme48read-image.c 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4. #include "prescheme.h"
  5. #include "scheme48vm-prelude.h"
  6. #include "scheme48vm.h"
  7. #include "scheme48heap.h"
  8. static void relocate_image(long, char *, char *);
  9. static void relocate_symbol_tableB(long, long);
  10. static void relocate_binding_tableB(long, long);
  11. long s48_startup_procedure(void);
  12. long s48_initial_symbols(void);
  13. long s48_initial_imported_bindings(void);
  14. long s48_initial_exported_bindings(void);
  15. long s48_resumer_records(void);
  16. void s48_set_image_valuesB(long, long, long, long, long);
  17. void s48_initializing_gc_root(void);
  18. void s48_initialization_completeB(void);
  19. void s48_reverse_byte_orderB(char *, char *);
  20. void s48_relocate_all(long, char *, char *, long, long, long);
  21. long s48_read_image(char*, long);
  22. static long SstatusS;
  23. static char SeofPS;
  24. static long Sstartup_procedureS;
  25. static long SsymbolsS;
  26. static long Simported_bindingsS;
  27. static long Sexported_bindingsS;
  28. static long Sresumer_recordsS;
  29. static char SinitializingPS;
  30. static void relocate_image(long delta_0X, char * start_1X, char * end_2X)
  31. {
  32. char * arg1K0;
  33. long arg0K0;
  34. long d_5X;
  35. long descriptor_4X;
  36. char * ptr_3X;
  37. { arg1K0 = start_1X;
  38. goto L1706;}
  39. L1706: {
  40. ptr_3X = arg1K0;
  41. if ((ptr_3X < end_2X)) {
  42. descriptor_4X = *((long *) ptr_3X);
  43. if ((3 == (3 & descriptor_4X))) {
  44. arg0K0 = (3 + (((long) ((((char *) (-3 + descriptor_4X))) + delta_0X))));
  45. goto L1711;}
  46. else {
  47. arg0K0 = descriptor_4X;
  48. goto L1711;}}
  49. else {
  50. return;}}
  51. L1711: {
  52. d_5X = arg0K0;
  53. *((long *) ptr_3X) = (long) (d_5X);
  54. if ((2 == (3 & d_5X))) {
  55. if (((31 & (((d_5X)>>2))) < 16)) {
  56. goto L1725;}
  57. else {
  58. arg1K0 = (ptr_3X + (4 + (-4 & (3 + ((long)(((unsigned long)d_5X)>>8))))));
  59. goto L1706;}}
  60. else {
  61. goto L1725;}}
  62. L1725: {
  63. arg1K0 = (ptr_3X + 4);
  64. goto L1706;}
  65. }
  66. static void relocate_symbol_tableB(long table_6X, long delta_7X)
  67. {
  68. long arg0K0;
  69. char * addr_19X;
  70. long val_18X;
  71. long next_17X;
  72. long next_16X;
  73. long link_15X;
  74. long entry_14X;
  75. char * addr_13X;
  76. long value_12X;
  77. long bucket_11X;
  78. long bucket_10X;
  79. long link_9X;
  80. long i_8X;
  81. { if ((3 == (3 & table_6X))) {
  82. if ((2 == (31 & ((((*((long *) ((((char *) (-3 + table_6X))) + -4))))>>2))))) {
  83. arg0K0 = 0;
  84. goto L1885;}
  85. else {
  86. return;}}
  87. else {
  88. return;}}
  89. L1885: {
  90. i_8X = arg0K0;
  91. if ((1024 == i_8X)) {
  92. return;}
  93. else {
  94. link_9X = *((long *) ((((char *) (-3 + table_6X))) + (((i_8X)<<2))));
  95. if ((0 == (3 & link_9X))) {
  96. arg0K0 = (3 + (-4 & link_9X));
  97. goto L1829;}
  98. else {
  99. arg0K0 = link_9X;
  100. goto L1829;}}}
  101. L1829: {
  102. bucket_10X = arg0K0;
  103. if ((1 == bucket_10X)) {
  104. goto L1890;}
  105. else {
  106. bucket_11X = bucket_10X + delta_7X;
  107. if ((3 == (3 & bucket_11X))) {
  108. arg0K0 = (-4 & bucket_11X);
  109. goto L1840;}
  110. else {
  111. arg0K0 = bucket_11X;
  112. goto L1840;}}}
  113. L1890: {
  114. arg0K0 = (1 + i_8X);
  115. goto L1885;}
  116. L1840: {
  117. value_12X = arg0K0;
  118. addr_13X = (((char *) (-3 + table_6X))) + (((i_8X)<<2));S48_WRITE_BARRIER(table_6X, addr_13X, value_12X);
  119. *((long *) addr_13X) = (long) (value_12X);
  120. arg0K0 = bucket_11X;
  121. goto L1846;}
  122. L1846: {
  123. entry_14X = arg0K0;
  124. link_15X = *((long *) ((((char *) (-3 + entry_14X))) + 4));
  125. if ((0 == (3 & link_15X))) {
  126. arg0K0 = (3 + (-4 & link_15X));
  127. goto L1850;}
  128. else {
  129. arg0K0 = link_15X;
  130. goto L1850;}}
  131. L1850: {
  132. next_16X = arg0K0;
  133. if ((1 == next_16X)) {
  134. goto L1890;}
  135. else {
  136. next_17X = next_16X + delta_7X;
  137. if ((3 == (3 & next_17X))) {
  138. arg0K0 = (-4 & next_17X);
  139. goto L1861;}
  140. else {
  141. arg0K0 = next_17X;
  142. goto L1861;}}}
  143. L1861: {
  144. val_18X = arg0K0;
  145. addr_19X = (((char *) (-3 + entry_14X))) + 4;S48_WRITE_BARRIER(entry_14X, addr_19X, val_18X);
  146. *((long *) addr_19X) = (long) (val_18X);
  147. arg0K0 = next_17X;
  148. goto L1846;}
  149. }
  150. static void relocate_binding_tableB(long table_20X, long delta_21X)
  151. {
  152. long arg0K0;
  153. char * addr_33X;
  154. long val_32X;
  155. long next_31X;
  156. long next_30X;
  157. long link_29X;
  158. long entry_28X;
  159. char * addr_27X;
  160. long value_26X;
  161. long bucket_25X;
  162. long bucket_24X;
  163. long link_23X;
  164. long i_22X;
  165. { if ((3 == (3 & table_20X))) {
  166. if ((2 == (31 & ((((*((long *) ((((char *) (-3 + table_20X))) + -4))))>>2))))) {
  167. arg0K0 = 0;
  168. goto L2087;}
  169. else {
  170. return;}}
  171. else {
  172. return;}}
  173. L2087: {
  174. i_22X = arg0K0;
  175. if ((1024 == i_22X)) {
  176. return;}
  177. else {
  178. link_23X = *((long *) ((((char *) (-3 + table_20X))) + (((i_22X)<<2))));
  179. if ((0 == (3 & link_23X))) {
  180. arg0K0 = (3 + (-4 & link_23X));
  181. goto L2031;}
  182. else {
  183. arg0K0 = link_23X;
  184. goto L2031;}}}
  185. L2031: {
  186. bucket_24X = arg0K0;
  187. if ((1 == bucket_24X)) {
  188. goto L2092;}
  189. else {
  190. bucket_25X = bucket_24X + delta_21X;
  191. if ((3 == (3 & bucket_25X))) {
  192. arg0K0 = (-4 & bucket_25X);
  193. goto L2042;}
  194. else {
  195. arg0K0 = bucket_25X;
  196. goto L2042;}}}
  197. L2092: {
  198. arg0K0 = (1 + i_22X);
  199. goto L2087;}
  200. L2042: {
  201. value_26X = arg0K0;
  202. addr_27X = (((char *) (-3 + table_20X))) + (((i_22X)<<2));S48_WRITE_BARRIER(table_20X, addr_27X, value_26X);
  203. *((long *) addr_27X) = (long) (value_26X);
  204. arg0K0 = bucket_25X;
  205. goto L2048;}
  206. L2048: {
  207. entry_28X = arg0K0;
  208. link_29X = *((long *) ((((char *) (-3 + entry_28X))) + 12));
  209. if ((0 == (3 & link_29X))) {
  210. arg0K0 = (3 + (-4 & link_29X));
  211. goto L2052;}
  212. else {
  213. arg0K0 = link_29X;
  214. goto L2052;}}
  215. L2052: {
  216. next_30X = arg0K0;
  217. if ((1 == next_30X)) {
  218. goto L2092;}
  219. else {
  220. next_31X = next_30X + delta_21X;
  221. if ((3 == (3 & next_31X))) {
  222. arg0K0 = (-4 & next_31X);
  223. goto L2063;}
  224. else {
  225. arg0K0 = next_31X;
  226. goto L2063;}}}
  227. L2063: {
  228. val_32X = arg0K0;
  229. addr_33X = (((char *) (-3 + entry_28X))) + 12;S48_WRITE_BARRIER(entry_28X, addr_33X, val_32X);
  230. *((long *) addr_33X) = (long) (val_32X);
  231. arg0K0 = next_31X;
  232. goto L2048;}
  233. }
  234. long s48_startup_procedure(void)
  235. {
  236. { return (Sstartup_procedureS);}
  237. }
  238. long s48_initial_symbols(void)
  239. {
  240. { return (SsymbolsS);}
  241. }
  242. long s48_initial_imported_bindings(void)
  243. {
  244. { return (Simported_bindingsS);}
  245. }
  246. long s48_initial_exported_bindings(void)
  247. {
  248. { return (Sexported_bindingsS);}
  249. }
  250. long s48_resumer_records(void)
  251. {
  252. { return (Sresumer_recordsS);}
  253. }
  254. void s48_set_image_valuesB(long startup_proc_34X, long symbols_35X, long imports_36X, long exports_37X, long records_38X)
  255. {
  256. { Sstartup_procedureS = startup_proc_34X;
  257. SsymbolsS = symbols_35X;
  258. Simported_bindingsS = imports_36X;
  259. Sexported_bindingsS = exports_37X;
  260. Sresumer_recordsS = records_38X;
  261. return;}
  262. }
  263. void s48_initializing_gc_root(void)
  264. {
  265. long v_43X;
  266. long v_42X;
  267. long v_41X;
  268. long v_40X;
  269. long v_39X;
  270. { if ((SinitializingPS)) {
  271. v_39X = s48_trace_value((Sstartup_procedureS));
  272. Sstartup_procedureS = v_39X;
  273. v_40X = s48_trace_value((SsymbolsS));
  274. SsymbolsS = v_40X;
  275. v_41X = s48_trace_value((Simported_bindingsS));
  276. Simported_bindingsS = v_41X;
  277. v_42X = s48_trace_value((Sexported_bindingsS));
  278. Sexported_bindingsS = v_42X;
  279. v_43X = s48_trace_value((Sresumer_recordsS));
  280. Sresumer_recordsS = v_43X;
  281. return;}
  282. else {
  283. return;}}
  284. }
  285. void s48_initialization_completeB(void)
  286. {
  287. { SinitializingPS = 0;
  288. return;}
  289. }
  290. void s48_reverse_byte_orderB(char * start_44X, char * end_45X)
  291. {
  292. char * arg1K0;
  293. char * next_50X;
  294. long value_49X;
  295. long x_48X;
  296. long x_47X;
  297. char * ptr_46X;
  298. { ps_write_string("Correcting byte order of resumed image.", (stderr));
  299. { long ignoreXX;
  300. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  301. arg1K0 = start_44X;
  302. goto L1607;}
  303. L1607: {
  304. ptr_46X = arg1K0;
  305. if ((ptr_46X < end_45X)) {
  306. x_47X = *((unsigned char *) ptr_46X);
  307. *((unsigned char *) ptr_46X) = (unsigned char) ((*((unsigned char *) (ptr_46X + 3))));
  308. *((unsigned char *) (ptr_46X + 3)) = (unsigned char) (x_47X);
  309. x_48X = *((unsigned char *) (ptr_46X + 1));
  310. *((unsigned char *) (ptr_46X + 1)) = (unsigned char) ((*((unsigned char *) (ptr_46X + 2))));
  311. *((unsigned char *) (ptr_46X + 2)) = (unsigned char) (x_48X);
  312. value_49X = *((long *) ptr_46X);
  313. next_50X = ptr_46X + 4;
  314. if ((2 == (3 & value_49X))) {
  315. if (((31 & (((value_49X)>>2))) < 16)) {
  316. arg1K0 = next_50X;
  317. goto L1607;}
  318. else {
  319. arg1K0 = (next_50X + (-4 & (3 + ((long)(((unsigned long)value_49X)>>8)))));
  320. goto L1607;}}
  321. else {
  322. arg1K0 = next_50X;
  323. goto L1607;}}
  324. else {
  325. return;}}
  326. }
  327. void s48_relocate_all(long delta_51X, char * new_begin_52X, char * new_hp_53X, long symbols_54X, long imported_55X, long exported_56X)
  328. {
  329. {relocate_symbol_tableB(symbols_54X, delta_51X);relocate_binding_tableB(imported_55X, delta_51X);relocate_binding_tableB(exported_56X, delta_51X);
  330. relocate_image(delta_51X, new_begin_52X, new_hp_53X);
  331. return;}
  332. }
  333. long s48_read_image(char *filename_57X, long heap_size_58X)
  334. {
  335. char * arg1K3;
  336. char * arg1K2;
  337. char * arg1K1;
  338. FILE * arg4K0;
  339. char *arg3K1;
  340. char arg2K1;
  341. char arg2K4;
  342. char arg2K0;
  343. long arg0K2;
  344. long arg0K1;
  345. long arg0K0;
  346. long v_162X;
  347. long descriptor_161X;
  348. long v_160X;
  349. long descriptor_159X;
  350. long v_158X;
  351. long descriptor_157X;
  352. long v_156X;
  353. long status_155X;
  354. long status_154X;
  355. long status_153X;
  356. long status_152X;
  357. long descriptor_151X;
  358. long v_150X;
  359. long descriptor_149X;
  360. long status_148X;
  361. long status_147X;
  362. char eofP_146X;
  363. char v_145X;
  364. char *string_144X;
  365. char okayP_143X;
  366. long status_142X;
  367. long status_141X;
  368. long status_140X;
  369. char eofP_139X;
  370. long got_138X;
  371. long need_137X;
  372. char * new_hp_136X;
  373. long delta_135X;
  374. char reverseP_134X;
  375. char * old_hp_133X;
  376. char * old_begin_132X;
  377. char * new_begin_131X;
  378. FILE * port_130X;
  379. long status_129X;
  380. char eofP_128X;
  381. long status_127X;
  382. long status_126X;
  383. long status_125X;
  384. long x_124X;
  385. long x_123X;
  386. char *string_122X;
  387. char okayP_121X;
  388. long status_120X;
  389. long status_119X;
  390. char eofP_118X;
  391. char ch_117X;
  392. long status_116X;
  393. char eofP_115X;
  394. long got_114X;
  395. char * new_begin_113X;
  396. long v_112X;
  397. long status_111X;
  398. char eofP_110X;
  399. long thing_109X;
  400. long v_108X;
  401. long status_107X;
  402. char eofP_106X;
  403. long thing_105X;
  404. long v_104X;
  405. long status_103X;
  406. char eofP_102X;
  407. long thing_101X;
  408. long v_100X;
  409. long status_99X;
  410. char eofP_98X;
  411. long thing_97X;
  412. long v_96X;
  413. long status_95X;
  414. char eofP_94X;
  415. long thing_93X;
  416. char * old_hp_92X;
  417. long cells_91X;
  418. long status_90X;
  419. char eofP_89X;
  420. long thing_88X;
  421. char * old_begin_87X;
  422. long cells_86X;
  423. long status_85X;
  424. char eofP_84X;
  425. char thing_83X;
  426. long status_82X;
  427. char eofP_81X;
  428. long thing_80X;
  429. long old_bytes_per_cell_79X;
  430. long status_78X;
  431. char eofP_77X;
  432. long status_76X;
  433. char eofP_75X;
  434. char ch_74X;
  435. long i_73X;
  436. long status_72X;
  437. char eofP_71X;
  438. long thing_70X;
  439. char same_versionP_69X;
  440. long status_68X;
  441. char eofP_67X;
  442. long status_66X;
  443. char eofP_65X;
  444. char ch_64X;
  445. long status_63X;
  446. char eofP_62X;
  447. char ch_61X;
  448. long status_60X;
  449. FILE * port_59X;
  450. { port_59X = ps_open_input_file(filename_57X, &status_60X);
  451. if ((status_60X == NO_ERRORS)) {
  452. SstatusS = NO_ERRORS;
  453. SeofPS = 0;
  454. if ((SeofPS)) {
  455. goto L2786;}
  456. else {
  457. goto L3525;}}
  458. else {
  459. ps_write_string("Can't open heap image file", (stderr));
  460. { long ignoreXX;
  461. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  462. ps_write_string((ps_error_string(status_60X)), (stderr));
  463. { long ignoreXX;
  464. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  465. return -1;}}
  466. L2786: {
  467. if ((SeofPS)) {
  468. goto L2819;}
  469. else {
  470. goto L3489;}}
  471. L3525: {
  472. PS_READ_CHAR(port_59X, ch_61X, eofP_62X, status_63X)
  473. if (eofP_62X) {
  474. arg2K0 = eofP_62X;
  475. arg0K1 = status_63X;
  476. goto L2764;}
  477. else {
  478. if ((status_63X == NO_ERRORS)) {
  479. if ((12 == ch_61X)) {
  480. arg2K0 = 0;
  481. arg0K1 = status_63X;
  482. goto L2764;}
  483. else {
  484. goto L3525;}}
  485. else {
  486. arg2K0 = eofP_62X;
  487. arg0K1 = status_63X;
  488. goto L2764;}}}
  489. L2819: {
  490. if ((SeofPS)) {
  491. arg2K0 = 0;
  492. goto L2852;}
  493. else {
  494. arg0K0 = 0;
  495. goto L3465;}}
  496. L3489: {
  497. PS_READ_CHAR(port_59X, ch_64X, eofP_65X, status_66X)
  498. if (eofP_65X) {
  499. arg2K0 = eofP_65X;
  500. arg0K1 = status_66X;
  501. goto L2797;}
  502. else {
  503. if ((status_66X == NO_ERRORS)) {
  504. if ((10 == ch_64X)) {
  505. arg2K0 = 0;
  506. arg0K1 = status_66X;
  507. goto L2797;}
  508. else {
  509. goto L3489;}}
  510. else {
  511. arg2K0 = eofP_65X;
  512. arg0K1 = status_66X;
  513. goto L2797;}}}
  514. L2764: {
  515. eofP_67X = arg2K0;
  516. status_68X = arg0K1;
  517. if (eofP_67X) {
  518. SeofPS = 1;
  519. goto L2786;}
  520. else {
  521. if (((SstatusS) == NO_ERRORS)) {
  522. goto L2786;}
  523. else {
  524. SeofPS = 1;
  525. SstatusS = status_68X;
  526. goto L2786;}}}
  527. L2852: {
  528. same_versionP_69X = arg2K0;
  529. if ((SeofPS)) {
  530. arg0K0 = -1;
  531. goto L2887;}
  532. else {
  533. PS_READ_INTEGER(port_59X, thing_70X, eofP_71X, status_72X)
  534. if (eofP_71X) {
  535. SeofPS = 1;
  536. arg0K0 = -1;
  537. goto L2887;}
  538. else {
  539. if (((SstatusS) == NO_ERRORS)) {
  540. arg0K0 = thing_70X;
  541. goto L2887;}
  542. else {
  543. SeofPS = 1;
  544. SstatusS = status_72X;
  545. arg0K0 = -1;
  546. goto L2887;}}}}
  547. L3465: {
  548. i_73X = arg0K0;
  549. PS_READ_CHAR(port_59X, ch_74X, eofP_75X, status_76X)
  550. if (eofP_75X) {
  551. arg2K0 = 0;
  552. arg2K1 = eofP_75X;
  553. arg0K2 = status_76X;
  554. goto L2830;}
  555. else {
  556. if ((status_76X == NO_ERRORS)) {
  557. if ((i_73X == (strlen((char *) "Vanilla 32")))) {
  558. arg2K0 = (10 == ch_74X);
  559. arg2K1 = 0;
  560. arg0K2 = status_76X;
  561. goto L2830;}
  562. else {
  563. if ((ch_74X == (*("Vanilla 32" + i_73X)))) {
  564. arg0K0 = (1 + i_73X);
  565. goto L3465;}
  566. else {
  567. arg2K0 = 0;
  568. arg2K1 = 0;
  569. arg0K2 = status_76X;
  570. goto L2830;}}}
  571. else {
  572. arg2K0 = 0;
  573. arg2K1 = eofP_75X;
  574. arg0K2 = status_76X;
  575. goto L2830;}}}
  576. L2797: {
  577. eofP_77X = arg2K0;
  578. status_78X = arg0K1;
  579. if (eofP_77X) {
  580. SeofPS = 1;
  581. goto L2819;}
  582. else {
  583. if (((SstatusS) == NO_ERRORS)) {
  584. goto L2819;}
  585. else {
  586. SeofPS = 1;
  587. SstatusS = status_78X;
  588. goto L2819;}}}
  589. L2887: {
  590. old_bytes_per_cell_79X = arg0K0;
  591. if ((SeofPS)) {
  592. arg0K0 = -1;
  593. goto L2922;}
  594. else {
  595. PS_READ_INTEGER(port_59X, thing_80X, eofP_81X, status_82X)
  596. if (eofP_81X) {
  597. SeofPS = 1;
  598. arg0K0 = -1;
  599. goto L2922;}
  600. else {
  601. if (((SstatusS) == NO_ERRORS)) {
  602. arg0K0 = thing_80X;
  603. goto L2922;}
  604. else {
  605. SeofPS = 1;
  606. SstatusS = status_82X;
  607. arg0K0 = -1;
  608. goto L2922;}}}}
  609. L2830: {
  610. thing_83X = arg2K0;
  611. eofP_84X = arg2K1;
  612. status_85X = arg0K2;
  613. if (eofP_84X) {
  614. SeofPS = 1;
  615. arg2K0 = 0;
  616. goto L2852;}
  617. else {
  618. if (((SstatusS) == NO_ERRORS)) {
  619. arg2K0 = thing_83X;
  620. goto L2852;}
  621. else {
  622. SeofPS = 1;
  623. SstatusS = status_85X;
  624. arg2K0 = 0;
  625. goto L2852;}}}
  626. L2922: {
  627. cells_86X = arg0K0;
  628. old_begin_87X = ((char *) (((cells_86X)<<2)));
  629. if ((SeofPS)) {
  630. arg0K0 = -1;
  631. goto L2959;}
  632. else {
  633. PS_READ_INTEGER(port_59X, thing_88X, eofP_89X, status_90X)
  634. if (eofP_89X) {
  635. SeofPS = 1;
  636. arg0K0 = -1;
  637. goto L2959;}
  638. else {
  639. if (((SstatusS) == NO_ERRORS)) {
  640. arg0K0 = thing_88X;
  641. goto L2959;}
  642. else {
  643. SeofPS = 1;
  644. SstatusS = status_90X;
  645. arg0K0 = -1;
  646. goto L2959;}}}}
  647. L2959: {
  648. cells_91X = arg0K0;
  649. old_hp_92X = ((char *) (((cells_91X)<<2)));
  650. if ((SeofPS)) {
  651. arg0K0 = -1;
  652. goto L2996;}
  653. else {
  654. PS_READ_INTEGER(port_59X, thing_93X, eofP_94X, status_95X)
  655. if (eofP_94X) {
  656. SeofPS = 1;
  657. arg0K0 = -1;
  658. goto L2996;}
  659. else {
  660. if (((SstatusS) == NO_ERRORS)) {
  661. arg0K0 = thing_93X;
  662. goto L2996;}
  663. else {
  664. SeofPS = 1;
  665. SstatusS = status_95X;
  666. arg0K0 = -1;
  667. goto L2996;}}}}
  668. L2996: {
  669. v_96X = arg0K0;
  670. SsymbolsS = v_96X;
  671. if ((SeofPS)) {
  672. arg0K0 = -1;
  673. goto L3032;}
  674. else {
  675. PS_READ_INTEGER(port_59X, thing_97X, eofP_98X, status_99X)
  676. if (eofP_98X) {
  677. SeofPS = 1;
  678. arg0K0 = -1;
  679. goto L3032;}
  680. else {
  681. if (((SstatusS) == NO_ERRORS)) {
  682. arg0K0 = thing_97X;
  683. goto L3032;}
  684. else {
  685. SeofPS = 1;
  686. SstatusS = status_99X;
  687. arg0K0 = -1;
  688. goto L3032;}}}}
  689. L3032: {
  690. v_100X = arg0K0;
  691. Simported_bindingsS = v_100X;
  692. if ((SeofPS)) {
  693. arg0K0 = -1;
  694. goto L3068;}
  695. else {
  696. PS_READ_INTEGER(port_59X, thing_101X, eofP_102X, status_103X)
  697. if (eofP_102X) {
  698. SeofPS = 1;
  699. arg0K0 = -1;
  700. goto L3068;}
  701. else {
  702. if (((SstatusS) == NO_ERRORS)) {
  703. arg0K0 = thing_101X;
  704. goto L3068;}
  705. else {
  706. SeofPS = 1;
  707. SstatusS = status_103X;
  708. arg0K0 = -1;
  709. goto L3068;}}}}
  710. L3068: {
  711. v_104X = arg0K0;
  712. Sexported_bindingsS = v_104X;
  713. if ((SeofPS)) {
  714. arg0K0 = -1;
  715. goto L3104;}
  716. else {
  717. PS_READ_INTEGER(port_59X, thing_105X, eofP_106X, status_107X)
  718. if (eofP_106X) {
  719. SeofPS = 1;
  720. arg0K0 = -1;
  721. goto L3104;}
  722. else {
  723. if (((SstatusS) == NO_ERRORS)) {
  724. arg0K0 = thing_105X;
  725. goto L3104;}
  726. else {
  727. SeofPS = 1;
  728. SstatusS = status_107X;
  729. arg0K0 = -1;
  730. goto L3104;}}}}
  731. L3104: {
  732. v_108X = arg0K0;
  733. Sresumer_recordsS = v_108X;
  734. if ((SeofPS)) {
  735. arg0K0 = -1;
  736. goto L3140;}
  737. else {
  738. PS_READ_INTEGER(port_59X, thing_109X, eofP_110X, status_111X)
  739. if (eofP_110X) {
  740. SeofPS = 1;
  741. arg0K0 = -1;
  742. goto L3140;}
  743. else {
  744. if (((SstatusS) == NO_ERRORS)) {
  745. arg0K0 = thing_109X;
  746. goto L3140;}
  747. else {
  748. SeofPS = 1;
  749. SstatusS = status_111X;
  750. arg0K0 = -1;
  751. goto L3140;}}}}
  752. L3140: {
  753. v_112X = arg0K0;
  754. Sstartup_procedureS = v_112X;
  755. if ((SeofPS)) {
  756. goto L3176;}
  757. else {
  758. goto L3396;}}
  759. L3176: {
  760. if (((SstatusS) == NO_ERRORS)) {
  761. if ((SeofPS)) {
  762. SstatusS = EDOM;
  763. ps_write_string("Premature EOF when reading image file", (stderr));
  764. { long ignoreXX;
  765. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  766. if (((SstatusS) == NO_ERRORS)) {
  767. goto L3265;}
  768. else {
  769. ps_write_string((ps_error_string((SstatusS))), (stderr));
  770. { long ignoreXX;
  771. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  772. goto L3265;}}
  773. else {
  774. if (same_versionP_69X) {
  775. if ((4 == old_bytes_per_cell_79X)) {
  776. new_begin_113X = s48_initialize_heap(heap_size_58X, ((((3 + (old_hp_92X - old_begin_87X)))>>2)), old_begin_87X);
  777. got_114X = ps_read_block(port_59X, ((char *) new_begin_113X), 4, &eofP_115X, &status_116X);
  778. if ((status_116X == NO_ERRORS)) {
  779. if (eofP_115X) {
  780. arg2K0 = 0;
  781. arg3K1 = "Premature EOF when reading image file";
  782. goto L2598;}
  783. else {
  784. if ((got_114X < 4)) {
  785. arg2K0 = 0;
  786. arg3K1 = "Read returned too few bytes";
  787. goto L2598;}
  788. else {
  789. arg2K0 = 1;
  790. arg3K1 = "";
  791. goto L2598;}}}
  792. else {
  793. SstatusS = status_116X;
  794. arg2K0 = 0;
  795. arg3K1 = "Error reading from image file";
  796. goto L2598;}}
  797. else {
  798. ps_write_string("Incompatible bytes-per-cell in image", (stderr));
  799. { long ignoreXX;
  800. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  801. if (((SstatusS) == NO_ERRORS)) {
  802. goto L3325;}
  803. else {
  804. ps_write_string((ps_error_string((SstatusS))), (stderr));
  805. { long ignoreXX;
  806. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  807. goto L3325;}}}
  808. else {
  809. ps_write_string("Format of image is incompatible with this version of system", (stderr));
  810. { long ignoreXX;
  811. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  812. if (((SstatusS) == NO_ERRORS)) {
  813. goto L3295;}
  814. else {
  815. ps_write_string((ps_error_string((SstatusS))), (stderr));
  816. { long ignoreXX;
  817. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  818. goto L3295;}}}}
  819. else {
  820. ps_write_string("Error reading from image file", (stderr));
  821. { long ignoreXX;
  822. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  823. if (((SstatusS) == NO_ERRORS)) {
  824. goto L3240;}
  825. else {
  826. ps_write_string((ps_error_string((SstatusS))), (stderr));
  827. { long ignoreXX;
  828. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  829. goto L3240;}}}
  830. L3396: {
  831. PS_READ_CHAR(port_59X, ch_117X, eofP_118X, status_119X)
  832. if (eofP_118X) {
  833. arg2K0 = eofP_118X;
  834. arg0K1 = status_119X;
  835. goto L3154;}
  836. else {
  837. if ((status_119X == NO_ERRORS)) {
  838. if ((12 == ch_117X)) {
  839. arg2K0 = 0;
  840. arg0K1 = status_119X;
  841. goto L3154;}
  842. else {
  843. goto L3396;}}
  844. else {
  845. arg2K0 = eofP_118X;
  846. arg0K1 = status_119X;
  847. goto L3154;}}}
  848. L3265: {
  849. status_120X = ps_close(port_59X);
  850. if ((status_120X == NO_ERRORS)) {
  851. return -1;}
  852. else {
  853. ps_write_string("Error closing image file", (stderr));
  854. { long ignoreXX;
  855. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  856. return -1;}}
  857. L2598: {
  858. okayP_121X = arg2K0;
  859. string_122X = arg3K1;
  860. if (okayP_121X) {
  861. if ((1 == (*((long *) new_begin_113X)))) {
  862. arg4K0 = port_59X;
  863. arg1K1 = new_begin_113X;
  864. arg1K2 = old_begin_87X;
  865. arg1K3 = old_hp_92X;
  866. arg2K4 = 0;
  867. goto L2228;}
  868. else {
  869. x_123X = *((unsigned char *) new_begin_113X);
  870. *((unsigned char *) new_begin_113X) = (unsigned char) ((*((unsigned char *) (new_begin_113X + 3))));
  871. *((unsigned char *) (new_begin_113X + 3)) = (unsigned char) (x_123X);
  872. x_124X = *((unsigned char *) (new_begin_113X + 1));
  873. *((unsigned char *) (new_begin_113X + 1)) = (unsigned char) ((*((unsigned char *) (new_begin_113X + 2))));
  874. *((unsigned char *) (new_begin_113X + 2)) = (unsigned char) (x_124X);
  875. if ((1 == (*((long *) new_begin_113X)))) {
  876. arg4K0 = port_59X;
  877. arg1K1 = new_begin_113X;
  878. arg1K2 = old_begin_87X;
  879. arg1K3 = old_hp_92X;
  880. arg2K4 = 1;
  881. goto L2228;}
  882. else {
  883. ps_write_string("Unable to correct byte order", (stderr));
  884. { long ignoreXX;
  885. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  886. if (((SstatusS) == NO_ERRORS)) {
  887. goto L2695;}
  888. else {
  889. ps_write_string((ps_error_string((SstatusS))), (stderr));
  890. { long ignoreXX;
  891. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  892. goto L2695;}}}}
  893. else {
  894. ps_write_string(string_122X, (stderr));
  895. { long ignoreXX;
  896. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  897. if (((SstatusS) == NO_ERRORS)) {
  898. goto L2649;}
  899. else {
  900. ps_write_string((ps_error_string((SstatusS))), (stderr));
  901. { long ignoreXX;
  902. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  903. goto L2649;}}}
  904. L3325: {
  905. status_125X = ps_close(port_59X);
  906. if ((status_125X == NO_ERRORS)) {
  907. return -1;}
  908. else {
  909. ps_write_string("Error closing image file", (stderr));
  910. { long ignoreXX;
  911. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  912. return -1;}}
  913. L3295: {
  914. status_126X = ps_close(port_59X);
  915. if ((status_126X == NO_ERRORS)) {
  916. return -1;}
  917. else {
  918. ps_write_string("Error closing image file", (stderr));
  919. { long ignoreXX;
  920. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  921. return -1;}}
  922. L3240: {
  923. status_127X = ps_close(port_59X);
  924. if ((status_127X == NO_ERRORS)) {
  925. return -1;}
  926. else {
  927. ps_write_string("Error closing image file", (stderr));
  928. { long ignoreXX;
  929. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  930. return -1;}}
  931. L3154: {
  932. eofP_128X = arg2K0;
  933. status_129X = arg0K1;
  934. if (eofP_128X) {
  935. SeofPS = 1;
  936. goto L3176;}
  937. else {
  938. if (((SstatusS) == NO_ERRORS)) {
  939. goto L3176;}
  940. else {
  941. SeofPS = 1;
  942. SstatusS = status_129X;
  943. goto L3176;}}}
  944. L2228: {
  945. port_130X = arg4K0;
  946. new_begin_131X = arg1K1;
  947. old_begin_132X = arg1K2;
  948. old_hp_133X = arg1K3;
  949. reverseP_134X = arg2K4;
  950. delta_135X = new_begin_131X - old_begin_132X;
  951. new_hp_136X = old_hp_133X + delta_135X;
  952. need_137X = old_hp_133X - old_begin_132X;
  953. got_138X = ps_read_block(port_130X, ((char *) new_begin_131X), need_137X, &eofP_139X, &status_140X);
  954. if ((status_140X == NO_ERRORS)) {
  955. if (eofP_139X) {
  956. arg2K0 = 0;
  957. arg3K1 = "Premature EOF when reading image file";
  958. goto L2236;}
  959. else {
  960. if ((got_138X < need_137X)) {
  961. arg2K0 = 0;
  962. arg3K1 = "Read returned too few bytes";
  963. goto L2236;}
  964. else {
  965. arg2K0 = 1;
  966. arg3K1 = "";
  967. goto L2236;}}}
  968. else {
  969. SstatusS = status_140X;
  970. arg2K0 = 0;
  971. arg3K1 = "Error reading from image file";
  972. goto L2236;}}
  973. L2695: {
  974. status_141X = ps_close(port_59X);
  975. if ((status_141X == NO_ERRORS)) {
  976. return -1;}
  977. else {
  978. ps_write_string("Error closing image file", (stderr));
  979. { long ignoreXX;
  980. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  981. return -1;}}
  982. L2649: {
  983. status_142X = ps_close(port_59X);
  984. if ((status_142X == NO_ERRORS)) {
  985. return -1;}
  986. else {
  987. ps_write_string("Error closing image file", (stderr));
  988. { long ignoreXX;
  989. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  990. return -1;}}
  991. L2236: {
  992. okayP_143X = arg2K0;
  993. string_144X = arg3K1;
  994. PS_READ_CHAR(port_130X, v_145X, eofP_146X, status_147X)
  995. if (okayP_143X) {
  996. if ((status_147X == NO_ERRORS)) {
  997. if (eofP_146X) {
  998. status_148X = ps_close(port_130X);
  999. if ((status_148X == NO_ERRORS)) {
  1000. descriptor_149X = Sstartup_procedureS;
  1001. if ((3 == (3 & descriptor_149X))) {
  1002. arg0K0 = (3 + (((long) ((((char *) (-3 + descriptor_149X))) + delta_135X))));
  1003. goto L2268;}
  1004. else {
  1005. arg0K0 = descriptor_149X;
  1006. goto L2268;}}
  1007. else {
  1008. ps_write_string("Error closing image file", (stderr));
  1009. { long ignoreXX;
  1010. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  1011. if (((SstatusS) == NO_ERRORS)) {
  1012. goto L2435;}
  1013. else {
  1014. ps_write_string((ps_error_string((SstatusS))), (stderr));
  1015. { long ignoreXX;
  1016. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  1017. goto L2435;}}}
  1018. else {
  1019. ps_write_string("Image file has extraneous data after image", (stderr));
  1020. { long ignoreXX;
  1021. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  1022. if (((SstatusS) == NO_ERRORS)) {
  1023. goto L2405;}
  1024. else {
  1025. ps_write_string((ps_error_string((SstatusS))), (stderr));
  1026. { long ignoreXX;
  1027. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  1028. goto L2405;}}}
  1029. else {
  1030. ps_write_string("Error reading from image file", (stderr));
  1031. { long ignoreXX;
  1032. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  1033. if (((SstatusS) == NO_ERRORS)) {
  1034. goto L2375;}
  1035. else {
  1036. ps_write_string((ps_error_string((SstatusS))), (stderr));
  1037. { long ignoreXX;
  1038. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  1039. goto L2375;}}}
  1040. else {
  1041. ps_write_string(string_144X, (stderr));
  1042. { long ignoreXX;
  1043. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  1044. if (((SstatusS) == NO_ERRORS)) {
  1045. goto L2345;}
  1046. else {
  1047. ps_write_string((ps_error_string((SstatusS))), (stderr));
  1048. { long ignoreXX;
  1049. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  1050. goto L2345;}}}
  1051. L2268: {
  1052. v_150X = arg0K0;
  1053. Sstartup_procedureS = v_150X;
  1054. descriptor_151X = SsymbolsS;
  1055. if ((3 == (3 & descriptor_151X))) {
  1056. arg0K0 = (3 + (((long) ((((char *) (-3 + descriptor_151X))) + delta_135X))));
  1057. goto L2273;}
  1058. else {
  1059. arg0K0 = descriptor_151X;
  1060. goto L2273;}}
  1061. L2435: {
  1062. status_152X = ps_close(port_130X);
  1063. if ((status_152X == NO_ERRORS)) {
  1064. return -1;}
  1065. else {
  1066. ps_write_string("Error closing image file", (stderr));
  1067. { long ignoreXX;
  1068. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  1069. return -1;}}
  1070. L2405: {
  1071. status_153X = ps_close(port_130X);
  1072. if ((status_153X == NO_ERRORS)) {
  1073. return -1;}
  1074. else {
  1075. ps_write_string("Error closing image file", (stderr));
  1076. { long ignoreXX;
  1077. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  1078. return -1;}}
  1079. L2375: {
  1080. status_154X = ps_close(port_130X);
  1081. if ((status_154X == NO_ERRORS)) {
  1082. return -1;}
  1083. else {
  1084. ps_write_string("Error closing image file", (stderr));
  1085. { long ignoreXX;
  1086. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  1087. return -1;}}
  1088. L2345: {
  1089. status_155X = ps_close(port_130X);
  1090. if ((status_155X == NO_ERRORS)) {
  1091. return -1;}
  1092. else {
  1093. ps_write_string("Error closing image file", (stderr));
  1094. { long ignoreXX;
  1095. PS_WRITE_CHAR(10, (stderr), ignoreXX) }
  1096. return -1;}}
  1097. L2273: {
  1098. v_156X = arg0K0;
  1099. SsymbolsS = v_156X;
  1100. descriptor_157X = Simported_bindingsS;
  1101. if ((3 == (3 & descriptor_157X))) {
  1102. arg0K0 = (3 + (((long) ((((char *) (-3 + descriptor_157X))) + delta_135X))));
  1103. goto L2278;}
  1104. else {
  1105. arg0K0 = descriptor_157X;
  1106. goto L2278;}}
  1107. L2278: {
  1108. v_158X = arg0K0;
  1109. Simported_bindingsS = v_158X;
  1110. descriptor_159X = Sexported_bindingsS;
  1111. if ((3 == (3 & descriptor_159X))) {
  1112. arg0K0 = (3 + (((long) ((((char *) (-3 + descriptor_159X))) + delta_135X))));
  1113. goto L2283;}
  1114. else {
  1115. arg0K0 = descriptor_159X;
  1116. goto L2283;}}
  1117. L2283: {
  1118. v_160X = arg0K0;
  1119. Sexported_bindingsS = v_160X;
  1120. descriptor_161X = Sresumer_recordsS;
  1121. if ((3 == (3 & descriptor_161X))) {
  1122. arg0K0 = (3 + (((long) ((((char *) (-3 + descriptor_161X))) + delta_135X))));
  1123. goto L2288;}
  1124. else {
  1125. arg0K0 = descriptor_161X;
  1126. goto L2288;}}
  1127. L2288: {
  1128. v_162X = arg0K0;
  1129. Sresumer_recordsS = v_162X;
  1130. if (reverseP_134X) {s48_reverse_byte_orderB(new_begin_131X, new_hp_136X);
  1131. goto L2299;}
  1132. else {
  1133. goto L2299;}}
  1134. L2299: {
  1135. if ((0 == delta_135X)) {
  1136. return 0;}
  1137. else {relocate_symbol_tableB((SsymbolsS), delta_135X);relocate_binding_tableB((Simported_bindingsS), delta_135X);relocate_binding_tableB((Sexported_bindingsS), delta_135X);relocate_image(delta_135X, new_begin_131X, new_hp_136X);
  1138. return 0;}}
  1139. }void
  1140. s48_read_image_init(void)
  1141. {
  1142. SstatusS = NO_ERRORS;
  1143. SeofPS = 0;
  1144. SinitializingPS = 1;
  1145. }